diff --git a/core/.classpath b/core/.classpath
index 4328dab5..e7a46736 100644
--- a/core/.classpath
+++ b/core/.classpath
@@ -18,8 +18,9 @@
-
+
+
diff --git a/core/src/main/java/it/cavallium/warppi/Engine.java b/core/src/main/java/it/cavallium/warppi/Engine.java
deleted file mode 100644
index 5f86a812..00000000
--- a/core/src/main/java/it/cavallium/warppi/Engine.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package it.cavallium.warppi;
-
-import java.io.IOException;
-
-import it.cavallium.warppi.Platform.ConsoleUtils;
-import it.cavallium.warppi.boot.StartupArguments;
-import it.cavallium.warppi.device.HardwareDevice;
-import it.cavallium.warppi.device.HardwareTouchDevice;
-import it.cavallium.warppi.device.InputManager;
-import it.cavallium.warppi.device.Keyboard;
-import it.cavallium.warppi.gui.DisplayManager;
-import it.cavallium.warppi.gui.HUD;
-import it.cavallium.warppi.gui.HardwareDisplay;
-import it.cavallium.warppi.gui.screens.Screen;
-import it.cavallium.warppi.util.ClassUtils;
-import it.cavallium.warppi.util.EventSubmitter;
-
-public class Engine {
- public static final Engine INSTANCE = new Engine();
- private static Platform platform;
- private static boolean running = false;
- private static EventSubmitter loadPhase = new EventSubmitter<>();
- private final EventSubmitter loaded = new EventSubmitter<>(false);
- private HardwareDevice hardwareDevice;
-
- private Engine() {}
-
- /**
- * Start an instance of the calculator.
- *
- * @param platform
- * Platform implementation
- * @param screen
- * Default screen to show at startup
- * @param disp
- * Hardware display
- * @param hud
- * Head-up display
- * @param args
- * Startup arguments
- * @throws InterruptedException
- * @throws IOException
- */
- public static void start(final Platform platform, final Screen screen, final HardwareDisplay disp,
- final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
- throws InterruptedException, IOException {
- if (Engine.running) {
- throw new RuntimeException("Already running!");
- } else {
- Engine.running = true;
- Engine.INSTANCE.startInstance(platform, screen, disp, touchdevice, hud, args);
- }
- }
-
- private void startInstance(final Platform platform, final Screen screen, final HardwareDisplay disp,
- final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
- throws InterruptedException, IOException {
- Engine.platform = platform;
- platform.getConsoleUtils().out().println("WarpPI Calculator");
- initializeEnvironment(args);
-
- final Thread currentThread = Thread.currentThread();
- currentThread.setPriority(Thread.MAX_PRIORITY);
- Engine.getPlatform().setThreadName(currentThread, "Main thread");
-
- final DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
- final Keyboard k = new Keyboard();
- final InputManager im = new InputManager(k, touchdevice);
- hardwareDevice = new HardwareDevice(dm, im);
-
- hardwareDevice.setup(() -> Engine.loadPhase.submit(new LoadingStatus()));
- }
-
- private void onShutdown() {
- Engine.platform.getConsoleUtils().out().println(1, "Shutdown...");
- beforeShutdown();
- Engine.platform.getConsoleUtils().out().println(1, "");
- Engine.platform.getConsoleUtils().out().println(1, "Closed.");
- Engine.getPlatform().exit(0);
- }
-
- private void initializeEnvironment(final StartupArguments args) throws IOException {
- ClassUtils.classLoader = this.getClass();
- StaticVars.startupArguments = args;
- StaticVars.debugWindow2x = args.isZoomed();
- if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) {
- StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
- }
- Engine.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args);
- checkDeviceType();
- if (args.isRaspberryModeAllowed() == false) {
- Engine.getPlatform().setRunningOnRaspberry(false);
- }
- if (Engine.getPlatform().isRunningOnRaspberry()) {
- Engine.getPlatform().getGpio().wiringPiSetupPhys();
- Engine.getPlatform().getGpio().pinMode(12, Engine.getPlatform().getGpio().valuePwmOutput());
- } else {
- StaticVars.screenPos = new int[] { 0, 0 };
- if (Engine.getPlatform().isJavascript() == false) {
- Engine.getPlatform().getSettings().setDebugEnabled(true);
- }
- }
- }
-
- private void checkDeviceType() {
- // TODO Auto-generated method stub
-
- }
-
- public void beforeShutdown() {
- Keyboard.stopKeyboard();
- }
-
- public EventSubmitter isLoaded() {
- return loaded;
- }
-
- public EventSubmitter getLoadPhase() {
- return Engine.loadPhase;
- }
-
- public HardwareDevice getHardwareDevice() {
- return hardwareDevice;
- }
-
- public static Platform getPlatform() {
- return Engine.platform;
- }
-
- public static class LoadingStatus {
- protected LoadingStatus() {
-
- }
-
- public void done() {
- Engine.INSTANCE.loaded.submit(true);
- Engine.INSTANCE.hardwareDevice.getDisplayManager().waitForExit();
- Engine.INSTANCE.onShutdown();
- }
-
- public void failed() {
- Engine.INSTANCE.onShutdown();
- }
- }
-}
diff --git a/core/src/main/java/it/cavallium/warppi/Platform.java b/core/src/main/java/it/cavallium/warppi/Platform.java
index 2c9083c3..c63da56e 100644
--- a/core/src/main/java/it/cavallium/warppi/Platform.java
+++ b/core/src/main/java/it/cavallium/warppi/Platform.java
@@ -9,7 +9,12 @@ import java.net.URL;
import java.util.List;
import java.util.Map;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.boot.StartupArguments;
+import it.cavallium.warppi.device.DeviceStateDevice;
+import it.cavallium.warppi.device.display.BacklightOutputDevice;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.KeyboardInputDevice;
+import it.cavallium.warppi.device.input.TouchInputDevice;
import it.cavallium.warppi.util.Error;
public interface Platform {
@@ -52,10 +57,16 @@ public interface Platform {
URLClassLoader newURLClassLoader(URL[] urls);
- Map getEnginesList();
+ TouchInputDevice getTouchInputDevice();
+
+ KeyboardInputDevice getKeyboardInputDevice();
+
+ DisplayOutputDevice getDisplayOutputDevice();
- GraphicEngine getEngine(String string) throws NullPointerException;
+ BacklightOutputDevice getBacklightOutputDevice();
+ DeviceStateDevice getDeviceStateDevice();
+
void throwNewExceptionInInitializerError(String text);
String[] stacktraceToString(Error e);
@@ -99,7 +110,7 @@ public interface Platform {
Object getBoardType();
}
-
+
public interface ConsoleUtils {
int OUTPUTLEVEL_NODEBUG = 0;
int OUTPUTLEVEL_DEBUG_MIN = 1;
@@ -206,4 +217,6 @@ public interface Platform {
}
+ void setArguments(StartupArguments args);
+
}
diff --git a/core/src/main/java/it/cavallium/warppi/StaticVars.java b/core/src/main/java/it/cavallium/warppi/StaticVars.java
index 4295b11d..6a06ef5c 100644
--- a/core/src/main/java/it/cavallium/warppi/StaticVars.java
+++ b/core/src/main/java/it/cavallium/warppi/StaticVars.java
@@ -10,8 +10,6 @@ import it.cavallium.warppi.util.EventSubmitter;
*/
public class StaticVars {
public static final boolean zoomed = true;
- public static int[] screenPos = new int[] { 0, 0 };
- public static final int[] screenSize = new int[] { 480, 320 };
public static int outputLevel = 0;
public static boolean debugWindow2x = false;
public static EventSubmitter windowZoom = new EventSubmitter<>(2F);
diff --git a/core/src/main/java/it/cavallium/warppi/WarpPI.java b/core/src/main/java/it/cavallium/warppi/WarpPI.java
new file mode 100644
index 00000000..64fa1b98
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/WarpPI.java
@@ -0,0 +1,156 @@
+package it.cavallium.warppi;
+
+import java.io.IOException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import it.cavallium.warppi.Platform.ConsoleUtils;
+import it.cavallium.warppi.boot.StartupArguments;
+import it.cavallium.warppi.device.Device;
+import it.cavallium.warppi.device.DeviceStateDevice;
+import it.cavallium.warppi.device.display.BacklightOutputDevice;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.InputManager;
+import it.cavallium.warppi.device.input.Keyboard;
+import it.cavallium.warppi.device.input.KeyboardInputDevice;
+import it.cavallium.warppi.device.input.TouchInputDevice;
+import it.cavallium.warppi.flow.BehaviorSubject;
+import it.cavallium.warppi.flow.Observable;
+import it.cavallium.warppi.gui.DisplayManager;
+import it.cavallium.warppi.gui.HUD;
+import it.cavallium.warppi.gui.screens.Screen;
+import it.cavallium.warppi.util.ClassUtils;
+import it.cavallium.warppi.util.RunnableWithException;
+
+public class WarpPI {
+ public static final WarpPI INSTANCE = new WarpPI();
+ private static Platform platform;
+ private static boolean running = false;
+ private final BehaviorSubject loaded = BehaviorSubject.create(false);
+ private Device device;
+
+ private WarpPI() {}
+
+ /**
+ * Start an instance of the calculator.
+ *
+ * @param platform
+ * Platform implementation
+ * @param screen
+ * Default screen to show at startup
+ * @param hud
+ * Head-up display
+ * @param args
+ * Startup arguments
+ * @throws InterruptedException
+ * @throws IOException
+ */
+ public static Future start(final Platform platform, final Screen screen, final HUD hud, final StartupArguments args, final RunnableWithException onLoading) throws IOException {
+ if (WarpPI.running) {
+ throw new RuntimeException("Already running!");
+ } else {
+ WarpPI.running = true;
+ return WarpPI.INSTANCE.startInstance(platform, screen, hud, args, onLoading);
+ }
+ }
+
+ private Future startInstance(final Platform platform, final Screen screen,
+ final HUD hud, final StartupArguments args, final RunnableWithException onLoading)
+ throws IOException {
+ WarpPI.platform = platform;
+ // Set arguments on platform before everything else
+ platform.setArguments(args);
+
+ platform.getConsoleUtils().out().println("WarpPI Calculator");
+ initializeEnvironment(args);
+
+ final Thread currentThread = Thread.currentThread();
+ currentThread.setPriority(Thread.MAX_PRIORITY);
+ WarpPI.getPlatform().setThreadName(currentThread, "Main thread");
+
+ return CompletableFuture.runAsync(() -> {
+ try {
+ final DisplayOutputDevice display = platform.getDisplayOutputDevice();
+ final BacklightOutputDevice backlight = platform.getBacklightOutputDevice();
+ final DisplayManager dm = new DisplayManager(display, backlight, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
+ final KeyboardInputDevice keyboard = platform.getKeyboardInputDevice();
+ final TouchInputDevice touchscreen = platform.getTouchInputDevice();
+ final DeviceStateDevice deviceState = platform.getDeviceStateDevice();
+ final InputManager im = new InputManager(keyboard, touchscreen);
+ device = new Device(dm, im, deviceState);
+ device.setup();
+ onLoading.run();
+ this.loadingCompleted();
+ } catch (Exception ex) {
+ this.loadingFailed(ex);
+ }
+ }).thenRun(this::onShutdown);
+ }
+
+ private void onShutdown() {
+ WarpPI.platform.getConsoleUtils().out().println(1, "Shutdown...");
+ beforeShutdown();
+ WarpPI.platform.getConsoleUtils().out().println(1, "");
+ WarpPI.platform.getConsoleUtils().out().println(1, "Closed.");
+ WarpPI.getPlatform().exit(0);
+ }
+
+ private void initializeEnvironment(final StartupArguments args) throws IOException {
+ ClassUtils.classLoader = this.getClass();
+ StaticVars.startupArguments = args;
+ StaticVars.debugWindow2x = args.isZoomed();
+ if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) {
+ StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
+ }
+ WarpPI.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args);
+ checkDeviceType();
+ if (args.isRaspberryModeAllowed() == false) {
+ WarpPI.getPlatform().setRunningOnRaspberry(false);
+ }
+ if (WarpPI.getPlatform().isRunningOnRaspberry()) {
+ WarpPI.getPlatform().getGpio().wiringPiSetupPhys();
+ WarpPI.getPlatform().getGpio().pinMode(12, WarpPI.getPlatform().getGpio().valuePwmOutput());
+ } else {
+ if (WarpPI.getPlatform().isJavascript() == false) {
+ WarpPI.getPlatform().getSettings().setDebugEnabled(true);
+ }
+ }
+ }
+
+ private void checkDeviceType() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeShutdown() {
+ Keyboard.stopKeyboard();
+ }
+
+ public Observable isLoaded() {
+ return loaded;
+ }
+
+ public Device getHardwareDevice() {
+ return device;
+ }
+
+ public static Platform getPlatform() {
+ return WarpPI.platform;
+ }
+
+
+ private void loadingCompleted() {
+ try {
+ WarpPI.INSTANCE.loaded.onNext(true);
+ WarpPI.INSTANCE.device.getDeviceStateDevice().waitForExit().get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new CompletionException(e);
+ }
+ }
+
+ private void loadingFailed(Exception e) {
+ e.printStackTrace();
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/boot/Boot.java b/core/src/main/java/it/cavallium/warppi/boot/Boot.java
index be4a9ea3..197a413e 100644
--- a/core/src/main/java/it/cavallium/warppi/boot/Boot.java
+++ b/core/src/main/java/it/cavallium/warppi/boot/Boot.java
@@ -1,81 +1,78 @@
-package it.cavallium.warppi.boot;
-
-import java.util.Arrays;
-
-import it.cavallium.warppi.Engine;
-import it.cavallium.warppi.Engine.LoadingStatus;
+package it.cavallium.warppi.boot;
+
+import java.util.Arrays;
+import java.util.concurrent.Future;
+
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform;
-import it.cavallium.warppi.device.PIHardwareDisplay;
-import it.cavallium.warppi.device.PIHardwareTouchDevice;
-import it.cavallium.warppi.gui.CalculatorHUD;
-import it.cavallium.warppi.gui.screens.LoadingScreen;
-import it.cavallium.warppi.math.rules.RulesManager;
-import it.cavallium.warppi.util.Error;
-
-public class Boot {
-
- public static void boot(final Platform platform, final String[] args) throws Exception {
- Engine.start(platform, new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), Boot.parseStartupArguments(args));
- Engine.INSTANCE.getLoadPhase().subscribe(Boot::loadCalculator);
- }
-
- private static void loadCalculator(final LoadingStatus loading) {
- try {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setBrightness(0.2f);
- RulesManager.initialize();
- RulesManager.warmUp();
- loading.done();
- } catch (InterruptedException | Error e) {
- e.printStackTrace();
- }
- loading.failed();
- }
-
- public static StartupArguments parseStartupArguments(final String[] a) {
- final StartupArgumentsImpl args = new StartupArgumentsImpl();
- Arrays.asList(a).stream().parallel().filter((x) -> x != null).map(String::toLowerCase).forEach(arg -> Boot.parseArgument(args, arg));
- return args;
- }
-
- public static void parseArgument(final StartupArgumentsImpl args, final String arg) {
- switch (arg) {
- case "-zoomed":
- args.setZoomed(true);
- break;
- case "-verbose":
- args.setVerboseLoggingEnabled(true);
- break;
- case "-noraspi":
- args.setRaspberryModeAllowed(false);
- break;
- case "nogui":
- args.setNoGUIEngineForced(true);
- break;
- case "ms-dos":
- args.setMSDOSModeEnabled(true);
- break;
- case "html":
- args.setHTMLEngineForced(true);
- break;
- case "gpu":
- args.setGPUEngineForced(true);
- break;
- case "cpu":
- args.setCPUEngineForced(true);
- break;
- case "framebuffer":
- args.setFrameBufferEngineForced(true);
- break;
- case "-debug":
- args.setDebugEnabled(true);
- break;
- case "-uncached":
- args.setUncached(true);
- break;
- default:
- // Not using ConsoleUtils because it isn't initialized at this point.
- System.out.println("Unrecognized argument " + arg);
- break;
- }
- }
-}
+import it.cavallium.warppi.gui.CalculatorHUD;
+import it.cavallium.warppi.gui.screens.LoadingScreen;
+import it.cavallium.warppi.math.rules.RulesManager;
+
+public class Boot {
+
+ public static void boot(final Platform platform, final String[] args) throws Exception {
+ Future execution = WarpPI.start(
+ platform,
+ new LoadingScreen(),
+ new CalculatorHUD(),
+ Boot.parseStartupArguments(args),
+ Boot::loadCalculator);
+ execution.get();
+ }
+
+ private static void loadCalculator() throws Exception {
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setBrightness(0.2f);
+ //TODO: plugins system: PluginsManager.initialize();
+ RulesManager.initialize();
+ RulesManager.warmUp();
+ }
+
+ public static StartupArguments parseStartupArguments(final String[] a) {
+ final StartupArgumentsImpl args = new StartupArgumentsImpl();
+ Arrays.asList(a).stream().parallel().filter((x) -> x != null).map(String::toLowerCase).forEach(arg -> Boot.parseArgument(args, arg));
+ return args;
+ }
+
+ public static void parseArgument(final StartupArgumentsImpl args, final String arg) {
+ switch (arg) {
+ case "-zoomed":
+ args.setZoomed(true);
+ break;
+ case "-verbose":
+ args.setVerboseLoggingEnabled(true);
+ break;
+ case "-noraspi":
+ args.setRaspberryModeAllowed(false);
+ break;
+ case "nogui":
+ args.setNoGUIEngineForced(true);
+ break;
+ case "ms-dos":
+ args.setMSDOSModeEnabled(true);
+ break;
+ case "html":
+ args.setHTMLEngineForced(true);
+ break;
+ case "gpu":
+ args.setGPUEngineForced(true);
+ break;
+ case "cpu":
+ args.setCPUEngineForced(true);
+ break;
+ case "framebuffer":
+ args.setFrameBufferEngineForced(true);
+ break;
+ case "-debug":
+ args.setDebugEnabled(true);
+ break;
+ case "-uncached":
+ args.setUncached(true);
+ break;
+ default:
+ // Not using ConsoleUtils because it isn't initialized at this point.
+ System.out.println("Unrecognized argument " + arg);
+ break;
+ }
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/CacheFile.java b/core/src/main/java/it/cavallium/warppi/device/CacheFile.java
index 48a5eb29..6e45a5d3 100644
--- a/core/src/main/java/it/cavallium/warppi/device/CacheFile.java
+++ b/core/src/main/java/it/cavallium/warppi/device/CacheFile.java
@@ -8,7 +8,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.UUID;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
public class CacheFile {
private String path;
@@ -22,7 +22,7 @@ public class CacheFile {
path = UUID.randomUUID().toString() + ".ser";
} while (new File(path).exists());
try {
- File.createTempFile(Engine.getPlatform().getSettings().getCalculatorNameLowercase(), "");
+ File.createTempFile(WarpPI.getPlatform().getSettings().getCalculatorNameLowercase(), "");
} catch (final IOException e) {
e.printStackTrace();
}
diff --git a/core/src/main/java/it/cavallium/warppi/device/Device.java b/core/src/main/java/it/cavallium/warppi/device/Device.java
new file mode 100644
index 00000000..2ea1083b
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/Device.java
@@ -0,0 +1,38 @@
+package it.cavallium.warppi.device;
+
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.input.InputManager;
+import it.cavallium.warppi.gui.DisplayManager;
+
+public class Device {
+ private final DisplayManager displayManager;
+ private final InputManager inputManager;
+ private final DeviceStateDevice deviceState;
+
+ public Device(final DisplayManager m, final InputManager im, final DeviceStateDevice dm) {
+ displayManager = m;
+ inputManager = im;
+ deviceState = dm;
+ }
+
+ public DisplayManager getDisplayManager() {
+ return displayManager;
+ }
+
+ public InputManager getInputManager() {
+ return inputManager;
+ }
+
+ public DeviceStateDevice getDeviceStateDevice() {
+ return deviceState;
+ }
+
+ public void setup() {
+ displayManager.initialize();
+ inputManager.initialize();
+ deviceState.initialize();
+
+ inputManager.getTouchDevice().listenTouchEvents(displayManager.getTouchEventListener());
+ }
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/DeviceStateDevice.java b/core/src/main/java/it/cavallium/warppi/device/DeviceStateDevice.java
new file mode 100644
index 00000000..90dc4a6a
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/DeviceStateDevice.java
@@ -0,0 +1,12 @@
+package it.cavallium.warppi.device;
+
+import java.util.concurrent.Future;
+
+public interface DeviceStateDevice {
+
+ void initialize();
+
+ Future> waitForExit();
+
+ void powerOff();
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/HardwareDevice.java b/core/src/main/java/it/cavallium/warppi/device/HardwareDevice.java
deleted file mode 100644
index 402060d8..00000000
--- a/core/src/main/java/it/cavallium/warppi/device/HardwareDevice.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package it.cavallium.warppi.device;
-
-import it.cavallium.warppi.Engine;
-import it.cavallium.warppi.gui.DisplayManager;
-
-public class HardwareDevice {
- private final DisplayManager displayManager;
- private final InputManager inputManager;
-
- public HardwareDevice(final DisplayManager m, final InputManager im) {
- displayManager = m;
- inputManager = im;
- }
-
- public DisplayManager getDisplayManager() {
- return displayManager;
- }
-
- public InputManager getInputManager() {
- return inputManager;
- }
-
- public void setup(final Runnable r) {
- displayManager.initialize();
- inputManager.getKeyboard().startKeyboard();
- final Thread t = new Thread(r);
- Engine.getPlatform().setThreadDaemon(t, false);
- Engine.getPlatform().setThreadName(t, "Main thread (after setup)");
- t.start();
- }
-
-}
diff --git a/core/src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java b/core/src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java
deleted file mode 100644
index 5bf36efb..00000000
--- a/core/src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package it.cavallium.warppi.device;
-
-import it.cavallium.warppi.event.TouchEventListener;
-import it.cavallium.warppi.event.TouchPoint;
-
-public interface HardwareTouchDevice extends TouchEventListener {
- boolean getInvertedXY();
-
- boolean getInvertedX();
-
- boolean getInvertedY();
-
- default void setInvertedXY() {}
-
- default void setInvertedX() {}
-
- default void setInvertedY() {}
-
- TouchPoint makePoint(long id, float x, float y, int maxX, int maxY, float radiusX, float radiusY, float force,
- float rotationAngle);
-}
diff --git a/core/src/main/java/it/cavallium/warppi/device/InputManager.java b/core/src/main/java/it/cavallium/warppi/device/InputManager.java
deleted file mode 100644
index 22e93090..00000000
--- a/core/src/main/java/it/cavallium/warppi/device/InputManager.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package it.cavallium.warppi.device;
-
-public class InputManager {
- private final Keyboard keyboard;
- private final HardwareTouchDevice touchDevice;
-
- public InputManager(final Keyboard k, final HardwareTouchDevice t) {
- keyboard = k;
- touchDevice = t;
- }
-
- public Keyboard getKeyboard() {
- return keyboard;
- }
-
- public HardwareTouchDevice getTouchDevice() {
- return touchDevice;
- }
-
-}
diff --git a/core/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java b/core/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java
deleted file mode 100644
index f652581e..00000000
--- a/core/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package it.cavallium.warppi.device;
-
-import it.cavallium.warppi.Engine;
-import it.cavallium.warppi.gui.HardwareDisplay;
-
-public class PIHardwareDisplay implements HardwareDisplay {
-
- @Override
- public void initialize() {}
-
- @Override
- public void shutdown() {}
-
- @Override
- public void setBrightness(final double value) {
- if (Engine.getPlatform().isRunningOnRaspberry()) {
- Engine.getPlatform().getGpio().pwmWrite(12, (int) Math.ceil(value * 1024f));
-// SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10)));
- } else {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness: " + value);
- }
- }
-
-}
diff --git a/core/src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java b/core/src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java
deleted file mode 100644
index 8b583108..00000000
--- a/core/src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package it.cavallium.warppi.device;
-
-import it.cavallium.warppi.Engine;
-import it.cavallium.warppi.event.TouchCancelEvent;
-import it.cavallium.warppi.event.TouchEndEvent;
-import it.cavallium.warppi.event.TouchMoveEvent;
-import it.cavallium.warppi.event.TouchPoint;
-import it.cavallium.warppi.event.TouchStartEvent;
-import it.cavallium.warppi.gui.screens.Screen;
-
-public class PIHardwareTouchDevice implements HardwareTouchDevice {
-
- private final boolean invertXY, invertX, invertY;
-
- public PIHardwareTouchDevice(final boolean invertXY, final boolean invertX, final boolean invertY) {
- this.invertXY = invertXY;
- this.invertX = invertX;
- this.invertY = invertY;
- }
-
- @Override
- public boolean onTouchStart(final TouchStartEvent e) {
- final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
- boolean refresh = false;
- if (scr != null && scr.initialized && scr.onTouchStart(e)) {
- refresh = true;
- } else {
- //Default behavior
- }
- if (refresh) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
- }
- return true;
- }
-
- @Override
- public boolean onTouchEnd(final TouchEndEvent e) {
- final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
- boolean refresh = false;
- if (scr != null && scr.initialized && scr.onTouchEnd(e)) {
- refresh = true;
- } else {
- //Default behavior
- }
- if (refresh) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
- }
- return true;
- }
-
- @Override
- public boolean onTouchCancel(final TouchCancelEvent e) {
- final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
- boolean refresh = false;
- if (scr != null && scr.initialized && scr.onTouchCancel(e)) {
- refresh = true;
- } else {
- //Default behavior
- }
- if (refresh) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
- }
- return true;
- }
-
- @Override
- public boolean onTouchMove(final TouchMoveEvent e) {
- final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
- boolean refresh = false;
- if (scr != null && scr.initialized && scr.onTouchMove(e)) {
- refresh = true;
- } else {
- //Default behavior
- }
- if (refresh) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
- }
- return true;
- }
-
- @Override
- public boolean getInvertedXY() {
- return invertXY;
- }
-
- @Override
- public boolean getInvertedX() {
- return invertX;
- }
-
- @Override
- public boolean getInvertedY() {
- return invertY;
- }
-
- @Override
- public TouchPoint makePoint(final long id, float x, float y, final int screenWidth, final int screenHeight,
- final float radiusX, final float radiusY, final float force, final float rotationAngle) {
- if (getInvertedXY()) {
- final double oldX = x;
- final double oldY = y;
- x = (float) (oldY * screenWidth / screenHeight);
- y = (float) (oldX * screenHeight / screenWidth);
- }
- if (getInvertedX()) {
- x = screenWidth - x;
- }
- if (getInvertedY()) {
- y = screenHeight - y;
- }
- return new TouchPoint(id, x, y, radiusX, radiusY, force, rotationAngle);
- }
-}
diff --git a/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java b/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java
index dfc74e6d..115c796a 100644
--- a/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java
+++ b/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java
@@ -1,6 +1,6 @@
package it.cavallium.warppi.device.chip;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
public class ParallelToSerial {
@@ -18,16 +18,16 @@ public class ParallelToSerial {
public boolean[] read() {
final boolean[] data = new boolean[8];
- Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueHigh());
- Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueLow());
- Engine.getPlatform().getGpio().delayMicroseconds(1);
- Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueHigh());
- Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueLow());
+ WarpPI.getPlatform().getGpio().digitalWrite(CLK_INH, WarpPI.getPlatform().getGpio().valueHigh());
+ WarpPI.getPlatform().getGpio().digitalWrite(SH_LD, WarpPI.getPlatform().getGpio().valueLow());
+ WarpPI.getPlatform().getGpio().delayMicroseconds(1);
+ WarpPI.getPlatform().getGpio().digitalWrite(SH_LD, WarpPI.getPlatform().getGpio().valueHigh());
+ WarpPI.getPlatform().getGpio().digitalWrite(CLK_INH, WarpPI.getPlatform().getGpio().valueLow());
for (int i = 7; i >= 0; i--) {
- Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueHigh());
- Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueLow());
- data[i] = Engine.getPlatform().getGpio().digitalRead(QH) == Engine.getPlatform().getGpio().valueHigh() ? true : false;
+ WarpPI.getPlatform().getGpio().digitalWrite(CLK, WarpPI.getPlatform().getGpio().valueHigh());
+ WarpPI.getPlatform().getGpio().digitalWrite(CLK, WarpPI.getPlatform().getGpio().valueLow());
+ data[i] = WarpPI.getPlatform().getGpio().digitalRead(QH) == WarpPI.getPlatform().getGpio().valueHigh() ? true : false;
}
return data;
diff --git a/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java b/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java
index 4168a1c6..ca97b717 100644
--- a/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java
+++ b/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java
@@ -1,6 +1,6 @@
package it.cavallium.warppi.device.chip;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
public class SerialToParallel {
private final int RCK; //Storage register clock pin (latch pin)
@@ -17,15 +17,15 @@ public class SerialToParallel {
if (data.length != 8) {
return;
} else {
- Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueLow());
+ WarpPI.getPlatform().getGpio().digitalWrite(RCK, WarpPI.getPlatform().getGpio().valueLow());
for (int i = 7; i >= 0; i--) {
- Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueLow());
- Engine.getPlatform().getGpio().digitalWrite(SER, data[i]);
- Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueHigh());
+ WarpPI.getPlatform().getGpio().digitalWrite(SCK, WarpPI.getPlatform().getGpio().valueLow());
+ WarpPI.getPlatform().getGpio().digitalWrite(SER, data[i]);
+ WarpPI.getPlatform().getGpio().digitalWrite(SCK, WarpPI.getPlatform().getGpio().valueHigh());
}
- Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueHigh());
+ WarpPI.getPlatform().getGpio().digitalWrite(RCK, WarpPI.getPlatform().getGpio().valueHigh());
}
}
}
diff --git a/core/src/main/java/it/cavallium/warppi/device/display/BacklightOutputDevice.java b/core/src/main/java/it/cavallium/warppi/device/display/BacklightOutputDevice.java
new file mode 100644
index 00000000..71ed527a
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/display/BacklightOutputDevice.java
@@ -0,0 +1,16 @@
+package it.cavallium.warppi.device.display;
+
+public interface BacklightOutputDevice {
+
+ /**
+ * Set the brightness level
+ * @param value Value from 0.0 to 1.0
+ */
+ void setBrightness(double value);
+
+ /**
+ * Turn on or off the backlight
+ * @param value true is ON, false is OFF
+ */
+ void setPower(boolean value);
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/display/DisplayOutputDevice.java b/core/src/main/java/it/cavallium/warppi/device/display/DisplayOutputDevice.java
new file mode 100644
index 00000000..2fa7a93d
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/display/DisplayOutputDevice.java
@@ -0,0 +1,8 @@
+package it.cavallium.warppi.device.display;
+
+import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+
+public interface DisplayOutputDevice {
+ public GraphicEngine getGraphicEngine();
+ public int[] getDisplaySize();
+}
\ No newline at end of file
diff --git a/core/src/main/java/it/cavallium/warppi/device/display/NoDisplaysAvailableException.java b/core/src/main/java/it/cavallium/warppi/device/display/NoDisplaysAvailableException.java
new file mode 100644
index 00000000..3866a0c2
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/display/NoDisplaysAvailableException.java
@@ -0,0 +1,7 @@
+package it.cavallium.warppi.device.display;
+
+public class NoDisplaysAvailableException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/display/NullBacklightOutputDevice.java b/core/src/main/java/it/cavallium/warppi/device/display/NullBacklightOutputDevice.java
new file mode 100644
index 00000000..fbfca669
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/display/NullBacklightOutputDevice.java
@@ -0,0 +1,18 @@
+package it.cavallium.warppi.device.display;
+
+public class NullBacklightOutputDevice implements BacklightOutputDevice {
+
+ private double brightness;
+ private boolean power;
+
+ @Override
+ public void setBrightness(double value) {
+ this.brightness = value;
+ }
+
+ @Override
+ public void setPower(boolean value) {
+ this.power = value;
+ }
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java b/core/src/main/java/it/cavallium/warppi/device/display/RAWFont.java
similarity index 93%
rename from core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java
rename to core/src/main/java/it/cavallium/warppi/device/display/RAWFont.java
index d344d79a..0500620e 100644
--- a/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java
+++ b/core/src/main/java/it/cavallium/warppi/device/display/RAWFont.java
@@ -1,4 +1,4 @@
-package it.cavallium.warppi.device.graphicengine;
+package it.cavallium.warppi.device.display;
import java.io.File;
import java.io.IOException;
@@ -7,7 +7,7 @@ import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.util.ClassUtils;
import it.cavallium.warppi.util.Utils;
@@ -32,7 +32,7 @@ public class RAWFont {
loadFont("/font_" + name + ".rft");
} catch (final IOException e) {
e.printStackTrace();
- Engine.getPlatform().exit(1);
+ WarpPI.getPlatform().exit(1);
}
chars32 = new int[(maxBound - minBound) * charIntCount];
for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) {
@@ -110,7 +110,7 @@ public class RAWFont {
} catch (final Exception ex) {
ex.printStackTrace();
System.out.println(string);
- Engine.getPlatform().exit(-1);
+ WarpPI.getPlatform().exit(-1);
}
}
} else {
diff --git a/core/src/main/java/it/cavallium/warppi/device/input/HardwareKeyboardDevice.java b/core/src/main/java/it/cavallium/warppi/device/input/HardwareKeyboardDevice.java
new file mode 100644
index 00000000..5ea6da96
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/input/HardwareKeyboardDevice.java
@@ -0,0 +1,5 @@
+package it.cavallium.warppi.device.input;
+
+public interface HardwareKeyboardDevice {
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/input/InputManager.java b/core/src/main/java/it/cavallium/warppi/device/input/InputManager.java
new file mode 100644
index 00000000..4c6961eb
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/input/InputManager.java
@@ -0,0 +1,27 @@
+package it.cavallium.warppi.device.input;
+
+import java.util.Objects;
+
+public class InputManager {
+ private final KeyboardInputDevice keyboard;
+ private final TouchInputDevice touchDevice;
+
+ public InputManager(KeyboardInputDevice keyboard, TouchInputDevice touchscreen) {
+ this.keyboard = Objects.requireNonNull(keyboard);
+ this.touchDevice = Objects.requireNonNull(touchscreen);
+ }
+
+ public KeyboardInputDevice getKeyboard() {
+ return keyboard;
+ }
+
+ public TouchInputDevice getTouchDevice() {
+ return touchDevice;
+ }
+
+ public void initialize() {
+ this.keyboard.initialize();
+ this.touchDevice.initialize();
+ }
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/Keyboard.java b/core/src/main/java/it/cavallium/warppi/device/input/Keyboard.java
similarity index 88%
rename from core/src/main/java/it/cavallium/warppi/device/Keyboard.java
rename to core/src/main/java/it/cavallium/warppi/device/input/Keyboard.java
index 0c54d416..f2e1ab5f 100644
--- a/core/src/main/java/it/cavallium/warppi/device/Keyboard.java
+++ b/core/src/main/java/it/cavallium/warppi/device/input/Keyboard.java
@@ -1,1118 +1,1118 @@
-package it.cavallium.warppi.device;
-
-import it.cavallium.warppi.Engine;
-import it.cavallium.warppi.Platform.ConsoleUtils;
-import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.device.chip.ParallelToSerial;
-import it.cavallium.warppi.device.chip.SerialToParallel;
-import it.cavallium.warppi.event.Key;
-import it.cavallium.warppi.event.KeyPressedEvent;
-import it.cavallium.warppi.event.KeyReleasedEvent;
-import it.cavallium.warppi.event.KeyboardEventListener;
-import it.cavallium.warppi.extra.mario.MarioScreen;
-import it.cavallium.warppi.extra.tetris.TetrisScreen;
-import it.cavallium.warppi.gui.GUIErrorMessage;
-import it.cavallium.warppi.gui.screens.KeyboardDebugScreen;
-import it.cavallium.warppi.gui.screens.Screen;
-
-public class Keyboard {
- public static volatile boolean alpha = false;
- public static volatile boolean shift = false;
-
- //From Serial
- private static final int RCK_pin = 35;
- private static final int SCK_and_CLK_pin = 38;
- private static final int SER_pin = 36;
-
- //To Serial
- private static final int SH_LD_pin = 37;
- private static final int QH_pin = 40;
- private static final int CLK_INH_pin = 33;
-
- private static volatile boolean[][] precedentStates = new boolean[8][8];
- public static volatile boolean[][] debugKeysDown = new boolean[8][8];
- public static volatile int debugKeyCode = -1;
- public static volatile int debugKeyCodeRelease = -1;
-
- private static volatile boolean refreshRequest = false;
-
- private static KeyboardEventListener additionalListener;
-
- public synchronized void startKeyboard() {
- final Thread kt = new Thread(() -> {
- if (Engine.getPlatform().isRunningOnRaspberry() == false) {
- try {
- while (true) {
- if (Keyboard.debugKeyCode != -1) {
- Keyboard.debugKey(Keyboard.debugKeyCode, false);
- Keyboard.debugKeyCode = -1;
- }
- if (Keyboard.debugKeyCodeRelease != -1) {
- Keyboard.debugKey(Keyboard.debugKeyCodeRelease, true);
- Keyboard.debugKeyCodeRelease = -1;
- }
- Thread.sleep(50);
- }
- } catch (final InterruptedException e) {}
- } else {
- Engine.getPlatform().getGpio().pinMode(Keyboard.CLK_INH_pin, Engine.getPlatform().getGpio().valueOutput());
- Engine.getPlatform().getGpio().pinMode(Keyboard.RCK_pin, Engine.getPlatform().getGpio().valueOutput());
- Engine.getPlatform().getGpio().pinMode(Keyboard.SER_pin, Engine.getPlatform().getGpio().valueOutput());
- Engine.getPlatform().getGpio().pinMode(Keyboard.SH_LD_pin, Engine.getPlatform().getGpio().valueOutput());
- Engine.getPlatform().getGpio().pinMode(Keyboard.SCK_and_CLK_pin, Engine.getPlatform().getGpio().valueOutput());
- Engine.getPlatform().getGpio().pinMode(Keyboard.QH_pin, Engine.getPlatform().getGpio().valueInput());
-
- Engine.getPlatform().getGpio().digitalWrite(Keyboard.CLK_INH_pin, false);
- Engine.getPlatform().getGpio().digitalWrite(Keyboard.RCK_pin, false);
- Engine.getPlatform().getGpio().digitalWrite(Keyboard.SER_pin, false);
- Engine.getPlatform().getGpio().digitalWrite(Keyboard.SH_LD_pin, false);
- Engine.getPlatform().getGpio().digitalWrite(Keyboard.SCK_and_CLK_pin, false);
- Engine.getPlatform().getGpio().digitalWrite(Keyboard.QH_pin, false);
- final SerialToParallel chip1 = new SerialToParallel(Keyboard.RCK_pin, Keyboard.SCK_and_CLK_pin /*SCK*/, Keyboard.SER_pin);
- final ParallelToSerial chip2 = new ParallelToSerial(Keyboard.SH_LD_pin, Keyboard.CLK_INH_pin, Keyboard.QH_pin, Keyboard.SCK_and_CLK_pin/*CLK*/);
-
- KeyboardDebugScreen.log("Started keyboard system");
-
- while (true) {
- boolean[] data;
- for (int col = 0; col < 8; col++) {
- data = new boolean[8];
- data[col] = true;
- chip1.write(data);
-
- data = chip2.read();
-// KeyboardDebugScreen.ks[col] = data;
-
- for (int row = 0; row < 8; row++) {
- if (data[row] == true && Keyboard.precedentStates[row][col] == false) {
- // System.out.println("Pressed button at " + (row + 1) + ", " + (col + 1));
-// KeyboardDebugScreen.log("Pressed button at " + (row + 1) + ", " + (col + 1));
- Keyboard.keyRaw(row, col, false);
- } else if (data[row] == false && Keyboard.precedentStates[row][col] == true) {
- Keyboard.keyRaw(row, col, true);
- }
-// KeyboardDebugScreen.log("Released button at " + (row + 1) + ", " + (col + 1));
- Keyboard.precedentStates[row][col] = data[row];
- }
- }
- }
- }
- });
- Engine.getPlatform().setThreadName(kt, "Keyboard thread");
- kt.setPriority(Thread.NORM_PRIORITY + 1);
- Engine.getPlatform().setThreadDaemon(kt);
- kt.start();
- }
-
- /**
- *
- * @param k
- * @param released true: released, false: pressed
- */
- private static void debugKey(Key k, boolean released) {
- if (released) {
- Keyboard.keyReleased(k);
- } else {
- Keyboard.keyPressed(k);
- }
- }
-
- /**
- *
- * @param keyCode
- * @param released true: released, false: pressed
- */
- public static void debugKey(final int keyCode, boolean released) {
- switch (keyCode) {
- case KeyboardAWTValues.VK_ESCAPE:
- debugKey(Key.BACK, released);
- break;
- case KeyboardAWTValues.VK_S:
- if (Keyboard.shift) {
- debugKey(Key.ARCSINE, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_S, released);
- } else {
- debugKey(Key.SINE, released);
- }
- break;
- case KeyboardAWTValues.VK_C:
- if (Keyboard.shift) {
- debugKey(Key.ARCCOSINE, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_C, released);
- } else {
- debugKey(Key.COSINE, released);
- }
- break;
- case KeyboardAWTValues.VK_T:
- if (Keyboard.shift) {
- debugKey(Key.ARCTANGENT, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_T, released);
- } else {
- debugKey(Key.TANGENT, released);
- }
- break;
- case KeyboardAWTValues.VK_D:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.debug_DEG, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_D, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_R:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.debug_RAD, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_R, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_G:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.debug_GRA, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_G, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_X:
- if (Keyboard.alpha) {
- debugKey(Key.LETTER_X, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_P:
- if (Keyboard.shift) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_P, released);
- } else {
- debugKey(Key.PI, released);
- }
- break;
- case KeyboardAWTValues.VK_E:
- if (Keyboard.shift) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_E, released);
- } else {
- debugKey(Key.EULER_NUMBER, released);
- }
- break;
- case KeyboardAWTValues.VK_Y:
- if (Keyboard.alpha) {
- debugKey(Key.LETTER_Y, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_B:
- if (Keyboard.shift) {
- debugKey(Key.BRIGHTNESS_CYCLE_REVERSE, released);
- } else if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.BRIGHTNESS_CYCLE, released);
- } else {
- debugKey(Key.LETTER_B, released);
- }
- break;
- case KeyboardAWTValues.VK_L:
- if (Keyboard.shift) {
- debugKey(Key.LOGARITHM, released);
- } else if (Keyboard.alpha) {
- debugKey(Key.LETTER_L, released);
- } else {
- debugKey(Key.LOGARITHM, released);
- }
- break;
- case KeyboardJogampValues.VK_ENTER:
- case KeyboardAWTValues.VK_ENTER:
- if (Keyboard.shift) {
- debugKey(Key.STEP, released);
- } else if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.SIMPLIFY, released);
- } else {
- debugKey(Key.NONE, released);
- }
- int row = 2;
- int col = 1;
- Keyboard.debugKeysDown[row - 1][col - 1] = true;
- break;
- case KeyboardAWTValues.VK_1:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM1, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_2:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM2, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_3:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM3, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_4:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM4, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_5:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM5, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_6:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM6, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_7:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM7, released);
- } else if (Keyboard.shift) {
- if (Engine.getPlatform().isRunningOnRaspberry() == false) {
- debugKey(Key.DIVIDE, released);
- }
- }
- break;
- case KeyboardAWTValues.VK_8:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM8, released);
- } else if (Keyboard.shift) {
- debugKey(Key.PARENTHESIS_OPEN, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_9:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM9, released);
- } else if (Keyboard.shift) {
- debugKey(Key.PARENTHESIS_CLOSE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_0:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NUM0, released);
- } else if (Keyboard.shift) {
- debugKey(Key.EQUAL, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_M:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.SURD_MODE, released);
- } else if (Keyboard.shift) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.LETTER_M, released);
- }
- break;
- case KeyboardJogampValues.VK_ADD:
- case KeyboardAWTValues.VK_ADD:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.PLUS, released);
- } else if (Keyboard.shift) {
- debugKey(Key.PLUS_MINUS, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_SUBTRACT:
- case KeyboardAWTValues.VK_SUBTRACT:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.MINUS, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_MULTIPLY:
- case KeyboardAWTValues.VK_MULTIPLY:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.MULTIPLY, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_DIVIDE:
- case KeyboardAWTValues.VK_DIVIDE:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.DIVIDE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_BACK_SPACE:
- debugKey(Key.DELETE, released);
- break;
- case KeyboardJogampValues.VK_DELETE:
- case KeyboardAWTValues.VK_DELETE:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.RESET, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_LEFT:
- case KeyboardAWTValues.VK_LEFT:
- //LEFT
- row = 2;
- col = 3;
- Keyboard.debugKeysDown[row - 1][col - 1] = true;
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.LEFT, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_RIGHT:
- case KeyboardAWTValues.VK_RIGHT:
- //RIGHT
- row = 2;
- col = 5;
- Keyboard.debugKeysDown[row - 1][col - 1] = true;
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.RIGHT, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_UP:
- case KeyboardAWTValues.VK_UP:
- //UP
- row = 1;
- col = 4;
- Keyboard.debugKeysDown[row - 1][col - 1] = true;
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.UP, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_DOWN:
- case KeyboardAWTValues.VK_DOWN:
- //DOWN
- row = 3;
- col = 4;
- Keyboard.debugKeysDown[row - 1][col - 1] = true;
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.DOWN, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case (short) 12:
- //DOWN
- row = 2;
- col = 4;
- Keyboard.debugKeysDown[row - 1][col - 1] = true;
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.OK, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_NUMPAD4:
- case KeyboardAWTValues.VK_NUMPAD4:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.HISTORY_BACK, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_NUMPAD6:
- case KeyboardAWTValues.VK_NUMPAD6:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.HISTORY_FORWARD, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_PERIOD:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.DOT, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_A:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_A, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_F:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_F, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_H:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_H, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_I:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_I, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_J:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_J, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_K:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_K, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_N:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_N, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_O:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_O, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_Q:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_Q, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_U:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_U, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_V:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_V, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_W:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_W, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardAWTValues.VK_Z:
- if (!Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.NONE, released);
- } else if (Keyboard.alpha && !Keyboard.shift) {
- debugKey(Key.LETTER_Z, released);
- } else if (Keyboard.shift && !Keyboard.alpha) {
- debugKey(Key.ZOOM_MODE, released);
- } else {
- debugKey(Key.NONE, released);
- }
- break;
- case KeyboardJogampValues.VK_SHIFT:
- case KeyboardAWTValues.VK_SHIFT:
- debugKey(Key.SHIFT, released);
- break;
- case KeyboardAWTValues.VK_CONTROL:
- debugKey(Key.ALPHA, released);
- break;
- case KeyboardJogampValues.VK_NUMPAD1:
- case KeyboardAWTValues.VK_NUMPAD1:
- debugKey(Key.SQRT, released);
- break;
- case KeyboardJogampValues.VK_NUMPAD2:
- case KeyboardAWTValues.VK_NUMPAD2:
- debugKey(Key.ROOT, released);
- break;
- case KeyboardJogampValues.VK_NUMPAD3:
- case KeyboardAWTValues.VK_NUMPAD3:
- debugKey(Key.POWER_OF_2, released);
- break;
- case KeyboardJogampValues.VK_NUMPAD5:
- case KeyboardAWTValues.VK_NUMPAD5:
- debugKey(Key.POWER_OF_x, released);
- break;
- }
- }
-
- private synchronized static void debugKeyReleased(final int keyCode) {
- switch (keyCode) {
- case KeyboardAWTValues.VK_ENTER:
- int row = 2;
- int col = 1;
- Keyboard.debugKeysDown[row - 1][col - 1] = false;
- break;
- case KeyboardJogampValues.VK_LEFT:
- case KeyboardAWTValues.VK_LEFT:
- //LEFT
- row = 2;
- col = 3;
- Keyboard.debugKeysDown[row - 1][col - 1] = false;
- break;
- case KeyboardJogampValues.VK_RIGHT:
- case KeyboardAWTValues.VK_RIGHT:
- //RIGHT
- row = 2;
- col = 5;
- Keyboard.debugKeysDown[row - 1][col - 1] = false;
- System.out.println("RELEASE");
- break;
- case KeyboardJogampValues.VK_UP:
- case KeyboardAWTValues.VK_UP:
- //UP
- row = 1;
- col = 4;
- Keyboard.debugKeysDown[row - 1][col - 1] = false;
- break;
- case KeyboardJogampValues.VK_DOWN:
- case KeyboardAWTValues.VK_DOWN:
- //DOWN
- row = 3;
- col = 4;
- Keyboard.debugKeysDown[row - 1][col - 1] = false;
- break;
- case (short) 12:
- //DOWN
- row = 2;
- col = 4;
- Keyboard.debugKeysDown[row - 1][col - 1] = false;
- break;
- }
- }
-
- /**
- *
- * @param row
- * @param col
- * @return
- */
- @Deprecated
- public static boolean isKeyDown(final int row, final int col) {
- if (Engine.getPlatform().isRunningOnRaspberry()) {
- return Keyboard.precedentStates[row - 1][col - 1];
- } else {
- return Keyboard.debugKeysDown[row - 1][col - 1];
- }
- }
-
- static final String[][][] KeyLabelsMap = /* [ROW, COLUMN, (0:normal 1:shift 2:alpha)] */
- { { /* ROW 0 */
- { "⇪", "⇪", null }, /* 0,0 */
- { "A", null, "A" }, /* 0,1 */
- { "", null, null }, /* 0,2 */
- { "⇧", null, null }, /* 0,3 */
- { "", null, null }, /* 0,4 */
- { "", null, null }, /* 0,5 */
- { "☼", "☼", null }, /* 0,6 */
- { "↩", null, null } /* 0,7 */
- }, { /* ROW 1 */
- { "", null, null }, /* 1,0 */
- { "", null, null }, /* 1,1 */
- { "⇦", null, null }, /* 1,2 */
- { "OK", null, null }, /* 1,3 */
- { "⇨", null, null }, /* 1,4 */
- { "≪", null, null }, /* 1,5 */
- { "≫", null, null }, /* 1,6 */
- { "", null, null } /* 1,7 */
- }, { /* ROW 2 */
- { "", null, null }, /* 2,0 */
- { "√▯", null, null }, /* 2,1 */
- { "", null, null }, /* 2,2 */
- { "⇩", null, null }, /* 2,3 */
- { "↶", null, null }, /* 2,4 */
- { "", null, null }, /* 2,5 */
- { "", null, null }, /* 2,6 */
- { "", null, null } /* 2,7 */
- }, { /* ROW 3 */
- { "", null, null }, /* 3,0 */
- { "", null, null }, /* 3,1 */
- { "▯^▯", null, null }, /* 3,2 */
- { "▯^2", null, null }, /* 3,3 */
- { "", null, null }, /* 3,4 */
- { "", null, null }, /* 3,5 */
- { "", null, null }, /* 3,6 */
- { ".", null, "y" } /* 3,7 */
- }, { /* ROW 4 */
- { "", null, null }, /* 4,0 */
- { "", null, null }, /* 4,1 */
- { "(▯)", null, null }, /* 4,2 */
- { ")", null, null }, /* 4,3 */
- { "", null, null }, /* 4,4 */
- { "S⇔D", null, null }, /* 4,5 */
- { "", null, null }, /* 4,6 */
- { "0", null, "x" } /* 4,7 */
- }, { /* ROW 5 */
- { "7", null, null }, /* 5,0 */
- { "8", null, null }, /* 5,1 */
- { "9", null, null }, /* 5,2 */
- { "⌫", null, null }, /* 5,3 */
- { "RESET", null, null }, /* 5,4 */
- { "", null, null }, /* 5,5 */
- { "", null, null }, /* 5,6 */
- { "", null, null } /* 5,7 */
- }, { /* ROW 6 */
- { "4", null, null }, /* 6,0 */
- { "5", null, null }, /* 6,1 */
- { "6", null, null }, /* 6,2 */
- { "*", null, null }, /* 6,3 */
- { "/", null, null }, /* 6,4 */
- { "", null, null }, /* 6,5 */
- { "", null, null }, /* 6,6 */
- { "", null, null } /* 6,7 */
- }, { /* ROW 7 */
- { "1", null, null }, /* 7,0 */
- { "2", null, null }, /* 7,1 */
- { "3", null, null }, /* 7,2 */
- { "+", null, null }, /* 7,3 */
- { "-", null, null }, /* 7,4 */
- { "", null, null }, /* 7,5 */
- { "", null, null }, /* 7,6 */
- { "", null, null } /* 7,7 */
- } };
-
- static final Key[][][] keyMap = /* [ROW, COLUMN, (0:normal 1:shift 2:alpha)] */
- { { /* ROW 0 */
- { Key.SHIFT, Key.SHIFT, Key.SHIFT }, /* 0,0 */
- { Key.ALPHA, Key.ALPHA, Key.ALPHA }, /* 0,1 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 0,2 */
- { Key.UP, Key.NONE, Key.NONE }, /* 0,3 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 0,4 */
- { Key.SETTINGS, Key.NONE, Key.NONE }, /* 0,5 */
- { Key.BRIGHTNESS_CYCLE, Key.BRIGHTNESS_CYCLE_REVERSE, Key.ZOOM_MODE }, /* 0,6 */
- { Key.SIMPLIFY, Key.STEP, Key.NONE } /* 0,7 */
- }, { /* ROW 1 */
- { Key.F4, Key.F4, Key.F4 }, /* 1,0 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 1,1 */
- { Key.LEFT, Key.NONE, Key.NONE }, /* 1,2 */
- { Key.OK, Key.NONE, Key.NONE }, /* 1,3 */
- { Key.RIGHT, Key.NONE, Key.NONE }, /* 1,4 */
- { Key.HISTORY_BACK, Key.NONE, Key.NONE }, /* 1,5 */
- { Key.HISTORY_FORWARD, Key.NONE, Key.NONE }, /* 1,6 */
- { Key.NONE, Key.PI, Key.DRG_CYCLE } /* 1,7 */
- }, { /* ROW 2 */
- { Key.F3, Key.F3, Key.F3 }, /* 2,0 */
- { Key.SQRT, Key.ROOT, Key.NONE }, /* 2,1 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 2,2 */
- { Key.DOWN, Key.NONE, Key.NONE }, /* 2,3 */
- { Key.BACK, Key.NONE, Key.NONE }, /* 2,4 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 2,5 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 2,6 */
- { Key.NONE, Key.NONE, Key.LETTER_Z } /* 2,7 */
- }, { /* ROW 3 */
- { Key.F2, Key.F2, Key.F2 }, /* 3,0 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 3,1 */
- { Key.POWER_OF_x, Key.NONE, Key.NONE }, /* 3,2 */
- { Key.POWER_OF_2, Key.NONE, Key.NONE }, /* 3,3 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 3,4 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 3,5 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 3,6 */
- { Key.DOT, Key.NONE, Key.LETTER_Y } /* 3,7 */
- }, { /* ROW 4 */
- { Key.F1, Key.F1, Key.F1 }, /* 4,0 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 4,1 */
- { Key.PARENTHESIS_OPEN, Key.NONE, Key.NONE }, /* 4,2 */
- { Key.PARENTHESIS_CLOSE, Key.NONE, Key.NONE }, /* 4,3 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 4,4 */
- { Key.SURD_MODE, Key.NONE, Key.NONE }, /* 4,5 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 4,6 */
- { Key.NUM0, Key.NONE, Key.LETTER_X } /* 4,7 */
- }, { /* ROW 5 */
- { Key.NUM7, Key.NONE, Key.NONE }, /* 5,0 */
- { Key.NUM8, Key.NONE, Key.NONE }, /* 5,1 */
- { Key.NUM9, Key.NONE, Key.NONE }, /* 5,2 */
- { Key.DELETE, Key.NONE, Key.NONE }, /* 5,3 */
- { Key.RESET, Key.NONE, Key.NONE }, /* 5,4 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 5,5 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 5,6 */
- { Key.NONE, Key.NONE, Key.NONE } /* 5,7 */
- }, { /* ROW 6 */
- { Key.NUM4, Key.NONE, Key.NONE }, /* 6,0 */
- { Key.NUM5, Key.NONE, Key.NONE }, /* 6,1 */
- { Key.NUM6, Key.NONE, Key.NONE }, /* 6,2 */
- { Key.MULTIPLY, Key.NONE, Key.NONE }, /* 6,3 */
- { Key.DIVIDE, Key.NONE, Key.NONE }, /* 6,4 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 6,5 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 6,6 */
- { Key.NONE, Key.NONE, Key.NONE } /* 6,7 */
- }, { /* ROW 7 */
- { Key.NUM1, Key.NONE, Key.NONE }, /* 7,0 */
- { Key.NUM2, Key.NONE, Key.NONE }, /* 7,1 */
- { Key.NUM3, Key.NONE, Key.NONE }, /* 7,2 */
- { Key.PLUS, Key.PLUS_MINUS, Key.NONE }, /* 7,3 */
- { Key.MINUS, Key.NONE, Key.NONE }, /* 7,4 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 7,5 */
- { Key.NONE, Key.NONE, Key.NONE }, /* 7,6 */
- { Key.NONE, Key.NONE, Key.NONE } /* 7,7 */
- } };
-
- public static String getKeyName(final int row, final int col) {
- return Keyboard.getKeyName(row, col, Keyboard.shift, Keyboard.alpha);
- }
-
- public static String getKeyName(final int row, final int col, final boolean shift, final boolean alpha) {
- final String[] keyValues = Keyboard.KeyLabelsMap[row][col];
- if (shift) {
- if (keyValues[1] != null) {
- return keyValues[1];
- }
- } else if (alpha) {
- if (keyValues[2] != null) {
- return keyValues[2];
- }
- }
- return keyValues[0];
- }
-
- public static boolean hasKeyName(final int row, final int col) {
- final String[] keyValues = Keyboard.KeyLabelsMap[row][col];
- if (Keyboard.shift) {
- return keyValues[1] != null;
- } else if (Keyboard.alpha) {
- return keyValues[2] != null;
- } else {
- return true;
- }
- }
-
- /**
- *
- * @param row
- * @param col
- * @param released true: released, false: pressed
- */
- public static synchronized void keyRaw(final int row, final int col, final boolean released) {
-// KeyboardDebugScreen.keyX = row;
-// KeyboardDebugScreen.keyY = col;
- final Key k = Keyboard.keyMap[row][col][Keyboard.shift ? 1 : Keyboard.alpha ? 2 : 0];
- if (k != null) {
- if (released) {
- Keyboard.keyReleased(k);
- } else {
- Keyboard.keyPressed(k);
- }
- } else {
- if (released) {
- Keyboard.keyReleased(Key.NONE);
- } else {
- Keyboard.keyPressed(Key.NONE);
- }
- }
- }
-
- public static void stopKeyboard() {
- if (Engine.getPlatform().isRunningOnRaspberry()) {
- Engine.getPlatform().getGpio().digitalWrite(33, false);
- Engine.getPlatform().getGpio().digitalWrite(35, false);
- Engine.getPlatform().getGpio().digitalWrite(36, false);
- Engine.getPlatform().getGpio().digitalWrite(37, false);
- Engine.getPlatform().getGpio().digitalWrite(38, false);
- Engine.getPlatform().getGpio().digitalWrite(40, false);
- }
- }
-
- public synchronized static void keyPressed(final Key k) {
- boolean done = false;
- if (Keyboard.additionalListener != null) {
- try {
- done = Keyboard.additionalListener.onKeyPressed(new KeyPressedEvent(k));
- } catch (final Exception ex) {
- new GUIErrorMessage(ex);
- }
- }
- if (Engine.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
- final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
- boolean refresh = false;
- boolean scrdone = false;
- try {
- scrdone = scr.onKeyPressed(new KeyPressedEvent(k));
- } catch (final Exception ex) {
- new GUIErrorMessage(ex);
- }
- if (scr != null && scr.initialized && scrdone) {
- refresh = true;
- } else {
- switch (k) {
- case POWEROFF:
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.destroy();
- break;
- case NONE:
- break;
- case BRIGHTNESS_CYCLE:
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new TetrisScreen()); //TODO: rimuovere: prova
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(false);
- refresh = true;
- break;
- case BRIGHTNESS_CYCLE_REVERSE:
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(true);
- refresh = true;
- break;
- case ZOOM_MODE:
- final float newZoom = StaticVars.windowZoom.getLastValue() % 3 + 1;
- StaticVars.windowZoom.submit(newZoom);
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom);
-// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
- refresh = true;
- break;
- case HISTORY_BACK:
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().goBack();
- refresh = true;
- break;
- case HISTORY_FORWARD:
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().goForward();
- refresh = true;
- break;
- case BACK:
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Closing current screen.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().closeScreen();
- refresh = true;
- break;
- default:
- break;
- }
- }
- switch (k) {
- case SHIFT:
- if (Keyboard.alpha) {
- Engine.getPlatform().alphaChanged(Keyboard.alpha = false);
- }
- Engine.getPlatform().shiftChanged(Keyboard.shift = !Keyboard.shift);
- refresh = true;
- break;
- case ALPHA:
- if (Keyboard.shift) {
- Engine.getPlatform().shiftChanged(Keyboard.shift = false);
- }
- Engine.getPlatform().alphaChanged(Keyboard.alpha = !Keyboard.alpha);
- refresh = true;
- break;
- default:
- if (k != Key.NONE) {
- if (Keyboard.shift) {
- Engine.getPlatform().shiftChanged(Keyboard.shift = false);
- }
- if (Keyboard.alpha) {
- Engine.getPlatform().alphaChanged(Keyboard.alpha = false);
- }
- }
- break;
- }
- if (refresh) {
- Keyboard.refreshRequest = true;
- }
- } else if (!done) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
- }
- }
-
- public synchronized static void keyReleased(final Key k) {
- boolean done = false;
- if (Keyboard.additionalListener != null) {
- done = Keyboard.additionalListener.onKeyReleased(new KeyReleasedEvent(k));
- }
- boolean refresh = false;
- if (Engine.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
- final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
- if (scr != null && scr.initialized && scr.onKeyReleased(new KeyReleasedEvent(k))) {
- refresh = true;
- } else {
- switch (k) {
- case NONE:
- break;
- default:
- break;
- }
- }
- if (refresh) {
- Keyboard.refreshRequest = true;
- }
- } else if (!done) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
- }
- }
-
- public void setAdditionalKeyboardListener(final KeyboardEventListener l) {
- Keyboard.additionalListener = l;
- }
-
- public static boolean popRefreshRequest() {
- if (Keyboard.refreshRequest) {
- Keyboard.refreshRequest = false;
- return true;
- }
- return false;
- }
-
-}
-
-/*
-
-
-
-Keyboard:
- Example button:
- |ROW,COLUMN----|
- | NORMAL STATE |
- | SHIFT STATE |
- | ALPHA STATE |
- |--------------|
-
- Physical keyboard:
- |0,0-----|0,1-----|########|0,3-----|########|0,5-----|0,6-----|
- | SHIFT | ALPHA |########| ^ |########|SETTINGS|+BRIGHT |
- | NORMAL | ALPHA |########| |########| |-BRIGHT |
- | SHIFT | NORMAL |########| |########| |ZOOMMODE|
- |1,0-----|1,1-----|1,2-----|1,3-----|1,4-----|1,5-----|1,6-----|
- | F_4 | | < | OK | > | Back | Fwd |
- | F_4 | | | | | | |
- | F_4 | | | | | | |
- |2,0-----|2,1-----|--------|2,3-----|--------|2,5-----|2,6-----|
- | F_3 | SQRT |########| v | BACK | | |
- | F_3 | ROOT |########| | | | |
- | F_3 | |########| | | | |
- |3,0-----|3,1-----|3,2-----|3,3-----|3,4-----|3,5-----|3,6-----|
- | F_2 | | POW x | POW 2 | | | |
- | F_2 | | | | | | |
- | F_2 | | | | | | |
- |4,0-----|4,1-----|4,2-----|4,3-----|4,4-----|4,5-----|4,6-----|
- | F_1 | | ( | ) | | S<=>D | |
- | F_1 | | | | | | |
- | F_1 | | | | | | |
- |5,0-----|5,1-----|5,2-----|5,3-----|5,4-----|5,5-----|5,6-----|
- | 7 | 8 | 9 | DEL | RESET |
- | | | | | |
- | | | | | |
- |6,0-----|6,1-----|6,2-----|6,3-----|6,4-----------------------|
- | 4 | 5 | 6 | * | / |
- | | | | | |
- | | | | | |
- |7,0-----|7,1-----|7,2-----|7,3-----|7,4-----------------------|
- | 1 | 2 | 3 | + | - |
- | | | | | |
- | | | | | |
- |4,7-----|3,7-----|2,7-----|1,7-----|0,7-----------------------|
- | 0 | . | | | SIMPLIFY |
- | | | |PI | STEP |
- | X | Y | Z |DRG CYCL| |
- |--------|--------|--------|--------|--------------------------|
-
-SCREEN F_n:
- MathInputScreen:
- Default:
- [F_1] Normal: Solve for X Shift: Solve for _ Alpha:
- [F_2] Normal: Shift: Alpha:
- [F_3] Normal: Variables & constants Shift: Alpha:
- [F_4] Normal: Functions f(x) Shift: Alpha:
- Variable popup:
- [F_1] Normal(if constant):Set value Shift: Alpha:
- [F_2] Normal: Shift: Alpha:
- [F_3] Normal: Shift: Alpha:
- [F_4] Normal: Shift: Alpha:
- MarioScreen
- [F_1] Normal: Shift: Alpha:
- [F_2] Normal: Shift: Alpha:
- [F_3] Normal: Shift: Alpha:
- [F_4] Normal: Shift: Alpha:
- ChooseVariableValueScreen
- [F_1] Normal: Shift: Alpha:
- [F_2] Normal: Shift: Alpha:
- [F_3] Normal: Shift: Alpha:
- [F_4] Normal: Shift: Alpha:
- SolveForXScreen
- [F_1] Normal: Shift: Alpha:
- [F_2] Normal: Shift: Alpha:
- [F_3] Normal: Shift: Alpha:
- [F_4] Normal: Shift: Alpha:
+package it.cavallium.warppi.device.input;
+
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.Platform.ConsoleUtils;
+import it.cavallium.warppi.StaticVars;
+import it.cavallium.warppi.device.chip.ParallelToSerial;
+import it.cavallium.warppi.device.chip.SerialToParallel;
+import it.cavallium.warppi.event.Key;
+import it.cavallium.warppi.event.KeyPressedEvent;
+import it.cavallium.warppi.event.KeyReleasedEvent;
+import it.cavallium.warppi.event.KeyboardEventListener;
+import it.cavallium.warppi.extra.mario.MarioScreen;
+import it.cavallium.warppi.extra.tetris.TetrisScreen;
+import it.cavallium.warppi.gui.GUIErrorMessage;
+import it.cavallium.warppi.gui.screens.KeyboardDebugScreen;
+import it.cavallium.warppi.gui.screens.Screen;
+
+public class Keyboard {
+ public static volatile boolean alpha = false;
+ public static volatile boolean shift = false;
+
+ //From Serial
+ private static final int RCK_pin = 35;
+ private static final int SCK_and_CLK_pin = 38;
+ private static final int SER_pin = 36;
+
+ //To Serial
+ private static final int SH_LD_pin = 37;
+ private static final int QH_pin = 40;
+ private static final int CLK_INH_pin = 33;
+
+ private static volatile boolean[][] precedentStates = new boolean[8][8];
+ public static volatile boolean[][] debugKeysDown = new boolean[8][8];
+ public static volatile int debugKeyCode = -1;
+ public static volatile int debugKeyCodeRelease = -1;
+
+ private static volatile boolean refreshRequest = false;
+
+ private static KeyboardEventListener additionalListener;
+
+ public synchronized void startKeyboard() {
+ final Thread kt = new Thread(() -> {
+ if (WarpPI.getPlatform().isRunningOnRaspberry() == false) {
+ try {
+ while (true) {
+ if (Keyboard.debugKeyCode != -1) {
+ Keyboard.debugKey(Keyboard.debugKeyCode, false);
+ Keyboard.debugKeyCode = -1;
+ }
+ if (Keyboard.debugKeyCodeRelease != -1) {
+ Keyboard.debugKey(Keyboard.debugKeyCodeRelease, true);
+ Keyboard.debugKeyCodeRelease = -1;
+ }
+ Thread.sleep(50);
+ }
+ } catch (final InterruptedException e) {}
+ } else {
+ WarpPI.getPlatform().getGpio().pinMode(Keyboard.CLK_INH_pin, WarpPI.getPlatform().getGpio().valueOutput());
+ WarpPI.getPlatform().getGpio().pinMode(Keyboard.RCK_pin, WarpPI.getPlatform().getGpio().valueOutput());
+ WarpPI.getPlatform().getGpio().pinMode(Keyboard.SER_pin, WarpPI.getPlatform().getGpio().valueOutput());
+ WarpPI.getPlatform().getGpio().pinMode(Keyboard.SH_LD_pin, WarpPI.getPlatform().getGpio().valueOutput());
+ WarpPI.getPlatform().getGpio().pinMode(Keyboard.SCK_and_CLK_pin, WarpPI.getPlatform().getGpio().valueOutput());
+ WarpPI.getPlatform().getGpio().pinMode(Keyboard.QH_pin, WarpPI.getPlatform().getGpio().valueInput());
+
+ WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.CLK_INH_pin, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.RCK_pin, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.SER_pin, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.SH_LD_pin, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.SCK_and_CLK_pin, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(Keyboard.QH_pin, false);
+ final SerialToParallel chip1 = new SerialToParallel(Keyboard.RCK_pin, Keyboard.SCK_and_CLK_pin /*SCK*/, Keyboard.SER_pin);
+ final ParallelToSerial chip2 = new ParallelToSerial(Keyboard.SH_LD_pin, Keyboard.CLK_INH_pin, Keyboard.QH_pin, Keyboard.SCK_and_CLK_pin/*CLK*/);
+
+ KeyboardDebugScreen.log("Started keyboard system");
+
+ while (true) {
+ boolean[] data;
+ for (int col = 0; col < 8; col++) {
+ data = new boolean[8];
+ data[col] = true;
+ chip1.write(data);
+
+ data = chip2.read();
+// KeyboardDebugScreen.ks[col] = data;
+
+ for (int row = 0; row < 8; row++) {
+ if (data[row] == true && Keyboard.precedentStates[row][col] == false) {
+ // System.out.println("Pressed button at " + (row + 1) + ", " + (col + 1));
+// KeyboardDebugScreen.log("Pressed button at " + (row + 1) + ", " + (col + 1));
+ Keyboard.keyRaw(row, col, false);
+ } else if (data[row] == false && Keyboard.precedentStates[row][col] == true) {
+ Keyboard.keyRaw(row, col, true);
+ }
+// KeyboardDebugScreen.log("Released button at " + (row + 1) + ", " + (col + 1));
+ Keyboard.precedentStates[row][col] = data[row];
+ }
+ }
+ }
+ }
+ });
+ WarpPI.getPlatform().setThreadName(kt, "Keyboard thread");
+ kt.setPriority(Thread.NORM_PRIORITY + 1);
+ WarpPI.getPlatform().setThreadDaemon(kt);
+ kt.start();
+ }
+
+ /**
+ *
+ * @param k
+ * @param released true: released, false: pressed
+ */
+ private static void debugKey(Key k, boolean released) {
+ if (released) {
+ Keyboard.keyReleased(k);
+ } else {
+ Keyboard.keyPressed(k);
+ }
+ }
+
+ /**
+ *
+ * @param keyCode
+ * @param released true: released, false: pressed
+ */
+ public static void debugKey(final int keyCode, boolean released) {
+ switch (keyCode) {
+ case KeyboardAWTValues.VK_ESCAPE:
+ debugKey(Key.BACK, released);
+ break;
+ case KeyboardAWTValues.VK_S:
+ if (Keyboard.shift) {
+ debugKey(Key.ARCSINE, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_S, released);
+ } else {
+ debugKey(Key.SINE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_C:
+ if (Keyboard.shift) {
+ debugKey(Key.ARCCOSINE, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_C, released);
+ } else {
+ debugKey(Key.COSINE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_T:
+ if (Keyboard.shift) {
+ debugKey(Key.ARCTANGENT, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_T, released);
+ } else {
+ debugKey(Key.TANGENT, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_D:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.debug_DEG, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_D, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_R:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.debug_RAD, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_R, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_G:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.debug_GRA, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_G, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_X:
+ if (Keyboard.alpha) {
+ debugKey(Key.LETTER_X, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_P:
+ if (Keyboard.shift) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_P, released);
+ } else {
+ debugKey(Key.PI, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_E:
+ if (Keyboard.shift) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_E, released);
+ } else {
+ debugKey(Key.EULER_NUMBER, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_Y:
+ if (Keyboard.alpha) {
+ debugKey(Key.LETTER_Y, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_B:
+ if (Keyboard.shift) {
+ debugKey(Key.BRIGHTNESS_CYCLE_REVERSE, released);
+ } else if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.BRIGHTNESS_CYCLE, released);
+ } else {
+ debugKey(Key.LETTER_B, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_L:
+ if (Keyboard.shift) {
+ debugKey(Key.LOGARITHM, released);
+ } else if (Keyboard.alpha) {
+ debugKey(Key.LETTER_L, released);
+ } else {
+ debugKey(Key.LOGARITHM, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_ENTER:
+ case KeyboardAWTValues.VK_ENTER:
+ if (Keyboard.shift) {
+ debugKey(Key.STEP, released);
+ } else if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.SIMPLIFY, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ int row = 2;
+ int col = 1;
+ Keyboard.debugKeysDown[row - 1][col - 1] = true;
+ break;
+ case KeyboardAWTValues.VK_1:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM1, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_2:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM2, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_3:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM3, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_4:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM4, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_5:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM5, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_6:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM6, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_7:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM7, released);
+ } else if (Keyboard.shift) {
+ if (WarpPI.getPlatform().isRunningOnRaspberry() == false) {
+ debugKey(Key.DIVIDE, released);
+ }
+ }
+ break;
+ case KeyboardAWTValues.VK_8:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM8, released);
+ } else if (Keyboard.shift) {
+ debugKey(Key.PARENTHESIS_OPEN, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_9:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM9, released);
+ } else if (Keyboard.shift) {
+ debugKey(Key.PARENTHESIS_CLOSE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_0:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NUM0, released);
+ } else if (Keyboard.shift) {
+ debugKey(Key.EQUAL, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_M:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.SURD_MODE, released);
+ } else if (Keyboard.shift) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.LETTER_M, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_ADD:
+ case KeyboardAWTValues.VK_ADD:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.PLUS, released);
+ } else if (Keyboard.shift) {
+ debugKey(Key.PLUS_MINUS, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_SUBTRACT:
+ case KeyboardAWTValues.VK_SUBTRACT:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.MINUS, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_MULTIPLY:
+ case KeyboardAWTValues.VK_MULTIPLY:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.MULTIPLY, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_DIVIDE:
+ case KeyboardAWTValues.VK_DIVIDE:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.DIVIDE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_BACK_SPACE:
+ debugKey(Key.DELETE, released);
+ break;
+ case KeyboardJogampValues.VK_DELETE:
+ case KeyboardAWTValues.VK_DELETE:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.RESET, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_LEFT:
+ case KeyboardAWTValues.VK_LEFT:
+ //LEFT
+ row = 2;
+ col = 3;
+ Keyboard.debugKeysDown[row - 1][col - 1] = true;
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.LEFT, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_RIGHT:
+ case KeyboardAWTValues.VK_RIGHT:
+ //RIGHT
+ row = 2;
+ col = 5;
+ Keyboard.debugKeysDown[row - 1][col - 1] = true;
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.RIGHT, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_UP:
+ case KeyboardAWTValues.VK_UP:
+ //UP
+ row = 1;
+ col = 4;
+ Keyboard.debugKeysDown[row - 1][col - 1] = true;
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.UP, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_DOWN:
+ case KeyboardAWTValues.VK_DOWN:
+ //DOWN
+ row = 3;
+ col = 4;
+ Keyboard.debugKeysDown[row - 1][col - 1] = true;
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.DOWN, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case (short) 12:
+ //DOWN
+ row = 2;
+ col = 4;
+ Keyboard.debugKeysDown[row - 1][col - 1] = true;
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.OK, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_NUMPAD4:
+ case KeyboardAWTValues.VK_NUMPAD4:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.HISTORY_BACK, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_NUMPAD6:
+ case KeyboardAWTValues.VK_NUMPAD6:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.HISTORY_FORWARD, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_PERIOD:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.DOT, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_A:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_A, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_F:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_F, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_H:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_H, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_I:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_I, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_J:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_J, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_K:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_K, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_N:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_N, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_O:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_O, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_Q:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_Q, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_U:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_U, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_V:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_V, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_W:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_W, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardAWTValues.VK_Z:
+ if (!Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.NONE, released);
+ } else if (Keyboard.alpha && !Keyboard.shift) {
+ debugKey(Key.LETTER_Z, released);
+ } else if (Keyboard.shift && !Keyboard.alpha) {
+ debugKey(Key.ZOOM_MODE, released);
+ } else {
+ debugKey(Key.NONE, released);
+ }
+ break;
+ case KeyboardJogampValues.VK_SHIFT:
+ case KeyboardAWTValues.VK_SHIFT:
+ debugKey(Key.SHIFT, released);
+ break;
+ case KeyboardAWTValues.VK_CONTROL:
+ debugKey(Key.ALPHA, released);
+ break;
+ case KeyboardJogampValues.VK_NUMPAD1:
+ case KeyboardAWTValues.VK_NUMPAD1:
+ debugKey(Key.SQRT, released);
+ break;
+ case KeyboardJogampValues.VK_NUMPAD2:
+ case KeyboardAWTValues.VK_NUMPAD2:
+ debugKey(Key.ROOT, released);
+ break;
+ case KeyboardJogampValues.VK_NUMPAD3:
+ case KeyboardAWTValues.VK_NUMPAD3:
+ debugKey(Key.POWER_OF_2, released);
+ break;
+ case KeyboardJogampValues.VK_NUMPAD5:
+ case KeyboardAWTValues.VK_NUMPAD5:
+ debugKey(Key.POWER_OF_x, released);
+ break;
+ }
+ }
+
+ private synchronized static void debugKeyReleased(final int keyCode) {
+ switch (keyCode) {
+ case KeyboardAWTValues.VK_ENTER:
+ int row = 2;
+ int col = 1;
+ Keyboard.debugKeysDown[row - 1][col - 1] = false;
+ break;
+ case KeyboardJogampValues.VK_LEFT:
+ case KeyboardAWTValues.VK_LEFT:
+ //LEFT
+ row = 2;
+ col = 3;
+ Keyboard.debugKeysDown[row - 1][col - 1] = false;
+ break;
+ case KeyboardJogampValues.VK_RIGHT:
+ case KeyboardAWTValues.VK_RIGHT:
+ //RIGHT
+ row = 2;
+ col = 5;
+ Keyboard.debugKeysDown[row - 1][col - 1] = false;
+ System.out.println("RELEASE");
+ break;
+ case KeyboardJogampValues.VK_UP:
+ case KeyboardAWTValues.VK_UP:
+ //UP
+ row = 1;
+ col = 4;
+ Keyboard.debugKeysDown[row - 1][col - 1] = false;
+ break;
+ case KeyboardJogampValues.VK_DOWN:
+ case KeyboardAWTValues.VK_DOWN:
+ //DOWN
+ row = 3;
+ col = 4;
+ Keyboard.debugKeysDown[row - 1][col - 1] = false;
+ break;
+ case (short) 12:
+ //DOWN
+ row = 2;
+ col = 4;
+ Keyboard.debugKeysDown[row - 1][col - 1] = false;
+ break;
+ }
+ }
+
+ /**
+ *
+ * @param row
+ * @param col
+ * @return
+ */
+ @Deprecated
+ public static boolean isKeyDown(final int row, final int col) {
+ if (WarpPI.getPlatform().isRunningOnRaspberry()) {
+ return Keyboard.precedentStates[row - 1][col - 1];
+ } else {
+ return Keyboard.debugKeysDown[row - 1][col - 1];
+ }
+ }
+
+ static final String[][][] KeyLabelsMap = /* [ROW, COLUMN, (0:normal 1:shift 2:alpha)] */
+ { { /* ROW 0 */
+ { "⇪", "⇪", null }, /* 0,0 */
+ { "A", null, "A" }, /* 0,1 */
+ { "", null, null }, /* 0,2 */
+ { "⇧", null, null }, /* 0,3 */
+ { "", null, null }, /* 0,4 */
+ { "", null, null }, /* 0,5 */
+ { "☼", "☼", null }, /* 0,6 */
+ { "↩", null, null } /* 0,7 */
+ }, { /* ROW 1 */
+ { "", null, null }, /* 1,0 */
+ { "", null, null }, /* 1,1 */
+ { "⇦", null, null }, /* 1,2 */
+ { "OK", null, null }, /* 1,3 */
+ { "⇨", null, null }, /* 1,4 */
+ { "≪", null, null }, /* 1,5 */
+ { "≫", null, null }, /* 1,6 */
+ { "", null, null } /* 1,7 */
+ }, { /* ROW 2 */
+ { "", null, null }, /* 2,0 */
+ { "√▯", null, null }, /* 2,1 */
+ { "", null, null }, /* 2,2 */
+ { "⇩", null, null }, /* 2,3 */
+ { "↶", null, null }, /* 2,4 */
+ { "", null, null }, /* 2,5 */
+ { "", null, null }, /* 2,6 */
+ { "", null, null } /* 2,7 */
+ }, { /* ROW 3 */
+ { "", null, null }, /* 3,0 */
+ { "", null, null }, /* 3,1 */
+ { "▯^▯", null, null }, /* 3,2 */
+ { "▯^2", null, null }, /* 3,3 */
+ { "", null, null }, /* 3,4 */
+ { "", null, null }, /* 3,5 */
+ { "", null, null }, /* 3,6 */
+ { ".", null, "y" } /* 3,7 */
+ }, { /* ROW 4 */
+ { "", null, null }, /* 4,0 */
+ { "", null, null }, /* 4,1 */
+ { "(▯)", null, null }, /* 4,2 */
+ { ")", null, null }, /* 4,3 */
+ { "", null, null }, /* 4,4 */
+ { "S⇔D", null, null }, /* 4,5 */
+ { "", null, null }, /* 4,6 */
+ { "0", null, "x" } /* 4,7 */
+ }, { /* ROW 5 */
+ { "7", null, null }, /* 5,0 */
+ { "8", null, null }, /* 5,1 */
+ { "9", null, null }, /* 5,2 */
+ { "⌫", null, null }, /* 5,3 */
+ { "RESET", null, null }, /* 5,4 */
+ { "", null, null }, /* 5,5 */
+ { "", null, null }, /* 5,6 */
+ { "", null, null } /* 5,7 */
+ }, { /* ROW 6 */
+ { "4", null, null }, /* 6,0 */
+ { "5", null, null }, /* 6,1 */
+ { "6", null, null }, /* 6,2 */
+ { "*", null, null }, /* 6,3 */
+ { "/", null, null }, /* 6,4 */
+ { "", null, null }, /* 6,5 */
+ { "", null, null }, /* 6,6 */
+ { "", null, null } /* 6,7 */
+ }, { /* ROW 7 */
+ { "1", null, null }, /* 7,0 */
+ { "2", null, null }, /* 7,1 */
+ { "3", null, null }, /* 7,2 */
+ { "+", null, null }, /* 7,3 */
+ { "-", null, null }, /* 7,4 */
+ { "", null, null }, /* 7,5 */
+ { "", null, null }, /* 7,6 */
+ { "", null, null } /* 7,7 */
+ } };
+
+ static final Key[][][] keyMap = /* [ROW, COLUMN, (0:normal 1:shift 2:alpha)] */
+ { { /* ROW 0 */
+ { Key.SHIFT, Key.SHIFT, Key.SHIFT }, /* 0,0 */
+ { Key.ALPHA, Key.ALPHA, Key.ALPHA }, /* 0,1 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 0,2 */
+ { Key.UP, Key.NONE, Key.NONE }, /* 0,3 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 0,4 */
+ { Key.SETTINGS, Key.NONE, Key.NONE }, /* 0,5 */
+ { Key.BRIGHTNESS_CYCLE, Key.BRIGHTNESS_CYCLE_REVERSE, Key.ZOOM_MODE }, /* 0,6 */
+ { Key.SIMPLIFY, Key.STEP, Key.NONE } /* 0,7 */
+ }, { /* ROW 1 */
+ { Key.F4, Key.F4, Key.F4 }, /* 1,0 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 1,1 */
+ { Key.LEFT, Key.NONE, Key.NONE }, /* 1,2 */
+ { Key.OK, Key.NONE, Key.NONE }, /* 1,3 */
+ { Key.RIGHT, Key.NONE, Key.NONE }, /* 1,4 */
+ { Key.HISTORY_BACK, Key.NONE, Key.NONE }, /* 1,5 */
+ { Key.HISTORY_FORWARD, Key.NONE, Key.NONE }, /* 1,6 */
+ { Key.NONE, Key.PI, Key.DRG_CYCLE } /* 1,7 */
+ }, { /* ROW 2 */
+ { Key.F3, Key.F3, Key.F3 }, /* 2,0 */
+ { Key.SQRT, Key.ROOT, Key.NONE }, /* 2,1 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 2,2 */
+ { Key.DOWN, Key.NONE, Key.NONE }, /* 2,3 */
+ { Key.BACK, Key.NONE, Key.NONE }, /* 2,4 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 2,5 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 2,6 */
+ { Key.NONE, Key.NONE, Key.LETTER_Z } /* 2,7 */
+ }, { /* ROW 3 */
+ { Key.F2, Key.F2, Key.F2 }, /* 3,0 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 3,1 */
+ { Key.POWER_OF_x, Key.NONE, Key.NONE }, /* 3,2 */
+ { Key.POWER_OF_2, Key.NONE, Key.NONE }, /* 3,3 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 3,4 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 3,5 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 3,6 */
+ { Key.DOT, Key.NONE, Key.LETTER_Y } /* 3,7 */
+ }, { /* ROW 4 */
+ { Key.F1, Key.F1, Key.F1 }, /* 4,0 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 4,1 */
+ { Key.PARENTHESIS_OPEN, Key.NONE, Key.NONE }, /* 4,2 */
+ { Key.PARENTHESIS_CLOSE, Key.NONE, Key.NONE }, /* 4,3 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 4,4 */
+ { Key.SURD_MODE, Key.NONE, Key.NONE }, /* 4,5 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 4,6 */
+ { Key.NUM0, Key.NONE, Key.LETTER_X } /* 4,7 */
+ }, { /* ROW 5 */
+ { Key.NUM7, Key.NONE, Key.NONE }, /* 5,0 */
+ { Key.NUM8, Key.NONE, Key.NONE }, /* 5,1 */
+ { Key.NUM9, Key.NONE, Key.NONE }, /* 5,2 */
+ { Key.DELETE, Key.NONE, Key.NONE }, /* 5,3 */
+ { Key.RESET, Key.NONE, Key.NONE }, /* 5,4 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 5,5 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 5,6 */
+ { Key.NONE, Key.NONE, Key.NONE } /* 5,7 */
+ }, { /* ROW 6 */
+ { Key.NUM4, Key.NONE, Key.NONE }, /* 6,0 */
+ { Key.NUM5, Key.NONE, Key.NONE }, /* 6,1 */
+ { Key.NUM6, Key.NONE, Key.NONE }, /* 6,2 */
+ { Key.MULTIPLY, Key.NONE, Key.NONE }, /* 6,3 */
+ { Key.DIVIDE, Key.NONE, Key.NONE }, /* 6,4 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 6,5 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 6,6 */
+ { Key.NONE, Key.NONE, Key.NONE } /* 6,7 */
+ }, { /* ROW 7 */
+ { Key.NUM1, Key.NONE, Key.NONE }, /* 7,0 */
+ { Key.NUM2, Key.NONE, Key.NONE }, /* 7,1 */
+ { Key.NUM3, Key.NONE, Key.NONE }, /* 7,2 */
+ { Key.PLUS, Key.PLUS_MINUS, Key.NONE }, /* 7,3 */
+ { Key.MINUS, Key.NONE, Key.NONE }, /* 7,4 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 7,5 */
+ { Key.NONE, Key.NONE, Key.NONE }, /* 7,6 */
+ { Key.NONE, Key.NONE, Key.NONE } /* 7,7 */
+ } };
+
+ public static String getKeyName(final int row, final int col) {
+ return Keyboard.getKeyName(row, col, Keyboard.shift, Keyboard.alpha);
+ }
+
+ public static String getKeyName(final int row, final int col, final boolean shift, final boolean alpha) {
+ final String[] keyValues = Keyboard.KeyLabelsMap[row][col];
+ if (shift) {
+ if (keyValues[1] != null) {
+ return keyValues[1];
+ }
+ } else if (alpha) {
+ if (keyValues[2] != null) {
+ return keyValues[2];
+ }
+ }
+ return keyValues[0];
+ }
+
+ public static boolean hasKeyName(final int row, final int col) {
+ final String[] keyValues = Keyboard.KeyLabelsMap[row][col];
+ if (Keyboard.shift) {
+ return keyValues[1] != null;
+ } else if (Keyboard.alpha) {
+ return keyValues[2] != null;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ *
+ * @param row
+ * @param col
+ * @param released true: released, false: pressed
+ */
+ public static synchronized void keyRaw(final int row, final int col, final boolean released) {
+// KeyboardDebugScreen.keyX = row;
+// KeyboardDebugScreen.keyY = col;
+ final Key k = Keyboard.keyMap[row][col][Keyboard.shift ? 1 : Keyboard.alpha ? 2 : 0];
+ if (k != null) {
+ if (released) {
+ Keyboard.keyReleased(k);
+ } else {
+ Keyboard.keyPressed(k);
+ }
+ } else {
+ if (released) {
+ Keyboard.keyReleased(Key.NONE);
+ } else {
+ Keyboard.keyPressed(Key.NONE);
+ }
+ }
+ }
+
+ public static void stopKeyboard() {
+ if (WarpPI.getPlatform().isRunningOnRaspberry()) {
+ WarpPI.getPlatform().getGpio().digitalWrite(33, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(35, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(36, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(37, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(38, false);
+ WarpPI.getPlatform().getGpio().digitalWrite(40, false);
+ }
+ }
+
+ public synchronized static void keyPressed(final Key k) {
+ boolean done = false;
+ if (Keyboard.additionalListener != null) {
+ try {
+ done = Keyboard.additionalListener.onKeyPressed(new KeyPressedEvent(k));
+ } catch (final Exception ex) {
+ new GUIErrorMessage(ex);
+ }
+ }
+ if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
+ final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
+ boolean refresh = false;
+ boolean scrdone = false;
+ try {
+ scrdone = scr.onKeyPressed(new KeyPressedEvent(k));
+ } catch (final Exception ex) {
+ new GUIErrorMessage(ex);
+ }
+ if (scr != null && scr.initialized && scrdone) {
+ refresh = true;
+ } else {
+ switch (k) {
+ case POWEROFF:
+ WarpPI.INSTANCE.getHardwareDevice().getDeviceStateDevice().powerOff();
+ break;
+ case NONE:
+ break;
+ case BRIGHTNESS_CYCLE:
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new TetrisScreen()); //TODO: rimuovere: prova
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(false);
+ refresh = true;
+ break;
+ case BRIGHTNESS_CYCLE_REVERSE:
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().cycleBrightness(true);
+ refresh = true;
+ break;
+ case ZOOM_MODE:
+ final float newZoom = StaticVars.windowZoom.getLastValue() % 3 + 1;
+ StaticVars.windowZoom.onNext(newZoom);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom);
+// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
+ refresh = true;
+ break;
+ case HISTORY_BACK:
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().goBack();
+ refresh = true;
+ break;
+ case HISTORY_FORWARD:
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().goForward();
+ refresh = true;
+ break;
+ case BACK:
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Closing current screen.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().closeScreen();
+ refresh = true;
+ break;
+ default:
+ break;
+ }
+ }
+ switch (k) {
+ case SHIFT:
+ if (Keyboard.alpha) {
+ WarpPI.getPlatform().alphaChanged(Keyboard.alpha = false);
+ }
+ WarpPI.getPlatform().shiftChanged(Keyboard.shift = !Keyboard.shift);
+ refresh = true;
+ break;
+ case ALPHA:
+ if (Keyboard.shift) {
+ WarpPI.getPlatform().shiftChanged(Keyboard.shift = false);
+ }
+ WarpPI.getPlatform().alphaChanged(Keyboard.alpha = !Keyboard.alpha);
+ refresh = true;
+ break;
+ default:
+ if (k != Key.NONE) {
+ if (Keyboard.shift) {
+ WarpPI.getPlatform().shiftChanged(Keyboard.shift = false);
+ }
+ if (Keyboard.alpha) {
+ WarpPI.getPlatform().alphaChanged(Keyboard.alpha = false);
+ }
+ }
+ break;
+ }
+ if (refresh) {
+ Keyboard.refreshRequest = true;
+ }
+ } else if (!done) {
+ WarpPI.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
+ }
+ }
+
+ public synchronized static void keyReleased(final Key k) {
+ boolean done = false;
+ if (Keyboard.additionalListener != null) {
+ done = Keyboard.additionalListener.onKeyReleased(new KeyReleasedEvent(k));
+ }
+ boolean refresh = false;
+ if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager() != null) {
+ final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
+ if (scr != null && scr.initialized && scr.onKeyReleased(new KeyReleasedEvent(k))) {
+ refresh = true;
+ } else {
+ switch (k) {
+ case NONE:
+ break;
+ default:
+ break;
+ }
+ }
+ if (refresh) {
+ Keyboard.refreshRequest = true;
+ }
+ } else if (!done) {
+ WarpPI.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
+ }
+ }
+
+ public void setAdditionalKeyboardListener(final KeyboardEventListener l) {
+ Keyboard.additionalListener = l;
+ }
+
+ public static boolean popRefreshRequest() {
+ if (Keyboard.refreshRequest) {
+ Keyboard.refreshRequest = false;
+ return true;
+ }
+ return false;
+ }
+
+}
+
+/*
+
+
+
+Keyboard:
+ Example button:
+ |ROW,COLUMN----|
+ | NORMAL STATE |
+ | SHIFT STATE |
+ | ALPHA STATE |
+ |--------------|
+
+ Physical keyboard:
+ |0,0-----|0,1-----|########|0,3-----|########|0,5-----|0,6-----|
+ | SHIFT | ALPHA |########| ^ |########|SETTINGS|+BRIGHT |
+ | NORMAL | ALPHA |########| |########| |-BRIGHT |
+ | SHIFT | NORMAL |########| |########| |ZOOMMODE|
+ |1,0-----|1,1-----|1,2-----|1,3-----|1,4-----|1,5-----|1,6-----|
+ | F_4 | | < | OK | > | Back | Fwd |
+ | F_4 | | | | | | |
+ | F_4 | | | | | | |
+ |2,0-----|2,1-----|--------|2,3-----|--------|2,5-----|2,6-----|
+ | F_3 | SQRT |########| v | BACK | | |
+ | F_3 | ROOT |########| | | | |
+ | F_3 | |########| | | | |
+ |3,0-----|3,1-----|3,2-----|3,3-----|3,4-----|3,5-----|3,6-----|
+ | F_2 | | POW x | POW 2 | | | |
+ | F_2 | | | | | | |
+ | F_2 | | | | | | |
+ |4,0-----|4,1-----|4,2-----|4,3-----|4,4-----|4,5-----|4,6-----|
+ | F_1 | | ( | ) | | S<=>D | |
+ | F_1 | | | | | | |
+ | F_1 | | | | | | |
+ |5,0-----|5,1-----|5,2-----|5,3-----|5,4-----|5,5-----|5,6-----|
+ | 7 | 8 | 9 | DEL | RESET |
+ | | | | | |
+ | | | | | |
+ |6,0-----|6,1-----|6,2-----|6,3-----|6,4-----------------------|
+ | 4 | 5 | 6 | * | / |
+ | | | | | |
+ | | | | | |
+ |7,0-----|7,1-----|7,2-----|7,3-----|7,4-----------------------|
+ | 1 | 2 | 3 | + | - |
+ | | | | | |
+ | | | | | |
+ |4,7-----|3,7-----|2,7-----|1,7-----|0,7-----------------------|
+ | 0 | . | | | SIMPLIFY |
+ | | | |PI | STEP |
+ | X | Y | Z |DRG CYCL| |
+ |--------|--------|--------|--------|--------------------------|
+
+SCREEN F_n:
+ MathInputScreen:
+ Default:
+ [F_1] Normal: Solve for X Shift: Solve for _ Alpha:
+ [F_2] Normal: Shift: Alpha:
+ [F_3] Normal: Variables & constants Shift: Alpha:
+ [F_4] Normal: Functions f(x) Shift: Alpha:
+ Variable popup:
+ [F_1] Normal(if constant):Set value Shift: Alpha:
+ [F_2] Normal: Shift: Alpha:
+ [F_3] Normal: Shift: Alpha:
+ [F_4] Normal: Shift: Alpha:
+ MarioScreen
+ [F_1] Normal: Shift: Alpha:
+ [F_2] Normal: Shift: Alpha:
+ [F_3] Normal: Shift: Alpha:
+ [F_4] Normal: Shift: Alpha:
+ ChooseVariableValueScreen
+ [F_1] Normal: Shift: Alpha:
+ [F_2] Normal: Shift: Alpha:
+ [F_3] Normal: Shift: Alpha:
+ [F_4] Normal: Shift: Alpha:
+ SolveForXScreen
+ [F_1] Normal: Shift: Alpha:
+ [F_2] Normal: Shift: Alpha:
+ [F_3] Normal: Shift: Alpha:
+ [F_4] Normal: Shift: Alpha:
*/
\ No newline at end of file
diff --git a/core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java b/core/src/main/java/it/cavallium/warppi/device/input/KeyboardAWTValues.java
similarity index 99%
rename from core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java
rename to core/src/main/java/it/cavallium/warppi/device/input/KeyboardAWTValues.java
index 083d0531..52f35b13 100644
--- a/core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java
+++ b/core/src/main/java/it/cavallium/warppi/device/input/KeyboardAWTValues.java
@@ -1,4 +1,4 @@
-package it.cavallium.warppi.device;
+package it.cavallium.warppi.device.input;
public interface KeyboardAWTValues {
diff --git a/core/src/main/java/it/cavallium/warppi/device/input/KeyboardInputDevice.java b/core/src/main/java/it/cavallium/warppi/device/input/KeyboardInputDevice.java
new file mode 100644
index 00000000..47af2687
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/input/KeyboardInputDevice.java
@@ -0,0 +1,7 @@
+package it.cavallium.warppi.device.input;
+
+public interface KeyboardInputDevice {
+
+ void initialize();
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/KeyboardJogampValues.java b/core/src/main/java/it/cavallium/warppi/device/input/KeyboardJogampValues.java
similarity index 96%
rename from core/src/main/java/it/cavallium/warppi/device/KeyboardJogampValues.java
rename to core/src/main/java/it/cavallium/warppi/device/input/KeyboardJogampValues.java
index 1cfe22e3..954327b1 100644
--- a/core/src/main/java/it/cavallium/warppi/device/KeyboardJogampValues.java
+++ b/core/src/main/java/it/cavallium/warppi/device/input/KeyboardJogampValues.java
@@ -1,4 +1,4 @@
-package it.cavallium.warppi.device;
+package it.cavallium.warppi.device.input;
public interface KeyboardJogampValues {
diff --git a/core/src/main/java/it/cavallium/warppi/device/input/NullTouchInputDevice.java b/core/src/main/java/it/cavallium/warppi/device/input/NullTouchInputDevice.java
new file mode 100644
index 00000000..ba5106cf
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/input/NullTouchInputDevice.java
@@ -0,0 +1,41 @@
+package it.cavallium.warppi.device.input;
+
+import java.util.function.Consumer;
+
+import it.cavallium.warppi.event.TouchEvent;
+import it.cavallium.warppi.event.TouchPoint;
+
+public class NullTouchInputDevice implements TouchInputDevice {
+
+ @Override
+ public boolean getSwappedAxes() {
+ return false;
+ }
+
+ @Override
+ public boolean getInvertedX() {
+ return false;
+ }
+
+ @Override
+ public boolean getInvertedY() {
+ return false;
+ }
+
+ @Override
+ public void listenTouchEvents(Consumer touchEventListener) {
+
+ }
+
+ @Override
+ public void initialize() {
+
+ }
+
+ @Override
+ public TouchPoint makePoint(long id, float x, float y, int maxX, int maxY, float radiusX, float radiusY,
+ float force, float rotationAngle) {
+ return new TouchPoint(id, maxX, maxY, radiusX, radiusY, force, rotationAngle);
+ }
+
+}
diff --git a/core/src/main/java/it/cavallium/warppi/device/input/TouchInputDevice.java b/core/src/main/java/it/cavallium/warppi/device/input/TouchInputDevice.java
new file mode 100644
index 00000000..2aa6bb78
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/device/input/TouchInputDevice.java
@@ -0,0 +1,43 @@
+package it.cavallium.warppi.device.input;
+
+import java.util.concurrent.Flow.Subscriber;
+import java.util.function.Consumer;
+
+import it.cavallium.warppi.event.TouchEvent;
+import it.cavallium.warppi.event.TouchEventListener;
+import it.cavallium.warppi.event.TouchPoint;
+
+public interface TouchInputDevice {
+ boolean getSwappedAxes();
+
+ boolean getInvertedX();
+
+ boolean getInvertedY();
+
+ default void setInvertedXY() {}
+
+ default void setInvertedX() {}
+
+ default void setInvertedY() {}
+
+ void listenTouchEvents(Consumer touchEventListener);
+
+ default TouchPoint makePoint(final long id, float x, float y, final int screenWidth, final int screenHeight,
+ final float radiusX, final float radiusY, final float force, final float rotationAngle) {
+ if (getSwappedAxes()) {
+ final double oldX = x;
+ final double oldY = y;
+ x = (float) (oldY * screenWidth / screenHeight);
+ y = (float) (oldX * screenHeight / screenWidth);
+ }
+ if (getInvertedX()) {
+ x = screenWidth - x;
+ }
+ if (getInvertedY()) {
+ y = screenHeight - y;
+ }
+ return new TouchPoint(id, x, y, radiusX, radiusY, force, rotationAngle);
+ }
+
+ void initialize();
+}
diff --git a/core/src/main/java/it/cavallium/warppi/extra/mario/MarioScreen.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioScreen.java
index a7a310f1..a4a32ca2 100644
--- a/core/src/main/java/it/cavallium/warppi/extra/mario/MarioScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioScreen.java
@@ -2,10 +2,11 @@ package it.cavallium.warppi.extra.mario;
import java.io.IOException;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Platform.ConsoleUtils;
-import it.cavallium.warppi.device.Keyboard;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent;
import it.cavallium.warppi.gui.HistoryBehavior;
@@ -48,30 +49,30 @@ public class MarioScreen extends Screen {
public void graphicInitialized() {
try {
if (MarioScreen.skin == null) {
- MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioskin.png");
+ MarioScreen.skin = d.display.getGraphicEngine().loadSkin("/marioskin.png");
}
if (MarioScreen.groundskin == null) {
- MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioground.png");
+ MarioScreen.groundskin = d.display.getGraphicEngine().loadSkin("/marioground.png");
}
if (MarioScreen.gpuTest2 == null) {
try {
- MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest2");
+ MarioScreen.gpuTest2 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest2");
} catch (final Exception ex) {}
}
if (MarioScreen.gpuTest1 == null) {
try {
- MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest12");
+ MarioScreen.gpuTest1 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest12");
MarioScreen.gpuTest12 = true;
} catch (final Exception ex) {
MarioScreen.gpuTest12 = false;
try {
- MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest1");
+ MarioScreen.gpuTest1 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest1");
} catch (final Exception ex2) {}
}
}
if (MarioScreen.gpuTest3 == null) {
try {
- MarioScreen.gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("N:\\gputest\\font_gputest3.png");
+ MarioScreen.gpuTest3 = d.display.getGraphicEngine().loadSkin("N:\\gputest\\font_gputest3.png");
} catch (final Exception ex) {
ex.printStackTrace();
}
@@ -85,30 +86,30 @@ public class MarioScreen extends Screen {
public void initialized() {
try {
if (MarioScreen.skin == null) {
- MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioskin.png");
+ MarioScreen.skin = d.display.getGraphicEngine().loadSkin("/marioskin.png");
}
if (MarioScreen.groundskin == null) {
- MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioground.png");
+ MarioScreen.groundskin = d.display.getGraphicEngine().loadSkin("/marioground.png");
}
if (MarioScreen.gpuTest2 == null) {
try {
- MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest2");
+ MarioScreen.gpuTest2 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest2");
} catch (final Exception ex) {}
}
if (MarioScreen.gpuTest1 == null) {
try {
- MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest12");
+ MarioScreen.gpuTest1 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest12");
MarioScreen.gpuTest12 = true;
} catch (final Exception ex) {
MarioScreen.gpuTest12 = false;
try {
- MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("N:\\gputest\\gputest1");
+ MarioScreen.gpuTest1 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest1");
} catch (final Exception ex2) {}
}
}
if (MarioScreen.gpuTest3 == null) {
try {
- MarioScreen.gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("N:\\gputest\\font_gputest3.png");
+ MarioScreen.gpuTest3 = d.display.getGraphicEngine().loadSkin("N:\\gputest\\font_gputest3.png");
} catch (final Exception ex) {
ex.printStackTrace();
}
@@ -182,24 +183,25 @@ public class MarioScreen extends Screen {
gpuCharTestt1Elapsed -= 1.5;
}
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
+ d.renderer.glClearColor(0xff000000);
}
}
@Override
public void render() {
+ DisplayOutputDevice display = d.display;
if (errored) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR");
+ d.renderer.glDrawStringLeft(0, 20, "ERROR");
} else {
if (MarioScreen.groundskin != null) {
final double playerX = g.getPlayer().getX();
final double playerY = g.getPlayer().getY();
- MarioScreen.groundskin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ MarioScreen.groundskin.use(d.display);
final MarioWorld w = g.getCurrentWorld();
final int width = w.getWidth();
final int height = w.getHeight();
- final float screenX = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() / 2f - 8f;
- final float screenY = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2f - 8f;
+ final float screenX = d.display.getGraphicEngine().getWidth() / 2f - 8f;
+ final float screenY = d.display.getGraphicEngine().getHeight() / 2f - 8f;
final float shiftX = -8 + 16 * (float) playerX;
final float shiftY = -8 + 16 * (height - (float) playerY);
int blue = -1;
@@ -212,59 +214,59 @@ public class MarioScreen extends Screen {
if (b == 0) {
if (blue != 1) {
blue = 1;
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xff9290ff);
+ d.renderer.glColor(0xff9290ff);
}
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
+ d.renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
} else {
if (blue != 0) {
blue = 0;
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
+ d.renderer.glColor(0xffffffff);
}
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
+ d.renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
}
}
}
}
if (blue != 0) {
blue = 0;
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
+ d.renderer.glColor(0xffffffff);
}
//DRAW MARIO
- MarioScreen.skin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - (g.getPlayer().flipped ? 3 : 0), screenY, 35, 27, 35 * (g.getPlayer().marioSkinPos[0] + (g.getPlayer().flipped ? 2 : 1)), 27 * g.getPlayer().marioSkinPos[1], 35 * (g.getPlayer().flipped ? -1 : 1), 27);
+ MarioScreen.skin.use(d.display);
+ d.renderer.glFillRect(screenX - (g.getPlayer().flipped ? 3 : 0), screenY, 35, 27, 35 * (g.getPlayer().marioSkinPos[0] + (g.getPlayer().flipped ? 2 : 1)), 27 * g.getPlayer().marioSkinPos[1], 35 * (g.getPlayer().flipped ? -1 : 1), 27);
// PIDisplay.renderer.glDrawSkin(getPosX() - 18, 25 + getPosY(), 35 * (marioSkinPos[0] + (flipped ? 2 : 1)), 27 * marioSkinPos[1], 35 * (marioSkinPos[0] + (flipped ? 1 : 2)), 27 * (marioSkinPos[1] + 1), true);
}
// GPU PERFORMANCE TEST
if (MarioScreen.gpuTest1 != null) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(1, 1, 1);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - (MarioScreen.gpuTest12 ? 512 : 256), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), MarioScreen.gpuTest12 ? 512 : 256, MarioScreen.gpuTest12 ? 512 : 256);
- MarioScreen.gpuTest1.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(0, 0, 0);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth(), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
+ d.renderer.glColor3f(1, 1, 1);
+ d.renderer.glFillColor(d.display.getGraphicEngine().getWidth() - (MarioScreen.gpuTest12 ? 512 : 256), d.display.getGraphicEngine().getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), MarioScreen.gpuTest12 ? 512 : 256, MarioScreen.gpuTest12 ? 512 : 256);
+ MarioScreen.gpuTest1.use(d.display);
+ d.renderer.glColor3f(0, 0, 0);
+ d.renderer.glDrawStringRight(d.display.getGraphicEngine().getWidth(), d.display.getGraphicEngine().getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
}
if (MarioScreen.gpuTest3 != null) {
- MarioScreen.gpuTest3.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
+ MarioScreen.gpuTest3.use(d.display);
+ d.renderer.glColor4f(1, 1, 1, 0.7f);
+ d.renderer.glFillRect(0, display.getDisplaySize()[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
}
if (MarioScreen.gpuTest2 != null) {
- MarioScreen.gpuTest2.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF000000);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "A");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF800000);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "B");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeea28e);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "C");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFee7255);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "D");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeac0b0);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "E");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFf3d8ce);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "F");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFffede7);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "G");
+ MarioScreen.gpuTest2.use(d.display);
+ d.renderer.glColor(0xFF000000);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "A");
+ d.renderer.glColor(0xFF800000);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "B");
+ d.renderer.glColor(0xFFeea28e);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "C");
+ d.renderer.glColor(0xFFee7255);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "D");
+ d.renderer.glColor(0xFFeac0b0);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "E");
+ d.renderer.glColor(0xFFf3d8ce);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "F");
+ d.renderer.glColor(0xFFffede7);
+ d.renderer.glDrawStringRight(display.getDisplaySize()[0], d.display.getGraphicEngine().getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "G");
}
}
}
diff --git a/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java b/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java
index 938775bc..9e3ca336 100644
--- a/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/extra/tetris/TetrisScreen.java
@@ -2,14 +2,14 @@ package it.cavallium.warppi.extra.tetris;
import java.io.IOException;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent;
import it.cavallium.warppi.gui.HistoryBehavior;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.screens.Screen;
@@ -30,7 +30,7 @@ public class TetrisScreen extends Screen {
private ButtonInfo backPressed = new ButtonInfo();
- private GraphicEngine e;
+ private DisplayOutputDevice e;
private Renderer r;
@@ -49,10 +49,10 @@ public class TetrisScreen extends Screen {
@Override
public void graphicInitialized() {
try {
- e = d.engine;
+ e = d.display;
r = d.renderer;
if (TetrisScreen.skin == null) {
- TetrisScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/tetrisskin.png");
+ TetrisScreen.skin = d.display.getGraphicEngine().loadSkin("/tetrisskin.png");
}
} catch (final IOException e) {
e.printStackTrace();
@@ -66,21 +66,22 @@ public class TetrisScreen extends Screen {
@Override
public void beforeRender(final float dt) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
+ d.renderer.glClearColor(0xff000000);
g.update(dt, leftPressed, rightPressed, downPressed, upPressed, okPressed, backPressed);
}
@Override
public void render() {
+ DisplayOutputDevice display = d.display;
if (TetrisScreen.skin != null) {
TetrisScreen.skin.use(e);
}
r.glColor3f(1, 1, 1);
BlockColor[] renderedGrid = g.getRenderedGrid();
- int centerScreen = StaticVars.screenSize[0]/2;
+ int centerScreen = display.getDisplaySize()[0]/2;
int centerGrid = TetrisGame.WIDTH*6/2-1;
final int leftOffset = centerScreen - centerGrid;
- final int topOffset = StaticVars.screenSize[1] - TetrisGame.HEIGHT*6-1;
+ final int topOffset = display.getDisplaySize()[1] - TetrisGame.HEIGHT*6-1;
for (int y = 0; y < TetrisGame.HEIGHT; y++) {
for (int x = 0; x < TetrisGame.WIDTH; x++) {
final int offset = x+y*TetrisGame.WIDTH;
diff --git a/core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java b/core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java
index 921c32ce..2c8778fa 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java
@@ -1,8 +1,9 @@
package it.cavallium.warppi.gui;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.Skin;
@@ -39,7 +40,8 @@ public class CalculatorHUD extends HUD {
@Override
public void renderTopmostBackground() {
final Renderer r = d.renderer;
- final GraphicEngine engine = d.engine;
+ final DisplayOutputDevice display = d.display;
+ final GraphicEngine engine = display.getGraphicEngine();
r.glColor(0xFFc5c2af);
r.glFillColor(0, 0, engine.getWidth(), 20);
@@ -48,14 +50,15 @@ public class CalculatorHUD extends HUD {
@Override
public void renderTopmost() {
final Renderer r = d.renderer;
- final GraphicEngine engine = d.engine;
+ final DisplayOutputDevice display = d.display;
+ final GraphicEngine engine = display.getGraphicEngine();
final Skin guiSkin = d.guiSkin;
//DRAW TOP
r.glColor3i(0, 0, 0);
r.glDrawLine(0, 20, engine.getWidth() - 1, 20);
r.glColor3i(255, 255, 255);
- guiSkin.use(engine);
+ guiSkin.use(display);
if (Keyboard.shift) {
r.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 2, 16 * 0, 16, 16);
} else {
@@ -69,31 +72,31 @@ public class CalculatorHUD extends HUD {
int padding = 2;
- final int brightness = (int) Math.ceil(Engine.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9);
+ final int brightness = (int) Math.ceil(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9);
if (brightness <= 10) {
- r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
+ r.glFillRect(display.getDisplaySize()[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
} else {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
+ WarpPI.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
}
padding += 18 + 6;
- final boolean canGoBack = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack();
- final boolean canGoForward = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward();
+ final boolean canGoBack = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack();
+ final boolean canGoForward = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward();
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
- r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
+ r.glFillRect(display.getDisplaySize()[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
padding += 18 + 6;
}
if (canGoBack && canGoForward) {
- r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
+ r.glFillRect(display.getDisplaySize()[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
} else if (canGoBack) {
- r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
+ r.glFillRect(display.getDisplaySize()[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
} else if (canGoForward) {
- r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
+ r.glFillRect(display.getDisplaySize()[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
} else {
- r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
+ r.glFillRect(display.getDisplaySize()[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
}
padding += 18;
@@ -101,23 +104,23 @@ public class CalculatorHUD extends HUD {
//DRAW BOTTOM
r.glDrawStringLeft(2, 90, d.displayDebugString);
- Utils.getFont(true, false).use(engine);
+ Utils.getFont(true, false).use(display);
r.glColor4i(255, 0, 0, 40);
- r.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
+ r.glDrawStringLeft(1 + 1, display.getDisplaySize()[1] - 7 - 7 + 1, "WORK IN");
r.glColor4i(255, 0, 0, 80);
- r.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
+ r.glDrawStringLeft(1, display.getDisplaySize()[1] - 7 - 7, "WORK IN");
r.glColor4i(255, 0, 0, 40);
- r.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
+ r.glDrawStringLeft(1 + 1, display.getDisplaySize()[1] - 7 + 1, "PROGRESS.");
r.glColor4i(255, 0, 0, 80);
- r.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
+ r.glDrawStringLeft(1, display.getDisplaySize()[1] - 7, "PROGRESS.");
int currentDebugLine = 2;
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
ObjectArrayList allSessions = new ObjectArrayList<>();
- for (Screen session : Engine.INSTANCE.getHardwareDevice().getDisplayManager().sessions) {
+ for (Screen session : WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().sessions) {
allSessions.add(0, session);
}
- Screen curScreen = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
+ Screen curScreen = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
if (curScreen.historyBehavior == HistoryBehavior.DONT_KEEP_IN_HISTORY) {
allSessions.add(curScreen);
}
@@ -126,7 +129,7 @@ public class CalculatorHUD extends HUD {
if (session != null) {
String title = session.getSessionTitle();
if (title != null && title.length() > 0) {
- Utils.getFont(true).use(engine);
+ Utils.getFont(true).use(display);
if (session.historyBehavior == HistoryBehavior.DONT_KEEP_IN_HISTORY) {
r.glColor(0xFF3333FF);
} else if (session.historyBehavior == HistoryBehavior.ALWAYS_KEEP_IN_HISTORY) {
@@ -134,19 +137,19 @@ public class CalculatorHUD extends HUD {
} else {
r.glColor(0xFF990000);
}
- r.glDrawStringLeft(0, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "[" + String.format("%1$03d", session.debugScreenID) + "] " + title.toUpperCase());
- if (session == Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen()) {
+ r.glDrawStringLeft(0, display.getDisplaySize()[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "[" + String.format("%1$03d", session.debugScreenID) + "] " + title.toUpperCase());
+ if (session == WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen()) {
r.glColor(0xFF00CC00);
} else {
r.glColor(0xFF990000);
}
- r.glDrawStringLeft(0, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), " " + title.toUpperCase());
+ r.glDrawStringLeft(0, display.getDisplaySize()[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), " " + title.toUpperCase());
}
currentDebugLine++;
}
}
r.glColor(0xFF000000);
- r.glDrawStringLeft(5, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "DEBUG ENABLED");
+ r.glDrawStringLeft(5, display.getDisplaySize()[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "DEBUG ENABLED");
}
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java
index 502e90a6..ed246226 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java
@@ -4,10 +4,20 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.Flow.Subscriber;
+import java.util.function.Consumer;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.Platform.Semaphore;
+import it.cavallium.warppi.device.display.BacklightOutputDevice;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.Keyboard;
+import it.cavallium.warppi.event.TouchCancelEvent;
+import it.cavallium.warppi.event.TouchEndEvent;
+import it.cavallium.warppi.event.TouchEvent;
+import it.cavallium.warppi.event.TouchMoveEvent;
+import it.cavallium.warppi.event.TouchStartEvent;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
@@ -26,8 +36,9 @@ public final class DisplayManager implements RenderingLoop {
private float brightness;
- public final GraphicEngine engine;
- public final HardwareDisplay monitor;
+ public final DisplayOutputDevice display;
+ public final GraphicEngine graphicEngine;
+ public final BacklightOutputDevice backlight;
public final boolean supportsPauses;
public Renderer renderer;
@@ -50,15 +61,16 @@ public final class DisplayManager implements RenderingLoop {
*/
public boolean forceRefresh;
- public DisplayManager(final HardwareDisplay monitor, final HUD hud, final Screen screen, final String title) {
- this.monitor = monitor;
+ public DisplayManager(final DisplayOutputDevice display, final BacklightOutputDevice backlight, final HUD hud, final Screen screen, final String title) {
+ this.display = display;
+ this.graphicEngine = display.getGraphicEngine();
+ this.backlight = backlight;
this.hud = hud;
initialTitle = title;
initialScreen = screen;
- screenChange = Engine.getPlatform().newSemaphore();
- engine = chooseGraphicEngine();
- supportsPauses = engine.doesRefreshPauses();
+ screenChange = WarpPI.getPlatform().newSemaphore();
+ supportsPauses = graphicEngine.doesRefreshPauses();
glyphsHeight = new int[] { 9, 6, 12, 9 };
displayDebugString = "";
@@ -66,8 +78,6 @@ public final class DisplayManager implements RenderingLoop {
}
public void initialize() {
- monitor.initialize();
-
try {
hud.d = this;
hud.create();
@@ -76,18 +86,17 @@ public final class DisplayManager implements RenderingLoop {
}
} catch (final Exception e) {
e.printStackTrace();
- Engine.getPlatform().exit(0);
+ WarpPI.getPlatform().exit(0);
}
try {
- engine.create();
- renderer = engine.getRenderer();
- engine.setTitle(initialTitle);
+ graphicEngine.create();
+ renderer = graphicEngine.getRenderer();
+ graphicEngine.setTitle(initialTitle);
loop();
} catch (final Exception ex) {
ex.printStackTrace();
}
- monitor.shutdown();
}
/*
@@ -110,54 +119,6 @@ public final class DisplayManager implements RenderingLoop {
* GL_UNSIGNED_BYTE, skin); } catch (IOException ex) { ex.printStackTrace(); } }
*/
- private GraphicEngine chooseGraphicEngine() {
- GraphicEngine d;
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "framebuffer engine", null);
- if (d != null && d.isSupported()) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Using FB Graphic Engine");
- return d;
- }
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "CPU engine", null);
- if (d != null && d.isSupported()) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Using CPU Graphic Engine");
- return d;
- }
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "GPU engine", null);
- if (d != null && d.isSupported()) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Using GPU Graphic Engine");
- return d;
- }
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 24 bit engine", null);
- if (d != null && d.isSupported()) {
- System.err.println(
- "Using Headless 24 bit Engine! This is a problem! No other graphic engines are available.");
- return d;
- }
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 256 colors engine", null);
- if (d != null && d.isSupported()) {
- System.err.println("Using Headless 256 Engine! This is a problem! No other graphic engines are available.");
- return d;
- }
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 8 colors engine", null);
- if (d != null && d.isSupported()) {
- System.err
- .println("Using Headless basic Engine! This is a problem! No other graphic engines are available.");
- return d;
- }
- d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "HTML5 engine", null);
- if (d != null && d.isSupported()) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG,
- "Using Html Graphic Engine");
- return d;
- }
- d = new NoGuiEngine();
- if (d != null && d.isSupported()) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Using NoGui Graphic Engine");
- return d;
- }
- throw new UnsupportedOperationException("No graphic engines available.");
- }
-
public void closeScreen() {
boolean isLastSession = sessions[1] == null;
if (!isLastSession) {
@@ -249,7 +210,7 @@ public final class DisplayManager implements RenderingLoop {
screenChange.release();
} catch (final Exception e) {
e.printStackTrace();
- Engine.getPlatform().exit(0);
+ WarpPI.getPlatform().exit(0);
}
}
@@ -275,7 +236,7 @@ public final class DisplayManager implements RenderingLoop {
screenChange.release();
} catch (final Exception e) {
e.printStackTrace();
- Engine.getPlatform().exit(0);
+ WarpPI.getPlatform().exit(0);
}
}
@@ -353,77 +314,85 @@ public final class DisplayManager implements RenderingLoop {
}
private void load_skin() throws IOException {
- guiSkin = engine.loadSkin("/skin.png");
+ guiSkin = graphicEngine.loadSkin("/skin.png");
}
private void load_fonts() throws IOException {
fonts = new BinaryFont[7];
- fonts[0] = engine.loadFont("smal");
- fonts[1] = engine.loadFont("smallest");
- fonts[2] = engine.loadFont("norm");
- fonts[3] = engine.loadFont("smal");
+ fonts[0] = graphicEngine.loadFont("smal");
+ fonts[1] = graphicEngine.loadFont("smallest");
+ fonts[2] = graphicEngine.loadFont("norm");
+ fonts[3] = graphicEngine.loadFont("smal");
// 4
// fonts[5] = engine.loadFont("square");
}
private void draw_init() {
- if (engine.supportsFontRegistering()) {
- final List fontsIterator = engine.getRegisteredFonts();
+ if (graphicEngine.supportsFontRegistering()) {
+ final List fontsIterator = graphicEngine.getRegisteredFonts();
for (final BinaryFont f : fontsIterator) {
if (!f.isInitialized()) {
- f.initialize(engine);
+ f.initialize(display);
}
}
}
if (!screen.graphicInitialized) {
try {
- screen.initializeGraphic();
+ var displaySize = display.getDisplaySize();
+ var fullCtx = new RenderContext(graphicEngine, renderer, displaySize[0], displaySize[1]);
+ screen.initializeGraphic(fullCtx);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
- renderer.glClear(engine.getWidth(), engine.getHeight());
+ renderer.glClear(graphicEngine.getWidth(), graphicEngine.getHeight());
}
private void draw_world() {
+ var displaySize = display.getDisplaySize();
+ var scrWidth = displaySize[0] - hud.getMarginLeft() - hud.getMarginRight();
+ var scrHeight = displaySize[1] - hud.getMarginTop() - hud.getMarginBottom();
+ var scrCtx = new RenderContext(graphicEngine, renderer.getBoundedInstance(hud.getMarginLeft(), hud.getMarginTop(), scrWidth, scrHeight), scrWidth, scrHeight);
+ var fullCtdx = new RenderContext(graphicEngine, renderer, displaySize[0], displaySize[1]);
+
renderer.glColor3i(255, 255, 255);
if (error != null) {
final BinaryFont fnt = Utils.getFont(false, false);
- if (fnt != null && fnt != engine.getRenderer().getCurrentFont()) {
- fnt.use(engine);
+ if (fnt != null && fnt != graphicEngine.getRenderer().getCurrentFont()) {
+ fnt.use(display);
}
renderer.glColor3i(129, 28, 22);
- renderer.glDrawStringRight(StaticVars.screenSize[0] - 2,
- StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2),
- Engine.getPlatform().getSettings().getCalculatorNameUppercase() + " CALCULATOR");
+ renderer.glDrawStringRight(display.getDisplaySize()[0] - 2,
+ display.getDisplaySize()[1] - (fnt.getCharacterHeight() + 2),
+ WarpPI.getPlatform().getSettings().getCalculatorNameUppercase() + " CALCULATOR");
renderer.glColor3i(149, 32, 26);
- renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 22, error);
+ renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, 22, error);
renderer.glColor3i(164, 34, 28);
int i = 22;
for (final String stackPart : errorStackTrace) {
renderer.glDrawStringLeft(2, 22 + i, stackPart);
i += 11;
}
- if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
- fonts[0].use(engine);
+ if (fonts[0] != null && fonts[0] != graphicEngine.getRenderer().getCurrentFont()) {
+ fonts[0].use(display);
}
renderer.glColor3i(129, 28, 22);
- renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 11, "UNEXPECTED EXCEPTION");
+ renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, 11, "UNEXPECTED EXCEPTION");
} else {
- if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
- fonts[0].use(engine);
+ if (fonts[0] != null && fonts[0] != graphicEngine.getRenderer().getCurrentFont()) {
+ fonts[0].use(display);
}
if (hud.visible)
hud.renderBackground();
- screen.render();
+ screen.render(scrCtx);
if (hud.visible) {
- hud.render();
+ hud.render(fullCtdx);
hud.renderTopmostBackground();
}
- screen.renderTopmost();
+ screen.renderTopmost(scrCtx);
if (hud.visible)
- hud.renderTopmost();
+ hud.renderTopmost(fullCtdx);
}
}
@@ -435,8 +404,8 @@ public final class DisplayManager implements RenderingLoop {
private long precTime = -1;
@Override
- public void refresh() {
- if (supportsPauses == false || Keyboard.popRefreshRequest() || forceRefresh || screen.mustBeRefreshed()) {
+ public void refresh(boolean force) {
+ if (force || supportsPauses == false || Keyboard.popRefreshRequest() || forceRefresh || screen.mustBeRefreshed()) {
forceRefresh = false;
draw();
}
@@ -455,7 +424,7 @@ public final class DisplayManager implements RenderingLoop {
}
} catch (final Exception e) {
e.printStackTrace();
- Engine.getPlatform().exit(0);
+ WarpPI.getPlatform().exit(0);
}
var displayRefreshManager = new DisplayRefreshManager(this::onRefresh);
@@ -494,7 +463,7 @@ public final class DisplayManager implements RenderingLoop {
public void setBrightness(final float newval) {
if (newval >= 0 && newval <= 1) {
brightness = newval;
- monitor.setBrightness(brightness);
+ backlight.setBrightness(brightness);
}
}
@@ -530,7 +499,31 @@ public final class DisplayManager implements RenderingLoop {
renderer.glFillRect(x, y, uvX2 - uvX, uvY2 - uvY, uvX, uvY, uvX2 - uvX, uvY2 - uvY);
}
- public void waitForExit() {
- engine.waitForExit();
+ public Consumer getTouchEventListener() {
+ return (TouchEvent t) -> {
+ boolean refresh = false;
+ if (screen != null && screen.initialized && executeTouchEventOnScreen(t, screen)) {
+ refresh = true;
+ } else {
+ //Default behavior
+ }
+ if (refresh) {
+ forceRefresh = true;
+ }
+ };
+ }
+
+ private boolean executeTouchEventOnScreen(TouchEvent t, Screen scr) {
+ if (t instanceof TouchStartEvent) {
+ return scr.onTouchStart((TouchStartEvent) t);
+ } else if (t instanceof TouchMoveEvent) {
+ return scr.onTouchMove((TouchMoveEvent) t);
+ } else if (t instanceof TouchEndEvent) {
+ return scr.onTouchEnd((TouchEndEvent) t);
+ } else if (t instanceof TouchCancelEvent) {
+ return scr.onTouchCancel((TouchCancelEvent) t);
+ } else {
+ throw new UnsupportedOperationException();
+ }
}
}
\ No newline at end of file
diff --git a/core/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java b/core/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java
index e39c7405..82c187a9 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java
@@ -1,6 +1,6 @@
package it.cavallium.warppi.gui;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.util.Error;
@@ -20,9 +20,9 @@ public class GUIErrorMessage {
creationTime = System.currentTimeMillis();
}
- public void draw(final GraphicEngine g, final Renderer r, final String msg) {
- final int scrW = g.getWidth();
- final int scrH = g.getHeight();
+ public void draw(final DisplayOutputDevice g, final Renderer r, final String msg) {
+ final int scrW = g.getGraphicEngine().getWidth();
+ final int scrH = g.getGraphicEngine().getHeight();
final int width = 200;
final int height = 20;
final int margin = 4;
diff --git a/core/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java b/core/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java
index f1ee5694..7287456d 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java
@@ -5,13 +5,13 @@ public interface GraphicalInterface {
void initialize() throws InterruptedException;
- void initializeGraphic() throws InterruptedException;
+ void initializeGraphic(ScreenContext ctx) throws InterruptedException;
- void render();
+ void render(RenderContext ctx);
- void renderTopmost();
+ void renderTopmost(RenderContext ctx);
- void beforeRender(float dt);
+ void beforeRender(ScreenContext ctx, float dt);
boolean mustBeRefreshed();
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/HUD.java b/core/src/main/java/it/cavallium/warppi/gui/HUD.java
index 79436fe9..8509c771 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/HUD.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/HUD.java
@@ -1,5 +1,7 @@
package it.cavallium.warppi.gui;
+import it.cavallium.warppi.gui.screens.Screen;
+
public abstract class HUD implements GraphicalInterface {
public DisplayManager d;
public boolean created = false;
@@ -18,7 +20,7 @@ public abstract class HUD implements GraphicalInterface {
}
@Override
- public void initializeGraphic() throws InterruptedException {
+ public void initializeGraphic(ScreenContext ctx) throws InterruptedException {
if (!graphicInitialized) {
graphicInitialized = true;
graphicInitialized();
@@ -42,15 +44,15 @@ public abstract class HUD implements GraphicalInterface {
public abstract void renderBackground();
@Override
- public abstract void render();
+ public abstract void render(RenderContext ctx);
public abstract void renderTopmostBackground();
@Override
- public abstract void renderTopmost();
+ public abstract void renderTopmost(RenderContext ctx);
@Override
- public abstract void beforeRender(float dt);
+ public abstract void beforeRender(ScreenContext ctx, float dt);
@Override
public boolean mustBeRefreshed() {
@@ -65,4 +67,11 @@ public abstract class HUD implements GraphicalInterface {
visible = true;
}
+ public abstract int getMarginLeft();
+
+ public abstract int getMarginTop();
+
+ public abstract int getMarginRight();
+
+ public abstract int getMarginBottom();
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java b/core/src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java
deleted file mode 100644
index 464ae061..00000000
--- a/core/src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package it.cavallium.warppi.gui;
-
-public interface HardwareDisplay {
- void initialize();
-
- void shutdown();
-
- void setBrightness(double value);
-}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/RenderContext.java b/core/src/main/java/it/cavallium/warppi/gui/RenderContext.java
new file mode 100644
index 00000000..2dce1755
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/gui/RenderContext.java
@@ -0,0 +1,17 @@
+package it.cavallium.warppi.gui;
+
+import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.gui.graphicengine.Renderer;
+
+public class RenderContext extends ScreenContext {
+ private final Renderer renderer;
+
+ public RenderContext(GraphicEngine graphicEngine, Renderer renderer, int width, int height) {
+ super(graphicEngine, width, height);
+ this.renderer = renderer;
+ }
+
+ public Renderer getRenderer() {
+ return renderer;
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/ScreenContext.java b/core/src/main/java/it/cavallium/warppi/gui/ScreenContext.java
new file mode 100644
index 00000000..822fddc8
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/gui/ScreenContext.java
@@ -0,0 +1,27 @@
+package it.cavallium.warppi.gui;
+
+import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+
+public class ScreenContext {
+ private final GraphicEngine graphicEngine;
+ private final int width;
+ private final int height;
+
+ public ScreenContext(GraphicEngine graphicEngine, int width, int height) {
+ this.graphicEngine = graphicEngine;
+ this.width = width;
+ this.height = height;
+ }
+
+ public GraphicEngine getGraphicEngine() {
+ return graphicEngine;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java b/core/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java
index 5c8b2f56..6fb229d6 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java
@@ -2,11 +2,11 @@ package it.cavallium.warppi.gui.expression;
import java.util.Arrays;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.event.KeyboardEventListener;
import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.blocks.BlockVariable;
import it.cavallium.warppi.gui.expression.blocks.TreeContainer;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
public abstract class ExtraMenu implements KeyboardEventListener {
@@ -32,7 +32,7 @@ public abstract class ExtraMenu implements KeyboardEventListene
protected int height;
protected int[] location;
- public abstract void draw(GraphicEngine ge, Renderer r, Caret caret);
+ public abstract void draw(DisplayOutputDevice ge, Renderer r, Caret caret);
public abstract void open();
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java
index 638c596d..1024ff69 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java
@@ -1,10 +1,10 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.ExtraMenu;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
@@ -45,7 +45,7 @@ public abstract class Block implements TreeBlock, GraphicalElement {
* Position relative to the window.
* @param small
*/
- public abstract void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret);
+ public abstract void draw(DisplayOutputDevice ge, Renderer r, int x, int y, Caret caret);
public abstract boolean putBlock(Caret caret, Block newBlock);
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java
index e9db9436..edd38175 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.parser.features.FeatureChar;
@@ -29,7 +29,7 @@ public class BlockChar extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
r.glDrawCharLeft(x, y, ch);
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java
index 96abf8ce..5d4b71a7 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java
@@ -2,13 +2,13 @@ package it.cavallium.warppi.gui.expression.blocks;
import java.util.Arrays;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.CaretState;
import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -182,7 +182,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
* @param caret
* Position of the caret.
*/
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
int paddingX = 1;
if (caret.getRemaining() == 0) {
@@ -396,7 +396,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
return BlockContainer.defFontSizes[b ? 3 : 1];
}
- public static void drawCaret(final GraphicEngine ge, final Renderer r, final Caret caret, final boolean small,
+ public static void drawCaret(final DisplayOutputDevice ge, final Renderer r, final Caret caret, final boolean small,
final int x, final int y, final int height) {
if (caret.getState() == CaretState.VISIBLE_ON) {
r.glColor(BlockContainer.getDefaultColor());
@@ -424,7 +424,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
private static void checkInitialized() {
if (!BlockContainer.initialized) {
- Engine.getPlatform().throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!");
+ WarpPI.getPlatform().throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!");
}
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java
index 3702cec5..ea5cd643 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -38,7 +38,7 @@ public class BlockDivision extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
containerUp.draw(ge, r, x + 1 + paddingLeftUpper, y, caret);
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java
index cdb25f9d..0d2d4d87 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
public class BlockExponentialNotation extends BlockPower {
@@ -25,7 +25,7 @@ public class BlockExponentialNotation extends BlockPower {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
r.glDrawStringLeft(x, y + height - bh, "ℯ℮");
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java
index 8699ed4d..6ae3fe3b 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -56,7 +56,7 @@ public class BlockLogarithm extends Block implements IParenthesis {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
if (prefix != null) {
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java
index bfff55c8..a9245a21 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
@@ -52,7 +52,7 @@ public abstract class BlockParenthesisAbstract extends Block implements IParenth
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
if (prefix != null) {
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java
index a665fa6d..5b027758 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -26,7 +26,7 @@ public class BlockPower extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(true).use(ge);
r.glColor(BlockContainer.getDefaultColor());
containerExponent.draw(ge, r, x, y, caret);
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower2.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower2.java
index e586a463..d3152dbd 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower2.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower2.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -32,7 +32,7 @@ public class BlockPower2 extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(true).use(ge);
r.glColor(BlockContainer.getDefaultColor());
containerExponent.draw(ge, r, x, y, caret);
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java
index 4bdfe9ea..136191f8 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -29,7 +29,7 @@ public class BlockSquareRoot extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
r.glDrawLine(x, y + height - 10 + 1, x, y + height - 10 + 2); // /
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java
index 46289191..43650aa7 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java
@@ -1,8 +1,8 @@
package it.cavallium.warppi.gui.expression.blocks;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.InputContext;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.MathematicalSymbols;
@@ -21,7 +21,7 @@ public class BlockUndefined extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
BlockContainer.getDefaultFont(small).use(ge);
r.glColor(BlockContainer.getDefaultColor());
r.glDrawStringLeft(x, y, "UNDEFINED");
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java
index aa59d8ee..4802aadc 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java
@@ -2,14 +2,14 @@ package it.cavallium.warppi.gui.expression.blocks;
import java.util.Arrays;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.ExtraMenu;
import it.cavallium.warppi.gui.expression.InputContext;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.MathContext;
import it.cavallium.warppi.math.functions.Variable.V_TYPE;
@@ -82,7 +82,7 @@ public class BlockVariable extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
if (ic.variableTypeDirtyID != typeDirtyID) {
retrieveValue();
}
@@ -238,9 +238,9 @@ public class BlockVariable extends Block {
}
@Override
- public void draw(final GraphicEngine ge, final Renderer r, final Caret caret) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final Caret caret) {
r.glColor3f(1.0f, 1.0f, 1.0f);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(ge);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(ge);
int popupX = location[0];
int popupY = location[1];
if (popupX < 0) {
@@ -249,7 +249,7 @@ public class BlockVariable extends Block {
if (popupY < 0) {
popupY = 0;
}
- final int[] screenSize = ge.getSize();
+ final int[] screenSize = ge.getDisplaySize();
if (popupX + width >= screenSize[0]) {
popupX = screenSize[0] - width - 1;
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java
index f31b413e..ed7bd6f2 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java
@@ -1,5 +1,6 @@
package it.cavallium.warppi.gui.expression.containers;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.event.KeyboardEventListener;
import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret;
@@ -10,7 +11,6 @@ import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.blocks.BlockContainer;
import it.cavallium.warppi.gui.expression.blocks.BlockReference;
import it.cavallium.warppi.gui.expression.layouts.InputLayout;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -211,7 +211,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout {
* @param y
* Position relative to the window.
*/
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y) {
caret.resetRemaining();
root.draw(ge, r, x, y, caret);
if (extra != null) {
diff --git a/core/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java
index b75d0bdc..b320ad18 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java
@@ -1,12 +1,12 @@
package it.cavallium.warppi.gui.expression.containers;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.GraphicalElement;
import it.cavallium.warppi.gui.expression.Caret;
import it.cavallium.warppi.gui.expression.CaretState;
import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.blocks.BlockContainer;
import it.cavallium.warppi.gui.expression.layouts.OutputLayout;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@@ -119,7 +119,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout
* @param y
* Position relative to the window.
*/
- public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y) {
+ public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y) {
int offset = 0;
for (final BlockContainer root : roots) {
root.draw(ge, r, x, y + offset, caret);
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java
index 350d499c..0e95363d 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java
@@ -10,20 +10,22 @@ public interface GraphicEngine {
int[] getSize();
+ boolean isSupported();
+
boolean isInitialized();
void setTitle(String title);
void setResizable(boolean r);
- void setDisplayMode(final int ww, final int wh);
+ void setDisplayMode(int ww, int wh);
+ void create(Runnable object);
+
default void create() {
create(null);
};
- void create(Runnable object);
-
EventSubscriber onResize();
int getWidth();
@@ -44,10 +46,6 @@ public interface GraphicEngine {
Skin loadSkin(String file) throws IOException;
- void waitForExit();
-
- boolean isSupported();
-
boolean doesRefreshPauses();
default boolean supportsFontRegistering() {
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java
index 25dba65c..a2d3b518 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java
@@ -42,4 +42,6 @@ public interface Renderer {
void glClearSkin();
BinaryFont getCurrentFont();
+
+ Renderer getBoundedInstance(int dx, int dy, int width, int height);
}
\ No newline at end of file
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java
index 7960f81e..2d9b5bee 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java
@@ -1,5 +1,5 @@
package it.cavallium.warppi.gui.graphicengine;
public interface RenderingLoop {
- void refresh();
+ void refresh(boolean force);
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java
index 80c24b71..622eb129 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java
@@ -3,15 +3,17 @@ package it.cavallium.warppi.gui.graphicengine;
import java.io.IOException;
import java.net.URISyntaxException;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+
public interface Skin {
void load(String file) throws IOException, URISyntaxException;
- void initialize(GraphicEngine d);
+ void initialize(DisplayOutputDevice d);
boolean isInitialized();
- void use(GraphicEngine d);
+ void use(DisplayOutputDevice d);
/**
* May not be available before initialization
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java
index 78a4fba0..eeb6d31c 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java
@@ -3,9 +3,9 @@ package it.cavallium.warppi.gui.graphicengine.impl.common;
import java.io.File;
import java.io.IOException;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ImageUtils.ImageReader;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Skin;
public abstract class PngSkin implements Skin {
@@ -25,7 +25,7 @@ public abstract class PngSkin implements Skin {
if (!file.startsWith("/")) {
file = "/" + file;
}
- final ImageReader r = Engine.getPlatform().getImageUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file));
+ final ImageReader r = WarpPI.getPlatform().getImageUtils().load(WarpPI.getPlatform().getStorageUtils().getResourceStream(file));
if (r == null) {
skinData = new int[0];
skinSize = new int[] { 0, 0 };
@@ -37,7 +37,7 @@ public abstract class PngSkin implements Skin {
}
@Override
- public void initialize(final GraphicEngine d) {
+ public void initialize(final DisplayOutputDevice d) {
// TODO Auto-generated method stub
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java
index a2baae3a..52cfeb09 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java
@@ -8,10 +8,10 @@ import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.util.Utils;
public abstract class RFTFont implements BinaryFont {
@@ -62,7 +62,7 @@ public abstract class RFTFont implements BinaryFont {
}
private void load(final String path, final boolean onlyRaw) throws IOException {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN + 1, "Loading font " + path);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN + 1, "Loading font " + path);
loadFont(path);
if (!onlyRaw) {
chars32 = new int[intervalsTotalSize * charIntCount];
@@ -94,14 +94,14 @@ public abstract class RFTFont implements BinaryFont {
}
}
- Engine.getPlatform().gc();
+ WarpPI.getPlatform().gc();
}
private void loadFont(String string) throws IOException {
if (!string.startsWith("/")) {
string = "/" + string;
}
- InputStream res = Engine.getPlatform().getStorageUtils().getResourceStream(string);
+ InputStream res = WarpPI.getPlatform().getStorageUtils().getResourceStream(string);
final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res, res.available()));
final int filelength = file.length;
if (filelength >= 16) {
@@ -140,7 +140,7 @@ public abstract class RFTFont implements BinaryFont {
} catch (final Exception ex) {
ex.printStackTrace();
System.out.println(string);
- Engine.getPlatform().exit(-1);
+ WarpPI.getPlatform().exit(-1);
}
}
} else {
@@ -266,7 +266,7 @@ public abstract class RFTFont implements BinaryFont {
}
@Override
- public void initialize(final GraphicEngine d) {}
+ public void initialize(final DisplayOutputDevice d) {}
@Override
public int getStringWidth(final String text) {
@@ -314,7 +314,7 @@ public abstract class RFTFont implements BinaryFont {
}
@Override
- public void use(final GraphicEngine d) {
+ public void use(final DisplayOutputDevice d) {
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java
index 5a59a0e6..a0f5b4de 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/nogui/NoGuiEngine.java
@@ -2,8 +2,9 @@ package it.cavallium.warppi.gui.graphicengine.impl.nogui;
import java.io.IOException;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.Semaphore;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer;
@@ -15,7 +16,6 @@ import it.cavallium.warppi.util.EventSubscriber;
public class NoGuiEngine implements GraphicEngine {
private boolean initialized;
- public Semaphore exitSemaphore = Engine.getPlatform().newSemaphore(0);
@Override
public int[] getSize() {
@@ -62,7 +62,6 @@ public class NoGuiEngine implements GraphicEngine {
@Override
public void destroy() {
initialized = false;
- exitSemaphore.release();
}
@Override
@@ -148,7 +147,7 @@ public class NoGuiEngine implements GraphicEngine {
public BinaryFont loadFont(final String fontName) throws IOException {
return new BinaryFont() {
@Override
- public void use(final GraphicEngine d) {}
+ public void use(final DisplayOutputDevice d) {}
@Override
public void load(final String file) throws IOException {}
@@ -159,7 +158,7 @@ public class NoGuiEngine implements GraphicEngine {
}
@Override
- public void initialize(final GraphicEngine d) {}
+ public void initialize(final DisplayOutputDevice d) {}
@Override
public int getStringWidth(final String text) {
@@ -194,7 +193,7 @@ public class NoGuiEngine implements GraphicEngine {
public BinaryFont loadFont(final String path, final String fontName) throws IOException {
return new BinaryFont() {
@Override
- public void use(final GraphicEngine d) {}
+ public void use(final DisplayOutputDevice d) {}
@Override
public void load(final String file) throws IOException {}
@@ -205,7 +204,7 @@ public class NoGuiEngine implements GraphicEngine {
}
@Override
- public void initialize(final GraphicEngine d) {}
+ public void initialize(final DisplayOutputDevice d) {}
@Override
public int getStringWidth(final String text) {
@@ -240,7 +239,7 @@ public class NoGuiEngine implements GraphicEngine {
public Skin loadSkin(final String file) throws IOException {
return new Skin() {
@Override
- public void use(final GraphicEngine d) {}
+ public void use(final DisplayOutputDevice d) {}
@Override
public void load(final String file) throws IOException {}
@@ -251,7 +250,7 @@ public class NoGuiEngine implements GraphicEngine {
}
@Override
- public void initialize(final GraphicEngine d) {}
+ public void initialize(final DisplayOutputDevice d) {}
@Override
public int getSkinWidth() {
@@ -267,13 +266,6 @@ public class NoGuiEngine implements GraphicEngine {
};
}
- @Override
- public void waitForExit() {
- try {
- exitSemaphore.acquire();
- } catch (final InterruptedException e) {}
- }
-
@Override
public boolean isSupported() {
return true;
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java
index 0c8a7ca7..26f57a42 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java
@@ -1,6 +1,7 @@
package it.cavallium.warppi.gui.screens;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.gui.HistoryBehavior;
@@ -32,21 +33,22 @@ public class ChooseVariableValueScreen extends Screen {
@Override
public void render() {
- Utils.getFont(false, true).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
+ DisplayOutputDevice display = d.display;
+ Utils.getFont(false, true).use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2 + 1, display.getDisplaySize()[1] / 2 - 20, "WORK IN PROGRESS.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2 + 1, display.getDisplaySize()[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 2 - 20, "WORK IN PROGRESS.");
- Utils.getFont(false, false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ Utils.getFont(false, false).use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2 + 1, display.getDisplaySize()[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2 + 1, display.getDisplaySize()[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
}
@Override
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java
index 412a08e7..502439a1 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java
@@ -1,6 +1,6 @@
package it.cavallium.warppi.gui.screens;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent;
@@ -32,19 +32,19 @@ public class KeyboardDebugScreen extends Screen {
@Override
public void render() {
- final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ final Renderer renderer = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.75f, 0.0f, 0.0f, 1.0f);
- renderer.glDrawStringRight(StaticVars.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
+ renderer.glDrawStringRight(d.display.getDisplaySize()[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
if (keyevent != "NONE") {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glDrawStringLeft(10, 30, "Key position");
renderer.glDrawStringLeft(10, 45, "X: " + KeyboardDebugScreen.keyX + ", Y:" + KeyboardDebugScreen.keyY);
renderer.glDrawStringLeft(10, 65, "Key value");
renderer.glDrawStringLeft(10, 80, key);
}
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
for (int i = 0; i < 5; i++) {
if (KeyboardDebugScreen.log[i] != null) {
@@ -56,10 +56,10 @@ public class KeyboardDebugScreen extends Screen {
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glFillColor(-80 + 100 + 200, 90, 5, 5);
renderer.glFillColor(-80 + 100, 100, 200, 70);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
renderer.glDrawStringCenter(-80 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "FROM SERIAL");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 0; i < 8; i++) {
if (KeyboardDebugScreen.pinsA[i] == 1) {
@@ -102,10 +102,10 @@ public class KeyboardDebugScreen extends Screen {
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glFillColor(150 + 90, 200, 5, 5);
renderer.glFillColor(150 + 100, 100, 200, 70);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
renderer.glDrawStringCenter(150 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "TO SERIAL");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 15; i >= 8; i--) {
if (KeyboardDebugScreen.pinsB[i] == 1) {
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java
index d2a618c6..b499faac 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java
@@ -1,6 +1,7 @@
package it.cavallium.warppi.gui.screens;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.GraphicUtils;
import it.cavallium.warppi.gui.HistoryBehavior;
@@ -21,7 +22,7 @@ public class LoadingScreen extends Screen {
@Override
public void created() throws InterruptedException {
- Engine.INSTANCE.isLoaded().subscribe((loaded) -> {
+ WarpPI.INSTANCE.isLoaded().subscribe((loaded) -> {
this.loaded = loaded;
});
endLoading = 0;
@@ -30,7 +31,7 @@ public class LoadingScreen extends Screen {
@Override
public void initialized() throws InterruptedException {
previousZoomValue = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().hide();
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().hide();
StaticVars.windowZoom.submit(1f);
}
@@ -42,24 +43,25 @@ public class LoadingScreen extends Screen {
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
endLoading += dt;
- if (!ended && loaded && (Engine.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) {
+ if (!ended && loaded && (WarpPI.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) {
ended = true;
StaticVars.windowZoom.submit(previousZoomValue);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show();
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show();
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
}
mustRefresh = true;
}
@Override
public void render() {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 255, 255);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
+ DisplayOutputDevice display = d.display;
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 255, 255);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(display.getDisplaySize()[0] / 2f - 80, display.getDisplaySize()[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(display.getDisplaySize()[0] / 2f - 24, display.getDisplaySize()[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(display.getDisplaySize()[0] - 224, display.getDisplaySize()[1] - 48, 224, 48, 0, 80, 224, 48);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(display.getDisplaySize()[0] - 160 - 24 - 224, display.getDisplaySize()[1] - 48, 160, 48, 224, 80, 160, 48);
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java
index 396c4eb3..714a66e1 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java
@@ -3,11 +3,13 @@ package it.cavallium.warppi.gui.screens;
import java.io.IOException;
import java.util.HashMap;
+import it.cavallium.warppi.gui.RenderContext;
+import it.cavallium.warppi.gui.ScreenContext;
import org.apache.commons.lang3.SerializationUtils;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils;
-import it.cavallium.warppi.device.Keyboard;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.event.KeyReleasedEvent;
@@ -66,7 +68,6 @@ public class MathInputScreen extends Screen {
/**
* Create a copy of this element
- * @param mathInputScreen
*/
private MathInputScreen(MathInputScreen old) {
this.calc = new MathContext(old.calc);
@@ -87,13 +88,6 @@ public class MathInputScreen extends Screen {
ic = new InputContext();
calc = new MathContext();
- try {
- BlockContainer.initializeFonts(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("norm"), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("smal"));
- } catch (final IOException e) {
- e.printStackTrace();
- Engine.getPlatform().exit(1);
- }
-
userInput = new NormalInputContainer(ic);
result = new NormalOutputContainer();
@@ -106,16 +100,22 @@ public class MathInputScreen extends Screen {
}
@Override
- public void graphicInitialized() throws InterruptedException {
+ public void graphicInitialized(ScreenContext ctx) throws InterruptedException {
/* Fine caricamento */
+ try {
+ BlockContainer.initializeFonts(ctx.getGraphicEngine().loadFont("norm"), ctx.getGraphicEngine().loadFont("smal"));
+ } catch (final IOException e) {
+ e.printStackTrace();
+ WarpPI.getPlatform().exit(1);
+ }
}
@Override
- public void beforeRender(final float dt) {
- if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error == null) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFc5c2af);
+ public void beforeRender(final ScreenContext ctx, final float dt) {
+ if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error == null) {
+ ctx.getGraphicEngine().getRenderer().glClearColor(0xFFc5c2af);
} else {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFDC3C32);
+ ctx.getGraphicEngine().getRenderer().glClearColor(0xFFDC3C32);
}
if (userInput.beforeRender(dt)) {
mustRefresh = true;
@@ -140,14 +140,14 @@ public class MathInputScreen extends Screen {
}
@Override
- public void render() {
- final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
- MathInputScreen.fontBig.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ public void render(RenderContext ctx) {
+ final Renderer renderer = ctx.getRenderer();
+ MathInputScreen.fontBig.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
final int textColor = 0xFF000000;
final int padding = 4;
renderer.glColor(textColor);
- userInput.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, padding, padding + 20);
+ userInput.draw(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display, renderer, padding, padding + 20);
if (computingResult) {
renderer.glColor3f(1, 1, 1);
@@ -156,20 +156,20 @@ public class MathInputScreen extends Screen {
final int size = 32;
final int posY = computingAnimationIndex % 2;
final int posX = (computingAnimationIndex - posY) / 2;
- renderer.glFillRect(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - size - 4, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size);
+ renderer.glFillRect(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().getWidth() - size - 4, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size);
if (computingBreakTipVisible) {
- Utils.getFont(false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ Utils.getFont(false).use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glColor3f(0.75f, 0, 0);
- renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - 4 - size - 4, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
+ renderer.glDrawStringRight(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().getWidth() - 4 - size - 4, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
}
} else if (!result.isContentEmpty()) {
- result.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - result.getWidth() - 2, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - result.getHeight() - 2);
+ result.draw(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display, renderer, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().getWidth() - result.getWidth() - 2, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().getHeight() - result.getHeight() - 2);
}
}
@Override
- public void renderTopmost() {
- final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
+ public void renderTopmost(RenderContext ctx) {
+ final Renderer renderer = ctx.getRenderer();
renderer.glColor3f(1, 1, 1);
final int pos = 2;
final int spacersNumb = 1;
@@ -179,7 +179,7 @@ public class MathInputScreen extends Screen {
} else {
skinN = 21;
}
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
renderer.glFillRect(2 + 18 * pos + 2 * spacersNumb, 2, 16, 16, 16 * skinN, 16 * 0, 16, 16);
}
@@ -195,7 +195,7 @@ public class MathInputScreen extends Screen {
@Override
public boolean onKeyPressed(final KeyPressedEvent k) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "MathInputScreen", "Pressed key " + k.getKey().toString());
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "MathInputScreen", "Pressed key " + k.getKey().toString());
try {
switch (k.getKey()) {
case OK:
@@ -347,9 +347,9 @@ public class MathInputScreen extends Screen {
userInput.clear();
result.clear();
currentStep = 0;
- if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
- Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
+ if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
+ WarpPI.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
}
return true;
case SURD_MODE:
@@ -361,7 +361,7 @@ public class MathInputScreen extends Screen {
}
return true;
case debug1:
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new EmptyScreen());
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new EmptyScreen());
return true;
case HISTORY_BACK:
// if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoBack()) {
@@ -428,7 +428,7 @@ public class MathInputScreen extends Screen {
@SuppressWarnings("unchecked")
private void swapInputScreen() {
MathInputScreen mis = new MathInputScreen(this);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis);
}
@SuppressWarnings("unused")
@@ -517,10 +517,10 @@ public class MathInputScreen extends Screen {
if (!step) {
currentStep = 0;
}
- if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
+ if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
//TODO: make the error management a global API rather than being relegated to this screen.
- Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
+ WarpPI.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error = null;
calc.f = null;
calc.f2 = null;
calc.resultsCount = 0;
@@ -540,13 +540,13 @@ public class MathInputScreen extends Screen {
calc.f2.clear();
}
calc.f.add(expr);
- Engine.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr);
+ WarpPI.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr);
final MathSolver ms = new MathSolver(expr);
final ObjectArrayList> resultSteps = ms.solveAllSteps();
resultSteps.add(0, Utils.newArrayList(expr));
final ObjectArrayList resultExpressions = resultSteps.get(resultSteps.size() - 1);
for (final Function rr : resultExpressions) {
- Engine.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString());
+ WarpPI.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString());
}
final ObjectArrayList> resultBlocks = MathParser.parseOutput(calc, resultExpressions);
result.setContentAsMultipleGroups(resultBlocks);
@@ -559,22 +559,22 @@ public class MathInputScreen extends Screen {
}
}
} catch (final InterruptedException ex) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
} catch (final Exception ex) {
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
ex.printStackTrace();
}
throw new Error(Errors.SYNTAX_ERROR);
}
} catch (final Error e) {
- d.errorStackTrace = Engine.getPlatform().stacktraceToString(e);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
+ d.errorStackTrace = WarpPI.getPlatform().stacktraceToString(e);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
System.err.println(e.id);
}
computingResult = false;
});
- Engine.getPlatform().setThreadName(computingThread, "Computing Thread");
- Engine.getPlatform().setThreadDaemon(computingThread);
+ WarpPI.getPlatform().setThreadName(computingThread, "Computing Thread");
+ WarpPI.getPlatform().setThreadDaemon(computingThread);
computingThread.setPriority(Thread.NORM_PRIORITY + 3);
computingThread.start();
return true;
@@ -638,9 +638,9 @@ public class MathInputScreen extends Screen {
boolean cancelled = false;
for (final Function f : knownVarsInFunctions) {
final ChooseVariableValueScreen cvs = new ChooseVariableValueScreen(this, new VariableValue((Variable) f, new Number(calc, 0)));
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(cvs);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(cvs);
try {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().screenChange.acquire();
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().screenChange.acquire();
} catch (final InterruptedException e) {}
if (cvs.resultNumberValue == null) {
cancelled = true;
@@ -661,9 +661,9 @@ public class MathInputScreen extends Screen {
}
}
});
- Engine.getPlatform().setThreadName(ct, "Variables user-input queue thread");
+ WarpPI.getPlatform().setThreadName(ct, "Variables user-input queue thread");
ct.setPriority(Thread.MIN_PRIORITY);
- Engine.getPlatform().setThreadDaemon(ct);
+ WarpPI.getPlatform().setThreadDaemon(ct);
ct.start();
}
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/Screen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/Screen.java
index 5c07dd1e..626f69ae 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/Screen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/Screen.java
@@ -2,9 +2,7 @@ package it.cavallium.warppi.gui.screens;
import it.cavallium.warppi.event.KeyboardEventListener;
import it.cavallium.warppi.event.TouchEventListener;
-import it.cavallium.warppi.gui.DisplayManager;
-import it.cavallium.warppi.gui.GraphicalInterface;
-import it.cavallium.warppi.gui.HistoryBehavior;
+import it.cavallium.warppi.gui.*;
public abstract class Screen implements KeyboardEventListener, TouchEventListener, GraphicalInterface {
public DisplayManager d;
@@ -21,10 +19,10 @@ public abstract class Screen implements KeyboardEventListener, TouchEventListene
}
@Override
- public void initializeGraphic() throws InterruptedException {
+ public void initializeGraphic(ScreenContext ctx) throws InterruptedException {
if (!graphicInitialized) {
graphicInitialized = true;
- graphicInitialized();
+ graphicInitialized(ctx);
}
}
@@ -66,18 +64,18 @@ public abstract class Screen implements KeyboardEventListener, TouchEventListene
* Called before initialized()
* @throws InterruptedException
*/
- public abstract void graphicInitialized() throws InterruptedException;
+ public abstract void graphicInitialized(ScreenContext ctx) throws InterruptedException;
@Override
- public abstract void render();
+ public abstract void render(RenderContext ctx);
@Override
- public void renderTopmost() {
+ public void renderTopmost(RenderContext ctx) {
}
@Override
- public abstract void beforeRender(float dt);
+ public abstract void beforeRender(ScreenContext ctx, float dt);
@Override
public abstract boolean mustBeRefreshed();
diff --git a/core/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java
index c9a06249..2526fc30 100644
--- a/core/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java
+++ b/core/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java
@@ -1,6 +1,7 @@
package it.cavallium.warppi.gui.screens;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.event.KeyPressedEvent;
import it.cavallium.warppi.gui.HistoryBehavior;
@@ -28,12 +29,13 @@ public class SolveForXScreen extends Screen {
@Override
public void render() {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ DisplayOutputDevice display = d.display;
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2 + 1, display.getDisplaySize()[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2 + 1, display.getDisplaySize()[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3i(255, 0, 0);
+ WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
}
@Override
diff --git a/core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java b/core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java
index 57ecd8b3..b84f725f 100644
--- a/core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java
+++ b/core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java
@@ -1,6 +1,6 @@
package it.cavallium.warppi.math.parser;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.gui.expression.blocks.Block;
import it.cavallium.warppi.gui.expression.containers.InputContainer;
@@ -83,17 +83,17 @@ public class MathParser {
boolean lastLoopDidSomething;
Function lastElement;
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
- Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
+ WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
for (final Function f : functionsList) {
- Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
+ WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
}
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
}
for (final MathParserStep step : steps) {
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
- Engine.getPlatform().getConsoleUtils().out().println(2, "Stack fixing step \"" + step.getStepName() + "\"");
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
+ WarpPI.getPlatform().getConsoleUtils().out().println(2, "Stack fixing step \"" + step.getStepName() + "\"");
}
final int stepQty = step.requiresReversedIteration() ? -1 : 1,
initialIndex = step.requiresReversedIteration() ? functionsList.size() - 1 : 0;
@@ -114,12 +114,12 @@ public class MathParser {
}
} while (lastLoopDidSomething);
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
- Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
+ WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
for (final Function f : functionsList) {
- Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
+ WarpPI.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
}
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
}
}
diff --git a/core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java b/core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java
index ecec1ad8..38317f9a 100644
--- a/core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java
+++ b/core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java
@@ -1,7 +1,8 @@
package it.cavallium.warppi.math.rules;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform;
+import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.MathContext;
@@ -28,7 +29,7 @@ public class RulesManager {
@SuppressWarnings({ "unchecked" })
public static void initialize() {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules");
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules");
RulesManager.rules = new ObjectArrayList[RuleType.values().length];
for (final RuleType val : RuleType.values()) {
RulesManager.rules[val.ordinal()] = new ObjectArrayList<>();
@@ -134,6 +135,6 @@ public class RulesManager {
public static void addRule(final Rule rule) {
RulesManager.rules[rule.getRuleType().ordinal()].add(rule);
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule");
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule");
}
}
diff --git a/core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java b/core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java
index 8394621e..d87e32ce 100644
--- a/core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java
+++ b/core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java
@@ -4,7 +4,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ConsoleUtils;
import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.rules.Rule;
@@ -40,7 +40,7 @@ public class MathSolver {
public ObjectArrayList> solveAllSteps() throws InterruptedException, Error {
final ObjectArrayList> steps = new ObjectArrayList<>();
ObjectArrayList lastFnc = null, currFnc = new ObjectArrayList<>();
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString());
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString());
currFnc.add(initialFunction);
long stepNumber = 0;
int initStepState = 0, endStepState = 0;
@@ -66,11 +66,11 @@ public class MathSolver {
}
lastFnc = currFnc;
initStepState = stepState.get();
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc);
final ObjectArrayList stepResult = solveStep(lastFnc, stepState);
if (stepResult != null) {
for (final Function result : stepResult) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString());
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString());
}
currFnc = stepResult;
steps.add(currFnc);
@@ -78,22 +78,22 @@ public class MathSolver {
endStepState = stepState.get();
stepNumber++;
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult);
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications.");
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]);
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications.");
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]);
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]);
}
- if (Engine.getPlatform().getSettings().isDebugEnabled()) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]);
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]);
}
} while (consecutiveNullSteps < stepStates.length && !checkEquals(currFnc, lastFunctions[0][endStepState]) && !checkEquals(currFnc, lastFunctions[1][endStepState]));
if (consecutiveNullSteps >= stepStates.length) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length);
} else if (checkEquals(currFnc, lastFunctions[0][endStepState])) {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]);
} else {
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]);
}
return steps;
}
@@ -244,7 +244,7 @@ public class MathSolver {
if (appliedRules.isEmpty()) {
results = null;
}
- if (Engine.getPlatform().getConsoleUtils().getOutputLevel() >= ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN & results != null && !appliedRules.isEmpty()) {
+ if (WarpPI.getPlatform().getConsoleUtils().getOutputLevel() >= ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN & results != null && !appliedRules.isEmpty()) {
final StringBuilder rulesStr = new StringBuilder();
for (final Rule r : appliedRules) {
rulesStr.append(r.getRuleName());
@@ -253,7 +253,7 @@ public class MathSolver {
if (rulesStr.length() > 0) {
rulesStr.setLength(rulesStr.length() - 1);
}
- Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr);
+ WarpPI.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr);
}
return results;
}
diff --git a/core/src/main/java/it/cavallium/warppi/util/RunnableWithException.java b/core/src/main/java/it/cavallium/warppi/util/RunnableWithException.java
new file mode 100644
index 00000000..a2a1e75e
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/util/RunnableWithException.java
@@ -0,0 +1,5 @@
+package it.cavallium.warppi.util;
+
+public interface RunnableWithException {
+ public void run() throws Exception;
+}
diff --git a/core/src/main/java/it/cavallium/warppi/util/Utils.java b/core/src/main/java/it/cavallium/warppi/util/Utils.java
index 0336f252..58cc123b 100644
--- a/core/src/main/java/it/cavallium/warppi/util/Utils.java
+++ b/core/src/main/java/it/cavallium/warppi/util/Utils.java
@@ -15,7 +15,7 @@ import java.util.Map;
import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.Rational;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.math.Function;
@@ -399,7 +399,7 @@ public class Utils {
}
public static final BinaryFont getFont(final boolean small, final boolean zoomed) {
- return Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[Utils.getFontIndex(small, zoomed)];
+ return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[Utils.getFontIndex(small, zoomed)];
}
public static final int getFontIndex(final boolean small, final boolean zoomed) {
@@ -423,14 +423,14 @@ public class Utils {
public static final int getFontHeight(final boolean small, final boolean zoomed) {
if (small) {
if (zoomed) {
- return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[3];
+ return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[3];
} else {
- return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[1];
+ return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[1];
}
} else if (zoomed) {
- return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[2];
+ return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[2];
} else {
- return Engine.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[0];
+ return WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().glyphsHeight[0];
}
}
@@ -567,7 +567,7 @@ public class Utils {
}
public static boolean isWindows() {
- return Engine.getPlatform().getOsName().indexOf("win") >= 0;
+ return WarpPI.getPlatform().getOsName().indexOf("win") >= 0;
}
public static ObjectArrayList newArrayList(final T o) {
@@ -578,7 +578,7 @@ public class Utils {
public static InputStream getResourceStreamSafe(final String string) throws IOException, URISyntaxException {
try {
- return Engine.getPlatform().getStorageUtils().getResourceStream(string);
+ return WarpPI.getPlatform().getStorageUtils().getResourceStream(string);
} catch (final Exception ex) {
return null;
}
diff --git a/desktop/.classpath b/desktop/.classpath
index d0ba9370..c35053bb 100644
--- a/desktop/.classpath
+++ b/desktop/.classpath
@@ -23,8 +23,9 @@
-
+
+
diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java
index feb4e75a..5418f080 100644
--- a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java
+++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java
@@ -8,7 +8,7 @@ import java.io.InputStream;
import javax.imageio.ImageIO;
import ar.com.hjg.pngj.ImageLineInt;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.ImageUtils.ImageReader;
public class DesktopImageReader implements ImageReader {
diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java
index 5072084f..4d2e2149 100644
--- a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java
+++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java
@@ -5,17 +5,26 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.ArrayList;
+import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLDisplayOutputDevice;
+import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
+import it.cavallium.warppi.gui.graphicengine.impl.swing.SwingDeviceState;
+import it.cavallium.warppi.gui.graphicengine.impl.swing.SwingTouchInputDevice;
import org.apache.commons.io.FileUtils;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.boot.StartupArguments;
+import it.cavallium.warppi.device.DeviceStateDevice;
+import it.cavallium.warppi.device.display.BacklightOutputDevice;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.display.NoDisplaysAvailableException;
+import it.cavallium.warppi.device.display.NullBacklightOutputDevice;
+import it.cavallium.warppi.device.input.KeyboardInputDevice;
+import it.cavallium.warppi.device.input.TouchInputDevice;
import it.cavallium.warppi.Platform;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
-import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
+import it.cavallium.warppi.gui.graphicengine.impl.swing.SwingDisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.swing.SwingEngine;
import it.cavallium.warppi.util.CacheUtils;
import it.cavallium.warppi.util.Error;
@@ -27,9 +36,13 @@ public class DesktopPlatform implements Platform {
private final DesktopStorageUtils su;
private final ImageUtils pu;
private final String on;
- private final Map el;
private final DesktopSettings settings;
private Boolean runningOnRaspberryOverride = null;
+ private StartupArguments args;
+ private DisplayOutputDevice displayOutputDevice;
+ private DeviceStateDevice deviceStateDevice;
+ private TouchInputDevice touchInputDevice;
+ private KeyboardInputDevice keyboardInputDevice;
public DesktopPlatform() {
cu = new DesktopConsoleUtils();
@@ -37,9 +50,6 @@ public class DesktopPlatform implements Platform {
su = new DesktopStorageUtils();
pu = new DesktopImageUtils();
on = System.getProperty("os.name").toLowerCase();
- el = new HashMap<>();
- el.put("CPU engine", new SwingEngine());
- el.put("GPU engine", new JOGLEngine());
settings = new DesktopSettings();
}
@@ -105,14 +115,14 @@ public class DesktopPlatform implements Platform {
@Override
public void alphaChanged(final boolean val) {
- final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
+ final DisplayOutputDevice currentEngine = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display;
if (currentEngine instanceof SwingEngine)
((SwingEngine) currentEngine).setAlphaChanged(val);
}
@Override
public void shiftChanged(final boolean val) {
- final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
+ final DisplayOutputDevice currentEngine = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display;
if (currentEngine instanceof SwingEngine)
((SwingEngine) currentEngine).setShiftChanged(val);
}
@@ -132,16 +142,6 @@ public class DesktopPlatform implements Platform {
return new DesktopURLClassLoader(urls);
}
- @Override
- public Map getEnginesList() {
- return el;
- }
-
- @Override
- public GraphicEngine getEngine(final String string) throws NullPointerException {
- return el.get(string);
- }
-
@Override
public void throwNewExceptionInInitializerError(final String text) {
throw new ExceptionInInitializerError();
@@ -178,14 +178,15 @@ public class DesktopPlatform implements Platform {
runningOnRaspberryOverride = false;
}
}
-
+
@Override
public boolean isRunningOnRaspberry() {
- if (runningOnRaspberryOverride != null) return runningOnRaspberryOverride;
+ if (runningOnRaspberryOverride != null)
+ return runningOnRaspberryOverride;
return CacheUtils.get("isRunningOnRaspberry", 24 * 60 * 60 * 1000, () -> {
- if (Engine.getPlatform().isJavascript())
+ if (WarpPI.getPlatform().isJavascript())
return false;
- if (Engine.getPlatform().getOsName().equals("Linux"))
+ if (WarpPI.getPlatform().getOsName().equals("Linux"))
try {
final File osRelease = new File("/etc", "os-release");
return FileUtils.readLines(osRelease, "UTF-8").stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name"));
@@ -197,4 +198,87 @@ public class DesktopPlatform implements Platform {
});
}
+ @Override
+ public TouchInputDevice getTouchInputDevice() {
+ return touchInputDevice;
+ }
+
+ @Override
+ public KeyboardInputDevice getKeyboardInputDevice() {
+ return keyboardInputDevice;
+ }
+
+ @Override
+ public DisplayOutputDevice getDisplayOutputDevice() {
+ return this.displayOutputDevice;
+ }
+
+ @Override
+ public BacklightOutputDevice getBacklightOutputDevice() {
+ return new NullBacklightOutputDevice();
+ }
+
+ @Override
+ public DeviceStateDevice getDeviceStateDevice() {
+ return this.deviceStateDevice;
+ }
+
+ @Override
+ public void setArguments(StartupArguments args) {
+ this.args = args;
+ this.chooseDevices();
+ }
+
+ private void chooseDevices() {
+ List availableDevices = new ArrayList<>();
+ List guiDevices = List.of(new SwingDisplayOutputDevice(), new JOGLDisplayOutputDevice());
+ List consoleDevices = List.of();
+
+ if (args.isMSDOSModeEnabled() || args.isNoGUIEngineForced()) {
+ availableDevices.addAll(consoleDevices);
+ }
+ if (!args.isNoGUIEngineForced()) {
+ availableDevices.addAll(guiDevices);
+ }
+
+ if (availableDevices.size() == 0) {
+ throw new NoDisplaysAvailableException();
+ }
+
+ for (DisplayOutputDevice device : availableDevices) {
+ if (device instanceof SwingDisplayOutputDevice) {
+ if (args.isCPUEngineForced()) {
+ this.displayOutputDevice = device;
+ }
+ } else if (device instanceof JOGLDisplayOutputDevice) {
+ if (args.isGPUEngineForced()) {
+ this.displayOutputDevice = device;
+ break;
+ }
+ }
+ }
+
+ if (this.displayOutputDevice == null) this.displayOutputDevice = availableDevices.get(0);
+
+
+ if (displayOutputDevice instanceof SwingDisplayOutputDevice) {
+ this.touchInputDevice = new SwingTouchInputDevice((SwingEngine) displayOutputDevice.getGraphicEngine());
+
+ //TODO: implement a keyboard input device
+ this.keyboardInputDevice = new KeyboardInputDevice() {
+ @Override
+ public void initialize() {
+
+ }
+ };
+
+ this.deviceStateDevice = new SwingDeviceState((SwingEngine) displayOutputDevice.getGraphicEngine());
+
+ } else if (displayOutputDevice instanceof JOGLDisplayOutputDevice) {
+ this.touchInputDevice = null;
+ this.keyboardInputDevice = null;
+ this.deviceStateDevice = null; //TODO: Implement
+ }
+ }
+
}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingDeviceState.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingDeviceState.java
new file mode 100644
index 00000000..0cfdfc98
--- /dev/null
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingDeviceState.java
@@ -0,0 +1,33 @@
+package it.cavallium.warppi.gui.graphicengine.impl.swing;
+
+import it.cavallium.warppi.device.DeviceStateDevice;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
+
+public class SwingDeviceState implements DeviceStateDevice {
+ private final SwingEngine graphicEngine;
+ private final CompletableFuture exitWait;
+
+ public SwingDeviceState(SwingEngine graphicEngine) {
+ this.graphicEngine = graphicEngine;
+ this.exitWait = new CompletableFuture<>();
+ }
+
+ @Override
+ public void initialize() {
+ graphicEngine.subscribeExit(() -> {
+ exitWait.complete(null);
+ });
+ }
+
+ @Override
+ public Future> waitForExit() {
+ return exitWait;
+ }
+
+ @Override
+ public void powerOff() {
+ graphicEngine.sendPowerOffSignal();
+ }
+}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingDisplayOutputDevice.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingDisplayOutputDevice.java
new file mode 100644
index 00000000..ddd2d5ed
--- /dev/null
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingDisplayOutputDevice.java
@@ -0,0 +1,23 @@
+package it.cavallium.warppi.gui.graphicengine.impl.swing;
+
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+
+public class SwingDisplayOutputDevice implements DisplayOutputDevice {
+
+ private final SwingEngine engine;
+
+ public SwingDisplayOutputDevice() {
+ this.engine = new SwingEngine(480, 320);
+ }
+
+ @Override
+ public GraphicEngine getGraphicEngine() {
+ return engine;
+ }
+
+ @Override
+ public int[] getDisplaySize() {
+ return engine.getSize();
+ }
+}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java
index 7404258c..c0e20e51 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingEngine.java
@@ -1,11 +1,12 @@
package it.cavallium.warppi.gui.graphicengine.impl.swing;
-import java.awt.GraphicsEnvironment;
+import java.awt.*;
+import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.Semaphore;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
@@ -15,11 +16,17 @@ import it.cavallium.warppi.util.EventSubmitter;
public class SwingEngine implements GraphicEngine {
+ private final int defaultWidth;
+ private final int defaultHeight;
private SwingWindow INSTANCE;
public SwingRenderer r;
public volatile BufferedImage g;
public volatile boolean initialized;
- public Semaphore exitSemaphore;
+
+ public SwingEngine(int defaultWidth, int defaultHeight) {
+ this.defaultWidth = defaultWidth;
+ this.defaultHeight = defaultHeight;
+ }
@Override
public void setTitle(final String title) {
@@ -51,10 +58,8 @@ public class SwingEngine implements GraphicEngine {
r = new SwingRenderer();
g = new BufferedImage(r.size[0], r.size[1], BufferedImage.TYPE_INT_RGB);
initialized = false;
- exitSemaphore = new Semaphore(0);
- INSTANCE = new SwingWindow(this);
- setResizable(Engine.getPlatform().getSettings().isDebugEnabled());
- setDisplayMode((int) (StaticVars.screenSize[0] / StaticVars.windowZoom.getLastValue()), (int) (StaticVars.screenSize[1] / StaticVars.windowZoom.getLastValue()));
+ INSTANCE = new SwingWindow(this, defaultWidth, defaultHeight);
+ setResizable(WarpPI.getPlatform().getSettings().isDebugEnabled());
INSTANCE.setVisible(true);
initialized = true;
if (onInitialized != null)
@@ -68,20 +73,21 @@ public class SwingEngine implements GraphicEngine {
@Override
public int getWidth() {
- return INSTANCE.getWWidth() - StaticVars.screenPos[0];
+ return this.getSize()[0];
}
@Override
public int getHeight() {
- return INSTANCE.getWHeight() - StaticVars.screenPos[1];
+ return this.getSize()[1];
}
@Override
public void destroy() {
+ sendPowerOffSignal();
+ }
+
+ protected void destroyEngine() {
initialized = false;
- exitSemaphore.release();
- INSTANCE.setVisible(false);
- INSTANCE.dispose();
}
@Override
@@ -112,7 +118,7 @@ public class SwingEngine implements GraphicEngine {
@Deprecated()
public void refresh() {
- if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null && Engine.INSTANCE.getHardwareDevice().getDisplayManager().error.length() > 0 || Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen().mustBeRefreshed())
+ if (WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error != null && WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().error.length() > 0 || WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen() == null || WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen().mustBeRefreshed())
INSTANCE.c.paintImmediately(0, 0, getWidth(), getHeight());
}
@@ -121,6 +127,49 @@ public class SwingEngine implements GraphicEngine {
INSTANCE.c.repaint();
}
+ public void subscribeExit(Runnable subscriber) {
+ INSTANCE.addWindowListener(new WindowListener() {
+ @Override
+ public void windowOpened(WindowEvent e) {
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ subscriber.run();
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+
+ }
+ });
+ }
+
+ public void sendPowerOffSignal() {
+ INSTANCE.sendPowerOffSignal();
+ }
+
public abstract class Startable {
public Startable() {
force = false;
@@ -137,7 +186,7 @@ public class SwingEngine implements GraphicEngine {
@Override
public int[] getSize() {
- return r.size;
+ return r.size.clone();
}
@Override
@@ -165,13 +214,6 @@ public class SwingEngine implements GraphicEngine {
return new SwingSkin(file);
}
- @Override
- public void waitForExit() {
- try {
- exitSemaphore.acquire();
- } catch (final InterruptedException e) {}
- }
-
@Override
public boolean isSupported() {
if (StaticVars.startupArguments.isEngineForced() && StaticVars.startupArguments.isCPUEngineForced() == false)
@@ -191,4 +233,13 @@ public class SwingEngine implements GraphicEngine {
public void setShiftChanged(final boolean val) {
INSTANCE.setShiftChanged(val);
}
+
+ public Insets getInsets() {
+ return INSTANCE.getInsets();
+ }
+
+ public void subscribeTouchDevice(MouseMotionListener mouseMotionListener, MouseListener mouseListener) {
+ INSTANCE.c.addMouseListener(mouseListener);
+ INSTANCE.c.addMouseMotionListener(mouseMotionListener);
+ }
}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingFont.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingFont.java
index 00266069..5e66f935 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingFont.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingFont.java
@@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.io.IOException;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class SwingFont extends RFTFont {
@@ -16,8 +16,8 @@ public class SwingFont extends RFTFont {
}
@Override
- public void use(final GraphicEngine d) {
- if (d.getRenderer() instanceof SwingRenderer)
- ((SwingRenderer) d.getRenderer()).currentFont = this;
+ public void use(final DisplayOutputDevice d) {
+ if (d.getGraphicEngine().getRenderer() instanceof SwingRenderer)
+ ((SwingRenderer) d.getGraphicEngine().getRenderer()).currentFont = this;
}
}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingRenderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingRenderer.java
index f5a55260..2d44e2b3 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingRenderer.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingRenderer.java
@@ -15,6 +15,10 @@ public class SwingRenderer implements Renderer {
public int[] size = new int[] { 1, 1 };
static int[] canvas2d = new int[1];
+ public SwingRenderer() {
+
+ }
+
@Override
public void glColor3i(final int r, final int gg, final int b) {
glColor4i(r, gg, b, 255);
@@ -57,8 +61,6 @@ public class SwingRenderer implements Renderer {
private void glDrawSkin(int x0, int y0, final int x1, final int y1, int s0, int t0, int s1, int t1,
final boolean transparent) {
- x0 += StaticVars.screenPos[0];
- y0 += StaticVars.screenPos[1];
final double incrementX = Math.abs((double) (x1 - x0) / (double) (s1 - s0));
final double incrementY = Math.abs((double) (y1 - y0) / (double) (t1 - t0));
final boolean flippedX = (x1 - x0) / (s1 - s0) < 0;
@@ -185,10 +187,6 @@ public class SwingRenderer implements Renderer {
@Override
public void glDrawLine(float x0, float y0, float x1, float y1) {
- x0 += StaticVars.screenPos[0];
- x1 += StaticVars.screenPos[0];
- y0 += StaticVars.screenPos[1];
- y1 += StaticVars.screenPos[1];
final int ix0 = (int) x0;
final int ix1 = (int) x1;
final int iy0 = (int) y0;
@@ -223,8 +221,6 @@ public class SwingRenderer implements Renderer {
@Override
public void glFillColor(float x, float y, final float width, final float height) {
- x += StaticVars.screenPos[0];
- y += StaticVars.screenPos[1];
final int ix = (int) x;
final int iy = (int) y;
@@ -256,8 +252,6 @@ public class SwingRenderer implements Renderer {
@Override
public void glDrawStringLeft(float x, float y, final String textString) {
- x += StaticVars.screenPos[0];
- y += StaticVars.screenPos[1];
final int ix = (int) x;
final int iy = (int) y;
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingSkin.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingSkin.java
index 9dbddb85..a8cf103d 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingSkin.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingSkin.java
@@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.io.IOException;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin;
public class SwingSkin extends PngSkin {
@@ -12,8 +12,8 @@ public class SwingSkin extends PngSkin {
}
@Override
- public void use(final GraphicEngine d) {
- if (d.getRenderer() instanceof SwingRenderer)
- ((SwingRenderer) d.getRenderer()).currentSkin = this;
+ public void use(final DisplayOutputDevice d) {
+ if (d.getGraphicEngine().getRenderer() instanceof SwingRenderer)
+ ((SwingRenderer) d.getGraphicEngine().getRenderer()).currentSkin = this;
}
}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingTouchInputDevice.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingTouchInputDevice.java
new file mode 100644
index 00000000..beb64ed6
--- /dev/null
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingTouchInputDevice.java
@@ -0,0 +1,106 @@
+package it.cavallium.warppi.gui.graphicengine.impl.swing;
+
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.input.TouchInputDevice;
+import it.cavallium.warppi.event.*;
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.util.concurrent.SubmissionPublisher;
+import java.util.function.Consumer;
+
+public class SwingTouchInputDevice implements TouchInputDevice {
+ private final SubmissionPublisher touchEventPublisher = new SubmissionPublisher<>();
+ private final SwingEngine graphicEngine;
+
+ public SwingTouchInputDevice(SwingEngine graphicEngine) {
+ this.graphicEngine = graphicEngine;
+ }
+
+ @Override
+ public boolean getSwappedAxes() {
+ return false;
+ }
+
+ @Override
+ public boolean getInvertedX() {
+ return false;
+ }
+
+ @Override
+ public boolean getInvertedY() {
+ return false;
+ }
+
+ @Override
+ public void listenTouchEvents(Consumer touchEventListener) {
+ touchEventPublisher.consume(touchEventListener);
+ }
+
+ @Override
+ public void initialize() {
+
+ graphicEngine.subscribeTouchDevice(new MouseMotionListener() {
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ final Insets wp = graphicEngine.getInsets();
+ final TouchPoint p = new TouchPoint(0, e.getX() - wp.left, e.getY() - wp.top, 5, 5, 1, 0);
+ final ObjectArrayList touches = new ObjectArrayList<>();
+ final ObjectArrayList changedTouches = new ObjectArrayList<>();
+ touches.add(p);
+ changedTouches.add(p);
+ final TouchMoveEvent tse = new TouchMoveEvent(changedTouches, touches);
+
+ SwingTouchInputDevice.this.touchEventPublisher.submit(tse);
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+
+ }
+ }, new MouseListener() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ final Insets wp = graphicEngine.getInsets();
+ final TouchPoint p = new TouchPoint(0, e.getX() - wp.left, e.getY() - wp.top, 5, 5, 1, 0);
+ final ObjectArrayList touches = new ObjectArrayList<>();
+ final ObjectArrayList changedTouches = new ObjectArrayList<>();
+ touches.add(p);
+ changedTouches.add(p);
+ final TouchStartEvent tse = new TouchStartEvent(changedTouches, touches);
+
+ SwingTouchInputDevice.this.touchEventPublisher.submit(tse);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ final Insets wp = graphicEngine.getInsets();
+ final TouchPoint p = new TouchPoint(0, e.getX() - wp.left, e.getY() - wp.top, 5, 5, 1, 0);
+ final ObjectArrayList touches = new ObjectArrayList<>();
+ final ObjectArrayList changedTouches = new ObjectArrayList<>();
+ changedTouches.add(p);
+ final TouchEndEvent tse = new TouchEndEvent(changedTouches, touches);
+
+ SwingTouchInputDevice.this.touchEventPublisher.submit(tse);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+
+ }
+ });
+ }
+}
diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java
index a185c561..6904acd9 100644
--- a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java
+++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/swing/SwingWindow.java
@@ -1,22 +1,13 @@
package it.cavallium.warppi.gui.graphicengine.impl.swing;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.Point;
-import java.awt.Toolkit;
+import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
@@ -27,9 +18,9 @@ import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.event.TouchEndEvent;
import it.cavallium.warppi.event.TouchMoveEvent;
import it.cavallium.warppi.event.TouchPoint;
@@ -40,6 +31,8 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class SwingWindow extends JFrame {
private static final long serialVersionUID = 2945898937634075491L;
+ private final int defaultWidth;
+ private final int defaultHeight;
public CustomCanvas c;
private RenderingLoop renderingLoop;
private final SwingEngine display;
@@ -49,12 +42,20 @@ public class SwingWindow extends JFrame {
public JPanel buttonsPanel;
private SwingAdvancedButton[][] buttons;
private int BTN_SIZE;
+ private volatile boolean windowShown;
+ private volatile boolean forceRepaint;
- public SwingWindow(final SwingEngine disp) {
+ public SwingWindow(final SwingEngine disp, int defaultWidth, int defaultHeight) {
display = disp;
+ this.defaultWidth = defaultWidth;
+ this.defaultHeight = defaultHeight;
setLayout(new BorderLayout());
setBackground(Color.BLACK);
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
c = new CustomCanvas();
+ c.setMinimumSize(new Dimension(0, 0));
+ c.setPreferredSize(new Dimension(defaultWidth, defaultHeight));
+ c.setSize(defaultWidth, defaultHeight);
c.setDoubleBuffered(false);
this.add(c, BorderLayout.CENTER);
try {
@@ -69,7 +70,7 @@ public class SwingWindow extends JFrame {
mult = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()).intValue();
- if (!Engine.getPlatform().getSettings().isDebugEnabled()) {
+ if (!WarpPI.getPlatform().getSettings().isDebugEnabled()) {
// Create a new blank cursor.
final Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
@@ -83,13 +84,35 @@ public class SwingWindow extends JFrame {
onResize = EventSubmitter.create();
onResize$ = onResize.map((newSize) -> {
- disp.r.size = new int[] { newSize[0], newSize[1] };
- if (disp.r.size[0] <= 0)
- disp.r.size[0] = 1;
- if (disp.r.size[1] <= 0)
- disp.r.size[1] = 1;
+ if (newSize[0] <= 0)
+ newSize[0] = 1;
+ if (newSize[1] <= 0)
+ newSize[1] = 1;
+
+ var oldSize = disp.r.size;
+ disp.r.size = new int[] { newSize[0], newSize[1] };
+
SwingRenderer.canvas2d = new int[disp.r.size[0] * disp.r.size[1]];
+ var oldG = disp.g;
disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB);
+ Graphics2D g = (Graphics2D) disp.g.getGraphics();
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g.setColor(Color.BLACK);
+ g.clearRect(0, 0, disp.r.size[0], disp.r.size[1]);
+ double oldRatio = (double) oldSize[0] / (double) oldSize[1];
+ double newRatio = (double) newSize[0] / (double) newSize[1];
+ int newFrameWidth;
+ int newFrameHeight = 0;
+ if ((int) (oldRatio * 100) == (int) (newRatio * 100)) {
+ newFrameWidth = newSize[0];
+ newFrameHeight = newSize[1];
+ } else {
+ newFrameWidth = oldSize[0];
+ newFrameHeight = oldSize[1];
+ }
+ g.drawImage(oldG, 0, 0, newFrameWidth, newFrameHeight, null);
+ forceRepaint = true;
+ display.repaint();
return newSize;
});
@@ -97,7 +120,7 @@ public class SwingWindow extends JFrame {
addComponentListener(new ComponentListener() {
@Override
public void componentHidden(final ComponentEvent e) {
- Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.destroy();
+ sendPowerOffSignal();
}
@Override
@@ -105,12 +128,15 @@ public class SwingWindow extends JFrame {
@Override
public void componentResized(final ComponentEvent e) {
+ if (windowShown) {
onResize.submit(new Integer[] { c.getWidth() / mult, c.getHeight() / mult });
+ }
}
@Override
public void componentShown(final ComponentEvent e) {
- if (Engine.getPlatform().getSettings().isDebugEnabled())
+ SwingWindow.this.windowShown = true;
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled())
SwingWindow.this.centerWindow();
}
});
@@ -133,60 +159,11 @@ public class SwingWindow extends JFrame {
}
});
- c.addMouseMotionListener(new MouseMotionListener() {
- @Override
- public void mouseDragged(final MouseEvent e) {
- final Insets wp = SwingWindow.this.getInsets();
- final TouchPoint p = new TouchPoint(0, e.getX() - wp.left, e.getY() - wp.top, 5, 5, 1, 0);
- final ObjectArrayList touches = new ObjectArrayList<>();
- final ObjectArrayList changedTouches = new ObjectArrayList<>();
- touches.add(p);
- changedTouches.add(p);
- final TouchMoveEvent tse = new TouchMoveEvent(changedTouches, touches);
- Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(tse);
- }
-
- @Override
- public void mouseMoved(final MouseEvent e) {}
- });
- c.addMouseListener(new MouseListener() {
- @Override
- public void mouseClicked(final MouseEvent e) {}
-
- @Override
- public void mousePressed(final MouseEvent e) {
- final Insets wp = SwingWindow.this.getInsets();
- final TouchPoint p = new TouchPoint(0, e.getX() - wp.left, e.getY() - wp.top, 5, 5, 1, 0);
- final ObjectArrayList touches = new ObjectArrayList<>();
- final ObjectArrayList changedTouches = new ObjectArrayList<>();
- touches.add(p);
- changedTouches.add(p);
- final TouchStartEvent tse = new TouchStartEvent(changedTouches, touches);
- Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(tse);
- }
-
- @Override
- public void mouseReleased(final MouseEvent e) {
- final Insets wp = SwingWindow.this.getInsets();
- final TouchPoint p = new TouchPoint(0, e.getX() - wp.left, e.getY() - wp.top, 5, 5, 1, 0);
- final ObjectArrayList touches = new ObjectArrayList<>();
- final ObjectArrayList changedTouches = new ObjectArrayList<>();
- changedTouches.add(p);
- final TouchEndEvent tse = new TouchEndEvent(changedTouches, touches);
- Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(tse);
- }
-
- @Override
- public void mouseEntered(final MouseEvent e) {}
-
- @Override
- public void mouseExited(final MouseEvent e) {}
- });
StaticVars.windowZoom$.subscribe((newZoomValue) -> {
if (newZoomValue != mult) {
mult = (int) newZoomValue.floatValue();
onResize.submit(new Integer[] { getWWidth(), getWHeight() });
- Engine.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed");
+ WarpPI.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed");
}
});
}
@@ -225,6 +202,10 @@ public class SwingWindow extends JFrame {
for (int a = 4; a >= 0; a--)
createBtn(a, b);
createBlankBox();
+
+ var size = super.getSize();
+ super.setSize(size.width, size.height + buttonsPanelContainer.getHeight());
+ super.pack();
}
private void createBlankBox() {
@@ -235,7 +216,7 @@ public class SwingWindow extends JFrame {
}
private void createBtn(final int row, final int col) throws IOException, URISyntaxException {
- final BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png"));
+ final BufferedImage img = ImageIO.read(WarpPI.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png"));
final SwingAdvancedButton b = new SwingAdvancedButton(img, new Dimension((int) (BTN_SIZE * 1.5), BTN_SIZE));
b.drawDefaultComponent = false;
b.setText(Keyboard.getKeyName(row, col));
@@ -328,6 +309,7 @@ public class SwingWindow extends JFrame {
return onResize$;
}
+ @Deprecated
@Override
public void setSize(final int width, final int height) {
c.setSize(new Dimension(width * mult, height * mult));
@@ -340,10 +322,12 @@ public class SwingWindow extends JFrame {
}
public int getWWidth() {
+ if (!windowShown) return defaultWidth;
return c.getWidth() / mult;
}
public int getWHeight() {
+ if (!windowShown) return defaultHeight;
return c.getHeight() / mult;
}
@@ -358,6 +342,12 @@ public class SwingWindow extends JFrame {
super.setLocation(x, y);
}
+ public void sendPowerOffSignal() {
+ display.destroyEngine();
+ this.setVisible(false);
+ this.dispose();
+ }
+
// private static ObjectArrayList mediaValori = new ObjectArrayList();
public class CustomCanvas extends JPanel {
@@ -371,7 +361,9 @@ public class SwingWindow extends JFrame {
public void paintComponent(final Graphics g) {
// long time1 = System.nanoTime();
if (renderingLoop != null) {
- renderingLoop.refresh();
+ boolean forceRepaint = SwingWindow.this.forceRepaint;
+ SwingWindow.this.forceRepaint = false;
+ renderingLoop.refresh(forceRepaint);
final int[] a = ((DataBufferInt) display.g.getRaster().getDataBuffer()).getData();
diff --git a/engine-jogl/.classpath b/engine-jogl/.classpath
index c9dea96e..df3014d2 100644
--- a/engine-jogl/.classpath
+++ b/engine-jogl/.classpath
@@ -18,8 +18,9 @@
-
+
+
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLDisplayOutputDevice.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLDisplayOutputDevice.java
new file mode 100644
index 00000000..d83de615
--- /dev/null
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLDisplayOutputDevice.java
@@ -0,0 +1,21 @@
+package it.cavallium.warppi.gui.graphicengine.impl.jogl;
+
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+
+public class JOGLDisplayOutputDevice implements DisplayOutputDevice {
+ private JOGLEngine engine;
+
+ public JOGLDisplayOutputDevice() {
+ this.engine = new JOGLEngine();
+ }
+
+ @Override
+ public int[] getDisplaySize() {
+ return engine.getSize();
+ }
+
+ @Override
+ public JOGLEngine getGraphicEngine() {
+ return engine;
+ }
+}
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java
index f8336b47..be1ce901 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLEngine.java
@@ -8,10 +8,11 @@ import java.util.Map.Entry;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Semaphore;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.util.texture.Texture;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
@@ -33,9 +34,12 @@ public class JOGLEngine implements GraphicEngine {
protected LinkedList registeredTextures;
protected LinkedList unregisteredTextures;
+ public JOGLEngine() {
+ }
+
@Override
public int[] getSize() {
- return size;
+ return size.clone();
}
@Override
@@ -71,19 +75,28 @@ public class JOGLEngine implements GraphicEngine {
public void create(final Runnable onInitialized) {
initialized = false;
created = false;
- size = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] };
+ this.getSize();
+ size = new int[] { this.getSize()[0], this.getSize()[1] };
created = true;
registeredTextures = new LinkedList<>();
unregisteredTextures = new LinkedList<>();
r = new JOGLRenderer();
wnd = new NEWTWindow(this);
wnd.create();
- setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
- setResizable(Engine.getPlatform().getSettings().isDebugEnabled());
+ setDisplayMode(this.getSize()[0], this.getSize()[1]);
+ setResizable(WarpPI.getPlatform().getSettings().isDebugEnabled());
initialized = true;
wnd.onInitialized = onInitialized;
}
+ /**
+ * INTERNAL USE ONLY!
+ * @return
+ */
+ public GLWindow getGLWindow() {
+ return wnd.window;
+ }
+
@Override
public EventSubscriber onResize() {
return wnd.onResizeEvent;
@@ -118,7 +131,7 @@ public class JOGLEngine implements GraphicEngine {
@Override
public void repaint() {
if (d != null & r != null && JOGLRenderer.gl != null)
- d.refresh();
+ d.refresh(false);
}
@Override
@@ -131,7 +144,8 @@ public class JOGLEngine implements GraphicEngine {
for (final Entry entry : fontCache.entrySet())
if (entry.getKey().equals(name))
return entry.getValue();
- final JOGLFont font = new JOGLFont(this, name);
+ final JOGLFont font = new JOGLFont(name);
+ this.registerFont(font);
fontCache.put(name, font);
return font;
}
@@ -141,21 +155,15 @@ public class JOGLEngine implements GraphicEngine {
for (final Entry entry : fontCache.entrySet())
if (entry.getKey().equals(name))
return entry.getValue();
- final JOGLFont font = new JOGLFont(this, path, name);
+ final JOGLFont font = new JOGLFont(path, name);
+ this.registerFont(font);
fontCache.put(name, font);
return font;
}
@Override
public Skin loadSkin(final String file) throws IOException {
- return new JOGLSkin(this, file);
- }
-
- @Override
- public void waitForExit() {
- try {
- exitSemaphore.acquire();
- } catch (final InterruptedException e) {}
+ return new JOGLSkin(file);
}
@Override
@@ -180,8 +188,12 @@ public class JOGLEngine implements GraphicEngine {
return false;
}
- public void registerFont(final JOGLFont gpuFont) {
- registeredFonts.add(gpuFont);
+ private void registerFont(final BinaryFont gpuFont) {
+ if (gpuFont instanceof JOGLFont || gpuFont == null) {
+ registeredFonts.add(gpuFont);
+ } else {
+ throw new IllegalArgumentException("Can't handle font type " + gpuFont.getClass().getSimpleName());
+ }
}
@Override
@@ -197,5 +209,4 @@ public class JOGLEngine implements GraphicEngine {
public void registerTexture(final Texture t) {
unregisteredTextures.addLast(t);
}
-
}
\ No newline at end of file
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLFont.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLFont.java
index 3e02de0d..7528329b 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLFont.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLFont.java
@@ -12,9 +12,9 @@ import ar.com.hjg.pngj.ImageInfo;
import ar.com.hjg.pngj.ImageLineHelper;
import ar.com.hjg.pngj.ImageLineInt;
import ar.com.hjg.pngj.PngWriter;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class JOGLFont implements BinaryFont {
@@ -35,13 +35,12 @@ public class JOGLFont implements BinaryFont {
private boolean initialized = false;
private File tmpFont;
- JOGLFont(final GraphicEngine g, final String name) throws IOException {
- this(g, null, name);
+ JOGLFont(final String name) throws IOException {
+ this(null, name);
}
- public JOGLFont(final GraphicEngine g, final String path, final String name) throws IOException {
+ public JOGLFont(final String path, final String name) throws IOException {
load(path, name);
- ((JOGLEngine) g).registerFont(this);
}
@Override
@@ -63,10 +62,10 @@ public class JOGLFont implements BinaryFont {
intervalsTotalSize = font.intervalsTotalSize;
boolean[][] rawchars = font.rawchars;
font = null;
- Engine.getPlatform().gc();
+ WarpPI.getPlatform().gc();
pregenTexture(rawchars);
rawchars = null;
- Engine.getPlatform().gc();
+ WarpPI.getPlatform().gc();
}
public int[] getCharIndexes(final String txt) {
@@ -154,7 +153,7 @@ public class JOGLFont implements BinaryFont {
}
chars = null;
png.end();
- Engine.getPlatform().gc();
+ WarpPI.getPlatform().gc();
try {
memoryWidth = w;
@@ -164,7 +163,7 @@ public class JOGLFont implements BinaryFont {
textureH = h;
outputStream.flush();
outputStream.close();
- Engine.getPlatform().gc();
+ WarpPI.getPlatform().gc();
tmpFont = f;
} catch (GLException | IOException e) {
e.printStackTrace();
@@ -185,17 +184,17 @@ public class JOGLFont implements BinaryFont {
}
@Override
- public void initialize(final GraphicEngine d) {
+ public void initialize(final DisplayOutputDevice d) {
genTexture();
tmpFont = null;
initialized = true;
}
@Override
- public void use(final GraphicEngine d) {
+ public void use(final DisplayOutputDevice d) {
if (!initialized)
initialize(d);
- final JOGLRenderer r = (JOGLRenderer) d.getRenderer();
+ final JOGLRenderer r = (JOGLRenderer) d.getGraphicEngine().getRenderer();
r.currentFont = this;
r.useTexture(texture, textureW, textureH);
}
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLRenderer.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLRenderer.java
index 6cdea1f2..db5287c6 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLRenderer.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLRenderer.java
@@ -17,7 +17,7 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.Renderer;
@@ -272,7 +272,7 @@ public class JOGLRenderer implements Renderer {
final int imgW = img.getWidth();
final int imgH = img.getHeight();
img = null;
- Engine.getPlatform().gc();
+ WarpPI.getPlatform().gc();
return new OpenedTextureData(imgW, imgH, f, isResource);
}
@@ -301,7 +301,7 @@ public class JOGLRenderer implements Renderer {
final Texture tex = TextureIO.newTexture(f, false);
if (deleteOnExit && f.exists())
try {
- if (Engine.getPlatform().getSettings().isDebugEnabled())
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled())
throw new IOException("Delete on exit!");
f.delete();
} catch (final Exception ex) {
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLSkin.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLSkin.java
index 08e15a86..89730ed4 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLSkin.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/JOGLSkin.java
@@ -8,8 +8,8 @@ import java.nio.file.Paths;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.texture.Texture;
-import it.cavallium.warppi.Engine;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLRenderer.OpenedTextureData;
@@ -23,21 +23,21 @@ public class JOGLSkin implements Skin {
private boolean initialized = false;
private boolean isResource;
- JOGLSkin(final GraphicEngine d, final String file) throws IOException {
+ JOGLSkin(final String file) throws IOException {
load(file);
}
@Override
public void load(final String file) throws IOException {
final boolean isResource = !Files.exists(Paths.get(file));
- if (isResource && Engine.getPlatform().getStorageUtils().getResourceStream(file) == null)
+ if (isResource && WarpPI.getPlatform().getStorageUtils().getResourceStream(file) == null)
throw new IOException("File '" + file + "' not found!");
texturePath = file;
this.isResource = isResource;
}
@Override
- public void initialize(final GraphicEngine d) {
+ public void initialize(final DisplayOutputDevice d) {
try {
final OpenedTextureData i = JOGLRenderer.openTexture(texturePath, isResource);
t = JOGLRenderer.importTexture(i.f, i.deleteOnExit);
@@ -52,10 +52,10 @@ public class JOGLSkin implements Skin {
}
@Override
- public void use(final GraphicEngine d) {
+ public void use(final DisplayOutputDevice d) {
if (!initialized)
initialize(d);
- final JOGLRenderer r = (JOGLRenderer) d.getRenderer();
+ final JOGLRenderer r = (JOGLRenderer) d.getGraphicEngine().getRenderer();
r.useTexture(t, w, h);
}
diff --git a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java
index f5e074b0..22d51ac3 100644
--- a/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java
+++ b/engine-jogl/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/jogl/NEWTWindow.java
@@ -28,12 +28,8 @@
package it.cavallium.warppi.gui.graphicengine.impl.jogl;
-import java.util.List;
-
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
-import com.jogamp.newt.event.MouseEvent;
-import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.event.WindowUpdateEvent;
@@ -50,17 +46,12 @@ import com.jogamp.opengl.fixedfunc.GLPointerFunc;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.texture.Texture;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.StaticVars;
-import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.event.Key;
-import it.cavallium.warppi.event.TouchEndEvent;
-import it.cavallium.warppi.event.TouchMoveEvent;
-import it.cavallium.warppi.event.TouchPoint;
-import it.cavallium.warppi.event.TouchStartEvent;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.util.EventSubmitter;
-import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/**
*
@@ -70,47 +61,44 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class NEWTWindow implements GLEventListener {
- private final JOGLEngine disp;
+ private final JOGLEngine engine;
private final JOGLRenderer renderer;
public GLWindow window;
public volatile float windowZoom = 1;
public int[] realWindowSize;
public Runnable onInitialized;
public volatile boolean refreshViewport;
- public List touches = new ObjectArrayList<>();
final EventSubmitter onRealResize;
final EventSubmitter onResizeEvent = EventSubmitter.create();
private final EventSubmitter onZoom = EventSubmitter.create();
private final EventSubmitter onGLContext = EventSubmitter.create();
- public NEWTWindow(final JOGLEngine disp) {
- this.disp = disp;
- renderer = disp.getRenderer();
- disp.size[0] = StaticVars.screenSize[0];
- disp.size[1] = StaticVars.screenSize[1];
- realWindowSize = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] };
+ public NEWTWindow(final JOGLEngine engine) {
+ this.engine = engine;
+ renderer = engine.getRenderer();
+ engine.size[0] = engine.getSize()[0];
+ engine.size[1] = engine.getSize()[1];
+ realWindowSize = new int[] { engine.getSize()[0], engine.getSize()[1] };
windowZoom = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
- onRealResize = EventSubmitter.create(new Integer[] { (int) (StaticVars.screenSize[0] * windowZoom), (int) (StaticVars.screenSize[1] * windowZoom) });
+ onRealResize = BehaviorSubject.create(new Integer[] { (int) (engine.getSize()[0] * windowZoom), (int) (engine.getSize()[1] * windowZoom) });
onRealResize.subscribe((realSize) -> {
realWindowSize[0] = realSize[0];
realWindowSize[1] = realSize[1];
- disp.size[0] = realSize[0] / (int) windowZoom;
- disp.size[1] = realSize[1] / (int) windowZoom;
- onResizeEvent.submit(new Integer[] { disp.size[0], disp.size[1] });
+ engine.size[0] = realSize[0] / (int) windowZoom;
+ engine.size[1] = realSize[1] / (int) windowZoom;
+ onResizeEvent.onNext(new Integer[] { engine.size[0], engine.size[1] });
refreshViewport = true;
});
- StaticVars.windowZoom$.subscribe((zoom) -> {
- onZoom.submit(zoom);
- });
+ StaticVars.windowZoom$.subscribe(onZoom::onNext);
onZoom.subscribe((z) -> {
if (windowZoom != 0) {
windowZoom = z;
- disp.size[0] = (int) (realWindowSize[0] / windowZoom);
- disp.size[1] = (int) (realWindowSize[1] / windowZoom);
- StaticVars.screenSize[0] = disp.size[0];
- StaticVars.screenSize[1] = disp.size[1];
+ engine.size[0] = (int) (realWindowSize[0] / windowZoom);
+ engine.size[1] = (int) (realWindowSize[1] / windowZoom);
+ engine.getSize()[0] = engine.size[0];
+ engine.getSize()[1] = engine.size[1];
refreshViewport = true;
}
});
@@ -123,7 +111,7 @@ class NEWTWindow implements GLEventListener {
System.err.println("Le OpenGL non sono presenti su questo computer!");
return;
}
- if (Engine.getPlatform().getSettings().isDebugEnabled())
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled())
System.setProperty("jnlp.newt.window.icons", "res/icons/calculator-016.png res/icons/calculator-018.png res/icons/calculator-256.png");
final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES1));
System.out.println("Loaded OpenGL");
@@ -148,7 +136,6 @@ class NEWTWindow implements GLEventListener {
@Override
public void windowDestroyed(final WindowEvent e) {
- final GraphicEngine engine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
if (engine.isInitialized())
engine.destroy();
}
@@ -314,112 +301,6 @@ class NEWTWindow implements GLEventListener {
}
}
});
- glWindow.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseClicked(final MouseEvent e) {
-// List newPoints = new ObjectArrayList<>();
-// List changedPoints = new ObjectArrayList<>();
-// List oldPoints = touches;
-// int[] xs = e.getAllX();
-// int[] ys = e.getAllY();
-// float[] ps = e.getAllPressures();
-// short[] is = e.getAllPointerIDs();
-// for (int i = 0; i < e.getPointerCount(); i++) {
-// newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
-// }
-//
-// changedPoints.add(newPoints.get(0));
-// newPoints.remove(0);
-// touches = newPoints;
-// Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
-// Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
- }
-
- @Override
- public void mouseEntered(final MouseEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void mouseExited(final MouseEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void mousePressed(final MouseEvent e) {
- final List newPoints = new ObjectArrayList<>();
- final List changedPoints = new ObjectArrayList<>();
- @SuppressWarnings("unused")
- final List oldPoints = touches;
- final int[] xs = e.getAllX();
- final int[] ys = e.getAllY();
- final float[] ps = e.getAllPressures();
- final short[] is = e.getAllPointerIDs();
- for (int i = 0; i < e.getPointerCount(); i++)
- newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
- changedPoints.add(newPoints.get(0));
- touches = newPoints;
- Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
- }
-
- @Override
- public void mouseReleased(final MouseEvent e) {
- final List newPoints = new ObjectArrayList<>();
- final List changedPoints = new ObjectArrayList<>();
- @SuppressWarnings("unused")
- final List oldPoints = touches;
- final int[] xs = e.getAllX();
- final int[] ys = e.getAllY();
- final float[] ps = e.getAllPressures();
- final short[] is = e.getAllPointerIDs();
- for (int i = 0; i < e.getPointerCount(); i++)
- newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
- changedPoints.add(newPoints.get(0));
- newPoints.remove(0);
- touches = newPoints;
- Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchEnd(new TouchEndEvent(changedPoints, touches));
- }
-
- @Override
- public void mouseMoved(final MouseEvent e) {}
-
- private long lastDraggedTime = 0;
-
- @Override
- public void mouseDragged(final MouseEvent e) {
- final long curTime = System.currentTimeMillis();
- if (curTime - lastDraggedTime > 50) {
- lastDraggedTime = curTime;
- final List newPoints = new ObjectArrayList<>();
- final List changedPoints = new ObjectArrayList<>();
- final List oldPoints = touches;
- final int[] xs = e.getAllX();
- final int[] ys = e.getAllY();
- final float[] ps = e.getAllPressures();
- final short[] is = e.getAllPointerIDs();
- for (int i = 0; i < e.getPointerCount(); i++)
- newPoints.add(Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().makePoint(is[i], xs[i], ys[i], disp.getWidth(), disp.getHeight(), 5, 5, ps[i], 0));
- newPoints.forEach((newp) -> {
- oldPoints.forEach((oldp) -> {
- if (newp.getID() == oldp.getID())
- if (newp.equals(oldp) == false)
- changedPoints.add(newp);
- });
- });
- touches = newPoints;
- Engine.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchMove(new TouchMoveEvent(changedPoints, touches));
- }
- }
-
- @Override
- public void mouseWheelMoved(final MouseEvent e) {
-
- }
-
- });
glWindow.addGLEventListener(this /* GLEventListener */);
final Animator animator = new Animator();
@@ -432,7 +313,7 @@ class NEWTWindow implements GLEventListener {
final GL2ES1 gl = drawable.getGL().getGL2ES1();
onGLContext.submit(gl);
- if (Engine.getPlatform().getSettings().isDebugEnabled())
+ if (WarpPI.getPlatform().getSettings().isDebugEnabled())
//Vsync
gl.setSwapInterval(1);
else
@@ -451,7 +332,7 @@ class NEWTWindow implements GLEventListener {
//gl.glEnable(GL.GL_MULTISAMPLE);
try {
- renderer.currentTex = ((JOGLSkin) disp.loadSkin("/test.png")).t;
+ renderer.currentTex = ((JOGLSkin) engine.loadSkin("/test.png")).t;
} catch (final Exception e) {
e.printStackTrace();
}
@@ -487,21 +368,21 @@ class NEWTWindow implements GLEventListener {
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
- gl.glOrtho(0.0, disp.size[0], disp.size[1], 0.0, -1, 1);
+ gl.glOrtho(0.0, engine.size[0], engine.size[1], 0.0, -1, 1);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity();
- for (final Texture t : disp.registeredTextures) {
+ for (final Texture t : engine.registeredTextures) {
t.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, linear ? GL.GL_LINEAR : GL.GL_NEAREST);
t.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
}
}
- while (disp.unregisteredTextures.isEmpty() == false) {
- final Texture t = disp.unregisteredTextures.pop();
+ while (engine.unregisteredTextures.isEmpty() == false) {
+ final Texture t = engine.unregisteredTextures.pop();
t.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, linear ? GL.GL_LINEAR : GL.GL_NEAREST);
t.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
- disp.registeredTextures.addLast(t);
+ engine.registeredTextures.addLast(t);
}
gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
@@ -510,7 +391,7 @@ class NEWTWindow implements GLEventListener {
renderer.initDrawCycle();
- disp.repaint();
+ engine.repaint();
renderer.endDrawCycle();
diff --git a/hardware/.classpath b/hardware/.classpath
index c9dea96e..df3014d2 100644
--- a/hardware/.classpath
+++ b/hardware/.classpath
@@ -18,8 +18,9 @@
-
+
+
diff --git a/hardware/src/main/java/it/cavallium/warppi/device/input/PIHardwareTouchDevice.java b/hardware/src/main/java/it/cavallium/warppi/device/input/PIHardwareTouchDevice.java
new file mode 100644
index 00000000..2d9935eb
--- /dev/null
+++ b/hardware/src/main/java/it/cavallium/warppi/device/input/PIHardwareTouchDevice.java
@@ -0,0 +1,128 @@
+package it.cavallium.warppi.device.input;
+
+import java.util.List;
+import java.util.concurrent.SubmissionPublisher;
+import java.util.function.Consumer;
+
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.opengl.GLWindow;
+
+import it.cavallium.warppi.event.TouchEndEvent;
+import it.cavallium.warppi.event.TouchEvent;
+import it.cavallium.warppi.event.TouchMoveEvent;
+import it.cavallium.warppi.event.TouchPoint;
+import it.cavallium.warppi.event.TouchStartEvent;
+import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
+
+public class PIHardwareTouchDevice implements TouchInputDevice {
+
+ private final boolean invertXY, invertX, invertY;
+ private final SubmissionPublisher touchEventPublisher = new SubmissionPublisher<>();
+ private final JOGLEngine engine;
+ private GLWindow window;
+ public List touches = new ObjectArrayList<>();
+ private long lastDraggedTime = 0;
+
+ public PIHardwareTouchDevice(final boolean invertXY, final boolean invertX, final boolean invertY, JOGLEngine joglEngine) {
+ this.invertXY = invertXY;
+ this.invertX = invertX;
+ this.invertY = invertY;
+ this.engine = joglEngine;
+ }
+
+ @Override
+ public void initialize() {
+ this.window = engine.getGLWindow();
+
+ window.addMouseListener(new MouseListener() {
+ @Override
+ public void mousePressed(final MouseEvent e) {
+ final List newPoints = new ObjectArrayList<>();
+ final List changedPoints = new ObjectArrayList<>();
+ @SuppressWarnings("unused")
+ final List oldPoints = touches;
+ final int[] xs = e.getAllX();
+ final int[] ys = e.getAllY();
+ final float[] ps = e.getAllPressures();
+ final short[] is = e.getAllPointerIDs();
+ for (int i = 0; i < e.getPointerCount(); i++)
+ newPoints.add(PIHardwareTouchDevice.this.makePoint(is[i], xs[i], ys[i], engine.getWidth(), engine.getHeight(), 5, 5, ps[i], 0));
+ changedPoints.add(newPoints.get(0));
+ touches = newPoints;
+ PIHardwareTouchDevice.this.touchEventPublisher.submit(new TouchStartEvent(changedPoints, touches));
+ }
+
+ @Override
+ public void mouseReleased(final MouseEvent e) {
+ final List newPoints = new ObjectArrayList<>();
+ final List changedPoints = new ObjectArrayList<>();
+ @SuppressWarnings("unused")
+ final List oldPoints = touches;
+ final int[] xs = e.getAllX();
+ final int[] ys = e.getAllY();
+ final float[] ps = e.getAllPressures();
+ final short[] is = e.getAllPointerIDs();
+ for (int i = 0; i < e.getPointerCount(); i++)
+ newPoints.add(PIHardwareTouchDevice.this.makePoint(is[i], xs[i], ys[i], engine.getWidth(), engine.getHeight(), 5, 5, ps[i], 0));
+ changedPoints.add(newPoints.get(0));
+ newPoints.remove(0);
+ touches = newPoints;
+ PIHardwareTouchDevice.this.touchEventPublisher.submit(new TouchEndEvent(changedPoints, touches));
+ }
+
+ @Override
+ public void mouseDragged(final MouseEvent e) {
+ final long curTime = System.currentTimeMillis();
+ if (curTime - lastDraggedTime > 50) {
+ lastDraggedTime = curTime;
+ final List newPoints = new ObjectArrayList<>();
+ final List changedPoints = new ObjectArrayList<>();
+ final List oldPoints = touches;
+ final int[] xs = e.getAllX();
+ final int[] ys = e.getAllY();
+ final float[] ps = e.getAllPressures();
+ final short[] is = e.getAllPointerIDs();
+ for (int i = 0; i < e.getPointerCount(); i++)
+ newPoints.add(PIHardwareTouchDevice.this.makePoint(is[i], xs[i], ys[i], engine.getWidth(), engine.getHeight(), 5, 5, ps[i], 0));
+ newPoints.forEach((newp) -> {
+ oldPoints.forEach((oldp) -> {
+ if (newp.getID() == oldp.getID())
+ if (newp.equals(oldp) == false)
+ changedPoints.add(newp);
+ });
+ });
+ touches = newPoints;
+ PIHardwareTouchDevice.this.touchEventPublisher.submit(new TouchMoveEvent(changedPoints, touches));
+ }
+ }
+
+ @Override public void mouseClicked(final MouseEvent e) { }
+ @Override public void mouseEntered(final MouseEvent e) { }
+ @Override public void mouseExited(final MouseEvent e) { }
+ @Override public void mouseMoved(final MouseEvent e) {}
+ @Override public void mouseWheelMoved(final MouseEvent e) { }
+ });
+ }
+
+ @Override
+ public boolean getSwappedAxes() {
+ return invertXY;
+ }
+
+ @Override
+ public boolean getInvertedX() {
+ return invertX;
+ }
+
+ @Override
+ public boolean getInvertedY() {
+ return invertY;
+ }
+
+ @Override
+ public void listenTouchEvents(Consumer touchEventListener) {
+ touchEventPublisher.consume(touchEventListener);
+ }
+}
diff --git a/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBFont.java b/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBFont.java
index 115fad26..480cc4b6 100644
--- a/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBFont.java
+++ b/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBFont.java
@@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class FBFont extends RFTFont {
@@ -16,7 +16,7 @@ public class FBFont extends RFTFont {
}
@Override
- public void use(final GraphicEngine d) {
+ public void use(final DisplayOutputDevice d) {
@SuppressWarnings("unused")
final FBEngine dfb = (FBEngine) d;
// TODO: implement
diff --git a/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBSkin.java b/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBSkin.java
index 4ad36356..919b1c06 100644
--- a/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBSkin.java
+++ b/hardware/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/framebuffer/FBSkin.java
@@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin;
public class FBSkin extends PngSkin {
@@ -12,7 +12,7 @@ public class FBSkin extends PngSkin {
}
@Override
- public void use(final GraphicEngine d) {
+ public void use(final DisplayOutputDevice d) {
@SuppressWarnings("unused")
final FBEngine dfb = (FBEngine) d;
// TODO: implement
diff --git a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java
index 4e3c78c8..c13ff359 100644
--- a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java
+++ b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java
@@ -11,8 +11,17 @@ import java.util.List;
import java.util.Map;
import it.cavallium.warppi.Platform;
+import it.cavallium.warppi.boot.StartupArguments;
+import it.cavallium.warppi.device.DeviceStateDevice;
+import it.cavallium.warppi.device.display.BacklightOutputDevice;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
+import it.cavallium.warppi.device.display.NoDisplaysAvailableException;
+import it.cavallium.warppi.device.input.KeyboardInputDevice;
+import it.cavallium.warppi.device.input.PIHardwareTouchDevice;
+import it.cavallium.warppi.device.input.TouchInputDevice;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.framebuffer.FBEngine;
+import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLDisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
import it.cavallium.warppi.util.Error;
@@ -26,6 +35,11 @@ public class HardwarePlatform implements Platform {
private final Map el;
private final HardwareSettings settings;
private Boolean runningOnRaspberryOverride = null;
+ private StartupArguments args;
+ private DisplayOutputDevice displayOutputDevice;
+ private BacklightOutputDevice backlightOutputDevice;
+ private KeyboardInputDevice keyboardInputDevice;
+ private TouchInputDevice touchInputDevice;
public HardwarePlatform() {
cu = new HardwareConsoleUtils();
@@ -122,16 +136,6 @@ public class HardwarePlatform implements Platform {
return new HardwareURLClassLoader(urls);
}
- @Override
- public Map getEnginesList() {
- return el;
- }
-
- @Override
- public GraphicEngine getEngine(final String string) throws NullPointerException {
- return el.get(string);
- }
-
@Override
public void throwNewExceptionInInitializerError(final String text) {
throw new ExceptionInInitializerError();
@@ -194,4 +198,62 @@ public class HardwarePlatform implements Platform {
*/
}
+ @Override
+ public TouchInputDevice getTouchInputDevice() {
+ return touchInputDevice;
+ }
+
+ @Override
+ public KeyboardInputDevice getKeyboardInputDevice() {
+ return keyboardInputDevice;
+ }
+
+ @Override
+ public DisplayOutputDevice getDisplayOutputDevice() {
+ return displayOutputDevice;
+ }
+
+ @Override
+ public BacklightOutputDevice getBacklightOutputDevice() {
+ return backlightOutputDevice;
+ }
+
+ @Override
+ public void setArguments(StartupArguments args) {
+ this.args = args;
+ this.chooseDevices();
+ }
+
+ private void chooseDevices() {
+ List availableDevices = new ArrayList<>();
+ List guiDevices = List.of(new JOGLDisplayOutputDevice());
+ List consoleDevices = List.of();
+
+ if (args.isMSDOSModeEnabled() || args.isNoGUIEngineForced()) {
+ availableDevices.addAll(consoleDevices);
+ }
+ if (!args.isNoGUIEngineForced()) {
+ availableDevices.addAll(guiDevices);
+ }
+
+ if (availableDevices.size() == 0) {
+ throw new NoDisplaysAvailableException();
+ }
+
+ for (DisplayOutputDevice device : availableDevices) {
+ if (device instanceof JOGLDisplayOutputDevice) {
+ if (args.isGPUEngineForced()) {
+ this.displayOutputDevice = device;
+ break;
+ }
+ }
+ }
+
+ if (this.displayOutputDevice == null) this.displayOutputDevice = availableDevices.get(0);
+
+ if (displayOutputDevice instanceof JOGLDisplayOutputDevice) {
+ this.touchInputDevice = new PIHardwareTouchDevice(false, false, false, (JOGLEngine) displayOutputDevice.getGraphicEngine());
+ }
+ }
+
}
diff --git a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java
index 4dbc0217..eba01289 100644
--- a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java
+++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java
@@ -17,10 +17,10 @@ import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.dom.html.HTMLInputElement;
import org.teavm.jso.dom.xml.NodeList;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Platform.Semaphore;
-import it.cavallium.warppi.device.Keyboard;
+import it.cavallium.warppi.device.input.Keyboard;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
@@ -85,7 +85,7 @@ public class HtmlEngine implements GraphicEngine {
@Override
public void create(final Runnable onInitialized) {
- exitSemaphore = Engine.getPlatform().newSemaphore(0);
+ exitSemaphore = WarpPI.getPlatform().newSemaphore(0);
width = -1;
height = -1;
canvas = (HTMLCanvasElement) HtmlEngine.document.createElement("canvas");
@@ -276,8 +276,8 @@ public class HtmlEngine implements GraphicEngine {
e.printStackTrace();
}
});
- Engine.getPlatform().setThreadName(th, "Canvas rendering thread");
- Engine.getPlatform().setThreadDaemon(th);
+ WarpPI.getPlatform().setThreadName(th, "Canvas rendering thread");
+ WarpPI.getPlatform().setThreadDaemon(th);
th.start();
}
@@ -315,7 +315,7 @@ public class HtmlEngine implements GraphicEngine {
@Override
public boolean isSupported() {
- return Engine.getPlatform().isJavascript();
+ return WarpPI.getPlatform().isJavascript();
}
@Override
diff --git a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java
index b66f448d..4d272edd 100644
--- a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java
+++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java
@@ -7,7 +7,7 @@ import org.teavm.jso.canvas.CanvasRenderingContext2D;
import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class HtmlFont extends RFTFont {
@@ -47,9 +47,9 @@ public class HtmlFont extends RFTFont {
}
@Override
- public void use(final GraphicEngine d) {
- if (d.getRenderer() instanceof HtmlRenderer)
- ((HtmlRenderer) d.getRenderer()).f = this;
+ public void use(final DisplayOutputDevice d) {
+ if (d.getGraphicEngine().getRenderer() instanceof HtmlRenderer)
+ ((HtmlRenderer) d.getGraphicEngine().getRenderer()).f = this;
}
}
\ No newline at end of file
diff --git a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java
index 0f2297be..5ea8e60f 100644
--- a/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java
+++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java
@@ -9,9 +9,9 @@ import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.dom.html.HTMLImageElement;
-import it.cavallium.warppi.Engine;
+import it.cavallium.warppi.WarpPI;
import it.cavallium.warppi.Platform.Semaphore;
-import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.Skin;
public class HtmlSkin implements Skin {
@@ -29,7 +29,7 @@ public class HtmlSkin implements Skin {
}
@Override
- public void use(final GraphicEngine d) {
+ public void use(final DisplayOutputDevice d) {
if (d instanceof HtmlEngine) {
if (!initd)
initialize(d);
@@ -39,11 +39,11 @@ public class HtmlSkin implements Skin {
@Override
public void load(String file) throws IOException {
- url = Engine.getPlatform().getStorageUtils().getBasePath() + (!file.startsWith("/") ? "/" : "") + file;
+ url = WarpPI.getPlatform().getStorageUtils().getBasePath() + (!file.startsWith("/") ? "/" : "") + file;
}
@Override
- public void initialize(final GraphicEngine d) {
+ public void initialize(final DisplayOutputDevice d) {
final HTMLDocument doc = Window.current().getDocument();
Boolean[] done = new Boolean[]{false};
imgEl = doc.createElement("img").cast();
diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java
index e47f6428..47d16bc5 100644
--- a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java
+++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java
@@ -11,6 +11,7 @@ import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.html.HTMLDocument;
import it.cavallium.warppi.Platform;
+import it.cavallium.warppi.device.display.DisplayOutputDevice;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.html.HtmlEngine;
import it.cavallium.warppi.util.Error;
@@ -123,12 +124,12 @@ public class TeaVMPlatform implements Platform {
}
@Override
- public Map getEnginesList() {
+ public Map getGraphicEnginesList() {
return el;
}
@Override
- public GraphicEngine getEngine(final String string) throws NullPointerException {
+ public DisplayOutputDevice getGraphicEngine(final String string) throws NullPointerException {
return el.get(string);
}
diff --git a/util/.classpath b/util/.classpath
index 4559ca0b..5e65e726 100644
--- a/util/.classpath
+++ b/util/.classpath
@@ -8,13 +8,14 @@
+
-
-
+
+
diff --git a/util/src/main/java/it/cavallium/warppi/util/Error.java b/util/src/main/java/it/cavallium/warppi/util/Error.java
index 0fd7a345..5ef807a2 100644
--- a/util/src/main/java/it/cavallium/warppi/util/Error.java
+++ b/util/src/main/java/it/cavallium/warppi/util/Error.java
@@ -1,6 +1,6 @@
package it.cavallium.warppi.util;
-public class Error extends java.lang.Throwable {
+public class Error extends java.lang.Exception {
/**
*