X11rdp: keyboard organization, added XKB ruls base option back, still default evdev
parent
02aa39c79d
commit
ada549bb24
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright 2005-2014 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
keyboard
|
||||
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
#include "rdpkeyboard.h"
|
||||
#include "rdpkeyboardevdev.h"
|
||||
|
||||
#define LOG_LEVEL 1
|
||||
#define LLOGLN(_level, _args) \
|
||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||
|
||||
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
|
||||
extern int g_shift_down; /* in rdpmain.c */
|
||||
extern int g_alt_down; /* in rdpmain.c */
|
||||
extern int g_ctrl_down; /* in rdpmain.c */
|
||||
extern int g_pause_spe; /* in rdpmain.c */
|
||||
extern int g_tab_down; /* in rdpmain.c */
|
||||
|
||||
/******************************************************************************/
|
||||
void
|
||||
rdpEnqueueKey(int type, int scancode)
|
||||
{
|
||||
int i;
|
||||
int n;
|
||||
EventListPtr rdp_events;
|
||||
xEvent *pev;
|
||||
|
||||
i = GetEventList(&rdp_events);
|
||||
n = GetKeyboardEvents(rdp_events, g_keyboard, type, scancode);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
pev = (rdp_events + i)->event;
|
||||
mieqEnqueue(g_keyboard, (InternalEvent *)pev);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void
|
||||
check_keysa(void)
|
||||
{
|
||||
if (g_ctrl_down != 0)
|
||||
{
|
||||
rdpEnqueueKey(KeyRelease, g_ctrl_down);
|
||||
g_ctrl_down = 0;
|
||||
}
|
||||
|
||||
if (g_alt_down != 0)
|
||||
{
|
||||
rdpEnqueueKey(KeyRelease, g_alt_down);
|
||||
g_alt_down = 0;
|
||||
}
|
||||
|
||||
if (g_shift_down != 0)
|
||||
{
|
||||
rdpEnqueueKey(KeyRelease, g_shift_down);
|
||||
g_shift_down = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void
|
||||
sendDownUpKeyEvent(int type, int x_scancode)
|
||||
{
|
||||
/* if type is keydown, send keyup + keydown */
|
||||
if (type == KeyPress)
|
||||
{
|
||||
rdpEnqueueKey(KeyRelease, x_scancode);
|
||||
rdpEnqueueKey(KeyPress, x_scancode);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdpEnqueueKey(KeyRelease, x_scancode);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright 2013-2014 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
keyboard map for base rules
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _RDPKEYBOARD_H
|
||||
#define _RDPKEYBOARD_H
|
||||
|
||||
#define MIN_KEY_CODE 8
|
||||
#define MAX_KEY_CODE 255
|
||||
#define NO_OF_KEYS ((MAX_KEY_CODE - MIN_KEY_CODE) + 1)
|
||||
#define GLYPHS_PER_KEY 2
|
||||
|
||||
#define RDPSCAN_Tab 15
|
||||
#define RDPSCAN_Return 28 /* ext is used to know KP or not */
|
||||
#define RDPSCAN_Control 29 /* ext is used to know L or R */
|
||||
#define RDPSCAN_Shift_L 42
|
||||
#define RDPSCAN_Slash 53
|
||||
#define RDPSCAN_Shift_R 54
|
||||
#define RDPSCAN_KP_Multiply 55
|
||||
#define RDPSCAN_Alt 56 /* ext is used to know L or R */
|
||||
#define RDPSCAN_Caps_Lock 58
|
||||
#define RDPSCAN_Pause 69
|
||||
#define RDPSCAN_Scroll_Lock 70
|
||||
#define RDPSCAN_KP_7 71 /* KP7 or home */
|
||||
#define RDPSCAN_KP_8 72 /* KP8 or up */
|
||||
#define RDPSCAN_KP_9 73 /* KP9 or page up */
|
||||
#define RDPSCAN_KP_4 75 /* KP4 or left */
|
||||
#define RDPSCAN_KP_6 77 /* KP6 or right */
|
||||
#define RDPSCAN_KP_1 79 /* KP1 or home */
|
||||
#define RDPSCAN_KP_2 80 /* KP2 or up */
|
||||
#define RDPSCAN_KP_3 81 /* KP3 or page down */
|
||||
#define RDPSCAN_KP_0 82 /* KP0 or insert */
|
||||
#define RDPSCAN_KP_Decimal 83 /* KP. or delete */
|
||||
#define RDPSCAN_89 89
|
||||
#define RDPSCAN_90 90
|
||||
#define RDPSCAN_LWin 91
|
||||
#define RDPSCAN_RWin 92
|
||||
#define RDPSCAN_Menu 93
|
||||
#define RDPSCAN_115 115
|
||||
#define RDPSCAN_126 126
|
||||
|
||||
void
|
||||
rdpEnqueueKey(int type, int scancode);
|
||||
void
|
||||
check_keysa(void);
|
||||
void
|
||||
sendDownUpKeyEvent(int type, int x_scancode);
|
||||
|
||||
#endif
|
@ -0,0 +1,300 @@
|
||||
/*
|
||||
Copyright 2005-2014 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
keyboard map for base rules
|
||||
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
#include "rdpkeyboard.h"
|
||||
#include "rdpkeyboardbase.h"
|
||||
|
||||
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
|
||||
extern int g_shift_down; /* in rdpmain.c */
|
||||
extern int g_alt_down; /* in rdpmain.c */
|
||||
extern int g_ctrl_down; /* in rdpmain.c */
|
||||
extern int g_pause_spe; /* in rdpmain.c */
|
||||
extern int g_tab_down; /* in rdpmain.c */
|
||||
|
||||
#define LOG_LEVEL 1
|
||||
#define LLOGLN(_level, _args) \
|
||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||
|
||||
#define XSCAN_Tab 23
|
||||
#define XSCAN_Return 36 /* above right shift */
|
||||
#define XSCAN_Control_L 37
|
||||
#define XSCAN_Shift_L 50
|
||||
#define XSCAN_slash 61
|
||||
#define XSCAN_Shift_R 62
|
||||
#define XSCAN_KP_Multiply 63
|
||||
#define XSCAN_Alt_L 64
|
||||
#define XSCAN_Caps_Lock 66 /* caps lock */
|
||||
#define XSCAN_Num_Lock 77 /* num lock */
|
||||
#define XSCAN_KP_7 79
|
||||
#define XSCAN_KP_8 80
|
||||
#define XSCAN_KP_9 81
|
||||
#define XSCAN_KP_4 83
|
||||
#define XSCAN_KP_6 85
|
||||
#define XSCAN_KP_1 87
|
||||
#define XSCAN_KP_2 88
|
||||
#define XSCAN_KP_3 89
|
||||
#define XSCAN_KP_0 90
|
||||
#define XSCAN_KP_Decimal 91
|
||||
/* "/ ?" on br keybaord */
|
||||
#define XSCAN_97 97 /* ------------------------------? */
|
||||
#define XSCAN_Enter 108 /* 104 */ /* on keypad */
|
||||
#define XSCAN_Control_R 109 /* 105 */
|
||||
#define XSCAN_KP_Divide 112 /* 106 */
|
||||
#define XSCAN_Print 111 /* 107 */
|
||||
#define XSCAN_Alt_R 113 /* 108 */
|
||||
#define XSCAN_Home 97 /* 110 */
|
||||
#define XSCAN_Up 98 /* 111 */
|
||||
#define XSCAN_Prior 99 /* 112 */
|
||||
#define XSCAN_Left 100 /* 113 */
|
||||
#define XSCAN_Right 102 /* 114 */
|
||||
#define XSCAN_End 103 /* 115 */
|
||||
#define XSCAN_Down 104 /* 116 */
|
||||
#define XSCAN_Next 105 /* 117 */
|
||||
#define XSCAN_Insert 106 /* 118 */
|
||||
#define XSCAN_Delete 107 /* 119 */
|
||||
#define XSCAN_Pause 110 /* 127 */
|
||||
/* . on br keypad */
|
||||
#define XSCAN_129 129 /* ------------------------------? */
|
||||
#define XSCAN_LWin 115 /* 133 */
|
||||
#define XSCAN_RWin 116 /* 134 */
|
||||
#define XSCAN_Menu 117 /* 135 */
|
||||
#define XSCAN_LMeta 156
|
||||
#define XSCAN_RMeta 156
|
||||
|
||||
/******************************************************************************/
|
||||
void
|
||||
KbdAddEvent_base(int down, int param1, int param2, int param3, int param4)
|
||||
{
|
||||
int rdp_scancode;
|
||||
int x_scancode;
|
||||
int is_ext;
|
||||
int is_spe;
|
||||
int type;
|
||||
|
||||
LLOGLN(10, ("KbdAddEvent_base: down=0x%x param1=0x%x param2=0x%x "
|
||||
"param3=0x%x param4=0x%x", down, param1, param2, param3, param4));
|
||||
if (g_keyboard == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
type = down ? KeyPress : KeyRelease;
|
||||
rdp_scancode = param3;
|
||||
is_ext = param4 & 256; /* 0x100 */
|
||||
is_spe = param4 & 512; /* 0x200 */
|
||||
x_scancode = 0;
|
||||
|
||||
switch (rdp_scancode)
|
||||
{
|
||||
case RDPSCAN_Caps_Lock: /* caps lock */
|
||||
case RDPSCAN_Shift_L: /* left shift */
|
||||
case RDPSCAN_Shift_R: /* right shift */
|
||||
case RDPSCAN_Scroll_Lock: /* scroll lock */
|
||||
x_scancode = rdp_scancode + MIN_KEY_CODE;
|
||||
|
||||
if (x_scancode > 0)
|
||||
{
|
||||
/* left or right shift */
|
||||
if ((rdp_scancode == RDPSCAN_Shift_L) ||
|
||||
(rdp_scancode == RDPSCAN_Shift_R))
|
||||
{
|
||||
g_shift_down = down ? x_scancode : 0;
|
||||
}
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
}
|
||||
break;
|
||||
|
||||
case RDPSCAN_Alt: /* left - right alt button */
|
||||
|
||||
if (is_ext)
|
||||
{
|
||||
x_scancode = XSCAN_Alt_R; /* right alt button */
|
||||
}
|
||||
else
|
||||
{
|
||||
x_scancode = XSCAN_Alt_L; /* left alt button */
|
||||
}
|
||||
|
||||
g_alt_down = down ? x_scancode : 0;
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Tab: /* tab */
|
||||
|
||||
if (!down && !g_tab_down)
|
||||
{
|
||||
check_keysa(); /* leave x_scancode 0 here, we don't want the tab key up */
|
||||
}
|
||||
else
|
||||
{
|
||||
sendDownUpKeyEvent(type, XSCAN_Tab);
|
||||
}
|
||||
|
||||
g_tab_down = down;
|
||||
break;
|
||||
|
||||
case RDPSCAN_Control: /* left or right ctrl */
|
||||
|
||||
/* this is to handle special case with pause key sending control first */
|
||||
if (is_spe)
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
g_pause_spe = 1;
|
||||
/* leave x_scancode 0 here, we don't want the control key down */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x_scancode = is_ext ? XSCAN_Control_R : XSCAN_Control_L;
|
||||
g_ctrl_down = down ? x_scancode : 0;
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RDPSCAN_Pause: /* Pause or Num Lock */
|
||||
|
||||
if (g_pause_spe)
|
||||
{
|
||||
x_scancode = XSCAN_Pause;
|
||||
|
||||
if (!down)
|
||||
{
|
||||
g_pause_spe = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x_scancode = g_ctrl_down ? XSCAN_Pause : XSCAN_Num_Lock;
|
||||
}
|
||||
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Return: /* Enter or Return */
|
||||
x_scancode = is_ext ? XSCAN_Enter : XSCAN_Return;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Slash: /* / */
|
||||
x_scancode = is_ext ? XSCAN_KP_Divide : XSCAN_slash;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_Multiply: /* * on KP or Print Screen */
|
||||
x_scancode = is_ext ? XSCAN_Print : XSCAN_KP_Multiply;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_7: /* 7 or Home */
|
||||
x_scancode = is_ext ? XSCAN_Home : XSCAN_KP_7;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_8: /* 8 or Up */
|
||||
x_scancode = is_ext ? XSCAN_Up : XSCAN_KP_8;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_9: /* 9 or PgUp */
|
||||
x_scancode = is_ext ? XSCAN_Prior : XSCAN_KP_9;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_4: /* 4 or Left */
|
||||
x_scancode = is_ext ? XSCAN_Left : XSCAN_KP_4;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_6: /* 6 or Right */
|
||||
x_scancode = is_ext ? XSCAN_Right : XSCAN_KP_6;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_1: /* 1 or End */
|
||||
x_scancode = is_ext ? XSCAN_End : XSCAN_KP_1;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_2: /* 2 or Down */
|
||||
x_scancode = is_ext ? XSCAN_Down : XSCAN_KP_2;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_3: /* 3 or PgDn */
|
||||
x_scancode = is_ext ? XSCAN_Next : XSCAN_KP_3;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_0: /* 0 or Insert */
|
||||
x_scancode = is_ext ? XSCAN_Insert : XSCAN_KP_0;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_Decimal: /* . or Delete */
|
||||
x_scancode = is_ext ? XSCAN_Delete : XSCAN_KP_Decimal;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_LWin: /* left win key */
|
||||
rdpEnqueueKey(type, XSCAN_LWin);
|
||||
break;
|
||||
|
||||
case RDPSCAN_RWin: /* right win key */
|
||||
rdpEnqueueKey(type, XSCAN_RWin);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Menu: /* menu key */
|
||||
rdpEnqueueKey(type, XSCAN_Menu);
|
||||
break;
|
||||
|
||||
case RDPSCAN_89: /* left meta */
|
||||
rdpEnqueueKey(type, XSCAN_LMeta);
|
||||
break;
|
||||
|
||||
case RDPSCAN_90: /* right meta */
|
||||
rdpEnqueueKey(type, XSCAN_RMeta);
|
||||
break;
|
||||
|
||||
case RDPSCAN_115:
|
||||
rdpEnqueueKey(type, XSCAN_97); /* "/ ?" on br keybaord */
|
||||
break;
|
||||
|
||||
case RDPSCAN_126:
|
||||
rdpEnqueueKey(type, XSCAN_129); /* . on br keypad */
|
||||
break;
|
||||
|
||||
default:
|
||||
x_scancode = rdp_scancode + MIN_KEY_CODE;
|
||||
|
||||
if (x_scancode > 0)
|
||||
{
|
||||
LLOGLN(10, ("KbdAddEvent_base: rdp_scancode %d x_scancode %d",
|
||||
rdp_scancode, x_scancode));
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2013-2014 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
keyboard map for base rules
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _RDPKEYBOARDBASE_H
|
||||
#define _RDPKEYBOARDBASE_H
|
||||
|
||||
void
|
||||
KbdAddEvent_base(int down, int param1, int param2, int param3, int param4);
|
||||
|
||||
#endif
|
@ -0,0 +1,300 @@
|
||||
/*
|
||||
Copyright 2005-2014 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
keyboard map for evdev rules
|
||||
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
#include "rdpkeyboard.h"
|
||||
#include "rdpkeyboardevdev.h"
|
||||
|
||||
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
|
||||
extern int g_shift_down; /* in rdpmain.c */
|
||||
extern int g_alt_down; /* in rdpmain.c */
|
||||
extern int g_ctrl_down; /* in rdpmain.c */
|
||||
extern int g_pause_spe; /* in rdpmain.c */
|
||||
extern int g_tab_down; /* in rdpmain.c */
|
||||
|
||||
#define LOG_LEVEL 1
|
||||
#define LLOGLN(_level, _args) \
|
||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||
|
||||
#define XSCAN_Tab 23
|
||||
#define XSCAN_Return 36 /* above right shift */
|
||||
#define XSCAN_Control_L 37
|
||||
#define XSCAN_Shift_L 50
|
||||
#define XSCAN_slash 61
|
||||
#define XSCAN_Shift_R 62
|
||||
#define XSCAN_KP_Multiply 63
|
||||
#define XSCAN_Alt_L 64
|
||||
#define XSCAN_Caps_Lock 66 /* caps lock */
|
||||
#define XSCAN_Num_Lock 77 /* num lock */
|
||||
#define XSCAN_KP_7 79
|
||||
#define XSCAN_KP_8 80
|
||||
#define XSCAN_KP_9 81
|
||||
#define XSCAN_KP_4 83
|
||||
#define XSCAN_KP_6 85
|
||||
#define XSCAN_KP_1 87
|
||||
#define XSCAN_KP_2 88
|
||||
#define XSCAN_KP_3 89
|
||||
#define XSCAN_KP_0 90
|
||||
#define XSCAN_KP_Decimal 91
|
||||
/* "/ ?" on br keybaord */
|
||||
#define XSCAN_97 97
|
||||
#define XSCAN_Enter 104 /* on keypad */
|
||||
#define XSCAN_Control_R 105
|
||||
#define XSCAN_KP_Divide 106
|
||||
#define XSCAN_Print 107
|
||||
#define XSCAN_Alt_R 108
|
||||
#define XSCAN_Home 110
|
||||
#define XSCAN_Up 111
|
||||
#define XSCAN_Prior 112
|
||||
#define XSCAN_Left 113
|
||||
#define XSCAN_Right 114
|
||||
#define XSCAN_End 115
|
||||
#define XSCAN_Down 116
|
||||
#define XSCAN_Next 117
|
||||
#define XSCAN_Insert 118
|
||||
#define XSCAN_Delete 119
|
||||
#define XSCAN_Pause 127
|
||||
/* . on br keypad */
|
||||
#define XSCAN_129 129
|
||||
#define XSCAN_LWin 133
|
||||
#define XSCAN_RWin 134
|
||||
#define XSCAN_Menu 135
|
||||
#define XSCAN_LMeta 156
|
||||
#define XSCAN_RMeta 156
|
||||
|
||||
/******************************************************************************/
|
||||
void
|
||||
KbdAddEvent_evdev(int down, int param1, int param2, int param3, int param4)
|
||||
{
|
||||
int rdp_scancode;
|
||||
int x_scancode;
|
||||
int is_ext;
|
||||
int is_spe;
|
||||
int type;
|
||||
|
||||
LLOGLN(10, ("KbdAddEvent_evdev: down=0x%x param1=0x%x param2=0x%x "
|
||||
"param3=0x%x param4=0x%x", down, param1, param2, param3, param4));
|
||||
if (g_keyboard == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
type = down ? KeyPress : KeyRelease;
|
||||
rdp_scancode = param3;
|
||||
is_ext = param4 & 256; /* 0x100 */
|
||||
is_spe = param4 & 512; /* 0x200 */
|
||||
x_scancode = 0;
|
||||
|
||||
switch (rdp_scancode)
|
||||
{
|
||||
case RDPSCAN_Caps_Lock: /* caps lock */
|
||||
case RDPSCAN_Shift_L: /* left shift */
|
||||
case RDPSCAN_Shift_R: /* right shift */
|
||||
case RDPSCAN_Scroll_Lock: /* scroll lock */
|
||||
x_scancode = rdp_scancode + MIN_KEY_CODE;
|
||||
|
||||
if (x_scancode > 0)
|
||||
{
|
||||
/* left or right shift */
|
||||
if ((rdp_scancode == RDPSCAN_Shift_L) ||
|
||||
(rdp_scancode == RDPSCAN_Shift_R))
|
||||
{
|
||||
g_shift_down = down ? x_scancode : 0;
|
||||
}
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
}
|
||||
break;
|
||||
|
||||
case RDPSCAN_Alt: /* left - right alt button */
|
||||
|
||||
if (is_ext)
|
||||
{
|
||||
x_scancode = XSCAN_Alt_R; /* right alt button */
|
||||
}
|
||||
else
|
||||
{
|
||||
x_scancode = XSCAN_Alt_L; /* left alt button */
|
||||
}
|
||||
|
||||
g_alt_down = down ? x_scancode : 0;
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Tab: /* tab */
|
||||
|
||||
if (!down && !g_tab_down)
|
||||
{
|
||||
check_keysa(); /* leave x_scancode 0 here, we don't want the tab key up */
|
||||
}
|
||||
else
|
||||
{
|
||||
sendDownUpKeyEvent(type, XSCAN_Tab);
|
||||
}
|
||||
|
||||
g_tab_down = down;
|
||||
break;
|
||||
|
||||
case RDPSCAN_Control: /* left or right ctrl */
|
||||
|
||||
/* this is to handle special case with pause key sending control first */
|
||||
if (is_spe)
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
g_pause_spe = 1;
|
||||
/* leave x_scancode 0 here, we don't want the control key down */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x_scancode = is_ext ? XSCAN_Control_R : XSCAN_Control_L;
|
||||
g_ctrl_down = down ? x_scancode : 0;
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RDPSCAN_Pause: /* Pause or Num Lock */
|
||||
|
||||
if (g_pause_spe)
|
||||
{
|
||||
x_scancode = XSCAN_Pause;
|
||||
|
||||
if (!down)
|
||||
{
|
||||
g_pause_spe = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x_scancode = g_ctrl_down ? XSCAN_Pause : XSCAN_Num_Lock;
|
||||
}
|
||||
|
||||
rdpEnqueueKey(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Return: /* Enter or Return */
|
||||
x_scancode = is_ext ? XSCAN_Enter : XSCAN_Return;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Slash: /* / */
|
||||
x_scancode = is_ext ? XSCAN_KP_Divide : XSCAN_slash;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_Multiply: /* * on KP or Print Screen */
|
||||
x_scancode = is_ext ? XSCAN_Print : XSCAN_KP_Multiply;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_7: /* 7 or Home */
|
||||
x_scancode = is_ext ? XSCAN_Home : XSCAN_KP_7;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_8: /* 8 or Up */
|
||||
x_scancode = is_ext ? XSCAN_Up : XSCAN_KP_8;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_9: /* 9 or PgUp */
|
||||
x_scancode = is_ext ? XSCAN_Prior : XSCAN_KP_9;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_4: /* 4 or Left */
|
||||
x_scancode = is_ext ? XSCAN_Left : XSCAN_KP_4;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_6: /* 6 or Right */
|
||||
x_scancode = is_ext ? XSCAN_Right : XSCAN_KP_6;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_1: /* 1 or End */
|
||||
x_scancode = is_ext ? XSCAN_End : XSCAN_KP_1;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_2: /* 2 or Down */
|
||||
x_scancode = is_ext ? XSCAN_Down : XSCAN_KP_2;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_3: /* 3 or PgDn */
|
||||
x_scancode = is_ext ? XSCAN_Next : XSCAN_KP_3;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_0: /* 0 or Insert */
|
||||
x_scancode = is_ext ? XSCAN_Insert : XSCAN_KP_0;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_KP_Decimal: /* . or Delete */
|
||||
x_scancode = is_ext ? XSCAN_Delete : XSCAN_KP_Decimal;
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
break;
|
||||
|
||||
case RDPSCAN_LWin: /* left win key */
|
||||
rdpEnqueueKey(type, XSCAN_LWin);
|
||||
break;
|
||||
|
||||
case RDPSCAN_RWin: /* right win key */
|
||||
rdpEnqueueKey(type, XSCAN_RWin);
|
||||
break;
|
||||
|
||||
case RDPSCAN_Menu: /* menu key */
|
||||
rdpEnqueueKey(type, XSCAN_Menu);
|
||||
break;
|
||||
|
||||
case RDPSCAN_89: /* left meta */
|
||||
rdpEnqueueKey(type, XSCAN_LMeta);
|
||||
break;
|
||||
|
||||
case RDPSCAN_90: /* right meta */
|
||||
rdpEnqueueKey(type, XSCAN_RMeta);
|
||||
break;
|
||||
|
||||
case RDPSCAN_115:
|
||||
rdpEnqueueKey(type, XSCAN_97); /* "/ ?" on br keybaord */
|
||||
break;
|
||||
|
||||
case RDPSCAN_126:
|
||||
rdpEnqueueKey(type, XSCAN_129); /* . on br keypad */
|
||||
break;
|
||||
|
||||
default:
|
||||
x_scancode = rdp_scancode + MIN_KEY_CODE;
|
||||
|
||||
if (x_scancode > 0)
|
||||
{
|
||||
LLOGLN(10, ("KbdAddEvent_evdev: rdp_scancode %d x_scancode %d",
|
||||
rdp_scancode, x_scancode));
|
||||
sendDownUpKeyEvent(type, x_scancode);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2013-2014 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
keyboard map for base rules
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _RDPKEYBOARDEVDEV_H
|
||||
#define _RDPKEYBOARDEVDEV_H
|
||||
|
||||
void
|
||||
KbdAddEvent_evdev(int down, int param1, int param2, int param3, int param4);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue