From: nazgul33 <nazgul33@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
Daniel Mack <daniel@caiaq.de>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] Input: rotary_encoder - Support key events
Date: Sun, 6 Jan 2019 12:36:29 +0900 [thread overview]
Message-ID: <CAEo1Rizj_HC5f+TWMP8ogrsXVhMDrxA+Nyo2h4KJJ4admtmanQ@mail.gmail.com> (raw)
In-Reply-To: <CAKdAkRQKnH++VuL37EGBaFSMmFPvbpCkVkZLwuMU9eWo+KsaXA@mail.gmail.com>
input_sync() is there, at the end of the function.
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_event(encoder->input, EV_KEY, keycode, 0);
} else {
unsigned int pos = encoder->pos;
if (encoder->dir < 0) {
/* turning counter-clockwise */
if (encoder->rollover)
pos += encoder->steps;
if (pos)
pos--;
} else {
/* turning clockwise */
if (encoder->rollover || pos < encoder->steps)
pos++;
}
if (encoder->rollover)
pos %= encoder->steps;
encoder->pos = pos;
input_report_abs(encoder->input, encoder->axis, encoder->pos);
}
input_sync(encoder->input);
}
On Sun, Jan 6, 2019 at 8:12 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Sat, Jan 5, 2019 at 2:27 PM Donghoon Han <nazgul33@gmail.com> wrote:
> >
> > From: Steven Han <nazgul33@gmail.com>
> >
> > Support generating EV_KEY pair, instead of EV_REL.
> >
> > Signed-off-by: Donghoon Han <nazgul33@gmail.com>
> > ---
> > drivers/input/misc/rotary_encoder.c | 23 +++++++++++++++++++++--
> > 1 file changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
> > index 72eee6d55527..180e35884289 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,10 @@ 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);
>
> You need input_sync() here.
>
> > + input_event(encoder->input, EV_KEY, keycode, 0);
> > } else {
> > unsigned int pos = encoder->pos;
> >
> > @@ -237,6 +243,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 +276,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
> >
>
> Thanks.
>
> --
> Dmitry
--
한동훈 드림.
next prev parent reply other threads:[~2019-01-06 3:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-05 20:26 [PATCH 0/2] input: rotary-encoder: Support key events Donghoon Han
2019-01-05 20:26 ` [PATCH 1/2] Input: rotary_encoder - " Donghoon Han
2019-01-05 23:12 ` Dmitry Torokhov
2019-01-06 3:36 ` nazgul33 [this message]
2019-01-07 0:38 ` Dmitry Torokhov
2019-01-05 20:26 ` [PATCH 2/2] Input: rotaty-encoder - Add DT binding document Donghoon Han
2019-01-05 23:11 ` Dmitry Torokhov
2019-01-06 3:41 ` nazgul33
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEo1Rizj_HC5f+TWMP8ogrsXVhMDrxA+Nyo2h4KJJ4admtmanQ@mail.gmail.com \
--to=nazgul33@gmail.com \
--cc=daniel@caiaq.de \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).