diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-22 23:07:17 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-22 23:07:17 +0200 |
commit | efbee96caa1452486a007eeeabb5073aa9025dae (patch) | |
tree | d048e38bd9749a6db3d1b47caa305d8d84b370ab /src/common.h | |
parent | 2e5e4955337dccc370ed72d0f4fc561abadf84f4 (diff) | |
download | uxngba-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.h | 16 |
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. |
303 | static inline u32 | 303 | static inline u32 |
304 | key_pressed(u32 key) { | 304 | key_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. | ||
309 | static inline u32 | ||
310 | key_pressed(u32 key) { | ||
311 | return (key_curr & key); | ||
312 | } | ||
313 | |||
314 | // Check if a given key was just released. | ||
315 | static inline u32 | ||
316 | key_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. |
309 | static inline u32 | 321 | static inline u32 |
310 | key_hold(u32 key) { | 322 | key_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. |