mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Fixed: #920 NeL - X11 Modifier Keys (Patch provided by rti)
This commit is contained in:
parent
61a8c90b04
commit
abe0f8d9a3
3 changed files with 100 additions and 65 deletions
|
@ -80,42 +80,43 @@ const CClassId EventIME (0x261f1ede, 0x1b0a6c3a);
|
||||||
|
|
||||||
enum TKey
|
enum TKey
|
||||||
{
|
{
|
||||||
Key0 ='0',
|
KeyNOKEY =0x00,
|
||||||
Key1 ='1',
|
Key0 ='0',
|
||||||
Key2 ='2',
|
Key1 ='1',
|
||||||
Key3 ='3',
|
Key2 ='2',
|
||||||
Key4 ='4',
|
Key3 ='3',
|
||||||
Key5 ='5',
|
Key4 ='4',
|
||||||
Key6 ='6',
|
Key5 ='5',
|
||||||
Key7 ='7',
|
Key6 ='6',
|
||||||
Key8 ='8',
|
Key7 ='7',
|
||||||
Key9 ='9',
|
Key8 ='8',
|
||||||
KeyA ='A',
|
Key9 ='9',
|
||||||
KeyB ='B',
|
KeyA ='A',
|
||||||
KeyC ='C',
|
KeyB ='B',
|
||||||
KeyD ='D',
|
KeyC ='C',
|
||||||
KeyE ='E',
|
KeyD ='D',
|
||||||
KeyF ='F',
|
KeyE ='E',
|
||||||
KeyG ='G',
|
KeyF ='F',
|
||||||
KeyH ='H',
|
KeyG ='G',
|
||||||
KeyI ='I',
|
KeyH ='H',
|
||||||
KeyJ ='J',
|
KeyI ='I',
|
||||||
KeyK ='K',
|
KeyJ ='J',
|
||||||
KeyL ='L',
|
KeyK ='K',
|
||||||
KeyM ='M',
|
KeyL ='L',
|
||||||
KeyN ='N',
|
KeyM ='M',
|
||||||
KeyO ='O',
|
KeyN ='N',
|
||||||
KeyP ='P',
|
KeyO ='O',
|
||||||
KeyQ ='Q',
|
KeyP ='P',
|
||||||
KeyR ='R',
|
KeyQ ='Q',
|
||||||
KeyS ='S',
|
KeyR ='R',
|
||||||
KeyT ='T',
|
KeyS ='S',
|
||||||
KeyU ='U',
|
KeyT ='T',
|
||||||
KeyV ='V',
|
KeyU ='U',
|
||||||
KeyW ='W',
|
KeyV ='V',
|
||||||
KeyX ='X',
|
KeyW ='W',
|
||||||
KeyY ='Y',
|
KeyX ='X',
|
||||||
KeyZ ='Z',
|
KeyY ='Y',
|
||||||
|
KeyZ ='Z',
|
||||||
KeyLBUTTON =0x01,
|
KeyLBUTTON =0x01,
|
||||||
KeyRBUTTON =0x02,
|
KeyRBUTTON =0x02,
|
||||||
KeyCANCEL =0x03,
|
KeyCANCEL =0x03,
|
||||||
|
@ -209,18 +210,18 @@ enum TKey
|
||||||
KeyLMENU =0xA4,
|
KeyLMENU =0xA4,
|
||||||
KeyRMENU =0xA5,
|
KeyRMENU =0xA5,
|
||||||
KeySEMICOLON =0xBA,
|
KeySEMICOLON =0xBA,
|
||||||
KeyEQUALS =0xBB,
|
KeyEQUALS =0xBB,
|
||||||
KeyCOMMA =0xBC,
|
KeyCOMMA =0xBC,
|
||||||
KeyDASH =0xBD,
|
KeyDASH =0xBD,
|
||||||
KeyPERIOD =0xBE,
|
KeyPERIOD =0xBE,
|
||||||
KeySLASH =0xBF,
|
KeySLASH =0xBF,
|
||||||
KeyTILDE =0xC0,
|
KeyTILDE =0xC0,
|
||||||
KeyLBRACKET =0xDB,
|
KeyLBRACKET =0xDB,
|
||||||
KeyBACKSLASH =0xDC,
|
KeyBACKSLASH =0xDC,
|
||||||
KeyRBRACKET =0xDD,
|
KeyRBRACKET =0xDD,
|
||||||
KeyAPOSTROPHE =0xDE,
|
KeyAPOSTROPHE =0xDE,
|
||||||
KeyPARAGRAPH =0xDF,
|
KeyPARAGRAPH =0xDF,
|
||||||
KeyOEM_102 =0xE2,
|
KeyOEM_102 =0xE2,
|
||||||
KeyPROCESSKEY =0xE5,
|
KeyPROCESSKEY =0xE5,
|
||||||
KeyATTN =0xF6,
|
KeyATTN =0xF6,
|
||||||
KeyCRSEL =0xF7,
|
KeyCRSEL =0xF7,
|
||||||
|
|
|
@ -503,6 +503,14 @@
|
||||||
RelativePath="stdopengl.h"
|
RelativePath="stdopengl.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\unix_event_emitter.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\unix_event_emitter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</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 getMouseButton (uint32 state)
|
||||||
{
|
{
|
||||||
TMouseButton button=noButton;
|
uint32 button=noButton;
|
||||||
if (state&ControlMask) (int&)button|=ctrlButton;
|
if (state&Button1Mask) button|=leftButton;
|
||||||
if (state&Button1Mask) (int&)button|=leftButton;
|
if (state&Button2Mask) button|=middleButton;
|
||||||
if (state&Button3Mask) (int&)button|=rightButton;
|
if (state&Button3Mask) button|=rightButton;
|
||||||
if (state&Button2Mask) (int&)button|=middleButton;
|
if (state&ControlMask) button|=ctrlButton;
|
||||||
if (state&ShiftMask) (int&)button|=shiftButton;
|
if (state&ShiftMask) button|=shiftButton;
|
||||||
// TODO manage ALT key
|
if (state&AltMask) button|=altButton;
|
||||||
// if (GetAsyncKeyState(VK_MENU)&(1<<15))
|
|
||||||
// (int&)button|=altButton;
|
return (TMouseButton)button;
|
||||||
return 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)
|
TKey getKey (KeySym keysym)
|
||||||
|
@ -122,11 +139,16 @@ TKey getKey (KeySym keysym)
|
||||||
case XK_Shift_R: return KeySHIFT;
|
case XK_Shift_R: return KeySHIFT;
|
||||||
case XK_Control_L: return KeyCONTROL;
|
case XK_Control_L: return KeyCONTROL;
|
||||||
case XK_Control_R: 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_Caps_Lock: return Key;
|
||||||
/// case XK_Meta_L: return Key;
|
/// case XK_Meta_L: return Key;
|
||||||
/// case XK_Meta_R: return Key;
|
/// case XK_Meta_R: return Key;
|
||||||
/// case XK_Alt_L: return Key;
|
case XK_Mode_switch: return KeyMENU;
|
||||||
/// case XK_Alt_R: return Key;
|
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_space: return KeySPACE;
|
||||||
// case XK_comma: return Key;
|
// case XK_comma: return Key;
|
||||||
// case XK_minus: return Key;
|
// case XK_minus: return Key;
|
||||||
|
@ -199,9 +221,9 @@ TKey getKey (KeySym keysym)
|
||||||
case XK_y: return KeyY;
|
case XK_y: return KeyY;
|
||||||
case XK_Z:
|
case XK_Z:
|
||||||
case XK_z: return KeyZ;
|
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;
|
int c;
|
||||||
c = XLookupString(&event.xkey, Text, 1024-1, &k, NULL);
|
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)
|
// 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';
|
Text[c] = '\0';
|
||||||
if(c>0)
|
if(c>0)
|
||||||
|
@ -303,9 +327,11 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
||||||
int c;
|
int c;
|
||||||
c = XLookupString(&event.xkey, Text, 1024-1, &k, NULL);
|
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)
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
Case(FocusIn)
|
Case(FocusIn)
|
||||||
|
|
Loading…
Reference in a new issue