summaryrefslogtreecommitdiffstats
path: root/src/input_common/sdl/sdl_impl.h
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-05-16 05:48:37 +0200
committergerman77 <juangerman-13@hotmail.com>2021-05-23 01:40:53 +0200
commitea4b7226a6af157be13798b2fcc7121f66d769d8 (patch)
treed54ac17e808b12f32b7edcb84a4e800ba85eb1cd /src/input_common/sdl/sdl_impl.h
parentMerge pull request #6248 from A-w-x/intelmesa (diff)
downloadyuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.tar
yuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.tar.gz
yuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.tar.bz2
yuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.tar.lz
yuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.tar.xz
yuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.tar.zst
yuzu-ea4b7226a6af157be13798b2fcc7121f66d769d8.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/sdl/sdl_impl.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/input_common/sdl/sdl_impl.h b/src/input_common/sdl/sdl_impl.h
index 121e01913..b77afcbd8 100644
--- a/src/input_common/sdl/sdl_impl.h
+++ b/src/input_common/sdl/sdl_impl.h
@@ -9,6 +9,17 @@
#include <mutex>
#include <thread>
#include <unordered_map>
+
+// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+#include <SDL.h>
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#include "common/common_types.h"
#include "common/threadsafe_queue.h"
#include "input_common/sdl/sdl.h"
@@ -18,6 +29,11 @@ using SDL_GameController = struct _SDL_GameController;
using SDL_Joystick = struct _SDL_Joystick;
using SDL_JoystickID = s32;
+using ButtonBindings =
+ std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 17>;
+using ZButtonBindings =
+ std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>;
+
namespace InputCommon::SDL {
class SDLAnalogFactory;
@@ -66,8 +82,25 @@ private:
/// Needs to be called before SDL_QuitSubSystem.
void CloseJoysticks();
- /// Returns a custom name for specific controllers because the default name is not correct
- std::string GetControllerName(SDL_GameController* controller) const;
+ /// Returns the default button bindings list for generic controllers
+ ButtonBindings GetDefaultButtonBinding() const;
+
+ /// Returns the default button bindings list for nintendo controllers
+ ButtonBindings GetNintendoButtonBinding(const std::shared_ptr<SDLJoystick>& joystick) const;
+
+ /// Returns the button mappings from a single controller
+ ButtonMapping GetSingleControllerMapping(const std::shared_ptr<SDLJoystick>& joystick,
+ const ButtonBindings& switch_to_sdl_button,
+ const ZButtonBindings& switch_to_sdl_axis) const;
+
+ /// Returns the button mappings from two different controllers
+ ButtonMapping GetDualControllerMapping(const std::shared_ptr<SDLJoystick>& joystick,
+ const std::shared_ptr<SDLJoystick>& joystick2,
+ const ButtonBindings& switch_to_sdl_button,
+ const ZButtonBindings& switch_to_sdl_axis) const;
+
+ /// Returns true if the button is on the left joycon
+ bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const;
// Set to true if SDL supports game controller subsystem
bool has_gamecontroller = false;