keyboard_key_press not implemented in Linux?
Reporter: 9Morello | Status: closed | Last Modified: December 17, 2018, 01:50:36 amSHELLmain.cpp:(.text+0x7836): undefined reference to `enigma_user::keyboard_key_release(int)'
/home/ug/.enigma/.eobjs/Linux/Linux/Run/SHELLmain.o: In function `enigma::OBJ_obj_seamless::myevent_roomstart()':
SHELLmain.cpp:(.text+0xe7a5): undefined reference to `enigma_user::keyboard_key_press(int)'
collect2: error: ld returned 1 exit status
Makefile:117: recipe for target 'compile_game' failed
make[1]: *** [compile_game] Error 1
make[1]: Leaving directory '/home/ug/enigma-dev/ENIGMAsystem/SHELL'
Makefile:12: recipe for target 'Game' failed
make: *** [Game] Error 2
The wiki page says it may be unimplemented in some platforms.
It most likely is not. Poking around the source for xdotool
, it seems the operative function for this is XTestFakeKeyEvent
. You can probably implement that function yourself, in one of the X11 sources. The only trick is reusing our existing keycode map, or just translating the given character to an X11 keycode. I can't remember how to do that off the top of my head, or I'd probably just edit the file on GitHub right now.
Don't you mean keyboard_check_pressed()? Last I checked, all the standard keyboard functions were working on Linux.
keyboard_key_press
and keyboard_key_release
functions.
I do not know if this is Linux specific or not. I tested it in a Debian Jessie VM.
XTestFakeKeyEvent
would do on Xlib. I would like to know for sure if GM itself does that or not though.
Edit: All I could find was this reddit post https://www.reddit.com/r/gamemaker/comments/3fnj6s/something_like_keyboard_key_press_but_for_the/
keyboard_key_press() does work outside of the game :) (at least on windows) I used this before in some software, and I just tested it again.
I decided to try it myself with the following in a step event: keyboard_key_press-test.zip
keyboard_key_press(ord('1'));
keyboard_key_release(ord('1'));
Just run a game with that and then focus some textbox or your browser's address bar, and it does seem to work outside of the game. I get this same behavior for GM8, GMS1.4, and ENIGMA. However, ENIGMA was harder to close the game in Windows 10.
git pull
and you can enable the new XTEST extension to use the functions on Xlib/Linux.
I also updated the Wiki docs to reflect these changes:
https://enigma-dev.org/docs/Wiki/Keyboard_key_press
https://enigma-dev.org/docs/Wiki/Keyboard_key_release