Stuff
This commit is contained in:
parent
b5fab4fcc6
commit
c6659f88a4
|
@ -178,6 +178,19 @@ public class Joystick {
|
||||||
return nHasZValue();
|
return nHasZValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See if a particular mouse button is down.
|
||||||
|
*
|
||||||
|
* @param button The index of the button you wish to test (0..getNumButtons())
|
||||||
|
* @return true if the specified button is down
|
||||||
|
* @see #getNumButtons()
|
||||||
|
*/
|
||||||
|
public static boolean isButtonDown(int button) {
|
||||||
|
assert created : "The joystick has not been created.";
|
||||||
|
return Joystick.button[button];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native implementation of hasZValue()
|
* Native implementation of hasZValue()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -173,6 +173,128 @@ public class Keyboard {
|
||||||
public static final int KEY_POWER = 0xDE;
|
public static final int KEY_POWER = 0xDE;
|
||||||
public static final int KEY_SLEEP = 0xDF;
|
public static final int KEY_SLEEP = 0xDF;
|
||||||
|
|
||||||
|
// Maps keycodes to ascii characters
|
||||||
|
private static final char map[] =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'1',
|
||||||
|
'2',
|
||||||
|
'3',
|
||||||
|
'4',
|
||||||
|
'5',
|
||||||
|
'6',
|
||||||
|
'7',
|
||||||
|
'8',
|
||||||
|
'9',
|
||||||
|
'0',
|
||||||
|
'-',
|
||||||
|
'=',
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'q',
|
||||||
|
'w',
|
||||||
|
'e',
|
||||||
|
'r',
|
||||||
|
't',
|
||||||
|
'y',
|
||||||
|
'u',
|
||||||
|
'i',
|
||||||
|
'o',
|
||||||
|
'p',
|
||||||
|
'[',
|
||||||
|
']',
|
||||||
|
'*',
|
||||||
|
'*',
|
||||||
|
'a',
|
||||||
|
's',
|
||||||
|
'd',
|
||||||
|
'f',
|
||||||
|
'g',
|
||||||
|
'h',
|
||||||
|
'j',
|
||||||
|
'k',
|
||||||
|
'l',
|
||||||
|
';',
|
||||||
|
'\'',
|
||||||
|
'#',
|
||||||
|
'*',
|
||||||
|
'\\',
|
||||||
|
'z',
|
||||||
|
'x',
|
||||||
|
'c',
|
||||||
|
'v',
|
||||||
|
'b',
|
||||||
|
'n',
|
||||||
|
'm',
|
||||||
|
',',
|
||||||
|
'.',
|
||||||
|
'/',
|
||||||
|
'*',
|
||||||
|
'*',
|
||||||
|
'*',
|
||||||
|
' ' };
|
||||||
|
private static final char shiftMap[] =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'!',
|
||||||
|
'"',
|
||||||
|
'*',
|
||||||
|
'$',
|
||||||
|
'%',
|
||||||
|
'^',
|
||||||
|
'&',
|
||||||
|
'*',
|
||||||
|
'(',
|
||||||
|
')',
|
||||||
|
'_',
|
||||||
|
'+',
|
||||||
|
'*',
|
||||||
|
'*',
|
||||||
|
'Q',
|
||||||
|
'W',
|
||||||
|
'E',
|
||||||
|
'R',
|
||||||
|
'T',
|
||||||
|
'Y',
|
||||||
|
'U',
|
||||||
|
'I',
|
||||||
|
'O',
|
||||||
|
'P',
|
||||||
|
'{',
|
||||||
|
'}',
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'A',
|
||||||
|
'S',
|
||||||
|
'D',
|
||||||
|
'F',
|
||||||
|
'G',
|
||||||
|
'H',
|
||||||
|
'J',
|
||||||
|
'K',
|
||||||
|
'L',
|
||||||
|
':',
|
||||||
|
'@',
|
||||||
|
'~',
|
||||||
|
0,
|
||||||
|
'|',
|
||||||
|
'Z',
|
||||||
|
'X',
|
||||||
|
'C',
|
||||||
|
'V',
|
||||||
|
'B',
|
||||||
|
'N',
|
||||||
|
'M',
|
||||||
|
'<',
|
||||||
|
'>',
|
||||||
|
'?',
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
' ' };
|
||||||
|
|
||||||
static {
|
static {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -344,4 +466,22 @@ public class Keyboard {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a keycode to a character.
|
||||||
|
* @param keyCode The keycode
|
||||||
|
* @return the corresponding ASCII character or 0 if no mapping is possible
|
||||||
|
*/
|
||||||
|
public static char map(int keyCode) {
|
||||||
|
char c;
|
||||||
|
|
||||||
|
if (keyCode < 0 || keyCode >= map.length)
|
||||||
|
return 0;
|
||||||
|
else if (isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT)) {
|
||||||
|
c = shiftMap[keyCode];
|
||||||
|
} else {
|
||||||
|
c = map[keyCode];
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,18 @@ public class Mouse {
|
||||||
*/
|
*/
|
||||||
private static native boolean nHasZValue();
|
private static native boolean nHasZValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See if a particular mouse button is down.
|
||||||
|
*
|
||||||
|
* @param button The index of the button you wish to test (0..getNumButtons())
|
||||||
|
* @return true if the specified button is down
|
||||||
|
* @see #getNumButtons()
|
||||||
|
*/
|
||||||
|
public static boolean isButtonDown(int button) {
|
||||||
|
assert created : "The mouse has not been created.";
|
||||||
|
return Mouse.button[button];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable mouse buffering. Must be called after the mouse is created.
|
* Enable mouse buffering. Must be called after the mouse is created.
|
||||||
* @return the size of the mouse buffer in events, or 0 if no buffering
|
* @return the size of the mouse buffer in events, or 0 if no buffering
|
||||||
|
|
Loading…
Reference in New Issue