1
0
Fork 0
mirror of https://github.com/rfc2822/GfxTablet synced 2025-10-05 18:34:18 +02:00

add tablet events, so xinput recognizes this as a Tablet, not a Touchscreen. Also add stylus-in-range pseudo-button and barrel buttons

This commit is contained in:
Jarrad Whitaker 2015-11-27 22:24:24 +11:00
parent f957287eac
commit c61378cef4
2 changed files with 22 additions and 1 deletions

View file

@ -35,6 +35,12 @@ void init_device(int fd)
die("error: ioctl UI_SET_EVBIT EV_KEY");
if (ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH) < 0)
die("error: ioctl UI_SET_KEYBIT");
if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_PEN) < 0)
die("error: ioctl UI_SET_KEYBIT");
if (ioctl(fd, UI_SET_KEYBIT, BTN_STYLUS) < 0)
die("error: ioctl UI_SET_KEYBIT");
if (ioctl(fd, UI_SET_KEYBIT, BTN_STYLUS2) < 0)
die("error: ioctl UI_SET_KEYBIT");
// enable 2 main axes + pressure (absolute positioning)
if (ioctl(fd, UI_SET_EVBIT, EV_ABS) < 0)
@ -144,8 +150,19 @@ int main(void)
send_event(device, EV_SYN, SYN_REPORT, 1);
break;
case EVENT_TYPE_BUTTON:
// stylus hovering
if (ev_pkt.button == -1)
send_event(device, EV_KEY, BTN_TOOL_PEN, ev_pkt.down);
// stylus touching
if (ev_pkt.button == 0)
send_event(device, EV_KEY, BTN_TOUCH, ev_pkt.down);
// button 1
if (ev_pkt.button == 1)
send_event(device, EV_KEY, BTN_STYLUS, ev_pkt.down);
// button 2
if (ev_pkt.button == 2)
send_event(device, EV_KEY, BTN_STYLUS2, ev_pkt.down);
printf("sent button: %hhi, %hhu\n", ev_pkt.button, ev_pkt.down);
send_event(device, EV_SYN, SYN_REPORT, 1);
break;

View file

@ -20,7 +20,11 @@ struct event_packet
};
struct { /* only required for EVENT_TYPE_BUTTON */
int8_t button; /* number of button, beginning with 1 */
int8_t button; /* button id:
-1 = stylus in range,
0 = tap/left click/button 0,
1 = button 1,
2 = button 2 */
int8_t down; /* 1 = button down, 0 = button up */
};
};