Linux ~: More bounds checks

This commit is contained in:
elias 2006-12-25 09:31:34 +00:00
parent 9d211951c1
commit 02196352eb

View file

@ -751,7 +751,13 @@ class LinuxNativeTypesMap {
* @return The jinput id
*/
public static Component.Identifier getRelAxisID(int nativeID) {
Component.Identifier retval = INSTANCE.relAxesIDs[nativeID];
Component.Identifier retval = null;
try {
retval = INSTANCE.relAxesIDs[nativeID];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("INSTANCE.relAxesIDis only " + INSTANCE.relAxesIDs.length + " long, so " + nativeID + " not contained");
//ignore, pretend it was null
}
if(retval == null) {
retval = Component.Identifier.Axis.SLIDER_VELOCITY;
INSTANCE.relAxesIDs[nativeID] = retval;
@ -784,8 +790,12 @@ class LinuxNativeTypesMap {
*/
public static Component.Identifier getButtonID(int nativeID) {
Component.Identifier retval = null;
if (nativeID >= 0 && nativeID < INSTANCE.buttonIDs.length)
try {
retval = INSTANCE.buttonIDs[nativeID];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("INSTANCE.buttonIDs is only " + INSTANCE.buttonIDs.length + " long, so " + nativeID + " not contained");
//ignore, pretend it was null
}
if(retval == null) {
retval = Component.Identifier.Key.UNKNOWN;
INSTANCE.buttonIDs[nativeID] = retval;