diff --git a/pom.xml b/pom.xml
index 890121a..8c8a58e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,8 +22,8 @@
maven-compiler-plugin3.5.1
-
- 1.8
+
+ 1.6
diff --git a/src/net/ash/HIDToVPADNetworkClient/gui/GuiControllerList.java b/src/net/ash/HIDToVPADNetworkClient/gui/GuiControllerList.java
index 51ba72d..7afea23 100644
--- a/src/net/ash/HIDToVPADNetworkClient/gui/GuiControllerList.java
+++ b/src/net/ash/HIDToVPADNetworkClient/gui/GuiControllerList.java
@@ -68,7 +68,7 @@ public class GuiControllerList extends JPanel {
List newComponents = new ArrayList();
- Map components = new HashMap<>();
+ Map components = new HashMap();
for (Component component : innerScrollPanel.getComponents()) {
if (component instanceof GuiControllerListItem) {
GuiControllerListItem comp = (GuiControllerListItem) component;
diff --git a/src/net/ash/HIDToVPADNetworkClient/manager/ActiveControllerManager.java b/src/net/ash/HIDToVPADNetworkClient/manager/ActiveControllerManager.java
index 65d3118..e739cf9 100644
--- a/src/net/ash/HIDToVPADNetworkClient/manager/ActiveControllerManager.java
+++ b/src/net/ash/HIDToVPADNetworkClient/manager/ActiveControllerManager.java
@@ -69,12 +69,12 @@ public class ActiveControllerManager implements Runnable{
}).start();
}
- private Map activeControllers = new HashMap<>();
+ private Map activeControllers = new HashMap();
public void updateControllerStates() {
List currentControllers = ControllerManager.getActiveControllers();
- List toAdd = new ArrayList<>();
- List toRemove = new ArrayList<>();
+ List toAdd = new ArrayList();
+ List toRemove = new ArrayList();
synchronized (activeControllers) {
//Adding all missing.
diff --git a/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java b/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java
index 9c1c96f..04bbecf 100644
--- a/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java
+++ b/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java
@@ -43,11 +43,12 @@ import net.ash.HIDToVPADNetworkClient.controller.XInput13Controller;
import net.ash.HIDToVPADNetworkClient.controller.XInput14Controller;
import net.ash.HIDToVPADNetworkClient.controller.XInputController;
import net.ash.HIDToVPADNetworkClient.exeption.ControllerInitializationFailedException;
+import net.ash.HIDToVPADNetworkClient.util.PureJavaHidApiManager;
import purejavahidapi.HidDeviceInfo;
import purejavahidapi.PureJavaHidApi;
public class ControllerManager{
- private static Map attachedControllers = new HashMap<>();
+ private static Map attachedControllers = new HashMap();
/**
* Detects all attached controller.
@@ -57,18 +58,24 @@ public class ControllerManager{
String os = System.getProperty("os.name");
//System.out.println("[ControllerDetector] OS: " + os);
- Map connectedDevices = new HashMap<>();
+ Map connectedDevices = new HashMap();
if (os.contains("Linux")) {
connectedDevices.putAll(detectLinuxControllers());
} else if (os.contains("Windows")) {
connectedDevices.putAll(detectWindowsControllers());
}
-
- connectedDevices.putAll(detectHIDDevices());
+
+ if (os.contains("Mac OS X")) {
+ connectedDevices.putAll(detectOSXHIDDevices());
+ PureJavaHidApiManager.MAC_OS_X = true;
+ } else {
+ connectedDevices.putAll(detectHIDDevices());
+ PureJavaHidApiManager.MAC_OS_X = false;
+ }
//Remove detached devices
- List toRemove = new ArrayList<>();
+ List toRemove = new ArrayList();
for(String s : attachedControllers.keySet()){
if(!connectedDevices.containsKey(s)){
toRemove.add(s);
@@ -135,11 +142,11 @@ public class ControllerManager{
@Synchronized("attachedControllers")
public static List getAttachedControllers() {
- return new ArrayList<>(attachedControllers.values());
+ return new ArrayList(attachedControllers.values());
}
private static Map detectHIDDevices() {
- Map connectedDevices = new HashMap<>();
+ Map connectedDevices = new HashMap();
for (HidDeviceInfo info : PureJavaHidApi.enumerateDevices()) {
if(info.getUsagePage() == 0x05 || info.getUsagePage() == 0x04 || (info.getVendorId() == 0x57e) || (info.getVendorId() == 0x054c) ){
@@ -149,9 +156,21 @@ public class ControllerManager{
return connectedDevices;
}
+
+ private static Map detectOSXHIDDevices() {
+ Map connectedDevices = new HashMap();
+
+ for (HidDeviceInfo info : PureJavaHidApi.enumerateDevices()) {
+ if(info.getUsagePage() == 0x05 || info.getUsagePage() == 0x04 || (info.getVendorId() == 0x57e) || (info.getVendorId() == 0x054c) ){
+ connectedDevices.put(info.getPath().substring(0, 13),ControllerType.PureJAVAHid);
+ }
+ }
+
+ return connectedDevices;
+ }
private static Map detectWindowsControllers() {
- Map result = new HashMap<>();
+ Map result = new HashMap();
ControllerType type = ControllerType.XINPUT13;
if(XInputDevice.isAvailable() || XInputDevice14.isAvailable()) {
if(XInputDevice14.isAvailable()){
@@ -175,7 +194,7 @@ public class ControllerManager{
}
private static Map detectLinuxControllers() {
- Map result = new HashMap<>();
+ Map result = new HashMap();
File devInput = new File("/dev/input");
if (!devInput.exists()) return result;
@@ -194,7 +213,7 @@ public class ControllerManager{
@Synchronized("attachedControllers")
public static List getActiveControllers() {
- List active = new ArrayList<>();
+ List active = new ArrayList();
for(Controller c : attachedControllers.values()){
if(c.isActive()){
active.add(c);
diff --git a/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java b/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java
index 1cbe99f..7a52c9b 100644
--- a/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java
+++ b/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java
@@ -45,7 +45,7 @@ public class NetworkHIDDevice {
@Getter @Setter private byte padslot;
@Getter private int hidHandle = HandleFoundry.next();
- @Getter(AccessLevel.PRIVATE) private List commands = new ArrayList<>();
+ @Getter(AccessLevel.PRIVATE) private List commands = new ArrayList();
@Getter(AccessLevel.PRIVATE) @Setter(AccessLevel.PRIVATE) private ReadCommand latestRead;
@@ -83,7 +83,7 @@ public class NetworkHIDDevice {
}
public Collection extends DeviceCommand> getCommandList() {
- List commands = new ArrayList<>();
+ List commands = new ArrayList();
commands.addAll(getCommands());
DeviceCommand lastRead;
diff --git a/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java b/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java
index be8a661..d7ef15d 100644
--- a/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java
+++ b/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java
@@ -43,7 +43,7 @@ public class NetworkManager implements Runnable{
private static NetworkManager instance = null;
- private List ownCommands = new ArrayList<>();
+ private List ownCommands = new ArrayList();
private NetworkManager() {
@@ -56,7 +56,7 @@ public class NetworkManager implements Runnable{
return instance;
}
- @Getter private List devices = new ArrayList<>();
+ @Getter private List devices = new ArrayList();
public void addHIDDevice(NetworkHIDDevice device){
if(!getDevices().contains(device)){
@@ -69,7 +69,7 @@ public class NetworkManager implements Runnable{
/*
* We want to remove them at the end of a cycle. To make sure the detach was send before removing.
*/
- @Getter private List toRemove = new ArrayList<>();
+ @Getter private List toRemove = new ArrayList();
@Synchronized("toRemove")
public void removeHIDDevice(NetworkHIDDevice device) {
device.sendDetach();
@@ -94,7 +94,7 @@ public class NetworkManager implements Runnable{
}
public void proccessCommands(){
- List commands = new ArrayList<>();
+ List commands = new ArrayList();
commands.addAll(ownCommands); //TODO: Does this need a synchronized block? It _should_ be only access from this thread. Need to think about it
ownCommands.clear();
synchronized (toRemove) {
@@ -108,7 +108,7 @@ public class NetworkManager implements Runnable{
if(commands.isEmpty())return;
//Split up into "read commands" and other commands.
- List readCommands = new ArrayList<>();
+ List readCommands = new ArrayList();
{
for(DeviceCommand command : commands){
if(command instanceof ReadCommand){
diff --git a/src/net/ash/HIDToVPADNetworkClient/util/HandleFoundry.java b/src/net/ash/HIDToVPADNetworkClient/util/HandleFoundry.java
index a68121c..f35564c 100644
--- a/src/net/ash/HIDToVPADNetworkClient/util/HandleFoundry.java
+++ b/src/net/ash/HIDToVPADNetworkClient/util/HandleFoundry.java
@@ -25,11 +25,11 @@
package net.ash.HIDToVPADNetworkClient.util;
-import java.util.concurrent.ThreadLocalRandom;
+import java.util.Random;
public class HandleFoundry {
//We start with a random value, so we have at each startup a different clientID!
- private static int h = ThreadLocalRandom.current().nextInt(1, 10000);
+ private static int h = new Random().nextInt();
private HandleFoundry(){}
diff --git a/src/net/ash/HIDToVPADNetworkClient/util/PureJavaHidApiManager.java b/src/net/ash/HIDToVPADNetworkClient/util/PureJavaHidApiManager.java
index ab60196..fca6687 100644
--- a/src/net/ash/HIDToVPADNetworkClient/util/PureJavaHidApiManager.java
+++ b/src/net/ash/HIDToVPADNetworkClient/util/PureJavaHidApiManager.java
@@ -32,6 +32,8 @@ public class PureJavaHidApiManager {
private PureJavaHidApiManager(){}
+ public static boolean MAC_OS_X;
+
/**
* Searches the corresponding HIDDevice for the given path
* @param path Path of the HIDDevice
@@ -41,9 +43,15 @@ public class PureJavaHidApiManager {
public static HidDevice getDeviceByPath(String path) throws IOException{
List devList = PureJavaHidApi.enumerateDevices();
for (HidDeviceInfo info : devList) {
- if(info.getPath().equals(path)){
- return PureJavaHidApi.openDevice(info);
- }
+ if (MAC_OS_X) {
+ if(info.getPath().substring(0, 13).equals(path)){
+ return PureJavaHidApi.openDevice(info);
+ }
+ } else {
+ if(info.getPath().equals(path)){
+ return PureJavaHidApi.openDevice(info);
+ }
+ }
}
return null;
}