Need help getting retropie to recognize button matrix.
-
So I am designing a handheld arcade system and I am using a 4x3 matrix for the button system. I have 12 of these on/off pushbuttons as well as 2 analog sticks that will be separate from the matrix.
I am using 7 pins to read 12 buttons (4 input pins and 3 output). I have done it this way to save space on the GPIO board for other necessary components.
My script currently uses a function to store a 1 or 0 in the the following variables based on which button is pressed within the matrix:
dUp
dDown
dLeft
dRight
buttonA
buttonB
buttonX
buttonY
buttonSel
buttonStart
buttonR
buttonLIf a 1 is stored in one of these buttons, this means the corresponding button is currently being pressed.
If buttonA is equal to 1, how do I get that to reflect in retropie? Is there a function I can call in my script? Do I have to include my python script within a retropie script? The matrix setup is necessary for my design.
-
Emulators and EmulationStation don't know about your GPIO inputs, you need to translate them into an input device, that can be detected and used by it.
You can use theuinput
python module to create a 'virtual' keyboard or gamepad and add events to it, based on the GPIO input. You can see an example in the Adafruit RetroGame project. -
Thanks for your reply mitu, It is hard to say from the example in the project alone, but I believe this may be what I am looking for. From my understanding, if I utilize uinput in my script, I can write an algorithm to basically make it so if buttonA == 1, the pi will register key "a" as being inputted correct? Or is my understanding of uinput wrong? Unfortunately I do not have too much time to look at the documentation tonight so I will have to look into this more tomorrow.
-
@madman5000 I think the Python
uinput
module is what you need, so when you have the time go over its documentation and look at some examples, then go over the Adafruit script again, it will probably make more sense then. -
Thanks for your help. Between the documentation and the example, I have the button matrix somewhat working I think.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.