Jump to content
  • Announcement

    The HyperSpin 2 early access beta is here!

    We’re starting the first public testing phase with Platinum Members to keep the scope manageable while we test the current feature set and begin to add more. In the future, we’ll provide a version for basic members as well.  On behalf of the entire HyperSpin team, we look forward to another exciting adventure with our community.

Any chance that HyperSpin can support the new Ultimarc ServoStik?


RetroBorg

Recommended Posts

Posted

This is something that could be built into HyperLaunch...and should be fairly easy to add. However one would need to run a script or app to parse Mame to create an INI that HyperLaunch could read from to see if a game being passed is 4-way or 8-way.

Not a difficult task at all....except that I personally don't do AutoHotKey. :P

Posted

API Support (for programmers)

The Ultimarc PacDrive DLL incorporates support for the Servostik. It provides two API calls:

bool PacSetServoStik4Way();

bool PacSetServoStik8Way();

The DLL is part of the PacDrive SDK

Copy/Pasted from source page

Seems like it could be incorporated this way as well.

Edit: Somehow I skipped right over your post BBB, otherwise I probably wouldn't have bothered posting the above API.

Posted

Simple script to parse Mame for 4-way Joystick action...currently amounts to under 500 games...this assumes all other games are 8-way. It also lists number of players...so that might be useful for doing more than one joystick...

AutoIt Source

#Include <Array.au3>
#Include <Constants.au3>
#Include <File.au3>
#Include <String.au3>

Dim $Info_Games

; Select Mame Executable
If NOT FileExists( @ScriptDir & '\MameList.xml' ) Then
While 1
	$Mame = FileOpenDialog( 'Select Mame Executable.' , '' , 'Executables (*.exe)' , 1 + 4 )
	If @Error Then
	    MsgBox( 4096 , 'Error:' , 'No Executable Chosen.' )
	    Exit
	Else
		; Write Out Mame List XML
		RunWait ( @ComSpec & ' /c "' & $Mame & '" -listxml > MameList.xml' , @ScriptDir , @SW_HIDE )
		ExitLoop
	EndIf
WEnd
EndIf

; Read Mame List XMl
$Mame = FileOpen( @ScriptDir & '\MameList.xml' , 0 )
If $Mame = -1 Then
   MsgBox(0, "Error", "Unable to open MameList.xml")
   Exit
EndIf

; Read Mame List XML
$Info_Games = FileRead( $Mame )
FileClose( $Mame )

; Perform Basic RegEx
$Mame__Version	= StringRegExp( $Info_Games , '(?s)(?i)\s*?<mame build="(.+?) \(.+?\)" debug=".+?" mameconfig=".+?">' , 3 )
$Games_Total	= StringRegExp( $Info_Games , '(?s)(?i)\s*?(<game .+?</game>)' , 3 )

; Free Memory (Distroy Array)
$Info_Games  = ''

; Find All JoyStick Games
$JoyStick4 = _ArrayFindAll( $Games_Total , '<control type="joy" ways="4"' , 1 , 0 , 0 , 1 )

Dim $ReturnString
$ReturnString &= '[JoyStick Last]' & @CRLF
$ReturnString &= 'Position = '   & @CRLF & @CRLF
For $i = 0 To UBound( $JoyStick4 ) - 1
$RegExFind_01 = StringRegExp( $Games_Total[$JoyStick4[$i - 1]] , '(?s)(?i)<game name="(.+?)"' , 1 )
$RegExFind_02 = StringRegExp( $Games_Total[$JoyStick4[$i - 1]] , '(?s)(?i)(?:.+?<input players="(.+?)")?' , 1 )

$ReturnString &= '[' & $RegExFind_01[0] & ']' & @CRLF
$ReturnString &= 'Players = ' & $RegExFind_02[0] & @CRLF & @CRLF
Next

$INIFile = FileOpen( @ScriptDir & '\ServoStik.ini' , 2 )
FileWrite( $INIFile , $ReturnString )
FileClose( $INIFile )

Posted
Simple script to parse Mame for 4-way Joystick action...currently amounts to under 500 games...this assumes all other games are 8-way. It also lists number of players...so that might be useful for doing more than one joystick...

AutoIt Source

#Include <Array.au3>
#Include <Constants.au3>
#Include <File.au3>
#Include <String.au3>

Dim $Info_Games

; Select Mame Executable
If NOT FileExists( @ScriptDir & '\MameList.xml' ) Then
While 1
	$Mame = FileOpenDialog( 'Select Mame Executable.' , '' , 'Executables (*.exe)' , 1 + 4 )
	If @Error Then
	    MsgBox( 4096 , 'Error:' , 'No Executable Chosen.' )
	    Exit
	Else
		; Write Out Mame List XML
		RunWait ( @ComSpec & ' /c "' & $Mame & '" -listxml > MameList.xml' , @ScriptDir , @SW_HIDE )
		ExitLoop
	EndIf
WEnd
EndIf

