You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
1
(1) |
|
2
(15) |
3
(20) |
4
(9) |
5
(2) |
6
|
7
(8) |
8
(3) |
|
9
(1) |
10
(8) |
11
(27) |
12
(12) |
13
(1) |
14
(6) |
15
(15) |
|
16
|
17
(2) |
18
|
19
|
20
|
21
(1) |
22
(3) |
|
23
|
24
|
25
(1) |
26
|
27
|
28
|
29
|
|
30
|
31
(3) |
|
|
|
|
|
|
From: <ma...@us...> - 2006-07-03 23:26:59
|
Revision: 2437 Author: matzon Date: 2006-07-03 16:26:54 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2437&view=rev Log Message: ----------- reworked installer to expect a jar with the platform natives inside a jar Modified Paths: -------------- trunk/LWJGL/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-03 23:23:49 UTC (rev 2436) +++ trunk/LWJGL/build.xml 2006-07-03 23:26:54 UTC (rev 2437) @@ -36,12 +36,6 @@ <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="**.*" /> @@ -109,8 +103,8 @@ <patternset id="lwjgl-win32.fileset"> <include name="lwjgl.dll" /> <include name="OpenAL32.dll" /> - <include name="jinput-dx8.dll" /> - <include name="jinput-raw.dll" /> + <include name="jinput-dx8.dll" /> + <include name="jinput-raw.dll" /> </patternset> <!-- Files to include in win32 optional package --> @@ -325,7 +319,6 @@ <!-- 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"/> <manifest> <attribute name="Sealed" value="true"/> </manifest> @@ -334,7 +327,7 @@ <!-- Create lwjgl_test.jar --> <jar destfile="${lwjgl.temp}/jar/lwjgl_test.jar" taskname="lwjgl_test.jar"> <fileset refid="lwjgl_test.fileset" /> - <fileset refid="lwjgl_test_extra.fileset" /> + <fileset refid="lwjgl_test_extra.fileset" /> </jar> <!-- Create lwjgl_util.jar --> @@ -364,6 +357,47 @@ <jar destfile="applet/lwjgl_applet.jar" taskname="lwjgl_applet.jar"> <fileset refid="lwjgl_applet.fileset" /> </jar> + + <!-- create each of the native jars --> + <jar destfile="applet/win32_natives.jar" taskname="win32_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"/> + + <jar destfile="applet/linux_natives.jar" taskname="linux_natives.jar"> + <fileset dir="${lwjgl.lib}/linux"> + <patternset refid="lwjgl-linux.fileset"/> + <patternset refid="lwjgl-linux_optional.fileset"/> + <include name="libfmod.so"/> + </fileset> + </jar> + <signjar jar="applet/linux_natives.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> + + <jar destfile="applet/macosx_natives.jar" taskname="macosx_natives.jar"> + <fileset dir="${lwjgl.lib}/macosx"> + <patternset refid="lwjgl-macosx.fileset"/> + <patternset refid="lwjgl-macosx_optional.fileset"/> + <include name="libfmod.dylib"/> + </fileset> + </jar> + <signjar jar="applet/macosx_natives.jar" alias="lwjgl" keystore="applet/lwjglkeystore" storepass="123456"/> + + <!-- add it to a natives jar --> + <jar destfile="applet/natives.jar" taskname="natives.jar"> + <fileset dir="applet"> + <include name="win32_natives.jar"/> + <include name="linux_natives.jar"/> + <include name="macosx_natives.jar"/> + </fileset> + </jar> + <delete file="applet/win32_natives.jar"/> + <delete file="applet/linux_natives.jar"/> + <delete file="applet/macosx_natives.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"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ma...@us...> - 2006-07-03 23:23:58
|
Revision: 2436 Author: matzon Date: 2006-07-03 16:23:49 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2436&view=rev Log Message: ----------- cleaned up imports Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenAL.java trunk/LWJGL/src/java/org/lwjgl/test/applet/Optional.java trunk/LWJGL/src/java/org/lwjgl/test/applet/Speed.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 23:23:14 UTC (rev 2435) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 23:23:49 UTC (rev 2436) @@ -34,10 +34,7 @@ import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Canvas; -import java.awt.Toolkit; -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; import org.lwjgl.util.applet.LWJGLInstaller; public class AppletTest extends Applet { Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenAL.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenAL.java 2006-07-03 23:23:14 UTC (rev 2435) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenAL.java 2006-07-03 23:23:49 UTC (rev 2436) @@ -31,7 +31,6 @@ */ package org.lwjgl.test.applet; -import java.nio.ByteBuffer; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/Optional.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/Optional.java 2006-07-03 23:23:14 UTC (rev 2435) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/Optional.java 2006-07-03 23:23:49 UTC (rev 2436) @@ -33,7 +33,6 @@ import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; -import java.net.URL; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; @@ -48,14 +47,9 @@ import org.lwjgl.fmod3.FMusic; import org.lwjgl.fmod3.FMusicModule; import org.lwjgl.fmod3.FSound; -import org.lwjgl.openal.AL; -import org.lwjgl.openal.AL10; import org.lwjgl.opengl.AWTGLCanvas; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; -import org.lwjgl.test.devil.BasicTest; -import org.lwjgl.test.fmod3.StreamPlayerMemory; -import org.lwjgl.util.WaveData; public class Optional extends AWTGLCanvas implements Test { Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/Speed.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/Speed.java 2006-07-03 23:23:14 UTC (rev 2435) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/Speed.java 2006-07-03 23:23:49 UTC (rev 2436) @@ -33,7 +33,6 @@ import org.lwjgl.LWJGLException; import org.lwjgl.opengl.AWTGLCanvas; -import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; public class Speed extends AWTGLCanvas implements Test { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ma...@us...> - 2006-07-03 23:23:19
|
Revision: 2435 Author: matzon Date: 2006-07-03 16:23:14 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2435&view=rev Log Message: ----------- cleaned up imports Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 23:22:46 UTC (rev 2434) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 23:23:14 UTC (rev 2435) @@ -31,7 +31,6 @@ */ package org.lwjgl.util.applet; -import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -46,15 +45,12 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.security.cert.Certificate; -import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.jar.JarEntry; -import java.util.jar.JarFile; import java.util.jar.JarInputStream; import org.lwjgl.LWJGLUtil; -import org.lwjgl.Sys; /** * <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ma...@us...> - 2006-07-03 23:22:53
|
Revision: 2434 Author: matzon Date: 2006-07-03 16:22:46 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2434&view=rev Log Message: ----------- added certificate check reworked installer to expect a jar with the platform natives inside a jar now installs into java.io.tmpdir/.lwjglinstall/<timestamp> uninstaller checks for removed watermark file - tho it never gets removed *grumble* Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 23:16:26 UTC (rev 2433) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 23:22:46 UTC (rev 2434) @@ -33,6 +33,8 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileFilter; import java.io.FileOutputStream; @@ -41,9 +43,18 @@ import java.io.OutputStream; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.security.cert.Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; /** * <p> @@ -55,16 +66,6 @@ */ 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; @@ -73,7 +74,13 @@ /** Buffer used when copying files */ private static final byte[] COPY_BUFFER = new byte[4096]; + + /** Directory all lwjgl installations go into */ + public static String MASTER_INSTALL_DIR = ".lwjglinstall"; + /** Name of the native jar we're expected to load and install */ + public static final String NATIVES_PLATFORM_JAR = "/" + LWJGLUtil.getPlatformName() + "_natives.jar"; + private LWJGLInstaller() { /* Unused */ } @@ -99,12 +106,14 @@ } try { - // libraries to validate and install - String[] libraries = PLATFORM_FILES[LWJGLUtil.getPlatform() - 1]; + // Validate the certificates of the platform native jar + HashMap files = (HashMap) + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws PrivilegedActionException{ + return validateCertificates(); + } + }); - // Validate the certificates of the native files - validateCertificates(); - // install shutdown installer hook if(!disableUninstall) { AccessController.doPrivileged(new PrivilegedAction() { @@ -123,11 +132,8 @@ 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); - } + // extract natives from jar + writeFiles(files, path); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -137,6 +143,8 @@ return null; } }); + + installed = true; } catch (Exception e) { LWJGLUtil.log("Failed extraction e = " + e.getMessage()); uninstall(); @@ -153,49 +161,95 @@ * 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 */ + private static HashMap validateCertificates() throws PrivilegedActionException { + InputStream is = LWJGLInstaller.class.getResourceAsStream(NATIVES_PLATFORM_JAR); + if(is == null) { + throw new PrivilegedActionException(new Exception("Unable to open " + NATIVES_PLATFORM_JAR + ", which was expected to be on the classpath")); + } + + // get our certificate chain + Certificate[] ownCerts = LWJGLInstaller.class.getProtectionDomain().getCodeSource().getCertificates(); + if(ownCerts == null || ownCerts.length == 0) { + throw new PrivilegedActionException(new Exception("Unable to get certificate chain for LWJGLInstaller")); + } + + // check that each of the entries in the jar is signed by same certificate as LWJGLInstaller + try { + HashMap files = new HashMap(); + JarInputStream jis = new JarInputStream(is); + + JarEntry native_entry = null; + while((native_entry = jis.getNextJarEntry()) != null) { + // skip directories and anything in directories + // conveniently ignores the manifest + if(native_entry.isDirectory() || native_entry.getName().indexOf('/') != -1) { + continue; + } + + // need to read the file, before the certificate is retrievable + // since we dont want to do two reads, we store it in memory for later use + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + copyFile(jis, baos, false); + files.put(native_entry.getName(), baos.toByteArray()); + + // now check the chain of an actual file + if(!validateCertificateChain(ownCerts, native_entry.getCertificates())) { + throw new Exception("Failed to validate certificate chain for " + native_entry.getName()); + } + } + + return files; + } catch (Exception e) { + throw new PrivilegedActionException(e); + } } /** + * Validates the certificate chain for a single file + * @param ownCerts Chain of certificates to check against + * @param native_certs Chain of certificates to check + * @return true if the chains match + */ + private static boolean validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs) { + if(native_certs == null) { + LWJGLUtil.log("Unable to validate certificate chain. Native entry did not have a certificate chain at all"); + return false; + } + + if(ownCerts.length != native_certs.length) { + LWJGLUtil.log("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]"); + return false; + } + + for(int i=0; i<ownCerts.length; i++) { + if(!ownCerts[i].equals(native_certs[i])) { + LWJGLUtil.log("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]); + return false; + } + } + return true; + } + + /** * 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) { + private static void writeFiles(final HashMap files, 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; + for(Iterator i = files.keySet().iterator(); i.hasNext();) { + String key = (String) i.next(); + File out = new File(path + File.separator + key); + out.createNewFile(); + InputStream is = new ByteArrayInputStream((byte[]) files.get(key)); + OutputStream os = new BufferedOutputStream(new FileOutputStream(out)); + copyFile(is, os, true); } - - 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()); + LWJGLUtil.log("Exception while extracting: " + ioe.getMessage()); return null; } return null; @@ -209,12 +263,15 @@ * @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 { + static void copyFile(InputStream is, OutputStream os, boolean closeInput) throws IOException { int len; while ((len = is.read(COPY_BUFFER)) > 0) { os.write(COPY_BUFFER, 0, len); } - is.close(); + + if(closeInput) { + is.close(); + } os.close(); } @@ -229,8 +286,8 @@ 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()) { + File tempDir = new File(user_temp_dir + File.separator + ".lwjglinstall" + File.separator + System.currentTimeMillis()); + if(!tempDir.mkdirs()) { throw new IOException("Failed to create directory: " + tempDir); } @@ -238,6 +295,7 @@ // TODO: Write some info to the file ? File watermark = new File(tempDir.getAbsolutePath() + File.separator + ".lwjglinstaller"); watermark.createNewFile(); + watermark.deleteOnExit(); return tempDir.getAbsolutePath(); } }); @@ -267,14 +325,14 @@ AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String temp = System.getProperty("java.io.tmpdir"); - File tempDir = new File(temp); + File tempDir = new File(temp + File.separator + MASTER_INSTALL_DIR); 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); + return isStale(pathname); } /** @@ -283,9 +341,9 @@ * @param directory Directory to check * @return true if the directory is an install directory */ - private boolean isInstallDirectory(File directory) { + private boolean isStale(File directory) { File installFile = new File(directory.getAbsolutePath() + File.separator + ".lwjglinstaller"); - return installFile.exists(); + return !installFile.exists(); } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-03 23:16:51
|
Revision: 2433 Author: elias_naur Date: 2006-07-03 16:16:26 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2433&view=rev Log Message: ----------- Implemented variable sized events in preparation of timestamped input events Modified Paths: -------------- 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/KeyboardEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.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/Win32Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -55,6 +55,9 @@ * $Id$ */ public class Keyboard { + /** Internal use - event size in bytes */ + public static final int EVENT_SIZE = 4 + 1 + 4; + /** * The special character meaning that no * character was translated for the event. @@ -199,8 +202,6 @@ /** Buffer size in events */ private static final int BUFFER_SIZE = 50; - /** Event size in elements */ - private static final int EVENT_SIZE = 3; /** Key names */ private static final String[] keyName = new String[255]; @@ -245,7 +246,7 @@ * followed by state. The state is followed by * a 4 byte code point representing the translated character. */ - private static IntBuffer readBuffer; + private static ByteBuffer readBuffer; /** The current keyboard character being examined */ private static int eventCharacter; @@ -290,7 +291,7 @@ return; Display.getImplementation().createKeyboard(); created = true; - readBuffer = BufferUtils.createIntBuffer(EVENT_SIZE*BUFFER_SIZE); + readBuffer = ByteBuffer.allocate(EVENT_SIZE*BUFFER_SIZE); reset(); } @@ -422,9 +423,9 @@ throw new IllegalStateException("Keyboard must be created before you can read events"); if (readBuffer.hasRemaining()) { - eventKey = readBuffer.get() & 0xFF; + eventKey = readBuffer.getInt() & 0xFF; eventState = readBuffer.get() != 0; - eventCharacter = readBuffer.get(); + eventCharacter = readBuffer.getInt(); return true; } else { return false; Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -59,6 +59,9 @@ * $Id$ */ public class Mouse { + /** Internal use - event size in bytes */ + public static final int EVENT_SIZE = 1 + 1 + 4 + 4 + 4; + /** Has the mouse been created? */ private static boolean created; @@ -102,7 +105,7 @@ private static boolean initialized; /** The mouse button events from the last read */ - private static IntBuffer readBuffer; + private static ByteBuffer readBuffer; /** The current mouse event button being examined */ private static int eventButton; @@ -120,8 +123,6 @@ /** Buffer size in events */ private static final int BUFFER_SIZE = 50; - /** Event size in elements */ - private static final int EVENT_SIZE = 5; private static boolean isGrabbed; @@ -232,7 +233,7 @@ coord_buffer = BufferUtils.createIntBuffer(3); if (currentCursor != null) setNativeCursor(currentCursor); - readBuffer = BufferUtils.createIntBuffer(EVENT_SIZE * BUFFER_SIZE); + readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE); readBuffer.limit(0); setGrabbed(isGrabbed); } @@ -363,13 +364,13 @@ eventButton = readBuffer.get(); eventState = readBuffer.get() != 0; if (isGrabbed()) { - event_dx = readBuffer.get(); - event_dy = readBuffer.get(); + event_dx = readBuffer.getInt(); + event_dy = readBuffer.getInt(); event_x += event_dx; event_y += event_dy; } else { - int new_event_x = readBuffer.get(); - int new_event_y = readBuffer.get(); + int new_event_x = readBuffer.getInt(); + int new_event_y = readBuffer.getInt(); event_dx = new_event_x - event_x; event_dy = new_event_y - event_y; event_x = new_event_x; @@ -377,7 +378,7 @@ } 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_dwheel = readBuffer.get(); + event_dwheel = readBuffer.getInt(); return true; } else return false; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -151,7 +151,7 @@ /** * Method to read the keyboard buffer */ - void readMouse(IntBuffer buffer); + void readMouse(ByteBuffer buffer); void grabMouse(boolean grab); @@ -197,7 +197,7 @@ /** * Method to read the keyboard buffer */ - void readKeyboard(IntBuffer buffer); + void readKeyboard(ByteBuffer 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-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -40,16 +40,15 @@ import java.nio.IntBuffer; class EventQueue { - private static final int QUEUE_SIZE = 200; private final int event_size; - private final IntBuffer queue; + private final ByteBuffer queue; protected EventQueue(int event_size) { this.event_size = event_size; - this.queue = ByteBuffer.allocateDirect(QUEUE_SIZE*event_size).asIntBuffer(); + this.queue = ByteBuffer.allocate(QUEUE_SIZE*event_size); } protected synchronized void clearEvents() { @@ -59,7 +58,7 @@ /** * Copy available events into the specified buffer. */ - public synchronized void copyEvents(IntBuffer dest) { + public synchronized void copyEvents(ByteBuffer dest) { queue.flip(); int old_limit = queue.limit(); if (dest.remaining() < queue.remaining()) @@ -73,10 +72,10 @@ * Put an event into the queue. * @return true if the event fitted into the queue, false otherwise */ - public synchronized boolean putEvent(int[] event) { - if (event.length != event_size) - throw new IllegalArgumentException("Internal error: event size " + event_size + " does not equals the given event size " + event.length); - if (queue.remaining() >= event.length) { + public synchronized boolean putEvent(ByteBuffer event) { + if (event.remaining() != event_size) + throw new IllegalArgumentException("Internal error: event size " + event_size + " does not equal the given event size " + event.remaining()); + if (queue.remaining() >= event.remaining()) { queue.put(event); return true; } else Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -44,14 +44,12 @@ import org.lwjgl.input.Keyboard; final class KeyboardEventQueue extends EventQueue implements KeyListener { - private static final int[] KEY_MAP = new int[0xffff]; - private static final int EVENT_SIZE = 3; private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE]; /** Event scratch array */ - private final int[] event = new int[EVENT_SIZE]; + private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); static { KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0; @@ -241,14 +239,14 @@ } public KeyboardEventQueue() { - super(EVENT_SIZE); + super(Keyboard.EVENT_SIZE); } - private void putKeyboardEvent(int key_code, int state, int character) { - event[0] = key_code; - event[1] = state; - event[2] = character; + private void putKeyboardEvent(int key_code, byte state, int character) { + event.putInt(key_code).put(state).putInt(character); + event.flip(); putEvent(event); + event.compact(); } public synchronized void poll(ByteBuffer key_down_buffer) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -648,7 +648,7 @@ } } - public void readMouse(IntBuffer buffer) { + public void readMouse(ByteBuffer buffer) { update(); lockAWT(); try { @@ -818,7 +818,7 @@ } } - public void readKeyboard(IntBuffer buffer) { + public void readKeyboard(ByteBuffer buffer) { update(); lockAWT(); try { @@ -972,7 +972,7 @@ /* Callbacks from nUpdate() */ private static void handleButtonEvent(long millis, int type, int button, int state) { if (mouse != null) - mouse.handleButtonEvent(grab, type, button); + mouse.handleButtonEvent(grab, type, (byte)button); } private static void handleKeyEvent(long event_ptr, long millis, int type, int keycode, int state) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -55,8 +55,6 @@ 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; @@ -70,9 +68,9 @@ 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 EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); - private final int[] tmp_event = new int[3]; + private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); 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(); @@ -152,7 +150,7 @@ private static native void destroyIC(long xic); private static native void closeIM(long xim); - public void read(IntBuffer buffer) { + public void read(ByteBuffer buffer) { event_queue.copyEvents(buffer); } @@ -162,11 +160,11 @@ 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; + private void putKeyboardEvent(int keycode, byte state, int ch) { + tmp_event.putInt(keycode).put(state).putInt(ch); + tmp_event.flip(); event_queue.putEvent(tmp_event); + tmp_event.compact(); } private int lookupStringISO88591(long event_ptr, int[] translation_buffer) { @@ -204,7 +202,7 @@ return lookupStringISO88591(event_ptr, translation_buffer); } - private void translateEvent(long event_ptr, int event_type, int keycode, int key_state) { + private void translateEvent(long event_ptr, int event_type, int keycode, byte key_state) { int num_chars, i; int ch; @@ -218,7 +216,7 @@ putKeyboardEvent(keycode, key_state, ch); for (i = 1; i < num_chars; i++) { ch = temp_translation_buffer[i]; - putKeyboardEvent(0, 0, ch); + putKeyboardEvent(0, (byte)0, ch); } } else { putKeyboardEvent(keycode, key_state, 0); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -46,7 +46,6 @@ import java.nio.charset.Charset; final class LinuxMouse { - private static final int EVENT_SIZE = 5; private static final int NUM_BUTTONS = 3; private static final int POINTER_WARP_BORDER = 10; // scale the mouse wheel according to DirectInput @@ -65,7 +64,7 @@ private final long display; private final long window; private final IntBuffer query_pointer_buffer = BufferUtils.createIntBuffer(4); - private final int[] event_buffer = new int[EVENT_SIZE]; + private final ByteBuffer event_buffer = ByteBuffer.allocate(Mouse.EVENT_SIZE); private int last_x; private int last_y; @@ -82,11 +81,11 @@ } private void reset() { - event_queue = new EventQueue(EVENT_SIZE); + event_queue = new EventQueue(event_buffer.capacity()); accum_dx = accum_dy = 0; } - public void read(IntBuffer buffer) { + public void read(ByteBuffer buffer) { event_queue.copyEvents(buffer); } @@ -104,13 +103,11 @@ buttons_buffer.put(i, buttons[i]); } - private boolean putMouseEventWithCoords(int button, int state, int coord1, int coord2, int dz) { - event_buffer[0] = button; - event_buffer[1] = state; - event_buffer[2] = coord1; - event_buffer[3] = coord2; - event_buffer[4] = dz; - return event_queue.putEvent(event_buffer); + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz) { + event_buffer.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz); + event_buffer.flip(); + event_queue.putEvent(event_buffer); + event_buffer.compact(); } private void setCursorPos(boolean grab, int x, int y) { @@ -122,9 +119,9 @@ last_x = x; last_y = y; if (grab) { - putMouseEventWithCoords(-1, 0, dx, dy, 0); + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0); } else { - putMouseEventWithCoords(-1, 0, x, y, 0); + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0); } } @@ -192,16 +189,16 @@ } private void handleButton(boolean grab, int button, byte state) { - int button_num; + byte button_num; switch (button) { case Button1: - button_num = 0; + button_num = (byte)0; break; case Button2: - button_num = 2; + button_num = (byte)2; break; case Button3: - button_num = 1; + button_num = (byte)1; break; default: return; @@ -210,24 +207,24 @@ putMouseEvent(grab, button_num, state, 0); } - private void putMouseEvent(boolean grab, int button, int state, int dz) { + private void putMouseEvent(boolean grab, byte button, byte state, int dz) { if (grab) putMouseEventWithCoords(button, state, 0, 0, dz); else putMouseEventWithCoords(button, state, last_x, last_y, dz); } - private void handleButtonPress(boolean grab, int button) { + private void handleButtonPress(boolean grab, byte button) { int delta = 0; switch (button) { case Button4: delta = WHEEL_SCALE; - putMouseEvent(grab, -1, 0, delta); + putMouseEvent(grab, (byte)-1, (byte)0, delta); accum_dz += delta; break; case Button5: delta = -WHEEL_SCALE; - putMouseEvent(grab, -1, 0, delta); + putMouseEvent(grab, (byte)-1, (byte)0, delta); accum_dz += delta; break; default: @@ -240,7 +237,7 @@ handleButton(grab, button, (byte)0); } - public void handleButtonEvent(boolean grab, int type, int button) { + public void handleButtonEvent(boolean grab, int type, byte button) { switch (type) { case ButtonRelease: handleButton(grab, button, (byte)0); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -321,7 +321,7 @@ mouse_queue.poll(coord_buffer, buttons_buffer); } - public void readMouse(IntBuffer buffer) { + public void readMouse(ByteBuffer buffer) { mouse_queue.copyEvents(buffer); } @@ -407,7 +407,7 @@ keyboard_queue.poll(keyDownBuffer); } - public void readKeyboard(IntBuffer buffer) { + public void readKeyboard(ByteBuffer buffer) { keyboard_queue.copyEvents(buffer); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -46,12 +46,11 @@ import java.nio.IntBuffer; import org.lwjgl.BufferUtils; +import org.lwjgl.input.Mouse; final class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener { - private static final int WHEEL_SCALE = 120; public static final int NUM_BUTTONS = 3; - private static final int EVENT_SIZE = 5; private final int width; private final int height; @@ -73,13 +72,13 @@ private boolean saved_control_state; /** Event scratch array */ - private final int[] event = new int[EVENT_SIZE]; + private final ByteBuffer event = ByteBuffer.allocate(Mouse.EVENT_SIZE); /** Buttons array */ private final byte[] buttons = new byte[NUM_BUTTONS]; MouseEventQueue(int width, int height) { - super(EVENT_SIZE); + super(Mouse.EVENT_SIZE); this.width = width; this.height = height; resetCursorToCenter(); @@ -105,20 +104,18 @@ ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); } - private boolean putMouseEvent(int button, int state, int dz) { - if ( grabbed ) - return putMouseEventWithCoords(button, state, 0, 0, dz); + private void putMouseEvent(byte button, byte state, int dz) { + if (grabbed) + putMouseEventWithCoords(button, state, 0, 0, dz); else - return putMouseEventWithCoords(button, state, last_x, last_y, dz); + putMouseEventWithCoords(button, state, last_x, last_y, dz); } - private boolean putMouseEventWithCoords(int button, int state, int coord1, int coord2, int dz) { - event[0] = button; - event[1] = state; - event[2] = coord1; - event[3] = coord2; - event[4] = dz; - return putEvent(event); + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz) { + event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz); + event.flip(); + putEvent(event); + event.compact(); } public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) { @@ -146,7 +143,7 @@ accum_dy += dy; last_x = x; last_y = y; - putMouseEventWithCoords(-1, 0, x, y, 0); + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0); } public void mouseClicked(MouseEvent e) { @@ -232,7 +229,7 @@ private synchronized void handleWheel(int amount) { accum_dz += amount; - putMouseEvent(-1, 0, amount); + putMouseEvent((byte)-1, (byte)0, amount); } private void updateDeltas() { @@ -243,7 +240,7 @@ int dx = delta_buffer.get(0); int dy = -delta_buffer.get(1); if ( dx != 0 || dy != 0 ) { - putMouseEventWithCoords(-1, 0, dx, dy, 0); + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0); accum_dx += dx; accum_dy += dy; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -206,7 +206,7 @@ mouse.poll(coord_buffer, buttons); } - public void readMouse(IntBuffer buffer) { + public void readMouse(ByteBuffer buffer) { update(); mouse.read(buffer); } @@ -251,7 +251,7 @@ keyboard.poll(keyDownBuffer); } - public void readKeyboard(IntBuffer buffer) { + public void readKeyboard(ByteBuffer buffer) { update(); keyboard.read(buffer); } @@ -340,7 +340,7 @@ private static void handleMouseButton(int button, int state) { if (mouse != null) - mouse.handleMouseButton(button, state); + mouse.handleMouseButton((byte)button, (byte)state); } private static void handleMouseMoved(int x, int y) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -103,14 +103,13 @@ } } - private void translateData(IntBuffer src, IntBuffer dst) { - int dst_index = dst.position(); + private void translateData(IntBuffer src, ByteBuffer dst) { while (dst.hasRemaining() && src.hasRemaining()) { int dwOfs = src.get(); - dst.put(dwOfs); - int dwData = src.get(); - dst.put(dwData); + dst.putInt(dwOfs); + byte dwData = (byte)src.get(); boolean key_down = (dwData & 0x80) != 0; + dst.put(key_down ? (byte)1 : (byte)0); if (key_down) { int virt_key = MapVirtualKey(dwOfs, 1); if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { @@ -126,28 +125,28 @@ int current_char = 0; do { if (current_char >= 1) { - dst.put(0); - dst.put(0); + dst.putInt(0); + dst.put((byte)0); } int char_int = ((int)unicode_buffer.get()) & 0xFFFF; - dst.put(char_int); + dst.putInt(char_int); current_char++; } while (dst.hasRemaining() && current_char < num_chars); } else { - dst.put(0); + dst.putInt(0); } } else { - dst.put(0); + dst.putInt(0); } } else - dst.put(0); + dst.putInt(0); } } 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 void read(IntBuffer buffer) { + public void read(ByteBuffer buffer) { int ret = keyboard.acquire(); if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) return; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-03 21:53:10 UTC (rev 2432) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-03 23:16:26 UTC (rev 2433) @@ -43,11 +43,11 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.BufferUtils; +import org.lwjgl.input.Mouse; 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; @@ -64,12 +64,12 @@ private final int mouse_button_count; private final boolean has_wheel; - private final EventQueue event_queue = new EventQueue(MOUSE_EVENT_SIZE); + 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 final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE); private boolean mouse_grabbed; private byte[] win32_message_button_states = new byte[BUTTON_STATES_SIZE]; @@ -180,46 +180,44 @@ } } - 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 void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz) { + mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz); + mouse_event.flip(); + event_queue.putEvent(mouse_event); + mouse_event.compact(); } - private boolean putMouseEvent(int button, int state, int dz) { + private void putMouseEvent(byte button, byte state, int dz) { if (mouse_grabbed) - return putMouseEventWithCoords(button, state, 0, 0, dz); + putMouseEventWithCoords(button, state, 0, 0, dz); else - return putMouseEventWithCoords(button, state, last_x, last_y, dz); + 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; + byte button_state; int i; while (buffer.hasRemaining()) { int dwOfs = buffer.get(); int dwData = buffer.get(); - button_state = (dwData & 0x80) != 0 ? 1 : 0; + button_state = (dwData & 0x80) != 0 ? (byte)1 : (byte)0; switch (dwOfs) { case DIMOFS_BUTTON0: - putMouseEventWithCoords(0, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON1: - putMouseEventWithCoords(1, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON2: - putMouseEventWithCoords(2, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON3: - putMouseEventWithCoords(3, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_X: @@ -234,7 +232,7 @@ } } if (dx != 0 || dy != 0 || dwheel != 0) - putMouseEventWithCoords(-1, 0, dx, -dy, dwheel); + putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel); } private void readDXBuffer() { @@ -261,7 +259,7 @@ } } - public void read(IntBuffer buffer) { + public void read(ByteBuffer buffer) { readDXBuffer(); event_queue.copyEvents(buffer); } @@ -288,7 +286,7 @@ public void handleMouseScrolled(int event_dwheel) { accum_dwheel += event_dwheel; - putMouseEvent(-1, 0, event_dwheel); + putMouseEvent((byte)-1, (byte)0, event_dwheel); } public void handleMouseMoved(int x, int y) { @@ -299,13 +297,13 @@ last_x = x; last_y = y; if (mouse_grabbed) { - putMouseEventWithCoords(-1, 0, dx, dy, 0); + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0); } else { - putMouseEventWithCoords(-1, 0, x, y, 0); + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0); } } - public void handleMouseButton(int button, int state) { + public void handleMouseButton(byte button, byte state) { putMouseEvent(button, state, 0); if (button < BUTTON_STATES_SIZE) win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-03 21:53:26
|
Revision: 2432 Author: elias_naur Date: 2006-07-03 14:53:10 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2432&view=rev Log Message: ----------- Removed svn:executable properties on windows java files Property Changed: ---------------- 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/WindowsMouse.java Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java ___________________________________________________________________ Name: svn:executable - * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-03 20:10:15
|
Revision: 2431 Author: elias_naur Date: 2006-07-03 13:10:10 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2431&view=rev Log Message: ----------- Don't delete the generated directories themselves on ant clean-generated, only the source files Modified Paths: -------------- trunk/LWJGL/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-03 19:22:20 UTC (rev 2430) +++ trunk/LWJGL/build.xml 2006-07-03 20:10:10 UTC (rev 2431) @@ -245,8 +245,10 @@ </target> <target name="clean-generated" description="Deletes the generated java and native source"> - <delete dir="${lwjgl.src}/generated" quiet="true" failonerror="false" taskname="cleaning java source"/> - <delete dir="${lwjgl.src.native}/generated" quiet="true" failonerror="false" taskname="cleaning native source"/> + <delete quiet="true" failonerror="false"> + <fileset dir="${lwjgl.src}/generated" includes="**"/> + <fileset dir="${lwjgl.src.native}/generated" includes="**"/> + </delete> </target> <!-- Cleans up any files created during the execution of this script --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-03 19:22:26
|
Revision: 2430 Author: elias_naur Date: 2006-07-03 12:22:20 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2430&view=rev Log Message: ----------- Fixed comment Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 19:09:47 UTC (rev 2429) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 19:22:20 UTC (rev 2430) @@ -58,9 +58,6 @@ /** * Copy available events into the specified buffer. - * Note that the buffer position is maintained, to emulate - * the behaviour of the native event queues. - * @return the number of events copied */ public synchronized void copyEvents(IntBuffer dest) { queue.flip(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-03 19:10:09
|
Revision: 2429 Author: elias_naur Date: 2006-07-03 12:09:47 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2429&view=rev Log Message: ----------- Now that no native side event_queue_t type is used anymore, convert input read() semantics to use normal nio Buffer semantics - that is, move the position when writing events Modified Paths: -------------- 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/LinuxKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -348,8 +348,7 @@ private static void read() { readBuffer.compact(); - int numEvents = Display.getImplementation().readKeyboard(readBuffer); - readBuffer.position(readBuffer.position() + numEvents*EVENT_SIZE); + Display.getImplementation().readKeyboard(readBuffer); readBuffer.flip(); } Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -306,8 +306,7 @@ private static void read() { readBuffer.compact(); - int numEvents = Display.getImplementation().readMouse(readBuffer); - readBuffer.position(readBuffer.position() + numEvents * EVENT_SIZE); + Display.getImplementation().readMouse(readBuffer); readBuffer.flip(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -150,10 +150,8 @@ /** * Method to read the keyboard buffer - * - * @return the total number of events read. */ - int readMouse(IntBuffer buffer); + void readMouse(IntBuffer buffer); void grabMouse(boolean grab); @@ -198,9 +196,8 @@ /** * Method to read the keyboard buffer - * @return the total number of events read. */ - int readKeyboard(IntBuffer buffer); + void 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-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -62,8 +62,7 @@ * the behaviour of the native event queues. * @return the number of events copied */ - public synchronized int copyEvents(IntBuffer dest) { - int old_position = dest.position(); + public synchronized void copyEvents(IntBuffer dest) { queue.flip(); int old_limit = queue.limit(); if (dest.remaining() < queue.remaining()) @@ -71,9 +70,6 @@ dest.put(queue); queue.limit(old_limit); queue.compact(); - int num_events = (dest.position() - old_position)/event_size; - dest.position(old_position); - return num_events; } /** Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -648,11 +648,11 @@ } } - public int readMouse(IntBuffer buffer) { + public void readMouse(IntBuffer buffer) { update(); lockAWT(); try { - return mouse.read(buffer); + mouse.read(buffer); } finally { unlockAWT(); } @@ -818,11 +818,11 @@ } } - public int readKeyboard(IntBuffer buffer) { + public void readKeyboard(IntBuffer buffer) { update(); lockAWT(); try { - return keyboard.read(buffer); + keyboard.read(buffer); } finally { unlockAWT(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -152,8 +152,8 @@ 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 read(IntBuffer buffer) { + event_queue.copyEvents(buffer); } public void poll(ByteBuffer keyDownBuffer) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -86,8 +86,8 @@ accum_dx = accum_dy = 0; } - public int read(IntBuffer buffer) { - return event_queue.copyEvents(buffer); + public void read(IntBuffer buffer) { + event_queue.copyEvents(buffer); } public void poll(boolean grab, IntBuffer coord_buffer, ByteBuffer buttons_buffer) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -321,8 +321,8 @@ mouse_queue.poll(coord_buffer, buttons_buffer); } - public int readMouse(IntBuffer buffer) { - return mouse_queue.copyEvents(buffer); + public void readMouse(IntBuffer buffer) { + mouse_queue.copyEvents(buffer); } public void grabMouse(boolean grab) { @@ -407,8 +407,8 @@ keyboard_queue.poll(keyDownBuffer); } - public int readKeyboard(IntBuffer buffer) { - return keyboard_queue.copyEvents(buffer); + public void readKeyboard(IntBuffer buffer) { + keyboard_queue.copyEvents(buffer); } /* public int isStateKeySet(int key) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -206,9 +206,9 @@ mouse.poll(coord_buffer, buttons); } - public int readMouse(IntBuffer buffer) { + public void readMouse(IntBuffer buffer) { update(); - return mouse.read(buffer); + mouse.read(buffer); } public void grabMouse(boolean grab) { @@ -251,9 +251,9 @@ keyboard.poll(keyDownBuffer); } - public int readKeyboard(IntBuffer buffer) { + public void readKeyboard(IntBuffer buffer) { update(); - return keyboard.read(buffer); + keyboard.read(buffer); } // public native int isStateKeySet(int key); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -103,15 +103,13 @@ } } - private int translateData(IntBuffer src, IntBuffer dst) { + private void translateData(IntBuffer src, IntBuffer dst) { int dst_index = dst.position(); - int num_events = 0; - while (dst_index < dst.limit() && src.hasRemaining()) { - num_events++; + while (dst.hasRemaining() && src.hasRemaining()) { int dwOfs = src.get(); - dst.put(dst_index++, dwOfs); + dst.put(dwOfs); int dwData = src.get(); - dst.put(dst_index++, dwData); + dst.put(dwData); boolean key_down = (dwData & 0x80) != 0; if (key_down) { int virt_key = MapVirtualKey(dwOfs, 1); @@ -128,33 +126,31 @@ int current_char = 0; do { if (current_char >= 1) { - num_events++; - dst.put(dst_index++, 0); - dst.put(dst_index++, 0); + dst.put(0); + dst.put(0); } int char_int = ((int)unicode_buffer.get()) & 0xFFFF; - dst.put(dst_index++, char_int); + dst.put(char_int); current_char++; - } while (dst_index < dst.limit() && current_char < num_chars); + } while (dst.hasRemaining() && current_char < num_chars); } else { - dst.put(dst_index++, 0); + dst.put(0); } } else { - dst.put(dst_index++, 0); + dst.put(0); } } else - dst.put(dst_index++, 0); + dst.put(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) { + public void read(IntBuffer buffer) { int ret = keyboard.acquire(); if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return 0; + return; keyboard.poll(); temp_data_buffer.clear(); ret = keyboard.getDeviceData(temp_data_buffer); @@ -173,6 +169,6 @@ break; } temp_data_buffer.flip(); - return translateData(temp_data_buffer, buffer); + translateData(temp_data_buffer, buffer); } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-03 18:56:15 UTC (rev 2428) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-03 19:09:47 UTC (rev 2429) @@ -261,9 +261,9 @@ } } - public int read(IntBuffer buffer) { + public void read(IntBuffer buffer) { readDXBuffer(); - return event_queue.copyEvents(buffer); + event_queue.copyEvents(buffer); } public void grab(boolean grab) { 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:56:26
|
Revision: 2428 Author: elias_naur Date: 2006-07-03 11:56:15 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2428&view=rev Log Message: ----------- Fixed comment Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 18:33:25 UTC (rev 2427) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 18:56:15 UTC (rev 2428) @@ -33,7 +33,6 @@ /** * A java implementation of a LWJGL compatible event queue. - * Currently only used by the Mac OS X implementation. * @author elias_naur */ Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:33:25 UTC (rev 2427) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:56:15 UTC (rev 2428) @@ -54,7 +54,6 @@ 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; 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:33:48
|
Revision: 2427 Author: elias_naur Date: 2006-07-03 11:33:25 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2427&view=rev Log Message: ----------- Linux: Moved Display state booleans to java side Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:18:27 UTC (rev 2426) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:33:25 UTC (rev 2427) @@ -97,6 +97,9 @@ private static boolean input_released; private static boolean grab; private static boolean focused; + private static boolean minimized; + private static boolean dirty; + private static boolean close_requested; private static ByteBuffer current_cursor; private static ByteBuffer blank_cursor; @@ -372,7 +375,10 @@ input_released = false; pointer_grabbed = false; keyboard_grabbed = false; + close_requested = false; grab = false; + minimized = false; + dirty = true; updateInputGrab(); nSetRepeatMode(getDisplay(), AutoRepeatModeOff); } finally { @@ -548,41 +554,24 @@ private static native void nSetTitle(String title); public boolean isCloseRequested() { - lockAWT(); - try { - return nIsCloseRequested(); - } finally { - unlockAWT(); - } + boolean result = close_requested; + close_requested = false; + return result; } - private static native boolean nIsCloseRequested(); public boolean isVisible() { - lockAWT(); - try { - return nIsVisible(); - } finally { - unlockAWT(); - } + return !minimized; } - private static native boolean nIsVisible(); public boolean isActive() { - lockAWT(); - try { - return focused || isLegacyFullscreen(); - } finally { - unlockAWT(); - } + return focused || isLegacyFullscreen(); } public boolean isDirty() { - lockAWT(); - boolean result = nIsDirty(); - unlockAWT(); + boolean result = dirty; + dirty = false; return result; } - private static native boolean nIsDirty(); public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { peer_info = new LinuxDisplayPeerInfo(pixel_format); @@ -1001,4 +990,22 @@ if (mouse != null) mouse.handleWarpEvent(x, y); } + + private static void handleExposeEvent() { + dirty = true; + } + + private static void handleUnmapNotifyEvent() { + dirty = true; + minimized = true; + } + + private static void handleMapNotifyEvent() { + dirty = true; + minimized = false; + } + + private static void handleCloseEvent() { + close_requested = true; + } } Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-07-03 18:18:27 UTC (rev 2426) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-07-03 18:33:25 UTC (rev 2427) @@ -79,11 +79,6 @@ static Visual *current_visual; -static bool dirty; -static bool minimized; -static bool closerequested; -static bool grab; - static int current_screen; static Display *display_connection = NULL; static bool async_x_error; @@ -186,6 +181,18 @@ jmethodID handleWarpEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleWarpEvent", "(II)V"); if (handleWarpEvent_method == NULL) return; + jmethodID handleMapNotifyEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleMapNotifyEvent", "()V"); + if (handleMapNotifyEvent_method == NULL) + return; + jmethodID handleUnmapNotifyEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleUnmapNotifyEvent", "()V"); + if (handleUnmapNotifyEvent_method == NULL) + return; + jmethodID handleExposeEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleExposeEvent", "()V"); + if (handleExposeEvent_method == NULL) + return; + jmethodID handleCloseEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleCloseEvent", "()V"); + if (handleCloseEvent_method == NULL) + return; while (!(*env)->ExceptionOccurred(env) && XPending(getDisplay()) > 0) { XNextEvent(getDisplay(), &event); if (XFilterEvent(&event, None) == True) @@ -198,18 +205,16 @@ if (event.xclient.message_type == warp_atom) { (*env)->CallStaticVoidMethod(env, disp_class, 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)) - closerequested = true; + (*env)->CallStaticVoidMethod(env, disp_class, handleCloseEvent_method); break; case MapNotify: - dirty = true; - minimized = false; + (*env)->CallStaticVoidMethod(env, disp_class, handleMapNotifyEvent_method); break; case UnmapNotify: - dirty = true; - minimized = true; + (*env)->CallStaticVoidMethod(env, disp_class, handleUnmapNotifyEvent_method); break; case Expose: - dirty = true; + (*env)->CallStaticVoidMethod(env, disp_class, handleExposeEvent_method); break; case ButtonPress: /* Fall through */ case ButtonRelease: @@ -308,10 +313,6 @@ static bool createWindow(JNIEnv* env, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) { bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); - dirty = true; - minimized = false; - closerequested = false; - grab = false; Window root_win; Window win; XSetWindowAttributes attribs; @@ -413,25 +414,6 @@ destroyWindow(env); } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsDirty - (JNIEnv *env, jclass clazz) { - bool result = dirty; - dirty = false; - return result ? JNI_TRUE : JNI_FALSE; -} - -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsVisible - (JNIEnv *env, jclass clazz) { - return minimized ? JNI_FALSE : JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsCloseRequested - (JNIEnv *env, jclass clazz) { - bool saved = closerequested; - closerequested = false; - return saved; -} - JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) { JAWT jawt; jawt.version = JAWT_VERSION_1_4; 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:18:41
|
Revision: 2426 Author: elias_naur Date: 2006-07-03 11:18:27 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2426&view=rev Log Message: ----------- Linux: Fix multiple calls of setIcon by creating copies of icon data instead of converting data in-place Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:07:44 UTC (rev 2425) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:18:27 UTC (rev 2426) @@ -44,6 +44,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; import org.lwjgl.input.Keyboard; final class LinuxDisplay implements DisplayImplementation { @@ -916,7 +917,8 @@ throw new UnsupportedOperationException(); } - private static void convertIcon(ByteBuffer icon, int width, int height) { + private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) { + ByteBuffer icon_copy = BufferUtils.createByteBuffer(icon.capacity()); int x = 0; int y = 5; byte r,g,b,a; @@ -930,12 +932,13 @@ b = icon.get((x*4)+(y*width*4)+2); a = icon.get((x*4)+(y*width*4)+3); - icon.put((x*depth)+(y*width*depth), b); // blue - icon.put((x*depth)+(y*width*depth)+1, g); // green - icon.put((x*depth)+(y*width*depth)+2, r); - icon.put((x*depth)+(y*width*depth)+3, a); + icon_copy.put((x*depth)+(y*width*depth), b); // blue + icon_copy.put((x*depth)+(y*width*depth)+1, g); // green + icon_copy.put((x*depth)+(y*width*depth)+2, r); + icon_copy.put((x*depth)+(y*width*depth)+3, a); } } + return icon_copy; } /** @@ -959,8 +962,8 @@ int size = icons[i].limit() / 4; int dimension = (int)Math.sqrt(size); if (dimension == 32) { - convertIcon(icons[i], dimension, dimension); - nSetWindowIcon(icons[i], icons[i].capacity(), dimension, dimension); + ByteBuffer icon = convertIcon(icons[i], dimension, dimension); + nSetWindowIcon(icon, icon.capacity(), dimension, dimension); return 1; } } 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-03 12:00:31
|
Revision: 2424 Author: elias_naur Date: 2006-07-03 05:00:12 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2424&view=rev Log Message: ----------- Added support for applets to jinput Modified Paths: -------------- trunk/LWJGL/libs/jinput.jar trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java Modified: trunk/LWJGL/libs/jinput.jar =================================================================== (Binary files differ) Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 11:44:34 UTC (rev 2423) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/LWJGLInstaller.java 2006-07-03 12:00:12 UTC (rev 2424) @@ -132,6 +132,8 @@ AccessController.doPrivileged(new PrivilegedAction() { public Object run() { System.setProperty("org.lwjgl.librarypath", path); + // Make sure jinput knows about the new path too + System.setProperty("net.java.games.input.librarypath", path); return null; } }); 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:44:41
|
Revision: 2423 Author: elias_naur Date: 2006-07-03 04:44:34 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2423&view=rev Log Message: ----------- Added seal to security sensitive jars Modified Paths: -------------- trunk/LWJGL/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2006-07-03 11:37:38 UTC (rev 2422) +++ trunk/LWJGL/build.xml 2006-07-03 11:44:34 UTC (rev 2423) @@ -315,12 +315,18 @@ <!-- Create lwjgl.jar --> <jar destfile="${lwjgl.temp}/jar/lwjgl.jar" taskname="lwjgl.jar"> <fileset refid="lwjgl.fileset" /> + <manifest> + <attribute name="Sealed" value="true"/> + </manifest> </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"/> + <manifest> + <attribute name="Sealed" value="true"/> + </manifest> </jar> <!-- Create lwjgl_test.jar --> @@ -337,11 +343,17 @@ <!-- Create lwjgl_fmod.jar --> <jar destfile="${lwjgl.temp}/jar/lwjgl_fmod3.jar" taskname="lwjgl_fmod3.jar"> <fileset refid="lwjgl_fmod3.fileset" /> + <manifest> + <attribute name="Sealed" value="true"/> + </manifest> </jar> <!-- Create lwjgl_devil.jar --> <jar destfile="${lwjgl.temp}/jar/lwjgl_devil.jar" taskname="lwjgl_devil.jar"> <fileset refid="lwjgl_devil.fileset" /> + <manifest> + <attribute name="Sealed" value="false"/> + </manifest> </jar> </target> 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:37:44
|
Revision: 2422 Author: elias_naur Date: 2006-07-03 04:37:38 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2422&view=rev Log Message: ----------- Moved LWJGLInstaller to org.lwjgl.util.applet Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/applet/ 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:36:34
|
Revision: 2421 Author: elias_naur Date: 2006-07-03 04:36:23 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2421&view=rev Log Message: ----------- Fixed AppletTest Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 11:30:30 UTC (rev 2420) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 11:36:23 UTC (rev 2421) @@ -38,7 +38,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; -import org.lwjgl.applet.LWJGLInstaller; +import org.lwjgl.util.applet.LWJGLInstaller; public class AppletTest extends Applet { 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 10:28:47
|
Revision: 2419 Author: elias_naur Date: 2006-07-03 03:28:32 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2419&view=rev Log Message: ----------- Removed multiple library names support from Sys.java, it is not needed anymore Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2006-07-03 10:21:44 UTC (rev 2418) +++ trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2006-07-03 10:28:32 UTC (rev 2419) @@ -39,13 +39,6 @@ * $Id$ */ abstract class DefaultSysImplementation implements SysImplementation { - /** The native library name */ - protected static final String LIBRARY_NAME = "lwjgl"; - - public String[] getNativeLibraryNames() { - return new String[]{LIBRARY_NAME}; - } - public native String getNativeLibraryVersion(); public native void setDebug(boolean debug); Modified: trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java 2006-07-03 10:21:44 UTC (rev 2418) +++ trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java 2006-07-03 10:28:32 UTC (rev 2419) @@ -42,37 +42,6 @@ * $Id$ */ class MacOSXSysImplementation extends J2SESysImplementation { - public String[] getNativeLibraryNames() { - /* If we're on 10.4, fine, we'll just try the default library name. For - * earlier versions of Mac OS X, try the legacy library first. - * - * Having a kludge like this is unfortunate, but necessary for the following reasons: - * 1. We need two libraries to support Mac OS X 10.2, 10.3 and 10.4. We could - * cover 10.2, 10.3 and 10.4 with one gcc 3 compiled library, but then we - * loose intel mac support. Instead, we'll distribute two versions of the lwjgl - * native library, the default and a legacy one. - * 2. The default library will be universal ('fat') with both intel and powerpc support - * compiled in. This requires gcc 4, and makes the library unusable on Mac OS X 10.3 - * and earlier (actually 10.3.9 has the required gcc 4 libraries, but we'll ignore that). - * We could still choose to load the default library first, and the legacy one later, - * but a bug in the Mac OS X java implementation forces a java program to exit - * if the loaded library has a missing dependency (The correct behaviour is to throw - * an UnsatisfiedLinkError, like on linux and windows). - * 3. If the LWJGL program is launched with an intelligent ClassLoader, this issue can be avoided - * altogether, and the legacy library naming can be avoided too. For example, when - * using webstart, one can supply two nativelib references, one for Mac OS X 10.4 - * (the default library), and one for earlier Mac OS X (the legacy library). This is the - * preferred way to deploy the libraries. The legacy naming is for the users that don't want to - * mess around with libraries and classloaders. They can simply make sure that lwjgl.jar - * is in the classpath and that both the default library and the legacy library is in the native - * library path (java.library.path). - */ - if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) - return super.getNativeLibraryNames(); - else - return new String[]{LIBRARY_NAME + "-legacy", LIBRARY_NAME}; - } - public boolean openURL(String url) { try { Method openURL_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-03 10:21:44 UTC (rev 2418) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-03 10:28:32 UTC (rev 2419) @@ -50,8 +50,10 @@ * $Id$ */ public final class Sys { + /** The native library name */ + private static final String JNI_LIBRARY_NAME = "lwjgl"; - /** Current version of library */ + /** Current version of library */ private static final String VERSION = "1.0beta2"; /** The implementation instance to delegate platform specific behavior to */ @@ -74,23 +76,8 @@ static { implementation = createImplementation(); - String[] library_names = implementation.getNativeLibraryNames(); - UnsatisfiedLinkError last_load_error = null; - for (int i = 0; i < library_names.length; i++) { - try { - loadLibrary(library_names[i]); - last_load_error = null; - break; - } catch (UnsatisfiedLinkError e) { - last_load_error = e; - } - } + loadLibrary(JNI_LIBRARY_NAME); - // check for error - if (last_load_error != null) { - throw last_load_error; - } - String native_version = implementation.getNativeLibraryVersion(); if (!native_version.equals(getVersion())) throw new LinkageError("Version mismatch: jar version is '" + getVersion() + Modified: trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2006-07-03 10:21:44 UTC (rev 2418) +++ trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2006-07-03 10:28:32 UTC (rev 2419) @@ -42,12 +42,6 @@ */ interface SysImplementation { /** - * Return an array of possible library names. later names - * tried last. - */ - public String[] getNativeLibraryNames(); - - /** * Return the version of the native library */ public String getNativeLibraryVersion(); Modified: trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-03 10:21:44 UTC (rev 2418) +++ trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-03 10:28:32 UTC (rev 2419) @@ -225,7 +225,7 @@ */ static String createTemporaryDir(final String user_temp_dir) throws Exception { return (String) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() { + public Object run() throws Exception { // create the temp directory File tempDir = new File(user_temp_dir + File.separator + "lwjgl-" + System.currentTimeMillis()); if(!tempDir.mkdir()) { Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 10:21:44 UTC (rev 2418) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 10:28:32 UTC (rev 2419) @@ -65,7 +65,7 @@ try { LWJGLInstaller.tempInstall(); - } catch (LWJGLException le) { + } catch (Exception le) { /* screwed */ le.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-03 10:22:25
|
Revision: 2418 Author: elias_naur Date: 2006-07-03 03:21:44 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2418&view=rev Log Message: ----------- Made sure no dependency from core LWJGL to LWJGLInstaller exists Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2006-07-02 22:45:56 UTC (rev 2417) +++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2006-07-03 10:21:44 UTC (rev 2418) @@ -42,7 +42,6 @@ import java.util.List; import java.util.StringTokenizer; -import org.lwjgl.applet.LWJGLInstaller; /** * <p> @@ -280,7 +279,7 @@ * @return the current platform type */ public static int getPlatform() { - String osName = System.getProperty("os.name"); + String osName = getPrivilegedProperty("os.name"); if (osName.startsWith("Windows")) { return PLATFORM_WINDOWS; @@ -358,16 +357,13 @@ } // add Installer path - if (LWJGLInstaller.installed) { - possible_paths.add(LWJGLInstaller.installDirectory + File.separator + platform_lib_name); + String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath"); + if (alternative_path != null) { + possible_paths.add(alternative_path + File.separator + platform_lib_name); } // Add all possible paths from java.library.path - String java_library_path = (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty("java.library.path"); - } - }); + String java_library_path = getPrivilegedProperty("java.library.path"); StringTokenizer st = new StringTokenizer(java_library_path, File.pathSeparator); while (st.hasMoreTokens()) { @@ -376,11 +372,7 @@ } //add current path - String current_dir = (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty("user.dir"); - } - }); + String current_dir = getPrivilegedProperty("user.dir"); possible_paths.add(current_dir + File.separator + platform_lib_name); //add pure library (no path, let OS search) @@ -393,6 +385,14 @@ return paths; } + private static String getPrivilegedProperty(final String property_name) { + return (String)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(property_name); + } + }); + } + /** * Tries to locate named library from the current ClassLoader * This method exists because native libraries are loaded from native code, and as such @@ -460,7 +460,7 @@ * specific code and will not work for any other platform. */ public static boolean isMacOSXEqualsOrBetterThan(int major_required, int minor_required) { - String os_version = System.getProperty("os.version"); + String os_version = getPrivilegedProperty("os.version"); StringTokenizer version_tokenizer = new StringTokenizer(os_version, "."); int major; int minor; Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-02 22:45:56 UTC (rev 2417) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-03 10:21:44 UTC (rev 2418) @@ -39,7 +39,6 @@ import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; -import org.lwjgl.applet.LWJGLInstaller; import org.lwjgl.input.Mouse; /** @@ -58,31 +57,28 @@ /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; - /** - * utility loadlibrary to load the native library using elevated priviledges - * @param name Name of library to load, or full path if usingPath is true - * @param usingPath true if using the full path to the native - */ - private static void loadLibrary(final String name, final boolean usingPath) { + private static void loadLibrary(final String lib_name) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { - if(usingPath) { - System.load(name); + String library_path = System.getProperty("org.lwjgl.librarypath"); + if (library_path != null) { + System.load(library_path + File.separator + + System.mapLibraryName(lib_name)); } else { - System.loadLibrary(name); + System.loadLibrary(lib_name); } return null; } }); - } - + } + static { implementation = createImplementation(); String[] library_names = implementation.getNativeLibraryNames(); UnsatisfiedLinkError last_load_error = null; for (int i = 0; i < library_names.length; i++) { try { - loadLibrary(library_names[i], false); + loadLibrary(library_names[i]); last_load_error = null; break; } catch (UnsatisfiedLinkError e) { @@ -90,19 +86,6 @@ } } - // failed normal loading - check installer - if (last_load_error != null && LWJGLInstaller.installed) { - for (int i = 0; i < library_names.length; i++) { - try { - loadLibrary(LWJGLInstaller.installDirectory + File.separator + System.mapLibraryName(library_names[i]), true); - last_load_error = null; - break; - } catch (UnsatisfiedLinkError e) { - last_load_error = e; - } - } - } - // check for error if (last_load_error != null) { throw last_load_error; Modified: trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-02 22:45:56 UTC (rev 2417) +++ trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-03 10:21:44 UTC (rev 2418) @@ -41,8 +41,8 @@ import java.io.OutputStream; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; -import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; /** @@ -71,9 +71,6 @@ /** 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]; @@ -94,53 +91,55 @@ * 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 { + public static void tempInstall() throws Exception { // only need to install once if (installed) { - return true; + return; } - - // 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) { + 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() { - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - LWJGLInstaller.uninstall(); - } - }); + System.setProperty("org.lwjgl.librarypath", path); return null; } }); + } catch (Exception e) { + LWJGLUtil.log("Failed extraction e = " + e.getMessage()); + uninstall(); + throw e; } - - // create a temporary dir for the native files - String user_temp_dir = getPriviledgedString("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; } /** @@ -150,9 +149,9 @@ * 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 + * @throws Exception If we encounter a certificate mismatch */ - private static void validateCertificates() throws LWJGLException { + private static void validateCertificates() throws Exception { /* TODO */ } @@ -161,15 +160,14 @@ * * @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() { + 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 false; + return null; } // create the new file and copy it to its destination @@ -183,12 +181,12 @@ // =========================================== if (os == null) { LWJGLUtil.log("Unable to write to outputstream at " + out.getAbsolutePath()); - return false; + return null; } if (is == null) { LWJGLUtil.log("Unable to read classpath inputstream from " + in); - return false; + return null; } // ------------------------------------------- @@ -196,9 +194,9 @@ copyFile(is, os); } catch (IOException ioe) { LWJGLUtil.log("Exception while extracting " + file + ": " + ioe.getMessage()); - return false; + return null; } - return true; + return null; } }); } @@ -225,23 +223,19 @@ * 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() { + static String createTemporaryDir(final String user_temp_dir) throws Exception { + return (String) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() { // create the temp directory File tempDir = new File(user_temp_dir + File.separator + "lwjgl-" + System.currentTimeMillis()); if(!tempDir.mkdir()) { - return null; + throw new IOException("Failed to create directory: " + tempDir); } // 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; - } + File watermark = new File(tempDir.getAbsolutePath() + File.separator + ".lwjglinstaller"); + watermark.createNewFile(); return tempDir.getAbsolutePath(); } }); Modified: trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-07-02 22:45:56 UTC (rev 2417) +++ trunk/LWJGL/src/java/org/lwjgl/devil/ILNative.java 2006-07-03 10:21:44 UTC (rev 2418) @@ -37,7 +37,6 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; -import org.lwjgl.applet.LWJGLInstaller; /** * <p> @@ -56,30 +55,23 @@ /** Version of IL */ public static final String VERSION = "1.0beta2"; - /** - * utility loadlibrary to load the native library using elevated priviledges - * @param name Name of library to load, or full path if usingPath is true - * @param usingPath true if using the full path to the native - */ - private static void loadLibrary(final String name, final boolean usingPath) { + private static void loadLibrary(final String lib_name) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { - if(usingPath) { - System.load(name); + String library_path = System.getProperty("org.lwjgl.librarypath"); + if (library_path != null) { + System.load(library_path + File.separator + + System.mapLibraryName(lib_name)); } else { - System.loadLibrary(name); + System.loadLibrary(lib_name); } return null; } }); - } - + } + static { - if (LWJGLInstaller.installed) { - loadLibrary(LWJGLInstaller.installDirectory + File.separator + System.mapLibraryName(JNI_LIBRARY_NAME), true); - } else { - loadLibrary(JNI_LIBRARY_NAME, false); - } + loadLibrary(JNI_LIBRARY_NAME); // check for mismatch String nativeVersion = getNativeLibraryVersion(); Modified: trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-07-02 22:45:56 UTC (rev 2417) +++ trunk/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java 2006-07-03 10:21:44 UTC (rev 2418) @@ -41,7 +41,6 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; -import org.lwjgl.applet.LWJGLInstaller; /** * <br> @@ -209,11 +208,7 @@ } initialized = true; - if (LWJGLInstaller.installed) { - loadLibrary(LWJGLInstaller.installDirectory + File.separator + System.mapLibraryName(JNI_LIBRARY_NAME), true); - } else { - loadLibrary(JNI_LIBRARY_NAME, false); - } + loadLibrary(JNI_LIBRARY_NAME); // check for mismatch String nativeVersion = getNativeLibraryVersion(); @@ -229,13 +224,15 @@ } } - private static void loadLibrary(final String name, final boolean usingPath) { + private static void loadLibrary(final String lib_name) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { - if(usingPath) { - System.load(name); + String library_path = System.getProperty("org.lwjgl.librarypath"); + if (library_path != null) { + System.load(library_path + File.separator + + System.mapLibraryName(lib_name)); } else { - System.loadLibrary(name); + System.loadLibrary(lib_name); } return null; } Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-02 22:45:56 UTC (rev 2417) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletTest.java 2006-07-03 10:21:44 UTC (rev 2418) @@ -44,19 +44,16 @@ Test test = null; - @Override public void destroy() { super.destroy(); System.out.println("*** destroy ***"); } - @Override public void start() { super.start(); System.out.println("*** start ***"); } - @Override public void stop() { super.stop(); System.out.println("*** stop ***"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |