mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-13 03:16:12 +00:00
changed gamepad preferences a bunch
- no longer have ControllerComponent provide the swing elements - renamed GamepadMapping methods to make more sense - GamepadConfigFrame now uses a grid layout and has some nice borders
This commit is contained in:
@@ -2,8 +2,6 @@ package com.limelight.input;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public enum ControllerComponent implements Serializable {
|
||||
@@ -15,20 +13,10 @@ public enum ControllerComponent implements Serializable {
|
||||
BTN_START("Start Button", false), BTN_BACK("Back Button", false), BTN_SPECIAL("Special Button", false);
|
||||
|
||||
private JLabel label;
|
||||
private JButton mapButton;
|
||||
private JCheckBox invertBox;
|
||||
private JCheckBox triggerBox;
|
||||
private boolean analog;
|
||||
|
||||
private ControllerComponent(String name, boolean analog) {
|
||||
this.label = new JLabel(name);
|
||||
this.mapButton = new JButton();
|
||||
this.mapButton.setName(this.name());
|
||||
this.invertBox = new JCheckBox("Invert");
|
||||
this.invertBox.setName(this.name());
|
||||
this.triggerBox = new JCheckBox("Trigger");
|
||||
this.triggerBox.setName(this.name());
|
||||
this.triggerBox.setToolTipText("If this component should act as a trigger.");
|
||||
this.analog = analog;
|
||||
}
|
||||
|
||||
@@ -36,22 +24,11 @@ public enum ControllerComponent implements Serializable {
|
||||
return label;
|
||||
}
|
||||
|
||||
public JButton getMapButton() {
|
||||
return mapButton;
|
||||
}
|
||||
|
||||
public JCheckBox getInvertBox() {
|
||||
return invertBox;
|
||||
}
|
||||
|
||||
public JCheckBox getTriggerBox() {
|
||||
return triggerBox;
|
||||
}
|
||||
|
||||
public boolean isAnalog() {
|
||||
return analog;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean sameAs(ControllerComponent other) {
|
||||
return this.name().equals(other.name());
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class Gamepad {
|
||||
}
|
||||
|
||||
private void handleComponent(Component comp, float value) {
|
||||
Mapping mapping = config.getMapping(comp);
|
||||
Mapping mapping = config.get(comp);
|
||||
if (mapping != null) {
|
||||
if (mapping.contComp.isAnalog()) {
|
||||
handleAnalog(mapping.contComp, sanitizeValue(mapping, value));
|
||||
|
||||
@@ -19,21 +19,21 @@ public class GamepadMapping implements Serializable {
|
||||
mapping.put(comp.getIdentifier().getName(), toMap);
|
||||
}
|
||||
|
||||
public Mapping getMapping(Component comp) {
|
||||
public Mapping get(Component comp) {
|
||||
return mapping.get(comp.getIdentifier().getName());
|
||||
}
|
||||
|
||||
public void removeMapping(Component comp) {
|
||||
public void remove(Component comp) {
|
||||
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) {
|
||||
public Mapping get(ControllerComponent contComp) {
|
||||
//#allTheJank
|
||||
for (Entry<String, Mapping> entry : mapping.entrySet()) {
|
||||
if (entry.getValue().contComp.sameAs(contComp)) {
|
||||
return entry.getValue();
|
||||
@@ -44,7 +44,6 @@ public class GamepadMapping implements Serializable {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user