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

Add Controller Input #110

Merged
merged 4 commits into from
Aug 29, 2021
Merged

Conversation

HaSa1002
Copy link
Member

@HaSa1002 HaSa1002 commented Aug 28, 2021

I also did some refactoring. For example, you can shorten TranslationServer.translate()to tr(), use _unhandled_input_event instead of _process to process input actions, and use GDScript format strings, to build strings.

THe change itself:
I added bindings for controllers (the easy part) and a new class called InputLabel that changes the input based on the device and supplied action. In order to insert any control into the translations they need to use format strings as well. Luckily %s converts anything that can be casted to a string (which is everything).

The detection of the used controller is incomplete, so everytime somebody reports a new GUID, it has to be added or we go and grab a SDL controller DB dumb an integrate that or we add a Godot Method with the most common gamepad types.

Lastly we should implement input settings. It should be relativly easy now, but I wanted to finish this PR to get into bed and back to my primary work. Please review carefully, as I had to a rebase way to late in the night.

Fixes #105

@Jean28518
Copy link
Member

Thanks for your pull request!
But you messed up the controls over keyboard..
Sorry, please fix that.

Comment on lines -405 to +414
if Input.is_action_pressed("ui_up"):
if Input.is_action_pressed("acc+"):
soll_command += 0.7 * delta
if Input.is_action_pressed("ui_down"):
if Input.is_action_pressed("acc-"):
soll_command -= 0.7 * delta
if soll_command >= 1:
soll_command = 1
if soll_command <= -1:
soll_command = -1
if Input.is_action_pressed("ui_left"):
if Input.is_action_pressed("brake-"):
soll_command = 0
if Input.is_action_pressed("ui_right"):
if Input.is_action_pressed("brake+"):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that one?
The behaviour is the same

@Jean28518
Copy link
Member

Just drive the tutorial track on this branch with Easy Mode and arrow keys...
That doesn't work anymore.

WASD Steering is also different to the version of master branch...

@HaSa1002
Copy link
Member Author

I fixed the arrow key steering. Maybe I am blind, but how is WASD steering different? Are the acceleration or break axis inversed?

@Jean28518 Jean28518 merged commit b2bc169 into Libre-TrainSim:master Aug 29, 2021
@HaSa1002
Copy link
Member Author

Your last commit removed WASD controls completly. Was that planned?

@Jean28518
Copy link
Member

Yes, that was planned :)

@HaSa1002 HaSa1002 deleted the controller-input-2 branch October 30, 2021 12:14
@nalquas nalquas added ux Usability and Expierience issues. enhancement New feature or request labels Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ux Usability and Expierience issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add controller support
3 participants