bushrat
Posts: 69
Joined: Mon Mar 05, 2012 8:35 pm

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:51 pm

before you press ^C, does the button work? If not try each of these, testing between:

A) In your config, change "KEY_7" to "7"

B) Try "sudo modprobe uinput" before starting pikeyd

C) Have a cup of Hot Chocolate and watch a nice film

D) Take a quick power nap

E) Reboot your Pi

F) Reboot your Pi, except this time wearing your lucky socks

Ok, everything after B isn't going to help with your problem, but try it anyway :D

LordSanta
Posts: 3
Joined: Tue Apr 23, 2013 4:41 pm

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 3:57 pm

lmercatanti wrote:Yes, sure, i don't press CTRL+C
I try "sudo pikeyd" and after instead of going to a text editor push the button, but... Nothing :(
Hey I had almost the exact same problem as you. Everything was fine but I couldn't get the key presses working in the application. I just simply added the line '/usr/local/bin/pikeyd -d' to /etc/rc.local so that it runs at boot. I restarted and it worked. I think the problem was the wireless keyboard and mouse I had connected, and even when I disconnected it before powering on, the GPIO buttons still didn't work. So the only way to get the GPIO buttons recognized was to force raspi to launch pikeyd as the default "keyboard" at startup. I still have my keyboard and mouse connected, but they don't work anymore.

If you are trying to map to GPIO pins 2 and 3 (0 and 1 in Version 1) with the 1K pull up resistors, it won't work if you have Version 2. Those pins already contain 2 1K8 pull up resistors (according to http://elinux.org/RPi_Low-level_periphe ... .28GPIO.29), so I reckon you'll just get a huge voltage drop, too much to register as an input.

I hope this helps :)

PhillyNJ
Posts: 112
Joined: Sat Dec 29, 2012 4:07 am

Re: Universal GPIO keyboard daemon

Fri May 03, 2013 10:25 am

bushrat wrote:Just thought I'd let people know, you don't need to disconnect your keyboard to get AdvMAME working, all you need to is change the device_keyboard attribute towards the top of the advmame.rc (or advmenu.rc) from auto to raw, works perfectly for me.
This worked for me.

User avatar
gruso
Posts: 40
Joined: Tue Mar 06, 2012 4:39 am

Re: Universal GPIO keyboard daemon

Sat May 04, 2013 12:34 am

Just wanted to say thanks for this. Working great with my arcade buttons in Advmame and Mame4all.

