[DEV] rework enums
This commit is contained in:
parent
d263376329
commit
aa71e26ba8
@ -37,7 +37,7 @@ public class Gale {
|
|||||||
* @param _argv Standard argv
|
* @param _argv Standard argv
|
||||||
* @return normal error int for the application error management
|
* @return normal error int for the application error management
|
||||||
*/
|
*/
|
||||||
public static int run(final Application application, final String[] arg) {
|
public static int run(final GaleApplication application, final String[] arg) {
|
||||||
init();
|
init();
|
||||||
//etk::init(_argc, _argv);
|
//etk::init(_argc, _argv);
|
||||||
Context context = null;
|
Context context = null;
|
||||||
|
@ -11,7 +11,7 @@ import org.atriasoft.gale.key.KeySpecial;
|
|||||||
import org.atriasoft.gale.key.KeyStatus;
|
import org.atriasoft.gale.key.KeyStatus;
|
||||||
import org.atriasoft.gale.key.KeyType;
|
import org.atriasoft.gale.key.KeyType;
|
||||||
|
|
||||||
public class Application {
|
public class GaleApplication {
|
||||||
private boolean needRedraw = true;
|
private boolean needRedraw = true;
|
||||||
private String title = "gale";
|
private String title = "gale";
|
||||||
private Uri iconName = null;
|
private Uri iconName = null;
|
||||||
@ -19,7 +19,7 @@ public class Application {
|
|||||||
private Orientation orientation = Orientation.screenAuto;
|
private Orientation orientation = Orientation.screenAuto;
|
||||||
private Vector2f windowsSize = new Vector2f(800, 600);
|
private Vector2f windowsSize = new Vector2f(800, 600);
|
||||||
|
|
||||||
public Application() {
|
public GaleApplication() {
|
||||||
Log.verbose("Constructor Gale Application");
|
Log.verbose("Constructor Gale Application");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,12 +289,16 @@ public class Application {
|
|||||||
if (size.x() <= 0 || size.y() <= 0) {
|
if (size.x() <= 0 || size.y() <= 0) {
|
||||||
Log.error("Wrong windows size: " + size);
|
Log.error("Wrong windows size: " + size);
|
||||||
}
|
}
|
||||||
|
Vector2f oldSize = this.windowsSize;
|
||||||
this.windowsSize = size;
|
this.windowsSize = size;
|
||||||
final Context context = Gale.getContext();
|
final Context context = Gale.getContext();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context.setSize(size);
|
if (!context.setSize(size)) {
|
||||||
|
Log.error("Can not set the size required by the user.");
|
||||||
|
this.windowsSize = oldSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,16 +1,16 @@
|
|||||||
package org.atriasoft.gale.context;
|
package org.atriasoft.gale.context;
|
||||||
|
|
||||||
public enum ClipboardList {
|
public enum ClipboardList {
|
||||||
clipboard0, //!< internal clipboard 0
|
CLIPBOARD_0, //!< internal clipboard 0
|
||||||
clipboard1, //!< internal clipboard 1
|
CLIPBOARD_1, //!< internal clipboard 1
|
||||||
clipboard2, //!< internal clipboard 2
|
CLIPBOARD_2, //!< internal clipboard 2
|
||||||
clipboard3, //!< internal clipboard 3
|
CLIPBOARD_3, //!< internal clipboard 3
|
||||||
clipboard4, //!< internal clipboard 4
|
CLIPBOARD_4, //!< internal clipboard 4
|
||||||
clipboard5, //!< internal clipboard 5
|
CLIPBOARD_5, //!< internal clipboard 5
|
||||||
clipboard6, //!< internal clipboard 6
|
CLIPBOARD_6, //!< internal clipboard 6
|
||||||
clipboard7, //!< internal clipboard 7
|
CLIPBOARD_7, //!< internal clipboard 7
|
||||||
clipboard8, //!< internal clipboard 8
|
CLIPBOARD_8, //!< internal clipboard 8
|
||||||
clipboard9, //!< internal clipboard 9
|
CLIPBOARD_9, //!< internal clipboard 9
|
||||||
clipboardStd, //!< External clipboard represent the Copy/Cut/Past buffer
|
CLIPBOARD_STD, //!< External clipboard represent the Copy/Cut/Past buffer
|
||||||
clipboardSelection, //!< External or internal clipboard depending on the OS, represent the middle button
|
CLIPBOARD_SELECTION, //!< External or internal clipboard depending on the OS, represent the middle button
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.atriasoft.etk.Color;
|
|||||||
import org.atriasoft.etk.ThreadAbstract;
|
import org.atriasoft.etk.ThreadAbstract;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.gale.Application;
|
import org.atriasoft.gale.GaleApplication;
|
||||||
import org.atriasoft.gale.Fps;
|
import org.atriasoft.gale.Fps;
|
||||||
import org.atriasoft.gale.Gale;
|
import org.atriasoft.gale.Gale;
|
||||||
import org.atriasoft.gale.Orientation;
|
import org.atriasoft.gale.Orientation;
|
||||||
@ -45,7 +45,7 @@ public abstract class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected ThreadAbstract periodicThread;;
|
protected ThreadAbstract periodicThread;;
|
||||||
protected Application application; //!< Application handle
|
protected GaleApplication application; //!< Application handle
|
||||||
protected ApplicationState applicationState = ApplicationState.UNDEFINED; // state of the application
|
protected ApplicationState applicationState = ApplicationState.UNDEFINED; // state of the application
|
||||||
private final CommandLine commandLine = new CommandLine(); //!< Start command line information;
|
private final CommandLine commandLine = new CommandLine(); //!< Start command line information;
|
||||||
private final ResourceManager resourceManager = new ResourceManager(); //!< global resources Manager
|
private final ResourceManager resourceManager = new ResourceManager(); //!< global resources Manager
|
||||||
@ -61,7 +61,7 @@ public abstract class Context {
|
|||||||
protected boolean fullscreen = false;
|
protected boolean fullscreen = false;
|
||||||
protected Vector2f windowsPos; //!< current size of the system
|
protected Vector2f windowsPos; //!< current size of the system
|
||||||
|
|
||||||
public Context(final Application application, final String[] args) {
|
public Context(final GaleApplication application, final String[] args) {
|
||||||
// set a basic
|
// set a basic
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.applicationState = ApplicationState.CREATE;
|
this.applicationState = ApplicationState.CREATE;
|
||||||
@ -109,7 +109,7 @@ public abstract class Context {
|
|||||||
Log.info("GALE v:" + Gale.getVersion());
|
Log.info("GALE v:" + Gale.getVersion());
|
||||||
forceOrientation(Orientation.screenAuto);
|
forceOrientation(Orientation.screenAuto);
|
||||||
postAction((context) -> {
|
postAction((context) -> {
|
||||||
final Application appl = context.getApplication();
|
final GaleApplication appl = context.getApplication();
|
||||||
if (appl == null) {
|
if (appl == null) {
|
||||||
this.applicationState = ApplicationState.UNDEFINED;
|
this.applicationState = ApplicationState.UNDEFINED;
|
||||||
return;
|
return;
|
||||||
@ -178,7 +178,7 @@ public abstract class Context {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Application getApplication() {
|
public GaleApplication getApplication() {
|
||||||
return this.application;
|
return this.application;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ public abstract class Context {
|
|||||||
*/
|
*/
|
||||||
public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) {
|
public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) {
|
||||||
postAction((context) -> {
|
postAction((context) -> {
|
||||||
final Application appl = context.getApplication();
|
final GaleApplication appl = context.getApplication();
|
||||||
if (appl != null) {
|
if (appl != null) {
|
||||||
appl.onClipboardEvent(clipboardID);
|
appl.onClipboardEvent(clipboardID);
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ public abstract class Context {
|
|||||||
postAction((context) -> {
|
postAction((context) -> {
|
||||||
Log.debug("Receive MSG : THREADMOVE : " + context.windowsPos + " ==> " + pos);
|
Log.debug("Receive MSG : THREADMOVE : " + context.windowsPos + " ==> " + pos);
|
||||||
context.windowsPos = pos;
|
context.windowsPos = pos;
|
||||||
final Application appl = context.getApplication();
|
final GaleApplication appl = context.getApplication();
|
||||||
if (appl == null) {
|
if (appl == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -496,7 +496,7 @@ public abstract class Context {
|
|||||||
Log.debug("Receive MSG : THREADRESIZE : " + context.windowsSize + " ==> " + size);
|
Log.debug("Receive MSG : THREADRESIZE : " + context.windowsSize + " ==> " + size);
|
||||||
context.windowsSize = size;
|
context.windowsSize = size;
|
||||||
//gale::Dimension::setPixelWindowsSize(context.windowsSize);
|
//gale::Dimension::setPixelWindowsSize(context.windowsSize);
|
||||||
final Application tmpAppl = context.getApplication();
|
final GaleApplication tmpAppl = context.getApplication();
|
||||||
if (tmpAppl != null) {
|
if (tmpAppl != null) {
|
||||||
tmpAppl.onResize(context.windowsSize);
|
tmpAppl.onResize(context.windowsSize);
|
||||||
}
|
}
|
||||||
@ -523,7 +523,7 @@ public abstract class Context {
|
|||||||
|
|
||||||
public void operatingSystemSetInput(final KeySpecial special, final KeyType type, final KeyStatus status, final int pointerID, final Vector2f pos) {
|
public void operatingSystemSetInput(final KeySpecial special, final KeyType type, final KeyStatus status, final int pointerID, final Vector2f pos) {
|
||||||
postAction((context) -> {
|
postAction((context) -> {
|
||||||
final Application appl = context.getApplication();
|
final GaleApplication appl = context.getApplication();
|
||||||
if (appl == null) {
|
if (appl == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ public abstract class Context {
|
|||||||
|
|
||||||
public void operatingSystemsetKeyboard2(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final Character charValue) {
|
public void operatingSystemsetKeyboard2(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final Character charValue) {
|
||||||
postAction((context) -> {
|
postAction((context) -> {
|
||||||
final Application appl = context.getApplication();
|
final GaleApplication appl = context.getApplication();
|
||||||
if (appl == null) {
|
if (appl == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -723,8 +723,9 @@ public abstract class Context {
|
|||||||
* The application request a change of his current size.
|
* The application request a change of his current size.
|
||||||
* @param size new Requested size of the windows.
|
* @param size new Requested size of the windows.
|
||||||
*/
|
*/
|
||||||
public void setSize(final Vector2f size) {
|
public boolean setSize(final Vector2f size) {
|
||||||
Log.info("setSize: NOT implemented ...");
|
Log.info("setSize: NOT implemented ...");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -809,7 +810,7 @@ class PeriodicThread extends ThreadAbstract {
|
|||||||
synchronized (this.context) {
|
synchronized (this.context) {
|
||||||
this.context.processEvents();
|
this.context.processEvents();
|
||||||
// call all the application for periodic request (the application manage multiple instance )...
|
// call all the application for periodic request (the application manage multiple instance )...
|
||||||
final Application appl = this.context.getApplication();
|
final GaleApplication appl = this.context.getApplication();
|
||||||
if (appl != null) {
|
if (appl != null) {
|
||||||
appl.onPeriod(System.currentTimeMillis());
|
appl.onPeriod(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ import io.scenarium.logger.Logger;
|
|||||||
|
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.gale.Application;
|
|
||||||
import org.atriasoft.gale.DisplayManagerDraw;
|
import org.atriasoft.gale.DisplayManagerDraw;
|
||||||
import org.atriasoft.gale.Fps;
|
import org.atriasoft.gale.Fps;
|
||||||
|
import org.atriasoft.gale.GaleApplication;
|
||||||
import org.atriasoft.gale.context.Context;
|
import org.atriasoft.gale.context.Context;
|
||||||
import org.atriasoft.gale.internal.Log;
|
import org.atriasoft.gale.internal.Log;
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
import org.atriasoft.gale.key.KeyKeyboard;
|
||||||
@ -67,7 +67,7 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
|
|||||||
private static double currentMousePositionX = 0;
|
private static double currentMousePositionX = 0;
|
||||||
private static double currentMousePositionY = 0;
|
private static double currentMousePositionY = 0;
|
||||||
|
|
||||||
public static Context create(final Application application, final String[] arg) {
|
public static Context create(final GaleApplication application, final String[] arg) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return new ContextLWJGLAWT(application, arg);
|
return new ContextLWJGLAWT(application, arg);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
|
|||||||
|
|
||||||
private final List<Integer> pressedKey = new ArrayList<>();
|
private final List<Integer> pressedKey = new ArrayList<>();
|
||||||
|
|
||||||
public ContextLWJGLAWT(final Application application, final String[] args) {
|
public ContextLWJGLAWT(final GaleApplication application, final String[] args) {
|
||||||
super(application, args);
|
super(application, args);
|
||||||
System.out.println("Hello JOGL !");
|
System.out.println("Hello JOGL !");
|
||||||
initWindows();
|
initWindows();
|
||||||
@ -202,50 +202,50 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
|
|||||||
public void keyEvent(final KeyEvent e, final boolean pressed, final boolean thisIsAReapeateKey) {
|
public void keyEvent(final KeyEvent e, final boolean pressed, final boolean thisIsAReapeateKey) {
|
||||||
//Log.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e);
|
//Log.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e);
|
||||||
boolean find = true;
|
boolean find = true;
|
||||||
KeyKeyboard keyInput = KeyKeyboard.unknow;
|
KeyKeyboard keyInput = KeyKeyboard.UNKNOWN;
|
||||||
//Log.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation());
|
//Log.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation());
|
||||||
switch (e.getKeyCode()) {
|
switch (e.getKeyCode()) {
|
||||||
//case 328: // keypad
|
//case 328: // keypad
|
||||||
case KeyEvent.VK_UP:
|
case KeyEvent.VK_UP:
|
||||||
keyInput = KeyKeyboard.up;
|
keyInput = KeyKeyboard.UP;
|
||||||
break;
|
break;
|
||||||
//case 324: // keypad
|
//case 324: // keypad
|
||||||
case KeyEvent.VK_LEFT:
|
case KeyEvent.VK_LEFT:
|
||||||
keyInput = KeyKeyboard.left;
|
keyInput = KeyKeyboard.LEFT;
|
||||||
break;
|
break;
|
||||||
//case 326: // keypad
|
//case 326: // keypad
|
||||||
case KeyEvent.VK_RIGHT:
|
case KeyEvent.VK_RIGHT:
|
||||||
keyInput = KeyKeyboard.right;
|
keyInput = KeyKeyboard.RIGHT;
|
||||||
break;
|
break;
|
||||||
//case 323: // keypad
|
//case 323: // keypad
|
||||||
case KeyEvent.VK_DOWN:
|
case KeyEvent.VK_DOWN:
|
||||||
keyInput = KeyKeyboard.down;
|
keyInput = KeyKeyboard.DOWN;
|
||||||
break;
|
break;
|
||||||
//case 329: // keypad
|
//case 329: // keypad
|
||||||
case KeyEvent.VK_PAGE_UP:
|
case KeyEvent.VK_PAGE_UP:
|
||||||
keyInput = KeyKeyboard.pageUp;
|
keyInput = KeyKeyboard.PAGE_UP;
|
||||||
break;
|
break;
|
||||||
//case 323: // keypad
|
//case 323: // keypad
|
||||||
case KeyEvent.VK_PAGE_DOWN:
|
case KeyEvent.VK_PAGE_DOWN:
|
||||||
keyInput = KeyKeyboard.pageDown;
|
keyInput = KeyKeyboard.PAGE_DOWN;
|
||||||
break;
|
break;
|
||||||
//case 327: // keypad
|
//case 327: // keypad
|
||||||
case KeyEvent.VK_HOME:
|
case KeyEvent.VK_HOME:
|
||||||
keyInput = KeyKeyboard.start;
|
keyInput = KeyKeyboard.START;
|
||||||
break;
|
break;
|
||||||
//case 321: // keypad
|
//case 321: // keypad
|
||||||
case KeyEvent.VK_END:
|
case KeyEvent.VK_END:
|
||||||
keyInput = KeyKeyboard.end;
|
keyInput = KeyKeyboard.END;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_PRINTSCREEN:
|
case KeyEvent.VK_PRINTSCREEN:
|
||||||
keyInput = KeyKeyboard.stopDefil;
|
keyInput = KeyKeyboard.STOP_DEFIL;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_PAUSE:
|
case KeyEvent.VK_PAUSE:
|
||||||
keyInput = KeyKeyboard.wait;
|
keyInput = KeyKeyboard.WAIT;
|
||||||
break;
|
break;
|
||||||
//case 320: // keypad
|
//case 320: // keypad
|
||||||
case KeyEvent.VK_INSERT:
|
case KeyEvent.VK_INSERT:
|
||||||
keyInput = KeyKeyboard.insert;
|
keyInput = KeyKeyboard.INSERT;
|
||||||
if (!pressed) {
|
if (!pressed) {
|
||||||
if (this.guiKeyBoardMode.getInsert()) {
|
if (this.guiKeyBoardMode.getInsert()) {
|
||||||
this.guiKeyBoardMode.setInsert(false);
|
this.guiKeyBoardMode.setInsert(false);
|
||||||
@ -256,117 +256,117 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
|
|||||||
break;
|
break;
|
||||||
//case 84: keyInput = KeyboardCenter; break; // Keypad
|
//case 84: keyInput = KeyboardCenter; break; // Keypad
|
||||||
case KeyEvent.VK_F1:
|
case KeyEvent.VK_F1:
|
||||||
keyInput = KeyKeyboard.f1;
|
keyInput = KeyKeyboard.F1;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F2:
|
case KeyEvent.VK_F2:
|
||||||
keyInput = KeyKeyboard.f2;
|
keyInput = KeyKeyboard.F2;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F3:
|
case KeyEvent.VK_F3:
|
||||||
keyInput = KeyKeyboard.f3;
|
keyInput = KeyKeyboard.F3;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F4:
|
case KeyEvent.VK_F4:
|
||||||
keyInput = KeyKeyboard.f4;
|
keyInput = KeyKeyboard.F4;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F5:
|
case KeyEvent.VK_F5:
|
||||||
keyInput = KeyKeyboard.f5;
|
keyInput = KeyKeyboard.F5;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F6:
|
case KeyEvent.VK_F6:
|
||||||
keyInput = KeyKeyboard.f6;
|
keyInput = KeyKeyboard.F6;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F7:
|
case KeyEvent.VK_F7:
|
||||||
keyInput = KeyKeyboard.f7;
|
keyInput = KeyKeyboard.F7;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F8:
|
case KeyEvent.VK_F8:
|
||||||
keyInput = KeyKeyboard.f8;
|
keyInput = KeyKeyboard.F8;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F9:
|
case KeyEvent.VK_F9:
|
||||||
keyInput = KeyKeyboard.f9;
|
keyInput = KeyKeyboard.F9;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F10:
|
case KeyEvent.VK_F10:
|
||||||
keyInput = KeyKeyboard.f10;
|
keyInput = KeyKeyboard.F10;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F11:
|
case KeyEvent.VK_F11:
|
||||||
keyInput = KeyKeyboard.f11;
|
keyInput = KeyKeyboard.F11;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_F12:
|
case KeyEvent.VK_F12:
|
||||||
keyInput = KeyKeyboard.f12;
|
keyInput = KeyKeyboard.F12;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_CAPS_LOCK:
|
case KeyEvent.VK_CAPS_LOCK:
|
||||||
keyInput = KeyKeyboard.capLock;
|
keyInput = KeyKeyboard.CAP_LOCK;
|
||||||
this.guiKeyBoardMode.setCapsLock(pressed);
|
this.guiKeyBoardMode.setCapsLock(pressed);
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_SHIFT:
|
case KeyEvent.VK_SHIFT:
|
||||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||||
keyInput = KeyKeyboard.shiftLeft;
|
keyInput = KeyKeyboard.SHIFT_LEFT;
|
||||||
this.guiKeyBoardMode.setShiftLeft(pressed);
|
this.guiKeyBoardMode.setShiftLeft(pressed);
|
||||||
break;
|
break;
|
||||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
||||||
keyInput = KeyKeyboard.shiftLeft;
|
keyInput = KeyKeyboard.SHIFT_LEFT;
|
||||||
this.guiKeyBoardMode.setShiftRight(pressed);
|
this.guiKeyBoardMode.setShiftRight(pressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_CONTROL:
|
case KeyEvent.VK_CONTROL:
|
||||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||||
keyInput = KeyKeyboard.ctrlLeft;
|
keyInput = KeyKeyboard.CTRL_LEFT;
|
||||||
this.guiKeyBoardMode.setCtrlLeft(pressed);
|
this.guiKeyBoardMode.setCtrlLeft(pressed);
|
||||||
break;
|
break;
|
||||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
||||||
keyInput = KeyKeyboard.ctrlRight;
|
keyInput = KeyKeyboard.CTRL_RIGHT;
|
||||||
this.guiKeyBoardMode.setCtrlRight(pressed);
|
this.guiKeyBoardMode.setCtrlRight(pressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_META:
|
case KeyEvent.VK_META:
|
||||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||||
keyInput = KeyKeyboard.metaLeft;
|
keyInput = KeyKeyboard.META_LEFT;
|
||||||
this.guiKeyBoardMode.setMetaLeft(pressed);
|
this.guiKeyBoardMode.setMetaLeft(pressed);
|
||||||
break;
|
break;
|
||||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
||||||
keyInput = KeyKeyboard.metaRight;
|
keyInput = KeyKeyboard.META_RIGHT;
|
||||||
this.guiKeyBoardMode.setMetaRight(pressed);
|
this.guiKeyBoardMode.setMetaRight(pressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_ALT:
|
case KeyEvent.VK_ALT:
|
||||||
keyInput = KeyKeyboard.altLeft;
|
keyInput = KeyKeyboard.ALT_LEFT;
|
||||||
this.guiKeyBoardMode.setAltLeft(pressed);
|
this.guiKeyBoardMode.setAltLeft(pressed);
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_ALT_GRAPH:
|
case KeyEvent.VK_ALT_GRAPH:
|
||||||
keyInput = KeyKeyboard.altRight;
|
keyInput = KeyKeyboard.ALT_RIGHT;
|
||||||
this.guiKeyBoardMode.setAltRight(pressed);
|
this.guiKeyBoardMode.setAltRight(pressed);
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_CONTEXT_MENU:
|
case KeyEvent.VK_CONTEXT_MENU:
|
||||||
keyInput = KeyKeyboard.contextMenu;
|
keyInput = KeyKeyboard.CONTEXT_MENU;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_NUM_LOCK:
|
case KeyEvent.VK_NUM_LOCK:
|
||||||
keyInput = KeyKeyboard.numLock;
|
keyInput = KeyKeyboard.NUM_LOCK;
|
||||||
this.guiKeyBoardMode.setNumLock(pressed);
|
this.guiKeyBoardMode.setNumLock(pressed);
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_DELETE: // Suppr on keypad
|
case KeyEvent.VK_DELETE: // Suppr on keypad
|
||||||
find = false;
|
find = false;
|
||||||
if (this.guiKeyBoardMode.getNumLock()) {
|
if (this.guiKeyBoardMode.getNumLock()) {
|
||||||
if (thisIsAReapeateKey) {
|
if (thisIsAReapeateKey) {
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
|
||||||
}
|
}
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
|
||||||
} else {
|
} else {
|
||||||
if (thisIsAReapeateKey) {
|
if (thisIsAReapeateKey) {
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
|
||||||
}
|
}
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_TAB: // special case for TAB
|
case KeyEvent.VK_TAB: // special case for TAB
|
||||||
find = false;
|
find = false;
|
||||||
if (thisIsAReapeateKey) {
|
if (thisIsAReapeateKey) {
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
|
||||||
}
|
}
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
find = false;
|
find = false;
|
||||||
if (thisIsAReapeateKey) {
|
if (thisIsAReapeateKey) {
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
|
||||||
}
|
}
|
||||||
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
|
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
|
||||||
}
|
}
|
||||||
if (find) {
|
if (find) {
|
||||||
if (thisIsAReapeateKey) {
|
if (thisIsAReapeateKey) {
|
||||||
|
@ -1,50 +1,50 @@
|
|||||||
package org.atriasoft.gale.key;
|
package org.atriasoft.gale.key;
|
||||||
|
|
||||||
public enum KeyKeyboard {
|
public enum KeyKeyboard {
|
||||||
unknow, //!< Unknown keyboard key
|
UNKNOWN, //!< Unknown keyboard key
|
||||||
character, //!< Char input is arrived ...
|
CHARACTER, //!< Char input is arrived ...
|
||||||
left, //!< Left key <--
|
LEFT, //!< Left key <--
|
||||||
right, //!< Right key -->
|
RIGHT, //!< Right key -->
|
||||||
up, //!< Up key ^
|
UP, //!< Up key ^
|
||||||
down, //!< Down key \/
|
DOWN, //!< Down key \/
|
||||||
pageUp, //!< Page Up key
|
PAGE_UP, //!< Page Up key
|
||||||
pageDown, //!< page down key
|
PAGE_DOWN, //!< page down key
|
||||||
start, //!< Start key
|
START, //!< Start key
|
||||||
end, //!< End key
|
END, //!< End key
|
||||||
print, //!< print screen key.
|
PRINT, //!< print screen key.
|
||||||
stopDefil, //!< Stop display key.
|
STOP_DEFIL, //!< Stop display key.
|
||||||
wait, //!< Wait key.
|
WAIT, //!< Wait key.
|
||||||
insert, //!< insert key.
|
INSERT, //!< insert key.
|
||||||
f1, //!< F1 key.
|
F1, //!< F1 key.
|
||||||
f2, //!< F2 key.
|
F2, //!< F2 key.
|
||||||
f3, //!< F3 key.
|
F3, //!< F3 key.
|
||||||
f4, //!< F4 key.
|
F4, //!< F4 key.
|
||||||
f5, //!< F5 key.
|
F5, //!< F5 key.
|
||||||
f6, //!< F6 key.
|
F6, //!< F6 key.
|
||||||
f7, //!< F7 key.
|
F7, //!< F7 key.
|
||||||
f8, //!< F8 key.
|
F8, //!< F8 key.
|
||||||
f9, //!< F9 key.
|
F9, //!< F9 key.
|
||||||
f10, //!< F10 key.
|
F10, //!< F10 key.
|
||||||
f11, //!< F11 key.
|
F11, //!< F11 key.
|
||||||
f12, //!< F12 key.
|
F12, //!< F12 key.
|
||||||
capLock, //!< Capital Letter Lock key.
|
CAP_LOCK, //!< Capital Letter Lock key.
|
||||||
shiftLeft, //!< Shift left key.
|
SHIFT_LEFT, //!< Shift left key.
|
||||||
shiftRight, //!< Shift right key.
|
SHIFT_RIGHT, //!< Shift right key.
|
||||||
ctrlLeft, //!< Control left key.
|
CTRL_LEFT, //!< Control left key.
|
||||||
ctrlRight, //!< Control right key.
|
CTRL_RIGHT, //!< Control right key.
|
||||||
metaLeft, //!< Meta left key (apple key or windows key).
|
META_LEFT, //!< Meta left key (apple key or windows key).
|
||||||
metaRight, //!< Meta right key (apple key or windows key).
|
META_RIGHT, //!< Meta right key (apple key or windows key).
|
||||||
altLeft, //!< Alt left key.
|
ALT_LEFT, //!< Alt left key.
|
||||||
altRight, //!< Alt right key.
|
ALT_RIGHT, //!< Alt right key.
|
||||||
contextMenu, //!< Contextual menu key.
|
CONTEXT_MENU, //!< Contextual menu key.
|
||||||
numLock, //!< Numerical Lock key
|
NUM_LOCK, //!< Numerical Lock key
|
||||||
// harware section:
|
// harware section:
|
||||||
volumeUp, //!< Hardware volume UP key
|
VOLUME_UP, //!< Hardware volume UP key
|
||||||
volumeDown, //!< Hardware volume DOWN key
|
VOLUME_DOWN, //!< Hardware volume DOWN key
|
||||||
menu, //!< Hardware Menu key
|
MENU, //!< Hardware Menu key
|
||||||
camera, //!< Hardware Camera key
|
CAMERA, //!< Hardware Camera key
|
||||||
home, //!< Hardware Home key
|
HOME, //!< Hardware Home key
|
||||||
power, //!< Hardware Power key
|
POWER, //!< Hardware Power key
|
||||||
back //!< Hardware Back key
|
BACK //!< Hardware Back key
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,293 +12,322 @@ public class KeySpecial {
|
|||||||
private boolean valueAltRight = false;
|
private boolean valueAltRight = false;
|
||||||
private boolean valueNumLock = false;
|
private boolean valueNumLock = false;
|
||||||
private boolean valueInsert = false;
|
private boolean valueInsert = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main ructor
|
* Main ructor
|
||||||
*/
|
*/
|
||||||
public KeySpecial() {
|
public KeySpecial() {
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* get the current CapLock Status
|
|
||||||
* @return The CapLock value
|
|
||||||
*/
|
|
||||||
public boolean getCapsLock() {
|
|
||||||
return valueCapLock;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* set the current CapLock Status
|
|
||||||
* @param value The new CapLock value
|
|
||||||
*/
|
|
||||||
public void setCapsLock(boolean value) {
|
|
||||||
valueCapLock = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Shift key status
|
|
||||||
* @return The Shift value
|
|
||||||
*/
|
|
||||||
public boolean getShift() {
|
|
||||||
return valueShiftLeft || valueShiftRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Shift left key status
|
|
||||||
* @return The Shift value
|
|
||||||
*/
|
|
||||||
public boolean getShiftLeft() {
|
|
||||||
return valueShiftLeft;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Shift right key status
|
|
||||||
* @return The Shift value
|
|
||||||
*/
|
|
||||||
public boolean getShiftRight() {
|
|
||||||
return valueShiftRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Shift left key status
|
|
||||||
* @param value The new Shift value
|
|
||||||
*/
|
|
||||||
public void setShiftLeft(boolean value) {
|
|
||||||
valueShiftLeft = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Shift right key status
|
|
||||||
* @param value The new Shift value
|
|
||||||
*/
|
|
||||||
public void setShiftRight(boolean value) {
|
|
||||||
valueShiftRight = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the Current Control key status
|
|
||||||
* @return The Control value
|
|
||||||
*/
|
|
||||||
public boolean getCtrl() {
|
|
||||||
return valueCtrlLeft || valueCtrlRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the Current Control left key status
|
|
||||||
* @return The Control value
|
|
||||||
*/
|
|
||||||
public boolean getCtrlLeft() {
|
|
||||||
return valueCtrlLeft;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the Current Control right key status
|
|
||||||
* @return The Control value
|
|
||||||
*/
|
|
||||||
public boolean getCtrlRight() {
|
|
||||||
return valueCtrlRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the Current Control left key status
|
|
||||||
* @param value The new Control value
|
|
||||||
*/
|
|
||||||
public void setCtrlLeft(boolean value){
|
|
||||||
valueCtrlLeft = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the Current Control right key status
|
|
||||||
* @param value The new Control value
|
|
||||||
*/
|
|
||||||
public void setCtrlRight(boolean value) {
|
|
||||||
valueCtrlRight = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Meta key status (also named windows or apple key)
|
|
||||||
* @return The Meta value (name Windows key, apple key, command key ...)
|
|
||||||
*/
|
|
||||||
public boolean getMeta() {
|
|
||||||
return valueMetaLeft || valueMetaRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Meta left key status (also named windows or apple key)
|
|
||||||
* @return The Meta value (name Windows key, apple key, command key ...)
|
|
||||||
*/
|
|
||||||
public boolean getMetaLeft() {
|
|
||||||
return valueMetaLeft;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Meta right key status (also named windows or apple key)
|
|
||||||
* @return The Meta value (name Windows key, apple key, command key ...)
|
|
||||||
*/
|
|
||||||
public boolean getMetaRight() {
|
|
||||||
return valueMetaRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Meta left key status (also named windows or apple key)
|
|
||||||
* @param value The new Meta value (name Windows key, apple key, command key ...)
|
|
||||||
*/
|
|
||||||
public void setMetaLeft(boolean value) {
|
|
||||||
valueMetaLeft = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Meta right key status (also named windows or apple key)
|
|
||||||
* @param value The new Meta value (name Windows key, apple key, command key ...)
|
|
||||||
*/
|
|
||||||
public void setMetaRight(boolean value) {
|
|
||||||
valueMetaRight = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Alt key status
|
|
||||||
* @return The Alt value
|
|
||||||
*/
|
|
||||||
public boolean getAlt() {
|
|
||||||
return valueAltLeft || valueAltRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Alt left key status
|
|
||||||
* @return The Alt value
|
|
||||||
*/
|
|
||||||
public boolean getAltLeft() {
|
|
||||||
return valueAltLeft;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Alt right key status (alt-gr)
|
|
||||||
* @return The Alt value
|
|
||||||
*/
|
|
||||||
public boolean getAltRight() {
|
|
||||||
return valueAltRight;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Alt left key status
|
|
||||||
* @param value The new Alt value
|
|
||||||
*/
|
|
||||||
public void setAltLeft(boolean value) {
|
|
||||||
valueAltLeft = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Alt right key status (alt-gr)
|
|
||||||
* @param value The new Alt value
|
|
||||||
*/
|
|
||||||
public void setAltRight(boolean value) {
|
|
||||||
valueAltRight = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Alt-Gr key status
|
|
||||||
* @return The Alt-gr value (does not exist on MacOs)
|
|
||||||
*/
|
|
||||||
public boolean getAltGr() {
|
|
||||||
return getAltRight();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Alt-Gr key status
|
|
||||||
* @param value The new Alt-gr value (does not exist on MacOs)
|
|
||||||
*/
|
|
||||||
public void setAltGr(boolean value) {
|
|
||||||
setAltRight(value);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Ver-num key status
|
|
||||||
* @return The Numerical Lock value
|
|
||||||
*/
|
|
||||||
public boolean getNumLock() {
|
|
||||||
return valueNumLock;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Ver-num key status
|
|
||||||
* @param value The new Numerical Lock value
|
|
||||||
*/
|
|
||||||
public void setNumLock(boolean value) {
|
|
||||||
valueNumLock = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the current Intert key status
|
|
||||||
* @return The Insert value
|
|
||||||
*/
|
|
||||||
public boolean getInsert() {
|
|
||||||
return valueInsert;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set the current Intert key status
|
|
||||||
* @param value The new Insert value
|
|
||||||
*/
|
|
||||||
public void setInsert(boolean value) {
|
|
||||||
valueInsert = value;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Update the internal value with the input moving key.
|
|
||||||
* @param move Moving key.
|
|
||||||
* @param isDown The key is pressed or not.
|
|
||||||
*/
|
|
||||||
public void update(KeyKeyboard move, boolean isDown) {
|
|
||||||
switch (move) {
|
|
||||||
case insert:
|
|
||||||
setInsert(isDown);
|
|
||||||
break;
|
|
||||||
case capLock:
|
|
||||||
setCapsLock(isDown);
|
|
||||||
break;
|
|
||||||
case shiftLeft:
|
|
||||||
setShiftLeft(isDown);
|
|
||||||
break;
|
|
||||||
case shiftRight:
|
|
||||||
setShiftRight(isDown);
|
|
||||||
break;
|
|
||||||
case ctrlLeft:
|
|
||||||
setCtrlLeft(isDown);
|
|
||||||
break;
|
|
||||||
case ctrlRight:
|
|
||||||
setCtrlRight(isDown);
|
|
||||||
break;
|
|
||||||
case metaLeft:
|
|
||||||
setMetaLeft(isDown);
|
|
||||||
break;
|
|
||||||
case metaRight:
|
|
||||||
setMetaRight(isDown);
|
|
||||||
break;
|
|
||||||
case altLeft:
|
|
||||||
setAltLeft(isDown);
|
|
||||||
break;
|
|
||||||
case altRight:
|
|
||||||
setAltRight(isDown);
|
|
||||||
break;
|
|
||||||
case numLock:
|
|
||||||
setNumLock(isDown);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Get the value with the input moving key.
|
* Get the value with the input moving key.
|
||||||
* @param move Moving key.
|
* @param move Moving key.
|
||||||
* @return true The key is pressed.
|
* @return true The key is pressed.
|
||||||
* @return false The key is released.
|
* @return false The key is released.
|
||||||
*/
|
*/
|
||||||
public boolean get(KeyKeyboard move) {
|
public boolean get(final KeyKeyboard move) {
|
||||||
switch (move) {
|
switch (move) {
|
||||||
case insert:
|
case INSERT:
|
||||||
return getInsert();
|
return getInsert();
|
||||||
case capLock:
|
case CAP_LOCK:
|
||||||
return getCapsLock();
|
return getCapsLock();
|
||||||
case shiftLeft:
|
case SHIFT_LEFT:
|
||||||
return getShiftLeft();
|
return getShiftLeft();
|
||||||
case shiftRight:
|
case SHIFT_RIGHT:
|
||||||
return getShiftRight();
|
return getShiftRight();
|
||||||
case ctrlLeft:
|
case CTRL_LEFT:
|
||||||
return getCtrlLeft();
|
return getCtrlLeft();
|
||||||
case ctrlRight:
|
case CTRL_RIGHT:
|
||||||
return getCtrlRight();
|
return getCtrlRight();
|
||||||
case metaLeft:
|
case META_LEFT:
|
||||||
return getMetaLeft();
|
return getMetaLeft();
|
||||||
case metaRight:
|
case META_RIGHT:
|
||||||
return getMetaRight();
|
return getMetaRight();
|
||||||
case altLeft:
|
case ALT_LEFT:
|
||||||
return getAltLeft();
|
return getAltLeft();
|
||||||
case altRight:
|
case ALT_RIGHT:
|
||||||
return getAltRight();
|
return getAltRight();
|
||||||
case numLock:
|
case NUM_LOCK:
|
||||||
return getNumLock();
|
return getNumLock();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Alt key status
|
||||||
|
* @return The Alt value
|
||||||
|
*/
|
||||||
|
public boolean getAlt() {
|
||||||
|
return this.valueAltLeft || this.valueAltRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Alt-Gr key status
|
||||||
|
* @return The Alt-gr value (does not exist on MacOs)
|
||||||
|
*/
|
||||||
|
public boolean getAltGr() {
|
||||||
|
return getAltRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Alt left key status
|
||||||
|
* @return The Alt value
|
||||||
|
*/
|
||||||
|
public boolean getAltLeft() {
|
||||||
|
return this.valueAltLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Alt right key status (alt-gr)
|
||||||
|
* @return The Alt value
|
||||||
|
*/
|
||||||
|
public boolean getAltRight() {
|
||||||
|
return this.valueAltRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the current CapLock Status
|
||||||
|
* @return The CapLock value
|
||||||
|
*/
|
||||||
|
public boolean getCapsLock() {
|
||||||
|
return this.valueCapLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Current Control key status
|
||||||
|
* @return The Control value
|
||||||
|
*/
|
||||||
|
public boolean getCtrl() {
|
||||||
|
return this.valueCtrlLeft || this.valueCtrlRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Current Control left key status
|
||||||
|
* @return The Control value
|
||||||
|
*/
|
||||||
|
public boolean getCtrlLeft() {
|
||||||
|
return this.valueCtrlLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Current Control right key status
|
||||||
|
* @return The Control value
|
||||||
|
*/
|
||||||
|
public boolean getCtrlRight() {
|
||||||
|
return this.valueCtrlRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Intert key status
|
||||||
|
* @return The Insert value
|
||||||
|
*/
|
||||||
|
public boolean getInsert() {
|
||||||
|
return this.valueInsert;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Meta key status (also named windows or apple key)
|
||||||
|
* @return The Meta value (name Windows key, apple key, command key ...)
|
||||||
|
*/
|
||||||
|
public boolean getMeta() {
|
||||||
|
return this.valueMetaLeft || this.valueMetaRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Meta left key status (also named windows or apple key)
|
||||||
|
* @return The Meta value (name Windows key, apple key, command key ...)
|
||||||
|
*/
|
||||||
|
public boolean getMetaLeft() {
|
||||||
|
return this.valueMetaLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Meta right key status (also named windows or apple key)
|
||||||
|
* @return The Meta value (name Windows key, apple key, command key ...)
|
||||||
|
*/
|
||||||
|
public boolean getMetaRight() {
|
||||||
|
return this.valueMetaRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Ver-num key status
|
||||||
|
* @return The Numerical Lock value
|
||||||
|
*/
|
||||||
|
public boolean getNumLock() {
|
||||||
|
return this.valueNumLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Shift key status
|
||||||
|
* @return The Shift value
|
||||||
|
*/
|
||||||
|
public boolean getShift() {
|
||||||
|
return this.valueShiftLeft || this.valueShiftRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Shift left key status
|
||||||
|
* @return The Shift value
|
||||||
|
*/
|
||||||
|
public boolean getShiftLeft() {
|
||||||
|
return this.valueShiftLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Shift right key status
|
||||||
|
* @return The Shift value
|
||||||
|
*/
|
||||||
|
public boolean getShiftRight() {
|
||||||
|
return this.valueShiftRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Alt-Gr key status
|
||||||
|
* @param value The new Alt-gr value (does not exist on MacOs)
|
||||||
|
*/
|
||||||
|
public void setAltGr(final boolean value) {
|
||||||
|
setAltRight(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Alt left key status
|
||||||
|
* @param value The new Alt value
|
||||||
|
*/
|
||||||
|
public void setAltLeft(final boolean value) {
|
||||||
|
this.valueAltLeft = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Alt right key status (alt-gr)
|
||||||
|
* @param value The new Alt value
|
||||||
|
*/
|
||||||
|
public void setAltRight(final boolean value) {
|
||||||
|
this.valueAltRight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the current CapLock Status
|
||||||
|
* @param value The new CapLock value
|
||||||
|
*/
|
||||||
|
public void setCapsLock(final boolean value) {
|
||||||
|
this.valueCapLock = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Current Control left key status
|
||||||
|
* @param value The new Control value
|
||||||
|
*/
|
||||||
|
public void setCtrlLeft(final boolean value) {
|
||||||
|
this.valueCtrlLeft = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Current Control right key status
|
||||||
|
* @param value The new Control value
|
||||||
|
*/
|
||||||
|
public void setCtrlRight(final boolean value) {
|
||||||
|
this.valueCtrlRight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Intert key status
|
||||||
|
* @param value The new Insert value
|
||||||
|
*/
|
||||||
|
public void setInsert(final boolean value) {
|
||||||
|
this.valueInsert = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Meta left key status (also named windows or apple key)
|
||||||
|
* @param value The new Meta value (name Windows key, apple key, command key ...)
|
||||||
|
*/
|
||||||
|
public void setMetaLeft(final boolean value) {
|
||||||
|
this.valueMetaLeft = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Meta right key status (also named windows or apple key)
|
||||||
|
* @param value The new Meta value (name Windows key, apple key, command key ...)
|
||||||
|
*/
|
||||||
|
public void setMetaRight(final boolean value) {
|
||||||
|
this.valueMetaRight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Ver-num key status
|
||||||
|
* @param value The new Numerical Lock value
|
||||||
|
*/
|
||||||
|
public void setNumLock(final boolean value) {
|
||||||
|
this.valueNumLock = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Shift left key status
|
||||||
|
* @param value The new Shift value
|
||||||
|
*/
|
||||||
|
public void setShiftLeft(final boolean value) {
|
||||||
|
this.valueShiftLeft = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current Shift right key status
|
||||||
|
* @param value The new Shift value
|
||||||
|
*/
|
||||||
|
public void setShiftRight(final boolean value) {
|
||||||
|
this.valueShiftRight = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Special [CapLock=" + valueCapLock + ", Shift=(" + valueShiftLeft + ","
|
return "Special [CapLock=" + this.valueCapLock + ", Shift=(" + this.valueShiftLeft + "," + this.valueShiftRight + "), Ctrl=(" + this.valueCtrlLeft + "," + this.valueCtrlRight + "), Meta=("
|
||||||
+ valueShiftRight + "), Ctrl=(" + valueCtrlLeft + "," + valueCtrlRight
|
+ this.valueMetaLeft + "," + this.valueMetaRight + "), Alt=(" + this.valueAltLeft + "," + this.valueAltRight + "), NumLock=" + this.valueNumLock + ", Insert=" + this.valueInsert + "]";
|
||||||
+ "), Meta=(" + valueMetaLeft + "," + valueMetaRight + "), Alt=("
|
}
|
||||||
+ valueAltLeft + "," + valueAltRight + "), NumLock=" + valueNumLock
|
|
||||||
+ ", Insert=" + valueInsert + "]";
|
/**
|
||||||
|
* Update the internal value with the input moving key.
|
||||||
|
* @param move Moving key.
|
||||||
|
* @param isDown The key is pressed or not.
|
||||||
|
*/
|
||||||
|
public void update(final KeyKeyboard move, final boolean isDown) {
|
||||||
|
switch (move) {
|
||||||
|
case INSERT:
|
||||||
|
setInsert(isDown);
|
||||||
|
break;
|
||||||
|
case CAP_LOCK:
|
||||||
|
setCapsLock(isDown);
|
||||||
|
break;
|
||||||
|
case SHIFT_LEFT:
|
||||||
|
setShiftLeft(isDown);
|
||||||
|
break;
|
||||||
|
case SHIFT_RIGHT:
|
||||||
|
setShiftRight(isDown);
|
||||||
|
break;
|
||||||
|
case CTRL_LEFT:
|
||||||
|
setCtrlLeft(isDown);
|
||||||
|
break;
|
||||||
|
case CTRL_RIGHT:
|
||||||
|
setCtrlRight(isDown);
|
||||||
|
break;
|
||||||
|
case META_LEFT:
|
||||||
|
setMetaLeft(isDown);
|
||||||
|
break;
|
||||||
|
case META_RIGHT:
|
||||||
|
setMetaRight(isDown);
|
||||||
|
break;
|
||||||
|
case ALT_LEFT:
|
||||||
|
setAltLeft(isDown);
|
||||||
|
break;
|
||||||
|
case ALT_RIGHT:
|
||||||
|
setAltRight(isDown);
|
||||||
|
break;
|
||||||
|
case NUM_LOCK:
|
||||||
|
setNumLock(isDown);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,10 @@ public class ResourceVirtualArrayObject extends Resource {
|
|||||||
return this.vaoID;
|
return this.vaoID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getVertexCount() {
|
||||||
|
return this.vertexCount;
|
||||||
|
}
|
||||||
|
|
||||||
public void loadAgainToVAO() {
|
public void loadAgainToVAO() {
|
||||||
createVAO();
|
createVAO();
|
||||||
if (this.indices != null) {
|
if (this.indices != null) {
|
||||||
@ -275,16 +279,20 @@ public class ResourceVirtualArrayObject extends Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void render(final RenderMode mode) {
|
public void render(final RenderMode mode) {
|
||||||
Log.warning("request rendering indices : " + this.vertexCount);
|
Log.verbose("request rendering indices : " + this.vertexCount);
|
||||||
OpenGL.drawElements(mode, this.vertexCount);
|
OpenGL.drawElements(mode, this.vertexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderArrays(final RenderMode mode) {
|
public void renderArrays(final RenderMode mode) {
|
||||||
Log.warning("request rendering direct : " + this.vertexCount);
|
Log.verbose("request rendering direct : " + this.vertexCount);
|
||||||
OpenGL.drawArrays(mode, 0, this.vertexCount);
|
OpenGL.drawArrays(mode, 0, this.vertexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColors(final Object colors) {
|
public void setColors(final Color[] colors) {
|
||||||
|
this.colors = colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColors(final float[] colors) {
|
||||||
this.colors = colors;
|
this.colors = colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,11 +305,19 @@ public class ResourceVirtualArrayObject extends Resource {
|
|||||||
this.vertexCount = this.indices.length;
|
this.vertexCount = this.indices.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNormals(final Object normals) {
|
public void setNormals(final float[] normals) {
|
||||||
this.normals = normals;
|
this.normals = normals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(final Object positions) {
|
public void setNormals(final Vector3f[] normals) {
|
||||||
|
this.normals = normals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(final float[] positions) {
|
||||||
|
this.positions = positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(final Vector3f[] positions) {
|
||||||
this.positions = positions;
|
this.positions = positions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,6 +325,10 @@ public class ResourceVirtualArrayObject extends Resource {
|
|||||||
this.textureCoordinates = textureCoordinates;
|
this.textureCoordinates = textureCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTextureCoordinate(final Vector2f[] textureCoordinates) {
|
||||||
|
this.textureCoordinates = textureCoordinates;
|
||||||
|
}
|
||||||
|
|
||||||
public void setVertexCount(final int vertexCount) {
|
public void setVertexCount(final int vertexCount) {
|
||||||
this.vertexCount = vertexCount;
|
this.vertexCount = vertexCount;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import org.atriasoft.etk.Uri;
|
|||||||
import org.atriasoft.etk.math.Matrix4f;
|
import org.atriasoft.etk.math.Matrix4f;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
import org.atriasoft.gale.Application;
|
import org.atriasoft.gale.GaleApplication;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
import org.atriasoft.gale.backend3d.OpenGL;
|
||||||
import org.atriasoft.gale.context.Context;
|
import org.atriasoft.gale.context.Context;
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
import org.atriasoft.gale.key.KeyKeyboard;
|
||||||
@ -15,7 +15,7 @@ import org.atriasoft.gale.key.KeyType;
|
|||||||
import org.atriasoft.gale.resource.ResourceProgram;
|
import org.atriasoft.gale.resource.ResourceProgram;
|
||||||
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
|
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
|
||||||
|
|
||||||
public class Sample1Application extends Application {
|
public class Sample1Application extends GaleApplication {
|
||||||
//float[] vertices = { 0.2f, 0.1f, 0.0f, 0.3f, 0.4f, 0.0f, 0.1f, 0.4f, 0.0f };
|
//float[] vertices = { 0.2f, 0.1f, 0.0f, 0.3f, 0.4f, 0.0f, 0.1f, 0.4f, 0.0f };
|
||||||
private static final float[] VERTICES = { -0.5f, -0.5f, -1.0f, 0.0f, 0.5f, -1.0f, 0.5f, -0.5f, -1.0f };
|
private static final float[] VERTICES = { -0.5f, -0.5f, -1.0f, 0.0f, 0.5f, -1.0f, 0.5f, -0.5f, -1.0f };
|
||||||
private static final float[] COLORS = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, };
|
private static final float[] COLORS = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, };
|
||||||
|
@ -5,7 +5,7 @@ import org.atriasoft.etk.Uri;
|
|||||||
import org.atriasoft.etk.math.Matrix4f;
|
import org.atriasoft.etk.math.Matrix4f;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector3f;
|
import org.atriasoft.etk.math.Vector3f;
|
||||||
import org.atriasoft.gale.Application;
|
import org.atriasoft.gale.GaleApplication;
|
||||||
import org.atriasoft.gale.backend3d.OpenGL;
|
import org.atriasoft.gale.backend3d.OpenGL;
|
||||||
import org.atriasoft.gale.context.Context;
|
import org.atriasoft.gale.context.Context;
|
||||||
import org.atriasoft.gale.key.KeyKeyboard;
|
import org.atriasoft.gale.key.KeyKeyboard;
|
||||||
@ -16,7 +16,7 @@ import org.atriasoft.gale.resource.ResourceProgram;
|
|||||||
import org.atriasoft.gale.resource.ResourceTexture;
|
import org.atriasoft.gale.resource.ResourceTexture;
|
||||||
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
|
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
|
||||||
|
|
||||||
public class Sample2Application extends Application {
|
public class Sample2Application extends GaleApplication {
|
||||||
private ResourceProgram oGLprogram;
|
private ResourceProgram oGLprogram;
|
||||||
private int oGLMatrixTransformation;
|
private int oGLMatrixTransformation;
|
||||||
private int oGLMatrixProjection;
|
private int oGLMatrixProjection;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user