From 0419d1ab84b221a41cf6831a086ff2dcb4f7252d Mon Sep 17 00:00:00 2001 From: Harry Kantas Date: Mon, 16 Aug 2021 17:24:20 +0000 Subject: [PATCH] Add support for Razer Book 13 (2020) Commit amended for code style by Adam Honse --- 60-openrgb.rules | 1 + .../RazerController/RazerController.cpp | 2 + .../RazerController/RazerControllerDetect.cpp | 1 + Controllers/RazerController/RazerDevices.h | 123 ++++++++++++++++++ 4 files changed, 127 insertions(+) diff --git a/60-openrgb.rules b/60-openrgb.rules index c4614691b..add3af48d 100644 --- a/60-openrgb.rules +++ b/60-openrgb.rules @@ -531,6 +531,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="0245", TAG+="uacces SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="024D", TAG+="uaccess" SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="0253", TAG+="uaccess" SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="0255", TAG+="uaccess" +SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="026A", TAG+="uaccess" # Razer Book 13 (2020) SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="026F", TAG+="uaccess" SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="0210", TAG+="uaccess" SUBSYSTEMS=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="0225", TAG+="uaccess" diff --git a/Controllers/RazerController/RazerController.cpp b/Controllers/RazerController/RazerController.cpp index 7c9837123..d87a607f9 100644 --- a/Controllers/RazerController/RazerController.cpp +++ b/Controllers/RazerController/RazerController.cpp @@ -164,6 +164,7 @@ RazerController::RazerController(hid_device* dev_handle, hid_device* dev_argb_ha case RAZER_BLADE_STEALTH_LATE_2019_PID: case RAZER_BLADE_STEALTH_2020_PID: case RAZER_BLADE_STEALTH_LATE_2020_PID: + case RAZER_BOOK_13_2020_PID: case RAZER_NAGA_HEX_V2_PID: matrix_type = RAZER_MATRIX_TYPE_STANDARD; break; @@ -437,6 +438,7 @@ bool RazerController::SupportsWave() case RAZER_BLADE_STEALTH_LATE_2016_PID: case RAZER_BLADE_STEALTH_2017_PID: case RAZER_BLADE_STEALTH_LATE_2017_PID: + case RAZER_BOOK_13_2020_PID: case RAZER_CYNOSA_CHROMA_PID: case RAZER_CYNOSA_V2_PID: case RAZER_DEATHSTALKER_CHROMA_PID: diff --git a/Controllers/RazerController/RazerControllerDetect.cpp b/Controllers/RazerController/RazerControllerDetect.cpp index a5365b8e9..755215029 100644 --- a/Controllers/RazerController/RazerControllerDetect.cpp +++ b/Controllers/RazerController/RazerControllerDetect.cpp @@ -251,6 +251,7 @@ REGISTER_HID_DETECTOR_IPU("Razer Blade Stealth (2019)", Det REGISTER_HID_DETECTOR_IPU("Razer Blade Stealth (Late 2019)", DetectRazerControllers, RAZER_VID, RAZER_BLADE_STEALTH_LATE_2019_PID, 0x00, 0x01, 0x02); REGISTER_HID_DETECTOR_IPU("Razer Blade Stealth (2020)", DetectRazerControllers, RAZER_VID, RAZER_BLADE_STEALTH_2020_PID, 0x00, 0x01, 0x02); REGISTER_HID_DETECTOR_IPU("Razer Blade Stealth (Late 2020)", DetectRazerControllers, RAZER_VID, RAZER_BLADE_STEALTH_LATE_2020_PID, 0x00, 0x01, 0x02); +REGISTER_HID_DETECTOR_IPU("Razer Book 13 (2020)", DetectRazerControllers, RAZER_VID, RAZER_BOOK_13_2020_PID, 0x00, 0x01, 0x02); /*-----------------------------------------------------------------------------------------------------*\ | Mice | diff --git a/Controllers/RazerController/RazerDevices.h b/Controllers/RazerController/RazerDevices.h index c1d5acefc..9eb083d0f 100644 --- a/Controllers/RazerController/RazerDevices.h +++ b/Controllers/RazerController/RazerDevices.h @@ -55,6 +55,7 @@ #define RAZER_BLADE_STEALTH_2020_PID 0x0252 #define RAZER_BLADE_STEALTH_LATE_2020_PID 0x0259 +#define RAZER_BOOK_13_2020_PID 0x026A #define RAZER_CYNOSA_CHROMA_PID 0x022A #define RAZER_CYNOSA_LITE_PID 0x023F @@ -415,6 +416,93 @@ static const razer_key blackwidow_chroma_te_keymap[] = { 0, 5, 17, "Key: Right Arrow" }, }; +#define BOOK_13_2020_KEYMAP_SIZE (sizeof(book_13_2020_keymap) / sizeof(book_13_2020_keymap[0])) + +static const razer_key book_13_2020_keymap[] = +{ + /*---------------------------------------------------------------------*\ + | Zone, Row, Column, Key | + \*---------------------------------------------------------------------*/ + { 0, 0, 1, "Key: Escape" }, + { 0, 0, 2, "Key: F1" }, + { 0, 0, 3, "Key: F2" }, + { 0, 0, 4, "Key: F3" }, + { 0, 0, 5, "Key: F4" }, + { 0, 0, 6, "Key: F5" }, + { 0, 0, 7, "Key: F6" }, + { 0, 0, 8, "Key: F7" }, + { 0, 0, 9, "Key: F8" }, + { 0, 0, 10, "Key: F9" }, + { 0, 0, 11, "Key: F10" }, + { 0, 0, 12, "Key: F11" }, + { 0, 0, 13, "Key: F12" }, + { 0, 0, 14, "Key: Delete" }, + { 0, 0, 15, "Key: Power" }, + { 0, 1, 1, "Key: `" }, + { 0, 1, 2, "Key: 1" }, + { 0, 1, 3, "Key: 2" }, + { 0, 1, 4, "Key: 3" }, + { 0, 1, 5, "Key: 4" }, + { 0, 1, 6, "Key: 5" }, + { 0, 1, 7, "Key: 6" }, + { 0, 1, 8, "Key: 7" }, + { 0, 1, 9, "Key: 8" }, + { 0, 1, 10, "Key: 9" }, + { 0, 1, 11, "Key: 0" }, + { 0, 1, 12, "Key: -" }, + { 0, 1, 13, "Key: =" }, + { 0, 1, 15, "Key: Backspace" }, + { 0, 2, 1, "Key: Tab" }, + { 0, 2, 2, "Key: Q" }, + { 0, 2, 3, "Key: W" }, + { 0, 2, 4, "Key: E" }, + { 0, 2, 5, "Key: R" }, + { 0, 2, 6, "Key: T" }, + { 0, 2, 7, "Key: Y" }, + { 0, 2, 8, "Key: U" }, + { 0, 2, 9, "Key: I" }, + { 0, 2, 10, "Key: O" }, + { 0, 2, 11, "Key: P" }, + { 0, 2, 12, "Key: [" }, + { 0, 2, 13, "Key: ]" }, + { 0, 2, 15, "Key: \\ (ANSI)" }, + { 0, 3, 1, "Key: Caps Lock" }, + { 0, 3, 2, "Key: A" }, + { 0, 3, 3, "Key: S" }, + { 0, 3, 4, "Key: D" }, + { 0, 3, 5, "Key: F" }, + { 0, 3, 6, "Key: G" }, + { 0, 3, 7, "Key: H" }, + { 0, 3, 8, "Key: J" }, + { 0, 3, 9, "Key: K" }, + { 0, 3, 10, "Key: L" }, + { 0, 3, 11, "Key: ;" }, + { 0, 3, 12, "Key: '" }, + { 0, 3, 15, "Key: Enter" }, + { 0, 4, 1, "Key: Left Shift" }, + { 0, 4, 3, "Key: Z" }, + { 0, 4, 4, "Key: X" }, + { 0, 4, 5, "Key: C" }, + { 0, 4, 6, "Key: V" }, + { 0, 4, 7, "Key: B" }, + { 0, 4, 8, "Key: N" }, + { 0, 4, 9, "Key: M" }, + { 0, 4, 10, "Key: ," }, + { 0, 4, 11, "Key: ." }, + { 0, 4, 12, "Key: /" }, + { 0, 4, 15, "Key: Right Shift" }, + { 0, 5, 1, "Key: Left Control" }, + { 0, 5, 2, "Key: Left Fn" }, + { 0, 5, 3, "Key: Left Windows" }, + { 0, 5, 5, "Key: Left Alt" }, + { 0, 5, 9, "Key: Right Alt" }, + { 0, 5, 11, "Key: Right Control" }, + { 0, 5, 12, "Key: Left Arrow" }, + { 0, 5, 13, "Key: Up Arrow" }, + { 0, 5, 14, "Key: Right Arrow" }, + { 0, 5, 15, "Key: Down Arrow" }, +}; + #define BLADE_14_2021_KEYMAP_SIZE (sizeof(blade_14_2021_keymap) / sizeof(blade_14_2021_keymap[0])) static const razer_key blade_14_2021_keymap[] = @@ -2823,6 +2911,41 @@ static const razer_device blade_14_2021_device = BLADE_14_2021_KEYMAP_SIZE }; +/*-------------------------------------------------------------*\ +| Razer Book 13 (2020) | +| | +| Zone "Keyboard" | +| Matrix | +| 6 Rows, 16 Columns | +\*-------------------------------------------------------------*/ +static const razer_zone book_13_2020_zone = +{ + "Keyboard", + ZONE_TYPE_MATRIX, + 6, + 16 +}; + +static const razer_device book_13_2020_device = +{ + "Razer Book 13 (2020)", + RAZER_BOOK_13_2020_PID, + DEVICE_TYPE_KEYBOARD, + true, + 6, + 16, + { + &book_13_2020_zone, + NULL, + NULL, + NULL, + NULL, + NULL + }, + book_13_2020_keymap, + BOOK_13_2020_KEYMAP_SIZE +}; + /*-------------------------------------------------------------*\ | Razer Blade Pro (2016) | | |