Skip to content

Commit

Permalink
KeyboardEventFilter: use mixxx::Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Oct 13, 2024
1 parent 44dc1c8 commit 44f47e9
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/controllers/keyboard/keyboardeventfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@

#include "moc_keyboardeventfilter.cpp"
#include "util/cmdlineargs.h"
#include "util/logger.h"
#include "widget/wbasewidget.h"

namespace {
mixxx::Logger kLogger("AnalyzerThread");
} // anonymous namespace

KeyboardEventFilter::KeyboardEventFilter(UserSettingsPointer pConfig,
QLocale& locale,
QObject* parent,
Expand Down Expand Up @@ -83,7 +88,7 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
if (configKey.group != "[KeyboardShortcuts]") {
ControlObject* control = ControlObject::getControl(configKey);
if (control) {
//qDebug() << configKey << "MidiOpCode::NoteOn" << 1;
// kLogger.debug() << configKey << "MidiOpCode::NoteOn" << 1;
// Add key to active key list
m_qActiveKeyList.append(KeyDownInformation(
keyId, ke->modifiers(), control));
Expand All @@ -93,8 +98,9 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
control->setValueFromMidi(MidiOpCode::NoteOn, 1);
result = true;
} else {
qDebug() << "Warning: Keyboard key is configured for nonexistent control:"
<< configKey.group << configKey.item;
kLogger.warning() << "Key" << keyId
<< "is configured for nonexistent control:"
<< configKey.group << configKey.item;
}
}
}
Expand Down Expand Up @@ -134,7 +140,8 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
#endif
bool autoRepeat = ke->isAutoRepeat();

//qDebug() << "KeyRelease event =" << ke->key() << "AutoRepeat =" << autoRepeat << "KeyId =" << keyId;
// kLogger.debug() << "KeyRelease event =" << ke->key()
// << "AutoRepeat=" << autoRepeat << "KeyId =" << keyId;

int clearModifiers = 0;
#ifdef __APPLE__
Expand All @@ -154,7 +161,7 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
if (keyDownInfo.keyId == keyId ||
(clearModifiers > 0 && keyDownInfo.modifiers == clearModifiers)) {
if (!autoRepeat) {
//qDebug() << pControl->getKey() << "MidiOpCode::NoteOff" << 0;
// kLogger.debug() << pControl->getKey() << "MidiOpCode::NoteOff" << 0;
pControl->setValueFromMidi(MidiOpCode::NoteOff, 0);
m_qActiveKeyList.removeAt(i);
}
Expand All @@ -167,7 +174,7 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
} else if (e->type() == QEvent::KeyboardLayoutChange) {
// This event is not fired on ubunty natty, why?
// TODO(XXX): find a way to support KeyboardLayoutChange Bug #997811
//qDebug() << "QEvent::KeyboardLayoutChange";
// kLogger.debug() << "QEvent::KeyboardLayoutChange";
}
return false;
}
Expand Down Expand Up @@ -205,9 +212,9 @@ QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) {

if (CmdlineArgs::Instance().getDeveloper()) {
if (e->type() == QEvent::KeyPress) {
qDebug() << "keyboard press: " << k.toString();
kLogger.debug() << "keyboard press: " << k.toString();
} else if (e->type() == QEvent::KeyRelease) {
qDebug() << "keyboard release: " << k.toString();
kLogger.debug() << "keyboard release: " << k.toString();
}
}

Expand Down Expand Up @@ -313,20 +320,20 @@ void KeyboardEventFilter::createKeyboardConfig() {
// Check first in user's Mixxx directory
QString keyboardFile = QDir(m_pConfig->getSettingsPath()).filePath("Custom.kbd.cfg");
if (QFile::exists(keyboardFile)) {
qDebug() << "Found and will use custom keyboard mapping" << keyboardFile;
kLogger.debug() << "Found and will use custom keyboard mapping" << keyboardFile;
} else {
// check if a default keyboard exists
const QString resourcePath = m_pConfig->getResourcePath();
keyboardFile = QString(resourcePath).append("keyboard/");
keyboardFile += m_locale.name();
keyboardFile += ".kbd.cfg";
if (QFile::exists(keyboardFile)) {
qDebug() << "Found and will use default keyboard mapping" << keyboardFile;
kLogger.debug() << "Found and will use default keyboard mapping" << keyboardFile;
} else {
qDebug() << keyboardFile << " not found, using en_US.kbd.cfg";
kLogger.debug() << keyboardFile << " not found, using en_US.kbd.cfg";
keyboardFile = QString(resourcePath).append("keyboard/").append("en_US.kbd.cfg");
if (!QFile::exists(keyboardFile)) {
qDebug() << keyboardFile << " not found, starting without shortcuts";
kLogger.debug() << keyboardFile << " not found, starting without shortcuts";
keyboardFile = "";
}
}
Expand Down

0 comments on commit 44f47e9

Please sign in to comment.