JoystickGremlin icon indicating copy to clipboard operation
JoystickGremlin copied to clipboard

The profile is deactivated when a new controller is plugged in

Open nguyenquyhy opened this issue 6 years ago • 18 comments

When I plugin an Xbox controller when Joystick Gremlin is activated, it is automatically deactivated. The same happen when the Xbox controller is turned off after some idling time.

Is it able to have an option to for the profile to be activated all the time?

nguyenquyhy avatar Feb 17 '20 17:02 nguyenquyhy

I suspect this is some kind of side-effect related to the way detecting new devices are handled. I'll have to look into what is actually happening behind the scenes and the implications of adding a new device. In any case, it should be possible to forcibly re-enable Gremlin after a new device is added and possibly turn this into an option if needed.

WhiteMagic avatar Feb 25 '20 00:02 WhiteMagic

Auto re-enable would be awesome and good enough as a workaround. If the deactivated time is long before the re-enabling though, I would also love to have an option for a sound alert when a profile is deactivated if that is not to difficult.

nguyenquyhy avatar Feb 25 '20 11:02 nguyenquyhy

I noticed this as well. Randomly disabled after windows sleep as well. But if I plug in any type of game controller that shows up in gremlin, I see a flash, the new devices show up, but the profile is deactivated.

Not great when you are on the starting line in a race and your pedals don't show up :)

flexgrip avatar Apr 07 '20 00:04 flexgrip

Same issue here. A force re-enable option would be greatly appreciated.

Wibbbs avatar Sep 11 '20 20:09 Wibbbs

I've a cordless controller which goes sleep after cca. 5 or 10 minutes inactivity. This also causes profile deactivation. (I think all cordless device would show such symptoms) Also switching on the controller also deactivates the actually active profile. Auto re-enable would be great or maybe the program could remember the state of the "Activate " button and apply that on each re-detection of devices. Just an idea.

psicore avatar Apr 11 '22 17:04 psicore

I've a cordless controller which goes sleep after cca. 5 or 10 minutes inactivity. This also causes profile deactivation. (I think all cordless device would show such symptoms) Also switching on the controller also deactivates the actually active profile. Auto re-enable would be great or maybe the program could remember the state of the "Activate " button and apply that on each re-detection of devices. Just an idea.

Same issue (I even started a new issue that got closed cause I missed this!)

I play Elite Dangerous with a Hotas, but the new on-foot portion with my Xbox controller. Unfortunately, when my controller goes to sleep, it kills all the curves I set up in JoystickGremlin and my ship goes dead. Pretty bad in the middle of combat!

Spidey002 avatar Aug 08 '22 19:08 Spidey002

@WhiteMagic I have no idea what the ramifications are of this, but for the last 3 months or so I've been running a modified version with:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        # Stop Gremlin execution
        # self.ui.actionActivate.setChecked(False)  ---- removed
        # self.activate(False)								    ---- removed

This leaves the profile always activated even when devices are removed or plugged in. It's worked for me but I'm sure it's there for a purpose?

Jonno12345 avatar Aug 19 '22 23:08 Jonno12345

@WhiteMagic I have no idea what the ramifications are of this, but for the last 3 months or so I've been running a modified version with:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        # Stop Gremlin execution
        # self.ui.actionActivate.setChecked(False)  ---- removed
        # self.activate(False)								    ---- removed

This leaves the profile always activated even when devices are removed or plugged in. It's worked for me but I'm sure it's there for a purpose?

Not having any coding experience, how would I go about adding this modification to my copy?

Spidey002 avatar Aug 20 '22 15:08 Spidey002

@WhiteMagic I have no idea what the ramifications are of this, but for the last 3 months or so I've been running a modified version with:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        # Stop Gremlin execution
        # self.ui.actionActivate.setChecked(False)  ---- removed
        # self.activate(False)								    ---- removed

This leaves the profile always activated even when devices are removed or plugged in. It's worked for me but I'm sure it's there for a purpose?

The only downside is that it will never be able to execute actions associated with the newly connected device. The more complete solution would be to deactivate and then reactivate the profile to force a reload of the action mapping to include the new device.

WhiteMagic avatar Aug 20 '22 17:08 WhiteMagic

@WhiteMagic I have no idea what the ramifications are of this, but for the last 3 months or so I've been running a modified version with:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        # Stop Gremlin execution
        # self.ui.actionActivate.setChecked(False)  ---- removed
        # self.activate(False)								    ---- removed

This leaves the profile always activated even when devices are removed or plugged in. It's worked for me but I'm sure it's there for a purpose?

The only downside is that it will never be able to execute actions associated with the newly connected device. The more complete solution would be to deactivate and then reactivate the profile to force a reload of the action mapping to include the new device.

This would work for me in the short term as I don't have any JoystickGremlin actions attached to my Xbox controller. How would I go about adding either solution to my copy of JoystickGremlin?

Spidey002 avatar Aug 20 '22 19:08 Spidey002

Sorry, when you say 'actions' do you mean things more complex than just remapping? With that change I can add/remove devices at will and they immediately take effect. I primarily use it for hotswapping my ESP32 based bluetooth wheels on my wheelbase, and they just start working in game without any changes.

I will add further to this, I've added the following line:

self.runner.setDefaultAxisValues(self._profile.settings)

eg, the entire section is now as follows:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        self.runner.setDefaultAxisValues(self._profile.settings)

This means that my pedals immediately reset to their default levels on plug/unplug of devices (just because my pedals otherwise were setting to 50% for a moment until something ran a refresh), but the remapping works immediately without any further changing.

@Spidey002 - It's too large to attach, but here is a download link for the build I'm using:

https://drive.google.com/file/d/1dxXqe2Z48XtCkjvMql2q0l4awg0W9r6A/view?usp=sharing

I've been using it myself on a profile used for remapping 9 different devices to a single controller, and as said, it seems to work as intended for me. I can't guarantee nothing bad will happen and nothing will explode however, and I'm not 100% sure I've compiled against the same versions of any python libraries. I also may have updated the vJoyInterface DLL as I'm using 2.1.9 I believe, so if it doesn't work it may be due to that.

Jonno12345 avatar Aug 20 '22 21:08 Jonno12345

I thought that I had some logic that filtered out actions of non-existing devices, but seems like it doesn't do that (anymore) which is a good thing in this case. The default axis line you had to add probably gets run when activating the profile, so that might be a way to keep that function working when it changes. Not that any of that will happen given all the changes for R14.

WhiteMagic avatar Aug 21 '22 06:08 WhiteMagic

@Jonno12345 Works like a charm! Thanks!

Spidey002 avatar Aug 21 '22 13:08 Spidey002

@Spidey002 Glad to hear, as said, easily possible something is maybe unstable or not working as intended as I have no idea on package compatibility, but hopefully it works okay for you for now!

I thought that I had some logic that filtered out actions of non-existing devices, but seems like it doesn't do that (anymore) which is a good thing in this case. The default axis line you had to add probably gets run when activating the profile, so that might be a way to keep that function working when it changes. Not that any of that will happen given all the changes for R14.

No I'm sure, may I ask if this concern has been considered in R14? I haven't yet had chance to dive through that, as I wasn't sure how stable it would be to base the tweak on. Honestly it was the only tweak I needed to make to make my setup entirely seamless, so on that note, thank you for all your work, really happy with how well it brings everything together and saves me having to manage 9+ individual arduino/ESP32s... Looking forward to seeing what R14 brings!

Jonno12345 avatar Aug 21 '22 15:08 Jonno12345

Nothing in that regard has been done in R14 so far but those ancillary bits haven't gotten any attention so far anyways. You also couldn't nase changes on the R14 dev part as it's not in a state where you would want to use it as the majority of the functionality is missing atm.

WhiteMagic avatar Aug 21 '22 19:08 WhiteMagic

Sorry, when you say 'actions' do you mean things more complex than just remapping? With that change I can add/remove devices at will and they immediately take effect. I primarily use it for hotswapping my ESP32 based bluetooth wheels on my wheelbase, and they just start working in game without any changes.

I will add further to this, I've added the following line:

self.runner.setDefaultAxisValues(self._profile.settings)

eg, the entire section is now as follows:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        self.runner.setDefaultAxisValues(self._profile.settings)

This means that my pedals immediately reset to their default levels on plug/unplug of devices (just because my pedals otherwise were setting to 50% for a moment until something ran a refresh), but the remapping works immediately without any further changing.

@Spidey002 - It's too large to attach, but here is a download link for the build I'm using:

https://drive.google.com/file/d/1dxXqe2Z48XtCkjvMql2q0l4awg0W9r6A/view?usp=sharing

I've been using it myself on a profile used for remapping 9 different devices to a single controller, and as said, it seems to work as intended for me. I can't guarantee nothing bad will happen and nothing will explode however, and I'm not 100% sure I've compiled against the same versions of any python libraries. I also may have updated the vJoyInterface DLL as I'm using 2.1.9 I believe, so if it doesn't work it may be due to that.

@Spidey002 THANK YOU VEEEERYY VERYYY MUCHHH - geniusss!!

diegonando22 avatar Jan 04 '24 23:01 diegonando22

I tried the version you did @Jonno12345 ! But actually for it doesn't open at all. I click on the exe, but nothing happens...

EDIT : But, when my joys are hidden the exe works...

Raz0rLegend avatar Feb 11 '24 10:02 Raz0rLegend

Sorry, when you say 'actions' do you mean things more complex than just remapping? With that change I can add/remove devices at will and they immediately take effect. I primarily use it for hotswapping my ESP32 based bluetooth wheels on my wheelbase, and they just start working in game without any changes.

I will add further to this, I've added the following line:

self.runner.setDefaultAxisValues(self._profile.settings)

eg, the entire section is now as follows:

    def _device_change_cb(self):
        """Handles addition and removal of joystick devices."""
        # Update device tabs
        self.devices = gremlin.joystick_handling.joystick_devices()
        self._create_tabs()

        self.runner.setDefaultAxisValues(self._profile.settings)

This means that my pedals immediately reset to their default levels on plug/unplug of devices (just because my pedals otherwise were setting to 50% for a moment until something ran a refresh), but the remapping works immediately without any further changing.

@Spidey002 - It's too large to attach, but here is a download link for the build I'm using:

https://drive.google.com/file/d/1dxXqe2Z48XtCkjvMql2q0l4awg0W9r6A/view?usp=sharing

I've been using it myself on a profile used for remapping 9 different devices to a single controller, and as said, it seems to work as intended for me. I can't guarantee nothing bad will happen and nothing will explode however, and I'm not 100% sure I've compiled against the same versions of any python libraries. I also may have updated the vJoyInterface DLL as I'm using 2.1.9 I believe, so if it doesn't work it may be due to that.

@Jonno12345 Would you mind sharing this again? The current link is no longer working (and my computer hard drive reset).

Spidey002 avatar Feb 16 '24 13:02 Spidey002