Refactor Input.set_joy_light()
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);
|
||||
|
||||
Reference in New Issue
Block a user