diff --git a/README.md b/README.md index f087570..67f334d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Currently working/fixed: - HID LEDs with Reactive LED fallback - sdvx/iidx spoof - untested on EAC - 1000hz polling +- Reversable Encoders - Switch and LED pins are now staggered for easier wiring - Fix 0-~71% encoder rollover in gamepad mode, uint32 max val isn't divisible evenly by ppr\*4 for joystick - thanks friends diff --git a/build_uf2/Pico_Game_Controller.uf2 b/build_uf2/Pico_Game_Controller.uf2 index 7fee644..8f48ba2 100644 Binary files a/build_uf2/Pico_Game_Controller.uf2 and b/build_uf2/Pico_Game_Controller.uf2 differ diff --git a/src/pico_game_controller.c b/src/pico_game_controller.c index 38e5df8..16b9600 100644 --- a/src/pico_game_controller.c +++ b/src/pico_game_controller.c @@ -36,7 +36,8 @@ const uint8_t SW_GPIO[] = { const uint8_t LED_GPIO[] = { 5, 7, 9, 11, 13, 15, 17, 19, 21, 26, 28, }; -const uint8_t ENC_GPIO[] = {0, 2}; // L_ENC(0, 1); R_ENC(2, 3) +const uint8_t ENC_GPIO[] = {0, 2}; // L_ENC(0, 1); R_ENC(2, 3) +const bool ENC_REV[] = {false, false}; // Reverse Encoders PIO pio; uint32_t enc_val[ENC_GPIO_SIZE]; @@ -129,7 +130,8 @@ void joy_mode() { // overflowed / underflowed by } - cur_enc_val[i] = cur_enc_val[i] + (delta * changeType); + cur_enc_val[i] = + cur_enc_val[i] + ((ENC_REV[i] ? 1 : -1) * delta * changeType); while (cur_enc_val[i] < 0) { cur_enc_val[i] = ENC_PULSE - cur_enc_val[i]; } @@ -209,7 +211,7 @@ void key_mode() { UINT32_MAX - delta[i] + 1; // this should give us how much we // overflowed / underflowed by } - delta[i] *= changeType; // set direction + delta[i] *= changeType * (ENC_REV[i] ? 1 : -1); // set direction prev_enc_val[i] = enc_val[i]; } tud_hid_mouse_report(REPORT_ID_MOUSE, 0x00, delta[0], delta[1], 0, 0);