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

Incorrect key pressed when using unicode_char_down #4

Open
Pauan opened this issue Dec 15, 2021 · 5 comments
Open

Incorrect key pressed when using unicode_char_down #4

Pauan opened this issue Dec 15, 2021 · 5 comments

Comments

@Pauan
Copy link

Pauan commented Dec 15, 2021

When running the following code...

let mut ctx = Context::new().unwrap();
ctx.unicode_char_down('s').unwrap();
ctx.unicode_char_up('s').unwrap();

On my computer it presses the ; key, even though it's supposed to press the s key.

However the following code works fine:

let mut ctx = Context::new().unwrap();
ctx.ascii_char_down(b's').unwrap();
ctx.ascii_char_up(b's').unwrap();

I'm using Linux (X11).

@indianakernick
Copy link
Owner

indianakernick commented Dec 21, 2021

I'm commenting to say that I have seen this and I've been thinking about it. I'm really not sure and unfortunately it's going to be a while before I have the time to troubleshoot this properly. Out of curiosity, what do you get from this?

let mut ctx = Context::new().unwrap();
for c in b' '..=b'~' {
    ctx.ascii_char(c).unwrap();
    ctx.ascii_char(b' ').unwrap();
    ctx.unicode_char(c as char).unwrap();
    ctx.ascii_char(b'\n').unwrap();
}

@Pauan
Copy link
Author

Pauan commented Dec 21, 2021

This is what I get:


   ! !
   " Q
   # #
   $ $
   % %
   & &
   ' q
   ( (
   ) )
   * *
   + }
   , w
   - '
   . e
   / [
   0 0
   1 1
   2 2
   3 3
   4 4
   5 5
   6 6
   7 7
   8 8
   9 9
   : Z
   ; z
   < W
   = ]
   > E
   ? {
   @ @
   A A
   B N
   C I
   D H
   E D
   F Y
   G U
   H J
   I G
   J C
   K V
   L P
   M M
   N L
   O S
   P R
   Q X
   R O
   S :
   T K
   U F
   V >
   W <
   X B
   Y T
   Z ?
   [ -
   \ \
   ] =
   ^ ^
   _ "
   ` `
   a a
   b n
   c i
   d h
   e d
   f y
   g u
   h j
   i g
   j c
   k v
   l p
   m m
   n l
   o s
   p r
   q x
   r o
   s ;
   t k
   u f
   v .
   w ,
   x b
   y t
   z /
   { _
   | |
   } +
   ~ ~

P.S. I prefer to use char::from(c) for converting from a u8 -> char, but it makes no difference in this test.

@indianakernick
Copy link
Owner

indianakernick commented Dec 21, 2021

You wouldn’t happen to be using Dvorak by any chance? 😉

Keyboard layout probably should have been my first question. I will admit that I only tested this with Qwerty.

@Pauan
Copy link
Author

Pauan commented Dec 21, 2021

Yes I am a Dvorak Master Race™. So it seems that tfc isn't taking into account keyboard layout.

This is what I get when I use QWERTY:

   
   ! !
   " "
   # #
   $ $
   % %
   & &
   ' '
   ( (
   ) )
   * *
   + +
   , ,
   - -
   . .
   / /
   0 0
   1 1
   2 2
   3 3
   4 4
   5 5
   6 6
   7 7
   8 8
   9 9
   : :
   ; ;
   < <
   = =
   > >
   ? ?
   @ @
   A A
   B B
   C C
   D D
   E E
   F F
   G G
   H H
   I I
   J J
   K K
   L L
   M M
   N N
   O O
   P P
   Q Q
   R R
   S S
   T T
   U U
   V V
   W W
   X X
   Y Y
   Z Z
   [ [
   \ \
   ] ]
   ^ ^
   _ _
   ` `
   a a
   b b
   c c
   d d
   e e
   f f
   g g
   h h
   i i
   j j
   k k
   l l
   m m
   n n
   o o
   p p
   q q
   r r
   s s
   t t
   u u
   v v
   w w
   x x
   y y
   z z
   { {
   | |
   } }
   ~ ~

@indianakernick
Copy link
Owner

indianakernick commented Feb 5, 2022

Things are starting to settle down a bit so I finally had the chance to investigate this properly today. Although I wasn't able to reproduce the problem unfortunately.

  1. I fired up an Ubuntu 20.04.3 VM using X11.
  2. I ran the example using the default English (US) layout and found that the characters on the left always matched the characters on the right.
  3. I switched to English (Dvorak) and found that the ascii_char characters were jumbled up while the unicode_char characters were in ASCII order.

This is expected behaviour. unicode_char('s') should always type an s no matter what the keyboard layout is. ascii_char(b's') will press the key in the position of an s on a QWERTY keyboard. When using the QWERTY layout, this results in an s being typed. However, when using Dvorak, pressing the s key results in an o being typed. I found that ascii_char(b's') typed an o when using Dvorak.

Can you tell me more about your setup? I might need to use a different distro or use a different method for changing the layout.

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