swift
keyboardlinux.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_INPUT_KEYBOARD_LINUX_H
7 #define SWIFT_INPUT_KEYBOARD_LINUX_H
8 
9 #include <QDir>
10 #include <QFileSystemWatcher>
11 #include <QHash>
12 
13 #include "input/keyboard.h"
15 
16 // Explicitly including X11 last
17 #include <X11/X.h>
18 #include <X11/Xlib.h>
19 
20 namespace swift::input
21 {
23  class CKeyboardLinux : public IKeyboard
24  {
25  Q_OBJECT
26 
27  public:
29  CKeyboardLinux(CKeyboardLinux const &) = delete;
30 
33 
35  virtual ~CKeyboardLinux() override;
36 
37  protected:
39  virtual bool init() override;
40 
41  private slots:
43  void deviceDirectoryChanged(const QString &);
44 
46  void inputReadyRead(int);
47 
48  private:
49  friend class IKeyboard;
50 
52  CKeyboardLinux(QObject *parent = nullptr);
53 
54  void addRawInputDevice(const QString &filePath);
55  void keyEvent(int keyCode, bool isPressed);
56  swift::misc::input::KeyCode convertToKey(int keyCode);
57  bool isModifier(int keyCode);
58  bool isMouseButton(int keyCode);
59 
61 
62  QFileSystemWatcher *m_devInputWatcher;
63  QHash<QString, QSharedPointer<QFile>> m_keyboardDevices;
64 
65  Display *m_display;
66  };
67 } // namespace swift::input
68 
69 #endif // SWIFT_INPUT_KEYBOARD_LINUX_H
Linux implemenation of IKeyboard using hook procedure.
Definition: keyboardlinux.h:24
virtual ~CKeyboardLinux()
Destructor.
CKeyboardLinux & operator=(CKeyboardLinux const &)=delete
Assignment operator.
virtual bool init()
Initializes the platform keyboard device.
CKeyboardLinux(CKeyboardLinux const &)=delete
Copy Constructor.
Abstract interface for native keyboard handling.
Definition: keyboard.h:23
Value object representing hotkey sequence.
KeyCode
Key code http://www.kbdlayout.info/.
Definition: keycodes.h:16