-
Notifications
You must be signed in to change notification settings - Fork 427
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
Partial support for macOS and Windows #1971
Conversation
Please fix up the style errors caught by the pre-commit scripts. Ideally you should set up git to run them when you check in changes on your machine. |
It would be useful to see whether this port can detect devices on USB and Bluetooth and devices that are not described in lib/logitech_receiver/descriptors.py. Also whether the port can handle devices connected after Solaar start. |
I will look into that. I ran isort and flake8 manually but maybe it didn't pick up the right settings for the project.
I don't have such devices. Can I test this by just commenting out my devices there and see if they still get picked up?
This works for my usb receiver connected devices. Unplugging the receiver makes the devices disappear and plugging it in again makes them appear correctly. There is no hotplug notification support in hdiapi at the moment (thought they have semi recent issues about it and some preliminary code). I have implemented this by using a separate thread which enumerates devices periodically and raises events for newly found ones. The polling delay is 5 seconds at the moment which I felt was a good compromise between usability and resource usage. We can change this if you think some other value is better or maybe make it configurable with a command line switch. |
I removed my devices from If I remove my receiver from Unfortunately I cannot pair my devices directly via bluetooth (seems to be a known issue for my particular MAC) so we will need someone else to test direct Bluetooth and USB connections. |
One thing to try is to start up Solaar with the receiver disconnected, assuming you can do this, and then plug in the receiver. Will Solaar pick up the receiver? |
The udev code that Solaar uses has some local edits. I'm planning on cleaning up the udev code to remove these edits and take the functionality back into the main Solaar code. This should help with ports. |
Yes, this works. There is a random delay of up to 5 seconds of course, until the next check for new devices happens. |
Recognition of newly active devices is done without a timed loop in the current version of Solaar. Where did you add the timed loop? |
It's in the |
Solaar requires R/W access to the raw interface for receivers and devices. How are permissions given to Solaar to allow it to do this? |
Some parts of rules should work in MacOS. As far as I can tell the "only" thing that doesn't work but that works under Wayland is simulating user input. Of course this is a big gap. |
On macOS only keyboard and mouse input devices have special protection. Trying to open them causes a popup with the option to give the application access. I don't think Solaar actually needs to access the keyboard and mouse input though so I have added a check which filters these devices out. No special permissions are then needed to run Solaar and it can still access the Logitech HID++ usage pages. |
I think that's right. I haven't really looked into the rules code because I didn't have an immediate need for it but it might be possible to support most or even all of it without much effort. I might look into this when I have a bit more time. |
It would be good to have someone else run this PR on a mac. |
When trying to run the PR on a mac (M2 air, 13.1), I would receive the following error:
After adding a platform check before loading the module, it appears that basic functionality is working on Mac. I can change DPI, enable/disable onboard profiles, and change polling rate. Battery Level also matches up with values reported on Linux and in G Hub. Devices are discovered as they are plugged in and disappear when removed from the system, seamlessly. |
Excellent. |
Hi, I just gave it a shot. So I quickly hacked together, his platform checks with this branch and now the CLI is working fine for me :) |
@markopy I have a suggested change to leave the rules button in, as rules will partly work. |
|
@mahfoozm fork is now working fine! The CLI & Ui now seems to work right away on macOS with devices connected via a unifying receiver. To get the UI working, I had to install psutil via pip On Windows, I'm getting this error after adding hidapi.dll to PATH:
|
Solaar detects devices connected to a Logitech receiver by means of messages the receiver emits, so Solaar can see these devices as soon as they are connected. Solaar on Linux detects receivers and devices that connect via USB or Bluetooth by listening for udev notifications. This Mac port uses polling for this and may only poll USB connections, not Bluetooth. Please try removing and reinserting your receiver and see whether it is removed after a short delay and then reappears, again after a short delay. |
This works as you described it, the receiver disappears and re-appears almost immediately after I reconnected it. I can then also see my kb & mouse reconnecting in the ui |
Good. But Bluetooth devices don't show up at all in Solaar even if they are actually working on your Mac? |
@DaPutzy Thanks. That's looking quite good. |
I don't have any specific instructions for Windows beyond the starting points in my initial message for this PR. I don't use Windows and haven't run it there myself. |
On M1 MacBook MacOS 12.6 I built and ran this PR with following:
It works both via CLI and GUI. |
This step is a bit unnecessary when you run it via
Since it installs solaar to I needed these as well to run it:
This is a good starting point: https://pwr-solaar.github.io/Solaar/installation |
One thing that doesn't work for me on MacOS is |
If you are not running the GUI then devices will reset to their default state whenever they come back from a power-saving mode. What you should be doing is running |
Thanks, I solved my issue by executing Solaar twice on startup, first time without GUI to switch my setting and second time with |
It should be the case that only the GUI should be needed as the GUI remembers the last value for settings and applies them at startup and at other points where this might be needed. |
The application runs, but no devices are detected. I am trying to connect a G512 through a USB hub.
|
Unfortunately I don't have a Mac to try this PR out on so I can only provide limited assistance. The messages output do show attempts to connect to various devices but they are failing for some reason that I do not understand. You might want to try |
@pfps thanks for the help. Yeah, it shows the same errors with -ddd. I will maybe attempt to debug the code locally later. |
PR works fine with Unifying Receiver (devices MX Keys keyboard, M720 Triathlon mouse). |
The interface that is used is only for USB. As I didn't do the port, I don't know what would be required to add Bluetooth support. |
* Add support for macOS via hidapi * Style fixes * Ignore keyboard and mouse input devices * Don't require pyudev on mac and windows * Fix debug log format error * More logging for failed hidpp checks * Don't try to load hid_darwin_set_open_exclusive on windows * Bring back button for rule editor since some rules will work --------- Co-authored-by: markopy <(none)> Co-authored-by: Peter F. Patel-Schneider <[email protected]>
OK I finally got around to checking that this PR doesn't do anything bad on Linux and then merged it. |
Can't get it to build on Mac OS (Sonoma, M1). Cloned the main repo, tried and it broke on patchelf:
Am I doing something wrong? I even tried it in a completely clean Sonoma virtual install, with just Homebrew and Python, no change. Cheers. |
@markopy Can you figure out what is going wrong here? |
@WWWFWWW You are missing autoreconf command on your machine,
should help with it |
Thanks, but I am still at a loss. Even after that, I get errors with patchelf: foo.c:5:65: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a comma I'd pretty much love to get it working, as I suspect plenty of Mac users would love using Solaar (the Logitech app for Mac is really abysmal, and that's an understatement). Yet I think the few people here who apparently got it working are not running a default environment, but are devs so their homebrew and python installed packages might somewhat differ. I'd love to help testing it and getting it to run, but at this point I am simply at a dead end, sorry. |
I'm seeing the same on an M2 Max running Sonoma 14.2.1. If anyone needs me to test a fix, let me know, but also hit a speed bump here. |
what to dl for windows? thx |
Someone will have to do some work to get the windows port working. See PR #2165 for more information. |
I'm in the same boat. |
I'll play around with extending the GitHub CI tests to run on Mac, which has the nice side effect, that necessary dependencies are documented. The installation should be simplified to e.g. a 'make command'. |
@markopy Was there a reason not to use the pyhidapi package besides the little bit different interface of the Linux udev implementation? |
This PR is related to #1244 and #1586 and adds support for macOS and potentially Windows (untested, see below) by using a platform independent library (https://github.com/libusb/hidapi) for device access. Solaar will be able to pair and configure devices but the rule and diversion system will not work because it is Linux specific and not really portable.
macOS
For macOS all dependencies can be installed via homebrew:
brew install hidapi gtk+3 pygobject3
Windows
This PR should also support Windows without any further changes but I don't have the environment to test this. If someone wants to give this a try the first step would be to obtain the hdiapi DLL from https://github.com/libusb/hidapi/releases and check that the command line interface works.
Getting the GUI to work requires GTK which seems non-trivial to install on windows. The starting point for this would be https://pygobject.readthedocs.io/en/latest/getting_started.html#windows-getting-started