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

Re: Universal GPIO keyboard daemon

Sun Mar 10, 2013 12:32 pm

Awesome! I just tried it and it works :D. Perfect.

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

Re: Universal GPIO keyboard daemon

Sun Mar 10, 2013 1:31 pm

PhillyNJ wrote:Awesome! I just tried it and it works :D. Perfect.
I'm glad I've managed to help someone :D

I figure the reason it doesn't work on auto is because on auto it AUTOmatically defines the first keyboard it sees as the only keyboard, where as raw tells it to get its information from the system instead.

So happy I found that preference, it would've been a real pain not being able to use custom buttons and a keyboard at the same time.

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

Re: Universal GPIO keyboard daemon

Sun Mar 10, 2013 4:21 pm

You have no idea how much this helped out. It was an absolute nightmare trying to work around this. Well done!

waltermixxx
Posts: 34
Joined: Wed May 09, 2012 7:21 pm
Location: Woodbridge, Ontario

Re: Universal GPIO keyboard daemon

Sun Mar 10, 2013 6:43 pm

The Wii arcade stick uses I2C and is a 3.3 volt device. http://www.amazon.com/Wii-Arcade-Stick- ... B002OTAD1Q

Could it be used instead of the mpc230017 chip? Has anyone tried it? It usually can be found at gamestop or ebgames for about $10.00.
Might be a quick and easy stick for the pi arcade...
Electronics for fun...
Raspberry Pi-1 Occidentalist, Tenda 311m x 2
Raspberry Pi-2 Raspbian Wheezy 07-15-12, Netgear N150 x1
Genius 8000 slimline wireless keyboard and mouse both work great with the usb wifi dongle right in the raspberry pi.

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

Re: Universal GPIO keyboard daemon

Tue Mar 12, 2013 10:19 am

Apparently there is still some confusion as to how to wire multiple switches to the GPIOs. I thought I'd drop this here for reference:
swcon.png
swcon.png (4.9 KiB) Viewed 5664 times

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

Re: Universal GPIO keyboard daemon

Tue Mar 12, 2013 11:04 am

mmoller2k wrote:Apparently there is still some confusion as to how to wire multiple switches to the GPIOs. I thought I'd drop this here for reference:
swcon.png
Thanks for the diagram. This really clears up a few issues in my design :D

RealElwood
Posts: 4
Joined: Thu Feb 28, 2013 11:23 am

Re: Universal GPIO keyboard daemon

Tue Mar 12, 2013 11:56 am

mmoller2k wrote:Apparently there is still some confusion as to how to wire multiple switches to the GPIOs.

Would you be so kind and clear out which GPIOS's should be used for a Rev. 1 PCB with 14 buttons?

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

Re: Universal GPIO keyboard daemon

Tue Mar 12, 2013 12:17 pm

Try the wiki: http://elinux.org/Rpi_Low-level_peripherals
According to this, the pins I/Os are
0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25
for rev 1, and
"on the Revision2.0 RaspberryPis, this list changes to: 2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27, with 28, 29, 30, 31 additionally available on the P5 header"
If you use the I2C pins you can omit the pull-up resistors, as these pins already have them.

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

Re: Universal GPIO keyboard daemon

Mon Mar 18, 2013 9:51 pm

W00T! Finally got my working prototype up and running. The below uses Pikeyd and UInput via the GPIO

http://instagram.com/p/XAfdiNSRFF/

mvc00134
Posts: 1
Joined: Mon Mar 25, 2013 9:06 pm

Re: Universal GPIO keyboard daemon

Mon Mar 25, 2013 9:10 pm

In regards to how to connect switches, I noticed on Chris Swan's blog that he was connecting a joystick to the GPIO and using the internal pull-up resistors so that no additional components were necessary.

http://blog.thestateofme.com/2012/08/10 ... -joystick/

See near the end of the posting.

Any thoughts on this? Is it possible to get away with not using resistors?

ErikH
Posts: 5
Joined: Tue Apr 02, 2013 8:25 pm

Re: Universal GPIO keyboard daemon

Sun Apr 07, 2013 7:21 pm

Thank you Mr. mmoller2k. I was implement your daemont into my RPi media center for controlling XBMC via buttons on front panel. It works like a charm.

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

Re: Universal GPIO keyboard daemon

Sun Apr 21, 2013 11:05 pm

Hi all,

I have tried to install pikeyd but I seem to be doing something wrong. Please bare with me as I am completely new to linux. I downloaded the zip from github to my windows machine. I extracted the zip to a folder named pikeyd and moved it onto the RPi (via winSCP) to /home/pi. Inside of that folder was the file "pikeyd" that I copied to /usr/local/bin and changed the chmod to rwxr-xr-x. I have a momentary push button hooked up to GPIO pin 18 and 3v3. When I press the button, I don't get an output in the terminal window. Can someon please help me get this to work? In the end I just need a button connected to pin 18 and 3v3 to output a letter to the terminal. it can be pretty much any letter!

Thanks in advance for any help!

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

Re: Universal GPIO keyboard daemon

Mon Apr 22, 2013 2:54 am

Hey AirBurn, first off, did you start the PiKeyD Daemon? You need to have it run as a Daemon to work with the terminal. Do this by running it as:

pikeyd -d

2nd, have you setup the conf file? This file is where you specify what GPIO pin does what key. 3rd, if you have setup the config file, are you certain you've labeled it right,

http://elinux.org/RPi_Low-level_periphe ... .28GPIO.29

This page is a good reference, just make sure you know what revision your Pi is, if it has 512MB of RAM then it's Revision 2, else it's 1.

After that the only thing that i could think to be wrong is your circuit. I'd double check to see if it's wired correctly, just in case. And if any of my information here is unclear, go back through the other pages of this thread, I'm certain all you need to know is in these posts.

Good Luck and happy coding :D

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

Re: Universal GPIO keyboard daemon

Wed Apr 24, 2013 9:53 pm

Hey AirBurn, first off, did you start the PiKeyD Daemon? You need to have it run as a Daemon to work with the terminal. Do this by running it as:

pikeyd -d

2nd, have you setup the conf file? This file is where you specify what GPIO pin does what key. 3rd, if you have setup the config file, are you certain you've labeled it right,

http://elinux.org/RPi_Low-level_periphe ... .28GPIO.29

This page is a good reference, just make sure you know what revision your Pi is, if it has 512MB of RAM then it's Revision 2, else it's 1.

After that the only thing that i could think to be wrong is your circuit. I'd double check to see if it's wired correctly, just in case. And if any of my information here is unclear, go back through the other pages of this thread, I'm certain all you need to know is in these posts.

Good Luck and happy coding :D
I have started it with -d, and I also added the line into the local file to start on every boot. It seems that when I navigate to the directory I placed the unziped files in through winSCP and type make, it does not create the pikeyd file. I only have the pikeyd.c and pikeyd.conf. Am I missing something?

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

Re: Universal GPIO keyboard daemon

Thu Apr 25, 2013 2:32 am

"Yes, it needs the uinput module. Load this manually with 'modprobe uinput', or automatically by adding 'uinput' to /etc/modules.
Then you need to run it as root, with perhaps the -d switch to make it ran as a daemon. Adding the line '/usr/local/bin/pikeyd -d' to /etc/rc.local makes it run as root at boot time.
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.
You define which pins does what by editing /etc/pikeyd.conf. One gpio pin can be defined to emit a series of characters as if it was a keyboard. That makes it compatible with whatever functions you want to control on whatever software - as long as it accepts keyboard input of course."

Found this in an earlier post. If the steps mentioned above dont work, try starting the PiKeyD Daemon and then unplug your Keyboard (if you have one plugged in)

Also, where are you testing the input, in the terminal or inside a program like Leafpad or MAME?

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

Re: Universal GPIO keyboard daemon

Tue Apr 30, 2013 1:48 pm

Hi,
I download and unzip the folder, but I tried to install without success.
I gave the command "sudo make" and move the file into /user/local/bin but after if i go to the console and i digit "pikeyd -d" i see this error:
pi@raspberrypi ~/Desktop/tastiera $ sudo pikeyd
/dev/i2c-1: No such file or directory
/root/.pikeyd.conf: No such file or directory
/etc/pikeyd.conf: No such file or directory
Polling 0 GPIO pin(s).
Found 0 I/O expander(s).
Ready.
Joystick init OK.
Press ^C to exit.
And the pikeyd doesn't works :(

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

Re: Universal GPIO keyboard daemon

Tue Apr 30, 2013 4:10 pm

Imercantanti, I believe to solve your problem, just read this:

"Usage: pikeyd [option]
Options:
-d run as daemon
-k try to terminate running daemon
-v version
-h this help

Install notes.
If you're using Raspbian wheezy add the folowing to /etc/modules:
uinput
i2c-dev

edit /etc/modprobe.d/raspi-blacklist.conf
and remove or comment out
#blacklist i2c-bcm2708"

After doing the steps mentioned above, make sure your config file is correct (pikeyd.conf). As you'll need to add in there what pins you want to trigger what key, so you need to tell pikeyd that you want pin 2 to be the letter "a".

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 9:20 am

This might be a noob question with a very obvious solution, but I have a problem.

I downloaded the .zip file from the github link. Unzipped it, changed directory to its location and ran "sudo make" but it just gives me a weird error 127

What am I doing wrong? I'm running Raspbmc. Any help would be appreciated, thanks.
Attachments
Error.JPG
Error after "sudo make" command
Error.JPG (58.58 KiB) Viewed 5279 times

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 11:00 am

Thanks bushrat for your reply, but where i can find:

uinput
i2c-dev

Thanks a lot in advance

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:06 pm

lmercatanti wrote:Thanks bushrat for your reply, but where i can find:

uinput
i2c-dev

Thanks a lot in advance
It's really simple, cause /etc/modules is actually a text file (.txt) so all you need to do is do:

"sudo nano /etc/modules"

This opens the file in nano (a command line text editor)
Then all you do is add:

uinput
i2c-dev

To the end of the file. Then do Control+O to save and press enter to confirm, then Control+X to exit. Then just reboot and hopefully it should work :D

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:19 pm

Thanks a lot again!
Now i have another problem :(

When i digit "pikeyd -d" the daemon start but if i push the button connect to input 17... Nothing!
If i digit "sudo pikeyid" this is the result and doesn't works:
pi@raspberrypi ~/Desktop/tastiera $ sudo pikeyd
Config file is /etc/pikeyd.conf
Line 23. No such expander: XIO_A
Line 24. No such expander: XIO_B
iic write data: Input/output error
iic init write 1
: Input/output error
iic write data: Input/output error
iic init write 2
: Input/output error
iic write data: Input/output error
Configuring MCP23008
Error writing to i2c: Input/output error
Error reading from i2c: Input/output error
Polling 1 GPIO pin(s).
Found 1 I/O expander(s).
Ready.
Joystick init OK.
Press ^C to exit.

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:22 pm

Have you also done this?

"edit /etc/modprobe.d/raspi-blacklist.conf
and remove or comment out
#blacklist i2c-bcm2708"

If you have and its still not working, could you post the contents of your pikeyd.cfg

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:34 pm

Yes, i commented "#blacklist i2c-bcm2708".
Now i clean the pikeyd.config to check if something changes.

Here the pikeyd.config (i move it to /etc/, right?)
#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
And this is the result when I digit "sudo pikeyd":

Code: Select all

pi@raspberrypi ~/Desktop/tastiera $ sudo pikeyd
Config file is /etc/pikeyd.conf
Polling 1 GPIO pin(s).
Found 0 I/O expander(s).
Ready.
Joystick init OK.
Press ^C to exit.
After this if i go to text editor and i push the button nothing happens.
The button works because i write a simple code that write in the console "button pushed" when i push the button

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:39 pm

Code: Select all

    pi@raspberrypi ~/Desktop/tastiera $ sudo pikeyd
    Config file is /etc/pikeyd.conf
    Polling 1 GPIO pin(s).
    Found 0 I/O expander(s).
    Ready.
    Joystick init OK.
    Press ^C to exit.
That's correct and it seems fine. But, instead of going to a text editor, just start PiKeyD and press your button and see if it works, DON'T press ^C. If it does work THEN press ^C and now try:

pikeyd -d

or

sudo pikeyd -d

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

Re: Universal GPIO keyboard daemon

Wed May 01, 2013 12:43 pm

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 :(

Return to “Gaming”