[Scummvm-git-logs] scummvm master -> 2177e685b70ed08e96b8541c8b1b34d9abef2b1f

rsn8887 rsn8887 at users.noreply.github.com
Sun Feb 9 14:34:20 UTC 2020


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
eea70a3c8c BACKEND: Allow SDL2 mapping of L2/R2, fix psp2/switch mapping
2177e685b7 KEYMAPPER: Allow joystick half axes to be remapped


Commit: eea70a3c8c8cc314f4ecebd7ac28e9ce45b26494
    https://github.com/scummvm/scummvm/commit/eea70a3c8c8cc314f4ecebd7ac28e9ce45b26494
Author: rsn8887 (rsn8887 at users.noreply.github.com)
Date: 2020-02-09T08:34:16-06:00

Commit Message:
BACKEND: Allow SDL2 mapping of L2/R2, fix psp2/switch mapping

Changed paths:
    backends/events/sdl/sdl-events.cpp
    backends/events/sdl/sdl-events.h
    backends/keymapper/hardware-input.cpp
    backends/platform/sdl/psp2/psp2.cpp
    backends/platform/sdl/psp2/psp2.h
    backends/platform/sdl/switch/switch.cpp
    backends/platform/sdl/switch/switch.h
    common/events.h


diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 98cb5eb..c7fcefa 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -89,7 +89,7 @@ void SdlEventSource::loadGameControllerMappingFile() {
 SdlEventSource::SdlEventSource()
     : EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false), _lastHatPosition(SDL_HAT_CENTERED)
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-      , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr)
+      , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr), _leftTriggerDown(false), _rightTriggerDown(false)
 #endif
       {
 	// Reset mouse state
@@ -1064,6 +1064,48 @@ bool SdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Eve
 		return handleAxisToMouseMotion(_km.joy_x, _km.joy_y);
 	}
 
+	// Left trigger is treated as axis in SDL
+	if (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT) {
+		if (ev.caxis.value < 8192) { // 25% pressed
+			if (_leftTriggerDown) {
+				_leftTriggerDown = false;
+				event.type = Common::EVENT_JOYBUTTON_UP;
+				event.joystick.button = Common::JOYSTICK_BUTTON_LEFT_TRIGGER;
+				return true;
+			} else
+				return false;
+		} else if (ev.caxis.value > 16384) { // 50% pressed
+			if (!_leftTriggerDown) {
+				_leftTriggerDown = true;
+				event.type = Common::EVENT_JOYBUTTON_DOWN;
+				event.joystick.button = Common::JOYSTICK_BUTTON_LEFT_TRIGGER;
+				return true;
+			} else
+				return false;
+		}
+	}
+
+	// Right trigger is treated as axis in SDL
+	if (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) {
+		if (ev.caxis.value < 8192) { // 25% pressed
+			if (_rightTriggerDown) {
+				_rightTriggerDown = false;
+				event.type = Common::EVENT_JOYBUTTON_UP;
+				event.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_TRIGGER;
+				return true;
+			} else
+				return false;
+		} else if (ev.caxis.value > 16384) { // 50% pressed
+			if (!_rightTriggerDown) {
+				_rightTriggerDown = true;
+				event.type = Common::EVENT_JOYBUTTON_DOWN;
+				event.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_TRIGGER;
+				return true;
+			} else
+				return false;
+		}
+	}
+
 	return false;
 }
 #endif
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index f1f2bdd..a7a2db4 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -84,6 +84,10 @@ protected:
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 	/** Game controller */
 	SDL_GameController *_controller;
+
+	/** keep memory of current trigger status */
+	bool _leftTriggerDown;
+	bool _rightTriggerDown;
 #endif
 
 	/** Last screen id for checking if it was modified */
diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp
index 0b4c0f5..d3a2d02 100644
--- a/backends/keymapper/hardware-input.cpp
+++ b/backends/keymapper/hardware-input.cpp
@@ -236,6 +236,8 @@ const HardwareInputTableEntry defaultJoystickButtons[] = {
     { "JOY_RIGHT_STICK",    JOYSTICK_BUTTON_RIGHT_STICK,    _s("Right Stick")    },
     { "JOY_LEFT_SHOULDER",  JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("Left Shoulder")  },
     { "JOY_RIGHT_SHOULDER", JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("Right Shoulder") },
+    { "JOY_LEFT_TRIGGER",   JOYSTICK_BUTTON_LEFT_TRIGGER,   _s("Left Trigger")  },
+    { "JOY_RIGHT_TRIGGER",  JOYSTICK_BUTTON_RIGHT_TRIGGER,  _s("Right Trigger") },
     { "JOY_UP",             JOYSTICK_BUTTON_DPAD_UP,        _s("D-pad Up")       },
     { "JOY_DOWN",           JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")     },
     { "JOY_LEFT",           JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")     },
diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp
index f87d8f8..ab535b9 100644
--- a/backends/platform/sdl/psp2/psp2.cpp
+++ b/backends/platform/sdl/psp2/psp2.cpp
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
+#include "common/translation.h"
 #include "backends/platform/sdl/psp2/psp2.h"
 #include "backends/graphics/psp2sdl/psp2sdl-graphics.h"
 #include "backends/saves/default/default-saves.h"
@@ -33,12 +34,30 @@
 #include "backends/fs/psp2/psp2-fs-factory.h"
 #include "backends/events/psp2sdl/psp2sdl-events.h"
 #include "backends/fs/psp2/psp2-dirent.h"
+#include "backends/keymapper/hardware-input.h"
 #include <sys/stat.h>
 
 #ifdef __PSP2_DEBUG__
 #include <psp2shell.h>
 #endif
 
+static const Common::HardwareInputTableEntry psp2JoystickButtons[] = {
+    { "JOY_A",              Common::JOYSTICK_BUTTON_A,              _s("Cross")       },
+    { "JOY_B",              Common::JOYSTICK_BUTTON_B,              _s("Circle")      },
+    { "JOY_X",              Common::JOYSTICK_BUTTON_X,              _s("Square")      },
+    { "JOY_Y",              Common::JOYSTICK_BUTTON_Y,              _s("Triangle")    },
+    { "JOY_BACK",           Common::JOYSTICK_BUTTON_BACK,           _s("Select")      },
+    { "JOY_START",          Common::JOYSTICK_BUTTON_START,          _s("Start")       },
+    { "JOY_LEFT_SHOULDER",  Common::JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("L")          },
+    { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R")          },
+    { "JOY_UP",             Common::JOYSTICK_BUTTON_DPAD_UP,        _s("D-pad Up")    },
+    { "JOY_DOWN",           Common::JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")  },
+    { "JOY_LEFT",           Common::JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")  },
+    { "JOY_RIGHT",          Common::JOYSTICK_BUTTON_DPAD_RIGHT,     _s("D-pad Right") },
+    { nullptr,              0,                                      nullptr           }
+};
+
+
 int access(const char *pathname, int mode) {
 	struct stat sb;
 
@@ -174,3 +193,16 @@ Common::String OSystem_PSP2::getDefaultConfigFileName() {
 Common::String OSystem_PSP2::getDefaultLogFileName() {
 	return "ux0:data/scummvm/scummvm.log";
 }
+
+Common::HardwareInputSet *OSystem_PSP2::getHardwareInputSet() {
+	using namespace Common;
+
+	CompositeHardwareInputSet *inputSet = new CompositeHardwareInputSet();
+
+	// Users may use USB / bluetooth mice and keyboards
+	inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
+	inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
+	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(psp2JoystickButtons));
+
+	return inputSet;
+}
\ No newline at end of file
diff --git a/backends/platform/sdl/psp2/psp2.h b/backends/platform/sdl/psp2/psp2.h
index 0b3be25..72422d8 100644
--- a/backends/platform/sdl/psp2/psp2.h
+++ b/backends/platform/sdl/psp2/psp2.h
@@ -36,6 +36,7 @@ public:
 	virtual void setFeatureState(Feature f, bool enable) override;
 	virtual bool getFeatureState(Feature f) override;
 	virtual void logMessage(LogMessageType::Type type, const char *message) override;
+	virtual Common::HardwareInputSet *getHardwareInputSet() override;
 
 protected:
 	virtual Common::String getDefaultConfigFileName() override;
diff --git a/backends/platform/sdl/switch/switch.cpp b/backends/platform/sdl/switch/switch.cpp
index 120fb95..270e398 100644
--- a/backends/platform/sdl/switch/switch.cpp
+++ b/backends/platform/sdl/switch/switch.cpp
@@ -24,11 +24,34 @@
 
 #include "common/scummsys.h"
 #include "common/config-manager.h"
+#include "common/translation.h"
 #include "backends/platform/sdl/switch/switch.h"
 #include "backends/events/switchsdl/switchsdl-events.h"
 #include "backends/saves/posix/posix-saves.h"
 #include "backends/fs/posix/posix-fs-factory.h"
 #include "backends/fs/posix/posix-fs.h"
+#include "backends/keymapper/hardware-input.h"
+
+static const Common::HardwareInputTableEntry switchJoystickButtons[] = {
+    { "JOY_A",              Common::JOYSTICK_BUTTON_A,              _s("B")       },
+    { "JOY_B",              Common::JOYSTICK_BUTTON_B,              _s("A")      },
+    { "JOY_X",              Common::JOYSTICK_BUTTON_X,              _s("Y")      },
+    { "JOY_Y",              Common::JOYSTICK_BUTTON_Y,              _s("X")    },
+    { "JOY_BACK",           Common::JOYSTICK_BUTTON_BACK,           _s("Minus")      },
+    { "JOY_START",          Common::JOYSTICK_BUTTON_START,          _s("Plus")       },
+    { "JOY_LEFT_STICK",     Common::JOYSTICK_BUTTON_LEFT_STICK,     _s("L3")          },
+    { "JOY_RIGHT_STICK",    Common::JOYSTICK_BUTTON_RIGHT_STICK,    _s("R3")          },
+    { "JOY_LEFT_SHOULDER",  Common::JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("L")          },
+    { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R")          },
+    { "JOY_LEFT_TRIGGER",   Common::JOYSTICK_BUTTON_LEFT_TRIGGER,   _s("ZL")          },
+    { "JOY_RIGHT_TRIGGER",  Common::JOYSTICK_BUTTON_RIGHT_TRIGGER,  _s("ZR")          },
+    { "JOY_UP",             Common::JOYSTICK_BUTTON_DPAD_UP,        _s("D-pad Up")    },
+    { "JOY_DOWN",           Common::JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")  },
+    { "JOY_LEFT",           Common::JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")  },
+    { "JOY_RIGHT",          Common::JOYSTICK_BUTTON_DPAD_RIGHT,     _s("D-pad Right") },
+    { nullptr,              0,                                      nullptr           }
+};
+
 
 void OSystem_Switch::init() {
 	
@@ -125,3 +148,16 @@ void OSystem_Switch::logMessage(LogMessageType::Type type, const char *message)
 Common::String OSystem_Switch::getDefaultLogFileName() {
 	return "scummvm.log";
 }
+
+Common::HardwareInputSet *OSystem_Switch::getHardwareInputSet() {
+	using namespace Common;
+
+	CompositeHardwareInputSet *inputSet = new CompositeHardwareInputSet();
+
+	// Users may use USB / bluetooth mice and keyboards
+	inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
+	inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
+	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(switchJoystickButtons));
+
+	return inputSet;
+}
\ No newline at end of file
diff --git a/backends/platform/sdl/switch/switch.h b/backends/platform/sdl/switch/switch.h
index 2bdea6f..ea2a21f 100644
--- a/backends/platform/sdl/switch/switch.h
+++ b/backends/platform/sdl/switch/switch.h
@@ -33,6 +33,7 @@ public:
 	virtual void setFeatureState(Feature f, bool enable) override;
 	virtual bool getFeatureState(Feature f) override;
 	virtual void logMessage(LogMessageType::Type type, const char *message) override;
+	virtual Common::HardwareInputSet *getHardwareInputSet() override;
 
 protected:
 	virtual Common::String getDefaultLogFileName() override;
diff --git a/common/events.h b/common/events.h
index 11bfc79..0221a98 100644
--- a/common/events.h
+++ b/common/events.h
@@ -131,6 +131,8 @@ enum JoystickButton {
 	JOYSTICK_BUTTON_RIGHT_STICK,
 	JOYSTICK_BUTTON_LEFT_SHOULDER,
 	JOYSTICK_BUTTON_RIGHT_SHOULDER,
+	JOYSTICK_BUTTON_LEFT_TRIGGER,
+	JOYSTICK_BUTTON_RIGHT_TRIGGER,
 	JOYSTICK_BUTTON_DPAD_UP,
 	JOYSTICK_BUTTON_DPAD_DOWN,
 	JOYSTICK_BUTTON_DPAD_LEFT,


Commit: 2177e685b70ed08e96b8541c8b1b34d9abef2b1f
    https://github.com/scummvm/scummvm/commit/2177e685b70ed08e96b8541c8b1b34d9abef2b1f
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-02-09T08:34:16-06:00

Commit Message:
KEYMAPPER: Allow joystick half axes to be remapped

Changed paths:
    backends/events/sdl/sdl-events.cpp
    backends/events/sdl/sdl-events.h
    backends/keymapper/hardware-input.cpp
    backends/keymapper/hardware-input.h
    backends/keymapper/input-watcher.cpp
    backends/keymapper/keymap.cpp
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    backends/platform/3ds/osystem-events.cpp
    backends/platform/sdl/ps3/ps3.cpp
    backends/platform/sdl/psp2/psp2.cpp
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/switch/switch.cpp
    common/events.h


diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index c7fcefa..ceef945 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -89,7 +89,7 @@ void SdlEventSource::loadGameControllerMappingFile() {
 SdlEventSource::SdlEventSource()
     : EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false), _lastHatPosition(SDL_HAT_CENTERED)
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-      , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr), _leftTriggerDown(false), _rightTriggerDown(false)
+      , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr)
 #endif
       {
 	// Reset mouse state
@@ -913,16 +913,8 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
 }
 
 bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
-	// TODO: move handleAxisToMouseMotion to Common?
-#if 0
-	if (!shouldGenerateMouseEvents()) {
-		event.type = Common::EVENT_JOYAXIS_MOTION;
-		event.joystick.axis = ev.jaxis.axis;
-		event.joystick.position = ev.jaxis.value;
-		return true;
-	}
-#endif
 
+	// TODO: Move hardcoded axis to mouse motion code to the keymapper
 	if (ev.jaxis.axis == JOY_XAXIS) {
 		_km.joy_x = ev.jaxis.value;
 		return handleAxisToMouseMotion(_km.joy_x, _km.joy_y);
@@ -931,7 +923,11 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
 		return handleAxisToMouseMotion(_km.joy_x, _km.joy_y);
 	}
 
-	return false;
+	event.type = Common::EVENT_JOYAXIS_MOTION;
+	event.joystick.axis = ev.jaxis.axis;
+	event.joystick.position = ev.jaxis.value;
+
+	return true;
 }
 
 #define HANDLE_HAT_UP(new, old, mask, joybutton) \
@@ -1046,16 +1042,8 @@ bool SdlEventSource::handleControllerButton(const SDL_Event &ev, Common::Event &
 }
 
 bool SdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event) {
-	// TODO: move handleAxisToMouseMotion to Common?
-#if 0
-	if (!shouldGenerateMouseEvents()) {
-		event.type = Common::EVENT_JOYAXIS_MOTION;
-		event.joystick.axis = ev.caxis.axis;
-		event.joystick.position = ev.caxis.value;
-		return true;
-	}
-#endif
 
+	// TODO: Move hardcoded axis to mouse motion code to the keymapper
 	if (ev.caxis.axis == SDL_CONTROLLER_AXIS_LEFTX) {
 		_km.joy_x = ev.caxis.value;
 		return handleAxisToMouseMotion(_km.joy_x, _km.joy_y);
@@ -1064,49 +1052,11 @@ bool SdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Eve
 		return handleAxisToMouseMotion(_km.joy_x, _km.joy_y);
 	}
 
-	// Left trigger is treated as axis in SDL
-	if (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT) {
-		if (ev.caxis.value < 8192) { // 25% pressed
-			if (_leftTriggerDown) {
-				_leftTriggerDown = false;
-				event.type = Common::EVENT_JOYBUTTON_UP;
-				event.joystick.button = Common::JOYSTICK_BUTTON_LEFT_TRIGGER;
-				return true;
-			} else
-				return false;
-		} else if (ev.caxis.value > 16384) { // 50% pressed
-			if (!_leftTriggerDown) {
-				_leftTriggerDown = true;
-				event.type = Common::EVENT_JOYBUTTON_DOWN;
-				event.joystick.button = Common::JOYSTICK_BUTTON_LEFT_TRIGGER;
-				return true;
-			} else
-				return false;
-		}
-	}
-
-	// Right trigger is treated as axis in SDL
-	if (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) {
-		if (ev.caxis.value < 8192) { // 25% pressed
-			if (_rightTriggerDown) {
-				_rightTriggerDown = false;
-				event.type = Common::EVENT_JOYBUTTON_UP;
-				event.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_TRIGGER;
-				return true;
-			} else
-				return false;
-		} else if (ev.caxis.value > 16384) { // 50% pressed
-			if (!_rightTriggerDown) {
-				_rightTriggerDown = true;
-				event.type = Common::EVENT_JOYBUTTON_DOWN;
-				event.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_TRIGGER;
-				return true;
-			} else
-				return false;
-		}
-	}
+	event.type = Common::EVENT_JOYAXIS_MOTION;
+	event.joystick.axis = ev.caxis.axis;
+	event.joystick.position = ev.caxis.value;
 
-	return false;
+	return true;
 }
 #endif
 
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index a7a2db4..f1f2bdd 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -84,10 +84,6 @@ protected:
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 	/** Game controller */
 	SDL_GameController *_controller;
-
-	/** keep memory of current trigger status */
-	bool _leftTriggerDown;
-	bool _rightTriggerDown;
 #endif
 
 	/** Last screen id for checking if it was modified */
diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp
index d3a2d02..da0cb78 100644
--- a/backends/keymapper/hardware-input.cpp
+++ b/backends/keymapper/hardware-input.cpp
@@ -236,8 +236,6 @@ const HardwareInputTableEntry defaultJoystickButtons[] = {
     { "JOY_RIGHT_STICK",    JOYSTICK_BUTTON_RIGHT_STICK,    _s("Right Stick")    },
     { "JOY_LEFT_SHOULDER",  JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("Left Shoulder")  },
     { "JOY_RIGHT_SHOULDER", JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("Right Shoulder") },
-    { "JOY_LEFT_TRIGGER",   JOYSTICK_BUTTON_LEFT_TRIGGER,   _s("Left Trigger")  },
-    { "JOY_RIGHT_TRIGGER",  JOYSTICK_BUTTON_RIGHT_TRIGGER,  _s("Right Trigger") },
     { "JOY_UP",             JOYSTICK_BUTTON_DPAD_UP,        _s("D-pad Up")       },
     { "JOY_DOWN",           JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")     },
     { "JOY_LEFT",           JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")     },
@@ -245,6 +243,16 @@ const HardwareInputTableEntry defaultJoystickButtons[] = {
     { nullptr,              0,                              nullptr              }
 };
 
+const AxisTableEntry defaultJoystickAxes[] = {
+    { "JOY_LEFT_TRIGGER",  JOYSTICK_AXIS_LEFT_TRIGGER,  kAxisTypeHalf, _s("Left Trigger")  },
+    { "JOY_RIGHT_TRIGGER", JOYSTICK_AXIS_RIGHT_TRIGGER, kAxisTypeHalf, _s("Right Trigger") },
+    { "JOY_LEFT_STICK_X",  JOYSTICK_AXIS_LEFT_STICK_X,  kAxisTypeFull, _s("Left Stick X")  },
+    { "JOY_LEFT_STICK_Y",  JOYSTICK_AXIS_LEFT_STICK_Y,  kAxisTypeFull, _s("Left Stick Y")  },
+    { "JOY_RIGHT_STICK_X", JOYSTICK_AXIS_RIGHT_STICK_X, kAxisTypeFull, _s("Right Stick X") },
+    { "JOY_RIGHT_STICK_Y", JOYSTICK_AXIS_RIGHT_STICK_Y, kAxisTypeFull, _s("Right Stick Y") },
+    { nullptr,             0,                           kAxisTypeFull, nullptr             }
+};
+
 HardwareInputSet::~HardwareInputSet() {
 }
 
@@ -384,18 +392,39 @@ HardwareInput MouseHardwareInputSet::findHardwareInput(const Event &event) const
 	return HardwareInput::createMouse(hw->hwId, hw->code, hw->desc);
 }
 
-JoystickHardwareInputSet::JoystickHardwareInputSet(const HardwareInputTableEntry *buttonEntries) :
-		_buttonEntries(buttonEntries) {
+JoystickHardwareInputSet::JoystickHardwareInputSet(const HardwareInputTableEntry *buttonEntries, const AxisTableEntry *axisEntries) :
+		_buttonEntries(buttonEntries),
+		_axisEntries(axisEntries) {
 	assert(_buttonEntries);
+	assert(_axisEntries);
 }
 
 HardwareInput JoystickHardwareInputSet::findHardwareInput(const String &id) const {
 	const HardwareInputTableEntry *hw = HardwareInputTableEntry::findWithId(_buttonEntries, id);
-	if (!hw || !hw->hwId) {
-		return HardwareInput();
+	if (hw && hw->hwId) {
+		return HardwareInput::createJoystickButton(hw->hwId, hw->code, hw->desc);
+	}
+
+	bool hasHalfSuffix = id.lastChar() == '-' || id.lastChar() == '+';
+	Common::String tableId = hasHalfSuffix ? Common::String(id.c_str(), id.size() - 1) : id;
+	const AxisTableEntry *axis = AxisTableEntry::findWithId(_axisEntries, tableId);
+	if (axis && axis->hwId) {
+		if (hasHalfSuffix && axis->type == kAxisTypeHalf) {
+			return HardwareInput(); // Half axes can't be split in halves
+		} else if (!hasHalfSuffix && axis->type == kAxisTypeFull) {
+			return HardwareInput(); // For now it's only possible to bind half axes
+		}
+
+		if (axis->type == kAxisTypeHalf) {
+			return HardwareInput::createJoystickHalfAxis(axis->hwId, axis->code, true, axis->desc);
+		} else {
+			bool positiveHalf = id.lastChar() == '+';
+			Common::String desc = String::format("%s%c", axis->desc, id.lastChar());
+			return HardwareInput::createJoystickHalfAxis(id, axis->code, positiveHalf, desc);
+		}
 	}
 
-	return HardwareInput::createJoystick(hw->hwId, hw->code, hw->desc);
+	return HardwareInput();
 }
 
 HardwareInput JoystickHardwareInputSet::findHardwareInput(const Event &event) const {
@@ -407,8 +436,29 @@ HardwareInput JoystickHardwareInputSet::findHardwareInput(const Event &event) co
 			return HardwareInput();
 		}
 
-		return HardwareInput::createJoystick(hw->hwId, hw->code, hw->desc);
+		return HardwareInput::createJoystickButton(hw->hwId, hw->code, hw->desc);
 	}
+	case EVENT_JOYAXIS_MOTION: {
+		if (ABS(event.joystick.position) < (JOYAXIS_MAX / 2)) {
+			return HardwareInput(); // Ignore incomplete presses for remapping purposes
+		}
+
+		const AxisTableEntry *hw = AxisTableEntry::findWithCode(_axisEntries, event.joystick.axis);
+		if (!hw || !hw->hwId) {
+			return HardwareInput();
+		}
+
+		if (hw->type == kAxisTypeHalf) {
+			return HardwareInput::createJoystickHalfAxis(hw->hwId, hw->code, true, hw->desc);
+		} else {
+			bool positiveHalf = event.joystick.position >= 0;
+			char halfSuffix = positiveHalf ? '+' : '-';
+			Common::String hwId = String::format("%s%c", hw->hwId, halfSuffix);
+			Common::String desc = String::format("%s%c", hw->desc, halfSuffix);
+			return HardwareInput::createJoystickHalfAxis(hwId, hw->code, positiveHalf, desc);
+		}
+	}
+
 	default:
 		return HardwareInput();
 	}
diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h
index bde98f6..bb64169 100644
--- a/backends/keymapper/hardware-input.h
+++ b/backends/keymapper/hardware-input.h
@@ -42,7 +42,9 @@ enum HardwareInputType {
 	/** Mouse input that sends -up and -down events */
 	kHardwareInputTypeMouse,
 	/** Joystick input that sends -up and -down events */
-	kHardwareInputTypeJoystick,
+	kHardwareInputTypeJoystickButton,
+	/** Joystick input that sends "analog" values */
+	kHardwareInputTypeJoystickHalfAxis,
 	/** Input that sends single events */
 	kHardwareInputTypeCustom
 };
@@ -91,13 +93,16 @@ struct HardwareInput {
 		return hardwareInput;
 	}
 
-	static HardwareInput createJoystick(const String &i, uint8 button, const String &desc) {
-		return createSimple(kHardwareInputTypeJoystick, i, button, desc);
+	static HardwareInput createJoystickButton(const String &i, uint8 button, const String &desc) {
+		return createSimple(kHardwareInputTypeJoystickButton, i, button, desc);
+	}
+
+	static HardwareInput createJoystickHalfAxis(const String &i, uint8 axis, bool positiveHalf, const String &desc) {
+		return createSimple(kHardwareInputTypeJoystickHalfAxis, i, axis * 2 + (positiveHalf ? 1 : 0), desc);
 	}
 
 	static HardwareInput createMouse(const String &i, uint8 button, const String &desc) {
 		return createSimple(kHardwareInputTypeMouse, i, button, desc);
-
 	}
 
 private:
@@ -156,6 +161,39 @@ struct ModifierTableEntry {
 	const char *desc;
 };
 
+enum AxisType {
+	/** An axis that sends "analog" values from JOYAXIS_MIN to JOYAXIS_MAX. e.g. a gamepad stick axis */
+	kAxisTypeFull,
+	/** An axis that sends "analog" values from 0 to JOYAXIS_MAX. e.g. a gamepad trigger */
+	kAxisTypeHalf
+};
+
+struct AxisTableEntry {
+	const char *hwId;
+	HardwareInputCode code;
+	AxisType type;
+	const char *desc;
+
+	static const AxisTableEntry *findWithCode(const AxisTableEntry *_entries, HardwareInputCode code) {
+		for (const AxisTableEntry *hw = _entries;  hw->hwId; hw++) {
+			if (hw->code == code) {
+				return hw;
+			}
+		}
+		return nullptr;
+	}
+
+	static const AxisTableEntry *findWithId(const AxisTableEntry *_entries, const String &id) {
+		for (const AxisTableEntry *hw = _entries;  hw->hwId; hw++) {
+			if (id.equals(hw->hwId)) {
+				return hw;
+			}
+		}
+		return nullptr;
+	}
+};
+
+
 /**
  * Interface for querying information about a hardware input device
  */
@@ -223,7 +261,7 @@ private:
  */
 class JoystickHardwareInputSet : public HardwareInputSet {
 public:
-	JoystickHardwareInputSet(const HardwareInputTableEntry *buttonEntries);
+	JoystickHardwareInputSet(const HardwareInputTableEntry *buttonEntries, const AxisTableEntry *axisEntries);
 
 	// HardwareInputSet API
 	HardwareInput findHardwareInput(const String &id) const override;
@@ -231,6 +269,7 @@ public:
 
 private:
 	const HardwareInputTableEntry *_buttonEntries;
+	const AxisTableEntry *_axisEntries;
 };
 
 /**
@@ -284,6 +323,9 @@ extern const HardwareInputTableEntry defaultMouseButtons[];
 /** A standard set of joystick buttons based on the ScummVM event model */
 extern const HardwareInputTableEntry defaultJoystickButtons[];
 
+/** A standard set of joystick axes based on the ScummVM event model */
+extern const AxisTableEntry defaultJoystickAxes[];
+
 } // End of namespace Common
 
 #endif // #ifndef COMMON_HARDWARE_KEY_H
diff --git a/backends/keymapper/input-watcher.cpp b/backends/keymapper/input-watcher.cpp
index 685d6b6..8b757ec 100644
--- a/backends/keymapper/input-watcher.cpp
+++ b/backends/keymapper/input-watcher.cpp
@@ -66,6 +66,7 @@ bool InputWatcher::notifyEvent(const Event &event) {
 			return true;
 		case EVENT_KEYUP:
 		case EVENT_JOYBUTTON_UP:
+		case EVENT_JOYAXIS_MOTION:
 		case EVENT_LBUTTONUP:
 		case EVENT_RBUTTONUP:
 		case EVENT_MBUTTONUP:
diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp
index e161439..d3a7878 100644
--- a/backends/keymapper/keymap.cpp
+++ b/backends/keymapper/keymap.cpp
@@ -148,7 +148,12 @@ Keymap::ActionArray Keymap::getMappedActions(const Event &event) const {
 	}
 	case EVENT_JOYBUTTON_DOWN:
 	case EVENT_JOYBUTTON_UP: {
-		HardwareInput hardwareInput = HardwareInput::createJoystick("", event.joystick.button, "");
+		HardwareInput hardwareInput = HardwareInput::createJoystickButton("", event.joystick.button, "");
+		return _hwActionMap[hardwareInput];
+	}
+	case EVENT_JOYAXIS_MOTION: {
+		bool positiveHalf = event.joystick.position >= 0;
+		HardwareInput hardwareInput = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, positiveHalf, "");
 		return _hwActionMap[hardwareInput];
 	}
 	case EVENT_CUSTOM_BACKEND_HARDWARE: {
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 0e0c287..adbd556 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -42,6 +42,7 @@ Keymapper::Keymapper(EventManager *eventMan) :
 		_enabled(true),
 		_enabledKeymapType(Keymap::kKeymapTypeGlobal) {
 	_eventMan->getEventDispatcher()->registerSource(_delayedEventSource, true);
+	resetInputState();
 }
 
 Keymapper::~Keymapper() {
@@ -178,6 +179,9 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
 		const Keymap::ActionArray &actions = _keymaps[i]->getMappedActions(ev);
 		for (Keymap::ActionArray::const_iterator it = actions.begin(); it != actions.end(); it++) {
 			Event mappedEvent = executeAction(*it, ev);
+			if (mappedEvent.type == EVENT_INVALID) {
+				continue;
+			}
 
 			// In case we mapped a mouse event to something else, we need to generate an artificial
 			// mouse move event so event observers can keep track of the mouse position.
@@ -200,6 +204,14 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
 		}
 	}
 
+	if (ev.type == EVENT_JOYAXIS_MOTION && ev.joystick.axis < ARRAYSIZE(_joystickAxisPreviouslyPressed)) {
+		if (ABS<int32>(ev.joystick.position) >= kJoyAxisPressedTreshold) {
+			_joystickAxisPreviouslyPressed[ev.joystick.axis] = true;
+		} else if (ABS<int32>(ev.joystick.position) < kJoyAxisUnpressedTreshold) {
+			_joystickAxisPreviouslyPressed[ev.joystick.axis] = false;
+		}
+	}
+
 	// Ignore keyboard repeat events. Repeat event are meant for text input,
 	// the keymapper / keymaps are supposed to be disabled during text input.
 	// TODO: Add a way to keep repeat events if needed.
@@ -218,6 +230,18 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
 Keymapper::IncomingEventType Keymapper::convertToIncomingEventType(const Event &ev) const {
 	if (ev.type == EVENT_CUSTOM_BACKEND_HARDWARE) {
 		return kIncomingEventInstant;
+	} else if (ev.type == EVENT_JOYAXIS_MOTION) {
+		if (ev.joystick.axis >= ARRAYSIZE(_joystickAxisPreviouslyPressed)) {
+			return kIncomingEventIgnored;
+		}
+
+		if (!_joystickAxisPreviouslyPressed[ev.joystick.axis] && ABS<int32>(ev.joystick.position) >= kJoyAxisPressedTreshold) {
+			return kIncomingEventStart;
+		} else if (_joystickAxisPreviouslyPressed[ev.joystick.axis] && ABS<int32>(ev.joystick.position) < kJoyAxisUnpressedTreshold) {
+			return kIncomingEventEnd;
+		} else {
+			return kIncomingEventIgnored;
+		}
 	} else if (ev.type == EVENT_KEYDOWN
 	           || ev.type == EVENT_LBUTTONDOWN
 	           || ev.type == EVENT_RBUTTONDOWN
@@ -240,8 +264,14 @@ bool Keymapper::isMouseEvent(const Event &event) {
 }
 
 Event Keymapper::executeAction(const Action *action, const Event &incomingEvent) {
-	IncomingEventType incomingType = convertToIncomingEventType(incomingEvent);
 	Event outgoingEvent = Event(action->event);
+
+	IncomingEventType incomingType = convertToIncomingEventType(incomingEvent);
+	if (incomingType == kIncomingEventIgnored) {
+		outgoingEvent.type = EVENT_INVALID;
+		return outgoingEvent;
+	}
+
 	EventType convertedType = convertStartToEnd(outgoingEvent.type);
 
 	// hardware keys need to send up instead when they are up
@@ -335,6 +365,12 @@ void Keymapper::hardcodedEventMapping(Event ev) {
 #endif
 }
 
+void Keymapper::resetInputState() {
+	for (uint i = 0; i < ARRAYSIZE(_joystickAxisPreviouslyPressed); i++) {
+		_joystickAxisPreviouslyPressed[i] = false;
+	}
+}
+
 void DelayedEventSource::scheduleEvent(const Event &ev, uint32 delayMillis) {
 	if (_delayedEvents.empty()) {
 		_delayedEffectiveTime = g_system->getMillis() + delayMillis;
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index 848943d..708732a 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -139,22 +139,31 @@ private:
 	DelayedEventSource *_delayedEventSource;
 
 	enum IncomingEventType {
+		kIncomingEventIgnored,
 		kIncomingEventStart,
 		kIncomingEventEnd,
 		kIncomingEventInstant
 	};
 
+	enum {
+		kJoyAxisPressedTreshold   = Common::JOYAXIS_MAX / 2,
+		kJoyAxisUnpressedTreshold = Common::JOYAXIS_MAX / 4
+	};
+
 	bool _enabled;
 	Keymap::KeymapType _enabledKeymapType;
 
 	KeymapArray _keymaps;
 
+	bool _joystickAxisPreviouslyPressed[6];
+
 	Event executeAction(const Action *act, const Event &incomingEvent);
 	EventType convertStartToEnd(EventType eventType);
 	IncomingEventType convertToIncomingEventType(const Event &ev) const;
 	static bool isMouseEvent(const Event &event);
 
 	void hardcodedEventMapping(Event ev);
+	void resetInputState();
 };
 
 class DelayedEventSource : public EventSource {
diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index a394741..d4d47f3 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -44,7 +44,7 @@ static InputMode inputMode = MODE_DRAG;
 static InputMode savedInputMode = MODE_DRAG;
 static aptHookCookie cookie;
 
-const Common::HardwareInputTableEntry ctrJoystickButtons[] = {
+static const Common::HardwareInputTableEntry ctrJoystickButtons[] = {
     { "JOY_A",              Common::JOYSTICK_BUTTON_A,              _s("A")           },
     { "JOY_B",              Common::JOYSTICK_BUTTON_B,              _s("B")           },
     { "JOY_X",              Common::JOYSTICK_BUTTON_X,              _s("X")           },
@@ -62,6 +62,12 @@ const Common::HardwareInputTableEntry ctrJoystickButtons[] = {
     { nullptr,              0,                                      nullptr           }
 };
 
+static const Common::AxisTableEntry ctrJoystickAxes[] = {
+    { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("C-Pad X") },
+    { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("C-Pad Y") },
+    { nullptr,            0,                                  Common::kAxisTypeFull, nullptr       }
+};
+
 const Common::HardwareInputTableEntry ctrMouseButtons[] = {
     { "MOUSE_LEFT",   Common::MOUSE_BUTTON_LEFT,   _s("Touch") },
     { nullptr,        0,                           nullptr     }
@@ -248,7 +254,7 @@ Common::HardwareInputSet *OSystem_3DS::getHardwareInputSet() {
 	CompositeHardwareInputSet *inputSet = new CompositeHardwareInputSet();
 	// Touch input sends mouse events for now, so we need to declare we have a mouse...
 	inputSet->addHardwareInputSet(new MouseHardwareInputSet(ctrMouseButtons));
-	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(ctrJoystickButtons));
+	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(ctrJoystickButtons, ctrJoystickAxes));
 
 	return inputSet;
 }
diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp
index fbcbc4a..1243508 100644
--- a/backends/platform/sdl/ps3/ps3.cpp
+++ b/backends/platform/sdl/ps3/ps3.cpp
@@ -56,6 +56,16 @@ static const Common::HardwareInputTableEntry playstationJoystickButtons[] = {
     { nullptr,              0,                                      nullptr           }
 };
 
+static const Common::AxisTableEntry playstationJoystickAxes[] = {
+    { "JOY_LEFT_TRIGGER",  Common::JOYSTICK_AXIS_LEFT_TRIGGER,  Common::kAxisTypeHalf, _s("L2")            },
+    { "JOY_RIGHT_TRIGGER", Common::JOYSTICK_AXIS_RIGHT_TRIGGER, Common::kAxisTypeHalf, _s("R2")            },
+    { "JOY_LEFT_STICK_X",  Common::JOYSTICK_AXIS_LEFT_STICK_X,  Common::kAxisTypeFull, _s("Left Stick X")  },
+    { "JOY_LEFT_STICK_Y",  Common::JOYSTICK_AXIS_LEFT_STICK_Y,  Common::kAxisTypeFull, _s("Left Stick Y")  },
+    { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") },
+    { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") },
+    { nullptr,             0,                                   Common::kAxisTypeFull, nullptr             }
+};
+
 int access(const char *pathname, int mode) {
 	struct stat sb;
 
@@ -107,7 +117,7 @@ Common::HardwareInputSet *OSystem_PS3::getHardwareInputSet() {
 	// Users may use USB / bluetooth mice and keyboards
 	inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
 	inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
-	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(playstationJoystickButtons));
+	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(playstationJoystickButtons, playstationJoystickAxes));
 
 	return inputSet;
 }
diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp
index ab535b9..dd114d8 100644
--- a/backends/platform/sdl/psp2/psp2.cpp
+++ b/backends/platform/sdl/psp2/psp2.cpp
@@ -48,8 +48,8 @@ static const Common::HardwareInputTableEntry psp2JoystickButtons[] = {
     { "JOY_Y",              Common::JOYSTICK_BUTTON_Y,              _s("Triangle")    },
     { "JOY_BACK",           Common::JOYSTICK_BUTTON_BACK,           _s("Select")      },
     { "JOY_START",          Common::JOYSTICK_BUTTON_START,          _s("Start")       },
-    { "JOY_LEFT_SHOULDER",  Common::JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("L")          },
-    { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R")          },
+    { "JOY_LEFT_SHOULDER",  Common::JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("L")           },
+    { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R")           },
     { "JOY_UP",             Common::JOYSTICK_BUTTON_DPAD_UP,        _s("D-pad Up")    },
     { "JOY_DOWN",           Common::JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")  },
     { "JOY_LEFT",           Common::JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")  },
@@ -57,6 +57,13 @@ static const Common::HardwareInputTableEntry psp2JoystickButtons[] = {
     { nullptr,              0,                                      nullptr           }
 };
 
+static const Common::AxisTableEntry psp2JoystickAxes[] = {
+    { "JOY_LEFT_STICK_X",  Common::JOYSTICK_AXIS_LEFT_STICK_X,  Common::kAxisTypeFull, _s("Left Stick X")  },
+    { "JOY_LEFT_STICK_Y",  Common::JOYSTICK_AXIS_LEFT_STICK_Y,  Common::kAxisTypeFull, _s("Left Stick Y")  },
+    { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") },
+    { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") },
+    { nullptr,             0,                                   Common::kAxisTypeFull, nullptr             }
+};
 
 int access(const char *pathname, int mode) {
 	struct stat sb;
@@ -202,7 +209,7 @@ Common::HardwareInputSet *OSystem_PSP2::getHardwareInputSet() {
 	// Users may use USB / bluetooth mice and keyboards
 	inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
 	inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
-	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(psp2JoystickButtons));
+	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(psp2JoystickButtons, psp2JoystickAxes));
 
 	return inputSet;
-}
\ No newline at end of file
+}
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index faa3234..20b488a 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -408,7 +408,7 @@ Common::HardwareInputSet *OSystem_SDL::getHardwareInputSet() {
 
 	bool joystickSupportEnabled = ConfMan.getInt("joystick_num") >= 0;
 	if (joystickSupportEnabled) {
-		inputSet->addHardwareInputSet(new JoystickHardwareInputSet(defaultJoystickButtons));
+		inputSet->addHardwareInputSet(new JoystickHardwareInputSet(defaultJoystickButtons, defaultJoystickAxes));
 	}
 
 	return inputSet;
diff --git a/backends/platform/sdl/switch/switch.cpp b/backends/platform/sdl/switch/switch.cpp
index 270e398..da25386 100644
--- a/backends/platform/sdl/switch/switch.cpp
+++ b/backends/platform/sdl/switch/switch.cpp
@@ -33,18 +33,16 @@
 #include "backends/keymapper/hardware-input.h"
 
 static const Common::HardwareInputTableEntry switchJoystickButtons[] = {
-    { "JOY_A",              Common::JOYSTICK_BUTTON_A,              _s("B")       },
-    { "JOY_B",              Common::JOYSTICK_BUTTON_B,              _s("A")      },
-    { "JOY_X",              Common::JOYSTICK_BUTTON_X,              _s("Y")      },
-    { "JOY_Y",              Common::JOYSTICK_BUTTON_Y,              _s("X")    },
-    { "JOY_BACK",           Common::JOYSTICK_BUTTON_BACK,           _s("Minus")      },
-    { "JOY_START",          Common::JOYSTICK_BUTTON_START,          _s("Plus")       },
+    { "JOY_A",              Common::JOYSTICK_BUTTON_A,              _s("B")           },
+    { "JOY_B",              Common::JOYSTICK_BUTTON_B,              _s("A")           },
+    { "JOY_X",              Common::JOYSTICK_BUTTON_X,              _s("Y")           },
+    { "JOY_Y",              Common::JOYSTICK_BUTTON_Y,              _s("X")           },
+    { "JOY_BACK",           Common::JOYSTICK_BUTTON_BACK,           _s("Minus")       },
+    { "JOY_START",          Common::JOYSTICK_BUTTON_START,          _s("Plus")        },
     { "JOY_LEFT_STICK",     Common::JOYSTICK_BUTTON_LEFT_STICK,     _s("L3")          },
     { "JOY_RIGHT_STICK",    Common::JOYSTICK_BUTTON_RIGHT_STICK,    _s("R3")          },
-    { "JOY_LEFT_SHOULDER",  Common::JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("L")          },
-    { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R")          },
-    { "JOY_LEFT_TRIGGER",   Common::JOYSTICK_BUTTON_LEFT_TRIGGER,   _s("ZL")          },
-    { "JOY_RIGHT_TRIGGER",  Common::JOYSTICK_BUTTON_RIGHT_TRIGGER,  _s("ZR")          },
+    { "JOY_LEFT_SHOULDER",  Common::JOYSTICK_BUTTON_LEFT_SHOULDER,  _s("L")           },
+    { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R")           },
     { "JOY_UP",             Common::JOYSTICK_BUTTON_DPAD_UP,        _s("D-pad Up")    },
     { "JOY_DOWN",           Common::JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")  },
     { "JOY_LEFT",           Common::JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")  },
@@ -52,6 +50,15 @@ static const Common::HardwareInputTableEntry switchJoystickButtons[] = {
     { nullptr,              0,                                      nullptr           }
 };
 
+static const Common::AxisTableEntry switchJoystickAxes[] = {
+    { "JOY_LEFT_TRIGGER",  Common::JOYSTICK_AXIS_LEFT_TRIGGER,  Common::kAxisTypeHalf, _s("ZL")            },
+    { "JOY_RIGHT_TRIGGER", Common::JOYSTICK_AXIS_RIGHT_TRIGGER, Common::kAxisTypeHalf, _s("ZR")            },
+    { "JOY_LEFT_STICK_X",  Common::JOYSTICK_AXIS_LEFT_STICK_X,  Common::kAxisTypeFull, _s("Left Stick X")  },
+    { "JOY_LEFT_STICK_Y",  Common::JOYSTICK_AXIS_LEFT_STICK_Y,  Common::kAxisTypeFull, _s("Left Stick Y")  },
+    { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") },
+    { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") },
+    { nullptr,             0,                                   Common::kAxisTypeFull, nullptr             }
+};
 
 void OSystem_Switch::init() {
 	
@@ -157,7 +164,7 @@ Common::HardwareInputSet *OSystem_Switch::getHardwareInputSet() {
 	// Users may use USB / bluetooth mice and keyboards
 	inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
 	inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
-	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(switchJoystickButtons));
+	inputSet->addHardwareInputSet(new JoystickHardwareInputSet(switchJoystickButtons, switchJoystickAxes));
 
 	return inputSet;
-}
\ No newline at end of file
+}
diff --git a/common/events.h b/common/events.h
index 0221a98..80a109c 100644
--- a/common/events.h
+++ b/common/events.h
@@ -117,7 +117,7 @@ struct JoystickState {
 };
 
 /**
- *  The list named buttons available from a joystick
+ *  The list of named buttons available from a joystick
  */
 enum JoystickButton {
 	JOYSTICK_BUTTON_A,
@@ -131,8 +131,6 @@ enum JoystickButton {
 	JOYSTICK_BUTTON_RIGHT_STICK,
 	JOYSTICK_BUTTON_LEFT_SHOULDER,
 	JOYSTICK_BUTTON_RIGHT_SHOULDER,
-	JOYSTICK_BUTTON_LEFT_TRIGGER,
-	JOYSTICK_BUTTON_RIGHT_TRIGGER,
 	JOYSTICK_BUTTON_DPAD_UP,
 	JOYSTICK_BUTTON_DPAD_DOWN,
 	JOYSTICK_BUTTON_DPAD_LEFT,
@@ -140,6 +138,18 @@ enum JoystickButton {
 };
 
 /**
+ *  The list of named axes available from a joystick
+ */
+enum JoystickAxis {
+	JOYSTICK_AXIS_LEFT_STICK_X,
+	JOYSTICK_AXIS_LEFT_STICK_Y,
+	JOYSTICK_AXIS_RIGHT_STICK_X,
+	JOYSTICK_AXIS_RIGHT_STICK_Y,
+	JOYSTICK_AXIS_LEFT_TRIGGER,
+	JOYSTICK_AXIS_RIGHT_TRIGGER
+};
+
+/**
  *  The list named buttons available from a mouse
  */
 enum MouseButton {




More information about the Scummvm-git-logs mailing list