Kaleidoscope
keyswitch_state.h
Go to the documentation of this file.
1 #pragma once
2 // switch debouncing and status
3 
4 #include <Arduino.h>
5 
6 #define INJECTED B10000000
7 #define IS_PRESSED B00000010
8 #define WAS_PRESSED B00000001
9 
10 #define keyWasPressed(keyState) ((keyState) & WAS_PRESSED)
11 #define keyIsPressed(keyState) ((keyState) & IS_PRESSED)
12 #define keyToggledOn(keyState) (keyIsPressed(keyState) && ! keyWasPressed(keyState))
13 #define keyToggledOff(keyState) (keyWasPressed(keyState) && ! keyIsPressed(keyState))
14 
15 
16 // Deprecated - Remove once the core has transitioned
17 
18 #define key_was_pressed(keyState) ((keyState) & WAS_PRESSED)
19 #define key_is_pressed(keyState) ((keyState) & IS_PRESSED)
20 #define key_toggled_on(keyState) (key_is_pressed(keyState) && ! key_was_pressed(keyState))
21 #define key_toggled_off(keyState) (key_was_pressed(keyState) && ! key_is_pressed(keyState))