Fix triple-click with fewer than 6 wheel functions
When users have only 4 wheel functions (2 sets), triple-click was trying to access Set 3 (functions 4-5) which don't exist, causing the code to wrap back to Set 0. Solution: - Check if Set 3 exists (totalWheels >= 5) before allowing triple-click - If Set 3 doesn't exist, ignore the triple-click and show debug message - This allows users to have 2, 4, or 6 wheel functions Examples: - 2 functions: Only Set 1 exists, single-click toggles 0↔1 - 4 functions: Sets 1-2 exist, double-click toggles, triple-click ignored - 6 functions: All 3 sets exist, full multi-click navigation works Files modified: - src/device.c: Add totalWheels check for Set 3 access
+14 −7 · 1 file changed
-
src/device.c+14 −7
@@ -337,15 +337,22 @@ void device_run(libusb_context* ctx, config_t* config, int debug, int accept, in } wheel_position_in_set = 0; // Start at first function in new set } else if (final_click_count >= 3) { - // Triple-click: toggle to/from Set 2 - if (wheel_current_set == 2) { - // From Set 2, go back to Set 0 - wheel_current_set = 0; + // Triple-click: toggle to/from Set 2 (only if Set 2 exists - need at least 5 functions) + if (config->totalWheels >= 5) { + if (wheel_current_set == 2) { + // From Set 2, go back to Set 0 + wheel_current_set = 0; + } else { + // From Set 0 or 1, go to Set 2 + wheel_current_set = 2; + } + wheel_position_in_set = 0; // Start at first function in new set } else { - // From Set 0 or 1, go to Set 2 - wheel_current_set = 2; + if (debug == 1) { + printf("Triple-click ignored: Set 3 requires at least 5 wheel functions (have %d)\n", + config->totalWheels); + } } - wheel_position_in_set = 0; // Start at first function in new set } // Calculate actual wheel function index