⛏️ index : haiku.git

author user <sylvain_kerjean@hotmail.com> 2020-09-16 22:53:41.0 +02:00:00
committer Alex von Gluck IV <kallisti5@unixzen.com> 2020-12-02 13:57:23.0 +00:00:00
commit
1132ecca079b804631f096c9634e7e8128ccf4e7 [patch]
tree
795391b826b92907b5d31532143aaebe94d1bee1
parent
c6aa02dc696a2028d4f32d884d623e85d58d20c6
download
1132ecca079b804631f096c9634e7e8128ccf4e7.tar.gz

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(-)

diff --git a/src/add-ons/kernel/bus_managers/ps2/ATKeymap.h b/src/add-ons/kernel/bus_managers/ps2/ATKeymap.h
index 0edbe3a..7b67655 100644
--- a/src/add-ons/kernel/bus_managers/ps2/ATKeymap.h
+++ b/src/add-ons/kernel/bus_managers/ps2/ATKeymap.h
@@ -11,7 +11,7 @@


const static uint32 kATKeycodeMap[] = {
	0x1,	// Esc
	0x1,	// Esc			1
	0x12, 	// 1
	0x13,	// 2
	0x14,	// 3
@@ -20,7 +20,7 @@
	0x17,	// 6
	0x18,	// 7
	0x19,	// 8
	0x1a,	// 9
	0x1a,	// 9			10
	0x1b,	// 0
	0x1c,	// -
	0x1d,	// =
@@ -30,7 +30,7 @@
	0x28,	// W
	0x29,	// E
	0x2a,	// R
	0x2b,	// T
	0x2b,	// T			20
	0x2c,	// Y
	0x2d,	// U
	0x2e,	// I
@@ -40,7 +40,7 @@
	0x32,	// ]
	0x47,	// ENTER
	0x5c,	// Left Control
	0x3c,	// A
	0x3c,	// A			30
	0x3d,	// S
	0x3e,	// D
	0x3f,	// F
@@ -50,7 +50,7 @@
	0x43,	// K
	0x44,	// L
	0x45,	// ;
	0x46,	// '
	0x46,	// '			40
	0x11,	// `
	0x4b,	// Left Shift
	0x33, 	// \ (backslash -- note: don't remove non-white-space after BS char)
@@ -60,7 +60,7 @@
	0x4f,	// V
	0x50,	// B
	0x51,	// N
	0x52,	// M
	0x52,	// M			50
	0x53,	// ,
	0x54,	// .
	0x55,	// /
@@ -70,7 +70,7 @@
	0x5e,	// Space
	0x3b,	// Caps
	0x02,	// F1
	0x03,	// F2
	0x03,	// F2			60
	0x04,	// F3
	0x05,	// F4
	0x06,	// F5
@@ -80,7 +80,7 @@
	0x0a,	// F9
	0x0b,	// F10
	0x22,	// Num
	0x0f,	// Scroll
	0x0f,	// Scroll		70
	0x37,	// KP 7
	0x38,	// KP 8
	0x39,	// KP 9
@@ -90,12 +90,12 @@
	0x4a,	// KP 6
	0x3a,	// KP +
	0x58,	// KP 1
	0x59,	// KP 2
	0x59,	// KP 2			80
	0x5a,	// KP 3
	0x64,	// KP 0
	0x65,	// KP .
	0x7e,	// SystReq
	0x00,	// UNMAPPED
	0x00,	// UNMAPPED
	0x69,	// <
	0x0c,	// F11
	0x0d,	// F12
@@ -208,7 +208,7 @@
	0x00,   // UNMAPPED
	0x00,   // UNMAPPED
	0x00,   // UNMAPPED
	0x7f,   // Break
	0x10,   // Pause
	0x20,   // Home
	0x57,	// Up Arrow		200
	0x21,   // Page Up
diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.cpp b/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.cpp
index c88d941..15ec67d 100644
--- a/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.cpp
+++ b/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.cpp
@@ -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;

	// TODO: Handle braindead "pause" key special case

	if (scancode == EXTENDED_KEY) {
		sIsExtended = true;
//		TRACE("Extended key\n");
	if (scancode == EXTENDED_KEY_0) {
		sIsExtended0 = true;
		//TRACE("Extended key 0\n");
		return B_HANDLED_INTERRUPT;
	}

//	TRACE("scancode: %x\n", scancode);
	if (scancode == EXTENDED_KEY_1) {
		sIsExtended1 = true;
		//TRACE("Extended key 1\n");
		return B_HANDLED_INTERRUPT;
	}

	if ((scancode & 0x80) != 0) {
		keyInfo.is_keydown = false;
		scancode &= 0x7f;
	} else
		keyInfo.is_keydown = true;

	//	TRACE("scancode: %x\n", scancode);

	// Handle braindead "pause" key special case
	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;
	}

	// Handle emergency keys