(FWIW, Mame4all doesn't care if the keyboard is connected.)

bushrat
Posts: 69
Joined: Mon Mar 05, 2012 8:35 pm

Re: Universal GPIO keyboard daemon

Wed May 08, 2013 9:50 am

#joy.cfg

#format:
# [keycode from /usr/include/linux/input.h] [whitespace] [GPIO pin no]
# Not limited to a single key. A GPIO press will emit all defined keys in order.


KEY_7 17
Instead of writing:
KEY_7 17
Try:
KEY_7 11
Leave you button hooked up to the same pin, just change the number.

lmercatanti
Posts: 9
Joined: Tue Jul 31, 2012 7:51 am

Re: Universal GPIO keyboard daemon

Sat May 11, 2013 3:21 pm

Hi everybody.. Nothing nothing nothing! :(
Why? :(

With a simple python code it's works (when i press the button the script writes "pressed" in the console, but with pikeyid no)

User avatar
gruso
Posts: 40
Joined: Tue Mar 06, 2012 4:39 am

Re: Universal GPIO keyboard daemon

Thu May 16, 2013 10:09 am

lmercatanti wrote:Hi everybody.. Nothing nothing nothing! :(
Why? :(

With a simple python code it's works (when i press the button the script writes "pressed" in the console, but with pikeyid no)
Any more detailed info? Error messages?

I had trouble getting it going. I kept notes as I went, here is a raw dump of them which may point you in the right direction:

Code: Select all

git clone https://github.com/mmoller2k/pikeyd.git
make
edit config file
sudo modprobe uinput (also add to /etc/modules)

sudo ./pikeyd -d (to run as daemon. -k to kill.)

^^ now running as daemon, no key inputs registering in terminal yet...

Error:

"/root/.pikeyd.conf: No such file or directory
/etc/pikeyd.conf: No such file or directory
Polling 0 GPIO pin(s)."

copying pikeyd.conf to /etc...

^^ Now working.

Gave /usr/local/bin/pikeyd root ownership.
Added to /etc/rc.local to run at boot. (add line before 'exit 0')
Note that they are just shorthand notes. A few bash commands and breadcrumbs. Don't go copypasting all that into your terminal :p

mmoller2k
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm

Re: Universal GPIO keyboard daemon

Fri May 17, 2013 10:08 pm

Thanks bushrat for pointing out a bug when connecting buttons via an I2C expander. I think it should be fixed now, but I can't test it. Let us know if the key-repeat problem is solved.

bushrat
Posts: 69
Joined: Mon Mar 05, 2012 8:35 pm

Re: Universal GPIO keyboard daemon

Mon May 20, 2013 5:02 am

Well, I just tested the software using the latest update, no luck.

As far as I can tell, the update didn't help.

In my efforts to try and solve it myself, I looked through config.c and and uncommented the debug comments. The software can definitely can tell when I'm pressing and releasing the button, but it won't repeat the key press.

I would imagine a while loop or similar could solve this issue, but I don't know.

If you make any more changes I should be able to test them immediately as I've taken my circuit home with me.

Sincerely, Bushrat

AirBurn
Posts: 4
Joined: Sun Apr 21, 2013 10:59 pm

Re: Universal GPIO keyboard daemon

Mon May 20, 2013 8:57 am

All,

I believe I found my problem:
The pins require pull-up resistors to 3V3 of 10k ohm, and the switches pull down. A 1K resistor in serial with the pin for protection doesn't hurt."
I didn't see this before. If I have a rev 2 board will I need the resistors, and if so will any 10k ohm resistor work? Like this one? (http://www.amazon.com/RESISTOR-METAL-FL ... m+resistor)

When I sudo pikeyd I get:

Code: Select all

Config file is /etc/pikeyd.conf
Polling 2 GPIO pin(s).
Found 0 I/O expander(s).
Ready.
Joystick init OK.
Press ^C to exit.
And my .conf is:

Code: Select all

#joy.cfg

#format:
# [keycode from /usr/include/linux/input.h] [whitespace] [GPIO pin no]
# Not limited to a single key. A GPIO press will emit all defined keys in order.

KEY_R		11
KEY_O		18

#define I/O expanders before using them
#XIO(tag) gpio_int_pin/chip_addr:register_no
#MCP23008 only has a single 8-bit bank
# XIO_M		17/0x20/MCP23008
#define an MCP23008 expander at address 0x20 with interrupt wired to GPIO-17

#MCP23017 has two 8-bit banks
#XIO_A		17/0x20/MCP23017A
#XIO_B		17/0x20/MCP23017B

# KEY_O		XIO_M:1
# KEY_L		XIO_M:2
# KEY_E		XIO_A:6
# KEY_E		XIO_B:6
Just looking for clarification that the resistors is the missing piece.

Thanks in advance!

bushrat
Posts: 69
Joined: Mon Mar 05, 2012 8:35 pm

Re: Universal GPIO keyboard daemon

Mon May 20, 2013 10:15 am

After having a chat with mmoller2k, we've nutted out a slightly neater circuit diagram for anyone looking to hook up an I2C chip to their Pi. Here it is:
Wiring 3.png
An updated I2C diagram.
Wiring 3.png (11.06 KiB) Viewed 7397 times
I hope this helps some ol' chap somewhere :)

mmoller2k
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm

Re: Universal GPIO keyboard daemon

Mon May 20, 2013 10:37 am

Airburn and Bushrat; yes, the pull-up resistors are not optional. Either on the keys themselves, when connecting directly, or on the interrupt pin when connecting through an expander.
Thanks for the diagram Bushrat.

bushrat
Posts: 69
Joined: Mon Mar 05, 2012 8:35 pm

Re: Universal GPIO keyboard daemon

Mon May 20, 2013 10:46 am

No prob mmoller2k :)

AirBurn
Posts: 4
Joined: Sun Apr 21, 2013 10:59 pm

Re: Universal GPIO keyboard daemon

Tue May 21, 2013 1:49 am

mmoller2k wrote:Airburn and Bushrat; yes, the pull-up resistors are not optional. Either on the keys themselves, when connecting directly, or on the interrupt pin when connecting through an expander.
Thanks for the diagram Bushrat.
Thanks for the reply. Adding the 10k resistors sorta works for me, but now I am having no luck troubleshooting my new problem. When I have only one button connected (using pin 18) I can get a letter to enter into the terminal every press without issues. When I introduce another button (having it's own resistor and using pin 13), the previous working button (connected to pin 18) does not work every press, and sometimes enters the letter multiple times. And the second button (pin 13) almost never enters a letter, and when it does it is the same letter that is set for pin 18.

As a side note I have also tried using pin 15 instead of pin 13 and tried having both buttons connected but commenting out the second button's line: it had the same outcome.

Code: Select all

#joy.cfg

#format:
# [keycode from /usr/include/linux/input.h] [whitespace] [GPIO pin no]
# Not limited to a single key. A GPIO press will emit all defined keys in order.

KEY_O		18
KEY_D		15

#define I/O expanders before using them
#XIO(tag) gpio_int_pin/chip_addr:register_no
#MCP23008 only has a single 8-bit bank
# XIO_M		17/0x20/MCP23008
#define an MCP23008 expander at address 0x20 with interrupt wired to GPIO-17

#MCP23017 has two 8-bit banks
#XIO_A		17/0x20/MCP23017A
#XIO_B		17/0x20/MCP23017B

# KEY_O		XIO_M:1
# KEY_L		XIO_M:2
# KEY_E		XIO_A:6
# KEY_E		XIO_B:6
Is there something I could be doing wrong or does anyone have an idea what could be happening?

Thanks all.

mmoller2k
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm

Re: Universal GPIO keyboard daemon

Wed May 22, 2013 7:43 am

Airburn, all I can think is that you need to check your power supply, and confirm that your pull-up resistors are indeed between 1k and 100k - anything in that range should work.

bushrat
Posts: 69
Joined: Mon Mar 05, 2012 8:35 pm

Re: Universal GPIO keyboard daemon

Thu May 23, 2013 1:57 am

Hey guys, a quick question to anyone who has this software currently working, can anyone get key repeat working in any program/command line?

By this, I mean, if anyone holds there button/switch down/closed, does the key keep pressing? e.g:

ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg

I've tried using an I2C chip AND wiring directly to the GPIO, no luck.

Is it just me? Or is someone, somewhere currently facing the same dilemma? Please answer guys, I really need to get these Joysticks going. Thanks :D

User avatar
Cia91
Posts: 89
Joined: Tue Jan 29, 2013 3:01 pm
Location: Pavia (italy)

Re: Universal GPIO keyboard daemon

Wed Jun 26, 2013 7:17 am

Hi all, i have some problem here...

here is my circuit:
Image

i don't have a pushbutton, so i simulate it by connecting ground to the line 20 of the board, with that red cable.

In the pikeyd.conf file i've only this line:

Code: Select all

KEY_5 12
ad i've added uinput to the /etc/modules.

Then i've added /usr/local/bin/pikeyd -d to rc.local file, in fact with htop i can see it in the running process.

What's wrong? :(

i can't get nothing in the terminal when i connect the red wire :(
Download GamePi OS: www.raspberrygaming.tk

m4xx
Posts: 2
Joined: Sat Aug 24, 2013 9:24 pm

Re: Universal GPIO keyboard daemon

Sat Aug 24, 2013 9:53 pm

Would it be possible for someone to put dots at the actual junction points? I'm a total noob and having a hard time following the diagram. Thanks!

m4xx
Posts: 2
Joined: Sat Aug 24, 2013 9:24 pm

Re: Universal GPIO keyboard daemon

Sun Aug 25, 2013 1:53 am

I believe i've wired everything as described.

Image

I've got the following config:

XIO_A 17/0x20/MCP23017A
XIO_B 17/0x20/MCP23017B

KEY_A XIO_B:5



When i run pikeyd in the terminal, i don't get any output. Anyone care to point me in the right direction?

DavidL
Posts: 13
Joined: Sat Aug 17, 2013 7:17 am

Re: Universal GPIO keyboard daemon

Sun Aug 25, 2013 12:34 pm

All,

I have forked off a branch in GitHub of this project and updated the configuration file parsing to be a little more flexible regarding comments and make it a little easier for me to include the extra functionality that I am looking at.

Fork is available here: https://github.com/Lencons/pikeyd

Reason I am posting this up is because I don't intend to use a I/O Expander and anyone out there that is willing to test that I haven't broken anything in the code in relation to I2C functionality would be appreciated.

My plan is to provide support for a key matrix rather than use an expander as there is more than enough I/O pins on the GPIO to handle all the buttons required for a 4-player cabinet in a matrix format.

Once that is done I will look at adding a "SHIFT" key capability, but one step at a time.

- Dave.

mmoller2k
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm

Re: Universal GPIO keyboard daemon

Mon Aug 26, 2013 12:36 am

Nice one Dave. That's what open source is all about. I like your old-school solution.

DavidL
Posts: 13
Joined: Sat Aug 17, 2013 7:17 am

Re: Universal GPIO keyboard daemon

Mon Aug 26, 2013 1:40 am

mmoller,

When I am sure that I haven't broken anything I2C, I will push it back into your master branch if your happy for me to do that.

Then I will get started on the Matrix functionality.

- Dave.

noob
Posts: 223
Joined: Sat Dec 08, 2012 3:58 pm

Re: Universal GPIO keyboard daemon

Thu Aug 29, 2013 3:24 pm

How Much ohm must the resistors have?

DavidL
Posts: 13
Joined: Sat Aug 17, 2013 7:17 am

Re: Universal GPIO keyboard daemon

Fri Sep 06, 2013 7:55 am

Cia91 wrote:Hi all, i have some problem here...

here is my circuit:
Image

i don't have a pushbutton, so i simulate it by connecting ground to the line 20 of the board, with that red cable.

In the pikeyd.conf file i've only this line:

Code: Select all

KEY_5 12
ad i've added uinput to the /etc/modules.

Then i've added /usr/local/bin/pikeyd -d to rc.local file, in fact with htop i can see it in the running process.

What's wrong? :(

i can't get nothing in the terminal when i connect the red wire :(
Cia91,

Did you ever resolve your issue here? The Pin number used in the pikeyd.conf file is the Broadcomm GPIO pin number and not the pin number on the RPi connector.

GPIO12 isn't available at the connector so I am assuming that your actually referring to PIN12 on the GPIO Connector. This is actually GPIO18, so try changing your config to:

Code: Select all

KEY_5 18
and see if that helps.

- Dave.

User avatar
Cia91
Posts: 89
Joined: Tue Jan 29, 2013 3:01 pm
Location: Pavia (italy)

Re: Universal GPIO keyboard daemon

Fri Sep 06, 2013 8:27 am

Yeah, i solved this month ago, the mistake was in the configuration like you think :D
Now i've made a pcb that connects directly to the gpio for my cabinet.

Image
Image

This is the old version, actual version also have 2 pin for powering the raspberry from gpio and faston for the connection with the control panel ;)
Download GamePi OS: www.raspberrygaming.tk

Return to “Gaming”