mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-05 15:36:10 +00:00
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:
40
src/com/limelight/input/GamepadMapping.java
Normal file
40
src/com/limelight/input/GamepadMapping.java
Normal 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 "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user