logiops icon indicating copy to clipboard operation
logiops copied to clipboard

Scroll support

Open abraha2d opened this issue 4 years ago • 5 comments

Note: Also contains a fixed version of #157. Should probably reach a resolution on that before this one. Note: Contains the following changes from #160, but modified to work with scroll support (since there were some merge conflicts with that):

  • GestureAction: Restrict movements to a single axis after threshold is reached
  • GestureAction: Don't wait till origin before switching directions

This pull request allows for one to utilize the scroll wheel for gestures. Fixes #150. Has the same consequences as #160 because of the above changes.

Changes:

  • Allow scroll events to be diverted from HiresScroll -> RemapButton
  • Added scroll method from RemapButton -> Action -> GestureAction
  • GestureAction: Add scroll support (ScrollUp and ScrollDown directions)
  • HiresScroll: Add default scroll up/down actions (useful for diverting scroll events to gestures, but using the wheel normally otherwise)

Known issues:

  • When HiresScroll divert is enabled with the default scroll up/down actions, the first scroll notch in any direction doesn't actually scroll.
    • Doesn't seem to be an issue fixable in logiops, since the scroll events are being generated properly. Current hypothesis is that something's wacky when mouse movement comes from one input, and scroll movement comes from another input.

Sample config (enables gesture scroll support, and binds scroll up and down to switch tabs):

devices: (
{
    name: "M720 Triathlon Multi-Device Mouse";
    hiresscroll: {
        target: true;  # This enables hiresscroll diverting. If no up or down actions are defined,
                       # the default actions are to scroll up and down on the REL_WHEEL axis.
    };
    buttons: (
	{
            cid: 0xd0;
            action = {
                type: "Gestures";
                gestures: (
                    {
                        direction: "ScrollUp";
                        threshold: 1;
                        mode: "OnInterval";
                        interval: 1;
                        action = {
                            type: "Keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_LEFTSHIFT", "KEY_TAB"];
                        };
                    },
                    {
                        direction: "ScrollDown";
                        threshold: 1;
                        mode: "OnInterval";
                        interval: 1;
                        action = {
                            type: "Keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_TAB"];
                        };
                    }
                );
            };
        }
    );
}
);

abraha2d avatar Nov 24 '20 19:11 abraha2d

I have tried it with the following logid.cfg:

devices: (
{
    name: "Wireless Mouse MX Master";
    smartshift:
    {
        on: true;
        threshold: 20;
    };
    hiresscroll:
    {
        hires: false;
        invert: false;
        target: true;
    };
    dpi: 1000;

    buttons: (
        {
            cid: 0xc3;
            action =
            {
                type: "Gestures";
                gestures: (
                    {
                        direction: "Up";
                        mode: "OnRelease";
                        # Show all windows from all program on any desktop
                        action =
                        {
                            type: "Keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_F10"];
                        };
                    },
                    {
                        direction: "Down";
                        mode: "OnRelease";
                        # Show all windows from current program on current desktop
                        action =
                        {
                            type: "Keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_F7"];
                        };
                    },
                    {
                        direction: "Left";
                        mode: "OnRelease";
                        # Move to the next right desktop
                        action =
                        {
                            type: "Keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_LEFTMETA", "KEY_RIGHT"];
                        };
                    },
                    {
                        direction: "Right";
                        mode: "OnRelease";
                        # Move to the next left desktop
                        action =
                        {
                            type: "Keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_LEFTMETA", "KEY_LEFT"];
                        }
                    },

                    {
                        direction: "None"
                        mode: "OnRelease";
                        action =
                        {
                            type: "keypress";
                            keys: ["KEY_LEFTCTRL", "KEY_F8"];
                        }
                    },
                    #   WAITING FOR [PULLREQUEST](https://github.com/PixlOne/logiops/pull/161) TO BE MERGED!
                    {
                        direction: "ScrollDown";
                        threshold: 1;
                        mode: "OnInterval";
                        interval: 1;
                        # Move to the next window of corresponding program on current desktop
                        action =
                        {
                            type: "Keypress";
                            keys: ["KEY_LEFTALT", "KEY_TAB"];
                        }
                    },
                    {
                        direction: "ScrollUp";
                        threshold: 1;
                        mode: "OnInterval";
                        interval: 1;
                        # Move to the previous window of corresponding program on current desktop
                        action =
                        {
                            type: "Keypress";
                            keys: ["KEY_LEFTALT", "KEY_LEFTSHIFT", "KEY_TAB"];
                        }
                    }
                );
            };
        },
        {
            cid: 0xc4;
            action =
            {
                type = "ToggleSmartshift";
            };
        },
        {
            # Next tab instead of fwd in history, Comment to default behavior
            cid: 0x53;
            action =
            {
                type :  "Keypress";
                keys: ["KEY_LEFTCTRL", "KEY_PAGEUP"];
            };
        },
        {
            # Previous tab instead of back in history, Comment to default behavior
            cid: 0x56;
            action =
            {
                type :  "Keypress";
                keys: ["KEY_LEFTCTRL", "KEY_PAGEDOWN"];
            };
        }
    );
},
{
# Another device to configure
name: "Other Logitech USB Receiver";

}
);

I have found two issues:

1: [major] different behavior from up and down. When I maintain the thumbs button pressed and scroll down the current and the next two windows switch only (this should be avoided: my opinion is that at every scroll a "new" ALT+TAB is triggered while the ALT should be maintained pressed). On the other hand, scrolling up works as expected: all the windows comes one after the next one (in reverse order as my config).

2: [minor] I use KDE with effect to showing the app while I switch between them, this behavior is lost when I switch using my custom mouse combination and windows bring focus and became active only "immediately"

My intent is to trigger the switch by pressing the thumb button and moving the wheel, next if I keep the thumbs pressed without moving the wheel I continue to maintain the app sequence on my screen to look at them and decide to continue scrolling up or down until my selection happens releasing everything (i.e. exactly as it happens when I press ALT+TAB once, maintain ALT pressed, and next start sequences of TAB or SHIFT+TAB (clearly, while maintaining ALT pressed).

Should I play with threshold or interval?

Anyhow, I can confirm that before this pull request setting target: true deactivates the scroll completely, now it works fine!

CorradoLanera avatar Nov 26 '20 13:11 CorradoLanera

Thanks for testing this out.

What you're looking for (to keep the ALT button pressed) is the app switching support PR. That should solve both of the issues that you describe. What it does is it modifies OnInterval to keep the first button in the sequence pressed (unless there is only 1 button in the sequence).

The dev branch over at https://github.com/abraha2d/logiops contains both app switching and scroll support (it's what I use daily).

abraha2d avatar Nov 27 '20 00:11 abraha2d

Wonderful! I have tested it, and I can confirm it works exactly as I expect, without changing anything in my current logid.cfg. Great!

CorradoLanera avatar Nov 27 '20 09:11 CorradoLanera

actions are not working with config below

devices = ({

	name = "Wireless Mouse MX Master 3"

	dpi = 1600

	buttons = (
		{
			### Gesture Button
			cid = 0xC3
			action = {
				type = "Gestures"
				gestures = (
					{
						direction = "ScrollUp"
						mode = "OnInterval"
						interval = 1
						threshold = 1
						action = {
							type = "Keypress"
							keys = ("KEY_LEFT")
						}
					},
					{
						direction = "ScrollDown"
						mode = "OnInterval"
						interval = 1
						threshold = 1
						action = {
							type = "Keypress"
							keys = ("KEY_RIGHT")
						}
					},
				)
			}
		},
	)

})

roshal avatar Jul 22 '23 23:07 roshal

actions work when hiresscroll target is true

devices = ({

	name = "Wireless Mouse MX Master 3"

	dpi = 1600

	hiresscroll = {
		hires = false
		### invert = false
		target = true
		up = {
			mode = "Axis"
			axis = "REL_WHEEL"
			axis_multiplier = +1.0
		}
		down = {
			mode = "Axis"
			axis = "REL_WHEEL"
			axis_multiplier = -1.0
		}
	}

	buttons = (
		{
			### Gesture Button
			cid = 0xC3
			action = {
				type = "Gestures"
				gestures = (
					{
						direction = "ScrollUp"
						mode = "OnInterval"
						interval = 1
						threshold = 1
						action = {
							type = "Keypress"
							keys = ("KEY_LEFT")
						}
					},
					{
						direction = "ScrollDown"
						mode = "OnInterval"
						interval = 1
						threshold = 1
						action = {
							type = "Keypress"
							keys = ("KEY_RIGHT")
						}
					},
				)
			}
		},
	)

})

roshal avatar Jul 22 '23 23:07 roshal