1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

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

@@ -986,6 +986,15 @@ void Input::set_joy_axis(int p_device, JoyAxis p_axis, float p_value) {
_joy_axis[c] = p_value;
}
void Input::set_joy_features(int p_device, JoypadFeatures *p_features) {
Joypad *joypad = joy_names.getptr(p_device);
if (!joypad) {
return;
}
joypad->features = p_features;
_update_joypad_features(p_device);
}
void Input::start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration) {
_THREAD_SAFE_METHOD_
if (p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) {
@@ -1478,6 +1487,15 @@ void Input::_update_action_cache(const StringName &p_action_name, ActionState &r
}
}
void Input::_update_joypad_features(int p_device) {
Joypad *joypad = joy_names.getptr(p_device);
if (!joypad || joypad->features == nullptr) {
return;
}
// Do something based on the features. For example, we can save the information about
// the joypad having motion sensors, LED light, etc.
}
Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button) {
JoyEvent event;