libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
ControllerDefaultMappings.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <unordered_map>
5#include <unordered_set>
6#include <vector>
7#include <SDL3/SDL.h>
9
10#ifndef CONTROLLERBUTTONS_T
11#define CONTROLLERBUTTONS_T uint16_t
12#endif
13
15
16namespace Ship {
17
26 public:
37 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<KbScancode>> defaultKeyboardKeyToButtonMappings,
38 std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>>
39 defaultKeyboardKeyToAxisDirectionMappings,
40 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GamepadButton>> defaultSDLButtonToButtonMappings,
41 std::unordered_map<StickIndex, std::vector<std::pair<Direction, SDL_GamepadButton>>>
42 defaultSDLButtonToAxisDirectionMappings,
43 std::unordered_map<CONTROLLERBUTTONS_T, std::vector<std::pair<SDL_GamepadAxis, int32_t>>>
44 defaultSDLAxisDirectionToButtonMappings,
45 std::unordered_map<StickIndex, std::vector<std::pair<Direction, std::pair<SDL_GamepadAxis, int32_t>>>>
46 defaultSDLAxisDirectionToAxisDirectionMappings);
47
51
56 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<KbScancode>> GetDefaultKeyboardKeyToButtonMappings();
57
62 std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>>
64
69 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GamepadButton>>
71
76 std::unordered_map<StickIndex, std::vector<std::pair<Direction, SDL_GamepadButton>>>
78
83 std::unordered_map<CONTROLLERBUTTONS_T, std::vector<std::pair<SDL_GamepadAxis, int32_t>>>
85
90 std::unordered_map<StickIndex, std::vector<std::pair<Direction, std::pair<SDL_GamepadAxis, int32_t>>>>
92
93 protected:
99 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<KbScancode>> defaultKeyboardKeyToButtonMappings);
100
106 std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>>
107 defaultKeyboardKeyToAxisDirectionMappings);
108
113 virtual void
114 SetDefaultSDLButtonToButtonMappings(std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GamepadButton>>
115 defaultSDLButtonToButtonMappings);
116
122 std::unordered_map<StickIndex, std::vector<std::pair<Direction, SDL_GamepadButton>>>
123 defaultSDLButtonToAxisDirectionMappings);
124
130 std::unordered_map<CONTROLLERBUTTONS_T, std::vector<std::pair<SDL_GamepadAxis, int32_t>>>
131 defaultSDLAxisDirectionToButtonMappings);
132
138 std::unordered_map<StickIndex, std::vector<std::pair<Direction, std::pair<SDL_GamepadAxis, int32_t>>>>
139 defaultSDLAxisDirectionToAxisDirectionMappings);
140
141 private:
142 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<KbScancode>> mDefaultKeyboardKeyToButtonMappings;
143 std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>>
144 mDefaultKeyboardKeyToAxisDirectionMappings;
145 std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GamepadButton>> mDefaultSDLButtonToButtonMappings;
146 std::unordered_map<StickIndex, std::vector<std::pair<Direction, SDL_GamepadButton>>>
147 mDefaultSDLButtonToAxisDirectionMappings;
148 std::unordered_map<CONTROLLERBUTTONS_T, std::vector<std::pair<SDL_GamepadAxis, int32_t>>>
149 mDefaultSDLAxisDirectionToButtonMappings;
150 std::unordered_map<StickIndex, std::vector<std::pair<Direction, std::pair<SDL_GamepadAxis, int32_t>>>>
151 mDefaultSDLAxisDirectionToAxisDirectionMappings;
152};
153} // namespace Ship
#define CONTROLLERBUTTONS_T
Definition ControllerButtonMapping.h:13
Holds the default input-to-button and input-to-axis mappings for a controller.
Definition ControllerDefaultMappings.h:25
ControllerDefaultMappings(std::unordered_map< CONTROLLERBUTTONS_T, std::unordered_set< KbScancode > > defaultKeyboardKeyToButtonMappings, std::unordered_map< StickIndex, std::vector< std::pair< Direction, KbScancode > > > defaultKeyboardKeyToAxisDirectionMappings, std::unordered_map< CONTROLLERBUTTONS_T, std::unordered_set< SDL_GamepadButton > > defaultSDLButtonToButtonMappings, std::unordered_map< StickIndex, std::vector< std::pair< Direction, SDL_GamepadButton > > > defaultSDLButtonToAxisDirectionMappings, std::unordered_map< CONTROLLERBUTTONS_T, std::vector< std::pair< SDL_GamepadAxis, int32_t > > > defaultSDLAxisDirectionToButtonMappings, std::unordered_map< StickIndex, std::vector< std::pair< Direction, std::pair< SDL_GamepadAxis, int32_t > > > > defaultSDLAxisDirectionToAxisDirectionMappings)
Constructs a ControllerDefaultMappings with fully specified default tables.
std::unordered_map< CONTROLLERBUTTONS_T, std::unordered_set< SDL_GamepadButton > > GetDefaultSDLButtonToButtonMappings()
Returns the default SDL-button-to-button mappings.
virtual void SetDefaultSDLButtonToButtonMappings(std::unordered_map< CONTROLLERBUTTONS_T, std::unordered_set< SDL_GamepadButton > > defaultSDLButtonToButtonMappings)
Replaces the default SDL-button-to-button mappings.
std::unordered_map< StickIndex, std::vector< std::pair< Direction, KbScancode > > > GetDefaultKeyboardKeyToAxisDirectionMappings()
Returns the default keyboard-key-to-axis-direction mappings.
std::unordered_map< CONTROLLERBUTTONS_T, std::unordered_set< KbScancode > > GetDefaultKeyboardKeyToButtonMappings()
Returns the default keyboard-key-to-button mappings.
virtual void SetDefaultKeyboardKeyToAxisDirectionMappings(std::unordered_map< StickIndex, std::vector< std::pair< Direction, KbScancode > > > defaultKeyboardKeyToAxisDirectionMappings)
Replaces the default keyboard-key-to-axis-direction mappings.
ControllerDefaultMappings()
Constructs a ControllerDefaultMappings with empty default tables.
virtual void SetDefaultKeyboardKeyToButtonMappings(std::unordered_map< CONTROLLERBUTTONS_T, std::unordered_set< KbScancode > > defaultKeyboardKeyToButtonMappings)
Replaces the default keyboard-key-to-button mappings.
std::unordered_map< CONTROLLERBUTTONS_T, std::vector< std::pair< SDL_GamepadAxis, int32_t > > > GetDefaultSDLAxisDirectionToButtonMappings()
Returns the default SDL-axis-direction-to-button mappings.
virtual void SetDefaultSDLButtonToAxisDirectionMappings(std::unordered_map< StickIndex, std::vector< std::pair< Direction, SDL_GamepadButton > > > defaultSDLButtonToAxisDirectionMappings)
Replaces the default SDL-button-to-axis-direction mappings.
std::unordered_map< StickIndex, std::vector< std::pair< Direction, SDL_GamepadButton > > > GetDefaultSDLButtonToAxisDirectionMappings()
Returns the default SDL-button-to-axis-direction mappings.
virtual void SetDefaultSDLAxisDirectionToAxisDirectionMappings(std::unordered_map< StickIndex, std::vector< std::pair< Direction, std::pair< SDL_GamepadAxis, int32_t > > > > defaultSDLAxisDirectionToAxisDirectionMappings)
Replaces the default SDL-axis-direction-to-axis-direction mappings.
std::unordered_map< StickIndex, std::vector< std::pair< Direction, std::pair< SDL_GamepadAxis, int32_t > > > > GetDefaultSDLAxisDirectionToAxisDirectionMappings()
Returns the default SDL-axis-direction-to-axis-direction mappings.
virtual void SetDefaultSDLAxisDirectionToButtonMappings(std::unordered_map< CONTROLLERBUTTONS_T, std::vector< std::pair< SDL_GamepadAxis, int32_t > > > defaultSDLAxisDirectionToButtonMappings)
Replaces the default SDL-axis-direction-to-button mappings.
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
Direction
Identifies the direction component of an axis mapping.
Definition ControllerAxisDirectionMapping.h:18
StickIndex
Identifies which analog stick an axis mapping applies to.
Definition ControllerAxisDirectionMapping.h:15