Added touch support and events. Refined hardware related classes

This commit is contained in:
Andrea Cavalli 2018-06-30 18:46:53 +02:00
parent d16d4e0e99
commit 6e327f0eb1
41 changed files with 988 additions and 301 deletions

View File

@ -4,6 +4,9 @@ import java.io.IOException;
import org.warp.picalculator.deps.DGpio;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.HardwareTouchDevice;
import org.warp.picalculator.device.InputManager;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.PIHardwareDisplay;
import org.warp.picalculator.gui.CalculatorHUD;
@ -30,17 +33,42 @@ public class Main {
beforeStart();
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
PlatformUtils.setThreadName(Thread.currentThread(), "Main thread");
new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
afterStart();
DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
Keyboard k = new Keyboard();
HardwareTouchDevice touch = new HardwareTouchDevice() {
@Override
public boolean getInvertedY() {
return false;
}
@Override
public boolean getInvertedXY() {
return false;
}
@Override
public boolean getInvertedX() {
return false;
}
};
InputManager im = new InputManager(k, touch);
HardwareDevice hardwareDevice = new HardwareDevice(dm, im);
hardwareDevice.setup(() -> {
try {
HardwareDevice.INSTANCE.getDisplayManager().setBrightness(0.2f);
RulesManager.initialize();
RulesManager.warmUp();
if (screen instanceof LoadingScreen) {
((LoadingScreen) screen).loaded = true;
}
DisplayManager.INSTANCE.waitForExit();
HardwareDevice.INSTANCE.getDisplayManager().waitForExit();
} catch (InterruptedException | Error e) {
e.printStackTrace();
}
ConsoleUtils.out.println(1, "Shutdown...");
beforeShutdown();
ConsoleUtils.out.println(1, "");
ConsoleUtils.out.println(1, "Closed.");
DSystem.exit(0);
});
}
public void beforeStart() throws IOException {
@ -101,13 +129,6 @@ public class Main {
Utils.msDosMode = true;
}
}
Keyboard.startKeyboard();
}
public void afterStart() throws InterruptedException, Error {
DisplayManager.INSTANCE.setBrightness(0.2f);
RulesManager.initialize();
RulesManager.warmUp();
}
public void beforeShutdown() {

View File

@ -4,9 +4,11 @@ import java.io.IOException;
import org.warp.picalculator.deps.DEngine;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.KeyboardEventListener;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.gui.expression.InputContext;
import org.warp.picalculator.gui.expression.blocks.BlockContainer;
import org.warp.picalculator.gui.expression.containers.NormalInputContainer;
@ -29,12 +31,13 @@ public class TestGPU {
Utils.debugThirdScreen = false;
d.create();
Keyboard.startKeyboard();
Keyboard.setAdditionalKeyboardListener(new KeyboardEventListener() {
Keyboard k = new Keyboard();
k.startKeyboard();
k.setAdditionalKeyboardListener(new KeyboardEventListener() {
@Override
public boolean keyPressed(Key k) {
public boolean onKeyPressed(KeyPressedEvent k) {
try {
switch (k) {
switch (k.getKey()) {
case LEFT:
c.moveLeft();
return true;
@ -124,7 +127,7 @@ public class TestGPU {
}
@Override
public boolean keyReleased(Key k) {
public boolean onKeyReleased(KeyReleasedEvent k) {
return false;
}

View File

@ -23,6 +23,7 @@ import java.util.Properties;
import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.Rational;
import org.warp.picalculator.deps.StorageUtils;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.math.Function;
@ -408,12 +409,12 @@ public class Utils {
//
// var.draw(x + wsegno, y + (hsegno - h1), null, null);
//
// DisplayManager.INSTANCE.renderer.glDrawLine(x + 1, y + hsegno - 3, x + 1, y + hsegno - 3);
// DisplayManager.INSTANCE.renderer.glDrawLine(x + 2, y + hsegno - 2, x + 2, y + hsegno - 2);
// DisplayManager.INSTANCE.renderer.glDrawLine(x + 3, y + hsegno - 1, x + 3, y + hsegno - 1);
// DisplayManager.INSTANCE.renderer.glDrawLine(x + 3, y + (hsegno - 1) / 2 + 1, x + 3, y + hsegno - 1);
// DisplayManager.INSTANCE.renderer.glDrawLine(x + 4, y, x + 4, y + (hsegno - 1) / 2);
// DisplayManager.INSTANCE.renderer.glDrawLine(x + 4, y, x + 4 + 1 + w1 + 1, y);
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 1, y + hsegno - 3, x + 1, y + hsegno - 3);
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 2, y + hsegno - 2, x + 2, y + hsegno - 2);
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 3, y + hsegno - 1, x + 3, y + hsegno - 1);
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 3, y + (hsegno - 1) / 2 + 1, x + 3, y + hsegno - 1);
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 4, y, x + 4, y + (hsegno - 1) / 2);
// HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawLine(x + 4, y, x + 4 + 1 + w1 + 1, y);
}
public static final int getFontHeight() {
@ -425,7 +426,7 @@ public class Utils {
}
public static final BinaryFont getFont(boolean small, boolean zoomed) {
return DisplayManager.INSTANCE.fonts[getFontIndex(small, zoomed)];
return HardwareDevice.INSTANCE.getDisplayManager().fonts[getFontIndex(small, zoomed)];
}
public static final int getFontIndex(boolean small, boolean zoomed) {
@ -451,19 +452,20 @@ public class Utils {
public static final int getFontHeight(boolean small, boolean zoomed) {
if (small) {
if (zoomed) {
return DisplayManager.INSTANCE.glyphsHeight[3];
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[3];
} else {
return DisplayManager.INSTANCE.glyphsHeight[1];
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[1];
}
} else {
if (zoomed) {
return DisplayManager.INSTANCE.glyphsHeight[2];
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[2];
} else {
return DisplayManager.INSTANCE.glyphsHeight[0];
return HardwareDevice.INSTANCE.getDisplayManager().glyphsHeight[0];
}
}
}
public static byte[] convertStreamToByteArray(InputStream stream, long size) throws IOException {
// check to ensure that file size is not larger than Integer.MAX_VALUE.

View File

@ -0,0 +1,33 @@
package org.warp.picalculator.device;
import org.warp.picalculator.gui.DisplayManager;
public class HardwareDevice {
public static HardwareDevice INSTANCE;
private final DisplayManager displayManager;
private final InputManager inputManager;
public HardwareDevice(DisplayManager m, InputManager im) {
INSTANCE = this;
displayManager = m;
inputManager = im;
}
public DisplayManager getDisplayManager() {
return displayManager;
}
public InputManager getInputManager() {
return inputManager;
}
public void setup(Runnable r) {
displayManager.initialize();
inputManager.getKeyboard().startKeyboard();
Thread t = new Thread(r);
t.setDaemon(false);
t.setName("Main thread (after setup)");
t.start();
}
}

View File

@ -0,0 +1,10 @@
package org.warp.picalculator.device;
public interface HardwareTouchDevice {
public boolean getInvertedXY();
public boolean getInvertedX();
public boolean getInvertedY();
public default void setInvertedXY() {}
public default void setInvertedX() {}
public default void setInvertedY() {}
}

View File

@ -0,0 +1,20 @@
package org.warp.picalculator.device;
public class InputManager {
private final Keyboard keyboard;
private final HardwareTouchDevice touchDevice;
public InputManager(Keyboard k, HardwareTouchDevice t) {
this.keyboard = k;
this.touchDevice = t;
}
public Keyboard getKeyboard() {
return keyboard;
}
public HardwareTouchDevice getTouchDevice() {
return touchDevice;
}
}

View File

@ -7,6 +7,10 @@ import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.chip.ParallelToSerial;
import org.warp.picalculator.device.chip.SerialToParallel;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GUIErrorMessage;
import org.warp.picalculator.gui.screens.KeyboardDebugScreen;
@ -39,7 +43,7 @@ public class Keyboard {
private static KeyboardEventListener additionalListener;
public synchronized static void startKeyboard() {
public synchronized void startKeyboard() {
final Thread kt = new Thread(() -> {
if (StaticVars.debugOn) {
try {
@ -629,17 +633,17 @@ public class Keyboard {
boolean done = false;
if (additionalListener != null) {
try {
done = additionalListener.keyPressed(k);
done = additionalListener.onKeyPressed(new KeyPressedEvent(k));
} catch (final Exception ex) {
new GUIErrorMessage(ex);
}
}
if (DisplayManager.INSTANCE != null) {
final Screen scr = DisplayManager.INSTANCE.getScreen();
if (HardwareDevice.INSTANCE.getDisplayManager() != null) {
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
boolean refresh = false;
boolean scrdone = false;
try {
scrdone = scr.keyPressed(k);
scrdone = scr.onKeyPressed(new KeyPressedEvent(k));
} catch (final Exception ex) {
new GUIErrorMessage(ex);
}
@ -648,7 +652,7 @@ public class Keyboard {
} else {
switch (k) {
case POWEROFF:
DisplayManager.INSTANCE.engine.destroy();
HardwareDevice.INSTANCE.getDisplayManager().engine.destroy();
break;
case NONE:
break;
@ -656,12 +660,12 @@ public class Keyboard {
letterPressed('X');
break;
case BRIGHTNESS_CYCLE:
DisplayManager.INSTANCE.cycleBrightness(false);
HardwareDevice.INSTANCE.getDisplayManager().cycleBrightness(false);
refresh = true;
break;
case BRIGHTNESS_CYCLE_REVERSE:
DisplayManager.INSTANCE.setScreen(new MarioScreen()); //TODO: rimuovere: prova
DisplayManager.INSTANCE.cycleBrightness(true);
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new MarioScreen()); //TODO: rimuovere: prova
HardwareDevice.INSTANCE.getDisplayManager().cycleBrightness(true);
refresh = true;
break;
case ZOOM_MODE:
@ -669,11 +673,11 @@ public class Keyboard {
// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
refresh = true;
case HISTORY_BACK:
DisplayManager.INSTANCE.goBack();
HardwareDevice.INSTANCE.getDisplayManager().goBack();
refresh = true;
break;
case HISTORY_FORWARD:
DisplayManager.INSTANCE.goForward();
HardwareDevice.INSTANCE.getDisplayManager().goForward();
refresh = true;
break;
default:
@ -720,12 +724,12 @@ public class Keyboard {
public synchronized static void keyReleased(Key k) {
boolean done = false;
if (additionalListener != null) {
done = additionalListener.keyReleased(k);
done = additionalListener.onKeyReleased(new KeyReleasedEvent(k));
}
boolean refresh = false;
if (DisplayManager.INSTANCE != null) {
final Screen scr = DisplayManager.INSTANCE.getScreen();
if (scr != null && scr.initialized && scr.keyReleased(k)) {
if (HardwareDevice.INSTANCE.getDisplayManager() != null) {
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
if (scr != null && scr.initialized && scr.onKeyReleased(new KeyReleasedEvent(k))) {
refresh = true;
} else {
switch (k) {
@ -743,7 +747,7 @@ public class Keyboard {
}
}
public static void setAdditionalKeyboardListener(KeyboardEventListener l) {
public void setAdditionalKeyboardListener(KeyboardEventListener l) {
additionalListener = l;
}

View File

@ -1,7 +0,0 @@
package org.warp.picalculator.device;
public interface KeyboardEventListener {
public abstract boolean keyPressed(Key k);
public abstract boolean keyReleased(Key k);
}

View File

@ -0,0 +1,5 @@
package org.warp.picalculator.event;
public interface Event {
}

View File

@ -1,4 +1,4 @@
package org.warp.picalculator.device;
package org.warp.picalculator.event;
public enum Key {
POWEROFF, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK, HISTORY_FORWARD, SURD_MODE, DRG_CYCLE, LETTER_X, LETTER_Y, LETTER_Z, STEP, SIMPLIFY, BRIGHTNESS_CYCLE, BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2, POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI, SETTINGS, F1, F2, F3, F4, BACK, ZOOM_MODE, LOGARITHM, EULER_NUMBER

View File

@ -0,0 +1,5 @@
package org.warp.picalculator.event;
public interface KeyEvent extends Event {
public Key getKey();
}

View File

@ -0,0 +1,16 @@
package org.warp.picalculator.event;
public class KeyPressedEvent implements KeyEvent {
private Key k;
public KeyPressedEvent(Key k) {
this.k = k;
}
@Override
public Key getKey() {
return k;
}
}

View File

@ -0,0 +1,16 @@
package org.warp.picalculator.event;
public class KeyReleasedEvent implements KeyEvent {
private Key k;
public KeyReleasedEvent(Key k) {
this.k = k;
}
@Override
public Key getKey() {
return k;
}
}

View File

@ -0,0 +1,10 @@
package org.warp.picalculator.event;
public interface KeyboardEventListener {
public default boolean onKeyPressed(KeyPressedEvent k) {
return false;
}
public default boolean onKeyReleased(KeyReleasedEvent k) {
return false;
}
}

View File

@ -0,0 +1,62 @@
package org.warp.picalculator.event;
import java.util.List;
public class TouchCancelEvent implements TouchEvent {
private final List<TouchPoint> changedTouches;
private final List<TouchPoint> touches;
public TouchCancelEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
super();
this.changedTouches = changedTouches;
this.touches = touches;
}
@Override
public List<TouchPoint> getChangedTouches() {
return changedTouches;
}
@Override
public List<TouchPoint> getTouches() {
return touches;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TouchCancelEvent other = (TouchCancelEvent) obj;
if (changedTouches == null) {
if (other.changedTouches != null)
return false;
} else if (!changedTouches.equals(other.changedTouches))
return false;
if (touches == null) {
if (other.touches != null)
return false;
} else if (!touches.equals(other.touches))
return false;
return true;
}
@Override
public String toString() {
return "TouchCancelEvent [changedTouches=" + changedTouches + ", touches=" + touches + "]";
}
}

View File

@ -0,0 +1,62 @@
package org.warp.picalculator.event;
import java.util.List;
public class TouchEndEvent implements TouchEvent {
private final List<TouchPoint> changedTouches;
private final List<TouchPoint> touches;
public TouchEndEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
super();
this.changedTouches = changedTouches;
this.touches = touches;
}
@Override
public List<TouchPoint> getChangedTouches() {
return changedTouches;
}
@Override
public List<TouchPoint> getTouches() {
return touches;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TouchEndEvent other = (TouchEndEvent) obj;
if (changedTouches == null) {
if (other.changedTouches != null)
return false;
} else if (!changedTouches.equals(other.changedTouches))
return false;
if (touches == null) {
if (other.touches != null)
return false;
} else if (!touches.equals(other.touches))
return false;
return true;
}
@Override
public String toString() {
return "TouchEndEvent [changedTouches=" + changedTouches + ", touches=" + touches + "]";
}
}

View File

@ -0,0 +1,8 @@
package org.warp.picalculator.event;
import java.util.List;
public interface TouchEvent extends Event {
public List<TouchPoint> getChangedTouches();
public List<TouchPoint> getTouches();
}

View File

@ -0,0 +1,16 @@
package org.warp.picalculator.event;
public interface TouchEventListener {
public default boolean onTouchStart(TouchStartEvent k) {
return false;
}
public default boolean onTouchEnd(TouchEndEvent k) {
return false;
}
public default boolean onTouchCancel(TouchCancelEvent k) {
return false;
}
public default boolean onTouchMove(TouchMoveEvent k) {
return false;
}
}

View File

@ -0,0 +1,62 @@
package org.warp.picalculator.event;
import java.util.List;
public class TouchMoveEvent implements TouchEvent {
private final List<TouchPoint> changedTouches;
private final List<TouchPoint> touches;
public TouchMoveEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
super();
this.changedTouches = changedTouches;
this.touches = touches;
}
@Override
public List<TouchPoint> getChangedTouches() {
return changedTouches;
}
@Override
public List<TouchPoint> getTouches() {
return touches;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TouchMoveEvent other = (TouchMoveEvent) obj;
if (changedTouches == null) {
if (other.changedTouches != null)
return false;
} else if (!changedTouches.equals(other.changedTouches))
return false;
if (touches == null) {
if (other.touches != null)
return false;
} else if (!touches.equals(other.touches))
return false;
return true;
}
@Override
public String toString() {
return "TouchMoveEvent [changedTouches=" + changedTouches + ", touches=" + touches + "]";
}
}

View File

@ -0,0 +1,97 @@
package org.warp.picalculator.event;
public class TouchPoint {
private final float radiusX;
private final float radiusY;
private final float rotationAngle;
private final float force;
private final float x;
private final float y;
private final long id;
public TouchPoint(long id, float x, float y, float radiusX, float radiusY, float force, float rotationAngle) {
super();
this.id = id;
this.radiusX = radiusX;
this.radiusY = radiusY;
this.rotationAngle = rotationAngle;
this.force = force;
this.x = x;
this.y = y;
}
public long getID() {
return id;
}
public float getRadiusX() {
return radiusX;
}
public float getRadiusY() {
return radiusY;
}
public float getRotationAngle() {
return rotationAngle;
}
public float getForce() {
return force;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(force);
result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + Float.floatToIntBits(radiusX);
result = prime * result + Float.floatToIntBits(radiusY);
result = prime * result + Float.floatToIntBits(rotationAngle);
result = prime * result + Float.floatToIntBits(x);
result = prime * result + Float.floatToIntBits(y);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TouchPoint other = (TouchPoint) obj;
if (Float.floatToIntBits(force) != Float.floatToIntBits(other.force))
return false;
if (id != other.id)
return false;
if (Float.floatToIntBits(radiusX) != Float.floatToIntBits(other.radiusX))
return false;
if (Float.floatToIntBits(radiusY) != Float.floatToIntBits(other.radiusY))
return false;
if (Float.floatToIntBits(rotationAngle) != Float.floatToIntBits(other.rotationAngle))
return false;
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
return false;
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
return false;
return true;
}
@Override
public String toString() {
return "TouchPoint [id=" + id + ", radiusX=" + radiusX + ", radiusY=" + radiusY + ", rotationAngle=" + rotationAngle + ", force=" + force + ", x=" + x + ", y=" + y + "]";
}
}

View File

@ -0,0 +1,62 @@
package org.warp.picalculator.event;
import java.util.List;
public class TouchStartEvent implements TouchEvent {
private final List<TouchPoint> changedTouches;
private final List<TouchPoint> touches;
public TouchStartEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
super();
this.changedTouches = changedTouches;
this.touches = touches;
}
@Override
public List<TouchPoint> getChangedTouches() {
return changedTouches;
}
@Override
public List<TouchPoint> getTouches() {
return touches;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TouchStartEvent other = (TouchStartEvent) obj;
if (changedTouches == null) {
if (other.changedTouches != null)
return false;
} else if (!changedTouches.equals(other.changedTouches))
return false;
if (touches == null) {
if (other.touches != null)
return false;
} else if (!touches.equals(other.touches))
return false;
return true;
}
@Override
public String toString() {
return "TouchStartEvent [changedTouches=" + changedTouches + ", touches=" + touches + "]";
}
}

View File

@ -3,6 +3,7 @@ package org.warp.picalculator.gui;
import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Renderer;
@ -80,7 +81,7 @@ public class CalculatorHUD extends HUD {
int padding = 2;
final int brightness = (int) (Math.ceil(DisplayManager.INSTANCE.getBrightness() * 9));
final int brightness = (int) (Math.ceil(HardwareDevice.INSTANCE.getDisplayManager().getBrightness() * 9));
if (brightness <= 10) {
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
} else {
@ -89,8 +90,8 @@ public class CalculatorHUD extends HUD {
padding += 18 + 6;
final boolean canGoBack = DisplayManager.INSTANCE.canGoBack();
final boolean canGoForward = DisplayManager.INSTANCE.canGoForward();
final boolean canGoBack = HardwareDevice.INSTANCE.getDisplayManager().canGoBack();
final boolean canGoForward = HardwareDevice.INSTANCE.getDisplayManager().canGoForward();
if (StaticVars.haxMode) {
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
@ -112,15 +113,15 @@ public class CalculatorHUD extends HUD {
//DRAW BOTTOM
d.renderer.glDrawStringLeft(2, 90, d.displayDebugString);
Utils.getFont(true, false).use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 40);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 80);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 40);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 80);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
Utils.getFont(true, false).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
}
@Override

View File

@ -12,7 +12,15 @@ import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DEngine;
import org.warp.picalculator.deps.DSemaphore;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.TouchCancelEvent;
import org.warp.picalculator.event.TouchEndEvent;
import org.warp.picalculator.event.TouchEvent;
import org.warp.picalculator.event.TouchEventListener;
import org.warp.picalculator.event.TouchMoveEvent;
import org.warp.picalculator.event.TouchStartEvent;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Renderer;
@ -23,8 +31,8 @@ import org.warp.picalculator.gui.screens.Screen;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public final class DisplayManager implements RenderingLoop {
public static DisplayManager INSTANCE;
public final class DisplayManager implements RenderingLoop, TouchEventListener {
private HardwareDevice device;
private float brightness;
public final GraphicEngine engine;
@ -41,22 +49,32 @@ public final class DisplayManager implements RenderingLoop {
private Screen screen;
private final HUD hud;
private final String initialTitle;
private final Screen initialScreen;
public DSemaphore screenChange = new DSemaphore(0);
public String displayDebugString;
public ObjectArrayList<GUIErrorMessage> errorMessages;
/**
* Set to true when an event is fired
*/
private boolean forceRefresh;
public DisplayManager(HardwareDisplay monitor, HUD hud, Screen screen, String title) {
INSTANCE = this;
engine = chooseGraphicEngine();
supportsPauses = engine.doesRefreshPauses();
this.monitor = monitor;
this.hud = hud;
this.initialTitle = title;
this.initialScreen = screen;
monitor.initialize();
glyphsHeight = new int[] { 9, 6, 12, 9 };
displayDebugString = "";
errorMessages = new ObjectArrayList<>();
}
public void initialize() {
monitor.initialize();
try {
hud.d = this;
@ -69,17 +87,18 @@ public final class DisplayManager implements RenderingLoop {
DSystem.exit(0);
}
setScreen(screen);
setScreen(initialScreen);
try {
engine.create();
renderer = engine.getRenderer();
engine.setTitle(title);
engine.setTitle(initialTitle);
loop();
} catch (final Exception ex) {
ex.printStackTrace();
}
monitor.shutdown();
}
/*
* private void load_skin() {
* try {
@ -159,23 +178,23 @@ public final class DisplayManager implements RenderingLoop {
public void setScreen(Screen screen) {
if (screen.initialized == false) {
if (screen.canBeInHistory) {
if (DisplayManager.INSTANCE.currentSession > 0) {
final int sl = DisplayManager.INSTANCE.sessions.length + 5; //TODO: I don't know why if i don't add +5 or more some items disappear
DisplayManager.INSTANCE.sessions = Arrays.copyOfRange(DisplayManager.INSTANCE.sessions, DisplayManager.INSTANCE.currentSession, sl);
if (this.currentSession > 0) {
final int sl = this.sessions.length + 5; //TODO: I don't know why if i don't add +5 or more some items disappear
this.sessions = Arrays.copyOfRange(this.sessions, this.currentSession, sl);
}
DisplayManager.INSTANCE.currentSession = 0;
for (int i = DisplayManager.INSTANCE.sessions.length - 1; i >= 1; i--) {
DisplayManager.INSTANCE.sessions[i] = DisplayManager.INSTANCE.sessions[i - 1];
this.currentSession = 0;
for (int i = this.sessions.length - 1; i >= 1; i--) {
this.sessions[i] = this.sessions[i - 1];
}
DisplayManager.INSTANCE.sessions[0] = screen;
this.sessions[0] = screen;
} else {
DisplayManager.INSTANCE.currentSession = -1;
this.currentSession = -1;
}
}
screen.d = this;
try {
screen.create();
DisplayManager.INSTANCE.screen = screen;
this.screen = screen;
screenChange.release();
if (screen.initialized == false) {
screen.initialize();
@ -189,18 +208,18 @@ public final class DisplayManager implements RenderingLoop {
public void replaceScreen(Screen screen) {
if (screen.initialized == false) {
if (screen.canBeInHistory) {
DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession] = screen;
this.sessions[this.currentSession] = screen;
} else {
DisplayManager.INSTANCE.currentSession = -1;
for (int i = 0; i < DisplayManager.INSTANCE.sessions.length - 2; i++) {
DisplayManager.INSTANCE.sessions[i] = DisplayManager.INSTANCE.sessions[i + 1];
this.currentSession = -1;
for (int i = 0; i < this.sessions.length - 2; i++) {
this.sessions[i] = this.sessions[i + 1];
}
}
}
screen.d = this;
try {
screen.create();
DisplayManager.INSTANCE.screen = screen;
this.screen = screen;
screenChange.release();
if (screen.initialized == false) {
screen.initialize();
@ -212,13 +231,13 @@ public final class DisplayManager implements RenderingLoop {
}
public boolean canGoBack() {
if (DisplayManager.INSTANCE.currentSession == -1) {
return DisplayManager.INSTANCE.sessions[0] != null;
if (this.currentSession == -1) {
return this.sessions[0] != null;
}
if (DisplayManager.INSTANCE.screen != DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession]) {
if (this.screen != this.sessions[this.currentSession]) {
} else if (DisplayManager.INSTANCE.currentSession + 1 < DisplayManager.INSTANCE.sessions.length) {
if (DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession + 1] != null) {
} else if (this.currentSession + 1 < this.sessions.length) {
if (this.sessions[this.currentSession + 1] != null) {
} else {
return false;
@ -226,7 +245,7 @@ public final class DisplayManager implements RenderingLoop {
} else {
return false;
}
if (DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession] != null) {
if (this.sessions[this.currentSession] != null) {
return true;
}
return false;
@ -234,22 +253,22 @@ public final class DisplayManager implements RenderingLoop {
public void goBack() {
if (canGoBack()) {
if (DisplayManager.INSTANCE.currentSession >= 0 && DisplayManager.INSTANCE.screen != DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession]) {} else {
DisplayManager.INSTANCE.currentSession += 1;
if (this.currentSession >= 0 && this.screen != this.sessions[this.currentSession]) {} else {
this.currentSession += 1;
}
DisplayManager.INSTANCE.screen = DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession];
this.screen = this.sessions[this.currentSession];
screenChange.release();
}
}
public boolean canGoForward() {
if (DisplayManager.INSTANCE.currentSession <= 0) { // -1 e 0
if (this.currentSession <= 0) { // -1 e 0
return false;
}
if (DisplayManager.INSTANCE.screen != DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession]) {
if (this.screen != this.sessions[this.currentSession]) {
} else if (DisplayManager.INSTANCE.currentSession > 0) {
if (DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession - 1] != null) {
} else if (this.currentSession > 0) {
if (this.sessions[this.currentSession - 1] != null) {
} else {
return false;
@ -257,7 +276,7 @@ public final class DisplayManager implements RenderingLoop {
} else {
return false;
}
if (DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession] != null) {
if (this.sessions[this.currentSession] != null) {
return true;
}
return false;
@ -265,12 +284,12 @@ public final class DisplayManager implements RenderingLoop {
public void goForward() {
if (canGoForward()) {
if (DisplayManager.INSTANCE.screen != DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession]) {
if (this.screen != this.sessions[this.currentSession]) {
} else {
DisplayManager.INSTANCE.currentSession -= 1;
this.currentSession -= 1;
}
DisplayManager.INSTANCE.screen = DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession];
this.screen = this.sessions[this.currentSession];
screenChange.release();
}
}
@ -354,7 +373,8 @@ public final class DisplayManager implements RenderingLoop {
@Override
public void refresh() {
if (supportsPauses == false || (Keyboard.popRefreshRequest() || screen.mustBeRefreshed())) {
if (supportsPauses == false || (Keyboard.popRefreshRequest() || forceRefresh || screen.mustBeRefreshed())) {
forceRefresh = false;
draw();
}
@ -498,7 +518,7 @@ public final class DisplayManager implements RenderingLoop {
}
public RenderingLoop getDrawable() {
return INSTANCE;
return this;
}
@Deprecated
@ -509,4 +529,64 @@ public final class DisplayManager implements RenderingLoop {
public void waitForExit() {
engine.waitForExit();
}
@Override
public boolean onTouchStart(TouchStartEvent e) {
final Screen scr = getScreen();
boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchStart(e)) {
refresh = true;
} else {
//Default behavior
}
if (refresh) {
forceRefresh = true;
}
return true;
}
@Override
public boolean onTouchEnd(TouchEndEvent e) {
final Screen scr = getScreen();
boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchEnd(e)) {
refresh = true;
} else {
//Default behavior
}
if (refresh) {
forceRefresh = true;
}
return true;
}
@Override
public boolean onTouchCancel(TouchCancelEvent e) {
final Screen scr = getScreen();
boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchCancel(e)) {
refresh = true;
} else {
//Default behavior
}
if (refresh) {
forceRefresh = true;
}
return true;
}
@Override
public boolean onTouchMove(TouchMoveEvent e) {
final Screen scr = getScreen();
boolean refresh = false;
if (scr != null && scr.initialized && scr.onTouchMove(e)) {
refresh = true;
} else {
//Default behavior
}
if (refresh) {
forceRefresh = true;
}
return true;
}
}

View File

@ -2,7 +2,7 @@ package org.warp.picalculator.gui.expression;
import java.io.Serializable;
import org.warp.picalculator.device.KeyboardEventListener;
import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Renderer;

View File

@ -1,7 +1,10 @@
package org.warp.picalculator.gui.expression.blocks;
import org.warp.picalculator.Error;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.expression.ExtraMenu;
@ -154,8 +157,8 @@ public class BlockVariable extends Block {
public void close() {}
@Override
public boolean keyPressed(Key k) {
switch (k) {
public boolean onKeyPressed(KeyPressedEvent k) {
switch (k.getKey()) {
case LEFT:
case UP:
switch (block.type) {
@ -199,7 +202,7 @@ public class BlockVariable extends Block {
}
@Override
public boolean keyReleased(Key k) {
public boolean onKeyReleased(KeyReleasedEvent k) {
return false;
}
@ -221,7 +224,7 @@ public class BlockVariable extends Block {
@Override
public void draw(GraphicEngine ge, Renderer r, Caret caret) {
r.glColor3f(1.0f, 1.0f, 1.0f);
DisplayManager.INSTANCE.guiSkin.use(ge);
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(ge);
int popupX = location[0];
int popupY = location[1];
if (popupX < 0) {

View File

@ -3,7 +3,7 @@ package org.warp.picalculator.gui.expression.containers;
import java.io.Serializable;
import org.warp.picalculator.Error;
import org.warp.picalculator.device.KeyboardEventListener;
import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.gui.GraphicalElement;
import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.expression.CaretState;

View File

@ -7,6 +7,7 @@ import java.util.concurrent.Semaphore;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
@ -127,7 +128,7 @@ public class CPUEngine implements GraphicEngine {
@Deprecated()
public void refresh() {
if (DisplayManager.INSTANCE.getScreen() == null || (DisplayManager.INSTANCE.error != null && DisplayManager.INSTANCE.error.length() > 0) || DisplayManager.INSTANCE.getScreen() == null || DisplayManager.INSTANCE.getScreen().mustBeRefreshed()) {
if (HardwareDevice.INSTANCE.getDisplayManager().getScreen() == null || (HardwareDevice.INSTANCE.getDisplayManager().error != null && HardwareDevice.INSTANCE.getDisplayManager().error.length() > 0) || HardwareDevice.INSTANCE.getDisplayManager().getScreen() == null || HardwareDevice.INSTANCE.getDisplayManager().getScreen().mustBeRefreshed()) {
INSTANCE.c.repaint();
}
}

View File

@ -17,6 +17,7 @@ import javax.swing.JPanel;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
@ -63,7 +64,7 @@ public class SwingWindow extends JFrame {
addComponentListener(new ComponentListener() {
@Override
public void componentHidden(ComponentEvent e) {
DisplayManager.INSTANCE.engine.destroy();
HardwareDevice.INSTANCE.getDisplayManager().engine.destroy();
}
@Override

View File

@ -54,7 +54,7 @@ public class GPUEngine implements GraphicEngine {
}
wnd.window.setResizable(r);
wnd.window.setUndecorated(!r);
wnd.window.setPointerVisible(r);
wnd.window.setPointerVisible(true);
}
@Override

View File

@ -28,13 +28,25 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import java.util.ArrayList;
import java.util.List;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.TouchEndEvent;
import org.warp.picalculator.event.TouchMoveEvent;
import org.warp.picalculator.event.TouchPoint;
import org.warp.picalculator.event.TouchStartEvent;
import org.warp.picalculator.gui.DisplayManager;
import com.jogamp.newt.event.GestureHandler.GestureEvent;
import com.jogamp.newt.event.GestureHandler.GestureListener;
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;
@ -51,6 +63,8 @@ import com.jogamp.opengl.fixedfunc.GLPointerFunc;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.texture.Texture;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/**
*
* @author Xerxes Rånby (xranby)
@ -64,6 +78,7 @@ class NEWTWindow implements GLEventListener {
public float windowZoom;
public int[] realWindowSize;
public Runnable onInitialized;
public List<TouchPoint> touches = new ObjectArrayList<>();
public NEWTWindow(GPUEngine disp) {
this.disp = disp;
@ -105,7 +120,7 @@ class NEWTWindow implements GLEventListener {
@Override
public void windowDestroyed(WindowEvent e) {
DisplayManager.INSTANCE.engine.destroy();
HardwareDevice.INSTANCE.getDisplayManager().engine.destroy();
}
@Override
@ -278,6 +293,111 @@ class NEWTWindow implements GLEventListener {
}
}
});
glWindow.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(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(new TouchPoint(is[i], xs[i], ys[i], 5, 5, ps[i], 0));
}
changedPoints.add(newPoints.get(0));
newPoints.remove(0);
touches = newPoints;
HardwareDevice.INSTANCE.getDisplayManager().onTouchStart(new TouchStartEvent(changedPoints, touches));
HardwareDevice.INSTANCE.getDisplayManager().onTouchEnd(new TouchEndEvent(changedPoints, touches));
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(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(new TouchPoint(is[i], xs[i], ys[i], 5, 5, ps[i], 0));
}
changedPoints.add(newPoints.get(0));
touches = newPoints;
HardwareDevice.INSTANCE.getDisplayManager().onTouchStart(new TouchStartEvent(changedPoints, touches));
}
@Override
public void mouseReleased(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(new TouchPoint(is[i], xs[i], ys[i], 5, 5, ps[i], 0));
}
changedPoints.add(newPoints.get(0));
newPoints.remove(0);
touches = newPoints;
HardwareDevice.INSTANCE.getDisplayManager().onTouchEnd(new TouchEndEvent(changedPoints, touches));
}
@Override
public void mouseMoved(MouseEvent e) {
}
@Override
public void mouseDragged(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(new TouchPoint(is[i], xs[i], ys[i], 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;
HardwareDevice.INSTANCE.getDisplayManager().onTouchMove(new TouchMoveEvent(changedPoints, touches));
}
@Override
public void mouseWheelMoved(MouseEvent e) {
}
});
glWindow.addGLEventListener(this /* GLEventListener */);
final Animator animator = new Animator();

View File

@ -7,8 +7,8 @@ import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.WindowsSupport;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.gui.graphicengine.Renderer;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;

View File

@ -7,8 +7,8 @@ import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.WindowsSupport;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.gui.graphicengine.Renderer;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
import org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitRenderer;

View File

@ -7,8 +7,8 @@ import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.WindowsSupport;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.gui.graphicengine.Renderer;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
import org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitRenderer;

View File

@ -2,7 +2,9 @@ package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.functions.Variable.VariableValue;
@ -28,21 +30,21 @@ public class ChooseVariableValueScreen extends Screen {
@Override
public void render() {
Utils.getFont(false, true).use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4i(0, 0, 0, 64);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glColor3i(255, 0, 0);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
Utils.getFont(false, true).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 0, 0);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
Utils.getFont(false, false).use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4i(0, 0, 0, 64);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glColor3i(255, 0, 0);
DisplayManager.INSTANCE.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(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
HardwareDevice.INSTANCE.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.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 0, 0);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
}
@Override
@ -56,8 +58,8 @@ public class ChooseVariableValueScreen extends Screen {
}
@Override
public boolean keyPressed(Key k) {
switch (k) {
public boolean onKeyPressed(KeyPressedEvent k) {
switch (k.getKey()) {
case LETTER_X:
// PIDisplay.INSTANCE.goBack();
// try {
@ -78,9 +80,4 @@ public class ChooseVariableValueScreen extends Screen {
}
}
@Override
public boolean keyReleased(Key k) {
return false;
}
}

View File

@ -1,6 +1,6 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.event.Key;
public class EmptyScreen extends Screen {
@ -35,15 +35,4 @@ public class EmptyScreen extends Screen {
return true;
}
@Override
public boolean keyPressed(Key k) {
return false;
}
@Override
public boolean keyReleased(Key k) {
return false;
}
}

View File

@ -1,7 +1,10 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.Renderer;
@ -27,19 +30,19 @@ public class KeyboardDebugScreen extends Screen {
@Override
public void render() {
final Renderer renderer = DisplayManager.INSTANCE.renderer;
DisplayManager.INSTANCE.fonts[2].use(DisplayManager.INSTANCE.engine);
final Renderer renderer = HardwareDevice.INSTANCE.getDisplayManager().renderer;
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glColor4f(0.75f, 0.0f, 0.0f, 1.0f);
renderer.glDrawStringRight(StaticVars.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
if (keyevent != "NONE") {
DisplayManager.INSTANCE.fonts[2].use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
renderer.glDrawStringLeft(10, 30, "Key position");
renderer.glDrawStringLeft(10, 45, "X: " + keyX + ", Y:" + keyY);
renderer.glDrawStringLeft(10, 65, "Key value");
renderer.glDrawStringLeft(10, 80, key);
}
DisplayManager.INSTANCE.fonts[3].use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().fonts[3].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
for (int i = 0; i < 5; i++) {
if (log[i] != null) {
@ -51,10 +54,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);
DisplayManager.INSTANCE.fonts[2].use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
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");
DisplayManager.INSTANCE.fonts[3].use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().fonts[3].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 0; i < 8; i++) {
if (pinsA[i] == 1) {
@ -97,10 +100,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);
DisplayManager.INSTANCE.fonts[2].use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().fonts[2].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
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");
DisplayManager.INSTANCE.fonts[3].use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().fonts[3].use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 15; i >= 8; i--) {
if (pinsB[i] == 1) {
@ -186,7 +189,7 @@ public class KeyboardDebugScreen extends Screen {
}
@Override
public boolean keyPressed(Key k) {
public boolean onKeyPressed(KeyPressedEvent k) {
beforetime = System.currentTimeMillis();
keyevent = "PRESSED";
keyX = 0;
@ -196,7 +199,7 @@ public class KeyboardDebugScreen extends Screen {
}
@Override
public boolean keyReleased(Key k) {
public boolean onKeyReleased(KeyReleasedEvent k) {
beforetime = System.currentTimeMillis();
keyevent = "RELEASED";
keyX = 0;

View File

@ -1,7 +1,8 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GraphicUtils;
@ -36,20 +37,20 @@ public class LoadingScreen extends Screen {
endLoading += dt;
if (loaded && (StaticVars.debugOn || endLoading >= 3.5f)) {
StaticVars.windowZoom = previousZoomValue;
DisplayManager.INSTANCE.setScreen(new MathInputScreen());
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new MathInputScreen());
}
mustRefresh = true;
}
@Override
public void render() {
DisplayManager.INSTANCE.guiSkin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor3i(255, 255, 255);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 255, 255);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
}
@ -63,14 +64,4 @@ public class LoadingScreen extends Screen {
}
}
@Override
public boolean keyPressed(Key k) {
return false;
}
@Override
public boolean keyReleased(Key k) {
return false;
}
}

View File

@ -3,8 +3,9 @@ package org.warp.picalculator.gui.screens;
import java.io.IOException;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.extra.mario.MarioGame;
import org.warp.picalculator.extra.mario.MarioWorld;
import org.warp.picalculator.gui.DisplayManager;
@ -46,31 +47,31 @@ public class MarioScreen extends Screen {
public void initialized() {
try {
if (skin == null) {
skin = DisplayManager.INSTANCE.engine.loadSkin("marioskin.png");
skin = HardwareDevice.INSTANCE.getDisplayManager().engine.loadSkin("marioskin.png");
}
if (groundskin == null) {
groundskin = DisplayManager.INSTANCE.engine.loadSkin("marioground.png");
groundskin = HardwareDevice.INSTANCE.getDisplayManager().engine.loadSkin("marioground.png");
}
if (gpuTest2 == null) {
try {
gpuTest2 = DisplayManager.INSTANCE.engine.loadFont("gputest2");
gpuTest2 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("gputest2");
} catch (final Exception ex) {}
}
if (gpuTest1 == null) {
try {
gpuTest1 = DisplayManager.INSTANCE.engine.loadFont("gputest12");
gpuTest1 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("gputest12");
gpuTest12 = true;
StaticVars.windowZoom = 1;
} catch (final Exception ex) {
gpuTest12 = false;
try {
gpuTest1 = DisplayManager.INSTANCE.engine.loadFont("gputest1");
gpuTest1 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("gputest1");
} catch (final Exception ex2) {}
}
}
if (gpuTest3 == null) {
try {
gpuTest3 = DisplayManager.INSTANCE.engine.loadSkin("font_gputest3.png");
gpuTest3 = HardwareDevice.INSTANCE.getDisplayManager().engine.loadSkin("font_gputest3.png");
} catch (final Exception ex) {}
}
} catch (final IOException e) {
@ -105,24 +106,24 @@ public class MarioScreen extends Screen {
gpuCharTestt1Elapsed -= 1.5;
}
DisplayManager.INSTANCE.renderer.glClearColor(0xff000000);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glClearColor(0xff000000);
}
}
@Override
public void render() {
if (errored) {
DisplayManager.INSTANCE.renderer.glDrawStringLeft(0, 20, "ERROR");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR");
} else {
if (groundskin != null) {
final double playerX = g.getPlayer().getX();
final double playerY = g.getPlayer().getY();
groundskin.use(DisplayManager.INSTANCE.engine);
groundskin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
final MarioWorld w = g.getCurrentWorld();
final int width = w.getWidth();
final int height = w.getHeight();
final float screenX = DisplayManager.INSTANCE.engine.getWidth() / 2f - 8f;
final float screenY = DisplayManager.INSTANCE.engine.getHeight() / 2f - 8f;
final float screenX = HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() / 2f - 8f;
final float screenY = HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() / 2f - 8f;
final float shiftX = -8 + 16 * (float) playerX;
final float shiftY = -8 + 16 * (height - (float) playerY);
int blue = -1;
@ -135,59 +136,59 @@ public class MarioScreen extends Screen {
if (b == 0) {
if (blue != 1) {
blue = 1;
DisplayManager.INSTANCE.renderer.glColor(0xff9290ff);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xff9290ff);
}
DisplayManager.INSTANCE.renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillColor(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16);
} else {
if (blue != 0) {
blue = 0;
DisplayManager.INSTANCE.renderer.glColor(0xffffffff);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xffffffff);
}
DisplayManager.INSTANCE.renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(screenX - shiftX + 16 * ix, screenY - shiftY + 16 * (height - iy), 16, 16, 0, 0, 16, 16);
}
}
}
}
if (blue != 0) {
blue = 0;
DisplayManager.INSTANCE.renderer.glColor(0xffffffff);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xffffffff);
}
//DRAW MARIO
skin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.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);
skin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.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);
// 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 (gpuTest1 != null) {
DisplayManager.INSTANCE.renderer.glColor3f(1, 1, 1);
DisplayManager.INSTANCE.renderer.glFillColor(DisplayManager.INSTANCE.engine.getWidth() - (gpuTest12 ? 512 : 256), DisplayManager.INSTANCE.engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuTest12 ? 512 : 256, gpuTest12 ? 512 : 256);
gpuTest1.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor3f(0, 0, 0);
DisplayManager.INSTANCE.renderer.glDrawStringRight(DisplayManager.INSTANCE.engine.getWidth(), DisplayManager.INSTANCE.engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3f(1, 1, 1);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillColor(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - (gpuTest12 ? 512 : 256), HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuTest12 ? 512 : 256, gpuTest12 ? 512 : 256);
gpuTest1.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3f(0, 0, 0);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth(), HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
}
if (gpuTest3 != null) {
gpuTest3.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4f(1, 1, 1, 0.7f);
DisplayManager.INSTANCE.renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
gpuTest3.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
}
if (gpuTest2 != null) {
gpuTest2.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor(0xFF000000);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "A");
DisplayManager.INSTANCE.renderer.glColor(0xFF800000);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "B");
DisplayManager.INSTANCE.renderer.glColor(0xFFeea28e);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "C");
DisplayManager.INSTANCE.renderer.glColor(0xFFee7255);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "D");
DisplayManager.INSTANCE.renderer.glColor(0xFFeac0b0);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "E");
DisplayManager.INSTANCE.renderer.glColor(0xFFf3d8ce);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "F");
DisplayManager.INSTANCE.renderer.glColor(0xFFffede7);
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - gpuTest2.getCharacterHeight(), "G");
gpuTest2.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFF000000);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "A");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFF800000);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "B");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFeea28e);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "C");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFee7255);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "D");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFeac0b0);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "E");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFf3d8ce);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "F");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor(0xFFffede7);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "G");
}
}
}
@ -197,14 +198,4 @@ public class MarioScreen extends Screen {
return true;
}
@Override
public boolean keyReleased(Key k) {
return false;
}
@Override
public boolean keyPressed(Key k) {
return false;
}
}

View File

@ -11,8 +11,11 @@ import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.expression.InputContext;
import org.warp.picalculator.gui.expression.blocks.Block;
@ -68,7 +71,7 @@ public class MathInputScreen extends Screen {
calc = new MathContext();
try {
BlockContainer.initializeFonts(DisplayManager.INSTANCE.engine.loadFont("norm"), DisplayManager.INSTANCE.engine.loadFont("smal"));
BlockContainer.initializeFonts(HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("norm"), HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("smal"));
} catch (final IOException e) {
e.printStackTrace();
DSystem.exit(1);
@ -87,10 +90,10 @@ public class MathInputScreen extends Screen {
@Override
public void beforeRender(float dt) {
if (DisplayManager.INSTANCE.error == null) {
DisplayManager.INSTANCE.renderer.glClearColor(0xFFc5c2af);
if (HardwareDevice.INSTANCE.getDisplayManager().error == null) {
HardwareDevice.INSTANCE.getDisplayManager().renderer.glClearColor(0xFFc5c2af);
} else {
DisplayManager.INSTANCE.renderer.glClearColor(0xFFDC3C32);
HardwareDevice.INSTANCE.getDisplayManager().renderer.glClearColor(0xFFDC3C32);
}
if (userInput.beforeRender(dt)) {
mustRefresh = true;
@ -116,13 +119,13 @@ public class MathInputScreen extends Screen {
@Override
public void render() {
final Renderer renderer = DisplayManager.INSTANCE.renderer;
fontBig.use(DisplayManager.INSTANCE.engine);
final Renderer renderer = HardwareDevice.INSTANCE.getDisplayManager().renderer;
fontBig.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
final int textColor = 0xFF000000;
final int padding = 4;
renderer.glColor(textColor);
userInput.draw(DisplayManager.INSTANCE.engine, renderer, padding, padding + 20);
userInput.draw(HardwareDevice.INSTANCE.getDisplayManager().engine, renderer, padding, padding + 20);
if (computingResult) {
renderer.glColor3f(1, 1, 1);
@ -131,22 +134,22 @@ public class MathInputScreen extends Screen {
final int size = 32;
final int posY = computingAnimationIndex % 2;
final int posX = (computingAnimationIndex - posY) / 2;
renderer.glFillRect(DisplayManager.INSTANCE.engine.getWidth() - size - 4, DisplayManager.INSTANCE.engine.getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size);
renderer.glFillRect(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - size - 4, HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - size - 4, size, size, leftX + size * posX, leftY + size * posY, size, size);
if (computingBreakTipVisible) {
Utils.getFont(false).use(DisplayManager.INSTANCE.engine);
Utils.getFont(false).use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glColor3f(0.75f, 0, 0);
renderer.glDrawStringRight(DisplayManager.INSTANCE.engine.getWidth() - 4 - size - 4, DisplayManager.INSTANCE.engine.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
renderer.glDrawStringRight(HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - 4 - size - 4, HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
}
} else {
if (!result.isContentEmpty()) {
result.draw(DisplayManager.INSTANCE.engine, renderer, DisplayManager.INSTANCE.engine.getWidth() - result.getWidth() - 2, DisplayManager.INSTANCE.engine.getHeight() - result.getHeight() - 2);
result.draw(HardwareDevice.INSTANCE.getDisplayManager().engine, renderer, HardwareDevice.INSTANCE.getDisplayManager().engine.getWidth() - result.getWidth() - 2, HardwareDevice.INSTANCE.getDisplayManager().engine.getHeight() - result.getHeight() - 2);
}
}
}
@Override
public void renderTopmost() {
final Renderer renderer = DisplayManager.INSTANCE.renderer;
final Renderer renderer = HardwareDevice.INSTANCE.getDisplayManager().renderer;
renderer.glColor3f(1, 1, 1);
final int pos = 2;
final int spacersNumb = 1;
@ -156,7 +159,7 @@ public class MathInputScreen extends Screen {
} else {
skinN = 21;
}
DisplayManager.INSTANCE.guiSkin.use(DisplayManager.INSTANCE.engine);
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
renderer.glFillRect(2 + 18 * pos + 2 * spacersNumb, 2, 16, 16, 16 * skinN, 16 * 0, 16, 16);
}
@ -171,10 +174,10 @@ public class MathInputScreen extends Screen {
}
@Override
public boolean keyPressed(Key k) {
public boolean onKeyPressed(KeyPressedEvent k) {
ConsoleUtils.out.println(1, k.toString());
try {
switch (k) {
switch (k.getKey()) {
case OK:
userInput.toggleExtra();
mustRefresh = true;
@ -187,12 +190,12 @@ public class MathInputScreen extends Screen {
return true;
}
default:
if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().keyPressed(k)) {
if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().onKeyPressed(k)) {
currentStep = 0;
return true;
} else {
final boolean step = k == Key.STEP;
switch (k) {
final boolean step = k.getKey() == Key.STEP;
switch (k.getKey()) {
case STEP:
currentStep++;
@ -200,10 +203,10 @@ public class MathInputScreen extends Screen {
if (!step) {
currentStep = 0;
}
if (DisplayManager.INSTANCE.error != null) {
if (HardwareDevice.INSTANCE.getDisplayManager().error != null) {
//TODO: make the error management a global API rather than being relegated to this screen.
ConsoleUtils.out.println(1, "Resetting after error...");
DisplayManager.INSTANCE.error = null;
HardwareDevice.INSTANCE.getDisplayManager().error = null;
calc.f = null;
calc.f2 = null;
calc.resultsCount = 0;
@ -249,7 +252,7 @@ public class MathInputScreen extends Screen {
}
} catch (final Error e) {
d.errorStackTrace = PlatformUtils.stacktraceToString(e);
DisplayManager.INSTANCE.error = e.id.toString();
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
System.err.println(e.id);
}
computingResult = false;
@ -387,9 +390,9 @@ public class MathInputScreen extends Screen {
userInput.clear();
result.clear();
currentStep = 0;
if (DisplayManager.INSTANCE.error != null) {
if (HardwareDevice.INSTANCE.getDisplayManager().error != null) {
ConsoleUtils.out.println(1, "Resetting after error...");
DisplayManager.INSTANCE.error = null;
HardwareDevice.INSTANCE.getDisplayManager().error = null;
}
return true;
case SURD_MODE:
@ -399,11 +402,11 @@ public class MathInputScreen extends Screen {
Keyboard.keyPressed(Key.SIMPLIFY);
return true;
case debug1:
DisplayManager.INSTANCE.setScreen(new EmptyScreen());
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new EmptyScreen());
return true;
case HISTORY_BACK:
// if (DisplayManager.INSTANCE.canGoBack()) {
// if (currentExpression != null && currentExpression.length() > 0 & DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession + 1] instanceof MathInputScreen) {
// if (HardwareDevice.INSTANCE.getDisplayManager().canGoBack()) {
// if (currentExpression != null && currentExpression.length() > 0 & HardwareDevice.INSTANCE.getDisplayManager().sessions[HardwareDevice.INSTANCE.getDisplayManager().currentSession + 1] instanceof MathInputScreen) {
// newExpression = currentExpression;
// try {
// interpreta(true);
@ -412,8 +415,8 @@ public class MathInputScreen extends Screen {
// }
return false;
case HISTORY_FORWARD:
// if (DisplayManager.INSTANCE.canGoForward()) {
// if (currentExpression != null && currentExpression.length() > 0 & DisplayManager.INSTANCE.sessions[DisplayManager.INSTANCE.currentSession - 1] instanceof MathInputScreen) {
// if (HardwareDevice.INSTANCE.getDisplayManager().canGoForward()) {
// if (currentExpression != null && currentExpression.length() > 0 & HardwareDevice.INSTANCE.getDisplayManager().sessions[HardwareDevice.INSTANCE.getDisplayManager().currentSession - 1] instanceof MathInputScreen) {
// newExpression = currentExpression;
// try {
// interpreta(true);
@ -482,7 +485,7 @@ public class MathInputScreen extends Screen {
final PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
DisplayManager.INSTANCE.error = e.id.toString();
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
System.err.println(e.id);
}
return null;
@ -499,7 +502,7 @@ public class MathInputScreen extends Screen {
final ObjectArrayList<Function> partialResults = new ObjectArrayList<>();
for (final Function f : calc.f2) {
if (f instanceof Equation) {
DisplayManager.INSTANCE.setScreen(new SolveEquationScreen(this));
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new SolveEquationScreen(this));
} else {
results.add(f);
for (final Function itm : results) {
@ -539,7 +542,7 @@ public class MathInputScreen extends Screen {
final PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
DisplayManager.INSTANCE.error = e.id.toString();
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
System.err.println(e.id);
}
*/
@ -552,7 +555,7 @@ public class MathInputScreen extends Screen {
try {
for (final Function f : calc.f) {
if (f instanceof Equation) {
DisplayManager.INSTANCE.setScreen(new SolveEquationScreen(this));
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new SolveEquationScreen(this));
return;
}
}
@ -581,7 +584,7 @@ public class MathInputScreen extends Screen {
final PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
DisplayManager.INSTANCE.error = e.id.toString();
HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString();
System.err.println(e.id);
}
*/
@ -595,9 +598,9 @@ public class MathInputScreen extends Screen {
// if (!userInput.isEmpty()) {
// final MathInputScreen cloned = clone();
// cloned.userInput.setCaretPosition(cloned.userInput.getCaretMaxPosition()-1);
// DisplayManager.INSTANCE.replaceScreen(cloned);
// HardwareDevice.INSTANCE.getDisplayManager().replaceScreen(cloned);
// initialized = false;
// DisplayManager.INSTANCE.setScreen(this);
// HardwareDevice.INSTANCE.getDisplayManager().setScreen(this);
//
// }
}
@ -608,14 +611,14 @@ public class MathInputScreen extends Screen {
}
@Override
public boolean keyReleased(Key k) {
if (k == Key.OK) {
public boolean onKeyReleased(KeyReleasedEvent k) {
if (k.getKey() == Key.OK) {
return true;
} else {
if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().keyReleased(k)) {
if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().onKeyReleased(k)) {
return true;
} else {
switch (k) {
switch (k.getKey()) {
default:
return false;
}
@ -639,9 +642,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)));
DisplayManager.INSTANCE.setScreen(cvs);
HardwareDevice.INSTANCE.getDisplayManager().setScreen(cvs);
try {
DisplayManager.INSTANCE.screenChange.acquire();
HardwareDevice.INSTANCE.getDisplayManager().screenChange.acquire();
} catch (final InterruptedException e) {}
if (cvs.resultNumberValue == null) {
cancelled = true;

View File

@ -1,10 +1,13 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.device.KeyboardEventListener;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.event.TouchEventListener;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GraphicalInterface;
public abstract class Screen implements KeyboardEventListener, GraphicalInterface {
public abstract class Screen implements KeyboardEventListener, TouchEventListener, GraphicalInterface {
public DisplayManager d;
public boolean created = false;
public boolean initialized = false;

View File

@ -1,7 +1,9 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Key;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.gui.DisplayManager;
public class SolveForXScreen extends Screen {
@ -24,12 +26,12 @@ public class SolveForXScreen extends Screen {
@Override
public void render() {
DisplayManager.INSTANCE.renderer.glColor4i(0, 0, 0, 64);
DisplayManager.INSTANCE.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.");
DisplayManager.INSTANCE.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.");
DisplayManager.INSTANCE.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.");
DisplayManager.INSTANCE.renderer.glColor3i(255, 0, 0);
DisplayManager.INSTANCE.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.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor4i(0, 0, 0, 64);
HardwareDevice.INSTANCE.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.");
HardwareDevice.INSTANCE.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.");
HardwareDevice.INSTANCE.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.");
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 0, 0);
HardwareDevice.INSTANCE.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.");
}
@Override
@ -43,15 +45,15 @@ public class SolveForXScreen extends Screen {
}
@Override
public boolean keyPressed(Key k) {
switch (k) {
public boolean onKeyPressed(KeyPressedEvent k) {
switch (k.getKey()) {
case LETTER_X:
//TODO: far funzionare questa parte
/*DisplayManager.INSTANCE.goBack();
/*HardwareDevice.INSTANCE.getDisplayManager().goBack();
try {
es.calc.solveExpression('X');
} catch (final Error e) {
final Screen scr = DisplayManager.INSTANCE.getScreen();
final Screen scr = HardwareDevice.INSTANCE.getDisplayManager().getScreen();
if (scr instanceof MathInputScreen) {
final MathInputScreen escr = (MathInputScreen) scr;
escr.errorLevel = 1;
@ -67,9 +69,4 @@ public class SolveForXScreen extends Screen {
}
}
@Override
public boolean keyReleased(Key k) {
return false;
}
}