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
|
2
|
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
|
10
|
11
|
12
|
13
|
14
|
15
(4) |
16
(2) |
|
17
(8) |
18
(10) |
19
(32) |
20
(3) |
21
(10) |
22
(5) |
23
|
|
24
(76) |
25
(77) |
26
(33) |
27
(36) |
28
(15) |
29
(14) |
30
(17) |
|
From: Brian M. <ma...@us...> - 2002-11-17 18:15:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test In directory usw-pr-cvs1:/tmp/cvs-serv8702 Added Files: JoystickTest.java Log Message: accompanying test for the joystick implementation --- NEW FILE: JoystickTest.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/test/JoystickTest.java /* * JoystickTest.java * * Created on 13. november 2002, 22:49 */ package org.lwjgl.input.test; import java.awt.*; import java.awt.event.*; import org.lwjgl.input.Joystick; /** * * @author Brian Matzon */ public class JoystickTest extends Panel { private Joystick joystick = null; private int counter = 0; public Thread animationThread; /** Creates a new instance of JoystickTest */ public JoystickTest() { joystick = new Joystick(); try { joystick.create(); } catch (Exception e) { e.printStackTrace(); joystick = null; } 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; if (joystick != null) { joystick.poll(); g.setColor(Color.blue); g.drawString("Buttoncount: " + joystick.buttonCount, x, y); y += 20; g.drawString("-----------------------------------------------", x, y); y += 20; g.drawString("x : " + joystick.x, x, y); y += 20; g.drawString("y : " + joystick.y, x, y); y += 20; if(joystick.hasZAxis) { g.drawString("z : " + joystick.z, x, y); y += 20; } if(joystick.hasPOV) { g.drawString("pov: " + joystick.pov, x, y); y += 20; } //paint buttons g.drawString("btn: ", x, y); x += g.getFontMetrics().stringWidth("btn: "); for(int i=0; i<joystick.buttonCount; i++) { if(joystick.isButtonDown(i)) { g.drawString(i + ", ", x, y); x+= 15; } } } } public void update(Graphics g) { paint(g); } /** * @param args the command line arguments */ public static void main(String[] args) { 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(); f.dispose(); } }); JoystickTest p = new JoystickTest(); p.setSize(640, 480); p.setLocation(0, 0); p.setBackground(Color.RED); f.add(p); f.show(); p.animationThread.start(); } } |
|
From: Brian M. <ma...@us...> - 2002-11-17 18:14:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test In directory usw-pr-cvs1:/tmp/cvs-serv7966/test Log Message: Directory /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test added to the repository |
|
From: Brian M. <ma...@us...> - 2002-11-17 18:14:15
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory usw-pr-cvs1:/tmp/cvs-serv7681 Modified Files: Joystick.java Log Message: first stab at the joystick implementation Index: Joystick.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Joystick.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Joystick.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Joystick.java 28 Aug 2002 21:58:14 -0000 1.7 +++ Joystick.java 17 Nov 2002 18:14:13 -0000 1.8 @@ -32,24 +32,24 @@ package org.lwjgl.input; -import java.nio.ByteBuffer; - -import org.lwjgl.Display; import org.lwjgl.Sys; /** * $Id$ - * + * <br> * A raw Joystick interface. This can be used to poll the current state of the * joystick buttons, and determine the joystick position. The joystick position - * is returned as floats in the range -1.0f to 1.0f. + * is returned as ints in the range -1000 to 1000. * * No buffering is available. - * - * Up to 8 buttons are available. A scrolly wheel or paddle, if present, is the z - * value. This will be in the range of 0.0f to 1.0f. - * - * @author cix_foo <ci...@us...> + * + * Currently n (native limits, currently 128) buttons, the x, y, z axis is supported along with a POV (or HAT), where the z axis + * represents a throttle. In the future the joystick may support more buttons and + * axises and other features. but this is a platform issue. + * + * The joystick implementation currently only supports the first attached joystick. + * + * @author Brian Matzon <br...@ma...> * @version $Revision$ */ public class Joystick { @@ -59,38 +59,47 @@ } /** Has the joystick been created? */ - private static boolean created; + private boolean created; - /** The joystick buttons status from the last poll */ - private static final boolean[] button = new boolean[8]; + /** The joystick buttons status */ + private boolean[] buttons; - /** X position, range -1.0f to 1.0f */ - public static float x; + /** X position, range -1000 to 1000 */ + public int x = -1; - /** Y position, range -1.0f to 1.0f */ - public static float y; + /** Y position, range -1000 to 1000 */ + public int y = -1; - /** Z position, range 0.0f to 1.0f */ - public static float z; + /** Z position, range -1000 to 1000 */ + public int z = -1; + + /** Position of Point of View from -1 to 27000 (360 degrees) */ + public int pov; + + /** Constant specifying centered POV */ + public static final int POV_CENTER = -1; - /** - * The joystick events from the last read: a sequence of Events - */ - private static ByteBuffer readBuffer; - - /** Address of the read buffer */ - private static int readBufferAddress; - - /** The size in bytes of a single joystick event */ - private static final int JOYSTICK_EVENT_SIZE = 20; + /** 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; + + /* Joystick capabilities */ + public int buttonCount = -1; + public boolean hasZAxis = false; + public boolean hasPOV = false; - /** The stride in bytes of a single joystick event */ - private static final int JOYSTICK_EVENT_STRIDE = 32; - /** * Joystick cannot be constructed. */ - private Joystick() { + public Joystick() { } /** @@ -102,159 +111,71 @@ } /** - * Register fields with the native library - */ - private static native void initIDs(); - - /** * "Create" the joystick. The display must first have been created. * @throws Exception if the joystick could not be created for any reason */ - public static void create() throws Exception { - if (created) + public void create() throws Exception { + if (created) { return; - if (!Display.isCreated()) - throw new Exception("The display has not yet been created."); - if (!nCreate()) + } + + if (!nCreate()) { throw new Exception("The joystick could not be created."); + } created = true; } /** - * Native method to create the joystick - * - * @return true if the joystick was created - */ - private static native boolean nCreate(); - - /** * "Destroy" the joystick */ - public static void destroy() { - if (!created) + public void destroy() { + if (!created) { return; + } + created = false; nDestroy(); } - - /** - * Native method the destroy the joystick - */ - private static native void nDestroy(); /** * Polls the joystick. */ - public static void poll() { + public void poll() { assert created : "The joystick has not been created."; nPoll(); } /** - * Native method to poll the joystick - */ - private static native void nPoll(); - - /** - * Queries the number of buttons the joystick has - * @return the number of buttons the joystick has - */ - public static int getNumButtons() { - assert created : "The joystick has not been created."; - return nGetNumButtons(); - } - - /** - * Native implementation of getNumButtons() - */ - private static native int nGetNumButtons(); - - /** - * Queries whether the joystick has a Z value - * @return true if the joystick has a Z value - */ - public static boolean hasZValue() { - assert created : "The joystick has not been created."; - return nHasZValue(); - } - - /** * See if a particular mouse button is down. * * @param button The index of the button you wish to test (0..getNumButtons()) * @return true if the specified button is down * @see #getNumButtons() */ - public static boolean isButtonDown(int button) { + public boolean isButtonDown(int button) { assert created : "The joystick has not been created."; - return Joystick.button[button]; + return buttons[button]; } - - - /** - * Native implementation of hasZValue() - */ - private static native boolean nHasZValue(); - + /** - * Enable joystick buffering. Must be called after the joystick is created. - * @return the size of the joystick buffer in events, or 0 if no buffering - * can be enabled for any reason + * Native method to poll the joystick */ - public static int enableBuffer() { - assert created : "The joystick has not been created."; - return nEnableBuffer(); - } - + private native void nPoll(); + /** - * Native method to read the joystick buffer + * Native method to create the joystick * - * @param readBufferAddress the address of the joystick buffer - * @return the number of joystick events read - */ - private static native int nRead(int readBufferAddress); - - /** - * Reads the joystick buffer. + * @return true if the joystick was created */ - public static void read() { - assert created : "The joystick has not been created."; - assert readBuffer != null : "Joystick buffering has not been enabled."; - readBuffer.clear(); - readBuffer.limit(nRead(readBufferAddress) << 1); - } - - /** - * Native method to enable the buffer - * @return the size of the buffer allocated, in events (1 event is 2 bytes), - * or 0 if no buffer can be allocated + private native boolean nCreate(); + + /** + * Native method the destroy the joystick */ - private static native int nEnableBuffer(); - + private native void nDestroy(); + /** - * Gets the next joystick event. This returns its results as if a poll() had - * been called. - * - * @return true if a joystick event was read, false otherwise + * Register fields with the native library */ - public static boolean next() { - assert created : "The joystick has not been created."; - assert readBuffer != null : "Joystick buffering has not been enabled."; - - if (readBuffer.hasRemaining()) { - x = readBuffer.getFloat(); - y = readBuffer.getFloat(); - z = readBuffer.getFloat(); - for (int i = 0; i < button.length; i ++) - button[i] = readBuffer.get() != (byte)0; - readBuffer.position(readBuffer.position() + (JOYSTICK_EVENT_STRIDE - JOYSTICK_EVENT_SIZE)); - return true; - } else - return false; - - } - - - - -} + private static native void initIDs(); +} \ No newline at end of file |
|
From: Brian M. <ma...@us...> - 2002-11-17 18:13:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory usw-pr-cvs1:/tmp/cvs-serv7088 Modified Files: org_lwjgl_input_Joystick.cpp Log Message: first stab at the win32 joystick implementation Index: org_lwjgl_input_Joystick.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_input_Joystick.cpp 19 Oct 2002 14:27:26 -0000 1.1 +++ org_lwjgl_input_Joystick.cpp 17 Nov 2002 18:13:46 -0000 1.2 @@ -35,40 +35,111 @@ * * Win32 analogue joystick handling. * - * @author cix_foo <ci...@us...> + * @author Brian Matzon <br...@ma...> * @version $Revision$ */ - - #define WIN32_LEAN_AND_MEAN -#include <windows.h> #include "org_lwjgl_input_Joystick.h" + +#include <windows.h> #undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0300 +#define DIRECTINPUT_VERSION 0x0500 #include <dinput.h> -extern LPDIRECTINPUT lpdi; -LPDIRECTINPUTDEVICE lpdiJoystick; -extern HWND hwnd; // The display, which must have been created -/* - * Class: org_lwjgl_input_Joystick - * Method: initIDs - * Signature: ()V +#define JOYMAX 1000 // Maxmimum range to which we'll gauge the swing +#define JOYMIN -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 joystick + +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 Joystick.java +jclass clsJoystick; +jobject objJoystick; +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 EnumerateJoysticks(); +BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef); +BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); +void Shutdown(); +void CreateJoystick(LPCDIDEVICEINSTANCE lpddi); +void SetupJoystick(); +void InitializeFields(); +void UpdateFields(); +void SetCapabilities(); +void CacheFields(jobject obj); +void PrintError(HRESULT error); + +/** + * Initializes any field ids */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs - (JNIEnv * env, jclass clazz) {} +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs(JNIEnv * env, jclass clazz) { + environment = env; +} -/* - * Class: org_lwjgl_input_Joystick - * Method: nCreate - * Signature: ()Z +/** + * Called when the Joystick instance is to be created */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate - (JNIEnv * env, jclass clazz) -{ - printf("Joystick not implemented yet!\n"); - return JNI_FALSE; +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate(JNIEnv *env, jobject obj) { + /* Cache fields in Joystick */ + CacheFields(obj); + + // Create the DirectInput object. + HRESULT hr; + hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); + if (FAILED(hr)) { + Shutdown(); + return JNI_FALSE; + } + + /* Find all joysticks */ + EnumerateJoysticks(); + if (!create_success) { + Shutdown(); + return JNI_FALSE; + } + + /* Enumerate capabilities of joystick */ + EnumerateCapabilities(); + if (!create_success) { + Shutdown(); + return JNI_FALSE; + } + + /* Initialize any fields on the Joystick */ + InitializeFields(); + + /* Set capabilities */ + SetCapabilities(); + + /* Aquire the joystick */ + hr = lpDIDevice->Acquire(); + if(FAILED(hr)) { + Shutdown(); + return JNI_FALSE; + } + + return create_success; } /* @@ -76,9 +147,8 @@ * Method: nDestroy * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jobject obj) { + Shutdown(); } /* @@ -86,52 +156,272 @@ * Method: nPoll * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jobject obj) { + lpDIDevice->Poll(); + UpdateFields(); } -/* - * Class: org_lwjgl_input_Joystick - * Method: nGetNumButtons - * Signature: ()I +/** + * Shutdown DI */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nGetNumButtons - (JNIEnv * env, jclass clazz) -{ - return 0; +void Shutdown() { + // release DI instance + if (lpDI != NULL) { + // release device + if (lpDIDevice != NULL) { + lpDIDevice->Unacquire(); + lpDIDevice->Release(); + lpDIDevice = NULL; + } + lpDI->Release(); + lpDI = NULL; + } + + // Delete are global reference to the Joystick + if(objJoystick != NULL) { + environment->DeleteGlobalRef(objJoystick); + } } -/* - * Class: org_lwjgl_input_Joystick - * Method: nHasZValue - * Signature: ()Z +/** + * Enumerates the capabilities of the joystick attached to the system */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nHasZValue - (JNIEnv * env, jclass clazz) -{ - return JNI_FALSE; +void EnumerateCapabilities() { + HRESULT hr; + hr = lpDIDevice->EnumObjects(EnumJoystickObjectsCallback, NULL, DIDFT_ALL); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; } -/* - * Class: org_lwjgl_input_Joystick - * Method: nRead - * Signature: (I)I +/** + * Enumerates the joysticks attached to the system */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nRead - (JNIEnv * env, jclass clazz, jint buf) -{ - int * bufPtr = (int *) buf; - return 0; +void EnumerateJoysticks() { + HRESULT hr; + hr = lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumJoystickCallback, 0, DIEDFL_ATTACHEDONLY); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; } -/* - * Class: org_lwjgl_input_Joystick - * Method: nEnableBuffer - * Signature: ()I +/** + * Callback from EnumDevices. Called for each joystick attached to the system */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nEnableBuffer - (JNIEnv * env, jclass clazz) -{ - return 0; +BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { + /* Add the joystick */ + CreateJoystick(pdinst); + if(create_success) { + /* Do setup of joystick */ + SetupJoystick(); + } + + /* just stop after 1st joystick */ + return DIENUM_STOP; +} + +/** + * Callback from EnumObjects. Called for each "object" on the joystick. + */ +BOOL CALLBACK EnumJoystickObjectsCallback(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 joystick + */ +void CreateJoystick(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 joystick properties + */ +void SetupJoystick() { + // set joystick 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 = JOYMIN; + diprg.lMax = JOYMAX; + + 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; } + +/** + * Aquires the Joystick + */ +bool AcquireInput(void) { + HRESULT hRes; + + // if we have a device + if (lpDIDevice != NULL) { + // acquire the device + hRes = lpDIDevice->Acquire(); + + if (SUCCEEDED(hRes)) { + // acquisition successful + return TRUE; + } else { + // acquisition failed + return FALSE; + } + } else { + // we don't have a current device + return FALSE; + } +} + +/** + * Sets the fields on the Joystick + */ +void InitializeFields() { + //set buttons array + jbooleanArray buttonsArray = environment->NewBooleanArray(buttoncount); + environment->SetObjectField(objJoystick, fidButtons, buttonsArray); +} + +/** + * Updates the fields on the Joystick + */ +void UpdateFields() { + HRESULT hRes; + + // poll the joystick to read the current state + hRes = lpDIDevice->Poll(); + if (FAILED(hRes)) { +#if _DEBUG + printf("Poll fail\n"); +#endif + return; + } + + // get data from the joystick + 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) { + AcquireInput(); +#if _DEBUG + printf("DIERR_INPUTLOST, reaquiring input\n"); +#endif + } + return; + } + + //axis's + environment->SetIntField(objJoystick, fidX, js.lX); + environment->SetIntField(objJoystick, fidY, js.lY); + if(hasz) { + environment->SetIntField(objJoystick, fidZ, js.lZ); + } + + //buttons + jbooleanArray buttonsArray = (jbooleanArray) environment->GetObjectField(objJoystick, fidButtons); + BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); + memcpy(buttons, js.rgbButtons, 4); + environment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0); + + //pov + if(haspov) { + environment->SetIntField(objJoystick, fidPOV, js.rgdwPOV[0]); + } +} + +/** + * Sets the capabilities of the joystick + */ +void SetCapabilities() { + //set buttoncount + environment->SetIntField(objJoystick, fidButtonCount, buttoncount); + + //set z axis + environment->SetIntField(objJoystick, fidHasZAxis, hasz); + + //set pov + environment->SetIntField(objJoystick, fidHasPOV, haspov); +} + +/** + * Caches the field ids for quicker access + */ +void CacheFields(jobject obj) { + /* make certain that we're caching from a global object, and not a local */ + objJoystick = environment->NewGlobalRef(obj); + clsJoystick = environment->GetObjectClass(objJoystick); + + /* cache fields */ + fidButtonCount = environment->GetFieldID(clsJoystick, "buttonCount", "I"); + fidHasZAxis = environment->GetFieldID(clsJoystick, "hasZAxis", "Z"); + fidHasPOV = environment->GetFieldID(clsJoystick, "hasPOV", "Z"); + fidButtons = environment->GetFieldID(clsJoystick, "buttons", "[Z"); + fidX = environment->GetFieldID(clsJoystick, "x", "I"); + fidY = environment->GetFieldID(clsJoystick, "y", "I"); + fidZ = environment->GetFieldID(clsJoystick, "z", "I"); + fidPOV = environment->GetFieldID(clsJoystick, "pov", "I"); +} \ No newline at end of file |
|
From: Brian M. <ma...@us...> - 2002-11-17 18:12:16
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory usw-pr-cvs1:/tmp/cvs-serv5047 Modified Files: org_lwjgl_input_Joystick.h Log Message: new joystick header Index: org_lwjgl_input_Joystick.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_input_Joystick.h 24 Aug 2002 21:17:37 -0000 1.1 +++ org_lwjgl_input_Joystick.h 17 Nov 2002 18:12:13 -0000 1.2 @@ -8,25 +8,24 @@ extern "C" { #endif /* Inaccessible static: _00024assertionsDisabled */ -/* Inaccessible static: created */ -/* Inaccessible static: button */ -/* Inaccessible static: x */ -/* Inaccessible static: y */ -/* Inaccessible static: z */ -/* Inaccessible static: readBuffer */ -/* Inaccessible static: readBufferAddress */ -#undef org_lwjgl_input_Joystick_JOYSTICK_EVENT_SIZE -#define org_lwjgl_input_Joystick_JOYSTICK_EVENT_SIZE 20L -#undef org_lwjgl_input_Joystick_JOYSTICK_EVENT_STRIDE -#define org_lwjgl_input_Joystick_JOYSTICK_EVENT_STRIDE 32L -/* Inaccessible static: class_000240 */ +#undef org_lwjgl_input_Joystick_POV_CENTER +#define org_lwjgl_input_Joystick_POV_CENTER -1L +#undef org_lwjgl_input_Joystick_POV_NORTH +#define org_lwjgl_input_Joystick_POV_NORTH 0L +#undef org_lwjgl_input_Joystick_POV_SOUTH +#define org_lwjgl_input_Joystick_POV_SOUTH 18000L +#undef org_lwjgl_input_Joystick_POV_EAST +#define org_lwjgl_input_Joystick_POV_EAST 27000L +#undef org_lwjgl_input_Joystick_POV_WEST +#define org_lwjgl_input_Joystick_POV_WEST 9000L +/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Joystick */ /* * Class: org_lwjgl_input_Joystick - * Method: initIDs + * Method: nPoll * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs - (JNIEnv *, jclass); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll + (JNIEnv *, jobject); /* * Class: org_lwjgl_input_Joystick @@ -34,7 +33,7 @@ * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate - (JNIEnv *, jclass); + (JNIEnv *, jobject); /* * Class: org_lwjgl_input_Joystick @@ -42,46 +41,14 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy - (JNIEnv *, jclass); + (JNIEnv *, jobject); /* * Class: org_lwjgl_input_Joystick - * Method: nPoll + * Method: initIDs * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll - (JNIEnv *, jclass); - -/* - * Class: org_lwjgl_input_Joystick - * Method: nGetNumButtons - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nGetNumButtons - (JNIEnv *, jclass); - -/* - * Class: org_lwjgl_input_Joystick - * Method: nHasZValue - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nHasZValue - (JNIEnv *, jclass); - -/* - * Class: org_lwjgl_input_Joystick - * Method: nRead - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nRead - (JNIEnv *, jclass, jint); - -/* - * Class: org_lwjgl_input_Joystick - * Method: nEnableBuffer - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nEnableBuffer +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs (JNIEnv *, jclass); #ifdef __cplusplus |
|
From: Elias N. <eli...@us...> - 2002-11-17 17:09:43
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory usw-pr-cvs1:/tmp/cvs-serv29961 Modified Files: Game.java Makefile Added Files: checkGLerror.h Log Message: Added debug support --- NEW FILE: checkGLerror.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/checkGLerror.h /* checkGLerror.h Author: C. Prince Created: 8 November 2001 Error checking for OpenGL bindings */ #ifndef _CHECKGLERROR_H_INCLUDED_ #define _CHECKGLERROR_H_INCLUDED_ #ifdef _DEBUG #include <jni.h> #include <GL/glu.h> #define CHECK_GL_ERROR \ { \ int err = glGetError(); \ if (err != GL_NO_ERROR) { \ jclass cls = (*env)->FindClass(env, "org/lwjgl/opengl/OpenGLException"); \ (*env)->ThrowNew(env, cls, (const char *)gluErrorString(err)); \ (*env)->DeleteLocalRef(env, cls); \ } \ } #else #define CHECK_GL_ERROR #endif /* _DEBUG */ #endif /* _CHECKGLERROR_H_INCLUDED_ */ Index: Game.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Game.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Game.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Game.java 17 Nov 2002 16:49:16 -0000 1.5 +++ Game.java 17 Nov 2002 17:09:40 -0000 1.6 @@ -33,7 +33,7 @@ /** * $Id$ * - * Simple test java program. + * Simple java test program. * * @author elias_naur <eli...@us...> * @version $Revision$ Index: Makefile CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Makefile =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile 15 Nov 2002 11:10:32 -0000 1.2 +++ Makefile 17 Nov 2002 17:09:40 -0000 1.3 @@ -42,25 +42,25 @@ GCC = gcc LINK = gcc JAVAHOME=/usr/java/j2sdk1.4.1_01 -JAVAC=$(JAVAHOME)/bin/javac -JAVAH=$(JAVAHOME)/bin/javah -CP=../../java -JAVAFILES=$(shell find ../../java -name \*.java -print|grep -v CVS) -CLASSFILES=$(JAVAFILES:.java=.class) +LIBOBJS=org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o +DEBUG_FLAGS=-D_DEBUG +LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU all: liblwjgl.so -liblwjgl.so: org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o - $(LINK) -shared -o $@ $^ -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU + +liblwjgl_d.so: $(LIBOBJS) + $(LINK) -shared -o $@ $^ $(LINKOPTS) cp $@ ../../../bin/ -.SUFFIXES: .cpp .so .o .java .h .class +liblwjgl.so: $(LIBOBJS) + $(LINK) -shared -o $@ $^ $(LINKOPTS) + cp $@ ../../../bin/ -%.class: %.java - $(JAVAC) -deprecation -O -source 1.4 -classpath $(CP) $< +.SUFFIXES: .cpp .so .o .java .h .class %.o : %.c - $(GCC) -Wall -I$(JAVAHOME)/include -I../common -I$(JAVAHOME)/include/linux -c -o $@ $< + $(GCC) $(DEBUG_FLAGS) -Wall -I$(JAVAHOME)/include -I../common -I$(JAVAHOME)/include/linux -c -o $@ $< testprog : main.o $(LINK) -o $@ $< -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU |
|
From: Elias N. <eli...@us...> - 2002-11-17 16:49:19
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory usw-pr-cvs1:/tmp/cvs-serv723 Modified Files: Game.java org_lwjgl_input_Mouse.c Log Message: Cursor z movement added Index: Game.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Game.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Game.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Game.java 16 Nov 2002 20:10:42 -0000 1.4 +++ Game.java 17 Nov 2002 16:49:16 -0000 1.5 @@ -109,8 +109,8 @@ angle = 0.0f; Mouse.poll(); - if (Mouse.dx != 0 || Mouse.dy != 0) - System.out.println("Mouse moved " + Mouse.dx + " " + Mouse.dy); + 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"); Index: org_lwjgl_input_Mouse.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_input_Mouse.c 17 Nov 2002 16:14:53 -0000 1.3 +++ org_lwjgl_input_Mouse.c 17 Nov 2002 16:49:16 -0000 1.4 @@ -46,7 +46,7 @@ #include <string.h> #include "org_lwjgl_input_Mouse.h" -#define NUM_BUTTONS 8 +#define NUM_BUTTONS 3 extern Display *disp; extern Window win; @@ -58,8 +58,10 @@ int last_x; int last_y; +int last_z; int current_x; int current_y; +int current_z; unsigned char buttons[NUM_BUTTONS]; Cursor blank_cursor; @@ -107,10 +109,10 @@ gc_values.foreground = 0; GC gc = XCreateGC(disp, mask, GCForeground, &gc_values); XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height); + XFreeGC(disp, gc); XColor dummy_color; blank_cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0); XFreePixmap(disp, mask); - XFreeGC(disp, gc); XDefineCursor(disp, win, blank_cursor); return 1; } @@ -124,7 +126,7 @@ (JNIEnv * env, jclass clazz) { int i; - current_x = current_y = last_x = last_y = 0; + current_x = current_y = current_z = last_x = last_y = last_z = 0; for (i = 0; i < NUM_BUTTONS; i++) buttons[i] = 0; if (!blankCursor()) { @@ -145,6 +147,25 @@ /* * Class: org_lwjgl_input_Mouse + * Method: nGetNumButtons + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNumButtons(JNIEnv *env, jclass clazz) { + return (jint)NUM_BUTTONS; +} + +/* + * Class: org_lwjgl_input_Mouse + * Method: nHasZValue + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasZValue(JNIEnv *env, jclass clazz) { + return JNI_TRUE; +} + + +/* + * Class: org_lwjgl_input_Mouse * Method: nDestroy * Signature: ()V */ @@ -156,27 +177,6 @@ XUngrabPointer(disp, CurrentTime); } -void setButtonState(XButtonEvent event, unsigned char val) { - switch (event.button) { - case Button1: - buttons[0] = val; - break; - case Button2: - buttons[1] = val; - break; - case Button3: - buttons[2] = val; - break; - case Button4: - buttons[3] = val; - break; - case Button5: - buttons[4] = val; - break; - default: assert(0); - } -} - int checkPointer() { XEvent event; int count = 0; @@ -184,10 +184,41 @@ count++; switch (event.type) { case ButtonPress: - setButtonState(event.xbutton, 1); + switch (event.xbutton.button) { + case Button1: + buttons[0] = 1; + break; + case Button2: + buttons[1] = 1; + break; + case Button3: + buttons[2] = 1; + break; + case Button4: + current_z--; + break; + case Button5: + current_z++; + break; + default: assert(0); + } break; case ButtonRelease: - setButtonState(event.xbutton, 0); + switch (event.xbutton.button) { + case Button1: + buttons[0] = 0; + break; + case Button2: + buttons[1] = 0; + break; + case Button3: + buttons[2] = 0; + break; + case Button4: /* Fall through */ + case Button5: + break; + default: assert(0); + } break; case MotionNotify: current_x = event.xbutton.x; @@ -210,11 +241,13 @@ checkPointer(); int moved_x = current_x - last_x; int moved_y = current_y - last_y; + int moved_z = current_z - last_z; (*env)->SetStaticIntField(env, clazz, fid_dx, (jint)moved_x); (*env)->SetStaticIntField(env, clazz, fid_dy, (jint)moved_y); - (*env)->SetStaticIntField(env, clazz, fid_dz, (jint)0); + (*env)->SetStaticIntField(env, clazz, fid_dz, (jint)moved_z); last_x = current_x; last_y = current_y; + last_z = current_z; jbooleanArray buttonsArray = (jbooleanArray) (*env)->GetStaticObjectField(env, clazz, fid_button); unsigned char * class_buttons = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, buttonsArray, NULL); memcpy(class_buttons, buttons, NUM_BUTTONS*sizeof(unsigned char)); |
|
From: Elias N. <eli...@us...> - 2002-11-17 16:14:56
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory usw-pr-cvs1:/tmp/cvs-serv23498 Modified Files: org_lwjgl_Display.c org_lwjgl_input_Mouse.c Log Message: Cursor blanking added Index: org_lwjgl_Display.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_Display.c 16 Nov 2002 20:10:42 -0000 1.5 +++ org_lwjgl_Display.c 17 Nov 2002 16:14:53 -0000 1.6 @@ -102,10 +102,18 @@ return JNI_FALSE; } screen = DefaultScreen(disp); + if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { + XCloseDisplay(disp); +#ifdef _DEBUG + printf("Could not get display modes\n"); +#endif + return JNI_FALSE; + } root_win = RootWindow(disp, screen); vis_info = glXChooseVisual(disp, screen, attriblist); if (vis_info == NULL) { + XCloseDisplay(disp); #ifdef _DEBUG printf("Could not choose glx visual\n"); #endif @@ -129,18 +137,16 @@ if (fullscreen) { XMapRaised(disp, win); waitMapped(disp, win); - if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { -#ifdef _DEBUG - printf("Could not get display modes\n"); -#endif - return JNI_FALSE; - } for ( i = 0; i < num_modes; ++i ) { #ifdef _DEBUG printf("Mode %d: %dx%d\n", i, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay); #endif if (avail_modes[i]->hdisplay == width && avail_modes[i]->vdisplay == height) { if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[i])) { + XFree(vis_info); + XFree(avail_modes); + XDestroyWindow(disp, win); + XCloseDisplay(disp); #ifdef _DEBUG printf("Could not switch mode\n"); #endif @@ -167,8 +173,8 @@ printf("Could not switch mode\n"); #endif } - XFree(avail_modes); } + XFree(avail_modes); XFree(vis_info); XCloseDisplay(disp); #ifdef _DEBUG Index: org_lwjgl_input_Mouse.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_input_Mouse.c 15 Nov 2002 11:10:32 -0000 1.2 +++ org_lwjgl_input_Mouse.c 17 Nov 2002 16:14:53 -0000 1.3 @@ -62,6 +62,8 @@ int current_y; unsigned char buttons[NUM_BUTTONS]; +Cursor blank_cursor; + /* * Class: org_lwjgl_input_Mouse * Method: initIDs @@ -92,6 +94,27 @@ } } +int blankCursor(void) { + int best_width, best_height; + if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) { +#ifdef _DEBUG + printf("Could not query best cursor size\n"); +#endif + return 0; + } + Pixmap mask = XCreatePixmap(disp, win, best_width, best_height, 1); + XGCValues gc_values; + gc_values.foreground = 0; + GC gc = XCreateGC(disp, mask, GCForeground, &gc_values); + XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height); + XColor dummy_color; + blank_cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0); + XFreePixmap(disp, mask); + XFreeGC(disp, gc); + XDefineCursor(disp, win, blank_cursor); + return 1; +} + /* * Class: org_lwjgl_input_Mouse * Method: nCreate @@ -104,6 +127,12 @@ current_x = current_y = last_x = last_y = 0; for (i = 0; i < NUM_BUTTONS; i++) buttons[i] = 0; + if (!blankCursor()) { +#ifdef _DEBUG + printf("Could not blank cursor\n"); +#endif + return JNI_FALSE; + } int result = XGrabPointer(disp, win, False, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, win, None, CurrentTime); if (result != GrabSuccess) { #ifdef _DEBUG @@ -122,6 +151,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy (JNIEnv * env, jclass clazz) { + XUndefineCursor(disp, win); + XFreeCursor(disp, blank_cursor); XUngrabPointer(disp, CurrentTime); } |