Merge branch 'feature/tilt' into libusb-port
This commit is contained in:
commit
b9359970c3
@ -3,14 +3,15 @@
|
||||
*
|
||||
* Filename: hanvon-libusb.c
|
||||
*
|
||||
* Description: Libusb GP0504 handler prototype
|
||||
* Description: libusb Hanvon tablet driver
|
||||
*
|
||||
* Version: 0.1
|
||||
* Created: 08/17/2020 04:05:14 PM
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: surkeh@protonmail.com
|
||||
* Maintaned by: scuti@teknik.io
|
||||
* surkeh@protonmail.com
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
@ -137,9 +138,9 @@ void callback_gp0504 (struct libusb_transfer *tx) { // for callback
|
||||
0x02: button press
|
||||
0x01: touching
|
||||
*/
|
||||
err = libevdev_uinput_write_event(
|
||||
ud, EV_KEY, BTN_TOOL_PEN, msg->is_move & (0x80|0x10));
|
||||
err = libevdev_uinput_write_event(ud, EV_KEY, BTN_TOOL_PEN, msg->is_move & (0x80|0x10));
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
|
||||
if(msg->is_move & (0x80|0x10)) {
|
||||
msg->x_movement = htobe16(msg->x_movement);
|
||||
//DEBUG("Set X to %x\n",msg->x_movement);
|
||||
@ -150,14 +151,18 @@ void callback_gp0504 (struct libusb_transfer *tx) { // for callback
|
||||
err = libevdev_uinput_write_event(ud, EV_ABS, ABS_Y, msg->y_movement);
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
}
|
||||
err = libevdev_uinput_write_event(
|
||||
ud, EV_ABS, ABS_PRESSURE, msg->pressure);
|
||||
|
||||
err = libevdev_uinput_write_event(ud, EV_ABS, ABS_PRESSURE, msg->pressure);
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
err = libevdev_uinput_write_event(ud, EV_ABS, ABS_TILT_X, msg->y_tilt);
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
err = libevdev_uinput_write_event(ud, EV_ABS, ABS_TILT_Y, msg->x_tilt);
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
err = libevdev_uinput_write_event(ud, EV_KEY, BTN_LEFT, msg->is_move & 0x01);
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
err = libevdev_uinput_write_event(
|
||||
ud, EV_KEY, BTN_RIGHT, (msg->is_move & 0x02) / 2);
|
||||
err = libevdev_uinput_write_event(ud, EV_KEY, BTN_RIGHT, (msg->is_move & 0x02) / 2);
|
||||
if(err) { DEBUG("err: %d\n",err); }
|
||||
|
||||
// data[1]:
|
||||
// 0x10 = lift, 0x90 = close, 0x91 = press
|
||||
// 0x12 = btn (lift), 0x92 = btn (close), 0x93 = btn (press)
|
||||
@ -196,30 +201,30 @@ int init_ctrl(struct libusb_device * const d, struct libevdev **evdev, struct li
|
||||
libevdev_enable_event_code((*evdev), EV_KEY, BTN_TOOL_PEN, NULL);
|
||||
libevdev_enable_event_code((*evdev), EV_KEY, BTN_LEFT, NULL); // pen tap
|
||||
libevdev_enable_event_code((*evdev), EV_KEY, BTN_RIGHT, NULL); // pen button
|
||||
libevdev_enable_event_type((*evdev), EV_ABS); // enable absolute position, pressure, tilt
|
||||
|
||||
libevdev_enable_event_type((*evdev), EV_ABS); // enable absolute position
|
||||
abs = malloc(sizeof(struct input_absinfo));
|
||||
// set up absolute x coordinate input
|
||||
abs->value = 0x1000;
|
||||
abs->minimum = 0;
|
||||
abs->maximum = 0x27DE;
|
||||
abs->fuzz = 0;
|
||||
abs->flat = 0;
|
||||
abs->resolution = 40;
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_X, abs)<0) // pen button
|
||||
{
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_X, abs)<0) {
|
||||
DEBUG("%s","failed to register absolute x\n");
|
||||
}
|
||||
abs = malloc(sizeof(struct input_absinfo));
|
||||
// set up absolute y coordinate input
|
||||
abs->value = 0x1000;
|
||||
abs->minimum = 0;
|
||||
abs->maximum = 0x1cfe;
|
||||
abs->fuzz = 0;
|
||||
abs->flat = 0;
|
||||
abs->resolution = 40;
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_Y, abs)<0) // pen button
|
||||
{
|
||||
DEBUG("%s","failed to register absolute x\n");
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_Y, abs)<0) {
|
||||
DEBUG("%s","failed to register absolute y\n");
|
||||
}
|
||||
// set up pressure input
|
||||
abs -> value = 0;
|
||||
abs -> minimum = 0;
|
||||
abs -> maximum = 0xff;
|
||||
@ -227,6 +232,23 @@ int init_ctrl(struct libusb_device * const d, struct libevdev **evdev, struct li
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_PRESSURE, abs)<0) {
|
||||
DEBUG("%s","failed to register pressure\n");
|
||||
}
|
||||
// set up tilt x input
|
||||
abs -> value = 0;
|
||||
abs -> minimum = 0;
|
||||
abs -> maximum = AM_MAX_TILT_X;
|
||||
abs -> resolution = 0;
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_TILT_X, abs)<0) {
|
||||
DEBUG("%s","failed to register x tilt\n");
|
||||
}
|
||||
// set up tilt y input
|
||||
abs -> value = 0;
|
||||
abs -> minimum = 0;
|
||||
abs -> maximum = AM_MAX_TILT_Y;
|
||||
abs -> resolution = 0;
|
||||
if(libevdev_enable_event_code((*evdev), EV_ABS, ABS_TILT_Y, abs)<0) {
|
||||
DEBUG("%s","failed to register y tilt\n");
|
||||
}
|
||||
|
||||
switch(desc.idProduct) {
|
||||
case PRODUCT_ID_GP0504:
|
||||
libevdev_set_name((*evdev), "Hanvon Graphicpal GP0504");
|
||||
@ -238,6 +260,7 @@ int init_ctrl(struct libusb_device * const d, struct libevdev **evdev, struct li
|
||||
}
|
||||
int err = libevdev_uinput_create_from_device((*evdev), LIBEVDEV_UINPUT_OPEN_MANAGED, uidev);
|
||||
printf("Initializing controls status: %x, \n", uidev);
|
||||
free(abs);
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
@ -360,4 +383,3 @@ libusb_device *FindHanvon( libusb_context **context)
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user