; Read Mame List XMl
$Mame = FileOpen( @ScriptDir & '\MameList.xml' , 0 )
If $Mame = -1 Then
   MsgBox(0, "Error", "Unable to open MameList.xml")
   Exit
EndIf

; Read Mame List XML
$Info_Games = FileRead( $Mame )
FileClose( $Mame )

; Perform Basic RegEx
$Mame__Version	= StringRegExp( $Info_Games , '(?s)(?i)\s*?<mame build="(.+?) \(.+?\)" debug=".+?" mameconfig=".+?">' , 3 )
$Games_Total	= StringRegExp( $Info_Games , '(?s)(?i)\s*?(<game .+?</game>)' , 3 )

; Free Memory (Distroy Array)
$Info_Games  = ''

; Find All JoyStick Games
$JoyStick4 = _ArrayFindAll( $Games_Total , '<control type="joy" ways="4"' , 1 , 0 , 0 , 1 )

Dim $ReturnString
$ReturnString &= '[JoyStick Last]' & @CRLF
$ReturnString &= 'Position = '   & @CRLF & @CRLF
For $i = 0 To UBound( $JoyStick4 ) - 1
$RegExFind_01 = StringRegExp( $Games_Total[$JoyStick4[$i - 1]] , '(?s)(?i)<game name="(.+?)"' , 1 )
$RegExFind_02 = StringRegExp( $Games_Total[$JoyStick4[$i - 1]] , '(?s)(?i)(?:.+?<input players="(.+?)")?' , 1 )

$ReturnString &= '[' & $RegExFind_01[0] & ']' & @CRLF
$ReturnString &= 'Players = ' & $RegExFind_02[0] & @CRLF & @CRLF
Next

$INIFile = FileOpen( @ScriptDir & '\ServoStik.ini' , 2 )
FileWrite( $INIFile , $ReturnString )
FileClose( $INIFile )

Wow that was quick Kodiak, Chillinwater wrote something similar in Auto Hotkey for me a while back as I added a servo to two joysticks to switch from 4-way to 8-way but I found there was a bit of lag while the script ran before the game launched (approx 10 secs, I do have a slow computer though), I was just hoping BBB might consider adding this feature into HyperSpin now that Ultimarc are selling these joysticks, I'm sure they are going to be very popular.

Cheers.

Posted

Well that script just creates and INI file...so it's hardly a good prototype for AHK code to go into HyperLaunch...that said I don't see any benefit in this support being native to HyperSpin it's self...being in the launcher would work just as well.

As for Chillinwater's script...not sure why it would take so long...granted I'm short changing stuff as this only lists 4-way...so all one needs to do in AI is call:

IniReadSectionNames ( "filename" )

Which would give me an Array of all the games in the file and quick search of that array would tell me if I'm going 4-way or not....so all about 0.5sec on a old drive & system.

You got a link to Chillin's script...might be interesting to look at...I'm guessing he doesn't read the whole file into memory...and thus has several I/O requests to read the file.

Posted
Well that script just creates and INI file...so it's hardly a good prototype for AHK code to go into HyperLaunch...that said I don't see any benefit in this support being native to HyperSpin it's self...being in the launcher would work just as well.

As for Chillinwater's script...not sure why it would take so long...granted I'm short changing stuff as this only lists 4-way...so all one needs to do in AI is call:

IniReadSectionNames ( "filename" )

Which would give me an Array of all the games in the file and quick search of that array would tell me if I'm going 4-way or not....so all about 0.5sec on a old drive & system.

You got a link to Chillin's script...might be interesting to look at...I'm guessing he doesn't read the whole file into memory...and thus has several I/O requests to read the file.

Yeah I don't think there's anything wrong with Chillin's script, I guess it just takes a while to check the 4-way game list, my computer is pretty slow and well overdue for an update.

http://www.hyperspin-fe.com/forum/showthread.php?11271-Need-help-with-a-script-for-switching-Magsticks-with-a-servo&highlight=servo

Posted

Okay first off this Controls.ini that Chillin's script is reading from....does it contain both 4-way & 8-way?

The reason that I ask is because if it contains both values...it's a huge file to read through...which will slow things down. This is why the INI my script creates is limited to 4-way...smaller script...faster to read from disk...and faster to find what I'm looking for.

I'd assume all games are 8-way unless the game is listed in the INI...if it's present then it's automatically assumed that it's 4-way...the only thing after that is if it's more than one player...and given your prior setup...and the new suggested setup...that doesn't even matter as the current executable appears to rotate all controls of that type.

Now if this stuff was added to HyperLaunch via an Include or directly into the main script...it would save time far as disk access...as it would be pulled in just as HyperLauch is loaded....also by being in HyperLaunch one could set a variable and check it on exit to see what it's state is...if it's set to 4-way then return the controls to 8-way before exiting...if already set to 8-way do nothing and exit.

In AutoIt we have a command called:

IniReadSection ( "filename", "section" )

This reads a file and looks for a section...if it's not found it sets @Error to 1, else it returns an Array of values.

So if I was to do:

$MyArray = IniReadSection( @ScriptDir & "\Controls.ini", "puckman" )

