Skip to content

Commit

Permalink
Removed the joystick type of KeyboardType.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceewing committed Mar 9, 2024
1 parent f9ad3e9 commit 3676f76
Showing 1 changed file with 13 additions and 64 deletions.
77 changes: 13 additions & 64 deletions core/src/main/java/com/agifans/agile/ui/KeyboardType.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,6 @@ public enum KeyboardType {
-1,
-2
),
JOYSTICK(
new Integer[][][] {{
{ Keys.NUMPAD_7, Keys.NUMPAD_7, Keys.NUMPAD_7, Keys.NUMPAD_8, Keys.NUMPAD_8, Keys.NUMPAD_8, Keys.NUMPAD_9, Keys.NUMPAD_9, Keys.NUMPAD_9 },
{ Keys.NUMPAD_7, Keys.NUMPAD_7, Keys.NUMPAD_7, Keys.NUMPAD_8, Keys.NUMPAD_8, Keys.NUMPAD_8, Keys.NUMPAD_9, Keys.NUMPAD_9, Keys.NUMPAD_9 },
{ Keys.NUMPAD_7, Keys.NUMPAD_7, Keys.NUMPAD_7, Keys.NUMPAD_8, Keys.NUMPAD_8, Keys.NUMPAD_8, Keys.NUMPAD_9, Keys.NUMPAD_9, Keys.NUMPAD_9 },
{ Keys.NUMPAD_4, Keys.NUMPAD_4, Keys.NUMPAD_4, Keys.NUMPAD_7, Keys.NUMPAD_8, Keys.NUMPAD_9, Keys.NUMPAD_6, Keys.NUMPAD_6, Keys.NUMPAD_6 },
{ Keys.NUMPAD_4, Keys.NUMPAD_4, Keys.NUMPAD_4, Keys.NUMPAD_4, null, Keys.NUMPAD_6, Keys.NUMPAD_6, Keys.NUMPAD_6, Keys.NUMPAD_6 },
{ Keys.NUMPAD_4, Keys.NUMPAD_4, Keys.NUMPAD_4, Keys.NUMPAD_1, Keys.NUMPAD_2, Keys.NUMPAD_3, Keys.NUMPAD_6, Keys.NUMPAD_6, Keys.NUMPAD_6 },
{ Keys.NUMPAD_1, Keys.NUMPAD_1, Keys.NUMPAD_1, Keys.NUMPAD_2, Keys.NUMPAD_2, Keys.NUMPAD_2, Keys.NUMPAD_3, Keys.NUMPAD_3, Keys.NUMPAD_3 },
{ Keys.NUMPAD_1, Keys.NUMPAD_1, Keys.NUMPAD_1, Keys.NUMPAD_2, Keys.NUMPAD_2, Keys.NUMPAD_2, Keys.NUMPAD_3, Keys.NUMPAD_3, Keys.NUMPAD_3 },
{ Keys.NUMPAD_1, Keys.NUMPAD_1, Keys.NUMPAD_1, Keys.NUMPAD_2, Keys.NUMPAD_2, Keys.NUMPAD_2, Keys.NUMPAD_3, Keys.NUMPAD_3, Keys.NUMPAD_3 }
},
{
{ Keys.NUMPAD_0, Keys.NUMPAD_0, Keys.NUMPAD_0 },
{ Keys.NUMPAD_0, Keys.NUMPAD_0, Keys.NUMPAD_0 },
{ Keys.NUMPAD_0, Keys.NUMPAD_0, Keys.NUMPAD_0 },
{ Keys.NUMPAD_0, Keys.NUMPAD_0, Keys.NUMPAD_0 },
{ Keys.NUMPAD_0, Keys.NUMPAD_0, Keys.NUMPAD_0 },
{ Keys.NUMPAD_0, Keys.NUMPAD_0, Keys.NUMPAD_0 }
}},
new String[] {"png/joystick_arrows.png", "png/joystick_fire.png"},
1.0f,
0,
100,
0,
-1,
0
),
MOBILE_ON_SCREEN, OFF;

// Constants for the two sides of a keyboard..
Expand Down Expand Up @@ -215,41 +187,23 @@ public Integer getKeyCode(float x, float y, int side) {
Integer keyCode = null;
int keyRow = 0;

// If we're showing the mini version of the joystick, adjust the height here.
if (equals(JOYSTICK) && !ViewportManager.getInstance().isPortrait() && (side == LEFT)) {
// TODO: Make this a flag in the construction of a KeyboardType.
keyRow = (int) ((textures[side].getHeight() - (y * 2) + renderOffset) / vertKeySize);

} else {
keyRow = (int) ((textures[side].getHeight() - (y - yStart) + renderOffset) / vertKeySize);
}

keyRow = (int) ((textures[side].getHeight() - (y - yStart) + renderOffset) / vertKeySize);

if (keyRow >= keyMap[side].length)
if (keyRow >= keyMap[side].length) {
keyRow = keyMap[side].length - 1;
}

switch (this) {
case LANDSCAPE:
case PORTRAIT:
if (x >= xStart) {
keyCode = keyMap[side][keyRow][(int) ((x - xStart) / horizKeySize)];
}
break;

case JOYSTICK:
if (!ViewportManager.getInstance().isPortrait() && (side == LEFT)) {
x = x * 2;
}
if (side == RIGHT) {
x = x - (ViewportManager.getInstance().getWidth() - getTexture(RIGHT).getWidth());
}
int keyCol = (int) (x / vertKeySize);
if (keyCol < keyMap[side][keyRow].length) {
keyCode = keyMap[side][keyRow][keyCol];
}
break;

default:
break;
case LANDSCAPE:
case PORTRAIT:
if (x >= xStart) {
keyCode = keyMap[side][keyRow][(int) ((x - xStart) / horizKeySize)];
}
break;

default:
break;
}

return keyCode;
Expand Down Expand Up @@ -289,11 +243,6 @@ public boolean isInKeyboard(float x, float y, int side) {
int textureHeight = getTextures()[side].getHeight();
int textureWidth = getTextures()[side].getWidth();

if (this.equals(JOYSTICK) && !ViewportManager.getInstance().isPortrait() && (side == LEFT)) {
textureHeight = textureHeight / 2;
textureWidth = textureWidth / 2;
}

boolean isInYBounds = (y < (textureHeight + renderOffset) && (y > renderOffset));
if (numOfSides == 1) {
// In this case, we only need to test the Y position since the keyboard image
Expand Down

0 comments on commit 3676f76

Please sign in to comment.