On 2 November 2017 at 15:20, Programmingkid <programmingk...@gmail.com> wrote: >> On Nov 2, 2017, at 5:10 AM, Peter Maydell <peter.mayd...@linaro.org> wrote: >> Testing this I have found that it makes the grab key be >> "ctrl+alt+ the key labelled 'g'", even if in the >> OSX host keyboard mapping that key doesn't produce the >> letter 'g'. This is in contrast to for instance the menu >> accelerators which honour the host keyboard layout, and >> it's also not what the GTK UI does. So I think we need >> to fix that. > > I just realized that the cocoa interface does not consider the keyboard > layout. Switching from QWERTY to DVORK I still see the same keys outputting > the same characters in OpenBIOS. This is a separate patch but sometime to > take note.
There's a difference between "what do we send to the guest" (where we're obliged to send raw keycodes, but the user can configure their guest with an appropriate keymap if they like) and "what do we do as part of the QEMU UI" (where there is no ability for the user to set a keymap and we should honour the host UI keymap settings). If you look at the behaviour of other VM implementations like Parallels I think you'll find it's the same. I think the way we need to implement this is that instead of doing "switch (keycode)" and looking for Q_KEY_CODE_1... we should do something like if (ctrl and alt pressed) { NSString *keychar = [theEvent charactersIgnoringModifiers]; if ([keychar length] == 1) { switch ([keychar characterAtIndex:0]) { case '1' .. '9': console_select(...); return; case 'g': /* handle ungrab */ return; } } as suggested by: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html thanks -- PMM