archagon / sensible-side-buttons

A macOS menu bar app that enables system-wide navigation functionality for the side buttons on third-party mice.
http://sensible-side-buttons.archagon.net
GNU General Public License v2.0
1.86k stars 126 forks source link

Switch between desktops #56

Closed jimrs closed 3 years ago

jimrs commented 3 years ago

Hello, would it be possible/hard for a beginner to modify the code to the "switch between full screen apps" functionality? On a Macbook trackpad usually done with 3 fingers. If it is indeed possible, can you please point me to the relevant files to change? Thank you.

noah-nuebling commented 3 years ago

Hey there, developer of Mac Mouse Fix here which can do that. The only reliable way I've found to do this is to:

  1. Use the private CGSSymbolicHotkey framework to temporarily map Switching Spaces to some keyboard key shortcut which is not available on any real keyboard
  2. Trigger that unavailble keyboard shortcut using the CGEvent framework - that will trigger the desktop switch
  3. Then map switching spaces back to the original keyboard shortcut so the user can still use the normal shortcuts

You can see this in action in the InputParser class in Mac Mouse Fix.

The symbolic Hotkeys corresponding to space switching are 79 and 81 iirc.

As for modifying Sensible Side buttons to be able to do this I think you'd probably have to

  1. Add a function that can trigger symbolic hotkeys like I described above. Renaming SwipeSimulator to input simulator and adding it there might make sense.
  2. Call that function from SideButtonFixer → AppDelegate.m → SBFMouseCallback() with symbolic hotkeyvalues 79 and 81
  3. Adjust the UI to let you select this / reflect that it's switching space now instead

Have fun!

jimrs commented 3 years ago

thanks brah, it might be easier for me to just use your program lmao

noah-nuebling commented 3 years ago

No worries haha, hope you like it!