libuiohook
libuiohook copied to clipboard
Assignment of several Keys (Delete and Arrows) in uiohook.h
Hi there, At first thanks for creating an awesome library! I really appreaciate the work you put in there.
I'm using the input overlay OBS-Plugin by univrsal (https://github.com/univrsal/input-overlay) which is dependent on your library.
I detected some issues, that i cannot reference several keys, despite writing the correct scancodes defined in your uiohook.h It happens with the keys Delete und Arrow Left Right Up or Down. If found that it your code exactly those keys are defined twice or are either remapped:
// Begin Numeric Zone
#define VC_NUM_LOCK 0x0045
#define VC_KP_DIVIDE 0x0E35
#define VC_KP_MULTIPLY 0x0037
#define VC_KP_SUBTRACT 0x004A
#define VC_KP_EQUALS 0x0E0D
#define VC_KP_ADD 0x004E
#define VC_KP_ENTER 0x0E1C
#define VC_KP_SEPARATOR 0x0053
#define VC_KP_1 0x004F
#define VC_KP_2 0x0050
#define VC_KP_3 0x0051
#define VC_KP_4 0x004B
#define VC_KP_5 0x004C
#define VC_KP_6 0x004D
#define VC_KP_7 0x0047
#define VC_KP_8 0x0048
#define VC_KP_9 0x0049
#define VC_KP_0 0x0052
#define VC_KP_END 0xEE00 | VC_KP_1
#define VC_KP_DOWN 0xEE00 | VC_KP_2
#define VC_KP_PAGE_DOWN 0xEE00 | VC_KP_3
#define VC_KP_LEFT 0xEE00 | VC_KP_4
#define VC_KP_CLEAR 0xEE00 | VC_KP_5
#define VC_KP_RIGHT 0xEE00 | VC_KP_6
#define VC_KP_HOME 0xEE00 | VC_KP_7
#define VC_KP_UP 0xEE00 | VC_KP_8
#define VC_KP_PAGE_UP 0xEE00 | VC_KP_9
#define VC_KP_INSERT 0xEE00 | VC_KP_0
#define VC_KP_DELETE 0xEE00 | VC_KP_SEPARATOR
// End Numeric Zone
Maybe this causes those issues. I would really appreaciate if you could check for any solution on that.
This is most likely not an issue with libuiohook (anymore). I tested it and the codes in uiohook.h seemed to work fine, it's most likely the outdated version of uiohook that the plugin uses.
Edit: Although the right button definitely seems to be broken on linux (just compiled 1.2 and I get keycode 0x0 in the pressed event): https://github.com/kwhat/libuiohook/blob/1.2/src/x11/input_helper.c#L466 Is that intended @kwhat? VC_RIGHT is mapped to 0 in both xfree86_scancode_table and evdev_scancode_table, VC_LEFT is mapped to 0 and to 122. Also there's a bunch of other keys that don't seem to be mapped to anything. I don't really have a clue how that stuff works, but I think those buttons used to work.
I could solve the issue with your proposed solution of adding EE to all hex values of these scancodes. Thanks a lot!
Is that intended
@univrsal probably not... but I would have to look. I seem to remember that working for me but I think I am using evdev. I'll take a look locally when I get a second. This weeks going to be a disaster for me so i'll try to remember to check it next week. Ping me if you don't hear back from me.
No worries, take your time.
I also noticed that MOUSE_BUTTON_3 is right click and MOUSE_BUTTON_2 is the mouse wheel, so might want to test that as well. Maybe it's just my setup.
For the button mappings, I suspect XGetDeviceButtonMapping is needed here: https://github.com/kwhat/libuiohook/blob/1.2/src/x11/input_hook.c#L534
Hi, kwhat, I have tested libuiohook in linux deepin 20.2.4. MOUSE_BUTTON_2 is middle button and MOUSE_BUTTON_3 is right button, VC_KP_LEFT is VC_ALT_R, how to solve these problems?
The mouse button issues are probably going to be easier to solve than the keyboard issue. There is an X11 function that returns the button mappings that should be called here, but I don't remember what the name of the function was. Maybe XGetDeviceButtonMapping as suggested above?
Now that I look at it, this maybe simpler than I thought. MOUSE_BUTTON_2 is middle button and MOUSE_BUTTON_3 is right button is what it should be from X11, is that not what it matches up with on Windows / Mac?
For the keyboard, things are going to be a lot more difficult and unless I can duplicate it locally, it won't get solved.
Thanks kwhat, I have also tested libuiohook in windows10 and 11, MOUSE_BUTTON_2 is right button and MOUSE_BUTTON_3 is middle button, but it has not been tested in MacOS yet.
Let me know what OS X is and I'll make them the same across.
On Windows, Linux and MacOS, Qt keycode mapping is correct, you can refer to the source code:
- windows https://github.com/qt/qtbase/blob/5.6/src/plugins/platforms/windows/qwindowskeymapper.cpp
- xcb https://github.com/qt/qtbase/blob/5.6/src/plugins/platforms/xcb/qxcbkeyboard.cpp
- cocoa https://github.com/qt/qtbase/blob/5.6/src/plugins/platforms/cocoa/qcocoakeymapper.mm
I've added a fix for the mouse button mappings. Still not sure if this is a problem with the keyboard map. I suspect we will probably need XGetKeyboardMapping for something similar to what xmodmap produces with -pk and -pm.
The current key mapping stuff on X11 is really a mess and I think XGetKeyboardMapping is the way to go. It is going to change a lot of stuff with the way key codes work so I am going to put that part off until 1.3.
Thanks for putting all that effort into this issues. I just gave the 1.3 branch a try and I do get correct keycodes for the arrow keys. On linux I get 0xEExx for the numpad arrows with numlock off and 0xE0xx for the normal arrows. However on Windows it's the other way around. I've also had some issues with building on windows because it couldn't find Advapi32. I've made some changes that fix both of these issues on numpad_masks_fix and windows_advapi_fix, maybe you can take a look when you have time.
@univrsal 1.3 is still pretty alpha, there is a massive change sitting on my local that will change a lot of stuff in that branch bringing much better language support to X11 platforms. Lets get the numpad_masks_fix in before I start working on the windows side of the 1.3 updates.
Ok, you merged the other commit already, though. Was that intentional? They were both based on 1.3
Yeah I was able to rebase the other one off of 1.2 in the browser. It's going to be a long time before 1.3 is stable.
On Sun, Apr 17, 2022, 11:50 AM Alex @.***> wrote:
Ok, you merged the other commit already, though. Was that intentional? They were both based on 1.3
— Reply to this email directly, view it on GitHub https://github.com/kwhat/libuiohook/issues/96#issuecomment-1100931403, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFFCRCNMUFDCBW443PFN2DVFRMOHANCNFSM4WKSHNWA . You are receiving this because you were assigned.Message ID: @.***>