Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Use device ID's for Lightgun/Mouse when using RawInput #218

Open
WarpedPolygon opened this issue Oct 31, 2024 · 0 comments
Open

Comments

@WarpedPolygon
Copy link

Using devise specific VID/PID ID's for mouse and lightguns will mitigate index switching.
I'm not sure if this is even possible so tell me to bugger off if not.

Just as some reference, here is how people are doing it with AHKs.

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

Run %ComSpec% /c "%A_ScriptDir%\ControllerRemap.exe" /list > list.txt ,, hide
Sleep 500

;***********************************
; Insert Controller ID/PID here
;***********************************
P1DeviceID = Controller (Xbox One For Windows)
P1DevicePID = ID=1
P2DeviceID = Controller (Xbox One For Windows)
P2DevicePID = ID=3
;***********************************

Loop, read, %A_ScriptDir%\list.txt
{
DeviceIndex := SubStr(A_LoopReadLine, 4 , 2)

if(DeviceIndex > 0 && DeviceIndex < 40) {
	if InStr(A_LoopReadLine, P1DevicePID) {
		if(DeviceIndex != P1DeviceID) {
			StringReplace, NewP1DeviceIndex, DeviceIndex, ., , all
		}
	}
	if InStr(A_LoopReadLine, P2DevicePID) {
		if(DeviceIndex != P2DeviceID) {
			StringReplace, NewP2DeviceIndex, DeviceIndex, ., , all
		}
	}
}

}
;***********************************
; Insert guns ID/PID here
;***********************************
P1DeviceGunID = VID_0000_PID_0000
P1DeviceGunPID = 0000
P2DeviceGunID = VID_0000_PID_0000
P2DeviceGunPID = 0000
;***********************************

Loop, read, %A_ScriptDir%\list.txt
{
DeviceIndex := SubStr(A_LoopReadLine, 4 , 1)

if(DeviceIndex > 0 && DeviceIndex < 30) {
	if InStr(A_LoopReadLine, P1DeviceGunPID) {
		if(DeviceIndex != P1DeviceGunID) {
			NewP1DeviceGunIndex = %DeviceIndex%
		}
	}
	if InStr(A_LoopReadLine, P2DeviceGunPID) {
		if(DeviceIndex != P2DeviceGunID) {
			NewP2DeviceGunIndex = %DeviceIndex%
		}
	}
}

}

if FileExist(A_ScriptDir "\Supermodel.exe") {

; modify values in SuperModel config file

; Common 
IniWrite, %A_Space%"KEY_1`,JOY%NewP1DeviceIndex%_BUTTON8`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputStart1
IniWrite, %A_Space%"KEY_2`,JOY%NewP2DeviceIndex%_BUTTON8`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputStart2
IniWrite, %A_Space%"KEY_3`,JOY%NewP1DeviceIndex%_BUTTON7`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputCoin1
IniWrite, %A_Space%"KEY_4`,JOY%NewP2DeviceIndex%_BUTTON7`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputCoin2

; 4-way digital joysticks (Fighting Vipers 2, Spikeout, Spikeout Final Edition, Virtua Fighter 3, Virtua Striker 2)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS_NEG`,JOY%NewP1DeviceIndex%_POV1_UP`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyUp
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS_POS`,JOY%NewP1DeviceIndex%_POV1_DOWN`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyDown
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS_NEG`,JOY%NewP1DeviceIndex%_POV1_LEFT`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyLeft
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS_POS`,JOY%NewP1DeviceIndex%_POV1_RIGHT`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyRight
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_YAXIS_NEG`,JOY%NewP2DeviceIndex%_POV1_UP`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyUp2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_YAXIS_POS`,JOY%NewP2DeviceIndex%_POV1_DOWN`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyDown2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_XAXIS_NEG`,JOY%NewP2DeviceIndex%_POV1_LEFT`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyLeft2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_XAXIS_POS`,JOY%NewP2DeviceIndex%_POV1_RIGHT`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJoyRight2

; Fighting game buttons (Fighting Vipers 2, Virtua Fighter 3)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputPunch
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputKick
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGuard
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON4", %A_ScriptDir%\Config\Supermodel.ini, Global, InputEscape
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputPunch2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputKick2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGuard2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON4", %A_ScriptDir%\Config\Supermodel.ini, Global, InputEscape2

; Spikeout button
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2`,JOY%NewP1DeviceIndex%_BUTTON6`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputShift
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputBeat
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputCharge
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON4", %A_ScriptDir%\Config\Supermodel.ini, Global, InputJump

; Virtua Striker button 
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputShortPass
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputLongPass
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputShoot
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputShortPass2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputLongPass2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputShoot2

; Steering wheel
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSteering

; Pedals 
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAccelerator
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_ZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputBrake

; Up/down shifter manual transmission (all racers - Dirt Devils, ECA, Harley-Davidson, Le Mans 24 are shift manual only)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON6", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGearShiftUp
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON5", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGearShiftDown

; 4-Speed manual transmission (Daytona 2, Sega Rally 2, Scud Race)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGearShift1
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGearShift2
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON4", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGearShift3
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGearShift4

; VR4 view change buttons (Daytona 2, Le Mans 24, Scud Race)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_POV1_UP", %A_ScriptDir%\Config\Supermodel.ini, Global, InputVR1
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_POV1_DOWN", %A_ScriptDir%\Config\Supermodel.ini, Global, InputVR2
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_POV1_LEFT", %A_ScriptDir%\Config\Supermodel.ini, Global, InputVR3
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_POV1_RIGHT", %A_ScriptDir%\Config\Supermodel.ini, Global, InputVR4

; Single view change button (Dirt Devils, ECA, Harley-Davidson, Sega Rally 2)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_POV1_UP", %A_ScriptDir%\Config\Supermodel.ini, Global, InputViewChange

; Handbrake (Sega Rally 2)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RYAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputHandBrake

; Harley-Davidson control
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputRearBrake
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputMusicSelect

; Virtual On macro
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RXAXIS_NEG", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyTurnLeft
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RXAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyTurnRight
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS_NEG", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyForward
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyReverse
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS_NEG", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyStrafeLeft
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyStrafeRight
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON4", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyJump
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyCrouch

; Virtual On button 
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_ZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyShot1
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyShot2
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3`,JOY%NewP1DeviceIndex%_BUTTON5`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyTurbo1
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2`,JOY%NewP1DeviceIndex%_BUTTON6`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTwinJoyTurbo2

; Ski Champ control 
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiX
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RXAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiY
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_ZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiPollLeft
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiPollRight
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiSelect1
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiSelect2
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON2", %A_ScriptDir%\Config\Supermodel.ini, Global, InputSkiSelect3

; Magical Truck Adventure control 
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputMagicalLever1
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_YAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputMagicalLever2
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputMagicalPedal1
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputMagicalPedal2

; Sega Bass Fishing / Get Bass control
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingRodX
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingRodY
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RXAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingStickX
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RYAXIS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingStickY
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_RZAXIS_POS", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingReel
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON3", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingCast
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1", %A_ScriptDir%\Config\Supermodel.ini, Global, InputFishingSelect

; Analog joystick (Star Wars Trilogy)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS_INV`,MOUSE%NewP1DeviceGunIndex%_XAXIS_INV", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogJoyX
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS_INV`,MOUSE%NewP1DeviceGunIndex%_YAXIS_INV", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogJoyY
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_ZAXIS_NEG`,JOY%NewP2DeviceIndex%_BUTTON3`,MOUSE%NewP1DeviceGunIndex%_LEFT_BUTTON", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogJoyTrigger
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1`,MOUSE%NewP1DeviceGunIndex%_RIGHT_BUTTON", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogJoyEvent

; Light guns (Lost World-only applies when set to 'gun' in Games.xml)
IniWrite, %A_Space%"KEY_A`,JOY%NewP1DeviceIndex%_BUTTON1`,MOUSE%NewP1DeviceGunIndex%_LEFT_BUTTON", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogTriggerLeft

IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS`,MOUSE%NewP1DeviceGunIndex%_XAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGunX
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS`,MOUSE%NewP1DeviceGunIndex%_YAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGunY
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_ZAXIS_NEG`,JOY%NewP2DeviceIndex%_BUTTON3`,MOUSE%NewP1DeviceGunIndex%_LEFT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTrigger
IniWrite, %A_Space%"MOUSE%NewP1DeviceGunIndex%_RIGHT_BUTTON`,JOY%NewP1DeviceIndex%_BUTTON1`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputOffscreen 

IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_XAXIS`,MOUSE%NewP2DeviceGunIndex%_XAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGunX2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_YAXIS`,MOUSE%NewP2DeviceGunIndex%_YAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputGunY2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_ZAXIS_NEG`,JOY%NewP1DeviceIndex%_BUTTON3`,MOUSE%NewP2DeviceGunIndex%_LEFT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputTrigger2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON1`,MOUSE%NewP2DeviceGunIndex%_RIGHT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputOffscreen2

; Analog guns (Ocean Hunter, LA Machineguns, Lost World-only applies when set to 'analog_gun' in Games.xml)
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_XAXIS`,MOUSE%NewP1DeviceGunIndex%_XAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogGunX
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_YAXIS`,MOUSE%NewP1DeviceGunIndex%_YAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogGunY
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_ZAXIS_NEG`,JOY%NewP2DeviceIndex%_BUTTON3`,MOUSE%NewP1DeviceGunIndex%_LEFT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogTriggerLeft
IniWrite, %A_Space%"JOY%NewP1DeviceIndex%_BUTTON1`,MOUSE%NewP1DeviceGunIndex%_RIGHT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogTriggerRight

IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_XAXIS`,MOUSE%NewP2DeviceGunIndex%_XAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogGunX2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_YAXIS`,MOUSE%NewP2DeviceGunIndex%_YAXIS`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogGunY2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_ZAXIS_NEG`,JOY%NewP1DeviceIndex%_BUTTON3`,MOUSE%NewP2DeviceGunIndex%_LEFT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogTriggerLeft2
IniWrite, %A_Space%"JOY%NewP2DeviceIndex%_BUTTON1`,MOUSE%NewP2DeviceGunIndex%_RIGHT_BUTTON`", %A_ScriptDir%\Config\Supermodel.ini, Global, InputAnalogTriggerRight2

}

ExitApp

@WarpedPolygon WarpedPolygon changed the title Request: Use devise ID's for Lightgun/Mouse when using RawInput Request: Use device ID's for Lightgun/Mouse when using RawInput Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant