Style fixes

This commit is contained in:
Roland Winklmeier
2015-06-18 22:58:11 +02:00
committed by Mathew Sutcliffe
parent c31a383547
commit 95fe93a83c
2 changed files with 24 additions and 22 deletions

View File

@@ -53,7 +53,7 @@ namespace BlackInput
void CKeyboardLinux::triggerKey(const CKeyboardKey &key, bool isPressed) void CKeyboardLinux::triggerKey(const CKeyboardKey &key, bool isPressed)
{ {
if(!isPressed) emit keyUp(key); if (!isPressed) emit keyUp(key);
else emit keyDown(key); else emit keyDown(key);
} }
@@ -61,10 +61,10 @@ namespace BlackInput
{ {
QDir eventFiles(dir, QLatin1String("event*"), 0, QDir::System); QDir eventFiles(dir, QLatin1String("event*"), 0, QDir::System);
foreach (QFileInfo fileInfo, eventFiles.entryInfoList()) foreach(QFileInfo fileInfo, eventFiles.entryInfoList())
{ {
QString path = fileInfo.absoluteFilePath(); QString path = fileInfo.absoluteFilePath();
if(!m_keyboardDevices.contains(path) ) if (!m_keyboardDevices.contains(path))
addRawInputDevice(path); addRawInputDevice(path);
} }
} }
@@ -73,7 +73,7 @@ namespace BlackInput
{ {
struct input_event eventInput; struct input_event eventInput;
QFile *fileInput=qobject_cast<QFile *>(sender()->parent()); QFile *fileInput = qobject_cast<QFile *>(sender()->parent());
if (!fileInput) if (!fileInput)
return; return;
@@ -100,10 +100,12 @@ namespace BlackInput
keyEvent(keyCode, isPressed); keyEvent(keyCode, isPressed);
} }
if (!found) { if (!found)
{
int fd = fileInput->handle(); int fd = fileInput->handle();
int version = 0; int version = 0;
if ((ioctl(fd, EVIOCGVERSION, &version) < 0) || (((version >> 16) & 0xFF) < 1)) { if ((ioctl(fd, EVIOCGVERSION, &version) < 0) || (((version >> 16) & 0xFF) < 1))
{
qWarning("CKeyboardLinux: Removing dead input device %s", qPrintable(fileInput->fileName())); qWarning("CKeyboardLinux: Removing dead input device %s", qPrintable(fileInput->fileName()));
m_keyboardDevices.remove(fileInput->fileName()); m_keyboardDevices.remove(fileInput->fileName());
} }
@@ -132,9 +134,9 @@ namespace BlackInput
char deviceName[255]; char deviceName[255];
if (ioctl(fd, EVIOCGNAME(sizeof(deviceName)), deviceName) < 0) { return; } if (ioctl(fd, EVIOCGNAME(sizeof(deviceName)), deviceName) < 0) { return; }
uint8_t bitmask[EV_MAX/8 + 1]; uint8_t bitmask[EV_MAX / 8 + 1];
memset(bitmask, 0, sizeof(bitmask)); memset(bitmask, 0, sizeof(bitmask));
if (ioctl(fd, EVIOCGBIT(0,sizeof(bitmask)), &bitmask) < 0) { return; } if (ioctl(fd, EVIOCGBIT(0, sizeof(bitmask)), &bitmask) < 0) { return; }
// Keyboards support EV_SYN and EV_KEY // Keyboards support EV_SYN and EV_KEY
// but do NOT support EV_REL and EV_ABS // but do NOT support EV_REL and EV_ABS
@@ -154,7 +156,7 @@ namespace BlackInput
else else
{ {
ioctl(fd, EVIOCGRAB, 0); ioctl(fd, EVIOCGRAB, 0);
uint8_t keys[KEY_MAX/8 + 1]; uint8_t keys[KEY_MAX / 8 + 1];
if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keys)), &keys) >= 0) && (keys[KEY_SPACE / 8] & (1 << (KEY_SPACE % 8)))) if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keys)), &keys) >= 0) && (keys[KEY_SPACE / 8] & (1 << (KEY_SPACE % 8))))
{ {
BlackMisc::CLogMessage(this).info("Found keyboard: %1") << deviceName; BlackMisc::CLogMessage(this).info("Found keyboard: %1") << deviceName;

View File

@@ -28,10 +28,10 @@ namespace BlackInput
public: public:
//! \brief Copy Constructor //! \brief Copy Constructor
CKeyboardLinux(CKeyboardLinux const&) = delete; CKeyboardLinux(CKeyboardLinux const &) = delete;
//! \brief Assignment operator //! \brief Assignment operator
CKeyboardLinux &operator=(CKeyboardLinux const&) = delete; CKeyboardLinux &operator=(CKeyboardLinux const &) = delete;
//! \brief Destructor //! \brief Destructor
virtual ~CKeyboardLinux(); virtual ~CKeyboardLinux();