Skip to content

Commit 7229c58

Browse files
Paul Donohuedtor
authored andcommitted
Input: ALPS - clean up TrackStick handling for SS5 hardware
For consistency and clarity, the input_report_*() functions should be called by alps_process_packet_ss4_v2() instead of by alps_decode_ss4_v2(). Reviewed-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Paul Donohue <linux-kernel@PaulSD.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 864db92 commit 7229c58

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

‎drivers/input/mouse/alps.c‎

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,18 +1267,12 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
12671267
break;
12681268

12691269
case SS4_PACKET_ID_STICK:
1270-
if (!(priv->flags & ALPS_DUALPOINT)) {
1271-
psmouse_warn(psmouse,
1272-
"Rejected trackstick packet from non DualPoint device");
1273-
} else {
1274-
int x = (s8)(((p[0] & 1) << 7) | (p[1] & 0x7f));
1275-
int y = (s8)(((p[3] & 1) << 7) | (p[2] & 0x7f));
1276-
int pressure = (s8)(p[4] & 0x7f);
1277-
1278-
input_report_rel(priv->dev2, REL_X, x);
1279-
input_report_rel(priv->dev2, REL_Y, -y);
1280-
input_report_abs(priv->dev2, ABS_PRESSURE, pressure);
1281-
}
1270+
/*
1271+
* x, y, and pressure are decoded in
1272+
* alps_process_packet_ss4_v2()
1273+
*/
1274+
f->first_mp = 0;
1275+
f->is_mp = 0;
12821276
break;
12831277

12841278
case SS4_PACKET_ID_IDLE:
@@ -1312,6 +1306,7 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
13121306
struct input_dev *dev = psmouse->dev;
13131307
struct input_dev *dev2 = priv->dev2;
13141308
struct alps_fields *f = &priv->f;
1309+
int x, y, pressure;
13151310

13161311
memset(f, 0, sizeof(struct alps_fields));
13171312
priv->decode_fields(f, packet, psmouse);
@@ -1348,12 +1343,25 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
13481343

13491344
/* Report trackstick */
13501345
if (alps_get_pkt_id_ss4_v2(packet) == SS4_PACKET_ID_STICK) {
1351-
if (priv->flags & ALPS_DUALPOINT) {
1352-
input_report_key(dev2, BTN_LEFT, f->ts_left);
1353-
input_report_key(dev2, BTN_RIGHT, f->ts_right);
1354-
input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
1355-
input_sync(dev2);
1346+
if (!(priv->flags & ALPS_DUALPOINT)) {
1347+
psmouse_warn(psmouse,
1348+
"Rejected trackstick packet from non DualPoint device");
1349+
return;
13561350
}
1351+
1352+
x = (s8)(((packet[0] & 1) << 7) | (packet[1] & 0x7f));
1353+
y = (s8)(((packet[3] & 1) << 7) | (packet[2] & 0x7f));
1354+
pressure = (s8)(packet[4] & 0x7f);
1355+
1356+
input_report_rel(dev2, REL_X, x);
1357+
input_report_rel(dev2, REL_Y, -y);
1358+
input_report_abs(dev2, ABS_PRESSURE, pressure);
1359+
1360+
input_report_key(dev2, BTN_LEFT, f->ts_left);
1361+
input_report_key(dev2, BTN_RIGHT, f->ts_right);
1362+
input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
1363+
1364+
input_sync(dev2);
13571365
return;
13581366
}
13591367

0 commit comments

Comments
 (0)