1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

Kernel+Userland: Implement support for PS2 scan code set 2

This scan code set is more advanced than the basic scan code set 1, and
is required to be supported for some bare metal hardware that might not
properly enable the PS2 first port translation in the i8042 controller.

LibWeb can now also generate bindings for keyboard events like the Pause
key, as well as other function keys (such as Right Alt, etc).

The logic for handling scan code sets is implemented by the PS2 keyboard
driver and is abstracted from the main HID KeyboardDevice code which
only handles "standard" KeyEvent(s).
This commit is contained in:
Liav A 2023-12-30 06:19:04 +02:00 committed by Andrew Kaster
parent cae184d7cf
commit c8f27d7cb8
12 changed files with 991 additions and 439 deletions

View file

@ -143,8 +143,9 @@ static ErrorOr<Optional<String>> get_event_named_key(KeyCode platform_key)
// 3.2. Modifier Keys, https://www.w3.org/TR/uievents-key/#keys-modifier
case KeyCode::Key_Alt:
return "Alt"_string;
// FIXME: AltGraph
return "AltLeft"_string;
case KeyCode::Key_RightAlt:
return "AltRight"_string;
case KeyCode::Key_CapsLock:
return "CapsLock"_string;
case KeyCode::Key_Control:
@ -457,7 +458,9 @@ static ErrorOr<String> get_event_code(KeyCode platform_key, unsigned modifiers)
// 3.1.2. Functional Keys, https://www.w3.org/TR/uievents-code/#key-alphanumeric-functional
case KeyCode::Key_Alt:
return "Alt"_string; // FIXME: Detect left vs. right key.
return "AltLeft"_string;
case KeyCode::Key_RightAlt:
return "AltRight"_string;
case KeyCode::Key_Backspace:
return "Backspace"_string;
case KeyCode::Key_CapsLock:
@ -465,7 +468,9 @@ static ErrorOr<String> get_event_code(KeyCode platform_key, unsigned modifiers)
case KeyCode::Key_Menu:
return "ContextMenu"_string;
case KeyCode::Key_Control:
return "Control"_string; // FIXME: Detect left vs. right key.
return "ControlLeft"_string;
case KeyCode::Key_RightControl:
return "ControlRight"_string;
case KeyCode::Key_Return:
return "Enter"_string;
case KeyCode::Key_Super:
@ -540,7 +545,60 @@ static ErrorOr<String> get_event_code(KeyCode platform_key, unsigned modifiers)
return "PrintScreen"_string;
case KeyCode::Key_ScrollLock:
return "ScrollLock"_string;
// FIXME: Pause
case KeyCode::Key_PauseBreak:
return "Pause"_string;
// 3.6. Media Section, https://www.w3.org/TR/uievents-code/#media-keys
case KeyCode::Key_BrowserSearch:
return "BrowserSearch"_string;
case KeyCode::Key_BrowserFavorites:
return "BrowserFavorites"_string;
case KeyCode::Key_BrowserHome:
return "BrowserHome"_string;
case KeyCode::Key_PreviousTrack:
return "PreviousTrack"_string;
case KeyCode::Key_BrowserBack:
return "BrowserBack"_string;
case KeyCode::Key_BrowserForward:
return "BrowserForward"_string;
case KeyCode::Key_BrowserRefresh:
return "BrowserRefresh"_string;
case KeyCode::Key_BrowserStop:
return "BrowserStop"_string;
case KeyCode::Key_VolumeDown:
return "AudioVolumeDown"_string;
case KeyCode::Key_VolumeUp:
return "AudioVolumeUp"_string;
case KeyCode::Key_Wake:
return "WakeUp"_string;
case KeyCode::Key_Sleep:
return "Sleep"_string;
case KeyCode::Key_NextTrack:
return "NextTrack"_string;
case KeyCode::Key_MediaSelect:
return "MediaSelect"_string;
case KeyCode::Key_Email:
return "LaunchMail"_string;
case KeyCode::Key_Power:
return "Power"_string;
case KeyCode::Key_Stop:
return "MediaStop"_string;
case KeyCode::Key_PlayPause:
return "MediaPlayPause"_string;
case KeyCode::Key_Mute:
return "AudioVolumeMute"_string;
case KeyCode::Key_Calculator:
return "LaunchApp2"_string;
case KeyCode::Key_MyComputer:
return "LaunchApp1"_string;
// FIXME: Are these correct?
case KeyCode::Key_LeftGUI:
return "LaunchApp2"_string;
case KeyCode::Key_RightGUI:
case KeyCode::Key_Apps:
return "LaunchApp1"_string;
// 3.7. Legacy, Non-Standard and Special Keys, https://www.w3.org/TR/uievents-code/#key-legacy
case KeyCode::Key_Invalid: