relative wheel implementation
This commit is contained in:
parent
535ea39e39
commit
74aefabc9d
20
hanvon.c
20
hanvon.c
@ -20,7 +20,6 @@ MODULE_LICENSE(DRIVER_LICENSE);
|
|||||||
#define B1 BTN_TOOL_FINGER
|
#define B1 BTN_TOOL_FINGER
|
||||||
#define B2 BTN_TOOL_PENCIL
|
#define B2 BTN_TOOL_PENCIL
|
||||||
#define B3 BTN_TOOL_AIRBRUSH
|
#define B3 BTN_TOOL_AIRBRUSH
|
||||||
#define TOTAL_WHEEL_ABS 0x40
|
|
||||||
#define WHEEL_THRESHOLD 10
|
#define WHEEL_THRESHOLD 10
|
||||||
|
|
||||||
struct hanvon {
|
struct hanvon {
|
||||||
@ -34,7 +33,7 @@ struct hanvon {
|
|||||||
unsigned b1:1;
|
unsigned b1:1;
|
||||||
unsigned b2:1;
|
unsigned b2:1;
|
||||||
unsigned b3:1;
|
unsigned b3:1;
|
||||||
int wheel_pos, old_wheel_pos;
|
int old_wheel_pos;
|
||||||
int pressure;
|
int pressure;
|
||||||
char phys[32];
|
char phys[32];
|
||||||
};
|
};
|
||||||
@ -73,17 +72,9 @@ static void hanvon_irq(struct urb *urb)
|
|||||||
input_report_key(dev, B3, hanvon->b3);
|
input_report_key(dev, B3, hanvon->b3);
|
||||||
} else {
|
} else {
|
||||||
if(data[2] <= 0x3f) { // slider area active
|
if(data[2] <= 0x3f) { // slider area active
|
||||||
int diff = hanvon->old_wheel_pos - data[2];
|
int diff = data[2] - hanvon->old_wheel_pos;
|
||||||
if(abs(diff) < WHEEL_THRESHOLD) {
|
if(abs(diff) < WHEEL_THRESHOLD)
|
||||||
hanvon->wheel_pos += diff;
|
input_report_key(dev, REL_WHEEL, diff);
|
||||||
|
|
||||||
if(hanvon->wheel_pos < -TOTAL_WHEEL_ABS)
|
|
||||||
hanvon->wheel_pos += TOTAL_WHEEL_ABS;
|
|
||||||
else if(hanvon->wheel_pos > TOTAL_WHEEL_ABS)
|
|
||||||
hanvon->wheel_pos -= TOTAL_WHEEL_ABS;
|
|
||||||
|
|
||||||
input_report_key(dev, ABS_WHEEL, hanvon->wheel_pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
hanvon->old_wheel_pos = data[2];
|
hanvon->old_wheel_pos = data[2];
|
||||||
}
|
}
|
||||||
@ -134,7 +125,7 @@ static int hanvon_open(struct input_dev *dev)
|
|||||||
{
|
{
|
||||||
struct hanvon *hanvon = input_get_drvdata(dev);
|
struct hanvon *hanvon = input_get_drvdata(dev);
|
||||||
|
|
||||||
hanvon->old_wheel_pos = -TOTAL_WHEEL_ABS-1;
|
hanvon->old_wheel_pos = -WHEEL_THRESHOLD-1;
|
||||||
hanvon->irq->dev = hanvon->usbdev;
|
hanvon->irq->dev = hanvon->usbdev;
|
||||||
if (usb_submit_urb(hanvon->irq, GFP_KERNEL))
|
if (usb_submit_urb(hanvon->irq, GFP_KERNEL))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@ -197,7 +188,6 @@ static int hanvon_probe(struct usb_interface *intf, const struct usb_device_id *
|
|||||||
input_set_abs_params(input_dev, ABS_X, 0, 0x27de, 4, 0);
|
input_set_abs_params(input_dev, ABS_X, 0, 0x27de, 4, 0);
|
||||||
input_set_abs_params(input_dev, ABS_Y, 0, 0x1cfe, 4, 0);
|
input_set_abs_params(input_dev, ABS_Y, 0, 0x1cfe, 4, 0);
|
||||||
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xffffffff, 4, 0);
|
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xffffffff, 4, 0);
|
||||||
input_set_abs_params(input_dev, ABS_WHEEL, 0, TOTAL_WHEEL_ABS, 4, 0);
|
|
||||||
|
|
||||||
endpoint = &intf->cur_altsetting->endpoint[0].desc;
|
endpoint = &intf->cur_altsetting->endpoint[0].desc;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user