N64 map buttons with Select+ Combo

Here is all the tutorials, FAQ and support for RetroStone
Post Reply
torofinance
Posts: 28
Joined: Thu 20 Sep 2018 14:24

N64 map buttons with Select+ Combo

Post by torofinance »

Played Ocarina of Time up until the time I am asked to play the Ocarina.

The obvious problem is that there are not enough buttons on the retrostone to map the complete controller of the N64.
Now, is there a way to configure - let's say - Select + A as one of the buttons? So that on the rare ocasion I do need them I can access them via a two-button combo?
User avatar
Admin
Administrateur du site
Posts: 505
Joined: Sat 10 Dec 2016 13:12

Re: N64 map buttons with Select+ Combo

Post by Admin »

I think this is possible to add in the GPIO driver.

I just did so, I have not tried it but it should work.

When you press Select + A, Select + B, Select + X, Select + Y it should trigger 4 virtual buttons.

However it will also trigger the buttons themself... So I am not sure it's the best way to do it. Also I think if you selected "select" as the hotkey in emulation station, you'll probably have a double behaviour. Note you can change Select button with another in the script below. Maybe R + A, R + B, R + Y and R+ X would be better.

If you want to test it you'll need to update the GPIO driver with the following one. I am actually not sure where to change the driver as it is preinstalled in retrorangepi. Best is to ask them how to do it.


Code: Select all

#!/usr/bin/env python


import evdev
import uinput
from time import sleep
from evdev import InputDevice, KeyEvent, UInput, AbsInfo, ecodes as e
from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector

#sleep(10)

events = ([
		uinput.BTN_A,
		uinput.BTN_B,
		uinput.BTN_C,
		uinput.BTN_X,
		uinput.BTN_Y,
		uinput.BTN_Z,
		uinput.BTN_TL,
		uinput.BTN_TR,
		uinput.BTN_THUMBL,
		uinput.BTN_THUMBR,
		uinput.BTN_SELECT,
		uinput.BTN_START,
		uinput.BTN_TL2,
		uinput.BTN_TR2,
		uinput.ABS_X + (0,255,0,0),
		uinput.ABS_Y + (0,255,0,0),
		uinput.BTN_TRIGGER_HAPPY1 = (0x01, 0x2c0),
		uinput.BTN_TRIGGER_HAPPY2 = (0x01, 0x2c1),
		uinput.BTN_TRIGGER_HAPPY3 = (0x01, 0x2c2),
		uinput.BTN_TRIGGER_HAPPY4 = (0x01, 0x2c3),
	])
#could use BTN_DPAD_UP BTN_DPAD_DOWN BTN_DPAD_LEFT BTN_DPAD_RIGHT but is it better?

gamepad = uinput.Device(events,"RetroStone Controle",0x00)

gamepad.emit(uinput.ABS_X, 128, syn=False)
gamepad.emit(uinput.ABS_Y, 128)

#--------------- define botoes -----------------
	# ---- PLAYER 1 ---------#
bt_up_p1 = port.PD12
bt_down_p1 = port.PD5
bt_left_p1 = port.PD0
bt_right_p1 = port.PD11

bt_l_p1 = port.PD6
bt_x_p1 = port.PD13
bt_y_p1 = port.PD9
bt_r_p1 = port.PD7
bt_b_p1 = port.PD15
bt_a_p1 = port.PD14

bt_select_p1 = port.PD4
bt_start_p1 = port.PD1

bt_left_trigger_p1 = port.PD8
bt_right_trigger_p1 = port.PD3

#optional buttons
bt_c_p1 = port.PC9
bt_z_p1 = port.PE3
bt_d_p1 = port.PA3
bt_e_p1 = port.PA15



#--------------------------------Initialize module. Always called first
gpio.init()

gpio.setcfg(bt_up_p1, gpio.INPUT)
gpio.pullup(bt_up_p1, gpio.PULLUP)

gpio.setcfg(bt_down_p1, gpio.INPUT)
gpio.pullup(bt_down_p1, gpio.PULLUP)

