refactor out "press a key" functions

pull/18/head
Jesse Vincent 10 years ago
parent 79c5a698b6
commit b6e9aba9cd

@ -71,7 +71,8 @@ void handle_synthetic_key_press(byte switchState, Key mappedKey);
void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y); void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y);
void send_key_events(); void send_key_events();
void press_key(Key mappedKey);
void release_key(Key mappedKey);

@ -694,10 +694,10 @@ void send_key_events()
if (key_is_pressed(switchState)) { if (key_is_pressed(switchState)) {
record_key_being_pressed(mappedKey.rawKey); record_key_being_pressed(mappedKey.rawKey);
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
Keyboard.press(mappedKey.rawKey); press_key(mappedKey);
} }
} else if (key_toggled_off (switchState)) { } else if (key_toggled_off (switchState)) {
Keyboard.release(mappedKey.rawKey); release_key(mappedKey);
} }
} }
} }
@ -707,6 +707,14 @@ void send_key_events()
release_keys_not_being_pressed(); release_keys_not_being_pressed();
} }
void press_key(Key mappedKey) {
Keyboard.press(mappedKey.rawKey);
}
void release_key(Key mappedKey){
Keyboard.release(mappedKey.rawKey);
}
// Hardware initialization // Hardware initialization
void setup_pins() void setup_pins()

Loading…
Cancel
Save