Skip to content
This repository was archived by the owner on Sep 29, 2021. It is now read-only.

Commit fb7aa2d

Browse files
committed
Only report touch coordinates if there's a touch
Duh. This prevents screen-pointers from jumping into a corner on screen after releasing the touchscreen. Also remove one instance of hidScanInput() that would mess with the readings of hidCollectData() (keys up/down could not be read).
1 parent b58cfde commit fb7aa2d

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

3DS/source/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ int main(int argc, char **argv)
110110
while (aptMainLoop()) {
111111

112112
if (isHomebrew) {
113-
hidScanInput();
114113
if (hidKeysHeld() == EXIT_KEYS) {
115114
res = RL_SUCCESS;
116115
break;

linux/src/devices/touchscreen.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,29 @@ int touchscreen_write(int uinputfd, struct hidinfo *hid)
8080
int res;
8181
static struct input_event events[NUMEVENTS];
8282

83-
size_t i = 0;
84-
events[i].type = EV_KEY;
85-
events[i].code = keys[i];
86-
events[i].value =
87-
HID_HAS_KEY(hid->keys.held | hid->keys.down, HID_KEY_TOUCH);
88-
i++;
83+
size_t i = 0;
84+
int touch = HID_HAS_KEY(hid->keys.held, HID_KEY_TOUCH);
8985

90-
events[i].type = EV_ABS;
91-
events[i].code = ABS_X;
92-
events[i].value = hid->touchscreen.px;
86+
events[i].type = EV_KEY;
87+
events[i].code = keys[i];
88+
events[i].value = touch;
9389
i++;
9490

95-
events[i].type = EV_ABS;
96-
events[i].code = ABS_Y;
97-
events[i].value = hid->touchscreen.py;
98-
i++;
91+
// Only report coordinates if a touch is registered, as the touchscreen will
92+
// always report to be at (0, 0) otherwise . This prevents screen-pointers,
93+
// such as your mouse, to suddenly jump into a corner once lift your stylus
94+
// or finger off the touchscreen.
95+
if (touch) {
96+
events[i].type = EV_ABS;
97+
events[i].code = ABS_X;
98+
events[i].value = hid->touchscreen.px;
99+
i++;
100+
101+
events[i].type = EV_ABS;
102+
events[i].code = ABS_Y;
103+
events[i].value = hid->touchscreen.py;
104+
i++;
105+
}
99106

100107
events[i].type = EV_SYN;
101108
events[i].code = SYN_REPORT;

0 commit comments

Comments
 (0)