@@ -516,10 +516,21 @@ void setupRaceStart()
516
516
517
517
InputDevice *device;
518
518
519
- // Use keyboard 0 by default in --no-start-screen
520
- device = input_manager->getDeviceManager ()->getKeyboard (0 );
519
+ // Assign the player a device; check the command line params for preferences; by default use keyboard 0
521
520
522
- // Create player and associate player with keyboard
521
+ if (UserConfigParams::m_default_keyboard > -1 ) {
522
+ device = input_manager->getDeviceManager ()->getKeyboard (UserConfigParams::m_default_keyboard);
523
+ }
524
+ else if (UserConfigParams::m_default_gamepad > -1 ) {
525
+ // getGamePad(int) returns a GamePadDevice which is a subclass of InputDevice
526
+ // However, the compiler doesn't like it so it has to be manually casted in
527
+ device = (InputDevice *) input_manager->getDeviceManager ()->getGamePad (UserConfigParams::m_default_gamepad);
528
+ }
529
+ else {
530
+ device = input_manager->getDeviceManager ()->getKeyboard (0 );
531
+ }
532
+
533
+ // Create player and associate player with device
523
534
StateManager::get ()->createActivePlayer (
524
535
PlayerManager::get ()->getPlayer (0 ), device);
525
536
@@ -557,10 +568,14 @@ void cmdLineHelp()
557
568
" menu.\n "
558
569
" -R, --race-now Same as -N but also skip the ready-set-go phase"
559
570
" and the music.\n "
571
+ " --use-keyboard=N Used in conjunction with the -N or -R option, will assign the player to the specified"
572
+ " keyboard. Is zero indexed.\n "
573
+ " --use-gamepad=N Used in conjunction with the -N or -R option, will assign the player to the specified"
574
+ " gamepad. Is zero indexed.\n "
560
575
" -t, --track=NAME Start track NAME.\n "
561
576
" --gp=NAME Start the specified Grand Prix.\n "
562
- " --add-gp-dir=DIR Load Grand Prix files in DIR. Setting will be saved\n "
563
- " in config.xml under additional_gp_directory. Use\n "
577
+ " --add-gp-dir=DIR Load Grand Prix files in DIR. Setting will be saved"
578
+ " in config.xml under additional_gp_directory. Use"
564
579
" --add-gp-dir=\"\" to unset.\n "
565
580
" --stk-config=FILE use ./data/FILE instead of "
566
581
" ./data/stk_config.xml\n "
@@ -1675,6 +1690,14 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
1675
1690
UserConfigParams::m_race_now = true ;
1676
1691
} // --race-now
1677
1692
1693
+ if (CommandLine::has ( " --use-keyboard" ,&n)) {
1694
+ UserConfigParams::m_default_keyboard = n;
1695
+ } // --use-keyboard
1696
+
1697
+ if (CommandLine::has ( " --use-gamepad" ,&n)) {
1698
+ UserConfigParams::m_default_gamepad = n;
1699
+ } // --use-gamepad
1700
+
1678
1701
if (CommandLine::has (" --laps" , &s))
1679
1702
{
1680
1703
int laps = atoi (s.c_str ());
0 commit comments