diff options
author | endolf <[email protected]> | 2006-04-29 22:29:27 +0000 |
---|---|---|
committer | endolf <[email protected]> | 2006-04-29 22:29:27 +0000 |
commit | 986c6106aa165d4168f6b8e1216eceb5353fce14 (patch) | |
tree | 1a61954c62909e8e4a4b4c578665a4df40d013cf /coreAPI | |
parent | 09bdd72a93f2a5498137d22540d035df87cff174 (diff) |
Make version 2 the main jinput version
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@139 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'coreAPI')
14 files changed, 556 insertions, 869 deletions
diff --git a/coreAPI/build.xml b/coreAPI/build.xml index 8d747dc..a87fdd6 100644 --- a/coreAPI/build.xml +++ b/coreAPI/build.xml @@ -1,104 +1,32 @@ <?xml version="1.0"?> -<!-- Written to assume that classpath is rooted in the current directory. --> -<!-- So this should be OK if you make this script in the root of a filesystem. --> -<!-- If not, you may prefer to adjust the basedir, or move some directories around. --> -<!-- The idea is that both Ant and NetBeans have to know what the package root is --> -<!-- for the classes in your application. --> <project name="Game Input API" basedir="." default="all"> - - <!-- Don't worry if you don't know the Ant syntax completely or need help on some tasks! --> - <!-- The standard Ant documentation is bundled. See Help | Help Sets | Ant 1.4.1 Manual. --> - <target name="init"> - <!-- You can set up any variables you want used throughout the script here. --> - <!-- property name="hello" value="world" --> - <!-- To use e.g. Jikes, uncomment this line. --> - <!-- (Or make the same change in Tools | Options | Ant Settings | Properties.) --> - <!-- <property name="build.compiler" value="jikes"/> --> - <!-- You might like to set up some overridable paths, etc.: --> - <property name="utils" value="lib/jutils.jar"/> + <property name="utils" location="../lib/jutils.jar"/> <mkdir dir="apidocs"/> <mkdir dir="classes"/> <mkdir dir="bin"/> </target> <target name="compile" depends="init"> - <!-- Both srcdir and destdir should be package roots. --> - <!-- They could be different of course; in that case NetBeans can also be set --> - <!-- up to compile to a different filesystem in the same way; see Compiler Types: --> <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4"> <include name="net/**"/> <!-- To add something to the classpath: --> <classpath> <pathelement location="${utils}"/> </classpath> - <!-- To exclude some files: --> - <!-- - <exclude name="com/foo/SomeFile.java"/> - <exclude name="com/foo/somepackage/"/> - --> </javac> </target> <target name="jar" depends="init,compile"> - <!-- To make a standalone app: --> - <!-- 1. Create a myapp.mf manifest somewhere. --> - <!-- 2. Put in it: --> - <!-- Manifest-Version: 1.0 --> - <!-- Main-Class: com.foo.Main --> - <!-- 3. Pass to <jar>: manifest="myapp.mf" --> - <jar jarfile="bin/jinput.jar" compress="true" basedir="classes"> - <include name="net/**"/> - <exclude name="**/*.java"/> - <exclude name="**/*.form"/> - <exclude name="myapp.mf"/> - <exclude name="myapp.jar"/> + <jar jarfile="bin/jinput-core.jar" compress="true" basedir="classes"> + <include name="net/java/games/input/*class"/> + </jar> + <jar jarfile="bin/jinput-test.jar" compress="true" basedir="classes"> + <include name="net/java/games/input/test/*class"/> </jar> - <copy file="bin/jinput.jar" todir="../plugins/DX8/lib" /> </target> - - <target name="texttest" depends="init,all" description="Try running it."> - <java classname="net.java.games.input.test.ControllerTextTest" - fork="true" failonerror="true" dir="src/tests"> - <classpath> - <pathelement location="bin/jinput.jar"/> - <pathelement location="${utils}"/> - </classpath> - <!-- Pass some args, perhaps: --> - <!-- <arg value="-myfile"/> --> - <!-- Will be given as an absolute path: --> - <!-- <arg file="myfile.txt"/> --> - </java> - </target> - <target name="readtest" depends="init,all" description="Try running it."> - <java classname="net.java.games.input.test.ControllerReadTest" - fork="true" failonerror="true" dir="src/tests"> - <classpath> - <pathelement location="bin/jinput.jar"/> - <pathelement location="${utils}"/> - </classpath> - <!-- Pass some args, perhaps: --> - <!-- <arg value="-myfile"/> --> - <!-- Will be given as an absolute path: --> - <!-- <arg file="myfile.txt"/> --> - </java> - </target> - <target name="rumbletest" depends="init,all" description="Try running it."> - <java classname="net.java.games.input.test.RumbleTest" - fork="true" failonerror="true" dir="src/tests"> - <classpath> - <pathelement location="bin/jinput.jar"/> - <pathelement location="${utils}"/> - </classpath> - <!-- Pass some args, perhaps: --> - <!-- <arg value="-myfile"/> --> - <!-- Will be given as an absolute path: --> - <!-- <arg file="myfile.txt"/> --> - </java> - </target> - <target name="javadoc" depends="init" description="Javadoc for my API."> <javadoc packagenames="net.java.games.input.*" destdir="apidocs" @@ -113,18 +41,12 @@ </target> <target name="clean" depends="init" description="Clean all build products."> - <delete> - <fileset dir="classes"> - <include name="**/*.class"/> - </fileset> - </delete> - <delete file="bin/jinput.jar"/> - <delete dir="apidocs"/> - <delete file="../plugins/DX8/lib/jinput.jar" /> + <delete dir="classes"/> + <delete dir="bin"/> + <delete dir="apidocs"/> </target> <target name="all" depends="init,jar" description="Build everything."> <echo message="JInput has been built and jinput.jar is located in the bin directory."/> - </target> - + </target> </project> diff --git a/coreAPI/src/java/net/java/games/input/AbstractComponent.java b/coreAPI/src/java/net/java/games/input/AbstractComponent.java index b829c1b..40a1750 100644 --- a/coreAPI/src/java/net/java/games/input/AbstractComponent.java +++ b/coreAPI/src/java/net/java/games/input/AbstractComponent.java @@ -38,6 +38,8 @@ *****************************************************************************/ package net.java.games.input; +import java.io.IOException; + /** * Skeleton implementation of a named axis. */ @@ -46,17 +48,12 @@ public abstract class AbstractComponent implements Component { /** * Human-readable name for this Axis */ - protected String name; - - /** - * Identifier for the axis - */ - protected Identifier id; + private final String name; - /** - * Whether this axis is ready to receive polling data - */ - private boolean polling; + private final Identifier id; + + private float value; + private float event_value; /** * Protected constructor @@ -65,7 +62,6 @@ public abstract class AbstractComponent implements Component { protected AbstractComponent(String name, Identifier id) { this.name = name; this.id = id; - this.polling = true; } /** @@ -84,30 +80,6 @@ public abstract class AbstractComponent implements Component { } /** - * Returns whether or not data polled from this axis is normalized - * between the values of -1.0f and 1.0f. - * @return true by default, can be overridden - */ - public boolean isNormalized() { - return true; - } - - /** - * Returns whether or not this axis is ready to receive polling data. - * By default, an abstract axis is set to receive polling data. - */ - public boolean isPolling() { - return polling; - } - - /** - * Sets whether or not the axis should receive polling data. - */ - public void setPolling(boolean polling) { - this.polling = polling; - } - - /** * Returns the suggested dead zone for this axis. Dead zone is the * amount polled data can vary before considered a significant change * in value. An application can safely ignore changes less than this @@ -125,10 +97,22 @@ public abstract class AbstractComponent implements Component { * 1.0f. * @return 0.0f by default, can be overridden */ - public float getPollData() { - return 0.0f; + public final float getPollData() { + return value; + } + + final void setPollData(float value) { + this.value = value; + } + + final float getEventValue() { + return event_value; } + final void setEventValue(float event_value) { + this.event_value = event_value; + } + /** * Returns a human-readable name for this axis. */ @@ -142,12 +126,7 @@ public abstract class AbstractComponent implements Component { public String toString() { return name; } + + protected abstract float poll() throws IOException; - /** - * Changes the name of this Axis. This should be done only during - * initialization of the axis so that its name remains immutable. - */ - public void setName(String name) { - this.name = name; - } } // AbstractAxis diff --git a/coreAPI/src/java/net/java/games/input/AbstractController.java b/coreAPI/src/java/net/java/games/input/AbstractController.java index 93475d2..266a303 100644 --- a/coreAPI/src/java/net/java/games/input/AbstractController.java +++ b/coreAPI/src/java/net/java/games/input/AbstractController.java @@ -38,27 +38,22 @@ *****************************************************************************/ package net.java.games.input; +import java.util.Map; +import java.util.List; +import java.util.HashMap; +import java.util.ArrayList; + +import java.io.IOException; + /** * An AbstractController is a skeleton implementation of a controller that * contains a fixed number of axes, controllers, and rumblers. */ public abstract class AbstractController implements Controller { - - /** - * Null array representing no axes - */ - protected static final Component[] NO_COMPONENTS = {}; - - /** - * Null array representing no child controllers - */ - protected static final Controller[] NO_CONTROLLERS = {}; - - /** - * Null array representing no rumblers - */ - protected static final Rumbler[] NO_RUMBLERS = {}; - + final static int EVENT_QUEUE_DEPTH = 32; + + private final static Event event = new Event(); + /** * Human-readable name for this Controller */ @@ -67,26 +62,24 @@ public abstract class AbstractController implements Controller { /** * Array of components */ - protected Component[] components; + private final Component[] components; /** * Array of child controllers */ - protected Controller[] children; + private final Controller[] children; /** * Array of rumblers */ - protected Rumbler[] rumblers; - - /** - * Protected constructor for a controller; initially contains no axes, - * child controllers, or rumblers. - * @param name The name for the controller - */ - protected AbstractController(String name) { - this(name, NO_COMPONENTS, NO_CONTROLLERS, NO_RUMBLERS); - } + private final Rumbler[] rumblers; + + /** + * Map from Component.Identifiers to Components + */ + private final Map id_to_components = new HashMap(); + + private EventQueue event_queue = new EventQueue(EVENT_QUEUE_DEPTH); /** * Protected constructor for a controller containing the specified @@ -96,21 +89,24 @@ public abstract class AbstractController implements Controller { * @param children child controllers for the controller * @param rumblers rumblers for the controller */ - protected AbstractController(String name, Component[] components, - Controller[] children, Rumbler[] rumblers) { + protected AbstractController(String name, Component[] components, Controller[] children, Rumbler[] rumblers) { this.name = name; this.components = components; this.children = children; this.rumblers = rumblers; - } - + // process from last to first to let earlier listed Components get higher priority + for (int i = components.length - 1; i >= 0; i--) { + id_to_components.put(components[i].getIdentifier(), components[i]); + } + } + /** * Returns the controllers connected to make up this controller, or * an empty array if this controller contains no child controllers. * The objects in the array are returned in order of assignment priority * (primary stick, secondary buttons, etc.). */ - public Controller[] getControllers() { + public final Controller[] getControllers() { return children; } @@ -123,35 +119,23 @@ public abstract class AbstractController implements Controller { * The array returned is an empty array if this controller contains no components * (such as a logical grouping of child controllers). */ - public Component[] getComponents() { + public final Component[] getComponents() { return components; } /** * Returns a single component based on its identifier, or null * if no component with the specified type could be found. - * By default, AbstractController calls getComponents in this method so that - * subclasses may lazily initialize the array of components, if necessary. */ - public Component getComponent(Component.Identifier id) { - // Calls getAxes() so that subclasses may lazily set the array of axes. - Component[] components = getComponents(); - if (components.length == 0) { - return null; - } - for (int i = 0; i < components.length; i++) { - if (components[i].getIdentifier() == id) { - return components[i]; - } - } - return null; + public final Component getComponent(Component.Identifier id) { + return (Component)id_to_components.get(id); } /** * Returns the rumblers for sending feedback to this controller, or an * empty array if there are no rumblers on this controller. */ - public Rumbler[] getRumblers() { + public final Rumbler[] getRumblers() { return rumblers; } @@ -174,7 +158,7 @@ public abstract class AbstractController implements Controller { /** * Returns a human-readable name for this Controller. */ - public String getName() { + public final String getName() { return name; } @@ -190,5 +174,68 @@ public abstract class AbstractController implements Controller { public Type getType() { return Type.UNKNOWN; } - + + /** + * Creates a new EventQueue. Events in old queue are lost. + */ + public final void setEventQueueSize(int size) { + try { + setDeviceEventQueueSize(size); + event_queue = new EventQueue(size); + } catch (IOException e) { + ControllerEnvironment.logln("Failed to create new event queue of size " + size + ": " + e); + } + } + + /** + * Plugins override this method to adjust their internal event queue size + */ + protected void setDeviceEventQueueSize(int size) throws IOException { + } + + public final EventQueue getEventQueue() { + return event_queue; + } + + protected abstract boolean getNextDeviceEvent(Event event) throws IOException; + + protected void pollDevice() throws IOException { + } + + /* poll() is synchronized to protect the static event */ + public synchronized boolean poll() { + Component[] components = getComponents(); + try { + pollDevice(); + for (int i = 0; i < components.length; i++) { + AbstractComponent component = (AbstractComponent)components[i]; + if (component.isRelative()) { + component.setPollData(0); + } else { + float value = component.poll(); + component.setPollData(value); + } + } + while (getNextDeviceEvent(event)) { + AbstractComponent component = (AbstractComponent)event.getComponent(); + float value = event.getValue(); + if (component.isRelative()) { + if (value == 0) + continue; + component.setPollData(component.getPollData() + value); + } else { + if (value == component.getEventValue()) + continue; + component.setEventValue(value); + } + if (!event_queue.isFull()) + event_queue.add(event); + } + return true; + } catch (IOException e) { + ControllerEnvironment.logln("Failed to poll device: " + e.getMessage()); + return false; + } + } + } // class AbstractController diff --git a/coreAPI/src/java/net/java/games/input/Component.java b/coreAPI/src/java/net/java/games/input/Component.java index 4f154d8..f3f9c9a 100644 --- a/coreAPI/src/java/net/java/games/input/Component.java +++ b/coreAPI/src/java/net/java/games/input/Component.java @@ -63,29 +63,6 @@ public interface Component { public abstract boolean isAnalog(); /** - * Returns whether or not data polled from this axis is normalized - * between the values of -1.0f and 1.0f. - * @see #getPollData - */ - public abstract boolean isNormalized(); - - /** - * Returns whether or not this axis is ready to receive polling data. - * @see #getPollData - * @see Controller#poll - * @see #setPolling - */ - public abstract boolean isPolling(); - - /** - * Sets whether or not the axis should receive polling data. - * @see #getPollData - * @see Controller#poll - * @see #isPolling - */ - public abstract void setPolling(boolean polling); - - /** * Returns the suggested dead zone for this axis. Dead zone is the * amount polled data can vary before considered a significant change * in value. An application can safely ignore changes less than this @@ -558,163 +535,148 @@ public interface Component { * Returns the side mouse button. */ public static final Button SIDE = new Button("Side"); - } /** * KeyIDs for standard PC (LATIN-1) keyboards */ public static class Key extends Identifier { - - private int keyID; - /** * Protected constructor */ - protected Key(String name, int keyID) { + protected Key(String name) { super(name); - this.keyID = keyID; - } - - protected Key(int keyID) { - this("Key " + keyID, keyID); - } - - public int getKeyIndex() { - return keyID; } /** * Standard keyboard (LATIN-1) keys * UNIX X11 keysym values are listed to the right */ - public static final Key VOID = new Key("Void", 0); // MS 0x00 UNIX 0xFFFFFF - public static final Key ESCAPE = new Key("Escape", 1); // MS 0x01 UNIX 0xFF1B - public static final Key _1 = new Key("1", 2); // MS 0x02 UNIX 0x031 EXCLAM 0x021 - public static final Key _2 = new Key("2", 3); // MS 0x03 UNIX 0x032 AT 0x040 - public static final Key _3 = new Key("3", 4); // MS 0x04 UNIX 0x033 NUMBERSIGN 0x023 - public static final Key _4 = new Key("4", 5); // MS 0x05 UNIX 0x034 DOLLAR 0x024 - public static final Key _5 = new Key("5", 6); // MS 0x06 UNIX 0x035 PERCENT 0x025 - public static final Key _6 = new Key("6", 7); // MS 0x07 UNIX 0x036 CIRCUMFLEX 0x05e - public static final Key _7 = new Key("7", 8); // MS 0x08 UNIX 0x037 AMPERSAND 0x026 - public static final Key _8 = new Key("8", 9); // MS 0x09 UNIX 0x038 ASTERISK 0x02a - public static final Key _9 = new Key("9", 10); // MS 0x0A UNIX 0x039 PARENLEFT 0x028 - public static final Key _0 = new Key("0", 11); // MS 0x0B UNIX 0x030 PARENRIGHT 0x029 - public static final Key MINUS = new Key("-", 12); // MS 0x0C UNIX 0x02d UNDERSCORE 0x05f - public static final Key EQUALS = new Key("=", 13); // MS 0x0D UNIX 0x03d PLUS 0x02b - public static final Key BACK = new Key("Back", 14); // MS 0x0E UNIX 0xFF08 - public static final Key TAB = new Key("Tab", 15); // MS 0x0F UNIX 0xFF09 - public static final Key Q = new Key("Q", 16); // MS 0x10 UNIX 0x071 UPPER 0x051 - public static final Key W = new Key("W", 17); // MS 0x11 UNIX 0x077 UPPER 0x057 - public static final Key E = new Key("E", 18); // MS 0x12 UNIX 0x065 UPPER 0x045 - public static final Key R = new Key("R", 19); // MS 0x13 UNIX 0x072 UPPER 0x052 - public static final Key T = new Key("T", 20); // MS 0x14 UNIX 0x074 UPPER 0x054 - public static final Key Y = new Key("Y", 21); // MS 0x15 UNIX 0x079 UPPER 0x059 - public static final Key U = new Key("U", 22); // MS 0x16 UNIX 0x075 UPPER 0x055 - public static final Key I = new Key("I", 23); // MS 0x17 UNIX 0x069 UPPER 0x049 - public static final Key O = new Key("O", 24); // MS 0x18 UNIX 0x06F UPPER 0x04F - public static final Key P = new Key("P", 25); // MS 0x19 UNIX 0x070 UPPER 0x050 - public static final Key LBRACKET = new Key("[", 26); // MS 0x1A UNIX 0x05b BRACE 0x07b - public static final Key RBRACKET = new Key("]", 27); // MS 0x1B UNIX 0x05d BRACE 0x07d - public static final Key RETURN = new Key("Return", 28); // MS 0x1C UNIX 0xFF0D - public static final Key LCONTROL = new Key("Left Control", 29); // MS 0x1D UNIX 0xFFE3 - public static final Key A = new Key("A", 30); // MS 0x1E UNIX 0x061 UPPER 0x041 - public static final Key S = new Key("S", 31); // MS 0x1F UNIX 0x073 UPPER 0x053 - public static final Key D = new Key("D", 32); // MS 0x20 UNIX 0x064 UPPER 0x044 - public static final Key F = new Key("F", 33); // MS 0x21 UNIX 0x066 UPPER 0x046 - public static final Key G = new Key("G", 34); // MS 0x22 UNIX 0x067 UPPER 0x047 - public static final Key H = new Key("H", 35); // MS 0x23 UNIX 0x068 UPPER 0x048 - public static final Key J = new Key("J", 36); // MS 0x24 UNIX 0x06A UPPER 0x04A - public static final Key K = new Key("K", 37); // MS 0x25 UNIX 0x06B UPPER 0x04B - public static final Key L = new Key("L", 38); // MS 0x26 UNIX 0x06C UPPER 0x04C - public static final Key SEMICOLON = new Key(";", 39); // MS 0x27 UNIX 0x03b COLON 0x03a - public static final Key APOSTROPHE = new Key("'", 40); // MS 0x28 UNIX 0x027 QUOTEDBL 0x022 - public static final Key GRAVE = new Key("~", 41); // MS 0x29 UNIX 0x060 TILDE 0x07e - public static final Key LSHIFT = new Key("Left Shift", 42); // MS 0x2A UNIX 0xFFE1 - public static final Key BACKSLASH = new Key("\\", 43); // MS 0x2B UNIX 0x05c BAR 0x07c - public static final Key Z = new Key("Z", 44); // MS 0x2C UNIX 0x07A UPPER 0x05A - public static final Key X = new Key("X", 45); // MS 0x2D UNIX 0x078 UPPER 0x058 - public static final Key C = new Key("C", 46); // MS 0x2E UNIX 0x063 UPPER 0x043 - public static final Key V = new Key("V", 47); // MS 0x2F UNIX 0x076 UPPER 0x056 - public static final Key B = new Key("B", 48); // MS 0x30 UNIX 0x062 UPPER 0x042 - public static final Key N = new Key("N", 49); // MS 0x31 UNIX 0x06E UPPER 0x04E - public static final Key M = new Key("M", 50); // MS 0x32 UNIX 0x06D UPPER 0x04D - public static final Key COMMA = new Key(",", 51); // MS 0x33 UNIX 0x02c LESS 0x03c - public static final Key PERIOD = new Key(".", 52); // MS 0x34 UNIX 0x02e GREATER 0x03e - public static final Key SLASH = new Key("/", 53); // MS 0x35 UNIX 0x02f QUESTION 0x03f - public static final Key RSHIFT = new Key("Right Shift", 54); // MS 0x36 UNIX 0xFFE2 - public static final Key MULTIPLY = new Key("Multiply", 55); // MS 0x37 UNIX 0xFFAA - public static final Key LALT = new Key("Left Alt", 56); // MS 0x38 UNIX 0xFFE9 - public static final Key SPACE = new Key(" ", 57); // MS 0x39 UNIX 0x020 - public static final Key CAPITAL = new Key("Caps Lock", 58); // MS 0x3A UNIX 0xFFE5 SHIFTLOCK 0xFFE6 - public static final Key F1 = new Key("F1", 59); // MS 0x3B UNIX 0xFFBE - public static final Key F2 = new Key("F2", 60); // MS 0x3C UNIX 0xFFBF - public static final Key F3 = new Key("F3", 61); // MS 0x3D UNIX 0xFFC0 - public static final Key F4 = new Key("F4", 62); // MS 0x3E UNIX 0xFFC1 - public static final Key F5 = new Key("F5", 63); // MS 0x3F UNIX 0xFFC2 - public static final Key F6 = new Key("F6", 64); // MS 0x40 UNIX 0xFFC3 - public static final Key F7 = new Key("F7", 65); // MS 0x41 UNIX 0xFFC4 - public static final Key F8 = new Key("F8", 66); // MS 0x42 UNIX 0xFFC5 - public static final Key F9 = new Key("F9", 67); // MS 0x43 UNIX 0xFFC6 - public static final Key F10 = new Key("F10", 68); // MS 0x44 UNIX 0xFFC7 - public static final Key NUMLOCK = new Key("Num Lock", 69); // MS 0x45 UNIX 0xFF7F - public static final Key SCROLL = new Key("Scroll Lock", 70); // MS 0x46 UNIX 0xFF14 - public static final Key NUMPAD7 = new Key("Num 7", 71); // MS 0x47 UNIX 0xFFB7 HOME 0xFF95 - public static final Key NUMPAD8 = new Key("Num 8", 72); // MS 0x48 UNIX 0xFFB8 UP 0xFF97 - public static final Key NUMPAD9 = new Key("Num 9", 73); // MS 0x49 UNIX 0xFFB9 PRIOR 0xFF9A - public static final Key SUBTRACT = new Key("Num -", 74); // MS 0x4A UNIX 0xFFAD - public static final Key NUMPAD4 = new Key("Num 4", 75); // MS 0x4B UNIX 0xFFB4 LEFT 0xFF96 - public static final Key NUMPAD5 = new Key("Num 5", 76); // MS 0x4C UNIX 0xFFB5 - public static final Key NUMPAD6 = new Key("Num 6", 77); // MS 0x4D UNIX 0xFFB6 RIGHT 0xFF98 - public static final Key ADD = new Key("Num +", 78); // MS 0x4E UNIX 0xFFAB - public static final Key NUMPAD1 = new Key("Num 1", 79); // MS 0x4F UNIX 0xFFB1 END 0xFF9C - public static final Key NUMPAD2 = new Key("Num 2", 80); // MS 0x50 UNIX 0xFFB2 DOWN 0xFF99 - public static final Key NUMPAD3 = new Key("Num 3", 81); // MS 0x51 UNIX 0xFFB3 NEXT 0xFF9B - public static final Key NUMPAD0 = new Key("Num 0", 82); // MS 0x52 UNIX 0xFFB0 INSERT 0xFF9E - public static final Key DECIMAL = new Key("Num .", 83); // MS 0x53 UNIX 0xFFAE DELETE 0xFF9F - public static final Key F11 = new Key("F11", 84); // MS 0x57 UNIX 0xFFC8 - public static final Key F12 = new Key("F12", 85); // MS 0x58 UNIX 0xFFC9 - public static final Key F13 = new Key("F13", 86); // MS 0x64 UNIX 0xFFCA - public static final Key F14 = new Key("F14", 87); // MS 0x65 UNIX 0xFFCB - public static final Key F15 = new Key("F15", 88); // MS 0x66 UNIX 0xFFCC - public static final Key KANA = new Key(89); // MS 0x70 UNIX 0xFF2D - public static final Key CONVERT = new Key(90); // MS 0x79 Japanese keyboard - public static final Key NOCONVERT = new Key(91); // MS 0x7B Japanese keyboard - public static final Key YEN = new Key(92); // MS 0x7D UNIX 0x0a5 - public static final Key NUMPADEQUAL = new Key("Num =", 93); // MS 0x8D UNIX 0xFFBD - public static final Key CIRCUMFLEX = new Key(94); // MS 0x90 Japanese keyboard - public static final Key AT = new Key(95); // MS 0x91 UNIX 0x040 - public static final Key COLON = new Key(96); // MS 0x92 UNIX 0x03a - public static final Key UNDERLINE = new Key(97); // MS 0x93 NEC PC98 - public static final Key KANJI = new Key(98); // MS 0x94 UNIX 0xFF21 - public static final Key STOP = new Key(99); // MS 0x95 UNIX 0xFF69 - public static final Key AX = new Key(100); // MS 0x96 Japan AX - public static final Key UNLABELED = new Key(101); // MS 0x97 J3100 - public static final Key NUMPADENTER = new Key("Num Enter", 102); // MS 0x9C UNIX 0xFF8D - public static final Key RCONTROL = new Key("Right Control", 103); // MS 0x9D UNIX 0xFFE4 - public static final Key NUMPADCOMMA = new Key("Num ,", 104); // MS 0xB3 UNIX 0xFFAC - public static final Key DIVIDE = new Key("Num /", 105); // MS 0xB5 UNIX 0xFFAF - public static final Key SYSRQ = new Key(106); // MS 0xB7 UNIX 0xFF15 PRINT 0xFF61 - public static final Key RALT = new Key("Right Alt", 107); // MS 0xB8 UNIX 0xFFEA - public static final Key PAUSE = new Key("Pause", 108); // MS 0xC5 UNIX 0xFF13 BREAK 0xFF6B - public static final Key HOME = new Key("Home", 109); // MS 0xC7 UNIX 0xFF50 - public static final Key UP = new Key("Up", 110); // MS 0xC8 UNIX 0xFF52 - public static final Key PAGEUP = new Key("Pg Up", 111); // MS 0xC9 UNIX 0xFF55 - public static final Key LEFT = new Key("Left", 112); // MS 0xCB UNIX 0xFF51 - public static final Key RIGHT = new Key("Right", 113); // MS 0xCD UNIX 0xFF53 - public static final Key END = new Key("End", 114); // MS 0xCF UNIX 0xFF57 - public static final Key DOWN = new Key("Down", 115); // MS 0xD0 UNIX 0xFF54 - public static final Key PAGEDOWN = new Key("Pg Down", 116); // MS 0xD1 UNIX 0xFF56 - public static final Key INSERT = new Key("Insert", 117); // MS 0xD2 UNIX 0xFF63 - public static final Key DELETE = new Key("Delete", 118); // MS 0xD3 UNIX 0xFFFF - public static final Key LWIN = new Key("Left Windows", 119); // MS 0xDB UNIX META 0xFFE7 SUPER 0xFFEB HYPER 0xFFED - public static final Key RWIN = new Key("Right Windows", 120); // MS 0xDC UNIX META 0xFFE8 SUPER 0xFFEC HYPER 0xFFEE - public static final Key APPS = new Key(121); // MS 0xDD UNIX 0xFF67 - public static final Key POWER = new Key("Power", 122); // MS 0xDE Sun 0x1005FF76 SHIFT 0x1005FF7D - public static final Key SLEEP = new Key("Sleep", 123); // MS 0xDF No UNIX keysym - public static final Key UNKNOWN = new Key("Unknown", 0); - protected static final Key FIRST = VOID; - protected static final Key LAST = SLEEP; + public static final Key VOID = new Key("Void"); // MS 0x00 UNIX 0xFFFFFF + public static final Key ESCAPE = new Key("Escape"); // MS 0x01 UNIX 0xFF1B + public static final Key _1 = new Key("1"); // MS 0x02 UNIX 0x031 EXCLAM 0x021 + public static final Key _2 = new Key("2"); // MS 0x03 UNIX 0x032 AT 0x040 + public static final Key _3 = new Key("3"); // MS 0x04 UNIX 0x033 NUMBERSIGN 0x023 + public static final Key _4 = new Key("4"); // MS 0x05 UNIX 0x034 DOLLAR 0x024 + public static final Key _5 = new Key("5"); // MS 0x06 UNIX 0x035 PERCENT 0x025 + public static final Key _6 = new Key("6"); // MS 0x07 UNIX 0x036 CIRCUMFLEX 0x05e + public static final Key _7 = new Key("7"); // MS 0x08 UNIX 0x037 AMPERSAND 0x026 + public static final Key _8 = new Key("8"); // MS 0x09 UNIX 0x038 ASTERISK 0x02a + public static final Key _9 = new Key("9"); // MS 0x0A UNIX 0x039 PARENLEFT 0x028 + public static final Key _0 = new Key("0"); // MS 0x0B UNIX 0x030 PARENRIGHT 0x029 + public static final Key MINUS = new Key("-"); // MS 0x0C UNIX 0x02d UNDERSCORE 0x05f + public static final Key EQUALS = new Key("="); // MS 0x0D UNIX 0x03d PLUS 0x02b + public static final Key BACK = new Key("Back"); // MS 0x0E UNIX 0xFF08 + public static final Key TAB = new Key("Tab"); // MS 0x0F UNIX 0xFF09 + public static final Key Q = new Key("Q"); // MS 0x10 UNIX 0x071 UPPER 0x051 + public static final Key W = new Key("W"); // MS 0x11 UNIX 0x077 UPPER 0x057 + public static final Key E = new Key("E"); // MS 0x12 UNIX 0x065 UPPER 0x045 + public static final Key R = new Key("R"); // MS 0x13 UNIX 0x072 UPPER 0x052 + public static final Key T = new Key("T"); // MS 0x14 UNIX 0x074 UPPER 0x054 + public static final Key Y = new Key("Y"); // MS 0x15 UNIX 0x079 UPPER 0x059 + public static final Key U = new Key("U"); // MS 0x16 UNIX 0x075 UPPER 0x055 + public static final Key I = new Key("I"); // MS 0x17 UNIX 0x069 UPPER 0x049 + public static final Key O = new Key("O"); // MS 0x18 UNIX 0x06F UPPER 0x04F + public static final Key P = new Key("P"); // MS 0x19 UNIX 0x070 UPPER 0x050 + public static final Key LBRACKET = new Key("["); // MS 0x1A UNIX 0x05b BRACE 0x07b + public static final Key RBRACKET = new Key("]"); // MS 0x1B UNIX 0x05d BRACE 0x07d + public static final Key RETURN = new Key("Return"); // MS 0x1C UNIX 0xFF0D + public static final Key LCONTROL = new Key("Left Control"); // MS 0x1D UNIX 0xFFE3 + public static final Key A = new Key("A"); // MS 0x1E UNIX 0x061 UPPER 0x041 + public static final Key S = new Key("S"); // MS 0x1F UNIX 0x073 UPPER 0x053 + public static final Key D = new Key("D"); // MS 0x20 UNIX 0x064 UPPER 0x044 + public static final Key F = new Key("F"); // MS 0x21 UNIX 0x066 UPPER 0x046 + public static final Key G = new Key("G"); // MS 0x22 UNIX 0x067 UPPER 0x047 + public static final Key H = new Key("H"); // MS 0x23 UNIX 0x068 UPPER 0x048 + public static final Key J = new Key("J"); // MS 0x24 UNIX 0x06A UPPER 0x04A + public static final Key K = new Key("K"); // MS 0x25 UNIX 0x06B UPPER 0x04B + public static final Key L = new Key("L"); // MS 0x26 UNIX 0x06C UPPER 0x04C + public static final Key SEMICOLON = new Key(";"); // MS 0x27 UNIX 0x03b COLON 0x03a + public static final Key APOSTROPHE = new Key("'"); // MS 0x28 UNIX 0x027 QUOTEDBL 0x022 + public static final Key GRAVE = new Key("~"); // MS 0x29 UNIX 0x060 TILDE 0x07e + public static final Key LSHIFT = new Key("Left Shift"); // MS 0x2A UNIX 0xFFE1 + public static final Key BACKSLASH = new Key("\\"); // MS 0x2B UNIX 0x05c BAR 0x07c + public static final Key Z = new Key("Z"); // MS 0x2C UNIX 0x07A UPPER 0x05A + public static final Key X = new Key("X"); // MS 0x2D UNIX 0x078 UPPER 0x058 + public static final Key C = new Key("C"); // MS 0x2E UNIX 0x063 UPPER 0x043 + public static final Key V = new Key("V"); // MS 0x2F UNIX 0x076 UPPER 0x056 + public static final Key B = new Key("B"); // MS 0x30 UNIX 0x062 UPPER 0x042 + public static final Key N = new Key("N"); // MS 0x31 UNIX 0x06E UPPER 0x04E + public static final Key M = new Key("M"); // MS 0x32 UNIX 0x06D UPPER 0x04D + public static final Key COMMA = new Key(","); // MS 0x33 UNIX 0x02c LESS 0x03c + public static final Key PERIOD = new Key("."); // MS 0x34 UNIX 0x02e GREATER 0x03e + public static final Key SLASH = new Key("/"); // MS 0x35 UNIX 0x02f QUESTION 0x03f + public static final Key RSHIFT = new Key("Right Shift"); // MS 0x36 UNIX 0xFFE2 + public static final Key MULTIPLY = new Key("Multiply"); // MS 0x37 UNIX 0xFFAA + public static final Key LALT = new Key("Left Alt"); // MS 0x38 UNIX 0xFFE9 + public static final Key SPACE = new Key(" "); // MS 0x39 UNIX 0x020 + public static final Key CAPITAL = new Key("Caps Lock"); // MS 0x3A UNIX 0xFFE5 SHIFTLOCK 0xFFE6 + public static final Key F1 = new Key("F1"); // MS 0x3B UNIX 0xFFBE + public static final Key F2 = new Key("F2"); // MS 0x3C UNIX 0xFFBF + public static final Key F3 = new Key("F3"); // MS 0x3D UNIX 0xFFC0 + public static final Key F4 = new Key("F4"); // MS 0x3E UNIX 0xFFC1 + public static final Key F5 = new Key("F5"); // MS 0x3F UNIX 0xFFC2 + public static final Key F6 = new Key("F6"); // MS 0x40 UNIX 0xFFC3 + public static final Key F7 = new Key("F7"); // MS 0x41 UNIX 0xFFC4 + public static final Key F8 = new Key("F8"); // MS 0x42 UNIX 0xFFC5 + public static final Key F9 = new Key("F9"); // MS 0x43 UNIX 0xFFC6 + public static final Key F10 = new Key("F10"); // MS 0x44 UNIX 0xFFC7 + public static final Key NUMLOCK = new Key("Num Lock"); // MS 0x45 UNIX 0xFF7F + public static final Key SCROLL = new Key("Scroll Lock"); // MS 0x46 UNIX 0xFF14 + public static final Key NUMPAD7 = new Key("Num 7"); // MS 0x47 UNIX 0xFFB7 HOME 0xFF95 + public static final Key NUMPAD8 = new Key("Num 8"); // MS 0x48 UNIX 0xFFB8 UP 0xFF97 + public static final Key NUMPAD9 = new Key("Num 9"); // MS 0x49 UNIX 0xFFB9 PRIOR 0xFF9A + public static final Key SUBTRACT = new Key("Num -"); // MS 0x4A UNIX 0xFFAD + public static final Key NUMPAD4 = new Key("Num 4"); // MS 0x4B UNIX 0xFFB4 LEFT 0xFF96 + public static final Key NUMPAD5 = new Key("Num 5"); // MS 0x4C UNIX 0xFFB5 + public static final Key NUMPAD6 = new Key("Num 6"); // MS 0x4D UNIX 0xFFB6 RIGHT 0xFF98 + public static final Key ADD = new Key("Num +"); // MS 0x4E UNIX 0xFFAB + public static final Key NUMPAD1 = new Key("Num 1"); // MS 0x4F UNIX 0xFFB1 END 0xFF9C + public static final Key NUMPAD2 = new Key("Num 2"); // MS 0x50 UNIX 0xFFB2 DOWN 0xFF99 + public static final Key NUMPAD3 = new Key("Num 3"); // MS 0x51 UNIX 0xFFB3 NEXT 0xFF9B + public static final Key NUMPAD0 = new Key("Num 0"); // MS 0x52 UNIX 0xFFB0 INSERT 0xFF9E + public static final Key DECIMAL = new Key("Num ."); // MS 0x53 UNIX 0xFFAE DELETE 0xFF9F + public static final Key F11 = new Key("F11"); // MS 0x57 UNIX 0xFFC8 + public static final Key F12 = new Key("F12"); // MS 0x58 UNIX 0xFFC9 + public static final Key F13 = new Key("F13"); // MS 0x64 UNIX 0xFFCA + public static final Key F14 = new Key("F14"); // MS 0x65 UNIX 0xFFCB + public static final Key F15 = new Key("F15"); // MS 0x66 UNIX 0xFFCC + public static final Key KANA = new Key("Kana"); // MS 0x70 UNIX 0xFF2D + public static final Key CONVERT = new Key("Convert"); // MS 0x79 Japanese keyboard + public static final Key NOCONVERT = new Key("Noconvert"); // MS 0x7B Japanese keyboard + public static final Key YEN = new Key("Yen"); // MS 0x7D UNIX 0x0a5 + public static final Key NUMPADEQUAL = new Key("Num ="); // MS 0x8D UNIX 0xFFBD + public static final Key CIRCUMFLEX = new Key("Circumflex"); // MS 0x90 Japanese keyboard + public static final Key AT = new Key("At"); // MS 0x91 UNIX 0x040 + public static final Key COLON = new Key("Colon"); // MS 0x92 UNIX 0x03a + public static final Key UNDERLINE = new Key("Underline"); // MS 0x93 NEC PC98 + public static final Key KANJI = new Key("Kanji"); // MS 0x94 UNIX 0xFF21 + public static final Key STOP = new Key("Stop"); // MS 0x95 UNIX 0xFF69 + public static final Key AX = new Key("Ax"); // MS 0x96 Japan AX + public static final Key UNLABELED = new Key("Unlabeled"); // MS 0x97 J3100 + public static final Key NUMPADENTER = new Key("Num Enter"); // MS 0x9C UNIX 0xFF8D + public static final Key RCONTROL = new Key("Right Control"); // MS 0x9D UNIX 0xFFE4 + public static final Key NUMPADCOMMA = new Key("Num ,"); // MS 0xB3 UNIX 0xFFAC + public static final Key DIVIDE = new Key("Num /"); // MS 0xB5 UNIX 0xFFAF + public static final Key SYSRQ = new Key("SysRq"); // MS 0xB7 UNIX 0xFF15 PRINT 0xFF61 + public static final Key RALT = new Key("Right Alt"); // MS 0xB8 UNIX 0xFFEA + public static final Key PAUSE = new Key("Pause"); // MS 0xC5 UNIX 0xFF13 BREAK 0xFF6B + public static final Key HOME = new Key("Home"); // MS 0xC7 UNIX 0xFF50 + public static final Key UP = new Key("Up"); // MS 0xC8 UNIX 0xFF52 + public static final Key PAGEUP = new Key("Pg Up"); // MS 0xC9 UNIX 0xFF55 + public static final Key LEFT = new Key("Left"); // MS 0xCB UNIX 0xFF51 + public static final Key RIGHT = new Key("Right"); // MS 0xCD UNIX 0xFF53 + public static final Key END = new Key("End"); // MS 0xCF UNIX 0xFF57 + public static final Key DOWN = new Key("Down"); // MS 0xD0 UNIX 0xFF54 + public static final Key PAGEDOWN = new Key("Pg Down"); // MS 0xD1 UNIX 0xFF56 + public static final Key INSERT = new Key("Insert"); // MS 0xD2 UNIX 0xFF63 + public static final Key DELETE = new Key("Delete"); // MS 0xD3 UNIX 0xFFFF + public static final Key LWIN = new Key("Left Windows"); // MS 0xDB UNIX META 0xFFE7 SUPER 0xFFEB HYPER 0xFFED + public static final Key RWIN = new Key("Right Windows"); // MS 0xDC UNIX META 0xFFE8 SUPER 0xFFEC HYPER 0xFFEE + public static final Key APPS = new Key("Apps"); // MS 0xDD UNIX 0xFF67 + public static final Key POWER = new Key("Power"); // MS 0xDE Sun 0x1005FF76 SHIFT 0x1005FF7D + public static final Key SLEEP = new Key("Sleep"); // MS 0xDF No UNIX keysym + public static final Key UNKNOWN = new Key("Unknown"); } // class StandardKeyboard.KeyID } // class Axis.Identifier diff --git a/coreAPI/src/java/net/java/games/input/Controller.java b/coreAPI/src/java/net/java/games/input/Controller.java index fc22cdd..61faaff 100644 --- a/coreAPI/src/java/net/java/games/input/Controller.java +++ b/coreAPI/src/java/net/java/games/input/Controller.java @@ -90,6 +90,17 @@ public interface Controller { public abstract boolean poll(); /** + * Initialized the controller event queue to a new size. Existing events + * in the queue are lost. + */ + public abstract void setEventQueueSize(int size); + + /** + * Get the device event queue + */ + public abstract EventQueue getEventQueue(); + + /** * Returns the port type for this Controller. */ public abstract PortType getPortType(); @@ -129,76 +140,65 @@ public interface Controller { } /** - * Mouse controller. + * Unkown controller type. */ - public static final Type UNKNOWN = new Type("unknown"); + public static final Type UNKNOWN = new Type("Unknown"); /** * Mouse controller. */ - public static final Type MOUSE = new Type("mouse"); + public static final Type MOUSE = new Type("Mouse"); /** - * A mouse ball or the ball part of a trackball controller. - * Note that a mouse wheel is considered part of a ball controller. - */ - public static final Type BALL = new Type("ball"); - - /** - * A group of buttons on a pad (mouse buttons, for - * example) or a keyboard. - */ - public static final Type BUTTONS = new Type("buttons"); - /** * A keyboard controller (same as BUTTONS) * @see #BUTTONS */ - public static final Type KEYBOARD = BUTTONS; + public static final Type KEYBOARD = new Type("Keyboard"); /** * Fingerstick controller; note that this may be sometimes treated as a * type of mouse or stick. */ - public static final Type FINGERSTICK = new Type("fingerstick"); + public static final Type FINGERSTICK = new Type("Fingerstick"); /** * Gamepad controller. */ - public static final Type GAMEPAD = new Type("gamepad"); + public static final Type GAMEPAD = new Type("Gamepad"); /** * Headtracker controller. */ - public static final Type HEADTRACKER = new Type("headtracker"); + public static final Type HEADTRACKER = new Type("Headtracker"); /** * Rudder controller. */ - public static final Type RUDDER = new Type("rudder"); + public static final Type RUDDER = new Type("Rudder"); /** * Stick controller, such as a joystick or flightstick. */ - public static final Type STICK = new Type("stick"); + public static final Type STICK = new Type("Stick"); /** * A trackball controller; note that this may sometimes be treated as a * type of mouse. */ - public static final Type TRACKBALL = new Type("trackball"); + public static final Type TRACKBALL = new Type("Trackball"); /** * A trackpad, such as a tablet, touchpad, or glidepad; * note that this may sometimes be treated as a type of mouse. */ - public static final Type TRACKPAD = new Type("trackpad"); + public static final Type TRACKPAD = new Type("Trackpad"); /** * A wheel controller, such as a steering wheel (note - * that a mouse wheel is considered part of a ball control, not a + * that a mouse wheel is considered part of a mouse, not a * wheel controller). */ - public static final Type WHEEL = new Type("wheel"); + public static final Type WHEEL = new Type("Wheel"); } // class Controller.Type /** diff --git a/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java b/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java index e68dde3..c7a4a42 100644 --- a/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java +++ b/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java @@ -66,7 +66,14 @@ import java.util.Iterator; * */ public abstract class ControllerEnvironment { - + static void logln(String msg) { + log(msg + "\n"); + } + + static void log(String msg) { + System.out.print(msg); + } + /** * The default controller environment */ diff --git a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java index e94b769..39db61a 100644 --- a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java +++ b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java @@ -123,35 +123,35 @@ class DefaultControllerEnvironment extends ControllerEnvironment { pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin"; } else if(osName.equals("Windows 98") || osName.equals("Windows 2000") || osName.equals("Windows XP")) { pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin"; - } else if(osName.startsWith("Windows")) { +// pluginClasses = pluginClasses + " net.java.games.input.RawInputEnvironmentPlugin"; + } else if (osName.startsWith("Windows")) { System.out.println("WARNING: Found unknown Windows version: " + osName); System.out.println("Attempting to use default windows plug-in."); System.out.flush(); pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin"; +// pluginClasses = pluginClasses + " net.java.games.input.RawInputEnvironmentPlugin"; } else { System.out.println("Trying to use default plugin, OS name " + osName +" not recognised"); } } - if(!pluginClasses.equals("")) { - ArrayList pluginClassList = new ArrayList(); - StringTokenizer pluginClassTok = new StringTokenizer(pluginClasses, " \t\n\r\f,;:"); - while(pluginClassTok.hasMoreTokens()) { - String className = pluginClassTok.nextToken(); - try { - if(!loadedPlugins.contains(className)) { - Class ceClass = Class.forName(className); - ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance(); - addControllers(ce.getControllers()); - } - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - } + ArrayList pluginClassList = new ArrayList(); + StringTokenizer pluginClassTok = new StringTokenizer(pluginClasses, " \t\n\r\f,;:"); + while(pluginClassTok.hasMoreTokens()) { + String className = pluginClassTok.nextToken(); + try { + if(!loadedPlugins.contains(className)) { + Class ceClass = Class.forName(className); + ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance(); + addControllers(ce.getControllers()); + } + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } } Controller[] ret = new Controller[controllers.size()]; Iterator it = controllers.iterator(); @@ -232,7 +232,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment { envClasses[i].newInstance(); addControllers(ce.getControllers()); loadedPlugins.add(ce.getClass().getName()); - } catch (Exception e) { + } catch (Throwable e) { e.printStackTrace(); } } diff --git a/coreAPI/src/java/net/java/games/input/Event.java b/coreAPI/src/java/net/java/games/input/Event.java new file mode 100644 index 0000000..c6bc5e9 --- /dev/null +++ b/coreAPI/src/java/net/java/games/input/Event.java @@ -0,0 +1,76 @@ +/* + * %W% %E% + * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ +/***************************************************************************** + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materails provided with the distribution. + * + * Neither the name Sun Microsystems, Inc. or the names of the contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND + * ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS + * A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST + * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, + * INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY + * OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for us in + * the design, construction, operation or maintenance of any nuclear facility + * + *****************************************************************************/ +package net.java.games.input; + +public final class Event { + private Component component; + private float value; + private long nanos; + + public final void set(Event other) { + this.set(other.getComponent(), other.getValue(), other.getNanos()); + } + + public final void set(Component component, float value, long nanos) { + this.component = component; + this.value = value; + this.nanos = nanos; + } + + public final Component getComponent() { + return component; + } + + public final float getValue() { + return value; + } + + /** + * Return the time the event happened, in nanoseconds. + * The time is relative and therefore can only be used + * to compare with other event times. + */ + public final long getNanos() { + return nanos; + } + + public final String toString() { + return "Event: component = " + component + " | value = " + value; + } +} diff --git a/coreAPI/src/java/net/java/games/input/EventQueue.java b/coreAPI/src/java/net/java/games/input/EventQueue.java new file mode 100644 index 0000000..960ed40 --- /dev/null +++ b/coreAPI/src/java/net/java/games/input/EventQueue.java @@ -0,0 +1,73 @@ +/* + * %W% %E% + * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ +/***************************************************************************** + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materails provided with the distribution. + * + * Neither the name Sun Microsystems, Inc. or the names of the contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND + * ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS + * A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST + * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, + * INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY + * OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for us in + * the design, construction, operation or maintenance of any nuclear facility + * + *****************************************************************************/ +package net.java.games.input; + +public final class EventQueue { + private final Event[] queue; + + private int head; + private int tail; + + public EventQueue(int size) { + queue = new Event[size + 1]; + for (int i = 0; i < queue.length; i++) + queue[i] = new Event(); + } + + final synchronized void add(Event event) { + queue[tail].set(event); + tail = increase(tail); + } + + final synchronized boolean isFull() { + return increase(tail) == head; + } + + private final int increase(int x) { + return (x + 1)%queue.length; + } + + public final synchronized boolean getNextEvent(Event event) { + if (head == tail) + return false; + event.set(queue[head]); + head = increase(head); + return true; + } +} diff --git a/coreAPI/src/java/net/java/games/input/Keyboard.java b/coreAPI/src/java/net/java/games/input/Keyboard.java index f01317d..e168869 100644 --- a/coreAPI/src/java/net/java/games/input/Keyboard.java +++ b/coreAPI/src/java/net/java/games/input/Keyboard.java @@ -44,14 +44,13 @@ package net.java.games.input; * are set to receive polling data. */ public abstract class Keyboard extends AbstractController { - /** * Protected constructor. * Subclasses should initialize the array of axes to an array of keys. * @param name The name of the keyboard */ - protected Keyboard(String name) { - super(name); + protected Keyboard(String name, Component[] keys, Controller[] children, Rumbler[] rumblers) { + super(name, keys, children, rumblers); } /** @@ -61,67 +60,10 @@ public abstract class Keyboard extends AbstractController { return Type.KEYBOARD; } - /** - * Returns the component corresponding to a particular key on the keypad, - * or null if a key with the specified ID could not be found. - */ - public Component getComponent(Component.Identifier id) { - assert components != null; - // Default implementation uses indices to lookup keys - // in the array of axes - if(id instanceof Component.Identifier.Key) { - int index = ((Component.Identifier.Key)id).getKeyIndex(); - assert components.length > index; - return components[index]; - } - return null; - } - - /** - * Returns whether or not the given key has been pressed since the last - * call to poll. This is called from a key's getPollData method. - */ - protected abstract boolean isKeyPressed(Key key); - - /** - * Axis representing a single key. By default, all keys are set to receive - * polling data. - */ - public class Key extends AbstractComponent { - - /** - * Key identifier - */ - private final Component.Identifier.Key keyID; - - /** - * Construct a new key object - */ - public Key(Component.Identifier.Key keyID) { - super(keyID.toString(), keyID); - this.keyID = keyID; - } - - /** - * Returns <code>true</code> if data returned from <code>poll</code> - * is relative to the last call, or <code>false</code> if data - * is absolute. - * @return false by default, can be overridden - */ - public final boolean isRelative() { - return false; - } - - /** - * Returns the data from the last time the control has been polled. - * The value returned will be either 0.0f or 1.0f. The result is always - * 0.0f if polling is turned off. - */ - public float getPollData() { - if (!isPolling()) { - return 0.0f; - } - return (isKeyPressed(this) ? 1.0f : 0.0f); - } - } // class Keyboard.Key + public final boolean isKeyDown(Component.Identifier.Key key_id) { + Component key = getComponent(key_id); + if (key == null) + return false; + return key.getPollData() != 0; + } } // class Keyboard diff --git a/coreAPI/src/java/net/java/games/input/Mouse.java b/coreAPI/src/java/net/java/games/input/Mouse.java index 790a6a4..83676a4 100644 --- a/coreAPI/src/java/net/java/games/input/Mouse.java +++ b/coreAPI/src/java/net/java/games/input/Mouse.java @@ -38,56 +38,17 @@ *****************************************************************************/ package net.java.games.input; +import java.util.List; +import java.util.ArrayList; + /** * A Mouse is a type of controller consisting of two child controllers, * a ball and a button pad. This includes devices such as touch pads, * trackballs, and fingersticks. */ public abstract class Mouse extends AbstractController { - - /** - * Mouse ball; should be initialized by subclasses - */ - protected Ball ball; - - /** - * Mouse buttons; should be initialized by subclasses - */ - protected Buttons buttons; - - /** - * Protected constructor; - * Subclasses should initialize the ball and buttons - */ - protected Mouse(String name) { - super(name); - } - - /** - * Returns the controllers connected to make up this controller, or - * an empty array if this controller contains no child controllers. - * The objects in the array are returned in order of assignment priority - * (primary stick, secondary buttons, etc.). - */ - public Controller[] getControllers() { - if (children.length == 0 && ball != null && buttons != null) { - children = new Controller[] { ball, buttons }; - } - return children; - } - - /** - * Returns the control for the ball of the mouse, never null. - */ - public Ball getBall() { - return ball; - } - - /** - * Returns the control for the buttons of the mouse, never null. - */ - public Buttons getButtons() { - return buttons; + protected Mouse(String name, Component[] components, Controller[] children, Rumbler[] rumblers) { + super(name, components, children, rumblers); } /** @@ -97,249 +58,79 @@ public abstract class Mouse extends AbstractController { return Type.MOUSE; } - /** - * Mouse ball controller - */ - public abstract class Ball extends AbstractController { - - /** - * X-axis; should be initialized by subclasses - */ - protected Component x; - - /** - * Y-axis; should be initialized by subclasses - */ - protected Component y; - - /** - * Mouse wheel; should be initialized by subclasses - */ - protected Component wheel; - - /** - * Protected constructor - */ - protected Ball(String name) { - super(name); - } - - /** - * Returns the type of Controller. - */ - public Type getType() { - return Type.BALL; - } - - /** - * Returns the x-axis for the mouse ball, never null. - */ - public Component getX() { - return x; - } - - /** - * Returns the y-axis for the mouse ball, never null. - */ - public Component getY() { - return y; - } - - /** - * Returns the mouse wheel, or null if no mouse wheel is present. - */ - public Component getWheel() { - return wheel; - } - - /** - * Returns the components on this controller, in order of assignment priority. - * Overridden to return the x-axis, followed by the y-axes, followed by - * the wheel (if present). - * The array returned is an empty array if this controller contains no - * axes (such as a logical grouping of child controllers). - */ - public Component[] getComponents() { - if (components.length == 0 && x != null && y != null) { - if (wheel == null) { - components = new Component[] { x, y }; - } else { - components = new Component[] { x, y, wheel }; - } - } - return components; - } + /** + * Returns the x-axis for the mouse ball, never null. + */ + public Component getX() { + return getComponent(Component.Identifier.Axis.X); + } - /** - * Polls axes for data. Returns false if the controller is no longer - * valid. Polling reflects the current state of the device when polled. - * By default, polling a mouse ball or button polls the entire mouse - * control. - */ - public boolean poll() { - return Mouse.this.poll(); - } - } // class Mouse.Ball - - /** - * Mouse buttons controller - */ - public abstract class Buttons extends AbstractController { - - /** - * Left button; should be initialized by subclasses - */ - protected Button left; - - /** - * Right button; should be initialized by subclasses - */ - protected Button right; - - /** - * Middle button; should be initialized by subclasses - */ - protected Button middle; - - /** - * Side button; should be initialized by subclasses - */ - protected Button side; - - /** - * Extra button; should be initialized by subclasses - */ - protected Button extra; - - /** - * Forward button; should be initialized by subclasses - */ - protected Button forward; - - /** - * Back button; should be initialized by subclasses - */ - protected Button back; - - /** - * Protected constructor - */ - protected Buttons(String name) { - super(name); - } - - /** - * Returns the type or identifier of the Controller. - */ - public Type getType() { - return Type.BUTTONS; - } - - /** - * Returns the left or primary mouse button, never null. - */ - public Button getLeft() { - return left; - } - - /** - * Returns the right or secondary mouse button, null if the mouse is - * a single-button mouse. - */ - public Button getRight() { - return right; - } - - /** - * Returns the middle or tertiary mouse button, null if the mouse has - * fewer than three buttons. - */ - public Button getMiddle() { - return middle; - } - - /** - * Returns the side or 4th mouse button, null if the mouse has - * fewer than 4 buttons. - */ - public Button getSide() { - return side; - } - - /** - * Returns the extra or 5th mouse button, null if the mouse has - * fewer than 5 buttons. - */ - public Button getExtra() { - return extra; - } - - /** - * Returns the forward mouse button, null if the mouse hasn't - * got one. - */ - public Button getForward() { - return forward; - } - - /** - * Returns the back mouse button, null if the mouse hasn't - * got one. - */ - public Button getBack() { - return back; - } - - /** - * Returns the components on this controller, in order of assignment priority. - * Overridden to return the the primary or leftmost mouse button, - * followed by the secondary or rightmost mouse button (if present), - * followed by the middle mouse button (if present). - * The array returned is an empty array if this controller contains no - * axes (such as a logical grouping of child controllers). - */ - public Component[] getComponents() { - if (components.length == 0 && left != null) { - if (right == null) { - components = new Component[] { left }; - } else if (middle == null) { - components = new Component[] { left, right }; - } else if (side == null) { - components = new Component[] { left, right, middle }; - } else if (extra == null) { - components = new Component[] { left, right, middle, side }; - } else if (forward == null) { - components = new Component[] { left, right, middle, side, extra }; - } else if (back == null) { - components = new Component[] { left, right, middle, side, extra, forward }; - } else { - components = new Component[] { left, right, middle, side, extra, forward, back }; - } - } - return components; - } + /** + * Returns the y-axis for the mouse ball, never null. + */ + public Component getY() { + return getComponent(Component.Identifier.Axis.Y); + } - /** - * Polls axes for data. Returns false if the controller is no longer - * valid. Polling reflects the current state of the device when polled. - * By default, polling a mouse ball or button polls the entire mouse - * control. - */ - public boolean poll() { - return Mouse.this.poll(); - } - } // class Mouse.Buttons - - /** - * Mouse button axis - */ - public abstract class Button extends AbstractComponent { - - /** - * Protected constructor - */ - protected Button(String name, Component.Identifier.Button id) { - super(name, id); - } - } // class Mouse.Button + /** + * Returns the mouse wheel, or null if no mouse wheel is present. + */ + public Component getWheel() { + return getComponent(Component.Identifier.Axis.Z); + } + + /** + * Returns the left or primary mouse button, never null. + */ + public Component getLeft() { + return getComponent(Component.Identifier.Button.LEFT); + } + + /** + * Returns the right or secondary mouse button, null if the mouse is + * a single-button mouse. + */ + public Component getRight() { + return getComponent(Component.Identifier.Button.RIGHT); + } + + /** + * Returns the middle or tertiary mouse button, null if the mouse has + * fewer than three buttons. + */ + public Component getMiddle() { + return getComponent(Component.Identifier.Button.MIDDLE); + } + + /** + * Returns the side or 4th mouse button, null if the mouse has + * fewer than 4 buttons. + */ + public Component getSide() { + return getComponent(Component.Identifier.Button.SIDE); + } + + /** + * Returns the extra or 5th mouse button, null if the mouse has + * fewer than 5 buttons. + */ + public Component getExtra() { + return getComponent(Component.Identifier.Button.EXTRA); + } + + /** + * Returns the forward mouse button, null if the mouse hasn't + * got one. + */ + public Component getForward() { + return getComponent(Component.Identifier.Button.FORWARD); + } + + /** + * Returns the back mouse button, null if the mouse hasn't + * got one. + */ + public Component getBack() { + return getComponent(Component.Identifier.Button.BACK); + } } // class Mouse diff --git a/coreAPI/src/java/net/java/games/input/StandardKeyboard.java b/coreAPI/src/java/net/java/games/input/StandardKeyboard.java deleted file mode 100644 index e25ef9b..0000000 --- a/coreAPI/src/java/net/java/games/input/StandardKeyboard.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * %W% %E% - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ -/***************************************************************************** - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materails provided with the distribution. - * - * Neither the name Sun Microsystems, Inc. or the names of the contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING - * ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND - * ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS - * A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST - * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, - * INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY - * OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE, - * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for us in - * the design, construction, operation or maintenance of any nuclear facility - * - *****************************************************************************/ -package net.java.games.input; - -/** - * Identifiers for physical keys for standard PC (LATIN-1) keyboards. - */ -public abstract class StandardKeyboard extends Keyboard { - - private Key[] standardKeys = { - new Key(Component.Identifier.Key.VOID ), new Key(Component.Identifier.Key.ESCAPE ), - new Key(Component.Identifier.Key._1 ), new Key(Component.Identifier.Key._2 ), - new Key(Component.Identifier.Key._3 ), new Key(Component.Identifier.Key._4 ), - new Key(Component.Identifier.Key._5 ), new Key(Component.Identifier.Key._6 ), - new Key(Component.Identifier.Key._7 ), new Key(Component.Identifier.Key._8 ), - new Key(Component.Identifier.Key._9 ), new Key(Component.Identifier.Key._0 ), - new Key(Component.Identifier.Key.MINUS ), new Key(Component.Identifier.Key.EQUALS ), - new Key(Component.Identifier.Key.BACK ), new Key(Component.Identifier.Key.TAB ), - new Key(Component.Identifier.Key.Q ), new Key(Component.Identifier.Key.W ), - new Key(Component.Identifier.Key.E ), new Key(Component.Identifier.Key.R ), - new Key(Component.Identifier.Key.T ), new Key(Component.Identifier.Key.Y ), - new Key(Component.Identifier.Key.U ), new Key(Component.Identifier.Key.I ), - new Key(Component.Identifier.Key.O ), new Key(Component.Identifier.Key.P ), - new Key(Component.Identifier.Key.LBRACKET ), new Key(Component.Identifier.Key.RBRACKET ), - new Key(Component.Identifier.Key.RETURN ), new Key(Component.Identifier.Key.LCONTROL ), - new Key(Component.Identifier.Key.A ), new Key(Component.Identifier.Key.S ), - new Key(Component.Identifier.Key.D ), new Key(Component.Identifier.Key.F ), - new Key(Component.Identifier.Key.G ), new Key(Component.Identifier.Key.H ), - new Key(Component.Identifier.Key.J ), new Key(Component.Identifier.Key.K ), - new Key(Component.Identifier.Key.L ), new Key(Component.Identifier.Key.SEMICOLON ), - new Key(Component.Identifier.Key.APOSTROPHE ), new Key(Component.Identifier.Key.GRAVE ), - new Key(Component.Identifier.Key.LSHIFT ), new Key(Component.Identifier.Key.BACKSLASH ), - new Key(Component.Identifier.Key.Z ), new Key(Component.Identifier.Key.X ), - new Key(Component.Identifier.Key.C ), new Key(Component.Identifier.Key.V ), - new Key(Component.Identifier.Key.B ), new Key(Component.Identifier.Key.N ), - new Key(Component.Identifier.Key.M ), new Key(Component.Identifier.Key.COMMA ), - new Key(Component.Identifier.Key.PERIOD ), new Key(Component.Identifier.Key.SLASH ), - new Key(Component.Identifier.Key.RSHIFT ), new Key(Component.Identifier.Key.MULTIPLY ), - new Key(Component.Identifier.Key.LALT ), new Key(Component.Identifier.Key.SPACE ), - new Key(Component.Identifier.Key.CAPITAL ), new Key(Component.Identifier.Key.F1 ), - new Key(Component.Identifier.Key.F2 ), new Key(Component.Identifier.Key.F3 ), - new Key(Component.Identifier.Key.F4 ), new Key(Component.Identifier.Key.F5 ), - new Key(Component.Identifier.Key.F6 ), new Key(Component.Identifier.Key.F7 ), - new Key(Component.Identifier.Key.F8 ), new Key(Component.Identifier.Key.F9 ), - new Key(Component.Identifier.Key.F10 ), new Key(Component.Identifier.Key.NUMLOCK ), - new Key(Component.Identifier.Key.SCROLL ), new Key(Component.Identifier.Key.NUMPAD7 ), - new Key(Component.Identifier.Key.NUMPAD8 ), new Key(Component.Identifier.Key.NUMPAD9 ), - new Key(Component.Identifier.Key.SUBTRACT ), new Key(Component.Identifier.Key.NUMPAD4 ), - new Key(Component.Identifier.Key.NUMPAD5 ), new Key(Component.Identifier.Key.NUMPAD6 ), - new Key(Component.Identifier.Key.ADD ), new Key(Component.Identifier.Key.NUMPAD1 ), - new Key(Component.Identifier.Key.NUMPAD2 ), new Key(Component.Identifier.Key.NUMPAD3 ), - new Key(Component.Identifier.Key.NUMPAD0 ), new Key(Component.Identifier.Key.DECIMAL ), - new Key(Component.Identifier.Key.F11 ), new Key(Component.Identifier.Key.F12 ), - new Key(Component.Identifier.Key.F13 ), new Key(Component.Identifier.Key.F14 ), - new Key(Component.Identifier.Key.F15 ), new Key(Component.Identifier.Key.KANA ), - new Key(Component.Identifier.Key.CONVERT ), new Key(Component.Identifier.Key.NOCONVERT ), - new Key(Component.Identifier.Key.YEN ), new Key(Component.Identifier.Key.NUMPADEQUAL), - new Key(Component.Identifier.Key.CIRCUMFLEX ), new Key(Component.Identifier.Key.AT ), - new Key(Component.Identifier.Key.COLON ), new Key(Component.Identifier.Key.UNDERLINE ), - new Key(Component.Identifier.Key.KANJI ), new Key(Component.Identifier.Key.STOP ), - new Key(Component.Identifier.Key.AX ), new Key(Component.Identifier.Key.UNLABELED ), - new Key(Component.Identifier.Key.NUMPADENTER), new Key(Component.Identifier.Key.RCONTROL ), - new Key(Component.Identifier.Key.NUMPADCOMMA), new Key(Component.Identifier.Key.DIVIDE ), - new Key(Component.Identifier.Key.SYSRQ ), new Key(Component.Identifier.Key.RALT ), - new Key(Component.Identifier.Key.PAUSE ), new Key(Component.Identifier.Key.HOME ), - new Key(Component.Identifier.Key.UP ), new Key(Component.Identifier.Key.PAGEUP ), - new Key(Component.Identifier.Key.LEFT ), new Key(Component.Identifier.Key.RIGHT ), - new Key(Component.Identifier.Key.END ), new Key(Component.Identifier.Key.DOWN ), - new Key(Component.Identifier.Key.PAGEDOWN ), new Key(Component.Identifier.Key.INSERT ), - new Key(Component.Identifier.Key.DELETE ), new Key(Component.Identifier.Key.LWIN ), - new Key(Component.Identifier.Key.RWIN ), new Key(Component.Identifier.Key.APPS ), - new Key(Component.Identifier.Key.POWER ), new Key(Component.Identifier.Key.SLEEP ), - }; - - /** - * Creates a new standard keyboard object with the default keys - * for a standard keyboard. - */ - protected StandardKeyboard(String name) { - super(name); - components = standardKeys; - } -} // class StandardKeyboard diff --git a/coreAPI/src/java/net/java/games/input/Version.java b/coreAPI/src/java/net/java/games/input/Version.java index 143f100..582e66a 100644 --- a/coreAPI/src/java/net/java/games/input/Version.java +++ b/coreAPI/src/java/net/java/games/input/Version.java @@ -89,7 +89,7 @@ public final class Version { /** * Version string of this build. */ - private static final String version = "1.0.0-b01"; + private static final String version = "2.0.0-b01"; /** * Returns the verison string and build number of diff --git a/coreAPI/src/java/net/java/games/input/test/ControllerReadTest.java b/coreAPI/src/java/net/java/games/input/test/ControllerReadTest.java index 0a41d54..a7c0e84 100644 --- a/coreAPI/src/java/net/java/games/input/test/ControllerReadTest.java +++ b/coreAPI/src/java/net/java/games/input/test/ControllerReadTest.java @@ -74,6 +74,10 @@ abstract class AxisPanel extends JPanel{ data = axis.getPollData(); renderData(); } + + public Component getAxis() { + return axis; + } protected abstract void renderData(); } @@ -153,7 +157,10 @@ class AnalogAxisPanel extends AxisPanel { } protected void renderData(){ - analogState.setText(""+data); + String extra = ""; + if (getAxis().getDeadZone() >= Math.abs(data)) + extra = " (DEADZONE)"; + analogState.setText(""+data+extra); analogState.repaint(); } } @@ -216,7 +223,7 @@ class ControllerWindow extends JFrame { } p.add(p2); axisList.add(p2); - ax.setPolling(true); + //ax.setPolling(true); } public void poll(){ |