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
(8) |
2
(8) |
3
(8) |
4
|
|
5
|
6
|
7
|
8
|
9
|
10
|
11
(6) |
|
12
(2) |
13
|
14
|
15
|
16
|
17
|
18
|
|
19
|
20
|
21
|
22
|
23
(6) |
24
|
25
|
|
26
|
27
(1) |
28
|
29
(2) |
30
(1) |
31
(2) |
|
|
From: Elias N. <eli...@us...> - 2003-01-31 19:04:51
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv7886/src/native/win32 Modified Files: org_lwjgl_Display.cpp Log Message: Added win32 alpha check Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Display.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_Display.cpp 23 Dec 2002 13:23:29 -0000 1.13 +++ org_lwjgl_Display.cpp 31 Jan 2003 19:04:45 -0000 1.14 @@ -381,6 +381,12 @@ printf("This application requires a greater colour depth.\n"); destroyAll(); return JNI_FALSE; + } + + if (desc.cAlphaBits < alphaBits) { + printf("This application requires a greater alpha depth.\n"); + destroyAll(); + return JNI_FALSE; } if (desc.cStencilBits < stencilBits) { |
|
From: Tristan C. <ex...@us...> - 2003-01-31 01:17:23
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx/altivec In directory sc8-pr-cvs1:/tmp/cvs-serv23989a Added Files: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp Log Message: First draft of a altivec copy with cache prefetch --- NEW FILE: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/altivec/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp /* * Copyright (c) 2002 Light Weight Java Game Library 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 'Light Weight Java Game Library' 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. */ /* remember to turn on the -faltivec flag for gcc compilation */ /** * $Id: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp,v 1.1 2003/01/31 01:17:19 exocet Exp $ * * math library. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ #ifdef _WIN32 #include <windows.h> #endif #include <string.h> #include "org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.h" #include "MatrixOpCommon.h" void altivec_CopyPackedSafe (char * src, char * dst, int length); /* * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe * Method: execute * Signature: (IIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpSafe_execute ( JNIEnv * env, jobject obj, jint sourceAddress, jint sourceStride, jint numElements, jint sourceWidth, jint sourceHeight, jboolean transposeSource, jint destAddress, jint destStride, jboolean transposeDest ) { // remove any unnecessary copying if (transposeSource == transposeDest) { transposeSource = false; transposeDest = false; } /* handle all cases where the data is packed and transposition is not necessary */ if ((transposeSource == transposeDest) && ((sourceWidth * sourceHeight * 4) == sourceStride)) { altivec_CopyPackedSafe((char *)sourceAddress, (char *)destAddress, numElements*sourceWidth*sourceHeight*4); return; } MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); float * srcMatrix, * destMatrix; int matrixByteCount = source.width*source.height*sizeof(jfloat); for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest.nextMatrix(); // just do a straight memory copy memcpy(destMatrix, srcMatrix, matrixByteCount); dest.writeComplete(); } } void altivec_CopyPackedSafe (char * src, char * dst, int length) { int src_a = (int)src; int dst_a = (int)dst; //std::cout << "src: " << src_a << " dst: " << dst_a <<"\n"; if ((src_a & 0x0F) == (dst_a & 0x0F)) { //std::cout << "same alignment\n" << "\n"; int first_bytes = 16 - ((int)(src) & 0x0000000F); //std::cout << "first bytes" << first_bytes << "\n"; int i = first_bytes; if (first_bytes > length) first_bytes = length; if (first_bytes == 16) first_bytes = 0; while (i--) dst[i] = src[i]; src = &src[first_bytes]; dst = &dst[first_bytes]; length -= first_bytes; //std::cout << "new length" << length << "\n"; // figure out how many 16 byte chunks there are int middle_cycles = (length >> 4); // ignore any other bytes length -= (middle_cycles << 4); while (middle_cycles --) { // load a vector, set the cache line to be LRU vector float a = (vector float) vec_ldl(0, (float *) src); src += 16; // write it back, set cache line LRU, gets flushed back to RAM (not L2 or L3) vec_stl(a, 0, (float *) dst); dst += 16; } // write back any remaining bytes while(length--) dst[length] = src[length]; } else { //std::cout << "different alignment\n"; // differing offsets (byte by byte copy) while (length--) dst[length] = src[length]; } } |
|
From: Gregory P. <gre...@us...> - 2003-01-30 18:57:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv31694/native/macosx Modified Files: org_lwjgl_opengl_BaseGL.cpp org_lwjgl_Display.cpp RenderingContext.h RenderingContext.cpp Log Message: Added changes to support the selection of display modes on OSX in multiple monitor configurations. Currently defaults to only getting the display modes of display[0] - the primary display since lwjgl doesn't yet support clean multi monitor configuration programatically. This code based off the Apple provided sample code at http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/Mode.htm Index: org_lwjgl_opengl_BaseGL.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- org_lwjgl_opengl_BaseGL.cpp 1 Jan 2003 03:58:03 -0000 1.4 +++ org_lwjgl_opengl_BaseGL.cpp 30 Jan 2003 18:56:55 -0000 1.5 @@ -42,9 +42,6 @@ #include "RenderingContext.h" #include "org_lwjgl_opengl_BaseGL.h" - - - /* * Class: org_lwjgl_opengl_BaseGL * Method: nCreate Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_Display.cpp 1 Jan 2003 03:58:03 -0000 1.7 +++ org_lwjgl_Display.cpp 30 Jan 2003 18:56:56 -0000 1.8 @@ -36,6 +36,20 @@ RenderingContext * renderingContext; +static int numberForKey( CFDictionaryRef desc, CFStringRef key ) +{ + CFNumberRef value; + int num = 0; + + if ( (value = CFDictionaryGetValue(desc, key)) == NULL ) + { + return 0; + } + + CFNumberGetValue( value, kCFNumberIntType, &num ); + return num; +} + /* * Class: org_lwjgl_Display * Method: getAvailableDisplayModes @@ -44,7 +58,54 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_getAvailableDisplayModes (JNIEnv * env, jclass clazz) { - return NULL; + CGDirectDisplayID * displays = renderingContext->enumerateDisplays(); + CFArrayRef modeList = renderingContext->enumerateDisplayModes( displays[0] ); + + // count the display modes + // + int cnt = CFArrayGetCount( modeList ); + + // Allocate an array of DisplayModes big enough + jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode"); + + // Note the * 16 - this is because we are manufacturing available alpha/depth/stencil combos. + jobjectArray ret = env->NewObjectArray(cnt * 16, displayModeClass, NULL); + jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIIIIII)V"); + + CFDictionaryRef mode; + for ( int i=0; i< cnt; i++ ) + { + mode = CFArrayGetValueAtIndex( modeList, i ); + + int width = numberForKey( mode, kCGDisplayWidth ); + int height = numberForKey( mode, kCGDisplayHeight ); + int bpp = numberForKey( mode, kCGDisplayBitsPerPixel ); + int refreshRate = numberForKey( mode, kCGDisplayRefreshRate ); + + if ( bpp <= 8 ) + { + continue; + } + else + { + jobject displayMode; + + for ( int depthBits = 0; depthBits <= 24; depthBits += 8 ) + { + for ( int stencilBits = 0; stencilBits <= 8; stencilBits += 8 ) + { + for ( int alphaBits = 0; alphaBits <= 8; alphaBits += 8 ) + { + displayMode = env->NewObject(displayModeClass, displayModeConstructor, + width, height, bpp, refreshRate, + alphaBits, depthBits, stencilBits ); + + env->SetObjectArrayElement( ret, i, displayMode ); + } + } + } + } + } } /* @@ -66,6 +127,10 @@ jfieldID fid_handle = env->GetStaticFieldID(clazz, "handle", "I"); env->SetStaticIntField(clazz, fid_handle, (jint) renderingContext->windowPtr ); + +#ifdef _DEBUG + printf("Display created\n"); +#endif return JNI_TRUE; } Index: RenderingContext.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/RenderingContext.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/RenderingContext.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- RenderingContext.h 2 Jan 2003 05:44:15 -0000 1.5 +++ RenderingContext.h 30 Jan 2003 18:56:56 -0000 1.6 @@ -45,6 +45,7 @@ #include "extgl.h" #include <Carbon/Carbon.h> +#include <ApplicationServices/ApplicationServices.h> class RenderingContext { @@ -59,6 +60,8 @@ bool createDisplay( int width, int height, int bpp, int freq ); void destroyDisplay(); + CGDirectDisplayID * enumerateDisplays(); + CFArrayRef enumerateDisplayModes( CGDirectDisplayID display ); bool createGL( int colorBits, int alphaBits, int depthBits, int stencilBits ); void destroyGL(); Index: RenderingContext.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/RenderingContext.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/RenderingContext.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- RenderingContext.cpp 2 Jan 2003 05:44:15 -0000 1.5 +++ RenderingContext.cpp 30 Jan 2003 18:56:56 -0000 1.6 @@ -41,6 +41,10 @@ #include "RenderingContext.h" +#define kMaxDisplays 16 + +CGDirectDisplayID display[kMaxDisplays]; + RenderingContext::RenderingContext() { } @@ -78,6 +82,41 @@ // DisposeWindow( windowPtr ); } + +CGDirectDisplayID * RenderingContext::enumerateDisplays() +{ + + CGDisplayCount numDisplays; + CGDisplayErr err; + + err = CGGetActiveDisplayList( kMaxDisplays, + display, + &numDisplays ); + + if ( err != CGDisplayNoErr ) + { + printf("Cannot get displays (%d). \n", err ); + } + + return display; +} + +CFArrayRef RenderingContext::enumerateDisplayModes( CGDirectDisplayID display ) +{ + CFArrayRef modeList; + + modeList = CGDisplayAvailableModes( display ); + if ( modeList = NULL ) + { + printf("Error. Display requested is invalid.\n"); + return NULL; + } + + return modeList; +} + + + bool RenderingContext::createGL( int colorBits, int alphaBits, int depthBits, int stencilBits ) { |
|
From: Brian M. <ma...@us...> - 2003-01-29 21:34:46
|
Update of /cvsroot/java-game-lib/LWJGL/website/documents/tutorials/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv14777 Modified Files: skeleton_code.html Log Message: made compatible with 0.4 Index: skeleton_code.html CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/website/documents/tutorials/opengl/skeleton_code.html =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/website/documents/tutorials/opengl/skeleton_code.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- skeleton_code.html 20 Dec 2002 21:23:31 -0000 1.1 +++ skeleton_code.html 29 Jan 2003 21:34:43 -0000 1.2 @@ -141,133 +141,161 @@ <p>Your mileage may vary...</p> <p>4.2 Show Me The Money</p> <p>Ok, ok, without further ado, here is a skeleton listing which you can use to -write a fullscreen Java game using LWJGL. Because we're games programmers, we +write a Java game using LWJGL. Because we're games programmers, we don't want to do a Hello World as we'd probably rather shoot it. But before we can make bullets we must pay homage to the <i>rotating square!</i></p> -<p style="background-color: #FFFFCC; border-style: solid; border-width: 1; padding: 3"><code>import -org.lwjgl.*;<br> -import org.lwjgl.opengl.*;<br> -import org.lwjgl.input.*;<br> -<br> -<br> -public -final class Game {<br> - static {<br> - try {<br> - DisplayMode[] modes = Display.getAvailableDisplayModes();<br> - System.out.println("Available display modes:");<br> - for (int i = 0; i < modes.length; i ++)<br> - -System.out.println(modes[i]);<br> - // For now let's just pick a mode we're certain to have<br> - Display.create(new DisplayMode(640, 480, 16, 60), true);<br> - System.out.println("Created display.");<br> - } catch (Exception e) {<br> - System.err.println("Failed to create display due to "+e);<br> - System.exit(1);<br> - }<br> - }<br> -<br> - public static final GL gl = new GL(16, 0, 16, 8);<br> - static {<br> - try {<br> - gl.create();<br> - System.out.println("Created OpenGL.");<br> - } catch (Exception e) {<br> - System.err.println("Failed to create OpenGL due to "+e);<br> - System.exit(1);<br> - }<br> - }<br> -<br> - /** Is the game finished? */<br> - private static boolean finished;<br> -<br> - /** A rotating square! */<br> - private static float angle;<br> -<br> - /**<br> - * No construction allowed<br> - */<br> - private Game() {<br> - }<br> -<br> - public static void main(String[] arguments) {<br> - try {<br> - init();<br> - while (!finished) {<br> - -Keyboard.poll();<br> - -mainLoop();<br> - -render();<br> - -gl.swapBuffers();<br> - }</code> <code><br> - } catch (Throwable t) {<br> - -t.printStackTrace();<br> - } finally {<br> - cleanup();<br> - }<br> - }<br> -<br> - /**<br> - * All calculations are done in here<br> - */<br> - private static void mainLoop() {<br> - angle += 1f;<br> - if (angle > 360.0f)<br> - angle = 0.0f;<br> -<br> - Keyboard.poll(); -<br> - if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))<br> - finished = true;<br> - }<br> -<br> - /**<br> - * All rendering is done in here<br> - */<br> - private static void render() {<br> - gl.clear(GL.COLOR_BUFFER_BIT);<br> - gl.pushMatrix();<br> - gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f);<br> - gl.rotatef(angle, 0, 0, 1.0f);<br> - gl.begin(GL.QUADS);<br> - gl.vertex2i(-50, -50);<br> - gl.vertex2i(50, -50);<br> - gl.vertex2i(50, 50);<br> - gl.vertex2i(-50, 50);<br> - gl.end();<br> - gl.popMatrix();<br> - }<br> -<br> - /**<br> - * Initialize<br> - */<br> - private static void init() throws Exception {<br> - Keyboard.create();<br> - // Go into orthographic projection mode.<br> - gl.matrixMode(GL.PROJECTION);<br> - gl.loadIdentity();<br> - glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight());<br> - gl.matrixMode(GL.MODELVIEW);<br> - gl.loadIdentity();<br> - gl.viewport(0, 0, Display.getWidth(), Display.getHeight());<br> - // Fix the refresh rate to the display frequency.<br> - gl.wglSwapIntervalEXT(1);<br> - }<br> -<br> - /**<br> - * Cleanup<br> - */<br> - private static void cleanup() {<br> - Keyboard.destroy();<br> - </code> <code>gl.destroy();<br> - Display.destroy();<br> - }<br> -}</code></p> +<pre style="border-style: solid; border-width: 1px; padding: 3px; background-color: rgb(255,255,204);"> +import org.lwjgl.*; +import org.lwjgl.opengl.*; +import org.lwjgl.input.*; + +import java.nio.*; + +public final class Game { + static { + try { + //find first display mode that allows us 640*480*16 + int mode = -1; + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for (int i = 0; i < modes.length; i++) { + if (modes[i].width == 640 + && modes[i].height == 480 + && modes[i].bpp >= 16) { + mode = i; + break; + } + } + + //select above found displaymode + Display.create(modes[mode], false); + System.out.println("Created display."); + } catch (Exception e) { + System.err.println("Failed to create display due to " + e); + System.exit(1); + } + } + + public static final GL gl = new GL(); + public static final GLU glu = new GLU(gl); + + static { + try { + gl.create(); + System.out.println("Created OpenGL."); + } catch (Exception e) { + System.err.println("Failed to create OpenGL due to " + e); + System.exit(1); + } + } + + /** Is the game finished? */ + private static boolean finished; + + /** A rotating square! */ + private static float angle; + + /** + * No construction allowed + */ + private Game() { + } + + public static void main(String[] arguments) { + try { + init(); + while (!finished) { + Keyboard.poll(); + + mainLoop(); + + render(); + + gl.swapBuffers(); + } + } catch (Throwable t) { + t.printStackTrace(); + } finally { + cleanup(); + } + } + + /** + * All calculations are done in here + */ + private static void mainLoop() { + angle += 1f; + if (angle > 360.0f) + angle = 0.0f; + + if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { + finished = true; + } + } + + /** + * All rendering is done in here + */ + private static void render() { + gl.clear(GL.COLOR_BUFFER_BIT); + gl.pushMatrix(); + gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); + gl.rotatef(angle, 0, 0, 1.0f); + gl.begin(GL.QUADS); + { + gl.vertex2i(-50, -50); + gl.vertex2i(50, -50); + gl.vertex2i(50, 50); + gl.vertex2i(-50, 50); + } + gl.end(); + gl.popMatrix(); + } + + /** + * Initialize + */ + private static void init() throws Exception { + System.out.println("Press the ESCAPE key to exit"); + + Keyboard.create(); + + //reset time + Sys.setTime(0); + + //set priority of this process + Sys.setProcessPriority(Sys.LOW_PRIORITY); + + //print timer resolution info + System.out.println("Timer resolution: " + Sys.getTimerResolution() + " ticks per second"); + + // Go into orthographic projection mode. + gl.matrixMode(GL.PROJECTION); + gl.loadIdentity(); + glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight()); + gl.matrixMode(GL.MODELVIEW); + gl.loadIdentity(); + gl.viewport(0, 0, Display.getWidth(), Display.getHeight()); + + //lets print out some info + ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4); + num_tex_units_buf.order(ByteOrder.nativeOrder()); + int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf); + gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr); + + System.out.println( + "Number of texture units: " + num_tex_units_buf.getInt()); + } + + /** + * Cleanup + */ + private static void cleanup() { + Keyboard.destroy(); + gl.destroy(); + Display.destroy(); + } +} +</pre> </body> |
|
From: Brian M. <ma...@us...> - 2003-01-29 21:34:21
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv14391 Modified Files: Game.java Log Message: cleaned up removed some stuff (specifically buffered mouse mode) Index: Game.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/Game.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/Game.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Game.java 22 Dec 2002 22:42:13 -0000 1.6 +++ Game.java 29 Jan 2003 21:34:15 -0000 1.7 @@ -45,147 +45,149 @@ import org.lwjgl.opengl.*; import org.lwjgl.input.*; -import java.nio.*; +import java.nio.*; public final class Game { - static { - try { - int mode = -1; - DisplayMode[] modes = Display.getAvailableDisplayModes(); - for (int i = 0; i < modes.length; i ++) { - if( modes[i].width == 640 && - modes[i].height == 480 && - modes[i].bpp >= 16) { - mode = i; - break; - } - } - // For now let's just pick a mode we're certain to have - Display.create(modes[mode], false); - System.out.println("Created display."); - } catch (Exception e) { - System.err.println("Failed to create display due to "+e); - System.exit(1); - } - } - - public static final GL gl = new GL(); - public static final GLU glu = new GLU(gl); - static { - try { - gl.create(); - System.out.println("Created OpenGL."); - } catch (Exception e) { - System.err.println("Failed to create OpenGL due to "+e); - System.exit(1); - } - } - - /** Is the game finished? */ - private static boolean finished; - - /** A rotating square! */ - private static float angle; - - /** - * No construction allowed - */ - private Game() { - } - - public static void main(String[] arguments) { - try { - init(); - while (!finished) { -// Keyboard.poll(); - mainLoop(); - render(); - gl.swapBuffers(); - } - } catch (Throwable t) { - t.printStackTrace(); - } finally { - cleanup(); - } - } - - /** - * All calculations are done in here - */ - private static void mainLoop() { - angle += 1f; - if (angle > 360.0f) - angle = 0.0f; - - Mouse.poll(); - if (Mouse.dx != 0 || Mouse.dy != 0 || Mouse.dz != 0) - System.out.println("Mouse moved " + Mouse.dx + " " + Mouse.dy + " " + Mouse.dz); - for (int i = 0; i < 8; i++) - if (Mouse.isButtonDown(i)) - System.out.println("Button " + i + " down"); -/* Keyboard.poll(); - if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) - finished = true;*/ - Keyboard.read(); - for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { - Keyboard.next(); - if (Keyboard.key == Keyboard.KEY_ESCAPE && Keyboard.state) - finished = true; - if (Keyboard.key == Keyboard.KEY_T && Keyboard.state) - System.out.println("Current time: " + Sys.getTime()); - } - } - - /** - * All rendering is done in here - */ - private static void render() { - gl.clear(GL.COLOR_BUFFER_BIT); - gl.pushMatrix(); - gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); - gl.rotatef(angle, 0, 0, 1.0f); - gl.begin(GL.QUADS); - gl.vertex2i(-50, -50); - gl.vertex2i(50, -50); - gl.vertex2i(50, 50); - gl.vertex2i(-50, 50); - gl.end(); - gl.popMatrix(); - } - - /** - * Initialize - */ - private static void init() throws Exception { - Keyboard.create(); - Keyboard.enableBuffer(); - Mouse.create(); - Sys.setTime(0); - Sys.setProcessPriority(Sys.HIGH_PRIORITY); - System.out.println("Timer resolution: " + Sys.getTimerResolution()); - // Go into orthographic projection mode. - gl.matrixMode(GL.PROJECTION); - gl.loadIdentity(); - glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight()); - gl.matrixMode(GL.MODELVIEW); - gl.loadIdentity(); - gl.viewport(0, 0, Display.getWidth(), Display.getHeight()); - ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4); - num_tex_units_buf.order(ByteOrder.nativeOrder()); - int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf); - gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr); - System.out.println("Number of texture units: " + num_tex_units_buf.getInt()); - // Fix the refresh rate to the display frequency. -// gl.wglSwapIntervalEXT(1); - } - - /** - * Cleanup - */ - private static void cleanup() { - Keyboard.destroy(); - Mouse.destroy(); - gl.destroy(); - Display.destroy(); - } - } + static { + try { + //find first display mode that allows us 640*480*16 + int mode = -1; + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for (int i = 0; i < modes.length; i++) { + if (modes[i].width == 640 + && modes[i].height == 480 + && modes[i].bpp >= 16) { + mode = i; + break; + } + } + + //select above found displaymode + Display.create(modes[mode], false); + System.out.println("Created display."); + } catch (Exception e) { + System.err.println("Failed to create display due to " + e); + System.exit(1); + } + } + + public static final GL gl = new GL(); + public static final GLU glu = new GLU(gl); + + static { + try { + gl.create(); + System.out.println("Created OpenGL."); + } catch (Exception e) { + System.err.println("Failed to create OpenGL due to " + e); + System.exit(1); + } + } + + /** Is the game finished? */ + private static boolean finished; + + /** A rotating square! */ + private static float angle; + + /** + * No construction allowed + */ + private Game() { + } + + public static void main(String[] arguments) { + try { + init(); + while (!finished) { + Keyboard.poll(); + + mainLoop(); + + render(); + + gl.swapBuffers(); + } + } catch (Throwable t) { + t.printStackTrace(); + } finally { + cleanup(); + } + } + + /** + * All calculations are done in here + */ + private static void mainLoop() { + angle += 1f; + if (angle > 360.0f) + angle = 0.0f; + + if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { + finished = true; + } + } + + /** + * All rendering is done in here + */ + private static void render() { + gl.clear(GL.COLOR_BUFFER_BIT); + gl.pushMatrix(); + gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); + gl.rotatef(angle, 0, 0, 1.0f); + gl.begin(GL.QUADS); + { + gl.vertex2i(-50, -50); + gl.vertex2i(50, -50); + gl.vertex2i(50, 50); + gl.vertex2i(-50, 50); + } + gl.end(); + gl.popMatrix(); + } + + /** + * Initialize + */ + private static void init() throws Exception { + System.out.println("Press the ESCAPE key to exit"); + + Keyboard.create(); + + //reset time + Sys.setTime(0); + + //set priority of this process + Sys.setProcessPriority(Sys.LOW_PRIORITY); + + //print timer resolution info + System.out.println("Timer resolution: " + Sys.getTimerResolution() + " ticks per second"); + + // Go into orthographic projection mode. + gl.matrixMode(GL.PROJECTION); + gl.loadIdentity(); + glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight()); + gl.matrixMode(GL.MODELVIEW); + gl.loadIdentity(); + gl.viewport(0, 0, Display.getWidth(), Display.getHeight()); + + //lets print out some info + ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4); + num_tex_units_buf.order(ByteOrder.nativeOrder()); + int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf); + gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr); + + System.out.println( + "Number of texture units: " + num_tex_units_buf.getInt()); + } + + /** + * Cleanup + */ + private static void cleanup() { + Keyboard.destroy(); + gl.destroy(); + Display.destroy(); + } +} \ No newline at end of file |
|
From: Tristan C. <ex...@us...> - 2003-01-27 21:09:12
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx/altivec In directory sc8-pr-cvs1:/tmp/cvs-serv25144/altivec Log Message: Directory /cvsroot/java-game-lib/LWJGL/src/native/macosx/altivec added to the repository |
|
From: Brian M. <ma...@us...> - 2003-01-23 21:38:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv31735 Modified Files: org_lwjgl_input_Controller.cpp Log Message: added rotational axis too Index: org_lwjgl_input_Controller.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_input_Controller.cpp 23 Jan 2003 21:14:04 -0000 1.3 +++ org_lwjgl_input_Controller.cpp 23 Jan 2003 21:38:33 -0000 1.4 @@ -56,8 +56,11 @@ int buttoncount = 0; // Temporary buttoncount bool hasx; // Temporary xaxis check +bool hasrx; // Temporary rotational xaxis check bool hasy; // Temporary yaxis check +bool hasry; // Temporary rotational yaxis check bool hasz; // Temporary zaxis check +bool hasrz; // Temporary rotational zaxis check bool haspov; // Temporary pov check bool hasslider; // Temporary slider check @@ -69,14 +72,20 @@ jclass clsController; jfieldID fidButtonCount; jfieldID fidHasXAxis; +jfieldID fidHasRXAxis; jfieldID fidHasYAxis; +jfieldID fidHasRYAxis; jfieldID fidHasZAxis; +jfieldID fidHasRZAxis; jfieldID fidHasPOV; jfieldID fidHasSlider; jfieldID fidButtons; jfieldID fidX; +jfieldID fidRX; jfieldID fidY; +jfieldID fidRY; jfieldID fidZ; +jfieldID fidRZ; jfieldID fidPOV; jfieldID fidSlider; @@ -271,6 +280,12 @@ haspov = true; } else if (lpddoi->guidType == GUID_Slider){ hasslider = true; + } else if (lpddoi->guidType == GUID_RxAxis) { + hasrx = true; + } else if (lpddoi->guidType == GUID_RyAxis) { + hasry = true; + } else if (lpddoi->guidType == GUID_RzAxis) { + hasrz = true; #if _DEBUG } else { printf("Unhandled object found: %s\n", lpddoi->tszName); @@ -316,18 +331,19 @@ create_success = false; return; } - - // set X-axis range to (-1000 ... +1000) + + // set range to (-1000 ... +1000) // This lets us test against 0 to see which way the stick is pointed. DIPROPRANGE diprg; diprg.diph.dwSize = sizeof(diprg); diprg.diph.dwHeaderSize = sizeof(diprg.diph); - diprg.diph.dwObj = DIJOFS_X; diprg.diph.dwHow = DIPH_BYOFFSET; diprg.lMin = AXISMIN; diprg.lMax = AXISMAX; + // set X-axis if(hasx) { + diprg.diph.dwObj = DIJOFS_X; if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { #if _DEBUG printf("SetProperty(DIJOFS_X) failed\n"); @@ -337,9 +353,20 @@ } } - // - // And again for Y-axis range - // + // set RX-axis + if(hasrx) { + diprg.diph.dwObj = DIJOFS_RX; + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_RX) failed\n"); +#endif + create_success = false; + return; + } + } + + + // set Y-axis if(hasy) { diprg.diph.dwObj = DIJOFS_Y; if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { @@ -351,9 +378,19 @@ } } - // - // And again for Z-axis range - // + // set RY-axis + if(hasry) { + diprg.diph.dwObj = DIJOFS_RY; + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_RY) failed\n"); +#endif + create_success = false; + return; + } + } + + // set Z-axis if(hasz) { diprg.diph.dwObj = DIJOFS_Z; if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { @@ -365,6 +402,19 @@ } } + + // set RZ-axis + if(hasrz) { + diprg.diph.dwObj = DIJOFS_RZ; + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_RZ) failed\n"); +#endif + create_success = false; + return; + } + } + // // Lastly slider // using z axis since we're running dx 5 @@ -414,17 +464,30 @@ //axis's if(hasx) { - environment->SetStaticIntField(clsController, fidX, js.lX); + environment->SetStaticIntField(clsController, fidX, js.lX); } if(hasy) { - environment->SetStaticIntField(clsController, fidY, js.lY); + environment->SetStaticIntField(clsController, fidY, js.lY); } if(hasz) { environment->SetStaticIntField(clsController, fidZ, js.lZ); } + //rotational axis + if(hasrx) { + environment->SetStaticIntField(clsController, fidRX, js.lRx); + } + + if(hasry) { + environment->SetStaticIntField(clsController, fidRY, js.lRy); + } + + if(hasrz) { + environment->SetStaticIntField(clsController, fidRZ, js.lRz); + } + //buttons jbooleanArray buttonsArray = (jbooleanArray) environment->GetStaticObjectField(clsController, fidButtons); BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); @@ -454,6 +517,11 @@ environment->SetStaticIntField(clsController, fidHasYAxis, hasy); environment->SetStaticIntField(clsController, fidHasZAxis, hasz); + //set rotational axis + environment->SetStaticIntField(clsController, fidHasRXAxis, hasrx); + environment->SetStaticIntField(clsController, fidHasRYAxis, hasry); + environment->SetStaticIntField(clsController, fidHasRZAxis, hasrz); + //set pov environment->SetStaticIntField(clsController, fidHasPOV, haspov); @@ -467,14 +535,20 @@ void CacheFields() { fidButtonCount = environment->GetStaticFieldID(clsController, "buttonCount", "I"); fidHasXAxis = environment->GetStaticFieldID(clsController, "hasXAxis", "Z"); + fidHasRXAxis = environment->GetStaticFieldID(clsController, "hasRXAxis", "Z"); fidHasYAxis = environment->GetStaticFieldID(clsController, "hasYAxis", "Z"); + fidHasRYAxis = environment->GetStaticFieldID(clsController, "hasRYAxis", "Z"); fidHasZAxis = environment->GetStaticFieldID(clsController, "hasZAxis", "Z"); + fidHasRZAxis = environment->GetStaticFieldID(clsController, "hasRZAxis", "Z"); fidHasPOV = environment->GetStaticFieldID(clsController, "hasPOV", "Z"); fidHasSlider = environment->GetStaticFieldID(clsController, "hasSlider", "Z"); fidButtons = environment->GetStaticFieldID(clsController, "buttons", "[Z"); fidX = environment->GetStaticFieldID(clsController, "x", "I"); + fidRX = environment->GetStaticFieldID(clsController, "rx", "I"); fidY = environment->GetStaticFieldID(clsController, "y", "I"); + fidRY = environment->GetStaticFieldID(clsController, "ry", "I"); fidZ = environment->GetStaticFieldID(clsController, "z", "I"); + fidRZ = environment->GetStaticFieldID(clsController, "rz", "I"); fidPOV = environment->GetStaticFieldID(clsController, "pov", "I"); fidSlider = environment->GetStaticFieldID(clsController, "slider", "I"); } |
|
From: Brian M. <ma...@us...> - 2003-01-23 21:38:23
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1:/tmp/cvs-serv31627 Modified Files: Controller.java Log Message: added rotational axis too Index: Controller.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Controller.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Controller.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Controller.java 3 Jan 2003 18:47:41 -0000 1.1 +++ Controller.java 23 Jan 2003 21:38:18 -0000 1.2 @@ -67,13 +67,22 @@ /** X position, range -1000 to 1000 */ public static int x = 0; - + + /** X rotational position, range -1000 to 1000 */ + public static int rx = 0; + /** Y position, range -1000 to 1000 */ public static int y = 0; - + + /** Y rotational position, range -1000 to 1000 */ + public static int ry = 0; + /** Z position, range -1000 to 1000 */ public static int z = 0; + /** Z rotational position, range -1000 to 1000 */ + public static int rz = 0; + /** Position of Point of View from -1 to 27000 (360 degrees) */ public static int pov; @@ -98,8 +107,11 @@ /* Controller capabilities */ public static int buttonCount = -1; public static boolean hasXAxis = false; + public static boolean hasRXAxis = false; public static boolean hasYAxis = false; - public static boolean hasZAxis = false; + public static boolean hasRYAxis = false; + public static boolean hasZAxis = false; + public static boolean hasRZAxis = false; public static boolean hasPOV = false; public static boolean hasSlider = false; |
|
From: Brian M. <ma...@us...> - 2003-01-23 21:38:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1:/tmp/cvs-serv31491 Modified Files: ControllerTest.java Log Message: added rotational axis too Index: ControllerTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ControllerTest.java 23 Jan 2003 21:11:16 -0000 1.2 +++ ControllerTest.java 23 Jan 2003 21:38:06 -0000 1.3 @@ -95,18 +95,33 @@ if(Controller.hasXAxis) { g.drawString("x : " + Controller.x, x, y); y += 20; - } + } + + if(Controller.hasRXAxis) { + g.drawString("rx : " + Controller.rx, x, y); + y += 20; + } if(Controller.hasYAxis) { g.drawString("y : " + Controller.y, x, y); y += 20; } + if(Controller.hasRYAxis) { + g.drawString("ry : " + Controller.ry, x, y); + y += 20; + } + if (Controller.hasZAxis) { g.drawString("z : " + Controller.z, x, y); y += 20; } + if (Controller.hasRZAxis) { + g.drawString("rz : " + Controller.rz, x, y); + y += 20; + } + if (Controller.hasPOV) { g.drawString("pov: " + Controller.pov, x, y); y += 20; |
|
From: Brian M. <ma...@us...> - 2003-01-23 21:14:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv18579 Modified Files: org_lwjgl_input_Controller.cpp Log Message: small comment on using z axis as slider Index: org_lwjgl_input_Controller.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_input_Controller.cpp 23 Jan 2003 21:11:01 -0000 1.2 +++ org_lwjgl_input_Controller.cpp 23 Jan 2003 21:14:04 -0000 1.3 @@ -367,6 +367,7 @@ // // Lastly slider + // using z axis since we're running dx 5 // if(hasslider) { diprg.diph.dwObj = DIJOFS_Z; |
|
From: Brian M. <ma...@us...> - 2003-01-23 21:11:21
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1:/tmp/cvs-serv17129 Modified Files: ControllerTest.java Log Message: new and improved version - w00t Index: ControllerTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ControllerTest.java 3 Jan 2003 18:47:41 -0000 1.1 +++ ControllerTest.java 23 Jan 2003 21:11:16 -0000 1.2 @@ -91,18 +91,31 @@ y += 20; g.drawString("-----------------------------------------------", x, y); y += 20; - g.drawString("x : " + Controller.x, x, y); - y += 20; - g.drawString("y : " + Controller.y, x, y); - y += 20; - if (Controller.hasZAxis) { + + if(Controller.hasXAxis) { + g.drawString("x : " + Controller.x, x, y); + y += 20; + } + + if(Controller.hasYAxis) { + g.drawString("y : " + Controller.y, x, y); + y += 20; + } + + if (Controller.hasZAxis) { g.drawString("z : " + Controller.z, x, y); y += 20; } - if (Controller.hasPOV) { + + if (Controller.hasPOV) { g.drawString("pov: " + Controller.pov, x, y); y += 20; } + + if (Controller.hasSlider) { + g.drawString("slder: " + Controller.slider, x, y); + y += 20; + } //paint buttons g.drawString("btn: ", x, y); |
|
From: Brian M. <ma...@us...> - 2003-01-23 21:11:09
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv16966 Modified Files: org_lwjgl_input_Controller.cpp Log Message: new and improved version - w00t Index: org_lwjgl_input_Controller.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_input_Controller.cpp 3 Jan 2003 18:47:42 -0000 1.1 +++ org_lwjgl_input_Controller.cpp 23 Jan 2003 21:11:01 -0000 1.2 @@ -55,8 +55,11 @@ DIJOYSTATE2 js; // State of Controller int buttoncount = 0; // Temporary buttoncount +bool hasx; // Temporary xaxis check +bool hasy; // Temporary yaxis check bool hasz; // Temporary zaxis check bool haspov; // Temporary pov check +bool hasslider; // Temporary slider check JNIEnv* environment; // JNIEnvironment copy @@ -65,13 +68,17 @@ // Cached fields of Controller.java jclass clsController; jfieldID fidButtonCount; +jfieldID fidHasXAxis; +jfieldID fidHasYAxis; jfieldID fidHasZAxis; jfieldID fidHasPOV; +jfieldID fidHasSlider; jfieldID fidButtons; jfieldID fidX; jfieldID fidY; jfieldID fidZ; jfieldID fidPOV; +jfieldID fidSlider; // Function prototypes (defined in the cpp file, since header file is generic across platforms void EnumerateCapabilities(); @@ -106,6 +113,9 @@ HRESULT hr; hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); if (FAILED(hr)) { +#if _DEBUG + printf("DirectInputCreate failed\n"); +#endif Shutdown(); return JNI_FALSE; } @@ -113,6 +123,9 @@ /* Find all Controllers */ EnumerateControllers(); if (!create_success) { +#if _DEBUG + printf("EnumerateControllers failed\n"); +#endif Shutdown(); return JNI_FALSE; } @@ -120,10 +133,18 @@ /* Enumerate capabilities of Controller */ EnumerateCapabilities(); if (!create_success) { +#if _DEBUG + printf("EnumerateCapabilities failed\n"); +#endif Shutdown(); return JNI_FALSE; } + if(create_success) { + /* Do setup of Controller */ + SetupController(); + } + /* Initialize any fields on the Controller */ InitializeFields(); @@ -133,10 +154,12 @@ /* Aquire the Controller */ hr = lpDIDevice->Acquire(); if(FAILED(hr)) { +#if _DEBUG + printf("Acquire failed\n"); +#endif Shutdown(); return JNI_FALSE; } - return create_success; } @@ -193,6 +216,9 @@ HRESULT hr; hr = lpDIDevice->EnumObjects(EnumControllerObjectsCallback, NULL, DIDFT_ALL); if FAILED(hr) { +#if _DEBUG + printf("EnumObjects failed\n"); +#endif create_success = false; return; } @@ -206,6 +232,9 @@ HRESULT hr; hr = lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY); if FAILED(hr) { +#if _DEBUG + printf("EnumDevices failed\n"); +#endif create_success = false; return; } @@ -218,10 +247,6 @@ BOOL CALLBACK EnumControllerCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { /* Add the Controller */ CreateController(pdinst); - if(create_success) { - /* Do setup of Controller */ - SetupController(); - } /* just stop after 1st Controller */ return DIENUM_STOP; @@ -231,16 +256,23 @@ * Callback from EnumObjects. Called for each "object" on the Controller. */ BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { +#if _DEBUG + printf("found %s\n", lpddoi->tszName); +#endif if(lpddoi->guidType == GUID_Button) { buttoncount++; - } else if(lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis) { - //do nothing - } else if(lpddoi->guidType == GUID_ZAxis || strcmp("Throttle", lpddoi->tszName) == 0){ + } else if(lpddoi->guidType == GUID_XAxis) { + hasx = true; + } else if(lpddoi->guidType == GUID_YAxis) { + hasy = true; + } else if(lpddoi->guidType == GUID_ZAxis){ hasz = true; } else if (lpddoi->guidType == GUID_POV){ haspov = true; + } else if (lpddoi->guidType == GUID_Slider){ + hasslider = true; +#if _DEBUG } else { -#ifdef _DEBUG printf("Unhandled object found: %s\n", lpddoi->tszName); #endif } @@ -254,6 +286,9 @@ HRESULT hr; hr = lpDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &lpDIDevice, NULL); if FAILED(hr) { +#if _DEBUG + printf("CreateDevice failed\n"); +#endif create_success = false; return; } @@ -266,12 +301,18 @@ void SetupController() { // set Controller data format if(lpDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { +#if _DEBUG + printf("SetDataFormat failed\n"); +#endif create_success = false; return; } // set the cooperative level if(lpDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { +#if _DEBUG + printf("SetCooperativeLevel failed\n"); +#endif create_success = false; return; } @@ -286,30 +327,56 @@ diprg.lMin = AXISMIN; diprg.lMax = AXISMAX; - if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { - create_success = false; - return; + if(hasx) { + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_X) failed\n"); +#endif + create_success = false; + return; + } } // // And again for Y-axis range // - diprg.diph.dwObj = DIJOFS_Y; - - if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) - { - create_success = false; - return; + if(hasy) { + diprg.diph.dwObj = DIJOFS_Y; + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_Y) failed\n"); +#endif + create_success = false; + return; + } } // - // And again for z-axis range (throttle) + // And again for Z-axis range // - diprg.diph.dwObj = DIJOFS_Z; + if(hasz) { + diprg.diph.dwObj = DIJOFS_Z; + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_Z) failed\n"); +#endif + create_success = false; + return; + } + } - if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { - create_success = false; - return; + // + // Lastly slider + // + if(hasslider) { + diprg.diph.dwObj = DIJOFS_Z; + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { +#if _DEBUG + printf("SetProperty(DIJOFS_Z(SLIDER)) failed\n"); +#endif + create_success = false; + return; + } } create_success = true; } @@ -338,15 +405,21 @@ if(hRes == DIERR_INPUTLOST) { lpDIDevice->Acquire(); #if _DEBUG - printf("DIERR_INPUTLOST, reaquiring input\n"); + printf("DIERR_INPUTLOST, reaquiring input : create_success=%d\n", create_success); #endif } return; } //axis's - environment->SetStaticIntField(clsController, fidX, js.lX); - environment->SetStaticIntField(clsController, fidY, js.lY); + if(hasx) { + environment->SetStaticIntField(clsController, fidX, js.lX); + } + + if(hasy) { + environment->SetStaticIntField(clsController, fidY, js.lY); + } + if(hasz) { environment->SetStaticIntField(clsController, fidZ, js.lZ); } @@ -361,6 +434,11 @@ if(haspov) { environment->SetStaticIntField(clsController, fidPOV, js.rgdwPOV[0]); } + + //slider + if(hasslider) { + environment->SetStaticIntField(clsController, fidSlider, js.lZ); + } } /** @@ -370,11 +448,16 @@ //set buttoncount environment->SetStaticIntField(clsController, fidButtonCount, buttoncount); - //set z axis + //set axis + environment->SetStaticIntField(clsController, fidHasXAxis, hasx); + environment->SetStaticIntField(clsController, fidHasYAxis, hasy); environment->SetStaticIntField(clsController, fidHasZAxis, hasz); //set pov environment->SetStaticIntField(clsController, fidHasPOV, haspov); + + //set slider + environment->SetStaticIntField(clsController, fidHasSlider, hasslider); } /** @@ -382,11 +465,15 @@ */ void CacheFields() { fidButtonCount = environment->GetStaticFieldID(clsController, "buttonCount", "I"); + fidHasXAxis = environment->GetStaticFieldID(clsController, "hasXAxis", "Z"); + fidHasYAxis = environment->GetStaticFieldID(clsController, "hasYAxis", "Z"); fidHasZAxis = environment->GetStaticFieldID(clsController, "hasZAxis", "Z"); fidHasPOV = environment->GetStaticFieldID(clsController, "hasPOV", "Z"); + fidHasSlider = environment->GetStaticFieldID(clsController, "hasSlider", "Z"); fidButtons = environment->GetStaticFieldID(clsController, "buttons", "[Z"); fidX = environment->GetStaticFieldID(clsController, "x", "I"); fidY = environment->GetStaticFieldID(clsController, "y", "I"); fidZ = environment->GetStaticFieldID(clsController, "z", "I"); fidPOV = environment->GetStaticFieldID(clsController, "pov", "I"); + fidSlider = environment->GetStaticFieldID(clsController, "slider", "I"); } |
|
From: Brian M. <ma...@us...> - 2003-01-12 22:22:15
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1:/tmp/cvs-serv21497 Modified Files: WaveData.java Log Message: rem: not needed import Index: WaveData.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/WaveData.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/WaveData.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- WaveData.java 3 Jan 2003 01:14:29 -0000 1.4 +++ WaveData.java 12 Jan 2003 22:22:12 -0000 1.5 @@ -41,7 +41,6 @@ import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; -//import java.io.FileInputStream; import java.io.IOException; /** |
|
From: Elias N. <eli...@us...> - 2003-01-12 11:42:30
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv3764/linux Modified Files: org_lwjgl_Display.cpp Log Message: Bug fix Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_Display.cpp 28 Dec 2002 10:41:17 -0000 1.12 +++ org_lwjgl_Display.cpp 12 Jan 2003 11:42:27 -0000 1.13 @@ -363,7 +363,7 @@ printf("Could not load GL\n"); #endif XCloseDisplay(disp); - return JNI_FALSE; + return NULL; } if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { #ifdef _DEBUG |
|
From: Elias N. <eli...@us...> - 2003-01-11 23:09:41
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1:/tmp/cvs-serv20458/java/org/lwjgl/input Modified Files: Keyboard.java Log Message: Added keyboard translation to linux and win32 Index: Keyboard.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Keyboard.java 21 Dec 2002 12:37:18 -0000 1.15 +++ Keyboard.java 11 Jan 2003 23:09:38 -0000 1.16 @@ -33,6 +33,7 @@ package org.lwjgl.input; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import org.lwjgl.Display; import org.lwjgl.Sys; @@ -49,6 +50,18 @@ * @version $Revision$ */ public class Keyboard { + /** + * The special character meaning that no + * character was translated for the event. + */ + public static final char CHAR_NONE = '\0'; + + /** + * The special keycode meaning that only the + * translated character is valid. + */ + public static final int KEY_NONE = 0x00; + public static final int KEY_ESCAPE = 0x01; public static final int KEY_1 = 0x02; public static final int KEY_2 = 0x03; @@ -173,132 +186,6 @@ public static final int KEY_POWER = 0xDE; public static final int KEY_SLEEP = 0xDF; - // Maps keycodes to ascii characters - private static final char map[] = - { - 0, - 0, - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '0', - '-', - '=', - 0, - '\t', - 'q', - 'w', - 'e', - 'r', - 't', - 'y', - 'u', - 'i', - 'o', - 'p', - '[', - ']', - '\n', - 0, - 'a', - 's', - 'd', - 'f', - 'g', - 'h', - 'j', - 'k', - 'l', - ';', - '\'', - '#', - 0, - '\\', - 'z', - 'x', - 'c', - 'v', - 'b', - 'n', - 'm', - ',', - '.', - '/', - 0, - 0, - 0, - ' ' }; - private static final char shiftMap[] = - { - 0, - 0, - '!', - '"', - '*', - '$', - '%', - '^', - '&', - '*', - '(', - ')', - '_', - '+', - 0, - '\t', - 'Q', - 'W', - 'E', - 'R', - 'T', - 'Y', - 'U', - 'I', - 'O', - 'P', - '{', - '}', - '\n', - 0, - 'A', - 'S', - 'D', - 'F', - 'G', - 'H', - 'J', - 'K', - 'L', - ':', - '@', - '~', - 0, - '|', - 'Z', - 'X', - 'C', - 'V', - 'B', - 'N', - 'M', - '<', - '>', - '?', - 0, - 0, - 0, - ' ' }; - - static { - initialize(); - } - /** Has the keyboard been created? */ private static boolean created; @@ -310,12 +197,19 @@ /** * The key events from the last read: a sequence of pairs of key number, - * followed by state. + * followed by state. If translation is enabled, the state is followed by + * a 2 byte java char representing the translated character. */ private static ByteBuffer readBuffer; - - /** Address of the read buffer */ - private static int readBufferAddress; + + /** True if translation is enabled */ + private static boolean translationEnabled; + + /** The number of events read in the last read() */ + private static int numEvents; + + /** The current keyboard character being examined */ + public static char character; /** The current keyboard event key being examined */ public static int key; @@ -323,8 +217,12 @@ /** The current state of the key being examined in the event queue */ public static boolean state; + static { + initialize(); + } + /** - * Mouse cannot be constructed. + * Keyboard cannot be constructed. */ private Keyboard() { } @@ -376,7 +274,7 @@ } /** - * Native method the destroy the keyboard + * Native method to destroy the keyboard */ private static native void nDestroy(); @@ -402,17 +300,35 @@ public static void read() { assert created : "The keyboard has not been created."; assert readBuffer != null : "Keyboard buffering has not been enabled."; + numEvents = nRead(); readBuffer.clear(); - readBuffer.limit(nRead(readBufferAddress) << 1); + if (translationEnabled) + readBuffer.limit(numEvents << 2); + else + readBuffer.limit(numEvents << 1); } /** * Native method to read the keyboard buffer - * - * @param readBufferAddress the address of the keyboard buffer - * @return the number of keyboard events read + * @return the total number of events read. */ - private static native int nRead(int readBufferAddress); + private static native int nRead(); + + /** + * Enable keyboard translation. Must be called after the keyboard is created, + * and keyboard buffering must be enabled. + */ + public static void enableTranslation() { + assert created : "The keyboard has not been created."; + assert readBuffer != null : "Keyboard buffering has not been enabled."; + nEnableTranslation(); + translationEnabled = true; + } + + /** + * Native method to enable the translation buffer + */ + private static native void nEnableTranslation(); /** * Enable keyboard buffering. Must be called after the keyboard is created. @@ -421,7 +337,10 @@ */ public static int enableBuffer() { assert created : "The keyboard has not been created."; - return nEnableBuffer(); + int buf_len = nEnableBuffer(); + if (readBuffer != null) + readBuffer.order(ByteOrder.nativeOrder()); + return buf_len; } /** @@ -446,7 +365,10 @@ * @return the number of keyboard events */ public static int getNumKeyboardEvents() { - return readBuffer.limit() >> 1; + assert created : "The keyboard has not been created."; + assert readBuffer != null : "Keyboard buffering has not been enabled."; + + return numEvents; } /** @@ -461,27 +383,10 @@ if (readBuffer.hasRemaining()) { key = readBuffer.get() & 0xFF; state = readBuffer.get() != 0; + if (translationEnabled) + character = readBuffer.getChar(); return true; } else return false; - - } - - /** - * Maps a keycode to a character. - * @param keyCode The keycode - * @return the corresponding ASCII character or 0 if no mapping is possible - */ - public static char map(int keyCode) { - char c; - - if (keyCode < 0 || keyCode >= map.length) - return 0; - else if (isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT)) { - c = shiftMap[keyCode]; - } else { - c = map[keyCode]; - } - return c; } } |
|
From: Elias N. <eli...@us...> - 2003-01-11 23:09:11
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv20335/win32 Modified Files: org_lwjgl_input_Keyboard.cpp Log Message: Added keyboard translation to linux and win32 Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_input_Keyboard.cpp 19 Dec 2002 16:35:35 -0000 1.5 +++ org_lwjgl_input_Keyboard.cpp 11 Jan 2003 23:09:08 -0000 1.6 @@ -49,8 +49,8 @@ #define KEYBOARD_BUFFER_SIZE 50 BYTE readBuffer[KEYBOARD_BUFFER_SIZE]; LPDIRECTINPUTDEVICE lpdiKeyboard = NULL; -jfieldID fid_readBuffer; -jfieldID fid_readBufferAddress; +jfieldID fid_readBuffer; +bool translationEnabled; extern LPDIRECTINPUT lpdi; extern HWND hwnd; @@ -70,7 +70,6 @@ } fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;"); - fid_readBufferAddress = env->GetStaticFieldID(clazz, "readBufferAddress", "I"); } /* @@ -80,7 +79,8 @@ */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate (JNIEnv * env, jclass clazz) -{ +{ + translationEnabled = false; // Check to see if we're already initialized if (lpdiKeyboard != NULL) { printf("Keyboard already created.\n"); @@ -180,13 +180,20 @@ * Signature: (I)V */ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead - (JNIEnv * env, jclass clazz, jint keys) + (JNIEnv * env, jclass clazz) { - static DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE]; + static DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE]; + wchar_t transBuf[KEYBOARD_BUFFER_SIZE]; + MSG msg; + + BYTE state[256]; DWORD bufsize = KEYBOARD_BUFFER_SIZE; - HRESULT ret; + HRESULT ret; + int num_chars; + int num_events = 0; + do { ret = lpdiKeyboard->Acquire(); } while (ret != DI_OK && ret != S_FALSE); @@ -198,13 +205,47 @@ 0); if (ret == DI_OK) { - unsigned char * buf = (unsigned char *) keys; - for (unsigned int i = 0; i < bufsize; i ++) { + unsigned char * buf = readBuffer; + for (unsigned int i = 0; i < bufsize; i ++) { + num_events++; *buf++ = (unsigned char) rgdod[i].dwOfs; - *buf++ = (unsigned char) rgdod[i].dwData; + *buf++ = (unsigned char) rgdod[i].dwData; + if (translationEnabled) { + while (PeekMessage(&msg, hwnd, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) != 0) + ; // Flush keyboard messages to update keyboard state + UINT virt_key = MapVirtualKey(rgdod[i].dwOfs, 1); + if (virt_key != 0) { + if (!GetKeyboardState(state)) + return -1; + num_chars = ToUnicode(virt_key, + rgdod[i].dwOfs, + state, + transBuf, + KEYBOARD_BUFFER_SIZE, 0); + if (num_chars > 0) { + wchar_t ch = transBuf[0]; + *buf++ = (unsigned char) (ch & 0xff); + *buf++ = (unsigned char) ((ch & 0xff00) >> 8); + for (int i = 1; i < num_chars; i++) { + num_events++; + ch = transBuf[i]; + *buf++ = 0; + *buf++ = 0; + *buf++ = (unsigned char) (ch & 0xff); + *buf++ = (unsigned char) ((ch & 0xff00) >> 8); + } + } else { + *buf++ = 0; + *buf++ = 0; + } + } else { + *buf++ = 0; + *buf++ = 0; + } + } } - return bufsize; - } if (ret == DI_BUFFEROVERFLOW) { + return num_events; + } else if (ret == DI_BUFFEROVERFLOW) { #ifdef _DEBUG printf("Keyboard buffer overflowed\n"); #endif @@ -242,6 +283,17 @@ } } +/* + * Class: org_lwjgl_input_Keyboard + * Method: nEnableTranslation + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation + (JNIEnv *, jclass) +{ + translationEnabled = true; +} + /* * Class: org_lwjgl_input_Keyboard * Method: nEnableBuffer @@ -252,6 +304,5 @@ { jobject newBuffer = env->NewDirectByteBuffer(&readBuffer, KEYBOARD_BUFFER_SIZE); env->SetStaticObjectField(clazz, fid_readBuffer, newBuffer); - env->SetStaticIntField(clazz, fid_readBufferAddress, (jint) (&readBuffer)); return KEYBOARD_BUFFER_SIZE; } |
|
From: Elias N. <eli...@us...> - 2003-01-11 23:09:11
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv20335/common Modified Files: org_lwjgl_input_Keyboard.h Log Message: Added keyboard translation to linux and win32 Index: org_lwjgl_input_Keyboard.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Keyboard.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Keyboard.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- org_lwjgl_input_Keyboard.h 11 Aug 2002 11:49:33 -0000 1.1.1.1 +++ org_lwjgl_input_Keyboard.h 11 Jan 2003 23:09:08 -0000 1.2 @@ -8,12 +8,266 @@ extern "C" { #endif /* Inaccessible static: _00024assertionsDisabled */ +#undef org_lwjgl_input_Keyboard_CHAR_NONE +#define org_lwjgl_input_Keyboard_CHAR_NONE 0L +#undef org_lwjgl_input_Keyboard_KEY_NONE +#define org_lwjgl_input_Keyboard_KEY_NONE 0L +#undef org_lwjgl_input_Keyboard_KEY_ESCAPE +#define org_lwjgl_input_Keyboard_KEY_ESCAPE 1L +#undef org_lwjgl_input_Keyboard_KEY_1 +#define org_lwjgl_input_Keyboard_KEY_1 2L +#undef org_lwjgl_input_Keyboard_KEY_2 +#define org_lwjgl_input_Keyboard_KEY_2 3L +#undef org_lwjgl_input_Keyboard_KEY_3 +#define org_lwjgl_input_Keyboard_KEY_3 4L +#undef org_lwjgl_input_Keyboard_KEY_4 +#define org_lwjgl_input_Keyboard_KEY_4 5L +#undef org_lwjgl_input_Keyboard_KEY_5 +#define org_lwjgl_input_Keyboard_KEY_5 6L +#undef org_lwjgl_input_Keyboard_KEY_6 +#define org_lwjgl_input_Keyboard_KEY_6 7L +#undef org_lwjgl_input_Keyboard_KEY_7 +#define org_lwjgl_input_Keyboard_KEY_7 8L +#undef org_lwjgl_input_Keyboard_KEY_8 +#define org_lwjgl_input_Keyboard_KEY_8 9L +#undef org_lwjgl_input_Keyboard_KEY_9 +#define org_lwjgl_input_Keyboard_KEY_9 10L +#undef org_lwjgl_input_Keyboard_KEY_0 +#define org_lwjgl_input_Keyboard_KEY_0 11L +#undef org_lwjgl_input_Keyboard_KEY_MINUS +#define org_lwjgl_input_Keyboard_KEY_MINUS 12L +#undef org_lwjgl_input_Keyboard_KEY_EQUALS +#define org_lwjgl_input_Keyboard_KEY_EQUALS 13L +#undef org_lwjgl_input_Keyboard_KEY_BACK +#define org_lwjgl_input_Keyboard_KEY_BACK 14L +#undef org_lwjgl_input_Keyboard_KEY_TAB +#define org_lwjgl_input_Keyboard_KEY_TAB 15L +#undef org_lwjgl_input_Keyboard_KEY_Q +#define org_lwjgl_input_Keyboard_KEY_Q 16L +#undef org_lwjgl_input_Keyboard_KEY_W +#define org_lwjgl_input_Keyboard_KEY_W 17L +#undef org_lwjgl_input_Keyboard_KEY_E +#define org_lwjgl_input_Keyboard_KEY_E 18L +#undef org_lwjgl_input_Keyboard_KEY_R +#define org_lwjgl_input_Keyboard_KEY_R 19L +#undef org_lwjgl_input_Keyboard_KEY_T +#define org_lwjgl_input_Keyboard_KEY_T 20L +#undef org_lwjgl_input_Keyboard_KEY_Y +#define org_lwjgl_input_Keyboard_KEY_Y 21L +#undef org_lwjgl_input_Keyboard_KEY_U +#define org_lwjgl_input_Keyboard_KEY_U 22L +#undef org_lwjgl_input_Keyboard_KEY_I +#define org_lwjgl_input_Keyboard_KEY_I 23L +#undef org_lwjgl_input_Keyboard_KEY_O +#define org_lwjgl_input_Keyboard_KEY_O 24L +#undef org_lwjgl_input_Keyboard_KEY_P +#define org_lwjgl_input_Keyboard_KEY_P 25L +#undef org_lwjgl_input_Keyboard_KEY_LBRACKET +#define org_lwjgl_input_Keyboard_KEY_LBRACKET 26L +#undef org_lwjgl_input_Keyboard_KEY_RBRACKET +#define org_lwjgl_input_Keyboard_KEY_RBRACKET 27L +#undef org_lwjgl_input_Keyboard_KEY_RETURN +#define org_lwjgl_input_Keyboard_KEY_RETURN 28L +#undef org_lwjgl_input_Keyboard_KEY_LCONTROL +#define org_lwjgl_input_Keyboard_KEY_LCONTROL 29L +#undef org_lwjgl_input_Keyboard_KEY_A +#define org_lwjgl_input_Keyboard_KEY_A 30L +#undef org_lwjgl_input_Keyboard_KEY_S +#define org_lwjgl_input_Keyboard_KEY_S 31L +#undef org_lwjgl_input_Keyboard_KEY_D +#define org_lwjgl_input_Keyboard_KEY_D 32L +#undef org_lwjgl_input_Keyboard_KEY_F +#define org_lwjgl_input_Keyboard_KEY_F 33L +#undef org_lwjgl_input_Keyboard_KEY_G +#define org_lwjgl_input_Keyboard_KEY_G 34L +#undef org_lwjgl_input_Keyboard_KEY_H +#define org_lwjgl_input_Keyboard_KEY_H 35L +#undef org_lwjgl_input_Keyboard_KEY_J +#define org_lwjgl_input_Keyboard_KEY_J 36L +#undef org_lwjgl_input_Keyboard_KEY_K +#define org_lwjgl_input_Keyboard_KEY_K 37L +#undef org_lwjgl_input_Keyboard_KEY_L +#define org_lwjgl_input_Keyboard_KEY_L 38L +#undef org_lwjgl_input_Keyboard_KEY_SEMICOLON +#define org_lwjgl_input_Keyboard_KEY_SEMICOLON 39L +#undef org_lwjgl_input_Keyboard_KEY_APOSTROPHE +#define org_lwjgl_input_Keyboard_KEY_APOSTROPHE 40L +#undef org_lwjgl_input_Keyboard_KEY_GRAVE +#define org_lwjgl_input_Keyboard_KEY_GRAVE 41L +#undef org_lwjgl_input_Keyboard_KEY_LSHIFT +#define org_lwjgl_input_Keyboard_KEY_LSHIFT 42L +#undef org_lwjgl_input_Keyboard_KEY_BACKSLASH +#define org_lwjgl_input_Keyboard_KEY_BACKSLASH 43L +#undef org_lwjgl_input_Keyboard_KEY_Z +#define org_lwjgl_input_Keyboard_KEY_Z 44L +#undef org_lwjgl_input_Keyboard_KEY_X +#define org_lwjgl_input_Keyboard_KEY_X 45L +#undef org_lwjgl_input_Keyboard_KEY_C +#define org_lwjgl_input_Keyboard_KEY_C 46L +#undef org_lwjgl_input_Keyboard_KEY_V +#define org_lwjgl_input_Keyboard_KEY_V 47L +#undef org_lwjgl_input_Keyboard_KEY_B +#define org_lwjgl_input_Keyboard_KEY_B 48L +#undef org_lwjgl_input_Keyboard_KEY_N +#define org_lwjgl_input_Keyboard_KEY_N 49L +#undef org_lwjgl_input_Keyboard_KEY_M +#define org_lwjgl_input_Keyboard_KEY_M 50L +#undef org_lwjgl_input_Keyboard_KEY_COMMA +#define org_lwjgl_input_Keyboard_KEY_COMMA 51L +#undef org_lwjgl_input_Keyboard_KEY_PERIOD +#define org_lwjgl_input_Keyboard_KEY_PERIOD 52L +#undef org_lwjgl_input_Keyboard_KEY_SLASH +#define org_lwjgl_input_Keyboard_KEY_SLASH 53L +#undef org_lwjgl_input_Keyboard_KEY_RSHIFT +#define org_lwjgl_input_Keyboard_KEY_RSHIFT 54L +#undef org_lwjgl_input_Keyboard_KEY_MULTIPLY +#define org_lwjgl_input_Keyboard_KEY_MULTIPLY 55L +#undef org_lwjgl_input_Keyboard_KEY_LMENU +#define org_lwjgl_input_Keyboard_KEY_LMENU 56L +#undef org_lwjgl_input_Keyboard_KEY_SPACE +#define org_lwjgl_input_Keyboard_KEY_SPACE 57L +#undef org_lwjgl_input_Keyboard_KEY_CAPITAL +#define org_lwjgl_input_Keyboard_KEY_CAPITAL 58L +#undef org_lwjgl_input_Keyboard_KEY_F1 +#define org_lwjgl_input_Keyboard_KEY_F1 59L +#undef org_lwjgl_input_Keyboard_KEY_F2 +#define org_lwjgl_input_Keyboard_KEY_F2 60L +#undef org_lwjgl_input_Keyboard_KEY_F3 +#define org_lwjgl_input_Keyboard_KEY_F3 61L +#undef org_lwjgl_input_Keyboard_KEY_F4 +#define org_lwjgl_input_Keyboard_KEY_F4 62L +#undef org_lwjgl_input_Keyboard_KEY_F5 +#define org_lwjgl_input_Keyboard_KEY_F5 63L +#undef org_lwjgl_input_Keyboard_KEY_F6 +#define org_lwjgl_input_Keyboard_KEY_F6 64L +#undef org_lwjgl_input_Keyboard_KEY_F7 +#define org_lwjgl_input_Keyboard_KEY_F7 65L +#undef org_lwjgl_input_Keyboard_KEY_F8 +#define org_lwjgl_input_Keyboard_KEY_F8 66L +#undef org_lwjgl_input_Keyboard_KEY_F9 +#define org_lwjgl_input_Keyboard_KEY_F9 67L +#undef org_lwjgl_input_Keyboard_KEY_F10 +#define org_lwjgl_input_Keyboard_KEY_F10 68L +#undef org_lwjgl_input_Keyboard_KEY_NUMLOCK +#define org_lwjgl_input_Keyboard_KEY_NUMLOCK 69L +#undef org_lwjgl_input_Keyboard_KEY_SCROLL +#define org_lwjgl_input_Keyboard_KEY_SCROLL 70L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD7 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD7 71L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD8 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD8 72L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD9 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD9 73L +#undef org_lwjgl_input_Keyboard_KEY_SUBTRACT +#define org_lwjgl_input_Keyboard_KEY_SUBTRACT 74L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD4 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD4 75L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD5 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD5 76L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD6 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD6 77L +#undef org_lwjgl_input_Keyboard_KEY_ADD +#define org_lwjgl_input_Keyboard_KEY_ADD 78L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD1 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD1 79L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD2 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD2 80L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD3 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD3 81L +#undef org_lwjgl_input_Keyboard_KEY_NUMPAD0 +#define org_lwjgl_input_Keyboard_KEY_NUMPAD0 82L +#undef org_lwjgl_input_Keyboard_KEY_DECIMAL +#define org_lwjgl_input_Keyboard_KEY_DECIMAL 83L +#undef org_lwjgl_input_Keyboard_KEY_F11 +#define org_lwjgl_input_Keyboard_KEY_F11 87L +#undef org_lwjgl_input_Keyboard_KEY_F12 +#define org_lwjgl_input_Keyboard_KEY_F12 88L +#undef org_lwjgl_input_Keyboard_KEY_F13 +#define org_lwjgl_input_Keyboard_KEY_F13 100L +#undef org_lwjgl_input_Keyboard_KEY_F14 +#define org_lwjgl_input_Keyboard_KEY_F14 101L +#undef org_lwjgl_input_Keyboard_KEY_F15 +#define org_lwjgl_input_Keyboard_KEY_F15 102L +#undef org_lwjgl_input_Keyboard_KEY_KANA +#define org_lwjgl_input_Keyboard_KEY_KANA 112L +#undef org_lwjgl_input_Keyboard_KEY_CONVERT +#define org_lwjgl_input_Keyboard_KEY_CONVERT 121L +#undef org_lwjgl_input_Keyboard_KEY_NOCONVERT +#define org_lwjgl_input_Keyboard_KEY_NOCONVERT 123L +#undef org_lwjgl_input_Keyboard_KEY_YEN +#define org_lwjgl_input_Keyboard_KEY_YEN 125L +#undef org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS +#define org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS 141L +#undef org_lwjgl_input_Keyboard_KEY_CIRCUMFLEX +#define org_lwjgl_input_Keyboard_KEY_CIRCUMFLEX 144L +#undef org_lwjgl_input_Keyboard_KEY_AT +#define org_lwjgl_input_Keyboard_KEY_AT 145L +#undef org_lwjgl_input_Keyboard_KEY_COLON +#define org_lwjgl_input_Keyboard_KEY_COLON 146L +#undef org_lwjgl_input_Keyboard_KEY_UNDERLINE +#define org_lwjgl_input_Keyboard_KEY_UNDERLINE 147L +#undef org_lwjgl_input_Keyboard_KEY_KANJI +#define org_lwjgl_input_Keyboard_KEY_KANJI 148L +#undef org_lwjgl_input_Keyboard_KEY_STOP +#define org_lwjgl_input_Keyboard_KEY_STOP 149L +#undef org_lwjgl_input_Keyboard_KEY_AX +#define org_lwjgl_input_Keyboard_KEY_AX 150L +#undef org_lwjgl_input_Keyboard_KEY_UNLABELED +#define org_lwjgl_input_Keyboard_KEY_UNLABELED 151L +#undef org_lwjgl_input_Keyboard_KEY_NUMPADENTER +#define org_lwjgl_input_Keyboard_KEY_NUMPADENTER 156L +#undef org_lwjgl_input_Keyboard_KEY_RCONTROL +#define org_lwjgl_input_Keyboard_KEY_RCONTROL 157L +#undef org_lwjgl_input_Keyboard_KEY_NUMPADCOMMA +#define org_lwjgl_input_Keyboard_KEY_NUMPADCOMMA 179L +#undef org_lwjgl_input_Keyboard_KEY_DIVIDE +#define org_lwjgl_input_Keyboard_KEY_DIVIDE 181L +#undef org_lwjgl_input_Keyboard_KEY_SYSRQ +#define org_lwjgl_input_Keyboard_KEY_SYSRQ 183L +#undef org_lwjgl_input_Keyboard_KEY_RMENU +#define org_lwjgl_input_Keyboard_KEY_RMENU 184L +#undef org_lwjgl_input_Keyboard_KEY_PAUSE +#define org_lwjgl_input_Keyboard_KEY_PAUSE 197L +#undef org_lwjgl_input_Keyboard_KEY_HOME +#define org_lwjgl_input_Keyboard_KEY_HOME 199L +#undef org_lwjgl_input_Keyboard_KEY_UP +#define org_lwjgl_input_Keyboard_KEY_UP 200L +#undef org_lwjgl_input_Keyboard_KEY_PRIOR +#define org_lwjgl_input_Keyboard_KEY_PRIOR 201L +#undef org_lwjgl_input_Keyboard_KEY_LEFT +#define org_lwjgl_input_Keyboard_KEY_LEFT 203L +#undef org_lwjgl_input_Keyboard_KEY_RIGHT +#define org_lwjgl_input_Keyboard_KEY_RIGHT 205L +#undef org_lwjgl_input_Keyboard_KEY_END +#define org_lwjgl_input_Keyboard_KEY_END 207L +#undef org_lwjgl_input_Keyboard_KEY_DOWN +#define org_lwjgl_input_Keyboard_KEY_DOWN 208L +#undef org_lwjgl_input_Keyboard_KEY_NEXT +#define org_lwjgl_input_Keyboard_KEY_NEXT 209L +#undef org_lwjgl_input_Keyboard_KEY_INSERT +#define org_lwjgl_input_Keyboard_KEY_INSERT 210L +#undef org_lwjgl_input_Keyboard_KEY_DELETE +#define org_lwjgl_input_Keyboard_KEY_DELETE 211L +#undef org_lwjgl_input_Keyboard_KEY_LWIN +#define org_lwjgl_input_Keyboard_KEY_LWIN 219L +#undef org_lwjgl_input_Keyboard_KEY_RWIN +#define org_lwjgl_input_Keyboard_KEY_RWIN 220L +#undef org_lwjgl_input_Keyboard_KEY_APPS +#define org_lwjgl_input_Keyboard_KEY_APPS 221L +#undef org_lwjgl_input_Keyboard_KEY_POWER +#define org_lwjgl_input_Keyboard_KEY_POWER 222L +#undef org_lwjgl_input_Keyboard_KEY_SLEEP +#define org_lwjgl_input_Keyboard_KEY_SLEEP 223L /* Inaccessible static: created */ /* Inaccessible static: keyDownBuffer */ /* Inaccessible static: keyDownAddress */ /* Inaccessible static: readBuffer */ -/* Inaccessible static: readBufferAddress */ -/* Inaccessible static: class_000240 */ +/* Inaccessible static: translationEnabled */ +/* Inaccessible static: numEvents */ +/* Inaccessible static: character */ +/* Inaccessible static: key */ +/* Inaccessible static: state */ +/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Keyboard */ /* * Class: org_lwjgl_input_Keyboard * Method: initIDs @@ -49,10 +303,18 @@ /* * Class: org_lwjgl_input_Keyboard * Method: nRead - * Signature: (I)V + * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead - (JNIEnv *, jclass, jint); + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_input_Keyboard + * Method: nEnableTranslation + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation + (JNIEnv *, jclass); /* * Class: org_lwjgl_input_Keyboard |
|
From: Elias N. <eli...@us...> - 2003-01-11 21:03:25
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv32247 Modified Files: Makefile.am org_lwjgl_input_Keyboard.cpp Removed Files: org_lwjgl_input_GamePad.cpp org_lwjgl_input_Joystick.cpp Log Message: Fixed linux compile Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 28 Nov 2002 22:40:06 -0000 1.1 +++ Makefile.am 11 Jan 2003 21:03:22 -0000 1.2 @@ -6,8 +6,7 @@ NATIVE = \ org_lwjgl_Display.cpp \ org_lwjgl_Sys.cpp \ - org_lwjgl_input_GamePad.cpp \ - org_lwjgl_input_Joystick.cpp \ + org_lwjgl_input_Controller.cpp \ org_lwjgl_input_Keyboard.cpp \ org_lwjgl_input_Mouse.cpp \ org_lwjgl_opengl_BaseGL.cpp Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_input_Keyboard.cpp 26 Nov 2002 20:07:49 -0000 1.9 +++ org_lwjgl_input_Keyboard.cpp 11 Jan 2003 21:03:22 -0000 1.10 @@ -41,6 +41,7 @@ #include <X11/X.h> #include <X11/Xlib.h> +#include <X11/Xutil.h> #include <string.h> #include <assert.h> #include "org_lwjgl_input_Keyboard.h" @@ -51,20 +52,16 @@ unsigned char readBuffer[KEYBOARD_BUFFER_SIZE * 2]; jfieldID fid_readBuffer; -jfieldID fid_readBufferAddress; unsigned char key_buf[KEYBOARD_SIZE]; unsigned char key_map[KEYBOARD_SIZE]; -typedef struct { - unsigned char keycode; - unsigned char state; -} input_event; - -input_event saved_key_events[KEY_EVENT_BACKLOG]; +XKeyEvent saved_key_events[KEY_EVENT_BACKLOG]; int list_start = 0; int list_end = 0; bool keyboard_grabbed; +bool buffer_enabled; +bool translation_enabled; extern Display *disp; extern Window win; @@ -88,7 +85,6 @@ } fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;"); - fid_readBufferAddress = env->GetStaticFieldID(clazz, "readBufferAddress", "I"); } int grabKeyboard(void) { @@ -127,7 +123,10 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate (JNIEnv * env, jclass clazz) { - keyboard_grabbed = 0; + keyboard_grabbed = false; + translation_enabled = false; + buffer_enabled = false; + if (updateKeyboardGrab() != GrabSuccess) { #ifdef _DEBUG printf("Could not grab keyboard\n"); @@ -170,29 +169,68 @@ ungrabKeyboard(); } -input_event *nextEventElement(void) { +XKeyEvent *nextEventElement(void) { if (list_start == list_end) return NULL; - input_event *result = &(saved_key_events[list_start]); + XKeyEvent *result = &(saved_key_events[list_start]); list_start = (list_start + 1)%KEY_EVENT_BACKLOG; return result; } -void putEventElement(unsigned char keycode, unsigned char state) { +void putEventElement(XKeyEvent *event) { int next_index = (list_end + 1)%KEY_EVENT_BACKLOG; if (next_index == list_start) return; - saved_key_events[list_end].keycode = keycode; - saved_key_events[list_end].state = state; + saved_key_events[list_end] = *event; list_end = next_index; } -unsigned char getKeycode(XEvent *event) { - unsigned char keycode = (unsigned char)((event->xkey.keycode - 8) & 0xff); +unsigned char getKeycode(XKeyEvent *event) { + unsigned char keycode = (unsigned char)((event->keycode - 8) & 0xff); keycode = key_map[keycode]; return keycode; } +int translateEvent(int *position, XKeyEvent *event) { + static char temp_translation_buffer[KEYBOARD_BUFFER_SIZE]; + static XComposeStatus status; + int num_chars, i; + + if (*position >= KEYBOARD_BUFFER_SIZE * 2) + return 0; + if (event->type == KeyRelease) { + readBuffer[(*position)++] = 0; + readBuffer[(*position)++] = 0; + return 0; + } + num_chars = XLookupString(event, temp_translation_buffer, KEYBOARD_BUFFER_SIZE, NULL, &status); + if (num_chars > 0) { + num_chars--; + /* Assume little endian byte order */ + readBuffer[(*position)++] = temp_translation_buffer[0]; + readBuffer[(*position)++] = 0; + for (i = 0; i < num_chars; i++) { + readBuffer[(*position)++] = 0; + readBuffer[(*position)++] = 0; + readBuffer[(*position)++] = temp_translation_buffer[i + 1]; + readBuffer[(*position)++] = 0; + } + } else { + readBuffer[(*position)++] = 0; + readBuffer[(*position)++] = 0; + } + return num_chars; +} + +unsigned char eventState(XKeyEvent *event) { + if (event->type == KeyPress) { + return 1; + } else if (event->type == KeyRelease) { + return 0; + } else + assert(0); +} + /* * Class: org_lwjgl_input_Keyboard * Method: nPoll @@ -202,20 +240,16 @@ (JNIEnv * env, jclass clazz, jint buf) { XEvent event; - int state; + unsigned char state; updateKeyboardGrab(); while (XCheckMaskEvent(disp, KeyPressMask | KeyReleaseMask, &event)) { - unsigned char keycode = getKeycode(&event); - if (event.type == KeyPress) { - state = 1; - } else if (event.type == KeyRelease) { - state = 0; - } else - assert(0); + unsigned char keycode = getKeycode(&(event.xkey)); + state = eventState(&(event.xkey)); key_buf[keycode] = state; - putEventElement(keycode, state); + if (buffer_enabled) + putEventElement(&(event.xkey)); } memcpy((unsigned char*)buf, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); } @@ -225,43 +259,51 @@ * Method: nRead * Signature: (I)V */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead - (JNIEnv * env, jclass clazz, jint keys) +JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead + (JNIEnv * env, jclass clazz) { XEvent event; - int count = 0; + XKeyEvent *key_event; int buf_count = 0; int state; - input_event *input_ev; - unsigned char *result_buf = (unsigned char *)keys; + int num_events = 0; updateKeyboardGrab(); - while ((input_ev = nextEventElement()) != NULL) { - count++; -// printf("Reading a key %d %d count %d\n", (int)input_ev->keycode, (int)input_ev->state, count); - result_buf[buf_count++] = input_ev->keycode; - result_buf[buf_count++] = input_ev->state; - if (buf_count >= KEYBOARD_BUFFER_SIZE * 2) - return count; + while (buf_count < KEYBOARD_BUFFER_SIZE * 2 && (key_event = nextEventElement()) != NULL) { + num_events++; + unsigned char keycode = getKeycode(key_event); + unsigned char state = eventState(key_event); +// printf("Reading a key %d %d count %d\n", (int)keycode, (int)state, num_events); + readBuffer[buf_count++] = keycode; + readBuffer[buf_count++] = state; + if (translation_enabled) + num_events += translateEvent(&buf_count, key_event); } - while (XCheckMaskEvent(disp, KeyPressMask | KeyReleaseMask, &event)) { - count++; - unsigned char keycode = getKeycode(&event); - if (event.type == KeyPress) { - state = 1; - } else if (event.type == KeyRelease) { - state = 0; - } else - assert(0); + while (buf_count < KEYBOARD_BUFFER_SIZE * 2 && XCheckMaskEvent(disp, KeyPressMask | KeyReleaseMask, &event)) { + num_events++; + unsigned char keycode = getKeycode(&(event.xkey)); + unsigned char state = eventState(&(event.xkey)); +// printf("Reading a key %d %d count %d\n", (int)keycode, (int)state, num_events); key_buf[keycode] = state; - result_buf[buf_count++] = keycode; - result_buf[buf_count++] = state; - if (buf_count >= KEYBOARD_BUFFER_SIZE * 2) - return count; + readBuffer[buf_count++] = keycode; + readBuffer[buf_count++] = state; + if (translation_enabled) + num_events += translateEvent(&buf_count, &(event.xkey)); } - return count; + return num_events; +} + +/* + * Class: org_lwjgl_input_Keyboard + * Method: nEnableTranslation + * Signature: ()I + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation + (JNIEnv *env, jclass clazz) +{ + translation_enabled = true; } /* @@ -274,6 +316,6 @@ { jobject newBuffer = env->NewDirectByteBuffer(&readBuffer, KEYBOARD_BUFFER_SIZE * 2); env->SetStaticObjectField(clazz, fid_readBuffer, newBuffer); - env->SetStaticIntField(clazz, fid_readBufferAddress, (jint) (&readBuffer)); + buffer_enabled = true; return KEYBOARD_BUFFER_SIZE; } --- org_lwjgl_input_GamePad.cpp DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_GamePad.cpp --- org_lwjgl_input_Joystick.cpp DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Joystick.cpp |
|
From: Elias N. <eli...@us...> - 2003-01-11 21:02:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv31661/linux Added Files: org_lwjgl_input_Controller.cpp Log Message: Fixed linux compile --- NEW FILE: org_lwjgl_input_Controller.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Controller.cpp /* * Copyright (c) 2002 Lightweight Java Game Library 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 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * $Id: org_lwjgl_input_Controller.cpp,v 1.1 2003/01/11 21:02:54 elias_naur Exp $ * * Win32 controller handling. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #include <jni.h> /** * Initializes any field ids */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jclass clazz) { } /** * Called when the Controller instance is to be created */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { return JNI_FALSE; } /* * Class: org_lwjgl_input_Controller * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy(JNIEnv *env, jclass clazz) { } /* * Class: org_lwjgl_input_Controller * Method: nPoll * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclass clazz) { } |
|
From: Brian M. <ma...@us...> - 2003-01-11 13:56:55
|
Update of /cvsroot/java-game-lib/LWJGL/website/documents In directory sc8-pr-cvs1:/tmp/cvs-serv12689 Modified Files: links.html Log Message: add: link to chman's nehe ports added Index: links.html CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/website/documents/links.html =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/website/documents/links.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- links.html 20 Dec 2002 21:23:30 -0000 1.1 +++ links.html 11 Jan 2003 13:56:51 -0000 1.2 @@ -39,6 +39,10 @@ More feature complete input support for java <br> <br> + - <a href="http://chman-area.tuxfamily.org/" target="blank">http://chman-area.tuxfamily.org/</a><br> + Chman's Java & OpenGL webpage - Nehe ports + <br> + <br> </font> </body> </html> |
|
From: Brian M. <ma...@us...> - 2003-01-03 18:47:46
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv28155/native/win32 Added Files: org_lwjgl_input_Controller.cpp Removed Files: org_lwjgl_input_GamePad.cpp org_lwjgl_input_Joystick.cpp Log Message: Joystick replaced by Controller GamePad no modelled as a controller --- NEW FILE: org_lwjgl_input_Controller.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp /* * Copyright (c) 2002 Lightweight Java Game Library 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 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * $Id: org_lwjgl_input_Controller.cpp,v 1.1 2003/01/03 18:47:42 matzon Exp $ * * Win32 controller handling. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #define WIN32_LEAN_AND_MEAN #include "org_lwjgl_input_Controller.h" #include <windows.h> #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0500 #include <dinput.h> #define AXISMAX 1000 // Maxmimum range to which we'll gauge the swing #define AXISMIN -1000 // Minimum range to which we'll gauge the swing extern HWND hwnd; // Handle to window IDirectInput* lpDI; // DI instance IDirectInputDevice2* lpDIDevice; // DI Device instance DIJOYSTATE2 js; // State of Controller int buttoncount = 0; // Temporary buttoncount bool hasz; // Temporary zaxis check bool haspov; // Temporary pov check JNIEnv* environment; // JNIEnvironment copy bool create_success; // bool used to determine successfull creation // Cached fields of Controller.java jclass clsController; jfieldID fidButtonCount; jfieldID fidHasZAxis; jfieldID fidHasPOV; jfieldID fidButtons; jfieldID fidX; jfieldID fidY; jfieldID fidZ; jfieldID fidPOV; // Function prototypes (defined in the cpp file, since header file is generic across platforms void EnumerateCapabilities(); void EnumerateControllers(); BOOL CALLBACK EnumControllerCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef); BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); void Shutdown(); void CreateController(LPCDIDEVICEINSTANCE lpddi); void SetupController(); void InitializeFields(); void CacheFields(); void UpdateFields(); void SetCapabilities(); void PrintError(HRESULT error); /** * Initializes any field ids */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jclass clazz) { environment = env; clsController = clazz; /* Cache fields in Controller */ CacheFields(); } /** * Called when the Controller instance is to be created */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { // Create the DirectInput object. HRESULT hr; hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); if (FAILED(hr)) { Shutdown(); return JNI_FALSE; } /* Find all Controllers */ EnumerateControllers(); if (!create_success) { Shutdown(); return JNI_FALSE; } /* Enumerate capabilities of Controller */ EnumerateCapabilities(); if (!create_success) { Shutdown(); return JNI_FALSE; } /* Initialize any fields on the Controller */ InitializeFields(); /* Set capabilities */ SetCapabilities(); /* Aquire the Controller */ hr = lpDIDevice->Acquire(); if(FAILED(hr)) { Shutdown(); return JNI_FALSE; } return create_success; } /* * Class: org_lwjgl_input_Controller * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy(JNIEnv *env, jclass clazz) { Shutdown(); } /* * Class: org_lwjgl_input_Controller * Method: nPoll * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclass clazz) { HRESULT hRes; // poll the Controller to read the current state hRes = lpDIDevice->Poll(); if (FAILED(hRes)) { #if _DEBUG printf("Poll fail\n"); #endif return; } UpdateFields(); } /** * Shutdown DI */ void Shutdown() { // release DI instance if (lpDI != NULL) { // release device if (lpDIDevice != NULL) { lpDIDevice->Unacquire(); lpDIDevice->Release(); lpDIDevice = NULL; } lpDI->Release(); lpDI = NULL; } } /** * Enumerates the capabilities of the Controller attached to the system */ void EnumerateCapabilities() { HRESULT hr; hr = lpDIDevice->EnumObjects(EnumControllerObjectsCallback, NULL, DIDFT_ALL); if FAILED(hr) { create_success = false; return; } create_success = true; } /** * Enumerates the Controllers attached to the system */ void EnumerateControllers() { HRESULT hr; hr = lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY); if FAILED(hr) { create_success = false; return; } create_success = true; } /** * Callback from EnumDevices. Called for each Controller attached to the system */ BOOL CALLBACK EnumControllerCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { /* Add the Controller */ CreateController(pdinst); if(create_success) { /* Do setup of Controller */ SetupController(); } /* just stop after 1st Controller */ return DIENUM_STOP; } /** * Callback from EnumObjects. Called for each "object" on the Controller. */ BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { if(lpddoi->guidType == GUID_Button) { buttoncount++; } else if(lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis) { //do nothing } else if(lpddoi->guidType == GUID_ZAxis || strcmp("Throttle", lpddoi->tszName) == 0){ hasz = true; } else if (lpddoi->guidType == GUID_POV){ haspov = true; } else { #ifdef _DEBUG printf("Unhandled object found: %s\n", lpddoi->tszName); #endif } return DIENUM_CONTINUE; } /** * Creates the specified device as a Controller */ void CreateController(LPCDIDEVICEINSTANCE lpddi) { HRESULT hr; hr = lpDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &lpDIDevice, NULL); if FAILED(hr) { create_success = false; return; } create_success = true; } /** * Sets up the Controller properties */ void SetupController() { // set Controller data format if(lpDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { create_success = false; return; } // set the cooperative level if(lpDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { create_success = false; return; } // set X-axis range to (-1000 ... +1000) // This lets us test against 0 to see which way the stick is pointed. DIPROPRANGE diprg; diprg.diph.dwSize = sizeof(diprg); diprg.diph.dwHeaderSize = sizeof(diprg.diph); diprg.diph.dwObj = DIJOFS_X; diprg.diph.dwHow = DIPH_BYOFFSET; diprg.lMin = AXISMIN; diprg.lMax = AXISMAX; if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { create_success = false; return; } // // And again for Y-axis range // diprg.diph.dwObj = DIJOFS_Y; if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { create_success = false; return; } // // And again for z-axis range (throttle) // diprg.diph.dwObj = DIJOFS_Z; if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { create_success = false; return; } create_success = true; } /** * Sets the fields on the Controller */ void InitializeFields() { //set buttons array jbooleanArray buttonsArray = environment->NewBooleanArray(buttoncount); environment->SetStaticObjectField(clsController, fidButtons, buttonsArray); } /** * Updates the fields on the Controller */ void UpdateFields() { HRESULT hRes; // get data from the Controller hRes = lpDIDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js); if (hRes != DI_OK) { // did the read fail because we lost input for some reason? // if so, then attempt to reacquire. if(hRes == DIERR_INPUTLOST) { lpDIDevice->Acquire(); #if _DEBUG printf("DIERR_INPUTLOST, reaquiring input\n"); #endif } return; } //axis's environment->SetStaticIntField(clsController, fidX, js.lX); environment->SetStaticIntField(clsController, fidY, js.lY); if(hasz) { environment->SetStaticIntField(clsController, fidZ, js.lZ); } //buttons jbooleanArray buttonsArray = (jbooleanArray) environment->GetStaticObjectField(clsController, fidButtons); BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); memcpy(buttons, js.rgbButtons, buttoncount); environment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0); //pov if(haspov) { environment->SetStaticIntField(clsController, fidPOV, js.rgdwPOV[0]); } } /** * Sets the capabilities of the Controller */ void SetCapabilities() { //set buttoncount environment->SetStaticIntField(clsController, fidButtonCount, buttoncount); //set z axis environment->SetStaticIntField(clsController, fidHasZAxis, hasz); //set pov environment->SetStaticIntField(clsController, fidHasPOV, haspov); } /** * Caches the field ids for quicker access */ void CacheFields() { fidButtonCount = environment->GetStaticFieldID(clsController, "buttonCount", "I"); fidHasZAxis = environment->GetStaticFieldID(clsController, "hasZAxis", "Z"); fidHasPOV = environment->GetStaticFieldID(clsController, "hasPOV", "Z"); fidButtons = environment->GetStaticFieldID(clsController, "buttons", "[Z"); fidX = environment->GetStaticFieldID(clsController, "x", "I"); fidY = environment->GetStaticFieldID(clsController, "y", "I"); fidZ = environment->GetStaticFieldID(clsController, "z", "I"); fidPOV = environment->GetStaticFieldID(clsController, "pov", "I"); } --- org_lwjgl_input_GamePad.cpp DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_GamePad.cpp --- org_lwjgl_input_Joystick.cpp DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp |
|
From: Brian M. <ma...@us...> - 2003-01-03 18:47:46
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1:/tmp/cvs-serv28155/java/org/lwjgl/input Added Files: Controller.java Removed Files: GamePad.java Joystick.java Log Message: Joystick replaced by Controller GamePad no modelled as a controller --- NEW FILE: Controller.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Controller.java /* * Copyright (c) 2002 Lightweight Java Game Library 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 'Light Weight Java Game Library' 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.input; import org.lwjgl.Sys; /** * $Id: Controller.java,v 1.1 2003/01/03 18:47:41 matzon Exp $ * <br> * A raw Controller interface. This can be used to poll the current state of a * controllers buttons, and axis positions. The axis positions * are returned as ints in the range -1000 to 1000. * * No buffering is available. * * Currently n (native limits, currently 128 - might change) buttons, the x, y, * z axis is supported along with a POV (or HAT) and a slider, where the z axis * represents a throttle. In the future the controller may support more buttons * and axises and other features. but this is a platform issue. * * The Controller implementation currently only supports the first attached device. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class Controller { static { initialize(); } /** Has the controller been created? */ private static boolean created; /** The controller buttons status */ private static boolean[] buttons; /** X position, range -1000 to 1000 */ public static int x = 0; /** Y position, range -1000 to 1000 */ public static int y = 0; /** Z position, range -1000 to 1000 */ public static int z = 0; /** Position of Point of View from -1 to 27000 (360 degrees) */ public static int pov; /** Slider position, range -1000 to 1000 */ public static int slider = 0; /** Constant specifying centered POV */ public static final int POV_CENTER = -1; /** Constant specifying nortward POV */ public static final int POV_NORTH = 0; /** Constant specifying southward POV */ public static final int POV_SOUTH = 18000; /** Constant specifying eastward POV */ public static final int POV_EAST = 27000; /** Constant specifying westward POV */ public static final int POV_WEST = 9000; /* Controller capabilities */ public static int buttonCount = -1; public static boolean hasXAxis = false; public static boolean hasYAxis = false; public static boolean hasZAxis = false; public static boolean hasPOV = false; public static boolean hasSlider = false; /** * Controller cannot be constructed. */ private Controller() { } /** * Static initialization */ private static void initialize() { System.loadLibrary(Sys.getLibraryName()); initIDs(); } /** * "Create" the controller. The display must first have been created. * @throws Exception if the controller could not be created for any reason */ public static void create() throws Exception { if (created) { return; } if (!nCreate()) { throw new Exception("The controller could not be created."); } created = true; } /** * "Destroy" the controller */ public static void destroy() { if (!created) { return; } created = false; nDestroy(); } /** * Polls the controller. */ public static void poll() { assert created : "The controller has not been created."; nPoll(); } /** * See if a particular button is down. * * @param button The index of the button you wish to test (0..buttonCount) * @return true if the specified button is down * @see #buttonCount */ public static boolean isButtonDown(int button) { assert created : "The controller has not been created."; return buttons[button]; } /** * Native method to poll the controller */ private static native void nPoll(); /** * Native method to create the controller * * @return true if the controller was created */ private static native boolean nCreate(); /** * Native method the destroy the controller */ private static native void nDestroy(); /** * Register fields with the native library */ private static native void initIDs(); } --- GamePad.java DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/GamePad.java --- Joystick.java DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Joystick.java |
|
From: Brian M. <ma...@us...> - 2003-01-03 18:47:46
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1:/tmp/cvs-serv28155/java/org/lwjgl/test/input Added Files: ControllerTest.java Removed Files: JoystickTest.java Log Message: Joystick replaced by Controller GamePad no modelled as a controller --- NEW FILE: ControllerTest.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java /* * Copyright (c) 2002 Lightweight Java Game Library 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 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.test.input; import java.awt.*; import java.awt.event.*; import org.lwjgl.input.Controller; /** * $Id: ControllerTest.java,v 1.1 2003/01/03 18:47:41 matzon Exp $ * <br> * Controller test, hwich shows a awt window, printing Controller state * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class ControllerTest extends Panel { private int counter = 0; public Thread animationThread; /** Creates a new instance of ControllerTest */ public ControllerTest() { try { Controller.create(); } catch (Exception e) { e.printStackTrace(); return; } animationThread = new Thread() { public void run() { while (true) { paint(getGraphics()); try { Thread.sleep(250); } catch (InterruptedException inte) { inte.printStackTrace(); } } } }; animationThread.setDaemon(true); } public void paint(Graphics g) { if (g == null) { return; } g.setColor(Color.white); g.fillRect(0, 0, 640, 480); int y = 100; int x = 100; Controller.poll(); g.setColor(Color.blue); g.drawString("Buttoncount: " + Controller.buttonCount, x, y); y += 20; g.drawString("-----------------------------------------------", x, y); y += 20; g.drawString("x : " + Controller.x, x, y); y += 20; g.drawString("y : " + Controller.y, x, y); y += 20; if (Controller.hasZAxis) { g.drawString("z : " + Controller.z, x, y); y += 20; } if (Controller.hasPOV) { g.drawString("pov: " + Controller.pov, x, y); y += 20; } //paint buttons g.drawString("btn: ", x, y); x += g.getFontMetrics().stringWidth("btn: "); for (int i = 0; i < Controller.buttonCount; i++) { if (Controller.isButtonDown(i)) { g.drawString(i + ", ", x, y); x += 15; } } } public void update(Graphics g) { paint(g); } public void disposing() { Controller.destroy(); } /** * @param args the command line arguments */ public static void main(String[] args) { final ControllerTest p = new ControllerTest(); final Frame f = new Frame(); f.setLayout(null); f.setSize(640, 480); f.setLocation(100, 100); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { f.hide(); p.disposing(); f.dispose(); } }); p.setSize(640, 480); p.setLocation(0, 0); p.setBackground(Color.RED); f.add(p); f.show(); p.animationThread.start(); } } --- JoystickTest.java DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/JoystickTest.java |
|
From: Brian M. <ma...@us...> - 2003-01-03 18:47:46
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv28155/native/common Added Files: org_lwjgl_input_Controller.h Removed Files: org_lwjgl_input_GamePad.h org_lwjgl_input_Joystick.h Log Message: Joystick replaced by Controller GamePad no modelled as a controller --- NEW FILE: org_lwjgl_input_Controller.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Controller.h /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class org_lwjgl_input_Controller */ #ifndef _Included_org_lwjgl_input_Controller #define _Included_org_lwjgl_input_Controller #ifdef __cplusplus extern "C" { #endif /* Inaccessible static: _00024assertionsDisabled */ /* Inaccessible static: created */ /* Inaccessible static: buttons */ /* Inaccessible static: x */ /* Inaccessible static: y */ /* Inaccessible static: z */ /* Inaccessible static: pov */ #undef org_lwjgl_input_Controller_POV_CENTER #define org_lwjgl_input_Controller_POV_CENTER -1L #undef org_lwjgl_input_Controller_POV_NORTH #define org_lwjgl_input_Controller_POV_NORTH 0L #undef org_lwjgl_input_Controller_POV_SOUTH #define org_lwjgl_input_Controller_POV_SOUTH 18000L #undef org_lwjgl_input_Controller_POV_EAST #define org_lwjgl_input_Controller_POV_EAST 27000L #undef org_lwjgl_input_Controller_POV_WEST #define org_lwjgl_input_Controller_POV_WEST 9000L /* Inaccessible static: buttonCount */ /* Inaccessible static: hasZAxis */ /* Inaccessible static: hasPOV */ /* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Controller */ /* * Class: org_lwjgl_input_Controller * Method: nPoll * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll (JNIEnv *, jclass); /* * Class: org_lwjgl_input_Controller * Method: nCreate * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate (JNIEnv *, jclass); /* * Class: org_lwjgl_input_Controller * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy (JNIEnv *, jclass); /* * Class: org_lwjgl_input_Controller * Method: initIDs * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs (JNIEnv *, jclass); #ifdef __cplusplus } #endif #endif --- org_lwjgl_input_GamePad.h DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_GamePad.h --- org_lwjgl_input_Joystick.h DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h |
|
From: Brian M. <ma...@us...> - 2003-01-03 01:19:42
|
Update of /cvsroot/java-game-lib/LWJGL In directory sc8-pr-cvs1:/tmp/cvs-serv16634 Modified Files: build.xml Log Message: mod: now loads data files for examples from /res/ Index: build.xml CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/build.xml =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/build.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- build.xml 22 Dec 2002 00:54:00 -0000 1.4 +++ build.xml 3 Jan 2003 01:19:39 -0000 1.5 @@ -7,7 +7,7 @@ <property name="lwjgl.dist" value="./dist"/> <property name="lwjgl.docs" value="./doc"/> <property name="lwjgl.temp" value="./temp"/> - <property name="lwjgl.test" value="./test"/> + <property name="lwjgl.res" value="./res"/> <property name="lwjgl.version" value="0.4"/> <!-- Creates a splash screen --> @@ -21,7 +21,7 @@ <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder"/> <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder"/> <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder"/> - <mkdir dir="${lwjgl.test}" taskname="initialiazing test folder"/> + <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder"/> <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder"/> </target> @@ -90,6 +90,9 @@ <fileset dir="${lwjgl.bin}"> <include name="**.class"/> </fileset> + <fileset dir="${lwjgl.res}"> + <include name="data/**"/> + </fileset> </jar> <!-- copy dll/so to lib directory --> @@ -98,16 +101,6 @@ <include name="lwjgl.*"/> <include name="lwjgl_d.*"/> </fileset> - </copy> - - <!-- Copy relevant files to test directory --> - <copy todir="${lwjgl.test}" taskname="jar"> - <fileset dir="${lwjgl.lib}"/> - </copy> - - <!-- copy data files for example --> - <copy todir="${lwjgl.test}/data" taskname="data"> - <fileset dir="examples/data"/> </copy> </target> |