Removed Controller
This commit is contained in:
parent
8220b2e04c
commit
250a87767f
|
@ -393,7 +393,6 @@
|
|||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
|
||||
<class name="org.lwjgl.Sys" />
|
||||
|
||||
<class name="org.lwjgl.input.Controller" />
|
||||
<class name="org.lwjgl.input.Cursor" />
|
||||
<class name="org.lwjgl.input.Keyboard" />
|
||||
<class name="org.lwjgl.input.Mouse" />
|
||||
|
|
|
@ -19,9 +19,6 @@ To run some of the included tests:
|
|||
|
||||
where TEST is one of the following:
|
||||
|
||||
org.lwjgl.test.input.ControllerCreationTest (Requires attached Controller)
|
||||
org.lwjgl.test.input.ControllerTest (Requires attached Controller)
|
||||
org.lwjgl.test.input.ControllerFieldTest (Requires attached Controller)
|
||||
org.lwjgl.test.input.MouseCreationTest
|
||||
org.lwjgl.test.input.MouseTest
|
||||
org.lwjgl.test.input.HWCursorTest
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.ArrayList;
|
|||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
@ -554,20 +553,17 @@ public class Game {
|
|||
case Keyboard.KEY_LEFT:
|
||||
return
|
||||
Keyboard.isKeyDown(Keyboard.KEY_LEFT) ||
|
||||
mouseX < 0 ||
|
||||
(Controller.isCreated() && Controller.getX() < 0);
|
||||
mouseX < 0;
|
||||
|
||||
case Keyboard.KEY_RIGHT:
|
||||
return
|
||||
Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ||
|
||||
mouseX > 0 ||
|
||||
(Controller.isCreated() && Controller.getX() > 0);
|
||||
mouseX > 0;
|
||||
|
||||
case Keyboard.KEY_SPACE:
|
||||
return
|
||||
Keyboard.isKeyDown(Keyboard.KEY_SPACE) ||
|
||||
Mouse.isButtonDown(0) ||
|
||||
(Controller.isCreated() && Controller.isButtonDown(0));
|
||||
Mouse.isButtonDown(0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -603,4 +599,4 @@ public class Game {
|
|||
public Sprite getSprite(String ref) {
|
||||
return new Sprite(textureLoader, ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,391 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.input;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <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) buttons, the x, y, z axis (also rotational x,y ,
|
||||
* z axis) is supported along with a POV (or HAT) and a slider
|
||||
*
|
||||
* The Controller implementation currently only supports the first attached device.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class Controller {
|
||||
|
||||
/** Has the controller been created? */
|
||||
private static boolean created;
|
||||
|
||||
/** The controller buttons status */
|
||||
private static boolean[] buttons;
|
||||
|
||||
/** X position, range -1000 to 1000 */
|
||||
private static int x = 0;
|
||||
|
||||
/** X rotational position, range -1000 to 1000 */
|
||||
private static int rx = 0;
|
||||
|
||||
/** Y position, range -1000 to 1000 */
|
||||
private static int y = 0;
|
||||
|
||||
/** Y rotational position, range -1000 to 1000 */
|
||||
private static int ry = 0;
|
||||
|
||||
/** Z position, range -1000 to 1000 */
|
||||
private static int z = 0;
|
||||
|
||||
/** Z rotational position, range -1000 to 1000 */
|
||||
private static int rz = 0;
|
||||
|
||||
/** Position of Point of View from -1 to 27000 (360 degrees) */
|
||||
private static int pov;
|
||||
|
||||
/** Slider position, range -1000 to 1000 */
|
||||
private 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;
|
||||
|
||||
/** Number of buttons on the controller */
|
||||
private static int buttonCount = -1;
|
||||
|
||||
/** Does this controller support a x axis */
|
||||
private static boolean hasXAxis = false;
|
||||
|
||||
/** Does this controller support a rotational x axis */
|
||||
private static boolean hasRXAxis = false;
|
||||
|
||||
/** Does this controller support an y axis */
|
||||
private static boolean hasYAxis = false;
|
||||
|
||||
/** Does this controller support a rotational y axis */
|
||||
private static boolean hasRYAxis = false;
|
||||
|
||||
/** Does this controller support a z axis */
|
||||
private static boolean hasZAxis = false;
|
||||
|
||||
/** Does this controller support a rotational z axis */
|
||||
private static boolean hasRZAxis = false;
|
||||
|
||||
/** Does this controller support a Point-Of-View (hat) */
|
||||
private static boolean hasPOV = false;
|
||||
|
||||
/** Does this controller support a slider */
|
||||
private static boolean hasSlider = false;
|
||||
|
||||
/** Button names. These are set upon create(), to names like BUTTON0, BUTTON1, etc. */
|
||||
private static String[] buttonName;
|
||||
private static final Map buttonMap = new HashMap(8);
|
||||
|
||||
/** Lazy initialization */
|
||||
private static boolean initialized;
|
||||
|
||||
/**
|
||||
* Controller cannot be constructed.
|
||||
*/
|
||||
private Controller() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static initialization
|
||||
*/
|
||||
private static void initialize() {
|
||||
if (initialized)
|
||||
return;
|
||||
Sys.initialize();
|
||||
initIDs();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Create" the controller. The display must first have been created.
|
||||
* @throws LWJGLException if the controller could not be created for any reason
|
||||
*/
|
||||
public static void create() throws LWJGLException {
|
||||
if (!Display.isCreated())
|
||||
throw new IllegalStateException("Display must be created before you can create Controller");
|
||||
initialize();
|
||||
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
nCreate();
|
||||
|
||||
// Assign names to all the buttons
|
||||
buttonName = new String[buttons.length];
|
||||
for (int i = 0; i < buttons.length; i ++) {
|
||||
buttonName[i] = "BUTTON" + i;
|
||||
buttonMap.put(buttonName[i], new Integer(i));
|
||||
}
|
||||
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the controller has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Destroy" the controller
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (!created) {
|
||||
return;
|
||||
}
|
||||
|
||||
created = false;
|
||||
nDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Polls the controller.
|
||||
*/
|
||||
public static void poll() {
|
||||
if (!created)
|
||||
throw new IllegalStateException("Controller must be created before you can poll the device");
|
||||
nPoll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a particular button is down.
|
||||
*
|
||||
* @param button The index of the button you wish to test (0..buttonCount-1)
|
||||
* @return true if the specified button is down
|
||||
* @see #getButtonCount()
|
||||
*/
|
||||
public static boolean isButtonDown(int button) {
|
||||
if (!created)
|
||||
throw new IllegalStateException("Controller must be created before you can query button state");
|
||||
return buttons[button];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the controller is buffered
|
||||
*/
|
||||
public static boolean isBuffered() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a button's name
|
||||
* @param button The button
|
||||
* @return a String with the button's human readable name in it or null if the button is unnamed
|
||||
*/
|
||||
public static String getButtonName(int button) {
|
||||
if (button < 0 || button >= buttonName.length)
|
||||
return null;
|
||||
else
|
||||
return buttonName[button];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's a button's index. If the button is unrecognised then -1 is returned.
|
||||
* @param buttonName The button name
|
||||
*/
|
||||
public static int getButtonIndex(String buttonName) {
|
||||
Integer ret = (Integer) buttonMap.get(buttonName);
|
||||
if (ret == null)
|
||||
return -1;
|
||||
else
|
||||
return ret.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to poll the controller
|
||||
*/
|
||||
private static native void nPoll();
|
||||
|
||||
/**
|
||||
* Native method to create the controller
|
||||
*/
|
||||
private static native void nCreate() throws LWJGLException;
|
||||
|
||||
/**
|
||||
* Native method the destroy the controller
|
||||
*/
|
||||
private static native void nDestroy();
|
||||
|
||||
/**
|
||||
* Register fields with the native library
|
||||
*/
|
||||
private static native void initIDs();
|
||||
/**
|
||||
* @return Returns the buttonCount.
|
||||
*/
|
||||
public static int getButtonCount() {
|
||||
return buttonCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether POV is supported
|
||||
*/
|
||||
public static boolean hasPOV() {
|
||||
return hasPOV;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a rotational x axis is supported
|
||||
*/
|
||||
public static boolean hasRXAxis() {
|
||||
return hasRXAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a rotational y axis is supported
|
||||
*/
|
||||
public static boolean hasRYAxis() {
|
||||
return hasRYAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a rotational z axis is supported
|
||||
*/
|
||||
public static boolean hasRZAxis() {
|
||||
return hasRZAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a slider is supported
|
||||
*/
|
||||
public static boolean hasSlider() {
|
||||
return hasSlider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a x axis is supported
|
||||
*/
|
||||
public static boolean hasXAxis() {
|
||||
return hasXAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a y axis is supported
|
||||
*/
|
||||
public static boolean hasYAxis() {
|
||||
return hasYAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether a z axis is supported
|
||||
*/
|
||||
public static boolean hasZAxis() {
|
||||
return hasZAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the POV value
|
||||
*/
|
||||
public static int getPov() {
|
||||
return pov;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the rotational value of the x axis
|
||||
*/
|
||||
public static int getRx() {
|
||||
return rx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the rotational value of the y axis
|
||||
*/
|
||||
public static int getRy() {
|
||||
return ry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the rotational value of the z axis
|
||||
*/
|
||||
public static int getRz() {
|
||||
return rz;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the slider value
|
||||
*/
|
||||
public static int getSlider() {
|
||||
return slider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the x axis value
|
||||
*/
|
||||
public static int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the y axis value
|
||||
*/
|
||||
public static int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the z axis value
|
||||
*/
|
||||
public static int getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
|
@ -50,7 +50,6 @@ import java.util.HashSet;
|
|||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
|
@ -232,9 +231,6 @@ public final class Display {
|
|||
if (Keyboard.isCreated()) {
|
||||
Keyboard.destroy();
|
||||
}
|
||||
if (Controller.isCreated()) {
|
||||
Controller.destroy();
|
||||
}
|
||||
display_impl.destroyWindow();
|
||||
}
|
||||
|
||||
|
@ -483,9 +479,6 @@ public final class Display {
|
|||
if (Keyboard.isCreated()) {
|
||||
Keyboard.poll();
|
||||
}
|
||||
if (Controller.isCreated()) {
|
||||
Controller.poll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -594,17 +587,6 @@ public final class Display {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (System.getProperty("os.name").startsWith("Win") && !Controller.isCreated() && !Boolean.getBoolean("org.lwjgl.opengl.Display.nocontroller")) {
|
||||
try {
|
||||
Controller.create();
|
||||
} catch (LWJGLException e) {
|
||||
if (Sys.DEBUG) {
|
||||
e.printStackTrace(System.err);
|
||||
} else {
|
||||
Sys.log("Failed to create Controller: "+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.test.input;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.vector.Vector2f;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
* Controller creation test
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ControllerCreationTest {
|
||||
/** position of quad to draw */
|
||||
private Vector2f position = new Vector2f(320.0f, 240.0f);
|
||||
|
||||
/** Creates a new instance of MouseTest */
|
||||
public ControllerCreationTest() {
|
||||
}
|
||||
|
||||
private void initialize(boolean fullscreen) {
|
||||
try {
|
||||
setDisplayMode();
|
||||
Display.setFullscreen(fullscreen);
|
||||
Display.create();
|
||||
|
||||
if(!Controller.isCreated()) {
|
||||
throw new Exception("Controller could not be created");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
initializeOpenGL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 640,
|
||||
"height=" + 480,
|
||||
"freq=" + 60,
|
||||
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||
});
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void initializeOpenGL() {
|
||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
public void executeTest() {
|
||||
initialize(false);
|
||||
|
||||
System.out.println("Test ready:\n");
|
||||
|
||||
// windowed mode
|
||||
System.out.println("=========== WINDOWED MODE ==============");
|
||||
for(int i=0; i<2; i++) {
|
||||
System.out.println("Test " + (i+1) + ":");
|
||||
wiggleController();
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
// recreate display in fullscreen mode
|
||||
System.out.print("Destroying display...");
|
||||
Display.destroy();
|
||||
System.out.println("success");
|
||||
|
||||
System.out.print("Entering fullscreen mode...");
|
||||
try {
|
||||
Display.destroy();
|
||||
initialize(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("success");
|
||||
|
||||
|
||||
// fullscreen mode
|
||||
System.out.println("=========== FULLSCREEN MODE ==============");
|
||||
for(int i=0; i<2; i++) {
|
||||
System.out.println("Test " + (i+3) + ":");
|
||||
wiggleController();
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
System.out.println("Test completed successfully!");
|
||||
System.out.print("Shutting down...");
|
||||
Display.destroy();
|
||||
System.out.println("shutdown complete");
|
||||
}
|
||||
|
||||
private void wiggleController() {
|
||||
System.out.print("Please move the controller around");
|
||||
|
||||
long statustime = Sys.getTime();
|
||||
long endtime = Sys.getTime() + Sys.getTimerResolution() * 5;
|
||||
|
||||
while (Sys.getTime() < endtime) {
|
||||
|
||||
Display.update();
|
||||
|
||||
//controller is a bit fuzzy
|
||||
if(Controller.getX() > 100) {
|
||||
position.x += 1;
|
||||
} else if (Controller.getX() < -100) {
|
||||
position.x -= 1;
|
||||
}
|
||||
if(Controller.getY() > 100) {
|
||||
position.y -= 1;
|
||||
} else if (Controller.getY() < -100) {
|
||||
position.y += 1;
|
||||
}
|
||||
|
||||
render();
|
||||
|
||||
if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
|
||||
System.out.print(".");
|
||||
statustime = Sys.getTime();
|
||||
}
|
||||
}
|
||||
System.out.println("thank you");
|
||||
}
|
||||
|
||||
private void render() {
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glBegin(GL11.GL_POLYGON);
|
||||
{
|
||||
GL11.glColor3f(0.0f, 1.0f, 1.0f);
|
||||
GL11.glVertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
|
||||
GL11.glColor3f(1.0f, 0.0f, 1.0f);
|
||||
GL11.glVertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
GL11.glVertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
|
||||
GL11.glColor3f(1.0f, 1.0f, 0.0f);
|
||||
GL11.glVertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
GL11.glVertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
}
|
||||
GL11.glEnd();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ControllerCreationTest cct = new ControllerCreationTest();
|
||||
cct.executeTest();
|
||||
}
|
||||
}
|
|
@ -1,194 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.test.input;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ControllerFieldTest {
|
||||
|
||||
private Panel panel;
|
||||
private Frame frame;
|
||||
private Label[] labels;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void executeTest() {
|
||||
initialize();
|
||||
|
||||
if(frame != null) {
|
||||
run();
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void destroy() {
|
||||
Display.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void run() {
|
||||
frame.setVisible(true);
|
||||
|
||||
String buttons;
|
||||
while(frame.isVisible()) {
|
||||
buttons = "";
|
||||
if(Display.isActive()) {
|
||||
Display.update();
|
||||
}
|
||||
|
||||
labels[0].setText("" + Controller.getX());
|
||||
labels[1].setText("" + Controller.getRx());
|
||||
labels[2].setText("" + Controller.getY());
|
||||
labels[3].setText("" + Controller.getRy());
|
||||
labels[4].setText("" + Controller.getZ());
|
||||
labels[5].setText("" + Controller.getRz());
|
||||
labels[6].setText("" + Controller.getPov());
|
||||
labels[7].setText("" + Controller.getSlider());
|
||||
|
||||
for(int i=0; i<Controller.getButtonCount(); i++) {
|
||||
buttons += (Controller.isButtonDown(i)) ? "" + i + ", ": "";
|
||||
}
|
||||
labels[17].setText(buttons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(320, 240, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 320,
|
||||
"height=" + 240,
|
||||
"freq=" + 60,
|
||||
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||
});
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void initialize() {
|
||||
|
||||
try {
|
||||
setDisplayMode();
|
||||
Display.create();
|
||||
} catch (LWJGLException lwjgle) {
|
||||
lwjgle.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Controller.isCreated()) {
|
||||
System.out.println("Unable to aquire controller - exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
// create our panel, with lots of field names | value
|
||||
panel = new Panel();
|
||||
panel.setLayout(new GridLayout(0,2));
|
||||
|
||||
String[] fields = new String[] {
|
||||
"x", "rx", "y", "ry",
|
||||
"z", "rz", "pov", "slider",
|
||||
"buttonCount", "hasXAxis", "hasRXAxis",
|
||||
"hasYAxis", "hasRYAxis", "hasZAxis",
|
||||
"hasRZAxis", "hasPOV", "hasSlider", "buttons"
|
||||
};
|
||||
labels = new Label[fields.length];
|
||||
|
||||
for(int i=0 ;i<fields.length; i++) {
|
||||
panel.add(new Label(fields[i]));
|
||||
panel.add(new Label(""));
|
||||
labels[i] = (Label) panel.getComponent((i*2)+1);
|
||||
}
|
||||
|
||||
frame = new Frame("ControllerFieldTest");
|
||||
frame.setBounds(400, 400, 640, 480);
|
||||
frame.add(panel);
|
||||
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
frame.pack();
|
||||
|
||||
// set initial fields
|
||||
labels[8].setText("" + Controller.getButtonCount());
|
||||
labels[9].setText("" + Controller.hasXAxis());
|
||||
labels[10].setText("" + Controller.hasRXAxis());
|
||||
labels[11].setText("" + Controller.hasYAxis());
|
||||
labels[12].setText("" + Controller.hasRYAxis());
|
||||
labels[13].setText("" + Controller.hasZAxis());
|
||||
labels[14].setText("" + Controller.hasRZAxis());
|
||||
labels[15].setText("" + Controller.hasPOV());
|
||||
labels[16].setText("" + Controller.hasSlider());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ControllerFieldTest test = new ControllerFieldTest();
|
||||
test.executeTest();
|
||||
}
|
||||
}
|
|
@ -1,403 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.test.input;
|
||||
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.vector.Vector2f;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
* <br>
|
||||
* Controller test
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ControllerTest {
|
||||
|
||||
/** Controller fuzz */
|
||||
public static final int FUZZ = 200;
|
||||
|
||||
/** Direction controller has moved */
|
||||
private int direction;
|
||||
|
||||
/** Last button pressed */
|
||||
private int lastButton = 0;
|
||||
|
||||
/** Last direction we scrolled in */
|
||||
private int lastScrollDirection = -1;
|
||||
|
||||
/** Width of window */
|
||||
private static int WINDOW_WIDTH = 640;
|
||||
|
||||
/** Height of window */
|
||||
private static int WINDOW_HEIGHT = 640;
|
||||
|
||||
/** Triangle size (in ½) */
|
||||
private Vector2f triangleSize = new Vector2f(120, 100);
|
||||
|
||||
/** Triangle color */
|
||||
private Vector3f triangleColor[] = new Vector3f[] {
|
||||
new Vector3f(1,1,1),
|
||||
new Vector3f(1,0,0),
|
||||
new Vector3f(0,1,0),
|
||||
new Vector3f(0,0,1)
|
||||
};
|
||||
|
||||
private Vector3f quadColor[] = new Vector3f[] {
|
||||
new Vector3f(1,1,1),
|
||||
new Vector3f(1,0,0),
|
||||
new Vector3f(0,1,0),
|
||||
new Vector3f(0,0,1)
|
||||
};
|
||||
|
||||
/** Triangles to paint */
|
||||
private Vector2f[] triangles = {
|
||||
new Vector2f(WINDOW_WIDTH/2, WINDOW_HEIGHT - triangleSize.y),
|
||||
new Vector2f(triangleSize.y, WINDOW_HEIGHT/2),
|
||||
new Vector2f(WINDOW_WIDTH/2, triangleSize.y),
|
||||
new Vector2f(WINDOW_WIDTH-triangleSize.y, WINDOW_HEIGHT/2)
|
||||
};
|
||||
|
||||
/** Whether the test is closing */
|
||||
private boolean closing = false;
|
||||
|
||||
/** Fullscreen or not */
|
||||
public static final boolean FULLSCREEN = false;
|
||||
|
||||
/** Creates a new instance of ControllerTest */
|
||||
public ControllerTest() {
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
// create display and opengl
|
||||
setupDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup display
|
||||
*/
|
||||
private void setupDisplay() {
|
||||
try {
|
||||
setDisplayMode();
|
||||
Display.setFullscreen(FULLSCREEN);
|
||||
Display.setVSyncEnabled(true);
|
||||
Display.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
initializeOpenGL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(WINDOW_WIDTH, WINDOW_HEIGHT, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + WINDOW_WIDTH,
|
||||
"height=" + WINDOW_HEIGHT,
|
||||
"freq=" + 60,
|
||||
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||
});
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes OpenGL
|
||||
*
|
||||
*/
|
||||
private void initializeOpenGL() {
|
||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the actual test
|
||||
*/
|
||||
public void executeTest() {
|
||||
initialize();
|
||||
|
||||
runTest();
|
||||
|
||||
Display.destroy();
|
||||
}
|
||||
/**
|
||||
* Runs the test
|
||||
*/
|
||||
private void runTest() {
|
||||
// while not exiting
|
||||
while (!closing) {
|
||||
handleWindow();
|
||||
|
||||
// secondary check
|
||||
if(!closing) {
|
||||
|
||||
// poll and check keyboard and mouse
|
||||
handleKeyboard();
|
||||
handleController();
|
||||
|
||||
|
||||
// pause and continue if minimized
|
||||
if(!Display.isVisible()) {
|
||||
pause(100);
|
||||
render();
|
||||
continue;
|
||||
}
|
||||
|
||||
// render and flip
|
||||
logic();
|
||||
render();
|
||||
}
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pauses the current thread for a specified time
|
||||
*
|
||||
* @param time milliseconds to pause
|
||||
*/
|
||||
private void pause(long time) {
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
} catch (InterruptedException inte) {
|
||||
inte.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the window
|
||||
*/
|
||||
private void handleWindow() {
|
||||
Display.update();
|
||||
closing = Display.isCloseRequested();
|
||||
}
|
||||
|
||||
/**
|
||||
* handles the controller
|
||||
*/
|
||||
private void handleController() {
|
||||
readController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the controller
|
||||
*/
|
||||
private void readController() {
|
||||
// get last button down
|
||||
for(int i=0;i<Controller.getButtonCount(); i++) {
|
||||
if(Controller.isButtonDown(i)) {
|
||||
lastButton = i;
|
||||
}
|
||||
}
|
||||
|
||||
updateState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates our "model"
|
||||
*/
|
||||
private void updateState() {
|
||||
direction = -1;
|
||||
|
||||
// get out if no movement
|
||||
if (Controller.getX() == Controller.getY() && Controller.getX() == 0) {
|
||||
if(!Controller.hasPOV()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// determine direction moved
|
||||
// ============================
|
||||
if(Controller.getX() > FUZZ) {
|
||||
direction = 3;
|
||||
}
|
||||
|
||||
if(Controller.getX() < -FUZZ) {
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
if(Controller.getY() > FUZZ) {
|
||||
direction = 2;
|
||||
}
|
||||
|
||||
if(Controller.getY() < -FUZZ) {
|
||||
direction = 0;
|
||||
}
|
||||
// ----------------------------
|
||||
|
||||
if(direction > -1) {
|
||||
|
||||
// based on which button was last pushed, update model
|
||||
switch(lastButton) {
|
||||
case -1:
|
||||
break;
|
||||
case 1:
|
||||
triangleColor[direction].y = 1;
|
||||
break;
|
||||
case 2:
|
||||
triangleColor[direction].z = 1;
|
||||
break;
|
||||
case 3:
|
||||
triangleColor[direction].x = 1;
|
||||
triangleColor[direction].y = 1;
|
||||
triangleColor[direction].z = 1;
|
||||
break;
|
||||
case 0: // fall through
|
||||
default:
|
||||
triangleColor[direction].x = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(Controller.hasPOV()) {
|
||||
// get direction to update in
|
||||
switch(Controller.getPov()) {
|
||||
case Controller.POV_CENTER:
|
||||
return;
|
||||
case Controller.POV_SOUTH:
|
||||
case Controller.POV_EAST:
|
||||
lastScrollDirection++;
|
||||
break;
|
||||
case Controller.POV_NORTH:
|
||||
case Controller.POV_WEST:
|
||||
lastScrollDirection--;
|
||||
break;
|
||||
}
|
||||
|
||||
// over/underflow
|
||||
if(lastScrollDirection < 0) {
|
||||
lastScrollDirection = 3;
|
||||
}
|
||||
if(lastScrollDirection > 3) {
|
||||
lastScrollDirection = 0;
|
||||
}
|
||||
|
||||
// update colors
|
||||
quadColor[lastScrollDirection].x = (float) Math.random();
|
||||
quadColor[lastScrollDirection].y = (float) Math.random();
|
||||
quadColor[lastScrollDirection].z = (float) Math.random();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the keyboard
|
||||
*/
|
||||
private void handleKeyboard() {
|
||||
// closing on ESCAPE
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
|
||||
closing = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the "model logic"
|
||||
*/
|
||||
private void logic() {
|
||||
// "we fade to black"
|
||||
// ===========================================
|
||||
for(int i=0; i<triangleColor.length; i++) {
|
||||
triangleColor[i].x -= 0.01;
|
||||
triangleColor[i].y -= 0.01;
|
||||
triangleColor[i].z -= 0.01;
|
||||
}
|
||||
|
||||
for(int i=0; i<quadColor.length; i++) {
|
||||
quadColor[i].x -= 0.01;
|
||||
quadColor[i].y -= 0.01;
|
||||
quadColor[i].z -= 0.01;
|
||||
}
|
||||
// -------------------------------------------
|
||||
}
|
||||
|
||||
/**
|
||||
* Render our triangles
|
||||
*/
|
||||
private void render() {
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// for each triangle, render it at position, rotating degrees for each
|
||||
for(int i=0; i<triangles.length; i++) {
|
||||
GL11.glPushMatrix(); {
|
||||
GL11.glTranslatef(triangles[i].x, triangles[i].y, 0);
|
||||
GL11.glRotatef(i*90, 0, 0, 1);
|
||||
|
||||
GL11.glColor3f(triangleColor[i].x, triangleColor[i].y, triangleColor[i].z);
|
||||
|
||||
GL11.glBegin(GL11.GL_TRIANGLES); {
|
||||
GL11.glVertex2f(0, triangleSize.y);
|
||||
GL11.glVertex2f(-triangleSize.x, -triangleSize.y);
|
||||
GL11.glVertex2f(+triangleSize.x, -triangleSize.y);
|
||||
}
|
||||
GL11.glEnd();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
// paint quad in the middle (yes, wasting cpu cycles by not precalculating)
|
||||
GL11.glBegin(GL11.GL_QUADS); {
|
||||
GL11.glColor3f(quadColor[0].x, quadColor[0].y, quadColor[0].z);
|
||||
GL11.glVertex2f(WINDOW_WIDTH/2-triangleSize.x, WINDOW_HEIGHT/2-triangleSize.x);
|
||||
GL11.glColor3f(quadColor[1].x, quadColor[1].y, quadColor[1].z);
|
||||
GL11.glVertex2f(WINDOW_WIDTH/2+triangleSize.x, WINDOW_HEIGHT/2-triangleSize.x);
|
||||
GL11.glColor3f(quadColor[2].x, quadColor[2].y, quadColor[2].z);
|
||||
GL11.glVertex2f(WINDOW_WIDTH/2+triangleSize.x, WINDOW_HEIGHT/2+triangleSize.x);
|
||||
GL11.glColor3f(quadColor[3].x, quadColor[3].y, quadColor[3].z);
|
||||
GL11.glVertex2f(WINDOW_WIDTH/2-triangleSize.x, WINDOW_HEIGHT/2+triangleSize.x);
|
||||
}
|
||||
GL11.glEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ControllerTest ct = new ControllerTest();
|
||||
ct.executeTest();
|
||||
}
|
||||
}
|
|
@ -1,538 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* Win32 controller handling.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.com>
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
#undef DIRECTINPUT_VERSION
|
||||
#define DIRECTINPUT_VERSION 0x0500
|
||||
#include "Window.h"
|
||||
#include "org_lwjgl_input_Controller.h"
|
||||
#include <dinput.h>
|
||||
#include "common_tools.h"
|
||||
|
||||
#define CONTROLLER_AXISMAX 1000 // Maxmimum range to which we'll gauge the swing
|
||||
#define CONTROLLER_AXISMIN -1000 // Minimum range to which we'll gauge the swing
|
||||
|
||||
extern HINSTANCE dll_handle;
|
||||
|
||||
static IDirectInput* cDI; // DI instance
|
||||
static IDirectInputDevice2* cDIDevice; // DI Device instance
|
||||
static DIJOYSTATE2 cJS; // State of Controller
|
||||
|
||||
static int cButtoncount = 0; // Temporary buttoncount
|
||||
static bool cHasx; // Temporary xaxis check
|
||||
static bool cHasrx; // Temporary rotational xaxis check
|
||||
static bool cHasy; // Temporary yaxis check
|
||||
static bool cHasry; // Temporary rotational yaxis check
|
||||
static bool cHasz; // Temporary zaxis check
|
||||
static bool cHasrz; // Temporary rotational zaxis check
|
||||
static bool cHaspov; // Temporary pov check
|
||||
static bool cHasslider; // Temporary slider check
|
||||
|
||||
static bool cCreate_success; // bool used to determine successfull creation
|
||||
static bool cFirstTimeInitialization = true; // boolean to determine first time initialization
|
||||
|
||||
// Cached fields of Controller.java
|
||||
static jfieldID fidCButtonCount;
|
||||
static jfieldID fidCHasXAxis;
|
||||
static jfieldID fidCHasRXAxis;
|
||||
static jfieldID fidCHasYAxis;
|
||||
static jfieldID fidCHasRYAxis;
|
||||
static jfieldID fidCHasZAxis;
|
||||
static jfieldID fidCHasRZAxis;
|
||||
static jfieldID fidCHasPOV;
|
||||
static jfieldID fidCHasSlider;
|
||||
static jfieldID fidCButtons;
|
||||
static jfieldID fidCX;
|
||||
static jfieldID fidCRX;
|
||||
static jfieldID fidCY;
|
||||
static jfieldID fidCRY;
|
||||
static jfieldID fidCZ;
|
||||
static jfieldID fidCRZ;
|
||||
static jfieldID fidCPOV;
|
||||
static jfieldID fidCSlider;
|
||||
|
||||
// Function prototypes (defined in the cpp file, since header file is generic across platforms
|
||||
void EnumerateControllerCapabilities();
|
||||
void EnumerateControllers();
|
||||
BOOL CALLBACK EnumControllerCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef);
|
||||
BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
|
||||
void ShutdownController();
|
||||
void CreateController(LPCDIDEVICEINSTANCE lpddi);
|
||||
void SetupController();
|
||||
void InitializeControllerFields(JNIEnv *env, jclass clsController);
|
||||
void CacheControllerFields(JNIEnv *env, jclass clsController);
|
||||
void UpdateControllerFields(JNIEnv *env, jclass clsController);
|
||||
void SetControllerCapabilities(JNIEnv *env, jclass clsController);
|
||||
|
||||
/**
|
||||
* Initializes any field ids
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jclass clazz) {
|
||||
/* Cache fields in Controller */
|
||||
CacheControllerFields(env, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Controller instance is to be created
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) {
|
||||
// Create the DirectInput object.
|
||||
HRESULT hr;
|
||||
hr = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &cDI, NULL);
|
||||
if (FAILED(hr)) {
|
||||
ShutdownController();
|
||||
throwException(env, "DirectInputCreate failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find all Controllers */
|
||||
EnumerateControllers();
|
||||
if (!cCreate_success) {
|
||||
ShutdownController();
|
||||
throwException(env, "Failed to enumerate.");
|
||||
return;
|
||||
}
|
||||
|
||||
/* check that we got at least 1 controller */
|
||||
if (cDIDevice == NULL) {
|
||||
ShutdownController();
|
||||
throwException(env, "No devices found.");
|
||||
return;
|
||||
}
|
||||
|
||||
//check for first time initialization - need to detect capabilities
|
||||
if (cFirstTimeInitialization) {
|
||||
cFirstTimeInitialization = false;
|
||||
|
||||
/* Enumerate capabilities of Controller */
|
||||
EnumerateControllerCapabilities();
|
||||
if (!cCreate_success) {
|
||||
ShutdownController();
|
||||
throwException(env, "Falied to enumerate capabilities.");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do setup of Controller */
|
||||
SetupController();
|
||||
|
||||
/* Initialize any fields on the Controller */
|
||||
InitializeControllerFields(env, clazz);
|
||||
|
||||
/* Set capabilities */
|
||||
SetControllerCapabilities(env, clazz);
|
||||
} else {
|
||||
if(cCreate_success) {
|
||||
/* Do setup of Controller */
|
||||
SetupController();
|
||||
|
||||
/* Initialize any fields on the Controller */
|
||||
InitializeControllerFields(env, clazz);
|
||||
}
|
||||
}
|
||||
|
||||
/* Aquire the Controller */
|
||||
hr = IDirectInputDevice_Acquire(cDIDevice);
|
||||
if(FAILED(hr)) {
|
||||
ShutdownController();
|
||||
throwException(env, "Acquire failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Controller
|
||||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy(JNIEnv *env, jclass clazz) {
|
||||
ShutdownController();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 = IDirectInputDevice2_Poll(cDIDevice);
|
||||
if (FAILED(hRes)) {
|
||||
printfDebug("Poll fail\n");
|
||||
|
||||
//check if we need to reaquire
|
||||
if(hRes == DIERR_INPUTLOST || hRes == DIERR_NOTACQUIRED) {
|
||||
IDirectInputDevice_Acquire(cDIDevice);
|
||||
printfDebug("DIERR_INPUTLOST, reaquiring input : cCreate_success=%d\n", cCreate_success);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateControllerFields(env, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown DI
|
||||
*/
|
||||
static void ShutdownController() {
|
||||
// release device
|
||||
if (cDIDevice != NULL) {
|
||||
IDirectInputDevice_Unacquire(cDIDevice);
|
||||
IDirectInputDevice_Release(cDIDevice);
|
||||
cDIDevice = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the capabilities of the Controller attached to the system
|
||||
*/
|
||||
static void EnumerateControllerCapabilities() {
|
||||
HRESULT hr;
|
||||
hr = IDirectInputDevice_EnumObjects(cDIDevice, EnumControllerObjectsCallback, NULL, DIDFT_ALL);
|
||||
if FAILED(hr) {
|
||||
printfDebug("EnumObjects failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
cCreate_success = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the Controllers attached to the system
|
||||
*/
|
||||
static void EnumerateControllers() {
|
||||
HRESULT hr;
|
||||
hr = IDirectInput_EnumDevices(cDI, DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY);
|
||||
if FAILED(hr) {
|
||||
printfDebug("EnumDevices failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
cCreate_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);
|
||||
|
||||
/* 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) {
|
||||
printfDebug("found %s\n", lpddoi->tszName);
|
||||
if(IsEqualGUID(&lpddoi->guidType, &GUID_Button)) {
|
||||
cButtoncount++;
|
||||
} else if(IsEqualGUID(&lpddoi->guidType, &GUID_XAxis)) {
|
||||
cHasx = true;
|
||||
} else if(IsEqualGUID(&lpddoi->guidType, &GUID_YAxis)) {
|
||||
cHasy = true;
|
||||
} else if(IsEqualGUID(&lpddoi->guidType, &GUID_ZAxis)) {
|
||||
cHasz = true;
|
||||
} else if (IsEqualGUID(&lpddoi->guidType, &GUID_POV)) {
|
||||
cHaspov = true;
|
||||
} else if (IsEqualGUID(&lpddoi->guidType, &GUID_Slider)) {
|
||||
cHasslider = true;
|
||||
} else if (IsEqualGUID(&lpddoi->guidType, &GUID_RxAxis)) {
|
||||
cHasrx = true;
|
||||
} else if (IsEqualGUID(&lpddoi->guidType, &GUID_RyAxis)) {
|
||||
cHasry = true;
|
||||
} else if (IsEqualGUID(&lpddoi->guidType, &GUID_RzAxis)) {
|
||||
cHasrz = true;
|
||||
} else {
|
||||
printfDebug("Unhandled object found: %s\n", lpddoi->tszName);
|
||||
}
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the specified device as a Controller
|
||||
*/
|
||||
static void CreateController(LPCDIDEVICEINSTANCE lpddi) {
|
||||
HRESULT hr;
|
||||
hr = IDirectInput_CreateDevice(cDI, &lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &cDIDevice, NULL);
|
||||
if FAILED(hr) {
|
||||
printfDebug("CreateDevice failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
cCreate_success = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the Controller properties
|
||||
*/
|
||||
static void SetupController() {
|
||||
DIPROPRANGE diprg;
|
||||
// set Controller data format
|
||||
if(IDirectInputDevice_SetDataFormat(cDIDevice, &c_dfDIJoystick2) != DI_OK) {
|
||||
printfDebug("SetDataFormat failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// set the cooperative level
|
||||
if(IDirectInputDevice_SetCooperativeLevel(cDIDevice, getCurrentHWND(), DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) {
|
||||
printfDebug("SetCooperativeLevel failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// set range to (-1000 ... +1000)
|
||||
// This lets us test against 0 to see which way the stick is pointed.
|
||||
diprg.diph.dwSize = sizeof(diprg);
|
||||
diprg.diph.dwHeaderSize = sizeof(diprg.diph);
|
||||
diprg.diph.dwHow = DIPH_BYOFFSET;
|
||||
diprg.lMin = CONTROLLER_AXISMIN;
|
||||
diprg.lMax = CONTROLLER_AXISMAX;
|
||||
|
||||
// set X-axis
|
||||
if(cHasx) {
|
||||
diprg.diph.dwObj = DIJOFS_X;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_X) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// set RX-axis
|
||||
if(cHasrx) {
|
||||
diprg.diph.dwObj = DIJOFS_RX;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_RX) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set Y-axis
|
||||
if(cHasy) {
|
||||
diprg.diph.dwObj = DIJOFS_Y;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_Y) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// set RY-axis
|
||||
if(cHasry) {
|
||||
diprg.diph.dwObj = DIJOFS_RY;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_RY) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// set Z-axis
|
||||
if(cHasz) {
|
||||
diprg.diph.dwObj = DIJOFS_Z;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_Z) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set RZ-axis
|
||||
if(cHasrz) {
|
||||
diprg.diph.dwObj = DIJOFS_RZ;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_RZ) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Lastly slider
|
||||
// using z axis since we're running dx 5
|
||||
//
|
||||
if(cHasslider) {
|
||||
diprg.diph.dwObj = DIJOFS_Z;
|
||||
if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) {
|
||||
printfDebug("SetProperty(DIJOFS_Z(SLIDER)) failed\n");
|
||||
cCreate_success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cCreate_success = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fields on the Controller
|
||||
*/
|
||||
static void InitializeControllerFields(JNIEnv *env, jclass clsController) {
|
||||
//create buttons array
|
||||
jbooleanArray cButtonsArray = (*env)->NewBooleanArray(env, cButtoncount);
|
||||
|
||||
//set buttons array
|
||||
(*env)->SetStaticObjectField(env, clsController, fidCButtons, cButtonsArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fields on the Controller
|
||||
*/
|
||||
static void UpdateControllerFields(JNIEnv *env, jclass clsController) {
|
||||
int i;
|
||||
jbyteArray buttonsArray;
|
||||
HRESULT hRes;
|
||||
|
||||
// get data from the Controller
|
||||
hRes = IDirectInputDevice_GetDeviceState(cDIDevice, sizeof(DIJOYSTATE2), &cJS);
|
||||
|
||||
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 || hRes == DIERR_NOTACQUIRED) {
|
||||
IDirectInputDevice_Acquire(cDIDevice);
|
||||
printfDebug("DIERR_INPUTLOST, reaquiring input : cCreate_success=%d\n", cCreate_success);
|
||||
}
|
||||
printfDebug("Error getting controller state: %d\n", hRes);
|
||||
return;
|
||||
}
|
||||
|
||||
//axis's
|
||||
if(cHasx) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCX, cJS.lX);
|
||||
}
|
||||
|
||||
if(cHasy) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCY, cJS.lY);
|
||||
}
|
||||
|
||||
if(cHasz) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCZ, cJS.lZ);
|
||||
}
|
||||
|
||||
//rotational axis
|
||||
if(cHasrx) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCRX, cJS.lRx);
|
||||
}
|
||||
|
||||
if(cHasry) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCRY, cJS.lRy);
|
||||
}
|
||||
|
||||
if(cHasrz) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCRZ, cJS.lRz);
|
||||
}
|
||||
|
||||
//buttons
|
||||
for (i = 0; i < cButtoncount; i++) {
|
||||
if (cJS.rgbButtons[i] != 0) {
|
||||
cJS.rgbButtons[i] = 1;
|
||||
} else {
|
||||
cJS.rgbButtons[i] = 0;
|
||||
}
|
||||
}
|
||||
buttonsArray = (jbyteArray) (*env)->GetStaticObjectField(env, clsController, fidCButtons);
|
||||
(*env)->SetByteArrayRegion(env, buttonsArray, 0, cButtoncount, (jbyte *)cJS.rgbButtons);
|
||||
|
||||
//pov
|
||||
if(cHaspov) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCPOV, cJS.rgdwPOV[0]);
|
||||
}
|
||||
|
||||
//slider
|
||||
if(cHasslider) {
|
||||
(*env)->SetStaticIntField(env, clsController, fidCSlider, cJS.lZ);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the capabilities of the Controller
|
||||
*/
|
||||
static void SetControllerCapabilities(JNIEnv *env, jclass clsController) {
|
||||
//set buttoncount
|
||||
(*env)->SetStaticIntField(env, clsController, fidCButtonCount, cButtoncount);
|
||||
|
||||
//set axis
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasXAxis, cHasx);
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasYAxis, cHasy);
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasZAxis, cHasz);
|
||||
|
||||
//set rotational axis
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasRXAxis, cHasrx);
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasRYAxis, cHasry);
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasRZAxis, cHasrz);
|
||||
|
||||
//set pov
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasPOV, cHaspov);
|
||||
|
||||
//set slider
|
||||
(*env)->SetStaticBooleanField(env, clsController, fidCHasSlider, cHasslider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the field ids for quicker access
|
||||
*/
|
||||
static void CacheControllerFields(JNIEnv *env, jclass clsController) {
|
||||
fidCButtonCount = (*env)->GetStaticFieldID(env, clsController, "buttonCount", "I");
|
||||
fidCHasXAxis = (*env)->GetStaticFieldID(env, clsController, "hasXAxis", "Z");
|
||||
fidCHasRXAxis = (*env)->GetStaticFieldID(env, clsController, "hasRXAxis", "Z");
|
||||
fidCHasYAxis = (*env)->GetStaticFieldID(env, clsController, "hasYAxis", "Z");
|
||||
fidCHasRYAxis = (*env)->GetStaticFieldID(env, clsController, "hasRYAxis", "Z");
|
||||
fidCHasZAxis = (*env)->GetStaticFieldID(env, clsController, "hasZAxis", "Z");
|
||||
fidCHasRZAxis = (*env)->GetStaticFieldID(env, clsController, "hasRZAxis", "Z");
|
||||
fidCHasPOV = (*env)->GetStaticFieldID(env, clsController, "hasPOV", "Z");
|
||||
fidCHasSlider = (*env)->GetStaticFieldID(env, clsController, "hasSlider", "Z");
|
||||
fidCButtons = (*env)->GetStaticFieldID(env, clsController, "buttons", "[Z");
|
||||
fidCX = (*env)->GetStaticFieldID(env, clsController, "x", "I");
|
||||
fidCRX = (*env)->GetStaticFieldID(env, clsController, "rx", "I");
|
||||
fidCY = (*env)->GetStaticFieldID(env, clsController, "y", "I");
|
||||
fidCRY = (*env)->GetStaticFieldID(env, clsController, "ry", "I");
|
||||
fidCZ = (*env)->GetStaticFieldID(env, clsController, "z", "I");
|
||||
fidCRZ = (*env)->GetStaticFieldID(env, clsController, "rz", "I");
|
||||
fidCPOV = (*env)->GetStaticFieldID(env, clsController, "pov", "I");
|
||||
fidCSlider = (*env)->GetStaticFieldID(env, clsController, "slider", "I");
|
||||
}
|
Loading…
Reference in New Issue