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

Different Keyboard Layout Problem #20

Open
Tahinli opened this issue Jun 26, 2023 · 8 comments
Open

Different Keyboard Layout Problem #20

Tahinli opened this issue Jun 26, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@Tahinli
Copy link

Tahinli commented Jun 26, 2023

Problem is my keyboard is Turkish and buttons are not correctly working. If change my layout to English UK, it works without any problem. So this problem can be caused in any other keyboard layouts which are different then English.

2023-06-26_20-05
This layout should work properly but as i said because of keyboard layout, "equal" behave like minus and "dot" behave like "comma".

My idea about solution is. Keeping code in fixed layout even OS has different layout. Maybe we can use ASCII.

@iamkroot iamkroot added the enhancement New feature or request label Jun 26, 2023
@iamkroot
Copy link
Owner

Looks like asus-numberpad-driver uses X11 APIs to query the actual keys-
https://github.com/asus-linux-drivers/asus-numberpad-driver/blob/fc78b5c06ca161d8d316a6b07b13445cc81a5369/asus_touchpad.py#L365-L392

We would need to do something similar to get this to work.

For a quick and dirty solution, you could clone this repo and edit the source code yourself (replacing the KPDOT value with the correct one for your layout).

@Tahinli
Copy link
Author

Tahinli commented Jun 26, 2023

Looks like asus-numberpad-driver uses X11 APIs to query the actual keys- https://github.com/asus-linux-drivers/asus-numberpad-driver/blob/fc78b5c06ca161d8d316a6b07b13445cc81a5369/asus_touchpad.py#L365-L392

We would need to do something similar to get this to work.

For a quick and dirty solution, you could clone this repo and edit the source code yourself (replacing the KPDOT value with the correct one for your layout).

i fixed "equal" with KEY_KPEQUAL, trying to find right dot :D.

Btw we can solve this problem with downloading "xdotool" and using with system calls.

Command::new("xdotool")
    .args(&["keydown", &format!("{}", ascii_code)])
    .spawn()
    .expect("Failed to execute xdotool");

Command::new("xdotool")
    .args(&["keyup", &format!("{}", ascii_code)])
    .spawn()
    .expect("Failed to execute xdotool");

like this. But most probably we can find some better solution.

@iamkroot
Copy link
Owner

trying to find right dot

You could probably get this by adding a print(key) after https://github.com/asus-linux-drivers/asus-numberpad-driver/blob/fc78b5c06ca161d8d316a6b07b13445cc81a5369/asus_touchpad.py#L377 to log the final key codes that get used.

@Tahinli
Copy link
Author

Tahinli commented Jun 26, 2023

Okay "KEY_SLASH" is "dot". It makes sense when we compare Turkish and English keyboard. Also if there is someone who want to find right key,

Install evtest
sudo evtest
select right device
{
In mine there were 2 keyboard. If I select 20 which is physical keyboard, it just prints all keys but if I select 2 which is, , Translated set, it captures and show what i press.
Screenshot from 2023-06-26 22-09-25

}

then change in code, you can find buttons in https://docs.rs/input-event-codes/latest/input_event_codes/index.html

@Tahinli
Copy link
Author

Tahinli commented Jun 26, 2023

trying to find right dot

You could probably get this by adding a print(key) after https://github.com/asus-linux-drivers/asus-numberpad-driver/blob/fc78b5c06ca161d8d316a6b07b13445cc81a5369/asus_touchpad.py#L377 to log the final key codes that get used.

also this solution makes sense.

@ldrahnik
Copy link

ldrahnik commented Jun 26, 2023

@Tahinli xdotool looks like the wrapper above functions that I use in the code mentioned by @iamkroot - anyway remember still it is X11 lib dependency so does not support distros with Wayland

@Tahinli
Copy link
Author

Tahinli commented Jun 26, 2023

@Tahinli xdotool looks like wrapper above functions what I use in code mentioned by @iamkroot - so it might be cleaner solution use it - but I have no exp - anyway remember still it is X11 lib dependency so does not support distros with Wayland I guess

It can be as you said. So in this situation, just need to find universal solution. I think it can be ascii, we just need to simulate button press with ascii codes.

@kamack38
Copy link

kamack38 commented Apr 7, 2024

Just to add our recent findings at asus-numberpad-driver, I'd like to say that getting the correct keys is possible using libxkbcommon which has both Wayland and X11 bindings.

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

No branches or pull requests

4 participants