diff --git a/lime/graphics/Image.hx b/lime/graphics/Image.hx index c1af1c125..5b0be071e 100644 --- a/lime/graphics/Image.hx +++ b/lime/graphics/Image.hx @@ -298,7 +298,7 @@ class Image { return lime_image_encode (buffer, 0, quality); - #else + #elseif !js try { diff --git a/lime/graphics/utils/ImageDataUtil.hx b/lime/graphics/utils/ImageDataUtil.hx index 7f390a93f..db5dd921a 100644 --- a/lime/graphics/utils/ImageDataUtil.hx +++ b/lime/graphics/utils/ImageDataUtil.hx @@ -236,7 +236,7 @@ class ImageDataUtil { for (i in 0...length) { - #if html5 + #if js data[i] = r; data[i + 1] = g; data[i + 2] = b; @@ -263,7 +263,7 @@ class ImageDataUtil { offset = (row * stride) + (column * 4); - #if html5 + #if js data[offset] = r; data[offset + 1] = g; data[offset + 2] = b; diff --git a/lime/system/System.hx b/lime/system/System.hx index 65984056d..9c085b10f 100644 --- a/lime/system/System.hx +++ b/lime/system/System.hx @@ -22,6 +22,8 @@ class System { #if neko private static var __loadedNekoAPI:Bool; + #elseif nodejs + private static var __nodeNDLLModule:Dynamic; #end @@ -165,7 +167,7 @@ class System { #elseif neko return neko.Lib.load (__moduleNames.get (library), method, args); #elseif nodejs - return js.Lib.load (__moduleNames.get (library), method, args); + return untyped __nodeNDLLModule.load_lib (__moduleNames.get (library), method, args); #else return null; #end @@ -177,6 +179,12 @@ class System { flash.Lib.load ("waxe", "wx_boot", 1); + } + #elseif nodejs + if (__nodeNDLLModule == null) { + + __nodeNDLLModule = untyped require('bindings')('node_ndll'); + } #end @@ -268,7 +276,7 @@ class System { #elseif (neko) var result = neko.Lib.load (name, func, args); #elseif nodejs - var result = js.Lib.load (name, func, args); + var result = untyped __nodeNDLLModule.load_lib (name, func, args); #else var result = null; #end diff --git a/lime/ui/KeyEventManager.hx b/lime/ui/KeyEventManager.hx index 363827698..0d58f5603 100644 --- a/lime/ui/KeyEventManager.hx +++ b/lime/ui/KeyEventManager.hx @@ -8,8 +8,12 @@ import lime.system.System; import js.Browser; #elseif flash import flash.Lib; +#elseif java +import org.lwjgl.system.glfw.GLFW; #end +@:allow(lime.ui.Window) + class KeyEventManager { @@ -145,7 +149,7 @@ class KeyEventManager { } - private static function handleEvent (#if (js && html5) event:js.html.KeyboardEvent #elseif flash event:flash.events.KeyboardEvent #end):Void { + private static function handleEvent (#if (js && html5) event:js.html.KeyboardEvent #elseif flash event:flash.events.KeyboardEvent #elseif java _window, key, scancode, action, mods #end):Void { #if (js && html5) @@ -182,6 +186,11 @@ class KeyEventManager { eventInfo.type = (event.type == flash.events.KeyboardEvent.KEY_DOWN ? KEY_DOWN : KEY_UP); + #elseif java + + eventInfo.keyCode = cast convertKeyCode (key); + eventInfo.type == (action == GLFW.GLFW_RELEASE ? KEY_UP : KEY_DOWN); + #end switch (eventInfo.type) { @@ -199,6 +208,23 @@ class KeyEventManager { } + private static function registerWindow (_window:Window):Void { + + #if java + + /*GLFW.glfwSetKeyCallback (_window.handle, keyfun = new GLFW.GLFWkeyfun() { + @Override + public void invoke(long window, int key, int scancode, int action, int mods) { + if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) + glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop + } + }));*/ + + #end + + } + + #if (cpp || neko || nodejs) private static var lime_key_event_manager_register = System.load ("lime", "lime_key_event_manager_register", 2); #end diff --git a/lime/ui/MouseEventManager.hx b/lime/ui/MouseEventManager.hx index d87d500c4..867e4362f 100644 --- a/lime/ui/MouseEventManager.hx +++ b/lime/ui/MouseEventManager.hx @@ -10,8 +10,9 @@ import js.Browser; import flash.Lib; #end - @:allow(lime.ui.Window) + + class MouseEventManager { diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index 521181c0e..cad16aa6a 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -20,7 +20,6 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.system.glfw.GLFW; #end - @:access(lime.app.Application) @@ -219,6 +218,7 @@ class Window { #end + KeyEventManager.registerWindow (this); MouseEventManager.registerWindow (this); TouchEventManager.registerWindow (this); diff --git a/lime/utils/ByteArray.hx b/lime/utils/ByteArray.hx index d335f19dd..e56f44919 100644 --- a/lime/utils/ByteArray.hx +++ b/lime/utils/ByteArray.hx @@ -698,6 +698,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess implements IDa private inline function write_uncheck (byte:Int) { + #if !js #if cpp untyped b.__unsafe_set (position++, byte); #elseif neko @@ -705,6 +706,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess implements IDa #else b[position++] = byte & 0xff; #end + #end }