@@ -268,6 +268,31 @@ public final class AppSettings extends HashMap<String, Object> {
268268 */
269269 public static final String JOAL = "JOAL" ;
270270
271+ /**
272+ * Map gamepads to Xbox-like layout.
273+ */
274+ public static final String JOYSTICKS_XBOX_MAPPER = "JOYSTICKS_XBOX_MAPPER" ;
275+
276+ /**
277+ * Map gamepads to an Xbox-like layout, with fallback to raw if the gamepad is not recognized.
278+ */
279+ public static final String JOYSTICKS_XBOX_WITH_FALLBACK_MAPPER = "JOYSTICKS_XBOX_WITH_FALLBACK_MAPPER" ;
280+
281+ /**
282+ * Map gamepads to an Xbox-like layout using the legacy jME input
283+ */
284+ public static final String JOYSTICKS_XBOX_LEGACY_MAPPER = "JOYSTICKS_XBOX_LEGACY_MAPPER" ;
285+
286+ /**
287+ * Map gamepads using the legacy jME mapper and input.
288+ */
289+ public static final String JOYSTICKS_LEGACY_MAPPER = "JOYSTICKS_LEGACY_MAPPER" ;
290+
291+ /**
292+ * Don't map gamepads, use raw events instead (ie. bring your own mapper)
293+ */
294+ public static final String JOYSTICKS_RAW_MAPPER = "JOYSTICKS_RAW_MAPPER" ;
295+
271296 static {
272297 defaults .put ("Display" , 0 );
273298 defaults .put ("CenterWindow" , true );
@@ -300,8 +325,10 @@ public final class AppSettings extends HashMap<String, Object> {
300325 defaults .put ("WindowYPosition" , 0 );
301326 defaults .put ("WindowXPosition" , 0 );
302327 defaults .put ("X11PlatformPreferred" , false );
303- defaults .put ("XboxLikeControllerLayout" , true );
304- defaults .put ("TriggerToButtonThreshold" , 0.5f );
328+ defaults .put ("JoysticksMapper" , JOYSTICKS_XBOX_MAPPER );
329+ defaults .put ("JoysticksTriggerToButtonThreshold" , 0.5f );
330+ defaults .put ("JoysticksAxisJitterThreshold" , 0.0001f );
331+ defaults .put ("SDLGameControllerDBResourcePath" , "" );
305332 // defaults.put("Icons", null);
306333 }
307334
@@ -1616,27 +1643,20 @@ public boolean isX11PlatformPreferred() {
16161643 }
16171644
16181645 /**
1619- * Enable/disable automatic normalization of gamepad mappings to an Xbox-like layout,
1620- * when possible.
1621- *
1622- * <p>
1623- * Depending on the platform and controller model, this setting might have no effect.
1624- * It is primarily intended to provide a consistent default button/axis layout across common
1625- * controllers.
1646+ * Set which joystick mapping to use for normalization of controller inputs
16261647 *
1627- * @param enabled true to enable, false to disable (default: true)
1648+ * @param mapper
1649+ * JOYSTICKS_MAPPER_* constant defining which mapping to use
16281650 */
1629- public void setXboxLikeControllerLayout ( boolean enabled ) {
1630- putBoolean ( "XboxLikeControllerLayout " , enabled );
1651+ public void setJoysticksMapper ( String mapper ) {
1652+ putString ( "JoysticksMapper " , mapper );
16311653 }
16321654
16331655 /**
1634- * Whether automatic normalization of controller mappings to an Xbox-like layout is enabled.
1635- *
1636- * @return true if enabled, otherwise false
1656+ * Get which joystick mapping to use for normalization of controller inputs
16371657 */
1638- public boolean isXboxLikeControllerLayout () {
1639- return getBoolean ( "XboxLikeControllerLayout " );
1658+ public String getJoysticksMapper () {
1659+ return getString ( "JoysticksMapper " );
16401660 }
16411661
16421662 /**
@@ -1649,17 +1669,57 @@ public boolean isXboxLikeControllerLayout(){
16491669 *
16501670 * @param threshold the trigger threshold in the range [0, 1] (default: 0.5f)
16511671 */
1652- public void setTriggerToButtonThreshold (float threshold ) {
1653- putFloat ("TriggerToButtonThreshold " , threshold );
1672+ public void setJoysticksTriggerToButtonThreshold (float threshold ) {
1673+ putFloat ("JoysticksTriggerToButtonThreshold " , threshold );
16541674 }
16551675
16561676 /**
16571677 * Gets the threshold above which an analog trigger should also generate a button-press event.
16581678 *
16591679 * @return the trigger threshold in the range [0, 1] (default: 0.5f)
1660- * @see #setTriggerToButtonThreshold (float)
1680+ * @see #setJoysticksTriggerToButtonThreshold (float)
16611681 */
1662- public float getTriggerToButtonThreshold () {
1663- return getFloat ("TriggerToButtonThreshold" );
1682+ public float getJoysticksTriggerToButtonThreshold () {
1683+ return getFloat ("JoysticksTriggerToButtonThreshold" );
1684+ }
1685+
1686+ /**
1687+ * Sets the jitter threshold for joystick axes.
1688+ *
1689+ * <p>
1690+ * Axis movements with a delta smaller than this threshold will be ignored. This is intended to reduce
1691+ * noise from analog joysticks.
1692+ */
1693+ public void setJoysticksAxisJitterThreshold (float threshold ) {
1694+ putFloat ("JoysticksAxisJitterThreshold" , threshold );
1695+ }
1696+
1697+ /**
1698+ * Gets the jitter threshold for joystick axes.
1699+ *
1700+ * @return the jitter threshold
1701+ * @see #setJoysticksAxisJitterThreshold(float)
1702+ */
1703+ public float getJoysticksAxisJitterThreshold () {
1704+ return getFloat ("JoysticksAxisJitterThreshold" );
1705+ }
1706+
1707+ /**
1708+ * Set resource path for a custom SDL game controller database.
1709+ *
1710+ * @param path
1711+ */
1712+ public void setSDLGameControllerDBResourcePath (String path ) {
1713+ putString ("SDLGameControllerDBResourcePath" , path );
1714+ }
1715+
1716+ /**
1717+ * Get resource path for a custom SDL game controller database.
1718+ *
1719+ * @return resource path
1720+ */
1721+ public String getSDLGameControllerDBResourcePath () {
1722+ return getString ("SDLGameControllerDBResourcePath" );
16641723 }
16651724}
1725+
0 commit comments