-
Notifications
You must be signed in to change notification settings - Fork 251
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
Support controller analog triggers #600
Open
Lgt2x
wants to merge
12
commits into
DescentDevelopers:main
Choose a base branch
from
Lgt2x:analog-triggers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ca89b4d
Report bidirectional axis and triggers separately
Lgt2x 47be84b
Forward axis trigger information to sdlcontroller.cpp
Lgt2x c8987c8
Don't allow mapping trigger axis to 2-directional controls
Lgt2x a95988d
Factorize get_controller_value for axis inputs
Lgt2x f9098b9
Support mapping controller analog triggers to buttons
Lgt2x e17871d
Read trigger analog value in the SDL adapter
Lgt2x 0d848ec
Make button for direction control analog
Lgt2x 09dc2ac
Read properly trigger analog value
Lgt2x e71e0d4
Unset default axis mappings that are analog triggers
Lgt2x 8879f62
POV: return analog value the same as digital
Lgt2x f8a06f7
Remove extra debug
Lgt2x deb9749
Replace C 'fabs' by 'std::abs'
Lgt2x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Descent 3 | ||
* Descent 3 | ||
* Copyright (C) 2024 Parallax Software | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -879,25 +879,25 @@ void DoControllerMovement(game_controls *controls) { | |
ct_packet ctl_pub, ctl_pdb, ctl_hlb, ctl_hrb, ctl_blb, ctl_brb; | ||
|
||
// read controls | ||
Controller->get_packet(ctfFORWARD_THRUSTAXIS, &ctl_z); | ||
Controller->get_packet(ctfUP_THRUSTAXIS, &ctl_y); | ||
Controller->get_packet(ctfRIGHT_THRUSTAXIS, &ctl_x); | ||
Controller->get_packet(ctfPITCH_DOWNAXIS, &ctl_p); | ||
Controller->get_packet(ctfBANK_RIGHTAXIS, &ctl_b); | ||
Controller->get_packet(ctfHEADING_RIGHTAXIS, &ctl_h); | ||
Controller->get_packet(ctfUP_BUTTON, &ctl_povu); | ||
Controller->get_packet(ctfDOWN_BUTTON, &ctl_povd); | ||
Controller->get_packet(ctfRIGHT_BUTTON, &ctl_povr); | ||
Controller->get_packet(ctfLEFT_BUTTON, &ctl_povl); | ||
Controller->get_packet(ctfFORWARD_BUTTON, &ctl_fb); | ||
Controller->get_packet(ctfREVERSE_BUTTON, &ctl_rb); | ||
Controller->get_packet(ctfAFTERBURN_BUTTON, &ctl_afterburn); | ||
Controller->get_packet(ctfHEADING_LEFTBUTTON, &ctl_hlb); | ||
Controller->get_packet(ctfHEADING_RIGHTBUTTON, &ctl_hrb); | ||
Controller->get_packet(ctfPITCH_UPBUTTON, &ctl_pub); | ||
Controller->get_packet(ctfPITCH_DOWNBUTTON, &ctl_pdb); | ||
Controller->get_packet(ctfBANK_LEFTBUTTON, &ctl_blb); | ||
Controller->get_packet(ctfBANK_RIGHTBUTTON, &ctl_brb); | ||
Controller->get_packet(ctfFORWARD_THRUSTAXIS, &ctl_z, ctAnalog); | ||
Controller->get_packet(ctfUP_THRUSTAXIS, &ctl_y, ctAnalog); | ||
Controller->get_packet(ctfRIGHT_THRUSTAXIS, &ctl_x, ctAnalog); | ||
Controller->get_packet(ctfPITCH_DOWNAXIS, &ctl_p, ctAnalog); | ||
Controller->get_packet(ctfBANK_RIGHTAXIS, &ctl_b, ctAnalog); | ||
Controller->get_packet(ctfHEADING_RIGHTAXIS, &ctl_h, ctAnalog); | ||
Controller->get_packet(ctfUP_BUTTON, &ctl_povu, ctAnalog); | ||
Controller->get_packet(ctfDOWN_BUTTON, &ctl_povd, ctAnalog); | ||
Controller->get_packet(ctfRIGHT_BUTTON, &ctl_povr, ctAnalog); | ||
Controller->get_packet(ctfLEFT_BUTTON, &ctl_povl, ctAnalog); | ||
Controller->get_packet(ctfFORWARD_BUTTON, &ctl_fb, ctAnalog); | ||
Controller->get_packet(ctfREVERSE_BUTTON, &ctl_rb, ctAnalog); | ||
Controller->get_packet(ctfAFTERBURN_BUTTON, &ctl_afterburn, ctAnalog); | ||
Controller->get_packet(ctfHEADING_LEFTBUTTON, &ctl_hlb, ctAnalog); | ||
Controller->get_packet(ctfHEADING_RIGHTBUTTON, &ctl_hrb, ctAnalog); | ||
Controller->get_packet(ctfPITCH_UPBUTTON, &ctl_pub, ctAnalog); | ||
Controller->get_packet(ctfPITCH_DOWNBUTTON, &ctl_pdb, ctAnalog); | ||
Controller->get_packet(ctfBANK_LEFTBUTTON, &ctl_blb, ctAnalog); | ||
Controller->get_packet(ctfBANK_RIGHTBUTTON, &ctl_brb, ctAnalog); | ||
|
||
// do x and y thrust | ||
controls->sideways_thrust += ctl_x.value; | ||
|
@@ -935,40 +935,40 @@ void DoControllerMovement(game_controls *controls) { | |
} | ||
|
||
// do button heading | ||
if (ctl_hlb.value) | ||
controls->heading_thrust += (-1.0f); | ||
if (ctl_hrb.value) | ||
controls->heading_thrust += (1.0f); | ||
if (ctl_hlb.value > 0.0f) | ||
controls->heading_thrust += ctl_hlb.value; | ||
if (ctl_hrb.value > 0.0f) | ||
controls->heading_thrust -= ctl_hlb.value; | ||
|
||
// do button pitch | ||
if (ctl_pub.value) | ||
controls->pitch_thrust += (-1.0f); | ||
if (ctl_pdb.value) | ||
controls->pitch_thrust += (1.0f); | ||
if (ctl_pub.value > 0.0f) | ||
controls->pitch_thrust -= ctl_pub.value; | ||
if (ctl_pdb.value > 0.0f) | ||
controls->pitch_thrust += ctl_pdb.value; | ||
|
||
// do forward thrust based off of button values. | ||
controls->forward_thrust += ((ctl_fb.value - ctl_rb.value) / Frametime); | ||
|
||
// do button banking | ||
if (ctl_blb.value) | ||
controls->bank_thrust += (1.0f); | ||
if (ctl_brb.value) | ||
controls->bank_thrust += (-1.0f); | ||
if (ctl_blb.value > 0.0f) | ||
controls->bank_thrust += ctl_blb.value; | ||
if (ctl_brb.value > 0.0f) | ||
controls->bank_thrust -= ctl_blb.value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for |
||
|
||
// do button sliding. use control frametime to set sliding times per frame. | ||
// note that vertical and sideways thrusts are dependent on what the keyboard controller | ||
// set these values to. so we save our own slidetimes. | ||
if (ctl_povu.value) { | ||
controls->vertical_thrust += (1.0f); | ||
if (ctl_povu.value > 0.0f) { | ||
controls->vertical_thrust += ctl_povu.value; | ||
} | ||
if (ctl_povd.value) { | ||
controls->vertical_thrust -= (1.0f); | ||
if (ctl_povd.value > 0.0f) { | ||
controls->vertical_thrust -= ctl_povd.value; | ||
} | ||
if (ctl_povr.value) { | ||
controls->sideways_thrust += (1.0f); | ||
if (ctl_povr.value > 0.0f) { | ||
controls->sideways_thrust += ctl_povr.value; | ||
} | ||
if (ctl_povl.value) { | ||
controls->sideways_thrust -= (1.0f); | ||
if (ctl_povl.value > 0.0f) { | ||
controls->sideways_thrust -= ctl_povl.value; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a copy-paste error? Shouldn't it be
-= ctl_hrb.value
?