@@ -178,6 +178,8 @@ ControllerSettingsRow::ControllerSettingsRow(EditableTableOption& parent_table)
178178 add_option (right_grip, " Right Grip" );
179179 add_option (official_color, " Official Color" );
180180
181+ set_profile (ControllerSettingsTable::random_profile (controller));
182+
181183 controller.add_listener (*this );
182184#if 1
183185 button_color.add_listener (*this );
@@ -268,6 +270,19 @@ std::vector<std::string> ControllerSettingsTable::make_header() const{
268270}
269271
270272
273+
274+ ControllerProfile ControllerSettingsTable::random_profile (ControllerType controller){
275+ const std::vector<OfficialJoyconColors>& DATABASE = OFFICIAL_JOYCON_COLORS ();
276+
277+ ControllerProfile profile;
278+
279+ uint64_t seed = std::chrono::high_resolution_clock::now ().time_since_epoch ().count ();
280+ seed = pabb_crc32 (0 , &seed, sizeof (seed));
281+ seed %= DATABASE.size ();
282+
283+ DATABASE[(size_t )seed].write_to_profile (profile, controller);
284+ return profile;
285+ }
271286ControllerProfile ControllerSettingsTable::get_or_make_profile (
272287 const std::string& name,
273288 ControllerType controller
@@ -305,13 +320,7 @@ ControllerProfile ControllerSettingsTable::get_or_make_profile(
305320 return profile;
306321 }
307322
308- const std::vector<OfficialJoyconColors>& DATABASE = OFFICIAL_JOYCON_COLORS ();
309-
310- uint64_t seed = std::chrono::high_resolution_clock::now ().time_since_epoch ().count ();
311- seed = pabb_crc32 (0 , &seed, sizeof (seed));
312- seed %= DATABASE.size ();
313-
314- DATABASE[(size_t )seed].write_to_profile (profile, controller);
323+ profile = random_profile (controller);
315324
316325 std::unique_ptr<ControllerSettingsRow> row (new ControllerSettingsRow (*this ));
317326 row->name .set (name);
0 commit comments