linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Input: tm2-touchkey - report scan codes
@ 2021-10-13 11:23 Stephan Gerhold
  2021-10-13 11:23 ` [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace Stephan Gerhold
  2021-10-16  3:27 ` [PATCH 1/2] Input: tm2-touchkey - report scan codes Dmitry Torokhov
  0 siblings, 2 replies; 4+ messages in thread
From: Stephan Gerhold @ 2021-10-13 11:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, ~postmarketos/upstreaming, 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.

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

diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index 6218b1c682ef..ce40ea2d940f 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -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]);
-- 
2.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace
  2021-10-13 11:23 [PATCH 1/2] Input: tm2-touchkey - report scan codes Stephan Gerhold
@ 2021-10-13 11:23 ` Stephan Gerhold
  2021-10-16  3:27   ` Dmitry Torokhov
  2021-10-16  3:27 ` [PATCH 1/2] Input: tm2-touchkey - report scan codes Dmitry Torokhov
  1 sibling, 1 reply; 4+ messages in thread
From: Stephan Gerhold @ 2021-10-13 11:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, ~postmarketos/upstreaming, 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.

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

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,
-- 
2.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Input: tm2-touchkey - report scan codes
  2021-10-13 11:23 [PATCH 1/2] Input: tm2-touchkey - report scan codes Stephan Gerhold
  2021-10-13 11:23 ` [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace Stephan Gerhold
@ 2021-10-16  3:27 ` Dmitry Torokhov
  1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2021-10-16  3:27 UTC (permalink / raw)
  To: Stephan Gerhold; +Cc: linux-input, ~postmarketos/upstreaming

On Wed, Oct 13, 2021 at 01:23:04PM +0200, Stephan Gerhold wrote:
> 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.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace
  2021-10-13 11:23 ` [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace Stephan Gerhold
@ 2021-10-16  3:27   ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2021-10-16  3:27 UTC (permalink / raw)
  To: Stephan Gerhold; +Cc: linux-input, ~postmarketos/upstreaming

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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-16  3:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 11:23 [PATCH 1/2] Input: tm2-touchkey - report scan codes Stephan Gerhold
2021-10-13 11:23 ` [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace Stephan Gerhold
2021-10-16  3:27   ` Dmitry Torokhov
2021-10-16  3:27 ` [PATCH 1/2] Input: tm2-touchkey - report scan codes Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).