Skip to content

Commit b5625db

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
Input: Add event-codes for macro keys found on various keyboards
Various keyboards have macro keys, which are intended to have user programmable actions / key-sequences bound to them. In some cases these macro keys are actually programmable in hardware, but more often they basically are just extra keys and the playback of the key-sequence is done by software running on the host. One example of keyboards with macro-keys are various "internet" / "office" keyboards have a set of so-called "Smart Keys", typically a set of 4 keys labeled "[A]" - "[D]". Another example are gaming keyboards, such as the Logitech G15 Gaming keyboard, which has 18 "G"aming keys labeled "G1" to G18", 3 keys to select macro presets labeled "M1" - "M3" and a key to start recording a macro called "MR" note that even though there us a record key everything is handled in sw on the host. Besides macro keys the G15 (and other gaming keyboards) also has a buildin LCD panel where the contents are controlled by the host. There are 5 keys directly below the LCD intended for controlling a menu shown on the LCD. The Microsoft SideWinder X6 keyboard is another gaming keyboard example, this keyboard has 30 "S"idewinder keys and a key to cycle through macro-presets. After discussion between various involved userspace people we've come to the conclusion that since these are all really just extra keys we should simply treat them as such and give them their own event-codes, see: libratbag/libratbag#172 This commit adds the following new KEY_ defines for this: KEY_MACRO1 - KEY_MACRO30. KEY_MACRO_RECORD_START/-STOP, KEY_MACRO_PRESET_CYCLE, KEY_MACRO_PRESET1 - KEY_MACRO_PRESET3, KEY_KBD_LCD_MENU1 - KEY_KBD_LCD_MENU5. The defines leave room for adding some more LCD-menu, preset or macro keys, the maximum values above are based on the maximum values to support all currently known internet, office and gaming keyboards. BugLink: libratbag/libratbag#172 Signed-off-by: Hans de Goede <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 1ad0bc7 commit b5625db

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

include/uapi/linux/input-event-codes.h

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,81 @@
650650
#define KEY_DATA 0x277
651651
#define KEY_ONSCREEN_KEYBOARD 0x278
652652

653+
/*
654+
* Some keyboards have keys which do not have a defined meaning, these keys
655+
* are intended to be programmed / bound to macros by the user. For most
656+
* keyboards with these macro-keys the key-sequence to inject, or action to
657+
* take, is all handled by software on the host side. So from the kernel's
658+
* point of view these are just normal keys.
659+
*
660+
* The KEY_MACRO# codes below are intended for such keys, which may be labeled
661+
* e.g. G1-G18, or S1 - S30. The KEY_MACRO# codes MUST NOT be used for keys
662+
* where the marking on the key does indicate a defined meaning / purpose.
663+
*
664+
* The KEY_MACRO# codes MUST also NOT be used as fallback for when no existing
665+
* KEY_FOO define matches the marking / purpose. In this case a new KEY_FOO
666+
* define MUST be added.
667+
*/
668+
#define KEY_MACRO1 0x290
669+
#define KEY_MACRO2 0x291
670+
#define KEY_MACRO3 0x292
671+
#define KEY_MACRO4 0x293
672+
#define KEY_MACRO5 0x294
673+
#define KEY_MACRO6 0x295
674+
#define KEY_MACRO7 0x296
675+
#define KEY_MACRO8 0x297
676+
#define KEY_MACRO9 0x298
677+
#define KEY_MACRO10 0x299
678+
#define KEY_MACRO11 0x29a
679+
#define KEY_MACRO12 0x29b
680+
#define KEY_MACRO13 0x29c
681+
#define KEY_MACRO14 0x29d
682+
#define KEY_MACRO15 0x29e
683+
#define KEY_MACRO16 0x29f
684+
#define KEY_MACRO17 0x2a0
685+
#define KEY_MACRO18 0x2a1
686+
#define KEY_MACRO19 0x2a2
687+
#define KEY_MACRO20 0x2a3
688+
#define KEY_MACRO21 0x2a4
689+
#define KEY_MACRO22 0x2a5
690+
#define KEY_MACRO23 0x2a6
691+
#define KEY_MACRO24 0x2a7
692+
#define KEY_MACRO25 0x2a8
693+
#define KEY_MACRO26 0x2a9
694+
#define KEY_MACRO27 0x2aa
695+
#define KEY_MACRO28 0x2ab
696+
#define KEY_MACRO29 0x2ac
697+
#define KEY_MACRO30 0x2ad
698+
699+
/*
700+
* Some keyboards with the macro-keys described above have some extra keys
701+
* for controlling the host-side software responsible for the macro handling:
702+
* -A macro recording start/stop key. Note that not all keyboards which emit
703+
* KEY_MACRO_RECORD_START will also emit KEY_MACRO_RECORD_STOP if
704+
* KEY_MACRO_RECORD_STOP is not advertised, then KEY_MACRO_RECORD_START
705+
* should be interpreted as a recording start/stop toggle;
706+
* -Keys for switching between different macro (pre)sets, either a key for
707+
* cycling through the configured presets or keys to directly select a preset.
708+
*/
709+
#define KEY_MACRO_RECORD_START 0x2b0
710+
#define KEY_MACRO_RECORD_STOP 0x2b1
711+
#define KEY_MACRO_PRESET_CYCLE 0x2b2
712+
#define KEY_MACRO_PRESET1 0x2b3
713+
#define KEY_MACRO_PRESET2 0x2b4
714+
#define KEY_MACRO_PRESET3 0x2b5
715+
716+
/*
717+
* Some keyboards have a buildin LCD panel where the contents are controlled
718+
* by the host. Often these have a number of keys directly below the LCD
719+
* intended for controlling a menu shown on the LCD. These keys often don't
720+
* have any labeling so we just name them KEY_KBD_LCD_MENU#
721+
*/
722+
#define KEY_KBD_LCD_MENU1 0x2b8
723+
#define KEY_KBD_LCD_MENU2 0x2b9
724+
#define KEY_KBD_LCD_MENU3 0x2ba
725+
#define KEY_KBD_LCD_MENU4 0x2bb
726+
#define KEY_KBD_LCD_MENU5 0x2bc
727+
653728
#define BTN_TRIGGER_HAPPY 0x2c0
654729
#define BTN_TRIGGER_HAPPY1 0x2c0
655730
#define BTN_TRIGGER_HAPPY2 0x2c1

0 commit comments

Comments
 (0)