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:
Diego Waxemberg
2013-12-24 18:59:07 -05:00
parent 518b686991
commit eccd3468ed
4 changed files with 202 additions and 185 deletions

View File

@@ -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());
}

View File

@@ -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));

View File

@@ -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
*/