Configure D-Pad
#11
Thanks for the speedy replies guys!

I’m looking for a permanent way to do it, and ideally would have the audio intact as well.

I’ve had a read through and started making my own DTS file, but have been very bogged down with work so it may take a little while before I can report back with results...
Reply
#12
Thanks Wink
Reply
#13
Ok so I’ve managed to get the button sending button presses by modifying the DTS file as per your earlier post, thanks Flavor Smile  The blog post and the linux codes page you posted were very helpful, and somehow for me the audio still works  Dodgy Big Grin

However, now I am trying to configure it so that the D-Pad moves the mouse cursor.
Just replacing the linux codes in the DTS file with, for example, Rel_X+1 doesn’t seem to work - I get a syntax error  message when I try to compile the dtbo file from the dts file, and in any case, the input device doesn’t seem to be configure to send EV_REL data (as a USB mouse input device does).

Do you have any pointers on how I can configure the device tree overlay so that it can move the mouse cursor?

Apologies if my message is a jumble, I’m very new to tinkering with linux!!!
Reply
#14
Further searching reveals that the kernel has a driver “gpio_mouse”, and I assume I must substitute “gpio_keys” in the “compatible = “gpio_keys”” section of the DTS file, then configure the GPIO lines accordingly...

I’ve found the “gpio_mouse” driver at:
https://git.kernel.org/pub/scm/linux/ker...io_mouse.c

But am unsure exactly how to modify the DTS file so that gpio pins 6, 5, 4 and 17 control mouse movement, pins 16 and 24 are left and right mouse clicks, and the rest of the pins are key presses as in your original DTS file Flavor.

Any help with how to do this would be much appreciated!!!
Reply
#15
Ooooooook,

So I have found what I need to put in the DTS file for the GPIO to control the mouse here: https://github.com/torvalds/linux/blob/m...-mouse.txt

And have written the following DTS file:
Code:
#include <dt-bindings/gpio/gpio.h>

gpio-mouse {
compatible = "gpio-mouse";
scan-interval-ms = <50>;
up-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
down-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
left-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
right-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
button-left-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
button-right-gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
};
Then I use the following command to compile a binary DTB file:

Code:
dtc -I dts -O dtb -o /boot/overlays/FPZgpiomouse.dtbo FPZgpiomouse.dts
But I get the following error message:
Code:
Error: FPZgpiomouse.dts:1.1-2 syntax error
FATAL ERROR: Unable to parse input tree
It seems the compiler doesn't like the "#include" line
Any suggestions where to go from here???
Reply
#16
I think the example is maybe outdated or not compatible with Rpi.
I am on my phone so it is hard to write a long explain :S

Look at https://github.com/TheFlav/Freeplay-Supp...eeplay.dts ,each key section.
Not sure the include is needed.
Reply
#17
Thanks for the reply Porcinus,

The DTS on TheFlav's github references the gpio_keys kernel driver, and I believe it can only send key presses, not mouse input, so I cannot simply replace the key presses with equivalent Linux codes for mouse input.

I believe that in order send mouse input I need to use the gpio_mouse kernel driver, so I've created a DTS file referencing that, but when I try to compile it into the binary DTBO file I get the above error...
Reply
#18
Little misunderstand,

On your current mouse DTS, please try:
- remove the include
- replace &gpio0 by &gpio (I was meaning this and the following line by "each key section")
- replace GPIO_ACTIVE_LOW by 1
Reply
#19
Thanks again for your reply Porcinus.

Okay, so this is the DTS file I've arrived at;
Code:
// Definitions for Freeplay Zero/CM3 gpio-keys
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2708";

fragment@0 {
// Configure the gpio pin controller
target = <&gpio>;
__overlay__ {
pin_state: button_pins@0 {
brcm,pins =     <6 5 4 17 16 24 19 26 14 23>; // gpio number
brcm,function = <0 0 0  0  0  0  0  0  0  0>; // 0 = input, 1 = output
brcm,pull =     <2 2 2  2  2  2  2  2  2  2>; // 0 = none, 1 = pull down, 2 = pull up
};
};
};
fragment@1 {
target-path = "/";
__overlay__ {
button: Freeplay_GPIO_Keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pin_state>;
status = "okay";

key@6 {
linux,code = <28>; //KEY_ENTER
gpios = <&gpio 19 1>;
};

key@7 {
linux,code = <57>; //KEY_SPACE
gpios = <&gpio 26 1>;
};


key@20 { //shoulder-l
linux,code = <38>;
gpios = <&gpio 14 1>;
label = "KEY_L";
};
key@21 { //shoulder-r
linux,code = <19>;
gpios = <&gpio 23 1>;
label = "KEY_R";
};
};
};
};
fragment@2 {
target-path = "/";
__overlay__ {
gpio-mouse {
compatible = "gpio-mouse";
scan-interval-ms = <50>;
        up-gpios = <&gpio 4 1>;
        down-gpios = <&gpio 17 1>;
        left-gpios = <&gpio 6 1>;
        right-gpios = <&gpio 5 1>;
        button-left-gpios = <&gpio 16 1>;
        button-right-gpios = <&gpio 24 1>;
};
};
};
};

(sorry pasting the code hasn't preserved the indents, but they are there!)


It compiles to binary, and I've updated /boot/config.txt

But it still doesn't work Undecided

I've downloaded the the evtest and input-utils packages
And when I enter the command lsinput I get the following:
Code:
/dev/input/event0
  bustype : BUS_PARPORT
  vendor  : 0x1
  product : 0x4
  version : 256
  name    : "GPIO Controller 1"
  phys    : "input0"
  bits ev : EV_SYN EV_KEY EV_ABS

/dev/input/event1
  bustype : BUS_HOST
  vendor  : 0x1
  product : 0x1
  version : 256
  name    : "Freeplay_GPIO_Keys"
  phys    : "gpio-keys/input0"
  bits ev : EV_SYN EV_KEY

So it isn't showing up as an input device...

Do you have any other recommendations for things I could try? I feel like we're so close to cracking it! Wink
Reply
#20
By curiosity, does dmesg show anything related to gpio-mouse?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)