changed a poorly named variable

This commit is contained in:
Diego Waxemberg
2013-12-30 22:19:09 -05:00
parent 5396ce03ed
commit db0eadf4d7
3 changed files with 25 additions and 25 deletions

View File

@@ -116,7 +116,7 @@ public class GamepadConfigFrame extends JFrame {
mapButton.setPreferredSize(buttonSize); mapButton.setPreferredSize(buttonSize);
mapButton.addActionListener(createMapListener()); mapButton.addActionListener(createMapListener());
setButtonText(mapButton, config.getMapping(mapping.contComp)); setButtonText(mapButton, config.getMapping(mapping.padComp));
invertBox.setSelected(mapping.invert); invertBox.setSelected(mapping.invert);
invertBox.addItemListener(createInvertListener()); invertBox.addItemListener(createInvertListener());
@@ -126,7 +126,7 @@ public class GamepadConfigFrame extends JFrame {
triggerBox.setToolTipText("If this component should act as a trigger. (one-way axis)"); triggerBox.setToolTipText("If this component should act as a trigger. (one-way axis)");
componentBox.add(Box.createHorizontalStrut(5)); componentBox.add(Box.createHorizontalStrut(5));
componentBox.add(mapping.contComp.getLabel()); componentBox.add(mapping.padComp.getLabel());
componentBox.add(Box.createHorizontalGlue()); componentBox.add(Box.createHorizontalGlue());
componentBox.add(mapButton); componentBox.add(mapButton);
componentBox.add(invertBox); componentBox.add(invertBox);
@@ -149,8 +149,8 @@ public class GamepadConfigFrame extends JFrame {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
JCheckBox clicked = (JCheckBox)e.getItem(); JCheckBox clicked = (JCheckBox)e.getItem();
GamepadComponent contComp = GamepadComponent.valueOf(clicked.getName()); GamepadComponent padComp = GamepadComponent.valueOf(clicked.getName());
config.get(contComp).invert = (e.getStateChange() == ItemEvent.SELECTED); config.get(padComp).invert = (e.getStateChange() == ItemEvent.SELECTED);
configChanged = true; configChanged = true;
} }
}; };
@@ -164,8 +164,8 @@ public class GamepadConfigFrame extends JFrame {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
JCheckBox clicked = (JCheckBox)e.getItem(); JCheckBox clicked = (JCheckBox)e.getItem();
GamepadComponent contComp = GamepadComponent.valueOf(clicked.getName()); GamepadComponent padComp = GamepadComponent.valueOf(clicked.getName());
config.get(contComp).trigger = (e.getStateChange() == ItemEvent.SELECTED); config.get(padComp).trigger = (e.getStateChange() == ItemEvent.SELECTED);
configChanged = true; configChanged = true;
} }
}; };
@@ -284,7 +284,7 @@ public class GamepadConfigFrame extends JFrame {
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) { } catch (InterruptedException e) {
setButtonText(buttonPressed, config.getMapping(mappingToMap.contComp)); setButtonText(buttonPressed, config.getMapping(mappingToMap.padComp));
GamepadListener.getInstance().removeListener(this); GamepadListener.getInstance().removeListener(this);
return; return;
} }

View File

