RE: [PATCH 0/2] GPIO joystick driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > 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?
> 
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux