3DS: add circle pad support for scrolling and navigation (Olivier Senn)

Map the circle pad to directional buttons, giving an alternative
input method to the D-pad. Uses a deadzone of 64 to prevent
unintended movement from minor stick drift.

💘 Generated with Crush

Assisted-by: Crush:deepseek-v4-pro

Edited by Vencislav Atanasov: Fixed KEY_SELECT handling.

Change-Id: I34bf7127688423fca209e199d9535e032ad8b753
This commit is contained in:
Vencislav Atanasov 2026-06-26 20:16:48 +02:00
parent a8f8aa40b9
commit 2be2aeb2a2
2 changed files with 17 additions and 2 deletions

View file

@ -766,6 +766,7 @@ Lê Khánh Bình
Michael McAllister
Hemant Kumar
Jerry Shen
Olivier Senn
The libmad team
The wavpack team

View file

@ -86,6 +86,8 @@ void update_sound_slider_level(void)
}
}
#define CPAD_DEADZONE 64
int button_read_device(int* data)
{
int key = BUTTON_NONE;
@ -97,14 +99,26 @@ int button_read_device(int* data)
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_SELECT) {
touchscreen_set_mode(touchscreen_get_mode() == TOUCHSCREEN_POINT ? TOUCHSCREEN_BUTTON : TOUCHSCREEN_POINT);
printf("Touchscreen mode: %s\n", touchscreen_get_mode() == TOUCHSCREEN_POINT ? "TOUCHSCREEN_POINT" : "TOUCHSCREEN_BUTTON");
}
u32 kHeld = hidKeysHeld();
/* Circle pad → directional buttons (alternative to D-pad) */
circlePosition cpad;
hidCircleRead(&cpad);
if (cpad.dx > CPAD_DEADZONE)
kHeld |= KEY_DRIGHT;
else if (cpad.dx < -CPAD_DEADZONE)
kHeld |= KEY_DLEFT;
if (cpad.dy > CPAD_DEADZONE)
kHeld |= KEY_DUP;
else if (cpad.dy < -CPAD_DEADZONE)
kHeld |= KEY_DDOWN;
/* rockbox will handle button repeats */
kDown |= kHeld;