|
@@ -149,6 +149,119 @@ void keyboard_modifying_key_set(uint8_t key) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//Set a specific numpad key value
|
|
|
|
+void numpad_key_set(bool isPress, uint8_t value) {
|
|
|
|
+ if (isPress) {
|
|
|
|
+ switch (value) {
|
|
|
|
+ case PAYLOAD_NUMPAD_0:
|
|
|
|
+ Keyboard_press('\352'); //0
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_1:
|
|
|
|
+ Keyboard_press('\341'); //1
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_2:
|
|
|
|
+ Keyboard_press('\342'); //2
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_3:
|
|
|
|
+ Keyboard_press('\343'); //3
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_4:
|
|
|
|
+ Keyboard_press('\344'); //4
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_5:
|
|
|
|
+ Keyboard_press('\345'); //5
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_6:
|
|
|
|
+ Keyboard_press('\346'); //6
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_7:
|
|
|
|
+ Keyboard_press('\347'); //7
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_8:
|
|
|
|
+ Keyboard_press('\350'); //8
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_9:
|
|
|
|
+ Keyboard_press('\351'); //9
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_DOT:
|
|
|
|
+ Keyboard_press('\353'); //.
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_TIMES:
|
|
|
|
+ Keyboard_press('\335'); //*
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_DIV:
|
|
|
|
+ Keyboard_press('\334'); // /
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_PLUS:
|
|
|
|
+ Keyboard_press('\337'); // +
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_MINUS:
|
|
|
|
+ Keyboard_press('\336'); // -
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_ENTER:
|
|
|
|
+ Keyboard_press('\340'); // Enter
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_NUMLOCK:
|
|
|
|
+ Keyboard_press('\333'); // NumLock
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ switch (value) {
|
|
|
|
+ case PAYLOAD_NUMPAD_0:
|
|
|
|
+ Keyboard_release('\352'); //0
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_1:
|
|
|
|
+ Keyboard_release('\341'); //1
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_2:
|
|
|
|
+ Keyboard_release('\342'); //2
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_3:
|
|
|
|
+ Keyboard_release('\343'); //3
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_4:
|
|
|
|
+ Keyboard_release('\344'); //4
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_5:
|
|
|
|
+ Keyboard_release('\345'); //5
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_6:
|
|
|
|
+ Keyboard_release('\346'); //6
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_7:
|
|
|
|
+ Keyboard_release('\347'); //7
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_8:
|
|
|
|
+ Keyboard_release('\350'); //8
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_9:
|
|
|
|
+ Keyboard_release('\351'); //9
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_DOT:
|
|
|
|
+ Keyboard_release('\353'); //.
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_TIMES:
|
|
|
|
+ Keyboard_release('\335'); //*
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_DIV:
|
|
|
|
+ Keyboard_release('\334'); // /
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_PLUS:
|
|
|
|
+ Keyboard_release('\337'); // +
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_MINUS:
|
|
|
|
+ Keyboard_release('\336'); // -
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_ENTER:
|
|
|
|
+ Keyboard_release('\340'); // Enter
|
|
|
|
+ return;
|
|
|
|
+ case PAYLOAD_NUMPAD_NUMLOCK:
|
|
|
|
+ Keyboard_release('\333'); // NumLock
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
//Entry point for keyboard emulation
|
|
//Entry point for keyboard emulation
|
|
uint8_t keyboard_emulation(uint8_t subtype, uint8_t value) {
|
|
uint8_t keyboard_emulation(uint8_t subtype, uint8_t value) {
|
|
//Check if the input is a supported ascii value
|
|
//Check if the input is a supported ascii value
|
|
@@ -175,10 +288,15 @@ uint8_t keyboard_emulation(uint8_t subtype, uint8_t value) {
|
|
case SUBTYPE_KEYBOARD_MODIFIER_CLEAR:
|
|
case SUBTYPE_KEYBOARD_MODIFIER_CLEAR:
|
|
keyboard_modifying_key_set(0x00);
|
|
keyboard_modifying_key_set(0x00);
|
|
return resp_ok;
|
|
return resp_ok;
|
|
- case SUBTYPE_KEYBOARD_FUNCTKEY_WRITE:
|
|
|
|
|
|
+ case SUBTYPE_KEYBOARD_FUNCTKEY_PRESS:
|
|
if (!is_funckey(value))
|
|
if (!is_funckey(value))
|
|
return resp_invalid_key_value;
|
|
return resp_invalid_key_value;
|
|
- Keyboard_write(value);
|
|
|
|
|
|
+ Keyboard_press(value);
|
|
|
|
+ return resp_ok;
|
|
|
|
+ case SUBTYPE_KEYBOARD_FUNCTKEY_RELEASE:
|
|
|
|
+ if (!is_funckey(value))
|
|
|
|
+ return resp_invalid_key_value;
|
|
|
|
+ Keyboard_release(value);
|
|
return resp_ok;
|
|
return resp_ok;
|
|
case SUBTYPE_KEYBOARD_OTHERKEY_PRESS:
|
|
case SUBTYPE_KEYBOARD_OTHERKEY_PRESS:
|
|
if (!is_validkeys(value))
|
|
if (!is_validkeys(value))
|
|
@@ -190,13 +308,22 @@ uint8_t keyboard_emulation(uint8_t subtype, uint8_t value) {
|
|
return resp_invalid_key_value;
|
|
return resp_invalid_key_value;
|
|
Keyboard_release(value);
|
|
Keyboard_release(value);
|
|
return resp_ok;
|
|
return resp_ok;
|
|
|
|
+ case SUBTYPE_KEYBOARD_NUMPAD_PRESS:
|
|
|
|
+ if (value > PAYLOAD_NUMPAD_NUMLOCK)
|
|
|
|
+ return resp_invalid_key_value;
|
|
|
|
+ numpad_key_set(true, value);
|
|
|
|
+ return resp_ok;
|
|
|
|
+ case SUBTYPE_KEYBOARD_NUMPAD_RELEASE:
|
|
|
|
+ if (value > PAYLOAD_NUMPAD_NUMLOCK)
|
|
|
|
+ return resp_invalid_key_value;
|
|
|
|
+ numpad_key_set(false, value);
|
|
|
|
+ return resp_ok;
|
|
case SUBTYPE_KEYBOARD_SPECIAL_CTRLALTDEL:
|
|
case SUBTYPE_KEYBOARD_SPECIAL_CTRLALTDEL:
|
|
// Press Ctrl + Alt + Del
|
|
// Press Ctrl + Alt + Del
|
|
Keyboard_press(KEY_LEFT_CTRL);
|
|
Keyboard_press(KEY_LEFT_CTRL);
|
|
Keyboard_press(KEY_LEFT_ALT);
|
|
Keyboard_press(KEY_LEFT_ALT);
|
|
Keyboard_press(KEY_DELETE);
|
|
Keyboard_press(KEY_DELETE);
|
|
delay(100); // Give a little longer time for all keys to be registered together
|
|
delay(100); // Give a little longer time for all keys to be registered together
|
|
-
|
|
|
|
// Release Ctrl + Alt + Del in reverse order
|
|
// Release Ctrl + Alt + Del in reverse order
|
|
Keyboard_release(KEY_DELETE);
|
|
Keyboard_release(KEY_DELETE);
|
|
delay(MIN_KEY_EVENTS_DELAY);
|
|
delay(MIN_KEY_EVENTS_DELAY);
|