Skip to contentSkip to conversation

GPIO joystick driver

PATCH In review Hans Holmberg 5 participants 14 messages Feb 6, 2015 – Feb 18, 2015 5 messages not in the archive

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

cover GPIO joystick driver

This series adds a driver for digital joysticks connected via GPIOs.

Tested on Rasperry Pi and Minnowboard MAX using evtest.

The DSDT AML-code snippet below illustrates how to configure a joystick on the Minnowboard MAX, using the new _DSD support in the kernel.

Scope (_SB)

{
        Device (JOY)
        {
            Name (_HID, "PRP0001")
            Name (_CRS, ResourceTemplate () {
               GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                  "\\_SB.GPO2", 0, ResourceConsumer) {1}
               GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                  "\\_SB.GPO2", 0, ResourceConsumer) {0}
               GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                  "\\_SB.GPO0", 0, ResourceConsumer) {95}
               GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                  "\\_SB.GPO0", 0, ResourceConsumer) {94}
               GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                  "\\_SB.GPO2", 0, ResourceConsumer) {2}
            })

            Name (_DSD, Package () {
                ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                Package () {
                    Package () {"compatible", "gpio-joy"},
                    Package () {"debounce-interval-ms", 15},
                    Package () {"left-gpio",    Package () {^JOY, 0, 0, 1}},
                    Package () {"right-gpio",   Package () {^JOY, 1, 0, 1}},
                    Package () {"up-gpio",      Package () {^JOY, 2, 0, 1}},
                    Package () {"down-gpio",    Package () {^JOY, 3, 0, 1}},
                    Package () {"button-gpio",  Package () {^JOY, 4, 0, 1}},
               }
            })
        }
}

Best regards,
Hans

Hans Holmberg (2):
Documentation: Device Tree binding information for gpio-joy driver
input: gpio-joy - GPIO joystick driver

 .../devicetree/bindings/input/gpio-joy.txt         |  29 +++
 drivers/input/joystick/Kconfig                     |  10 +
 drivers/input/joystick/Makefile                    |   1 +
 drivers/input/joystick/gpio_joy.c                  | 208 +++++++++++++++++++++
 4 files changed, 248 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-joy.txt
 create mode 100644 drivers/input/joystick/gpio_joy.c
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 2/2 input: gpio-joy - GPIO joystick driver

This is an interrupt-driven driver for digital joysticks connected to GPIOs. Supports any digital joystick with signals for up, down, left, right and one signal for trigger button press, i.e. C64/Atari joysticks.

---
 drivers/input/joystick/Kconfig    |  10 ++
 drivers/input/joystick/Makefile   |   1 +
 drivers/input/joystick/gpio_joy.c | 208 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+)
 create mode 100644 drivers/input/joystick/gpio_joy.c
drivers/input/joystick/Kconfig +10 -0
index 56eb471..de0220e 100644
@@ -70,6 +70,16 @@ config JOYSTICK_GF2K
 	  To compile this driver as a module, choose M here: the
 	  module will be called gf2k.
 
+config JOYSTICK_GPIO
+	tristate "Joysticks connected to GPIOs"
+	depends on GPIOLIB
+	help
+	 Say Y here if you have one or more joysticks connected to your
+	 device directly via GPIOs.
+
+	 To compile this driver as a module, choose M here: the
+	 module will be called gpio_joy.
+
 config JOYSTICK_GRIP
 	tristate "Gravis GrIP joysticks and gamepads"
 	select GAMEPORT
drivers/input/joystick/Makefile +1 -0
index 92dc0de..c20a51a 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_JOYSTICK_COBRA)		+= cobra.o
 obj-$(CONFIG_JOYSTICK_DB9)		+= db9.o
 obj-$(CONFIG_JOYSTICK_GAMECON)		+= gamecon.o
 obj-$(CONFIG_JOYSTICK_GF2K)		+= gf2k.o
+obj-$(CONFIG_JOYSTICK_GPIO)		+= gpio_joy.o
 obj-$(CONFIG_JOYSTICK_GRIP)		+= grip.o
 obj-$(CONFIG_JOYSTICK_GRIP_MP)		+= grip_mp.o
 obj-$(CONFIG_JOYSTICK_GUILLEMOT)	+= guillemot.o
drivers/input/joystick/gpio_joy.c new file +208 -0

208 lines not on this page · raw message

Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1423215122-19947-3-git-send-email-hans.holmberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#3 lore raw

Re: [PATCH 2/2] input: gpio-joy - GPIO joystick driver

Quoted 12 lines · Hans Holmberg

This is an interrupt-driven driver for digital joysticks connected to GPIOs. Supports any digital joystick with signals for up, down, left, right and one signal for trigger button press, i.e. C64/Atari joysticks.

---
 drivers/input/joystick/Kconfig    |  10 ++
 drivers/input/joystick/Makefile   |   1 +
 drivers/input/joystick/gpio_joy.c | 208 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+)
 create mode 100644 drivers/input/joystick/gpio_joy.c

[...]

drivers/input/joystick/gpio_joy.c line 103

Quoted 7 lines
drivers/input/joystick/gpio_joy.c new file +7 -0
+static int gpio_joy_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct input_dev *input;
+	struct gpio_joy_drvdata *ddata;
+	int i, err;
+	unsigned int debounce_ms;

This should be a u32 given you pass it to a function expecting a u32 pointer.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	ddata = devm_kzalloc(dev, sizeof(struct gpio_joy_drvdata), GFP_KERNEL);

Use sizeof(*ddata)

[...]

drivers/input/joystick/gpio_joy.c line 188

Quoted 4 lines
drivers/input/joystick/gpio_joy.c new file +4 -0
+	return 0;
+fail:
+	return err;
+}

Given there's no cleanup, the fail path seems redundant.

[...]

drivers/input/joystick/gpio_joy.c line 193

Quoted 4 lines
drivers/input/joystick/gpio_joy.c new file +4 -0
+static const struct of_device_id gpio_joy_of_match[] = {
+	{ .compatible = DRV_NAME, },
+	{ },
+};

The compatible string should be independent of DRV_NAME, because it must match the binding. The driver can be arbitrarily and independently renamed.

Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

RE: [PATCH 2/2] input: gpio-joy - GPIO joystick driver

Quoted 27 lines

drivers/input/joystick/gpio_joy.c line 103

Quoted 7 lines
drivers/input/joystick/gpio_joy.c new file +6 -0
+static int gpio_joy_probe(struct platform_device *pdev) {
+	struct device *dev = &pdev->dev;
+	struct input_dev *input;
+	struct gpio_joy_drvdata *ddata;
+	int i, err;
+	unsigned int debounce_ms;

This should be a u32 given you pass it to a function expecting a u32 pointer.

Review

Quoted 3 lines
(quoted diff) +3 -0
+
+	ddata = devm_kzalloc(dev, sizeof(struct gpio_joy_drvdata),
+GFP_KERNEL);

Use sizeof(*ddata)

[...]

drivers/input/joystick/gpio_joy.c line 188

Quoted 4 lines
drivers/input/joystick/gpio_joy.c new file +4 -0
+	return 0;
+fail:
+	return err;
+}

Given there's no cleanup, the fail path seems redundant.

[...]

Quoted 8 lines

drivers/input/joystick/gpio_joy.c line 193

Quoted 4 lines
drivers/input/joystick/gpio_joy.c new file +4 -0
+static const struct of_device_id gpio_joy_of_match[] = {
+	{ .compatible = DRV_NAME, },
+	{ },
+};

The compatible string should be independent of DRV_NAME, because it must match the binding. The driver can be arbitrarily and independently renamed.

I'll address all of these comments, thanks for reviewing! Hans

A message that is not in the archive (sent off-list or not yet received): 1423215122-19947-1-git-send-email-hans.holmberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#6 lore raw

PATCH 1/2 Documentation: Device Tree binding information for gpio-joy driver

This document describes the Device Tree bindings for the gpio-joy driver.

---
 .../devicetree/bindings/input/gpio-joy.txt         | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-joy.txt
Documentation/devicetree/bindings/input/gpio-joy.txt new file +29 -0
new file mode 100644
index 0000000..ef8ad09
@@ -0,0 +1,29 @@
+Device-Tree bindings for input/joystick/gpio_joy.c joystick driver
+
+This driver can be used for connecting i.e. C64 and Atari joysticks.
+
+Required properties:
+	- compatible    = "gpio-joy";
+
+	- left-gpio     : gpio connected to the "left" joystick signal
+	- right-gpio    : gpio connected to the "right" joystick signal
+	- up-gpio       : gpio connected to the "up" joystick signal
+	- down-gpio     : gpio connected to the "down" joystick signal
+	- button-gpio   : gpio connected to the "button" joystick signal
+		See OF device-tree gpio specification.
+
+Optional properties:
+	- debounce-interval-ms: debounce interval in milliseconds for connected pins
+		Default is 10 milliseconds
+
+Example node:
+
+joystick {
+	compatible = "gpio-joy";
+	left-gpio = <&gpio 24 GPIO_ACTIVE_LOW>;
+	right-gpio = <&gpio 10 GPIO_ACTIVE_LOW>;
+	up-gpio	= <&gpio 3 GPIO_ACTIVE_LOW>;
+	down-gpio = <&gpio 27 GPIO_ACTIVE_LOW>;
+	button-gpio = <&gpio 2 GPIO_ACTIVE_LOW>;
+};
+
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1423215122-19947-2-git-send-email-hans.holmberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#8 lore raw

