|
@@ -55,6 +55,7 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
{
|
|
|
+ struct wacom_features *features = &wacom->features;
|
|
|
unsigned char *data = wacom->data;
|
|
|
int prox, pressure;
|
|
|
|
|
@@ -68,9 +69,9 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
if (prox) {
|
|
|
wacom->id[0] = ERASER_DEVICE_ID;
|
|
|
pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
|
|
|
- if (wacom->features->pressure_max > 255)
|
|
|
+ if (features->pressure_max > 255)
|
|
|
pressure = (pressure << 1) | ((data[4] >> 6) & 1);
|
|
|
- pressure += (wacom->features->pressure_max + 1) / 2;
|
|
|
+ pressure += (features->pressure_max + 1) / 2;
|
|
|
|
|
|
/*
|
|
|
* if going from out of proximity into proximity select between the eraser
|
|
@@ -152,6 +153,7 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
{
|
|
|
+ struct wacom_features *features = &wacom->features;
|
|
|
unsigned char *data = wacom->data;
|
|
|
int x, y, rw;
|
|
|
static int penData = 0;
|
|
@@ -179,8 +181,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
case 2: /* Mouse with wheel */
|
|
|
wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
|
|
|
- if (wacom->features->type == WACOM_G4 ||
|
|
|
- wacom->features->type == WACOM_MO) {
|
|
|
+ if (features->type == WACOM_G4 || features->type == WACOM_MO) {
|
|
|
rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
|
|
|
wacom_report_rel(wcombo, REL_WHEEL, -rw);
|
|
|
} else
|
|
@@ -192,8 +193,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
wacom->id[0] = CURSOR_DEVICE_ID;
|
|
|
wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
|
|
|
wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
|
|
|
- if (wacom->features->type == WACOM_G4 ||
|
|
|
- wacom->features->type == WACOM_MO)
|
|
|
+ if (features->type == WACOM_G4 || features->type == WACOM_MO)
|
|
|
wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
|
|
|
else
|
|
|
wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
|
|
@@ -230,7 +230,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
}
|
|
|
|
|
|
/* send pad data */
|
|
|
- switch (wacom->features->type) {
|
|
|
+ switch (features->type) {
|
|
|
case WACOM_G4:
|
|
|
if (data[7] & 0xf8) {
|
|
|
if (penData) {
|
|
@@ -300,11 +300,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
|
|
|
{
|
|
|
+ struct wacom_features *features = &wacom->features;
|
|
|
unsigned char *data = wacom->data;
|
|
|
int idx = 0;
|
|
|
|
|
|
/* tool number */
|
|
|
- if (wacom->features->type == INTUOS)
|
|
|
+ if (features->type == INTUOS)
|
|
|
idx = data[1] & 0x01;
|
|
|
|
|
|
/* Enter report */
|
|
@@ -402,7 +403,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
|
|
|
wacom_report_key(wcombo, BTN_STYLUS2, 0);
|
|
|
wacom_report_key(wcombo, BTN_TOUCH, 0);
|
|
|
wacom_report_abs(wcombo, ABS_WHEEL, 0);
|
|
|
- if (wacom->features->type >= INTUOS3S)
|
|
|
+ if (features->type >= INTUOS3S)
|
|
|
wacom_report_abs(wcombo, ABS_Z, 0);
|
|
|
}
|
|
|
wacom_report_key(wcombo, wacom->tool[idx], 0);
|
|
@@ -416,13 +417,14 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
|
|
|
{
|
|
|
+ struct wacom_features *features = &wacom->features;
|
|
|
unsigned char *data = wacom->data;
|
|
|
unsigned int t;
|
|
|
|
|
|
/* general pen packet */
|
|
|
if ((data[1] & 0xb8) == 0xa0) {
|
|
|
t = (data[6] << 2) | ((data[7] >> 6) & 3);
|
|
|
- if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L)
|
|
|
+ if (features->type >= INTUOS4S && features->type <= INTUOS4L)
|
|
|
t = (t << 1) | (data[1] & 1);
|
|
|
wacom_report_abs(wcombo, ABS_PRESSURE, t);
|
|
|
wacom_report_abs(wcombo, ABS_TILT_X,
|
|
@@ -446,6 +448,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
{
|
|
|
+ struct wacom_features *features = &wacom->features;
|
|
|
unsigned char *data = wacom->data;
|
|
|
unsigned int t;
|
|
|
int idx = 0, result;
|
|
@@ -457,7 +460,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
}
|
|
|
|
|
|
/* tool number */
|
|
|
- if (wacom->features->type == INTUOS)
|
|
|
+ if (features->type == INTUOS)
|
|
|
idx = data[1] & 0x01;
|
|
|
|
|
|
/* pad packets. Works as a second tool and is always in prox */
|
|
@@ -466,7 +469,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
if (wacom->tool[1] != BTN_TOOL_FINGER)
|
|
|
wacom->tool[1] = BTN_TOOL_FINGER;
|
|
|
|
|
|
- if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
|
|
|
+ if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
|
|
|
wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
|
|
|
wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
|
|
|
wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
|
|
@@ -480,7 +483,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
/* Out of proximity, clear wheel value. */
|
|
|
wacom_report_abs(wcombo, ABS_WHEEL, 0);
|
|
|
}
|
|
|
- if (wacom->features->type != INTUOS4S) {
|
|
|
+ if (features->type != INTUOS4S) {
|
|
|
wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
|
|
|
wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
|
|
|
}
|
|
@@ -528,18 +531,20 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
return 0;
|
|
|
|
|
|
/* Only large Intuos support Lense Cursor */
|
|
|
- if ((wacom->tool[idx] == BTN_TOOL_LENS)
|
|
|
- && ((wacom->features->type == INTUOS3)
|
|
|
- || (wacom->features->type == INTUOS3S)
|
|
|
- || (wacom->features->type == INTUOS4)
|
|
|
- || (wacom->features->type == INTUOS4S)))
|
|
|
+ if (wacom->tool[idx] == BTN_TOOL_LENS &&
|
|
|
+ (features->type == INTUOS3 ||
|
|
|
+ features->type == INTUOS3S ||
|
|
|
+ features->type == INTUOS4 ||
|
|
|
+ features->type == INTUOS4S)) {
|
|
|
+
|
|
|
return 0;
|
|
|
+ }
|
|
|
|
|
|
/* Cintiq doesn't send data when RDY bit isn't set */
|
|
|
- if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
|
|
|
+ if (features->type == CINTIQ && !(data[1] & 0x40))
|
|
|
return 0;
|
|
|
|
|
|
- if (wacom->features->type >= INTUOS3S) {
|
|
|
+ if (features->type >= INTUOS3S) {
|
|
|
wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
|
|
|
wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
|
|
|
wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
|
|
@@ -557,7 +562,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
if (data[1] & 0x02) {
|
|
|
/* Rotation packet */
|
|
|
- if (wacom->features->type >= INTUOS3S) {
|
|
|
+ if (features->type >= INTUOS3S) {
|
|
|
/* I3 marker pen rotation */
|
|
|
t = (data[6] << 3) | ((data[7] >> 5) & 7);
|
|
|
t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
|
|
@@ -570,7 +575,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
((t - 1) / 2) : -t / 2);
|
|
|
}
|
|
|
|
|
|
- } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
|
|
|
+ } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
|
|
|
/* 4D mouse packet */
|
|
|
wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
|
|
|
wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
|
|
@@ -583,7 +588,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
} else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
|
|
|
/* I4 mouse */
|
|
|
- if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
|
|
|
+ if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
|
|
|
wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
|
|
|
wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
|
|
|
wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
|
|
@@ -604,13 +609,13 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
- ((data[8] & 0x02) >> 1));
|
|
|
|
|
|
/* I3 2D mouse side buttons */
|
|
|
- if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
|
|
|
+ if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
|
|
|
wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
|
|
|
wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
|
|
|
}
|
|
|
}
|
|
|
- } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L ||
|
|
|
- wacom->features->type == INTUOS4L) &&
|
|
|
+ } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
|
|
|
+ features->type == INTUOS4L) &&
|
|
|
wacom->tool[idx] == BTN_TOOL_LENS) {
|
|
|
/* Lens cursor packets */
|
|
|
wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
|
|
@@ -718,6 +723,7 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
{
|
|
|
+ struct wacom_features *features = &wacom->features;
|
|
|
char *data = wacom->data;
|
|
|
int prox = 0, pressure, idx = -1;
|
|
|
static int stylusInProx, touchInProx = 1, touchOut;
|
|
@@ -791,7 +797,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
|
|
|
pressure = ((data[7] & 0x01) << 8) | data[6];
|
|
|
if (pressure < 0)
|
|
|
- pressure = wacom->features->pressure_max + pressure + 1;
|
|
|
+ pressure = features->pressure_max + pressure + 1;
|
|
|
wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
|
|
|
wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
|
|
|
} else {
|
|
@@ -815,7 +821,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
|
|
|
|
|
|
int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
|
|
|
{
|
|
|
- switch (wacom_wac->features->type) {
|
|
|
+ switch (wacom_wac->features.type) {
|
|
|
case PENPARTNER:
|
|
|
return wacom_penpartner_irq(wacom_wac, wcombo);
|
|
|
|
|
@@ -853,7 +859,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
|
|
|
|
|
|
void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
|
|
|
{
|
|
|
- switch (wacom_wac->features->type) {
|
|
|
+ switch (wacom_wac->features.type) {
|
|
|
case WACOM_MO:
|
|
|
input_dev_mo(input_dev, wacom_wac);
|
|
|
case WACOM_G4:
|
|
@@ -888,7 +894,7 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
|
|
|
/* fall through */
|
|
|
case TABLETPC:
|
|
|
input_dev_tpc(input_dev, wacom_wac);
|
|
|
- if (wacom_wac->features->device_type != BTN_TOOL_PEN)
|
|
|
+ if (wacom_wac->features.device_type != BTN_TOOL_PEN)
|
|
|
break; /* no need to process stylus stuff */
|
|
|
|
|
|
/* fall through */
|