From cf856752dd64c473a2bc5467b67686f697e78b5c Mon Sep 17 00:00:00 2001 From: Karl Fleischmann Date: Wed, 20 May 2026 16:30:40 +0200 Subject: [PATCH] daemon: Clarify byte/bit iteration in is_wheel_keybit() This commit renames the variables in is_wheel_keybit() to match the ones used in inputupdate_keys() (and also make more sense). --- src/daemon/input.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/daemon/input.c b/src/daemon/input.c index b48768bb..1fc8cc66 100644 --- a/src/daemon/input.c +++ b/src/daemon/input.c @@ -229,16 +229,17 @@ static void* play_macro(void* param) { // Checks if the macro mask contains any wheels to prevent it from looping endlessly static inline int is_wheel_keybit(const usbdevice* kb, const uchar* macro){ - for(int i = 0; i < N_KEYBYTES_INPUT; i++){ + for(int byte = 0; byte < N_KEYBYTES_INPUT; byte++){ // Most entries are probably going to be 0, so skip over them - if(!macro[i]) + if(!macro[byte]) continue; // Go through each bit - for(int j = 0; j < 8; j++){ - if(!((macro[i] >> j) & 1)) + for(int bit = 0; bit < 8; bit++){ + int keyindex = byte * 8 + bit; + if(!((macro[byte] >> bit) & 1)) continue; // Get the index of the item and look it up in the keymap - const key* ckey = kb->keymap + i * 8 + j; + const key* ckey = kb->keymap + keyindex; // If there's at least a single wheel, return true if(IS_VOLWHEEL(ckey->scan) || IS_SCROLLWHEEL_V(ckey->scan) || IS_SCROLLWHEEL_H(ckey->scan)) return 1;