Skip to content

Commit

Permalink
chore: Improve logs
Browse files Browse the repository at this point in the history
- Remove the most spammy ones
- Add log showing currently precessed event
-other logs
  • Loading branch information
pktiuk committed Oct 13, 2022
1 parent 24467c9 commit 56a55e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
36 changes: 33 additions & 3 deletions src/inputdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,38 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)

while (SDL_PollEvent(&event) > 0)
{
if (Logger::isDebugEnabled())
{
const QMap<Uint32, QString> 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:
Expand Down Expand Up @@ -904,11 +936,9 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *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()))
{
Expand Down
4 changes: 2 additions & 2 deletions src/joyaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/joybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 56a55e0

Please sign in to comment.