From 8e6960a69e0202cb1e6f3b3dc9f9bb34e1c1d889 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 4 Mar 2020 13:36:09 -0300 Subject: Refactored input, goes all via windows now. Also renamed Input to InputFilter because all it does is filter events. --- platform/android/java_godot_lib_jni.cpp | 4 +- platform/android/os_android.cpp | 6 +- platform/android/os_android.h | 2 +- platform/haiku/haiku_direct_window.cpp | 2 +- platform/haiku/haiku_direct_window.h | 2 +- platform/haiku/os_haiku.h | 2 +- platform/iphone/os_iphone.h | 4 +- platform/javascript/os_javascript.cpp | 12 +-- platform/javascript/os_javascript.h | 2 +- platform/linuxbsd/display_server_x11.cpp | 124 +++++++++++++++++++++++++------ platform/linuxbsd/display_server_x11.h | 14 +++- platform/linuxbsd/joypad_linux.cpp | 22 +++--- platform/linuxbsd/joypad_linux.h | 10 +-- platform/linuxbsd/os_linuxbsd.cpp | 2 +- platform/linuxbsd/os_linuxbsd.h | 2 +- platform/osx/joypad_osx.cpp | 2 +- platform/osx/joypad_osx.h | 2 +- platform/osx/os_osx.h | 2 +- platform/server/os_server.h | 2 +- platform/uwp/joypad_uwp.h | 2 +- platform/uwp/os_uwp.h | 2 +- platform/windows/os_windows.cpp | 14 ++-- platform/windows/os_windows.h | 2 +- 23 files changed, 163 insertions(+), 75 deletions(-) (limited to 'platform') diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index e6ab272e7f..e018ee69f0 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "java_godot_lib_jni.h" + #include "java_godot_io_wrapper.h" #include "java_godot_wrapper.h" @@ -37,7 +38,7 @@ #include "api/java_class_wrapper.h" #include "audio_driver_jandroid.h" #include "core/engine.h" -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "core/project_settings.h" #include "dir_access_jandroid.h" #include "file_access_android.h" @@ -48,6 +49,7 @@ #include "os_android.h" #include "string_android.h" #include "thread_jandroid.h" + #include static JavaClassWrapper *java_class_wrapper = NULL; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 8021d6dd07..e3792b1f31 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -306,14 +306,14 @@ void OS_Android::main_loop_end() { void OS_Android::main_loop_focusout() { if (main_loop) - main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); + main_loop->notification(NOTIFICATION_WM_FOCUS_OUT); audio_driver_android.set_pause(true); } void OS_Android::main_loop_focusin() { if (main_loop) - main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); + main_loop->notification(NOTIFICATION_WM_FOCUS_IN); audio_driver_android.set_pause(false); } @@ -568,7 +568,7 @@ void OS_Android::init_video_mode(int p_video_width, int p_video_height) { void OS_Android::main_loop_request_go_back() { if (main_loop) - main_loop->notification(MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST); + main_loop->notification(NOTIFICATION_WM_GO_BACK_REQUEST); } void OS_Android::set_display_size(Size2 p_size) { diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 745a28f6df..d09f4e10d6 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -33,7 +33,7 @@ #include "audio_driver_jandroid.h" #include "audio_driver_opensl.h" -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "core/os/main_loop.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 2d7efe6b61..18e1862d33 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -74,7 +74,7 @@ void HaikuDirectWindow::SetMainLoop(MainLoop *p_main_loop) { bool HaikuDirectWindow::QuitRequested() { StopMessageRunner(); - main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); + main_loop->notification(NOTIFICATION_WM_CLOSE_REQUEST); return false; } diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 4817abbb7a..925bb9ac5d 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -35,7 +35,7 @@ #include -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "core/os/os.h" #include "haiku_gl_view.h" diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 6804ae5f82..90c0abc3ef 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -33,7 +33,7 @@ #include "audio_driver_media_kit.h" #include "context_gl_haiku.h" -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "drivers/unix/os_unix.h" #include "haiku_application.h" #include "haiku_direct_window.h" diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 3a61a40b26..2efb7af7c2 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -33,11 +33,9 @@ #ifndef OS_IPHONE_H #define OS_IPHONE_H -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/unix/os_unix.h" - -#include "core/input/input.h" #include "game_center.h" #include "icloud.h" #include "in_app_store.h" diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index db90b01f8f..b7feb5bfbd 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -1009,10 +1009,10 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, update_clipboard(evt.clipboardData.getData('text')); }, true); }, - MainLoop::NOTIFICATION_WM_MOUSE_ENTER, - MainLoop::NOTIFICATION_WM_MOUSE_EXIT, - MainLoop::NOTIFICATION_WM_FOCUS_IN, - MainLoop::NOTIFICATION_WM_FOCUS_OUT + NOTIFICATION_WM_MOUSE_ENTER, + NOTIFICATION_WM_MOUSE_EXIT, + NOTIFICATION_WM_FOCUS_IN, + NOTIFICATION_WM_FOCUS_OUT ); /* clang-format on */ @@ -1121,8 +1121,8 @@ int OS_JavaScript::get_process_id() const { extern "C" EMSCRIPTEN_KEEPALIVE void send_notification(int p_notification) { - if (p_notification == MainLoop::NOTIFICATION_WM_MOUSE_ENTER || p_notification == MainLoop::NOTIFICATION_WM_MOUSE_EXIT) { - cursor_inside_canvas = p_notification == MainLoop::NOTIFICATION_WM_MOUSE_ENTER; + if (p_notification == NOTIFICATION_WM_MOUSE_ENTER || p_notification == NOTIFICATION_WM_MOUSE_EXIT) { + cursor_inside_canvas = p_notification == NOTIFICATION_WM_MOUSE_ENTER; } OS_JavaScript::get_singleton()->get_main_loop()->notification(p_notification); } diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index c4ef33f7b1..1a3a6616b0 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -32,7 +32,7 @@ #define OS_JAVASCRIPT_H #include "audio_driver_javascript.h" -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" #include "servers/visual/rasterizer.h" diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 0b4a6b19d8..b68b766ddd 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -208,7 +208,7 @@ void DisplayServerX11::_update_real_mouse_position(const WindowData &wd) { last_mouse_pos.x = win_x; last_mouse_pos.y = win_y; last_mouse_pos_valid = true; - Input::get_singleton()->set_mouse_position(last_mouse_pos); + InputFilter::get_singleton()->set_mouse_position(last_mouse_pos); } } } @@ -389,7 +389,7 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) { XWarpPointer(x11_display, None, main_window.x11_window, 0, 0, 0, 0, (int)center.x, (int)center.y); - Input::get_singleton()->set_mouse_position(center); + InputFilter::get_singleton()->set_mouse_position(center); } } else { do_mouse_warp = false; @@ -673,6 +673,29 @@ void DisplayServerX11::window_set_resize_callback(const Callable &p_callable, Wi wd.resize_callback = p_callable; } +void DisplayServerX11::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { + ERR_FAIL_COND(!windows.has(p_window)); + WindowData &wd = windows[p_window]; + wd.event_callback = p_callable; +} + +void DisplayServerX11::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) { + ERR_FAIL_COND(!windows.has(p_window)); + WindowData &wd = windows[p_window]; + wd.input_event_callback = p_callable; +} +void DisplayServerX11::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) { + ERR_FAIL_COND(!windows.has(p_window)); + WindowData &wd = windows[p_window]; + wd.input_text_callback = p_callable; +} + +void DisplayServerX11::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) { + ERR_FAIL_COND(!windows.has(p_window)); + WindowData &wd = windows[p_window]; + wd.drop_files_callback = p_callable; +} + int DisplayServerX11::window_get_current_screen(WindowID p_window) const { ERR_FAIL_COND_V(!windows.has(p_window), -1); const WindowData &wd = windows[p_window]; @@ -1837,7 +1860,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_shift(true); } - Input::get_singleton()->accumulate_input_event(k); + InputFilter::get_singleton()->accumulate_input_event(k); } memfree(utf8string); return; @@ -1979,14 +2002,14 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_metakey(false); } - bool last_is_pressed = Input::get_singleton()->is_key_pressed(k->get_keycode()); + bool last_is_pressed = InputFilter::get_singleton()->is_key_pressed(k->get_keycode()); if (k->is_pressed()) { if (last_is_pressed) { k->set_echo(true); } } - Input::get_singleton()->accumulate_input_event(k); + InputFilter::get_singleton()->accumulate_input_event(k); } void DisplayServerX11::_xim_destroy_callback(::XIM im, ::XPointer client_data, @@ -2041,6 +2064,47 @@ void DisplayServerX11::_window_changed(XEvent *event) { } } +void DisplayServerX11::_dispatch_input_events(const Ref &p_event) { + ((DisplayServerX11 *)(get_singleton()))->_dispatch_input_event(p_event); +} + +void DisplayServerX11::_dispatch_input_event(const Ref &p_event) { + + Variant ev = p_event; + Variant *evp = &ev; + Variant ret; + Callable::CallError ce; + + Ref event_from_window = p_event; + if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) { + //send to a window + ERR_FAIL_COND(!windows.has(event_from_window->get_window_id())); + Callable callable = windows[event_from_window->get_window_id()].input_event_callback; + if (callable.is_null()) { + return; + } + callable.call((const Variant **)&evp, 1, ret, ce); + } else { + //send to all windows + for (Map::Element *E = windows.front(); E; E = E->next()) { + Callable callable = E->get().input_event_callback; + if (callable.is_null()) { + continue; + } + callable.call((const Variant **)&evp, 1, ret, ce); + } + } +} + +void DisplayServerX11::_send_window_event(const WindowData &wd, WindowEvent p_event) { + if (!wd.event_callback.is_null()) { + Variant event = int(p_event); + Variant *eventp = &event; + Variant ret; + Callable::CallError ce; + wd.event_callback.call((const Variant **)&eventp, 1, ret, ce); + } +} void DisplayServerX11::process_events() { do_mouse_warp = false; @@ -2180,12 +2244,12 @@ void DisplayServerX11::process_events() { // in a spurious mouse motion event being sent to Godot; remember it to be able to filter it out xi.mouse_pos_to_filter = pos; } - Input::get_singleton()->accumulate_input_event(st); + InputFilter::get_singleton()->accumulate_input_event(st); } else { if (!xi.state.has(index)) // Defensive break; xi.state.erase(index); - Input::get_singleton()->accumulate_input_event(st); + InputFilter::get_singleton()->accumulate_input_event(st); } } break; @@ -2204,7 +2268,7 @@ void DisplayServerX11::process_events() { sd->set_index(index); sd->set_position(pos); sd->set_relative(pos - curr_pos_elem->value()); - Input::get_singleton()->accumulate_input_event(sd); + InputFilter::get_singleton()->accumulate_input_event(sd); curr_pos_elem->value() = pos; } @@ -2229,18 +2293,20 @@ void DisplayServerX11::process_events() { minimized = (visibility->state == VisibilityFullyObscured); } break; case LeaveNotify: { - if (!mouse_mode_grab) - Input::get_singleton()->parse_notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT); + if (!mouse_mode_grab) { + _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT); + } } break; case EnterNotify: { - if (!mouse_mode_grab) - Input::get_singleton()->parse_notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER); + if (!mouse_mode_grab) { + _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER); + } } break; case FocusIn: minimized = false; window_has_focus = true; - Input::get_singleton()->parse_notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); + _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN); window_focused = true; if (mouse_mode_grab) { @@ -2272,8 +2338,8 @@ void DisplayServerX11::process_events() { case FocusOut: window_has_focus = false; - Input::get_singleton()->release_pressed_events(); - Input::get_singleton()->parse_notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); + InputFilter::get_singleton()->release_pressed_events(); + _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_OUT); window_focused = false; if (mouse_mode_grab) { @@ -2301,7 +2367,7 @@ void DisplayServerX11::process_events() { st->set_index(E->key()); st->set_window_id(window_id); st->set_position(E->get()); - Input::get_singleton()->accumulate_input_event(st); + InputFilter::get_singleton()->accumulate_input_event(st); } xi.state.clear(); #endif @@ -2363,7 +2429,7 @@ void DisplayServerX11::process_events() { } } - Input::get_singleton()->accumulate_input_event(mb); + InputFilter::get_singleton()->accumulate_input_event(mb); } break; case MotionNotify: { @@ -2465,8 +2531,8 @@ void DisplayServerX11::process_events() { mm->set_button_mask(mouse_get_button_state()); mm->set_position(posi); mm->set_global_position(posi); - Input::get_singleton()->set_mouse_position(posi); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + InputFilter::get_singleton()->set_mouse_position(posi); + mm->set_speed(InputFilter::get_singleton()->get_last_mouse_speed()); mm->set_relative(rel); @@ -2477,7 +2543,7 @@ void DisplayServerX11::process_events() { // this is so that the relative motion doesn't get messed up // after we regain focus. if (window_has_focus || !mouse_mode_grab) - Input::get_singleton()->accumulate_input_event(mm); + InputFilter::get_singleton()->accumulate_input_event(mm); } break; case KeyPress: @@ -2561,7 +2627,14 @@ void DisplayServerX11::process_events() { for (int i = 0; i < files.size(); i++) { files.write[i] = files[i].replace("file://", "").http_unescape().strip_edges(); } - Input::get_singleton()->parse_drop_files(files); + + if (!windows[window_id].drop_files_callback.is_null()) { + Variant v = files; + Variant *vp = &v; + Variant ret; + Callable::CallError ce; + windows[window_id].drop_files_callback.call((const Variant **)&vp, 1, ret, ce); + } //Reply that all is well. XClientMessageEvent m; @@ -2581,8 +2654,9 @@ void DisplayServerX11::process_events() { case ClientMessage: - if ((unsigned int)event.xclient.data.l[0] == (unsigned int)wm_delete) - Input::get_singleton()->parse_notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); + if ((unsigned int)event.xclient.data.l[0] == (unsigned int)wm_delete) { + _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST); + } else if ((unsigned int)event.xclient.message_type == (unsigned int)xdnd_enter) { @@ -2662,7 +2736,7 @@ void DisplayServerX11::process_events() { */ } - Input::get_singleton()->flush_accumulated_events(); + InputFilter::get_singleton()->flush_accumulated_events(); } void DisplayServerX11::release_rendering_thread() { @@ -2881,6 +2955,8 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, c DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { + InputFilter::get_singleton()->set_event_dispatch_function(_dispatch_input_events); + r_error = OK; last_button_state = 0; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index b1ecde30d9..e17078c5ca 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -35,7 +35,7 @@ #include "servers/display_server.h" -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "drivers/alsa/audio_driver_alsa.h" #include "drivers/alsamidi/midi_driver_alsamidi.h" @@ -120,6 +120,10 @@ class DisplayServerX11 : public DisplayServer { Size2i im_position; bool im_active = false; Callable resize_callback; + Callable event_callback; + Callable input_event_callback; + Callable input_text_callback; + Callable drop_files_callback; //better to guess on the fly, given WM can change it //WindowMode mode; @@ -224,6 +228,10 @@ class DisplayServerX11 : public DisplayServer { Context context = CONTEXT_ENGINE; + void _send_window_event(const WindowData &wd, WindowEvent p_event); + static void _dispatch_input_events(const Ref &p_event); + void _dispatch_input_event(const Ref &p_event); + protected: void _window_changed(XEvent *event); @@ -256,6 +264,10 @@ public: virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID); virtual void window_set_resize_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const; virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 7531b1160f..c4c793093d 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -71,7 +71,7 @@ void JoypadLinux::Joypad::reset() { dpad = 0; fd = -1; - Input::JoyAxis jx; + InputFilter::JoyAxis jx; jx.min = -1; jx.value = 0.0f; for (int i = 0; i < MAX_ABS; i++) { @@ -80,7 +80,7 @@ void JoypadLinux::Joypad::reset() { } } -JoypadLinux::JoypadLinux(Input *in) { +JoypadLinux::JoypadLinux(InputFilter *in) { exit_udev = false; input = in; joy_thread = Thread::create(joy_thread_func, this); @@ -436,11 +436,11 @@ void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { joy.ff_effect_timestamp = p_timestamp; } -Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const { +InputFilter::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const { int min = p_abs->minimum; int max = p_abs->maximum; - Input::JoyAxis jx; + InputFilter::JoyAxis jx; if (min < 0) { jx.min = -1; @@ -492,11 +492,11 @@ void JoypadLinux::process_joypads() { case ABS_HAT0X: if (ev.value != 0) { if (ev.value < 0) - joy->dpad |= Input::HAT_MASK_LEFT; + joy->dpad |= InputFilter::HAT_MASK_LEFT; else - joy->dpad |= Input::HAT_MASK_RIGHT; + joy->dpad |= InputFilter::HAT_MASK_RIGHT; } else - joy->dpad &= ~(Input::HAT_MASK_LEFT | Input::HAT_MASK_RIGHT); + joy->dpad &= ~(InputFilter::HAT_MASK_LEFT | InputFilter::HAT_MASK_RIGHT); input->joy_hat(i, joy->dpad); break; @@ -504,11 +504,11 @@ void JoypadLinux::process_joypads() { case ABS_HAT0Y: if (ev.value != 0) { if (ev.value < 0) - joy->dpad |= Input::HAT_MASK_UP; + joy->dpad |= InputFilter::HAT_MASK_UP; else - joy->dpad |= Input::HAT_MASK_DOWN; + joy->dpad |= InputFilter::HAT_MASK_DOWN; } else - joy->dpad &= ~(Input::HAT_MASK_UP | Input::HAT_MASK_DOWN); + joy->dpad &= ~(InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_DOWN); input->joy_hat(i, joy->dpad); break; @@ -517,7 +517,7 @@ void JoypadLinux::process_joypads() { if (ev.code >= MAX_ABS) return; if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) { - Input::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value); + InputFilter::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value); joy->curr_axis[joy->abs_map[ev.code]] = value; } break; diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h index 0d175193a5..1d2ed5bbc1 100644 --- a/platform/linuxbsd/joypad_linux.h +++ b/platform/linuxbsd/joypad_linux.h @@ -33,7 +33,7 @@ #define JOYPAD_LINUX_H #ifdef JOYDEV_ENABLED -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "core/os/mutex.h" #include "core/os/thread.h" @@ -41,7 +41,7 @@ struct input_absinfo; class JoypadLinux { public: - JoypadLinux(Input *in); + JoypadLinux(InputFilter *in); ~JoypadLinux(); void process_joypads(); @@ -53,7 +53,7 @@ private: }; struct Joypad { - Input::JoyAxis curr_axis[MAX_ABS]; + InputFilter::JoyAxis curr_axis[MAX_ABS]; int key_map[MAX_KEY]; int abs_map[MAX_ABS]; int dpad; @@ -74,7 +74,7 @@ private: bool exit_udev; Mutex joy_mutex; Thread *joy_thread; - Input *input; + InputFilter *input; Joypad joypads[JOYPADS_MAX]; Vector attached_devices; @@ -95,7 +95,7 @@ private: void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); void joypad_vibration_stop(int p_id, uint64_t p_timestamp); - Input::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const; + InputFilter::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const; }; #endif diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 2c596b0058..084453bdc6 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -64,7 +64,7 @@ void OS_LinuxBSD::initialize() { void OS_LinuxBSD::initialize_joypads() { #ifdef JOYDEV_ENABLED - joypad = memnew(JoypadLinux(Input::get_singleton())); + joypad = memnew(JoypadLinux(InputFilter::get_singleton())); #endif } diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index f6586aa45f..6c656c1945 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -31,7 +31,7 @@ #ifndef OS_LINUXBSD_H #define OS_LINUXBSD_H -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "crash_handler_linuxbsd.h" #include "drivers/alsa/audio_driver_alsa.h" #include "drivers/alsamidi/midi_driver_alsamidi.h" diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index e9f46fb5a4..26735b71d1 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -573,7 +573,7 @@ void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const { JoypadOSX::JoypadOSX() { self = this; - input = (InputDefault *)Input::get_singleton(); + input = (InputDefault *)InputFilter::get_singleton(); int okay = 1; const void *vals[] = { diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h index 287cf63cc8..c8ed8fbfa9 100644 --- a/platform/osx/joypad_osx.h +++ b/platform/osx/joypad_osx.h @@ -40,7 +40,7 @@ #include #include -#include "core/input/input.h" +#include "core/input/input_filter.h" struct rec_element { IOHIDElementRef ref; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index b98c279f92..de8a9345e3 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -33,7 +33,7 @@ #define BitMap _QDBitMap // Suppress deprecated QuickDraw definition. -#include "core/input/input.h" +#include "core/input/inpu_filter.h" #include "crash_handler_osx.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/coremidi/midi_driver_coremidi.h" diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 6bbfe471e0..d40905718e 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -31,7 +31,7 @@ #ifndef OS_SERVER_H #define OS_SERVER_H -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "drivers/dummy/texture_loader_dummy.h" #include "drivers/unix/os_unix.h" #ifdef __APPLE__ diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h index 69431052e5..054b67ddc8 100644 --- a/platform/uwp/joypad_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -31,7 +31,7 @@ #ifndef JOYPAD_UWP_H #define JOYPAD_UWP_H -#include "core/input/input.h" +#include "core/input/input_filter.h" ref class JoypadUWP sealed { diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 29fd975274..cc4dfcc79f 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -32,7 +32,7 @@ #define OS_UWP_H #include "context_egl_uwp.h" -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "core/math/transform_2d.h" #include "core/os/os.h" #include "core/ustring.h" diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 041a5bffa6..c49f096ec5 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -361,14 +361,14 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) }; if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) { - main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); + main_loop->notification(NOTIFICATION_WM_FOCUS_IN); window_focused = true; alt_mem = false; control_mem = false; shift_mem = false; } else { // WM_INACTIVE input->release_pressed_events(); - main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); + main_loop->notification(NOTIFICATION_WM_FOCUS_OUT); window_focused = false; alt_mem = false; }; @@ -414,7 +414,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_CLOSE: // Did We Receive A Close Message? { if (main_loop) - main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); + main_loop->notification(NOTIFICATION_WM_CLOSE_REQUEST); //force_quit=true; return 0; // Jump Back } @@ -423,7 +423,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) old_invalid = true; outside = true; if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED) - main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT); + main_loop->notification(NOTIFICATION_WM_MOUSE_EXIT); } break; case WM_INPUT: { @@ -536,7 +536,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) //mouse enter if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED) - main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER); + main_loop->notification(NOTIFICATION_WM_MOUSE_ENTER); CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; @@ -630,7 +630,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) //mouse enter if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED) - main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER); + main_loop->notification(NOTIFICATION_WM_MOUSE_ENTER); CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; @@ -974,7 +974,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // When SetCapture is used, ALT+F4 hotkey is ignored by Windows, so handle it ourselves if (wParam == VK_F4 && alt_mem && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)) { if (main_loop) - main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); + main_loop->notification(NOTIFICATION_WM_CLOSE_REQUEST); } } /* diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index a7b31fa85f..d07423f2f3 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -31,7 +31,7 @@ #ifndef OS_WINDOWS_H #define OS_WINDOWS_H -#include "core/input/input.h" +#include "core/input/input_filter.h" #include "core/os/os.h" #include "core/project_settings.h" #include "crash_handler_windows.h" -- cgit v1.2.3