WhiteMagic / JoystickGremlin

A tool for configuring and managing joystick devices.
http://whitemagic.github.io/JoystickGremlin/
GNU General Public License v3.0
322 stars 46 forks source link

The profile is deactivated when a new controller is plugged in #276

Open nguyenquyhy opened 4 years ago

nguyenquyhy commented 4 years ago

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?

WhiteMagic commented 4 years ago

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.

nguyenquyhy commented 4 years ago

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.

flexgrip commented 4 years ago

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 :)

Wibbbs commented 4 years ago

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

psicore commented 2 years ago

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.

Spidey002 commented 2 years ago

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!

Jonno12345 commented 2 years ago

@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?

Spidey002 commented 2 years ago

@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?

WhiteMagic commented 2 years ago

@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.

Spidey002 commented 2 years ago

@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?

Jonno12345 commented 2 years ago

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.

WhiteMagic commented 2 years ago

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.

Spidey002 commented 2 years ago

@Jonno12345 Works like a charm! Thanks!

Jonno12345 commented 2 years ago

@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!

WhiteMagic commented 2 years ago

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.

diegonando22 commented 10 months ago

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!!

Raz0rLegend commented 9 months ago

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...

Spidey002 commented 9 months ago

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).