From c9eca9e8d21211ce9d04fb47796179678fe34cbc Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Fri, 3 Nov 2023 02:36:03 +0200 Subject: [PATCH] * Fix first mouse event being skipped due to reading garbage --- source/client/player/input/MouseDevice.cpp | 12 ++++++++++++ source/client/player/input/MouseDevice.hpp | 1 + 2 files changed, 13 insertions(+) diff --git a/source/client/player/input/MouseDevice.cpp b/source/client/player/input/MouseDevice.cpp index bd668fe..3827e5c 100644 --- a/source/client/player/input/MouseDevice.cpp +++ b/source/client/player/input/MouseDevice.cpp @@ -8,6 +8,18 @@ #include "MouseDevice.hpp" +MouseDevice::MouseDevice() +{ + _index = -1; + _x = 0; + _y = 0; + _xOld = 0; + _yOld = 0; + + for (int i = 0; i < BUTTON_COUNT; i++) + _buttonStates[i] = 0; +} + void MouseDevice::feed(MouseButtonType buttonType, bool buttonState, int posX, int posY) { if (buttonType != BUTTON_NONE) diff --git a/source/client/player/input/MouseDevice.hpp b/source/client/player/input/MouseDevice.hpp index 5ffdbe9..65a533f 100644 --- a/source/client/player/input/MouseDevice.hpp +++ b/source/client/player/input/MouseDevice.hpp @@ -59,6 +59,7 @@ struct MouseAction class MouseDevice { public: + MouseDevice(); void feed(MouseButtonType buttonType, bool buttonState, int posX, int posY); short getX(); short getY();