summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-04 00:22:37 +0200
committerGitHub <noreply@github.com>2022-06-04 00:22:37 +0200
commitb34677580c0fa41bbfb9ddb590518e3f2ff22120 (patch)
tree2d545dcc3a5585986407439284832582aaa12c6b
parent5507f9ef73c28850e23a2cce8ab60c9c290dd07f (diff)
parent3e53afd52c82262278681ea25c6cf36b27e483bf (diff)
Merge pull request #61671 from raulsntos/typed-joypads
Add array element type to `get_connected_joypads`
-rw-r--r--core/input/input.cpp4
-rw-r--r--core/input/input.h3
-rw-r--r--doc/classes/Input.xml2
3 files changed, 5 insertions, 4 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 4befdfac58..dbb6bd8d9c 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -1401,8 +1401,8 @@ String Input::get_joy_guid(int p_device) const {
return joy_names[p_device].uid;
}
-Array Input::get_connected_joypads() {
- Array ret;
+TypedArray<int> Input::get_connected_joypads() {
+ TypedArray<int> ret;
HashMap<int, Joypad>::Iterator elem = joy_names.begin();
while (elem) {
if (elem->value.connected) {
diff --git a/core/input/input.h b/core/input/input.h
index 9a5b8e6e06..35812604b2 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -36,6 +36,7 @@
#include "core/os/keyboard.h"
#include "core/os/thread_safe.h"
#include "core/templates/rb_set.h"
+#include "core/variant/typed_array.h"
class Input : public Object {
GDCLASS(Input, Object);
@@ -259,7 +260,7 @@ public:
float get_joy_axis(int p_device, JoyAxis p_axis) const;
String get_joy_name(int p_idx);
- Array get_connected_joypads();
+ TypedArray<int> get_connected_joypads();
Vector2 get_joy_vibration_strength(int p_device);
float get_joy_vibration_duration(int p_device);
uint64_t get_joy_vibration_timestamp(int p_device);
diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml
index 2a4381b41b..dcbdbe6fb4 100644
--- a/doc/classes/Input.xml
+++ b/doc/classes/Input.xml
@@ -80,7 +80,7 @@
</description>
</method>
<method name="get_connected_joypads">
- <return type="Array" />
+ <return type="int[]" />
<description>
Returns an [Array] containing the device IDs of all currently connected joypads.
</description>