Re: [PATCH 1/2] Documentation: Device Tree binding information for gpio-joy driver

Quoted 15 lines · Hans Holmberg

This document describes the Device Tree bindings for the gpio-joy driver.

---
 .../devicetree/bindings/input/gpio-joy.txt         | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-joy.txt
Documentation/devicetree/bindings/input/gpio-joy.txt new file +0 -0
new file mode 100644
index 0000000..ef8ad09

Documentation/devicetree/bindings/input/gpio-joy.txt line 3

Quoted 3 lines
Documentation/devicetree/bindings/input/gpio-joy.txt new file +3 -0
@@ -0,0 +1,29 @@
+Device-Tree bindings for input/joystick/gpio_joy.c joystick driver
+
+This driver can be used for connecting i.e. C64 and Atari joysticks.

The binding should be for a class of hardware, not for a driver. Please describe the class of hardware the binding represents, and remove references to the Linux driver.

Documentation/devicetree/bindings/input/gpio-joy.txt line 6

Quoted 2 lines
Documentation/devicetree/bindings/input/gpio-joy.txt new file +2 -0
+Required properties:
+	- compatible    = "gpio-joy";

That does not strike me as a very informative compatible string. At the least, s/joy/joystick/.

Documentation/devicetree/bindings/input/gpio-joy.txt line 12

Quoted 6 lines
Documentation/devicetree/bindings/input/gpio-joy.txt new file +6 -0
+
+	- left-gpio     : gpio connected to the "left" joystick signal
+	- right-gpio    : gpio connected to the "right" joystick signal
+	- up-gpio       : gpio connected to the "up" joystick signal
+	- down-gpio     : gpio connected to the "down" joystick signal
+	- button-gpio   : gpio connected to the "button" joystick signal

Only one button?

Thanks,
Mark.

Quoted 25 lines
Documentation/devicetree/bindings/input/gpio-joy.txt new file +17 -0
+		See OF device-tree gpio specification.
+
+Optional properties:
+	- debounce-interval-ms: debounce interval in milliseconds for connected pins
+		Default is 10 milliseconds
+
+Example node:
+
+joystick {
+	compatible = "gpio-joy";
+	left-gpio = <&gpio 24 GPIO_ACTIVE_LOW>;
+	right-gpio = <&gpio 10 GPIO_ACTIVE_LOW>;
+	up-gpio	= <&gpio 3 GPIO_ACTIVE_LOW>;
+	down-gpio = <&gpio 27 GPIO_ACTIVE_LOW>;
+	button-gpio = <&gpio 2 GPIO_ACTIVE_LOW>;
+};
+
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

RE: [PATCH 1/2] Documentation: Device Tree binding information for gpio-joy driver

Quoted 4 lines

The binding should be for a class of hardware, not for a driver. Please describe the class of hardware the binding represents, and remove references to the Linux driver.

Will do.

Quoted 6 lines

Documentation/devicetree/bindings/input/gpio-joy.txt line 6

Quoted 3 lines
Documentation/devicetree/bindings/input/gpio-joy.txt new file +2 -0
+Required properties:
+	- compatible    = "gpio-joy";

That does not strike me as a very informative compatible string. At the least, s/joy/joystick/.

You're very right, gpio-joystick is better and as about as specific as it can be I believe.

Quoted 8 lines

Documentation/devicetree/bindings/input/gpio-joy.txt line 12

Quoted 6 lines
Documentation/devicetree/bindings/input/gpio-joy.txt new file +6 -0
+
+	- left-gpio     : gpio connected to the "left" joystick signal
+	- right-gpio    : gpio connected to the "right" joystick signal
+	- up-gpio       : gpio connected to the "up" joystick signal
+	- down-gpio     : gpio connected to the "down" joystick signal
+	- button-gpio   : gpio connected to the "button" joystick signal

Only one button?

Hmm, yes, but it would make more sense to have sub-nodes defining an arbitrary number of buttons instead, right?

Thanks for reviewing!
Hans

#10 lore raw
In reply to a message not in the archive

Hi Hans,

Quoted 2 lines · Hans Holmberg

This series adds a driver for digital joysticks connected via GPIOs.

Why do we need this new driver when we have gpio-keys driver that can be configured to emit ABS_* events?

