Files
pilotclient/src/blackinput/linux/keyboardlinux.h
Roland Winklmeier bd251b5de6 Fix license headers
2016-02-16 20:01:21 +01:00

81 lines
2.2 KiB
C++

/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
/*!
\file
*/
#ifndef BLACKINPUT_KEYBOARD_LINUX_H
#define BLACKINPUT_KEYBOARD_LINUX_H
#include "blackinput/keyboard.h"
#include "blackmisc/input/hotkeycombination.h"
#include <QHash>
#include <X11/X.h>
#include <X11/Xlib.h>
class QFileSystemWatcher;
class QFile;
namespace BlackInput
{
//! \brief Linux implemenation of IKeyboard using hook procedure
class CKeyboardLinux : public IKeyboard
{
Q_OBJECT
public:
//! \brief Copy Constructor
CKeyboardLinux(CKeyboardLinux const &) = delete;
//! \brief Assignment operator
CKeyboardLinux &operator=(CKeyboardLinux const &) = delete;
//! \brief Destructor
virtual ~CKeyboardLinux();
protected:
//! \copydoc IKeyboard::init()
virtual bool init() override;
private slots:
//! Changed directory to linux devices
void deviceDirectoryChanged(const QString &);
//! Device is ready to read new input
void inputReadyRead(int);
private:
friend class IKeyboard;
//! \brief Constructor
CKeyboardLinux(QObject *parent = nullptr);
void addRawInputDevice(const QString &filePath);
void keyEvent(int keyCode, bool isPressed);
BlackMisc::Input::KeyCode convertToKey(int keyCode);
bool isModifier(int keyCode);
bool isMouseButton(int keyCode);
BlackMisc::Input::CHotkeyCombination m_keyCombination; //!< Current status of pressed keys;
QFileSystemWatcher *m_devInputWatcher; //!< Watches the device file system for input devices
QHash<QString, QSharedPointer<QFile>> m_keyboardDevices; //!< All known input devices
Display *m_display;
};
}
#endif // BLACKINPUT_KEYBOARD_LINUX_H