diff --git a/board/recalbox/fsoverlay/recalbox/share_init/system/.emulationstation/lightgun.xml b/board/recalbox/fsoverlay/recalbox/share_init/system/.emulationstation/lightgun.xml index 8997f09422e3ad35917d0c1fb648716f7b857039..6bc14f83f27ac71e9b43dd5a1bb2bd81d080a35c 100644 --- a/board/recalbox/fsoverlay/recalbox/share_init/system/.emulationstation/lightgun.xml +++ b/board/recalbox/fsoverlay/recalbox/share_init/system/.emulationstation/lightgun.xml @@ -1169,4 +1169,17 @@ + + + + + + + + + + + + + diff --git a/projects/configgen/configgen/generators/supermodel/supermodelControllers.py b/projects/configgen/configgen/generators/supermodel/supermodelControllers.py index 941caf66510d2fa0e05299b18d047a27e517781f..d300ce6d82c5075fceb69424336000d24c5f299a 100644 --- a/projects/configgen/configgen/generators/supermodel/supermodelControllers.py +++ b/projects/configgen/configgen/generators/supermodel/supermodelControllers.py @@ -14,8 +14,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): ################ Mapping Conversion Supermodel to Recalbox ################ # set recalbox Hotkey - HOTKEY_BUTTONS: Dict[str, int] = \ - { + HOTKEY_BUTTONS: Dict[str, int] = { "InputUIExit": InputItem.ItemStart, "InputUISaveState": InputItem.ItemY, "InputUIChangeSlot": InputItem.ItemUp, @@ -25,16 +24,14 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): "InputUIPause": InputItem.ItemB, } - SERVICE_TEST_BUTTON: Dict[str, int] = \ - { + SERVICE_TEST_BUTTON: Dict[str, int] = { "InputServiceA": InputItem.ItemL3, "InputTestA": InputItem.ItemR3, } ##################### Player 1 controllers ############################### - BUTTONS_P1: Dict[str, int] = \ - { + BUTTONS_P1: Dict[str, int] = { "InputCoin1": InputItem.ItemSelect, "InputStart1": InputItem.ItemStart, # Fighting game buttons @@ -77,7 +74,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): "InputGearShiftUp": InputItem.ItemR1, # 4-Speed manual transmission (Daytona 2, Sega Rally 2, Scud Race) # unsettings N - "InputGearShiftN": -1, + "InputGearShiftN": "-1", # VR4 view change buttons (Daytona 2, Le Mans 24, Scud Race) "InputVR1": InputItem.ItemY, "InputVR2": InputItem.ItemX, @@ -88,10 +85,10 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): # Sega Bass Fishing / Get Bass controls "InputFishingCast": InputItem.ItemY, "InputFishingSelect": InputItem.ItemA, + } - DIGITAL_JOYSTICK_P1: Dict[str, int] = \ - { + DIGITAL_JOYSTICK_P1: Dict[str, int] = { "InputJoyUp": InputItem.ItemUp, "InputJoyDown": InputItem.ItemDown, "InputJoyLeft": InputItem.ItemLeft, @@ -128,19 +125,17 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): "InputFishingStickY": InputItem.ItemJoy1Up, } - BUTTONS_AXIS: Dict[str, int] = \ - { - #### NEED A BYPASS BUTTON OR AXIS #### + BUTTONS_AXIS: Dict[str, int] = { + # NEED A BYPASS BUTTON OR AXIS #### # Pedals "InputAccelerator": InputItem.ItemR2, "InputBrake": InputItem.ItemL2, - #### NEED A BYPASS BUTTON OR AXIS #### + # NEED A BYPASS BUTTON OR AXIS #### "InputFishingReel": InputItem.ItemL2, "InputFishingTension": InputItem.ItemR2, } - ANALOG_JOYSTICK_P1: Dict[str, int] = \ - { + ANALOG_JOYSTICK_P1: Dict[str, int] = { # Need setting all axis position (POS/NEG) # Virtual On individual joystick mapping "InputTwinJoyDown1": InputItem.ItemJoy1Down, @@ -159,8 +154,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): "InputGearShift4": InputItem.ItemJoy2Right, } - MOUSE_GAME: Dict[str, int] = \ - { + MOUSE_GAME: Dict[str, int] = { # Light guns (Lost World) "InputGunX": InputItem.ItemJoy1Left, "InputGunY": InputItem.ItemJoy1Up, @@ -170,12 +164,35 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): # Analog joystick (Star Wars Trilogy) "InputAnalogJoyX": InputItem.ItemJoy1Left, "InputAnalogJoyY": InputItem.ItemJoy1Up, + # Trigger for gun + "InputTrigger": InputItem.ItemA, + "InputAnalogJoyTrigger": InputItem.ItemA, + "InputAnalogJoyEvent": InputItem.ItemB, + "InputAnalogTriggerLeft": InputItem.ItemL2, + "InputAnalogTriggerRight": InputItem.ItemR2, + } + + GUNCON_JOY: Dict[str, str] = { + # Light guns (Lost World) + "InputGunX": "XAXIS", + "InputGunY": "YAXIS", + # Analog guns (Ocean Hunter, LA Machineguns) + "InputAnalogGunX": "XAXIS", + "InputAnalogGunY": "YAXIS", + # Analog joystick (Star Wars Trilogy) + "InputAnalogJoyX": "XAXIS", + "InputAnalogJoyY": "YAXIS", + # Trigger for gun + "InputTrigger": "BUTTON6", + "InputAnalogJoyTrigger": "BUTTON6", + "InputAnalogJoyEvent": "BUTTON8", + "InputAnalogTriggerLeft": "BUTTON6", + "InputAnalogTriggerRight": "BUTTON8", } ####################### Players 2 controllers ############################ - BUTTONS_P2: Dict[str, int] = \ - { + BUTTONS_P2: Dict[str, int] = { # Commons buttons "InputCoin2": InputItem.ItemSelect, "InputStart2": InputItem.ItemStart, @@ -192,8 +209,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): "InputMagicalPedal2": InputItem.ItemB, } - DIGITAL_JOYSTICK_P2: Dict[str, int] = \ - { + DIGITAL_JOYSTICK_P2: Dict[str, int] = { "InputJoyDown2": InputItem.ItemDown, "InputJoyLeft2": InputItem.ItemLeft, "InputJoyRight2": InputItem.ItemRight, @@ -206,15 +222,13 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): ###### Map an Recalbox direction to the corresponding Supermodel ###### - TYPE_TO_NAME: Dict[int, str] = \ - { + TYPE_TO_NAME: Dict[int, str] = { InputItem.TypeAxis: 'AXIS', InputItem.TypeButton: 'BUTTON', InputItem.TypeHat: 'POV', } - HATS_TO_NAME: Dict[int, str] = \ - { + HATS_TO_NAME: Dict[int, str] = { 1: 'UP', 2: 'RIGHT', 4: 'DOWN', @@ -229,8 +243,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): 'up': 'UP', }""" - SUPERMODEL_JOY: Dict[int, str] = \ - { + SUPERMODEL_JOY: Dict[int, str] = { # lEFT JOYSTICK InputItem.ItemJoy1Down: 'YAXIS', InputItem.ItemJoy1Left: 'XAXIS', @@ -244,6 +257,57 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): # AXIS ON L2/R2 BUTTONS InputItem.ItemL2: 'ZAXIS', InputItem.ItemR2: 'RZAXIS', + # JAMMA + InputItem.ItemDown: 'DOWN', + InputItem.ItemLeft: 'LEFT', + InputItem.ItemRight: 'RIGHT', + InputItem.ItemUp: 'UP', + } + + JAMMA_CONTROL_P1: Dict[str, int] = { + # Fighting game buttons + "InputGuard": InputItem.ItemY, + "InputPunch": InputItem.ItemA, + "InputKick": InputItem.ItemB, + "InputEscape": InputItem.ItemX, + # Spikeout buttons + "InputShift": InputItem.ItemY, + "InputBeat": InputItem.ItemA, + "InputCharge": InputItem.ItemB, + "InputJump": InputItem.ItemX, + # Virtua Striker buttons + "InputShortPass": InputItem.ItemA, + "InputLongPass": InputItem.ItemB, + "InputShoot": InputItem.ItemX, + # Pedals + "InputAccelerator": InputItem.ItemA, + "InputBrake": InputItem.ItemB, + # Handbrake (Dirt Devils, Sega Rally 2) + "InputHandBrake": InputItem.ItemX, + # Single view change button (Dirt Devils, ECA, Harley-Davidson, Sega Rally 2) + "InputViewChange": InputItem.ItemY, + # VR4 view change buttons (Daytona 2, Le Mans 24, Scud Race) + "InputVR1": -1, + "InputVR2": -1, + "InputVR3": -1, + "InputVR4": -1, + } + + JAMMA_CONTROL_P2: Dict[str, int] = { + # Fighting game buttons + "InputGuard": InputItem.ItemY, + "InputPunch": InputItem.ItemA, + "InputKick": InputItem.ItemB, + "InputEscape": InputItem.ItemX, + # Spikeout buttons + "InputShift": InputItem.ItemY, + "InputBeat": InputItem.ItemA, + "InputCharge": InputItem.ItemB, + "InputJump": InputItem.ItemX, + # Virtua Striker buttons + "InputShortPass": InputItem.ItemA, + "InputLongPass": InputItem.ItemB, + "InputShoot": InputItem.ItemX, } def getConfigValue(inputItem: InputItem, targetConf: Dict[str, int]): @@ -252,7 +316,10 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): return '{}{}'.format(TYPE_TO_NAME[inputItem.Type], inputItem.Id + 1) # Output format RYAXIS, RXAXIS, XAXIS, YAXIS if inputItem.IsAxis: - return '{}'.format(SUPERMODEL_JOY[targetConf[x]]) + if x in targetConf: + return '{}'.format(SUPERMODEL_JOY[targetConf[x]]) + else: + return '' # Output format POV1_DOWN if inputItem.IsHat: return '{}{}_{}'.format(TYPE_TO_NAME[inputItem.Type], inputItem.Id + 1, HATS_TO_NAME[inputItem.Value]) @@ -265,7 +332,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): def getConfigValueJ2(inputItem: InputItem): return getConfigValue(inputItem, DIGITAL_JOYSTICK_P2) - # More Games need a Position value of Axis + # More Games need a Position value of Axis def getPositionConfigValue(inputItem: InputItem): if inputItem.IsAxis: # Output format XAXIS_NEG/XAXIS_POS ,RXAXIS_NEG/RXAXIS_POS @@ -286,8 +353,11 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): raise TypeError def getlightGunConfigValue(inputItem: InputItem): + if inputItem.IsAxis: - return 'MOUSE_{}'.format(SUPERMODEL_JOY[MOUSE_GAME[x]]) + return 'JOY{}_{}'.format(pad.SdlIndex + 1, SUPERMODEL_JOY[MOUSE_GAME[x]]) + else: + return '' raise TypeError @@ -338,7 +408,6 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): supermodelControllersSettings.setString(self.SECTION_GLOBAL, "InputJoy2RZDeadZone", deadzone) \ .setString(self.SECTION_GLOBAL, "InputJoy2XDeadZone", deadzone) - # Set Saturation analog configurable in ConfigModel3.ini saturation = supermodelSettings.getString("saturation", "") # joystick1 Players 1 @@ -362,9 +431,12 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): if pad.PlayerIndex != 1: continue - # increase +1 controller index + # increase +1 controller index padIndex = 'JOY{}'.format(pad.SdlIndex + 1) + is_jamma = pad.DeviceName.startswith("JammaController") + is_guncon = pad.DeviceName.startswith("Namco GunCon 2") + # Add hotkey buttons for x in HOTKEY_BUTTONS: if pad.HasInput(HOTKEY_BUTTONS[x]): @@ -377,7 +449,7 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): if pad.HasInput(SERVICE_TEST_BUTTON[x]): inp = pad.Input(SERVICE_TEST_BUTTON[x]) ServiceBtn = supermodelSettings.getString("service-button", "") - if ServiceBtn == "1" : + if ServiceBtn == "1": supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}_{}"'.format(padIndex, getConfigValueJ1(inp))) else: supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, "NONE") @@ -397,6 +469,14 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): inp = pad.Input(ANALOG_JOYSTICK_P1[x]) supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}_{}"'.format(padIndex, getPositionConfigValue(inp))) + if is_jamma: + for x in JAMMA_CONTROL_P1: + if JAMMA_CONTROL_P1[x] != -1: + print("CONFIGURE P1") + supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}_BUTTON{}"'.format(padIndex, JAMMA_CONTROL_P1[x] + 1)) + else: + supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '') + for x in BUTTONS_AXIS: if pad.HasInput(BUTTONS_AXIS[x]): inp = pad.Input(BUTTONS_AXIS[x]) @@ -407,6 +487,10 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): inp = pad.Input(MOUSE_GAME[x]) supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}"'.format(getlightGunConfigValue(inp))) + if is_guncon: + for x in GUNCON_JOY: + supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}_{}"'.format(padIndex, GUNCON_JOY[x])) + if pad.PlayerIndex == 2: continue @@ -422,6 +506,19 @@ def generateControllerConfig(self, playersControllers: ControllerPerPlayer): inp = pad.Input(DIGITAL_JOYSTICK_P2[x]) supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}_{}"'.format(padIndex, getConfigValueJ2(inp))) + if pad.PlayerIndex == 2 and is_guncon: + padIndexj1 = 'JOY{}'.format(pad.SdlIndex + 1) + for x in GUNCON_JOY: + supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '"{}_{},{}_{}"'.format(padIndexj1, GUNCON_JOY[x], padIndex, GUNCON_JOY[x])) + + if pad.PlayerIndex == 2 and is_jamma: + for x in JAMMA_CONTROL_P2: + if JAMMA_CONTROL_P2[x] != -1: + print("CONFIGURE P2") + supermodelControllersSettings.setString(self.SECTION_GLOBAL, "{}2".format(x), '"{}_BUTTON{}"'.format(padIndex, JAMMA_CONTROL_P2[x] + 1)) + else: + supermodelControllersSettings.setString(self.SECTION_GLOBAL, x, '') + break # Save configuration