diff options
| author | Pedro J. Estébanez | 2018-02-24 03:04:30 +0100 |
|---|---|---|
| committer | Pedro J. Estébanez | 2018-04-30 19:04:35 +0200 |
| commit | e10a2e5999bb646b0145f898328e8f01731ca854 (patch) | |
| tree | 365a9bde5795edb7ba4cb6f9b7e8a14e81137620 /core | |
| parent | 74e72c995de0ad42d4da885eaaacbc7a71f625ef (diff) | |
| download | godot-e10a2e5999bb646b0145f898328e8f01731ca854.tar.gz godot-e10a2e5999bb646b0145f898328e8f01731ca854.tar.zst godot-e10a2e5999bb646b0145f898328e8f01731ca854.zip | |
Implement universal translation of touch to mouse
Now generating mouse events from touch is optional (on by default) and it's performed by `InputDefault` instead of having each OS abstraction doing it. (*)
The translation algorithm waits for a touch index to be pressed and tracks it translating its events to mouse events until it is raised, while ignoring other pointers.
Furthermore, to avoid an stuck "touch mouse", since not all platforms may report touches raised when the window is unfocused, it checks if touches are still down by the time it's focused again and if so it resets the state of the emulated mouse.
*: In the case of Windows, since it already provides touch-to-mouse translation by itself, "echo" mouse events are filtered out to have it working like the rest.
On X11 a little hack has been needed to avoid a case of a spurious mouse motion event that is generated during touch interaction.
Plus: Improve/fix tracking of current mouse position.
Diffstat (limited to 'core')
| -rw-r--r-- | core/os/input.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/os/input.h b/core/os/input.h index 9c7595ff7..45a3391f1 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -118,6 +118,7 @@ public: void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; virtual bool is_emulating_touchscreen() const = 0; + virtual bool is_emulating_mouse_from_touch() const = 0; virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) = 0; virtual void set_mouse_in_window(bool p_in_window) = 0; |
