[Vm-dev] [Windows cog vm] [Keyboard events related] about keycode mapping

Guillermo Polito guillermopolito at gmail.com
Thu Jan 26 13:52:05 UTC 2012


Hi!

I was playing to add Function Ket support in the windows vm (yep, always
the same :P), and looking at the code, I saw this in the
recordKeyboardEvent:

evt = (sqKeyboardEvent*) sqNextEventPut();
  evt->type = EventTypeKeyboard;
  evt->timeStamp = msg->time;
*  evt->charCode = keymap[keyCode & 0xff];*
*
*
the problem with that line is that KeyDown and KeyUp events send
VirtualKeycodes as keycodes and the Char event sends a unicode char value.
 And, it makes collisions, since for example

$p char value is 112
and F1 virtual code value is 112 too :P

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646276(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646281(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

And so with other keys, having the same keycode in the image side with
different keys...

I'm trying a solution like this, providing in a Char event the keycode
without mapping to the image:

...
    case WM_CHAR:
    case WM_SYSCHAR:
      /* Note: VK_RETURN is recorded as virtual key ONLY */
      if(keyCode == 13) return 1;
    *  charCode = keyCode;*
      pressCode = EventKeyChar;
     break
...
 evt->timeStamp = msg->time;
*  evt->charCode = charCode? charCode : keymap[keyCode & 0xff];*
  evt->pressCode = pressCode;
...

changing only the bold lines, and It seems to work.

What do you think?
Guille
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120126/77c2fe86/attachment.htm


More information about the Vm-dev mailing list