Removed deprecated method and renamed some classes. Created a new package to separate gamepad classes from keyboard/mouse classes

This commit is contained in:
Diego Waxemberg
2013-12-27 10:08:31 -05:00
parent bc79e1ee06
commit 2c3ed99a3a
9 changed files with 41 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
package com.limelight.input;
package com.limelight.input.gamepad;
import com.limelight.input.GamepadMapping.Mapping;
import com.limelight.input.gamepad.GamepadMapping.Mapping;
import com.limelight.nvstream.NvConnection;
import com.limelight.nvstream.input.ControllerPacket;
@@ -134,7 +134,7 @@ public class Gamepad {
}
}
private void handleAnalog(ControllerComponent contComp, float value) {
private void handleAnalog(GamepadComponent contComp, float value) {
switch (contComp) {
case LS_X:
leftStickX = (short)Math.round(value * 0x7FFF);
@@ -160,7 +160,7 @@ public class Gamepad {
}
}
private void handleButtons(ControllerComponent contComp, float value) {
private void handleButtons(GamepadComponent contComp, float value) {
boolean press = false;
if (value > 0.5F) {

View File

@@ -1,10 +1,10 @@
package com.limelight.input;
package com.limelight.input.gamepad;
import java.io.Serializable;
import javax.swing.JLabel;
public enum ControllerComponent implements Serializable {
public enum GamepadComponent implements Serializable {
BTN_A("Button 1 (A)", false), BTN_X("Button 2 (X)", false), BTN_Y("Button 3 (Y)", false), BTN_B("Button 4 (B)", false),
DPAD_UP("D-pad Up", false), DPAD_DOWN("D-pad Down", false), DPAD_LEFT("D-pad Left", false), DPAD_RIGHT("D-pad Right", false),
LS_X("Left Stick X", true), LS_Y("Left Stick Y", true), RS_X("Right Stick X", true), RS_Y("Right Stick Y", true),
@@ -15,7 +15,7 @@ public enum ControllerComponent implements Serializable {
private JLabel label;
private boolean analog;
private ControllerComponent(String name, boolean analog) {
private GamepadComponent(String name, boolean analog) {
this.label = new JLabel(name);
this.analog = analog;
}
@@ -27,9 +27,4 @@ public enum ControllerComponent implements Serializable {
public boolean isAnalog() {
return analog;
}
@Deprecated
public boolean sameAs(ControllerComponent other) {
return this.name().equals(other.name());
}
}

View File

@@ -1,4 +1,4 @@
package com.limelight.input;
package com.limelight.input.gamepad;
import java.util.Collections;

View File

@@ -1,4 +1,4 @@
package com.limelight.input;
package com.limelight.input.gamepad;
import java.lang.reflect.Constructor;
import java.util.LinkedList;
@@ -8,7 +8,7 @@ import com.limelight.nvstream.NvConnection;
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;
public class ControllerListener {
public class GamepadListener {
private static Thread listenerThread;
private static NvConnection conn;

View File

@@ -1,9 +1,10 @@
package com.limelight.input;
package com.limelight.input.gamepad;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map.Entry;
import net.java.games.input.Component;
public class GamepadMapping implements Serializable {
@@ -32,10 +33,10 @@ public class GamepadMapping implements Serializable {
* @param contComp the component to get a mapping for
* @return a mapping or an null if there is none
*/
public Mapping get(ControllerComponent contComp) {
public Mapping get(GamepadComponent contComp) {
//#allTheJank
for (Entry<String, Mapping> entry : mapping.entrySet()) {
if (entry.getValue().contComp.sameAs(contComp)) {
if (entry.getValue().contComp == contComp) {
return entry.getValue();
}
}
@@ -47,9 +48,9 @@ public class GamepadMapping implements Serializable {
* @param contComp the component to get a mapping for
* @return a mapping or an empty string if there is none
*/
public String getMapping(ControllerComponent contComp) {
public String getMapping(GamepadComponent contComp) {
for (Entry<String, Mapping> entry : mapping.entrySet()) {
if (entry.getValue().contComp.sameAs(contComp)) {
if (entry.getValue().contComp == contComp) {
return entry.getKey();
}
}
@@ -59,11 +60,11 @@ public class GamepadMapping implements Serializable {
public class Mapping implements Serializable {
private static final long serialVersionUID = -8407172977953214242L;
public ControllerComponent contComp;
public GamepadComponent contComp;
public boolean invert;
public boolean trigger;
public Mapping(ControllerComponent contComp, boolean invert, boolean trigger) {
public Mapping(GamepadComponent contComp, boolean invert, boolean trigger) {
this.contComp = contComp;
this.invert = invert;
this.trigger = trigger;