3DS: implement touchscreen_enable_device to gate touch input (Olivier Senn)

Change-Id: I2f9d2505b727a6a68e8dba9199ea4053aa902b64
This commit is contained in:
Vencislav Atanasov 2026-06-26 22:21:43 +02:00 • committed by Solomon Peachy
parent 4d3c7aed03
commit 9cef2a3aef

View file

@ -53,6 +53,8 @@ static enum {
STATE_DOWN = 1,
} last_touch_state = STATE_UNKNOWN;
static bool touch_enabled = true;
static double map_values(double n, double source_start, double source_end, double dest_start, double dest_end, int decimal_precision ) {
double delta_start = source_end - source_start;
double delta_end = dest_end - dest_start;
@ -152,22 +154,25 @@ int button_read_device(int* data)
}
touchPosition touch;
hidTouchRead(&touch);
if (touch_enabled)
{
hidTouchRead(&touch);
/* Generate UP and DOWN events */
if (kDown & KEY_TOUCH) {
last_touch_state = STATE_DOWN;
}
else {
last_touch_state = STATE_UP;
}
/* Generate UP and DOWN events */
if (kDown & KEY_TOUCH) {
last_touch_state = STATE_DOWN;
}
else {
last_touch_state = STATE_UP;
}
last_x = touch.px;
last_y = touch.py;
last_x = touch.px;
last_y = touch.py;
int tkey = touchscreen_to_pixels(last_x, last_y, data);
if (last_touch_state == STATE_DOWN) {
key |= tkey;
int tkey = touchscreen_to_pixels(last_x, last_y, data);
if (last_touch_state == STATE_DOWN) {
key |= tkey;
}
}
update_sound_slider_level();
@ -183,7 +188,7 @@ void button_init_device(void)
#ifndef HAS_BUTTON_HOLD
void touchscreen_enable_device(bool en)
{
(void)en;
touch_enabled = en;
}
#endif