summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorpunto- <ariel@godotengine.org>2016-01-12 03:59:19 -0300
committerpunto- <ariel@godotengine.org>2016-01-12 03:59:19 -0300
commit7393e404521350cbb3e69ce87a19ee602ec2a7a4 (patch)
tree2c0b71bce28a0bbbbd448084b80bc602183e19b0 /core
parent8cb013a1bf4728853851d0cbcbc963754632d330 (diff)
parentc632c13c66db715b816390f0734f2b1839a7ff3e (diff)
Merge pull request #3272 from Hinsbart/joy-binding
Add some joystick functions to input. Enables manipulation of mapping…
Diffstat (limited to 'core')
-rw-r--r--core/os/input.cpp4
-rw-r--r--core/os/input.h5
-rw-r--r--core/os/os.cpp7
-rw-r--r--core/os/os.h3
4 files changed, 18 insertions, 1 deletions
diff --git a/core/os/input.cpp b/core/os/input.cpp
index d8d746c811..6e1e618d9a 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -53,8 +53,12 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed);
ObjectTypeDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed);
ObjectTypeDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed);
+ ObjectTypeDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping);
+ ObjectTypeDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known);
ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis);
ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name);
+ ObjectTypeDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid);
ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);
//ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want
ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed);
diff --git a/core/os/input.h b/core/os/input.h
index 57eaa973d9..2dd4496f26 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -63,7 +63,10 @@ public:
virtual float get_joy_axis(int p_device,int p_axis)=0;
virtual String get_joy_name(int p_idx)=0;
virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid)=0;
-
+ virtual void add_joy_mapping(String p_mapping, bool p_update_existing=false)=0;
+ virtual void remove_joy_mapping(String p_guid)=0;
+ virtual bool is_joy_known(int p_device)=0;
+ virtual String get_joy_guid(int p_device) const=0;
virtual Point2 get_mouse_pos() const=0;
virtual Point2 get_mouse_speed() const=0;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 1a505fb236..be447d511e 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -507,6 +507,13 @@ float OS::get_time_scale() const {
return _time_scale;
}
+bool OS::is_joy_known(int p_device) {
+ return true;
+}
+
+String OS::get_joy_guid(int p_device) const {
+ return "Default Joystick";
+}
OS::OS() {
last_error=NULL;
diff --git a/core/os/os.h b/core/os/os.h
index 711743f23a..83ea2c2101 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -397,6 +397,9 @@ public:
_FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
+ virtual bool is_joy_known(int p_device);
+ virtual String get_joy_guid(int p_device)const;
+
OS();
virtual ~OS();