summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Rogalsky <ed.rogalsky@googlemail.com>2014-03-02 18:52:02 (GMT)
committerEd Rogalsky <ed.rogalsky@googlemail.com>2014-03-02 18:52:02 (GMT)
commit4b84e98f0c659f04b6e798f9d83e607adf6f6bd2 (patch)
tree36e1930d0144f4e2ebaeefa9e6e18d832e72de84
parent8fd72a344483e436b396a1c288221a6e2f311dde (diff)
jogshuttle: enumerate devices using mediactrl
-rw-r--r--src/jogshuttle.cpp14
-rw-r--r--src/lib/external/media_ctrl/mediactrl.c3
2 files changed, 9 insertions, 8 deletions
diff --git a/src/jogshuttle.cpp b/src/jogshuttle.cpp
index 00b0c79..c846e9c 100644
--- a/src/jogshuttle.cpp
+++ b/src/jogshuttle.cpp
@@ -388,8 +388,7 @@ void JogShuttle::customEvent(QEvent* e)
QString JogShuttle::enumerateDevice(const QString& device)
{
- QDir canonDir(device);
- return canonDir.canonicalPath();
+ return QDir(device).canonicalPath();
}
DeviceMap JogShuttle::enumerateDevices(const QString& devPath)
@@ -407,12 +406,13 @@ DeviceMap JogShuttle::enumerateDevices(const QString& devPath)
QString fileLink = JogShuttle::enumerateDevice(devFullPath);
kDebug() << QString(" [%1] ").arg(fileName);
kDebug() << QString(" [%1] ").arg(fileLink);
- char name[256] = "unknown";
- int fd = KDE_open((char*)fileLink.toUtf8().data(), O_RDONLY);
- if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
- devs.insert(name, devFullPath);
+
+ struct media_ctrl mc;
+ media_ctrl_open2(&mc, (char*)fileLink.toUtf8().data());
+ if (mc.fd > 0 && mc.device) {
+ devs.insert(QString(mc.device->name), devFullPath);
}
- ::close(fd);
+ media_ctrl_close(&mc);
}
return devs;
diff --git a/src/lib/external/media_ctrl/mediactrl.c b/src/lib/external/media_ctrl/mediactrl.c
index 4ca6527..3558d82 100644
--- a/src/lib/external/media_ctrl/mediactrl.c
+++ b/src/lib/external/media_ctrl/mediactrl.c
@@ -282,7 +282,7 @@ void translate_compliant(struct media_ctrl *ctrl, struct input_event *ev, struct
struct media_ctrl_device supported_devices[] = {
{ 0x0b33, 0x0030, "Contour ShuttlePRO v2", mc_shuttle_pro_keys, translate_contour_hid_event },
- { 0x0b33, 0x0020, "Contour ShuttleXPress", mc_shuttle_xpress_keys, translate_contour_hid_event },
+ { 0x0b33, 0x0020, "Contour Design ShuttleXpress", mc_shuttle_xpress_keys, translate_contour_hid_event },
{ 0x0b33, 0x0010, "Contour ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event },
{ 0x0b33, 0x0011, "Contour ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event }, /* Hercules OEM */
{ 0x05f3, 0x0240, "Contour ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event },
@@ -430,6 +430,7 @@ void media_ctrl_open2(struct media_ctrl *mc, const char *devname)
fd = open( devname, O_RDONLY );
if ( fd < 0 ) {
perror(devname);
+ mc->fd = -1;
} else {
mc->fd = fd;
//mc->eventno = i;