mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-17 14:22:00 +00:00
renamed gamepad config page, No longer shit bricks if the gamepad disconnects while trying to map. Now rescans for gamepads
This commit is contained in:
+42
-26
@@ -31,7 +31,7 @@ import com.limelight.input.GamepadMapping;
|
||||
import com.limelight.input.GamepadMapping.Mapping;
|
||||
import com.limelight.settings.GamepadSettingsManager;
|
||||
|
||||
public class SettingsFrame extends JFrame {
|
||||
public class GamepadConfigFrame extends JFrame {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean configChanged = false;
|
||||
@@ -40,7 +40,7 @@ public class SettingsFrame extends JFrame {
|
||||
private Thread mappingThread;
|
||||
private GamepadMapping config;
|
||||
|
||||
public SettingsFrame() {
|
||||
public GamepadConfigFrame() {
|
||||
super("Gamepad Settings");
|
||||
System.out.println("Creating Settings Frame");
|
||||
this.setSize(900, 500);
|
||||
@@ -87,6 +87,9 @@ public class SettingsFrame extends JFrame {
|
||||
comp.getMapButton().setMinimumSize(buttonSize);
|
||||
comp.getMapButton().setPreferredSize(buttonSize);
|
||||
|
||||
for (ActionListener l : comp.getMapButton().getActionListeners()) {
|
||||
comp.getMapButton().removeActionListener(l);
|
||||
}
|
||||
comp.getMapButton().addActionListener(createListener());
|
||||
comp.getMapButton().setText(config.getMapping(comp));
|
||||
|
||||
@@ -172,7 +175,7 @@ public class SettingsFrame extends JFrame {
|
||||
List<Gamepad> gamepads = GamepadHandler.getGamepads();
|
||||
|
||||
if (gamepads.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(SettingsFrame.this, "No Gamepad Detected");
|
||||
JOptionPane.showMessageDialog(GamepadConfigFrame.this, "No Gamepad Detected");
|
||||
return;
|
||||
}
|
||||
map(contComp, gamepads.get(0));
|
||||
@@ -198,17 +201,22 @@ public class SettingsFrame extends JFrame {
|
||||
Component newMapping = null;
|
||||
|
||||
while (newMapping == null) {
|
||||
pad.poll();
|
||||
EventQueue queue = pad.getEvents();
|
||||
Event event = new Event();
|
||||
if (pad.poll()) {
|
||||
EventQueue queue = pad.getEvents();
|
||||
Event event = new Event();
|
||||
|
||||
while (queue.getNextEvent(event)) {
|
||||
if (Math.abs(event.getValue()) > .75F) {
|
||||
newMapping = event.getComponent();
|
||||
break;
|
||||
while (queue.getNextEvent(event)) {
|
||||
if (!pad.poll()) {
|
||||
break;
|
||||
}
|
||||
if (Math.abs(event.getValue()) > .75F) {
|
||||
newMapping = event.getComponent();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {}
|
||||
@@ -218,30 +226,38 @@ public class SettingsFrame extends JFrame {
|
||||
Thread consumeEvents = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pad.poll();
|
||||
EventQueue queue = pad.getEvents();
|
||||
Event event = new Event();
|
||||
if (pad.poll()) {
|
||||
EventQueue queue = pad.getEvents();
|
||||
Event event = new Event();
|
||||
|
||||
while (queue.getNextEvent(event)) {
|
||||
while (queue.getNextEvent(event)) {
|
||||
if (!pad.poll()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
consumeEvents.setName("Consume Events Thread");
|
||||
consumeEvents.start();
|
||||
|
||||
Mapping oldConfig = config.getMapping(newMapping);
|
||||
if (oldConfig != null) {
|
||||
config.removeMapping(newMapping);
|
||||
oldConfig.contComp.getMapButton().setText("");
|
||||
}
|
||||
if (newMapping != null) {
|
||||
Mapping oldConfig = config.getMapping(newMapping);
|
||||
if (oldConfig != null) {
|
||||
config.removeMapping(newMapping);
|
||||
oldConfig.contComp.getMapButton().setText("");
|
||||
}
|
||||
|
||||
Mapping newConfig = config.getMappedComponent(contComp);
|
||||
if (newConfig == null) {
|
||||
newConfig = config.new Mapping(contComp, false, false);
|
||||
Mapping newConfig = config.getMappedComponent(contComp);
|
||||
if (newConfig == null) {
|
||||
newConfig = config.new Mapping(contComp, false, false);
|
||||
}
|
||||
config.insertMapping(newConfig, newMapping);
|
||||
contComp.getMapButton().setText(newMapping.getName());
|
||||
configChanged = true;
|
||||
} else {
|
||||
contComp.getMapButton().setText(config.getMapping(contComp));
|
||||
}
|
||||
config.insertMapping(newConfig, newMapping);
|
||||
contComp.getMapButton().setText(newMapping.getName());
|
||||
configChanged = true;
|
||||
contComp.getMapButton().setSelected(false);
|
||||
}
|
||||
});
|
||||
@@ -125,7 +125,7 @@ public class MainFrame {
|
||||
gamepadSettings.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SettingsFrame().build();
|
||||
new GamepadConfigFrame().build();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -40,11 +40,9 @@ public class ControllerListener {
|
||||
|
||||
ControllerEnvironment defaultEnv = null;
|
||||
|
||||
//TODO: allow "rescanning" to work again
|
||||
defaultEnv = (ControllerEnvironment)construct.newInstance();
|
||||
|
||||
while(!isInterrupted()) {
|
||||
|
||||
defaultEnv = (ControllerEnvironment)construct.newInstance();
|
||||
Controller[] ca = defaultEnv.getControllers();
|
||||
LinkedList<Controller> gamepads = new LinkedList<Controller>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user