|
4 | 4 | namespace Ship {
|
5 | 5 | ControllerDefaultMappings::ControllerDefaultMappings(
|
6 | 6 | std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<KbScancode>> defaultKeyboardKeyToButtonMappings,
|
| 7 | + std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>> |
| 8 | + defaultKeyboardKeyToAxisDirectionMappings, |
7 | 9 | std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GameControllerButton>>
|
8 | 10 | defaultSDLButtonToButtonMappings,
|
9 | 11 | std::unordered_map<CONTROLLERBUTTONS_T, std::vector<std::pair<SDL_GameControllerAxis, int32_t>>>
|
10 | 12 | defaultSDLAxisDirectionToButtonMappings) {
|
11 | 13 | SetDefaultKeyboardKeyToButtonMappings(defaultKeyboardKeyToButtonMappings);
|
| 14 | + SetDefaultKeyboardKeyToAxisDirectionMappings(defaultKeyboardKeyToAxisDirectionMappings); |
12 | 15 | SetDefaultSDLButtonToButtonMappings(defaultSDLButtonToButtonMappings);
|
13 | 16 | SetDefaultSDLAxisDirectionToButtonMappings(defaultSDLAxisDirectionToButtonMappings);
|
14 | 17 | }
|
15 | 18 |
|
16 | 19 | ControllerDefaultMappings::ControllerDefaultMappings()
|
17 | 20 | : ControllerDefaultMappings(
|
18 | 21 | std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<KbScancode>>(),
|
| 22 | + std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>>(), |
19 | 23 | std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GameControllerButton>>(),
|
20 | 24 | std::unordered_map<CONTROLLERBUTTONS_T, std::vector<std::pair<SDL_GameControllerAxis, int32_t>>>()) {
|
21 | 25 | }
|
@@ -51,6 +55,25 @@ void ControllerDefaultMappings::SetDefaultKeyboardKeyToButtonMappings(
|
51 | 55 | mDefaultKeyboardKeyToButtonMappings[BTN_DRIGHT] = { KbScancode::LUS_KB_H };
|
52 | 56 | }
|
53 | 57 |
|
| 58 | +std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>> |
| 59 | +ControllerDefaultMappings::GetDefaultKeyboardKeyToAxisDirectionMappings() { |
| 60 | + return mDefaultKeyboardKeyToAxisDirectionMappings; |
| 61 | +} |
| 62 | + |
| 63 | +void ControllerDefaultMappings::SetDefaultKeyboardKeyToAxisDirectionMappings( |
| 64 | + std::unordered_map<StickIndex, std::vector<std::pair<Direction, KbScancode>>> |
| 65 | + defaultKeyboardKeyToAxisDirectionMappings) { |
| 66 | + if (!defaultKeyboardKeyToAxisDirectionMappings.empty()) { |
| 67 | + mDefaultKeyboardKeyToAxisDirectionMappings = defaultKeyboardKeyToAxisDirectionMappings; |
| 68 | + return; |
| 69 | + } |
| 70 | + |
| 71 | + mDefaultKeyboardKeyToAxisDirectionMappings[LEFT_STICK] = { { LEFT, KbScancode::LUS_KB_A }, |
| 72 | + { RIGHT, KbScancode::LUS_KB_D }, |
| 73 | + { UP, KbScancode::LUS_KB_W }, |
| 74 | + { DOWN, KbScancode::LUS_KB_S } }; |
| 75 | +} |
| 76 | + |
54 | 77 | std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<SDL_GameControllerButton>>
|
55 | 78 | ControllerDefaultMappings::GetDefaultSDLButtonToButtonMappings() {
|
56 | 79 | return mDefaultSDLButtonToButtonMappings;
|
|
0 commit comments