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

Adding mouse button support #269

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

lokxii
Copy link

@lokxii lokxii commented May 7, 2023

Merged conflicts of #248

This pull request adds mouse button support on top of existing functionality in response to #195 and #245. A mouse button is made to treat as a key in config file such that writing (non-modifier) key + mouse combination not supported. It is however possible to do for example shift + alt - mouse_left.

A total of 32 keywords are added to correspond to what Carbon supports.

It is possible to use -k flag to synthesize a mouse click. However it is intentionally made to click at coordinates (-1, -1) to prevent clicking any elements on screen.

@kzvi
Copy link

kzvi commented Jun 13, 2023

I get this compiler warning which seems important:

In file included from src/skhd.c:39:
src/synthesize.c:76:24: warning: result of comparison of constant -1 with expression of type 'uint8_t' (aka 'unsigned char') is always false [-Wtautological-constant-out-of-range-compare]
    if (hotkey->button == -1) {
        ~~~~~~~~~~~~~~ ^  ~~

@lokxii
Copy link
Author

lokxii commented Jun 14, 2023

thx for pointing it out. Probably I just filtered away warnings and somehow testing was fine (or test not thorough enough)

@koekeishiya
Copy link
Owner

I think in cases like this it would be more appropriate to use UINT8_MAX instead of -1 to signal intent (even though -1 will have the same binary representation when stored in a uint8_t). I do think the compare with -1 is undefined behaviour unless explicitly casted to an unsigned type, and even if it is not, using the hex representation (0xFF) would be more appropriate.

There probably won't be further code changes to this repo, so it's not like I want or expect these changes to be done; just a note.

@rickalex21
Copy link

There's no mouse button support? I was looking to do a middle click. I did not know that. 🤔

@palkx
Copy link

palkx commented Jan 15, 2024

@9tin9tin9 are there any updates on this? It would be very helpful to have this feature implemented. If this is blocked by something, can we resolve this? Thanks!

@lokxii
Copy link
Author

lokxii commented Jan 15, 2024

I don't think koekeishiya will merge this into master. So if you want to use this feature, maybe you can download and install skhd from my fork.

I won't be maintaining / adding new features besides merging from master because I personally is not a mouse user. However, if you have feature request about mouse hotkeys, I may consider implementing it.

@palkx
Copy link

palkx commented Jan 15, 2024

Yes, I find this pretty useful. For example, when you have a mouse with additional keys you can map those keys to switch between workspaces. On the Apple mouse, you can do this simply with gestures. @koekeishiya is it possible to merge this PR?

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

Successfully merging this pull request may close these issues.

5 participants