Removed deprecated method and renamed some classes. Created a new package to separate gamepad classes from keyboard/mouse classes

This commit is contained in:
Diego Waxemberg
2013-12-27 10:08:31 -05:00
parent bc79e1ee06
commit 2c3ed99a3a
9 changed files with 41 additions and 49 deletions

View File

@@ -0,0 +1,73 @@
package com.limelight.input.gamepad;
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, Mapping> mapping;
public GamepadMapping() {
mapping = new HashMap<String, Mapping>();
}
public void insertMapping(Mapping toMap, Component comp) {
mapping.put(comp.getIdentifier().getName(), toMap);
}
public Mapping get(Component comp) {
return mapping.get(comp.getIdentifier().getName());
}
public void remove(Component comp) {
mapping.remove(comp.getIdentifier().getName());
}
/**
* Gets the mapped ControllerComponent for the specified ControllerComponent.</br>
* @param contComp the component to get a mapping for
* @return a mapping or an null if there is none
*/
public Mapping get(GamepadComponent contComp) {
//#allTheJank
for (Entry<String, Mapping> entry : mapping.entrySet()) {
if (entry.getValue().contComp == contComp) {
return entry.getValue();
}
}
return null;
}
/**
* Gets the mapping for the specified component.</br>
* @param contComp the component to get a mapping for
* @return a mapping or an empty string if there is none
*/
public String getMapping(GamepadComponent contComp) {
for (Entry<String, Mapping> entry : mapping.entrySet()) {
if (entry.getValue().contComp == contComp) {
return entry.getKey();
}
}
return "";
}
public class Mapping implements Serializable {
private static final long serialVersionUID = -8407172977953214242L;
public GamepadComponent contComp;
public boolean invert;
public boolean trigger;
public Mapping(GamepadComponent contComp, boolean invert, boolean trigger) {
this.contComp = contComp;
this.invert = invert;
this.trigger = trigger;
}
}
}