Took care of the bigger issue with joystick emulation breaking (still testing to see if the emulator starts with it correctly)

This commit is contained in:
Brendan Robert 2015-08-13 00:45:29 -05:00
parent c098d6345b
commit 8a1844fb90

View File

@ -91,8 +91,8 @@ public class Joystick extends Device {
private void readJoystick() { private void readJoystick() {
if (useKeyboard) { if (useKeyboard) {
joyX = leftPressed ? (rightPressed ? 128 : 0) : (rightPressed ? 255 : 128); joyX = (leftPressed ? -128 : 0) + (rightPressed ? 255:128);
joyY = upPressed ? (downPressed ? 128 : 0) : (downPressed ? 255 : 128); joyY = (upPressed ? -128 : 0) + (downPressed ? 255:128);
} else { } else {
Point l = MouseInfo.getPointerInfo().getLocation(); Point l = MouseInfo.getPointerInfo().getLocation();
if (l.x < lastMouseLocation.x) { if (l.x < lastMouseLocation.x) {
@ -209,6 +209,7 @@ public class Joystick extends Device {
@InvokableAction(name = "Left", category = "joystick", defaultKeyMapping = "left", notifyOnRelease = true) @InvokableAction(name = "Left", category = "joystick", defaultKeyMapping = "left", notifyOnRelease = true)
public boolean joystickLeft(boolean pressed) { public boolean joystickLeft(boolean pressed) {
if (!useKeyboard) return false;
leftPressed = pressed; leftPressed = pressed;
if (pressed) { if (pressed) {
rightPressed = false; rightPressed = false;
@ -219,6 +220,7 @@ public class Joystick extends Device {
; ;
@InvokableAction(name = "Right", category = "joystick", defaultKeyMapping = "right", notifyOnRelease = true) @InvokableAction(name = "Right", category = "joystick", defaultKeyMapping = "right", notifyOnRelease = true)
public boolean joystickRight(boolean pressed) { public boolean joystickRight(boolean pressed) {
if (!useKeyboard) return false;
rightPressed = pressed; rightPressed = pressed;
if (pressed) { if (pressed) {
leftPressed = false; leftPressed = false;
@ -229,6 +231,7 @@ public class Joystick extends Device {
; ;
@InvokableAction(name = "Up", category = "joystick", defaultKeyMapping = "up", notifyOnRelease = true) @InvokableAction(name = "Up", category = "joystick", defaultKeyMapping = "up", notifyOnRelease = true)
public boolean joystickUp(boolean pressed) { public boolean joystickUp(boolean pressed) {
if (!useKeyboard) return false;
upPressed = pressed; upPressed = pressed;
if (pressed) { if (pressed) {
downPressed = false; downPressed = false;
@ -239,6 +242,7 @@ public class Joystick extends Device {
; ;
@InvokableAction(name = "Down", category = "joystick", defaultKeyMapping = "down", notifyOnRelease = true) @InvokableAction(name = "Down", category = "joystick", defaultKeyMapping = "down", notifyOnRelease = true)
public boolean joystickDown(boolean pressed) { public boolean joystickDown(boolean pressed) {
if (!useKeyboard) return false;
downPressed = pressed; downPressed = pressed;
if (pressed) { if (pressed) {
upPressed = false; upPressed = false;
@ -252,6 +256,6 @@ public class Joystick extends Device {
private void removeListeners() { private void removeListeners() {
computer.getMemory().removeListener(listener); computer.getMemory().removeListener(listener);
Keyboard.unregisterAllHandlers(this); // Keyboard.unregisterAllHandlers(this);
} }
} }