mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Refactor conflicting defines
This commit is contained in:
parent
95d133b919
commit
f38a0f6515
2 changed files with 17 additions and 45 deletions
18
hidboot.cpp
18
hidboot.cpp
|
@ -56,7 +56,7 @@ void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
|
||||||
if (prevState.bInfo[0x00] != buf[0x00]) {
|
if (prevState.bInfo[0x00] != buf[0x00]) {
|
||||||
OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]);
|
OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 2; i < 8; i++) {
|
for (uint8_t i = 2; i < 8; i++) {
|
||||||
bool down = false;
|
bool down = false;
|
||||||
bool up = false;
|
bool up = false;
|
||||||
|
@ -82,13 +82,13 @@ uint8_t KeyboardReportParser::HandleLockingKeys(HID *hid, uint8_t key) {
|
||||||
uint8_t old_keys = kbdLockingKeys.bLeds;
|
uint8_t old_keys = kbdLockingKeys.bLeds;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_NUM_LOCK:
|
case UHS_HID_BOOT_KEY_NUM_LOCK:
|
||||||
kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
|
kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
|
||||||
break;
|
break;
|
||||||
case KEY_CAPS_LOCK:
|
case UHS_HID_BOOT_KEY_CAPS_LOCK:
|
||||||
kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
|
kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
|
||||||
break;
|
break;
|
||||||
case KEY_SCROLL_LOCK:
|
case UHS_HID_BOOT_KEY_SCROLL_LOCK:
|
||||||
kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
|
kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,11 @@ uint8_t KeyboardReportParser::OemToAscii(uint8_t mod, uint8_t key) {
|
||||||
return (uint8_t)pgm_read_byte(&padKeys[key - 0x54]);
|
return (uint8_t)pgm_read_byte(&padKeys[key - 0x54]);
|
||||||
else {
|
else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_SPACE: return (0x20);
|
case UHS_HID_BOOT_KEY_SPACE: return (0x20);
|
||||||
case KEY_ENTER: return (0x13);
|
case UHS_HID_BOOT_KEY_ENTER: return (0x13);
|
||||||
case KEY_ZERO: return ((shift) ? ')': '0');
|
case UHS_HID_BOOT_KEY_ZERO: return ((shift) ? ')': '0');
|
||||||
case KEY_ZERO2: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '0': 0);
|
case UHS_HID_BOOT_KEY_ZERO2: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '0': 0);
|
||||||
case KEY_PERIOD: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '.': 0);
|
case UHS_HID_BOOT_KEY_PERIOD: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '.': 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ( 0);
|
return ( 0);
|
||||||
|
|
44
hidboot.h
44
hidboot.h
|
@ -19,42 +19,14 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
|
|
||||||
//
|
#define UHS_HID_BOOT_KEY_ZERO 0x27
|
||||||
// FIX-ME:
|
#define UHS_HID_BOOT_KEY_ENTER 0x28
|
||||||
// Prevent teensy HID collisions.
|
#define UHS_HID_BOOT_KEY_SPACE 0x2c
|
||||||
// These are problematic. Who changes?
|
#define UHS_HID_BOOT_KEY_CAPS_LOCK 0x39
|
||||||
// The best policy for now is to take over these definitions.
|
#define UHS_HID_BOOT_KEY_SCROLL_LOCK 0x47
|
||||||
// This is a classic reason why a library should prefix defines with something unique.
|
#define UHS_HID_BOOT_KEY_NUM_LOCK 0x53
|
||||||
// I suggest prefixing with 'UHS_' for every define in the entire library.
|
#define UHS_HID_BOOT_KEY_ZERO2 0x62
|
||||||
// Yes, this could break things, but what is one to do?
|
#define UHS_HID_BOOT_KEY_PERIOD 0x63
|
||||||
//
|
|
||||||
#ifdef KEY_SPACE
|
|
||||||
#undef KEY_SPACE
|
|
||||||
#endif
|
|
||||||
#ifdef KEY_ENTER
|
|
||||||
#undef KEY_ENTER
|
|
||||||
#endif
|
|
||||||
#ifdef KEY_PERIOD
|
|
||||||
#undef KEY_PERIOD
|
|
||||||
#endif
|
|
||||||
#ifdef KEY_NUM_LOCK
|
|
||||||
#undef KEY_NUM_LOCK
|
|
||||||
#endif
|
|
||||||
#ifdef KEY_CAPS_LOCK
|
|
||||||
#undef KEY_CAPS_LOCK
|
|
||||||
#endif
|
|
||||||
#ifdef KEY_SCROLL_LOCK
|
|
||||||
#undef KEY_SCROLL_LOCK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define KEY_ZERO 0x27
|
|
||||||
#define KEY_ENTER 0x28
|
|
||||||
#define KEY_SPACE 0x2c
|
|
||||||
#define KEY_CAPS_LOCK 0x39
|
|
||||||
#define KEY_SCROLL_LOCK 0x47
|
|
||||||
#define KEY_NUM_LOCK 0x53
|
|
||||||
#define KEY_ZERO2 0x62
|
|
||||||
#define KEY_PERIOD 0x63
|
|
||||||
|
|
||||||
|
|
||||||
struct MOUSEINFO {
|
struct MOUSEINFO {
|
||||||
|
|
Loading…
Reference in a new issue