mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-16 13:30:35 +00:00
Gamepad mapping configurable
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package com.limelight.input;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Mapping between gamepad and gamestream input
|
||||
* @author Iwan Timmer
|
||||
@@ -32,4 +39,25 @@ public class GamepadMapping {
|
||||
public short btn_dpad_left = EvdevConstants.BTN_DPAD_LEFT;
|
||||
public short btn_dpad_right = EvdevConstants.BTN_DPAD_RIGHT;
|
||||
|
||||
public GamepadMapping(File file) throws IOException {
|
||||
Properties props = new Properties();
|
||||
props.load(new FileInputStream(file));
|
||||
|
||||
for (Map.Entry entry:props.entrySet()) {
|
||||
try {
|
||||
Field field = this.getClass().getField(entry.getKey().toString());
|
||||
field.setShort(this, Short.parseShort(entry.getValue().toString()));
|
||||
} catch (NoSuchFieldException e) {
|
||||
System.err.println("No mapping found named " + entry.getKey());
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Not a number for " + entry.getKey());
|
||||
} catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
System.err.println("Can't change mapping for " + entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GamepadMapping() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user