From: tmk Date: Mon, 11 May 2020 12:51:41 +0000 (+0900) Subject: core: Add HID usage for Display Brightness Control X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=dd316b990f4523c49a0d1eef677cee67318d123d;p=max%2Ftmk_keyboard.git core: Add HID usage for Display Brightness Control --- diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 5a6f3df3..85a0631f 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -1,5 +1,5 @@ /* -Copyright 2012,2013 Jun Wako +Copyright 2012,2013,2020 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tmk_core/common/actionmap.h b/tmk_core/common/actionmap.h index ca643e82..c8f9c38d 100644 --- a/tmk_core/common/actionmap.h +++ b/tmk_core/common/actionmap.h @@ -1,5 +1,5 @@ /* -Copyright 2015 Jun Wako +Copyright 2015,2020 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -283,6 +283,8 @@ along with this program. If not, see . #define AC_WWW_STOP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) #define AC_WWW_REFRESH ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) #define AC_WWW_FAVORITES ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) +#define AC_BRIGHTNESS_INC ACTION_USAGE_CONSUMER(BRIGHTNESS_INCREMENT) +#define AC_BRIGHTNESS_DEC ACTION_USAGE_CONSUMER(BRIGHTNESS_DECREMENT) /* Mousekey */ #define AC_MS_UP ACTION_MOUSEKEY(KC_MS_UP) @@ -417,6 +419,8 @@ along with this program. If not, see . #define AC_WSTP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) #define AC_WREF ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) #define AC_WFAV ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) +#define AC_BRTI ACTION_USAGE_CONSUMER(BRIGHTNESS_INCREMENT) +#define AC_BRTD ACTION_USAGE_CONSUMER(BRIGHTNESS_DECREMENT) /* Transparent */ #define AC_TRNS ACTION_KEY(KC_TRANSPARENT) diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index acbe5c32..534f52d5 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -1,5 +1,5 @@ /* -Copyright 2011,2012 Jun Wako +Copyright 2011,2012,2020 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ along with this program. If not, see . #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) -#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) +#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_BRIGHTNESS_DEC) #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) #define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) #define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT) @@ -174,6 +174,8 @@ along with this program. If not, see . #define KC_WSTP KC_WWW_STOP #define KC_WREF KC_WWW_REFRESH #define KC_WFAV KC_WWW_FAVORITES +#define KC_BRTI KC_BRIGHTNESS_INC +#define KC_BRTD KC_BRIGHTNESS_DEC /* Jump to bootloader */ #define KC_BTLD KC_BOOTLOADER /* Transparent */ @@ -438,7 +440,9 @@ enum internal_special_keycodes { KC_WWW_FORWARD, KC_WWW_STOP, KC_WWW_REFRESH, - KC_WWW_FAVORITES, /* 0xBC */ + KC_WWW_FAVORITES, + KC_BRIGHTNESS_INC, + KC_BRIGHTNESS_DEC, /* 0xBE */ /* Jump to bootloader */ KC_BOOTLOADER = 0xBF, diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 80ad388e..617a1f70 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -1,5 +1,5 @@ /* -Copyright 2013,2016 Jun Wako +Copyright 2013,2016,2020 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -145,7 +145,7 @@ static action_t keycode_to_action(uint8_t keycode) case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: return (action_t)ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; - case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: + case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DEC: return (action_t)ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 2a2ff2de..fde57776 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -1,5 +1,5 @@ /* -Copyright 2011,2012 Jun Wako +Copyright 2011,2012,2020 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,8 +37,15 @@ along with this program. If not, see . #define MOUSE_BTN7 (1<<6) #define MOUSE_BTN8 (1<<7) -/* Consumer Page(0x0C) - * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx + +/* + * USB HID Specifications + * https://www.usb.org/hid#approved-usage-table-review-requests + */ + +/* + * Consumer Page(0x0C) + * https://github.com/tmk/tmk_keyboard/issues/370 */ #define AUDIO_MUTE 0x00E2 #define AUDIO_VOL_UP 0x00E9 @@ -68,8 +75,13 @@ along with this program. If not, see . #define TRANSPORT_REWIND 0x00B4 #define TRANSPORT_EJECT 0x00B8 #define APPCONTROL_MINIMIZE 0x0206 +/* Display Brightness Controls https://www.usb.org/sites/default/files/hutrr41_0.pdf */ +#define BRIGHTNESS_INCREMENT 0x006F +#define BRIGHTNESS_DECREMENT 0x0070 -/* Generic Desktop Page(0x01) - system power control */ +/* + * Generic Desktop Page(0x01) - system power control + */ #define SYSTEM_POWER_DOWN 0x0081 #define SYSTEM_SLEEP 0x0082 #define SYSTEM_WAKE_UP 0x0083 @@ -182,7 +194,9 @@ typedef struct { (key == KC_WWW_FORWARD ? APPCONTROL_FORWARD : \ (key == KC_WWW_STOP ? APPCONTROL_STOP : \ (key == KC_WWW_REFRESH ? APPCONTROL_REFRESH : \ - (key == KC_WWW_FAVORITES ? APPCONTROL_BOOKMARKS : 0))))))))))))))))))))) + (key == KC_WWW_FAVORITES ? APPCONTROL_BOOKMARKS : \ + (key == KC_BRIGHTNESS_INC ? BRIGHTNESS_INCREMENT : \ + (key == KC_BRIGHTNESS_DEC ? BRIGHTNESS_DECREMENT : 0))))))))))))))))))))))) #ifdef __cplusplus }