Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment of several Keys (Delete and Arrows) in uiohook.h #96

Open
ladyViolet opened this issue Jan 20, 2021 · 18 comments
Open

Assignment of several Keys (Delete and Arrows) in uiohook.h #96

ladyViolet opened this issue Jan 20, 2021 · 18 comments
Assignees
Milestone

Comments

@ladyViolet
Copy link

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.

@ladyViolet ladyViolet changed the title Assignment of Assignment of several Keys (Delete and Arrows) in uiohook.h Jan 20, 2021
@univrsal
Copy link
Contributor

univrsal commented Jan 20, 2021

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.

@ladyViolet
Copy link
Author

I could solve the issue with your proposed solution of adding EE to all hex values of these scancodes. Thanks a lot!

@kwhat
Copy link
Owner

kwhat commented Jan 21, 2021

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.

@kwhat kwhat reopened this Jan 21, 2021
@kwhat kwhat self-assigned this Jan 21, 2021
@univrsal
Copy link
Contributor

No worries, take your time.

@univrsal
Copy link
Contributor

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.

@kwhat
Copy link
Owner

kwhat commented Feb 3, 2021

For the button mappings, I suspect XGetDeviceButtonMapping is needed here: https://github.com/kwhat/libuiohook/blob/1.2/src/x11/input_hook.c#L534

@ysx1993
Copy link

ysx1993 commented Oct 12, 2021

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?

@kwhat
Copy link
Owner

kwhat commented Oct 13, 2021

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.

@ysx1993
Copy link

ysx1993 commented Oct 13, 2021

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.

@kwhat
Copy link
Owner

kwhat commented Oct 13, 2021

Let me know what OS X is and I'll make them the same across.

@ysx1993
Copy link

ysx1993 commented Oct 13, 2021

@kwhat kwhat added this to the 1.2.2 milestone Mar 9, 2022
@kwhat
Copy link
Owner

kwhat commented Mar 9, 2022

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.

@kwhat
Copy link
Owner

kwhat commented Mar 11, 2022

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.

@kwhat kwhat modified the milestones: 1.2.2, 1.3 Mar 11, 2022
@kwhat kwhat modified the milestones: 1.2.2, 1.3 Mar 11, 2022
@kwhat kwhat added the bug label Mar 11, 2022
@univrsal
Copy link
Contributor

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.

@kwhat
Copy link
Owner

kwhat commented Apr 17, 2022

@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.

@univrsal
Copy link
Contributor

Ok, you merged the other commit already, though. Was that intentional? They were both based on 1.3

@kwhat
Copy link
Owner

kwhat commented Apr 17, 2022 via email

@kwhat
Copy link
Owner

kwhat commented Apr 20, 2024

I still have a few more things to merge, but 1.3 should be fairly stable at this point. As far as I can tell, this issue was resolved in that branch. If someone can confirm, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants