Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--ignore-buttons does not work with remapped buttons #46

Open
noctuid opened this issue Apr 7, 2019 · 3 comments
Open

--ignore-buttons does not work with remapped buttons #46

noctuid opened this issue Apr 7, 2019 · 3 comments

Comments

@noctuid
Copy link

noctuid commented Apr 7, 2019

Discussion continued from #40. To summarize, --ignore-buttons does not consider remappings (e.g. made with xinput --set-button-map). If I set a button that is initially 1 to be anything other than 1, --ignore-buttons <new number> does not work. Only --ignore-button <original number> works.

I checked to confirm and the event's evtype is XI_RawButtonPress and the event's detail is always the original button number (e.g. 1). I'm not sure if this means it's impossible to do anything about it. Let me know if there's any other specific information I can provide.

@Airblader
Copy link
Owner

Thanks! I think we need to look into what xinput does under the good, and find out if we can query this mapping through some API in Xinput2. If so there shouldn't be any reason why we can't respect the mapping.

@Airblader
Copy link
Owner

Airblader commented Apr 7, 2019

Relevant code from xinput: https://cgit.freedesktop.org/xorg/app/xinput/tree/src/buttonmap.c

The button map is actually device specific. We can use XGetDeviceButtonMapping to get the map, and I think the raw event has a deviceid property.

Edit: Also, just for reference, here's the XI2 spec: https://www.x.org/releases/X11R7.7/doc/inputproto/XI2proto.txt

@Airblader
Copy link
Owner

Approach-wise, we can do the following:

static bool is_button_ignored(const XIRawEvent *data) {
    if (config.ignore_scrolling && (data->detail == 4 || data->detail == 5)) {
        return true;
    }

    if (config.ignore_buttons.count == 0) {
        // Return early so we don't query the mapping unless needed
        return false;
    }

    long mapped_button = /* … Get mapping of data->detail … */
    // …
}

I think for --ignore-scrolling we should not map the 4 / 5 as I believe those should always be interpreted as scroll wheel – I'm not entirely sure, to be honest, though. Even if so, the user could always ignore scrolling respecting the mapping by using --ignore-buttons instead then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants