WhiteMagic / JoystickGremlin

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

Conditional button remap (button+button shift) problem #251

Open Francky63 opened 5 years ago

Francky63 commented 5 years ago

Hi WM, I have set up a remap for a button (main button) when another button is pressed (shift button)

Eg.

if Joy button 1 is pressed AND Joy button 3 is pressed then vJoy Button 1 is pressed

            <button description="COM 1 per  Voice Attack" id="2">
                <container type="basic">
                    <action-set>
                        <remap button="1" vjoy="1">
                            <activation-condition rule="all">
                                <condition comparison="pressed" condition-type="vjoy" id="4" input="button" vjoy-id="1"/>
                            </activation-condition>
                        </remap>
                    </action-set>
                </container>
            </button>

the expected behavior is that vJoy 1 must be press when both main button and shift button is pressed and vJoy 1 is released when main button or shift button ins released .

What happens is true ONLY if main button is released before shift button, i f shift button is released before main button vJo1 button 1 it remain ON also when main button is released

Francky63 commented 5 years ago

This it happen also with the keyboard rermap, I have a condition button remaped on ctrl alt F9 (track IR freeze command) if I release very quick the shift button CTRL ALT it look like it remain pressed

I started to monitor keyboard and joystick button because it ... (CTRL ALT that it remain pressed are compromise alla other key and button depress)

If you need any additional information i can send you a video from my pc that show what happen

WhiteMagic commented 5 years ago

What Gremlin does is technically correct as far as the implementation goes, though in certain cases it is not what you want it to do. The conditions in Gremlin are evaluated on every single activation and have no state, i.e. don't care what happened before. In that sense, for either press or release, the condition has to hold for the action to trigger.

The problem is that depending on user intent there may different behaviors that are desired. In your case because the condition is intended to implement a shift key and you want the shift key only to be needed to activate it you'd like the condition to not matter upon release of the input. However, there are many other situations where this would not be desired. This inability to make one condition dependent on another one is a design choice of the condition system, as the UI and logic would get out of hand very quickly if I wanted to cover all possible combinations.

You can still achieve the behavior you want by adding a macro that triggers on release of the physical input and release the shifted vJoy input. This may set the state twice some times but should not cause any harm.

In short, this is a known limitation of the system which can be worked around to some extent. It's not ideal but I haven't found a good generic solution to solve this yet. If there are conceptual ides on this I'd be more then happy to hear them.

Francky63 commented 5 years ago

sorry, may be i don't explain correctly the main problem, or i'm not able to understand, if condition is shift button pressed and shift button is no more pressed there is condition is false e musto not be remaped any more.... this is why don't understand why if main button is released before shift button the rempend button/key goes off and if shift button is released before main button when main button is released the remaped button or key it doesn't go off... What happen if the button is remaped on i.e. CTRL ALT F12 is that CTRL and ALT key it remain pressed (no F12) and every digit on the keyboard is handle as "CTRL ALT key" with unpredictable consequence ... i don't think this is a wished behavior and usually main and shift buttons are released together and if SHIFT is release 1/100 sec before main it happen what i described. I know how to emulate the button that it remain pressed with a macro but not how to do what i need

please if there is a work around with macro or script let me know how

WhiteMagic commented 5 years ago

Based on the XML snippet and your description of what you expect to happen:

The expected behavior is that vJoy 1 must be press when both main button and shift button is pressed and vJoy 1 is released when main button or shift button ins released.

The main difference is that you want vJoy 1 to be release when the main button OR the shift button is released. However, what the snippet really encodes is that vJoy is to be released ONLY if main button is release WHILE the shift button is held down.

If I were to write the two cases down in pseudo code it might look something like the following. Your desired behaviour is:

if release_main or release_shift then
    release vJoy

while how Gremlin reads this is:

if shift_is_pressed then
    if release_main then
        release vJoy

Gremlin effectively wraps conditions around the actions, and only considers executing the action if the condition is met. For this reason, Gremlin doesn't care that the shift button was released as it has no association between the use of that button as a condition and the action that this allowed to be performed.

If you truly want the behaviour I describe above, i.e. releasing either the main or shift button, to cause the vJoy button to be released, then you would have to add actions onto those events separately without conditions. I'll try to make an example of this when I'm back home after the weekend.

Francky63 commented 5 years ago

STAND BY I rebuild all the profile for to check with a MACRO in the same rules as PRESSED adding a RELEASE shift key condition ... and I get the problem that every time i changed tab in Jgremlin the released condition was changed in pressed. (??) I delete all and reinsert and NOW everything it work the only change is that I DON'T insert the condition SHIFT key pressed on a TEMPO action and i'n NOT used as shift key vJoy but the regular joy ... I tried to check again the old config with vJoy as SHIFT key in TEMPO action and it work ... I am happy and a little bit concerned ... may be something was wrong in my profile. I mean, NOW when both button are released the remaped button is switched of with ot take care the sequence of released button ... before if the shift was released before main the remaped was on also after main button was release and this it happen also with keyboard. This behavior i think is better to open another issue

WhiteMagic commented 5 years ago

The issue with the condition changing on its own is something I'm aware of, though due to all of that logic and UI getting scraped I'm not really planning on fixing that since it won't be around with the new version anymore.

Though good to hear you managed to get a workaround solution.

Francky63 commented 4 years ago

my workaround is to setup a key without CTRL ALT