Package com.jme3.input
Class JoystickCompatibilityMappings
java.lang.Object
com.jme3.input.JoystickCompatibilityMappings
Provides compatibility mapping to different joysticks
that both report their name in a unique way and require
remapping to achieve a proper default layout.
All mappings MUST be defined before the joystick support has been initialized in the InputManager.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAxisMapping
(String stickName, String sourceComponentId, String remapId) Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name.static void
addAxisMapping
(String stickName, String sourceComponentId, String remapId, float[] range) Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name.static void
addButtonMapping
(String stickName, String sourceComponentId, String remapId) Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name.static void
addJoystickNameRegex
(String regex, String name) Maps a regular expression to a normalized name for that joystick.static void
addMapping
(String stickName, String sourceComponentId, String remapId) Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name.static void
Adds a preconfigured set of mappings in Properties object form where the names are dot notation "axis"/"button"/"".getButtonMappings
(String joystickName, boolean create) Obtains mappings specific to the joystick buttonsgetJoystickButtonMappings
(String joystickName) Returns a set of Joystick button name remappings if they exist otherwise it returns an empty map.getJoystickMappings
(String joystickName) Returns a set of Joystick axis/button name remappings if they exist otherwise it returns an empty map.getMappings
(String joystickName, boolean create) protected static String
getNormalizedName
(String name) protected static void
Loads the default compatibility mappings by looking for joystick-mapping.properties files on the classpath.static void
Loads a set of compatibility mappings from the property file specified by the given URL.protected static void
loadMappings
(String path) static String
Takes the original name of an axis, specifically, and returns the new name it will function under.static float
remapAxisRange
(JoystickAxis axis, float currentValue) This method will take a "raw" axis value from the system and rescale it based on what the remapper has specified.static String
remapButton
(String joystickName, String componentId) Takes the original name of a button, specifically, and returns the new name it will function under.static String
remapComponent
(String joystickName, String componentId) Returns the remapped version of the axis/button name if there is a mapping for it otherwise it returns the original name.
-
Method Details
-
getMappings
-
getButtonMappings
Obtains mappings specific to the joystick buttons- Parameters:
joystickName
- - The name of the joystick type to obtain mappings for.create
- - If there are no mappings present and this parameter is true, then a new entry for this joystick is created.- Returns:
- The various button remappings for the requested joystick, or null of there are none.
-
remapAxisRange
This method will take a "raw" axis value from the system and rescale it based on what the remapper has specified. For example, if the remapper specified an axis to be scaled to [0.0,1.0], then a raw value of -0.5 would be converted to 0.25.- Parameters:
axis
- - The axis to remap.currentValue
- - The raw value the system is outputting, on a scale of -1.0 to 1.0.- Returns:
- The new value that will be provided to listeners, on a scale specified by the remappings file.
-
remapAxis
Takes the original name of an axis, specifically, and returns the new name it will function under.- Parameters:
joystickName
- - The joystick type the axis comes from.componentId
- - The system-provided name for the axis.- Returns:
- The new name for the axis, or just componentId if no remapping was provided.
-
remapButton
Takes the original name of a button, specifically, and returns the new name it will function under.- Parameters:
joystickName
- - The joystick type the axis comes from.componentId
- - The system-provided name for the button.- Returns:
- The new name for the button, or just componentId if no remapping was provided.
-
remapComponent
Returns the remapped version of the axis/button name if there is a mapping for it otherwise it returns the original name.- Parameters:
joystickName
- which joystick (not null)componentId
- the unmapped axis/button name- Returns:
- the resulting axis/button name
-
getJoystickButtonMappings
Returns a set of Joystick button name remappings if they exist otherwise it returns an empty map.- Parameters:
joystickName
- which joystick (not null)- Returns:
- an unmodifiable map
-
getJoystickMappings
Returns a set of Joystick axis/button name remappings if they exist otherwise it returns an empty map.- Parameters:
joystickName
- which joystick (not null)- Returns:
- an unmodifiable map
-
addAxisMapping
Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name. The "remap" value will be used instead.- Parameters:
stickName
- which joystick (not null)sourceComponentId
- the name to be remappedremapId
- the remapped name
-
addAxisMapping
public static void addAxisMapping(String stickName, String sourceComponentId, String remapId, float[] range) Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name. The "remap" value will be used instead.- Parameters:
stickName
- which joystick (not null)sourceComponentId
- the name to be remappedremapId
- the remapped namerange
- the desired range (not null, exactly 2 elements)
-
addButtonMapping
Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name. The "remap" value will be used instead.- Parameters:
stickName
- which joystick (not null)sourceComponentId
- the name to be remappedremapId
- the remapped name
-
addMapping
Adds a single Joystick axis or button remapping based on the joystick's name and axis/button name. The "remap" value will be used instead.- Parameters:
stickName
- which joystick (not null)sourceComponentId
- the name to be remappedremapId
- the remapped name
-
addMappings
Adds a preconfigured set of mappings in Properties object form where the names are dot notation "axis"/"button"/"". "joystick"."axis/button name" and the values are the remapped component name. This calls addMapping(stickName, sourceComponent, remap) for every property that it is able to parse.- Parameters:
p
- (not null)
-
addJoystickNameRegex
Maps a regular expression to a normalized name for that joystick.- Parameters:
regex
- the regular expression to be matchedname
- the remapped name
-
getNormalizedName
-
loadMappingProperties
Loads a set of compatibility mappings from the property file specified by the given URL.- Parameters:
u
- the URL of the properties file (not null)- Throws:
IOException
- if an I/O exception occurs
-
loadMappings
- Throws:
IOException
-
loadDefaultMappings
protected static void loadDefaultMappings()Loads the default compatibility mappings by looking for joystick-mapping.properties files on the classpath.
-