mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-05 07:26:07 +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:
@@ -8,20 +8,21 @@ import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import com.limelight.input.GamepadSettings;
|
||||
import com.limelight.input.GamepadMapping;
|
||||
|
||||
public class GamepadSettingsManager {
|
||||
private static GamepadSettings cachedSettings;
|
||||
private static GamepadMapping cachedSettings;
|
||||
|
||||
|
||||
public static GamepadSettings getSettings() {
|
||||
public static GamepadMapping getSettings() {
|
||||
if (cachedSettings == null) {
|
||||
System.out.println("Reading Gamepad Settings");
|
||||
File gamepadFile = SettingsManager.getInstance().getGamepadFile();
|
||||
ObjectInputStream ois = null;
|
||||
|
||||
try {
|
||||
ois = new ObjectInputStream(new FileInputStream(gamepadFile));
|
||||
GamepadSettings savedSettings = (GamepadSettings)ois.readObject();
|
||||
GamepadMapping savedSettings = (GamepadMapping)ois.readObject();
|
||||
cachedSettings = savedSettings;
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -47,13 +48,20 @@ public class GamepadSettingsManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cachedSettings == null) {
|
||||
System.out.println("Unable to get gamepad settings. Using an empty mapping instead.");
|
||||
cachedSettings = new GamepadMapping();
|
||||
writeSettings(cachedSettings);
|
||||
}
|
||||
return cachedSettings;
|
||||
}
|
||||
|
||||
public static void writeSettings(GamepadSettings settings) {
|
||||
public static void writeSettings(GamepadMapping settings) {
|
||||
cachedSettings = settings;
|
||||
System.out.println("Writing Gamepad Settings");
|
||||
|
||||
File gamepadFile = SettingsManager.getInstance().getGamepadFile();
|
||||
|
||||
ObjectOutputStream ous = null;
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user