Add support for getting a joypad's battery and connection information#112680
Add support for getting a joypad's battery and connection information#112680Nintorch wants to merge 1 commit intogodotengine:masterfrom
Conversation
eaee036 to
c7569a8
Compare
c7569a8 to
3c03aa1
Compare
3c03aa1 to
98019c6
Compare
|
Thank you for your review, AThousandShips! |
| The Left and Right Triggers are implemented as digital buttons and report either [code]0[/code] or [code]1[/code]. Left Stick, Right Stick, LSB, and RSB are optional. | ||
| </constant> | ||
| <constant name="JOY_DEVICE_THROTTLE" value="9" enum="JoyDeviceType"> | ||
| A throttle controller. |
There was a problem hiding this comment.
This needs more documentation too, but I'm not sure where to get it/how to make it :(
|
What should we call |
ea11c41 to
19d92da
Compare
Maybe just |
Hm, I think that's a good idea :D |
19d92da to
1f60e61
Compare
|
Thank you for your review, AThousandShips! I included your suggested changes into the code! |
|
@DanielSnd Hello, sorry for bothering you, but may I ask if you can help with Steam Deck documentation for this PR as I don't have one myself, if you're willing to do so of course? |
I'm not super sure what that means. Do I have to run some code on the steamdeck and send you the output? I could do that if that's the case. I'm not super familiar with this stuff. |
|
Sure, I can prepare a test project later! |
Sounds good then :) |
|
Here :D And I just found a web page with Steam Deck's buttons and their names, so we will use it to get more specific button names. https://steamcommunity.com/sharedfiles/filedetails/?id=2804823261&ysclid=mjy9ogdptd46361097 May I ask if you can test the project above, verify that the model name is "Steam Deck", press every button on the Steam Deck that is usable in games and save the reported names for them that are shown in "Last pressed button" label? |
0cf5de7 to
87fb44a
Compare
|
I decided to use |
987e44c to
eaae023
Compare
eaae023 to
c8347d4
Compare
c8347d4 to
e96da05
Compare
|
I might move the buttons/axes names into a separate PR, I think I have a better way to make this functionality Or it might make sense to let the developers themselves provide the buttons/axes names based on the joypad model. |
|
I was thinking about writing a proposal for this PR (specifically, for battery and connection information), but now that I think about it, these methods might not be useful for games, since I currently can't find an example of games that use those and I currently can't think of a good reason to use those in a game, in which case I might remove these features from this PR (unless we can find a good reason for them to exist in Godot). |
|
Would it be too harmful to keep them though? If it's not too costly, then I personally think there would be no downsides to keeping these methods available for those few who can find a use for it. Consider that Godot is also used for things beyond just games, like desktop apps or even development tools as well. For example, if someone is developing a gamepad tester/viewer, or a launcher app, or anything that would benefit from visual display of this queried info. Whereas for games, I can imagine being able to query battery info coming in handy to let the player know their controller is low on battery, then pausing the game or suggesting them to save their progress, plug the controller in or switch controllers. Similarly for connection information, if I understood what it means correctly, games could use that to warn about features that won't work over a wireless connection, for example. Some games on Steam do that already, especially if they use fancy hardware-specific capabilities that only work through USB or whatnot. |
|
Hm, in this case I think I should write a proposal for this functionality and keep this PR for it. EDIT: Done! godotengine/godot-proposals#14482 |
e96da05 to
127fdb9
Compare
This PR adds the ability to get information about the joypad's battery state (no battery, charging, fully charged), battery percentage, connection state (wired, wireless).
127fdb9 to
68335be
Compare
I decided to split my big SDL3 joypad features PR ( #107967 ) into several smaller PRs, this PR is one of them.
This PR adds the ability to get information about the joypad's battery state (no battery, charging, fully charged), battery percentage, connection state (wired, wireless).
Relevant SDL documentation:
SDL_GetJoystickPowerInfo
SDL_GetJoystickConnectionState
This PR used to have a name
Add support for querying more joypad information, but was repurposed toAdd support for getting a joypad's battery and connection informationsince getting button/axis names andhas_joy_axis/button()might not be necessary to be builtin in Godot, andget_joy_model(),get_joy_type()have been moved into a separate PR ( #117526 ).Old TODO
JOY_MODEL_STEAM_DECKdocumentationThrottle documentationI don't have access to one :(I think checking if a joypad has a particular axis/button is more usefulget_joy_num_axes/buttons()has_joy_axis/button()(Support for other platforms will be done in a separate PR)get_joy_model()andget_joy_scheme()for Android and Web (depends on Add support for SDL-compatible joypad GUID andInput.get_joy_info()on Android #114338 and Add support forInput.get_joy_info()for web #114589 )get_joy_power_state()andget_joy_battery_percent()for Android ( https://stackoverflow.com/questions/78331095/how-to-get-battery-level-of-a-game-controller-from-an-android-application and https://developer.android.com/reference/android/hardware/BatteryState )has_joy_axis/button()for Android and Web based on Godot's mapping systemget_joy_model()andget_joy_type()functionality since it's been moved into a separate PR ( Add support for querying joypad type, model and layout scheme #117526 )