소스 검색

Kernel: Add a key code modifier to detect the number pad

This is analagous to how Qt exposes whether the number pad was used for
a key press.
Timothy Flynn 2 년 전
부모
커밋
f798e43ea8
2개의 변경된 파일21개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      Kernel/API/KeyCode.h
  2. 18 0
      Kernel/Devices/HID/KeyboardDevice.cpp

+ 3 - 1
Kernel/API/KeyCode.h

@@ -134,7 +134,8 @@ enum KeyModifier {
     Mod_Shift = (1 << 2),
     Mod_Super = (1 << 3),
     Mod_AltGr = (1 << 4),
-    Mod_Mask = Mod_Alt | Mod_Ctrl | Mod_Shift | Mod_Super | Mod_AltGr,
+    Mod_Keypad = (1 << 5),
+    Mod_Mask = Mod_Alt | Mod_Ctrl | Mod_Shift | Mod_Super | Mod_AltGr | Mod_Keypad,
 
     Is_Press = 0x80,
 };
@@ -151,6 +152,7 @@ struct KeyEvent {
     bool shift() const { return flags & Mod_Shift; }
     bool super() const { return flags & Mod_Super; }
     bool altgr() const { return flags & Mod_AltGr; }
+    bool keypad() const { return flags & Mod_Keypad; }
     unsigned modifiers() const { return flags & Mod_Mask; }
     bool is_press() const { return flags & Is_Press; }
 };

+ 18 - 0
Kernel/Devices/HID/KeyboardDevice.cpp

@@ -243,6 +243,24 @@ void KeyboardDevice::handle_scan_code_input_event(ScanCodeEvent event)
         m_right_shift_pressed = event.pressed;
         update_modifier(Mod_Shift, m_left_shift_pressed || m_right_shift_pressed);
         break;
+    case 0x35:
+    case 0x37:
+    case 0x47:
+    case 0x48:
+    case 0x49:
+    case 0x4a:
+    case 0x4b:
+    case 0x4c:
+    case 0x4d:
+    case 0x4e:
+    case 0x4f:
+    case 0x50:
+    case 0x51:
+    case 0x52:
+    case 0x53:
+        // FIXME: This should also include the keypad "enter" key, but that has the same scan code as the return key (0x1c).
+        update_modifier(Mod_Keypad, event.pressed);
+        break;
     }
 
     KeyCode key = (m_modifiers & Mod_Shift) ? shifted_key_map[event.scan_code_value] : unshifted_key_map[event.scan_code_value];