Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When launching the game via "-N" (command line) can't use gamepad #5213

Open
DesiOtaku opened this issue Nov 20, 2024 · 8 comments
Open

When launching the game via "-N" (command line) can't use gamepad #5213

DesiOtaku opened this issue Nov 20, 2024 · 8 comments

Comments

@DesiOtaku
Copy link
Contributor

Description

So I want to set up a "kiosk" style computer to play SuperTuxKart where the game skips the setup and goes to a race. Best way to do that right now is to launch the game using the arguments "-N" or "-R". It works mostly as expected but by default it will always use the keyboard instead of the gamepad. This happens no matter what I do in the controls config or even editing "input.xml".

Steps to reproduce

  • Play a game of SuperTuxKart using a controller
  • Notice how it will use it by default
  • Launch the game using "-N"
  • Notice that it will only allow keyboard input

Configuration

STK release version: 1.4
STK Source (PPA, distribution package, official binary, etc.): Ubuntu 22.04

System: amd64

Graphics card: AMD

CPU: Ryzen

Gamepads/keyboards models if related to the issue:
Regular keyboard
PS4 controller (via bluetooth)
XBox controllers are effected as well)

Additional information

input.xml:

<input version="1">

<!--
Event 1 : Keyboard button press
    'id' indicates which button, as defined by irrlicht's EKEY_CODE enum
Event 2 : Gamepad stick motion
    'id' indicates which stick, starting from 0
    'direction' 0 means negative, 1 means positive
Event 3 : Gamepad button press
    'id' indicates which button, starting from 0
-->

<keyboard enabled="true" configName="">
     <action name="steerLeft" event="1" id="37" />
    <action name="steerRight" event="1" id="39" />
    <action name="accel" event="1" id="38" />
    <action name="brake" event="1" id="40" />
    <action name="nitro" event="1" id="78" />
    <action name="drift" event="1" id="86" />
    <action name="rescue" event="1" id="8" />
    <action name="fire" event="1" id="32" />
    <action name="lookBack" event="1" id="66" />
    <action name="pauserace" event="1" id="27" />
    <action name="menuUp" event="1" id="38" />
    <action name="menuDown" event="1" id="40" />
    <action name="menuLeft" event="1" id="37" />
    <action name="menuRight" event="1" id="39" />
    <action name="menuSelect" event="1" id="13" />
    <action name="menuCancel" event="1" id="27" />
</keyboard>

<gamepad name ="PS4 Controller" deadzone="4096" desensitize="0" auto-center="20" force-feedback="1" enabled="true" configName="">
     <action name="steerLeft" event="2" id="0" direction="0" range="0" />
    <action name="steerRight" event="2" id="0" direction="1" range="0" />
    <action name="accel" event="3" id="3" />
    <action name="brake" event="3" id="2" />
    <action name="nitro" event="3" id="9" />
    <action name="drift" event="3" id="10" />
    <action name="rescue" event="3" id="4" />
    <action name="fire" event="3" id="1" />
    <action name="lookBack" event="3" id="0" />
    <action name="pauserace" event="3" id="6" />
    <action name="menuUp" event="2" id="1" direction="0" range="0" />
    <action name="menuDown" event="2" id="1" direction="1" range="0" />
    <action name="menuLeft" event="2" id="0" direction="0" range="0" />
    <action name="menuRight" event="2" id="0" direction="1" range="0" />
    <action name="menuSelect" event="3" id="0" />
    <action name="menuCancel" event="3" id="1" />
</gamepad>

</input>

@DesiOtaku
Copy link
Contributor Author

DesiOtaku commented Nov 20, 2024

Really, the source of the issue is this line:

device = input_manager->getDeviceManager()->getKeyboard(0);

It hard codes to use the keyboard no matter what.

A way around this for now is to once again hard code it to:

device = input_manager->getDeviceManager()->getGamePad(0);

@Alayan-stk-2
Copy link
Collaborator

The main purpose of the quick-start is to speed up testing during development of code or tracks, a use case for which the limitation is not very important.

The quick-start code doesn't prevent later going back to the main menu and accessing all the other parts of the game, so you'd probably want further custom change for your kiosk-style computer to work as intended.

That being said, I suppose an additional command-line parameter to pass which input device should be used in no-start-screen could be simple enough and also work for your use case?

@DesiOtaku
Copy link
Contributor Author

That being said, I suppose an additional command-line parameter to pass which input device should be used in no-start-screen could be simple enough and also work for your use case?

Yeah, I think one extra argument like --use-gamepad=N in which it will call the function input_manager->getDeviceManager()->getGamePad(N); in setupRaceStart() would make it work for me.

Technically speaking, the game should close when the race is done but that's not a major issue as of right now since we can easily relaunch the game as needed. I have no clue who else in the world besides us that are using SuperTuxKart in a kiosk like setting.

If need be, I can write the patch / merge request but if you would rather write it I am fine with that too.

@Alayan-stk-2
Copy link
Collaborator

If need be, I can write the patch / merge request but if you would rather write it I am fine with that too.

I could write it, but if you could do it that would save me some time to focus on other tickets, so that would be appreciated!

Perhaps also have a look to make the command line solution a bit more general, allowing to select keyboard configurations beyond the 1st one or input devices that are not keyboards or gamepads?

@DesiOtaku
Copy link
Contributor Author

Perhaps also have a look to make the command line solution a bit more general, allowing to select keyboard configurations beyond the 1st one or input devices that are not keyboards or gamepads?

Yeah, so I can add arguments like --use-gamepad=N and --use-keyboard=N and it should use getGamePad or getKeyboard accordingly. I can work on it later this week. I'll be adding a few more variables to UserConfigParams and then launch the game with those parameters. I'll probably also have to update the help section as well.

@DesiOtaku
Copy link
Contributor Author

Made a pull request:

#5230

@Alayan-stk-2
Copy link
Collaborator

Fixed with the above PR and the following commit: 31d3596

@Alayan-stk-2
Copy link
Collaborator

@Benau Why did you reopen this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants