Skip to content

Commit 3338ca1

Browse files
committed
AZERTY for keyboard FCE.
1 parent 618c205 commit 3338ca1

File tree

7 files changed

+333
-173
lines changed

7 files changed

+333
-173
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,8 @@ file(GLOB MAIN_SOURCES
11011101
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_CodeEntryTools.h
11021102
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp
11031103
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h
1104+
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardEntryMappings.cpp
1105+
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardEntryMappings.h
11041106
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_NumberCodeEntry.cpp
11051107
Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_NumberCodeEntry.h
11061108
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.cpp

SerialPrograms/Source/NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
1313
#include "Common/Cpp/Options/TimeDurationOption.h"
1414
#include "Common/Cpp/Options/EnumDropdownOption.h"
15+
#include "NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardEntryMappings.h"
1516

1617
namespace PokemonAutomation{
1718
namespace NintendoSwitch{
1819

1920

2021

21-
enum class KeyboardLayout{
22-
QWERTY,
23-
AZERTY
24-
};
2522
class KeyboardLayoutOption : public EnumDropdownOption<KeyboardLayout>{
2623
public:
2724
KeyboardLayoutOption();

SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp

Lines changed: 5 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.h"
1313
#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h"
1414
#include "NintendoSwitch_CodeEntryTools.h"
15+
#include "NintendoSwitch_KeyboardEntryMappings.h"
1516
#include "NintendoSwitch_KeyboardCodeEntry.h"
1617

1718
//#include <iostream>
@@ -33,7 +34,7 @@ void keyboard_enter_code(
3334
auto* keyboard = context->cast<StandardHid::Keyboard>();
3435
if (keyboard){
3536
StandardHid::KeyboardContext subcontext(context);
36-
keyboard_enter_code(console, subcontext, code, include_plus);
37+
keyboard_enter_code(console, subcontext, keyboard_layout, code, include_plus);
3738
return;
3839
}
3940

@@ -55,7 +56,7 @@ void keyboard_enter_code(
5556

5657
void keyboard_enter_code(
5758
ConsoleHandle& console, StandardHid::KeyboardContext& context,
58-
const std::string& code,
59+
KeyboardLayout keyboard_layout, const std::string& code,
5960
bool include_plus
6061
){
6162
using namespace StandardHid;
@@ -64,44 +65,7 @@ void keyboard_enter_code(
6465
Milliseconds hold = ConsoleSettings::instance().KEYBOARD_CONTROLLER_TIMINGS.HOLD;
6566
Milliseconds cool = ConsoleSettings::instance().KEYBOARD_CONTROLLER_TIMINGS.COOLDOWN;
6667

67-
static const std::map<char, KeyboardKey> MAP{
68-
{'1', KeyboardKey::KEY_1},
69-
{'2', KeyboardKey::KEY_2},
70-
{'3', KeyboardKey::KEY_3},
71-
{'4', KeyboardKey::KEY_4},
72-
{'5', KeyboardKey::KEY_5},
73-
{'6', KeyboardKey::KEY_6},
74-
{'7', KeyboardKey::KEY_7},
75-
{'8', KeyboardKey::KEY_8},
76-
{'9', KeyboardKey::KEY_9},
77-
{'0', KeyboardKey::KEY_0},
78-
79-
{'Q', KeyboardKey::KEY_Q},
80-
{'W', KeyboardKey::KEY_W},
81-
{'E', KeyboardKey::KEY_E},
82-
{'R', KeyboardKey::KEY_R},
83-
{'T', KeyboardKey::KEY_T},
84-
{'Y', KeyboardKey::KEY_Y},
85-
{'U', KeyboardKey::KEY_U},
86-
{'P', KeyboardKey::KEY_P},
87-
88-
{'A', KeyboardKey::KEY_A},
89-
{'S', KeyboardKey::KEY_S},
90-
{'D', KeyboardKey::KEY_D},
91-
{'F', KeyboardKey::KEY_F},
92-
{'G', KeyboardKey::KEY_G},
93-
{'H', KeyboardKey::KEY_H},
94-
{'J', KeyboardKey::KEY_J},
95-
{'K', KeyboardKey::KEY_K},
96-
{'L', KeyboardKey::KEY_L},
97-
98-
{'X', KeyboardKey::KEY_X},
99-
{'C', KeyboardKey::KEY_C},
100-
{'V', KeyboardKey::KEY_V},
101-
{'B', KeyboardKey::KEY_B},
102-
{'N', KeyboardKey::KEY_N},
103-
{'M', KeyboardKey::KEY_M},
104-
};
68+
const std::map<char, KeyboardKey>& MAP = KEYBOARD_MAPPINGS(keyboard_layout);
10569

10670
for (char ch : code){
10771
auto iter = MAP.find(ch);
@@ -132,102 +96,6 @@ void keyboard_enter_code(
13296

13397

13498

135-
136-
137-
138-
struct KeyboardEntryPosition{
139-
uint8_t row;
140-
uint8_t col;
141-
};
142-
143-
static const std::map<char, KeyboardEntryPosition>& KEYBOARD_POSITIONS_QWERTY(){
144-
static const std::map<char, KeyboardEntryPosition> map{
145-
{'1', {0, 0}},
146-
{'2', {0, 1}},
147-
{'3', {0, 2}},
148-
{'4', {0, 3}},
149-
{'5', {0, 4}},
150-
{'6', {0, 5}},
151-
{'7', {0, 6}},
152-
{'8', {0, 7}},
153-
{'9', {0, 8}},
154-
{'0', {0, 9}},
155-
156-
{'Q', {1, 0}},
157-
{'W', {1, 1}},
158-
{'E', {1, 2}},
159-
{'R', {1, 3}},
160-
{'T', {1, 4}},
161-
{'Y', {1, 5}},
162-
{'U', {1, 6}},
163-
{'P', {1, 9}},
164-
165-
{'A', {2, 0}},
166-
{'S', {2, 1}},
167-
{'D', {2, 2}},
168-
{'F', {2, 3}},
169-
{'G', {2, 4}},
170-
{'H', {2, 5}},
171-
{'J', {2, 6}},
172-
{'K', {2, 7}},
173-
{'L', {2, 8}},
174-
175-
{'X', {3, 1}},
176-
{'C', {3, 2}},
177-
{'V', {3, 3}},
178-
{'B', {3, 4}},
179-
{'N', {3, 5}},
180-
{'M', {3, 6}},
181-
};
182-
return map;
183-
}
184-
static const std::map<char, KeyboardEntryPosition>& KEYBOARD_POSITIONS_AZERTY(){
185-
static const std::map<char, KeyboardEntryPosition> map{
186-
{'1', {0, 0}},
187-
{'2', {0, 1}},
188-
{'3', {0, 2}},
189-
{'4', {0, 3}},
190-
{'5', {0, 4}},
191-
{'6', {0, 5}},
192-
{'7', {0, 6}},
193-
{'8', {0, 7}},
194-
{'9', {0, 8}},
195-
{'0', {0, 9}},
196-
197-
{'A', {1, 0}},
198-
{'E', {1, 2}},
199-
{'R', {1, 3}},
200-
{'T', {1, 4}},
201-
{'Y', {1, 5}},
202-
{'U', {1, 6}},
203-
{'P', {1, 9}},
204-
205-
{'Q', {2, 0}},
206-
{'S', {2, 1}},
207-
{'D', {2, 2}},
208-
{'F', {2, 3}},
209-
{'G', {2, 4}},
210-
{'H', {2, 5}},
211-
{'J', {2, 6}},
212-
{'K', {2, 7}},
213-
{'L', {2, 8}},
214-
{'M', {2, 9}},
215-
216-
{'W', {3, 0}},
217-
{'X', {3, 1}},
218-
{'C', {3, 2}},
219-
{'V', {3, 3}},
220-
{'B', {3, 4}},
221-
{'N', {3, 5}},
222-
};
223-
return map;
224-
}
225-
226-
227-
228-
229-
230-
23199
// Return the path from "source" to "destination".
232100
std::vector<CodeEntryAction> keyboard_get_path(
233101
KeyboardEntryPosition source,
@@ -374,18 +242,7 @@ void keyboard_enter_code(
374242
bool include_plus
375243
){
376244
// Calculate the coordinates.
377-
auto get_keyboard_layout = [](KeyboardLayout keyboard_layout){
378-
switch (keyboard_layout){
379-
case KeyboardLayout::QWERTY:
380-
return KEYBOARD_POSITIONS_QWERTY();
381-
case KeyboardLayout::AZERTY:
382-
return KEYBOARD_POSITIONS_AZERTY();
383-
default:
384-
return KEYBOARD_POSITIONS_QWERTY();
385-
}
386-
};
387-
388-
const std::map<char, KeyboardEntryPosition>& POSITION_MAP = get_keyboard_layout(keyboard_layout);
245+
const std::map<char, KeyboardEntryPosition>& POSITION_MAP = KEYBOARD_POSITIONS(keyboard_layout);
389246
std::vector<KeyboardEntryPosition> positions;
390247
for (char ch : code){
391248
auto iter = POSITION_MAP.find(ch);

SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void keyboard_enter_code(
2929

3030
void keyboard_enter_code(
3131
ConsoleHandle& console, StandardHid::KeyboardContext& context,
32-
const std::string& code,
32+
KeyboardLayout keyboard_layout, const std::string& code,
3333
bool include_plus
3434
);
3535
void keyboard_enter_code(

0 commit comments

Comments
 (0)