tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

Keycodes 0xB0-0xDD are not supported #684

Closed tmk closed 3 years ago

tmk commented 3 years ago

Keycodes 0xB0-0xDD(HID usages) including KP_00 and KP_000 are not supported with current firmware.

https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/keycode.h#L357-L402

0xA5-DF and 0xF0-FF are used for special purpose like media and mouse keys. This code range conflicts the HID usages(0xB0-DD). https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/keycode.h#L417-L483

With current implementation ACTION_KEY(0xB0) is translated to KC_MEDIA_PLAY_PAUSE, not KC_KP_00.

This patch changes this behaviour in reverse.

diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index 7ed711a4..e5773ac4 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -27,6 +27,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define IS_ANY(code)             (KC_A         <= (code) && (code) <= 0xFF)

 // Use original HID usages on B0-DD instead of TMK specific codes
+#define USE_ORIGINAL_HID_USAGE
 #ifndef USE_ORIGINAL_HID_USAGE
 #define IS_KEY(code)             (KC_A         <= (code) && (code) <= KC_EXSEL)
 #else

register_code() and unregister_code() need to be changed, perhaps. https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/action.c#L418-L441

Also refer to this. https://deskthority.net/viewtopic.php?p=487067#p487067

tmk commented 3 years ago

I seems that the keycodes 0xB0-0xDD are not supported by Windows and Linux and not useful in fact.

Using the code ranges(0xA5-FF) for TMK internal special purpose would be reasonable and preferable for users. In current implementation, they are actually used as keyocodes of media keys and mouse keys. I'll keep this current implementation and KP_00 and KP_000 are not supported by default.

If you want to send USB HID usage range (0xB0-DD) instead of media/mouse keys define USE_ORIGINAL_HID_USAGE in config.h.

It may be useful to define builtin macro for the 00 and 000 on specific keyboard like IBM 4704 keyboards. https://geekhack.org/index.php?topic=54706.0