PS/2 Keyboard: fix handling of Pause key.
- There is one single "Puase" key also acting as "Break"
- For historical reasons it sends a complex sequence (control + num lock) instead of having its own key code
Change-Id: If9fd84caf9a06cd8409b9c3642fe313a7c01fad1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3449
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Diff
src/add-ons/kernel/bus_managers/ps2/ATKeymap.h | 22 ++++++++++++++--------
src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.cpp | 44 +++++++++++++++++++++++++++++++++++++-------
2 files changed, 44 insertions(+), 22 deletions(-)
@@ -11,7 +11,7 @@
const static uint32 kATKeycodeMap[] = {
0x1,
0x1,
0x12,
0x13,
0x14,
@@ -20,7 +20,7 @@
0x17,
0x18,
0x19,
0x1a,
0x1a,
0x1b,
0x1c,
0x1d,
@@ -30,7 +30,7 @@
0x28,
0x29,
0x2a,
0x2b,
0x2b,
0x2c,
0x2d,
0x2e,
@@ -40,7 +40,7 @@
0x32,
0x47,
0x5c,
0x3c,
0x3c,
0x3d,
0x3e,
0x3f,
@@ -50,7 +50,7 @@
0x43,
0x44,
0x45,
0x46,
0x46,
0x11,
0x4b,
0x33,
@@ -60,7 +60,7 @@
0x4f,
0x50,
0x51,
0x52,
0x52,
0x53,
0x54,
0x55,
@@ -70,7 +70,7 @@
0x5e,
0x3b,
0x02,
0x03,
0x03,
0x04,
0x05,
0x06,
@@ -80,7 +80,7 @@
0x0a,
0x0b,
0x22,
0x0f,
0x0f,
0x37,
0x38,
0x39,
@@ -90,12 +90,12 @@
0x4a,
0x3a,
0x58,
0x59,
0x59,
0x5a,
0x64,
0x65,
0x7e,
0x00,
0x00,
0x69,
0x0c,
0x0d,
@@ -208,7 +208,7 @@
0x00,
0x00,
0x00,
0x7f,
0x10,
0x20,
0x57,
0x21,
@@ -5,7 +5,7 @@
* Authors (in chronological order):
* Stefano Ceccherini (burton666@libero.it)
* Axel Dörfler, axeld@pinc-software.de
* Marcus Overhagen <marcus@overhagen.de>
* Marcus Overhagen <marcus@overhagen.de>
*/
@@ -37,12 +37,14 @@
};
enum {
EXTENDED_KEY = 0xe0,
EXTENDED_KEY_0 = 0xe0,
EXTENDED_KEY_1 = 0xe1,
LEFT_ALT_KEY = 0x38,
RIGHT_ALT_KEY = 0xb8,
SYS_REQ_KEY = 0x54,
PRNT_SCRN_KEY = 0x80 | 0x37,
PAUSE_KEY = 0x80 | 0x46,
};
@@ -58,7 +60,9 @@
static bool sHasDebugReader = false;
static sem_id sKeyboardSem;
static struct packet_buffer *sKeyBuffer;
static bool sIsExtended = false;
static bool sIsExtended0 = false;
static bool sIsExtended1 = false;
static uint8 sPauseSequenceRead = 0;
static int32 sKeyboardRepeatRate;
static bigtime_t sKeyboardRepeatDelay;
@@ -126,6 +130,8 @@
EMERGENCY_RIGHT_ALT = 0x02,
EMERGENCY_SYS_REQ = 0x04,
};
static const uint8 pauseSequence[] = { 0x1D, 0x45 };
static int emergencyKeyStatus = 0;
raw_key_info keyInfo;
uint8 scancode = dev->history[0].data;
@@ -133,25 +139,41 @@
if (atomic_get(&sKeyboardOpenCount) == 0)
return B_HANDLED_INTERRUPT;
if (scancode == EXTENDED_KEY) {
sIsExtended = true;
if (scancode == EXTENDED_KEY_0) {
sIsExtended0 = true;
return B_HANDLED_INTERRUPT;
}
if (scancode == EXTENDED_KEY_1) {
sIsExtended1 = true;
return B_HANDLED_INTERRUPT;
}
if ((scancode & 0x80) != 0) {
keyInfo.is_keydown = false;
scancode &= 0x7f;
} else
keyInfo.is_keydown = true;
if (sIsExtended1 && scancode == pauseSequence[sPauseSequenceRead]) {
sPauseSequenceRead++;
if (sPauseSequenceRead == 2) {
sIsExtended1 = false;
sPauseSequenceRead = 0;
scancode = PAUSE_KEY;
} else {
return B_HANDLED_INTERRUPT;
}
}
if (sIsExtended) {
if (sIsExtended0) {
scancode |= 0x80;
sIsExtended = false;
sIsExtended0 = false;
}