2010-08-29 17:21:50 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui/wiimotedevshortcutgrabber.h"
|
|
|
|
#include "ui_wiimotedevshortcutgrabber.h"
|
|
|
|
#include "wiimotedev/interface.h"
|
|
|
|
#include "ui/wiimotedevshortcutsconfig.h"
|
|
|
|
|
|
|
|
|
2010-08-29 18:24:19 +02:00
|
|
|
WiimotedevShortcutGrabber::WiimotedevShortcutGrabber(QWidget *parent)
|
2010-08-29 17:21:50 +02:00
|
|
|
: QDialog(parent),
|
|
|
|
ui_(new Ui_WiimotedevShortcutGrabber),
|
2010-08-29 18:24:19 +02:00
|
|
|
config_(qobject_cast<WiimotedevShortcutsConfig*>(parent)),
|
2010-08-29 17:21:50 +02:00
|
|
|
wiimotedev_device_(1),
|
|
|
|
wiimotedev_buttons_(0)
|
|
|
|
{
|
|
|
|
ui_->setupUi(this);
|
|
|
|
|
2010-08-29 19:19:59 +02:00
|
|
|
if (QDBusConnection::systemBus().isConnected()) {
|
|
|
|
wiimotedev_iface_ = new DBusDeviceEventsInterface(WIIMOTEDEV_DBUS_SERVICE_NAME,
|
|
|
|
WIIMOTEDEV_DBUS_EVENTS_OBJECT,
|
|
|
|
QDBusConnection::systemBus(),
|
|
|
|
this);
|
2010-08-29 17:21:50 +02:00
|
|
|
|
2010-08-29 19:19:59 +02:00
|
|
|
connect(wiimotedev_iface_, SIGNAL(dbusWiimoteGeneralButtons(quint32,quint64)),
|
|
|
|
this, SLOT(DbusWiimoteGeneralButtons(quint32, quint64)));
|
|
|
|
}
|
2010-08-29 17:21:50 +02:00
|
|
|
|
2010-08-29 18:24:19 +02:00
|
|
|
foreach (const QString& name, config_->text_actions_.values())
|
|
|
|
ui_->comboBox->addItem(name);
|
|
|
|
|
2010-08-29 17:21:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WiimotedevShortcutGrabber::~WiimotedevShortcutGrabber() {
|
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiimotedevShortcutGrabber::DbusWiimoteGeneralButtons(quint32 id, quint64 value) {
|
|
|
|
if (wiimotedev_device_ != id) return;
|
|
|
|
|
|
|
|
quint64 buttons = value & ~(WIIMOTE_TILT_MASK | NUNCHUK_TILT_MASK);
|
|
|
|
if (wiimotedev_buttons_ == buttons) return;
|
|
|
|
|
2010-08-29 18:24:19 +02:00
|
|
|
ui_->combo->setText(config_->GetReadableWiiremoteSequence(buttons));
|
2010-08-29 17:21:50 +02:00
|
|
|
|
|
|
|
wiimotedev_buttons_ = buttons;
|
|
|
|
}
|