Skip to contentSkip to conversation

Input: tm2-touchkey - report scan codes

PATCH Applied Stephan Gerhold 2 participants 4 messages Oct 13, 2021 – Oct 16, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Input: tm2-touchkey - report scan codes

Report the index of pressed touch key as MSC_SCAN code to userspace so it is possible to identify which of the keys was pressed (not just the function that is currently assigned to the key).

This is done similarly also in mcs_touchkey and mpr121_touchkey.

---
 drivers/input/keyboard/tm2-touchkey.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/input/keyboard/tm2-touchkey.c +3 -0
index 6218b1c682ef..ce40ea2d940f 100644
@@ -156,6 +156,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 		goto out;
 	}
 
+	input_event(touchkey->input_dev, EV_MSC, MSC_SCAN, index);
+
 	if (data & TM2_TOUCHKEY_BIT_PRESS_EV) {
 		for (i = 0; i < touchkey->num_keycodes; i++)
 			input_report_key(touchkey->input_dev,
@@ -250,6 +252,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 	touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
 	touchkey->input_dev->id.bustype = BUS_I2C;
 
+	input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN);
 	for (i = 0; i < touchkey->num_keycodes; i++)
 		input_set_capability(touchkey->input_dev, EV_KEY,
 				     touchkey->keycodes[i]);
Signature · 1 line
2.33.0
#1 lore raw

PATCH 2/2 Input: tm2-touchkey - allow changing keycodes from userspace

At the moment the touch keys have key codes assigned from the device tree. In some cases, users might want to change the key code from userspace. There is existing functionality for this in the input core using the EVIOCSKEYCODE ioctl, which is integrated for example into udev.

Make it possible to use this functionality for tm2-touchkey by simply making the input core aware of the array that holds the keycodes. Similar code also exists in mcs_touchkey and mpr121_touchkey.

---
 drivers/input/keyboard/tm2-touchkey.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/input/keyboard/tm2-touchkey.c +4 -0
index ce40ea2d940f..632cd6c1c8d4 100644
@@ -252,6 +252,10 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 	touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
 	touchkey->input_dev->id.bustype = BUS_I2C;
 
+	touchkey->input_dev->keycode = touchkey->keycodes;
+	touchkey->input_dev->keycodemax = touchkey->num_keycodes;
+	touchkey->input_dev->keycodesize = sizeof(touchkey->keycodes[0]);
+
 	input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN);
 	for (i = 0; i < touchkey->num_keycodes; i++)
 		input_set_capability(touchkey->input_dev, EV_KEY,
Signature · 1 line
2.33.0
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace

Quoted 10 lines · Stephan Gerhold

At the moment the touch keys have key codes assigned from the device tree. In some cases, users might want to change the key code from userspace. There is existing functionality for this in the input core using the EVIOCSKEYCODE ioctl, which is integrated for example into udev.

Make it possible to use this functionality for tm2-touchkey by simply making the input core aware of the array that holds the keycodes. Similar code also exists in mcs_touchkey and mpr121_touchkey.

Applied, thank you.

Signature · 1 line
Dmitry
maintainer Applied
#3 lore raw
In reply to Stephan Gerhold
Quoted 7 lines · Stephan Gerhold

Report the index of pressed touch key as MSC_SCAN code to userspace so it is possible to identify which of the keys was pressed (not just the function that is currently assigned to the key).

This is done similarly also in mcs_touchkey and mpr121_touchkey.

Applied, thank you.

Signature · 1 line
Dmitry