Skip to content

Commit

Permalink
Renamed XBox/PlayStation specific buttons to clarify the difference b…
Browse files Browse the repository at this point in the history
…etwen 'cross' and 'x'
  • Loading branch information
kevinfrei committed Sep 16, 2023
1 parent 78f09db commit 5c6a624
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public class GamepadBase<T extends ButtonBase, U extends AxisBase> implements Pe
/**
* The button objects for the XBox game controller
*/
public T a, b, x, y, start, back;
public T xbox_a, xbox_b, xbox_x, xbox_y, xbox_start, xbox_back;
/**
* The button objects for the PS4 game controller
*/
public T cross, circle, square, triangle, share, options;
public T ps_cross, ps_circle, ps_square, ps_triangle, ps_share, ps_options;
/**
* The button objects for both the XBox and PS4 controllers
*/
Expand Down Expand Up @@ -73,12 +73,12 @@ public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
dpad = new GamepadDpad<>(dpadUp, dpadDown, dpadLeft, dpadRight);
periodics =
new Periodic[] {
a,
b,
x,
y,
start,
back,
xbox_a,
xbox_b,
xbox_x,
xbox_y,
xbox_start,
xbox_back,
leftBumper,
rightBumper,
leftTrigger,
Expand All @@ -89,12 +89,12 @@ public GamepadBase(Gamepad g, Class<T> bClass, Class<U> aClass) {
};
enablables =
new Enablable[] {
a,
b,
x,
y,
start,
back,
xbox_a,
xbox_b,
xbox_x,
xbox_y,
xbox_start,
xbox_back,
leftBumper,
rightBumper,
leftTrigger,
Expand All @@ -110,19 +110,19 @@ private void setComponents(Gamepad g)
throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
// buttons
// a=new T();
a = buttonInstance(() -> g.a);
b = buttonInstance(() -> g.b);
x = buttonInstance(() -> g.x);
y = buttonInstance(() -> g.y);
cross = a;
circle = b;
square = x;
triangle = y;

start = buttonInstance(() -> g.start);
back = buttonInstance(() -> g.back);
share = back;
options = start;
xbox_a = buttonInstance(() -> g.a);
xbox_b = buttonInstance(() -> g.b);
xbox_x = buttonInstance(() -> g.x);
xbox_y = buttonInstance(() -> g.y);
ps_cross = xbox_a;
ps_circle = xbox_b;
ps_square = xbox_x;
ps_triangle = xbox_y;

xbox_start = buttonInstance(() -> g.start);
xbox_back = buttonInstance(() -> g.back);
ps_share = xbox_back;
ps_options = xbox_start;

// bumpers
leftBumper = buttonInstance(() -> g.left_bumper);
Expand Down Expand Up @@ -158,51 +158,51 @@ public enum Button {
/**
* XBox A button
*/
A,
XBOX_A,
/**
* XBox B button
*/
B,
XBOX_B,
/**
* XBox X button
*/
X,
XBOX_X,
/**
* XBox Y button
*/
Y,
XBOX_Y,
/**
* PS4 Cross (X) button
*/
CROSS,
PS_CROSS,
/**
* PS4 Circle (O) button
*/
CIRCLE,
PS_CIRCLE,
/**
* PS4 Square button
*/
SQUARE,
PS_SQUARE,
/**
* PS4 Triangle button
*/
TRIANGLE,
PS_TRIANGLE,
/**
* PS4 Share button
*/
SHARE,
PS_SHARE,
/**
* PS4 Options button
*/
OPTIONS,
PS_OPTIONS,
/**
* PS4/XBox Start button
* XBox Start button
*/
START,
XBOX_START,
/**
* PS4/XBox Back button
* XBox Back button
*/
BACK,
XBOX_BACK,
/**
* Left bumper button
*/
Expand Down Expand Up @@ -259,30 +259,30 @@ public enum Axis {
*/
public T getButton(Button bu) {
switch (bu) {
case A:
return a;
case B:
return b;
case X:
return x;
case Y:
return y;
case CROSS:
return cross;
case CIRCLE:
return circle;
case SQUARE:
return square;
case TRIANGLE:
return triangle;
case SHARE:
return share;
case OPTIONS:
return options;
case BACK:
return back;
case START:
return start;
case XBOX_A:
return xbox_a;
case XBOX_B:
return xbox_b;
case XBOX_X:
return xbox_x;
case XBOX_Y:
return xbox_y;
case PS_CROSS:
return ps_cross;
case PS_CIRCLE:
return ps_circle;
case PS_SQUARE:
return ps_square;
case PS_TRIANGLE:
return ps_triangle;
case PS_SHARE:
return ps_share;
case PS_OPTIONS:
return ps_options;
case XBOX_BACK:
return xbox_back;
case XBOX_START:
return xbox_start;
case LEFT_BUMPER:
return leftBumper;
case RIGHT_BUMPER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void setup() {

@Test
public void buttonTest() {
CommandButton commandButton = commandGamepad.a;
CommandButton commandButton = commandGamepad.xbox_a;
gamepad.a = false;
commandButton.periodic();
gamepad.a = true;
Expand Down

0 comments on commit 5c6a624

Please sign in to comment.