mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #111681 from Nintorch/joypad-led
Add support for setting a joypad's LED light color
This commit is contained in:
commit
52e7b970af
5 changed files with 58 additions and 5 deletions
|
|
@ -302,6 +302,19 @@ void JoypadSDL::close_joypad(int p_pad_idx) {
|
|||
}
|
||||
}
|
||||
|
||||
bool JoypadSDL::Joypad::has_joy_light() const {
|
||||
SDL_PropertiesID properties_id = SDL_GetJoystickProperties(get_sdl_joystick());
|
||||
if (properties_id == 0) {
|
||||
return false;
|
||||
}
|
||||
return SDL_GetBooleanProperty(properties_id, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, false) || SDL_GetBooleanProperty(properties_id, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, false);
|
||||
}
|
||||
|
||||
bool JoypadSDL::Joypad::set_joy_light(const Color &p_color) {
|
||||
Color linear = p_color.srgb_to_linear();
|
||||
return SDL_SetJoystickLED(get_sdl_joystick(), linear.get_r8(), linear.get_g8(), linear.get_b8());
|
||||
}
|
||||
|
||||
SDL_Joystick *JoypadSDL::Joypad::get_sdl_joystick() const {
|
||||
return SDL_GetJoystickFromID(sdl_instance_idx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue