Universal GPIO keyboard daemon


131 posts   Page 2 of 6   1, 2, 3, 4, 5, 6
by atvdude01 » Fri Jan 25, 2013 11:45 pm
think someone could who knows c can do it? just learned python so i want to stick with it for a bit... ill look into it for python if no one does it.... how much more cpu would python need than in C if you could estimate.... and do u think it would affect mame speed?
Posts: 21
Joined: Wed Oct 03, 2012 8:01 pm
by Møller » Mon Jan 28, 2013 7:34 am
PhillyNJ wrote:Thanks - got it to display "5" in the console but Advmame is not liking it.. Trying PiMame. I'll keep you posted


Dear PhillyNJ,
I had same problems were it showed in console but Pimame was not getting it.
I found that if I disconnected my USB keyboard the inputs started to work with Pimame.
I read somewhere that it can not accept two keyboards and that is why uinput did not work.

SOLUTION: Remove your USB keyboard and boot again without.
Posts: 1
Joined: Sun Nov 11, 2012 1:51 pm
by PhillyNJ » Fri Feb 01, 2013 1:03 pm
Thanks, I'll give it a try. As a note I got it working with a different build:

Code: Select all
https://github.com/BirchJD/advancemame-0.106.1-RPi


The clone already has a compiled version. So no need to build :D

I had to tweak the config file, but got it working. I'll try your suggestion too. Whats cool is I can use my keyboard also. Give it a try.

Thanks!
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by PhillyNJ » Sun Feb 03, 2013 2:37 pm
Just a followup - after trying get all my buttons working, I was unable to wire up the joystick. So, I tried your suggestion (disconnect the keyboard) and it works. Thx again!
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by mmoller2k » Mon Feb 04, 2013 12:36 pm
Due to popular demand I've added I2C polling for MCP23008 and MCP23017 I/O expanders.
This is in a new branch here: https://github.com/mmoller2k/pikeyd/tree/iic
Consider it a beta release. Once I get independent confirmation that it works, I'll merge it with the master branch.
The interrupt output pins are configured open-drain, so multiple pins from multiple chips can be wired together. Don't forget to add a pull-up resistor on the interrupt pin and to tie the reset pin to VDD. The expanders can also be run at 5V if you only pull-up to 3V3.
The internal pull-ups are activated, so none are needed on the switches themselves.
Here's the diagram:
wiring.png
wiring.png (21.23 KiB) Viewed 2134 times
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm
by mmoller2k » Thu Feb 07, 2013 5:49 am
Thank you atvdude01 for all your patience. Together we found and squashed some bugs in my code, and all seems to be working now.
I've merged the I2C I/O expander support into the main branch at https://github.com/mmoller2k/pikeyd
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm
by GR4NT » Fri Feb 15, 2013 12:21 am
I have successfully configured the GPIO to simulate key presses and have it working when activated manually however whenever I run it via rc.local the Raspberry pi won't let me press ^c. Instead it just shows ^C on the line bellow. Do you know any way around this?
Posts: 3
Joined: Thu Feb 14, 2013 11:36 pm
by mmoller2k » Sun Feb 17, 2013 2:48 am
I'm not sure I understand. What are you trying to do with the ^C? Are you trying to have pikeyd generate a ^C, or are you trying to interrupt it using a ^C? Are you running it with the -d switch to run it in the background? The ^C only works for stopping the program if it is running in the foreground.
Posts: 31
Joined: Fri Dec 28, 2012 2:52 pm
by mykey1968 » Wed Feb 27, 2013 10:21 am
HAY,
I got a problem
i can see the keys in the console output,
but pimame doesn't.
Have you got an idea?
THanks a lot
Mike
Posts: 4
Joined: Wed Feb 27, 2013 10:15 am
by mrpi64 » Wed Feb 27, 2013 11:00 am
Nice!
I'm happy to help.
http://goo.gl/TAUaLS - List of games that work on the Pi.
User avatar
Posts: 789
Joined: Sat Feb 16, 2013 5:13 pm
by PhillyNJ » Wed Feb 27, 2013 12:19 pm
See below the response from Møller:

Møller wrote:I had same problems were it showed in console but Pimame was not getting it.
I found that if I disconnected my USB keyboard the inputs started to work with Pimame.
I read somewhere that it can not accept two keyboards and that is why uinput did not work.

SOLUTION: Remove your USB keyboard and boot again without.


This works. It is a bit of a pain while you are configuring your Pi and the controls, but it works.
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by SSilver2k2 » Wed Feb 27, 2013 7:08 pm
I will be looking at this this week. This is awesome stuff.
My blog of various geeky things - http://blog.sheasilverman.com
DeskCade.com - Mini Raspberry Pi Arcade Cabinet
PiMAME - http://pimame.org
Posts: 177
Joined: Wed Jun 06, 2012 1:51 am
Location: United States
by RealElwood » Thu Feb 28, 2013 11:32 am
I'm gonna give this a go. I've bulit my cabinett with 10 buttons(1 player, 2 player, credit, exit B1-B6) and a 4/8 way joystick. So i need 14 IO's.

I have a rev. 1 board. can i use any GPIO pins or is there some that wont work?

found this in the joy_RPI.c
"// Raspberry Pi V1 GPIO
//static int GPIO_Pin[] = { 0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25 };
// Raspberry Pi V2 GPIO
//static int GPIO_Pin[] = { 2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27 };
//MameBox pins
//static int GPIO_Pin[] = { 4, 17, 18, 22, 23, 24, 10, 25, 11, 8, 7 };"

Does this mean i can only use 11 GPIO as MameBox pins says or is the complete array from V1 available? I need 14.

/Mathias
Posts: 4
Joined: Thu Feb 28, 2013 11:23 am
by PhillyNJ » Thu Feb 28, 2013 12:46 pm
You can use 17 pins:

2,3,4,17,27,22,10,9,11,14,15,18,23,24,25,8 & 7.

I would personally not use 14 TX and 15 RX. I like to keep these pins free in case I ever need to add functionality. These pins are for serial communication and can be used and expanded :D .

Good luck.

My rig has 10 buttons also, including the 4-way joystick. I am interested in seeing your final PCB when your done.
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by RealElwood » Thu Feb 28, 2013 1:44 pm
PhillyNJ wrote:You can use 17 pins:

2,3,4,17,27,22,10,9,11,14,15,18,23,24,25,8 & 7.

I would personally not use 14 TX and 15 RX. I like to keep these pins free in case I ever need to add functionality. These pins are for serial communication and can be used and expanded :D .

Good luck.

My rig has 10 buttons also, including the 4-way joystick. I am interested in seeing your final PCB when your done.


Rev. 1 don't have pins 2, 3, 27 but i have 0, 1, 21.

So i should go with:
4,17,22,10,9,11,14,15,18,23,24,25,8 & 7???
Posts: 4
Joined: Thu Feb 28, 2013 11:23 am
by GuardianBob » Thu Feb 28, 2013 2:58 pm
Wow, um, I had a similar problem I solved in a completely different way.
http://www.powerfulboard.com/

This chip is easy to configure. Making it a USB HID keyboard was simple using this app note:
http://www.cypress.com/?rID=40103

The limitation on this solution is you can only read 6 real keys at once. Modifiers, such as ctrl/shift/alt are all encoded into the first byte so you technically could do more that 6. The limitation is due to how USB HID works for keyboards, not the chip.
Posts: 15
Joined: Mon Feb 04, 2013 1:41 pm
by PhillyNJ » Fri Mar 01, 2013 12:55 am
GuardianBob wrote:Wow, um, I had a similar problem I solved in a completely different way.
http://www.powerfulboard.com/


Awesome stuff. I choose to build mine from scratch. I started in January and building the control was a blast. I learned about wiring, resistors, switches, GPIO and Python. I could of bought an iPac but that was too easy. :geek:

My Mame arcade is almost done. My only issue is when its finished I'll have to buy another Pi :D
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by PhillyNJ » Fri Mar 01, 2013 1:03 am
RealElwood wrote:So i should go with:
4,17,22,10,9,11,14,15,18,23,24,25,8 & 7???


I would do some more research. I am not 100% sure.
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by mykey1968 » Sat Mar 02, 2013 6:39 am
OK,
Disconnecting the keyboard will make the GPIOs work.
But i wanted to keep the keyboard connected for other things.
I read something about the multiple keyboard in mame.ini
can anybody help me about that.

Thanks
Mike ;)
Posts: 4
Joined: Wed Feb 27, 2013 10:15 am
by PhillyNJ » Sat Mar 02, 2013 12:30 pm
mykey1968 wrote:OK,
Disconnecting the keyboard will make the GPIOs work.
But i wanted to keep the keyboard connected for other things.
I read something about the multiple keyboard in mame.ini
can anybody help me about that.

Thanks
Mike ;)

I read this http://forum.arcadecontrols.com/index.php?topic=116469.0. Give it a try and report back. I would like to know if that solves the issue.
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by mykey1968 » Sat Mar 02, 2013 12:52 pm
This is funny I already tried to figure out how this works
(the link you posted)
, but i can't (i didn't find the keymap)
:oops:
Posts: 4
Joined: Wed Feb 27, 2013 10:15 am
by PhillyNJ » Sat Mar 02, 2013 1:08 pm
I havent tried this, so I am not sure it works. Try

Code: Select all
<gamename> -multikeyboard


From the command line

Ref: http://easyemu.mameworld.info/Mame%20Guide.pdf
Posts: 109
Joined: Sat Dec 29, 2012 4:07 am
by mykey1968 » Mon Mar 04, 2013 11:20 am
Hay I tried it out.

I havent tried this, so I am not sure it works. Try

Code: Select all
<gamename> -multikeyboard


but it does not work
only if i disconnect the usb kb the buttons are recognized.
Can anybody help me.
Thanks
Mike
Posts: 4
Joined: Wed Feb 27, 2013 10:15 am
by RealElwood » Mon Mar 04, 2013 12:18 pm
PhillyNJ wrote:
RealElwood wrote:So i should go with:
4,17,22,10,9,11,14,15,18,23,24,25,8 & 7???


I would do some more research. I am not 100% sure.


Kind of hoping to find the answer here, I'll give it a try when i can find the time and comeback with the results.
Posts: 4
Joined: Thu Feb 28, 2013 11:23 am
by bushrat » Sun Mar 10, 2013 10:39 am
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.
Posts: 58
Joined: Mon Mar 05, 2012 8:35 pm