commit 9adfe2dfb7a441afdc9b0886cf89cdb6d57c9eec
parent 137b27400dcb4e3d503eaa1199db3023f1213b2d
Author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
Date: Wed, 5 Oct 2022 19:59:32 +0200
keyboard-fw: bind Hyper+F1/F2 to display brightness decrement/increment
Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
Diffstat:
5 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/reform2-keyboard-fw/descriptors.c b/reform2-keyboard-fw/descriptors.c
@@ -40,8 +40,8 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MediaControlReport[] =
HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer Page */
HID_RI_USAGE(8, 0x01), /* Consumer Controls */
HID_RI_COLLECTION(8, 0x01), /* Application */
- HID_RI_USAGE(8, 0xB0), /* Play */
- HID_RI_USAGE(8, 0xB1), /* Pause */
+ HID_RI_USAGE(8, 0x70), /* Display Brightness Increment */
+ HID_RI_USAGE(8, 0x6F), /* Display Brightness Decrement */
HID_RI_USAGE(8, 0xB3), /* Fast Forward */
HID_RI_USAGE(8, 0xB4), /* Rewind */
HID_RI_USAGE(8, 0xB5), /* Next Track */
diff --git a/reform2-keyboard-fw/keyboard.c b/reform2-keyboard-fw/keyboard.c
@@ -122,6 +122,12 @@ bool get_media_keys(uint8_t keycode, USB_MediaReport_Data_t* mcr) {
} else if (keycode == HID_KEYBOARD_SC_MEDIA_PLAY) {
if (mcr) mcr->PlayPause = 1;
media_key = true;
+ } else if (keycode == HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_DOWN) {
+ if (mcr) mcr->BrightnessDown = 1;
+ media_key = true;
+ } else if (keycode == HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_UP) {
+ if (mcr) mcr->BrightnessUp = 1;
+ media_key = true;
}
return media_key;
}
diff --git a/reform2-keyboard-fw/keyboard.h b/reform2-keyboard-fw/keyboard.h
@@ -25,6 +25,10 @@
#define set_input(portdir,pin) portdir &= ~(1<<pin)
#define set_output(portdir,pin) portdir |= (1<<pin)
+// Reuse existing key codes
+#define HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_DOWN HID_KEYBOARD_SC_MEDIA_RELOAD
+#define HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_UP HID_KEYBOARD_SC_MEDIA_CALCULATOR
+
// Top row, left to right
#define MATRIX_DEFAULT_ROW_1 \
KEY_ESCAPE,\
@@ -128,8 +132,8 @@
// MediaController USB Report
typedef struct
{
- unsigned Play : 1;
- unsigned Pause : 1;
+ unsigned BrightnessUp : 1;
+ unsigned BrightnessDown : 1;
unsigned FForward : 1;
unsigned Rewind : 1;
unsigned NextTrack : 1;
diff --git a/reform2-keyboard-fw/matrix.h b/reform2-keyboard-fw/matrix.h
@@ -24,8 +24,8 @@ uint8_t matrix[KBD_MATRIX_SZ] = {
uint8_t matrix_fn[KBD_MATRIX_SZ] = {
// Media keys on Hyper + F7-F12
KEY_ESCAPE,
- KEY_F1,
- KEY_F2,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_DOWN,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_UP,
KEY_F3,
KEY_F4,
KEY_F5,
@@ -49,8 +49,8 @@ uint8_t matrix_fn[KBD_MATRIX_SZ] = {
uint8_t matrix_fn_toggled[KBD_MATRIX_SZ] = {
// Custom top row
KEY_ESCAPE,
- KEY_F1,
- KEY_F2,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_DOWN,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_UP,
KEY_F3,
KEY_F4,
KEY_F5,
diff --git a/reform2-keyboard-fw/matrix_v.h b/reform2-keyboard-fw/matrix_v.h
@@ -37,8 +37,8 @@ uint8_t matrix[KBD_MATRIX_SZ] = {
uint8_t matrix_fn[KBD_MATRIX_SZ] = {
// Custom top row
KEY_ESCAPE,
- KEY_F1,
- KEY_F2,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_DOWN,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_UP,
KEY_F3,
KEY_F4,
KEY_F5,
@@ -90,8 +90,8 @@ uint8_t matrix_fn[KBD_MATRIX_SZ] = {
uint8_t matrix_fn_toggled[KBD_MATRIX_SZ] = {
// Custom top row
KEY_ESCAPE,
- KEY_F1,
- KEY_F2,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_DOWN,
+ HID_KEYBOARD_SC_MEDIA_BRIGHTNESS_UP,
KEY_F3,
KEY_F4,
KEY_F5,