mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-05 15:36:10 +00:00
fixed invert and trigger settings not being saved
This commit is contained in:
@@ -9,17 +9,17 @@ import net.java.games.input.Component;
|
||||
public class GamepadMapping implements Serializable {
|
||||
private static final long serialVersionUID = -185035113915743149L;
|
||||
|
||||
private HashMap<String, ControllerComponent> mapping;
|
||||
|
||||
private HashMap<String, Mapping> mapping;
|
||||
|
||||
public GamepadMapping() {
|
||||
mapping = new HashMap<String, ControllerComponent>();
|
||||
mapping = new HashMap<String, Mapping>();
|
||||
}
|
||||
|
||||
public void insertMapping(ControllerComponent contComp, Component comp) {
|
||||
mapping.put(comp.getIdentifier().getName(), contComp);
|
||||
public void insertMapping(Mapping toMap, Component comp) {
|
||||
mapping.put(comp.getIdentifier().getName(), toMap);
|
||||
}
|
||||
|
||||
public ControllerComponent getControllerComponent(Component comp) {
|
||||
public Mapping getMapping(Component comp) {
|
||||
return mapping.get(comp.getIdentifier().getName());
|
||||
}
|
||||
|
||||
@@ -27,6 +27,21 @@ public class GamepadMapping implements Serializable {
|
||||
mapping.remove(comp.getIdentifier().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mapped ControllerComponent for the specified ControllerComponent.</br>
|
||||
* NOTE: Use sparingly takes O(N) time.
|
||||
* @param contComp the component to get a mapping for
|
||||
* @return a mapping or an null if there is none
|
||||
*/
|
||||
public Mapping getMappedComponent(ControllerComponent contComp) {
|
||||
for (Entry<String, Mapping> entry : mapping.entrySet()) {
|
||||
if (entry.getValue().contComp.sameAs(contComp)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mapping for the specified component.</br>
|
||||
* NOTE: Use sparingly takes O(N) time.
|
||||
@@ -34,11 +49,25 @@ public class GamepadMapping implements Serializable {
|
||||
* @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)) {
|
||||
for (Entry<String, Mapping> entry : mapping.entrySet()) {
|
||||
if (entry.getValue().contComp.sameAs(contComp)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public class Mapping implements Serializable {
|
||||
private static final long serialVersionUID = -8407172977953214242L;
|
||||
|
||||
public ControllerComponent contComp;
|
||||
public boolean invert;
|
||||
public boolean trigger;
|
||||
|
||||
public Mapping(ControllerComponent contComp, boolean invert, boolean trigger) {
|
||||
this.contComp = contComp;
|
||||
this.invert = invert;
|
||||
this.trigger = trigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user