diff mbox series

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

Message ID 20211013112305.41574-2-stephan@gerhold.net (mailing list archive)
State Mainlined
Commit 872e57abd171515bc180f2d44c2c99da29542320
Headers show
Series [1/2] Input: tm2-touchkey - report scan codes | expand

Commit Message

Stephan Gerhold Oct. 13, 2021, 11:23 a.m. UTC
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.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
 drivers/input/keyboard/tm2-touchkey.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Dmitry Torokhov Oct. 16, 2021, 3:27 a.m. UTC | #1
On Wed, Oct 13, 2021 at 01:23:05PM +0200, Stephan Gerhold wrote:
> 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.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index ce40ea2d940f..632cd6c1c8d4 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -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,