gpio.setcfg(bt_left_p1, gpio.INPUT)
gpio.pullup(bt_left_p1, gpio.PULLUP)

gpio.setcfg(bt_right_p1, gpio.INPUT)
gpio.pullup(bt_right_p1, gpio.PULLUP)


gpio.setcfg(bt_l_p1, gpio.INPUT)
gpio.pullup(bt_l_p1, gpio.PULLUP)

gpio.setcfg(bt_x_p1, gpio.INPUT)
gpio.pullup(bt_x_p1, gpio.PULLUP)

gpio.setcfg(bt_y_p1, gpio.INPUT)
gpio.pullup(bt_y_p1, gpio.PULLUP)

gpio.setcfg(bt_r_p1, gpio.INPUT)
gpio.pullup(bt_r_p1, gpio.PULLUP)

gpio.setcfg(bt_b_p1, gpio.INPUT)
gpio.pullup(bt_b_p1, gpio.PULLUP)

gpio.setcfg(bt_a_p1, gpio.INPUT)
gpio.pullup(bt_a_p1, gpio.PULLUP)

gpio.setcfg(bt_c_p1, gpio.INPUT)
gpio.pullup(bt_c_p1, gpio.PULLUP)

gpio.setcfg(bt_z_p1, gpio.INPUT)
gpio.pullup(bt_z_p1, gpio.PULLUP)

gpio.setcfg(bt_d_p1, gpio.INPUT)
gpio.pullup(bt_d_p1, gpio.PULLUP)

gpio.setcfg(bt_e_p1, gpio.INPUT)
gpio.pullup(bt_e_p1, gpio.PULLUP)

gpio.setcfg(bt_select_p1, gpio.INPUT)
gpio.pullup(bt_select_p1, gpio.PULLUP)

gpio.setcfg(bt_start_p1, gpio.INPUT)
gpio.pullup(bt_start_p1, gpio.PULLUP)

gpio.setcfg(bt_left_trigger_p1, gpio.INPUT)
gpio.pullup(bt_left_trigger_p1, gpio.PULLUP)

gpio.setcfg(bt_right_trigger_p1, gpio.INPUT)
gpio.pullup(bt_right_trigger_p1, gpio.PULLUP)

	
_bt_up_p1 = False
_bt_down_p1 = False
_bt_left_p1 = False
_bt_right_p1 = False
_bt_a_p1 = False
_bt_b_p1 = False
_bt_x_p1 = False
_bt_y_p1 = False
_bt_c_p1 = False
_bt_z_p1 = False
_bt_d_p1 = False
_bt_e_p1 = False
_bt_l_p1 = False
_bt_r_p1 = False
_bt_select_p1 = False
_bt_start_p1 = False
_bt_left_trigger_p1 = False
_bt_right_trigger_p1 = False
_bt_virtual_1 = False
_bt_virtual_2 = False
_bt_virtual_3 = False
_bt_virtual_4 = False

print gpio.input(bt_a_p1)

while True:
	#------ player 1 -----------#		
#bt a =====================
	if (not _bt_a_p1) and (gpio.input(bt_a_p1) == 0):
		_bt_a_p1 = True
		gamepad.emit(uinput.BTN_A, 1)	
	if (_bt_a_p1) and (gpio.input(bt_a_p1) == 1):
		_bt_a_p1 = False
		gamepad.emit(uinput.BTN_A, 0)	
#bt b =====================

	if (not _bt_b_p1) and (gpio.input(bt_b_p1) == 0):
		_bt_b_p1 = True
		gamepad.emit(uinput.BTN_B, 1)	
	if (_bt_b_p1) and (gpio.input(bt_b_p1) == 1):
		_bt_b_p1 = False
		gamepad.emit(uinput.BTN_B, 0)	

#bt X =====================

	if (not _bt_x_p1) and (gpio.input(bt_x_p1) == 0):
		_bt_x_p1 = True
		gamepad.emit(uinput.BTN_X, 1)	
	if (_bt_x_p1) and (gpio.input(bt_x_p1) == 1):
		_bt_x_p1 = False
		gamepad.emit(uinput.BTN_X, 0)	
#bt Y =====================

	if (not _bt_y_p1) and (gpio.input(bt_y_p1) == 0):
		_bt_y_p1 = True
		gamepad.emit(uinput.BTN_Y, 1)	
	if (_bt_y_p1) and (gpio.input(bt_y_p1) == 1):
		_bt_y_p1 = False
		gamepad.emit(uinput.BTN_Y, 0)	

#bt C =====================

	if (not _bt_c_p1) and (gpio.input(bt_c_p1) == 0):
		_bt_c_p1 = True
		gamepad.emit(uinput.BTN_C, 1)	
	if (_bt_c_p1) and (gpio.input(bt_c_p1) == 1):
		_bt_c_p1 = False
		gamepad.emit(uinput.BTN_C, 0)	
#bt Z =====================

	if (not _bt_z_p1) and (gpio.input(bt_z_p1) == 0):
		_bt_z_p1 = True
		gamepad.emit(uinput.BTN_Z, 1)	
	if (_bt_z_p1) and (gpio.input(bt_z_p1) == 1):
		_bt_z_p1 = False
		gamepad.emit(uinput.BTN_Z, 0)	

#bt D =====================

	if (not _bt_d_p1) and (gpio.input(bt_d_p1) == 0):
		_bt_d_p1 = True
		gamepad.emit(uinput.BTN_THUMBL, 1)	
	if (_bt_d_p1) and (gpio.input(bt_d_p1) == 1):
		_bt_d_p1 = False
		gamepad.emit(uinput.BTN_THUMBL, 0)	
#bt E =====================

	if (not _bt_e_p1) and (gpio.input(bt_e_p1) == 0):
		_bt_e_p1 = True
		gamepad.emit(uinput.BTN_THUMBR, 1)	
	if (_bt_e_p1) and (gpio.input(bt_e_p1) == 1):
		_bt_e_p1 = False
		gamepad.emit(uinput.BTN_THUMBR, 0)	
		
#bt L =====================
	if (not _bt_l_p1) and (gpio.input(bt_l_p1) == 0):
		_bt_l_p1 = True
		gamepad.emit(uinput.BTN_TL, 1)	
	if (_bt_l_p1) and (gpio.input(bt_l_p1) == 1):
		_bt_l_p1 = False
		gamepad.emit(uinput.BTN_TL, 0)	
#bt R =====================
	if (not _bt_r_p1) and (gpio.input(bt_r_p1) == 0):
		_bt_r_p1 = True
		gamepad.emit(uinput.BTN_TR, 1)	
	if (_bt_r_p1) and (gpio.input(bt_r_p1) == 1):
		_bt_r_p1 = False
		gamepad.emit(uinput.BTN_TR, 0)
#bt select =====================
	if (not _bt_select_p1) and (gpio.input(bt_select_p1) == 0):
		_bt_select_p1 = True
		gamepad.emit(uinput.BTN_SELECT, 1)	
	if (_bt_select_p1) and (gpio.input(bt_select_p1) == 1):
		_bt_select_p1 = False
		gamepad.emit(uinput.BTN_SELECT, 0)	
		_bt_virtual_1 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY1, 0)
		_bt_virtual_2 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY2, 0)
		_bt_virtual_3 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY3, 0)
		_bt_virtual_4 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY4, 0)

	#virtual button 1 on select		
	if (_bt_select_p1) and (not _bt_virtual_1) and (gpio.input(bt_a_p1) == 0):
		_bt_virtual_1 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY1, 1)
	if (_bt_select_p1) and (_bt_virtual_1) and (gpio.input(bt_a_p1) == 1):	
		_bt_virtual_1 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY1, 0)
	#virtual button 2 on select		
	if (_bt_select_p1) and (not _bt_virtual_2) and (gpio.input(bt_b_p1) == 0):
		_bt_virtual_2 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY2, 1)
	if (_bt_select_p1) and (_bt_virtual_2) and (gpio.input(bt_b_p1) == 1):	
		_bt_virtual_2 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY2, 0)
	#virtual button 3 on select		
	if (_bt_select_p1) and (not _bt_virtual_3) and (gpio.input(bt_x_p1) == 0):
		_bt_virtual_3 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY3, 1)
	if (_bt_select_p1) and (_bt_virtual_3) and (gpio.input(bt_x_p1) == 1):	
		_bt_virtual_3 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY3, 0)
	#virtual button 4 on select		
	if (_bt_select_p1) and (not _bt_virtual_4) and (gpio.input(bt_y_p1) == 0):
		_bt_virtual_4 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY4, 1)
	if (_bt_select_p1) and (_bt_virtual_4) and (gpio.input(bt_y_p1) == 1):	
		_bt_virtual_4 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY4, 0)		
		
		
#bt start =====================
	if (not _bt_start_p1) and (gpio.input(bt_start_p1) == 0):
		_bt_start_p1 = True
		gamepad.emit(uinput.BTN_START, 1)	
	if (_bt_start_p1) and (gpio.input(bt_start_p1) == 1):
		_bt_start_p1 = False
		gamepad.emit(uinput.BTN_START, 0)
#bt L2 =====================
	if (not _bt_left_trigger_p1) and (gpio.input(bt_left_trigger_p1) == 0):
		_bt_left_trigger_p1 = True
		gamepad.emit(uinput.BTN_TL2, 1)	
	if (_bt_left_trigger_p1) and (gpio.input(bt_left_trigger_p1) == 1):
		_bt_left_trigger_p1 = False
		gamepad.emit(uinput.BTN_TL2, 0)	
#bt R2 =====================
	if (not _bt_right_trigger_p1) and (gpio.input(bt_right_trigger_p1) == 0):
		_bt_right_trigger_p1 = True
		gamepad.emit(uinput.BTN_TR2, 1)	
	if (_bt_right_trigger_p1) and (gpio.input(bt_right_trigger_p1) == 1):
		_bt_right_trigger_p1 = False
		gamepad.emit(uinput.BTN_TR2, 0)	
####DIRECTIONS P1 ###########################

#bt up =====================
	if (not _bt_up_p1) and (gpio.input(bt_up_p1) == 0):
		_bt_up_p1 = True
		gamepad.emit(uinput.ABS_Y, 0)	
	if (_bt_up_p1) and (gpio.input(bt_up_p1) == 1):
		_bt_up_p1 = False
		gamepad.emit(uinput.ABS_Y, 128)
#bt down =====================
	if (not _bt_down_p1) and (gpio.input(bt_down_p1) == 0):
		_bt_down_p1 = True
		gamepad.emit(uinput.ABS_Y, 255)	
	if (_bt_down_p1) and (gpio.input(bt_down_p1) == 1):
		_bt_down_p1 = False
		gamepad.emit(uinput.ABS_Y, 128)
#bt left =====================
	if (not _bt_left_p1) and (gpio.input(bt_left_p1) == 0):
		_bt_left_p1 = True
		gamepad.emit(uinput.ABS_X, 0)	
	if (_bt_left_p1) and (gpio.input(bt_left_p1) == 1):
		_bt_left_p1 = False
		gamepad.emit(uinput.ABS_X, 128)
#bt right =====================
	if (not _bt_right_p1) and (gpio.input(bt_right_p1) == 0):
		_bt_right_p1 = True
		gamepad.emit(uinput.ABS_X, 255)	
	if (_bt_right_p1) and (gpio.input(bt_right_p1) == 1):
		_bt_right_p1 = False
		gamepad.emit(uinput.ABS_X, 128)
	
	sleep(.02)
torofinance
Posts: 28
Joined: Thu 20 Sep 2018 14:24

Re: N64 map buttons with Select+ Combo

Post by torofinance »

Ok asked here: http://orangepi.club/showthread.php?tid=2945

"Using R+KEY" to map the yellow buttons on the N64 controller is better, I agree.
Could you change the code to reflect that ...I'm not fluent enough to do so myself :cry:
User avatar
Admin
Administrateur du site
Posts: 505
Joined: Sat 10 Dec 2016 13:12