Thanks.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1AA6C46C-36D9-4243-9DC5-254A7202D339-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#12 lore raw

SGkgRG1pdHJ5LA0KDQo+IFdoeSBkbyB3ZSBuZWVkIHRoaXMgbmV3IGRyaXZlciB3aGVuIHdlIGhh dmUgZ3Bpby1rZXlzIGRyaXZlciB0aGF0IGNhbiBiZQ0KPiBjb25maWd1cmVkIHRvIGVtaXQgQUJT XyogZXZlbnRzPw0KPiANCg0KQXMgZmFyIGFzIEkgY2FuIHRlbGwsIHRoZXJlIGlzIG5vIHdheSB0 byBzcGVjaWZ5IHZhbHVlcyBmb3IgQUJTLSJrZXlzIiBpbiB0aGUNCmRldmljZSB0cmVlIGJpbmRp bmcuIA0KDQpXaGlsZSBib3RoIHRoZSBkZXZpY2UgdHJlZSBiaW5kaW5nIGFuZCB0aGUgZ3Bpby1r ZXlzIGRyaXZlciBjb3VsZCBwb3NzaWJseSBiZSBhZGFwdGVkIHRvIA0Kc3VwcG9ydCB0aGlzLCBp dCBtYWtlcyBzZW5zZSB0byBtZSB0byBkZXNjcmliZSBqb3lzdGlja3MgaW4gYSBzZXBhcmF0ZSBi aW5kaW5nIGFuZCBrZWVwDQp0aGUgZHJpdmVyIGltcGxlbWVudGF0aW9ucyBhcGFydC4NCg0KSW4g YWRkaXRpb24gdG8gdGhpcywgIGF1dG8tcmVwZWF0IGFuZCB0aGUgc3lzIGZzIGRpc2FibGUgaW50 ZXJmYWNlIGZvciBpbmRpdmlkdWFsIGtleXMgDQpkb2VzIG5vdCBtYWtlIHNlbnNlIGZvciBqb3lz dGlja3MuDQoNCkluIG15IG1pbmQsIGtleWJvYXJkcyBhbmQgam95c3RpY2tzIGFyZSBkaWZmZXJl bnQgZW5vdWdoLg0KDQpUaGFua3MgZm9yIGxvb2tpbmcgYXQgdGhpcywNCkhhbnMNCg== --
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4B6D6D87A8FB62428BE0A3E38461A1AB18D6AF04-pww93C2UFcwu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org

#14 lore raw

Hi Hans,

Quoted 8 lines · Hans

Hi Dmitry,

Quoted 3 lines

Why do we need this new driver when we have gpio-keys driver that can be configured to emit ABS_* events?

As far as I can tell, there is no way to specify values for ABS-"keys" in the device tree binding.

It may mot be present in device tree binding, but the driver does support it, so I would rather extend the binding than have a brand new driver.

Quoted 4 lines

While both the device tree binding and the gpio-keys driver could possibly be adapted to support this, it makes sense to me to describe joysticks in a separate binding and keep the driver implementations apart.

Why? From the input core perspective there is no difference. It is just a device that emits set of events.

Quoted 3 lines

In addition to this, auto-repeat and the sys fs disable interface for individual keys does not make sense for joysticks.

You do not need to use it when you describe the device (BTW autorepeat for trigger might be a good thing).

Thanks.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw
Quoted 6 lines
Quoted 3 lines

As far as I can tell, there is no way to specify values for ABS-"keys" in the device tree binding.

It may not be present in device tree binding, but the driver does support it, so I would rather extend the binding than have a brand new driver.

All right, I find it a bit like whacking a round peg down a square hole, but I'll head down that path and see where it leads.

Quoted 8 lines
Quoted 3 lines

While both the device tree binding and the gpio-keys driver could possibly be adapted to support this, it makes sense to me to describe joysticks in a separate binding and keep the driver implementations apart.

Why? From the input core perspective there is no difference. It is just a device that emits set of events.

Quoted 7 lines

From a hardware-description/devicee-tree binding perspective its confusing (at least to me) to describe joysticks as keyboards.

Quoted 2 lines

In addition to this, auto-repeat and the sys fs disable interface for individual keys does not make sense for joysticks.

You do not need to use it when you describe the device (BTW autorepeat for trigger might be a good thing).

Ah, yes. autofire.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

As far as I can tell, there is no way to specify values for ABS-"keys" in the device tree binding.

It may not be present in device tree binding, but the driver does support it, so I would rather extend the binding than have a brand new

driver.

All right, I find it a bit like whacking a round peg down a square hole, but I'll head down that path and see where it leads.

This is what I've found:

