diff options
author | Kostadin Damyanov <maxmight@gmail.com> | 2015-09-05 12:03:17 +0300 |
---|---|---|
committer | Kostadin Damyanov <maxmight@gmail.com> | 2015-09-05 12:03:17 +0300 |
commit | c5f574b914b3cb11d97ae616df4a0bced45bb17c (patch) | |
tree | d7b70f0842c00c480ce10039b873a1dddd894a6c /core/os/input.cpp | |
parent | 2a757a6ad4ef4e7767b7d3ef7e177ec6613ef6d1 (diff) | |
parent | b0aa49accbd7e45dae38f1bd43b0fbdd11714211 (diff) | |
download | redot-engine-c5f574b914b3cb11d97ae616df4a0bced45bb17c.tar.gz |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'core/os/input.cpp')
-rw-r--r-- | core/os/input.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/os/input.cpp b/core/os/input.cpp index 2b939ede46..cf2938f5cd 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -271,6 +271,38 @@ void InputDefault::parse_input_event(const InputEvent& p_event) { mouse_button_mask|=(1<<p_event.mouse_button.button_index); else mouse_button_mask&=~(1<<p_event.mouse_button.button_index); + + if (main_loop && emulate_touch && p_event.mouse_button.button_index==1) { + InputEventScreenTouch touch_event; + touch_event.index=0; + touch_event.pressed=p_event.mouse_button.pressed; + touch_event.x=p_event.mouse_button.x; + touch_event.y=p_event.mouse_button.y; + InputEvent ev; + ev.type=InputEvent::SCREEN_TOUCH; + ev.screen_touch=touch_event; + main_loop->input_event(ev); + } + } break; + case InputEvent::MOUSE_MOTION: { + + if (main_loop && emulate_touch && p_event.mouse_motion.button_mask&1) { + InputEventScreenDrag drag_event; + drag_event.index=0; + drag_event.x=p_event.mouse_motion.x; + drag_event.y=p_event.mouse_motion.y; + drag_event.relative_x=p_event.mouse_motion.relative_x; + drag_event.relative_y=p_event.mouse_motion.relative_y; + drag_event.speed_x=p_event.mouse_motion.speed_x; + drag_event.speed_y=p_event.mouse_motion.speed_y; + + InputEvent ev; + ev.type=InputEvent::SCREEN_DRAG; + ev.screen_drag=drag_event; + + main_loop->input_event(ev); + } + } break; case InputEvent::JOYSTICK_BUTTON: { @@ -362,8 +394,19 @@ void InputDefault::action_release(const StringName& p_action){ } } +void InputDefault::set_emulate_touch(bool p_emulate) { + + emulate_touch=p_emulate; +} + +bool InputDefault::is_emulating_touchscreen() const { + + return emulate_touch; +} + InputDefault::InputDefault() { mouse_button_mask=0; + emulate_touch=false; main_loop=NULL; } |