|
@@ -79,6 +79,10 @@ class Key {
|
|
public static inline var LALT = ALT | LOC_LEFT;
|
|
public static inline var LALT = ALT | LOC_LEFT;
|
|
public static inline var RALT = ALT | LOC_RIGHT;
|
|
public static inline var RALT = ALT | LOC_RIGHT;
|
|
|
|
|
|
|
|
+ #if noEngine
|
|
|
|
+ public static var frameCount = 0;
|
|
|
|
+ #end
|
|
|
|
+
|
|
static var initDone = false;
|
|
static var initDone = false;
|
|
static var keyPressed : Array<Int> = [];
|
|
static var keyPressed : Array<Int> = [];
|
|
|
|
|
|
@@ -86,12 +90,20 @@ class Key {
|
|
return keyPressed[code] > 0;
|
|
return keyPressed[code] > 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static inline function getFrame() {
|
|
|
|
+ #if noEngine
|
|
|
|
+ return frameCount;
|
|
|
|
+ #else
|
|
|
|
+ return h3d.Engine.getCurrent().frameCount + 1;
|
|
|
|
+ #end
|
|
|
|
+ }
|
|
|
|
+
|
|
public static function isPressed( code : Int ) {
|
|
public static function isPressed( code : Int ) {
|
|
- return keyPressed[code] == h3d.Engine.getCurrent().frameCount+1;
|
|
|
|
|
|
+ return keyPressed[code] == getFrame();
|
|
}
|
|
}
|
|
|
|
|
|
public static function isReleased( code : Int ) {
|
|
public static function isReleased( code : Int ) {
|
|
- return keyPressed[code] == -(h3d.Engine.getCurrent().frameCount+1);
|
|
|
|
|
|
+ return keyPressed[code] == -getFrame();
|
|
}
|
|
}
|
|
|
|
|
|
public static function initialize() {
|
|
public static function initialize() {
|
|
@@ -125,13 +137,13 @@ class Key {
|
|
static function onEvent( e : Event ) {
|
|
static function onEvent( e : Event ) {
|
|
switch( e.kind ) {
|
|
switch( e.kind ) {
|
|
case EKeyDown:
|
|
case EKeyDown:
|
|
- keyPressed[e.keyCode] = h3d.Engine.getCurrent().frameCount+1;
|
|
|
|
|
|
+ keyPressed[e.keyCode] = getFrame();
|
|
case EKeyUp:
|
|
case EKeyUp:
|
|
- keyPressed[e.keyCode] = -(h3d.Engine.getCurrent().frameCount+1);
|
|
|
|
|
|
+ keyPressed[e.keyCode] = -getFrame();
|
|
case EPush:
|
|
case EPush:
|
|
- keyPressed[e.button] = h3d.Engine.getCurrent().frameCount+1;
|
|
|
|
|
|
+ keyPressed[e.button] = getFrame();
|
|
case ERelease:
|
|
case ERelease:
|
|
- keyPressed[e.button] = -(h3d.Engine.getCurrent().frameCount+1);
|
|
|
|
|
|
+ keyPressed[e.button] = -getFrame();
|
|
default:
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|