From 016330c12bcb887e5105f59d68bc010ebf84cee5 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 20 Feb 2019 23:00:02 +0100 Subject: [PATCH] ui: move a lot of files around. Most input and GUI files are now in a common ui/ directory. The platform/ directory is no longer, as everythyng was moved to application/ or ui/. --- doc/doxygen.cfg.in | 7 +- src/Makefile.am | 18 +- .../android-app.cpp} | 7 +- .../android-app.h} | 0 src/application/application.cpp | 4 +- src/{eglapp.cpp => application/egl-app.cpp} | 4 +- src/{eglapp.h => application/egl-app.h} | 0 src/application/sdl-app.cpp | 4 +- src/lol-core.vcxproj | 36 ++-- src/lol-core.vcxproj.filter | 61 +++--- src/lol/extras.h | 10 +- src/platform/emscripten/lol_shell.html | 187 ------------------ src/{input => ui}/controller.cpp | 11 -- src/{input => ui}/controller.h | 28 +-- .../d3d9/d3d9input.cpp => ui/d3d9-input.cpp} | 26 ++- .../d3d9/d3d9input.h => ui/d3d9-input.h} | 0 src/{lolimgui.cpp => ui/gui.cpp} | 0 src/{lolimgui.h => ui/gui.h} | 0 src/{input => ui}/input.cpp | 10 +- src/{input => ui}/input.h | 25 +-- src/{input => ui}/input_internal.h | 0 src/{input => ui}/keys.inc | 0 src/{input => ui}/sdl-input.cpp | 8 +- src/{input => ui}/sdl-input.h | 0 24 files changed, 112 insertions(+), 334 deletions(-) rename src/{platform/android/androidapp.cpp => application/android-app.cpp} (98%) rename src/{platform/android/androidapp.h => application/android-app.h} (100%) rename src/{eglapp.cpp => application/egl-app.cpp} (99%) rename src/{eglapp.h => application/egl-app.h} (100%) delete mode 100644 src/platform/emscripten/lol_shell.html rename src/{input => ui}/controller.cpp (98%) rename src/{input => ui}/controller.h (86%) rename src/{platform/d3d9/d3d9input.cpp => ui/d3d9-input.cpp} (76%) rename src/{platform/d3d9/d3d9input.h => ui/d3d9-input.h} (100%) rename src/{lolimgui.cpp => ui/gui.cpp} (100%) rename src/{lolimgui.h => ui/gui.h} (100%) rename src/{input => ui}/input.cpp (96%) rename src/{input => ui}/input.h (85%) rename src/{input => ui}/input_internal.h (100%) rename src/{input => ui}/keys.inc (100%) rename src/{input => ui}/sdl-input.cpp (98%) rename src/{input => ui}/sdl-input.h (100%) diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in index ce743f0a..390226c5 100644 --- a/doc/doxygen.cfg.in +++ b/doc/doxygen.cfg.in @@ -790,18 +790,17 @@ INPUT = .. \ ../src/easymesh \ ../src/gpu \ ../src/image \ - ../src/input \ ../src/lol \ ../src/lol/math \ ../src/lol/core \ - ../src/ath \ + ../src/math \ ../src/mesh \ ../src/platform \ ../src/platform/android \ - ../src/platform/d3d9 \ ../src/platform/sdl \ ../src/platform/xbox \ - ../src/thread + ../src/thread \ + ../src/ui # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/src/Makefile.am b/src/Makefile.am index a602d05e..ea650aac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,11 +69,10 @@ liblol_core_headers = \ liblol_core_sources = \ application/application.cpp application/application.h \ + application/egl-app.cpp application/egl-app.h \ \ lolua/baselua.cpp lolua/baselua.h \ \ - eglapp.cpp eglapp.h \ - \ commandstack.h \ easymesh/easymeshbuild.cpp easymesh/easymeshbuild.h \ easymesh/easymeshrender.cpp easymesh/easymeshrender.h \ @@ -99,8 +98,9 @@ liblol_core_sources = \ \ audio/audio.cpp audio/sample.cpp \ \ - input/input.cpp input/input.h input/input_internal.h input/keys.inc \ - input/controller.cpp input/controller.h \ + ui/input.cpp ui/input.h ui/input_internal.h ui/keys.inc \ + ui/controller.cpp ui/controller.h \ + ui/gui.cpp ui/gui.h \ \ gpu/default-material.lolfx \ gpu/empty-material.lolfx \ @@ -142,19 +142,15 @@ liblol_core_sources = \ if LOL_USE_SDL sdl_sources = \ application/sdl-app.cpp application/sdl-app.h \ - input/sdl-input.cpp input/sdl-input.h + ui/sdl-input.cpp ui/sdl-input.h endif d3d9_sources = \ - platform/d3d9/d3d9input.cpp platform/d3d9/d3d9input.h + ui/d3d9-input.cpp ui/d3d9-input.h include 3rdparty/lol-imgui.am -imgui_sources += \ - lolimgui.cpp lolimgui.h \ - $(NULL) - android_sources = \ image/codec/android-image.cpp \ - platform/android/androidapp.cpp platform/android/androidapp.h + application/android-app.cpp application/android-app.h diff --git a/src/platform/android/androidapp.cpp b/src/application/android-app.cpp similarity index 98% rename from src/platform/android/androidapp.cpp rename to src/application/android-app.cpp index 4ab80922..e34d4c1c 100644 --- a/src/platform/android/androidapp.cpp +++ b/src/application/android-app.cpp @@ -27,9 +27,8 @@ extern "C" { #include } -#include "androidapp.h" - -#include "input/input_internal.h" +#include "application/android-app.h" +#include "ui/input_internal.h" using namespace lol; @@ -107,7 +106,7 @@ private: */ int lol::AndroidAppData::CreateDisplay() { - /* FIXME: there is a lot of code common to eglapp.cpp here. */ + /* FIXME: there is a lot of code common to egl-app.cpp here. */ const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, diff --git a/src/platform/android/androidapp.h b/src/application/android-app.h similarity index 100% rename from src/platform/android/androidapp.h rename to src/application/android-app.h diff --git a/src/application/application.cpp b/src/application/application.cpp index da8a66e8..0d93d355 100644 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -19,11 +19,11 @@ #include "lolgl.h" #if __ANDROID__ -# include "platform/android/androidapp.h" +# include "application/android-app.h" #elif LOL_USE_SDL # include "application/sdl-app.h" #elif HAVE_GLES_2X -# include "eglapp.h" +# include "application/egl-app.h" #endif namespace lol diff --git a/src/eglapp.cpp b/src/application/egl-app.cpp similarity index 99% rename from src/eglapp.cpp rename to src/application/egl-app.cpp index 357988ec..0737d769 100644 --- a/src/eglapp.cpp +++ b/src/application/egl-app.cpp @@ -27,11 +27,11 @@ #endif #if LOL_USE_SDL -# include "input/sdl-input.h" +# include "ui/sdl-input.h" #endif #include "lolgl.h" -#include "eglapp.h" +#include "application/egl-app.h" namespace lol { diff --git a/src/eglapp.h b/src/application/egl-app.h similarity index 100% rename from src/eglapp.h rename to src/application/egl-app.h diff --git a/src/application/sdl-app.cpp b/src/application/sdl-app.cpp index d7857b33..a2c005b7 100644 --- a/src/application/sdl-app.cpp +++ b/src/application/sdl-app.cpp @@ -22,9 +22,9 @@ #include "lolgl.h" #include "application/sdl-app.h" -#include "input/sdl-input.h" +#include "ui/sdl-input.h" #if LOL_USE_XINPUT -# include "platform/d3d9/d3d9input.h" +# include "ui/d3d9-input.h" #endif namespace lol diff --git a/src/lol-core.vcxproj b/src/lol-core.vcxproj index c618c966..819a5779 100644 --- a/src/lol-core.vcxproj +++ b/src/lol-core.vcxproj @@ -81,6 +81,7 @@ + true @@ -104,7 +105,6 @@ - @@ -149,13 +149,7 @@ - - - - true - - @@ -167,7 +161,6 @@ - @@ -178,10 +171,18 @@ + + + + + + true + + true @@ -195,7 +196,6 @@ - @@ -205,17 +205,9 @@ - - - - - - true - - @@ -285,7 +277,6 @@ - @@ -293,6 +284,15 @@ + + + + + + + + true + diff --git a/src/lol-core.vcxproj.filter b/src/lol-core.vcxproj.filter index 80638a63..d5cf41b1 100644 --- a/src/lol-core.vcxproj.filter +++ b/src/lol-core.vcxproj.filter @@ -22,7 +22,7 @@ {123803f1-1722-4421-8245-098667654cda} - + {94992c0e-ebc5-4185-b766-323b06547dcf} @@ -76,9 +76,6 @@ {317cb5cc-5dcc-4e14-be90-40a125a2e2ec} - - {a914e15d-3201-467a-a9c9-d7c5244b13ee} - {63e63eea-c96e-4d37-81f6-f3f17e18b751} @@ -123,8 +120,8 @@ application - - input + + ui math @@ -189,11 +186,11 @@ gpu - - input + + ui - - platform\d3d9 + + ui audio @@ -204,8 +201,8 @@ ... - - ... + + application ... @@ -279,8 +276,8 @@ debug - - input + + ui ... @@ -375,7 +372,9 @@ tileset - + + ui + mesh @@ -396,8 +395,8 @@ debug - - input + + ui application @@ -486,17 +485,17 @@ platform\xbox - - input + + ui - - platform\d3d9 + + ui ... - - ... + + application ... @@ -666,14 +665,14 @@ lol\image - - input + + ui - - input + + ui - - input + + ui ... @@ -721,7 +720,9 @@ tileset - + + ui + mesh diff --git a/src/lol/extras.h b/src/lol/extras.h index 4ac35e83..f5908675 100644 --- a/src/lol/extras.h +++ b/src/lol/extras.h @@ -27,10 +27,6 @@ #include #include -// Input -#include -#include - // Engine #include #include @@ -47,7 +43,11 @@ #include #include #include -#include + +// UI +#include +#include +#include // Other objects #include diff --git a/src/platform/emscripten/lol_shell.html b/src/platform/emscripten/lol_shell.html deleted file mode 100644 index 474d3552..00000000 --- a/src/platform/emscripten/lol_shell.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - -YOUR PAGE NAME HERE - - - - - -
- -
- - -
- Resize canvas - Lock/hide mouse pointer -     - -
- - - - - - - - - - - - diff --git a/src/input/controller.cpp b/src/ui/controller.cpp similarity index 98% rename from src/input/controller.cpp rename to src/ui/controller.cpp index 7d31bf71..a0b118cb 100644 --- a/src/input/controller.cpp +++ b/src/ui/controller.cpp @@ -59,11 +59,6 @@ bool KeyBinding::Unbind(const std::string& device_name, const std::string& key_n return false; } -void KeyBinding::ClearBindings() -{ - m_keybindings.clear(); -} - /////////////////////////////////////////////////////////////////////////////// // AxisBinding @@ -188,12 +183,6 @@ bool AxisBinding::UnbindKeys(const std::string& device_name, const std::string& } -void AxisBinding::ClearBindings() -{ - m_axisbindings.clear(); - m_keybindings.clear(); -} - float AxisBinding::RetrieveCurrentValue() { float max_positive = 0.0f; diff --git a/src/input/controller.h b/src/ui/controller.h similarity index 86% rename from src/input/controller.h rename to src/ui/controller.h index 3d69d103..2fc5a6ed 100644 --- a/src/input/controller.h +++ b/src/ui/controller.h @@ -53,10 +53,6 @@ public: bool UnbindMouse(const std::string& key_name) { return Unbind(g_name_mouse, key_name); } bool UnbindKeyboard(const std::string& key_name) { return Unbind(g_name_keyboard, key_name); } bool UnbindJoystick(const uint64_t num, const std::string& key_name) { return Unbind(g_name_joystick(num), key_name); } - /** Clear current binding */ - void ClearBindings(); - /** Indicate wheither a physical device and key has been bound. Returns the number of bindings set. */ - int IsBound() const { return m_keybindings.count(); } protected: /** Update the binding value. Called internally by the controller, once per frame */ @@ -110,29 +106,17 @@ public: /** Unbind a previously bound physical device and axis. Returns true if the binding was existing. */ bool UnbindKeys(const std::string& device_name, const std::string& min_key_name, const std::string& max_key_name); /* Small helpers */ - void BindMouse(const std::string& axis_name) { Bind(g_name_mouse, axis_name); } - void BindMouseKey(const std::string& key_name) { BindKey(g_name_mouse, key_name); } - void BindMouseKeys(const std::string& min_key_name, const std::string& max_key_name) { BindKeys(g_name_mouse, min_key_name, max_key_name); } - bool UnbindMouse(const std::string& axis_name) { return Unbind(g_name_mouse, axis_name); } - bool UnbindMouseKey(const std::string& key_name) { return UnbindKey(g_name_mouse, key_name); } - bool UnbindMouseKeys(const std::string& min_key_name, const std::string& max_key_name){ return UnbindKeys(g_name_mouse, min_key_name, max_key_name); } + void BindMouse(const std::string& axis_name) { Bind(g_name_mouse, axis_name); } + bool UnbindMouse(const std::string& axis_name) { return Unbind(g_name_mouse, axis_name); } /* */ - void BindJoystick(const uint64_t num, const std::string& axis_name) { Bind(g_name_joystick(num), axis_name); } - void BindJoystickKey(const uint64_t num, const std::string& key_name) { BindKey(g_name_joystick(num), key_name); } - void BindJoystickKeys(const uint64_t num, const std::string& min_key_name, const std::string& max_key_name) { BindKeys(g_name_joystick(num), min_key_name, max_key_name); } - bool UnbindJoystick(const uint64_t num, const std::string& axis_name) { return Unbind(g_name_joystick(num), axis_name); } - bool UnbindJoystickKey(const uint64_t num, const std::string& key_name) { return UnbindKey(g_name_joystick(num), key_name); } - bool UnbindJoystickKeys(const uint64_t num, const std::string& min_key_name, const std::string& max_key_name){ return UnbindKeys(g_name_joystick(num), min_key_name, max_key_name); } - /** Clear current binding */ - void ClearBindings(); - /** Indicate wheither a physical device and axis has been bound. Returns the number of bindings set. */ - int IsBound() const { return m_axisbindings.count() + m_keybindings.count(); } + void BindJoystick(const uint64_t num, const std::string& axis_name) { Bind(g_name_joystick(num), axis_name); } + bool UnbindJoystick(const uint64_t num, const std::string& axis_name) { return Unbind(g_name_joystick(num), axis_name); } protected: void Update() { m_previous = m_current; - m_current = IsBound() ? RetrieveCurrentValue() : 0.0f; + m_current = RetrieveCurrentValue(); } float RetrieveCurrentValue(); @@ -321,7 +305,7 @@ public: void register_default_keys() { #define _SC(id, str, name) *this << InputProfile::Keyboard(id, #name); -#include "input/keys.inc" +#include "ui/keys.inc" } private: diff --git a/src/platform/d3d9/d3d9input.cpp b/src/ui/d3d9-input.cpp similarity index 76% rename from src/platform/d3d9/d3d9input.cpp rename to src/ui/d3d9-input.cpp index d6652d60..0cfdb97c 100644 --- a/src/platform/d3d9/d3d9input.cpp +++ b/src/ui/d3d9-input.cpp @@ -20,13 +20,33 @@ #include -#include "d3d9input.h" - -#include "input/input_internal.h" +#include "ui/d3d9-input.h" +#include "ui/input_internal.h" namespace lol { +static const std::string g_name_xbox_key_dpad_up("DPadUp"); +static const std::string g_name_xbox_key_dpad_down("DPadDown"); +static const std::string g_name_xbox_key_dpad_left("DPadLeft"); +static const std::string g_name_xbox_key_dpad_right("DPadRight"); +static const std::string g_name_xbox_key_left_thumb("LeftThumb"); +static const std::string g_name_xbox_key_right_thumb("RightThumb"); +static const std::string g_name_xbox_key_left_shoulder("LeftShoulder"); +static const std::string g_name_xbox_key_right_shoulder("Rightshoulder"); +static const std::string g_name_xbox_key_a("A"); +static const std::string g_name_xbox_key_b("B"); +static const std::string g_name_xbox_key_x("X"); +static const std::string g_name_xbox_key_y("Y"); +static const std::string g_name_xbox_key_start("Start"); +static const std::string g_name_xbox_key_back("Back"); +static const std::string g_name_xbox_axis_left_x("Axis1"); +static const std::string g_name_xbox_axis_left_y("Axis2"); +static const std::string g_name_xbox_axis_right_x("Axis3"); +static const std::string g_name_xbox_axis_right_y("Axis4"); +static const std::string g_name_xbox_axis_left_trigger("Axis5"); +static const std::string g_name_xbox_axis_right_trigger("Axis6"); + /* * D3d9 Input implementation class */ diff --git a/src/platform/d3d9/d3d9input.h b/src/ui/d3d9-input.h similarity index 100% rename from src/platform/d3d9/d3d9input.h rename to src/ui/d3d9-input.h diff --git a/src/lolimgui.cpp b/src/ui/gui.cpp similarity index 100% rename from src/lolimgui.cpp rename to src/ui/gui.cpp diff --git a/src/lolimgui.h b/src/ui/gui.h similarity index 100% rename from src/lolimgui.h rename to src/ui/gui.h diff --git a/src/input/input.cpp b/src/ui/input.cpp similarity index 96% rename from src/input/input.cpp rename to src/ui/input.cpp index 0c60e54c..97694048 100644 --- a/src/input/input.cpp +++ b/src/ui/input.cpp @@ -16,7 +16,7 @@ #include #include -#include "input/input_internal.h" +#include "ui/input_internal.h" namespace lol { @@ -25,19 +25,19 @@ namespace lol static std::vector g_all_keys { #define _SC(code, str, name) input::key::SC_##name, -#include "input/keys.inc" +#include "ui/keys.inc" }; static std::map g_key_to_name { #define _SC(code, str, name) { input::key::SC_##name, #name }, -#include "input/keys.inc" +#include "ui/keys.inc" }; static std::map g_name_to_key { #define _SC(code, str, name) { #name, input::key::SC_##name }, -#include "input/keys.inc" +#include "ui/keys.inc" }; std::vector const &input::all_keys() @@ -136,7 +136,7 @@ InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() /* Register all scancodes known to SDL (from the USB standard) */ # define _SC(id, str, name) keyboard->AddKey(id, #name); -# include "input/keys.inc" +# include "ui/keys.inc" return keyboard; } diff --git a/src/input/input.h b/src/ui/input.h similarity index 85% rename from src/input/input.h rename to src/ui/input.h index 8c386b49..13ac67dc 100644 --- a/src/input/input.h +++ b/src/ui/input.h @@ -25,7 +25,7 @@ public: enum class key : uint16_t { #define _SC(id, str, name) SC_##name = id, -#include "input/keys.inc" +#include "ui/keys.inc" }; static std::vector const &all_keys(); @@ -33,7 +33,6 @@ public: static key name_to_key(std::string const &name); }; -const std::string g_name_max("MAX"); const std::string g_name_mouse("Mouse"); const std::string g_name_keyboard("Keyboard"); @@ -55,28 +54,6 @@ const std::string g_name_mouse_axis_ypixel("YPixel"); const std::string g_name_mouse_axis_scroll("Scroll"); const std::string g_name_mouse_cursor("Cursor"); -// Xbox default buttons/axis -const std::string g_name_xbox_key_dpad_up("DPadUp"); -const std::string g_name_xbox_key_dpad_down("DPadDown"); -const std::string g_name_xbox_key_dpad_left("DPadLeft"); -const std::string g_name_xbox_key_dpad_right("DPadRight"); -const std::string g_name_xbox_key_left_thumb("LeftThumb"); -const std::string g_name_xbox_key_right_thumb("RightThumb"); -const std::string g_name_xbox_key_left_shoulder("LeftShoulder"); -const std::string g_name_xbox_key_right_shoulder("Rightshoulder"); -const std::string g_name_xbox_key_a("A"); -const std::string g_name_xbox_key_b("B"); -const std::string g_name_xbox_key_x("X"); -const std::string g_name_xbox_key_y("Y"); -const std::string g_name_xbox_key_start("Start"); -const std::string g_name_xbox_key_back("Back"); -const std::string g_name_xbox_axis_left_x("Axis1"); -const std::string g_name_xbox_axis_left_y("Axis2"); -const std::string g_name_xbox_axis_right_x("Axis3"); -const std::string g_name_xbox_axis_right_y("Axis4"); -const std::string g_name_xbox_axis_left_trigger("Axis5"); -const std::string g_name_xbox_axis_right_trigger("Axis6"); - class InputDevice { public: diff --git a/src/input/input_internal.h b/src/ui/input_internal.h similarity index 100% rename from src/input/input_internal.h rename to src/ui/input_internal.h diff --git a/src/input/keys.inc b/src/ui/keys.inc similarity index 100% rename from src/input/keys.inc rename to src/ui/keys.inc diff --git a/src/input/sdl-input.cpp b/src/ui/sdl-input.cpp similarity index 98% rename from src/input/sdl-input.cpp rename to src/ui/sdl-input.cpp index 8925bf54..922f6d89 100644 --- a/src/input/sdl-input.cpp +++ b/src/ui/sdl-input.cpp @@ -23,8 +23,8 @@ # include #endif -#include "input/input_internal.h" -#include "input/sdl-input.h" +#include "ui/input_internal.h" +#include "ui/sdl-input.h" /* We force joystick polling because no events are received when * there is no SDL display (eg. on the Raspberry Pi). */ @@ -47,7 +47,7 @@ static String ScanCodeToText(int sc) { #define _SC(id, str, name) \ case id: return String(str); -#include "input/keys.inc" +#include "ui/keys.inc" default: msg::error("ScanCodeToText unknown scancode %0d\n", sc); } @@ -62,7 +62,7 @@ static String ScanCodeToName(int sc) { #define _SC(id, str, name) \ case id: return String(#name); -#include "input/keys.inc" +#include "ui/keys.inc" default: msg::error("ScanCodeToText unknown scancode %0d\n", sc); } diff --git a/src/input/sdl-input.h b/src/ui/sdl-input.h similarity index 100% rename from src/input/sdl-input.h rename to src/ui/sdl-input.h