aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-22 23:07:17 +0200
committerBad Diode <bd@badd10de.dev>2021-05-22 23:07:17 +0200
commitefbee96caa1452486a007eeeabb5073aa9025dae (patch)
treed048e38bd9749a6db3d1b47caa305d8d84b370ab /src/common.h
parent2e5e4955337dccc370ed72d0f4fc561abadf84f4 (diff)
downloaduxngba-efbee96caa1452486a007eeeabb5073aa9025dae.tar.gz
uxngba-efbee96caa1452486a007eeeabb5073aa9025dae.zip
Update mouse control code to use key taps instead of press
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common.h b/src/common.h
index e293770..08736ea 100644
--- a/src/common.h
+++ b/src/common.h
@@ -301,14 +301,26 @@ poll_keys(void) {
301// function will return `true` only on the frame where the key initially 301// function will return `true` only on the frame where the key initially
302// activated. 302// activated.
303static inline u32 303static inline u32
304key_pressed(u32 key) { 304key_tap(u32 key) {
305 return (key_curr & key) & ~(key_prev & key); 305 return (key_curr & key) & ~(key_prev & key);
306} 306}
307 307
308// Check if a given key is currently pressed.
309static inline u32
310key_pressed(u32 key) {
311 return (key_curr & key);
312}
313
314// Check if a given key was just released.
315static inline u32
316key_released(u32 key) {
317 return ~(key_curr & key) & (key_prev & key);
318}
319
308// Check if the given key is pressed and has been since at least one frame. 320// Check if the given key is pressed and has been since at least one frame.
309static inline u32 321static inline u32
310key_hold(u32 key) { 322key_hold(u32 key) {
311 return (key_curr & key) & key_prev & key; 323 return key_curr & key_prev & key;
312} 324}
313 325
314// Check if the given key/button is currently pressed. 326// Check if the given key/button is currently pressed.