Comments (4)
Once you've changed the pin numbers in the array you will need to modify the call on line 425 to match:
setGpioPullUps(0xBC6C610);
So note down the GPIO pins you are using in ascending order, then organise that right to left with a leading 0. For example the above number corresponds to the pins for player 1 in the image on the github page:
PINS: 4,9,10,14,15,17,18,22,23,24,25,27
1011 1100 0110 1100 0110 0001 0000
The last zero on the right above is padding is padding, So counting right to left we can see the position of the 1s correspond to the pins. Take that binary and convert it to hex and you get 0xBC6C610.
Now my understanding the second line that calls the function is it's just setting all the pins to pull ups. You may not want this behaviour, especially if like me you have some of the pins being used for other tasks and they don't want pulling up. I think, though cannot yet confirm because of problems I've raised in #9 that you can modify that line too. I think you'd need to change it to cover the pins you using for P1 and P2. In my case that section of code reads:
case MK_ARCADE_GPIO:
for (i = 0; i < mk_max_arcade_buttons; i++) {
setGpioAsInput(mk_arcade_gpio_maps[i]);
}
setGpioPullUps(0x9C6C01C);
printk("GPIO configured for pad%d\n", idx);
break;
case MK_ARCADE_GPIO_BPLUS:
for (i = 0; i < mk_max_arcade_buttons; i++) {
setGpioAsInput(mk_arcade_gpio_maps_bplus[i]);
}
setGpioPullUps(0x40939E0 | 0x9C6C01C);
printk("GPIO configured for pad%d\n", idx);
break;
So I OR my two masks for the pins I use together. So if I just configure 1 joystick I get the masks for P1, and if I configure 2 joysticks it ors the P1 and P2 masks together.
Hope that makes sense, and of course is accurate. Hopefully the original developer can weigh in with any corrections for me.
from mk_arcade_joystick_rpi.
You can actually calculate the mask required from the array by iterating the array, bit shifting and using a logical OR. I plan to write that code but can't really do so until I solve the issue I'm having.
E.g.
int32_t mask = 0x0000000;
static const int mk_arcade_gpio_maps[] = {4, 17, 27, 22, 10, 9, 25, 24, 23, 18, 15, 14 };
for (int i=0; i<12;i++) {
int32_t pin_mask = 1<<mk_arcade_gpio_maps[i];
mask = mask | pin_mask;
}
above not tested but hopefully gives the idea.
from mk_arcade_joystick_rpi.
Hi, I actually have the same issue, as I cannot use GPIOs 14 & 15 on account of them being allocated for something else, but can basically use any of the GPIOs associated with a second joystick. How would it go if I wanted to swap GPIOs 14 & 15 for GPIOs 7 & 8?
Thanks so much in advance!
from mk_arcade_joystick_rpi.
I have no idea how I missed this comment for so long. Looking through the code and the readme as it stands now the concept I presented would appear to be in there. You can specify custom pin maps via module config now. Sweet. 👍
from mk_arcade_joystick_rpi.
Related Issues (20)
- Analog Joystick With arduino as adc? HOT 3
- RX data HOT 1
- Add support for MCP23S17 HOT 3
- Using const for mcp max buttons HOT 1
- mk_arcade_joystick_rpi not found - repository not found HOT 1
- Retropie 4.4 Error! Bad return status for module build on kernel: 4.14.30-v7+ (armv7l) HOT 10
- One button not work
- Custom pin always on
- linux-headers-4.9.35-v7+_4.9.35-v7+-2_armhf.deb
- hotkey input
- Branch hotkeybtn Imposes USB Audio Issue on Amiberry
- Install script has a 404 at the kernel headers HOT 4
- gpio for 2 joysticks problem
- recalbox 6.0-DragonBlaze /recalbox 4.1 gpio buttons do not work at zero but work at pi3 HOT 30
- setup_timer needs to be replaced by timer_setup HOT 2
- Can I use this driver at raspberry pi 4B ? HOT 9
- mk_arcade_joystick_rpi can
- mk_arcade_joystick_rpi not work at retropie 4.6 HOT 2
- Not working for RetroPie 4.8 on Pi Zero WH
- Add support for RGB-Pi Jamma hat
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mk_arcade_joystick_rpi.