You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user