more gamepad changes

- now have a menu bar to access settings
- now handle user input to assign mappings
- fixed some typos
- now properly shutdown controller threads on exit
- renamed GamepadSettings to GamepadMapping
- created a lock to ensure we do not add/remove gamepads from the list while we are handling their events
- fixed settings directory booch
This commit is contained in:
Diego Waxemberg
2013-12-20 13:00:30 -05:00
parent 43df4cf93e
commit ba0b84f9e5
10 changed files with 184 additions and 80 deletions

View File

@@ -0,0 +1,40 @@
package com.limelight.input;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map.Entry;
import net.java.games.input.Component;
public class GamepadMapping implements Serializable {
private static final long serialVersionUID = -185035113915743149L;
private HashMap<String, ControllerComponent> mapping;
public GamepadMapping() {
mapping = new HashMap<String, ControllerComponent>();
}
public void insertMapping(ControllerComponent contComp, Component comp) {
mapping.put(comp.getIdentifier().getName(), contComp);
}
public ControllerComponent getControllerComponent(Component comp) {
return mapping.get(comp.getIdentifier().getName());
}
/**
* Gets the mapping for the specified component.</br>
* NOTE: Use sparingly takes O(N) time.
* @param contComp the component to get a mapping for
* @return a mapping or an empty string if there is none
*/
public String getMapping(ControllerComponent contComp) {
for (Entry<String, ControllerComponent> entry : mapping.entrySet()) {
if (entry.getValue().equals(contComp)) {
return entry.getKey();
}
}
return "";
}
}