From: <eli...@us...> - 2006-06-26 13:52:08
|
Revision: 2386 Author: elias_naur Date: 2006-06-26 06:50:48 -0700 (Mon, 26 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2386&view=rev Log Message: ----------- Windows: LWJGL didn't work well with jinput, but compatibility could be greatly improved if LWJGL used DirectInput 8 (like jinput). This can't be done unconditionally, since we need the DX3 support for older versions of windows. So, I've moved most Mouse and Keyboard stuff from native to java side and generalized DirectInput access through an abstract base class, with two concrete subclasses, one for dx3 and one for dx8. Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/platform_build/win32_ms_cmdline/build.bat trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/common/common_tools.h trunk/LWJGL/src/native/win32/LWJGL.c trunk/LWJGL/src/native/win32/Window.h trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java trunk/LWJGL/src/native/win32/dinputhelper.c trunk/LWJGL/src/native/win32/dinputhelper.h trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsDirectInput3.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsDirectInput8.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsDirectInputDevice3.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsDirectInputDevice8.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsKeyboard.c Removed Paths: ------------- trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c trunk/LWJGL/src/native/win32/org_lwjgl_input_Mouse.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/build.xml 2006-06-26 13:50:48 UTC (rev 2386) @@ -420,6 +420,11 @@ </javah> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/win32" force="yes"> + <class name="org.lwjgl.opengl.WindowsKeyboard" /> + <class name="org.lwjgl.opengl.WindowsDirectInput8" /> + <class name="org.lwjgl.opengl.WindowsDirectInputDevice8" /> + <class name="org.lwjgl.opengl.WindowsDirectInput3" /> + <class name="org.lwjgl.opengl.WindowsDirectInputDevice3" /> <class name="org.lwjgl.opengl.Win32PbufferPeerInfo" /> <class name="org.lwjgl.opengl.Win32Display" /> <class name="org.lwjgl.opengl.Win32Registry" /> Modified: trunk/LWJGL/platform_build/win32_ms_cmdline/build.bat =================================================================== --- trunk/LWJGL/platform_build/win32_ms_cmdline/build.bat 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/platform_build/win32_ms_cmdline/build.bat 2006-06-26 13:50:48 UTC (rev 2386) @@ -9,7 +9,7 @@ set COPTIONS=/Wp64 /I"%CHOME%\include" /I"%PLTSDKHOME%\include" /I"%DXSDK_DIR%\include" /I"%JAVA_HOME%\include" /I"%JAVA_HOME%\include\win32" /I"%ALHOME%\include" /I"..\..\src\native\common" /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LWJGL_EXPORTS" /D "_WINDLL" set LINKEROPTS=/link /LIBPATH:"%JAVA_HOME%\lib" /LIBPATH:"%ALHOME%\libs" /LIBPATH:"%DXSDK_DIR%\Lib\x86" /LIBPATH:"%PLTSDKHOME%\Lib" /LIBPATH:"%CHOME%\Lib" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:X86 /NOLOGO /DLL /DELAYLOAD:jawt.dll -set LIBS=Kernel32.lib dinput.lib dxguid.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib +set LIBS=Kernel32.lib ole32.lib dinput.lib dxguid.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib for %%x in (..\..\src\native\win32\*.c) do cl %COPTIONS% %%x for %%x in (..\..\src\native\common\*.c) do cl %COPTIONS% %%x Modified: trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -71,6 +71,16 @@ } /** + * Construct a direct native-order charbuffer with the specified number + * of elements. + * @param size The size, in chars + * @return an CharBuffer + */ + public static CharBuffer createCharBuffer(int size) { + return createByteBuffer(size << 1).asCharBuffer(); + } + + /** * Construct a direct native-order intbuffer with the specified number * of elements. * @param size The size, in ints @@ -81,10 +91,10 @@ } /** - * Construct a direct native-order intbuffer with the specified number + * Construct a direct native-order longbuffer with the specified number * of elements. - * @param size The size, in ints - * @return an IntBuffer + * @param size The size, in longs + * @return an LongBuffer */ public static LongBuffer createLongBuffer(int size) { return createByteBuffer(size << 3).asLongBuffer(); Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -348,7 +348,7 @@ private static void read() { readBuffer.compact(); - int numEvents = Display.getImplementation().readKeyboard(readBuffer, readBuffer.position()); + int numEvents = Display.getImplementation().readKeyboard(readBuffer); readBuffer.position(readBuffer.position() + numEvents*EVENT_SIZE); readBuffer.flip(); } Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -306,7 +306,7 @@ private static void read() { readBuffer.compact(); - int numEvents = Display.getImplementation().readMouse(readBuffer, readBuffer.position()); + int numEvents = Display.getImplementation().readMouse(readBuffer); readBuffer.position(readBuffer.position() + numEvents * EVENT_SIZE); readBuffer.flip(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -153,9 +153,8 @@ * * @return the total number of events read. */ - int readMouse(IntBuffer buffer, int buffer_position); + int readMouse(IntBuffer buffer); - void grabMouse(boolean grab); /** @@ -201,7 +200,7 @@ * Method to read the keyboard buffer * @return the total number of events read. */ - int readKeyboard(IntBuffer buffer, int buffer_position); + int readKeyboard(IntBuffer buffer); // int isStateKeySet(int key); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -40,7 +40,7 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; -abstract class EventQueue { +class EventQueue { private static final int QUEUE_SIZE = 200; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -513,10 +513,10 @@ } private static native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons); - public int readMouse(IntBuffer buffer, int buffer_position) { + public int readMouse(IntBuffer buffer) { update(); lockAWT(); - int count = nReadMouse(buffer, buffer_position); + int count = nReadMouse(buffer, buffer.position()); unlockAWT(); return count; } @@ -616,10 +616,10 @@ } private static native void nPollKeyboard(ByteBuffer keyDownBuffer); - public int readKeyboard(IntBuffer buffer, int buffer_position) { + public int readKeyboard(IntBuffer buffer) { update(); lockAWT(); - int count = nReadKeyboard(buffer, buffer_position); + int count = nReadKeyboard(buffer, buffer.position()); unlockAWT(); return count; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -321,8 +321,7 @@ mouse_queue.poll(coord_buffer, buttons_buffer); } - public int readMouse(IntBuffer buffer, int buffer_position) { - assert buffer_position == buffer.position(); + public int readMouse(IntBuffer buffer) { return mouse_queue.copyEvents(buffer); } @@ -408,8 +407,7 @@ keyboard_queue.poll(keyDownBuffer); } - public int readKeyboard(IntBuffer buffer, int buffer_position) { - assert buffer_position == buffer.position(); + public int readKeyboard(IntBuffer buffer) { return keyboard_queue.copyEvents(buffer); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -48,9 +48,23 @@ final class Win32Display implements DisplayImplementation { private final static int GAMMA_LENGTH = 256; + private final static int WM_MOUSEMOVE = 0x0200; + private final static int WM_LBUTTONDOWN = 0x0201; + private final static int WM_LBUTTONUP = 0x0202; + private final static int WM_LBUTTONDBLCLK = 0x0203; + private final static int WM_RBUTTONDOWN = 0x0204; + private final static int WM_RBUTTONUP = 0x0205; + private final static int WM_RBUTTONDBLCLK = 0x0206; + private final static int WM_MBUTTONDOWN = 0x0207; + private final static int WM_MBUTTONUP = 0x0208; + private final static int WM_MBUTTONDBLCLK = 0x0209; + private final static int WM_MOUSEWHEEL = 0x020A; private static Win32DisplayPeerInfo peer_info; + private static WindowsKeyboard keyboard; + private static WindowsMouse mouse; + public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { nCreateWindow(mode, fullscreen, x, y); peer_info.initDC(); @@ -126,47 +140,70 @@ public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException; /* Mouse */ - public native boolean hasWheel(); - public native int getButtonCount(); - public native void createMouse() throws LWJGLException; - public native void destroyMouse(); + public boolean hasWheel() { + return mouse.hasWheel(); + } + + public int getButtonCount() { + return mouse.getButtonCount(); + } + + public void createMouse() throws LWJGLException { + mouse = new WindowsMouse(createDirectInput(), getHwnd()); + } + + public void destroyMouse() { + mouse.destroy(); + mouse = null; + } + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { update(); - nPollMouse(coord_buffer, buttons); + mouse.poll(coord_buffer, buttons); } - private native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons); - public int readMouse(IntBuffer buffer, int buffer_position) { + public int readMouse(IntBuffer buffer) { update(); - return nReadMouse(buffer, buffer_position); + return mouse.read(buffer); } - private native int nReadMouse(IntBuffer buffer, int buffer_position); - public native void grabMouse(boolean grab); + public void grabMouse(boolean grab) { + mouse.grab(grab); + } + public int getNativeCursorCapabilities() { return Cursor.CURSOR_ONE_BIT_TRANSPARENCY; } public native void setCursorPosition(int x, int y); + public native void setNativeCursor(Object handle) throws LWJGLException; + public native int getMinCursorSize(); public native int getMaxCursorSize(); + private static native long getDllInstance(); + private static native long getHwnd(); + /* Keyboard */ - public native void createKeyboard() throws LWJGLException; - public native void destroyKeyboard(); + public void createKeyboard() throws LWJGLException { + keyboard = new WindowsKeyboard(createDirectInput(), getHwnd()); + } + + public void destroyKeyboard() { + keyboard.destroy(); + keyboard = null; + } public void pollKeyboard(ByteBuffer keyDownBuffer) { update(); - nPollKeyboard(keyDownBuffer); + keyboard.poll(keyDownBuffer); } - private native void nPollKeyboard(ByteBuffer keyDownBuffer); - public int readKeyboard(IntBuffer buffer, int buffer_position) { + public int readKeyboard(IntBuffer buffer) { update(); - return nReadKeyboard(buffer, buffer_position); + return keyboard.read(buffer); } - private native int nReadKeyboard(IntBuffer buffer, int buffer_position); // public native int isStateKeySet(int key); @@ -249,4 +286,64 @@ private static native int nSetWindowIcon16(IntBuffer icon); private static native int nSetWindowIcon32(IntBuffer icon); + + private static void handleMouseButton(int button, int state) { + if (mouse != null) + mouse.handleMouseButton(button, state); + } + + private static void handleMouseMoved(int x, int y) { + if (mouse != null) + mouse.handleMouseMoved(x, y); + } + + private static void handleMouseScrolled(int amount) { + if (mouse != null) + mouse.handleMouseScrolled(amount); + } + + private static native int transformY(long hwnd, int y); + + private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam) { + switch (msg) { + case WM_MOUSEMOVE: + int xPos = (int)(short)(lParam & 0xFFFF); + int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); + handleMouseMoved(xPos, yPos); + return true; + case WM_MOUSEWHEEL: + int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); + handleMouseScrolled(dwheel); + return true; + case WM_LBUTTONDOWN: + handleMouseButton(0, 1); + return true; + case WM_LBUTTONUP: + handleMouseButton(0, 0); + return true; + case WM_RBUTTONDOWN: + handleMouseButton(1, 1); + return true; + case WM_RBUTTONUP: + handleMouseButton(1, 0); + return true; + case WM_MBUTTONDOWN: + handleMouseButton(2, 1); + return true; + case WM_MBUTTONUP: + handleMouseButton(2, 0); + return true; + default: + return false; + } + } + + private static WindowsDirectInput createDirectInput() throws LWJGLException { + try { + return new WindowsDirectInput8(getDllInstance()); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3"); + return new WindowsDirectInput3(getDllInstance()); + } + } } Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInput base class + * @author elias_naur + */ + +import org.lwjgl.LWJGLException; + +abstract class WindowsDirectInput { + public final static int KEYBOARD_TYPE = 1; + public final static int MOUSE_TYPE = 2; + + /* DirectInput constants */ + public final static int DI_OK = 0x00000000; + public final static int DI_NOEFFECT = 0x00000001; + public final static int DI_PROPNOEFFECT = 0x00000001; + + public final static int DI_DOWNLOADSKIPPED = 0x00000003; + public final static int DI_EFFECTRESTARTED = 0x00000004; + public final static int DI_TRUNCATED = 0x00000008; + public final static int DI_SETTINGSNOTSAVED = 0x0000000B; + public final static int DI_TRUNCATEDANDRESTARTED = 0x0000000C; + + public final static int DI_BUFFEROVERFLOW = 0x00000001; + public final static int DIERR_INPUTLOST = 0x8007001E; + public final static int DIERR_NOTACQUIRED = 0x8007001C; + public final static int DIERR_OTHERAPPHASPRIO = 0x80070005; + + private final long di_interface; + + public WindowsDirectInput(long hinst) throws LWJGLException { + di_interface = createDirectInput(hinst); + } + protected abstract long createDirectInput(long hinst) throws LWJGLException; + + public WindowsDirectInputDevice createDevice(int type) throws LWJGLException { + return createDevice(di_interface, type); + } + protected abstract WindowsDirectInputDevice createDevice(long di_interface, int type) throws LWJGLException; + + public void release() { + release(di_interface); + } + protected abstract void release(long di_interface); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInput3 interface + * @author elias_naur + */ + +import org.lwjgl.LWJGLException; + +final class WindowsDirectInput3 extends WindowsDirectInput { + /* Re-define device types to get them included in the native headers */ + public final static int KEYBOARD_TYPE = WindowsDirectInput.KEYBOARD_TYPE; + public final static int MOUSE_TYPE = WindowsDirectInput.MOUSE_TYPE; + + public WindowsDirectInput3(long hinst) throws LWJGLException { + super(hinst); + } + + protected native long createDirectInput(long hinst) throws LWJGLException; + + protected WindowsDirectInputDevice createDevice(long di_interface, int type) throws LWJGLException { + long device = nCreateDevice(di_interface, type); + return new WindowsDirectInputDevice3(device); + } + private static native long nCreateDevice(long di_interface, int type) throws LWJGLException; + + protected native void release(long di_interface); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInput8 interface + * @author elias_naur + */ + +import org.lwjgl.LWJGLException; + +final class WindowsDirectInput8 extends WindowsDirectInput { + /* Re-define device types to get them included in the native headers */ + public final static int KEYBOARD_TYPE = WindowsDirectInput.KEYBOARD_TYPE; + public final static int MOUSE_TYPE = WindowsDirectInput.MOUSE_TYPE; + + public WindowsDirectInput8(long hinst) throws LWJGLException { + super(hinst); + } + + protected native long createDirectInput(long hinst) throws LWJGLException; + + protected WindowsDirectInputDevice createDevice(long di_interface, int type) throws LWJGLException { + long device = nCreateDevice(di_interface, type); + return new WindowsDirectInputDevice8(device); + } + private static native long nCreateDevice(long di_interface, int type) throws LWJGLException; + + protected native void release(long di_interface); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInputDevice interface + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import org.lwjgl.LWJGLException; +import org.lwjgl.BufferUtils; + +abstract class WindowsDirectInputDevice { + public final static int DISCL_EXCLUSIVE = 0x00000001; + public final static int DISCL_NONEXCLUSIVE = 0x00000002; + public final static int DISCL_FOREGROUND = 0x00000004; + public final static int DISCL_BACKGROUND = 0x00000008; + public final static int DISCL_NOWINKEY = 0x00000010; + + public final static int GUID_XAxis = 1; + public final static int GUID_YAxis = 2; + public final static int GUID_ZAxis = 3; + public final static int GUID_Button = 4; + public final static int GUID_Unknown = 5; + + private final long di_device; + private ByteBuffer event_buffer; + + public WindowsDirectInputDevice(long di_device) { + this.di_device = di_device; + } + + public void release() { + release(di_device); + } + protected abstract void release(long di_device); + + public int poll() { + return poll(di_device); + } + protected abstract int poll(long di_device); + + public void setDataFormat(int type) throws LWJGLException { + int ret = setDataFormat(di_device, type); + if (ret != WindowsDirectInput.DI_OK) + throw new LWJGLException("Failed to set data format (" + ret + ")"); + } + protected abstract int setDataFormat(long di_device, int type); + + public void setCooperateLevel(long hwnd, int flags) throws LWJGLException { + int ret = setCooperativeLevel(di_device, hwnd, flags); + if (ret != WindowsDirectInput.DI_OK) + throw new LWJGLException("Failed to set cooperative level (" + ret + ")"); + } + protected abstract int setCooperativeLevel(long di_device, long hwnd, int flags); + + public int acquire() { + return acquire(di_device); + } + protected abstract int acquire(long di_device); + + public void setBufferSize(int buffer_size) throws LWJGLException { + int ret = setBufferSize(di_device, buffer_size); + if (ret != WindowsDirectInput.DI_OK) + throw new LWJGLException("Failed to set buffer size (" + ret + ")"); + int event_buffer_size = getEventSize()*buffer_size; + event_buffer = BufferUtils.createByteBuffer(event_buffer_size); + } + protected abstract int setBufferSize(long di_device, int buffer_size); + + public int getDeviceData(IntBuffer buffer) { + int events_remaining = buffer.remaining()/2; + if (event_buffer == null || events_remaining > event_buffer.remaining()/getEventSize()) + event_buffer = BufferUtils.createByteBuffer(events_remaining*getEventSize()); + return getDeviceData(di_device, event_buffer, event_buffer.capacity(), buffer, buffer.position(), buffer.remaining()); + } + protected abstract int getDeviceData(long di_device, ByteBuffer event_buffer, int event_buffer_size, IntBuffer buffer, int position, int size); + + /** + * Device data is returned in tuples of the form <dwOfs, dwData>. + * buffer position() is moved accordingly to number of events. + */ + public int getDeviceState(ByteBuffer buffer) { + return getDeviceState(di_device, buffer, buffer.position(), buffer.remaining()); + } + protected abstract int getDeviceState(long di_device, ByteBuffer buffer, int position, int size); + + public void unacquire() { + unacquire(di_device); + } + protected abstract int unacquire(long di_device); + + public int enumObjects(WindowsDirectInputDeviceObjectCallback enumerator) { + return enumObjects(di_device, enumerator); + } + protected abstract int enumObjects(long di_device, WindowsDirectInputDeviceObjectCallback enumerator); + + protected abstract int getEventSize(); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInputDevice3 interface + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import org.lwjgl.LWJGLException; + +final class WindowsDirectInputDevice3 extends WindowsDirectInputDevice { + /** Re-declare to get the constants into the native headers */ + public final static int GUID_XAxis = WindowsDirectInputDevice.GUID_XAxis; + public final static int GUID_YAxis = WindowsDirectInputDevice.GUID_YAxis; + public final static int GUID_ZAxis = WindowsDirectInputDevice.GUID_ZAxis; + public final static int GUID_Button = WindowsDirectInputDevice.GUID_Button; + public final static int GUID_Unknown = WindowsDirectInputDevice.GUID_Unknown; + + public WindowsDirectInputDevice3(long di_device) { + super(di_device); + } + + protected native int setDataFormat(long di_device, int type); + + protected native int setCooperativeLevel(long di_device, long hwnd, int flags); + + protected native int acquire(long di_device); + + protected native int getDeviceState(long di_device, ByteBuffer buffer, int position, int size); + + protected native int getDeviceData(long di_device, ByteBuffer event_buffer, int event_buffer_size, IntBuffer buffer, int position, int size); + + protected native int unacquire(long di_device); + + protected int poll(long di_device) { + return WindowsDirectInput.DI_OK; + } + + protected native int setBufferSize(long di_device, int buffer_size); + protected native int getEventSize(); + + protected native void release(long di_device); + + protected native int enumObjects(long di_device, WindowsDirectInputDeviceObjectCallback enumerator); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInputDevice3 interface + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import org.lwjgl.LWJGLException; + +final class WindowsDirectInputDevice8 extends WindowsDirectInputDevice { + /** Re-declare to get the constants into the native headers */ + public final static int GUID_XAxis = WindowsDirectInputDevice.GUID_XAxis; + public final static int GUID_YAxis = WindowsDirectInputDevice.GUID_YAxis; + public final static int GUID_ZAxis = WindowsDirectInputDevice.GUID_ZAxis; + public final static int GUID_Button = WindowsDirectInputDevice.GUID_Button; + public final static int GUID_Unknown = WindowsDirectInputDevice.GUID_Unknown; + + public WindowsDirectInputDevice8(long di_device) { + super(di_device); + } + + protected native int setDataFormat(long di_device, int type); + + protected native int setCooperativeLevel(long di_device, long hwnd, int flags); + + protected native int acquire(long di_device); + + protected native int getDeviceState(long di_device, ByteBuffer buffer, int position, int size); + + protected native int getDeviceData(long di_device, ByteBuffer event_buffer, int event_buffer_size, IntBuffer buffer, int position, int size); + + protected native int unacquire(long di_device); + + protected native int poll(long di_device); + + protected native int setBufferSize(long di_device, int buffer_size); + protected native int getEventSize(); + + protected native void release(long di_device); + + protected native int enumObjects(long di_device, WindowsDirectInputDeviceObjectCallback enumerator); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the DirectInputDevice callback interface + * @author elias_naur + */ + +interface WindowsDirectInputDeviceObjectCallback { + public boolean nextObject(int type, String name); +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java ___________________________________________________________________ Name: svn:executable + * Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java (from rev 2382, trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the Windows implementation of the Keyboard. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.CharBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; + +final class WindowsKeyboard { + private final static int BUFFER_SIZE = 50; + + private final WindowsDirectInput dinput; + private final WindowsDirectInputDevice keyboard; + private final IntBuffer temp_data_buffer; + private final ByteBuffer keyboard_state; + private final CharBuffer unicode_buffer; + + public WindowsKeyboard(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + this.dinput = dinput; + try { + keyboard = dinput.createDevice(WindowsDirectInput.KEYBOARD_TYPE); + try { + keyboard.setCooperateLevel(hwnd, WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND); + keyboard.setDataFormat(WindowsDirectInput.KEYBOARD_TYPE); + keyboard.setBufferSize(BUFFER_SIZE); + } catch (LWJGLException e) { + keyboard.release(); + throw e; + } + } catch (LWJGLException e) { + dinput.release(); + throw e; + } + keyboard.acquire(); + temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*2); + keyboard_state = BufferUtils.createByteBuffer(256); + unicode_buffer = BufferUtils.createCharBuffer(BUFFER_SIZE); + } + + public void destroy() { + keyboard.unacquire(); + keyboard.release(); + dinput.release(); + } + + public void poll(ByteBuffer keyDownBuffer) { + int ret = keyboard.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + keyboard.poll(); + ret = keyboard.getDeviceState(keyDownBuffer); + switch (ret) { + case WindowsDirectInput.DI_OK: + break; + case WindowsDirectInput.DI_BUFFEROVERFLOW: + LWJGLUtil.log("Keyboard buffer overflow"); + break; + case WindowsDirectInput.DIERR_INPUTLOST: + break; + case WindowsDirectInput.DIERR_NOTACQUIRED: + break; + default: + LWJGLUtil.log("Failed to poll keyboard (0x" + Integer.toHexString(ret) + ")"); + break; + } + } + + private int translateData(IntBuffer src, IntBuffer dst) { + int dst_index = dst.position(); + int num_events = 0; + while (dst_index < dst.limit() && src.hasRemaining()) { + num_events++; + int dwOfs = src.get(); + dst.put(dst_index++, dwOfs); + int dwData = src.get(); + dst.put(dst_index++, dwData); + boolean key_down = (dwData & 0x80) != 0; + if (key_down) { + int virt_key = MapVirtualKey(dwOfs, 1); + if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { + // Mark key down in the scan code + dwOfs = dwOfs & 0x7fff; + unicode_buffer.clear(); + int num_chars = ToUnicode(virt_key, + dwOfs, + keyboard_state, + unicode_buffer, + unicode_buffer.capacity(), 0); + if (num_chars > 0) { + int current_char = 0; + do { + if (current_char >= 1) { + num_events++; + dst.put(dst_index++, 0); + dst.put(dst_index++, 0); + } + int char_int = ((int)unicode_buffer.get()) & 0xFFFF; + dst.put(dst_index++, char_int); + current_char++; + } while (dst_index < dst.limit() && current_char < num_chars); + } else { + dst.put(dst_index++, 0); + } + } else { + dst.put(dst_index++, 0); + } + } else + dst.put(dst_index++, 0); + } + return num_events; + } + private static native int MapVirtualKey(int uCode, int uMapType); + private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags); + private static native int GetKeyboardState(ByteBuffer lpKeyState); + + public int read(IntBuffer buffer) { + int ret = keyboard.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return 0; + keyboard.poll(); + temp_data_buffer.clear(); + ret = keyboard.getDeviceData(temp_data_buffer); + switch (ret) { + case WindowsDirectInput.DI_OK: + break; + case WindowsDirectInput.DI_BUFFEROVERFLOW: + LWJGLUtil.log("Keyboard buffer overflow"); + break; + case WindowsDirectInput.DIERR_INPUTLOST: + break; + case WindowsDirectInput.DIERR_NOTACQUIRED: + break; + default: + LWJGLUtil.log("Failed to read keyboard (0x" + Integer.toHexString(ret) + ")"); + break; + } + temp_data_buffer.flip(); + return translateData(temp_data_buffer, buffer); + } +} Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-06-26 13:50:48 UTC (rev 2386) @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the Windows implementation of the Mouse. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.CharBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; + +final class WindowsMouse { + private final static int BUFFER_SIZE = 50; + private final static int BUTTON_STATES_SIZE = 7; + private final static int MOUSE_EVENT_SIZE = 5; + + private final static int DIMOFS_X = 0; + private final static int DIMOFS_Y = 4; + private final static int DIMOFS_Z = 8; + private final static int DIMOFS_BUTTON0 = 12; + private final static int DIMOFS_BUTTON1 = 13; + private final static int DIMOFS_BUTTON2 = 14; + private final static int DIMOFS_BUTTON3 = 15; + + private final long hwnd; + private final WindowsDirectInput dinput; + private final WindowsDirectInputDevice mouse; + + private final int mouse_button_count; + private final boolean has_wheel; + + private final EventQueue event_queue = new EventQueue(MOUSE_EVENT_SIZE); + /* Buffer to hold a DIMOUSESTATE */ + private final ByteBuffer mouse_state; + private final IntBuffer temp_data_buffer; + + private final int[] mouse_event = new int[MOUSE_EVENT_SIZE]; + + private boolean mouse_grabbed; + private byte[] win32_message_button_states = new byte[BUTTON_STATES_SIZE]; + private int accum_dwheel; + private int last_x; + private int last_y; + + public WindowsMouse(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + this.hwnd = hwnd; + this.dinput = dinput; + try { + mouse = dinput.createDevice(WindowsDirectInput.MOUSE_TYPE); + try { + mouse.setDataFormat(WindowsDirectInput.MOUSE_TYPE); + mouse.setBufferSize(BUFFER_SIZE); + if (!acquireNonExclusive()) + throw new LWJGLException("Failed to acquire mouse non-exclusive"); + } catch (LWJGLException e) { + mouse.release(); + throw e; + } + } catch (LWJGLException e) { + dinput.release(); + throw e; + } + MouseEnumerator enumerator = new MouseEnumerator(); + mouse.enumObjects(enumerator); + this.mouse_button_count = Math.min(enumerator.getButtonCount(), 4); + this.has_wheel = enumerator.hasWheel(); + mouse_state = BufferUtils.createByteBuffer(3*4 + 4); + temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*2); + } + + public boolean hasWheel() { + return has_wheel; + } + + public int getButtonCount() { + return mouse_button_count; + } + + private boolean acquire(int flags) { + try { + mouse.setCooperateLevel(hwnd, flags); + mouse.acquire(); + return true; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to acquire mouse: " + e); + return false; + } + } + + private boolean acquireNonExclusive() { + return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || + acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); + } + + public void destroy() { + mouse.unacquire(); + mouse.release(); + dinput.release(); + } + + public void poll(IntBuffer coord_buffer, ByteBuffer buttons) { + int ret = mouse.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + mouse.poll(); + for (int i = 0; i < coord_buffer.remaining(); i++) + coord_buffer.put(coord_buffer.position() + i, 0); + mouse_state.clear(); + ret = mouse.getDeviceState(mouse_state); + int mouse_state_lx = mouse_state.getInt(); + int mouse_state_ly = mouse_state.getInt(); + int mouse_state_lz = mouse_state.getInt(); + int num_buttons = mouse_button_count; + if (mouse_grabbed || ret == WindowsDirectInput.DI_OK) { + if (ret != WindowsDirectInput.DI_OK) { + LWJGLUtil.log("Error getting mouse state: (0x" + Integer.toHexString(ret) + ")"); + return; + } + + coord_buffer.put(coord_buffer.position() + 2, mouse_state_lz); + if (num_buttons > buttons.remaining()) + num_buttons = buttons.remaining(); + for (int j = 0; j < num_buttons; j++) { + byte button_state = (mouse_state.get() & 0x80) != 0 ? (byte)1 : (byte)0; + buttons.put(buttons.position() + j, button_state); + // track the button state in the windows message buffer state array + // to get accurate button information when releasing a grab + win32_message_button_states[j] = button_state; + } + } else { + coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); + if (num_buttons > win32_message_button_states.length) + num_buttons = win32_message_button_states.length; + for (int j = 0; j < num_buttons; j++) { + buttons.put(buttons.position() + j, win32_message_button_states[j]); + } + } + accum_dwheel = 0; + if (mouse_grabbed) { + coord_buffer.put(coord_buffer.position() + 0, mouse_state_lx); + coord_buffer.put(coord_buffer.position() + 1, -mouse_state_ly); + } else { + coord_buffer.put(coord_buffer.position() + 0, last_x); + coord_buffer.put(coord_buffer.position() + 1, last_y); + } + } + + private boolean putMouseEventWithCoords(int button, int state, int coord1, int coord2, int dz) { + mouse_event[0] = button; + mouse_event[1] = state; + mouse_event[2] = coord1; + mouse_event[3] = coord2; + mouse_event[4] = dz; + return event_queue.putEvent(mouse_event); + } + + private boolean putMouseEvent(int button, int state, int dz) { + if (mouse_grabbed) + return putMouseEventWithCoords(button, state, 0, 0, dz); + else + return putMouseEventWithCoords(button, state, last_x, last_y, dz); + } + + private void copyDXEvents(IntBuffer buffer) { + int buffer_index = 0; + int dx = 0, dy = 0, dwheel = 0; + int button_state; + int i; + while (buffer.hasRemaining()) { + int dwOfs = buffer.get(); + int dwData = buffer.get(); + button_state = (dwData & 0x80) != 0 ? 1 : 0; + switch (dwOfs) { + case DIMOFS_BUTTON0: + putMouseEventWithCoords(0, button_state, dx, -dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON1: + putMouseEventWithCoords(1, button_state, dx, -dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON2: + putMouseEventWithCoords(2, button_state, dx, -dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON3: + putMouseEventWithCoords(3, button_state, dx, -dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_X: + dx += dwData; + break; + case DIMOFS_Y: + dy += dwData; + break; + case DIMOFS_Z: + dwheel += dwData; + break; + } + } + if (dx != 0 || dy != 0 || dwheel != 0) + putMouseEventWithCoords(-1, 0, dx, -dy, dwheel); + } + + private void readDXBuffer() { + int ret = mouse.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + mouse.poll(); + temp_data_buffer.clear(); + ret = mouse.getDeviceData(temp_data_buffer); + + if (ret == WindowsDirectInput.DI_OK) { + if (mouse_grabbed) { + temp_data_buffer.flip(); + copyDXEvents(temp_data_buffer); + } + } else if (ret == WindowsDirectInput.DI_BUFFEROVERFLOW) { + LWJGLUtil.log("Mouse buffer overflowed"); + } else if (ret == WindowsDirectInput.DIERR_INPUTLOST) { + LWJGLUtil.log("Mouse input lost"); + } else if (ret == WindowsDirectInput.DIERR_NOTACQUIRED) { + LWJGLUtil.log("Mouse not acquired"); + } else { + LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); + } + } + + public int read(IntBuffer buffer) { + readDXBuffer(); + return event_queue.copyEvents(buffer); + } + + public void grab(boolean grab) { + if(grab) { + if (!mouse_grabbed) { + // flush DX event buffer + readDXBuffer(); + mouse_grabbed = true; + mouse.unacquire(); + if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) + LWJGLUtil.log("Failed to reset cooperative mode"); + } + } else { + if (mouse_grabbed) { + mouse_grabbed = false; + mouse.unacquire(); + acquireNonExclusive(); + } + } + event_queue.clearEvents(); + } + + public void handleMouseScrolled(int event_dwheel) { + accum_dwheel += event_dwheel; + putMouseEvent(-1, 0, event_dwheel); + } + + public void handleMouseMoved(int x, int y) { + int dx; + int dy; + dx = x - last_x; + dy = y - last_y; + last_x = x; + last_y = y; + if (mouse_grabbed) { + putMouseEventWithCoords(-1, 0, dx, dy, 0); + } else { + putMouseEventWithCoords(-1, 0, x, y, 0); + } + } + + public void handleMouseButton(int button, int state) { + putMouseEvent(button, state, 0); + if (button < BUTTON_STATES_SIZE) + win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; + } + + private static class MouseEnumerator implements WindowsDirectInputDeviceObjectCallback { + private int button_count; + private boolean has_wheel; + + public int getButtonCount() { + return button_count; + } + + public boolean hasWheel() { + return has_wheel; + } + + public boolean nextObject(int type, String name) { + LWJGLUtil.log("Found mouse object: " + name); + switch (type) { + case WindowsDirectInputDevice.GUID_ZAxis: + has_wheel = true; + break; + case WindowsDirectInputDevice.GUID_Button: + button_count++; + break; + default: + break; + } + return true; + } + } +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java ___________________________________________________________________ Name: svn:executable + * Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2006-06-23 16:45:21 UTC (rev 2385) +++ trunk/LWJGL/src/native/common/common_tools.c 2006-06-26 13:50:48 UTC (rev 2386) @@ -97,12 +97,16 @@ jclass org_lwjgl_LWJGLUtil_class; jmethodID log_method; va_list ap; - if (isDebugEnabled()) { + if (isDebugEnabled() && !(*env)->ExceptionOccurred(env)) { va_start(ap, format);... [truncated message content] |
From: <eli...@us...> - 2006-06-27 15:42:25
|
Revision: 2393 Author: elias_naur Date: 2006-06-27 08:41:53 -0700 (Tue, 27 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2393&view=rev Log Message: ----------- Added an applet test (lwjgl from applets doesn't work yet). Modified Paths: -------------- trunk/LWJGL/build.xml Added Paths: ----------- trunk/LWJGL/applet/ trunk/LWJGL/applet/applet.html trunk/LWJGL/applet/lwjglkeystore Added: trunk/LWJGL/applet/applet.html =================================================================== --- trunk/LWJGL/applet/applet.html (rev 0) +++ trunk/LWJGL/applet/applet.html 2006-06-27 15:41:53 UTC (rev 2393) @@ -0,0 +1,5 @@ +<html> +<body> +<applet code="org.lwjgl.test.applet.LWJGLApplet" archive="lwjgl_applet.jar,lwjgl.jar" width="640" height="480"></applet> +</body> +</html> Added: trunk/LWJGL/applet/lwjglkeystore =================================================================== (Binary files differ) Property changes on: trunk/LWJGL/applet/lwjglkeystore ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-06-27 12:57:04 UTC (rev 2392) +++ trunk/LWJGL/build.xml 2006-06-27 15:41:53 UTC (rev 2393) @@ -75,6 +75,12 @@ <include name="org/lwjgl/devil/**"/> </fileset> + <!-- Files to include in the lwjgl_applet.jar file --> + <fileset id="lwjgl_applet.fileset" dir="${lwjgl.bin}"> + <exclude name="**.*"/> + <include name="org/lwjgl/test/applet/**"/> + </fileset> + <!-- Files to make Javadoc from --> <fileset id="lwjgl.javadoc.fileset" dir="${lwjgl.src}"> <include name="**/*.java" /> @@ -334,8 +340,18 @@ <jar destfile="${lwjgl.temp}/jar/lwjgl_devil.jar" taskname="lwjgl_devil.jar"> <fileset refid="lwjgl_devil.fileset" /> </jar> + </target> + <target name="applet" depends="jars"> + <!-- Create lwjgl_applet.jar --> + <jar destfile="applet/lwjgl_applet.jar" taskname="lwjgl_applet.jar"> + <fileset refid="lwjgl_applet.fileset" /> + </jar> + <copy file="${lwjgl.lib}/lwjgl.jar" todir="applet"/> + <signjar jar="applet/lwjgl.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> + </target> + <!-- Distributes files --> <target name="-distribute"> <delete> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-03 11:30:49
|
Revision: 2420 Author: elias_naur Date: 2006-07-03 04:30:30 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2420&view=rev Log Message: ----------- Removed org.lwjgl.util.model Modified Paths: -------------- trunk/LWJGL/build.xml Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/util/applet/ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java Removed Paths: ------------- trunk/LWJGL/res/model/ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java trunk/LWJGL/src/java/org/lwjgl/util/model/ Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-03 10:28:32 UTC (rev 2419) +++ trunk/LWJGL/build.xml 2006-07-03 11:30:30 UTC (rev 2420) @@ -31,6 +31,17 @@ <exclude name="org/lwjgl/examples/**" /> </fileset> + <fileset id="lwjgl_util_applet.fileset" dir="${lwjgl.bin}"> + <exclude name="**.*"/> + <include name="org/lwjgl/util/applet/**"/> + </fileset> + + <fileset id="lwjgl_util_applet_natives.fileset" dir="${lwjgl.lib}"> + <include name="win32/**"/> + <include name="linux/**"/> + <include name="macosx/**"/> + </fileset> + <!-- Files to include in the lwjgl_test.jar file --> <fileset id="lwjgl_test.fileset" dir="${lwjgl.bin}"> <exclude name="**.*" /> @@ -53,16 +64,10 @@ <fileset id="lwjgl_util.fileset" dir="${lwjgl.bin}"> <exclude name="**.*" /> <exclude name="org/lwjgl/util/generator/**" /> - <exclude name="org/lwjgl/util/model/**" /> + <exclude name="org/lwjgl/util/applet/**" /> <include name="org/lwjgl/util/**" /> </fileset> - <!-- Files to include in the lwjgl_model.jar file --> - <fileset id="lwjgl_model.fileset" dir="${lwjgl.bin}"> - <exclude name="**.*" /> - <include name="org/lwjgl/util/model/**" /> - </fileset> - <!-- Files to include in the lwjgl_fmod3.jar file --> <fileset id="lwjgl_fmod3.fileset" dir="${lwjgl.bin}"> <exclude name="**.*" /> @@ -162,7 +167,6 @@ <include name="**" /> <exclude name="jar/lwjgl_fmod3.jar" /> <exclude name="jar/lwjgl_devil.jar" /> - <exclude name="jar/lwjgl_model.jar" /> <exclude name="native/win32/lwjgl-*.dll" /> <exclude name="native/win32/DevIL.dll" /> <exclude name="native/win32/ILU.dll" /> @@ -171,7 +175,6 @@ <exclude name="native/linux/liblwjgl-*.so" /> <exclude name="native/macosx/libIL*.dylib" /> <exclude name="native/macosx/liblwjgl-*.jnilib" /> - <exclude name="res/model/**" /> <exclude name="res/ILtest.*" /> <exclude name="res/Missing_you.mod" /> <exclude name="res/phero*.*" /> @@ -182,7 +185,6 @@ <patternset id="lwjgl_optional"> <include name="jar/lwjgl_fmod3.jar" /> <include name="jar/lwjgl_devil.jar" /> - <include name="jar/lwjgl_model.jar" /> <include name="native/win32/lwjgl-*.dll" /> <include name="native/win32/DevIL.dll" /> <include name="native/win32/ILU.dll" /> @@ -314,6 +316,12 @@ <jar destfile="${lwjgl.temp}/jar/lwjgl.jar" taskname="lwjgl.jar"> <fileset refid="lwjgl.fileset" /> </jar> + + <!-- Create lwjgl_util_applet.jar --> + <jar destfile="${lwjgl.temp}/jar/lwjgl_util_applet.jar" taskname="lwjgl_util_applet.jar"> + <fileset refid="lwjgl_util_applet.fileset" /> + <fileset refid="lwjgl_util_applet_natives.fileset"/> + </jar> <!-- Create lwjgl_test.jar --> <jar destfile="${lwjgl.temp}/jar/lwjgl_test.jar" taskname="lwjgl_test.jar"> @@ -326,11 +334,6 @@ <fileset refid="lwjgl_util.fileset" /> </jar> - <!-- Create lwjgl_model.jar --> - <jar destfile="${lwjgl.temp}/jar/lwjgl_model.jar" taskname="lwjgl_model.jar"> - <fileset refid="lwjgl_model.fileset" /> - </jar> - <!-- Create lwjgl_fmod.jar --> <jar destfile="${lwjgl.temp}/jar/lwjgl_fmod3.jar" taskname="lwjgl_fmod3.jar"> <fileset refid="lwjgl_fmod3.fileset" /> @@ -348,18 +351,15 @@ <fileset refid="lwjgl_applet.fileset" /> </jar> <copy file="${lwjgl.lib}/lwjgl.jar" todir="applet"/> + <copy file="${lwjgl.lib}/lwjgl_util_applet.jar" todir="applet"/> <copy file="${lwjgl.lib}/lwjgl_util.jar" todir="applet"/> <copy file="${lwjgl.lib}/lwjgl_fmod3.jar" todir="applet"/> <copy file="${lwjgl.lib}/lwjgl_devil.jar" todir="applet"/> <zip destfile="applet/res.jar"> <zipfileset dir="${lwjgl.res}" includes="Footsteps.wav, ILtest.tga, Missing_you.mod"/> </zip> - <zip destfile="applet/lwjgl.jar" update="true"> - <zipfileset dir="${lwjgl.lib}" prefix="native" includes="win32/**"/> - <zipfileset dir="${lwjgl.lib}" prefix="native" includes="linux/**"/> - <zipfileset dir="${lwjgl.lib}" prefix="native" includes="macosx/**"/> - </zip> <signjar jar="applet/lwjgl.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> + <signjar jar="applet/lwjgl_util_applet.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> <signjar jar="applet/lwjgl_fmod3.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> <signjar jar="applet/lwjgl_devil.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> </target> @@ -438,6 +438,7 @@ <target name="headers" description="invokes javah on java classes" depends="compile"> <!-- platform specific classes --> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes"> + <class name="org.lwjgl.opengl.LinuxKeyboard" /> <class name="org.lwjgl.opengl.LinuxDisplay" /> <class name="org.lwjgl.opengl.LinuxPeerInfo" /> <class name="org.lwjgl.opengl.LinuxPbufferPeerInfo" /> Copied: trunk/LWJGL/src/java/org/lwjgl/util/applet (from rev 2415, trunk/LWJGL/src/java/org/lwjgl/applet) Deleted: trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-02 22:01:27 UTC (rev 2415) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 11:30:30 UTC (rev 2420) @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2006 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.applet; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileFilter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; - -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; - -/** - * <p> - * - * </p> - * @author Brian Matzon <br...@ma...> - * @version $Revision$ - * $Id$ - */ -public class LWJGLInstaller { - - /** - * Files to install for each supported platform - * @see org.lwjgl.LWJGLUtil#getPlatform() - */ - public static final String[][] PLATFORM_FILES = { - { "lwjgl", "lwjgl-fmod3", "lwjgl-devil", "openal", "fmod", "IL", "ILU", "ILUT", "jinput-osx"}, - { "lwjgl", "lwjgl-fmod3", "lwjgl-devil", "openal", "fmod", "IL", "ILU", "ILUT", "jinput-linux"}, - { "lwjgl", "lwjgl-fmod3", "lwjgl-devil", "OpenAL32", "fmod", "DevIL", "ILU", "ILUT", "jinput-dx8", "jinput-raw"} - }; - - /** Whether the installer has been called */ - public static boolean installed; - - /** Whether to hook uninstall rutine. Must be called prior to installation */ - public static boolean disableUninstall = false; - - /** Directory that was installed into */ - public static String installDirectory; - - /** Buffer used when copying files */ - private static final byte[] COPY_BUFFER = new byte[4096]; - - private LWJGLInstaller() { - /* Unused */ - } - - /** - * Create a temporary installation of LWJGL. - * This will extract the relevant native files (for the platform) into - * the users temp directory, and instruct the LWJGL subsystem to load its - * native files from there. - * The files required by the installer, are gotten from the classloader via its - * getResource command, and are assumed to in the path: /native/<win32|linux|macosx>/ - * Any call to this method will also add a shutdown hook to the uninstall of the libraries - * Note: Due to the nature of native libraries, we cannot actually uninstall the currently - * loaded files, but rather the "last" installed. This means that the most recent install of LWJGL - * will always be present in the users temp dir. - * - * @see java.lang.ClassLoader#getResource(String) - * @return true if the installation was successfull - */ - public static boolean tempInstall() throws LWJGLException { - // only need to install once - if (installed) { - return true; - } - - // libraries to validate and install - String[] libraries = PLATFORM_FILES[LWJGLUtil.getPlatform() - 1]; - - // Validate the certificates of the native files - validateCertificates(); - - // install shutdown installer hook - if(!disableUninstall) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - LWJGLInstaller.uninstall(); - } - }); - return null; - } - }); - } - - // create a temporary dir for the native files - String user_temp_dir = getPriveledgedString("java.io.tmpdir"); - String path = createTemporaryDir(user_temp_dir); - if(path == null) { - throw new LWJGLException("Failed creation of temporary directory in " + user_temp_dir); - } - - // extract natives - for (int i = 0; i < libraries.length; i++) { - String library = System.mapLibraryName(libraries[i]); - if(!extract(library, path)) { - LWJGLUtil.log("Failed extract of " + library + " to " + path); - uninstall(); - return false; - } - } - - installDirectory = path; - return installed = true; - } - - /** - * Validates the certificates of the native libraries. - * When installing native libraries, it is imperative that we also check the certficates. - * The reson for this, is that a user may inject a malicious jar to the classpath - * before the "real" LWJGL jar, containing native libraries with unwanted code. - * By forcing all the native libraries to have the same certificate as the signed - * installer, we can also be sure that the native libraries indeed are correct. - * @throws LWJGLException If we encounter a certificate mismatch - */ - private static void validateCertificates() throws LWJGLException { - /* TODO */ - } - - /** - * Extracts a file in the classpath to a specified dir - * - * @param file File to extract - * @param path Path to extract to - * @return true if the file was extracted successdully - */ - private static boolean extract(final String file, final String path) throws LWJGLException { - return (Boolean) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - // check for existing file, and get out - File out = new File(path + File.separator + file); - if (out.exists()) { - return false; - } - - // create the new file and copy it to its destination - try { - out.createNewFile(); - String in = "/native/" + LWJGLUtil.getPlatformName() + "/" + file; - OutputStream os = new BufferedOutputStream(new FileOutputStream(out)); - InputStream is = new BufferedInputStream(getClass().getResourceAsStream(in)); - - // Sanity check - // =========================================== - if (os == null) { - LWJGLUtil.log("Unable to write to outputstream at " + out.getAbsolutePath()); - return false; - } - - if (is == null) { - LWJGLUtil.log("Unable to read classpath inputstream from " + in); - return false; - } - // ------------------------------------------- - - // copy the actual file - copyFile(is, os); - } catch (IOException ioe) { - LWJGLUtil.log("Exception while extracting " + file + ": " + ioe.getMessage()); - return false; - } - return true; - } - }); - } - - /** - * Copies an inputstream to an outputstream - * @param is InputStream to read from - * @param os OutputStream to write to - * @throws IOException if the copy process fail in any way - */ - static void copyFile(InputStream is, OutputStream os) throws IOException { - int len; - while ((len = is.read(COPY_BUFFER)) > 0) { - os.write(COPY_BUFFER, 0, len); - } - is.close(); - os.close(); - } - - /** - * Creates the temporary dir to store lwjgl files in. - * The temporary dir will be created in the users temp dir and - * called 'lwjgl-' and appended System.currentTimeMillis(). A watermark file - * called '.lwjglinstaller' will also be created in the directory. - * @return Name of temp directory or null if directory creation failed - */ - static String createTemporaryDir(final String user_temp_dir) { - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - // create the temp directory - File tempDir = new File(user_temp_dir + File.separator + "lwjgl-" + System.currentTimeMillis()); - if(!tempDir.mkdir()) { - return null; - } - - // add the watermark file - // TODO: Write some info to the file ? - try { - File watermark = new File(tempDir.getAbsolutePath() + File.separator + ".lwjglinstaller"); - watermark.createNewFile(); - } catch (IOException ioe) { - return null; - } - return tempDir.getAbsolutePath(); - } - }); - } - - - /** - * Gets a property as a privileged action. - */ - private static String getPriveledgedString(final String property) { - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); - } - - /** - * Uninstalls any PREVIOUS installations - * We cannot uninstall the current installation, since the files are locked - * by the VM. - */ - private static void uninstall() { - LWJGLUtil.log("running LWJGL uninstaller"); - - // locate all installer dirs and uninstall them - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String temp = System.getProperty("java.io.tmpdir"); - File tempDir = new File(temp); - File[] files = tempDir.listFiles(new FileFilter() { - - /* - * @see java.io.FileFilter#accept(java.io.File) - */ - public boolean accept(File pathname) { - return pathname.getAbsolutePath().indexOf("lwjgl") != -1 && isInstallDirectory(pathname); - } - - /** - * Checks whether the specified directory is an install directory. - * This is done by checking for the watermark file - * @param directory Directory to check - * @return true if the directory is an install directory - */ - private boolean isInstallDirectory(File directory) { - File installFile = new File(directory.getAbsolutePath() + File.separator + ".lwjglinstaller"); - return installFile.exists(); - } - - }); - - // uninstall each of the dirs - for (int i = 0; i < files.length; i++) { - uninstall(files[i]); - } - return null; - } - }); - } - - /** - * Uninstall LWJGL from a directory. This deletes all the files in the directory - * and deletes the directory too. - * @param file directory to uninstall LWJGL from - */ - private static void uninstall(File file) { - File[] files = file.listFiles(); - for (int i = 0; i < files.length; i++) { - files[i].delete(); - } - file.delete(); - } -} \ No newline at end of file Copied: trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java (from rev 2419, trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 11:30:30 UTC (rev 2420) @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2006 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.applet; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileFilter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; + +import org.lwjgl.LWJGLUtil; + +/** + * <p> + * + * </p> + * @author Brian Matzon <br...@ma...> + * @version $Revision$ + * $Id$ + */ +public class LWJGLInstaller { + + /** + * Files to install for each supported platform + * @see org.lwjgl.LWJGLUtil#getPlatform() + */ + public static final String[][] PLATFORM_FILES = { + { "lwjgl", "lwjgl-fmod3", "lwjgl-devil", "openal", "fmod", "IL", "ILU", "ILUT", "jinput-osx"}, + { "lwjgl", "lwjgl-fmod3", "lwjgl-devil", "openal", "fmod", "IL", "ILU", "ILUT", "jinput-linux"}, + { "lwjgl", "lwjgl-fmod3", "lwjgl-devil", "OpenAL32", "fmod", "DevIL", "ILU", "ILUT", "jinput-dx8", "jinput-raw"} + }; + + /** Whether the installer has been called */ + public static boolean installed; + + /** Whether to hook uninstall rutine. Must be called prior to installation */ + public static boolean disableUninstall = false; + + /** Buffer used when copying files */ + private static final byte[] COPY_BUFFER = new byte[4096]; + + private LWJGLInstaller() { + /* Unused */ + } + + /** + * Create a temporary installation of LWJGL. + * This will extract the relevant native files (for the platform) into + * the users temp directory, and instruct the LWJGL subsystem to load its + * native files from there. + * The files required by the installer, are gotten from the classloader via its + * getResource command, and are assumed to in the path: /native/<win32|linux|macosx>/ + * Any call to this method will also add a shutdown hook to the uninstall of the libraries + * Note: Due to the nature of native libraries, we cannot actually uninstall the currently + * loaded files, but rather the "last" installed. This means that the most recent install of LWJGL + * will always be present in the users temp dir. + * + * @see java.lang.ClassLoader#getResource(String) + */ + public static void tempInstall() throws Exception { + // only need to install once + if (installed) { + return; + } + + try { + // libraries to validate and install + String[] libraries = PLATFORM_FILES[LWJGLUtil.getPlatform() - 1]; + + // Validate the certificates of the native files + validateCertificates(); + + // install shutdown installer hook + if(!disableUninstall) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + uninstall(); + } + }); + return null; + } + }); + } + + // create a temporary dir for the native files + String user_temp_dir = getPriviledgedString("java.io.tmpdir"); + final String path = createTemporaryDir(user_temp_dir); + + // extract natives + for (int i = 0; i < libraries.length; i++) { + String library = System.mapLibraryName(libraries[i]); + extract(library, path); + } + + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + System.setProperty("org.lwjgl.librarypath", path); + return null; + } + }); + } catch (Exception e) { + LWJGLUtil.log("Failed extraction e = " + e.getMessage()); + uninstall(); + throw e; + } + } + + /** + * Validates the certificates of the native libraries. + * When installing native libraries, it is imperative that we also check the certficates. + * The reson for this, is that a user may inject a malicious jar to the classpath + * before the "real" LWJGL jar, containing native libraries with unwanted code. + * By forcing all the native libraries to have the same certificate as the signed + * installer, we can also be sure that the native libraries indeed are correct. + * @throws Exception If we encounter a certificate mismatch + */ + private static void validateCertificates() throws Exception { + /* TODO */ + } + + /** + * Extracts a file in the classpath to a specified dir + * + * @param file File to extract + * @param path Path to extract to + */ + private static void extract(final String file, final String path) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + // check for existing file, and get out + File out = new File(path + File.separator + file); + if (out.exists()) { + return null; + } + + // create the new file and copy it to its destination + try { + out.createNewFile(); + String in = "/native/" + LWJGLUtil.getPlatformName() + "/" + file; + OutputStream os = new BufferedOutputStream(new FileOutputStream(out)); + InputStream is = new BufferedInputStream(getClass().getResourceAsStream(in)); + + // Sanity check + // =========================================== + if (os == null) { + LWJGLUtil.log("Unable to write to outputstream at " + out.getAbsolutePath()); + return null; + } + + if (is == null) { + LWJGLUtil.log("Unable to read classpath inputstream from " + in); + return null; + } + // ------------------------------------------- + + // copy the actual file + copyFile(is, os); + } catch (IOException ioe) { + LWJGLUtil.log("Exception while extracting " + file + ": " + ioe.getMessage()); + return null; + } + return null; + } + }); + } + + /** + * Copies an inputstream to an outputstream + * @param is InputStream to read from + * @param os OutputStream to write to + * @throws IOException if the copy process fail in any way + */ + static void copyFile(InputStream is, OutputStream os) throws IOException { + int len; + while ((len = is.read(COPY_BUFFER)) > 0) { + os.write(COPY_BUFFER, 0, len); + } + is.close(); + os.close(); + } + + /** + * Creates the temporary dir to store lwjgl files in. + * The temporary dir will be created in the users temp dir and + * called 'lwjgl-' and appended System.currentTimeMillis(). A watermark file + * called '.lwjglinstaller' will also be created in the directory. + * @return Name of temp directory or null if directory creation failed + */ + static String createTemporaryDir(final String user_temp_dir) throws Exception { + return (String) AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + // create the temp directory + File tempDir = new File(user_temp_dir + File.separator + "lwjgl-" + System.currentTimeMillis()); + if(!tempDir.mkdir()) { + throw new IOException("Failed to create directory: " + tempDir); + } + + // add the watermark file + // TODO: Write some info to the file ? + File watermark = new File(tempDir.getAbsolutePath() + File.separator + ".lwjglinstaller"); + watermark.createNewFile(); + return tempDir.getAbsolutePath(); + } + }); + } + + + /** + * Gets a property as a privileged action. + */ + private static String getPriviledgedString(final String property) { + return (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(property); + } + }); + } + + /** + * Uninstalls any PREVIOUS installations + * We cannot uninstall the current installation, since the files are locked + * by the VM. + */ + private static void uninstall() { + LWJGLUtil.log("running LWJGL uninstaller"); + + // locate all installer dirs and uninstall them + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + String temp = System.getProperty("java.io.tmpdir"); + File tempDir = new File(temp); + File[] files = tempDir.listFiles(new FileFilter() { + + /* + * @see java.io.FileFilter#accept(java.io.File) + */ + public boolean accept(File pathname) { + return pathname.getAbsolutePath().indexOf("lwjgl") != -1 && isInstallDirectory(pathname); + } + + /** + * Checks whether the specified directory is an install directory. + * This is done by checking for the watermark file + * @param directory Directory to check + * @return true if the directory is an install directory + */ + private boolean isInstallDirectory(File directory) { + File installFile = new File(directory.getAbsolutePath() + File.separator + ".lwjglinstaller"); + return installFile.exists(); + } + + }); + + // uninstall each of the dirs + for (int i = 0; i < files.length; i++) { + uninstall(files[i]); + } + return null; + } + }); + } + + /** + * Uninstall LWJGL from a directory. This deletes all the files in the directory + * and deletes the directory too. + * @param file directory to uninstall LWJGL from + */ + private static void uninstall(File file) { + File[] files = file.listFiles(); + for (int i = 0; i < files.length; i++) { + files[i].delete(); + } + file.delete(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-03 18:08:54
|
Revision: 2425 Author: elias_naur Date: 2006-07-03 11:07:44 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2425&view=rev Log Message: ----------- Linux: Moved most input related stuff from native to java Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/common/common_tools.h trunk/LWJGL/src/native/linux/Window.h trunk/LWJGL/src/native/linux/display.c trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c trunk/LWJGL/src/native/win32/dinputhelper.c trunk/LWJGL/src/native/win32/dinputhelper.h Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeycodes.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c Removed Paths: ------------- trunk/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.c trunk/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-03 12:00:12 UTC (rev 2424) +++ trunk/LWJGL/build.xml 2006-07-03 18:07:44 UTC (rev 2425) @@ -450,6 +450,7 @@ <target name="headers" description="invokes javah on java classes" depends="compile"> <!-- platform specific classes --> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes"> + <class name="org.lwjgl.opengl.LinuxMouse" /> <class name="org.lwjgl.opengl.LinuxKeyboard" /> <class name="org.lwjgl.opengl.LinuxDisplay" /> <class name="org.lwjgl.opengl.LinuxPeerInfo" /> Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 12:00:12 UTC (rev 2424) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:07:44 UTC (rev 2425) @@ -47,6 +47,13 @@ import org.lwjgl.input.Keyboard; final class LinuxDisplay implements DisplayImplementation { + /* X11 constants */ + private final static int GrabSuccess = 0; + private final static int AutoRepeatModeOff = 0; + private final static int AutoRepeatModeOn = 1; + private final static int AutoRepeatModeDefault = 2; + + /** Window mode enum */ private static final int FULLSCREEN_LEGACY = 1; private static final int FULLSCREEN_NETWM = 2; @@ -63,8 +70,6 @@ /** Current mode swithcing API */ private static int current_displaymode_extension = NONE; - private static final int NUM_BUTTONS = 3; - /** Keep track on the current awt lock owner to avoid * depending on JAWT locking to be re-entrant (This is a * problem with GCJ). JAWT locking is not that well specified @@ -86,6 +91,17 @@ private static DisplayMode saved_mode; private static DisplayMode current_mode; + private static boolean keyboard_grabbed; + private static boolean pointer_grabbed; + private static boolean input_released; + private static boolean grab; + private static boolean focused; + private static ByteBuffer current_cursor; + private static ByteBuffer blank_cursor; + + private static LinuxKeyboard keyboard; + private static LinuxMouse mouse; + private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { lockAWT(); try { @@ -257,15 +273,113 @@ return WINDOWED; } + private static native long getDisplay(); + private static native int getScreen(); + private static native long getWindow(); + + private static void ungrabKeyboard() { + if (keyboard_grabbed) { + nUngrabKeyboard(getDisplay()); + keyboard_grabbed = false; + } + } + private static native int nUngrabKeyboard(long display); + + private static void grabKeyboard() { + if (!keyboard_grabbed) { + int res = nGrabKeyboard(getDisplay(), getWindow()); + if (res == GrabSuccess) + keyboard_grabbed = true; + } + } + private static native int nGrabKeyboard(long display, long window); + + private static void grabPointer() { + if (!pointer_grabbed) { + int result = nGrabPointer(getDisplay(), getWindow()); + if (result == GrabSuccess) { + pointer_grabbed = true; + // make sure we have a centered window + if (isLegacyFullscreen()) { + nSetViewPort(getDisplay(), getWindow(), getScreen()); + } + } + } + } + private static native int nGrabPointer(long display, long window); + private static native void nSetViewPort(long display, long window, int screen); + + private static void ungrabPointer() { + if (pointer_grabbed) { + pointer_grabbed = false; + nUngrabPointer(getDisplay()); + } + } + private static native int nUngrabPointer(long display); + + private static boolean isFullscreen() { + return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM; + } + + private static boolean shouldGrab() { + return !input_released && grab; + } + + private static void updatePointerGrab() { + if (isFullscreen() || shouldGrab()) { + grabPointer(); + } else { + ungrabPointer(); + } + updateCursor(); + } + + private static void updateCursor() { + ByteBuffer cursor; + if (shouldGrab()) { + cursor = blank_cursor; + } else { + cursor = current_cursor; + } + nDefineCursor(getDisplay(), getWindow(), cursor); + } + private static native void nDefineCursor(long display, long window, ByteBuffer cursor_handle); + + private static boolean isLegacyFullscreen() { + return current_window_mode == FULLSCREEN_LEGACY; + } + + private static void updateKeyboardGrab() { + if (isLegacyFullscreen()) + grabKeyboard(); + else + ungrabKeyboard(); + } + public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { lockAWT(); try { - ByteBuffer handle = peer_info.lockAndGetHandle(); + incDisplay(); try { - current_window_mode = getWindowMode(fullscreen); - nCreateWindow(handle, mode, current_window_mode, x, y); - } finally { - peer_info.unlock(); + ByteBuffer handle = peer_info.lockAndGetHandle(); + try { + current_window_mode = getWindowMode(fullscreen); + nCreateWindow(handle, mode, current_window_mode, x, y); + blank_cursor = createBlankCursor(); + current_cursor = null; + focused = true; + input_released = false; + pointer_grabbed = false; + keyboard_grabbed = false; + grab = false; + updateInputGrab(); + nSetRepeatMode(getDisplay(), AutoRepeatModeOff); + } finally { + peer_info.unlock(); + } + } catch (LWJGLException e) { + decDisplay(); + throw e; } } finally { unlockAWT(); @@ -273,23 +387,41 @@ } private static native void nCreateWindow(ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException; + private static void updateInputGrab() { + updatePointerGrab(); + updateKeyboardGrab(); + } + public void destroyWindow() { lockAWT(); - nDestroyWindow(); - unlockAWT(); + try { + try { + setNativeCursor(null); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset cursor: " + e.getMessage()); + } + nDestroyCursor(blank_cursor); + blank_cursor = null; + ungrabKeyboard(); + nDestroyWindow(); + nSetRepeatMode(getDisplay(), AutoRepeatModeDefault); + decDisplay(); + } finally { + unlockAWT(); + } } private static native void nDestroyWindow(); public void switchDisplayMode(DisplayMode mode) throws LWJGLException { lockAWT(); try { - nSwitchDisplayMode(current_displaymode_extension, mode); + nSwitchDisplayMode(getScreen(), current_displaymode_extension, mode); current_mode = mode; } finally { unlockAWT(); } } - private static native void nSwitchDisplayMode(int extension, DisplayMode mode) throws LWJGLException; + private static native void nSwitchDisplayMode(int screen, int extension, DisplayMode mode) throws LWJGLException; public void resetDisplayMode() { lockAWT(); @@ -312,7 +444,7 @@ try { incDisplay(); try { - return nGetGammaRampLength(); + return nGetGammaRampLength(getDisplay(), getScreen()); } catch (LWJGLException e) { LWJGLUtil.log("Got exception while querying gamma length: " + e); return 0; @@ -327,7 +459,7 @@ unlockAWT(); } } - private static native int nGetGammaRampLength() throws LWJGLException; + private static native int nGetGammaRampLength(long display, int screen) throws LWJGLException; public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { if (!isXF86VidModeSupported()) @@ -338,13 +470,13 @@ private static void doSetGamma(ByteBuffer native_gamma) throws LWJGLException { lockAWT(); try { - nSetGammaRamp(native_gamma); + nSetGammaRamp(getScreen(), native_gamma); current_gamma = native_gamma; } finally { unlockAWT(); } } - private static native void nSetGammaRamp(ByteBuffer gammaRamp) throws LWJGLException; + private static native void nSetGammaRamp(int screen, ByteBuffer gammaRamp) throws LWJGLException; private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException { return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining()); @@ -406,34 +538,42 @@ public void setTitle(String title) { lockAWT(); - nSetTitle(title); - unlockAWT(); + try { + nSetTitle(title); + } finally { + unlockAWT(); + } } private static native void nSetTitle(String title); public boolean isCloseRequested() { lockAWT(); - boolean result = nIsCloseRequested(); - unlockAWT(); - return result; + try { + return nIsCloseRequested(); + } finally { + unlockAWT(); + } } private static native boolean nIsCloseRequested(); public boolean isVisible() { lockAWT(); - boolean result = nIsVisible(); - unlockAWT(); - return result; + try { + return nIsVisible(); + } finally { + unlockAWT(); + } } private static native boolean nIsVisible(); public boolean isActive() { lockAWT(); - boolean result = nIsActive(current_window_mode); - unlockAWT(); - return result; + try { + return focused || isLegacyFullscreen(); + } finally { + unlockAWT(); + } } - private static native boolean nIsActive(int window_mode); public boolean isDirty() { lockAWT(); @@ -452,17 +592,22 @@ lockAWT(); try { nUpdate(current_displaymode_extension, current_window_mode, saved_gamma, current_gamma, saved_mode, current_mode); + checkInput(); } catch (LWJGLException e) { LWJGLUtil.log("Caught exception while processing messages: " + e); + } finally { + unlockAWT(); } - unlockAWT(); } private static native void nUpdate(int extension, int current_window_mode, ByteBuffer saved_gamma, ByteBuffer current_gamma, DisplayMode saved_mode, DisplayMode current_mode) throws LWJGLException; public void reshape(int x, int y, int width, int height) { lockAWT(); - nReshape(x, y, width, height); - unlockAWT(); + try { + nReshape(x, y, width, height); + } finally { + unlockAWT(); + } } private static native void nReshape(int x, int y, int width, int height); @@ -488,61 +633,118 @@ } public int getButtonCount() { - return NUM_BUTTONS; + return mouse.getButtonCount(); } public void createMouse() { lockAWT(); - nCreateMouse(current_window_mode); - unlockAWT(); + try { + mouse = new LinuxMouse(getDisplay(), getWindow()); + } finally { + unlockAWT(); + } } - private static native void nCreateMouse(int window_mode); public void destroyMouse() { - lockAWT(); - nDestroyMouse(); - unlockAWT(); + mouse = null; } - private static native void nDestroyMouse(); public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { update(); lockAWT(); - nPollMouse(coord_buffer, buttons); - unlockAWT(); + try { + mouse.poll(grab, coord_buffer, buttons); + } finally { + unlockAWT(); + } } - private static native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons); public int readMouse(IntBuffer buffer) { update(); lockAWT(); - int count = nReadMouse(buffer, buffer.position()); - unlockAWT(); - return count; + try { + return mouse.read(buffer); + } finally { + unlockAWT(); + } } - private static native int nReadMouse(IntBuffer buffer, int buffer_position); public void setCursorPosition(int x, int y) { lockAWT(); - nSetCursorPosition(x, y); - unlockAWT(); + try { + mouse.setCursorPosition(x, y); + } finally { + unlockAWT(); + } } - private native void nSetCursorPosition(int x, int y); - public void grabMouse(boolean grab) { + private static void checkInput() { + focused = nGetInputFocus(getDisplay()) == getWindow(); + if (focused) { + acquireInput(); + } else { + releaseInput(); + } + } + private static native long nGetInputFocus(long display); + + private static void releaseInput() { + if (isLegacyFullscreen() || input_released) + return; + input_released = true; + nSetRepeatMode(getDisplay(), AutoRepeatModeDefault); + updateInputGrab(); + if (current_window_mode == FULLSCREEN_NETWM) { + nIconifyWindow(getDisplay(), getWindow(), getScreen()); + try { + nSwitchDisplayMode(getScreen(), current_displaymode_extension, saved_mode); + nSetGammaRamp(getScreen(), saved_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage()); + } + } + } + private static native void nIconifyWindow(long display, long window, int screen); + + private static void acquireInput() { + if (isLegacyFullscreen() || !input_released) + return; + input_released = false; + nSetRepeatMode(getDisplay(), AutoRepeatModeOff); + updateInputGrab(); + if (current_window_mode == FULLSCREEN_NETWM) { + try { + nSwitchDisplayMode(getScreen(), current_displaymode_extension, current_mode); + nSetGammaRamp(getScreen(), current_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore mode: " + e.getMessage()); + } + } + } + private static native void nSetRepeatMode(long display, int mode); + + public void grabMouse(boolean new_grab) { lockAWT(); - nGrabMouse(current_window_mode, grab); - unlockAWT(); + try { + if (new_grab != grab) { + grab = new_grab; + updateInputGrab(); + mouse.changeGrabbed(grab, pointer_grabbed, shouldGrab()); + } + } finally { + unlockAWT(); + } } - private static native void nGrabMouse(int window_mode, boolean grab); public int getNativeCursorCapabilities() { lockAWT(); try { incDisplay(); - int caps = nGetNativeCursorCapabilities(); - decDisplay(); - return caps; + try { + return nGetNativeCursorCapabilities(); + } finally { + decDisplay(); + } } catch (LWJGLException e) { throw new RuntimeException(e); } finally { @@ -552,19 +754,24 @@ private static native int nGetNativeCursorCapabilities() throws LWJGLException; public void setNativeCursor(Object handle) throws LWJGLException { + current_cursor = (ByteBuffer)handle; lockAWT(); - nSetNativeCursor(handle); - unlockAWT(); + try { + updateCursor(); + } finally { + unlockAWT(); + } } - private static native void nSetNativeCursor(Object handle) throws LWJGLException; public int getMinCursorSize() { lockAWT(); try { incDisplay(); - int min_size = nGetMinCursorSize(); - decDisplay(); - return min_size; + try { + return nGetMinCursorSize(); + } finally { + decDisplay(); + } } catch (LWJGLException e) { LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e); return 0; @@ -578,9 +785,11 @@ lockAWT(); try { incDisplay(); - int max_size = nGetMaxCursorSize(); - decDisplay(); - return max_size; + try { + return nGetMaxCursorSize(); + } finally { + decDisplay(); + } } catch (LWJGLException e) { LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e); return 0; @@ -594,36 +803,41 @@ public void createKeyboard() throws LWJGLException { lockAWT(); try { - nCreateKeyboard(current_window_mode); + keyboard = new LinuxKeyboard(getDisplay(), getWindow()); } finally { unlockAWT(); } } - private static native void nCreateKeyboard(int window_mode) throws LWJGLException; public void destroyKeyboard() { lockAWT(); - nDestroyKeyboard(); - unlockAWT(); + try { + keyboard.destroy(); + keyboard = null; + } finally { + unlockAWT(); + } } - private static native void nDestroyKeyboard(); public void pollKeyboard(ByteBuffer keyDownBuffer) { update(); lockAWT(); - nPollKeyboard(keyDownBuffer); - unlockAWT(); + try { + keyboard.poll(keyDownBuffer); + } finally { + unlockAWT(); + } } - private static native void nPollKeyboard(ByteBuffer keyDownBuffer); public int readKeyboard(IntBuffer buffer) { update(); lockAWT(); - int count = nReadKeyboard(buffer, buffer.position()); - unlockAWT(); - return count; + try { + return keyboard.read(buffer); + } finally { + unlockAWT(); + } } - private static native int nReadKeyboard(IntBuffer buffer, int buffer_position); /* public int isStateKeySet(int key) { return Keyboard.STATE_UNKNOWN; @@ -631,6 +845,11 @@ */ private static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; + private static ByteBuffer createBlankCursor() { + return nCreateBlankCursor(getDisplay(), getWindow()); + } + private static native ByteBuffer nCreateBlankCursor(long display, long window); + public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { lockAWT(); try { @@ -648,9 +867,12 @@ public void destroyCursor(Object cursorHandle) { lockAWT(); - nDestroyCursor(cursorHandle); - decDisplay(); - unlockAWT(); + try { + nDestroyCursor(cursorHandle); + decDisplay(); + } finally { + unlockAWT(); + } } private static native void nDestroyCursor(Object cursorHandle); @@ -658,9 +880,11 @@ lockAWT(); try { incDisplay(); - int caps = nGetPbufferCapabilities(); - decDisplay(); - return caps; + try { + return nGetPbufferCapabilities(); + } finally { + decDisplay(); + } } catch (LWJGLException e) { LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e); return 0; @@ -753,4 +977,25 @@ } private static native void nSetWindowIcon(ByteBuffer icon, int icons_size, int width, int height); + + /* Callbacks from nUpdate() */ + private static void handleButtonEvent(long millis, int type, int button, int state) { + if (mouse != null) + mouse.handleButtonEvent(grab, type, button); + } + + private static void handleKeyEvent(long event_ptr, long millis, int type, int keycode, int state) { + if (keyboard != null) + keyboard.handleKeyEvent(event_ptr, millis, type, keycode, state); + } + + private static void handlePointerMotionEvent(long root_window, int x_root, int y_root, int x, int y, int state) { + if (mouse != null) + mouse.handlePointerMotion(grab, pointer_grabbed, shouldGrab(), root_window, x_root, y_root, x, y); + } + + private static void handleWarpEvent(int x, int y) { + if (mouse != null) + mouse.handleWarpEvent(x, y); + } } Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java (from rev 2397, trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-03 18:07:44 UTC (rev 2425) @@ -0,0 +1,305 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.CharBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Keyboard; + +import java.nio.charset.CharsetDecoder; +import java.nio.charset.Charset; + +final class LinuxKeyboard { + private static final int LockMapIndex = 1; + private static final int KeyPress = 2; + private static final int KeyRelease = 3; + private static final long NoSymbol = 0; + private static final long ShiftMask = 1 << 0; + private static final long LockMask = 1 << 1; + private static final int XLookupChars = 2; + private static final int XLookupBoth = 4; + + + private static final int EVENT_SIZE = 3; + private static final int KEYBOARD_BUFFER_SIZE = 50; + + private final long xim; + private final long xic; + + private final int numlock_mask; + private final int modeswitch_mask; + private final int caps_lock_mask; + private final int shift_lock_mask; + + private final ByteBuffer compose_status; + + private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; + private final EventQueue event_queue = new EventQueue(EVENT_SIZE); + + private final int[] tmp_event = new int[3]; + private final int[] temp_translation_buffer = new int[KEYBOARD_BUFFER_SIZE]; + private final ByteBuffer native_translation_buffer = BufferUtils.createByteBuffer(KEYBOARD_BUFFER_SIZE); + private final CharsetDecoder utf8_decoder = Charset.forName("UTF-8").newDecoder(); + private final CharBuffer char_buffer = CharBuffer.allocate(KEYBOARD_BUFFER_SIZE); + + public LinuxKeyboard(long display, long window) { + long modifier_map = getModifierMapping(display); + int tmp_numlock_mask = 0; + int tmp_modeswitch_mask = 0; + int tmp_caps_lock_mask = 0; + int tmp_shift_lock_mask = 0; + if (modifier_map != 0) { + int max_keypermod = getMaxKeyPerMod(modifier_map); + // Find modifier masks + int i, j; + for (i = 0; i < 8; i++) { + for (j = 0; j < max_keypermod; j++) { + int key_code = lookupModifierMap(modifier_map, i*max_keypermod + j); + int key_sym = (int)keycodeToKeySym(display, key_code); + int mask = 1 << i; + switch (key_sym) { + case LinuxKeycodes.XK_Num_Lock: + tmp_numlock_mask |= mask; + break; + case LinuxKeycodes.XK_Mode_switch: + tmp_modeswitch_mask |= mask; + break; + case LinuxKeycodes.XK_Caps_Lock: + if (i == LockMapIndex) { + tmp_caps_lock_mask = mask; + tmp_shift_lock_mask = 0; + } + break; + case LinuxKeycodes.XK_Shift_Lock: + if (i == LockMapIndex && tmp_caps_lock_mask == 0) + tmp_shift_lock_mask = mask; + break; + default: + break; + } + } + } + freeModifierMapping(modifier_map); + } + numlock_mask = tmp_numlock_mask; + modeswitch_mask = tmp_modeswitch_mask; + caps_lock_mask = tmp_caps_lock_mask; + shift_lock_mask = tmp_shift_lock_mask; + xim = openIM(display); + if (xim != 0) { + xic = createIC(xim, window); + if (xic != 0) { + setupIMEventMask(display, window, xic); + } else { + destroy(); + } + } else { + xic = 0; + } + compose_status = allocateComposeStatus(); + } + private static native long getModifierMapping(long display); + private static native void freeModifierMapping(long modifier_map); + private static native int getMaxKeyPerMod(long modifier_map); + private static native int lookupModifierMap(long modifier_map, int index); + private static native long keycodeToKeySym(long display, int key_code); + + private static native long openIM(long display); + private static native long createIC(long xim, long window); + private static native void setupIMEventMask(long display, long window, long xic); + private static native ByteBuffer allocateComposeStatus(); + + public void destroy() { + destroyIC(xic); + closeIM(xim); + } + private static native void destroyIC(long xic); + private static native void closeIM(long xim); + + public int read(IntBuffer buffer) { + return event_queue.copyEvents(buffer); + } + + public void poll(ByteBuffer keyDownBuffer) { + int old_position = keyDownBuffer.position(); + keyDownBuffer.put(key_down_buffer); + keyDownBuffer.position(old_position); + } + + private void putKeyboardEvent(int keycode, int state, int ch) { + tmp_event[0] = keycode; + tmp_event[1] = state; + tmp_event[2] = ch; + event_queue.putEvent(tmp_event); + } + + private int lookupStringISO88591(long event_ptr, int[] translation_buffer) { + int i; + + int num_chars = lookupString(event_ptr, native_translation_buffer, compose_status); + for (i = 0; i < num_chars; i++) { + translation_buffer[i] = ((int)native_translation_buffer.get(i)) & 0xff; + } + return num_chars; + } + private static native int lookupString(long event_ptr, ByteBuffer buffer, ByteBuffer compose_status); + + private int lookupStringUnicode(long event_ptr, int[] translation_buffer) { + int status = utf8LookupString(xic, event_ptr, native_translation_buffer, native_translation_buffer.position(), native_translation_buffer.remaining()); + if (status != XLookupChars && status != XLookupBoth) + return 0; + native_translation_buffer.flip(); + utf8_decoder.decode(native_translation_buffer, char_buffer, true); + native_translation_buffer.compact(); + char_buffer.flip(); + int i = 0; + while (char_buffer.hasRemaining() && i < translation_buffer.length) { + translation_buffer[i++] = char_buffer.get(); + } + char_buffer.compact(); + return i; + } + private static native int utf8LookupString(long xic, long event_ptr, ByteBuffer buffer, int pos, int size); + + private int lookupString(long event_ptr, int[] translation_buffer) { + if (xic != 0) { + return lookupStringUnicode(event_ptr, translation_buffer); + } else + return lookupStringISO88591(event_ptr, translation_buffer); + } + + private void translateEvent(long event_ptr, int event_type, int keycode, int key_state) { + int num_chars, i; + int ch; + + if (event_type == KeyRelease) { + putKeyboardEvent(keycode, key_state, 0); + return; + } + num_chars = lookupString(event_ptr, temp_translation_buffer); + if (num_chars > 0) { + ch = temp_translation_buffer[0]; + putKeyboardEvent(keycode, key_state, ch); + for (i = 1; i < num_chars; i++) { + ch = temp_translation_buffer[i]; + putKeyboardEvent(0, 0, ch); + } + } else { + putKeyboardEvent(keycode, key_state, 0); + } + } + + private static boolean isKeypadKeysym(long keysym) { + return (0xFF80 <= keysym && keysym <= 0xFFBD) || + (0x11000000 <= keysym && keysym <= 0x1100FFFF); + } + + private static boolean isNoSymbolOrVendorSpecific(long keysym) { + return keysym == NoSymbol || (keysym & (1 << 28)) != 0; + } + + private static long getKeySym(long event_ptr, int group, int index) { + long keysym = lookupKeysym(event_ptr, group*2 + index); + if (isNoSymbolOrVendorSpecific(keysym) && index == 1) { + keysym = lookupKeysym(event_ptr, group*2 + 0); + } + if (isNoSymbolOrVendorSpecific(keysym) && group == 1) + keysym = getKeySym(event_ptr, 0, index); + return keysym; + } + private static native long lookupKeysym(long event_ptr, int index); + private static native long toUpper(long keysym); + + private long mapEventToKeySym(long event_ptr, int event_state) { + int group; + long keysym; + if ((event_state & modeswitch_mask) != 0) + group = 1; + else + group = 0; + if ((event_state & numlock_mask) != 0 && isKeypadKeysym(keysym = getKeySym(event_ptr, group, 1))) { + if ((event_state & (ShiftMask | shift_lock_mask)) != 0) { + return getKeySym(event_ptr, group, 0); + } else { + return keysym; + } + } else if ((event_state & (ShiftMask | LockMask)) == 0) { + return getKeySym(event_ptr, group, 0); + } else if ((event_state & ShiftMask) == 0) { + keysym = getKeySym(event_ptr, group, 0); + if ((event_state & caps_lock_mask) != 0) + keysym = toUpper(keysym); + return keysym; + } else { + keysym = getKeySym(event_ptr, group, 1); + if ((event_state & caps_lock_mask) != 0) + keysym = toUpper(keysym); + return keysym; + } + } + + private int getKeycode(long event_ptr, int event_state) { + long keysym = mapEventToKeySym(event_ptr, event_state); + int keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym); + if (keycode == Keyboard.KEY_NONE) { + // Try unshifted keysym mapping + keysym = lookupKeysym(event_ptr, 0); + keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym); + } + return keycode; + } + + private byte getKeyState(int event_type) { + switch (event_type) { + case KeyPress: + return 1; + case KeyRelease: + return 0; + default: + throw new IllegalArgumentException("Unknown event_type: " + event_type); + } + } + + public void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) { + int keycode = getKeycode(event_ptr, event_state); + byte key_state = getKeyState(event_type); + key_down_buffer[keycode] = key_state; + translateEvent(event_ptr, event_type, keycode, key_state); + } +} Added: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeycodes.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeycodes.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeycodes.java 2006-07-03 18:07:44 UTC (rev 2425) @@ -0,0 +1,760 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * @author elias_naur + */ + +import org.lwjgl.input.Keyboard; + +final class LinuxKeycodes { + public final static int XK_Kanji = 0xff21; + + public final static int XK_ISO_Left_Tab = 0xfe20; + + public final static int XK_dead_grave = 0xfe50; + public final static int XK_dead_acute = 0xfe51; + public final static int XK_dead_circumflex = 0xfe52; + public final static int XK_dead_tilde = 0xfe53; + public final static int XK_dead_macron = 0xfe54; + public final static int XK_dead_breve = 0xfe55; + public final static int XK_dead_abovedot = 0xfe56; + public final static int XK_dead_diaeresis = 0xfe57; + public final static int XK_dead_abovering = 0xfe58; + public final static int XK_dead_doubleacute = 0xfe59; + public final static int XK_dead_caron = 0xfe5a; + public final static int XK_dead_cedilla = 0xfe5b; + public final static int XK_dead_ogonek = 0xfe5c; + public final static int XK_dead_iota = 0xfe5d; + public final static int XK_dead_voiced_sound = 0xfe5e; + public final static int XK_dead_semivoiced_sound = 0xfe5f; + public final static int XK_dead_belowdot = 0xfe60; + public final static int XK_dead_hook = 0xfe61; + public final static int XK_dead_horn = 0xfe62; + + public final static int XK_BackSpace = 0xff08; + public final static int XK_Tab = 0xff09; + public final static int XK_Linefeed = 0xff0a; + public final static int XK_Clear = 0xff0b; + public final static int XK_Return = 0xff0d; + public final static int XK_Pause = 0xff13; + public final static int XK_Scroll_Lock = 0xff14; + public final static int XK_Sys_Req = 0xff15; + public final static int XK_Escape = 0xff1b; + public final static int XK_Delete = 0xffff; + + public final static int XK_Home = 0xff50; + public final static int XK_Left = 0xff51; + public final static int XK_Up = 0xff52; + public final static int XK_Right = 0xff53; + public final static int XK_Down = 0xff54; + public final static int XK_Prior = 0xff55; + public final static int XK_Page_Up = 0xff55; + public final static int XK_Next = 0xff56; + public final static int XK_Page_Down = 0xff56; + public final static int XK_End = 0xff57; + public final static int XK_Begin = 0xff58; + + +/* Misc functions */ + + public final static int XK_Select = 0xff60; + public final static int XK_Print = 0xff61; + public final static int XK_Execute = 0xff62; + public final static int XK_Insert = 0xff63; + public final static int XK_Undo = 0xff65; + public final static int XK_Redo = 0xff66; + public final static int XK_Menu = 0xff67; + public final static int XK_Find = 0xff68; + public final static int XK_Cancel = 0xff69; + public final static int XK_Help = 0xff6a; + public final static int XK_Break = 0xff6b; + public final static int XK_Mode_switch = 0xff7e; + public final static int XK_script_switch = 0xff7e; + public final static int XK_Num_Lock = 0xff7f; + +/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */ + + public final static int XK_KP_Space = 0xff80; + public final static int XK_KP_Tab = 0xff89; + public final static int XK_KP_Enter = 0xff8d; + public final static int XK_KP_F1 = 0xff91; + public final static int XK_KP_F2 = 0xff92; + public final static int XK_KP_F3 = 0xff93; + public final static int XK_KP_F4 = 0xff94; + public final static int XK_KP_Home = 0xff95; + public final static int XK_KP_Left = 0xff96; + public final static int XK_KP_Up = 0xff97; + public final static int XK_KP_Right = 0xff98; + public final static int XK_KP_Down = 0xff99; + public final static int XK_KP_Prior = 0xff9a; + public final static int XK_KP_Page_Up = 0xff9a; + public final static int XK_KP_Next = 0xff9b; + public final static int XK_KP_Page_Down = 0xff9b; + public final static int XK_KP_End = 0xff9c; + public final static int XK_KP_Begin = 0xff9d; + public final static int XK_KP_Insert = 0xff9e; + public final static int XK_KP_Delete = 0xff9f; + public final static int XK_KP_Equal = 0xffbd; + public final static int XK_KP_Multiply = 0xffaa; + public final static int XK_KP_Add = 0xffab; + public final static int XK_KP_Separator = 0xffac; + public final static int XK_KP_Subtract = 0xffad; + public final static int XK_KP_Decimal = 0xffae; + public final static int XK_KP_Divide = 0xffaf; + + public final static int XK_KP_0 = 0xffb0; + public final static int XK_KP_1 = 0xffb1; + public final static int XK_KP_2 = 0xffb2; + public final static int XK_KP_3 = 0xffb3; + public final static int XK_KP_4 = 0xffb4; + public final static int XK_KP_5 = 0xffb5; + public final static int XK_KP_6 = 0xffb6; + public final static int XK_KP_7 = 0xffb7; + public final static int XK_KP_8 = 0xffb8; + public final static int XK_KP_9 = 0xffb9; + + + +/* + * Auxilliary functions; note the duplicate definitions for left and right + * function keys; Sun keyboards and a few other manufactures have such + * function key groups on the left and/or right sides of the keyboard. + * We've not found a keyboard with more than 35 function keys total. + */ + + public final static int XK_F1 = 0xffbe; + public final static int XK_F2 = 0xffbf; + public final static int XK_F3 = 0xffc0; + public final static int XK_F4 = 0xffc1; + public final static int XK_F5 = 0xffc2; + public final static int XK_F6 = 0xffc3; + public final static int XK_F7 = 0xffc4; + public final static int XK_F8 = 0xffc5; + public final static int XK_F9 = 0xffc6; + public final static int XK_F10 = 0xffc7; + public final static int XK_F11 = 0xffc8; + public final static int XK_L1 = 0xffc8; + public final static int XK_F12 = 0xffc9; + public final static int XK_L2 = 0xffc9; + public final static int XK_F13 = 0xffca; + public final static int XK_L3 = 0xffca; + public final static int XK_F14 = 0xffcb; + public final static int XK_L4 = 0xffcb; + public final static int XK_F15 = 0xffcc; + public final static int XK_L5 = 0xffcc; + public final static int XK_F16 = 0xffcd; + public final static int XK_L6 = 0xffcd; + public final static int XK_F17 = 0xffce; + public final static int XK_L7 = 0xffce; + public final static int XK_F18 = 0xffcf; + public final static int XK_L8 = 0xffcf; + public final static int XK_F19 = 0xffd0; + public final static int XK_L9 = 0xffd0; + public final static int XK_F20 = 0xffd1; + public final static int XK_L10 = 0xffd1; + public final static int XK_F21 = 0xffd2; + public final static int XK_R1 = 0xffd2; + public final static int XK_F22 = 0xffd3; + public final static int XK_R2 = 0xffd3; + public final static int XK_F23 = 0xffd4; + public final static int XK_R3 = 0xffd4; + public final static int XK_F24 = 0xffd5; + public final static int XK_R4 = 0xffd5; + public final static int XK_F25 = 0xffd6; + public final static int XK_R5 = 0xffd6; + public final static int XK_F26 = 0xffd7; + public final static int XK_R6 = 0xffd7; + public final static int XK_F27 = 0xffd8; + public final static int XK_R7 = 0xffd8; + public final static int XK_F28 = 0xffd9; + public final static int XK_R8 = 0xffd9; + public final static int XK_F29 = 0xffda; + public final static int XK_R9 = 0xffda; + public final static int XK_F30 = 0xffdb; + public final static int XK_R10 = 0xffdb; + public final static int XK_F31 = 0xffdc; + public final static int XK_R11 = 0xffdc; + public final static int XK_F32 = 0xffdd; + public final static int XK_R12 = 0xffdd; + public final static int XK_F33 = 0xffde; + public final static int XK_R13 = 0xffde; + public final static int XK_F34 = 0xffdf; + public final static int XK_R14 = 0xffdf; + public final static int XK_F35 = 0xffe0; + public final static int XK_R15 = 0xffe0; + +/* Modifiers */ + + public final static int XK_Shift_L = 0xffe1; + public final static int XK_Shift_R = 0xffe2; + public final static int XK_Control_L = 0xffe3; + public final static int XK_Control_R = 0xffe4; + public final static int XK_Caps_Lock = 0xffe5; + public final static int XK_Shift_Lock = 0xffe6; + + public final static int XK_Meta_L = 0xffe7; + public final static int XK_Meta_R = 0xffe8; + public final static int XK_Alt_L = 0xffe9; + public final static int XK_Alt_R = 0xffea; + public final static int XK_Super_L = 0xffeb; + public final static int XK_Super_R = 0xffec; + public final static int XK_Hyper_L = 0xffed; + public final static int XK_Hyper_R = 0xffee; + public final static int XK_space = 0x0020; + public final static int XK_exclam = 0x0021; + public final static int XK_quotedbl = 0x0022; + public final static int XK_numbersign = 0x0023; + public final static int XK_dollar = 0x0024; + public final static int XK_percent = 0x0025; + public final static int XK_ampersand = 0x0026; + public final static int XK_apostrophe = 0x0027; + public final static int XK_quoteright = 0x0027; + public final static int XK_parenleft = 0x0028; + public final static int XK_parenright = 0x0029; + public final static int XK_asterisk = 0x002a; + public final static int XK_plus = 0x002b; + public final static int XK_comma = 0x002c; + public final static int XK_minus = 0x002d; + public final static int XK_period = 0x002e; + public final static int XK_slash = 0x002f; + + public final static int XK_0 = 0x0030; + public final static int XK_1 = 0x0031; + public final static int XK_2 = 0x0032; + public final static int XK_3 = 0x0033; + public final static int XK_4 = 0x0034; + public final static int XK_5 = 0x0035; + public final static int XK_6 = 0x0036; + public final static int XK_7 = 0x0037; + public final static int XK_8 = 0x0038; + public final static int XK_9 = 0x0039; + public final static int XK_colon = 0x003a; + public final static int XK_semicolon = 0x003b; + public final static int XK_less = 0x003c; + public final static int XK_equal = 0x003d; + public final static int XK_greater = 0x003e; + public final static int XK_question = 0x003f; + public final static int XK_at = 0x0040; + public final static int XK_A = 0x0041; + public final static int XK_B = 0x0042; + public final static int XK_C = 0x0043; + public final static int XK_D = 0x0044; + public final static int XK_E = 0x0045; + public final static int XK_F = 0x0046; + public final static int XK_G = 0x0047; + public final static int XK_H = 0x0048; + public final static int XK_I = 0x0049; + public final static int XK_J = 0x004a; + public final static int XK_K = 0x004b; + public final static int XK_L = 0x004c; + public final static int XK_M = 0x004d; + public final static int XK_N = 0x004e; + public final static int XK_O = 0x004f; + public final static int XK_P = 0x0050; + public final static int XK_Q = 0x0051; + public final static int XK_R = 0x0052; + public final static int XK_S = 0x0053; + public final static int XK_T = 0x0054; + public final static int XK_U = 0x0055; + public final static int XK_V = 0x0056; + public final static int XK_W = 0x0057; + public final static int XK_X = 0x0058; + public final static int XK_Y = 0x0059; + public final static int XK_Z = 0x005a; + public final static int XK_bracketleft = 0x005b; + public final static int XK_backslash = 0x005c; + public final static int XK_bracketright = 0x005d; + public final static int XK_asciicircum = 0x005e; + public final static int XK_underscore = 0x005f; + public final static int XK_grave = 0x0060; + public final static int XK_quoteleft = 0x0060; + public final static int XK_a = 0x0061; + public final static int XK_b = 0x0062; + public final static int XK_c = 0x0063; + public final static int XK_d = 0x0064; + public final static int XK_e = 0x0065; + public final static int XK_f = 0x0066; + public final static int XK_g = 0x0067; + public final static int XK_h = 0x0068; + public final static int XK_i = 0x0069; + public final static int XK_j = 0x006a; + public final static int XK_k = 0x006b; + public final static int XK_l = 0x006c; + public final static int XK_m = 0x006d; + public final static int XK_n = 0x006e; + public final static int XK_o = 0x006f; + public final static int XK_p = 0x0070; + public final static int XK_q = 0x0071; + public final static int XK_r = 0x0072; + public final static int XK_s = 0x0073; + public final static int XK_t = 0x0074; + public final static int XK_u = 0x0075; + public final static int XK_v = 0x0076; + public final static int XK_w = 0x0077; + public final static int XK_x = 0x0078; + public final static int XK_y = 0x0079; + public final static int XK_z = 0x007a; + public final static int XK_braceleft = 0x007b; + public final static int XK_bar = 0x007c; + public final static int XK_braceright = 0x007d; + public final static int XK_asciitilde = 0x007e; + + public final static int XK_nobreakspace = 0x00a0; + public final static int XK_exclamdown = 0x00a1; + public final static int XK_cent = 0x00a2; + public final static int XK_sterling = 0x00a3; + public final static int XK_currency = 0x00a4; + public final static int XK_yen = 0x00a5; + public final static int XK_brokenbar = 0x00a6; + public final static int XK_section = 0x00a7; + public final static int XK_diaeresis = 0x00a8; + public final static int XK_copyright = 0x00a9; + public final static int XK_ordfeminine = 0x00aa; + public final static int XK_guillemotleft = 0x00ab; + public final static int XK_notsign = 0x00ac; + public final static int XK_hyphen = 0x00ad; + public final static int XK_registered = 0x00ae; + public final static int XK_macron = 0x00af; + public final static int XK_degree = 0x00b0; + public final static int XK_plusminus = 0x00b1; + public final static int XK_twosuperior = 0x00b2; + public final static int XK_threesuperior = 0x00b3; + public final static int XK_acute = 0x00b4; + public final static int XK_mu = 0x00b5; + public final static int XK_paragraph = 0x00b6; + public final static int XK_periodcentered = 0x00b7; + public final static int XK_cedilla = 0x00b8; + public final static int XK_onesuperior = 0x00b9; + public final static int XK_masculine = 0x00ba; + public final static int XK_guillemotright = 0x00bb; + public final static int XK_onequarter = 0x00bc; + public final static int XK_onehalf = 0x00bd; + public final static int XK_threequarters = 0x00be; + public final static int XK_questiondown = 0x00bf; + public final static int XK_Agrave = 0x00c0; + public final static int XK_Aacute = 0x00c1; + public final static int XK_Acircumflex = 0x00c2; + public final static int XK_Atilde = 0x00c3; + public final static int XK_Adiaeresis = 0x00c4; + public final static int XK_Aring = 0x00c5; + public final static int XK_AE = 0x00c6; + public final static int XK_Ccedilla = 0x00c7; + public final static int XK_Egrave = 0x00c8; + public final static int XK_Eacute = 0x00c9; + public final static int XK_Ecircumflex = 0x00ca; + public final static int XK_Ediaeresis = 0x00cb; + public final static int XK_Igrave = 0x00cc; + public final static int XK_Iacute = 0x00cd; + public final static int XK_Icircumflex = 0x00ce; + public final static int XK_Idiaeresis = 0x00cf; + public final static int XK_ETH = 0x00d0; + public final static int XK_Eth = 0x00d0; + public final static int XK_Ntilde = 0x00d1; + public final static int XK_Ograve = 0x00d2; + public final static int XK_Oacute = 0x00d3; + public final static int XK_Ocircumflex = 0x00d4; + public final static int XK_Otilde = 0x00d5; + public final static int XK_Odiaeresis = 0x00d6; + public final static int XK_multiply = 0x00d7; + public final static int XK_Oslash = 0x00d8; + public final static int XK_Ooblique = 0x00d8; + public final static int XK_Ugrave = 0x00d9; + public final static int XK_Uacute = 0x00da; + public final static int XK_Ucircumflex = 0x00db; + public final static int XK_Udiaeresis = 0x00dc; + public final static int XK_Yacute = 0x00dd; + public final static int XK_THORN = 0x00de; + public final static int XK_Thorn = 0x00de; + public final static int XK_ssharp = 0x00df; + public final static int XK_agrave = 0x00e0; + public final static int XK_aacute = 0x00e1; + public final static int XK_acircumflex = 0x00e2; + public final static int XK_atilde = 0x00e3; + public final static int XK_adiaeresis = 0x00e4; + public final static int XK_aring = 0x00e5; + public final static int XK_ae = 0x00e6; + public final static int XK_ccedilla = 0x00e7; + public final static int XK_egrave = 0x00e8; + public final static int XK_eacute = 0x00e9; + public final static int XK_ecircumflex = 0x00ea; + public final static int XK_ediaeresis = 0x00eb; + public final static int XK_igrave = 0x00ec; + public final static int XK_iacute = 0x00ed; + public final static int XK_icircumflex = 0x00ee; + public final static int XK_idiaeresis = 0x00ef; + public final static int XK_eth = 0x00f0; + public final static int XK_ntilde = 0x00f1; + public final static int XK_ograve = 0x00f2; + public final static int XK_oacute = 0x00f3; + public final static int XK_ocircumflex = 0x00f4; + public final static int XK_otilde = 0x00f5; + public final static int XK_odiaeresis = 0x00f6; + public final static int XK_division = 0x00f7; + public final static int XK_oslash = 0x00f8; + public final static int XK_ooblique = 0x00f8; + public final static int XK_ugrave = 0x00f9; + public final static int XK_uacute = 0x00fa; + public final static int XK_ucircumflex = 0x00fb; + public final static int XK_udiaeresis = 0x00fc; + public final static int XK_yacute = 0x00fd; + public final static int XK_thorn = 0x00fe; + public final static int XK_ydiaeresis = 0x00ff; + + public static int mapKeySymToLWJGLKeyCode(long keysym) { + switch ((int)keysym) { + case XK_BackSpace: + return Keyboard.KEY_BACK; + case XK_ISO_Left_Tab: + case XK_Tab: + return Keyboard.KEY_TAB; + case XK_Return: + return Keyboard.KEY_RETURN; + case XK_Pause: + return Keyboard.KEY_PAUSE; + case XK_Scroll_Lock: + return Keyboard.KEY_SCROLL; + case XK_Sys_Req: + return Keyboard.KEY_SYSRQ; + case XK_Escape: + return Keyboard.KEY_ESCAPE; + case XK_Delete: + return Keyboard.KEY_DELETE; + + /* Japanese keyboard support */ + + case XK_Kanji: + return Keyboard.KEY_KANJI; + + /* Cursor control & motion */ + + case XK_Home: + return Keyboard.KEY_HOME; + case XK_Left: + return Keyboard.KEY_LEFT; + case XK_Up: + return Keyboard.KEY_UP; + case XK_Right: + return Keyboard.KEY_RIGHT; + case XK_Down: + return Keyboard.KEY_DOWN; + case XK_Page_Up: + return Keyboard.KEY_PRIOR; + case XK_Page_Down: + return Keyboard.KEY_NEXT; + case XK_End: + return Keyboard.KEY_END; + + + /* Misc Functions */ + + case XK_Break: + return Keyboard.KEY_PAUSE; + case XK_Insert: + return Keyboard.KEY_INSERT; + case XK_Num_Lock: + return Keyboard.KEY_NUMLOCK; + + /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */ + + case XK_KP_Space: + return Keyboard.KEY_SPACE; + case XK_KP_Tab: + return Keyboard.KEY_TAB; + case XK_KP_Enter: + return Keyboard.KEY_NUMPADENTER; + case XK_KP_F1: + return Keyboard.KEY_F1; + case XK_KP_F2: + return Keyboard.KEY_F2; + case XK_KP_F3: + return Keyboard.KEY_F3; + case XK_KP_F4: + return Keyboard.KEY_F4; + case XK_KP_Home: + return Keyboard.KEY_HOME; + case XK_KP_Left: + return Keyboard.KEY_LEFT; + case XK_KP_Up: + return Keyboard.KEY_UP; + case XK_KP_Right: + return Keyboard.KEY_RIGHT; + case XK_KP_Down: + return Keyboard.KEY_DOWN; + case XK_KP_Page_Up: + return Keyboard.KEY_PRIOR; + case XK_KP_Page_Down: + return Keyboard.KEY_NEXT; + case XK_KP_End: + return Keyboard.KEY_END; + case XK_KP_Insert: + return Keyboard.KEY_INSERT; + case XK_KP_Delete: + return Keyboard.KEY_DELETE; + case XK_KP_Equal: + return Keyboard.KEY_NUMPADEQUALS; + case XK_KP_Multiply: + return Keyboard.KEY_MULTIPLY; + case XK_KP_Add: + return Keyboard.KEY_ADD; + case XK_KP_Subtract: + return Keyboard.KEY_SUBT... [truncated message content] |
From: <eli...@us...> - 2006-07-07 11:00:43
|
Revision: 2451 Author: elias_naur Date: 2006-07-07 04:00:32 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2451&view=rev Log Message: ----------- Added linux specific build.xml for building liblwjgl.so. Moved FMOD and Devil native builds to compile_native_optional ant target Modified Paths: -------------- trunk/LWJGL/build.xml Added Paths: ----------- trunk/LWJGL/platform_build/linux_ant/ trunk/LWJGL/platform_build/linux_ant/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-07 10:38:54 UTC (rev 2450) +++ trunk/LWJGL/build.xml 2006-07-07 11:00:32 UTC (rev 2451) @@ -1,4 +1,4 @@ -<project name="LWJGL" default="compile" basedir="."> +<project name="LWJGL" default="all" basedir="."> <!-- ================================================================== --> <!-- Global properties for build --> @@ -249,10 +249,7 @@ <target name="clean" description="Cleans the diectories controlled by this ant script"> <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" /> <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" /> - <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" /> - <delete taskname="cleaning bin folder" failonerror="false"> - <fileset dir="${lwjgl.bin}" includes="*.class" /> - </delete> + <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" /> </target> <!-- Creates a distribution of LWJGL --> @@ -297,6 +294,8 @@ <antcall target="-distribute" /> </target> + <target name="all" description="Creates the Java archives and the natives for the current platform" depends="jars, compile_native"/> + <!-- Create ONLY the jar archives --> <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, compile, -createjars"> <move todir="libs/"> @@ -465,7 +464,7 @@ </target> <!-- Compiles the Java source code --> - <target name="compile" description="Compiles the java source code"> + <target name="compile" description="Compiles the java source code" depends="-initialize"> <javac debug="yes" destdir="${lwjgl.bin}" includes="org/lwjgl/opengl/**" source="1.4" target="1.4" classpath="${lwjgl.lib}/jinput.jar" taskname="core"> <src path="${lwjgl.src}/java/"/> <src path="${lwjgl.src}/generated/"/> @@ -632,6 +631,8 @@ </apply> </target> + <target name="compile_native_all" depends="compile_native, compile_native_optional" description="Compiles the native files"/> + <!-- Compiles the native files --> <target name="compile_native" depends="headers" description="Compiles the native files"> <!-- check each platform, and run their build target --> @@ -650,7 +651,16 @@ </condition> <antcall target="-compile_native_mac" /> </target> + + <target name="compile_native_optional" depends="headers" description="Compiles the native files"> + <!-- check each platform, and run their build target --> + <condition property="lwjgl.platform.linux"> + <os name="Linux" /> + </condition> + <antcall target="-compile_native_linux_optional" /> + </target> + <!-- Compiles LWJGL on Win32 platforms --> <target name="-compile_native_win32" if="lwjgl.platform.windows"> <echo>Compiling Win32 LWJGL version</echo> @@ -695,9 +705,12 @@ <!-- Compiles LWJGL on Linux platforms --> <target name="-compile_native_linux" if="lwjgl.platform.linux"> - <echo>Compiling Linux LWJGL version</echo> + <ant antfile="platform_build/linux_ant/build.xml" inheritAll="false"/> + <copy file="${lwjgl.bin}/liblwjgl.so" tofile="${lwjgl.lib}/linux/liblwjgl.so" /> + </target> - <!-- check for required properties --> + <target name="-compile_native_linux_optional" if="lwjgl.platform.linux"> + <!-- check for required properties --> <property environment="env"/> <fail message="Missing JAVA_HOME path environment property" unless="env.JAVA_HOME"/> <fail message="Missing FMOD path environment property" unless="env.FMOD"/> @@ -709,7 +722,6 @@ <exec executable="make" dir="${lwjgl.src.native}/common/fmod3"> <arg line="-f Makefile.linux"/> </exec> - <move file="${lwjgl.src.native}/linux/liblwjgl.so" tofile="${lwjgl.lib}/linux/liblwjgl.so" /> <move file="${lwjgl.src.native}/common/devil/liblwjgl-devil.so" tofile="${lwjgl.lib}/linux/liblwjgl-devil.so" /> <move file="${lwjgl.src.native}/common/fmod3/liblwjgl-fmod3.so" tofile="${lwjgl.lib}/linux/liblwjgl-fmod3.so" /> </target> @@ -745,12 +757,12 @@ <cvs command="export -D 'now'" compressionlevel="3" cvsRoot=":pserver:ano...@cv...:/cvsroot/java-game-lib" package="LWJGL/build.xml" dest="." /> <cvs command="export -D 'now'" compressionlevel="3" cvsRoot=":pserver:ano...@cv...:/cvsroot/java-game-lib" package="LWJGL/src" dest="." /> <cvs command="export -D 'now'" compressionlevel="3" cvsRoot=":pserver:ano...@cv...:/cvsroot/java-game-lib" package="LWJGL/doc" dest="." /> - <ant dir="LWJGL" target="compile_native" /> + <ant dir="LWJGL" target="compile_native_all" /> <ant dir="LWJGL" target="release" /> </target> <!-- --> - <target name="sign" description="Using relased files, creates the nescesarry files used for jnlp demos"> + <target name="sign" description="Using released files, creates the necessary files used for jnlp demos"> <!-- delete existing temp --> <delete dir="${lwjgl.temp}"/> Added: trunk/LWJGL/platform_build/linux_ant/build.xml =================================================================== --- trunk/LWJGL/platform_build/linux_ant/build.xml (rev 0) +++ trunk/LWJGL/platform_build/linux_ant/build.xml 2006-07-07 11:00:32 UTC (rev 2451) @@ -0,0 +1,39 @@ +<?xml version="1.0"?> + +<project name="lwjgl native code, linux" basedir="../../bin" default="compile"> + <property name="native" location="../src/native"/> + <property name="libname" value="liblwjgl.so"/> + <property name="libs" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lpthread -L${java.home}/lib/i386 -ljawt -Wl,-static,-lXxf86vm,-lXcursor,-lXrender,-lXrandr,-lXfixes,-call_shared"/> + <property name="cflags" value="-O2 -Wall -c -fPIC -std=c99 -pthread"/> + <property name="linker_flags" value="-Wl,--version-script=${native}/linux/lwjgl.map -shared -O2 -Wall -o ${libname} ${libs}"/> + + <target name="clean"> + <delete> + <fileset dir="." includes="*.o"/> + <fileset file="${libname}"/> + </delete> + </target> + + <target name="compile"> + <apply dir="." executable="cc" dest="." skipemptyfilesets="true" failonerror="true"> + <arg line="${cflags}"/> + <arg value="-I${java.home}/include"/> + <arg value="-I${java.home}/include/linux"/> + <arg value="-I${native}/common"/> + <arg value="-I${native}/linux"/> + <mapper type="glob" from="*.c" to="*.o"/> + <fileset dir="${native}/linux" includes="*.c"/> + <fileset dir="${native}/generated" includes="*.c"/> + <fileset dir="${native}/common" includes="*.c"/> + </apply> + <apply dir="." parallel="true" executable="cc" failonerror="true"> + <srcfile/> + <arg line="${linker_flags}"/> + <fileset dir="." includes="*.o"/> + </apply> + <apply dir="." parallel="true" executable="strip" failonerror="true"> + <fileset file="${libname}"/> + </apply> + </target> +</project> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-07 12:41:54
|
Revision: 2453 Author: elias_naur Date: 2006-07-07 05:41:36 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2453&view=rev Log Message: ----------- Mac OS X: Added support for compile_native target. Moved optional libraries to compile_native_optional target Modified Paths: -------------- trunk/LWJGL/build.xml Added Paths: ----------- trunk/LWJGL/platform_build/macosx_ant/ trunk/LWJGL/platform_build/macosx_ant/build-symbol-list trunk/LWJGL/platform_build/macosx_ant/build.xml Removed Paths: ------------- trunk/LWJGL/src/native/macosx/build-symbol-list trunk/LWJGL/src/native/macosx/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-07 11:47:56 UTC (rev 2452) +++ trunk/LWJGL/build.xml 2006-07-07 12:41:36 UTC (rev 2453) @@ -646,10 +646,10 @@ </condition> <antcall target="-compile_native_linux" /> - <condition property="lwjgl.platform.mac"> + <condition property="lwjgl.platform.macosx"> <os name="Mac OS X" /> </condition> - <antcall target="-compile_native_mac" /> + <antcall target="-compile_native_macosx" /> </target> <target name="compile_native_optional" depends="headers" description="Compiles the native files"> @@ -658,6 +658,10 @@ <os name="Linux" /> </condition> <antcall target="-compile_native_linux_optional" /> + <condition property="lwjgl.platform.macosx"> + <os name="Mac OS X" /> + </condition> + <antcall target="-compile_native_macosx_optional" /> </target> @@ -706,7 +710,7 @@ <!-- Compiles LWJGL on Linux platforms --> <target name="-compile_native_linux" if="lwjgl.platform.linux"> <ant antfile="platform_build/linux_ant/build.xml" inheritAll="false"/> - <copy file="${lwjgl.bin}/liblwjgl.so" tofile="${lwjgl.lib}/linux/liblwjgl.so" /> + <copy file="${lwjgl.bin}/liblwjgl.so" todir="${lwjgl.lib}/linux"/> </target> <target name="-compile_native_linux_optional" if="lwjgl.platform.linux"> @@ -715,7 +719,6 @@ <fail message="Missing JAVA_HOME path environment property" unless="env.JAVA_HOME"/> <fail message="Missing FMOD path environment property" unless="env.FMOD"/> - <exec executable="make" dir="${lwjgl.src.native}/linux"/> <exec executable="make" dir="${lwjgl.src.native}/common/devil"> <arg line="-f Makefile.linux"/> </exec> @@ -726,22 +729,25 @@ <move file="${lwjgl.src.native}/common/fmod3/liblwjgl-fmod3.so" tofile="${lwjgl.lib}/linux/liblwjgl-fmod3.so" /> </target> + <target name="-compile_native_macosx" if="lwjgl.platform.macosx"> + <ant antfile="platform_build/macosx_ant/build.xml" inheritAll="false"/> + <copy file="${lwjgl.bin}/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/> + </target> + <!-- Compiles LWJGL on Mac OS X platforms --> - <target name="-compile_native_mac" if="lwjgl.platform.mac"> + <target name="-compile_native_macosx_optional" if="lwjgl.platform.macosx"> <!-- check for required properties --> <property environment="env"/> <fail message="Missing AL path environment property" unless="env.AL"/> <fail message="Missing FMOD path environment property" unless="env.FMOD"/> - <exec executable="make" dir="${lwjgl.src.native}/macosx" failonerror="true"/> <exec executable="make" dir="${lwjgl.src.native}/common/devil"> <arg line="-f Makefile.macosx"/> </exec> <exec executable="make" dir="${lwjgl.src.native}/common/fmod3"> <arg line="-f Makefile.macosx"/> </exec> - <move file="${lwjgl.src.native}/macosx/liblwjgl.jnilib" tofile="${lwjgl.lib}/macosx/liblwjgl.jnilib" /> <move file="${lwjgl.src.native}/common/devil/liblwjgl-devil.jnilib" tofile="${lwjgl.lib}/macosx/liblwjgl-devil.jnilib" /> <move file="${lwjgl.src.native}/common/fmod3/liblwjgl-fmod3.jnilib" tofile="${lwjgl.lib}/macosx/liblwjgl-fmod3.jnilib" /> </target> Copied: trunk/LWJGL/platform_build/macosx_ant/build-symbol-list (from rev 2451, trunk/LWJGL/src/native/macosx/build-symbol-list) =================================================================== --- trunk/LWJGL/platform_build/macosx_ant/build-symbol-list (rev 0) +++ trunk/LWJGL/platform_build/macosx_ant/build-symbol-list 2006-07-07 12:41:36 UTC (rev 2453) @@ -0,0 +1,3 @@ +#!/bin/sh + +nm -g "$1"/*.o | grep "Java_" | cut -d ' ' -f3 | cut -c 1- Copied: trunk/LWJGL/platform_build/macosx_ant/build.xml (from rev 2451, trunk/LWJGL/src/native/macosx/build.xml) =================================================================== --- trunk/LWJGL/platform_build/macosx_ant/build.xml (rev 0) +++ trunk/LWJGL/platform_build/macosx_ant/build.xml 2006-07-07 12:41:36 UTC (rev 2453) @@ -0,0 +1,82 @@ +<?xml version="1.0" ?> +<project name="OS X Native code" basedir="../../bin" default="nativelibrary"> + <property name="native" location="../src/native"/> + + <target name="init"> + <mkdir dir="ppc"/> + <mkdir dir="intel"/> + </target> + + <target name="clean"> + <delete failonerror="false"> + <fileset dir="intel"/> + <fileset dir="ppc"/> + <fileset dir="." includes="liblwjgl.jnilib"/> + <fileset dir="." includes="lwjgl.symbols"/> + </delete> + </target> + + <target name="compile"> + <apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}"> + <arg line="${cflags} -O2 -Wall -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I${native}/common -I${native}/macosx"/> + <!-- Map from *.m and *.c to .o --> + <mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/> + <fileset dir="${native}/macosx" includes="*.m"/> + <fileset dir="${native}/macosx" includes="*.c"/> + <fileset dir="${native}/common" includes="*.c"/> + <fileset dir="${native}/generated" includes="*.c"/> + </apply> + </target> + + <target name="link"> + <apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true"> + <arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/> + <fileset dir="${objdir}" includes="*.o"/> + </apply> + <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true"> + <arg line="-S -X"/> + <fileset dir="." file="${libname}"/> + </apply> + </target> + + <target name="nativelibrary" depends="init"> + <property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/> + <property name="legacy_sdkroot" location="/Developer/SDKs/MacOSX10.3.9.sdk"/> + <property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386"/> + <antcall target="compile"> + <param name="dstdir" location="intel"/> + <param name="compiler" value="gcc-4.0"/> + <param name="sdkroot" location="${universal_sdkroot}"/> + <param name="cflags" value="${universal_flags}"/> + </antcall> + <antcall target="compile"> + <param name="dstdir" location="ppc"/> + <param name="compiler" value="gcc-3.3"/> + <param name="sdkroot" location="${legacy_sdkroot}"/> + <param name="cflags" value=""/> + </antcall> + <exec vmlauncher="false" executable="../platform_build/macosx_ant/build-symbol-list" output="lwjgl.symbols" failonerror="true"> + <arg path="intel"/> + </exec> + <antcall target="link"> + <param name="objdir" location="intel"/> + <param name="libname" value="liblwjgl-intel.jnilib"/> + <param name="linker" value="gcc-4.0"/> + <param name="linkerflags" value="${universal_flags}"/> + </antcall> + <antcall target="link"> + <param name="objdir" location="ppc"/> + <param name="libname" value="liblwjgl-ppc.jnilib"/> + <param name="linker" value="gcc-3.3"/> + <param name="linkerflags" value=""/> + </antcall> + <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" > + <arg value="-create"/> + <srcfile/> + <arg value="-output"/> + <arg path="liblwjgl.jnilib"/> + <fileset file="ppc/liblwjgl-ppc.jnilib"/> + <fileset file="intel/liblwjgl-intel.jnilib"/> + </apply> + </target> +</project> Deleted: trunk/LWJGL/src/native/macosx/build-symbol-list =================================================================== --- trunk/LWJGL/src/native/macosx/build-symbol-list 2006-07-07 11:47:56 UTC (rev 2452) +++ trunk/LWJGL/src/native/macosx/build-symbol-list 2006-07-07 12:41:36 UTC (rev 2453) @@ -1,3 +0,0 @@ -#!/bin/sh - -nm -g intel/*.o | grep "Java_" | cut -d ' ' -f3 | cut -c 1- Deleted: trunk/LWJGL/src/native/macosx/build.xml =================================================================== --- trunk/LWJGL/src/native/macosx/build.xml 2006-07-07 11:47:56 UTC (rev 2452) +++ trunk/LWJGL/src/native/macosx/build.xml 2006-07-07 12:41:36 UTC (rev 2453) @@ -1,76 +0,0 @@ -<?xml version="1.0" ?> -<project name="OS X Native code" basedir="." default="nativelibrary"> - <target name="init"> - <mkdir dir="ppc"/> - <mkdir dir="intel"/> - </target> - - <target name="clean"> - <delete failonerror="false"> - <fileset dir="intel"/> - <fileset dir="ppc"/> - <fileset dir="." includes="liblwjgl.jnilib"/> - </delete> - </target> - - <target name="compile"> - <apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}"> - <arg line="${cflags} -O2 -Wall -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I../../common -I.."/> - <mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/> - <fileset dir="." includes="*.m"/> - <fileset dir="." includes="*.c"/> - <fileset dir="../common" includes="*.c"/> - <fileset dir="../generated" includes="*.c"/> - </apply> - </target> - - <target name="link"> - <apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true"> - <arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/> - <fileset dir="${objdir}" includes="*.o"/> - </apply> - <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true"> - <arg line="-S -X"/> - <fileset dir="." file="${libname}"/> - </apply> - </target> - - <target name="nativelibrary" depends="init"> - <property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/> - <property name="legacy_sdkroot" location="/Developer/SDKs/MacOSX10.3.9.sdk"/> - <property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386"/> - <antcall target="compile"> - <param name="dstdir" location="intel"/> - <param name="compiler" value="gcc-4.0"/> - <param name="sdkroot" location="${universal_sdkroot}"/> - <param name="cflags" value="${universal_flags}"/> - </antcall> - <antcall target="compile"> - <param name="dstdir" location="ppc"/> - <param name="compiler" value="gcc-3.3"/> - <param name="sdkroot" location="${legacy_sdkroot}"/> - <param name="cflags" value=""/> - </antcall> - <exec executable="./build-symbol-list" output="lwjgl.symbols"/> - <antcall target="link"> - <param name="objdir" location="intel"/> - <param name="libname" value="liblwjgl-intel.jnilib"/> - <param name="linker" value="gcc-4.0"/> - <param name="linkerflags" value="${universal_flags}"/> - </antcall> - <antcall target="link"> - <param name="objdir" location="ppc"/> - <param name="libname" value="liblwjgl-ppc.jnilib"/> - <param name="linker" value="gcc-3.3"/> - <param name="linkerflags" value=""/> - </antcall> - <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" > - <arg value="-create"/> - <srcfile/> - <arg value="-output"/> - <arg path="liblwjgl.jnilib"/> - <fileset file="ppc/liblwjgl-ppc.jnilib"/> - <fileset file="intel/liblwjgl-intel.jnilib"/> - </apply> - </target> -</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-08 17:20:54
|
Revision: 2457 Author: elias_naur Date: 2006-07-08 10:20:18 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2457&view=rev Log Message: ----------- Windows: Added ant build.xml for native core Modified Paths: -------------- trunk/LWJGL/build.xml Added Paths: ----------- trunk/LWJGL/platform_build/windows_ant/ trunk/LWJGL/platform_build/windows_ant/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-07 14:06:46 UTC (rev 2456) +++ trunk/LWJGL/build.xml 2006-07-08 17:20:18 UTC (rev 2457) @@ -654,6 +654,11 @@ <target name="compile_native_optional" depends="headers" description="Compiles the native files"> <!-- check each platform, and run their build target --> + <condition property="lwjgl.platform.windows"> + <os family="windows" /> + </condition> + <antcall target="-compile_native_win32_optional" /> + <condition property="lwjgl.platform.linux"> <os name="Linux" /> </condition> @@ -670,15 +675,20 @@ <echo>Compiling Win32 LWJGL version</echo> <!-- check for required properties --> - <property environment="env"/> + <!-- <property environment="env"/> <fail message="Missing PLTSDKHOME path environment property" unless="env.PLTSDKHOME"/> <fail message="Missing ALHOME path environment property" unless="env.ALHOME"/> <fail message="Missing JAVA_HOME path environment property" unless="env.JAVA_HOME"/> <fail message="Missing CHOME path environment property" unless="env.CHOME"/> <fail message="Missing DXHOME path environment property" unless="env.DXHOME"/> + + <antcall target="-compile_native_win32_main" />--> + <ant antfile="platform_build/windows_ant/build.xml" inheritAll="false"/> + <copy file="${lwjgl.bin}/lwjgl.dll" todir="${lwjgl.lib}/win32"/> + </target> + + <target name="-compile_native_win32_optional" if="lwjgl.platform.windows"> <fail message="Missing FMODHOME path environment property" unless="env.FMODHOME"/> - - <antcall target="-compile_native_win32_main" /> <antcall target="-compile_native_win32_fmod" /> <antcall target="-compile_native_win32_devil" /> </target> Added: trunk/LWJGL/platform_build/windows_ant/build.xml =================================================================== --- trunk/LWJGL/platform_build/windows_ant/build.xml (rev 0) +++ trunk/LWJGL/platform_build/windows_ant/build.xml 2006-07-08 17:20:18 UTC (rev 2457) @@ -0,0 +1,61 @@ +<?xml version="1.0"?> + +<project name="lwjgl native code, native code" basedir="../../bin" default="compile"> + <property name="native" location="../src/native"/> + + <target name="compile_dir"> + <apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true"> + <arg line="/Ox /Wp64 /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c /D WIN32 /c"/> + <arg value="/I${toolkithome}\include"/> + <arg value="/I${sdkhome}\include"/> + <arg value="/I${dxhome}\include"/> + <arg value="/I${alhome}\include"/> + <arg value="/I${java.home}\..\include"/> + <arg value="/I${java.home}\..\include\win32"/> + <arg value="/I${native}/common"/> + <arg value="/I${native}/win32"/> + <srcfile/> + <fileset dir="${native}/win32" includes="*.c"/> + <fileset dir="${native}/common" includes="*.c"/> + <fileset dir="${native}/generated" includes="*.c"/> + <mapper type="glob" from="*.c" to="*.obj"/> + </apply> + </target> + + <target name="link"> + <apply dir="." parallel="true" executable="cl" failonerror="true"> + <arg line="/LD /nologo"/> + <srcfile/> + <arg line="/Fe${dllname} /link"/> + <arg value="/LIBPATH:${java.home}\..\lib"/> + <arg value="/LIBPATH:${dxhome}\lib\x86"/> + <arg value="/LIBPATH:${sdkhome}\lib"/> + <arg value="/LIBPATH:${alhome}\libs"/> + <arg value="/LIBPATH:${toolkithome}\lib"/> + <arg value="/OPT:REF"/> + <arg value="/OPT:ICF"/> + <arg line="/DLL /DELAYLOAD:jawt.dll ${libs}"/> + <fileset dir="." includes="*.obj"/> + </apply> + </target> + + <target name="clean"> + <delete> + <fileset dir="." includes="*.obj"/> + <fileset dir="." includes="*.dll"/> + </delete> + </target> + + <target name="compile"> + <property name="program_files" location="c:\Program Files"/> + <property name="dxhome" location="${program_files}\Microsoft DirectX SDK (February 2006)"/> + <property name="toolkithome" location="${program_files}\Microsoft Visual C++ Toolkit 2003"/> + <property name="sdkhome" location="${program_files}\Microsoft Platform SDK"/> + <property name="alhome" location="${program_files}\OpenAL 1.0 Software Development Kit"/> + <property name="dllname" value="lwjgl.dll"/> + <property name="libs" value="Kernel32.lib ole32.lib dinput.lib dxguid.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib"/> + <antcall target="compile_dir"/> + <antcall target="link"/> + </target> +</project> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-11 20:30:41
|
Revision: 2479 Author: elias_naur Date: 2006-07-11 13:30:19 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2479&view=rev Log Message: ----------- Linux: added support for 64 bit JVMs Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/platform_build/linux_ant/build.xml trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/build.xml 2006-07-11 20:30:19 UTC (rev 2479) @@ -358,14 +358,14 @@ </jar> <!-- create each of the native jars --> - <jar destfile="applet/win32_natives.jar" taskname="win32_natives.jar"> + <jar destfile="applet/windows_natives.jar" taskname="windows_natives.jar"> <fileset dir="${lwjgl.lib}/win32"> <patternset refid="lwjgl-win32.fileset"/> <patternset refid="lwjgl-win32_optional.fileset"/> <include name="fmod.dll"/> </fileset> </jar> - <signjar jar="applet/win32_natives.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> + <signjar jar="applet/windows_natives.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> <jar destfile="applet/linux_natives.jar" taskname="linux_natives.jar"> <fileset dir="${lwjgl.lib}/linux"> @@ -388,12 +388,12 @@ <!-- add it to a natives jar --> <jar destfile="applet/natives.jar" taskname="natives.jar"> <fileset dir="applet"> - <include name="win32_natives.jar"/> + <include name="windows_natives.jar"/> <include name="linux_natives.jar"/> <include name="macosx_natives.jar"/> </fileset> </jar> - <delete file="applet/win32_natives.jar"/> + <delete file="applet/windows_natives.jar"/> <delete file="applet/linux_natives.jar"/> <delete file="applet/macosx_natives.jar"/> Modified: trunk/LWJGL/platform_build/linux_ant/build.xml =================================================================== --- trunk/LWJGL/platform_build/linux_ant/build.xml 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/platform_build/linux_ant/build.xml 2006-07-11 20:30:19 UTC (rev 2479) @@ -2,7 +2,8 @@ <project name="lwjgl native code, linux" basedir="../../bin" default="compile"> <property name="native" location="../src/native"/> - <property name="libname" value="liblwjgl.so"/> + <property name="libname32" value="liblwjgl.so"/> + <property name="libname64" value="liblwjgl64.so"/> <property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lpthread -L${java.home}/lib/i386 -ljawt -Wl,-static,-lXxf86vm,-lXcursor,-lXrender,-lXrandr,-lXfixes,-call_shared"/> <property name="libs64" value="-L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lpthread -L${java.home}/lib/amd64 -ljawt -lXxf86vm -lXcursor -lXrender -lXrandr -lXfixes"/> <property name="cflags" value="-O2 -Wall -c -fPIC -std=c99 -pthread"/> @@ -21,6 +22,9 @@ <condition property="libs" value="${libs64}" else="${libs32}"> <equals arg1="${hwplatform}" arg2="x86_64"/> </condition> + <condition property="libname" value="${libname64}" else="${libname32}"> + <equals arg1="${hwplatform}" arg2="x86_64"/> + </condition> <property name="linker_flags" value="-Wl,--version-script=${native}/linux/lwjgl.map -shared -O2 -Wall -o ${libname} ${libs}"/> <apply dir="." executable="cc" dest="." skipemptyfilesets="true" failonerror="true"> <arg line="${cflags}"/> Modified: trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2006-07-11 20:30:19 UTC (rev 2479) @@ -46,6 +46,10 @@ return 1000; } + public boolean has64Bit() { + return false; + } + public abstract long getTime(); public abstract void alert(String title, String message); public abstract String getClipboard(); Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2006-07-11 20:30:19 UTC (rev 2479) @@ -58,7 +58,7 @@ public static final int PLATFORM_WINDOWS = 3; public static final String PLATFORM_LINUX_NAME = "linux"; public static final String PLATFORM_MACOSX_NAME = "macosx"; - public static final String PLATFORM_WINDOWS_NAME = "win32"; + public static final String PLATFORM_WINDOWS_NAME = "windows"; /** LWJGL Logo - 16 by 16 pixels */ public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] { Modified: trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java 2006-07-11 20:30:19 UTC (rev 2479) @@ -71,4 +71,8 @@ // Seems to have failed return false; } + + public boolean has64Bit() { + return true; + } } Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-11 20:30:19 UTC (rev 2479) @@ -58,8 +58,10 @@ /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; + + private final static String POSTFIX64BIT = "64"; - private static void loadLibrary(final String lib_name) { + private static void doLoadLibrary(final String lib_name) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String library_path = System.getProperty("org.lwjgl.librarypath"); @@ -72,6 +74,21 @@ return null; } }); + } + + private static void loadLibrary(final String lib_name) { + try { + loadLibrary(lib_name); + } catch (UnsatisfiedLinkError e) { + if (implementation.has64Bit()) { + try { + loadLibrary(lib_name + POSTFIX64BIT); + } catch (UnsatisfiedLinkError e2) { + LWJGLUtil.log("Failed to load 64 bit library:" + e2.getMessage()); + } + } + throw e; + } } static { Modified: trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2006-07-11 20:30:19 UTC (rev 2479) @@ -44,22 +44,28 @@ /** * Return the version of the native library */ - public String getNativeLibraryVersion(); + String getNativeLibraryVersion(); - public void setDebug(boolean debug); + void setDebug(boolean debug); /** * Obtains the number of ticks that the hires timer does in a second. * * @return timer resolution in ticks per second or 0 if no timer is present. */ - public long getTimerResolution(); + long getTimerResolution(); - public long getTime(); + long getTime(); - public void alert(String title, String message); + void alert(String title, String message); boolean openURL(String url); - public String getClipboard(); + String getClipboard(); + + /** + * Returns true there exists a separate 64 bit library + * on the platform + */ + boolean has64Bit(); } Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-11 20:00:27 UTC (rev 2478) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-11 20:30:19 UTC (rev 2479) @@ -84,7 +84,7 @@ * the user's temp directory, and instruct the LWJGL subsystem to load its * native files from there. * The file required by the installer, is gotten from the classloader via its - * getResource command, and is expected to be named <win32 | linux | macosx>_natives.jar. + * getResource command, and is expected to be named <windows | linux | macosx>_natives.jar. * Note: Due to the nature of native libraries, we cannot actually uninstall the currently * loaded files, but rather the "last" installed. This means that the most recent install of LWJGL * will always be present in the users temp dir. When invoking the tempInstall method, all old installations This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-11 20:49:36
|
Revision: 2480 Author: elias_naur Date: 2006-07-11 13:49:28 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2480&view=rev Log Message: ----------- Linux: more 64 bit stuff Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-11 20:30:19 UTC (rev 2479) +++ trunk/LWJGL/build.xml 2006-07-11 20:49:28 UTC (rev 2480) @@ -118,9 +118,9 @@ <!-- Files to include in linux, glibc2.3 package --> <patternset id="lwjgl-linux.fileset"> - <include name="liblwjgl.so" /> + <include name="liblwjgl*.so" /> <include name="libopenal.so" /> - <include name="libjinput-linux.so" /> + <include name="libjinput-linux.so" /> </patternset> <!-- Files to include in linux optional, glibc2.3 package --> @@ -720,7 +720,9 @@ <!-- Compiles LWJGL on Linux platforms --> <target name="-compile_native_linux" if="lwjgl.platform.linux"> <ant antfile="platform_build/linux_ant/build.xml" inheritAll="false"/> - <copy file="${lwjgl.bin}/liblwjgl.so" todir="${lwjgl.lib}/linux"/> + <copy todir="${lwjgl.lib}/linux"> + <fileset dir="${lwjgl.bin}" includes="liblwjgl*.so"/> + </copy> </target> <target name="-compile_native_linux_optional" if="lwjgl.platform.linux"> Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-11 20:30:19 UTC (rev 2479) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-11 20:49:28 UTC (rev 2480) @@ -78,11 +78,11 @@ private static void loadLibrary(final String lib_name) { try { - loadLibrary(lib_name); + doLoadLibrary(lib_name); } catch (UnsatisfiedLinkError e) { if (implementation.has64Bit()) { try { - loadLibrary(lib_name + POSTFIX64BIT); + doLoadLibrary(lib_name + POSTFIX64BIT); } catch (UnsatisfiedLinkError e2) { LWJGLUtil.log("Failed to load 64 bit library:" + e2.getMessage()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-12 18:09:25
|
Revision: 2497 Author: elias_naur Date: 2006-07-12 11:09:11 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2497&view=rev Log Message: ----------- Windows: move natives from src/native/win32 to src/native/windows because the source really is bitness neutral, not 32 bit specific. Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/platform_build/windows_ant/build.xml Added Paths: ----------- trunk/LWJGL/src/native/windows/ Removed Paths: ------------- trunk/LWJGL/src/native/win32/ Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-12 16:55:05 UTC (rev 2496) +++ trunk/LWJGL/build.xml 2006-07-12 18:09:11 UTC (rev 2497) @@ -153,7 +153,7 @@ <fileset id="lwjgl.source.fileset" dir="."> <include name="build.xml" /> <include name="src/**" /> - <include name="platform_build/win32_ms_cmdline/*.bat" /> + <include name="platform_build/**/*" /> </fileset> <!-- files in the base package --> @@ -201,7 +201,7 @@ <uptodate property="lwjgl.main.built" targetfile="${lwjgl.lib}/win32/lwjgl.dll" > <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c*"/> <srcfiles dir= "${lwjgl.src.native}/generated" includes="*.c"/> - <srcfiles dir= "${lwjgl.src.native}/win32" includes="*.cpp"/> + <srcfiles dir= "${lwjgl.src.native}/windows" includes="*.c"/> </uptodate> <uptodate property="lwjgl.fmod.built" targetfile="${lwjgl.lib}/win32/lwjgl-fmod3.dll" > @@ -356,9 +356,20 @@ <target name="runtest" depends="all"> <fail message="test.mainclass is not set. Use 'ant -Dtest.mainclass=<main-class> runtest'" unless="test.mainclass"/> + <condition property="native_path" value="libs/win32"> + <os family="windows" /> + </condition> + + <condition property="native_path" value="libs/linux"> + <os name="Linux" /> + </condition> + + <condition property="native_path" value="libs/macosx"> + <os name="Mac OS X" /> + </condition> <java classname="${test.mainclass}" classpath="${lwjgl.lib}/lwjgl.jar:${lwjgl.lib}/lwjgl_util.jar:${lwjgl.lib}/lwjgl_test.jar" fork="true"> <jvmarg value="-Dorg.lwjgl.util.Debug=true"/> - <jvmarg value="-Djava.library.path=libs/linux:libs/win32:libs/macosx"/> + <jvmarg value="-Djava.library.path=${native_path}"/> </java> </target> @@ -507,7 +518,7 @@ <class name="org.lwjgl.opengl.LinuxCanvasImplementation" /> </javah> - <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/win32" force="yes"> + <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes"> <class name="org.lwjgl.opengl.WindowsKeyboard" /> <class name="org.lwjgl.opengl.WindowsDirectInput8" /> <class name="org.lwjgl.opengl.WindowsDirectInputDevice8" /> Modified: trunk/LWJGL/platform_build/windows_ant/build.xml =================================================================== --- trunk/LWJGL/platform_build/windows_ant/build.xml 2006-07-12 16:55:05 UTC (rev 2496) +++ trunk/LWJGL/platform_build/windows_ant/build.xml 2006-07-12 18:09:11 UTC (rev 2497) @@ -18,9 +18,9 @@ <arg value="/I${java.home}\..\include"/> <arg value="/I${java.home}\..\include\win32"/> <arg value="/I${native}\common"/> - <arg value="/I${native}\win32"/> + <arg value="/I${native}\windows"/> <srcfile/> - <fileset dir="${native}/win32" includes="*.c"/> + <fileset dir="${native}/windows" includes="*.c"/> <fileset dir="${native}/common" includes="*.c"/> <fileset dir="${native}/generated" includes="*.c"/> <mapper type="glob" from="*.c" to="*.obj"/> Copied: trunk/LWJGL/src/native/windows (from rev 2495, trunk/LWJGL/src/native/win32) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-12 18:11:26
|
Revision: 2498 Author: elias_naur Date: 2006-07-12 11:10:43 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2498&view=rev Log Message: ----------- remove .cvsignore files Removed Paths: ------------- trunk/LWJGL/.cvsignore trunk/LWJGL/src/native/common/.cvsignore trunk/LWJGL/src/native/common/devil/.cvsignore trunk/LWJGL/src/native/common/fmod3/.cvsignore trunk/LWJGL/src/native/linux/.cvsignore trunk/LWJGL/src/native/macosx/.cvsignore trunk/LWJGL/src/native/windows/.cvsignore Deleted: trunk/LWJGL/.cvsignore =================================================================== --- trunk/LWJGL/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1,4 +0,0 @@ -.classpath *.class *.class~ *.java~ .nbattrs .project -dist -libs -temp Deleted: trunk/LWJGL/src/native/common/.cvsignore =================================================================== --- trunk/LWJGL/src/native/common/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/src/native/common/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1,13 +0,0 @@ -Debug -Release -org_lwjgl_input_Cursor.h -org_lwjgl_input_Keyboard.h -org_lwjgl_input_Mouse.h -org_lwjgl_openal_AL.h -org_lwjgl_openal_ALC.h -org_lwjgl_opengl_GLContext.h -org_lwjgl_opengl_Pbuffer.h -org_lwjgl_Sys.h -org_lwjgl_opengl_Display.h -org_lwjgl_DefaultSysImplementation.h -org_lwjgl_NativeSysImplementation.h Deleted: trunk/LWJGL/src/native/common/devil/.cvsignore =================================================================== --- trunk/LWJGL/src/native/common/devil/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/src/native/common/devil/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1 +0,0 @@ -org_lwjgl_devil_ILNative.h \ No newline at end of file Deleted: trunk/LWJGL/src/native/common/fmod3/.cvsignore =================================================================== --- trunk/LWJGL/src/native/common/fmod3/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/src/native/common/fmod3/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1,3 +0,0 @@ -org_lwjgl_fmod3_FMOD.h -org_lwjgl_fmod3_FMusic.h -org_lwjgl_fmod3_FSound.h Deleted: trunk/LWJGL/src/native/linux/.cvsignore =================================================================== --- trunk/LWJGL/src/native/linux/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/src/native/linux/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1 +0,0 @@ -org_lwjgl_opengl_LinuxDisplay.h Deleted: trunk/LWJGL/src/native/macosx/.cvsignore =================================================================== --- trunk/LWJGL/src/native/macosx/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/src/native/macosx/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1 +0,0 @@ -org_lwjgl_opengl_MacOSXDisplay.h Deleted: trunk/LWJGL/src/native/windows/.cvsignore =================================================================== --- trunk/LWJGL/src/native/windows/.cvsignore 2006-07-12 18:09:11 UTC (rev 2497) +++ trunk/LWJGL/src/native/windows/.cvsignore 2006-07-12 18:10:43 UTC (rev 2498) @@ -1,5 +0,0 @@ -Debug -Release -org_lwjgl_opengl_Win32Display.h -org_lwjgl_Win32SysImplementation.h -org_lwjgl_NativeSysImplementation.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-12 18:34:35
|
Revision: 2499 Author: elias_naur Date: 2006-07-12 11:32:58 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2499&view=rev Log Message: ----------- Windows: Rename Win32* files to Windows* Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/native/windows/LWJGL.c trunk/LWJGL/src/native/windows/context.c trunk/LWJGL/src/native/windows/context.h trunk/LWJGL/src/native/windows/display.c trunk/LWJGL/src/native/windows/display.h trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsRegistry.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c trunk/LWJGL/src/native/windows/windows_al.c Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32AWTGLCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32CanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32DisplayPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PbufferPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Registry.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Win32AWTGLCanvasPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Win32ContextImplementation.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Win32DisplayPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Win32PeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Win32Registry.c trunk/LWJGL/src/native/windows/win32_al.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/build.xml 2006-07-12 18:32:58 UTC (rev 2499) @@ -524,14 +524,14 @@ <class name="org.lwjgl.opengl.WindowsDirectInputDevice8" /> <class name="org.lwjgl.opengl.WindowsDirectInput3" /> <class name="org.lwjgl.opengl.WindowsDirectInputDevice3" /> - <class name="org.lwjgl.opengl.Win32PbufferPeerInfo" /> - <class name="org.lwjgl.opengl.Win32Display" /> - <class name="org.lwjgl.opengl.Win32Registry" /> + <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" /> + <class name="org.lwjgl.opengl.WindowsDisplay" /> + <class name="org.lwjgl.opengl.WindowsRegistry" /> <class name="org.lwjgl.NativeSysImplementation" /> - <class name="org.lwjgl.opengl.Win32AWTGLCanvasPeerInfo" /> - <class name="org.lwjgl.opengl.Win32PeerInfo" /> - <class name="org.lwjgl.opengl.Win32DisplayPeerInfo" /> - <class name="org.lwjgl.opengl.Win32ContextImplementation" /> + <class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo" /> + <class name="org.lwjgl.opengl.WindowsPeerInfo" /> + <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" /> + <class name="org.lwjgl.opengl.WindowsContextImplementation" /> </javah> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes"> Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -89,7 +89,7 @@ class_name = "org.lwjgl.opengl.LinuxCanvasImplementation"; break; case LWJGLUtil.PLATFORM_WINDOWS: - class_name = "org.lwjgl.opengl.Win32CanvasImplementation"; + class_name = "org.lwjgl.opengl.WindowsCanvasImplementation"; break; case LWJGLUtil.PLATFORM_MACOSX: class_name = "org.lwjgl.opengl.MacOSXCanvasImplementation"; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -79,7 +79,7 @@ class_name = "org.lwjgl.opengl.LinuxContextImplementation"; break; case LWJGLUtil.PLATFORM_WINDOWS: - class_name = "org.lwjgl.opengl.Win32ContextImplementation"; + class_name = "org.lwjgl.opengl.WindowsContextImplementation"; break; case LWJGLUtil.PLATFORM_MACOSX: class_name = "org.lwjgl.opengl.MacOSXContextImplementation"; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -144,7 +144,7 @@ class_name = "org.lwjgl.opengl.LinuxDisplay"; break; case LWJGLUtil.PLATFORM_WINDOWS: - class_name = "org.lwjgl.opengl.Win32Display"; + class_name = "org.lwjgl.opengl.WindowsDisplay"; break; case LWJGLUtil.PLATFORM_MACOSX: class_name = "org.lwjgl.opengl.MacOSXDisplay"; Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32AWTGLCanvasPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32AWTGLCanvasPeerInfo.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32AWTGLCanvasPeerInfo.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.nio.ByteBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - * $Id$ - */ -final class Win32AWTGLCanvasPeerInfo extends Win32PeerInfo { - private final AWTGLCanvas canvas; - private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); - private final PixelFormat pixel_format; - private boolean has_pixel_format= false; - - public Win32AWTGLCanvasPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) { - this.canvas = canvas; - this.pixel_format = pixel_format; - } - - protected void doLockAndInitHandle() throws LWJGLException { - nInitHandle(awt_surface.lockAndGetHandle(canvas), getHandle()); - if (!has_pixel_format) { - // If we haven't applied a pixel format yet, do it now - choosePixelFormat(canvas.getX(), canvas.getY(), pixel_format, null, true, true, false, true); - has_pixel_format = true; - } - } - private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; - - protected void doUnlock() throws LWJGLException { - awt_surface.unlock(); - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32CanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32CanvasImplementation.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32CanvasImplementation.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.Toolkit; -import java.security.PrivilegedAction; -import java.security.AccessController; - -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - * $Id$ - */ -final class Win32CanvasImplementation implements AWTCanvasImplementation { - static { - // Make sure the awt stuff is properly initialised (the jawt library in particular) - Toolkit.getDefaultToolkit(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - try { - System.loadLibrary("jawt"); - } catch (UnsatisfiedLinkError e) { - /* It is probably already loaded, potentially by a different ClassLoader - * so just log the exception and continue - */ - LWJGLUtil.log("Failed to load jawt: " + e.getMessage()); - } - return null; - } - }); - } - - public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException { - return new Win32AWTGLCanvasPeerInfo(canvas, pixel_format); - } - - /** - * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. - * - * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format. - */ - public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { - /* - * It seems like the best way is to simply return null and - * use SetPixelFormat in JNI later. - */ - return null; - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.nio.ByteBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - * $Id$ - */ -final class Win32ContextImplementation implements ContextImplementation { - public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException { - ByteBuffer peer_handle = peer_info.lockAndGetHandle(); - try { - return nCreate(peer_handle, shared_context_handle); - } finally { - peer_info.unlock(); - } - } - private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; - - public void swapBuffers() throws LWJGLException { - Context current_context = Context.getCurrentContext(); - if (current_context == null) - throw new IllegalStateException("No context is current"); - synchronized (current_context) { - PeerInfo current_peer_info = current_context.getPeerInfo(); - ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); - try { - nSwapBuffers(peer_handle); - } finally { - current_peer_info.unlock(); - } - } - } - private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; - - public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { - } - - public void update(ByteBuffer context_handle) { - } - - public void releaseCurrentContext() throws LWJGLException { - nReleaseCurrentContext(); - } - private static native void nReleaseCurrentContext() throws LWJGLException; - - public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { - ByteBuffer peer_handle = peer_info.lockAndGetHandle(); - try { - nMakeCurrent(peer_handle, handle); - } finally { - peer_info.unlock(); - } - } - private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; - - public boolean isCurrent(ByteBuffer handle) throws LWJGLException { - boolean result = nIsCurrent(handle); - return result; - } - private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; - - public void setSwapInterval(int value) { - Context current_context = Context.getCurrentContext(); - if (current_context == null) - throw new IllegalStateException("No context is current"); - synchronized (current_context) { - nSetSwapInterval(current_context.getHandle(), value); - } - } - private static native void nSetSwapInterval(ByteBuffer context_handle, int value); - - public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { - nDestroy(handle); - } - private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException; -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,590 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -/** - * This is the Display implementation interface. Display delegates - * to implementors of this interface. There is one DisplayImplementation - * for each supported platform. - * @author elias_naur - */ - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; -import org.lwjgl.input.Cursor; - -final class Win32Display implements DisplayImplementation { - private final static int GAMMA_LENGTH = 256; - private final static int WM_MOUSEMOVE = 0x0200; - private final static int WM_LBUTTONDOWN = 0x0201; - private final static int WM_LBUTTONUP = 0x0202; - private final static int WM_LBUTTONDBLCLK = 0x0203; - private final static int WM_RBUTTONDOWN = 0x0204; - private final static int WM_RBUTTONUP = 0x0205; - private final static int WM_RBUTTONDBLCLK = 0x0206; - private final static int WM_MBUTTONDOWN = 0x0207; - private final static int WM_MBUTTONUP = 0x0208; - private final static int WM_MBUTTONDBLCLK = 0x0209; - private final static int WM_MOUSEWHEEL = 0x020A; - - private final static int WM_QUIT = 0x0012; - private final static int WM_SYSCOMMAND = 0x0112; - private final static int WM_PAINT = 0x000F; - - private final static int SC_SIZE = 0xF000; - private final static int SC_MOVE = 0xF010; - private final static int SC_MINIMIZE = 0xF020; - private final static int SC_MAXIMIZE = 0xF030; - private final static int SC_NEXTWINDOW = 0xF040; - private final static int SC_PREVWINDOW = 0xF050; - private final static int SC_CLOSE = 0xF060; - private final static int SC_VSCROLL = 0xF070; - private final static int SC_HSCROLL = 0xF080; - private final static int SC_MOUSEMENU = 0xF090; - private final static int SC_KEYMENU = 0xF100; - private final static int SC_ARRANGE = 0xF110; - private final static int SC_RESTORE = 0xF120; - private final static int SC_TASKLIST = 0xF130; - private final static int SC_SCREENSAVE = 0xF140; - private final static int SC_HOTKEY = 0xF150; - private final static int SC_DEFAULT = 0xF160; - private final static int SC_MONITORPOWER = 0xF170; - private final static int SC_CONTEXTHELP = 0xF180; - private final static int SC_SEPARATOR = 0xF00F; - - private final static int SM_CXCURSOR = 13; - - private final static int SIZE_RESTORED = 0; - private final static int SIZE_MINIMIZED = 1; - private final static int SIZE_MAXIMIZED = 2; - private final static int WM_SIZE = 0x0005; - private final static int WM_ACTIVATE = 0x0006; - private final static int WA_INACTIVE = 0; - private final static int WA_ACTIVE = 1; - private final static int WA_CLICKACTIVE = 2; - private final static int SW_SHOWMINNOACTIVE = 7; - private final static int SW_RESTORE = 9; - - private static Win32Display current_display; - - private Win32DisplayPeerInfo peer_info; - - private WindowsKeyboard keyboard; - private WindowsMouse mouse; - - private boolean close_requested; - private boolean is_dirty; - - private ByteBuffer current_gamma; - private ByteBuffer saved_gamma; - private DisplayMode current_mode; - - private boolean mode_set; - private boolean isFullscreen; - private boolean isMinimized; - private boolean isFocused; - private boolean did_maximize; - private boolean inAppActivate; - - public Win32Display() { - current_display = this; - } - - public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { - close_requested = false; - is_dirty = false; - isFullscreen = fullscreen; - isMinimized = false; - isFocused = false; - did_maximize = false; - nCreateWindow(mode, fullscreen, x, y); - peer_info.initDC(); - } - private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; - - public void destroyWindow() { - nDestroyWindow(); - if (isFullscreen) - resetCursorClipping(); - } - private static native void nDestroyWindow(); - private static native void resetCursorClipping(); - private static native void setupCursorClipping(long hwnd) throws LWJGLException; - - public void switchDisplayMode(DisplayMode mode) throws LWJGLException { - nSwitchDisplayMode(mode); - current_mode = mode; - mode_set = true; - } - private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException; - - /* - * Called when the application is alt-tabbed to or from - */ - private void appActivate(boolean active) { - if (inAppActivate) { - return; - } - inAppActivate = true; - isFocused = active; - if (active) { - if (isFullscreen) { - restoreDisplayMode(); - } - showWindow(getHwnd(), SW_RESTORE); - setForegroundWindow(getHwnd()); - setFocus(getHwnd()); - did_maximize = true; - } else if (isFullscreen) { - showWindow(getHwnd(), SW_SHOWMINNOACTIVE); - resetDisplayMode(); - } - inAppActivate = false; - } - private static native void showWindow(long hwnd, int mode); - private static native void setForegroundWindow(long hwnd); - private static native void setFocus(long hwnd); - - private void restoreDisplayMode() { - try { - doSetGammaRamp(current_gamma); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to restore gamma: " + e.getMessage()); - } - - if (!mode_set) { - mode_set = true; - try { - nSwitchDisplayMode(current_mode); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to restore display mode: " + e.getMessage()); - } - } - } - - public void resetDisplayMode() { - try { - doSetGammaRamp(saved_gamma); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to reset gamma ramp: " + e.getMessage()); - } - current_gamma = saved_gamma; - if (mode_set) { - mode_set = false; - nResetDisplayMode(); - } - resetCursorClipping(); - } - private static native void nResetDisplayMode(); - - public int getGammaRampLength() { - return GAMMA_LENGTH; - } - - public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { - doSetGammaRamp(convertToNativeRamp(gammaRamp)); - } - private static native ByteBuffer convertToNativeRamp(FloatBuffer gamma_ramp) throws LWJGLException; - private static native ByteBuffer getCurrentGammaRamp() throws LWJGLException; - - private void doSetGammaRamp(ByteBuffer native_gamma) throws LWJGLException { - nSetGammaRamp(native_gamma); - current_gamma = native_gamma; - } - private static native void nSetGammaRamp(ByteBuffer native_ramp) throws LWJGLException; - - public String getAdapter() { - try { - String adapter_string = Win32Registry.queryRegistrationKey( - Win32Registry.HKEY_LOCAL_MACHINE, - "HARDWARE\\DeviceMap\\Video", - "\\Device\\Video0"); - String root_key = "\\registry\\machine\\"; - if (adapter_string.toLowerCase().startsWith(root_key)) { - String driver_value = Win32Registry.queryRegistrationKey( - Win32Registry.HKEY_LOCAL_MACHINE, - adapter_string.substring(root_key.length()), - "InstalledDisplayDrivers"); - return driver_value; - } - } catch (LWJGLException e) { - LWJGLUtil.log("Exception occurred while querying registry: " + e); - } - return null; - } - - public String getVersion() { - String driver = getAdapter(); - if (driver != null) - return nGetVersion(driver); - else - return null; - } - private native String nGetVersion(String driver); - - public DisplayMode init() throws LWJGLException { - current_gamma = saved_gamma = getCurrentGammaRamp(); - return current_mode = getCurrentDisplayMode(); - } - private static native DisplayMode getCurrentDisplayMode() throws LWJGLException; - - public native void setTitle(String title); - - public boolean isCloseRequested() { - boolean saved = close_requested; - close_requested = false; - return saved; - } - - public boolean isVisible() { - return !isMinimized; - } - - public boolean isActive() { - return isFocused; - } - - public boolean isDirty() { - boolean saved = is_dirty; - is_dirty = false; - return saved; - } - - public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { - peer_info = new Win32DisplayPeerInfo(pixel_format); - return peer_info; - } - public void update() { - nUpdate(); - if (did_maximize) { - did_maximize = false; - /** - * WORKAROUND: - * Making the context current (redundantly) when the window - * is maximized helps some gfx recover from fullscreen - */ - try { - if (Display.getContext().isCurrent()) - Display.getContext().makeCurrent(); - } catch (LWJGLException e) { - LWJGLUtil.log("Exception occurred while trying to make context current: " + e); - } - } - } - private static native void nUpdate(); - - public void reshape(int x, int y, int width, int height) { - if (!isFullscreen) - nReshape(getHwnd(), x, y, width, height); - } - private static native void nReshape(long hwnd, int x, int y, int width, int height); - public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException; - - /* Mouse */ - public boolean hasWheel() { - return mouse.hasWheel(); - } - - public int getButtonCount() { - return mouse.getButtonCount(); - } - - public void createMouse() throws LWJGLException { - mouse = new WindowsMouse(createDirectInput(), getHwnd()); - } - - public void destroyMouse() { - mouse.destroy(); - mouse = null; - } - - public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - update(); - mouse.poll(coord_buffer, buttons); - } - - public void readMouse(ByteBuffer buffer) { - update(); - mouse.read(buffer); - } - - public void grabMouse(boolean grab) { - mouse.grab(grab); - } - - public int getNativeCursorCapabilities() { - return Cursor.CURSOR_ONE_BIT_TRANSPARENCY; - } - - public void setCursorPosition(int x, int y) { - nSetCursorPosition(x, y, isFullscreen); - } - private static native void nSetCursorPosition(int x, int y, boolean fullscreen); - - public native void setNativeCursor(Object handle) throws LWJGLException; - - public int getMinCursorSize() { - return getSystemMetrics(SM_CXCURSOR); - } - - public int getMaxCursorSize() { - return getSystemMetrics(SM_CXCURSOR); - } - - public native int getSystemMetrics(int index); - - private static native long getDllInstance(); - private static native long getHwnd(); - - /* Keyboard */ - public void createKeyboard() throws LWJGLException { - keyboard = new WindowsKeyboard(createDirectInput(), getHwnd()); - } - - public void destroyKeyboard() { - keyboard.destroy(); - keyboard = null; - } - - public void pollKeyboard(ByteBuffer keyDownBuffer) { - update(); - keyboard.poll(keyDownBuffer); - } - - public void readKeyboard(ByteBuffer buffer) { - update(); - keyboard.read(buffer); - } - -// public native int isStateKeySet(int key); - - public native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; - - public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { - return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1); - } - - public native void destroyCursor(Object cursorHandle); - public int getPbufferCapabilities() { - try { - // Return the capabilities of a minimum pixel format - return nGetPbufferCapabilities(new PixelFormat(0, 0, 0, 0, 0, 0, 0, 0, false)); - } catch (LWJGLException e) { - LWJGLUtil.log("Exception occurred while determining pbuffer capabilities: " + e); - return 0; - } - } - private native int nGetPbufferCapabilities(PixelFormat format) throws LWJGLException; - - public boolean isBufferLost(PeerInfo handle) { - return ((Win32PbufferPeerInfo)handle).isBufferLost(); - } - - public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs) throws LWJGLException { - return new Win32PbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs); - } - - public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { - ((Win32PbufferPeerInfo)handle).setPbufferAttrib(attrib, value); - } - - public void bindTexImageToPbuffer(PeerInfo handle, int buffer) { - ((Win32PbufferPeerInfo)handle).bindTexImageToPbuffer(buffer); - } - - public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { - ((Win32PbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer); - } - - - /** - * Sets one or more icons for the Display. - * <ul> - * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li> - * <li>Linux (and similar platforms) expect one 32x32 icon.</li> - * <li>Mac OS X should be supplied one 128x128 icon</li> - * </ul> - * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. - * - * @param icons Array of icons in RGBA mode - * @return number of icons used. - */ - public int setIcon(ByteBuffer[] icons) { - boolean done16 = false; - boolean done32 = false; - int used = 0; - - for (int i=0;i<icons.length;i++) { - int size = icons[i].limit() / 4; - - if ((((int) Math.sqrt(size)) == 16) && (!done16)) { - nSetWindowIcon16(icons[i].asIntBuffer()); - used++; - done16 = true; - } - if ((((int) Math.sqrt(size)) == 32) && (!done32)) { - nSetWindowIcon32(icons[i].asIntBuffer()); - used++; - done32 = true; - } - } - - return used; - } - - private static native int nSetWindowIcon16(IntBuffer icon); - - private static native int nSetWindowIcon32(IntBuffer icon); - - private void handleMouseButton(int button, int state, long millis) { - if (mouse != null) - mouse.handleMouseButton((byte)button, (byte)state, millis); - } - - private void handleMouseMoved(int x, int y, long millis) { - if (mouse != null) - mouse.handleMouseMoved(x, y, millis); - } - - private void handleMouseScrolled(int amount, long millis) { - if (mouse != null) - mouse.handleMouseScrolled(amount, millis); - } - - private static native int transformY(long hwnd, int y); - - private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { - if (current_display != null) - return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); - else - return false; - } - - private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { - if (isFullscreen && !isMinimized && isFocused) { - try { - setupCursorClipping(getHwnd()); - } catch (LWJGLException e) { - LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage()); - } - } - switch (msg) { - // disable screen saver and monitor power down messages which wreak havoc - case WM_ACTIVATE: - switch ((int)wParam) { - case WA_ACTIVE: - case WA_CLICKACTIVE: - appActivate(true); - break; - case WA_INACTIVE: - appActivate(false); - break; - } - return true; - case WM_SIZE: - switch ((int)wParam) { - case SIZE_RESTORED: - case SIZE_MAXIMIZED: - isMinimized = false; - break; - case SIZE_MINIMIZED: - isMinimized = true; - break; - } - return false; - case WM_MOUSEMOVE: - int xPos = (int)(short)(lParam & 0xFFFF); - int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); - handleMouseMoved(xPos, yPos, millis); - return true; - case WM_MOUSEWHEEL: - int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); - handleMouseScrolled(dwheel, millis); - return true; - case WM_LBUTTONDOWN: - handleMouseButton(0, 1, millis); - return true; - case WM_LBUTTONUP: - handleMouseButton(0, 0, millis); - return true; - case WM_RBUTTONDOWN: - handleMouseButton(1, 1, millis); - return true; - case WM_RBUTTONUP: - handleMouseButton(1, 0, millis); - return true; - case WM_MBUTTONDOWN: - handleMouseButton(2, 1, millis); - return true; - case WM_MBUTTONUP: - handleMouseButton(2, 0, millis); - return true; - case WM_QUIT: - close_requested = true; - return true; - case WM_SYSCOMMAND: - switch ((int)wParam) { - case SC_KEYMENU: - case SC_MOUSEMENU: - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return true; - case SC_CLOSE: - close_requested = true; - return true; - default: - break; - } - return false; - case WM_PAINT: - is_dirty = true; - return false; - default: - return false; - } - } - - private static WindowsDirectInput createDirectInput() throws LWJGLException { - try { - return new WindowsDirectInput8(getDllInstance()); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3"); - return new WindowsDirectInput3(getDllInstance()); - } - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32DisplayPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32DisplayPeerInfo.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32DisplayPeerInfo.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.nio.ByteBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - * $Id$ - */ -final class Win32DisplayPeerInfo extends Win32PeerInfo { - public Win32DisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { - GLContext.loadOpenGLLibrary(); - try { - createDummyDC(getHandle()); - try { - choosePixelFormat(0, 0, pixel_format, null, true, true, false, true); - } catch (LWJGLException e) { - nDestroy(getHandle()); - throw e; - } - } catch (LWJGLException e) { - GLContext.unloadOpenGLLibrary(); - throw e; - } - } - private static native void createDummyDC(ByteBuffer peer_info_handle) throws LWJGLException; - - void initDC() { - nInitDC(getHandle()); - } - private static native void nInitDC(ByteBuffer peer_info_handle); - - private static native void nDestroy(ByteBuffer peer_info_handle); - - protected void doLockAndInitHandle() throws LWJGLException { - // NO-OP - } - - private static native void setPixelFormat(ByteBuffer peer_info_handle); - - protected void doUnlock() throws LWJGLException { - // NO-OP - } - - public void destroy() { - super.destroy(); - nDestroy(getHandle()); - GLContext.unloadOpenGLLibrary(); - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PbufferPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PbufferPeerInfo.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PbufferPeerInfo.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - * $Id$ - */ -final class Win32PbufferPeerInfo extends Win32PeerInfo { - public Win32PbufferPeerInfo(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { - nCreate(getHandle(), width, height, pixel_format, pixelFormatCaps, pBufferAttribs); - } - private static native void nCreate(ByteBuffer handle, int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException; - - public boolean isBufferLost() { - return nIsBufferLost(getHandle()); - } - private static native boolean nIsBufferLost(ByteBuffer handle); - - public void setPbufferAttrib(int attrib, int value) { - nSetPbufferAttrib(getHandle(), attrib, value); - } - private static native void nSetPbufferAttrib(ByteBuffer handle, int attrib, int value); - - public void bindTexImageToPbuffer(int buffer) { - nBindTexImageToPbuffer(getHandle(), buffer); - } - private static native void nBindTexImageToPbuffer(ByteBuffer handle, int buffer); - - public void releaseTexImageFromPbuffer(int buffer) { - nReleaseTexImageFromPbuffer(getHandle(), buffer); - } - private static native void nReleaseTexImageFromPbuffer(ByteBuffer handle, int buffer); - - public void destroy() { - nDestroy(getHandle()); - } - private static native void nDestroy(ByteBuffer handle); - - protected void doLockAndInitHandle() throws LWJGLException { - // NO-OP - } - - protected void doUnlock() throws LWJGLException { - // NO-OP - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PeerInfo.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32PeerInfo.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - * $Id$ - */ -abstract class Win32PeerInfo extends PeerInfo { - public Win32PeerInfo() { - super(createHandle()); - } - private static native ByteBuffer createHandle(); - - protected void choosePixelFormat(int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { - nChoosePixelFormat(getHandle(), origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered); - } - private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException; -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Registry.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Registry.java 2006-07-12 18:10:43 UTC (rev 2498) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Registry.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -/** - * This is an interface to the windows registry - * @author elias_naur - */ - -import org.lwjgl.LWJGLException; - -final class Win32Registry { - final static int HKEY_CLASSES_ROOT = 1; - final static int HKEY_CURRENT_USER = 2; - final static int HKEY_LOCAL_MACHINE = 3; - final static int HKEY_USERS = 4; - - /** - * Query the registry value specified by the root key, subkey, value tuple - */ - static String queryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException { - switch (root_key) { - case HKEY_CLASSES_ROOT: - case HKEY_CURRENT_USER: - case HKEY_LOCAL_MACHINE: - case HKEY_USERS: - break; - default: - throw new IllegalArgumentException("Invalid enum: " + root_key); - } - return nQueryRegistrationKey(root_key, subkey, value); - } - - private static native String nQueryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException; -} Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java (from rev 2495, trunk/LWJGL/src/java/org/lwjgl/opengl/Win32AWTGLCanvasPeerInfo.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision$ + * $Id$ + */ +final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo { + private final AWTGLCanvas canvas; + private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); + private final PixelFormat pixel_format; + private boolean has_pixel_format= false; + + public WindowsAWTGLCanvasPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) { + this.canvas = canvas; + this.pixel_format = pixel_format; + } + + protected void doLockAndInitHandle() throws LWJGLException { + nInitHandle(awt_surface.lockAndGetHandle(canvas), getHandle()); + if (!has_pixel_format) { + // If we haven't applied a pixel format yet, do it now + choosePixelFormat(canvas.getX(), canvas.getY(), pixel_format, null, true, true, false, true); + has_pixel_format = true; + } + } + private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; + + protected void doUnlock() throws LWJGLException { + awt_surface.unlock(); + } +} Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java (from rev 2495, trunk/LWJGL/src/java/org/lwjgl/opengl/Win32CanvasImplementation.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Toolkit; +import java.security.PrivilegedAction; +import java.security.AccessController; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision$ + * $Id$ + */ +final class WindowsCanvasImplementation implements AWTCanvasImplementation { + static { + // Make sure the awt stuff is properly initialised (the jawt library in particular) + Toolkit.getDefaultToolkit(); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + try { + System.loadLibrary("jawt"); + } catch (UnsatisfiedLinkError e) { + /* It is probably already loaded, potentially by a different ClassLoader + * so just log the exception and continue + */ + LWJGLUtil.log("Failed to load jawt: " + e.getMessage()); + } + return null; + } + }); + } + + public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException { + return new WindowsAWTGLCanvasPeerInfo(canvas, pixel_format); + } + + /** + * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. + * + * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format. + */ + public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { + /* + * It seems like the best way is to simply return null and + * use SetPixelFormat in JNI later. + */ + return null; + } +} Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java (from rev 2495, trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2006-07-12 18:32:58 UTC (rev 2499) @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision$ + * $Id$ + */ +final class WindowsContextImplementation implements ContextImplementation { + public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + return nCreate(peer_handle, shared_context_handle); + } finally { + peer_info.unlock(); + } + } + private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; + + public void swapBuffers() throws LWJGLException { + Context current_context = Context.getCurrentContext(); + if (current_context == null) + throw new IllegalStateException("No context is current"); + synchronized (current_context) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + try { + nSwapBuffers(peer_handle); + } finally { + current_peer_info.unlock(); + } + } + } + private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; + + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } + + public void update(ByteBuffer context_handle) { + } + + public void releaseCurrentContext() throws LWJGLException { + nReleaseCurrentContext(); + } + private static native void nReleaseCurrentContext() throws LWJGLException; + + public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + nMakeCurrent(peer_handle, handle); + } finally { + peer_info.unlock(); + } + } + private static native void nMakeCurrent(ByteBu... [truncated message content] |
From: <eli...@us...> - 2006-07-14 08:32:44
|
Revision: 2509 Author: elias_naur Date: 2006-07-14 01:32:01 -0700 (Fri, 14 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2509&view=rev Log Message: ----------- Added a Controllers applet test Modified Paths: -------------- trunk/LWJGL/applet/applet.html trunk/LWJGL/build.xml trunk/LWJGL/libs/jinput.jar Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/test/applet/ControllersTest.java Modified: trunk/LWJGL/applet/applet.html =================================================================== --- trunk/LWJGL/applet/applet.html 2006-07-13 18:56:19 UTC (rev 2508) +++ trunk/LWJGL/applet/applet.html 2006-07-14 08:32:01 UTC (rev 2509) @@ -1,6 +1,6 @@ <html> <body> - <applet code="org.lwjgl.test.applet.AppletTest" archive="lwjgl_applet.jar,lwjgl_util_applet.jar,lwjgl.jar,res.jar,lwjgl_util.jar,lwjgl_fmod3.jar,lwjgl_devil.jar,natives.jar" width="640" height="480"> + <applet code="org.lwjgl.test.applet.AppletTest" archive="lwjgl_applet.jar,lwjgl_util_applet.jar,lwjgl.jar,res.jar,lwjgl_util.jar,lwjgl_fmod3.jar,lwjgl_devil.jar,natives.jar,jinput.jar" width="640" height="480"> <param name="test" value="org.lwjgl.test.applet.OpenGL"> </applet> </body> Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-13 18:56:19 UTC (rev 2508) +++ trunk/LWJGL/build.xml 2006-07-14 08:32:01 UTC (rev 2509) @@ -359,7 +359,7 @@ <condition property="native_path" value="libs/macosx"> <os name="Mac OS X" /> </condition> - <java classname="${test.mainclass}" classpath="${lwjgl.lib}/lwjgl.jar:${lwjgl.lib}/lwjgl_util.jar:${lwjgl.lib}/lwjgl_test.jar" fork="true"> + <java classname="${test.mainclass}" classpath="${lwjgl.lib}/lwjgl.jar:${lwjgl.lib}/lwjgl_util.jar:${lwjgl.lib}/lwjgl_test.jar:${lwjgl.lib}/jinput.jar" fork="true"> <jvmarg value="-Dorg.lwjgl.util.Debug=true"/> <jvmarg value="-Djava.library.path=${native_path}"/> </java> @@ -416,10 +416,12 @@ <copy file="${lwjgl.lib}/lwjgl_util.jar" todir="applet"/> <copy file="${lwjgl.lib}/lwjgl_fmod3.jar" todir="applet"/> <copy file="${lwjgl.lib}/lwjgl_devil.jar" todir="applet"/> + <copy file="${lwjgl.lib}/jinput.jar" todir="applet"/> <zip destfile="applet/res.jar"> <zipfileset dir="${lwjgl.res}" includes="Footsteps.wav, ILtest.tga, Missing_you.mod"/> </zip> <signjar jar="applet/lwjgl.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> + <signjar jar="applet/jinput.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> <signjar jar="applet/lwjgl_util_applet.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> <signjar jar="applet/lwjgl_fmod3.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> <signjar jar="applet/lwjgl_devil.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> Modified: trunk/LWJGL/libs/jinput.jar =================================================================== (Binary files differ) Added: trunk/LWJGL/src/java/org/lwjgl/test/applet/ControllersTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/ControllersTest.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/ControllersTest.java 2006-07-14 08:32:01 UTC (rev 2509) @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2006 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.test.applet; + +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Controllers; + +public class ControllersTest extends Canvas implements Test { + public void start() { + try { + Controllers.create(); + } catch (LWJGLException e) { + e.printStackTrace(); + return; + } + System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount()); + } + + public void stop() { + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-15 19:45:57
|
Revision: 2521 Author: elias_naur Date: 2006-07-15 12:45:36 -0700 (Sat, 15 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2521&view=rev Log Message: ----------- Windows: Moved NativeSysImplementation.java to WindowsSysImplementation.java and moved some native code to java. Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/NativeSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/Win32SysImplementation.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-15 19:25:13 UTC (rev 2520) +++ trunk/LWJGL/build.xml 2006-07-15 19:45:36 UTC (rev 2521) @@ -514,7 +514,7 @@ <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" /> <class name="org.lwjgl.opengl.WindowsDisplay" /> <class name="org.lwjgl.opengl.WindowsRegistry" /> - <class name="org.lwjgl.NativeSysImplementation" /> + <class name="org.lwjgl.WindowsSysImplementation" /> <class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo" /> <class name="org.lwjgl.opengl.WindowsPeerInfo" /> <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" /> Deleted: trunk/LWJGL/src/java/org/lwjgl/NativeSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/NativeSysImplementation.java 2006-07-15 19:25:13 UTC (rev 2520) +++ trunk/LWJGL/src/java/org/lwjgl/NativeSysImplementation.java 2006-07-15 19:45:36 UTC (rev 2521) @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl; - -/** - * A SysImplementation that uses native calls only. - * <p> - * @author $Author$ - * @version $Revision$ - * $Id$ - */ -class NativeSysImplementation extends DefaultSysImplementation { - - static { - Sys.initialize(); - } - - public native long getTimerResolution(); - - public native long getTime(); - - public native void alert(String title, String message); - - public native boolean openURL(String url); - - public native String getClipboard(); -} Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-15 19:25:13 UTC (rev 2520) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-15 19:45:36 UTC (rev 2521) @@ -57,7 +57,7 @@ private static final String VERSION = "1.0beta2"; /** Current version of the JNI library */ - static final int JNI_VERSION = 2; + static final int JNI_VERSION = 3; /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; @@ -114,7 +114,7 @@ class_name = "org.lwjgl.LinuxSysImplementation"; break; case LWJGLUtil.PLATFORM_WINDOWS: - class_name = "org.lwjgl.Win32SysImplementation"; + class_name = "org.lwjgl.WindowsSysImplementation"; break; case LWJGLUtil.PLATFORM_MACOSX: class_name = "org.lwjgl.MacOSXSysImplementation"; Deleted: trunk/LWJGL/src/java/org/lwjgl/Win32SysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Win32SysImplementation.java 2006-07-15 19:25:13 UTC (rev 2520) +++ trunk/LWJGL/src/java/org/lwjgl/Win32SysImplementation.java 2006-07-15 19:45:36 UTC (rev 2521) @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl; - -/** - * <p> - * Win32 SysImplementation. This is just a straightforward NativsSysImplementation. - * </p> - * @author $Author$ - * @version $Revision$ - * $Id$ - */ -class Win32SysImplementation extends NativeSysImplementation { -} Copied: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java (from rev 2520, trunk/LWJGL/src/java/org/lwjgl/NativeSysImplementation.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2006-07-15 19:45:36 UTC (rev 2521) @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl; + +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; + +/** + * <p> + * @author $Author$ + * @version $Revision$ + * $Id$ + */ +class WindowsSysImplementation extends DefaultSysImplementation { + static { + Sys.initialize(); + } + + public long getTimerResolution() { + return 1000; + } + + public native long getTime(); + + public native void alert(String title, String message); + + public boolean openURL(final String url) { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Runtime.getRuntime().exec(new String[]{"rundll32", "url.dll,FileProtocolHandler", url}); + return null; + } + }); + return true; + } catch (PrivilegedActionException e) { + LWJGLUtil.log("Failed to open url (" + url + "): " + e.getCause().getMessage()); + return false; + } + } + + public native String getClipboard(); +} Modified: trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java 2006-07-15 19:25:13 UTC (rev 2520) +++ trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java 2006-07-15 19:45:36 UTC (rev 2521) @@ -69,6 +69,7 @@ System.out.println("Info about current:"); System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion()); +System.exit(1); System.out.println("Resolution: " + Display.getDisplayMode().getWidth() + "x" + Display.getDisplayMode().getHeight() + "x" + Modified: trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2006-07-15 19:25:13 UTC (rev 2520) +++ trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2006-07-15 19:45:36 UTC (rev 2521) @@ -41,48 +41,21 @@ #include "Window.h" #include "mmsystem.h" -#include "org_lwjgl_NativeSysImplementation.h" +#include "org_lwjgl_WindowsSysImplementation.h" #include "common_tools.h" #include <malloc.h> -/* - * Class: org_lwjgl_Sys - * Method: getTimerResolution - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_lwjgl_NativeSysImplementation_getTimerResolution - (JNIEnv * env, jobject ignored) -{ - return (jlong) 1000L; -} - -/* - * Class: org_lwjgl_Sys - * Method: ngetTime - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_lwjgl_NativeSysImplementation_getTime - (JNIEnv * env, jobject ignored) -{ - - MMRESULT result; +JNIEXPORT jlong JNICALL Java_org_lwjgl_WindowsSysImplementation_getTime(JNIEnv * env, jobject ignored) { DWORD time; - result = timeBeginPeriod(1); + timeBeginPeriod(1); time = timeGetTime(); - result = timeEndPeriod(1); + timeEndPeriod(1); return time; } -/* - * Class: org_lwjgl_Sys - * Method: alert - * Signature: (Ljava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_NativeSysImplementation_alert - (JNIEnv * env, jobject ignored, jstring title, jstring message) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_alert(JNIEnv * env, jobject ignored, jstring title, jstring message) { char * eMessageText = GetStringNativeChars(env, message); char * cTitleBarText = GetStringNativeChars(env, title); MessageBox(getCurrentHWND(), eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); @@ -93,56 +66,7 @@ free(cTitleBarText); } -/* - * Class: org_lwjgl_Sys - * Method: openURL - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_NativeSysImplementation_openURL - (JNIEnv * env, jobject ignored, jstring url) -{ -#define BUFFER_SIZE 1024 - const char *std_args = "rundll32 url.dll,FileProtocolHandler "; - STARTUPINFO si; - PROCESS_INFORMATION pi; - - char * urlString = GetStringNativeChars(env, url); - - char command[BUFFER_SIZE]; - strncpy_s(command, BUFFER_SIZE, "", 1); - strncat_s(command, BUFFER_SIZE, std_args, _TRUNCATE); - strncat_s(command, BUFFER_SIZE, urlString, _TRUNCATE); - free(urlString); - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - // Start the child process. - if( !CreateProcess( NULL, // No module name (use command line). - command, // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. - &si, // Pointer to STARTUPINFO structure. - &pi ) // Pointer to PROCESS_INFORMATION structure. - ) - { - printfDebugJava(env, "Failed to open URL %s", urlString); - return JNI_FALSE; - } - - // Close process and thread handles. - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - - return JNI_TRUE; -} - -JNIEXPORT jstring JNICALL Java_org_lwjgl_NativeSysImplementation_getClipboard +JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_getClipboard (JNIEnv * env, jobject ignored) { // Check to see if there's text available in the clipboard This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2006-07-25 15:31:50
|
Revision: 2536 Author: spasi Date: 2006-07-25 08:31:16 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2536&view=rev Log Message: ----------- Added SGIS_generate_mipmap & SGIS_texture_lod extensions Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/generated/org/lwjgl/opengl/ATITextFragmentShader.java trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTTimerQuery.java trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTTimerQuery.c Added Paths: ----------- trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISGenerateMipmap.java trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISTextureLOD.java trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-22 21:30:31 UTC (rev 2535) +++ trunk/LWJGL/build.xml 2006-07-25 15:31:16 UTC (rev 2536) @@ -15,7 +15,7 @@ <property name="lwjgl.res" location="res" /> <property name="lwjgl.version" value="1.0beta2" /> - <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java"/> + <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java"/> <!-- ================================================================== --> <!-- Filesets used for targets --> <!-- ================================================================== --> Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/ATITextFragmentShader.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/ATITextFragmentShader.java 2006-07-22 21:30:31 UTC (rev 2535) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/ATITextFragmentShader.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -1,24 +1,24 @@ -/* MACHINE GENERATED FILE, DO NOT EDIT */ - -package org.lwjgl.opengl; - -import org.lwjgl.LWJGLException; -import org.lwjgl.BufferChecks; -import java.nio.*; - -public final class ATITextFragmentShader { - /** - * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, - * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, - * and GetDoublev, and by the <target> parameter of ProgramStringARB, - * BindProgramARB, ProgramEnvParameter4{d,dv,f,fv}ARB, - * ProgramLocalParameter4{d,dv,f,fv}ARB, - * GetProgramEnvParameter{dv,fv}ARB, GetProgramLocalParameter{dv,fv}ARB, - * GetProgramivARB, GetProgramfvATI, and GetProgramStringARB. - */ - public static final int GL_TEXT_FRAGMENT_SHADER_ATI = 0x8200; - - private ATITextFragmentShader() { - } - -} +/* MACHINE GENERATED FILE, DO NOT EDIT */ + +package org.lwjgl.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; +import java.nio.*; + +public final class ATITextFragmentShader { + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev, and by the <target> parameter of ProgramStringARB, + * BindProgramARB, ProgramEnvParameter4{d,dv,f,fv}ARB, + * ProgramLocalParameter4{d,dv,f,fv}ARB, + * GetProgramEnvParameter{dv,fv}ARB, GetProgramLocalParameter{dv,fv}ARB, + * GetProgramivARB, GetProgramfvATI, and GetProgramStringARB. + */ + public static final int GL_TEXT_FRAGMENT_SHADER_ATI = 0x8200; + + private ATITextFragmentShader() { + } + +} Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java 2006-07-22 21:30:31 UTC (rev 2535) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -144,6 +144,8 @@ public final boolean GL_NV_vertex_program2; public final boolean GL_NV_vertex_program2_option; public final boolean GL_NV_vertex_program3; + public final boolean GL_SGIS_generate_mipmap; + public final boolean GL_SGIS_texture_lod; public final boolean GL_SUN_slice_accum; long ARB_buffer_object_glBindBufferARB_pointer; @@ -2398,6 +2400,8 @@ this.GL_NV_vertex_program2 = supported_extensions.contains("GL_NV_vertex_program2"); this.GL_NV_vertex_program2_option = supported_extensions.contains("GL_NV_vertex_program2_option"); this.GL_NV_vertex_program3 = supported_extensions.contains("GL_NV_vertex_program3"); + this.GL_SGIS_generate_mipmap = supported_extensions.contains("GL_SGIS_generate_mipmap"); + this.GL_SGIS_texture_lod = supported_extensions.contains("GL_SGIS_texture_lod"); this.GL_SUN_slice_accum = supported_extensions.contains("GL_SUN_slice_accum"); } } Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTTimerQuery.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTTimerQuery.java 2006-07-22 21:30:31 UTC (rev 2535) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTTimerQuery.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -1,35 +1,35 @@ -/* MACHINE GENERATED FILE, DO NOT EDIT */ - -package org.lwjgl.opengl; - -import org.lwjgl.LWJGLException; -import org.lwjgl.BufferChecks; -import java.nio.*; - -public final class EXTTimerQuery { - /** - * Accepted by the <target> parameter of BeginQuery, EndQuery, and - * GetQueryiv: - */ - public static final int GL_TIME_ELAPSED_EXT = 0x88bf; - - private EXTTimerQuery() { - } - - - public static void glGetQueryObjectEXT(int id, int pname, LongBuffer params) { - long function_pointer = GLContext.getCapabilities().EXT_timer_query_glGetQueryObjecti64vEXT_pointer; - BufferChecks.checkFunctionAddress(function_pointer); - BufferChecks.checkBuffer(params, 1); - nglGetQueryObjecti64vEXT(id, pname, params, params.position(), function_pointer); - } - private static native void nglGetQueryObjecti64vEXT(int id, int pname, LongBuffer params, int params_position, long function_pointer); - - public static void glGetQueryObjectuEXT(int id, int pname, LongBuffer params) { - long function_pointer = GLContext.getCapabilities().EXT_timer_query_glGetQueryObjectui64vEXT_pointer; - BufferChecks.checkFunctionAddress(function_pointer); - BufferChecks.checkBuffer(params, 1); - nglGetQueryObjectui64vEXT(id, pname, params, params.position(), function_pointer); - } - private static native void nglGetQueryObjectui64vEXT(int id, int pname, LongBuffer params, int params_position, long function_pointer); -} +/* MACHINE GENERATED FILE, DO NOT EDIT */ + +package org.lwjgl.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; +import java.nio.*; + +public final class EXTTimerQuery { + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + public static final int GL_TIME_ELAPSED_EXT = 0x88bf; + + private EXTTimerQuery() { + } + + + public static void glGetQueryObjectEXT(int id, int pname, LongBuffer params) { + long function_pointer = GLContext.getCapabilities().EXT_timer_query_glGetQueryObjecti64vEXT_pointer; + BufferChecks.checkFunctionAddress(function_pointer); + BufferChecks.checkBuffer(params, 1); + nglGetQueryObjecti64vEXT(id, pname, params, params.position(), function_pointer); + } + private static native void nglGetQueryObjecti64vEXT(int id, int pname, LongBuffer params, int params_position, long function_pointer); + + public static void glGetQueryObjectuEXT(int id, int pname, LongBuffer params) { + long function_pointer = GLContext.getCapabilities().EXT_timer_query_glGetQueryObjectui64vEXT_pointer; + BufferChecks.checkFunctionAddress(function_pointer); + BufferChecks.checkBuffer(params, 1); + nglGetQueryObjectui64vEXT(id, pname, params, params.position(), function_pointer); + } + private static native void nglGetQueryObjectui64vEXT(int id, int pname, LongBuffer params, int params_position, long function_pointer); +} Added: trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISGenerateMipmap.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISGenerateMipmap.java (rev 0) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISGenerateMipmap.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -0,0 +1,24 @@ +/* MACHINE GENERATED FILE, DO NOT EDIT */ + +package org.lwjgl.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; +import java.nio.*; + +public final class SGISGenerateMipmap { + /** + * Accepted by the <pname> parameter of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv. + */ + public static final int GL_GENERATE_MIPMAP_SGIS = 0x8191; + /** + * Accepted by the <target> parameter of Hint, and by the <pname> + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. + */ + public static final int GL_GENERATE_MIPMAP_HINT_SGIS = 0x8192; + + private SGISGenerateMipmap() { + } + +} Added: trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISTextureLOD.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISTextureLOD.java (rev 0) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/SGISTextureLOD.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -0,0 +1,22 @@ +/* MACHINE GENERATED FILE, DO NOT EDIT */ + +package org.lwjgl.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; +import java.nio.*; + +public final class SGISTextureLOD { + /** + * Accepted by the <pname> parameter of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv. + */ + public static final int GL_TEXTURE_MIN_LOD_SGIS = 0x813a; + public static final int GL_TEXTURE_MAX_LOD_SGIS = 0x813b; + public static final int GL_TEXTURE_BASE_LEVEL_SGIS = 0x813c; + public static final int GL_TEXTURE_MAX_LEVEL_SGIS = 0x813d; + + private SGISTextureLOD() { + } + +} Modified: trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTTimerQuery.c =================================================================== --- trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTTimerQuery.c 2006-07-22 21:30:31 UTC (rev 2535) +++ trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTTimerQuery.c 2006-07-25 15:31:16 UTC (rev 2536) @@ -1,20 +1,20 @@ -/* MACHINE GENERATED FILE, DO NOT EDIT */ - -#include <jni.h> -#include "extgl.h" - -typedef void (APIENTRY *glGetQueryObjecti64vEXTPROC) (GLuint id, GLenum pname, GLint64EXT * params); -typedef void (APIENTRY *glGetQueryObjectui64vEXTPROC) (GLuint id, GLenum pname, GLuint64EXT * params); - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTimerQuery_nglGetQueryObjecti64vEXT(JNIEnv *env, jclass clazz, jint id, jint pname, jobject params, jint params_position, jlong function_pointer) { - GLint64EXT *params_address = ((GLint64EXT *)(*env)->GetDirectBufferAddress(env, params)) + params_position; - glGetQueryObjecti64vEXTPROC glGetQueryObjecti64vEXT = (glGetQueryObjecti64vEXTPROC)((intptr_t)function_pointer); - glGetQueryObjecti64vEXT(id, pname, params_address); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTimerQuery_nglGetQueryObjectui64vEXT(JNIEnv *env, jclass clazz, jint id, jint pname, jobject params, jint params_position, jlong function_pointer) { - GLuint64EXT *params_address = ((GLuint64EXT *)(*env)->GetDirectBufferAddress(env, params)) + params_position; - glGetQueryObjectui64vEXTPROC glGetQueryObjectui64vEXT = (glGetQueryObjectui64vEXTPROC)((intptr_t)function_pointer); - glGetQueryObjectui64vEXT(id, pname, params_address); -} - +/* MACHINE GENERATED FILE, DO NOT EDIT */ + +#include <jni.h> +#include "extgl.h" + +typedef void (APIENTRY *glGetQueryObjecti64vEXTPROC) (GLuint id, GLenum pname, GLint64EXT * params); +typedef void (APIENTRY *glGetQueryObjectui64vEXTPROC) (GLuint id, GLenum pname, GLuint64EXT * params); + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTimerQuery_nglGetQueryObjecti64vEXT(JNIEnv *env, jclass clazz, jint id, jint pname, jobject params, jint params_position, jlong function_pointer) { + GLint64EXT *params_address = ((GLint64EXT *)(*env)->GetDirectBufferAddress(env, params)) + params_position; + glGetQueryObjecti64vEXTPROC glGetQueryObjecti64vEXT = (glGetQueryObjecti64vEXTPROC)((intptr_t)function_pointer); + glGetQueryObjecti64vEXT(id, pname, params_address); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTimerQuery_nglGetQueryObjectui64vEXT(JNIEnv *env, jclass clazz, jint id, jint pname, jobject params, jint params_position, jlong function_pointer) { + GLuint64EXT *params_address = ((GLuint64EXT *)(*env)->GetDirectBufferAddress(env, params)) + params_position; + glGetQueryObjectui64vEXTPROC glGetQueryObjectui64vEXT = (glGetQueryObjectui64vEXTPROC)((intptr_t)function_pointer); + glGetQueryObjectui64vEXT(id, pname, params_address); +} + Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; + +public interface SGIS_generate_mipmap { + + /** + * Accepted by the <pname> parameter of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv. + */ + int GL_GENERATE_MIPMAP_SGIS = 0x8191; + + /** + * Accepted by the <target> parameter of Hint, and by the <pname> + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. + */ + int GL_GENERATE_MIPMAP_HINT_SGIS = 0x8192; + +} \ No newline at end of file Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java 2006-07-25 15:31:16 UTC (rev 2536) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; + +@Extension(postfix = "SGIS", className = "SGISTextureLOD") +public interface SGIS_texture_lod { + + /** + * Accepted by the <pname> parameter of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv. + */ + int GL_TEXTURE_MIN_LOD_SGIS = 0x813A; + int GL_TEXTURE_MAX_LOD_SGIS = 0x813B; + int GL_TEXTURE_BASE_LEVEL_SGIS = 0x813C; + int GL_TEXTURE_MAX_LEVEL_SGIS = 0x813D; +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-08-01 14:10:22
|
Revision: 2542 Author: elias_naur Date: 2006-08-01 07:10:17 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2542&view=rev Log Message: ----------- Mac OS X: Build fixes Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/platform_build/macosx_ant/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-08-01 13:55:19 UTC (rev 2541) +++ trunk/LWJGL/build.xml 2006-08-01 14:10:17 UTC (rev 2542) @@ -711,7 +711,7 @@ <target name="-compile_native_macosx" if="lwjgl.platform.macosx"> <ant antfile="platform_build/macosx_ant/build.xml" inheritAll="false"/> - <copy file="${lwjgl.bin}/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/> + <copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/> </target> <!-- Compiles LWJGL on Mac OS X platforms --> Modified: trunk/LWJGL/platform_build/macosx_ant/build.xml =================================================================== --- trunk/LWJGL/platform_build/macosx_ant/build.xml 2006-08-01 13:55:19 UTC (rev 2541) +++ trunk/LWJGL/platform_build/macosx_ant/build.xml 2006-08-01 14:10:17 UTC (rev 2542) @@ -29,11 +29,11 @@ </target> <target name="link"> - <apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true"> - <arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/> + <apply dir="." parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true"> + <arg line="${linkerflags} -exported_symbols_list lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/> <fileset dir="${objdir}" includes="*.o"/> </apply> - <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true"> + <apply dir="." executable="strip" os="Mac OS X" failonerror="true"> <arg line="-S -X"/> <fileset dir="." file="${libname}"/> </apply> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-08-10 08:45:50
|
Revision: 2547 Author: elias_naur Date: 2006-08-10 01:45:10 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2547&view=rev Log Message: ----------- Update to beta3 Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java trunk/LWJGL/src/native/common/devil/extil.c trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-08-10 08:16:03 UTC (rev 2546) +++ trunk/LWJGL/build.xml 2006-08-10 08:45:10 UTC (rev 2547) @@ -13,7 +13,7 @@ <property name="lwjgl.docs" location="doc" /> <property name="lwjgl.temp" location="temp" /> <property name="lwjgl.res" location="res" /> - <property name="lwjgl.version" value="1.0beta2" /> + <property name="lwjgl.version" value="1.0beta3" /> <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java"/> <!-- ================================================================== --> Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-08-10 08:16:03 UTC (rev 2546) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-08-10 08:45:10 UTC (rev 2547) @@ -54,7 +54,7 @@ private static final String JNI_LIBRARY_NAME = "lwjgl"; /** Current version of library */ - private static final String VERSION = "1.0beta2"; + private static final String VERSION = "1.0beta3"; /** Current version of the JNI library */ static final int JNI_VERSION = 3; Modified: trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-08-10 08:16:03 UTC (rev 2546) +++ trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-08-10 08:45:10 UTC (rev 2547) @@ -53,7 +53,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-devil"; /** Version of IL */ - public static final String VERSION = "1.0beta2"; + public static final String VERSION = "1.0beta3"; private static void loadLibrary(final String lib_name) { AccessController.doPrivileged(new PrivilegedAction() { Modified: trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-08-10 08:16:03 UTC (rev 2546) +++ trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-08-10 08:45:10 UTC (rev 2547) @@ -193,7 +193,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-fmod3"; /** Version of FMOD */ - public static final String VERSION = "1.0beta2"; + public static final String VERSION = "1.0beta3"; static { initialize(); Modified: trunk/LWJGL/src/native/common/devil/extil.c =================================================================== --- trunk/LWJGL/src/native/common/devil/extil.c 2006-08-10 08:16:03 UTC (rev 2546) +++ trunk/LWJGL/src/native/common/devil/extil.c 2006-08-10 08:45:10 UTC (rev 2547) @@ -8,7 +8,7 @@ static void* devILhandle; #endif -static const char* VERSION = "1.0beta2"; +static const char* VERSION = "1.0beta3"; /* * Class: org_lwjgl_devil_ILNative Modified: trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c =================================================================== --- trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c 2006-08-10 08:16:03 UTC (rev 2546) +++ trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c 2006-08-10 08:45:10 UTC (rev 2547) @@ -33,7 +33,7 @@ #include "org_lwjgl_fmod3_FMOD.h" #include "extfmod3.h" -static const char* VERSION = "1.0beta2"; +static const char* VERSION = "1.0beta3"; /* * Class: org_lwjgl_fmod3_FMOD This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-24 09:52:26
|
Revision: 2599 http://svn.sourceforge.net/java-game-lib/?rev=2599&view=rev Author: elias_naur Date: 2006-10-24 02:52:12 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Linux: Moved more event handling logic to java Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-10-24 08:33:09 UTC (rev 2598) +++ trunk/LWJGL/build.xml 2006-10-24 09:52:12 UTC (rev 2599) @@ -494,6 +494,7 @@ <target name="headers" description="invokes javah on java classes" depends="compile"> <!-- platform specific classes --> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes"> + <class name="org.lwjgl.opengl.LinuxEvent" /> <class name="org.lwjgl.opengl.LinuxMouse" /> <class name="org.lwjgl.opengl.LinuxKeyboard" /> <class name="org.lwjgl.opengl.LinuxDisplay" /> Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 08:33:09 UTC (rev 2598) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 09:52:12 UTC (rev 2599) @@ -82,11 +82,15 @@ private static int display_connection_usage_count = 0; + /** Event buffer */ + private final LinuxEvent event_buffer = new LinuxEvent(); + /** Current mode swithcing API */ private int current_displaymode_extension = NONE; /** Atom used for the pointer warp messages */ private long warp_atom; + private long delete_atom; private PeerInfo peer_info; @@ -268,8 +272,8 @@ } } - private static native long openDisplay() throws LWJGLException; - private static native void closeDisplay(long display); + static native long openDisplay() throws LWJGLException; + static native void closeDisplay(long display); private int getWindowMode(boolean fullscreen) throws LWJGLException { if (fullscreen) { @@ -552,6 +556,7 @@ lockAWT(); try { warp_atom = getWarpAtom(); + delete_atom = internAtom("WM_DELETE_WINDOW", false); current_displaymode_extension = getBestDisplayModeExtension(); if (current_displaymode_extension == NONE) throw new LWJGLException("No display mode extension is available"); @@ -629,18 +634,56 @@ return peer_info; } + private void processEvents() { + while (LinuxEvent.getPending(getDisplay()) > 0) { + event_buffer.nextEvent(getDisplay()); + long event_window = event_buffer.getWindow(); + if (event_window != getWindow()) + continue; + if (event_buffer.filterEvent(event_window)) + continue; + switch (event_buffer.getType()) { + case LinuxEvent.ClientMessage: + if (event_buffer.getClientMessageType() == warp_atom) { + handleWarpEvent(event_buffer.getClientData(0), event_buffer.getClientData(1)); + } else if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom)) + handleCloseEvent(); + break; + case LinuxEvent.MapNotify: + handleMapNotifyEvent(); + break; + case LinuxEvent.UnmapNotify: + handleUnmapNotifyEvent(); + break; + case LinuxEvent.Expose: + handleExposeEvent(); + break; + case LinuxEvent.ButtonPress: /* Fall through */ + case LinuxEvent.ButtonRelease: + handleButtonEvent(event_buffer.getButtonTime(), event_buffer.getButtonType(), event_buffer.getButtonButton(), event_buffer.getButtonState()); + break; + case LinuxEvent.MotionNotify: + handlePointerMotionEvent(event_buffer.getButtonTime(), event_buffer.getButtonRoot(), event_buffer.getButtonXRoot(), event_buffer.getButtonYRoot(), event_buffer.getButtonX(), event_buffer.getButtonY(), event_buffer.getButtonState()); + break; + case LinuxEvent.KeyPress: /* Fall through */ + case LinuxEvent.KeyRelease: + handleKeyEvent(event_buffer.getKeyAddress(), event_buffer.getKeyTime(), event_buffer.getKeyType(), event_buffer.getKeyKeyCode(), event_buffer.getKeyState()); + break; + default: + break; + } + } + } + public void update() { lockAWT(); try { - nUpdate(getDisplay(), getWindow(), warp_atom); + processEvents(); checkInput(); - } catch (LWJGLException e) { - LWJGLUtil.log("Caught exception while processing messages: " + e); } finally { unlockAWT(); } } - private native void nUpdate(long display, long window, long warp_atom) throws LWJGLException; public void reshape(int x, int y, int width, int height) { lockAWT(); @@ -1023,7 +1066,6 @@ private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height); - /* Callbacks from nUpdate() */ private void handleButtonEvent(long millis, int type, int button, int state) { if (mouse != null) mouse.handleButtonEvent(grab, millis, type, (byte)button); Added: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java 2006-10-24 09:52:12 UTC (rev 2599) @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.nio.ByteBuffer; + +/** + * Wrapper class for X11 events. + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2286 $ + * $Id: LinuxPeerInfo.java 2286 2006-03-23 19:32:21Z matzon $ + */ +final class LinuxEvent { + public final static int KeyPress = 2; + public final static int KeyRelease = 3; + public final static int ButtonPress = 4; + public final static int ButtonRelease = 5; + public final static int MotionNotify = 6; + public final static int UnmapNotify = 18; + public final static int MapNotify = 19; + public final static int Expose = 12; + public final static int ClientMessage = 33; + + private final ByteBuffer event_buffer; + + public LinuxEvent() { + this.event_buffer = createEventBuffer(); + } + private static native ByteBuffer createEventBuffer(); + + public final static native int getPending(long display); + + public final boolean filterEvent(long window) { + return nFilterEvent(event_buffer, window); + } + private static native boolean nFilterEvent(ByteBuffer event_buffer, long window); + + public final void nextEvent(long display) { + nNextEvent(display, event_buffer); + } + private static native void nNextEvent(long display, ByteBuffer event_buffer); + + public final int getType() { + return nGetType(event_buffer); + } + private static native int nGetType(ByteBuffer event_buffer); + + public final long getWindow() { + return nGetWindow(event_buffer); + } + private static native long nGetWindow(ByteBuffer event_buffer); + + /* ClientMessage methods */ + + public final long getClientMessageType() { + return nGetClientMessageType(event_buffer); + } + private static native long nGetClientMessageType(ByteBuffer event_buffer); + + public final int getClientData(int index) { + return nGetClientData(event_buffer, index); + } + private static native int nGetClientData(ByteBuffer event_buffer, int index); + + public final int getClientFormat() { + return nGetClientFormat(event_buffer); + } + private static native int nGetClientFormat(ByteBuffer event_buffer); + + /* Button methods */ + + public final long getButtonTime() { + return nGetButtonTime(event_buffer); + } + private static native long nGetButtonTime(ByteBuffer event_buffer); + + public final int getButtonState() { + return nGetButtonState(event_buffer); + } + private static native int nGetButtonState(ByteBuffer event_buffer); + + public final int getButtonType() { + return nGetButtonType(event_buffer); + } + private static native int nGetButtonType(ByteBuffer event_buffer); + + public final int getButtonButton() { + return nGetButtonButton(event_buffer); + } + private static native int nGetButtonButton(ByteBuffer event_buffer); + + public final long getButtonRoot() { + return nGetButtonRoot(event_buffer); + } + private static native long nGetButtonRoot(ByteBuffer event_buffer); + + public final int getButtonXRoot() { + return nGetButtonXRoot(event_buffer); + } + private static native int nGetButtonXRoot(ByteBuffer event_buffer); + + public final int getButtonYRoot() { + return nGetButtonYRoot(event_buffer); + } + private static native int nGetButtonYRoot(ByteBuffer event_buffer); + + public final int getButtonX() { + return nGetButtonX(event_buffer); + } + private static native int nGetButtonX(ByteBuffer event_buffer); + + public final int getButtonY() { + return nGetButtonY(event_buffer); + } + private static native int nGetButtonY(ByteBuffer event_buffer); + + /* Key methods */ + + public final long getKeyAddress() { + return nGetKeyAddress(event_buffer); + } + private static native int nGetKeyAddress(ByteBuffer event_buffer); + + public final long getKeyTime() { + return nGetKeyTime(event_buffer); + } + private static native int nGetKeyTime(ByteBuffer event_buffer); + + public final int getKeyType() { + return nGetKeyType(event_buffer); + } + private static native int nGetKeyType(ByteBuffer event_buffer); + + public final int getKeyKeyCode() { + return nGetKeyKeyCode(event_buffer); + } + private static native int nGetKeyKeyCode(ByteBuffer event_buffer); + + public final int getKeyState() { + return nGetKeyState(event_buffer); + } + private static native int nGetKeyState(ByteBuffer event_buffer); +} Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-24 08:33:09 UTC (rev 2598) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-24 09:52:12 UTC (rev 2599) @@ -69,7 +69,6 @@ static GLXWindow glx_window = None; -static Atom delete_atom; static Colormap cmap; static int current_depth; static Pixmap current_icon_pixmap; @@ -158,73 +157,6 @@ return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY; } -static void handleMessages(JNIEnv *env, jobject disp_obj, Display *disp, Window window, Atom warp_atom) { - XEvent event; - jclass disp_class = (*env)->GetObjectClass(env, disp_obj); - if (disp_class == NULL) - return; - jmethodID handleKeyEvent_method = (*env)->GetMethodID(env, disp_class, "handleKeyEvent", "(JJIII)V"); - if (handleKeyEvent_method == NULL) - return; - jmethodID handleButtonEvent_method = (*env)->GetMethodID(env, disp_class, "handleButtonEvent", "(JIII)V"); - if (handleButtonEvent_method == NULL) - return; - jmethodID handlePointerMotionEvent_method = (*env)->GetMethodID(env, disp_class, "handlePointerMotionEvent", "(JJIIIII)V"); - if (handlePointerMotionEvent_method == NULL) - return; - jmethodID handleWarpEvent_method = (*env)->GetMethodID(env, disp_class, "handleWarpEvent", "(II)V"); - if (handleWarpEvent_method == NULL) - return; - jmethodID handleMapNotifyEvent_method = (*env)->GetMethodID(env, disp_class, "handleMapNotifyEvent", "()V"); - if (handleMapNotifyEvent_method == NULL) - return; - jmethodID handleUnmapNotifyEvent_method = (*env)->GetMethodID(env, disp_class, "handleUnmapNotifyEvent", "()V"); - if (handleUnmapNotifyEvent_method == NULL) - return; - jmethodID handleExposeEvent_method = (*env)->GetMethodID(env, disp_class, "handleExposeEvent", "()V"); - if (handleExposeEvent_method == NULL) - return; - jmethodID handleCloseEvent_method = (*env)->GetMethodID(env, disp_class, "handleCloseEvent", "()V"); - if (handleCloseEvent_method == NULL) - return; - while (!(*env)->ExceptionOccurred(env) && XPending(disp) > 0) { - XNextEvent(disp, &event); - if (XFilterEvent(&event, None) == True) - continue; - // Ignore events from old windows - if (event.xany.window != window) - continue; - switch (event.type) { - case ClientMessage: - if (event.xclient.message_type == warp_atom) { - (*env)->CallVoidMethod(env, disp_obj, handleWarpEvent_method, (jint)event.xclient.data.l[0], (jint)event.xclient.data.l[1]); - } else if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom)) - (*env)->CallVoidMethod(env, disp_obj, handleCloseEvent_method); - break; - case MapNotify: - (*env)->CallVoidMethod(env, disp_obj, handleMapNotifyEvent_method); - break; - case UnmapNotify: - (*env)->CallVoidMethod(env, disp_obj, handleUnmapNotifyEvent_method); - break; - case Expose: - (*env)->CallVoidMethod(env, disp_obj, handleExposeEvent_method); - break; - case ButtonPress: /* Fall through */ - case ButtonRelease: - (*env)->CallVoidMethod(env, disp_obj, handleButtonEvent_method, (jlong)event.xbutton.time, (jint)event.xbutton.type, (jint)event.xbutton.button, (jint)event.xbutton.state); - break; - case MotionNotify: - (*env)->CallVoidMethod(env, disp_obj, handlePointerMotionEvent_method, (jlong)event.xbutton.time, (jlong)event.xbutton.root, (jint)event.xbutton.x_root, (jint)event.xbutton.y_root, (jint)event.xbutton.x, (jint)event.xbutton.y, (jint)event.xbutton.state); - break; - case KeyPress: - case KeyRelease: - (*env)->CallVoidMethod(env, disp_obj, handleKeyEvent_method, (jlong)(intptr_t)&(event.xkey), (jlong)event.xkey.time, (jint)event.xkey.type, (jint)event.xkey.keycode, (jint)event.xkey.state); - break; - } - } -} - static void setWindowTitle(Display *disp, Window window, const char *title) { XStoreName(disp, window, title); } @@ -356,7 +288,7 @@ size_hints->max_height = height; XSetWMNormalHints(disp, win, size_hints); XFree(size_hints); - delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False); + Atom delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False); XSetWMProtocols(disp, win, &delete_atom, 1); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); @@ -373,13 +305,6 @@ return win; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display, jlong window_ptr, jlong warp_atom_ptr) { - Display *disp = (Display *)(intptr_t)display; - Window window = (Window)window_ptr; - Atom warp_atom = (Atom)warp_atom_ptr; - handleMessages(env, disp_obj, disp, window, warp_atom); -} - JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) { Display *disp = (Display *)(intptr_t)display; X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); Added: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c (rev 0) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c 2006-10-24 09:52:12 UTC (rev 2599) @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id: org_lwjgl_opengl_LinuxEvent.c 2598 2006-10-24 08:33:09Z elias_naur $ + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2598 $ + */ + +#include <X11/X.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <jni.h> +#include "common_tools.h" +#include "org_lwjgl_opengl_LinuxEvent.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxEvent_createEventBuffer(JNIEnv *env, jclass unused) { + return newJavaManagedByteBuffer(env, sizeof(XEvent)); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_getPending(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + return XPending(disp); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxEvent_nFilterEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Window window = (Window)window_ptr; + return XFilterEvent(event, window) == True ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nNextEvent(JNIEnv *env, jclass unused, jlong display_ptr, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Display *disp = (Display *)(intptr_t)display_ptr; + XNextEvent(disp, event); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->type; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetWindow(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xany.window; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientMessageType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xclient.message_type; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientData(JNIEnv *env, jclass unused, jobject event_buffer, jint index) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xclient.data.l[index]; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientFormat(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xclient.format; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonTime(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.time; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonState(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.state; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.type; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonButton(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.button; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonRoot(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.root; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonXRoot(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.x_root; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonYRoot(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.y_root; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonX(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.x; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonY(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.y; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return (jlong)(intptr_t)&(event->xkey); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyTime(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.time; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.type; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyKeyCode(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.keycode; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyState(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.state; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-26 20:20:14
|
Revision: 2609 http://svn.sourceforge.net/java-game-lib/?rev=2609&view=rev Author: elias_naur Date: 2006-10-26 13:19:40 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Added org.lwjgl.opengl.AWTInputAdapter which enabled use of Mouse and Keyboard with AWTGLCanvases. Programs can now avoid implementing AWT input processing and access the mouse grabbing features from both Display and AWTGLCanvas. See org.lwjgl.test.opengl.awt.AWTInputAdapterTest for an example. Note: This commit is the linux and generic AWT imlementation and can still change a lot while implementing windows and mac os x. Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxPeerInfo.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/build.xml 2006-10-26 20:19:40 UTC (rev 2609) @@ -494,6 +494,7 @@ <target name="headers" description="invokes javah on java classes" depends="compile"> <!-- platform specific classes --> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes"> + <class name="org.lwjgl.opengl.LinuxAWTInput" /> <class name="org.lwjgl.opengl.LinuxEvent" /> <class name="org.lwjgl.opengl.LinuxMouse" /> <class name="org.lwjgl.opengl.LinuxKeyboard" /> Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -42,7 +42,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.Sys; import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.DisplayImplementation; +import org.lwjgl.opengl.InputImplementation; /** * <br> @@ -264,7 +264,7 @@ /** One time initialization */ private static boolean initialized; - private static DisplayImplementation implementation; + private static InputImplementation implementation; /** * Keyboard cannot be constructed. @@ -283,25 +283,33 @@ } /** - * "Create" the keyboard. The display must first have been created. The - * reason for this is so the keyboard has a window to "focus" in. + * "Create" the keyboard with the given implementation. This is used + * reflectively from AWTInputAdapter. * * @throws LWJGLException if the keyboard could not be created for any reason */ - public static void create() throws LWJGLException { - if (!Display.isCreated()) - throw new IllegalStateException("Display must be created before you can create Keyboard"); + private static void create(InputImplementation impl) throws LWJGLException { + if (created) + throw new IllegalStateException("Destroy the Keyboard first."); if (!initialized) initialize(); - if (created) - return; - implementation = Mouse.getImplementation(); + implementation = impl; implementation.createKeyboard(); created = true; readBuffer = ByteBuffer.allocate(EVENT_SIZE*BUFFER_SIZE); reset(); } + /** + * "Create" the keyboard. The display must first have been created. The + * reason for this is so the keyboard has a window to "focus" in. + * + * @throws LWJGLException if the keyboard could not be created for any reason + */ + public static void create() throws LWJGLException { + create(Mouse.createImplementation()); + } + private static void reset() { readBuffer.limit(0); for (int i = 0; i < keyDownBuffer.remaining(); i++) Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -40,8 +40,8 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.Sys; -import org.lwjgl.opengl.DisplayImplementation; import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.InputImplementation; import java.lang.reflect.Method; import java.security.AccessController; @@ -57,7 +57,7 @@ * n buttons supported, n being a native limit. A scrolly wheel is also * supported, if one such is available. Movement is reported as delta from * last position or as an absolute position. If the window has been created - * the absolute position will be clamped to 0 - Display (width | height) + * the absolute position will be clamped to 0 - width | height. * * @author cix_foo <ci...@us...> * @author elias_naur <eli...@us...> @@ -134,10 +134,10 @@ private static boolean isGrabbed; - private static DisplayImplementation implementation; + private static InputImplementation implementation; - /** Whether we're running windows - which need to manually update cursor animation */ - private static final boolean isWindows = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS; + /** Whether we're running windows - which need to manually update cursor animation */ + private static final boolean isWindows = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS; /** * Mouse cannot be constructed. @@ -220,13 +220,19 @@ readBuffer.position(readBuffer.limit()); } - static DisplayImplementation getImplementation() { + static InputImplementation getImplementation() { + return implementation; + } + + static InputImplementation createImplementation() { + if (!Display.isCreated()) throw new IllegalStateException("Display must be created."); + /* Use reflection since we can't make Display.getImplementation * public */ try { - return (DisplayImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception{ + return (InputImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null); getImplementation_method.setAccessible(true); return getImplementation_method.invoke(null, null); @@ -238,19 +244,17 @@ } /** - * "Create" the mouse. The display must first have been created. - * Initially, the mouse is not grabbed and the delta values are reported - * with respect to the center of the display. + * "Create" the mouse with the given custom implementation. This is used + * reflectively by AWTInputAdapter. * * @throws LWJGLException if the mouse could not be created for any reason */ - public static void create() throws LWJGLException { - if (!Display.isCreated()) throw new IllegalStateException("Display must be created prior to creating mouse"); - + private static void create(InputImplementation impl) throws LWJGLException { + if (created) + throw new IllegalStateException("Destroy the mouse first."); if (!initialized) initialize(); - if (created) return; - implementation = getImplementation(); + implementation = impl; implementation.createMouse(); hasWheel = implementation.hasWheel(); created = true; @@ -259,7 +263,7 @@ buttonCount = implementation.getButtonCount(); buttons = BufferUtils.createByteBuffer(buttonCount); coord_buffer = BufferUtils.createIntBuffer(3); - if (currentCursor != null) + if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0) setNativeCursor(currentCursor); readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE); readBuffer.limit(0); @@ -267,6 +271,17 @@ } /** + * "Create" the mouse. The display must first have been created. + * Initially, the mouse is not grabbed and the delta values are reported + * with respect to the center of the display. + * + * @throws LWJGLException if the mouse could not be created for any reason + */ + public static void create() throws LWJGLException { + create(createImplementation()); + } + + /** * @return true if the mouse has been created */ public static boolean isCreated() { @@ -327,8 +342,8 @@ x = poll_coord1; y = poll_coord2; } - x = Math.min(Display.getDisplayMode().getWidth() - 1, Math.max(0, x)); - y = Math.min(Display.getDisplayMode().getHeight() - 1, Math.max(0, y)); + x = Math.min(implementation.getWidth() - 1, Math.max(0, x)); + y = Math.min(implementation.getHeight() - 1, Math.max(0, y)); dwheel += poll_dwheel; read(); } @@ -404,8 +419,8 @@ event_x = new_event_x; event_y = new_event_y; } - event_x = Math.min(Display.getDisplayMode().getWidth() - 1, Math.max(0, event_x)); - event_y = Math.min(Display.getDisplayMode().getHeight() - 1, Math.max(0, event_y)); + event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x)); + event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y)); event_dwheel = readBuffer.getInt(); event_nanos = readBuffer.getLong(); return true; @@ -476,8 +491,8 @@ } /** - * Retrieves the absolute position. If the Display has been created - * x will be clamped to 0...width-1. + * Retrieves the absolute position. It will be clamped to + * 0...width-1. * * @return Absolute x axis position of mouse */ @@ -486,8 +501,8 @@ } /** - * Retrieves the absolute position. If the Display has been created - * y will be clamped to 0...height-1. + * Retrieves the absolute position. It will be clamped to + * 0...height-1. * * @return Absolute y axis position of mouse */ Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -46,7 +46,7 @@ /** * Return an opaque handle to the canvas peer information required to create a context from it. */ - public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException; + PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException; /** * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. @@ -54,5 +54,13 @@ * @return A GraphicsConfiguration matching the given GraphicsConfiguration and PixelFormat. * @throws LWJGLException if no suitable configuration could be found. */ - public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException; + GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException; + + /** + * Create an AWTCanvasInputImplementation for a specified AWTGLCanvas. + * + * @return A platform specific AWTCanvasInputImplementation. + * @param canvas An AWTGLCanvas + */ + AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException; } Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002-2006 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2286 $ + * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $ + */ +interface AWTCanvasInputImplementation extends InputImplementation { + void processInput(PeerInfo peer_info); + void update(); + void init(); + void destroy(); +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -81,6 +81,9 @@ /** Tracks whether initGL() needs to be called */ private boolean first_run; + /** Track the input adapter, if any */ + private volatile AWTCanvasInputImplementation awt_input; + static { Sys.initialize(); String class_name; @@ -109,7 +112,17 @@ } } + /** + * Used from AWTInputAdapter + */ + static AWTCanvasImplementation getImplementation() { + return implementation; + } + void setInput(AWTCanvasInputImplementation awt_input) { + this.awt_input = awt_input; + } + private void setUpdate() { synchronized(SYNC_LOCK) { update_context = true; @@ -271,8 +284,9 @@ */ public final void paint(Graphics g) { try { - if (peer_info == null) + if (peer_info == null) { this.peer_info = implementation.createPeerInfo(this, pixel_format); + } peer_info.lockAndGetHandle(); try { if (context == null) { @@ -288,6 +302,9 @@ context.update(); update_context = false; } + AWTCanvasInputImplementation current_input = awt_input; + if (current_input != null) + current_input.processInput(peer_info); if (first_run) { first_run = false; initGL(); Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2002-2006 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Mouse; +import org.lwjgl.input.Keyboard; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; + +import java.lang.reflect.Method; + +import java.awt.Canvas; + +/** + * This is the static class for using LWJGL input (Mouse and Keyboard) + * with an AWTGLCanvas. + * + * @author Elias Naur + * @version $Revision: 2286 $ + * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $ + */ +public final class AWTInputAdapter { + private static AWTCanvasInputImplementation awt_input; + + /** + * Create AWTInputAdapter with the specified AWTGLCanvas. Use + * update() to receive input. + * + * @param canvas The canvas to receive input from. + */ + public static synchronized void create(AWTGLCanvas canvas) throws LWJGLException { + if (awt_input != null) + throw new IllegalStateException("You need to destroy() the adapter."); + awt_input = AWTGLCanvas.getImplementation().createInput(canvas); + // Invoke Mouse.create(awt_input) and Keyboard.create(awt_input) + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + private void invokeCreate(Class input_class) throws Exception { + Method create_method = input_class.getDeclaredMethod("create", new Class[]{InputImplementation.class}); + create_method.setAccessible(true); + create_method.invoke(null, new Object[]{awt_input}); + } + + public Object run() throws Exception { + invokeCreate(Mouse.class); + invokeCreate(Keyboard.class); + return null; + } + }); + } catch (PrivilegedActionException e) { + Throwable cause = e.getCause(); + if (cause instanceof LWJGLException) + throw (LWJGLException)cause; + else + throw new Error(cause); + } + awt_input.init(); + } + + public static synchronized void destroy() { + if (awt_input != null) { + awt_input.destroy(); + awt_input = null; + } + } + + public static synchronized void update() { + if (awt_input == null) + throw new IllegalStateException("You need to create() the adapter."); + awt_input.update(); + Display.pollDevices(); + } +} Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.nio.IntBuffer; +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +import java.awt.event.FocusListener; +import java.awt.Cursor; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2586 $ + * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ + */ +abstract class AbstractAWTInput implements AWTCanvasInputImplementation { + private AWTGLCanvas canvas; + + private volatile int current_height; + private volatile int current_width; + private KeyboardEventQueue keyboard_queue; + private MouseEventQueue mouse_queue; + private volatile boolean grab; + + protected AbstractAWTInput(AWTGLCanvas canvas) throws LWJGLException { + this.canvas = canvas; + } + + public synchronized void grabMouse(boolean grab) { + this.grab = grab; + if (mouse_queue != null) + mouse_queue.setGrabbed(grab); + } + + protected boolean isGrabbed() { + return grab; + } + + protected final AWTGLCanvas getCanvas() { + return canvas; + } + + public final void init() { + canvas.setInput(this); + } + + public synchronized void destroy() { + canvas.setInput(null); + canvas = null; + } + + public final int getWidth() { + return current_width; + } + + public final int getHeight() { + return current_height; + } + + public synchronized void processInput(PeerInfo peer_info) { + current_width = canvas.getWidth(); + current_height = canvas.getHeight(); + } + + public boolean hasWheel() { + return AWTUtil.hasWheel(); + } + + public int getButtonCount() { + return AWTUtil.getButtonCount(); + } + + public void createMouse() throws LWJGLException { + mouse_queue = new MouseEventQueue(canvas); + mouse_queue.register(); + } + + public void destroyMouse() { + mouse_queue.unregister(); + } + + public int getNativeCursorCapabilities() { + return AWTUtil.getNativeCursorCapabilities(); + } + + public void setCursorPosition(int x, int y) { + AWTUtil.setCursorPosition(canvas, x, y); + } + + public void setNativeCursor(Object handle) throws LWJGLException { + canvas.setCursor((Cursor)handle); + } + + public int getMinCursorSize() { + return AWTUtil.getMinCursorSize(); + } + + public int getMaxCursorSize() { + return AWTUtil.getMaxCursorSize(); + } + + public synchronized void createKeyboard() throws LWJGLException { + keyboard_queue = new KeyboardEventQueue(canvas); + keyboard_queue.register(); + } + + public synchronized void destroyKeyboard() { + if (keyboard_queue != null) + keyboard_queue.unregister(); + } + + public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays); + } + + public void destroyCursor(Object cursor_handle) { + } + + public synchronized void readMouse(ByteBuffer buffer) { + mouse_queue.copyEvents(buffer); + } + + public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + mouse_queue.poll(coord_buffer, buttons); + } + + public synchronized void readKeyboard(ByteBuffer buffer) { + keyboard_queue.copyEvents(buffer); + } + + public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { + keyboard_queue.poll(keyDownBuffer); + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -44,7 +44,7 @@ import org.lwjgl.LWJGLException; -public interface DisplayImplementation { +interface DisplayImplementation extends InputImplementation { void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; @@ -124,88 +124,6 @@ */ DisplayMode[] getAvailableDisplayModes() throws LWJGLException; - /* - * Mouse methods - */ - /** Query of wheel support */ - boolean hasWheel(); - - /** Query of button count */ - int getButtonCount(); - - /** - * Method to create the mouse. - */ - void createMouse() throws LWJGLException; - - /** - * Method the destroy the mouse - */ - void destroyMouse(); - - /** - * Method to poll the mouse - */ - void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); - - /** - * Method to read the keyboard buffer - */ - void readMouse(ByteBuffer buffer); - - void grabMouse(boolean grab); - - /** - * Function to determine native cursor support - */ - int getNativeCursorCapabilities(); - - /** Method to set the native cursor position */ - void setCursorPosition(int x, int y); - - /** Method to set the native cursor */ - void setNativeCursor(Object handle) throws LWJGLException; - - /** Method returning the minimum cursor size */ - int getMinCursorSize(); - - /** Method returning the maximum cursor size */ - int getMaxCursorSize(); - - /* - * Keyboard methods - */ - - /** - * Method to create the keyboard - */ - void createKeyboard() throws LWJGLException; - - /** - * Method to destroy the keyboard - */ - void destroyKeyboard(); - - /** - * Method to poll the keyboard. - * - * @param keyDownBuffer the address of a 256-byte buffer to place - * key states in. - */ - void pollKeyboard(ByteBuffer keyDownBuffer); - - /** - * Method to read the keyboard buffer - */ - void readKeyboard(ByteBuffer buffer); - -// int isStateKeySet(int key); - - /** Native cursor handles */ - Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException; - - void destroyCursor(Object cursor_handle); - /* Pbuffer */ int getPbufferCapabilities(); Added: trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the input implementation interface. Mouse and Keyboard delegates + * to implementors of this interface. There is one InputImplementation + * for each supported platform. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.LWJGLException; + +public interface InputImplementation { + /* + * Mouse methods + */ + /** Query of wheel support */ + boolean hasWheel(); + + /** Query of button count */ + int getButtonCount(); + + /** + * Method to create the mouse. + */ + void createMouse() throws LWJGLException; + + /** + * Method the destroy the mouse + */ + void destroyMouse(); + + /** + * Method to poll the mouse + */ + void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); + + /** + * Method to read the keyboard buffer + */ + void readMouse(ByteBuffer buffer); + + void grabMouse(boolean grab); + + /** + * Function to determine native cursor support + */ + int getNativeCursorCapabilities(); + + /** Method to set the native cursor position */ + void setCursorPosition(int x, int y); + + /** Method to set the native cursor */ + void setNativeCursor(Object handle) throws LWJGLException; + + /** Method returning the minimum cursor size */ + int getMinCursorSize(); + + /** Method returning the maximum cursor size */ + int getMaxCursorSize(); + + /* + * Keyboard methods + */ + + /** + * Method to create the keyboard + */ + void createKeyboard() throws LWJGLException; + + /** + * Method to destroy the keyboard + */ + void destroyKeyboard(); + + /** + * Method to poll the keyboard. + * + * @param keyDownBuffer the address of a 256-byte buffer to place + * key states in. + */ + void pollKeyboard(ByteBuffer keyDownBuffer); + + /** + * Method to read the keyboard buffer + */ + void readKeyboard(ByteBuffer buffer); + +// int isStateKeySet(int key); + + /** Native cursor handles */ + Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException; + + void destroyCursor(Object cursor_handle); + + int getWidth(); + + int getHeight(); +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -32,8 +32,7 @@ package org.lwjgl.opengl; /** - * A java implementation of a LWJGL compatible Keyboard event queue. - * Currently only used by the Mac OS X implementation. + * An AWT implementation of a LWJGL compatible Keyboard event queue. * @author elias_naur */ Added: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.nio.IntBuffer; +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +import java.awt.event.FocusEvent; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2586 $ + * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ + */ +final class LinuxAWTInput extends AbstractAWTInput { + private final long display; + private final long input_window; + private final LinuxEvent event = new LinuxEvent(); + + private long cached_window; + private LinuxMouse cached_mouse; +// private LinuxKeyboard cached_keyboard; + private long blank_cursor = LinuxDisplay.None; + private boolean input_grabbed; + private boolean input_released; + + public LinuxAWTInput(AWTGLCanvas canvas) throws LWJGLException { + super(canvas); + LinuxDisplay.lockAWT(); + try { + this.display = LinuxDisplay.openDisplay(); + this.input_window = createInputOnlyWindow(display, LinuxDisplay.nGetDefaultScreen(display)); + } finally { + LinuxDisplay.unlockAWT(); + } + } + private static native long createInputOnlyWindow(long display, int screen); + + public synchronized void destroy() { + super.destroy(); + LinuxDisplay.lockAWT(); + try { + destroyCursor(); + LinuxDisplay.nDestroyWindow(display, input_window); + LinuxDisplay.closeDisplay(display); + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private void ungrabInputLocked() { + LinuxDisplay.lockAWT(); + try { + ungrabInput(); + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private void ungrabInput() { + if (input_grabbed) { +// LinuxDisplay.nUngrabKeyboard(display); + LinuxDisplay.nUngrabPointer(display); + LinuxDisplay.nSetRepeatMode(display, LinuxDisplay.AutoRepeatModeDefault); + input_grabbed = false; + } + } + + private void grabInput(long window) { + if (!input_grabbed) { +// int res1 = LinuxDisplay.nGrabKeyboard(display, window); + LinuxDisplay.nSetRepeatMode(display, LinuxDisplay.AutoRepeatModeOff); + int res2 = LinuxDisplay.nGrabPointer(display, window, blank_cursor); + if (/*res1 == LinuxDisplay.GrabSuccess && */res2 == LinuxDisplay.GrabSuccess) + input_grabbed = true; + } + } + + private final void destroyCursor() { + if (blank_cursor != LinuxDisplay.None) + LinuxDisplay.nDestroyCursor(display, blank_cursor); + } + + public synchronized void processInput(PeerInfo peer_info) { + super.processInput(peer_info); + LinuxDisplay.lockAWT(); + try { + LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info; + long new_window = linux_peer_info.getDrawable(); + if (new_window != cached_window) { + ungrabInput(); + cached_window = new_window; + try { + cached_mouse = new LinuxMouse(display, new_window, input_window); +// cached_keyboard = new LinuxKeyboard(display, new_window); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to create input devices: " + e); + } + destroyCursor(); + this.blank_cursor = LinuxDisplay.nCreateBlankCursor(display, new_window); + } + checkFocus(); + if (!input_grabbed && shouldGrab()) + grabInput(new_window); + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private void checkFocus() { + if (getCanvas().hasFocus()) { + input_released = false; + } else { + input_released = true; + ungrabInput(); + } + } + + private boolean shouldGrab() { + return !input_released && isGrabbed(); + } + + public synchronized void update() { + LinuxDisplay.lockAWT(); + try { + while (LinuxEvent.getPending(display) > 0) { + event.nextEvent(display); + if (shouldGrab()) { + long event_window = event.getWindow(); + boolean processed = event.filterEvent(event_window) || + cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event)/* || + cached_keyboard.filterEvent(event)*/; + } + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + + public synchronized void grabMouse(boolean grab) { + if (grab != isGrabbed()) { + super.grabMouse(grab); + if (cached_mouse != null) + cached_mouse.changeGrabbed(grab, shouldGrab()); + ungrabInputLocked(); + } + } + +/* public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { + if (isGrabbed()) { + LinuxDisplay.lockAWT(); + try { + if (cached_keyboard != null) + cached_keyboard.poll(keyDownBuffer); + } finally { + LinuxDisplay.unlockAWT(); + } + } else + super.pollKeyboard(keyDownBuffer); + } + + public synchronized void readKeyboard(ByteBuffer buffer) { + if (isGrabbed()) { + LinuxDisplay.lockAWT(); + try { + if (cached_keyboard != null) + cached_keyboard.read(buffer); + } finally { + LinuxDisplay.unlockAWT(); + } + } else + super.readKeyboard(buffer); + } +*/ + public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + if (isGrabbed()) { + LinuxDisplay.lockAWT(); + try { + if (cached_mouse != null) + cached_mouse.poll(isGrabbed(), coord_buffer, buttons); + } finally { + LinuxDisplay.unlockAWT(); + } + } else + super.pollMouse(coord_buffer, buttons); + } + + public synchronized void readMouse(ByteBuffer buffer) { + if (isGrabbed()) { + LinuxDisplay.lockAWT(); + try { + if (cached_mouse != null) + cached_mouse.read(buffer); + } finally { + LinuxDisplay.unlockAWT(); + } + } else + super.readMouse(buffer); + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -119,4 +119,8 @@ } } private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException; + + public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { + return new LinuxAWTInput(canvas); + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -50,9 +50,9 @@ final class LinuxDisplay implements DisplayImplementation { /* X11 constants */ public final static int GrabSuccess = 0; - private final static int AutoRepeatModeOff = 0; - private final static int AutoRepeatModeOn = 1; - private final static int AutoRepeatModeDefault = 2; + public final static int AutoRepeatModeOff = 0; + public final static int AutoRepeatModeOn = 1; + public final static int AutoRepeatModeDefault = 2; public final static int None = 0; /** Window mode enum */ @@ -754,7 +754,7 @@ releaseInput(); } } - private static native long nGetInputFocus(long display); + static native long nGetInputFocus(long display); private void releaseInput() { if (isLegacyFullscreen() || input_released) @@ -789,7 +789,7 @@ } } } - private static native void nSetRepeatMode(long display, int mode); + static native void nSetRepeatMode(long display, int mode); public void grabMouse(boolean new_grab) { lockAWT(); @@ -1054,4 +1054,12 @@ } private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height); + + public int getWidth() { + return Display.getDisplayMode().getWidth(); + } + + public int getHeight() { + return Display.getDisplayMode().getHeight(); + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -44,4 +44,14 @@ super(createHandle()); } private static native ByteBuffer createHandle(); + + public final long getDisplay() { + return nGetDisplay(getHandle()); + } + private static native long nGetDisplay(ByteBuffer handle); + + public final long getDrawable() { + return nGetDrawable(getHandle()); + } + private static native long nGetDrawable(ByteBuffer handle); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -62,4 +62,8 @@ */ return null; } + + public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { + throw new UnsupportedOperationException(); + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -303,7 +303,7 @@ public void createMouse() throws LWJGLException { MacOSXGLCanvas canvas = frame.getCanvas(); - this.mouse_queue = new MouseEventQueue(canvas); + this.mouse_queue = new MacOSXMouseEventQueue(canvas); mouse_queue.register(); } @@ -520,4 +520,12 @@ return 1; } + + public int getWidth() { + return Display.getDisplayMode().getWidth(); + } + + public int getHeight() { + return Display.getDisplayMode().getHeight(); + } } Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java (from rev 2607, trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * An AWT implementation of a LWJGL compatible Mouse event queue. + * @author elias_naur + */ + +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.awt.Component; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Mouse; + +final class MacOSXMouseEventQueue extends MouseEventQueue { + private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2); + + MacOSXMouseEventQueue(Component component) { + super(component); + } + + protected void resetCursorToCenter() { + super.resetCursorToCenter(); + /* Clear accumulated deltas */ + ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); + } + + protected void updateDeltas(long nanos) { + super.updateDeltas(nanos); + synchronized ( this ) { + ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); + int dx = delta_buffer.get(0); + int dy = -delta_buffer.get(1); + if ( dx != 0 || dy != 0 ) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + addDelta(dx, dy); + } + } + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -48,7 +48,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; -final class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener { +class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener { private static final int WHEEL_SCALE = 120; public static final int NUM_BUTTONS = 3; @@ -56,7 +56,6 @@ private boolean grabbed; - private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2); /** The accumulated mouse deltas returned by poll() */ private int accum_dx; @@ -107,11 +106,9 @@ return component.getHeight() - 1 - y; } - private void resetCursorToCenter() { + protected void resetCursorToCenter() { clearEvents(); accum_dx = accum_dy = 0; - /* Clear accumulated deltas */ - ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); } private void putMouseEvent(byte button, byte state, int dz, long nanos) { @@ -121,7 +118,7 @@ putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); } - private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { event.clear(); event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); event.flip(); @@ -149,13 +146,17 @@ return; int dx = x - last_x; int dy = y - last_y; - accum_dx += dx; - accum_dy += dy; + addDelta(dx, dy); last_x = x; last_y = y; putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); } + protected void addDelta(int dx, int dy) { + accum_dx += dx; + accum_dy += dy; + } + public void mouseClicked(MouseEvent e) { } @@ -242,19 +243,7 @@ putMouseEvent((byte)-1, (byte)0, amount, nanos); } - private void updateDeltas(long nanos) { - if (!grabbed) - return; - synchronized ( this ) { - ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); - int dx = delta_buffer.get(0); - int dy = -delta_buffer.get(1); - if ( dx != 0 || dy != 0 ) { - putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); - accum_dx += dx; - accum_dy += dy; - } - } + protected void updateDeltas(long nanos) { } public void mouseWheelMoved(MouseWheelEvent e) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -65,6 +65,10 @@ }); } + public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { + throw new UnsupportedOperationException(); + } + public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException { return new WindowsAWTGLCanvasPeerInfo(canvas, pixel_format); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-26 19:41:15 UTC (rev 2608) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -589,4 +589,12 @@ return new WindowsDirectInput3(getDllInstance()); } } + + public int getWidth() { + return Display.getDisplayMode().getWidth(); + } + + public int getHeight() { + return Display.getDisplayMode().getHeight(); + } } Added: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2006-10-26 20:19:40 UTC (rev 2609) @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2002-2005 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.test.opengl.awt; + +import java.awt.Frame; +import java.awt.Color; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.FloatBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Mouse; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.ARBTransposeMatrix; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.AWTInputAdapter; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; + +/** + * <p> + * Gears demo using AWTInputAdapter input + * <p> + * @version $Revision$ + * @author Brian Matzon <br...@ma...> + * @author Elias Naur <eli...@us...> + * $Id$ + */ +public class AWTInputAdapterTest extends Frame { + /** AWT GL canvas */ + private AWTGLCanvas canvas0; + + private float view_rotx = 20.0f; + + private float view_roty = 30.0f; + + private float view_rotz = 0.0f; + + private int gear1; + + private int gear2; + + private int gear3; + + private float angle = 0.0f; + + /** + * C'tor + */ + public AWTInputAdapterTest() throws LWJGLException { + setTitle("Gears"); + setSize(300, 300); + setBackground(Color.BLACK); + add(canvas0 = new AWTGLCanvas() { + long startTime = 0; + long fps = 0; + int current_width; + int current_height; + public void paintGL() { + + if(startTime == 0) { + setup(); + startTime = System.currentTimeMillis() + 5000; + } + + try { + angle += 2.0f; + if (getWidth() != current_width || getHeight() != current_height) { + current_width = getWidth(); + current_height = getHeight(); + GL11.glViewport(0, 0, current_width, current_height); + } + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glPushMatrix(); + GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.0f, -2.0f, 0.0f); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear1); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(3.1f, -2.0f, 0.0f); + GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear2); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.1f, 4.2f, 0.0f); + GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear3); + GL11.glPopMatrix(); + + GL11.glPopMatrix(); + swapBuffers(); + repaint(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + if (startTime > System.currentTimeMillis()) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " + + (fps / (timeUsed / 1000f))); + fps = 0; + } + AWTInputAdapter.update(); + while (Mouse.next()) { + view_roty += Mouse.getEventDX()*.1; + view_rotx -= Mouse.getEventDY()*.1; + } + while (Keyboard.next()) { + if (Keyboard.getEventKeyState()) { + switch (Keyboard.getEventKey()) { + case Keyboard.KEY_ESCAPE: + System.exit(0); + break; + case Keyboard.KEY_G: + Mouse.setGrabbed(!Mouse.isGrabbed()); + break; + default: + break; + } + } + if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE) + System.out.println("Typed: " + Keyboard.getEventCharacter()); + } + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) + view_rotx -= .1; + else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) + view_rotx += .1; + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) + view_roty -= .1; + else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) + view_roty += .1; + } + }); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + System.exit(0); + } + }); + AWTInputAdapter.create(canvas0); + canvas0.setFocusable(true); + canvas0.requestFocus(); + setResizable(true); + setVisible(true); + } + + private void setup() { + // setup ogl + FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); + FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); + FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); + FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); + pos.flip(); + red.flip(); + green.flip(); + blue.flip(); + + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + /* make the gears */ + gear1 = GL11.glGenLists(1); + GL11.glNewList(gear1, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + GL11.glEndList(); + + gear2 = GL11.glGenLists(1); + GL11.glNewList(gear2, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + GL11.glEndList(); + + gear3 = GL11.glGenLists(1); + GL11.glNewList(gear3, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + GL11.glEndList(); + + GL11.glEnable(GL11.GL_NORMALIZE); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + + System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing."); + System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + System.err.println(); + System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); + if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { + // --- not using extensions + GL11.glLoadIdentity(); + } else { + // --- using extensions + final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( + new float[] { 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 1}); + identityTranspose.fli... [truncated message content] |
From: <eli...@us...> - 2006-10-26 20:49:21
|
Revision: 2611 http://svn.sourceforge.net/java-game-lib/?rev=2611&view=rev Author: elias_naur Date: 2006-10-26 13:49:07 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Mac OS X: Moved mouse handling from MacOSXDisplay to MacOSXMouseEventQueue Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-10-26 20:33:40 UTC (rev 2610) +++ trunk/LWJGL/build.xml 2006-10-26 20:49:07 UTC (rev 2611) @@ -524,6 +524,7 @@ </javah> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes"> + <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" /> <class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" /> <class name="org.lwjgl.opengl.MacOSXPeerInfo" /> <class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" /> Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 20:33:40 UTC (rev 2610) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 20:49:07 UTC (rev 2611) @@ -69,7 +69,7 @@ private static final int GAMMA_LENGTH = 256; private MacOSXFrame frame; - private MouseEventQueue mouse_queue; + private MacOSXMouseEventQueue mouse_queue; private KeyboardEventQueue keyboard_queue; private java.awt.DisplayMode requested_mode; @@ -256,20 +256,11 @@ GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport); GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3)); } - if (frame.syncShouldWarpCursor()) { - warpCursor(); + if (frame.syncShouldWarpCursor() && mouse_queue != null) { + mouse_queue.warpCursor(); } } - private void warpCursor() { - if (mouse_queue != null && mouse_queue.isGrabbed()) { - Rectangle bounds = frame.syncGetBounds(); - int x = bounds.x + bounds.width/2; - int y = bounds.y + bounds.height/2; - nWarpCursor(x, y); - } - } - /** * This is an interface to the native Carbon call * SetSystemUIMode. It is used to hide the dock in a way @@ -286,8 +277,6 @@ private native void nHideUI(boolean hide); - native void getMouseDeltas(IntBuffer delta_buffer); - public void reshape(int x, int y, int width, int height) { frame.resize(x, y, width, height); } @@ -323,14 +312,8 @@ public void grabMouse(boolean grab) { mouse_queue.setGrabbed(grab); - warpCursor(); - nGrabMouse(grab); } - private native void nWarpCursor(int x, int y); - - private native void nGrabMouse(boolean grab); - public int getNativeCursorCapabilities() { return AWTUtil.getNativeCursorCapabilities(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-26 20:33:40 UTC (rev 2610) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-26 20:49:07 UTC (rev 2611) @@ -42,6 +42,7 @@ import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.Component; +import java.awt.Rectangle; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -55,16 +56,22 @@ super(component); } + public void setGrabbed(boolean grab) { + super.setGrabbed(grab); + warpCursor(); + nGrabMouse(grab); + } + protected void resetCursorToCenter() { super.resetCursorToCenter(); /* Clear accumulated deltas */ - ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); + getMouseDeltas(delta_buffer); } protected void updateDeltas(long nanos) { super.updateDeltas(nanos); synchronized ( this ) { - ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); + getMouseDeltas(delta_buffer); int dx = delta_buffer.get(0); int dy = -delta_buffer.get(1); if ( dx != 0 || dy != 0 ) { @@ -73,4 +80,19 @@ } } } + + void warpCursor() { + if (isGrabbed()) { + Rectangle bounds = getComponent().getBounds(); + int x = bounds.x + bounds.width/2; + int y = bounds.y + bounds.height/2; + nWarpCursor(x, y); + } + } + + private static native void getMouseDeltas(IntBuffer delta_buffer); + + private static native void nWarpCursor(int x, int y); + + private static native void nGrabMouse(boolean grab); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:33:40 UTC (rev 2610) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:49:07 UTC (rev 2611) @@ -56,7 +56,6 @@ private boolean grabbed; - /** The accumulated mouse deltas returned by poll() */ private int accum_dx; private int accum_dy; @@ -93,6 +92,10 @@ component.removeMouseWheelListener(this); } + protected Component getComponent() { + return component; + } + public synchronized void setGrabbed(boolean grabbed) { this.grabbed = grabbed; resetCursorToCenter(); Modified: trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c =================================================================== --- trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c 2006-10-26 20:33:40 UTC (rev 2610) +++ trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c 2006-10-26 20:49:07 UTC (rev 2611) @@ -41,11 +41,12 @@ #include <jni.h> #include <ApplicationServices/ApplicationServices.h> +#include "org_lwjgl_opengl_MacOSXMouseEventQueue.h" #include "common_tools.h" static bool is_grabbed; -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGrabMouse(JNIEnv *env, jobject this, jboolean grab) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse(JNIEnv *env, jclass unused, jboolean grab) { bool new_grabbed = grab == JNI_TRUE; if (is_grabbed != new_grabbed) { is_grabbed = new_grabbed; @@ -57,14 +58,14 @@ } } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWarpCursor(JNIEnv *env, jobject this, jint x, jint y) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nWarpCursor(JNIEnv *env, jclass unused, jint x, jint y) { CGPoint p; p.x = x; p.y = y; CGWarpMouseCursorPosition(p); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_getMouseDeltas(JNIEnv *env, jobject this, jobject delta_buffer) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_getMouseDeltas(JNIEnv *env, jclass unused, jobject delta_buffer) { CGMouseDelta dx, dy; CGGetLastMouseDelta(&dx, &dy); int buffer_length = (*env)->GetDirectBufferCapacity(env, delta_buffer); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-30 15:47:06
|
Revision: 2618 http://svn.sourceforge.net/java-game-lib/?rev=2618&view=rev Author: elias_naur Date: 2006-10-30 07:46:42 -0800 (Mon, 30 Oct 2006) Log Message: ----------- Windows: Implemented AWTInputAdapter. Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java trunk/LWJGL/src/native/windows/context.h trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/build.xml 2006-10-30 15:46:42 UTC (rev 2618) @@ -508,6 +508,7 @@ </javah> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes"> + <class name="org.lwjgl.opengl.WindowsAWTInput" /> <class name="org.lwjgl.opengl.WindowsKeyboard" /> <class name="org.lwjgl.opengl.WindowsDirectInput8" /> <class name="org.lwjgl.opengl.WindowsDirectInputDevice8" /> Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2006-10-30 15:46:42 UTC (rev 2618) @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import java.nio.IntBuffer; +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; + +import java.awt.Cursor; +import java.awt.Point; + +/** + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2586 $ + * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ + */ +final class WindowsAWTInput extends AbstractAWTInput { + private final static int WS_CHILD = 0x40000000; + private final Cursor blank_cursor; + private Cursor cached_cursor; + + private long cached_hwnd; + private WindowsMouse cached_mouse; + private boolean has_grabbed; + + public WindowsAWTInput(AWTGLCanvas canvas) throws LWJGLException { + super(canvas); + int w = AWTUtil.getMinCursorSize(); + int h = AWTUtil.getMinCursorSize(); + blank_cursor = AWTUtil.createCursor(w, h, 0, 0, 1, BufferUtils.createIntBuffer(w*h), null); + } + + public synchronized void destroy() { + super.destroy(); + if (cached_mouse != null) { + grab(false); + cached_mouse.destroy(); + } + } + + public synchronized void processInput(PeerInfo peer_info) { + WindowsPeerInfo windows_peerinfo = (WindowsPeerInfo)peer_info; + long hwnd = windows_peerinfo.getHwnd(); + try { + hwnd = findTopLevelWindow(hwnd); + if (cached_mouse == null || hwnd != cached_hwnd) { + has_grabbed = false; + cached_hwnd = hwnd; + if (cached_mouse != null) + cached_mouse.destroy(); + cached_mouse = new WindowsMouse(WindowsDisplay.createDirectInput(), hwnd); + } + if (isGrabbed() && getCanvas().getCursor() != blank_cursor) { + cached_cursor = getCanvas().getCursor(); + /** + * For some reason, DirectInput won't let us blank the cursor + * with the EXCLUSIVE access mode, so we'll work around it with a + * custom blank cursor + */ + getCanvas().setCursor(blank_cursor); + } + grab(isGrabbed()); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to create windows mouse: " + e); + } + } + private static native int getWindowStyles(long hwnd) throws LWJGLException; + private static native long getParentWindow(long hwnd); + + private static long findTopLevelWindow(long hwnd) throws LWJGLException { + int window_styles = getWindowStyles(hwnd); + while ((window_styles & WS_CHILD) != 0) { + hwnd = getParentWindow(hwnd); + window_styles = getWindowStyles(hwnd); + } + return hwnd; + } + + private void grab(boolean grab) { + if (has_grabbed != grab) { + cached_mouse.grab(grab); + has_grabbed = grab; + if (!grab) + getCanvas().setCursor(cached_cursor); + } + } + + public synchronized void grabMouse(boolean grab) { + if (grab != isGrabbed()) { + super.grabMouse(grab); + /* Only ungrab since grabbing can only occur in processInput + * when the hwnd is guaranteed valid + */ + if (cached_mouse != null && !grab) + grab(grab); + } + } + + public void update() { + } + + public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + if (isGrabbed()) { + if (cached_mouse != null) + cached_mouse.poll(coord_buffer, buttons); + } else + super.pollMouse(coord_buffer, buttons); + } + + public synchronized void readMouse(ByteBuffer buffer) { + if (isGrabbed()) { + if (cached_mouse != null) + cached_mouse.read(buffer); + } else + super.readMouse(buffer); + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-30 15:46:42 UTC (rev 2618) @@ -66,7 +66,7 @@ } public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - throw new UnsupportedOperationException(); + return new WindowsAWTInput(canvas); } public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-10-30 15:46:42 UTC (rev 2618) @@ -76,14 +76,14 @@ public void setDataFormat(int type) throws LWJGLException { int ret = setDataFormat(di_device, type); if (ret != WindowsDirectInput.DI_OK) - throw new LWJGLException("Failed to set data format (" + ret + ")"); + throw new LWJGLException("Failed to set data format (" + Integer.toHexString(ret) + ")"); } protected abstract int setDataFormat(long di_device, int type); public void setCooperateLevel(long hwnd, int flags) throws LWJGLException { int ret = setCooperativeLevel(di_device, hwnd, flags); if (ret != WindowsDirectInput.DI_OK) - throw new LWJGLException("Failed to set cooperative level (" + ret + ")"); + throw new LWJGLException("Failed to set cooperative level (" + Integer.toHexString(ret) + ")"); } protected abstract int setCooperativeLevel(long di_device, long hwnd, int flags); @@ -95,7 +95,7 @@ public void setBufferSize(int buffer_size) throws LWJGLException { int ret = setBufferSize(di_device, buffer_size); if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_PROPNOEFFECT && ret != WindowsDirectInput.DI_POLLEDDEVICE) - throw new LWJGLException("Failed to set buffer size (" + ret + ")"); + throw new LWJGLException("Failed to set buffer size (" + Integer.toHexString(ret) + ")"); int event_buffer_size = getEventSize()*buffer_size; event_buffer = BufferUtils.createByteBuffer(event_buffer_size); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-30 15:46:42 UTC (rev 2618) @@ -289,6 +289,7 @@ peer_info = new WindowsDisplayPeerInfo(pixel_format); return peer_info; } + public void update() { nUpdate(); if (did_maximize) { @@ -581,7 +582,7 @@ } } - private static WindowsDirectInput createDirectInput() throws LWJGLException { + static WindowsDirectInput createDirectInput() throws LWJGLException { try { return new WindowsDirectInput8(getDllInstance()); } catch (LWJGLException e) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java 2006-10-30 15:46:42 UTC (rev 2618) @@ -52,4 +52,9 @@ nChoosePixelFormat(getHandle(), origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered); } private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException; + + public final long getHwnd() { + return nGetHwnd(getHandle()); + } + private static native long nGetHwnd(ByteBuffer handle); } Modified: trunk/LWJGL/src/native/windows/context.h =================================================================== --- trunk/LWJGL/src/native/windows/context.h 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/native/windows/context.h 2006-10-30 15:46:42 UTC (rev 2618) @@ -47,12 +47,15 @@ #include "extgl_wgl.h" typedef struct { - struct { - HPBUFFERARB pbuffer; - // Contains the function pointers that - // created the pbuffer - WGLExtensions extensions; - } pbuffer; + union { + HWND hwnd; + struct { + HPBUFFERARB pbuffer; + // Contains the function pointers that + // created the pbuffer + WGLExtensions extensions; + } pbuffer; + } u; HDC drawable_hdc; } WindowsPeerInfo; Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c 2006-10-30 15:46:42 UTC (rev 2618) @@ -169,23 +169,23 @@ throwException(env, "Could not get Pbuffer DC"); return; } - peer_info->pbuffer.extensions = extensions; - peer_info->pbuffer.pbuffer = Pbuffer; + peer_info->u.pbuffer.extensions = extensions; + peer_info->u.pbuffer.pbuffer = Pbuffer; peer_info->drawable_hdc = Pbuffer_dc; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->pbuffer.extensions.wglReleasePbufferDCARB(peer_info->pbuffer.pbuffer, peer_info->drawable_hdc); - peer_info->pbuffer.extensions.wglDestroyPbufferARB(peer_info->pbuffer.pbuffer); + peer_info->u.pbuffer.extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer.pbuffer, peer_info->drawable_hdc); + peer_info->u.pbuffer.extensions.wglDestroyPbufferARB(peer_info->u.pbuffer.pbuffer); } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); BOOL buffer_lost; - peer_info->pbuffer.extensions.wglQueryPbufferARB(peer_info->pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); + peer_info->u.pbuffer.extensions.wglQueryPbufferARB(peer_info->u.pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); return buffer_lost ? JNI_TRUE : JNI_FALSE; } @@ -198,17 +198,17 @@ attribs[1] = value; attribs[2] = 0; - peer_info->pbuffer.extensions.wglSetPbufferAttribARB(peer_info->pbuffer.pbuffer, attribs); + peer_info->u.pbuffer.extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer.pbuffer, attribs); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->pbuffer.extensions.wglBindTexImageARB(peer_info->pbuffer.pbuffer, buffer); + peer_info->u.pbuffer.extensions.wglBindTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->pbuffer.extensions.wglReleaseTexImageARB(peer_info->pbuffer.pbuffer, buffer); + peer_info->u.pbuffer.extensions.wglReleaseTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618) @@ -51,4 +51,5 @@ AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); JAWT_Win32DrawingSurfaceInfo *win32_dsi = (JAWT_Win32DrawingSurfaceInfo *)surface->dsi->platformInfo; peer_info->drawable_hdc = win32_dsi->hdc; + peer_info->u.hwnd = win32_dsi->hwnd; } Added: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c (rev 0) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c 2006-10-30 15:46:42 UTC (rev 2618) @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2575 2006-09-19 14:17:13Z elias_naur $ + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2575 $ + */ + +#include <jni.h> +#include "context.h" +#include "org_lwjgl_opengl_WindowsAWTInput.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getWindowStyles(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(intptr_t)hwnd_ptr; + WINDOWINFO window_info; + if (!GetWindowInfo(hwnd, &window_info)) { + throwFormattedException(env, "Failed to get window info (%d).", GetLastError()); + return 0; + } + return window_info.dwStyle; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getParentWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(intptr_t)hwnd_ptr; + return (intptr_t)GetParent(hwnd); +} Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618) @@ -47,4 +47,5 @@ (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); peer_info->drawable_hdc = getCurrentHDC(); + peer_info->u.hwnd = getCurrentHWND(); } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-10-28 22:06:24 UTC (rev 2617) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618) @@ -58,3 +58,8 @@ // Let it throw applyPixelFormat(env, peer_info->drawable_hdc, pixel_format_id); } + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + return peer_info->u.hwnd; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-11-09 11:04:25
|
Revision: 2622 http://svn.sourceforge.net/java-game-lib/?rev=2622&view=rev Author: elias_naur Date: 2006-11-09 03:03:55 -0800 (Thu, 09 Nov 2006) Log Message: ----------- Add applettest ant target for easy LWJGL applet testing in appletviewer Modified Paths: -------------- trunk/LWJGL/build.xml Added Paths: ----------- trunk/LWJGL/applet/appletviewer.policy Added: trunk/LWJGL/applet/appletviewer.policy =================================================================== --- trunk/LWJGL/applet/appletviewer.policy (rev 0) +++ trunk/LWJGL/applet/appletviewer.policy 2006-11-09 11:03:55 UTC (rev 2622) @@ -0,0 +1,5 @@ +keystore "lwjglkeystore"; + +grant SignedBy "lwjgl" { + permission java.security.AllPermission; +}; Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-11-07 15:14:31 UTC (rev 2621) +++ trunk/LWJGL/build.xml 2006-11-09 11:03:55 UTC (rev 2622) @@ -345,6 +345,13 @@ </jar> </target> + <target name="applettest" depends="applet"> + <exec executable="appletviewer"> + <arg value="-J-Djava.security.policy=applet/appletviewer.policy"/> + <arg path="applet/applet.html"/> + </exec> + </target> + <target name="runtest" depends="all"> <fail message="test.mainclass is not set. Use 'ant -Dtest.mainclass=<main-class> runtest'" unless="test.mainclass"/> <condition property="native_path" value="libs/win32"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2006-11-18 22:22:44
|
Revision: 2655 http://svn.sourceforge.net/java-game-lib/?rev=2655&view=rev Author: matzon Date: 2006-11-18 14:22:41 -0800 (Sat, 18 Nov 2006) Log Message: ----------- beta4 Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java trunk/LWJGL/src/native/common/devil/extil.c trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-11-18 22:03:02 UTC (rev 2654) +++ trunk/LWJGL/build.xml 2006-11-18 22:22:41 UTC (rev 2655) @@ -13,7 +13,7 @@ <property name="lwjgl.docs" location="doc" /> <property name="lwjgl.temp" location="temp" /> <property name="lwjgl.res" location="res" /> - <property name="lwjgl.version" value="1.0beta3" /> + <property name="lwjgl.version" value="1.0beta4" /> <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java"/> <!-- ================================================================== --> Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-11-18 22:03:02 UTC (rev 2654) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-11-18 22:22:41 UTC (rev 2655) @@ -54,7 +54,7 @@ private static final String JNI_LIBRARY_NAME = "lwjgl"; /** Current version of library */ - private static final String VERSION = "1.0beta3"; + private static final String VERSION = "1.0beta4"; /** Current version of the JNI library */ static final int JNI_VERSION = 5; Modified: trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-11-18 22:03:02 UTC (rev 2654) +++ trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-11-18 22:22:41 UTC (rev 2655) @@ -53,7 +53,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-devil"; /** Version of IL */ - public static final String VERSION = "1.0beta3"; + public static final String VERSION = "1.0beta4"; /** Current version of the JNI library */ static final int JNI_VERSION = 1; Modified: trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-11-18 22:03:02 UTC (rev 2654) +++ trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-11-18 22:22:41 UTC (rev 2655) @@ -193,7 +193,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-fmod3"; /** Version of FMOD */ - public static final String VERSION = "1.0beta3"; + public static final String VERSION = "1.0beta4"; /** Current version of the JNI library */ static final int JNI_VERSION = 1; Modified: trunk/LWJGL/src/native/common/devil/extil.c =================================================================== --- trunk/LWJGL/src/native/common/devil/extil.c 2006-11-18 22:03:02 UTC (rev 2654) +++ trunk/LWJGL/src/native/common/devil/extil.c 2006-11-18 22:22:41 UTC (rev 2655) @@ -10,9 +10,7 @@ #endif #include "org_lwjgl_devil_ILNative.h"; -static const char* VERSION = "1.0beta3"; - -/* + /* * Class: org_lwjgl_devil_ILNative * Method: getNativeLibraryVersion * Signature: ()I Modified: trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c =================================================================== --- trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c 2006-11-18 22:03:02 UTC (rev 2654) +++ trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c 2006-11-18 22:22:41 UTC (rev 2655) @@ -33,8 +33,6 @@ #include "org_lwjgl_fmod3_FMOD.h" #include "extfmod3.h" -static const char* VERSION = "1.0beta3"; - /* * Class: org_lwjgl_fmod3_FMOD * Method: getNativeLibraryVersion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2006-12-18 18:27:16
|
Revision: 2695 http://svn.sourceforge.net/java-game-lib/?rev=2695&view=rev Author: matzon Date: 2006-12-18 10:27:15 -0800 (Mon, 18 Dec 2006) Log Message: ----------- 1.0-rc1 version string Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-12-12 21:44:46 UTC (rev 2694) +++ trunk/LWJGL/build.xml 2006-12-18 18:27:15 UTC (rev 2695) @@ -13,7 +13,7 @@ <property name="lwjgl.docs" location="doc" /> <property name="lwjgl.temp" location="temp" /> <property name="lwjgl.res" location="res" /> - <property name="lwjgl.version" value="1.0beta4" /> + <property name="lwjgl.version" value="1.0-rc1" /> <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java"/> <!-- ================================================================== --> Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-12-12 21:44:46 UTC (rev 2694) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-12-18 18:27:15 UTC (rev 2695) @@ -54,7 +54,7 @@ private static final String JNI_LIBRARY_NAME = "lwjgl"; /** Current version of library */ - private static final String VERSION = "1.0beta4"; + private static final String VERSION = "1.0-rc1"; /** Current version of the JNI library */ static final int JNI_VERSION = 6; Modified: trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-12-12 21:44:46 UTC (rev 2694) +++ trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-12-18 18:27:15 UTC (rev 2695) @@ -53,7 +53,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-devil"; /** Version of IL */ - static final String VERSION = "1.0beta4"; + static final String VERSION = "1.0-rc1"; /** Current version of the JNI library */ static final int JNI_VERSION = 2; Modified: trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-12-12 21:44:46 UTC (rev 2694) +++ trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-12-18 18:27:15 UTC (rev 2695) @@ -193,7 +193,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-fmod3"; /** Version of FMOD */ - private static final String VERSION = "1.0beta4"; + private static final String VERSION = "1.0-rc1"; /** Current version of the JNI library */ static final int JNI_VERSION = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-02-03 12:22:58
|
Revision: 2736 http://svn.sourceforge.net/java-game-lib/?rev=2736&view=rev Author: matzon Date: 2007-02-03 04:22:25 -0800 (Sat, 03 Feb 2007) Log Message: ----------- 1.0 version string Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2007-01-31 14:07:20 UTC (rev 2735) +++ trunk/LWJGL/build.xml 2007-02-03 12:22:25 UTC (rev 2736) @@ -13,7 +13,7 @@ <property name="lwjgl.docs" location="doc" /> <property name="lwjgl.temp" location="temp" /> <property name="lwjgl.res" location="res" /> - <property name="lwjgl.version" value="1.0-rc1" /> + <property name="lwjgl.version" value="1.0" /> <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java"/> <!-- ================================================================== --> Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-01-31 14:07:20 UTC (rev 2735) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-02-03 12:22:25 UTC (rev 2736) @@ -54,7 +54,7 @@ private static final String JNI_LIBRARY_NAME = "lwjgl"; /** Current version of library */ - private static final String VERSION = "1.0-rc2"; + private static final String VERSION = "1.0"; /** Current version of the JNI library */ static final int JNI_VERSION = 8; Modified: trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2007-01-31 14:07:20 UTC (rev 2735) +++ trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2007-02-03 12:22:25 UTC (rev 2736) @@ -53,7 +53,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-devil"; /** Version of IL */ - static final String VERSION = "1.0-rc2"; + static final String VERSION = "1.0"; /** Current version of the JNI library */ static final int JNI_VERSION = 2; Modified: trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2007-01-31 14:07:20 UTC (rev 2735) +++ trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2007-02-03 12:22:25 UTC (rev 2736) @@ -193,7 +193,7 @@ private static String JNI_LIBRARY_NAME = "lwjgl-fmod3"; /** Version of FMOD */ - private static final String VERSION = "1.0-rc2"; + private static final String VERSION = "1.0"; /** Current version of the JNI library */ static final int JNI_VERSION = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |