Skip to content

Commit

Permalink
macOS: Fix HID crashing regression (#1267)
Browse files Browse the repository at this point in the history
Use thread-safe calls for macOS HID
Uses a custom snapshot of hid4java gary-rowe/hid4java#153
---------

Co-authored-by: Tres Finocchiaro <tres.finocchiaro@gmail.com>
  • Loading branch information
Vzor- and tresf authored Jul 23, 2024
1 parent 522fba3 commit fb12d07
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
Binary file removed lib/communication/hid4java-0.7.2-SNAPSHOT.jar
Binary file not shown.
Binary file added lib/communication/hid4java-0.8.0+7.jar
Binary file not shown.
15 changes: 2 additions & 13 deletions src/qz/communication/H4J_HidUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,16 @@
import org.hid4java.HidDevice;
import org.hid4java.HidManager;
import org.hid4java.HidServices;
import qz.utils.SystemUtilities;

import javax.usb.util.UsbUtil;
import java.util.HashSet;
import java.util.List;

public class H4J_HidUtilities {

private static HidServices service = HidManager.getHidServices();

private static final HidServices service = HidManager.getHidServices();

public static List<HidDevice> getHidDevices() {
List<HidDevice> devices = service.getAttachedHidDevices();

// FIXME: Prevent hard crash on OSX
// Per upstream Mac bug https://github.com/gary-rowe/hid4java/issues/37
if (SystemUtilities.isMac()) {
service.shutdown();
}
return devices;
return service.getAttachedHidDevices();
}

public static JSONArray getHidDevicesJSON() throws JSONException {
Expand Down Expand Up @@ -72,5 +62,4 @@ public static HidDevice findDevice(DeviceOptions dOpts) {

return null;
}

}

0 comments on commit fb12d07

Please sign in to comment.