Support adding advanced joypad features

This commit is contained in:
Nintorch
2025-10-20 19:28:06 +05:00
parent 36b92128b1
commit 7ae67813a1
9 changed files with 560 additions and 3 deletions

View File

@ -79,6 +79,15 @@ public:
CURSOR_MAX
};
class JoypadFeatures {
public:
virtual ~JoypadFeatures() {}
// None at the moment, but later we can add new features like:
// virtual bool has_joy_accelerometer() const { return false; }
// virtual bool set_joy_accelerometer_enabled(bool p_enable) { return false; }
};
static constexpr int32_t JOYPADS_MAX = 16;
typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event);
@ -174,6 +183,7 @@ private:
int mapping = -1;
int hat_current = 0;
Dictionary info;
Input::JoypadFeatures *features = nullptr;
};
VelocityTrack mouse_velocity_track;
@ -253,6 +263,7 @@ private:
void _button_event(int p_device, JoyButton p_index, bool p_pressed);
void _axis_event(int p_device, JoyAxis p_axis, float p_value);
void _update_action_cache(const StringName &p_action_name, ActionState &r_action_state);
void _update_joypad_features(int p_device);
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
@ -346,6 +357,8 @@ public:
void set_gyroscope(const Vector3 &p_gyroscope);
void set_joy_axis(int p_device, JoyAxis p_axis, float p_value);
void set_joy_features(int p_device, JoypadFeatures *p_features);
void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
void stop_joy_vibration(int p_device);
void vibrate_handheld(int p_duration_ms = 500, float p_amplitude = -1.0);