absolute wheel implementation
This commit is contained in:
parent
87403d3f9c
commit
535ea39e39
22
hanvon.c
22
hanvon.c
@ -20,6 +20,8 @@ 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
|
||||||
|
|
||||||
struct hanvon {
|
struct hanvon {
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -32,7 +34,7 @@ struct hanvon {
|
|||||||
unsigned b1:1;
|
unsigned b1:1;
|
||||||
unsigned b2:1;
|
unsigned b2:1;
|
||||||
unsigned b3:1;
|
unsigned b3:1;
|
||||||
int b_wheel;
|
int wheel_pos, old_wheel_pos;
|
||||||
int pressure;
|
int pressure;
|
||||||
char phys[32];
|
char phys[32];
|
||||||
};
|
};
|
||||||
@ -70,9 +72,21 @@ static void hanvon_irq(struct urb *urb)
|
|||||||
input_report_key(dev, B2, hanvon->b2);
|
input_report_key(dev, B2, hanvon->b2);
|
||||||
input_report_key(dev, B3, hanvon->b3);
|
input_report_key(dev, B3, hanvon->b3);
|
||||||
} else {
|
} else {
|
||||||
hanvon->b_wheel = data[2]; // FIXME: calculate position 0 .. 255
|
if(data[2] <= 0x3f) { // slider area active
|
||||||
|
int diff = hanvon->old_wheel_pos - data[2];
|
||||||
|
if(abs(diff) < WHEEL_THRESHOLD) {
|
||||||
|
hanvon->wheel_pos += diff;
|
||||||
|
|
||||||
input_report_key(dev, BTN_WHEEL, hanvon->b_wheel);
|
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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -120,6 +134,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->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;
|
||||||
@ -182,6 +197,7 @@ 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