joystick : if a button id isn't a numeric it will be set to the button index

cleanup_build_scripts
Dokthar 9 years ago
parent 256abb38fa
commit 119a076f11
  1. 46
      jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/JInputJoyInput.java

@ -1,3 +1,35 @@
/*
* Copyright (c) 2009-2016 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.input.lwjgl; package com.jme3.input.lwjgl;
import com.jme3.input.AbstractJoystick; import com.jme3.input.AbstractJoystick;
@ -60,8 +92,7 @@ public class JInputJoyInput implements JoyInput {
logger.log(Level.FINE, "Attempting to create joystick for: \"{0}\"", c); logger.log(Level.FINE, "Attempting to create joystick for: \"{0}\"", c);
// Try to create it like a joystick // Try to create it like a joystick
JInputJoystick stick = new JInputJoystick(inputManager, this, c, list.size(), JInputJoystick stick = new JInputJoystick(inputManager, this, c, list.size(), c.getName());
c.getName());
for( Component comp : c.getComponents() ) { for( Component comp : c.getComponents() ) {
stick.addComponent(comp); stick.addComponent(comp);
} }
@ -210,13 +241,18 @@ public class JInputJoyInput implements JoyInput {
Identifier id = comp.getIdentifier(); Identifier id = comp.getIdentifier();
if( !(id instanceof Button) ) { if( !(id instanceof Button) ) {
throw new IllegalArgumentException( "Component is not an axis:" + comp ); throw new IllegalArgumentException( "Component is not an button:" + comp );
} }
String name = comp.getName(); String name = comp.getName();
String original = id.getName(); String original = id.getName();
try {
Integer.parseInt(original);
} catch (NumberFormatException e){
original = String.valueOf(buttonIndex.size());
}
String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original );
if( name != original ) { if( logicalId != original ) {
logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId);
} }
@ -238,7 +274,7 @@ public class JInputJoyInput implements JoyInput {
String name = comp.getName(); String name = comp.getName();
String original = id.getName(); String original = id.getName();
String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original );
if( name != original ) { if( logicalId != original ) {
logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId);
} }

Loading…
Cancel
Save