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

Commit

Permalink
Only report touch coordinates if there's a touch
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
phijor committed Jun 15, 2016
1 parent b58cfde commit fb7aa2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
1 change: 0 additions & 1 deletion 3DS/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ int main(int argc, char **argv)
while (aptMainLoop()) {

if (isHomebrew) {
hidScanInput();
if (hidKeysHeld() == EXIT_KEYS) {
res = RL_SUCCESS;
break;
Expand Down
33 changes: 20 additions & 13 deletions linux/src/devices/touchscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,29 @@ int touchscreen_write(int uinputfd, struct hidinfo *hid)
int res;
static struct input_event events[NUMEVENTS];

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

events[i].type = EV_ABS;
events[i].code = ABS_X;
events[i].value = hid->touchscreen.px;
events[i].type = EV_KEY;
events[i].code = keys[i];
events[i].value = touch;
i++;

events[i].type = EV_ABS;
events[i].code = ABS_Y;
events[i].value = hid->touchscreen.py;
i++;
// Only report coordinates if a touch is registered, as the touchscreen will
// always report to be at (0, 0) otherwise . This prevents screen-pointers,
// such as your mouse, to suddenly jump into a corner once lift your stylus
// or finger off the touchscreen.
if (touch) {
events[i].type = EV_ABS;
events[i].code = ABS_X;
events[i].value = hid->touchscreen.px;
i++;

events[i].type = EV_ABS;
events[i].code = ABS_Y;
events[i].value = hid->touchscreen.py;
i++;
}

events[i].type = EV_SYN;
events[i].code = SYN_REPORT;
Expand Down

0 comments on commit fb7aa2d

Please sign in to comment.