A digital joystick driver needs to report three states per axis: min, max and neutral. The hardware only have two signals per axis(i.e. up and down) however. See http://wiki.icomp.de/wiki/DB9-Joystick

This makes gpio-keys pretty much impossible to use for joysticks - as the driver only reports abs-events when a button/key is pressed, how would the neutral state be reported? (as there is no signal for "neutral")

Even if through some hackery the driver would be modified to report a special neutral event if all "buttons/keys" for that axis are not pressed, what value should be reported? An average of the values for that axis? Also, reporting such an implicit neutral event would break the behavior of existing abs-reporting instances, right?

Do you still prefer this approach?

Thanks,
Hans

#17 lore raw
Quoted 22 lines · Hans
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

As far as I can tell, there is no way to specify values for ABS-"keys" in the device tree binding.

It may not be present in device tree binding, but the driver does support it, so I would rather extend the binding than have a brand new

driver.

All right, I find it a bit like whacking a round peg down a square hole, but I'll head down that path and see where it leads.

This is what I've found:

A digital joystick driver needs to report three states per axis: min, max and neutral. The hardware only have two signals per axis(i.e. up and down) however. See http://wiki.icomp.de/wiki/DB9-Joystick

This makes gpio-keys pretty much impossible to use for joysticks - as the driver only reports abs-events when a button/key is pressed, how would the neutral state be reported? (as there is no signal for "neutral")

Quoted 5 lines

Even if through some hackery the driver would be modified to report a special neutral event if all "buttons/keys" for that axis are not pressed, what value should be reported? An average of the values for
that axis? Also, reporting such an implicit neutral event would
break the behavior of existing abs-reporting instances, right?

You have 2 gpio per axis, and since you can't measure how "far" down the axis you have moved the driver should only report values -1, 0, 1 per axis. You start at neutral position, and move right. IRQ for right gpio is fired and you report EV_ABS/ABS_X/1. Then you start moving to the left, gpio IRQ fires (you want it to trigger on both edges) and you report EV_ABS/ABS_X/0. You continue moving to the left and IRQ for left gpio fires up and you report EV_ABS/ABS_X/-1.

This assumes that you assign EV_ABS/ABS_X and value 1 for right gpio and EV_ABS/ABS_X and value -1 for left gpio.

Thanks.

Signature · 1 line
Dmitry
#18 lore raw
Quoted 15 lines
Quoted 9 lines

A digital joystick driver needs to report three states per axis: min, max and neutral. The hardware only have two signals per axis(i.e. up and down) however. See http://wiki.icomp.de/wiki/DB9-Joystick

This makes gpio-keys pretty much impossible to use for joysticks - as the driver only reports abs-events when a button/key is pressed, how would the neutral state be reported? (as there is no signal for "neutral")

Quoted 5 lines

Even if through some hackery the driver would be modified to report a special neutral event if all "buttons/keys" for that axis are not pressed, what value should be reported? An average of the values for
that axis? Also, reporting such an implicit neutral event would
break the behavior of existing abs-reporting instances, right?

Quoted 9 lines

You have 2 gpio per axis, and since you can't measure how "far" down the axis you have moved the driver should only report values -1, 0, 1 per axis. You start at neutral position, and move right. IRQ for right gpio is fired and you report EV_ABS/ABS_X/1. Then you start moving to the left, gpio IRQ fires (you want it to trigger on both edges) and you report EV_ABS/ABS_X/0. You continue moving to the left and IRQ for left gpio fires up and you report EV_ABS/ABS_X/-1.
This assumes that you assign EV_ABS/ABS_X and value 1 for right gpio and EV_ABS/ABS_X and value -1 for left gpio.

Right, but the problem I was referring to is that "up/release" events are not reported by gpio-keys.c today:

        if (type == EV_ABS) {
                if (state)
                        input_event(input, type, button->code, button->value);
        } else {
                input_event(input, type, button->code, !!state);
        }

I see three solutions:

1. Start reporting ABS=0 if state == 0 - this is what I would expect of the driver, but would break the current behavior.
2. Add an optional down-abs-value per key. If it is not specified, It won't be reported.
3. Add a device-global property ("report-neutral-abs") that will report ABS=0 on all "up" events for abs-keys.

Comments?

In any case, I have a patch set based on (3) that works (but that I need to test a bit more), enabling gpio-keys to support digital joysticks using the new device property api.

I had to define the abs-value device tree property as a 2's complement signed 32 integer. Negative numbers are not commonly used but the device tree compiler supports it. In the ACPI case, the iasl compiler only supports unsigned ints, but it's easy enough to work around (-1 <-> 0xFFFFFFFF) .

Thanks!
Hans