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

In Linux implementation some keys have the same codes as Numpad keys #52

Open
positiveway opened this issue Jan 13, 2022 · 4 comments
Open

Comments

@positiveway
Copy link
Contributor

positiveway commented Jan 13, 2022

In the scan_code and other functions

0x47 => Some(HomeKey),
0x4b => Some(LeftKey),
0x4d => Some(RightKey),
0x48 => Some(UpKey),
0x50 => Some(DownKey),
0x52 => Some(InsertKey),
0x53 => Some(DeleteKey),
0x52 => Some(Numpad0Key),
0x50 => Some(Numpad2Key),
0x4b => Some(Numpad4Key),
0x4d => Some(Numpad6Key),
0x47 => Some(Numpad7Key),
0x48 => Some(Numpad8Key),

Gonna investigate further and create a PR

@positiveway
Copy link
Contributor Author

positiveway commented Jan 13, 2022

This issue is a more detailed duplicate of #37 and #19 . I will leave it open for discussion. Because not only some keys are repeated but some crucial ones like Super are missing.

Seems like the author of #37 added some bindings in his fork. Gonna look into that.

@positiveway
Copy link
Contributor Author

The solution was easy:
uinput is used for simulating events, it internally uses uinput-sys.
Here is the list of proper codes from that library

Replacing codes with proper ones indeed solves the issue.
Like 108 for DownKey instead of 80 (0x50)

@obv-mikhail will you be able to copy proper codes from that list? And maybe add some new useful ones. They are all listed in an easy-to-read format.

@positiveway
Copy link
Contributor Author

positiveway commented Jan 14, 2022

@obv-mikhail does it make sense to continue using hexadecimal notation?
It would be simpler and easier to read/maintain if we replace all codes with decimal values from uinput-sys list.
Because that's where these codes come from anyways and they are organized neatly.

I think it would be more reliable not to copy specific values but to have a mapping like this in
inputs.rs

extern crate uinput_sys;
use uinput_sys::*;
...
pub fn key_to_scan_code(key: &KeybdKey) -> i32 {
    match key {
        LeftKey => KEY_LEFT,
        DownKey => KEY_DOWN,
        ...
    }
}

in Cargo.toml

[dependencies]
uinput = { version = "0.1.3", default-features = false }
uinput-sys = "*"

to always match uinput-sys version with what's used in uinput

@obv-mikhail
Copy link
Owner

@positiveway yes, the approach of using the consts from uinput-sys by name sounds good to me.

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

No branches or pull requests

2 participants