How do I send simulated keystroke to steam games on Windows 10? - c

I want to create a simple game controller/bot inside of a steam game similar to the one done here on gtaV to try out machine learning techniques. I've tried everything from pyautogui package, pyinput, and this go to method that was also used in the previous link and all of them work on the desktop apps and browsers but none of them work once I start the game.
I've also tried making and compiling this C code that I'm guessing the python is wrapping around but it's the same issue where it works until I enter the game screen.
I'm guessing the issue is something with the method of input as in the previous case, it had to be changed from ScanCodes instead of VKs but I have no idea on how to even figure out which input method must be used.
My current setup is python3 on windows10 home edition.

Related

What do you even call the ability of code to auto update and how do you do it?

I'm having a hard time understanding how to even search online for this behavior. I've seen it several times before and know it's something that can be done but don't know if this is a language level feature or what. What do you call the ability for code that you edited to automatically be applied to an executed instance of said code being run.
To use a common version of this that I see: you'll have a game that you're developing open and you'll be running that game in your engine and then edit a value (let's say one representing walking speed) and then simply save that file (maybe compile it? maybe just that line? I don't know how it's done) and then, suddenly, that behavior is updated in the live instance of the program just like that.
It seems so much better then having to recompile a file, or a whole project, and then run it to be able to test it. How do I do this kind of rapid iteration and what is it called? NOTE: the first time I saw this was with Clojure in emacs. Does that have something to do with it?
You may want to read about the Clojure REPL and also here.
"Hot Reloading" is related and is commonly used in UI development in the browser with ClojureScript:
Shadow CLJS
Figwheel Main

Starting a graphical application using sfml on Raspberry Pi boot

I would like to make a Graphical interface for a home-made program using SFML on Raspberry Pi2. I am using Raspbian. I recompiled the graphical lib
It works fine unsing startx first, then using my application, which wors perfectly fine.
But I can't figure if it is possible or how to launch my application directly after boot without launching startx (just to optimise the cpu of the Raspberry).
Starting my program direcly after boot, I get the following error:
Failed to open X11 display: make sure the DISPLAY environnement variable is set correctly.
Aborted.
I already tested the classic export DISPLAY=:0.0 but without sucess.
I interested myself in x and xinit, but I am not sure that would even do it.
Where should I start looking? I don't need a complete solution, even a hint or an idea would be nice!
I checked to see if it was possible to open a graphical app without the X desktop environment and as that answer states, with Firefox at least, you need the X server which SFML also probably needs in order to create a window.
The answer states:
Basically something like:
$ X
Then you just start Firefox in this X server:
$ DISPLAY=:0 firefox
You can switch from the X server and the framebuffer by using
CTRL+ALT+F1 and CTRL+ALT+F7.
You could try that and see if it helps.
Also, still searching, I found a forum post on the sfml website about what you're trying to accomplish stating somewhere:
SFML requires OpenGL, so as far as I know you need at least X running,
but you probably don't need gnome, KDE or a similar Desktop
Environment on top.
The forum guy asking for help seems to have managed to get X11 and a SFML basic render window to work on Ubuntu server after someone posted a link to xinitrc. I guess, that's the route to go from here.

Is it a good idea to use a Screensaver on a raspberry pi as digital signage?

I asked this question in the Raspberry PI section, so please forgive me for posting this here again. Its just there doesn't seem to be as active as this section of the forum. So, onto my question...
I have an idea and I'm working on it right now. I just wanted to see what the community's thought was on using a screensaver as digital signage. Every tutorial I've read shows someone using chromium in kiosk mode, and while that's fine and works well for some uses, it doesn't work for what I need. I have successfully completed a chromium kiosk, and it was cool. But the signage that I need to create now, has to work without internet. I've thought about installing LAMP locally on the PI, and still using chromium. I still may have to if this idea doesn't pan out. All I need from the signage is a Title Message in the top center, and a message body underneath it, with roughly 300-400 character limit. My idea is to write a screensaver module, in C, that will work with a screensaver such as xscreensaver. The module would need to be able to load messages from a directory on the pi. Then for my clients to update their signage text, I would write a simple client that sent commands as well as the text via SSH to the pi. I want to know what other people think about this. Is it a good idea? Bad idea? Should I "waste" my time doing something like this?
Thanks in advance.
I am already using a rPi as digital signage, just over a year. I am using two different setups:
version 1 uses Raspian loading xdesktop and qiv image viewer to cycle images stored on the Pi itself, synchronized with a remote server. The problem I found was power and SD stability, when the power fails, which it will do no matter what, just when... The Sd card can become corrupt due to all the writing that Raspian does all the time. Certainly does not really need to write to SD.
version 2 uses a RO-filesystem and a command line image tool. Uses the same process to show images from local, and sync with server. But power fail causes no ill effects.
I am not using screensaver to display images, that seemed redundant to me, and unnecessary to wait for the SS to start just to display the images.
Some of the images are created using imagemagik, which is nicely dynamic where needed.

OS X Intercept Keyboard Events to Password Forms Elements

I am currently creating a c program that counts all of the keys I press in a day and sorts the key types by amount, so I can tell which ones I press most often. It was more of a side project than anything else but I have become annoyed with the fact that my program doesn't seem to be able to intercept any input to password fields. I suppose this is a good thing, but I have been spending hours looking at documentation and trying to figure how to do this. I am not trying to create any sort of malicious software. Is there a way around this? My program is running as root. I am using the ApplicationServices framework and CGEventRef and the CGEventTapCreate funcion. Should I be using a different framework or struct? Also, is there a difference between kCGHIDEventTap, kCGSessionEventTap, and kCGAnnotatedSessionEventTap? I have tried using each of them and it does not seem to make a difference in my program.
I am running this on OS X 10.9
UPDATE
Apparently I cannot capture keystrokes going to terminal either, which is where I spend most of my time on my laptop. This is a problem.
What you want is fairly complicated and requires a kernel extension. The interprocess communication is also not trivial. Take a look at logKext, specifically logKext.cpp. That project actually logs the keystrokes to an encrypted file. You should be able to pull everything you need from it.

Using SDL_INIT_JOYSTICK without SDL_INIT_VIDEO

I've lost some time trying to get joystick support for my an application using SDL, mostly because the initialization steps where these:
SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_VIDEO);
SDL_JoystickEventState(SDL_ENABLE);
It didn't work if I just initialized the joystick, it needed to be done together with the video. I want this to be very minimalistic, so it would be nice to know if there's a way to initialize just the joystick. If not, can someone tell me if there's any disadvantage of initializing the video and never using it?
I'm on Ubuntu here, but I expect this to run in various platforms. Does this behavior vary in different environments?
Thanks :)
I had similiar issues when developing a small CLI app that took joypad input. Basically, it didn't work without SDL_INIT_VIDEO because SDLs event system stems from the video driver, at least on Linux (X11).
It is perfectly fine to init video without ever creating a window (it works at least). I've tested this approach on both Win32 and Linux, so it does seem to work fine multiplatform as well.
I have a similar issue, I solved it by not using the event loop. Instead I manually update the joysticks and then use the SDL functions to check the joysticks.
SDL_Init(SDL_INIT_JOYSTICK);
SDL_JoystickEventState(SDL_DISABLE);
joystick = SDL_JoystickOpen(0);
SDL_Joystick* joystick;
while(true)
{
SDL_JoystickUpdate();
SDL_JoystickGetAxis(joystick, 0);
}

Resources