Move pause key processing from xorgxrdp

This commit moves processing of the pause key from xorgxrdp
back to xrdp itself, so that the key can be passed to the VNC
backend.
This commit is contained in:
matt335672
2024-06-19 21:40:36 +01:00
parent 5779edd23f
commit 7fe5b3ea34
8 changed files with 149 additions and 50 deletions
+22 -5
View File
@@ -167,7 +167,8 @@ static const struct scancode_to_keycode
{ 0x165, 225 }, // VK_BROWSER_SEARCH I225 (KEY_SEARCH)
{ 0x166, 164 }, // VK_BROWSER_FAVORITES I164 (KEY_BOOKMARKS)
{ 0x16b, 165 }, // VK_LAUNCH_APP1 I165 (KEY_COMPUTER)
{ 0x16c, 163 } // VK_LAUNCH_MAIL I163 (KEY_MAIL)
{ 0x16c, 163 }, // VK_LAUNCH_MAIL I163 (KEY_MAIL)
{ 0x21d, 127 } // VK_PAUSE PAUS (KEY_PAUSE)
};
// Sources:-
@@ -291,7 +292,8 @@ static const struct scancode_to_keycode
{ 0x153, 107 }, // VK_DELETE DELE
{ 0x15b, 115 }, // VK_LWIN LWIN
{ 0x15c, 116 }, // VK_RWIN RWIN
{ 0x15d, 117 } // VK_APPS COMP
{ 0x15d, 117 }, // VK_APPS COMP
{ 0x21d, 110 } // VK_PAUSE PAUS (KEY_PAUSE)
};
struct map_settings
@@ -339,12 +341,23 @@ scancode_to_index(unsigned short scancode)
// 0x80 - 0xff : Invalid code
return -1;
}
if (scancode <= 0x17f)
if (scancode <= 0x177)
{
// 01x100 - 0x17f : Move bit 9 to bit 8
// 01x100 - 0x177 : Move bit 9 to bit 8
return (scancode & 0x7f) | 0x80;
}
if (scancode == SCANCODE_PAUSE_KEY)
{
return SCANCODE_INDEX_PAUSE_KEY;
}
// This leaves the following which are all rejected
// 0x178 - 0x17f (currently unused). These would map to indexes 0xf8
// to 0xff which we are reserving for extended1 keys.
// 0x180 - 0x1ff Illegal format
// >0x200 Anything not mentioned explicitly above (e.g.
// SCANCODE_PAUSE_KEY)
return -1;
}
@@ -354,7 +367,11 @@ scancode_from_index(int index)
{
index &= 0xff;
unsigned short result;
if (index < 0x80)
if (index == SCANCODE_INDEX_PAUSE_KEY)
{
result = SCANCODE_PAUSE_KEY;
}
else if (index < 0x80)
{
result = index;
}
+11 -5
View File
@@ -75,6 +75,7 @@ enum
SCANCODE_BACKSPACE_KEY = 0x0e,
SCANCODE_ENTER_KEY = 0x1c,
SCANCODE_TAB_KEY = 0x0f,
SCANCODE_PAUSE_KEY = 0x21d,
SCANCODE_KP_ENTER_KEY = 0x11c,
SCANCODE_KP_DEL_KEY = 0x53,
@@ -99,6 +100,8 @@ enum
SCANCODE_INDEX_LSHIFT_KEY = SCANCODE_LSHIFT_KEY,
SCANCODE_INDEX_RSHIFT_KEY = SCANCODE_RSHIFT_KEY,
SCANCODE_INDEX_RALT_KEY = (SCANCODE_RALT_KEY & 0x7f) | 0x80,
SCANCODE_INDEX_PAUSE_KEY = 0xf8,
// 0xf9 - 0xff reserved for future extended1 mappings
/**
* Keys affected by numlock
@@ -116,7 +119,7 @@ enum
// Convert key_code and flags values received from a TS_KEYBOARD_EVENT
// into a value suitable for use by this module
#define SCANCODE_FROM_KBD_EVENT(key_code,keyboard_flags) \
(((key_code) & 0x7f) | ((keyboard_flags) & 0x100))
(((key_code) & 0x7f) | ((keyboard_flags) & 0x300))
// Convert a scancode used by this module back into a
// TS_KEYBOARD_EVENT keyCode value
@@ -124,16 +127,18 @@ enum
// Convert a scancode used by this module back into a
// TS_KEYBOARD_EVENT keyboardFlags value
#define SCANCODE_TO_KBD_EVENT_KBD_FLAGS(scancode) ((scancode) & 0x100)
#define SCANCODE_TO_KBD_EVENT_KBD_FLAGS(scancode) ((scancode) & 0x300)
/**
* Convert a scancode to an index
* @param scancode scancode in the range 0x00 - 0x1ff
* @param scancode scancode in the range 0x00 - 0x2ff
* @return index in the range 0..SCANCODE_MAX_INDEX (inclusive) or -1
*
* This function converts a 9-bit scancode into an 8-bit array index,
* This function converts a 10-bit scancode into an 8-bit array index,
* independent of the currently loaded keymap
*
* This is possible as the scancodes from 0x80 - 0x2ff are sparsely allocated.
*
* For scancodes in the range 0x00 - 0x7f, the index is identical to the
* scancode. This includes scancodes for all the keys affected by
* numlock.
@@ -157,7 +162,8 @@ scancode_from_index(int index);
* Looks up an RDP scancode and converts to an x11 keycode
*
* @param scancode Scancode. Extended scancodes have bit 9 set
* (i.e. are in 0x100 - 0x1ff).
* (i.e. are in 0x100 - 0x1ff). Extended1 scancodes
* (currently just the pause key) are in the range 0x200-0x2ff
* @return keycode, or 0 for no keycode
*/
unsigned short