diff --git a/Dungeoneer/src/com/interrupt/dungeoneer/game/Options.java b/Dungeoneer/src/com/interrupt/dungeoneer/game/Options.java index 0a7861c0..2b1bc3f0 100644 --- a/Dungeoneer/src/com/interrupt/dungeoneer/game/Options.java +++ b/Dungeoneer/src/com/interrupt/dungeoneer/game/Options.java @@ -98,7 +98,7 @@ public Options() { } } - public static void SetInputOptions(GamepadDefinition defaultGamepad) { + public static void SetKeyboardBindings() { Actions.keyBindings.put(Action.USE, Options.instance.key_use); Actions.keyBindings.put(Action.ATTACK, Options.instance.key_attack); Actions.keyBindings.put(Action.FORWARD, Options.instance.key_forward); @@ -114,7 +114,9 @@ public static void SetInputOptions(GamepadDefinition defaultGamepad) { Actions.keyBindings.put(Action.TURN_LEFT, Options.instance.key_turn_left); Actions.keyBindings.put(Action.TURN_RIGHT, Options.instance.key_turn_right); Actions.keyBindings.put(Action.JUMP, Options.instance.key_jump); + } + public static void SetGamepadBindings(GamepadDefinition defaultGamepad) { SetGamepadAction(Action.USE, Options.instance.gamepad_use, defaultGamepad); SetGamepadAction(Action.ATTACK, Options.instance.gamepad_attack, defaultGamepad); SetGamepadAction(Action.FORWARD, Options.instance.gamepad_forward, defaultGamepad); @@ -171,6 +173,8 @@ public static void loadOptions() { JsonUtil.toJson(o, file); return o; }); + + SetKeyboardBindings(); } /** Save options to file. */ diff --git a/Dungeoneer/src/com/interrupt/dungeoneer/input/GamepadManager.java b/Dungeoneer/src/com/interrupt/dungeoneer/input/GamepadManager.java index ba368d8d..66b29230 100644 --- a/Dungeoneer/src/com/interrupt/dungeoneer/input/GamepadManager.java +++ b/Dungeoneer/src/com/interrupt/dungeoneer/input/GamepadManager.java @@ -302,23 +302,30 @@ public void init() { Controller first = Controllers.getControllers().first(); if(first != null) mapController(first); } - + public void mapController(Controller controller) { - String controllerName = controller.getName().toLowerCase(); - if (controllerName.contains("microsoft corporatio controller")) - controllerMapping.put(controller, new GamepadDefinition(new Xbox360OSXPad())); - else if (controllerName.contains("microsoft") || controllerName.contains("xbox") || controllerName.contains("360")) - controllerMapping.put(controller, new GamepadDefinition(new Xbox360Pad())); - else if (controllerName.contains("sony")) - controllerMapping.put(controller, new GamepadDefinition(new SonyPad())); - else if(controller.getName().equals(Ouya.ID)) - controllerMapping.put(controller, new GamepadDefinition(new Ouya())); - else if (controllerName.contains("moga")) - controllerMapping.put(controller, new GamepadDefinition(new MogaProPad())); - else - controllerMapping.put(controller, new GamepadDefinition(new Xbox360Pad())); - - Options.SetInputOptions(controllerMapping.get(controller)); + String controllerName = controller.getName().toLowerCase(); + + if (controllerName.contains("microsoft corporatio controller")) { + controllerMapping.put(controller, new GamepadDefinition(new Xbox360OSXPad())); + } + else if (controllerName.contains("microsoft") || controllerName.contains("xbox") || controllerName.contains("360")) { + controllerMapping.put(controller, new GamepadDefinition(new Xbox360Pad())); + } + else if (controllerName.contains("sony")) { + controllerMapping.put(controller, new GamepadDefinition(new SonyPad())); + } + else if (controller.getName().equals(Ouya.ID)) { + controllerMapping.put(controller, new GamepadDefinition(new Ouya())); + } + else if (controllerName.contains("moga")) { + controllerMapping.put(controller, new GamepadDefinition(new MogaProPad())); + } + else { + controllerMapping.put(controller, new GamepadDefinition(new Xbox360Pad())); + } + + Options.SetGamepadBindings(controllerMapping.get(controller)); } public Vector2 applyDeadzone(Vector2 rawInput) {