From: Mikko Rasa Date: Sun, 27 Nov 2022 10:51:13 +0000 (+0200) Subject: Use default member initializers and defaulted default constructors X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=294c354ae3b1f26887c37f866f082e52c08d80f1;p=libs%2Fgui.git Use default member initializers and defaulted default constructors --- diff --git a/source/graphics/android/display.cpp b/source/graphics/android/display.cpp index d62c877..a44687e 100644 --- a/source/graphics/android/display.cpp +++ b/source/graphics/android/display.cpp @@ -8,17 +8,13 @@ using namespace std; namespace Msp { namespace Graphics { -Display::Display(const string &): - primary_monitor(0), - focus_window(0) +Display::Display(const string &) { Android::MainThread *thread = reinterpret_cast(Application::get_data()); if(!thread->is_starting_up()) throw logic_error("Display must be created during startup"); priv = new Private; - priv->input_queue = 0; - priv->native_window = 0; thread->signal_native_window_created.connect(sigc::mem_fun(priv, &PlatformDisplayPrivate::native_window_created)); thread->signal_native_window_resized.connect(sigc::mem_fun(priv, &PlatformDisplayPrivate::native_window_resized)); diff --git a/source/graphics/android/display_platform.h b/source/graphics/android/display_platform.h index 32c1bed..207f6ef 100644 --- a/source/graphics/android/display_platform.h +++ b/source/graphics/android/display_platform.h @@ -14,10 +14,10 @@ typedef void *DisplayHandle; struct PlatformDisplayPrivate: public sigc::trackable { - AInputQueue *input_queue; + AInputQueue *input_queue = 0; std::list events; Mutex event_mutex; - WindowHandle native_window; + WindowHandle native_window = 0; Mutex window_mutex; void push_event(AndroidEventType); diff --git a/source/graphics/android/window.cpp b/source/graphics/android/window.cpp index 301af2a..d3260ca 100644 --- a/source/graphics/android/window.cpp +++ b/source/graphics/android/window.cpp @@ -10,7 +10,6 @@ namespace Graphics { void Window::platform_init() { - priv->window = 0; } void Window::platform_cleanup() diff --git a/source/graphics/android/window_platform.h b/source/graphics/android/window_platform.h index 3ed8f84..633444b 100644 --- a/source/graphics/android/window_platform.h +++ b/source/graphics/android/window_platform.h @@ -26,7 +26,7 @@ struct PlatformWindowPrivate struct PlatformEvent { AndroidEventType type; - AInputEvent *aevent; + AInputEvent *aevent = 0; }; } // namespace Graphics diff --git a/source/graphics/bmploader.cpp b/source/graphics/bmploader.cpp index 8a6c7a0..b85cce1 100644 --- a/source/graphics/bmploader.cpp +++ b/source/graphics/bmploader.cpp @@ -29,8 +29,7 @@ namespace Graphics { BmpLoader::BmpLoader(IO::Base &i, unsigned sb): io(i), - sig_bytes(sb), - invert_row_order(false) + sig_bytes(sb) { // Image data location is stored at offset 10 and can't be skipped if(sig_bytes>10) diff --git a/source/graphics/bmploader.h b/source/graphics/bmploader.h index 60d4a2e..926516d 100644 --- a/source/graphics/bmploader.h +++ b/source/graphics/bmploader.h @@ -10,8 +10,8 @@ class BmpLoader: public ImageLoader { private: IO::Base &io; - unsigned sig_bytes; - bool invert_row_order; + unsigned sig_bytes = 0; + bool invert_row_order = false; public: BmpLoader(IO::Base &, unsigned = 0); diff --git a/source/graphics/cgl/glcontext.cpp b/source/graphics/cgl/glcontext.cpp index d05364e..c1a3a0e 100644 --- a/source/graphics/cgl/glcontext.cpp +++ b/source/graphics/cgl/glcontext.cpp @@ -14,7 +14,7 @@ typedef CocoaGLContext *ContextHandle; struct GLContext::Private { - ContextHandle context; + ContextHandle context = 0; }; void GLContext::platform_init(const GLOptions &opts) diff --git a/source/graphics/cocoa/display.cpp b/source/graphics/cocoa/display.cpp index 367691e..bf0c562 100644 --- a/source/graphics/cocoa/display.cpp +++ b/source/graphics/cocoa/display.cpp @@ -9,9 +9,7 @@ namespace Msp { namespace Graphics { Display::Display(const string &): - primary_monitor(0), - priv(new Private), - focus_window(0) + priv(new Private) { static ErrorDialog err_dlg(0); diff --git a/source/graphics/devil/devilloader.h b/source/graphics/devil/devilloader.h index 2a8e28d..beab02f 100644 --- a/source/graphics/devil/devilloader.h +++ b/source/graphics/devil/devilloader.h @@ -10,7 +10,7 @@ class DevilLoader: public ImageLoader { private: IO::Base &io; - unsigned id; + unsigned id = 0; public: DevilLoader(IO::Seekable &); diff --git a/source/graphics/display.h b/source/graphics/display.h index 092abbe..da3eafa 100644 --- a/source/graphics/display.h +++ b/source/graphics/display.h @@ -24,11 +24,11 @@ public: private: std::list monitors; - Monitor *primary_monitor; + Monitor *primary_monitor = 0; std::list modes; - Private *priv; - ErrorDialog *err_dialog; - Window *focus_window; + Private *priv = 0; + ErrorDialog *err_dialog = 0; + Window *focus_window = 0; public: Display(const std::string &disp_name = std::string()); diff --git a/source/graphics/display_private.h b/source/graphics/display_private.h index d5f0bf0..71fc094 100644 --- a/source/graphics/display_private.h +++ b/source/graphics/display_private.h @@ -12,7 +12,7 @@ namespace Graphics { struct Display::Private: PlatformDisplayPrivate { - DisplayHandle display; + DisplayHandle display = 0; std::map windows; }; diff --git a/source/graphics/egl_android/glcontext.cpp b/source/graphics/egl_android/glcontext.cpp index 26a4063..ebdb801 100644 --- a/source/graphics/egl_android/glcontext.cpp +++ b/source/graphics/egl_android/glcontext.cpp @@ -13,10 +13,10 @@ namespace Graphics { struct GLContext::Private { - EGLDisplay display; - EGLConfig config; - EGLSurface surface; - EGLContext context; + EGLDisplay display = EGL_NO_DISPLAY; + EGLConfig config = EGL_NO_CONFIG; + EGLSurface surface = EGL_NO_SURFACE; + EGLContext context = EGL_NO_CONTEXT; void attach(WindowHandle); void detach(); diff --git a/source/graphics/errordialog.h b/source/graphics/errordialog.h index 562883c..e0c423c 100644 --- a/source/graphics/errordialog.h +++ b/source/graphics/errordialog.h @@ -11,7 +11,7 @@ class Display; class ErrorDialog: public Debug::ErrorReporter { private: - Display *display; + Display *display = 0; public: ErrorDialog(Display *d): display(d) { } diff --git a/source/graphics/glcontext.cpp b/source/graphics/glcontext.cpp index 16c1a55..a66ca30 100644 --- a/source/graphics/glcontext.cpp +++ b/source/graphics/glcontext.cpp @@ -8,18 +8,6 @@ using namespace std; namespace Msp { namespace Graphics { -GLOptions::GLOptions(): - alpha(false), - stencil(false), - doublebuffer(true), - multisample(0), - forward_compatible(false), - core_profile(false), - gl_version_major(DEFAULT_VERSION), - gl_version_minor(DEFAULT_VERSION) -{ } - - unsupported_gl_mode::unsupported_gl_mode(const GLOptions &opts): runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d, .forward_compatible=%s, .core_profile=%s, .gl_version=%s }", opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample, opts.forward_compatible, opts.core_profile, format_version(opts))) diff --git a/source/graphics/glcontext.h b/source/graphics/glcontext.h index 986dd91..7f08f0e 100644 --- a/source/graphics/glcontext.h +++ b/source/graphics/glcontext.h @@ -17,16 +17,14 @@ struct GLOptions LATEST_VERSION = 0xFFFFFFFF }; - bool alpha; - bool stencil; - bool doublebuffer; - unsigned multisample; - bool forward_compatible; - bool core_profile; - unsigned gl_version_major; - unsigned gl_version_minor; - - GLOptions(); + bool alpha = false; + bool stencil = false; + bool doublebuffer = true; + unsigned multisample = 0; + bool forward_compatible = false; + bool core_profile = false; + unsigned gl_version_major = DEFAULT_VERSION; + unsigned gl_version_minor = DEFAULT_VERSION; }; @@ -47,7 +45,7 @@ private: Display &display; Window &window; - Private *priv; + Private *priv = 0; public: GLContext(Window &wnd, const GLOptions &opts = GLOptions()); diff --git a/source/graphics/glx/glcontext.cpp b/source/graphics/glx/glcontext.cpp index 6859e3e..699f856 100644 --- a/source/graphics/glx/glcontext.cpp +++ b/source/graphics/glx/glcontext.cpp @@ -17,10 +17,10 @@ typedef GLXContext ContextHandle; struct GLContext::Private { - ContextHandle context; + ContextHandle context = 0; // We need to create a window with the chosen visual - WindowHandle subwnd; - GLXWindow glxwnd; + WindowHandle subwnd = None; + GLXWindow glxwnd = None; }; diff --git a/source/graphics/image.cpp b/source/graphics/image.cpp index 2903d49..5b2eb1a 100644 --- a/source/graphics/image.cpp +++ b/source/graphics/image.cpp @@ -10,14 +10,6 @@ using namespace std; namespace Msp { namespace Graphics { -Image::Data::Data(): - fmt(RGB), - width(0), - height(0), - owned_pixels(0), - pixels(0) -{ } - Image::Data::Data(const Data &other): fmt(other.fmt), width(other.width), diff --git a/source/graphics/image.h b/source/graphics/image.h index 51147ce..d9f5870 100644 --- a/source/graphics/image.h +++ b/source/graphics/image.h @@ -16,14 +16,14 @@ class Image public: struct Data { - PixelFormat fmt; - unsigned width; - unsigned height; - unsigned stride; - char *owned_pixels; - char *pixels; - - Data(); + PixelFormat fmt = RGB; + unsigned width = 0; + unsigned height = 0; + unsigned stride = 0; + char *owned_pixels = 0; + char *pixels = 0; + + Data() = default; Data(const Data &); Data &operator=(const Data &); ~Data(); diff --git a/source/graphics/imageloader.cpp b/source/graphics/imageloader.cpp index 0746f6f..fe88f40 100644 --- a/source/graphics/imageloader.cpp +++ b/source/graphics/imageloader.cpp @@ -22,11 +22,6 @@ using namespace std; namespace Msp { namespace Graphics { -ImageLoader::ImageLoader(): - source(0), - state(INITIAL) -{ } - ImageLoader::~ImageLoader() { delete source; @@ -141,10 +136,6 @@ bool ImageLoader::signature_size_compare(RegisterBase *r1, RegisterBase *r2) } -ImageLoader::Registry::Registry(): - changed(false) -{ } - ImageLoader::Registry::~Registry() { for(auto l: loaders) diff --git a/source/graphics/imageloader.h b/source/graphics/imageloader.h index 9645f11..65f3c56 100644 --- a/source/graphics/imageloader.h +++ b/source/graphics/imageloader.h @@ -54,18 +54,17 @@ protected: struct Registry { std::list loaders; - bool changed; + bool changed = false; - Registry(); ~Registry(); }; private: - IO::Base *source; - State state; + IO::Base *source = 0; + State state = INITIAL; protected: - ImageLoader(); + ImageLoader() = default; public: virtual ~ImageLoader(); diff --git a/source/graphics/jpeg/jpegloader.h b/source/graphics/jpeg/jpegloader.h index 793951a..4773168 100644 --- a/source/graphics/jpeg/jpegloader.h +++ b/source/graphics/jpeg/jpegloader.h @@ -11,7 +11,7 @@ class JpegLoader: public ImageLoader private: struct Private; - Private *priv; + Private *priv = 0; public: JpegLoader(IO::Seekable &); diff --git a/source/graphics/monitor.cpp b/source/graphics/monitor.cpp deleted file mode 100644 index d1bdd43..0000000 --- a/source/graphics/monitor.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "monitor.h" - -using namespace std; - -namespace Msp { -namespace Graphics { - -Monitor::Monitor(): - index(0), - next_left(0), - next_right(0) -{ } - - -Monitor::Settings::Settings(): - mode(0), - rotation(ROTATE_NORMAL), - x(0), - y(0) -{ } - -} // namespace Graphics -} // namespace Msp diff --git a/source/graphics/monitor.h b/source/graphics/monitor.h index fefd986..0fc9798 100644 --- a/source/graphics/monitor.h +++ b/source/graphics/monitor.h @@ -12,22 +12,19 @@ struct Monitor { struct Settings { - const VideoMode *mode; - VideoRotation rotation; - int x, y; - - Settings(); + const VideoMode *mode = 0; + VideoRotation rotation = ROTATE_NORMAL; + int x = 0; + int y = 0; }; - unsigned index; + unsigned index = 0; std::string name; std::list video_modes; Settings desktop_settings; Settings current_settings; - const Monitor *next_left; - const Monitor *next_right; - - Monitor(); + const Monitor *next_left = 0; + const Monitor *next_right = 0; }; } // namespace Graphics diff --git a/source/graphics/png/pngloader.cpp b/source/graphics/png/pngloader.cpp index aae7015..850bbf0 100644 --- a/source/graphics/png/pngloader.cpp +++ b/source/graphics/png/pngloader.cpp @@ -26,10 +26,10 @@ namespace Graphics { struct PngLoader::Private { - std::string message; - png_struct *png; - png_info *info; - int interlace; + string message; + png_struct *png = 0; + png_info *info = 0; + int interlace = PNG_INTERLACE_NONE; }; diff --git a/source/graphics/png/pngloader.h b/source/graphics/png/pngloader.h index 8023b01..c21cc5a 100644 --- a/source/graphics/png/pngloader.h +++ b/source/graphics/png/pngloader.h @@ -11,7 +11,7 @@ class PngLoader: public ImageLoader private: struct Private; - Private *priv; + Private *priv = 0; public: PngLoader(IO::Base &, unsigned = 0); diff --git a/source/graphics/quartz/quartzloader.h b/source/graphics/quartz/quartzloader.h index 2aa0588..c4517ec 100644 --- a/source/graphics/quartz/quartzloader.h +++ b/source/graphics/quartz/quartzloader.h @@ -11,7 +11,7 @@ class QuartzLoader: public ImageLoader private: struct Private; - Private *priv; + Private *priv = 0; public: QuartzLoader(IO::Seekable &); diff --git a/source/graphics/videomode.cpp b/source/graphics/videomode.cpp index dfd002e..d9c2079 100644 --- a/source/graphics/videomode.cpp +++ b/source/graphics/videomode.cpp @@ -9,22 +9,9 @@ unsupported_video_mode::unsupported_video_mode(const VideoMode &mode): { } -VideoMode::VideoMode(): - index(0), - monitor(0), - width(0), - height(0), - rate(0), - rotation(ROTATE_ANY) -{ } - VideoMode::VideoMode(unsigned w, unsigned h): - index(0), - monitor(0), width(w), - height(h), - rate(0), - rotation(ROTATE_ANY) + height(h) { } } // namespace Graphics diff --git a/source/graphics/videomode.h b/source/graphics/videomode.h index 205245c..6c83d94 100644 --- a/source/graphics/videomode.h +++ b/source/graphics/videomode.h @@ -27,14 +27,14 @@ enum VideoRotation struct VideoMode { - unsigned index; - const Monitor *monitor; - unsigned width; - unsigned height; - float rate; - VideoRotation rotation; - - VideoMode(); + unsigned index = 0; + const Monitor *monitor = 0; + unsigned width = 0; + unsigned height = 0; + float rate = 0.0f; + VideoRotation rotation = ROTATE_ANY; + + VideoMode() = default; VideoMode(unsigned, unsigned); }; diff --git a/source/graphics/vkxlib/vulkancontext.cpp b/source/graphics/vkxlib/vulkancontext.cpp index 0d332b3..439ece6 100644 --- a/source/graphics/vkxlib/vulkancontext.cpp +++ b/source/graphics/vkxlib/vulkancontext.cpp @@ -61,13 +61,6 @@ string vulkan_error::get_error_message(unsigned code) } } -VulkanOptions::VulkanOptions(): - enable_validation(false), - enable_debug_report(false), - enable_geometry_shader(false), - enable_tessellation_shader(false) -{ } - void VulkanContext::platform_init(const VulkanOptions &opts) { @@ -131,8 +124,6 @@ void VulkanContext::platform_init(const VulkanOptions &opts) if(result!=VK_SUCCESS) throw vulkan_error(result, "vkCreateDebugReportCallback"); } - else - priv->debug_report_callback = 0; VkXlibSurfaceCreateInfoKHR surface_create_info = { }; surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; @@ -154,7 +145,6 @@ void VulkanContext::platform_init(const VulkanOptions &opts) if(result!=VK_SUCCESS) throw vulkan_error(result, "vkEnumeratePhysicalDevices"); - priv->physical_device = 0; unsigned gfx_queue_index = 0; for(unsigned i=0; iwindow) throw system_error("CreateWindowEx"); - - priv->cursor_in_client_area = false; - priv->cursor_visible = true; } void Window::platform_cleanup() diff --git a/source/graphics/windows/window_platform.h b/source/graphics/windows/window_platform.h index 77f4526..35d2ab3 100644 --- a/source/graphics/windows/window_platform.h +++ b/source/graphics/windows/window_platform.h @@ -10,8 +10,8 @@ typedef HWND WindowHandle; struct PlatformWindowPrivate { - bool cursor_in_client_area; - bool cursor_visible; + bool cursor_in_client_area = false; + bool cursor_visible = true; }; struct PlatformEvent diff --git a/source/graphics/x11/display.cpp b/source/graphics/x11/display.cpp index 8209deb..9e82627 100644 --- a/source/graphics/x11/display.cpp +++ b/source/graphics/x11/display.cpp @@ -84,9 +84,7 @@ namespace Msp { namespace Graphics { Display::Display(const string &disp_name): - primary_monitor(0), - priv(new Private), - focus_window(0) + priv(new Private) { if(disp_name.empty()) priv->display = XOpenDisplay(0); diff --git a/source/graphics/x11/window.cpp b/source/graphics/x11/window.cpp index fb77c32..e33511e 100644 --- a/source/graphics/x11/window.cpp +++ b/source/graphics/x11/window.cpp @@ -25,10 +25,6 @@ void Window::platform_init() DisplayHandle dpy = display.get_private().display; priv->wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", true); - priv->invisible_cursor = 0; - priv->reparented = false; - priv->rel_x = 0; - priv->rel_y = 0; XSetWindowAttributes attr; attr.override_redirect = options.fullscreen; diff --git a/source/graphics/x11/window_platform.h b/source/graphics/x11/window_platform.h index 41cdec8..a727297 100644 --- a/source/graphics/x11/window_platform.h +++ b/source/graphics/x11/window_platform.h @@ -10,11 +10,11 @@ typedef ::Window WindowHandle; struct PlatformWindowPrivate { - Atom wm_delete_window; - Cursor invisible_cursor; - bool reparented; - int rel_x; - int rel_y; + Atom wm_delete_window = None; + Cursor invisible_cursor = None; + bool reparented = false; + int rel_x = 0; + int rel_y = 0; }; struct PlatformEvent diff --git a/source/input/binarycontrol.cpp b/source/input/binarycontrol.cpp index 09efe40..df07fb9 100644 --- a/source/input/binarycontrol.cpp +++ b/source/input/binarycontrol.cpp @@ -4,21 +4,12 @@ namespace Msp { namespace Input { -BinaryControl::BinaryControl(): - state(false), - threshold(0.5) -{ } - BinaryControl::BinaryControl(const ControlSource &s): - Control(s), - state(false), - threshold(0.5) + Control(s) { } BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i): - Control(d, t, i), - state(false), - threshold(0.5) + Control(d, t, i) { } BinaryControl::~BinaryControl() diff --git a/source/input/binarycontrol.h b/source/input/binarycontrol.h index e71f4c3..0d71bdc 100644 --- a/source/input/binarycontrol.h +++ b/source/input/binarycontrol.h @@ -18,11 +18,11 @@ public: sigc::signal signal_release; private: - bool state; - float threshold; + bool state = false; + float threshold = 0.5f; public: - BinaryControl(); + BinaryControl() = default; BinaryControl(const ControlSource &); BinaryControl(Device &, ControlSrcType, unsigned); ~BinaryControl(); diff --git a/source/input/bindings.h b/source/input/bindings.h index b5e3a3b..f5a935d 100644 --- a/source/input/bindings.h +++ b/source/input/bindings.h @@ -69,9 +69,9 @@ public: }; std::string control; - unsigned device; - ControlSrcType type; - unsigned index; + unsigned device = 0; + ControlSrcType type = NONE; + unsigned index = 0; }; private: diff --git a/source/input/control.cpp b/source/input/control.cpp index f82b9c3..fb1d376 100644 --- a/source/input/control.cpp +++ b/source/input/control.cpp @@ -9,12 +9,6 @@ using namespace std; namespace Msp { namespace Input { -ControlSource::ControlSource(): - dev(0), - type(NONE), - index(0) -{ } - ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i): dev(&d), type(t), @@ -36,30 +30,12 @@ std::string ControlSource::str() const } -Control::Control(): - capture_dev(0), - activator(0), - origin(0), - rising_edge(false), - falling_edge(false) -{ } - Control::Control(const ControlSource &s): - src(s), - capture_dev(0), - activator(0), - origin(0), - rising_edge(false), - falling_edge(false) + src(s) { } Control::Control(Device &d, ControlSrcType t, unsigned i): - src(d, t, i), - capture_dev(0), - activator(0), - origin(0), - rising_edge(false), - falling_edge(false) + src(d, t, i) { connect_signals(); } diff --git a/source/input/control.h b/source/input/control.h index 7a4fd0e..dcf7bf3 100644 --- a/source/input/control.h +++ b/source/input/control.h @@ -25,11 +25,11 @@ different types of controls in a uniform way. */ struct ControlSource { - Device *dev; - ControlSrcType type; - unsigned index; + Device *dev = 0; + ControlSrcType type = NONE; + unsigned index = 0; - ControlSource(); + ControlSource() = default; ControlSource(Device &, ControlSrcType, unsigned); std::string str() const; }; @@ -55,13 +55,13 @@ public: protected: ControlSource src; - Device *capture_dev; - BinaryControl *activator; - float origin; - bool rising_edge; - bool falling_edge; + Device *capture_dev = 0; + BinaryControl *activator = 0; + float origin = 0.0f; + bool rising_edge = false; + bool falling_edge = false; - Control(); + Control() = default; Control(const ControlSource &); Control(Device &, ControlSrcType, unsigned); public: diff --git a/source/input/device.h b/source/input/device.h index 5ef6305..e800290 100644 --- a/source/input/device.h +++ b/source/input/device.h @@ -57,7 +57,7 @@ public: sigc::signal::accumulated signal_axis_motion; protected: - DeviceType type; + DeviceType type = UNSPECIFIED; std::string name; std::vector buttons; std::vector axes; diff --git a/source/input/gamecontroller.h b/source/input/gamecontroller.h index 19f98d5..6393ac0 100644 --- a/source/input/gamecontroller.h +++ b/source/input/gamecontroller.h @@ -13,8 +13,8 @@ class GameController: public Device private: struct Private; - Private *priv; - IO::EventDispatcher *event_disp; + Private *priv = 0; + IO::EventDispatcher *event_disp = 0; static bool detect_done; static unsigned n_detected_controllers; diff --git a/source/input/gesturedetector.cpp b/source/input/gesturedetector.cpp index f6678e8..1b57789 100644 --- a/source/input/gesturedetector.cpp +++ b/source/input/gesturedetector.cpp @@ -11,10 +11,7 @@ namespace Input { GestureDetector::GestureDetector(Touchscreen &ts): Device(UNSPECIFIED), - touchscreen(ts), - current_gesture(GESTURE_NONE), - pending_tap(GESTURE_NONE), - invalid_gesture(false) + touchscreen(ts) { name = "Gesture"; diff --git a/source/input/gesturedetector.h b/source/input/gesturedetector.h index 5f7c4af..7f9726c 100644 --- a/source/input/gesturedetector.h +++ b/source/input/gesturedetector.h @@ -49,11 +49,11 @@ private: Touchscreen &touchscreen; TouchPoint points[MAX_POINTS]; - Gesture current_gesture; - Gesture pending_tap; - bool invalid_gesture; - float threshold_x_sq; - float threshold_y_sq; + Gesture current_gesture = GESTURE_NONE; + Gesture pending_tap = GESTURE_NONE; + bool invalid_gesture = false; + float threshold_x_sq = 1.0f; + float threshold_y_sq = 1.0f; public: GestureDetector(Touchscreen &); diff --git a/source/input/linux/gamecontroller.cpp b/source/input/linux/gamecontroller.cpp index c6b17c8..06008bc 100644 --- a/source/input/linux/gamecontroller.cpp +++ b/source/input/linux/gamecontroller.cpp @@ -16,8 +16,7 @@ namespace Input { vector GameController::Private::detected_controllers; GameController::GameController(unsigned index): - Device(GAME_CONTROLLER), - event_disp(0) + Device(GAME_CONTROLLER) { if(!detect_done) detect(); diff --git a/source/input/linux/gamecontroller_platform.h b/source/input/linux/gamecontroller_platform.h index 58313b6..8676875 100644 --- a/source/input/linux/gamecontroller_platform.h +++ b/source/input/linux/gamecontroller_platform.h @@ -33,7 +33,7 @@ public: struct GameController::Private { - JsDevice *dev; + JsDevice *dev = 0; static std::vector detected_controllers; }; diff --git a/source/input/smoothcontrol.cpp b/source/input/smoothcontrol.cpp index c9d0a3c..988509b 100644 --- a/source/input/smoothcontrol.cpp +++ b/source/input/smoothcontrol.cpp @@ -6,27 +6,12 @@ using namespace std; namespace Msp { namespace Input { -SmoothControl::SmoothControl(): - value(0), - paired_ctrl(0), - dead_zone(0.1), - threshold(0.9) -{ } - SmoothControl::SmoothControl(const ControlSource &s): - Control(s), - value(0), - paired_ctrl(0), - dead_zone(0.1), - threshold(0.9) + Control(s) { } SmoothControl::SmoothControl(Device &d, ControlSrcType t, unsigned i): - Control(d, t, i), - value(0), - paired_ctrl(0), - dead_zone(0.1), - threshold(0.9) + Control(d, t, i) { } SmoothControl::~SmoothControl() diff --git a/source/input/smoothcontrol.h b/source/input/smoothcontrol.h index 11744dd..5f71824 100644 --- a/source/input/smoothcontrol.h +++ b/source/input/smoothcontrol.h @@ -20,13 +20,13 @@ public: sigc::signal signal_motion; private: - float value; - SmoothControl *paired_ctrl; - float dead_zone; - float threshold; + float value = 0.0f; + SmoothControl *paired_ctrl = 0; + float dead_zone = 0.1f; + float threshold = 0.9f; public: - SmoothControl(); + SmoothControl() = default; SmoothControl(const ControlSource &); SmoothControl(Device &, ControlSrcType, unsigned); ~SmoothControl(); diff --git a/source/input/windows/gamecontroller.cpp b/source/input/windows/gamecontroller.cpp index 9c6853a..df29666 100644 --- a/source/input/windows/gamecontroller.cpp +++ b/source/input/windows/gamecontroller.cpp @@ -101,13 +101,6 @@ void GameController::tick(const Time::TimeDelta &) } -GameController::Private::Private(): - index(0), - last_packet_number(0), - event_pipe(0), - timer_slot(0) -{ } - bool GameController::Private::generate_event() { event_pipe->put(1); @@ -144,8 +137,7 @@ void GameController::Private::update_state(GameController &ctrl, const XINPUT_ST GameControllerTimerThread *GameControllerTimerThread::thread = 0; GameControllerTimerThread::GameControllerTimerThread(): - Thread("GameController"), - n_users(0) + Thread("GameController") { launch(); } diff --git a/source/input/windows/gamecontroller_platform.h b/source/input/windows/gamecontroller_platform.h index 928ad67..d6ee6c2 100644 --- a/source/input/windows/gamecontroller_platform.h +++ b/source/input/windows/gamecontroller_platform.h @@ -14,7 +14,7 @@ class GameControllerTimerThread: public Msp::Thread { private: Time::Timer timer; - unsigned n_users; + unsigned n_users = 0; static GameControllerTimerThread *thread; @@ -31,15 +31,13 @@ private: struct GameController::Private { - unsigned index; - unsigned last_packet_number; - IO::Pipe *event_pipe; - Time::Timer::Slot *timer_slot; + unsigned index = 0; + unsigned last_packet_number = 0; + IO::Pipe *event_pipe = 0; + Time::Timer::Slot *timer_slot = 0; static std::vector detected_controllers; - Private(); - bool generate_event(); void update_state(GameController &, const XINPUT_STATE &, bool);