{"action":"created","issue":{"url":"https://api.github.com/repos/stsp/dosemu2/issues/43","labels_url":"https://api.github.com/repos/stsp/dosemu2/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/stsp/dosemu2/issues/43/comments","events_url":"https://api.github.com/repos/stsp/dosemu2/issues/43/events","html_url":"https://github.com/stsp/dosemu2/issues/43","id":93816040,"number":43,"title":"Keyboard detection in X and SDL picking wrong keyboard","user":{"login":"andrewbird","id":220835,"avatar_url":"https://avatars.githubusercontent.com/u/220835?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewbird","html_url":"https://github.com/andrewbird","followers_url":"https://api.github.com/users/andrewbird/followers","following_url":"https://api.github.com/users/andrewbird/following{/other_user}","gists_url":"https://api.github.com/users/andrewbird/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewbird/subscriptions","organizations_url":"https://api.github.com/users/andrewbird/orgs","repos_url":"https://api.github.com/users/andrewbird/repos","events_url":"https://api.github.com/users/andrewbird/events{/privacy}","received_events_url":"https://api.github.com/users/andrewbird/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-07-08T15:16:32Z","updated_at":"2015-07-13T12:24:08Z","closed_at":null,"body":"I have a system using United Kingdom keyboard (GB keymap) with secondary US keymap installed, the dosemu.conf is default i.e. 'auto' but the detected keymap is US. Here is the salient portion of the boot log with -D+a\r\n\r\n~~~\r\nKBD: keyb_server_init()\r\nKBD: setup_default_keytable: setting up table 35\r\nsetup_default_keytable: failed\r\n10 keysyms per keycode not supported, set to 4\r\nAttempting to match against \"us\"\r\nmatches=46, mismatches=11, seq=45, score=45\r\nAttempting to match against \"us\"\r\nmatches=51, mismatches=6, seq=50, score=75\r\nAttempting to match against \"finnish\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"finnish\"\r\nmatches=35, mismatches=22, seq=34, score=-22\r\nAttempting to match against \"finnish-latin1\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"finnish-latin1\"\r\nmatches=34, mismatches=23, seq=33, score=-27\r\nAttempting to match against \"uk\"\r\nmatches=39, mismatches=18, seq=39, score=4\r\nAttempting to match against \"uk\"\r\nmatches=48, mismatches=9, seq=47, score=57\r\nAttempting to match against \"de\"\r\nmatches=31, mismatches=26, seq=28, score=-45\r\nAttempting to match against \"de\"\r\nmatches=33, mismatches=24, seq=30, score=-33\r\nAttempting to match against \"de-latin1\"\r\nmatches=30, mismatches=27, seq=27, score=-50\r\nAttempting to match against \"de-latin1\"\r\nmatches=33, mismatches=24, seq=30, score=-33\r\nAttempting to match against \"fr\"\r\nmatches=28, mismatches=29, seq=25, score=-62\r\nAttempting to match against \"fr\"\r\nmatches=33, mismatches=24, seq=28, score=-35\r\nAttempting to match against \"fr-latin1\"\r\nmatches=28, mismatches=29, seq=25, score=-62\r\nAttempting to match against \"fr-latin1\"\r\nmatches=32, mismatches=25, seq=27, score=-41\r\nAttempting to match against \"dk\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"dk\"\r\nmatches=35, mismatches=22, seq=34, score=-22\r\nAttempting to match against \"dk-latin1\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"dk-latin1\"\r\nmatches=34, mismatches=23, seq=33, score=-27\r\nAttempting to match against \"dvorak\"\r\nmatches=40, mismatches=17, seq=24, score=11\r\nAttempting to match against \"dvorak\"\r\nmatches=51, mismatches=6, seq=33, score=75\r\nAttempting to match against \"sg\"\r\nmatches=33, mismatches=24, seq=30, score=-34\r\nAttempting to match against \"sg\"\r\nmatches=33, mismatches=24, seq=29, score=-35\r\nAttempting to match against \"sg-latin1\"\r\nmatches=31, mismatches=26, seq=28, score=-44\r\nAttempting to match against \"sg-latin1\"\r\nmatches=32, mismatches=25, seq=28, score=-40\r\nAttempting to match against \"keyb-no\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"keyb-no\"\r\nmatches=34, mismatches=23, seq=33, score=-27\r\nAttempting to match against \"no-latin1\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"no-latin1\"\r\nmatches=34, mismatches=23, seq=33, score=-27\r\nAttempting to match against \"sf\"\r\nmatches=33, mismatches=24, seq=30, score=-34\r\nAttempting to match against \"sf\"\r\nmatches=33, mismatches=24, seq=29, score=-35\r\nAttempting to match against \"sf-latin1\"\r\nmatches=31, mismatches=26, seq=28, score=-44\r\nAttempting to match against \"sf-latin1\"\r\nmatches=31, mismatches=26, seq=28, score=-45\r\nAttempting to match against \"es\"\r\nmatches=31, mismatches=26, seq=30, score=-44\r\nAttempting to match against \"es\"\r\nmatches=36, mismatches=21, seq=35, score=-16\r\nAttempting to match against \"es-latin1\"\r\nmatches=31, mismatches=26, seq=30, score=-44\r\nAttempting to match against \"es-latin1\"\r\nmatches=33, mismatches=24, seq=32, score=-33\r\nAttempting to match against \"be\"\r\nmatches=31, mismatches=26, seq=26, score=-45\r\nAttempting to match against \"be\"\r\nmatches=33, mismatches=24, seq=27, score=-35\r\nAttempting to match against \"po\"\r\nmatches=33, mismatches=24, seq=31, score=-33\r\nAttempting to match against \"po\"\r\nmatches=36, mismatches=21, seq=34, score=-15\r\nAttempting to match against \"it\"\r\nmatches=34, mismatches=23, seq=32, score=-26\r\nAttempting to match against \"it\"\r\nmatches=35, mismatches=22, seq=33, score=-21\r\nAttempting to match against \"sw\"\r\nmatches=32, mismatches=25, seq=31, score=-38\r\nAttempting to match against \"sw\"\r\nmatches=34, mismatches=23, seq=33, score=-27\r\nAttempting to match against \"hu\"\r\nmatches=13, mismatches=44, seq=12, score=-152\r\nAttempting to match against \"hu\"\r\nmatches=31, mismatches=26, seq=28, score=-45\r\nAttempting to match against \"hu-cwi\"\r\nmatches=17, mismatches=40, seq=16, score=-128\r\nAttempting to match against \"hu-cwi\"\r\nmatches=31, mismatches=26, seq=28, score=-45\r\nAttempting to match against \"hu-latin2\"\r\nmatches=13, mismatches=44, seq=12, score=-152\r\nAttempting to match against \"hu-latin2\"\r\nmatches=31, mismatches=26, seq=28, score=-45\r\nAttempting to match against \"jp106\"\r\nmatches=39, mismatches=18, seq=38, score=3\r\nAttempting to match against \"jp106\"\r\nmatches=41, mismatches=16, seq=39, score=15\r\nAttempting to match against \"pl\"\r\nmatches=37, mismatches=20, seq=36, score=-9\r\nAttempting to match against \"pl\"\r\nmatches=51, mismatches=6, seq=50, score=75\r\nAttempting to match against \"hr-cp852\"\r\nmatches=19, mismatches=38, seq=17, score=-116\r\nAttempting to match against \"hr-cp852\"\r\nmatches=34, mismatches=23, seq=31, score=-27\r\nAttempting to match against \"hr-latin2\"\r\nmatches=19, mismatches=38, seq=17, score=-116\r\nAttempting to match against \"hr-latin2\"\r\nmatches=34, mismatches=23, seq=31, score=-27\r\nAttempting to match against \"cz-qwerty\"\r\nmatches=13, mismatches=44, seq=12, score=-153\r\nAttempting to match against \"cz-qwerty\"\r\nmatches=31, mismatches=26, seq=29, score=-46\r\nAttempting to match against \"cz-qwertz\"\r\nmatches=13, mismatches=44, seq=11, score=-153\r\nAttempting to match against \"cz-qwertz\"\r\nmatches=31, mismatches=26, seq=27, score=-46\r\nAttempting to match against \"ru\"\r\nmatches=13, mismatches=44, seq=13, score=-153\r\nAttempting to match against \"ru\"\r\nmatches=15, mismatches=42, seq=15, score=-141\r\nAttempting to match against \"tr\"\r\nmatches=30, mismatches=27, seq=30, score=-51\r\nAttempting to match against \"tr\"\r\nmatches=31, mismatches=26, seq=31, score=-45\r\nAttempting to match against \"keyb-user\"\r\nmatches=46, mismatches=11, seq=45, score=45\r\nAttempting to match against \"keyb-user\"\r\nmatches=51, mismatches=6, seq=50, score=75\r\nUsing closest match (us) for scan/virtual codes mapping.\r\nCONF: detected layout is \"us\"\r\nCONF: detected alternate layout: us\r\nrules->trans_rules.rule_arr[j].rule_map:\r\n~~~\r\n\r\nI'm not sure how the detection works exactly, but because of the line\r\n~~~\r\n10 keysyms per keycode not supported, set to 4\r\n~~~\r\nI tried increasing the array lengths to 10 and altering the if accordingly and it almost worked. I got 'BE' primary with 'US' secondary, but obviously it's not correct.\r\n\r\nIs there any way of reading the keyboard type from SDL or X instead and does the keymap have to be set at Dosemu startup i.e. could it be switchable from the desktop like most X applications?\r\n "},"comment":{"url":"https://api.github.com/repos/stsp/dosemu2/issues/comments/120908506","html_url":"https://github.com/stsp/dosemu2/issues/43#issuecomment-120908506","issue_url":"https://api.github.com/repos/stsp/dosemu2/issues/43","id":120908506,"user":{"login":"andrewbird","id":220835,"avatar_url":"https://avatars.githubusercontent.com/u/220835?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewbird","html_url":"https://github.com/andrewbird","followers_url":"https://api.github.com/users/andrewbird/followers","following_url":"https://api.github.com/users/andrewbird/following{/other_user}","gists_url":"https://api.github.com/users/andrewbird/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewbird/subscriptions","organizations_url":"https://api.github.com/users/andrewbird/orgs","repos_url":"https://api.github.com/users/andrewbird/repos","events_url":"https://api.github.com/users/andrewbird/events{/privacy}","received_events_url":"https://api.github.com/users/andrewbird/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T12:24:08Z","updated_at":"2015-07-13T12:24:08Z","body":"Hi,\r\nHere's a link about the differences with XKB and pure X11, but it has a nice table for what's returned in pure X11.\r\nhttp://pascal.tsu.ru/en/xkb/internals.html#types\r\nI think what we have for comparing just the first four values is OK as long as we don't try to evaluate anything other than layout1 unshifted/shifted and layout2 unshifted/shifted. \r\n\r\nMy problem seems to be that the ALT keymap seems to be compared during detection with the alternative layout. I think there's some confusion there, for instance testing with the keycode 11\r\n~~~\r\n key: 3 score -1 for keycode 11, 32 22 40, got 32 22 32 40\r\n~~~\r\nDosemu has \r\nunshifted map = 32\r\nshifted map = 22\r\nalt map = 40\r\n\r\nX returns\r\nlayout 1 unshifted map 32\r\nlayout 1 shifted map 22\r\nlayout 2 unshifted map 32\r\nlayout 2 shifted map 40\r\n\r\nI suggest that Dosemu alt_map != layout2, but the detection logic compares lkey[2] to ckey[2] i.e. Dosemu alt modified layout1 key to X unshifted layout2 key\r\n\r\nNow for a little test with 'xev -event keyboard'\r\n\r\nWith layout 1 selected in X and keycode 11\r\n~~~\r\nunshifted\r\nstate 0x0, keycode 11 (keysym 0x32, 2), same_screen YES\r\n\r\nshifted\r\nstate 0x1, keycode 11 (keysym 0x22, quotedbl), same_screen YES\r\n\r\nalt\r\nstate 0x8, keycode 11 (keysym 0x32, 2), same_screen YES,\r\n\r\nctrl\r\nstate 0x4, keycode 11 (keysym 0x32, 2), same_screen YES,\r\n\r\naltgr\r\nstate 0x80, keycode 11 (keysym 0xb2, twosuperior), same_screen YES,\r\n~~~\r\n\r\nSo I think the UK alt map is wrong, at least in X, but I don't think it should compared against the alternate layout anyway. "}}