Modified the string-based look-ups to use logical
ID instead of name. The names may be localized for the local language.... Bouton 0 instead of Button 0, etc. I also changed the compatible layer and the one default mapping to use logical IDs now. Added a few constants to JoystickButton just to make things easier for the standard buttons 0-11. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9782 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
56bf97a7e2
commit
9b763443fa
@ -99,15 +99,10 @@ public abstract class AbstractJoystick implements Joystick {
|
||||
inputManager.addMapping(negativeMapping, new JoyAxisTrigger(joyId, axisId, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JoystickAxis with the specified name.
|
||||
*
|
||||
* @param name The name of the axis to search for as returned by JoystickAxis.getName().
|
||||
*/
|
||||
@Override
|
||||
public JoystickAxis getAxis(String name) {
|
||||
public JoystickAxis getAxis(String logicalId) {
|
||||
for( JoystickAxis axis : axes ) {
|
||||
if( axis.getName().equals(name) )
|
||||
if( axis.getLogicalId().equals(logicalId) )
|
||||
return axis;
|
||||
}
|
||||
return null;
|
||||
@ -131,15 +126,10 @@ public abstract class AbstractJoystick implements Joystick {
|
||||
return axes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JoystickButton with the specified name.
|
||||
*
|
||||
* @param name The name of the button to search for as returned by JoystickButton.getName().
|
||||
*/
|
||||
@Override
|
||||
public JoystickButton getButton(String name) {
|
||||
public JoystickButton getButton(String logicalId) {
|
||||
for( JoystickButton b : buttons ) {
|
||||
if( b.getName().equals(name) )
|
||||
if( b.getLogicalId().equals(logicalId) )
|
||||
return b;
|
||||
}
|
||||
return null;
|
||||
|
@ -456,6 +456,10 @@ public class InputManager implements RawInputListener {
|
||||
invokeTimedActions(hash, evt.getTime(), evt.isPressed());
|
||||
}
|
||||
|
||||
public void simulateEvent( InputEvent evt ) {
|
||||
inputQueue.add(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback from RawInputListener. Do not use.
|
||||
*/
|
||||
|
@ -41,11 +41,11 @@ public interface Joystick {
|
||||
public void assignAxis(String positiveMapping, String negativeMapping, int axisId);
|
||||
|
||||
/**
|
||||
* Returns the JoystickAxis with the specified name.
|
||||
* Returns the JoystickAxis with the specified logical ID.
|
||||
*
|
||||
* @param name The name of the axis to search for as returned by JoystickAxis.getName().
|
||||
* @param logicalId The id of the axis to search for as returned by JoystickAxis.getLogicalId().
|
||||
*/
|
||||
public JoystickAxis getAxis(String name);
|
||||
public JoystickAxis getAxis(String logicalId);
|
||||
|
||||
/**
|
||||
* Returns a read-only list of all joystick axes for this Joystick.
|
||||
@ -53,11 +53,11 @@ public interface Joystick {
|
||||
public List<JoystickAxis> getAxes();
|
||||
|
||||
/**
|
||||
* Returns the JoystickButton with the specified name.
|
||||
* Returns the JoystickButton with the specified logical ID.
|
||||
*
|
||||
* @param name The name of the button to search for as returned by JoystickButton.getName().
|
||||
* @param logicalId The id of the axis to search for as returned by JoystickButton.getLogicalId().
|
||||
*/
|
||||
public JoystickButton getButton(String name);
|
||||
public JoystickButton getButton(String logicalId);
|
||||
|
||||
/**
|
||||
* Returns a read-only list of all joystick buttons for this Joystick.
|
||||
|
@ -10,13 +10,13 @@ import com.jme3.input.controls.JoyButtonTrigger;
|
||||
*/
|
||||
public interface JoystickAxis {
|
||||
|
||||
public static final String X_AXIS = "X Axis";
|
||||
public static final String Y_AXIS = "Y Axis";
|
||||
public static final String Z_AXIS = "Z Axis";
|
||||
public static final String Z_ROTATION = "Z Rotation";
|
||||
public static final String X_AXIS = "x";
|
||||
public static final String Y_AXIS = "y";
|
||||
public static final String Z_AXIS = "z";
|
||||
public static final String Z_ROTATION = "rz";
|
||||
|
||||
public static final String POV_X = "JME:POV_X";
|
||||
public static final String POV_Y = "JME:POV_Y";
|
||||
public static final String POV_X = "pov_x";
|
||||
public static final String POV_Y = "pov_y";
|
||||
|
||||
/**
|
||||
* Assign the mappings to receive events from the given joystick axis.
|
||||
|
@ -10,6 +10,19 @@ import com.jme3.input.controls.JoyButtonTrigger;
|
||||
*/
|
||||
public interface JoystickButton {
|
||||
|
||||
public static final String BUTTON_0 = "0";
|
||||
public static final String BUTTON_1 = "1";
|
||||
public static final String BUTTON_2 = "2";
|
||||
public static final String BUTTON_3 = "3";
|
||||
public static final String BUTTON_4 = "4";
|
||||
public static final String BUTTON_5 = "5";
|
||||
public static final String BUTTON_6 = "6";
|
||||
public static final String BUTTON_7 = "7";
|
||||
public static final String BUTTON_8 = "8";
|
||||
public static final String BUTTON_9 = "9";
|
||||
public static final String BUTTON_10 = "10";
|
||||
public static final String BUTTON_11 = "11";
|
||||
|
||||
/**
|
||||
* Assign the mapping name to receive events from the given button index
|
||||
* on the joystick.
|
||||
|
@ -81,13 +81,13 @@ public class JoystickCompatibilityMappings {
|
||||
* Returns the remapped version of the axis/button name if there
|
||||
* is a mapping for it otherwise it returns the original name.
|
||||
*/
|
||||
public static String remapComponent( String joystickName, String componentName ) {
|
||||
public static String remapComponent( String joystickName, String componentId ) {
|
||||
Map<String,String> map = getMappings(joystickName.trim(), false);
|
||||
if( map == null )
|
||||
return componentName;
|
||||
if( !map.containsKey(componentName) )
|
||||
return componentName;
|
||||
return map.get(componentName);
|
||||
return componentId;
|
||||
if( !map.containsKey(componentId) )
|
||||
return componentId;
|
||||
return map.get(componentId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,9 +106,9 @@ public class JoystickCompatibilityMappings {
|
||||
* joystick's name and axis/button name. The "remap" value will be
|
||||
* used instead.
|
||||
*/
|
||||
public static void addMapping( String stickName, String sourceComponent, String remap ) {
|
||||
logger.log(Level.INFO, "addMapping(" + stickName + ", " + sourceComponent + ", " + remap + ")" );
|
||||
getMappings(stickName, true).put( sourceComponent, remap );
|
||||
public static void addMapping( String stickName, String sourceComponentId, String remapId ) {
|
||||
logger.log(Level.INFO, "addMapping(" + stickName + ", " + sourceComponentId + ", " + remapId + ")" );
|
||||
getMappings(stickName, true).put( sourceComponentId, remapId );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user