Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
Fixes and debug - #64
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagoda committed Apr 29, 2019
1 parent 43e8c02 commit de44bee
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 50 deletions.
18 changes: 13 additions & 5 deletions src/autoprofilewatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ void AutoProfileWatcher::stopTimer()
checkWindowTimer.stop();
}

// TROP
void AutoProfileWatcher::runAppCheck()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

// TROP
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << qApp->applicationFilePath();
#endif
Expand All @@ -111,6 +113,7 @@ void AutoProfileWatcher::runAppCheck()
if (!getAppProfileAssignments().isEmpty())
{
appLocation = findAppLocation();
qDebug() << "appLocation is " << appLocation << endl;
}
#else
// In Windows, get program location no matter what.
Expand All @@ -124,6 +127,7 @@ void AutoProfileWatcher::runAppCheck()
// More portable check for whether antimicro is the current application
// with focus.
QWidget *focusedWidget = qApp->activeWindow();
if (focusedWidget != nullptr) qDebug() << "get active window of app" << endl;
QString nowWindow = QString();
QString nowWindowClass = QString();
QString nowWindowName = QString();
Expand All @@ -133,21 +137,23 @@ void AutoProfileWatcher::runAppCheck()
#elif defined(Q_OS_UNIX)

long currentWindow = X11Extras::getInstance()->getWindowInFocus();
qDebug() << "getWindowInFocus: " << currentWindow << endl;

if (currentWindow > 0)
{
long tempWindow = X11Extras::getInstance()->findParentClient(currentWindow);
qDebug() << "findParentClient: " << tempWindow << endl;

if (tempWindow > 0) currentWindow = tempWindow;

nowWindow = QString::number(currentWindow);
qDebug() << "number of window now: " << nowWindow << endl;

nowWindowClass = X11Extras::getInstance()->getWindowClass(static_cast<Window>(currentWindow));
nowWindowName = X11Extras::getInstance()->getWindowTitle(static_cast<Window>(currentWindow));
qDebug() << "class of window now: " << nowWindowClass << endl;

#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << nowWindowClass;
qDebug() << nowWindowName;
#endif
nowWindowName = X11Extras::getInstance()->getWindowTitle(static_cast<Window>(currentWindow));
qDebug() << "title of window now: " << nowWindowName << endl;
}
#endif

Expand All @@ -157,6 +163,8 @@ void AutoProfileWatcher::runAppCheck()

bool checkForTitleChange = getWindowNameProfileAssignments().size() > 0;

qDebug() << "window profile assignments size: " << getWindowNameProfileAssignments().size() << endl;

qDebug() << "checkForTitleChange: " << checkForTitleChange;

#ifdef Q_OS_WIN
Expand Down
9 changes: 8 additions & 1 deletion src/inputdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ void InputDaemon::refresh()

QEventLoop q;
connect(eventWorker, &SDLEventReader::sdlStarted, &q, &QEventLoop::quit);
QMetaObject::invokeMethod(eventWorker, "refresh", Qt::BlockingQueuedConnection);
QTimer::singleShot(0, eventWorker, SLOT(refresh()));
//QMetaObject::invokeMethod(eventWorker, "refresh", Qt::BlockingQueuedConnection);

if (eventWorker->isSDLOpen()) q.exec();

Expand Down Expand Up @@ -849,6 +850,8 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
}
case SDL_JOYDEVICEREMOVED:
case SDL_JOYDEVICEADDED:
case SDL_CONTROLLERDEVICEADDED:
case SDL_CONTROLLERDEVICEREMOVED:
{
sdlEventQueue->append(event);
break;
Expand Down Expand Up @@ -987,6 +990,8 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
}
case SDL_JOYDEVICEREMOVED:
case SDL_JOYDEVICEADDED:
case SDL_CONTROLLERDEVICEREMOVED:
case SDL_CONTROLLERDEVICEADDED:
{
tempQueue.enqueue(event);
break;
Expand Down Expand Up @@ -1163,6 +1168,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
}

case SDL_JOYDEVICEREMOVED:
case SDL_CONTROLLERDEVICEREMOVED:
{
InputDevice *device = m_joysticks->value(event.jdevice.which);

Expand All @@ -1179,6 +1185,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
}

