@@ -28,14 +28,38 @@ uint32_t average_colors(uint32_t x, uint32_t y){
2828}
2929
3030
31- struct OfficialJoyconColors {
31+
32+ struct ControllerColors {
3233 std::string name;
34+
35+ ControllerColors (std::string p_name)
36+ : name(std::move(p_name))
37+ {}
38+ virtual ~ControllerColors () = default ;
39+ virtual void write_to_profile (ControllerProfile& profile, ControllerType controller) const = 0;
40+ };
41+
42+ struct JoyconColors : public ControllerColors {
3343 uint32_t left_body;
3444 uint32_t left_buttons;
3545 uint32_t right_body;
3646 uint32_t right_buttons;
3747
38- void write_to_profile (ControllerProfile& profile, ControllerType controller) const {
48+ JoyconColors (
49+ std::string p_name,
50+ uint32_t p_left_body,
51+ uint32_t p_left_button,
52+ uint32_t p_right_body,
53+ uint32_t p_right_buttons
54+ )
55+ : ControllerColors(std::move(p_name))
56+ , left_body(p_left_body)
57+ , left_buttons(p_left_button)
58+ , right_body(p_right_body)
59+ , right_buttons(p_right_buttons)
60+ {}
61+
62+ virtual void write_to_profile (ControllerProfile& profile, ControllerType controller) const override {
3963 profile.official_name = name;
4064 switch (controller){
4165 case ControllerType::NintendoSwitch_WirelessProController:{
@@ -56,13 +80,55 @@ struct OfficialJoyconColors{
5680 break ;
5781 default :;
5882 }
59-
83+ }
84+ };
85+ struct ProconColors : public ControllerColors {
86+ uint32_t left_grip;
87+ uint32_t right_grip;
88+ uint32_t body;
89+ uint32_t buttons;
90+
91+ ProconColors (
92+ std::string p_name,
93+ uint32_t p_left_grip,
94+ uint32_t p_right_grip,
95+ uint32_t p_body,
96+ uint32_t p_buttons
97+ )
98+ : ControllerColors(std::move(p_name))
99+ , left_grip(p_left_grip)
100+ , right_grip(p_right_grip)
101+ , body(p_body)
102+ , buttons(p_buttons)
103+ {}
104+
105+ virtual void write_to_profile (ControllerProfile& profile, ControllerType controller) const override {
106+ profile.official_name = name;
107+ switch (controller){
108+ case ControllerType::NintendoSwitch_WirelessProController:{
109+ // Set the grips to the joycon colors.
110+ profile.left_grip = left_grip;
111+ profile.right_grip = right_grip;
112+ profile.body_color = body;
113+ profile.button_color = buttons;
114+ break ;
115+ }
116+ case ControllerType::NintendoSwitch_LeftJoycon:
117+ profile.button_color = buttons;
118+ profile.body_color = left_grip;
119+ break ;
120+ case ControllerType::NintendoSwitch_RightJoycon:
121+ profile.button_color = buttons;
122+ profile.body_color = right_grip;
123+ break ;
124+ default :;
125+ }
60126 }
61127};
62128
63- const std::vector<OfficialJoyconColors >& OFFICIAL_JOYCON_COLORS (){
129+ const std::vector<JoyconColors >& OFFICIAL_JOYCON_COLORS0 (){
64130 // From: https://switchbrew.org/wiki/Joy-Con#Colors
65- const static std::vector<OfficialJoyconColors > database{
131+ const static std::vector<JoyconColors > database{
66132 {" Developer Black" , 0x313131 , 0x0F0F0F , 0x313131 , 0x0F0F0F },
67133
68134 {" Stock: Grey / Grey" , 0x828282 , 0x0F0F0F , 0x828282 , 0x0F0F0F },
@@ -94,20 +160,51 @@ const std::vector<OfficialJoyconColors>& OFFICIAL_JOYCON_COLORS(){
94160 };
95161 return database;
96162}
163+ const std::vector<ProconColors>& OFFICIAL_PROCON_COLORS0 (){
164+ // From: https://gbatemp.net/threads/people-with-special-edition-pro-controllers-i-need-your-help-with-colors.627413/
165+ const static std::vector<ProconColors> database{
166+ {" Procon: Stock Black" , 0x323232 , 0x323232 , 0x323232 , 0xFFFFFF },
167+ {" Procon: Super Smash Bros. Ultimate" , 0xFFFFFF , 0xFFFFFF , 0x2D2D2D , 0xE6E6E6 },
168+ {" Procon: Zelda Tears of the Kingdom" , 0x464646 , 0xFFFFFF , 0x2D2D2D , 0xE6E6E6 },
169+ // {"Procon: Xenoblade Chronicles 2", 0xFFFFFF, 0xFFFFFF, 0x323132, 0xFFFFFF}, // The actual values. Switch automatically replaces grips with pink.
170+ {" Procon: Xenoblade Chronicles 2" , 0xff3a66 , 0xff3a66 , 0x323132 , 0xFFFFFF }, // Grip color is a guess.
171+ {" Procon: Splatoon 2" , 0x1EDC00 , 0xFF3278 , 0x2D2D2D , 0xE6E6E6 }, // This is just a guess.
172+ {" Procon: Splatoon 3" , 0x6455F5 , 0xC3FA05 , 0x2D2D2D , 0xE6E6E6 },
173+ };
174+ return database;
175+ }
176+ std::vector<const ControllerColors*> make_OFFICIAL_CONTROLLER_COLORS (){
177+ std::vector<const ControllerColors*> ret;
178+ for (const JoyconColors& item : OFFICIAL_JOYCON_COLORS0 ()){
179+ ret.emplace_back (&item);
180+ }
181+ for (const ProconColors& item : OFFICIAL_PROCON_COLORS0 ()){
182+ ret.emplace_back (&item);
183+ }
184+ return ret;
185+ }
186+ const std::vector<const ControllerColors*> OFFICIAL_CONTROLLER_COLORS (){
187+ static const std::vector<const ControllerColors*> database = make_OFFICIAL_CONTROLLER_COLORS ();
188+ return database;
189+ }
97190
98-
99- StringSelectDatabase make_JOYCON_DATABASE (){
191+ StringSelectDatabase make_CONTROLLER_DATABASE (){
100192 StringSelectDatabase database;
101193 database.add_entry (StringSelectEntry (" Custom" , " Custom" ));
102- for (const OfficialJoyconColors& item : OFFICIAL_JOYCON_COLORS ()){
194+ for (const JoyconColors& item : OFFICIAL_JOYCON_COLORS0 ()){
195+ database.add_entry (
196+ StringSelectEntry (item.name , item.name )
197+ );
198+ }
199+ for (const ProconColors& item : OFFICIAL_PROCON_COLORS0 ()){
103200 database.add_entry (
104201 StringSelectEntry (item.name , item.name )
105202 );
106203 }
107204 return database;
108205}
109- const StringSelectDatabase& JOYCON_DATABASE (){
110- static const StringSelectDatabase database = make_JOYCON_DATABASE ();
206+ const StringSelectDatabase& CONTROLLER_DATABASE (){
207+ static const StringSelectDatabase database = make_CONTROLLER_DATABASE ();
111208 return database;
112209}
113210
@@ -166,7 +263,7 @@ ControllerSettingsRow::ControllerSettingsRow(EditableTableOption& parent_table)
166263 0x96F5F5 , 0x96F5F5
167264 )
168265 , official_color(
169- JOYCON_DATABASE (),
266+ CONTROLLER_DATABASE (),
170267 LockMode::UNLOCK_WHILE_RUNNING,
171268 0
172269 )
@@ -240,7 +337,7 @@ void ControllerSettingsRow::on_config_value_changed(void* object){
240337 m_pending_official_load++;
241338
242339 ControllerProfile profile{};
243- OFFICIAL_JOYCON_COLORS ()[index - 1 ]. write_to_profile (profile, controller);
340+ OFFICIAL_CONTROLLER_COLORS ()[index - 1 ]-> write_to_profile (profile, controller);
244341 this ->set_profile (profile);
245342
246343 m_pending_official_load--;
@@ -277,15 +374,15 @@ std::vector<std::string> ControllerSettingsTable::make_header() const{
277374
278375
279376ControllerProfile ControllerSettingsTable::random_profile (ControllerType controller){
280- const std::vector<OfficialJoyconColors >& DATABASE = OFFICIAL_JOYCON_COLORS ();
377+ const std::vector<const ControllerColors* >& DATABASE = OFFICIAL_CONTROLLER_COLORS ();
281378
282379 ControllerProfile profile;
283380
284381 uint64_t seed = std::chrono::high_resolution_clock::now ().time_since_epoch ().count ();
285382 seed = pabb_crc32 (0 , &seed, sizeof (seed));
286383 seed %= DATABASE.size ();
287384
288- DATABASE[(size_t )seed]. write_to_profile (profile, controller);
385+ DATABASE[(size_t )seed]-> write_to_profile (profile, controller);
289386 return profile;
290387}
291388ControllerProfile ControllerSettingsTable::get_or_make_profile (
0 commit comments