Re: N64 map buttons with Select+ Combo

Post by Admin »

Did you already tried previous code btw?

You mean up down right left buttons instead of ABXY ?

Should be like this. Can you test and let us know if it works? Have not tested it.

Code: Select all

#!/usr/bin/env python


import evdev
import uinput
from time import sleep
from evdev import InputDevice, KeyEvent, UInput, AbsInfo, ecodes as e
from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector

#sleep(10)

events = ([
		uinput.BTN_A,
		uinput.BTN_B,
		uinput.BTN_C,
		uinput.BTN_X,
		uinput.BTN_Y,
		uinput.BTN_Z,
		uinput.BTN_TL,
		uinput.BTN_TR,
		uinput.BTN_THUMBL,
		uinput.BTN_THUMBR,
		uinput.BTN_SELECT,
		uinput.BTN_START,
		uinput.BTN_TL2,
		uinput.BTN_TR2,
		uinput.ABS_X + (0,255,0,0),
		uinput.ABS_Y + (0,255,0,0),
		uinput.BTN_TRIGGER_HAPPY1 = (0x01, 0x2c0),
		uinput.BTN_TRIGGER_HAPPY2 = (0x01, 0x2c1),
		uinput.BTN_TRIGGER_HAPPY3 = (0x01, 0x2c2),
		uinput.BTN_TRIGGER_HAPPY4 = (0x01, 0x2c3),
	])
#could use BTN_DPAD_UP BTN_DPAD_DOWN BTN_DPAD_LEFT BTN_DPAD_RIGHT but is it better?

gamepad = uinput.Device(events,"RetroStone Controle",0x00)

gamepad.emit(uinput.ABS_X, 128, syn=False)
gamepad.emit(uinput.ABS_Y, 128)

#--------------- define botoes -----------------
	# ---- PLAYER 1 ---------#
bt_up_p1 = port.PD12
bt_down_p1 = port.PD5
bt_left_p1 = port.PD0
bt_right_p1 = port.PD11

bt_l_p1 = port.PD6
bt_x_p1 = port.PD13
bt_y_p1 = port.PD9
bt_r_p1 = port.PD7
bt_b_p1 = port.PD15
bt_a_p1 = port.PD14

bt_select_p1 = port.PD4
bt_start_p1 = port.PD1

bt_left_trigger_p1 = port.PD8
bt_right_trigger_p1 = port.PD3

#optional buttons
bt_c_p1 = port.PC9
bt_z_p1 = port.PE3
bt_d_p1 = port.PA3
bt_e_p1 = port.PA15



#--------------------------------Initialize module. Always called first
gpio.init()

gpio.setcfg(bt_up_p1, gpio.INPUT)
gpio.pullup(bt_up_p1, gpio.PULLUP)

gpio.setcfg(bt_down_p1, gpio.INPUT)
gpio.pullup(bt_down_p1, gpio.PULLUP)

gpio.setcfg(bt_left_p1, gpio.INPUT)
gpio.pullup(bt_left_p1, gpio.PULLUP)

gpio.setcfg(bt_right_p1, gpio.INPUT)
gpio.pullup(bt_right_p1, gpio.PULLUP)


gpio.setcfg(bt_l_p1, gpio.INPUT)
gpio.pullup(bt_l_p1, gpio.PULLUP)

gpio.setcfg(bt_x_p1, gpio.INPUT)
gpio.pullup(bt_x_p1, gpio.PULLUP)

gpio.setcfg(bt_y_p1, gpio.INPUT)
gpio.pullup(bt_y_p1, gpio.PULLUP)

gpio.setcfg(bt_r_p1, gpio.INPUT)
gpio.pullup(bt_r_p1, gpio.PULLUP)

gpio.setcfg(bt_b_p1, gpio.INPUT)
gpio.pullup(bt_b_p1, gpio.PULLUP)

gpio.setcfg(bt_a_p1, gpio.INPUT)
gpio.pullup(bt_a_p1, gpio.PULLUP)

