-display/emulate_touchscreen now really emulates a touchscreen

-icons to show node menus
This commit is contained in:
Juan Linietsky 2015-08-29 17:16:11 -03:00
parent 1fecba6b5b
commit b4acd18f32
11 changed files with 77 additions and 6 deletions

View file

@ -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;
}

View file

@ -78,6 +78,8 @@ public:
void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
virtual bool is_emulating_touchscreen() const=0;
Input();
};
@ -99,6 +101,8 @@ class InputDefault : public Input {
Vector2 mouse_pos;
MainLoop *main_loop;
bool emulate_touch;
struct SpeedTrack {
uint64_t last_tick;
@ -147,6 +151,9 @@ public:
void iteration(float p_step);
void set_emulate_touch(bool p_emulate);
virtual bool is_emulating_touchscreen() const;
InputDefault();
};

View file

@ -31,7 +31,7 @@
#include <stdarg.h>
#include "dir_access.h"
#include "globals.h"
#include "input.h"
OS* OS::singleton=NULL;
@ -363,7 +363,7 @@ Error OS::set_cwd(const String& p_cwd) {
bool OS::has_touchscreen_ui_hint() const {
//return false;
return GLOBAL_DEF("display/emulate_touchscreen",false);
return Input::get_singleton() && Input::get_singleton()->is_emulating_touchscreen();
}
int OS::get_free_static_memory() const {