diff options
author | Guilherme Silva <guilhermefelipecgs@gmail.com> | 2017-11-10 08:50:11 -0200 |
---|---|---|
committer | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2017-12-17 13:40:29 -0200 |
commit | a392dbdbe3f67d42698e47399421fbdf6ae5c90a (patch) | |
tree | 0a824a34a62a5f9510850e4e4f451e8c54e5ed46 /main | |
parent | fa8a1fc4201dc4c16b5eef844dde17c5bba92dc8 (diff) |
Add implementation for custom hardware cursor
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 20 | ||||
-rw-r--r-- | main/input_default.h | 2 | ||||
-rw-r--r-- | main/main.cpp | 2 |
3 files changed, 7 insertions, 17 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index f637e77d56..9902332e9d 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -497,26 +497,16 @@ bool InputDefault::is_emulating_touchscreen() const { return emulate_touch; } -void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot) { - /* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors +void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { + if (Engine::get_singleton()->is_editor_hint()) + return; + if (custom_cursor == p_cursor) return; custom_cursor = p_cursor; - if (p_cursor.is_null()) { - set_mouse_mode(MOUSE_MODE_VISIBLE); - //removed, please insist us to implement hardare cursors - //VisualServer::get_singleton()->cursor_set_visible(false); - } else { - Ref<AtlasTexture> atex = custom_cursor; - Rect2 region = atex.is_valid() ? atex->get_region() : Rect2(); - set_mouse_mode(MOUSE_MODE_HIDDEN); - VisualServer::get_singleton()->cursor_set_visible(true); - VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(), p_hotspot, 0, region); - VisualServer::get_singleton()->cursor_set_pos(get_mouse_position()); - } - */ + OS::get_singleton()->set_custom_mouse_cursor(p_cursor, (OS::CursorShape)p_shape, p_hotspot); } void InputDefault::set_mouse_in_window(bool p_in_window) { diff --git a/main/input_default.h b/main/input_default.h index e2cb03e67c..18918b26e0 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -225,7 +225,7 @@ public: void set_emulate_touch(bool p_emulate); virtual bool is_emulating_touchscreen() const; - virtual void set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot = Vector2()); + virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()); virtual void set_mouse_in_window(bool p_in_window); void parse_mapping(String p_mapping); diff --git a/main/main.cpp b/main/main.cpp index ab520c5e7f..8afda31200 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1105,7 +1105,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (cursor.is_valid()) { //print_line("loaded ok"); Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot"); - Input::get_singleton()->set_custom_mouse_cursor(cursor, hotspot); + Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot); } } #ifdef TOOLS_ENABLED |