gpio.setcfg(bt_c_p1, gpio.INPUT)
gpio.pullup(bt_c_p1, gpio.PULLUP)

gpio.setcfg(bt_z_p1, gpio.INPUT)
gpio.pullup(bt_z_p1, gpio.PULLUP)

gpio.setcfg(bt_d_p1, gpio.INPUT)
gpio.pullup(bt_d_p1, gpio.PULLUP)

gpio.setcfg(bt_e_p1, gpio.INPUT)
gpio.pullup(bt_e_p1, gpio.PULLUP)

gpio.setcfg(bt_select_p1, gpio.INPUT)
gpio.pullup(bt_select_p1, gpio.PULLUP)

gpio.setcfg(bt_start_p1, gpio.INPUT)
gpio.pullup(bt_start_p1, gpio.PULLUP)

gpio.setcfg(bt_left_trigger_p1, gpio.INPUT)
gpio.pullup(bt_left_trigger_p1, gpio.PULLUP)

gpio.setcfg(bt_right_trigger_p1, gpio.INPUT)
gpio.pullup(bt_right_trigger_p1, gpio.PULLUP)

	
_bt_up_p1 = False
_bt_down_p1 = False
_bt_left_p1 = False
_bt_right_p1 = False
_bt_a_p1 = False
_bt_b_p1 = False
_bt_x_p1 = False
_bt_y_p1 = False
_bt_c_p1 = False
_bt_z_p1 = False
_bt_d_p1 = False
_bt_e_p1 = False
_bt_l_p1 = False
_bt_r_p1 = False
_bt_select_p1 = False
_bt_start_p1 = False
_bt_left_trigger_p1 = False
_bt_right_trigger_p1 = False
_bt_virtual_1 = False
_bt_virtual_2 = False
_bt_virtual_3 = False
_bt_virtual_4 = False

print gpio.input(bt_a_p1)

while True:
	#------ player 1 -----------#		
#bt a =====================
	if (not _bt_a_p1) and (gpio.input(bt_a_p1) == 0):
		_bt_a_p1 = True
		gamepad.emit(uinput.BTN_A, 1)	
	if (_bt_a_p1) and (gpio.input(bt_a_p1) == 1):
		_bt_a_p1 = False
		gamepad.emit(uinput.BTN_A, 0)	
#bt b =====================

	if (not _bt_b_p1) and (gpio.input(bt_b_p1) == 0):
		_bt_b_p1 = True
		gamepad.emit(uinput.BTN_B, 1)	
	if (_bt_b_p1) and (gpio.input(bt_b_p1) == 1):
		_bt_b_p1 = False
		gamepad.emit(uinput.BTN_B, 0)	

#bt X =====================

	if (not _bt_x_p1) and (gpio.input(bt_x_p1) == 0):
		_bt_x_p1 = True
		gamepad.emit(uinput.BTN_X, 1)	
	if (_bt_x_p1) and (gpio.input(bt_x_p1) == 1):
		_bt_x_p1 = False
		gamepad.emit(uinput.BTN_X, 0)	
#bt Y =====================

	if (not _bt_y_p1) and (gpio.input(bt_y_p1) == 0):
		_bt_y_p1 = True
		gamepad.emit(uinput.BTN_Y, 1)	
	if (_bt_y_p1) and (gpio.input(bt_y_p1) == 1):
		_bt_y_p1 = False
		gamepad.emit(uinput.BTN_Y, 0)	

#bt C =====================

	if (not _bt_c_p1) and (gpio.input(bt_c_p1) == 0):
		_bt_c_p1 = True
		gamepad.emit(uinput.BTN_C, 1)	
	if (_bt_c_p1) and (gpio.input(bt_c_p1) == 1):
		_bt_c_p1 = False
		gamepad.emit(uinput.BTN_C, 0)	
#bt Z =====================

	if (not _bt_z_p1) and (gpio.input(bt_z_p1) == 0):
		_bt_z_p1 = True
		gamepad.emit(uinput.BTN_Z, 1)	
	if (_bt_z_p1) and (gpio.input(bt_z_p1) == 1):
		_bt_z_p1 = False
		gamepad.emit(uinput.BTN_Z, 0)	

