Hi all,
This patch changes the behaviour of gemkeyname, so that it will return the actual key pressed including modifyers held. This only applies to linux. I don't know if and how it should be changed for windows/OSX. This means gemkeyname will return A when shift-a is pressed, and will give the keyname as a symbol only for the modifier-keys and things like insert/tab/etc. Also ctrl-letter now gets passed as a /x0something number. Basically it now behaves like [keyname] except for the number-pad.
The previous behaviour was to pass the keyname of every key pressed, including modifiers etc. gemkeyboard still gives the raw keycodes, so you can use that.
I needed it to make a typewriter in Gem which would otherwise need a key parser written in pd. I hope this will get applied to Gem asap.
regards Gerard
--- gem-0.90.0/src/Base/GemMan.cpp 2004-05-16 19:22:49.000000000 +0000 +++ gem-0.90.0-key/src/Base/GemMan.cpp 2004-09-26 13:34:44.000000000 +0000 @@ -172,7 +172,9 @@ XKeyEvent* kb = (XKeyEvent*)&event; XResizeRequestEvent *res = (XResizeRequestEvent*)&event; win = GemMan::getWindowInfo(); - + char keystring[2]; + KeySym keysym_return; + while (XCheckWindowEvent(win.dpy,win.win, ResizeRedirectMask | KeyPressMask | KeyReleaseMask | @@ -194,17 +196,37 @@ triggerMotionEvent(eb->x, eb->y); break; case KeyPress: - triggerKeyboardEvent(XKeysymToString(XKeycodeToKeysym(win.dpy, kb->keycode, 0)), kb->keycode, 1); - break; + if (XLookupString(kb,keystring,2,&keysym_return,NULL)==0) { + //modifier key:use keysym + triggerKeyboardEvent(XKeysymToString(keysym_return), kb->keycode, 1); + } + + if ( (keysym_return & 0xff00)== 0xff00 ) { + //non alphanumeric key: use keysym + triggerKeyboardEvent(XKeysymToString(keysym_return), kb->keycode, 1); + } else { + triggerKeyboardEvent(keystring, kb->keycode, 1); + } + break; case KeyRelease: - triggerKeyboardEvent(XKeysymToString(XKeycodeToKeysym(win.dpy, kb->keycode, 0)), kb->keycode, 0); - break; + if (XLookupString(kb,keystring,2,&keysym_return,NULL)==0) { + //modifier key:use keysym + triggerKeyboardEvent(XKeysymToString(keysym_return), kb->keycode, 0); + } + + if ( (keysym_return & 0xff00)== 0xff00 ) { + //non alphanumeric key: use keysym + triggerKeyboardEvent(XKeysymToString(keysym_return), kb->keycode, 0); + } else { + triggerKeyboardEvent(keystring, kb->keycode, 0); + } + break; case ResizeRequest: - triggerResizeEvent(res->width, res->height); - XResizeWindow(win.dpy, win.win, res->width, res->height); - break; + triggerResizeEvent(res->width, res->height); + XResizeWindow(win.dpy, win.win, res->width, res->height); + break; default: - break; + break; } } clock_delay(s_windowClock, s_windowDelTime);