Commit 02624a2
authored
Avoid taking an exclusive lock on Litra devices on macOS (#93)
Currently, when a Litra handle device is opened with `open()`,
on macOS we take an exclusive lock on the device, which stops
it being managed by other applications.
This isn't a problem if the device handle is quickly closed
again (e.g. if the application exits), but it can be annoying if
you have a long-running application that holds onto the device
handle for a long time (e.g. `litra auto-toggle`).
As an example, if you run `litra auto-toggle` and then try to
turn the device on or off with `litra on` or `litra off` in
another shell, it would fail with an error:
> HID error occurred: hidapi error: hid_open_path: failed to open IOHIDDevice from mach entry: (0xE00002C5) (iokit/common) exclusive access and device already open
This switches to taking a non-exclusive lock on macOS, affecting
use of this code as a Rust library and our long-running
`auto-toggle` command.1 parent 6f3db81 commit 02624a2
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
180 | | - | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
0 commit comments