diff options
author | gregorypierce <[email protected]> | 2003-08-08 07:08:41 +0000 |
---|---|---|
committer | gregorypierce <[email protected]> | 2003-08-08 07:08:41 +0000 |
commit | b044146181500258082acf0cd70506558816048f (patch) | |
tree | 83dd9927e4f4f681b0918a5ddb3903731c20eb0b | |
parent | bacc9bbd213bd1455a489dd90bdf5034775aa10c (diff) |
Added information for keyboard return codes. There are many international keys whose mappings are not totally clear.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@42 e343933a-64c8-49c5-92b1-88f2ce3e89e8
-rwxr-xr-x | plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java | 213 | ||||
-rw-r--r-- | plugins/OSX/src/java/net/java/games/input/OSXKeyboard.java | 32 |
2 files changed, 238 insertions, 7 deletions
diff --git a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java index a39e04b..1e3df64 100755 --- a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java +++ b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java @@ -77,6 +77,184 @@ public class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugi public static final int HID_USAGE_DPAD_LEFT = 0x92; public static final int HID_USAGE_DPAD_RIGHT = 0x93; + + public static final int HID_USAGE_KEYBOARD_ERRORROLLOVER = 0x01; /* ErrorRollOver */ + public static final int HID_USAGE_KEYBOARD_POSTFAIL = 0x02; /* POSTFail */ + public static final int HID_USAGE_KEYBOARD_ERRORUNDEFINED = 0x03; /* ErrorUndefined */ + public static final int HID_USAGE_KEYBOARD_A = 0x04; /* a or A */ + public static final int HID_USAGE_KEYBOARD_B = 0x05; /* b or B */ + public static final int HID_USAGE_KEYBOARD_C = 0x06; /* c or C */ + public static final int HID_USAGE_KEYBOARD_D = 0x07; /* d or D */ + public static final int HID_USAGE_KEYBOARD_E = 0x08; /* e or E */ + public static final int HID_USAGE_KEYBOARD_F = 0x09; /* f or F */ + public static final int HID_USAGE_KEYBOARD_G = 0x0A; /* g or G */ + public static final int HID_USAGE_KEYBOARD_H = 0x0B; /* h or H */ + public static final int HID_USAGE_KEYBOARD_I = 0x0C; /* i or I */ + public static final int HID_USAGE_KEYBOARD_J = 0x0D; /* j or J */ + public static final int HID_USAGE_KEYBOARD_K = 0x0E; /* k or K */ + public static final int HID_USAGE_KEYBOARD_L = 0x0F; /* l or L */ + public static final int HID_USAGE_KEYBOARD_M = 0x10; /* m or M */ + public static final int HID_USAGE_KEYBOARD_N = 0x11; /* n or N */ + public static final int HID_USAGE_KEYBOARD_O = 0x12; /* o or O */ + public static final int HID_USAGE_KEYBOARD_P = 0x13; /* p or P */ + public static final int HID_USAGE_KEYBOARD_Q = 0x14; /* q or Q */ + public static final int HID_USAGE_KEYBOARD_R = 0x15; /* r or R */ + public static final int HID_USAGE_KEYBOARD_S = 0x16; /* s or S */ + public static final int HID_USAGE_KEYBOARD_T = 0x17; /* t or T */ + public static final int HID_USAGE_KEYBOARD_U = 0x18; /* u or U */ + public static final int HID_USAGE_KEYBOARD_V = 0x19; /* v or V */ + public static final int HID_USAGE_KEYBOARD_W = 0x1A; /* w or W */ + public static final int HID_USAGE_KEYBOARD_X = 0x1B; /* x or X */ + public static final int HID_USAGE_KEYBOARD_Y = 0x1C; /* y or Y */ + public static final int HID_USAGE_KEYBOARD_Z = 0x1D; /* z or Z */ + public static final int HID_USAGE_KEYBOARD_1 = 0x1E; /* 1 or ! */ + public static final int HID_USAGE_KEYBOARD_2 = 0x1F; /* 2 or @ */ + public static final int HID_USAGE_KEYBOARD_3 = 0x20; /* 3 or # */ + public static final int HID_USAGE_KEYBOARD_4 = 0x21; /* 4 or $ */ + public static final int HID_USAGE_KEYBOARD_5 = 0x22; /* 5 or % */ + public static final int HID_USAGE_KEYBOARD_6 = 0x23; /* 6 or ^ */ + public static final int HID_USAGE_KEYBOARD_7 = 0x24; /* 7 or & */ + public static final int HID_USAGE_KEYBOARD_8 = 0x25; /* 8 or * */ + public static final int HID_USAGE_KEYBOARD_9 = 0x26; /* 9 or ( */ + public static final int HID_USAGE_KEYBOARD_0 = 0x27; /* 0 or ) */ + public static final int HID_USAGE_KEYBOARD_ENTER = 0x28; /* Return (Enter) */ + public static final int HID_USAGE_KEYBOARD_ESCAPE = 0x29; /* Escape */ + public static final int HID_USAGE_KEYBOARD_BACKSPACE = 0x2A; /* Delete (Backspace) */ + public static final int HID_USAGE_KEYBOARD_TAB = 0x2B; /* Tab */ + public static final int HID_USAGE_KEYBOARD_SPACEBAR = 0x2C; /* Spacebar */ + public static final int HID_USAGE_KEYBOARD_HYPHEN = 0x2D; /* - or _ */ + public static final int HID_USAGE_KEYBOARD_EQUALSIGN = 0x2E; /* = or + */ + public static final int HID_USAGE_KEYBOARD_OPENBRACKET = 0x2F; /* [ or { */ + public static final int HID_USAGE_KEYBOARD_CLOSEBRACKET = 0x30; /* ] or } */ + public static final int HID_USAGE_KEYBOARD_BACKSLASH = 0x31; /* \ or | */ + public static final int HID_USAGE_KEYBOARD_NONUSPOUNT = 0x32; /* Non-US # or _ */ + public static final int HID_USAGE_KEYBOARD_SEMICOLON = 0x33; /* ; or : */ + public static final int HID_USAGE_KEYBOARD_QUOTE = 0x34; /* ' or " */ + public static final int HID_USAGE_KEYBOARD_TILDE = 0x35; /* Grave Accent and Tilde */ + public static final int HID_USAGE_KEYBOARD_COMMA = 0x36; /* , or < */ + public static final int HID_USAGE_KEYBOARD_PERIOD = 0x37; /* . or > */ + public static final int HID_USAGE_KEYBOARD_SLASH = 0x38; /* / or ? */ + public static final int HID_USAGE_KEYBOARD_CAPSLOCK = 0x39; /* Caps Lock */ + public static final int HID_USAGE_KEYBOARD_F1 = 0x3A; /* F1 */ + public static final int HID_USAGE_KEYBOARD_F2 = 0x3B; /* F2 */ + public static final int HID_USAGE_KEYBOARD_F3 = 0x3C; /* F3 */ + public static final int HID_USAGE_KEYBOARD_F4 = 0x3D; /* F4 */ + public static final int HID_USAGE_KEYBOARD_F5 = 0x3E; /* F5 */ + public static final int HID_USAGE_KEYBOARD_F6 = 0x3F; /* F6 */ + public static final int HID_USAGE_KEYBOARD_F7 = 0x40; /* F7 */ + public static final int HID_USAGE_KEYBOARD_F8 = 0x41; /* F8 */ + public static final int HID_USAGE_KEYBOARD_F9 = 0x42; /* F9 */ + public static final int HID_USAGE_KEYBOARD_F10 = 0x43; /* F10 */ + public static final int HID_USAGE_KEYBOARD_F11 = 0x44; /* F11 */ + public static final int HID_USAGE_KEYBOARD_F12 = 0x45; /* F12 */ + public static final int HID_USAGE_KEYBOARD_PRINTSCREEN = 0x46; /* Print Screen */ + public static final int HID_USAGE_KEYBOARD_SCROLLLOCK = 0x47; /* Scroll Lock */ + public static final int HID_USAGE_KEYBOARD_PAUSE = 0x48; /* Pause */ + public static final int HID_USAGE_KEYBOARD_INSERT = 0x49; /* Insert */ + public static final int HID_USAGE_KEYBOARD_HOME = 0x4A; /* Home */ + public static final int HID_USAGE_KEYBOARD_PAGEUP = 0x4B; /* Page Up */ + public static final int HID_USAGE_KEYBOARD_DELETE = 0x4C; /* Delete Forward */ + public static final int HID_USAGE_KEYBOARD_END = 0x4D; /* End */ + public static final int HID_USAGE_KEYBOARD_PAGEDOWN = 0x4E; /* Page Down */ + public static final int HID_USAGE_KEYBOARD_RIGHTARROW = 0x4F; /* Right Arrow */ + public static final int HID_USAGE_KEYBOARD_LEFTARROW = 0x50; /* Left Arrow */ + public static final int HID_USAGE_KEYBOARD_DOWNARROW = 0x51; /* Down Arrow */ + public static final int HID_USAGE_KEYBOARD_UPARROW = 0x52; /* Up Arrow */ + public static final int HID_USAGE_KEYPAD_NUMLOCK = 0x53; /* Keypad NumLock or Clear */ + public static final int HID_USAGE_KEYPAD_SLASH = 0x54; /* Keypad / */ + public static final int HID_USAGE_KEYPAD_ASTERICK = 0x55; /* Keypad * */ + public static final int HID_USAGE_KEYPAD_HYPHEN = 0x56; /* Keypad - */ + public static final int HID_USAGE_KEYPAD_PLUS = 0x57; /* Keypad + */ + public static final int HID_USAGE_KEYPAD_ENTER = 0x58; /* Keypad Enter */ + public static final int HID_USAGE_KEYPAD_1 = 0x59; /* Keypad 1 or End */ + public static final int HID_USAGE_KEYPAD_2 = 0x5A; /* Keypad 2 or Down Arrow */ + public static final int HID_USAGE_KEYPAD_3 = 0x5B; /* Keypad 3 or Page Down */ + public static final int HID_USAGE_KEYPAD_4 = 0x5C; /* Keypad 4 or Left Arrow */ + public static final int HID_USAGE_KEYPAD_5 = 0x5D; /* Keypad 5 */ + public static final int HID_USAGE_KEYPAD_6 = 0x5E; /* Keypad 6 or Right Arrow */ + public static final int HID_USAGE_KEYPAD_7 = 0x5F; /* Keypad 7 or Home */ + public static final int HID_USAGE_KEYPAD_8 = 0x60; /* Keypad 8 or Up Arrow */ + public static final int HID_USAGE_KEYPAD_9 = 0x61; /* Keypad 9 or Page Up */ + public static final int HID_USAGE_KEYPAD_0 = 0x62; /* Keypad 0 or Insert */ + public static final int HID_USAGE_KEYPAD_PERIOD = 0x63; /* Keypad . or Delete */ + public static final int HID_USAGE_KEYBOARD_NONUSBACKSLASH = 0x64; /* Non-US \ or | */ + public static final int HID_USAGE_KEYBOARD_APPLICATION = 0x65; /* Application */ + public static final int HID_USAGE_KEYBOARD_POWER = 0x66; /* Power */ + public static final int HID_USAGE_KEYPAD_EQUALSIGN = 0x67; /* Keypad = */ + public static final int HID_USAGE_KEYBOARD_F13 = 0x68; /* F13 */ + public static final int HID_USAGE_KEYBOARD_F14 = 0x69; /* F14 */ + public static final int HID_USAGE_KEYBOARD_F15 = 0x6A; /* F15 */ + public static final int HID_USAGE_KEYBOARD_F16 = 0x6B; /* F16 */ + public static final int HID_USAGE_KEYBOARD_F17 = 0x6C; /* F17 */ + public static final int HID_USAGE_KEYBOARD_F18 = 0x6D; /* F18 */ + public static final int HID_USAGE_KEYBOARD_F19 = 0x6E; /* F19 */ + public static final int HID_USAGE_KEYBOARD_F20 = 0x6F; /* F20 */ + public static final int HID_USAGE_KEYBOARD_F21 = 0x70; /* F21 */ + public static final int HID_USAGE_KEYBOARD_F22 = 0x71; /* F22 */ + public static final int HID_USAGE_KEYBOARD_F23 = 0x72; /* F23 */ + public static final int HID_USAGE_KEYBOARD_F24 = 0x73; /* F24 */ + public static final int HID_USAGE_KEYBOARD_EXECUTE = 0x74; /* Execute */ + public static final int HID_USAGE_KEYBOARD_HELP = 0x75; /* Help */ + public static final int HID_USAGE_KEYBOARD_MENU = 0x76; /* Menu */ + public static final int HID_USAGE_KEYBOARD_SELECT = 0x77; /* Select */ + public static final int HID_USAGE_KEYBOARD_STOP = 0x78; /* Stop */ + public static final int HID_USAGE_KEYBOARD_AGAIN = 0x79; /* Again */ + public static final int HID_USAGE_KEYBOARD_UNDO = 0x7A; /* Undo */ + public static final int HID_USAGE_KEYBOARD_CUT = 0x7B; /* Cut */ + public static final int HID_USAGE_KEYBOARD_COPY = 0x7C; /* Copy */ + public static final int HID_USAGE_KEYBOARD_PASTE = 0x7D; /* Paste */ + public static final int HID_USAGE_KEYBOARD_FIND = 0x7E; /* Find */ + public static final int HID_USAGE_KEYBOARD_MUTE = 0x7F; /* Mute */ + public static final int HID_USAGE_KEYBOARD_VOLUMEUP = 0x80; /* Volume Up */ + public static final int HID_USAGE_KEYBOARD_VOLUMEDOWN = 0x81; /* Volume Down */ + public static final int HID_USAGE_KEYBOARD_LOCKINGCAPSLOCK = 0x82; /* Locking Caps Lock */ + public static final int HID_USAGE_KEYBOARD_LOCKINGNUMLOCK = 0x83; /* Locking Num Lock */ + public static final int HID_USAGE_KEYBOARD_LOCKINGSCROLLLOCK = 0x84; /* Locking Scroll Lock */ + public static final int HID_USAGE_KEYPAD_COMMA = 0x85; /* Keypad Comma */ + public static final int HID_USAGE_KEYPAD_EQUALSSIGNAS400 = 0x86; /* Keypad Equal Sign for AS/400 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL1 = 0x87; /* International1 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL2 = 0x88; /* International2 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL3 = 0x89; /* International3 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL4 = 0x8A; /* International4 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL5 = 0x8B; /* International5 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL6 = 0x8C; /* International6 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL7 = 0x8D; /* International7 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL8 = 0x8E; /* International8 */ + public static final int HID_USAGE_KEYBOARD_INTERNATIONAL9 = 0x8F; /* International9 */ + public static final int HID_USAGE_KEYBOARD_LANG1 = 0x90; /* LANG1 */ + public static final int HID_USAGE_KEYBOARD_LANG2 = 0x91; /* LANG2 */ + public static final int HID_USAGE_KEYBOARD_LANG3 = 0x92; /* LANG3 */ + public static final int HID_USAGE_KEYBOARD_LANG4 = 0x93; /* LANG4 */ + public static final int HID_USAGE_KEYBOARD_LANG5 = 0x94; /* LANG5 */ + public static final int HID_USAGE_KEYBOARD_LANG6 = 0x95; /* LANG6 */ + public static final int HID_USAGE_KEYBOARD_LANG7 = 0x96; /* LANG7 */ + public static final int HID_USAGE_KEYBOARD_LANG8 = 0x97; /* LANG8 */ + public static final int HID_USAGE_KEYBOARD_LANG9 = 0x98; /* LANG9 */ + public static final int HID_USAGE_KEYBOARD_ALTERNATEERASE = 0x99; /* AlternateErase */ + public static final int HID_USAGE_KEYBOARD_SYSREQORATTENTION = 0x9A; /* SysReq/Attention */ + public static final int HID_USAGE_KEYBOARD_CANCEL = 0x9B; /* Cancel */ + public static final int HID_USAGE_KEYBOARD_CLEAR = 0x9C; /* Clear */ + public static final int HID_USAGE_KEYBOARD_PRIOR = 0x9D; /* Prior */ + public static final int HID_USAGE_KEYBOARD_RETURN = 0x9E; /* Return */ + public static final int HID_USAGE_KEYBOARD_SEPARATOR = 0x9F; /* Separator */ + public static final int HID_USAGE_KEYBOARD_OUT = 0xA0; /* Out */ + public static final int HID_USAGE_KEYBOARD_OPER = 0xA1; /* Oper */ + public static final int HID_USAGE_KEYBOARD_CLEARORAGAIN = 0xA2; /* Clear/Again */ + public static final int HID_USAGE_KEYBOARD_CRSELORPROPS = 0xA3; /* CrSel/Props */ + public static final int HID_USAGE_KEYBOARD_EXSEL = 0xA4; /* ExSel */ + /* 0xA5-0xDF Reserved */ + public static final int HID_USAGE_KEYBOARD_LEFTCONTROL = 0xE0; /* Left Control */ + public static final int HID_USAGE_KEYBOARD_LEFTSHIFT = 0xE1; /* Left Shift */ + public static final int HID_USAGE_KEYBOARD_LEFTALT = 0xE2; /* Left Alt */ + public static final int HID_USAGE_KEYBOARD_LEFTGUI = 0xE3; /* Left GUI */ + public static final int HID_USAGE_KEYBOARD_RIGHTCONTROL = 0xE4; /* Right Control */ + public static final int HID_USAGE_KEYBOARD_RIGHTSHIFT = 0xE5; /* Right Shift */ + public static final int HID_USAGE_KEYBOARD_RIGHTALT = 0xE6; /* Right Alt */ + public static final int HID_USAGE_KEYBOARD_RIGHTGUI = 0xE7; /* Right GUI */ + /* 0xE8-0xFFFF Reserved */ + public static final int HID_USAGE_KEYBOARD__RESERVED = 0xFFFF; + + public static final int HID_USAGEPAGE_UNDEFINED = 0x00; public static final int HID_USAGEPAGE_GENERICDESKTOP = 0x01; public static final int HID_USAGEPAGE_SIMULATION = 0x02; @@ -111,6 +289,10 @@ public class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugi public static final int HID_ELEMENTTYPE_COLLECTION = 513; + + + + static { System.loadLibrary("jinput"); @@ -145,11 +327,23 @@ public class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugi public OSXEnvironmentPlugin() { System.out.println("net.java.games.input.OSXEnvironmentPlugin instance created"); + + System.out.println("Creating HID engine"); + hidCreate(); + + System.out.println("Enumerating devices"); + enumDevices(); + } + + public void finalize() + { + System.out.println("Disposing HID engine"); + hidDispose(); } public Controller[] getControllers() { - return (Controller[])devices.values().toArray(); + return (Controller[])(devices.values().toArray( new Controller[0])); } public Controller createController( long lpDevice, String productName, int usage ) @@ -267,14 +461,19 @@ public class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugi System.out.println("Started net.java.games.input.OSXEnvironmentPlugin"); OSXEnvironmentPlugin newjni = new OSXEnvironmentPlugin(); - System.out.println("Creating HID engine"); - newjni.hidCreate(); + //newjni.hidCreate(); - System.out.println("Enumerating devices"); - newjni.enumDevices(); + //newjni.enumDevices(); - System.out.println("Disposing HID engine"); - newjni.hidDispose(); + + Controller[] controllers = newjni.getControllers(); + + for ( int i = 0; i < controllers.length; i++ ) + { + System.out.println("Controller [" + controllers[i].getName() +"] enumerated..."); + } + + //newjni.hidDispose(); System.out.println("Done"); } diff --git a/plugins/OSX/src/java/net/java/games/input/OSXKeyboard.java b/plugins/OSX/src/java/net/java/games/input/OSXKeyboard.java index fa48a56..4319827 100644 --- a/plugins/OSX/src/java/net/java/games/input/OSXKeyboard.java +++ b/plugins/OSX/src/java/net/java/games/input/OSXKeyboard.java @@ -9,6 +9,22 @@ package net.java.games.input; */ public class OSXKeyboard extends StandardKeyboard implements InputController { + + private final static int[] CROSSTABLE = { + 0x00, 0x29, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, // _9 + 0x27, 0x2D, 0x2E, 0x2A, 0x2B, 0x14, 0x1A, 0x08, 0x15, 0x17, 0x1C, // Y + 0x18, 0x0C, 0x12, 0x13, 0x2F, 0x30, 0x28, 0xE0, 0x04, 0x16, 0x07, // D + 0x09, 0x0A, 0x0B, 0x0D, 0x0E, 0x0F, 0x33, 0x34, 0x35, 0xE1, 0x31, // BACKSLASH + 0x1D, 0x1B, 0x06, 0x19, 0x05, 0x11, 0x10, 0x36, 0x37, 0x38, 0xE5, // RSHIFT + 0x55, 0xE2, 0x2C, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, // F7 + 0x41, 0x42, 0x43, 0x53, 0x47, 0x5F, 0x60, 0x61, 0x56, 0x5C, 0x5D, // NUMPAD5 + 0x5E, 0x57, 0x59, 0x5A, 0x5B, 0x62, 0x63, 0x44, 0x45, 0x68, 0x69, // F14 + 0x6A, 0x87, 0x88, 0x89, 0x8A, 0x67, 0x8B, 0x8C, 0x8D, 0x9F, 0x8E, // KANJI + 0x78, 0x8F, 0x90, 0x58, 0xE4, 0x85, 0x54, 0x9A, 0xE6, 0x48, 0x4A, // HOME + 0x52, 0x9D, 0x50, 0x4F, 0x4D, 0x51, 0xA2, 0x49, 0x4C, 0xE3, 0xE7, // RWIN + 0x65, 0x66, 0x66 // SLEEP + }; + private OSXEnvironmentPlugin plugin; private long lpDevice; private long lpQueue; @@ -40,6 +56,13 @@ public class OSXKeyboard extends StandardKeyboard implements InputController public void addControllerElement(InputControllerElement element) { + + switch( element.getUsagePage() ) + { + case OSXEnvironmentPlugin.HID_USAGEPAGE_KEYBOARD: + System.out.println("Adding key [" + element.getUsage() + "]"); + break; + } /* switch ( element.getElementType() ) { @@ -88,8 +111,17 @@ public class OSXKeyboard extends StandardKeyboard implements InputController return true; } + + /** Returns whether or not the given key has been pressed since the last + * call to poll. + * @param key The key whose state to check. + * @return true if this key has changed state since last read of its state, false otherwise. + */ protected boolean isKeyPressed(Keyboard.Key key) { + KeyID id = (KeyID)key.getIdentifier(); + int keyIndex = id.getKeyIndex(); + return false; } } |