Author Topic: Ultimarc ServoStik Plugin  (Read 4560 times)

TomCoder

  • Newbie
  • *
  • Posts: 1
    • View Profile
Ultimarc ServoStik Plugin
« on: September 22, 2017, 04:57:11 PM »
A while back there was a question posted as to whether a plugin exists for the Ultimarc ServoStik.
http://forum.attractmode.org/index.php?topic=855.msg7485#msg7485
I recently installed a ServoStik and needed that very thing, so I created one.
It executes the Ultimarc ServoStik Joytray application to set the ServoStik to 4-way before the game is loaded and back to 8-way when the game is ended. Control information must be present in the romlist file. Switching to 4-way occurs when the "Control" information for the rom in the romlist is equal to "4-Way Joystick".

protocolgeorge

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Ultimarc ServoStik Plugin
« Reply #1 on: November 28, 2017, 08:34:52 PM »
Awesome idea...Thank you.  However I seem to having trouble getting the plugin to work.  I placed the .nut file in the "plugins" folder and I see it in attract mode, but I can only enable or disable it.  There does not seem be any additional configuration possible and it does not seem to work.  Any advice would be greatly appreciated.  Thanks again.

skeeboe

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Ultimarc ServoStik Plugin
« Reply #2 on: December 30, 2017, 12:28:04 PM »
I've tried everything I can think of to make this nut work.

I'm using Windows 10, and MAME and MsPacman as a test.

I've tried changing the trigger, different paths, verified the config, etc etc. I've even removed the "if" portion so it should just trigger on every game 4-way in, 8-way out. No joy.

The stick switching works when I use command prompt, or any other method. Not sure what's different between OPs implementation in AM and mine.

If anyone wants to post their fully-functional nut file, configured with their own directories etc, please do!

Arcadefan1

  • Full Member
  • ***
  • Posts: 27
    • View Profile
Re: Ultimarc ServoStik Plugin
« Reply #3 on: December 31, 2017, 03:15:58 AM »
Hi skeeboe,
Here is mine. It works for my setup. I think you need to check what your "(fe.game_info( Info.Control )" actually contains in your setup. That's what I needed to change to get it working here...

I also added the option to switch it to 4-way when it's actually a 2-way stick game.
And I only set it when entering a game. When leaving a game I don't switch at all, because in my Layout it doesn't matter if it's 4-way or 8-way.


Code: [Select]
///////////////////////////////////////////////////
//
// Attract-Mode Frontend - JoyTray plugin
//
// For use with the Ultimarc ServoStik
//
///////////////////////////////////////////////////

//
// The UserConfig class identifies plugin settings that can be configured
// from Attract-Mode's configuration menu
//
class UserConfig </ help="Integration plug-in for use with the JoyTray software provided by Ultimarc: http://www.ultimarc.com" /> {

</ label="Command", help="Path to the JoyTray executable", order=1 />
command="C:/Program Files (x86)/JoyTray/JoyTray.exe";
}

local config=fe.get_config(); // get user config settings corresponding to the UserConfig class above

//
// Copy the configured values from uconfig so we can use them
// whenever the transition callback function gets called
//

fe.add_transition_callback( "joytray_plugin_transition" );

function joytray_plugin_transition( ttype, var, ttime ) {

if ( ScreenSaverActive )
return false;

switch ( ttype )
    {
case Transition.ToGame:
if (fe.game_info( Info.Control ) == "joystick (4-way),joystick (4-way)")
fe.plugin_command_bg( config["command"], "-servo joy4way" );
else if (fe.game_info( Info.Control ) == "joystick (2-way),joystick (2-way)")
fe.plugin_command_bg( config["command"], "-servo joy4way" );
else
fe.plugin_command_bg( config["command"], "-servo joy8way" );
break;

// case Transition.FromGame:
// fe.plugin_command_bg( config["command"], "-servo joy8way" );
// break;
}

return false; // must return false
}

wrybread

  • Full Member
  • ***
  • Posts: 95
    • View Profile
Re: Ultimarc ServoStik Plugin
« Reply #4 on: January 26, 2018, 06:39:57 PM »
Thanks for the above code, I was able to adapt it to make a plugin to control the Servo-Stik from Linux, notes here in case it's useful to anyone:

http://forum.attractmode.org/index.php?topic=2123.msg14494#msg14494
« Last Edit: February 13, 2018, 12:05:19 AM by wrybread »

squareboy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Ultimarc ServoStik Plugin
« Reply #5 on: March 13, 2022, 04:44:05 PM »
I think you need to check what your "(fe.game_info( Info.Control )" actually contains in your setup. That's what I needed to change to get it working here...

I'm having issues implementing this plugin. I've saved it as a .nut and placed it in my plugins folder, and activated it. I've also installed the JoyTray application to the correct path. 

I'm not sure how to "check what your (fe.game_info( Info.Control ) actually contains in your setup".  I'm not sure how to display this info.

Thank you for any assistance.
« Last Edit: March 13, 2022, 04:45:36 PM by squareboy »

squareboy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Ultimarc ServoStik Plugin
« Reply #6 on: March 13, 2022, 05:33:01 PM »
OK I figured it out.
For clarity, here are all the steps:

1: Download the Joytray.exe program from ultimarc
2. Install it to the C:/Program Files (x86)/JoyTray/JoyTray.exe location  (otherwise change the address in the Joytray.nut file)
3. Copy Arcadefan1's code above to notepad and save it as JoyTray.nut into the plugins folder of Attract Mode
4. Look at / edit your romlist file.  (see Easier Romlist Editing below)
   - look in your \romlist foder
   - make a backup copy of your romlist
   - open the romlist you are working with in a text editor
   - the list is semicolon seperated values for your roms:
    (#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons;Series;Language;Region;Rating)

   - the 10th value, or "Control" needs to match the name in the JoyTray.nut file 
       Arcadefan1  uses the value:  "joystick (4-way),joystick (4-way)" in his code above.
       I simplified the value to: "4-Way Joystick"     
       so in my JoyTray.nut file  the line reads as:   if (fe.game_info( Info.Control ) == "4-Way Joystick")
       and in my romlist file, Mrs.Pacman (a 4-way game) is:   mspacman;Ms. Pacman;Arcade;;;Midway Games;Sandbox;2;;4-Way Joystick;;;;;Ms. Pac-Man;;;;;;
       * the plugin defaults to 8-way if no value is present, and 4-way if the value of "2-way"  is present in the romlist.

   - save the romlist
5. Start up Attract Mode and go into settings->Plug-ins, and enable the JoyTray plugin.

If everything is set up right things should be working. You should only hear the servo move when you change from 4-way to 8-way, or the opposite.
Remember to restart Attract Mode if you are actively editing the plugin or romlist.





Easier Romlist Editing. I imported it into google sheets (free with signup)

To open your romlist in google sheets:

0. Make a backup copy of your romlist file
1. Open Google Sheets
2. Choose “File” → “Import” → “Upload” → “Select a file from your computer.”
3. Choose your romlist file.
4. A  "Import File" window will pop up. Choose “Create new spreadsheet” "custom" and type  ";"   (no quotes) for the custom separator.
     now all the cells will be lined up and you can easily copy and paste "4-Way Joystick" or your chosen value onto the 4-way games.


To save your romlist as a .csv (comma separated values)  file:
 
1. Choose "File" -> "Download", and choose "Comma Separated Values"
2. Open the .csv file in a text editor and replace the commas with semicolons.   In notepad its the edit->replace function.  IN notepad++ its search->replace->replace all
3. Rename the .csv file to the original .txt filename  eg.  arcade.txt                 
4. Place the file back in your romlist folder.



TLDR:

1. Download and install Joytray.exe from ultimarc website
2. Copy Arcadefan1's code above and save it as JoyTray.nut in the plugins folder
3. Make sure "joystick (4-way),joystick (4-way)" is the 10th value for your 4-way games in your romlist
4. Activate the JoyTray plugin in Attract Mode. Restart Attract Mode if necessary.







« Last Edit: March 13, 2022, 09:07:38 PM by squareboy »