@@ -46,13 +46,13 @@ public class Gamepad implements DeviceListener {
return; return;
} }
if (!mapped.contComp.isAnalog()) { if (!mapped.padComp.isAnalog()) {
handleDigitalComponent(mapped, pressed); handleDigitalComponent(mapped, pressed);
} else { } else {
handleAnalogComponent(mapped.contComp, sanitizeValue(mapped, pressed)); handleAnalogComponent(mapped.padComp, sanitizeValue(mapped, pressed));
} }
//printInfo(device, new SourceComponent(Type.BUTTON, buttonId), mapped.contComp, pressed ? 1F : 0F); //printInfo(device, new SourceComponent(Type.BUTTON, buttonId), mapped.padComp, pressed ? 1F : 0F);
} }
@Override @Override
@@ -67,13 +67,13 @@ public class Gamepad implements DeviceListener {
float value = sanitizeValue(mapped, newValue); float value = sanitizeValue(mapped, newValue);
if (mapped.contComp.isAnalog()) { if (mapped.padComp.isAnalog()) {
handleAnalogComponent(mapped.contComp, value); handleAnalogComponent(mapped.padComp, value);
} else { } else {
handleDigitalComponent(mapped, (value > 0.5)); handleDigitalComponent(mapped, (value > 0.5));
} }
//printInfo(device, new SourceComponent(Type.AXIS, axisId), mapped.contComp, newValue); //printInfo(device, new SourceComponent(Type.AXIS, axisId), mapped.padComp, newValue);
} }
private float sanitizeValue(Mapping mapped, boolean value) { private float sanitizeValue(Mapping mapped, boolean value) {
@@ -123,7 +123,7 @@ public class Gamepad implements DeviceListener {
private void handleDigitalComponent(Mapping mapped, boolean pressed) { private void handleDigitalComponent(Mapping mapped, boolean pressed) {
switch (mapped.contComp) { switch (mapped.padComp) {
case BTN_A: case BTN_A:
toggle(ControllerPacket.A_FLAG, pressed); toggle(ControllerPacket.A_FLAG, pressed);
break; break;
@@ -170,7 +170,7 @@ public class Gamepad implements DeviceListener {
toggle(ControllerPacket.SPECIAL_BUTTON_FLAG, pressed); toggle(ControllerPacket.SPECIAL_BUTTON_FLAG, pressed);
break; break;
default: default:
System.out.println("A mapping error has occured. Ignoring: " + mapped.contComp.name()); System.out.println("A mapping error has occured. Ignoring: " + mapped.padComp.name());
return; return;
} }
if (conn != null) { if (conn != null) {

View File

@@ -49,13 +49,13 @@ public class GamepadMapping implements Serializable {
/** /**
* Gets the mapped ControllerComponent for the specified ControllerComponent.</br> * Gets the mapped ControllerComponent for the specified ControllerComponent.</br>
* <b>NOTE: Iterates a hashmap, use sparingly</b> * <b>NOTE: Iterates a hashmap, use sparingly</b>
* @param contComp the component to get a mapping for * @param padComp the component to get a mapping for
* @return a mapping or an null if there is none * @return a mapping or an null if there is none
*/ */
public Mapping get(GamepadComponent contComp) { public Mapping get(GamepadComponent padComp) {
//#allTheJank //#allTheJank
for (Entry<SourceComponent, Mapping> entry : mapping.entrySet()) { for (Entry<SourceComponent, Mapping> entry : mapping.entrySet()) {
if (entry.getValue().contComp == contComp) { if (entry.getValue().padComp == padComp) {
return entry.getValue(); return entry.getValue();
} }
} }
@@ -65,12 +65,12 @@ public class GamepadMapping implements Serializable {
/** /**
* Gets the mapping for the specified component.</br> * Gets the mapping for the specified component.</br>
* <b>NOTE: Iterates a hashmap, use sparingly</b> * <b>NOTE: Iterates a hashmap, use sparingly</b>
* @param contComp the component to get a mapping for * @param padComp the component to get a mapping for
* @return a mapping or an empty string if there is none * @return a mapping or an empty string if there is none
*/ */
public SourceComponent getMapping(GamepadComponent contComp) { public SourceComponent getMapping(GamepadComponent padComp) {
for (Entry<SourceComponent, Mapping> entry : mapping.entrySet()) { for (Entry<SourceComponent, Mapping> entry : mapping.entrySet()) {
if (entry.getValue().contComp == contComp) { if (entry.getValue().padComp == padComp) {
return entry.getKey(); return entry.getKey();
} }
} }
@@ -87,7 +87,7 @@ public class GamepadMapping implements Serializable {
/** /**
* The component this mapping belongs to * The component this mapping belongs to
*/ */
public GamepadComponent contComp; public GamepadComponent padComp;
/** /**
* Whether the value of this component should be inverted * Whether the value of this component should be inverted
@@ -101,12 +101,12 @@ public class GamepadMapping implements Serializable {
/** /**
* Constructs a new mapping with the specified configuration * Constructs a new mapping with the specified configuration
* @param contComp the component this mapping belongs to * @param padComp the component this mapping belongs to
* @param invert whether the value should be inverted * @param invert whether the value should be inverted
* @param trigger whether this component should be treated as a trigger * @param trigger whether this component should be treated as a trigger
*/ */
public Mapping(GamepadComponent contComp, boolean invert, boolean trigger) { public Mapping(GamepadComponent padComp, boolean invert, boolean trigger) {
this.contComp = contComp; this.padComp = padComp;
this.invert = invert; this.invert = invert;
this.trigger = trigger; this.trigger = trigger;
} }