Note that this makes it so you can't control the Servo-Stik via USB anymore, which is a shame. And the change is permanent! So proceed with caution, and you might want to read my "alternative methods" section below before proceeding.

Once you make this change you're essentially switching the mode of the Servo-Stik with a relay acting as a toggle switch.

- Strip the wires from a USB mini cable. Connect the red and black wires to a 5v power supply (the 5v pins on the USB relay didn't seem to provide enough power for reliable operation), then connect the white wire to the NO pin of the relay, the green wire to the NC pin of the relay, and roll up the shielding and connect it to the common pin of the relay.

- When you're done it'll look something like the attached image, except that I wouldn't recommend getting power from the relay board itself as in the picture, things were really flaky for me until I connected the power to a stripped down 5v wall wort.

- You'll need to install the usbrelay program as described here (https://github.com/darrylb123/usbrelay), or in Debian variants you can just run "sudo apt-get install usbrelay". After installing run "usbrelay" to see the address of your relay and adapt this plugin if needed. You can adapt it either through Attract Mode's plugin configuration section, or directly in the code of the plugin.

On my system this command turns on the relay:

usbrelay HURTM_1=1

And this turns off the relay:

usbrelay HURTM_1=0

If you have things wired up you should see your Servo-Stik magically switching between 4 and 8 way. If not, run simply "usbrelay" to get the address of the relay ("HURTM" in the example above). I don't know if the address varies from relay to relay. If you have a different address you'll need to edit the plugin either directly or by going to it's plugin config section of Attract Mode. You should be able to switch the mode of the Servo-Stik with the above lines of code at this point. If not, go over the steps above carefully.

- With the configuration here, I'm turning on the relay for 2 and 4 way games, and turning it off for 8 way games. Works great.

Feel free to email directly with any questions, since I don't think the post notification feature is working on this board. My email is wrybread at gmail dot you know what.

Alternate methods:

- I'm really impressed with the Servo-Stik, but it would be nice if we didn't have to put the control board into "hardware board" to control it in from a relay or switch, since doing so is a permanent change, meaning we can't control it via USB ever again. Andy, if you're listening, how about adding a couple of pins to the board so this is always possible, even in regular USB mode? Or a jumper to return the board to regular USB mode?

- I tried RGBCommander, which was able to control the ServoStik, but not in conjunction with Attract Mode since my version of MAME (.175) isn't supported. Most of my ROMs didn't work with later versions of MAME so I abandoned that route, but more notes on the issue are in this thread http://forum.arcadecontrols.com/index.php?topic=156479.0.

- the author of RGBCommander said he has a commandline utility to switch the Servo-Stik, which would solve the issue completely, but as of now he hasn't released it yet. Please do?

- I'd love to make a Python script to control the Servo-Stik directly using pyusb, but couldn't find very many details on the protocol. Andy sent this over, maybe someone can make sense of it?

This is an Attract-Mode plugin to use a ServoStik under Linux (or other OS's) with a USB relay. These USB relays are dirt cheap, under $5 shipped to the U.S.,and work beautifully with a ServoStik in hardware mode.

More notes on the relays here:

https://github.com/darrylb123/usbrelay

More setup notes for this plugin here:

http://forum.attractmode.org/index.php?topic=2123.0

wrybread at gmail dot you know whatFebruary 12, 2018

*/

// user configclass UserConfig </ help="Plugin to use a ServoStik joystick in hardware mode under Linux. See the header of the ServoStikUSBRelay plugin for more information." /> {