case SDL_JOYDEVICEADDED:
case SDL_CONTROLLERDEVICEADDED:
{
addInputDevice(event.jdevice.which);
break;
Expand Down
9 changes: 5 additions & 4 deletions src/joytabwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,9 @@ void JoyTabWidget::changeJoyConfig(int index)
removeCurrentButtons();
emit forceTabUnflash(this);

QMetaObject::invokeMethod(&tabHelper, "readConfigFile", Qt::BlockingQueuedConnection,
Q_ARG(QString, filename));
tabHelper.readConfigFile(filename);
// QMetaObject::invokeMethod(&tabHelper, "readConfigFile", Qt::BlockingQueuedConnection,
// Q_ARG(QString, filename));

fillButtons();
refreshSetButtons();
Expand Down Expand Up @@ -1539,9 +1540,9 @@ void JoyTabWidget::loadDeviceSettings()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

//settings.beginGroup("Controllers");
//m_settings->beginGroup("Controllers");
loadSettings();
//settings.endGroup();
//m_settings->endGroup();
}

bool JoyTabWidget::isDisplayingNames()
Expand Down
55 changes: 41 additions & 14 deletions src/localantimicroserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QLocalServer>
#include <QDebug>


LocalAntiMicroServer::LocalAntiMicroServer(QObject *parent) :
QObject(parent)
{
Expand All @@ -37,30 +38,56 @@ void LocalAntiMicroServer::startLocalServer()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

QLocalServer::removeServer(PadderCommon::localSocketKey);
localServer->setMaxPendingConnections(1);
if (!localServer->listen(PadderCommon::localSocketKey))
if (localServer != nullptr)
{
QTextStream errorstream(stderr);
QString message("Could not start signal server. Profiles cannot be reloaded\n");
message.append("from command-line");
errorstream << trUtf8(message.toStdString().c_str()) << endl;
if (!localServer->hasPendingConnections()) QLocalServer::removeServer(PadderCommon::localSocketKey);

if (localServer->maxPendingConnections() != 1) localServer->setMaxPendingConnections(1);

if (!localServer->isListening())
{
if (!localServer->listen(PadderCommon::localSocketKey))
{
QTextStream errorstream(stderr);
QString message("Could not start signal server. Profiles cannot be reloaded\n");
message.append("from command-line");
errorstream << trUtf8(message.toStdString().c_str()) << endl;
qDebug() << "Could not start signal server. Profiles cannot be reloaded\n" << " \nfrom command-line\n " << trUtf8(message.toStdString().c_str()) << endl;
}
else
{
connect(localServer, &QLocalServer::newConnection, this, &LocalAntiMicroServer::handleOutsideConnection);
}
}
}
else
{
connect(localServer, &QLocalServer::newConnection, this, &LocalAntiMicroServer::handleOutsideConnection);
qDebug() << "LocalAntiMicroServer::startLocalServer(): localServer is nullptr" << endl;
}
}

void LocalAntiMicroServer::handleOutsideConnection()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

QLocalSocket *socket = localServer->nextPendingConnection();
if (socket != nullptr)
if (localServer != nullptr)
{
QLocalSocket *socket = localServer->nextPendingConnection();

if (socket != nullptr)
{
qDebug() << "There is next pending connection: " << socket->socketDescriptor() << endl;
connect(socket, &QLocalSocket::disconnected, this, &LocalAntiMicroServer::handleSocketDisconnect);
connect(socket, &QLocalSocket::disconnected, socket, &QLocalSocket::deleteLater);
}
else
{
qDebug() << "There isn't next pending connection: " << endl;
}
}
else
{
connect(socket, &QLocalSocket::disconnected, this, &LocalAntiMicroServer::handleSocketDisconnect);
connect(socket, &QLocalSocket::disconnected, socket, &QLocalSocket::deleteLater);
qDebug() << "LocalAntiMicroServer::handleOutsideConnection(): localServer is nullptr" << endl;
}
}

Expand All @@ -78,7 +105,7 @@ void LocalAntiMicroServer::close()
localServer->close();
}

QLocalServer* LocalAntiMicroServer::getLocalServer() const {

QLocalServer* LocalAntiMicroServer::getLocalServer() const
{
return localServer;
}
Loading

0 comments on commit de44bee

Please sign in to comment.