Joystick should play nicely with oa+ca keys, also fixed smartport crash bug!
This commit is contained in:
parent
d7bfb5e197
commit
58e43c468d
|
@ -302,13 +302,17 @@ public class Keyboard implements Reconfigurable {
|
|||
e.consume();
|
||||
}
|
||||
|
||||
public static boolean isOpenApplePressed = false;
|
||||
@InvokableAction(name = "Open Apple Key", alternatives = "OA", category = "Keyboard", notifyOnRelease = true, defaultKeyMapping = "Alt", consumeKeyEvent = false)
|
||||
public void openApple(boolean pressed) {
|
||||
isOpenApplePressed = pressed;
|
||||
SoftSwitches.PB0.getSwitch().setState(pressed);
|
||||
}
|
||||
|
||||
public static boolean isClosedApplePressed = false;
|
||||
@InvokableAction(name = "Closed Apple Key", alternatives = "CA", category = "Keyboard", notifyOnRelease = true, defaultKeyMapping = {"Shortcut","Meta","Command"}, consumeKeyEvent = false)
|
||||
public void solidApple(boolean pressed) {
|
||||
isClosedApplePressed = pressed;
|
||||
SoftSwitches.PB1.getSwitch().setState(pressed);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import jace.config.DynamicSelection;
|
|||
import jace.config.InvokableAction;
|
||||
import jace.core.Computer;
|
||||
import jace.core.Device;
|
||||
import jace.core.Keyboard;
|
||||
import jace.core.RAMEvent;
|
||||
import jace.core.RAMListener;
|
||||
import jace.state.Stateful;
|
||||
|
@ -329,6 +330,7 @@ public class Joystick extends Device {
|
|||
String guid = GLFW.glfwGetJoystickGUID(controllerNumber);
|
||||
long end = System.currentTimeMillis();
|
||||
POLLING_TIME = (end - start) / CALIBRATION_ITERATIONS + 1;
|
||||
POLLING_TIME = Math.min(POLLING_TIME*2, 45);
|
||||
lastPollTime = end;
|
||||
System.out.println("Calibrated polling time to " + POLLING_TIME + "ms for joystick " + guid);
|
||||
}
|
||||
|
@ -362,8 +364,8 @@ public class Joystick extends Device {
|
|||
b0 = button0 >=0 && button0 < buttons.capacity() ? buttons.get(button0) : 0;
|
||||
b1 = button1 >=0 && button1 < buttons.capacity() ? buttons.get(button1) : 0;
|
||||
}
|
||||
SoftSwitches.PB0.getSwitch().setState(b0 != 0);
|
||||
SoftSwitches.PB1.getSwitch().setState(b1 != 0);
|
||||
SoftSwitches.PB0.getSwitch().setState(b0 != 0 || Keyboard.isOpenApplePressed);
|
||||
SoftSwitches.PB1.getSwitch().setState(b1 != 0 || Keyboard.isClosedApplePressed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,7 +383,6 @@ public class Joystick extends Device {
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
ticksSinceLastRead++;
|
||||
boolean finished = true;
|
||||
if (x > 0) {
|
||||
if (--x == 0) {
|
||||
|
@ -398,9 +399,8 @@ public class Joystick extends Device {
|
|||
}
|
||||
}
|
||||
if (selectedPhysicalController()) {
|
||||
if (finished && ticksSinceLastRead >= 1000000) {
|
||||
setRun(false);
|
||||
} else if (ticksSinceLastRead > 1000 && ticksSinceLastRead % 1000 == 0) {
|
||||
ticksSinceLastRead++;
|
||||
if (ticksSinceLastRead % 1000 == 0) {
|
||||
readButtons();
|
||||
}
|
||||
} else if (finished) {
|
||||
|
|
|
@ -58,9 +58,8 @@ public abstract class SmartportDriver {
|
|||
boolean extendedCall = command >= 0x040;
|
||||
// command &= 0x0f;
|
||||
// Modify stack so that RTS goes to the right place after the smartport device call
|
||||
//cpu.pushWord(callAddress + (extendedCall ? 5 : 3));
|
||||
// Kludge due to the CPU not getting the faked RTS opcode
|
||||
cpu.setProgramCounter(callAddress + (extendedCall ? 5 : 3));
|
||||
cpu.setProgramCounter(callAddress + (extendedCall ? 4 : 2));
|
||||
|
||||
// Calculate parameter address block
|
||||
int parmAddr;
|
||||
|
@ -73,15 +72,15 @@ public abstract class SmartportDriver {
|
|||
parmAddr = parmAddrHi << 16 | parmAddrLo;
|
||||
}
|
||||
// Now process command
|
||||
System.out.println("Received command " + command + " with address block " + Integer.toHexString(parmAddr));
|
||||
// System.out.println(String.format("Received %s command %d with address block %s", (extendedCall ? "extended" : "normal"), command, Integer.toHexString(parmAddr)));
|
||||
// byte numParms = ram.readRaw(parmAddr);
|
||||
int[] params = new int[16];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int value = 0x0ff & ram.readRaw(parmAddr + i);
|
||||
params[i] = value;
|
||||
System.out.print(Integer.toHexString(value) + " ");
|
||||
// System.out.print(Integer.toHexString(value) + " ");
|
||||
}
|
||||
System.out.println();
|
||||
// System.out.println();
|
||||
int unitNumber = params[1];
|
||||
if (!changeUnit(unitNumber)) {
|
||||
System.out.println("Invalid unit: "+unitNumber);
|
||||
|
@ -96,8 +95,8 @@ public abstract class SmartportDriver {
|
|||
case 1: //Read Block
|
||||
int blockNum = params[4] | (params[5] << 8) | (params[6] << 16);
|
||||
read(blockNum, dataBuffer);
|
||||
// System.out.println("reading "+blockNum+" to $"+Integer.toHexString(dataBuffer));
|
||||
return ERROR_CODE.NO_ERROR;
|
||||
// System.out.println("reading "+blockNum+" to $"+Integer.toHexString(dataBuffer));
|
||||
case 2: //Write Block
|
||||
blockNum = params[4] | (params[5] << 8) | (params[6] << 16);
|
||||
write(blockNum, dataBuffer);
|
||||
|
|
Loading…
Reference in New Issue