Implemented TouchDevice and DeviceStateDevice
This commit is contained in:
parent
87d4daf195
commit
9e1e751a59
@ -9,6 +9,8 @@ import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
@ -62,6 +64,8 @@ public interface Platform {
|
||||
DisplayOutputDevice getDisplayOutputDevice();
|
||||
|
||||
BacklightOutputDevice getBacklightOutputDevice();
|
||||
|
||||
DeviceStateDevice getDeviceStateDevice();
|
||||
|
||||
void throwNewExceptionInInitializerError(String text);
|
||||
|
||||
@ -211,4 +215,6 @@ public interface Platform {
|
||||
|
||||
}
|
||||
|
||||
void setArguments(StartupArguments args);
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,14 @@ 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;
|
||||
@ -57,6 +60,9 @@ public class WarpPI {
|
||||
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);
|
||||
|
||||
@ -71,8 +77,9 @@ public class WarpPI {
|
||||
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);
|
||||
device = new Device(dm, im, deviceState);
|
||||
device.setup();
|
||||
onLoading.run();
|
||||
this.loadingCompleted();
|
||||
@ -135,8 +142,12 @@ public class WarpPI {
|
||||
|
||||
|
||||
private void loadingCompleted() {
|
||||
WarpPI.INSTANCE.loaded.onNext(true);
|
||||
WarpPI.INSTANCE.device.getDisplayManager().waitForExit();
|
||||
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) {
|
||||
|
@ -3,9 +3,8 @@ 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.input.PIHardwareTouchDevice;
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
import it.cavallium.warppi.Platform;
|
||||
import it.cavallium.warppi.gui.CalculatorHUD;
|
||||
import it.cavallium.warppi.gui.screens.LoadingScreen;
|
||||
import it.cavallium.warppi.math.rules.RulesManager;
|
||||
|
@ -7,10 +7,12 @@ 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) {
|
||||
public Device(final DisplayManager m, final InputManager im, final DeviceStateDevice dm) {
|
||||
displayManager = m;
|
||||
inputManager = im;
|
||||
deviceState = dm;
|
||||
}
|
||||
|
||||
public DisplayManager getDisplayManager() {
|
||||
@ -20,9 +22,17 @@ public class Device {
|
||||
public InputManager getInputManager() {
|
||||
return inputManager;
|
||||
}
|
||||
|
||||
public DeviceStateDevice getDeviceStateDevice() {
|
||||
return deviceState;
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
displayManager.initialize();
|
||||
inputManager.initialize();
|
||||
deviceState.initialize();
|
||||
|
||||
inputManager.getTouchDevice().listenTouchEvents(displayManager.getTouchEventListener());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package it.cavallium.warppi.device;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public interface DeviceStateDevice {
|
||||
|
||||
void initialize();
|
||||
|
||||
Future<?> waitForExit();
|
||||
|
||||
void powerOff();
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package it.cavallium.warppi.device.display;
|
||||
|
||||
public class NoDisplaysAvailableException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -8,8 +8,6 @@ public class InputManager {
|
||||
this.keyboard = keyboard;
|
||||
this.touchDevice = touchscreen;
|
||||
}
|
||||
|
||||
// TODO: manage the keyboard and the touchscreen here!
|
||||
|
||||
public KeyboardInputDevice getKeyboard() {
|
||||
return keyboard;
|
||||
@ -19,4 +17,9 @@ public class InputManager {
|
||||
return touchDevice;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
this.keyboard.initialize();
|
||||
this.touchDevice.initialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -925,7 +925,7 @@ public class Keyboard {
|
||||
} else {
|
||||
switch (k) {
|
||||
case POWEROFF:
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.destroy();
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDeviceStateDevice().powerOff();
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
|
@ -2,4 +2,6 @@ package it.cavallium.warppi.device.input;
|
||||
|
||||
public interface KeyboardInputDevice {
|
||||
|
||||
void initialize();
|
||||
|
||||
}
|
||||
|
@ -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<TouchEvent> 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);
|
||||
}
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
package it.cavallium.warppi.device.input;
|
||||
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
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 TouchInputDevice {
|
||||
|
||||
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 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchStart(e)) {
|
||||
refresh = true;
|
||||
} else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEnd(final TouchEndEvent e) {
|
||||
final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchEnd(e)) {
|
||||
refresh = true;
|
||||
} else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchCancel(final TouchCancelEvent e) {
|
||||
final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchCancel(e)) {
|
||||
refresh = true;
|
||||
} else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchMove(final TouchMoveEvent e) {
|
||||
final Screen scr = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchMove(e)) {
|
||||
refresh = true;
|
||||
} else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
WarpPI.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);
|
||||
}
|
||||
}
|
@ -1,10 +1,14 @@
|
||||
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 extends TouchEventListener {
|
||||
boolean getInvertedXY();
|
||||
public interface TouchInputDevice {
|
||||
boolean getSwappedAxes();
|
||||
|
||||
boolean getInvertedX();
|
||||
|
||||
@ -16,6 +20,24 @@ public interface TouchInputDevice extends TouchEventListener {
|
||||
|
||||
default void setInvertedY() {}
|
||||
|
||||
TouchPoint makePoint(long id, float x, float y, int maxX, int maxY, float radiusX, float radiusY, float force,
|
||||
float rotationAngle);
|
||||
void listenTouchEvents(Consumer<TouchEvent> 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();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.Platform.ConsoleUtils;
|
||||
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;
|
||||
@ -48,30 +49,30 @@ public class MarioScreen extends Screen {
|
||||
public void graphicInitialized() {
|
||||
try {
|
||||
if (MarioScreen.skin == null) {
|
||||
MarioScreen.skin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioskin.png");
|
||||
MarioScreen.skin = d.display.getGraphicEngine().loadSkin("/marioskin.png");
|
||||
}
|
||||
if (MarioScreen.groundskin == null) {
|
||||
MarioScreen.groundskin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioground.png");
|
||||
MarioScreen.groundskin = d.display.getGraphicEngine().loadSkin("/marioground.png");
|
||||
}
|
||||
if (MarioScreen.gpuTest2 == null) {
|
||||
try {
|
||||
MarioScreen.gpuTest2 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest2");
|
||||
MarioScreen.gpuTest2 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest2");
|
||||
} catch (final Exception ex) {}
|
||||
}
|
||||
if (MarioScreen.gpuTest1 == null) {
|
||||
try {
|
||||
MarioScreen.gpuTest1 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest1");
|
||||
MarioScreen.gpuTest1 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest1");
|
||||
} catch (final Exception ex2) {}
|
||||
}
|
||||
}
|
||||
if (MarioScreen.gpuTest3 == null) {
|
||||
try {
|
||||
MarioScreen.gpuTest3 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioskin.png");
|
||||
MarioScreen.skin = d.display.getGraphicEngine().loadSkin("/marioskin.png");
|
||||
}
|
||||
if (MarioScreen.groundskin == null) {
|
||||
MarioScreen.groundskin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadSkin("/marioground.png");
|
||||
MarioScreen.groundskin = d.display.getGraphicEngine().loadSkin("/marioground.png");
|
||||
}
|
||||
if (MarioScreen.gpuTest2 == null) {
|
||||
try {
|
||||
MarioScreen.gpuTest2 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest2");
|
||||
MarioScreen.gpuTest2 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest2");
|
||||
} catch (final Exception ex) {}
|
||||
}
|
||||
if (MarioScreen.gpuTest1 == null) {
|
||||
try {
|
||||
MarioScreen.gpuTest1 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("N:\\gputest\\gputest1");
|
||||
MarioScreen.gpuTest1 = d.display.getGraphicEngine().loadFont("N:\\gputest\\gputest1");
|
||||
} catch (final Exception ex2) {}
|
||||
}
|
||||
}
|
||||
if (MarioScreen.gpuTest3 == null) {
|
||||
try {
|
||||
MarioScreen.gpuTest3 = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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;
|
||||
}
|
||||
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
|
||||
d.renderer.glClearColor(0xff000000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
DisplayOutputDevice display = d.display;
|
||||
if (errored) {
|
||||
WarpPI.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(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
MarioScreen.groundskin.use(d.display);
|
||||
final MarioWorld w = g.getCurrentWorld();
|
||||
final int width = w.getWidth();
|
||||
final int height = w.getHeight();
|
||||
final float screenX = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() / 2f - 8f;
|
||||
final float screenY = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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;
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xff9290ff);
|
||||
d.renderer.glColor(0xff9290ff);
|
||||
}
|
||||
WarpPI.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;
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
|
||||
d.renderer.glColor(0xffffffff);
|
||||
}
|
||||
WarpPI.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;
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
|
||||
d.renderer.glColor(0xffffffff);
|
||||
}
|
||||
|
||||
//DRAW MARIO
|
||||
MarioScreen.skin.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
WarpPI.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) {
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(1, 1, 1);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - (MarioScreen.gpuTest12 ? 512 : 256), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), MarioScreen.gpuTest12 ? 512 : 256, MarioScreen.gpuTest12 ? 512 : 256);
|
||||
MarioScreen.gpuTest1.use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(0, 0, 0);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth(), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f);
|
||||
WarpPI.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(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF000000);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "A");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF800000);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "B");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeea28e);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "C");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFee7255);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "D");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeac0b0);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "E");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFf3d8ce);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "F");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFffede7);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class TetrisScreen extends Screen {
|
||||
e = d.display;
|
||||
r = d.renderer;
|
||||
if (TetrisScreen.skin == null) {
|
||||
TetrisScreen.skin = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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) {
|
||||
WarpPI.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;
|
||||
|
@ -4,6 +4,7 @@ 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.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||
import it.cavallium.warppi.gui.graphicengine.Skin;
|
||||
import it.cavallium.warppi.gui.screens.Screen;
|
||||
@ -39,7 +40,8 @@ public class CalculatorHUD extends HUD {
|
||||
@Override
|
||||
public void renderTopmostBackground() {
|
||||
final Renderer r = d.renderer;
|
||||
final DisplayOutputDevice engine = d.display;
|
||||
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 DisplayOutputDevice engine = d.display;
|
||||
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 {
|
||||
@ -71,7 +74,7 @@ public class CalculatorHUD extends HUD {
|
||||
|
||||
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 {
|
||||
WarpPI.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
|
||||
}
|
||||
@ -82,18 +85,18 @@ public class CalculatorHUD extends HUD {
|
||||
final boolean canGoForward = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward();
|
||||
|
||||
if (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
|
||||
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,15 +104,15 @@ 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 (WarpPI.getPlatform().getSettings().isDebugEnabled()) {
|
||||
@ -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());
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ 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.WarpPI;
|
||||
import it.cavallium.warppi.Platform.ConsoleUtils;
|
||||
@ -11,9 +13,15 @@ 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.flow.Observable;
|
||||
import it.cavallium.warppi.flow.Pair;
|
||||
import it.cavallium.warppi.flow.Subscription;
|
||||
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
|
||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||
@ -348,11 +356,11 @@ public final class DisplayManager implements RenderingLoop {
|
||||
fnt.use(display);
|
||||
}
|
||||
renderer.glColor3i(129, 28, 22);
|
||||
renderer.glDrawStringRight(StaticVars.screenSize[0] - 2,
|
||||
StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2),
|
||||
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) {
|
||||
@ -363,7 +371,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
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] != graphicEngine.getRenderer().getCurrentFont()) {
|
||||
fonts[0].use(display);
|
||||
@ -434,8 +442,8 @@ public final class DisplayManager implements RenderingLoop {
|
||||
|
||||
if (pair.getRight() != null) {
|
||||
final Integer[] windowSize = pair.getRight();
|
||||
StaticVars.screenSize[0] = windowSize[0];
|
||||
StaticVars.screenSize[1] = windowSize[1];
|
||||
display.getDisplaySize()[0] = windowSize[0];
|
||||
display.getDisplaySize()[1] = windowSize[1];
|
||||
}
|
||||
|
||||
screen.beforeRender((float) (dt / 1000d));
|
||||
@ -491,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() {
|
||||
graphicEngine.waitForExit();
|
||||
public Consumer<TouchEvent> 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -21,8 +21,8 @@ public class GUIErrorMessage {
|
||||
}
|
||||
|
||||
public void draw(final DisplayOutputDevice g, final Renderer r, final String msg) {
|
||||
final int scrW = g.getWidth();
|
||||
final int scrH = g.getHeight();
|
||||
final int scrW = g.getGraphicEngine().getWidth();
|
||||
final int scrH = g.getGraphicEngine().getHeight();
|
||||
final int width = 200;
|
||||
final int height = 20;
|
||||
final int margin = 4;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
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() {
|
||||
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(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
|
||||
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(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringCenter(display.getDisplaySize()[0] / 2, display.getDisplaySize()[1] / 2 - 20, "WORK IN PROGRESS.");
|
||||
|
||||
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(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
|
||||
WarpPI.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.");
|
||||
WarpPI.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.");
|
||||
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(StaticVars.screenSize[0] / 2, StaticVars.screenSize[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, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,7 +35,7 @@ public class KeyboardDebugScreen extends Screen {
|
||||
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") {
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
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;
|
||||
@ -53,13 +54,14 @@ public class LoadingScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
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(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
|
||||
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);
|
||||
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
|
||||
WarpPI.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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class MathInputScreen extends Screen {
|
||||
calc = new MathContext();
|
||||
|
||||
try {
|
||||
BlockContainer.initializeFonts(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("norm"), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.loadFont("smal"));
|
||||
BlockContainer.initializeFonts(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().loadFont("norm"), WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getGraphicEngine().loadFont("smal"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
WarpPI.getPlatform().exit(1);
|
||||
@ -156,14 +156,14 @@ public class MathInputScreen extends Screen {
|
||||
final int size = 32;
|
||||
final int posY = computingAnimationIndex % 2;
|
||||
final int posX = (computingAnimationIndex - posY) / 2;
|
||||
renderer.glFillRect(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - size - 4, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display);
|
||||
renderer.glColor3f(0.75f, 0, 0);
|
||||
renderer.glDrawStringRight(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - 4 - size - 4, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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(WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display, renderer, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.getWidth() - result.getWidth() - 2, WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
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() {
|
||||
DisplayOutputDevice display = d.display;
|
||||
WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
|
||||
WarpPI.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.");
|
||||
WarpPI.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.");
|
||||
WarpPI.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.");
|
||||
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(StaticVars.screenSize[0] / 2, StaticVars.screenSize[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, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ 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.LinkedList;
|
||||
import java.util.List;
|
||||
@ -13,14 +14,21 @@ import java.util.Map;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
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.JOGLDisplayOutputDevice;
|
||||
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.gui.graphicengine.impl.swing.SwingSkin;
|
||||
import it.cavallium.warppi.util.CacheUtils;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import net.lingala.zip4j.core.ZipFile;
|
||||
@ -36,6 +44,9 @@ public class DesktopPlatform implements Platform {
|
||||
private final String on;
|
||||
private final DesktopSettings settings;
|
||||
private Boolean runningOnRaspberryOverride = null;
|
||||
private StartupArguments args;
|
||||
private DisplayOutputDevice displayOutputDevice;
|
||||
private DeviceStateDevice deviceStateDevice;
|
||||
|
||||
public DesktopPlatform() {
|
||||
cu = new DesktopConsoleUtils();
|
||||
@ -206,10 +217,11 @@ 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 (WarpPI.getPlatform().isJavascript())
|
||||
return false;
|
||||
@ -239,16 +251,57 @@ public class DesktopPlatform implements Platform {
|
||||
|
||||
@Override
|
||||
public DisplayOutputDevice getDisplayOutputDevice() {
|
||||
return displayOutput
|
||||
new SwingEngine();
|
||||
new JOGLEngine();
|
||||
List<DisplayOutputDevice> availableDevices = new LinkedList<>();
|
||||
return this.displayOutputDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BacklightOutputDevice getBacklightOutputDevice() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
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<DisplayOutputDevice> availableDevices = new ArrayList<>();
|
||||
List<DisplayOutputDevice> guiDevices = List.of(new SwingDisplayOutputDevice(), new JOGLDisplayOutputDevice());
|
||||
List<DisplayOutputDevice> 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);
|
||||
|
||||
this.deviceStateDevice = null; //TODO: Implement device state that listen exit signal from swing
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphicEngine getGraphicEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDisplaySize() {
|
||||
return engine.getSize();
|
||||
}
|
||||
}
|
@ -18,8 +18,9 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
|
@ -0,0 +1,22 @@
|
||||
package it.cavallium.warppi.gui.graphicengine.impl.jogl;
|
||||
|
||||
import it.cavallium.warppi.device.display.DisplayOutputDevice;
|
||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -8,10 +8,12 @@ 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.WarpPI;
|
||||
import it.cavallium.warppi.device.display.DisplayOutputDevice;
|
||||
import it.cavallium.warppi.StaticVars;
|
||||
import it.cavallium.warppi.flow.Observable;
|
||||
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
|
||||
@ -21,6 +23,7 @@ import it.cavallium.warppi.gui.graphicengine.Skin;
|
||||
|
||||
public class JOGLEngine implements GraphicEngine {
|
||||
|
||||
private final JOGLDisplayOutputDevice display;
|
||||
private volatile boolean initialized;
|
||||
private volatile boolean created;
|
||||
private NEWTWindow wnd;
|
||||
@ -33,6 +36,10 @@ public class JOGLEngine implements GraphicEngine {
|
||||
protected LinkedList<Texture> registeredTextures;
|
||||
protected LinkedList<Texture> unregisteredTextures;
|
||||
|
||||
public JOGLEngine(JOGLDisplayOutputDevice display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSize() {
|
||||
return size;
|
||||
@ -71,19 +78,27 @@ public class JOGLEngine implements GraphicEngine {
|
||||
public void create(final Runnable onInitialized) {
|
||||
initialized = false;
|
||||
created = false;
|
||||
size = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] };
|
||||
size = new int[] { display.getDisplaySize()[0], display.getDisplaySize()[1] };
|
||||
created = true;
|
||||
registeredTextures = new LinkedList<>();
|
||||
unregisteredTextures = new LinkedList<>();
|
||||
r = new JOGLRenderer();
|
||||
wnd = new NEWTWindow(this);
|
||||
wnd = new NEWTWindow(display);
|
||||
wnd.create();
|
||||
setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
|
||||
setDisplayMode(display.getDisplaySize()[0], display.getDisplaySize()[1]);
|
||||
setResizable(WarpPI.getPlatform().getSettings().isDebugEnabled());
|
||||
initialized = true;
|
||||
wnd.onInitialized = onInitialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USE ONLY!
|
||||
* @return
|
||||
*/
|
||||
public GLWindow getGLWindow() {
|
||||
return wnd.window;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<Integer[]> onResize() {
|
||||
return wnd.onResizeEvent;
|
||||
@ -131,7 +146,7 @@ public class JOGLEngine implements GraphicEngine {
|
||||
for (final Entry<String, JOGLFont> entry : fontCache.entrySet())
|
||||
if (entry.getKey().equals(name))
|
||||
return entry.getValue();
|
||||
final JOGLFont font = new JOGLFont(this, name);
|
||||
final JOGLFont font = new JOGLFont(display, name);
|
||||
fontCache.put(name, font);
|
||||
return font;
|
||||
}
|
||||
@ -141,14 +156,14 @@ public class JOGLEngine implements GraphicEngine {
|
||||
for (final Entry<String, JOGLFont> entry : fontCache.entrySet())
|
||||
if (entry.getKey().equals(name))
|
||||
return entry.getValue();
|
||||
final JOGLFont font = new JOGLFont(this, path, name);
|
||||
final JOGLFont font = new JOGLFont(display, path, name);
|
||||
fontCache.put(name, font);
|
||||
return font;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skin loadSkin(final String file) throws IOException {
|
||||
return new JOGLSkin(this, file);
|
||||
return new JOGLSkin(display, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,13 +35,13 @@ public class JOGLFont implements BinaryFont {
|
||||
private boolean initialized = false;
|
||||
private File tmpFont;
|
||||
|
||||
JOGLFont(final DisplayOutputDevice g, final String name) throws IOException {
|
||||
JOGLFont(final JOGLDisplayOutputDevice g, final String name) throws IOException {
|
||||
this(g, null, name);
|
||||
}
|
||||
|
||||
public JOGLFont(final DisplayOutputDevice g, final String path, final String name) throws IOException {
|
||||
public JOGLFont(final JOGLDisplayOutputDevice g, final String path, final String name) throws IOException {
|
||||
load(path, name);
|
||||
((JOGLEngine) g).registerFont(this);
|
||||
g.getGraphicEngine().registerFont(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -195,7 +195,7 @@ public class JOGLFont implements BinaryFont {
|
||||
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);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class JOGLSkin implements Skin {
|
||||
private boolean initialized = false;
|
||||
private boolean isResource;
|
||||
|
||||
JOGLSkin(final DisplayOutputDevice d, final String file) throws IOException {
|
||||
JOGLSkin(final JOGLDisplayOutputDevice d, final String file) throws IOException {
|
||||
load(file);
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ import it.cavallium.warppi.event.TouchStartEvent;
|
||||
import it.cavallium.warppi.flow.BehaviorSubject;
|
||||
import it.cavallium.warppi.flow.SimpleSubject;
|
||||
import it.cavallium.warppi.flow.Subject;
|
||||
import it.cavallium.warppi.gui.DisplayManager;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
/**
|
||||
@ -72,35 +73,36 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
class NEWTWindow implements GLEventListener {
|
||||
|
||||
private final JOGLEngine disp;
|
||||
private final DisplayOutputDevice display;
|
||||
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<TouchPoint> touches = new ObjectArrayList<>();
|
||||
|
||||
final BehaviorSubject<Integer[]> onRealResize;
|
||||
final BehaviorSubject<Integer[]> onResizeEvent = BehaviorSubject.create();
|
||||
private final BehaviorSubject<Float> onZoom = BehaviorSubject.create();
|
||||
private final Subject<GL2ES1> onGLContext = SimpleSubject.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 JOGLDisplayOutputDevice display) {
|
||||
this.display = display;
|
||||
this.engine = display.getGraphicEngine();
|
||||
renderer = engine.getRenderer();
|
||||
engine.size[0] = display.getDisplaySize()[0];
|
||||
engine.size[1] = display.getDisplaySize()[1];
|
||||
realWindowSize = new int[] { display.getDisplaySize()[0], display.getDisplaySize()[1] };
|
||||
windowZoom = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
|
||||
onRealResize = BehaviorSubject.create(new Integer[] { (int) (StaticVars.screenSize[0] * windowZoom), (int) (StaticVars.screenSize[1] * windowZoom) });
|
||||
onRealResize = BehaviorSubject.create(new Integer[] { (int) (display.getDisplaySize()[0] * windowZoom), (int) (display.getDisplaySize()[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.onNext(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) -> {
|
||||
@ -109,10 +111,10 @@ class NEWTWindow implements GLEventListener {
|
||||
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);
|
||||
display.getDisplaySize()[0] = engine.size[0];
|
||||
display.getDisplaySize()[1] = engine.size[1];
|
||||
refreshViewport = true;
|
||||
}
|
||||
});
|
||||
@ -150,7 +152,6 @@ class NEWTWindow implements GLEventListener {
|
||||
|
||||
@Override
|
||||
public void windowDestroyed(final WindowEvent e) {
|
||||
final DisplayOutputDevice engine = WarpPI.INSTANCE.getHardwareDevice().getDisplayManager().display;
|
||||
if (engine.isInitialized())
|
||||
engine.destroy();
|
||||
}
|
||||
@ -316,112 +317,6 @@ class NEWTWindow implements GLEventListener {
|
||||
}
|
||||
}
|
||||
});
|
||||
glWindow.addMouseListener(new MouseListener() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent e) {
|
||||
// List<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
// List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
// List<TouchPoint> 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<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
@SuppressWarnings("unused")
|
||||
final List<TouchPoint> 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(WarpPI.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;
|
||||
WarpPI.INSTANCE.getHardwareDevice().getInputManager().getTouchDevice().onTouchStart(new TouchStartEvent(changedPoints, touches));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(final MouseEvent e) {
|
||||
final List<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
@SuppressWarnings("unused")
|
||||
final List<TouchPoint> 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(WarpPI.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;
|
||||
WarpPI.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<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> 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(WarpPI.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;
|
||||
WarpPI.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();
|
||||
@ -453,7 +348,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();
|
||||
}
|
||||
@ -489,21 +384,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);
|
||||
@ -512,7 +407,7 @@ class NEWTWindow implements GLEventListener {
|
||||
|
||||
renderer.initDrawCycle();
|
||||
|
||||
disp.repaint();
|
||||
engine.repaint();
|
||||
|
||||
renderer.endDrawCycle();
|
||||
|
||||
|
@ -18,8 +18,9 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
|
@ -0,0 +1,132 @@
|
||||
package it.cavallium.warppi.device.input;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Flow.Subscriber;
|
||||
import java.util.concurrent.SubmissionPublisher;
|
||||
|
||||
import com.jogamp.newt.event.MouseEvent;
|
||||
import com.jogamp.newt.event.MouseListener;
|
||||
import com.jogamp.newt.opengl.GLWindow;
|
||||
|
||||
import it.cavallium.warppi.WarpPI;
|
||||
import it.cavallium.warppi.device.input.TouchInputDevice;
|
||||
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.TouchPoint;
|
||||
import it.cavallium.warppi.event.TouchStartEvent;
|
||||
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
|
||||
import it.cavallium.warppi.gui.screens.Screen;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class PIHardwareTouchDevice implements TouchInputDevice {
|
||||
|
||||
private final boolean invertXY, invertX, invertY;
|
||||
private final SubmissionPublisher<TouchEvent> touchEventPublisher = new SubmissionPublisher<>();
|
||||
private final JOGLEngine engine;
|
||||
private GLWindow window;
|
||||
public List<TouchPoint> 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<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
@SuppressWarnings("unused")
|
||||
final List<TouchPoint> 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<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
@SuppressWarnings("unused")
|
||||
final List<TouchPoint> 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<TouchPoint> newPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> changedPoints = new ObjectArrayList<>();
|
||||
final List<TouchPoint> 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(Subscriber<TouchEvent> touchEventListener) {
|
||||
touchEventPublisher.subscribe(touchEventListener);
|
||||
}
|
||||
}
|
@ -4,14 +4,22 @@ import java.io.File;
|
||||
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 it.cavallium.warppi.Platform;
|
||||
import it.cavallium.warppi.boot.StartupArguments;
|
||||
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;
|
||||
import net.lingala.zip4j.core.ZipFile;
|
||||
@ -22,18 +30,21 @@ public class HardwarePlatform implements Platform {
|
||||
|
||||
private final HardwareConsoleUtils cu;
|
||||
private final HardwareGpio gi;
|
||||
private final HardwareKeyboard hk;
|
||||
private final HardwareStorageUtils su;
|
||||
private final ImageUtils pu;
|
||||
private final String on;
|
||||
private final Map<String, GraphicEngine> 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();
|
||||
gi = new HardwareGpio();
|
||||
hk = new HardwareKeyboard();
|
||||
su = new HardwareStorageUtils();
|
||||
pu = new HardwareImageUtils();
|
||||
on = System.getProperty("os.name").toLowerCase();
|
||||
@ -53,11 +64,6 @@ public class HardwarePlatform implements Platform {
|
||||
return gi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardInputDevice getHardwareKeyboard() {
|
||||
return gi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageUtils getStorageUtils() {
|
||||
return su;
|
||||
@ -131,16 +137,6 @@ public class HardwarePlatform implements Platform {
|
||||
return new HardwareURLClassLoader(urls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, GraphicEngine> getGraphicEnginesList() {
|
||||
return el;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayOutputDevice getGraphicEngine(final String string) throws NullPointerException {
|
||||
return el.get(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void throwNewExceptionInInitializerError(final String text) {
|
||||
throw new ExceptionInInitializerError();
|
||||
@ -238,4 +234,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<DisplayOutputDevice> availableDevices = new ArrayList<>();
|
||||
List<DisplayOutputDevice> guiDevices = List.of(new JOGLDisplayOutputDevice());
|
||||
List<DisplayOutputDevice> 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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user