diff --git a/lib/bin/net/java/games/input/AWTEnvironmentPlugin.class b/lib/bin/net/java/games/input/AWTEnvironmentPlugin.class index 0d68ba6..fc0b9c0 100644 Binary files a/lib/bin/net/java/games/input/AWTEnvironmentPlugin.class and b/lib/bin/net/java/games/input/AWTEnvironmentPlugin.class differ diff --git a/lib/bin/net/java/games/input/ControllerEnvironment.class b/lib/bin/net/java/games/input/ControllerEnvironment.class index 7033c54..4077c1a 100644 Binary files a/lib/bin/net/java/games/input/ControllerEnvironment.class and b/lib/bin/net/java/games/input/ControllerEnvironment.class differ diff --git a/lib/bin/net/java/games/input/DefaultControllerEnvironment.class b/lib/bin/net/java/games/input/DefaultControllerEnvironment.class index d5bbbe8..1e11efc 100644 Binary files a/lib/bin/net/java/games/input/DefaultControllerEnvironment.class and b/lib/bin/net/java/games/input/DefaultControllerEnvironment.class differ diff --git a/lib/bin/net/java/games/input/DirectAndRawInputEnvironmentPlugin.class b/lib/bin/net/java/games/input/DirectAndRawInputEnvironmentPlugin.class index ee9b572..5ded1c6 100644 Binary files a/lib/bin/net/java/games/input/DirectAndRawInputEnvironmentPlugin.class and b/lib/bin/net/java/games/input/DirectAndRawInputEnvironmentPlugin.class differ diff --git a/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin$ShutdownHook.class b/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin$ShutdownHook.class index dea7316..1d58975 100644 Binary files a/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin$ShutdownHook.class and b/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin$ShutdownHook.class differ diff --git a/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin.class b/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin.class index 47b7287..cabbf12 100644 Binary files a/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin.class and b/lib/bin/net/java/games/input/DirectInputEnvironmentPlugin.class differ diff --git a/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$1.class b/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$1.class index 1f5cb1b..49c4e47 100644 Binary files a/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$1.class and b/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$1.class differ diff --git a/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$ShutdownHook.class b/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$ShutdownHook.class index f2fba2a..f2c31a0 100644 Binary files a/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$ShutdownHook.class and b/lib/bin/net/java/games/input/LinuxEnvironmentPlugin$ShutdownHook.class differ diff --git a/lib/bin/net/java/games/input/LinuxEnvironmentPlugin.class b/lib/bin/net/java/games/input/LinuxEnvironmentPlugin.class index 851dffe..95e2227 100644 Binary files a/lib/bin/net/java/games/input/LinuxEnvironmentPlugin.class and b/lib/bin/net/java/games/input/LinuxEnvironmentPlugin.class differ diff --git a/lib/bin/net/java/games/input/OSXEnvironmentPlugin.class b/lib/bin/net/java/games/input/OSXEnvironmentPlugin.class index 512b5b5..4e317ff 100644 Binary files a/lib/bin/net/java/games/input/OSXEnvironmentPlugin.class and b/lib/bin/net/java/games/input/OSXEnvironmentPlugin.class differ diff --git a/lib/bin/net/java/games/input/RawInputEnvironmentPlugin.class b/lib/bin/net/java/games/input/RawInputEnvironmentPlugin.class index 4461038..44fc8c4 100644 Binary files a/lib/bin/net/java/games/input/RawInputEnvironmentPlugin.class and b/lib/bin/net/java/games/input/RawInputEnvironmentPlugin.class differ diff --git a/lib/jinput.jar b/lib/jinput.jar index df3efa1..82579cd 100644 Binary files a/lib/jinput.jar and b/lib/jinput.jar differ diff --git a/src/sig/RabiClone.java b/src/sig/RabiClone.java index 2281a0f..e53bf43 100644 --- a/src/sig/RabiClone.java +++ b/src/sig/RabiClone.java @@ -7,6 +7,7 @@ import net.java.games.input.Controller; import net.java.games.input.ControllerEnvironment; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import sig.engine.Panel; @@ -24,6 +25,7 @@ import sig.engine.PaletteColor; import java.awt.Toolkit; import java.awt.event.KeyEvent; +import java.lang.reflect.Constructor; public class RabiClone{ public static final String PROGRAM_NAME="RabiClone"; @@ -48,6 +50,20 @@ public class RabiClone{ public static Controller[] CONTROLLERS = new Controller[]{}; public static long lastControllerScan = System.currentTimeMillis(); + + private static ControllerEnvironment createDefaultEnvironment() throws ReflectiveOperationException { + + // Find constructor (class is package private, so we can't access it directly) + Constructor constructor = (Constructor) + Class.forName("net.java.games.input.DefaultControllerEnvironment").getDeclaredConstructors()[0]; + + // Constructor is package private, so we have to deactivate access control checks + constructor.setAccessible(true); + + // Create object with default constructor + return constructor.newInstance(); + } + public static void main(String[] args) { Key.InitializeKeyConversionMap(); @@ -79,7 +95,11 @@ public class RabiClone{ long lastGameTime = System.nanoTime(); - CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers(); + try { + CONTROLLERS = createDefaultEnvironment().getControllers(); + } catch (ReflectiveOperationException e) { + e.printStackTrace(); + } while (true) { long timePassed = System.nanoTime()-lastGameTime; lastGameTime=System.nanoTime(); @@ -87,10 +107,6 @@ public class RabiClone{ //System.out.println(CONTROLLERS.length); - CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers(); - if (System.currentTimeMillis()-lastControllerScan>=5000) { - CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().rescanControllers(); - } for (int i=0;i5000) { + try { + CONTROLLERS=createDefaultEnvironment().getControllers(); + } catch (ReflectiveOperationException e) { + e.printStackTrace(); + } + } for (int i=0;i clist = KeyBind.KEYBINDS.get(selectedAction); @@ -67,15 +75,6 @@ public class ConfigureControls extends Object{ } } - public void rawKeyPressed(int keyCode) { - if (assigningKey) { - List clist = KeyBind.KEYBINDS.get(selectedAction); - clist.add(new KeyBind(keyCode)); - KeyBind.KEYBINDS.put(selectedAction,clist); - assigningKey=false; - } - } - @Override protected void MousePressed(MouseEvent e) { if (e.getButton()==MouseEvent.BUTTON1) { @@ -91,5 +90,14 @@ public class ConfigureControls extends Object{ } return sb; } + + public void rawKeyPressed(int keyCode) { + if (assigningKey) { + List clist = KeyBind.KEYBINDS.get(selectedAction); + clist.add(new KeyBind(keyCode)); + KeyBind.KEYBINDS.put(selectedAction,clist); + assigningKey=false; + } + } }