mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-25 02:10:53 +00:00
Fixed: #920 NeL - X11 Modifier Keys (Patch provided by rti)
This commit is contained in:
parent
39f2624a69
commit
b6138d5ec8
3 changed files with 100 additions and 65 deletions
|
@ -80,6 +80,7 @@ const CClassId EventIME (0x261f1ede, 0x1b0a6c3a);
|
|||
|
||||
enum TKey
|
||||
{
|
||||
KeyNOKEY =0x00,
|
||||
Key0 ='0',
|
||||
Key1 ='1',
|
||||
Key2 ='2',
|
||||
|
|
|
@ -503,6 +503,14 @@
|
|||
RelativePath="stdopengl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unix_event_emitter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unix_event_emitter.h"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
|
|
@ -52,18 +52,35 @@ void CUnixEventEmitter::submitEvents(CEventServer & server, bool allWindows)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef AltMask
|
||||
# ifdef NL_OS_MAC
|
||||
# define AltMask (8192)
|
||||
# else
|
||||
# define AltMask (Mod1Mask)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
TMouseButton getMouseButton (uint32 state)
|
||||
{
|
||||
TMouseButton button=noButton;
|
||||
if (state&ControlMask) (int&)button|=ctrlButton;
|
||||
if (state&Button1Mask) (int&)button|=leftButton;
|
||||
if (state&Button3Mask) (int&)button|=rightButton;
|
||||
if (state&Button2Mask) (int&)button|=middleButton;
|
||||
if (state&ShiftMask) (int&)button|=shiftButton;
|
||||
// TODO manage ALT key
|
||||
// if (GetAsyncKeyState(VK_MENU)&(1<<15))
|
||||
// (int&)button|=altButton;
|
||||
return button;
|
||||
uint32 button=noButton;
|
||||
if (state&Button1Mask) button|=leftButton;
|
||||
if (state&Button2Mask) button|=middleButton;
|
||||
if (state&Button3Mask) button|=rightButton;
|
||||
if (state&ControlMask) button|=ctrlButton;
|
||||
if (state&ShiftMask) button|=shiftButton;
|
||||
if (state&AltMask) button|=altButton;
|
||||
|
||||
return (TMouseButton)button;
|
||||
}
|
||||
|
||||
TKeyButton getKeyButton (uint32 state)
|
||||
{
|
||||
uint32 button=noKeyButton;
|
||||
if (state&ControlMask) button|=ctrlKeyButton;
|
||||
if (state&ShiftMask) button|=shiftKeyButton;
|
||||
if (state&AltMask) button|=altKeyButton;
|
||||
|
||||
return (TKeyButton)button;
|
||||
}
|
||||
|
||||
TKey getKey (KeySym keysym)
|
||||
|
@ -122,11 +139,16 @@ TKey getKey (KeySym keysym)
|
|||
case XK_Shift_R: return KeySHIFT;
|
||||
case XK_Control_L: return KeyCONTROL;
|
||||
case XK_Control_R: return KeyCONTROL;
|
||||
case XK_Super_L: return KeyLWIN;
|
||||
case XK_Super_R: return KeyRWIN;
|
||||
/// case XK_Caps_Lock: return Key;
|
||||
/// case XK_Meta_L: return Key;
|
||||
/// case XK_Meta_R: return Key;
|
||||
/// case XK_Alt_L: return Key;
|
||||
/// case XK_Alt_R: return Key;
|
||||
case XK_Mode_switch: return KeyMENU;
|
||||
case XK_ISO_Level3_Shift: return KeyMENU;
|
||||
case XK_Menu: return KeyAPPS;
|
||||
case XK_Alt_L: return KeyMENU;
|
||||
case XK_Alt_R: return KeyMENU;
|
||||
case XK_space: return KeySPACE;
|
||||
// case XK_comma: return Key;
|
||||
// case XK_minus: return Key;
|
||||
|
@ -199,9 +221,9 @@ TKey getKey (KeySym keysym)
|
|||
case XK_y: return KeyY;
|
||||
case XK_Z:
|
||||
case XK_z: return KeyZ;
|
||||
default: nldebug ("0x%x %d '%c'", keysym, keysym, keysym);
|
||||
default: //nldebug ("0x%x %d '%c'", keysym, keysym, keysym);
|
||||
}
|
||||
return KeyNUMLOCK;
|
||||
return KeyNOKEY;
|
||||
}
|
||||
|
||||
|
||||
|
@ -282,9 +304,11 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
|||
int c;
|
||||
c = XLookupString(&event.xkey, Text, 1024-1, &k, NULL);
|
||||
|
||||
TKey key = getKey (k);
|
||||
TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
|
||||
if(key == KeyNOKEY)
|
||||
key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1));
|
||||
// TODO manage the bool (first time pressed)
|
||||
server.postEvent (new CEventKeyDown (key, noKeyButton, true, this));
|
||||
server.postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), true, this));
|
||||
|
||||
Text[c] = '\0';
|
||||
if(c>0)
|
||||
|
@ -303,9 +327,11 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
|||
int c;
|
||||
c = XLookupString(&event.xkey, Text, 1024-1, &k, NULL);
|
||||
|
||||
TKey key = getKey (k);
|
||||
TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
|
||||
if(key == KeyNOKEY)
|
||||
key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1));
|
||||
// TODO manage the bool (first time pressed)
|
||||
server.postEvent (new CEventKeyUp (key, noKeyButton, this));
|
||||
server.postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
|
||||
break;
|
||||
}
|
||||
Case(FocusIn)
|
||||
|
|
Loading…
Reference in a new issue