<div dir="ltr"><div>Hi Ken,</div><div>there is work in progress wrt keyboard events.</div><div><br></div><div>Currently, we have to generate:</div><div>- an EventKeyDown at each keydown, and at each repeat</div><div>- an EventKeyStroke if ever the key is producing a character (or several EventKeyStroke if we produce several characters)<br></div><div>- an EventKeyUp when the key is released</div><div><br></div><div>Those events should have a platform independent key code in charCode field (event at: 3) <br></div><div>And a 32 bits unicode character in utf32 field (event at: 6) - that is also known as ucs4</div><div><br></div><div>Currently, the key code is almost universal, but not realy, this is WIP as I said above.</div><div>The code is not explicit.</div><div><br></div><div>It matches iso latin1 encoding for printable characters.</div><div>Good news, it's also the choice of X11 KeySym and windows virtual key codes!</div><br><div>When Ctrl+letter is pressed, it delivers an ASCII control character (code 1 to 26) instead of the keycode of the letter</div><div>But PharoVM wants the uppercase character code in both charCode and utf32 fields...<br></div><div><br></div><div>For some well known "symbolic" keys (tab escape backspace del insert pageUp pageDown arrows...) the encoding chosen by OSVM is not that of X11 KeySym.</div><div>It's rather that of curses or ncurses (If I remember, it's too long ago, and too late to start searching the net), see function translateCode<br></div><div><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/f70cf5f34041e0e197542651e90505a0b86325f6/platforms/unix/vm-display-X11/sqUnixX11.c#L4558">https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/f70cf5f34041e0e197542651e90505a0b86325f6/platforms/unix/vm-display-X11/sqUnixX11.c#L4558</a></div><div>We also deliver a EventKeyChar (keystroke) for these events with the same encoding for utf32 field.</div><div><br></div><div>You get the essentials... You will have to do something with dead keys too (^ ¨ ` etc...).</div><div>Having a single keystroke with precomposed unicode would be nice, but it can eventually be 2 keystroke with decomposed unicode...</div><div><br></div><div>I was suggesting to further use thre reserved1 field to pass the device dependent keycode to the image, if ever we want to experiment leaner VM (and fater image!). But this will necessitate passing ore state, like caps lock, num lock, etc...</div><div>See <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/456">https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/456</a></div><div><br></div><div>In other issues, I tried to reverse engineer all those layers.</div><div>Some are dusty, we do not change VM everyday...</div><div>And when we do it, we always add, never remove code, compatibility oblige!!!</div><div>I always tell that I pay removed lines twice than added, but only figurativley, otherwise my colleagues would immediately start committing many useless lines to pocket thrice ;)<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 27 déc. 2019 à 19:29, <<a href="mailto:ken.dickey@whidbey.com">ken.dickey@whidbey.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
OK. What I am gleaning is that I should map from<br>
<br>
/usr/include/linux/input-event-codes.h<br>
#define KEY_L                   38<br>
#define KEY_PAGEDOWN           109<br>
<br>
to:<br>
<br>
/usr/include/X11/keysymdef<br>
#define XK_L               0x004c  /* U+004C LATIN CAPITAL LETTER L */<br>
#define XK_l               0x006c  /* U+006C LATIN SMALL LETTER L */<br>
#define XK_Page_Down       0xff56<br>
<br>
UNICODE<br>
  L -> 0x004C<br>
  l -> 0x006C<br>
  page down -> 0x21DF<br>
<br>
given<br>
   recordKeyboardEvent(int keyCode, int pressCode, int modifiers, int <br>
ucs4)<br>
<br>
When I see Key: (38 = x26)  'l'<br>
-> recordKeyboardEvent( 0x006c, EventKeyChar, 0, 0x006c)<br>
<br>
when I see Key: (38 = x26) + Shift  'L'<br>
-> recordKeyboardEvent( 0x004c, EventKeyChar, ShiftKeyBit, 0x004c)<br>
<br>
When I see Key: (109=0x6d) KEY_PAGEDOWN -> XK_Page_Down = 0xFF56<br>
-> recordKeyboardEvent( 0xFF56, EventKeyUp, 0, 0x21DF)<br>
<br>
Is this close to right?<br>
<br>
Thanks much,<br>
-KenD<br>
</blockquote></div>