#bt D =====================

	if (not _bt_d_p1) and (gpio.input(bt_d_p1) == 0):
		_bt_d_p1 = True
		gamepad.emit(uinput.BTN_THUMBL, 1)	
	if (_bt_d_p1) and (gpio.input(bt_d_p1) == 1):
		_bt_d_p1 = False
		gamepad.emit(uinput.BTN_THUMBL, 0)	
#bt E =====================

	if (not _bt_e_p1) and (gpio.input(bt_e_p1) == 0):
		_bt_e_p1 = True
		gamepad.emit(uinput.BTN_THUMBR, 1)	
	if (_bt_e_p1) and (gpio.input(bt_e_p1) == 1):
		_bt_e_p1 = False
		gamepad.emit(uinput.BTN_THUMBR, 0)	
		
#bt L =====================
	if (not _bt_l_p1) and (gpio.input(bt_l_p1) == 0):
		_bt_l_p1 = True
		gamepad.emit(uinput.BTN_TL, 1)	
	if (_bt_l_p1) and (gpio.input(bt_l_p1) == 1):
		_bt_l_p1 = False
		gamepad.emit(uinput.BTN_TL, 0)	
#bt R =====================
	if (not _bt_r_p1) and (gpio.input(bt_r_p1) == 0):
		_bt_r_p1 = True
		gamepad.emit(uinput.BTN_TR, 1)	
	if (_bt_r_p1) and (gpio.input(bt_r_p1) == 1):
		_bt_r_p1 = False
		gamepad.emit(uinput.BTN_TR, 0)
#bt select =====================
	if (not _bt_select_p1) and (gpio.input(bt_select_p1) == 0):
		_bt_select_p1 = True
		gamepad.emit(uinput.BTN_SELECT, 1)	
	if (_bt_select_p1) and (gpio.input(bt_select_p1) == 1):
		_bt_select_p1 = False
		gamepad.emit(uinput.BTN_SELECT, 0)	
		_bt_virtual_1 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY1, 0)
		_bt_virtual_2 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY2, 0)
		_bt_virtual_3 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY3, 0)
		_bt_virtual_4 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY4, 0)

	#virtual button 1 on select		
	if (_bt_select_p1) and (not _bt_virtual_1) and (gpio.input(bt_up_p1) == 0):
		_bt_virtual_1 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY1, 1)
	if (_bt_select_p1) and (_bt_virtual_1) and (gpio.input(bt_up_p1) == 1):	
		_bt_virtual_1 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY1, 0)
	#virtual button 2 on select		
	if (_bt_select_p1) and (not _bt_virtual_2) and (gpio.input(bt_down_p1) == 0):
		_bt_virtual_2 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY2, 1)
	if (_bt_select_p1) and (_bt_virtual_2) and (gpio.input(bt_down_p1) == 1):	
		_bt_virtual_2 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY2, 0)
	#virtual button 3 on select		
	if (_bt_select_p1) and (not _bt_virtual_3) and (gpio.input(bt_left_p1) == 0):
		_bt_virtual_3 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY3, 1)
	if (_bt_select_p1) and (_bt_virtual_3) and (gpio.input(bt_left_p1) == 1):	
		_bt_virtual_3 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY3, 0)
	#virtual button 4 on select		
	if (_bt_select_p1) and (not _bt_virtual_4) and (gpio.input(bt_right_p1) == 0):
		_bt_virtual_4 = True
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY4, 1)
	if (_bt_select_p1) and (_bt_virtual_4) and (gpio.input(bt_right_p1) == 1):	
		_bt_virtual_4 = False
		gamepad.emit(uinput.BTN_TRIGGER_HAPPY4, 0)		
		
		
#bt start =====================
	if (not _bt_start_p1) and (gpio.input(bt_start_p1) == 0):
		_bt_start_p1 = True
		gamepad.emit(uinput.BTN_START, 1)	
	if (_bt_start_p1) and (gpio.input(bt_start_p1) == 1):
		_bt_start_p1 = False
		gamepad.emit(uinput.BTN_START, 0)
