Skip to content

Commit

Permalink
Fix x2
Browse files Browse the repository at this point in the history
  • Loading branch information
shinovon committed May 17, 2024
1 parent f1e6e37 commit f3f63b1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/emulator/ui/swt/EmulatorScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public final class EmulatorScreen implements
private int screenWidth;
private int screenHeight;
private boolean pointerState;
private boolean win;

public EmulatorScreen(final int n, final int n2) {
super();
Expand Down Expand Up @@ -269,7 +270,8 @@ public final void start(final boolean midletLoaded) {
this.shell.open();
this.shell.addDisposeListener(this);
this.shell.addControlListener(this);
if (Emulator.win) {
win = Emulator.win;
if (win) {
new Thread("KEmulator keyboard poll thread") {
boolean b;

Expand Down Expand Up @@ -319,7 +321,7 @@ public void run() {
private static Method win32OSGetKeyState;

public synchronized void pollKeyboard(Canvas canvas) {
if (!Emulator.win || canvas == null || canvas.isDisposed()) return;
if (!win || canvas == null || canvas.isDisposed()) return;
long now = System.currentTimeMillis();
Shell shell = canvas.getShell();
if (shell == this.shell) {
Expand All @@ -334,8 +336,11 @@ public synchronized void pollKeyboard(Canvas canvas) {
if (win32OS == null)
win32OS = Class.forName("org.eclipse.swt.internal.win32.OS");
if (win32OSGetKeyState == null &&
(win32OSGetKeyState = ReflectUtil.getMethod(win32OS, "GetAsyncKeyState", int.class)) == null)
return;
(win32OSGetKeyState = ReflectUtil.getMethod(win32OS, "GetAsyncKeyState", int.class)) == null) {
// TODO jna
win = false;
return;
}
for (int i = 0; i < keyboardButtonStates.length; i++) {
lastKeyboardButtonStates[i] = keyboardButtonStates[i];
short keyState = (Short) win32OSGetKeyState.invoke(null, i);
Expand Down Expand Up @@ -1612,7 +1617,7 @@ public final void keyPressed(final KeyEvent keyEvent) {
}

public final void keyReleased(final KeyEvent keyEvent) {
if (!Settings.canvasKeyboard && Emulator.win) {
if (!Settings.canvasKeyboard && win) {
return;
}
int n = keyEvent.keyCode & 0xFEFFFFFF;
Expand Down Expand Up @@ -1662,7 +1667,7 @@ protected final void handleKeyRelease(int n) {
}
n = Integer.parseInt(r);
synchronized (pressedKeys) {
if (Emulator.win && !pressedKeys.contains(n)) {
if (win && !pressedKeys.contains(n)) {
return;
}
pressedKeys.removeElement(n);
Expand Down

0 comments on commit f3f63b1

Please sign in to comment.