If @Error Then

Do_Nothing

Else

Do_Something_To_Go_4_Way

EndIf

Or

$MyArray = IniReadSection( @ScriptDir & "\Controls.ini", "puckman" )

If NOT @Error Then

Do_Something_To_Go_4_Way

EndIf

And since puckman is a 4-way game it would return an Array, else it would set the Error flag and I can act accordingly.

Not sure if this helps you...but I would imagine that there should be something like this is AHK...maybe bug djvj to take a look at this...he's a wiz at AHK...course there is nothing like doing stuff yourself.

Anyways stuff like this should take less than a second even on an old 386...let alone what you are likely running now.

Posted

It would only need to be added to the mame module, not HL itself, which is left open source so anyone can add it themselves. Unless I have one of these sticks, I'm not interested in adding it myself right now. If someone wants to spend the time adding it to the mame module, I will add it to HyperList.

Posted

Well I "guess" something like the following would be added to the top and bottom of the Mame module...AHK is not my lang.

IniRead , CurrentGame , %a_scriptdir%\Controls.ini , %romName% , Players

; Test if We should Go 4-way
IfNotEqual ( CurrentGame = "ERROR" )
{
IniRead , Position , %a_scriptdir%\Controls.ini , "JoyStick Last" , Position

IfNotEqual ( Position = "4-way" )
{
	IniWrite , "4-way" , %a_scriptdir%\Controls.ini , "JoyStick Last" , Position
	Run %comspec% /c "usccmd --sub 0`,4"      ; (For 4-Way Mode)
	Run %comspec% /c "JoyTray -servo joy4way" ; (For 4-Way Mode) - ServoStik
}
}
Else
{
IniRead , Position , %a_scriptdir%\Controls.ini , "JoyStick Last" , Position

IfNotEqual ( Position = "8-way" )
{
	IniWrite , "8-way" , %a_scriptdir%\Controls.ini , "JoyStick Last" , Position
	Run %comspec% /c "usccmd --sub 0`,8"      ; (For 8-Way Mode)
	Run %comspec% /c "JoyTray -servo joy8way" ; (For 8-Way Mode) - ServoStik
}
}


<< Add Code >>


; Test if We should Go Back to 8-way
IfNotEqual ( CurrentGame = "ERROR" )
{
IniWrite , "8-way" , %a_scriptdir%\Controls.ini , "JoyStick Last" , Position
Run %comspec% /c "usccmd --sub 0`,8"      ; (For 8-Way Mode)
Run %comspec% /c "JoyTray -servo joy8way" ; (For 8-Way Mode) - ServoStik
}

Again this assumes that only 4-way games are listed in the Controls.ini...or whatever you wish to call your INI file...this also assumes that the sections are named after the roms short name...and that you have a key called Players set to some value...don't care what...just a value.

There will also need to be a section called "JoyStick Last" with a key called Position that is set to 8-way or 4-way...with 8-way being the default.

Note this is for the homemade servo outfit you made...and it's based in part on Chillin's script.

Posted

Hehe not sure about that...I noticed I made a mistake...and that I left out some code that should be in there as well...now I think it's good...maybe...hehe

There should be a reset to 8-way hotkey attached to a function...in this script...but also any other script/module in case of crash or hang preventing the joysticks returning to the default 8-way position.

Oh I'm fine with AutoIt...if anything I should be banging on C# or C++, besides you dont' want me stealing your glory now do you. :)

  • 7 months later...
  • 1 year later...
Posted

I know I'm bumping an old thread but it seems to be the most relevant topic based on my searches..

I recently ordered a servo-stick ( haven't got it in yet) has this been tested/confirmed working? is this still considered the best method or is there a newer method that people are using?

Posted

I don't know what has being done for that, but if you want to have a automatic selection, without the need to filling a ini file with the control type info, you could use the info contained on the listxml file about the control type to make the selection automatically for you.

As djvj said before, I really do not have the interesting of making the support for that as I do not have a servo-stick myself, but if you take a look at the mame module, every time that is runs, we call a function named ListXMLInfo that creates and reads the info inside the MAME created info file for the running game. Inside this info there is a field that have the type of controls for the current game. For example:

<input players="2" buttons="5" coins="4" service="yes" tilt="yes">
		<control type="joy" ways="8"/>

If you know a little bit of programming, you can see how things are done in the ListXMLInfo function and extend it to get also the info from the "ways" field to add a automatic change for your servo-stick without the need for any ini edit.

Posted

I'm looking at the U360 with the servo attachment (hopefully with rotary and RGB but haven't heard yet) as that will give me everything I could desire.

  • 4 months later...
Posted

Made some changes to the MAME.ahk as suggested in earlier post to try and get Ultimarc's ServoStick auto-switching. Hopefully it'll keep working as I continue with the rest of the software component of my cab.

Never looked at any AHK code before, so maybe there are better ways, but it'll do for me now.

I've attached my file here,.. just rename it,... see how you go.

Cheers,

Jim.....

Servo-MAME.ahk.txt

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...