#bt L2 =====================
	if (not _bt_left_trigger_p1) and (gpio.input(bt_left_trigger_p1) == 0):
		_bt_left_trigger_p1 = True
		gamepad.emit(uinput.BTN_TL2, 1)	
	if (_bt_left_trigger_p1) and (gpio.input(bt_left_trigger_p1) == 1):
		_bt_left_trigger_p1 = False
		gamepad.emit(uinput.BTN_TL2, 0)	
#bt R2 =====================
	if (not _bt_right_trigger_p1) and (gpio.input(bt_right_trigger_p1) == 0):
		_bt_right_trigger_p1 = True
		gamepad.emit(uinput.BTN_TR2, 1)	
	if (_bt_right_trigger_p1) and (gpio.input(bt_right_trigger_p1) == 1):
		_bt_right_trigger_p1 = False
		gamepad.emit(uinput.BTN_TR2, 0)	
####DIRECTIONS P1 ###########################

#bt up =====================
	if (not _bt_up_p1) and (gpio.input(bt_up_p1) == 0):
		_bt_up_p1 = True
		gamepad.emit(uinput.ABS_Y, 0)	
	if (_bt_up_p1) and (gpio.input(bt_up_p1) == 1):
		_bt_up_p1 = False
		gamepad.emit(uinput.ABS_Y, 128)
#bt down =====================
	if (not _bt_down_p1) and (gpio.input(bt_down_p1) == 0):
		_bt_down_p1 = True
		gamepad.emit(uinput.ABS_Y, 255)	
	if (_bt_down_p1) and (gpio.input(bt_down_p1) == 1):
		_bt_down_p1 = False
		gamepad.emit(uinput.ABS_Y, 128)
#bt left =====================
	if (not _bt_left_p1) and (gpio.input(bt_left_p1) == 0):
		_bt_left_p1 = True
		gamepad.emit(uinput.ABS_X, 0)	
	if (_bt_left_p1) and (gpio.input(bt_left_p1) == 1):
		_bt_left_p1 = False
		gamepad.emit(uinput.ABS_X, 128)
#bt right =====================
	if (not _bt_right_p1) and (gpio.input(bt_right_p1) == 0):
		_bt_right_p1 = True
		gamepad.emit(uinput.ABS_X, 255)	
	if (_bt_right_p1) and (gpio.input(bt_right_p1) == 1):
		_bt_right_p1 = False
		gamepad.emit(uinput.ABS_X, 128)
	
	sleep(.02)
torofinance
Posts: 28
Joined: Thu 20 Sep 2018 14:24

Re: N64 map buttons with Select+ Combo

Post by torofinance »

Seems to be messed up completely after replacing the file ... :(


Image
Last edited by torofinance on Mon 3 Dec 2018 20:08, edited 1 time in total.
torofinance
Posts: 28
Joined: Thu 20 Sep 2018 14:24

Re: N64 map buttons with Select+ Combo

Post by torofinance »

Ok, I was able to - in Linux - change the file back to the original on the SD card -> retrostone booting up fine again :mrgreen:
I assume the file you sent contains errors? Can you fix & check?
torofinance
Posts: 28
Joined: Thu 20 Sep 2018 14:24

Re: N64 map buttons with Select+ Combo

Post by torofinance »

So - figured it out. ...I am posting it here if anyone ever wants to play Zelda on Retrostone and has similar problems
----No need to replace any files----

Steps:
  • Use the "lr-mupen64plus" emulator - this also supports the normal Retroarch Menu Image
  • Enter the Controls-Menu and change the mapping ... (here is a supporting table, "Actual Key on Pad" means Retrostone button) Image
  • Here is my control mapping, all buttons mapped except L1 (useless in Zelda anyway) Image
-> Sidenote: Y- is actually Y+ (error in Retropie I assume, that's why Up key is mapped with Y- which is actually Y+)
Post Reply