Merge pull request #114851 from Nintorch/set-joy-light-return-type
Change return type for `Input.set_joy_light()` from `bool` to `void`
This commit is contained in:
@@ -1004,12 +1004,13 @@ void Input::set_joy_features(int p_device, JoypadFeatures *p_features) {
|
||||
_update_joypad_features(p_device);
|
||||
}
|
||||
|
||||
bool Input::set_joy_light(int p_device, const Color &p_color) {
|
||||
void Input::set_joy_light(int p_device, const Color &p_color) {
|
||||
Joypad *joypad = joy_names.getptr(p_device);
|
||||
if (!joypad || joypad->features == nullptr) {
|
||||
return false;
|
||||
if (!joypad || !joypad->has_light || joypad->features == nullptr) {
|
||||
return;
|
||||
}
|
||||
return joypad->features->set_joy_light(p_color);
|
||||
Color linear = p_color.srgb_to_linear();
|
||||
joypad->features->set_joy_light(linear);
|
||||
}
|
||||
|
||||
bool Input::has_joy_light(int p_device) const {
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
virtual ~JoypadFeatures() {}
|
||||
|
||||
virtual bool has_joy_light() const { return false; }
|
||||
virtual bool set_joy_light(const Color &p_color) { return false; }
|
||||
virtual void set_joy_light(const Color &p_color) {}
|
||||
};
|
||||
|
||||
static constexpr int32_t JOYPADS_MAX = 16;
|
||||
@@ -360,7 +360,7 @@ public:
|
||||
|
||||
void set_joy_features(int p_device, JoypadFeatures *p_features);
|
||||
|
||||
bool set_joy_light(int p_device, const Color &p_color);
|
||||
void set_joy_light(int p_device, const Color &p_color);
|
||||
bool has_joy_light(int p_device) const;
|
||||
|
||||
void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
|
||||
|
||||
@@ -398,11 +398,11 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_joy_light">
|
||||
<return type="bool" />
|
||||
<return type="void" />
|
||||
<param index="0" name="device" type="int" />
|
||||
<param index="1" name="color" type="Color" />
|
||||
<description>
|
||||
Sets the joypad's LED light, if available, to the specified color. Returns [code]true[/code] if the operation was successful. See also [method has_joy_light].
|
||||
Sets the joypad's LED light, if available, to the specified color. See also [method has_joy_light].
|
||||
[b]Note:[/b] There is no way to get the color of the light from a joypad. If you need to know the assigned color, store it separately.
|
||||
[b]Note:[/b] This feature is only supported on Windows, Linux, and macOS.
|
||||
</description>
|
||||
|
||||
@@ -297,9 +297,8 @@ bool JoypadSDL::Joypad::has_joy_light() const {
|
||||
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());
|
||||
void JoypadSDL::Joypad::set_joy_light(const Color &p_color) {
|
||||
SDL_SetJoystickLED(get_sdl_joystick(), p_color.get_r8(), p_color.get_g8(), p_color.get_b8());
|
||||
}
|
||||
|
||||
SDL_Joystick *JoypadSDL::Joypad::get_sdl_joystick() const {
|
||||
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
uint64_t ff_effect_timestamp = 0;
|
||||
|
||||
virtual bool has_joy_light() const override;
|
||||
virtual bool set_joy_light(const Color &p_color) override;
|
||||
virtual void set_joy_light(const Color &p_color) override;
|
||||
|
||||
SDL_Joystick *get_sdl_joystick() const;
|
||||
SDL_Gamepad *get_sdl_gamepad() const;
|
||||
|
||||
Reference in New Issue
Block a user