From 56a55e08bd272c98eddf116023128902c950f348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Thu, 13 Oct 2022 20:48:55 +0200 Subject: [PATCH] chore: Improve logs - Remove the most spammy ones - Add log showing currently precessed event -other logs --- src/inputdaemon.cpp | 36 +++++++++++++++++++++++++++++++++--- src/joyaxis.cpp | 4 ++-- src/joybutton.cpp | 4 +++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/inputdaemon.cpp b/src/inputdaemon.cpp index 3c84ef6d8..9133ee673 100644 --- a/src/inputdaemon.cpp +++ b/src/inputdaemon.cpp @@ -721,6 +721,38 @@ void InputDaemon::firstInputPass(QQueue *sdlEventQueue) while (SDL_PollEvent(&event) > 0) { + if (Logger::isDebugEnabled()) + { + const QMap STRING_MAP = { + {SDL_JOYBUTTONDOWN, "SDL_JOYBUTTONDOWN"}, + {SDL_JOYBUTTONUP, "SDL_JOYBUTTONUP"}, + {SDL_JOYAXISMOTION, "SDL_JOYAXISMOTION"}, + {SDL_JOYHATMOTION, "SDL_JOYHATMOTION"}, + {SDL_CONTROLLERAXISMOTION, "SDL_CONTROLLERAXISMOTION"}, + {SDL_CONTROLLERBUTTONDOWN, "SDL_CONTROLLERBUTTONDOWN"}, + {SDL_CONTROLLERBUTTONUP, "SDL_CONTROLLERBUTTONUP"}, + {SDL_JOYDEVICEREMOVED, "SDL_JOYDEVICEREMOVED"}, + {SDL_JOYDEVICEADDED, "SDL_JOYDEVICEADDED"}, + {SDL_CONTROLLERDEVICEREMOVED, "SDL_CONTROLLERDEVICEREMOVED"}, + {SDL_CONTROLLERDEVICEADDED, "SDL_CONTROLLERDEVICEADDED"}, +#if SDL_VERSION_ATLEAST(2, 0, 14) + {SDL_CONTROLLERSENSORUPDATE, "SDL_CONTROLLERSENSORUPDATE"}, + {SDL_CONTROLLERTOUCHPADDOWN, "SDL_CONTROLLERTOUCHPADDOWN"}, + {SDL_CONTROLLERTOUCHPADMOTION, "SDL_CONTROLLERTOUCHPADMOTION"}, + {SDL_CONTROLLERTOUCHPADUP, "SDL_CONTROLLERTOUCHPADUP"} +#endif + }; + + QString type; + if (STRING_MAP.contains(event.type)) + type = STRING_MAP[event.type]; + else + type = QString().number(event.type); + DEBUG() << "Processing event: " << type << " From joystick with instance id: " << (int)event.jbutton.which + << " Got button with id: " << (int)event.jbutton.button << " is one of the GameControllers: " + << (trackcontrollers.contains(event.jbutton.which) ? "true" : "false") << " is one of the joysticks:" + << (getTrackjoysticksLocal().contains(event.jbutton.which) ? "true" : "false"); + } switch (event.type) { case SDL_JOYBUTTONDOWN: @@ -904,11 +936,9 @@ void InputDaemon::modifyUnplugEvents(QQueue *sdlEventQueue) InputDeviceBitArrayStatus *generatedTemp = genIter.value(); QBitArray tempBitArray = generatedTemp->generateFinalBitArray(); - qDebug() << "ARRAY: " << tempBitArray; - int bitArraySize = tempBitArray.size(); - qDebug() << "ARRAY SIZE: " << bitArraySize; + qDebug() << "Raw array: " << tempBitArray << " array size: " << bitArraySize; if ((bitArraySize > 0) && (tempBitArray.count(true) == device->getNumberAxes())) { diff --git a/src/joyaxis.cpp b/src/joyaxis.cpp index 53db6784d..d245f9403 100644 --- a/src/joyaxis.cpp +++ b/src/joyaxis.cpp @@ -183,13 +183,13 @@ bool JoyAxis::inDeadZone(int value) if (abs(temp) <= deadZone) { - qDebug() << "Value of throttle is in (less than) dead zone: " << abs(temp) << " <= " << deadZone; + // qDebug() << "Value of throttle is in (less than) dead zone: " << abs(temp) << " <= " << deadZone; result = true; } else { - qDebug() << "Value of throttle is not in (greater than) dead zone: " << abs(temp) << " > " << deadZone; + // qDebug() << "Value of throttle is not in (greater than) dead zone: " << abs(temp) << " > " << deadZone; } return result; diff --git a/src/joybutton.cpp b/src/joybutton.cpp index 9fd5fed7b..66a20d823 100644 --- a/src/joybutton.cpp +++ b/src/joybutton.cpp @@ -118,6 +118,7 @@ JoyButton::JoyButton(int index, int originset, SetJoystick *parentSet, QObject * m_index = index; m_originset = originset; quitEvent = true; + VERBOSE() << "Created button with ID: " << m_index << " For set: " << originset << " Name: " << getName(); } JoyButton::~JoyButton() @@ -175,7 +176,8 @@ void JoyButton::vdpadPassEvent(bool pressed, bool ignoresets) void JoyButton::joyEvent(bool pressed, bool ignoresets) { if (Logger::isDebugEnabled()) - DEBUG() << "Processing joyEvent for: " << getName(); + DEBUG() << "Processing JoyButton::joyEvent for: " << getName() << " SDL index: " << m_index + << " className: " << metaObject()->className(); if ((m_vdpad != nullptr) && !pendingEvent) {