Jump to content
LaunchBox Community Forums

Recommended Posts

2 hours ago, rmetzger said:

I have a question on this.   I downloaded and it works great as long as the 4 way is the primary controller.   I had atari 5200 which had "atari joystick" as the primary controller and I added 4 way under it so that it would switch automatically to 4 way and it didn't. I then got rid of "atari joystick" and it worked fine.  If I put atari joystick after the 4 way it still worked.  I'm guessing it has to be the primary controller for this to work.  Correct on this thought?

After a change to the last release there is an easy fix for this without having to make a bunch of changes in launchbox. The plugin config file now has a field with a list of 4-way and 8-way controllers. all we have to do is add atari jokstick to the list and blam it will work for all atari joysticks. I'll update the plugin but if you don't want to wait you can make the fix yourself following these steps.
1. open the servosticker config file. This is located in the launchbox plugin folder. the file is called ServoStiker.conf.

in this file find the line like this:

"4-way-names": "4-Way Joystick,Double 4-Way Joysticks,Half 4-Way Joystick,Double Horizontal Joysticks,Double Vertical JoysticksHorizontal Joystick,Vertical Joystick",
    

Add ",atari joystick" to the list in the quotes

the line should read something like this:

"4-way-names": "4-Way Joystick,Double 4-Way Joysticks,Half 4-Way Joystick,Double Horizontal Joysticks,Double Vertical JoysticksHorizontal Joystick,Vertical Joystick,Atari Joystick",

Save the file and restart launchbox

If you have any others controller types you can add them just like that.

Out of curiosity, Are there other controller types that i should add by default to the list? I wasn't aware of atari joysticks so i didn't know i should include it.

Link to comment
Share on other sites

well, Atari games can be 4 or 8 way.  I was referring to a game like Pac Man where you want it to be a 4 way joystick.  Atari joystick was 1st and then 4 way was 2nd, it didn't work.   I put 4 way first and atari 2nd and it worked.  There are atari games that are 8 way so I wouldn't want them to be all 4 way..  I was just asking if I need to make sure that the 4 way is 1st and then atari is 2nd so that it will change automatically.  The atari joystick is more for playlists than anything I believe.  

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...
  • 7 months later...

Thanks for this plugin that i will try on my Bartop.

I'm not a coder but i modified the coding for another frontend, in order to avoid to stress servostik if not necessary.

Example : 

I start from 8 ways (default) and i play a 4 ways : a command is sent to rotate. In this case a variable X should take 4.
I exit from that game and I play another 2/4 ways. If x=4 there's no need to send any command.
I exit and i play a 8 (or more) ways. Since X != 8 then rotate and X=8 
and so on...

Do you think that it's feasible ?

Link to comment
Share on other sites

On 9/30/2021 at 6:57 AM, Dinomight said:

In case you want to contribute here is the github link : https://github.com/Darkmadda/ServoStiker

I checked the source code of the DLL and is different. Could you please post the source code of the latest DLL ? (1.0.4) ?
Anyway, i decompiled the DLL in order to get the code and changed the behaviour when the stick is already in 4 or 8 ways, in order to no stress the motor.  It seems working but i need to reproduce different user cases.

In the conf file there is a typo 

"4-way-names": "4-Way Joystick,Double 4-Way Joysticks,Half 4-Way Joystick,Double Horizontal Joysticks,Double Vertical JoysticksHorizontal Joystick,Vertical Joystick",

Edited by cybermat
Link to comment
Share on other sites

6 hours ago, cybermat said:

I checked the source code of the DLL and is different. Could you please post the source code of the latest DLL ? (1.0.4) ?
Anyway, i decompiled the DLL in order to get the code and changed the behaviour when the stick is already in 4 or 8 ways, in order to no stress the motor.  It seems working but i need to reproduce different user cases.

In the conf file there is a typo 

"4-way-names": "4-Way Joystick,Double 4-Way Joysticks,Half 4-Way Joystick,Double Horizontal Joysticks,Double Vertical JoysticksHorizontal Joystick,Vertical Joystick",

Thanks for checking that. I will fix the typo and do state management (My only concern was if the joystick was changed and the plugin being unaware of this change which would mean it wouldn't switch properly. I think know how i want to do it.) I probably won't be able to work on it until this weekend but once i do it should only take a few minutes. I will message you with the latest version once it's done and have you test it before i upload the version to the launchbox download system. Thank you again.

Link to comment
Share on other sites

First of all thanks for your plugin. 

I'm a total noob regarding coding, but analyzing your code i did same changes i applied for another front end. So according with my test cases, now i send rotate command only when needed. I tried to load a lot of 4 ways games, then a lot of 8 ways games with just one rotation.
Furthermore, in order to cover all the cases (i hope), i also tested with games "out" from the config file and i get properly the default value only if i've servo rotated to 4 ways. (i put 8 ways as default, but turned off RESET on exit).

The only case where i could "force" is when i boot the first time. 

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using TinyJson;
using Unbroken.LaunchBox.Plugins;
using Unbroken.LaunchBox.Plugins.Data;

namespace ServoStiker
{
    public class ServoStiker : IGameLaunchingPlugin
    {
        private string pathToJoyToTray;
        private string pathToConfig;
        private string defaultMode;
        private string[] eightNames;
        private string[] fourNames;
        private string resetOnExit;
        string arguments = "";
        int x = 0;

        public ServoStiker()
        {
            this.pathToConfig = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\ServoStiker.conf";
            Dictionary<string, object> dictionary = (Dictionary<string, object>)File.ReadAllText(this.pathToConfig).FromJson<object>();
            this.pathToJoyToTray = dictionary["joytrayPath"].ToString();
            this.defaultMode = dictionary["default"].ToString();
            char[] chArray = new char[2] { ',', ';' };
            this.eightNames = dictionary["8-way-names"].ToString().Split(chArray);
            this.fourNames = dictionary["4-way-names"].ToString().Split(chArray);
            this.resetOnExit = dictionary["reset-on-exit"].ToString();
        }

        public void OnAfterGameLaunched(IGame game, IAdditionalApplication app, IEmulator emulator)
        {
        }

        public void OnBeforeGameLaunching(IGame game, IAdditionalApplication app, IEmulator emulator)
        {
            KeyValuePair<IGameController, int?>[] controllerSupport = game.GetControllerSupport();
            
            for (int index = 0; index < controllerSupport.Length; ++index)
            {
                KeyValuePair<IGameController, int?> keyValuePair = controllerSupport[index];
                int num1 = Array.IndexOf<string>(this.fourNames, keyValuePair.Key.Name);
                int num2 = Array.IndexOf<string>(this.eightNames, keyValuePair.Key.Name);
                if ((num1 > -1) && (x != 4))
                {
                    arguments = "-servo joy4way";
                    x = 4;
                    Process.Start(this.pathToJoyToTray, arguments);
                }

                else if ((num2 > -1) && (x != 8))
                {
                    arguments = "-servo joy8way";
                    x = 8;
                    Process.Start(this.pathToJoyToTray, arguments);
                }

                else if ((this.defaultMode == "4-way") && (num1 <= -1) && (num2 <= -1) && (x != 4))
                {
                    arguments = "-servo joy4way";
                    x = 4;
                    Process.Start(this.pathToJoyToTray, arguments);
                }
                else if ((this.defaultMode == "8-way") && (num1 <= -1) && (num2 <= -1) && (x != 8))
                {
                    arguments = "-servo joy8way";
                    x = 8;
                    Process.Start(this.pathToJoyToTray, arguments);
                }
            }
            
        }

        public void OnGameExited()
        {
            if (!(this.resetOnExit == "True"))
                return;
            string arguments = "";
            if (this.defaultMode == "8-way")
                arguments = "-servo joy8way";
            else if (this.defaultMode == "4-way")
                arguments = "-servo joy4way";
            Process.Start(this.pathToJoyToTray, arguments);
        }
    }
}

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...
  • 4 months later...

Hey mate, great plugin! The first version works great but it does have the issues that you fixed in that other versions. Problem is, the links you've provided aren't working anymore. Can you please link that most updated version (1.0.4 I think).

Thanks mate!!!

 

(Or anyone who has it)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...