See each commit for messages.
This fixes bug: https://bugs.winehq.org/show_bug.cgi?id=56204
From: Daniel Hill daniel@gluo.nz
This make dvorak more consistent with X11/Wayland/Windows, qwertz and azerty layouts having the same physical scancode layout as a qwerty keyboard and only differing in the labels on the keycaps.
Signed-off-by: Daniel Hill daniel@gluo.nz --- dlls/winex11.drv/keyboard.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 5c7f6c37276..89bf7da550a 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -99,19 +99,6 @@ static const WORD main_key_scan_abnt_qwerty[MAIN_LEN] = 0x56, /* the 102nd key (actually to the right of l-shift) */ };
-static const WORD main_key_scan_dvorak[MAIN_LEN] = -{ - /* ` 1 2 3 4 5 6 7 8 9 0 [ ] */ - 0x29,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x1A,0x1B, - /* ' , . p y f g c r l / = */ - 0x28,0x33,0x34,0x19,0x15,0x21,0x22,0x2E,0x13,0x26,0x35,0x0D, - /* a o e u i d h t n s - \ */ - 0x1E,0x18,0x12,0x16,0x17,0x20,0x23,0x14,0x31,0x1F,0x0C,0x2B, - /* ; q j k x b m w v z */ - 0x27,0x10,0x24,0x25,0x2D,0x30,0x32,0x11,0x2F,0x2C, - 0x56 /* the 102nd key (actually to the right of l-shift) */ -}; - static const WORD main_key_scan_qwerty_jp106[MAIN_LEN] = { /* 1 2 3 4 5 6 7 8 9 0 - ^ \ (Yen) */ @@ -866,7 +853,8 @@ static const struct { } main_key_tab[]={ {0x0409, "United States keyboard layout", &main_key_US, &main_key_scan_qwerty, &main_key_vkey_qwerty}, {0x0409, "United States keyboard layout (phantom key version)", &main_key_US_phantom, &main_key_scan_qwerty, &main_key_vkey_qwerty}, - {0x0409, "United States keyboard layout (dvorak)", &main_key_US_dvorak, &main_key_scan_dvorak, &main_key_vkey_dvorak}, + /* Dvorak users tend to run QWERTY keyboards and rely on Windows/X11/Wayland to translate to the correct keysyms */ + {0x0409, "United States keyboard layout (dvorak)", &main_key_US_dvorak, &main_key_scan_qwerty, &main_key_vkey_dvorak}, {0x0409, "United States International keyboard layout", &main_key_US_intl, &main_key_scan_qwerty, &main_key_vkey_qwerty}, {0x0809, "British keyboard layout", &main_key_UK, &main_key_scan_qwerty, &main_key_vkey_qwerty}, {0x0407, "German keyboard layout", &main_key_DE, &main_key_scan_qwerty, &main_key_vkey_qwertz},
From: Daniel Hill daniel@gluo.nz
Dvorak detection would sometimes fallback to Phantom keys, because we only use seq as a tie breaker greater emphasis on locality is required for layouts using the same language.
A rewrite to use taxi cab distance for the score might be more accurate, especially if we introduce more alternative layouts.
Signed-off-by: Daniel Hill daniel@gluo.nz --- dlls/winex11.drv/keyboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 89bf7da550a..2e7a118c110 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1522,8 +1522,7 @@ X11DRV_KEYBOARD_DetectLayout( Display *display ) } TRACE("matches=%d, mismatches=%d, seq=%d, score=%d\n", match, mismatch, seq, score); - if ((score > max_score) || - ((score == max_score) && (seq > max_seq))) { + if (score + (int)seq > max_score + (int)max_seq) { /* best match so far */ kbd_layout = current; max_score = score;
From: Daniel Hill daniel@gluo.nz
Signed-off-by: Daniel Hill daniel@gluo.nz --- dlls/winex11.drv/keyboard.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 2e7a118c110..dde74303bad 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -226,6 +226,16 @@ static const char main_key_US_dvorak[MAIN_LEN][4] = ";:","qQ","jJ","kK","xX","bB","mM","wW","vV","zZ" };
+/*** United States keyboard layout (dvorak phantom key version) */ +static const char main_key_US_dvorak_phantom[MAIN_LEN][4] = +{ + "`~","1!","2@","3#","4$","5%","6^","7&","8*","9(","0)","[{","]}", + "'"",",<",".>","pP","yY","fF","gG","cC","rR","lL","/?","=+", + "aA","oO","eE","uU","iI","dD","hH","tT","nN","sS","-_","\|", + ";:","qQ","jJ","kK","xX","bB","mM","wW","vV","zZ", + "<>" +}; + /*** British keyboard layout */ static const char main_key_UK[MAIN_LEN][4] = { @@ -855,6 +865,7 @@ static const struct { {0x0409, "United States keyboard layout (phantom key version)", &main_key_US_phantom, &main_key_scan_qwerty, &main_key_vkey_qwerty}, /* Dvorak users tend to run QWERTY keyboards and rely on Windows/X11/Wayland to translate to the correct keysyms */ {0x0409, "United States keyboard layout (dvorak)", &main_key_US_dvorak, &main_key_scan_qwerty, &main_key_vkey_dvorak}, + {0x0409, "United States keyboard layout (dvorak with phantom key)", &main_key_US_dvorak_phantom, &main_key_scan_qwerty, &main_key_vkey_dvorak}, {0x0409, "United States International keyboard layout", &main_key_US_intl, &main_key_scan_qwerty, &main_key_vkey_qwerty}, {0x0809, "British keyboard layout", &main_key_UK, &main_key_scan_qwerty, &main_key_vkey_qwerty}, {0x0407, "German keyboard layout", &main_key_DE, &main_key_scan_qwerty, &main_key_vkey_qwertz},
Did a quick check with various layouts configured with `setxkbmap` and this didn't change the results for any of them except for the dvorak layout which was no better detected. 15165e916dd9719125add752de4f66bc855c9d16 looks good regardless of the scoring changes.
On Thu Jan 18 14:45:33 2024 +0000, Rémi Bernon wrote:
Did a quick check with various layouts configured with `setxkbmap` and this didn't change the results for any of them except for the dvorak layout which was now better detected. 15165e916dd9719125add752de4f66bc855c9d16 looks good regardless of the scoring changes.
I meant, it *did* fix the dvorak detection. Edited.