lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190107164249.2342-2-nazgul33@gmail.com>
Date:   Tue,  8 Jan 2019 01:42:48 +0900
From:   Donghoon Han <nazgul33@...il.com>
To:     linux-input@...r.kernel.org
Cc:     Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Daniel Mack <daniel@...aq.de>, linux-kernel@...r.kernel.org,
        Steven Han <nazgul33@...il.com>
Subject: [PATCH V2 1/2] Input: rotary_encoder - Support key events

From: Steven Han <nazgul33@...il.com>

Support generating EV_KEY pair, instead of EV_REL.

Signed-off-by: Donghoon Han <nazgul33@...il.com>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Daniel Mack <daniel@...aq.de>
To: linux-input@...r.kernel.org
---
V2: added missing input_sync()
---
 drivers/input/misc/rotary_encoder.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 72eee6d55527..0014a7d9f8f9 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -41,6 +41,8 @@ struct rotary_encoder {
 	u32 steps;
 	u32 axis;
 	bool relative_axis;
+	bool relative_keys;
+	u32 keycodes[2];
 	bool rollover;
 	enum rotary_encoder_encoding encoding;
 
@@ -79,6 +81,11 @@ static void rotary_encoder_report_event(struct rotary_encoder *encoder)
 	if (encoder->relative_axis) {
 		input_report_rel(encoder->input,
 				 encoder->axis, encoder->dir);
+	} else if (encoder->relative_keys) {
+		u32 keycode = encoder->keycodes[encoder->dir > 0];
+		input_event(encoder->input, EV_KEY, keycode, 1);
+		input_sync(encoder->input);
+		input_event(encoder->input, EV_KEY, keycode, 0);
 	} else {
 		unsigned int pos = encoder->pos;
 
@@ -237,6 +244,16 @@ static int rotary_encoder_probe(struct platform_device *pdev)
 	device_property_read_u32(dev, "linux,axis", &encoder->axis);
 	encoder->relative_axis =
 		device_property_read_bool(dev, "rotary-encoder,relative-axis");
+	encoder->relative_keys =
+		device_property_read_bool(dev, "rotary-encoder,relative-keys");
+	if (encoder->relative_keys) {
+		err = device_property_read_u32_array(dev,
+					"rotary-encoder,relative-keycodes",
+					encoder->keycodes, 2);
+		if (err)
+			dev_err(dev, "unable to get keycodes: %d\n", err);
+		return err;
+	}
 
 	encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN);
 	if (IS_ERR(encoder->gpios)) {
@@ -260,9 +277,12 @@ static int rotary_encoder_probe(struct platform_device *pdev)
 	input->id.bustype = BUS_HOST;
 	input->dev.parent = dev;
 
-	if (encoder->relative_axis)
+	if (encoder->relative_axis) {
 		input_set_capability(input, EV_REL, encoder->axis);
-	else
+	} else if (encoder->relative_keys) {
+		input_set_capability(input, EV_KEY, encoder->keycodes[0]);
+		input_set_capability(input, EV_KEY, encoder->keycodes[1]);
+	} else
 		input_set_abs_params(input,
 				     encoder->axis, 0, encoder->steps, 0, 1);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