Page 1 of 1

Using Battery Indicator Button as a Controller Button

Posted: Sun 31 Dec 2017 20:23
by StrangersWrath
I received my Raspiboy yesterday and absolutely love It! I had to reseat the dpad as it wasn't registering properly but it took a minute to fix, everything else was covered in the assembly guide and went pretty smoothly!

I do have a question related to Pierre's post on his kickstart page regarding using the battery indicator button as a controller button on the new 1.2 pcb.
Battery button is no longer a battey indicator button, it is now the GPIO 17 that was not used so far (it's from one of the audio pogo pins pair) So now this button will connect GPIO 17 to ground. So you can use it for different purpose such as : add a controller button if you need one more, make a soft shutdown button (?).
Is there anything I need to configure to get this reading as a controller input? It doesn't work in 'configure input' in emulationstation, so do I need to configure it elsewhere? Maybe the gpio has to be set in boot config, but I'm not too sure what I'm doing there if I'm honest, can anyone assist with that? Ideally I want to make it my 'hotkey enable' button.

Many thanks.

Re: Using Battery Indicator Button as a Controller Button

Posted: Tue 2 Jan 2018 14:42
by Graylag
It cannot be used as Controller Button - at least not in default state.

This button is connected to GPIO pins, that is as internal hardware signal. However in default setting Retropie recognizes only USB input devices and GPIO does not behave as one. In order to do so, you would have to configure the system to use GPIO signals as input device. However, even if you do so, this will not result in adding one more button to available controller but will instead create second controller. This means unless specific emulator can utilize inputs from two or more input devices at the same time, you cannot use main controll buttons and rear battery indicator button at the same time.

Re: Using Battery Indicator Button as a Controller Button

Posted: Tue 2 Jan 2018 18:32
by roostaar
There is an app called retrogame which appears to be exactly what we need here.

However, having installed it and mapped GPIO pin 17 to ESC, the button does not register in MAME or the Emulation Station configuration input.

https://learn.adafruit.com/retro-gaming ... s-software

Anyone else want to give this a go? Is this possible to work??

I think best use is to map the button to ESC, and the long press to TAB. Then you can exit and configure MAME4ALL without a keyboard and still have a 6-button controller.

All other emulators are libretro so use the RetroArch hotkeys.

'Select' in my experience is the best key to use as the hotkey, and only become the hotkey when you press a button combo.

Re: Using Battery Indicator Button as a Controller Button

Posted: Tue 2 Jan 2018 19:29
by roostaar
Posts taking ages to be moderated which is slowing down progress!! I thought first post might be moderated but after that would be instant?
---
I'm not sure which 'Pin 17' Pierre means....

Physical Pin 17 = 3.3v DC power
Physical Pin 11 = GPIO Pin 17

https://pinout.xyz/pinout/pin11_gpio17

If it's the GPIO Pin 17, then using retrogame should work...but it doesn't for me (yet).

Re: Using Battery Indicator Button as a Controller Button

Posted: Thu 4 Jan 2018 09:34
by Admin
It's GPIO 17 sorry for this was unclear!

And sorry about the need to validate the post, I receive a lot of spam so I had to implement that.
I'm looking for a moderator by the way to help validating the messages if you'r interested in helping me there :)

Re: Using Battery Indicator Button as a Controller Button

Posted: Thu 4 Jan 2018 10:05
by StrangersWrath
Thanks for the info.

Funnily enough, I came across the adafruit stuff when I was Googling a possible solution. I might have a stab at it the weekend. I think you're absolutely right that any other method would see it as another controller, so it wouldn't create the desired result anyway. Having it map as a keystroke might just be the closest thing we'll get (ideally I wanted it as the Hotkey enable button as I'm not using MAME4ALL).

If I get time over the weekend I may have a play around with adafruit and see if I can get anything working.

Re: Using Battery Indicator Button as a Controller Button

Posted: Thu 4 Jan 2018 15:10
by roostaar
Admin wrote:It's GPIO 17 sorry for this was unclear!

And sorry about the need to validate the post, I receive a lot of spam so I had to implement that.
I'm looking for a moderator by the way to help validating the messages if you'r interested in helping me there :)
Cheers Pierre, no worries about being unclear. 8-)

Sorry for being confused still, but are GPIO and BCM numbers the same?

Retrogame wants to know the BCM number to apply a keypress to.

According to my GPIO readout (see attached image), BCM 17 = wPi 0 = GPIO.0 = Mode 'IN' = Voltage 1 = Physical Pin 11

I have tried asking retrogame to address '17', '11' and '0' but neither seem to work.

Retrogame does require that the buttons are 'passive'. Is the Raspiboy battery button a 'passive' button?

Retrogame doesn’t work with my optical buttons!
Unfortunately, yes. retrogame only works with “passive” switches between a GPIO pin and ground (logic low=pressed). It won’t work with switches that have the opposite logic level (high=pressed).

This is probably a query for the adafruit forum, but it would be good to know what state the GPIO button is in first.

Hope you can help Pierre.

PS Would be happy to help moderate if you wish.

Re: Using Battery Indicator Button as a Controller Button

Posted: Thu 4 Jan 2018 16:46
by Shay
I was wondering what that button is for. So it has no default use on the current build of 8BCraft device? Does it allow checking battery status?

Re: Using Battery Indicator Button as a Controller Button

Posted: Thu 4 Jan 2018 18:08
by roostaar
Graylag wrote:It cannot be used as Controller Button - at least not in default state.

This button is connected to GPIO pins, that is as internal hardware signal. However in default setting Retropie recognizes only USB input devices and GPIO does not behave as one. In order to do so, you would have to configure the system to use GPIO signals as input device. However, even if you do so, this will not result in adding one more button to available controller but will instead create second controller. This means unless specific emulator can utilize inputs from two or more input devices at the same time, you cannot use main controll buttons and rear battery indicator button at the same time.
Ok! I get it now. :oops: I have configured retrogame to map GPIO 17 to keypress ESC and I can see when I launch a retroarch game, the GPIO 'controller' flashes up as 'not configured'. So this is indeed working as expected. EmulationStation also sees two gamepads if I go to 'configure input'. I cannot configure the GPIO button here as it is mapped to ESC.

I guess it will be impossible to set this button up as a keystroke for the built in USB gamepad? Pierre alluded to this being possible?

Anyone have any other suggestions of how to make use of this button?

As there is no useable retroarch emulator for mame on the zero, I was hoping to use the battery button to 'escape' and quit mame4all.

As a workaround, I mapped 'L' to ESC and 'R' to TAB for config.

This limits me to just 4 buttons in mame4all, but thats good enough for all but Street Fighter and the like.

Re: Using Battery Indicator Button as a Controller Button

Posted: Thu 4 Jan 2018 18:15
by StrangersWrath
Good work, although the results are disappointing it's certainly a step in the right direction!

On a side note, I use lr-mame2000 on my 4.3 build with pretty good results, and as it uses the ra core, the standard hotkeys apply.