swift
keyboardmacos.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 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_KEYBOARDMACOS_H
7 #define SWIFT_INPUT_KEYBOARDMACOS_H
8 
9 #include <ApplicationServices/ApplicationServices.h>
10 #include <IOKit/hid/IOHIDManager.h>
11 
12 #include <QHash>
13 
14 #include "input/keyboard.h"
16 #include "misc/input/keycodes.h"
17 
18 namespace swift::input
19 {
21  class CKeyboardMacOS : public IKeyboard
22  {
23  Q_OBJECT
24 
25  public:
27  CKeyboardMacOS(CKeyboardMacOS const &) = delete;
28 
31 
33  virtual ~CKeyboardMacOS() override;
34 
35  protected:
37  virtual bool init() override;
38 
39  private:
40  friend class IKeyboard;
41 
43  CKeyboardMacOS(QObject *parent = nullptr);
44 
45  void processKeyEvent(IOHIDValueRef value);
46 
47  static swift::misc::input::KeyCode convertToKey(quint32 keyCode);
48  static void valueCallback(void *context, IOReturn result, void *sender, IOHIDValueRef value);
49 
50  IOHIDManagerRef m_hidManager = nullptr;
52  };
53 } // namespace swift::input
54 
55 #endif // SWIFT_INPUT_KEYBOARDMACOS_H
MacOS implemenation of IKeyboard using hook procedure.
Definition: keyboardmacos.h:22
CKeyboardMacOS(CKeyboardMacOS const &)=delete
Copy Constructor.
virtual ~CKeyboardMacOS()
Destructor.
CKeyboardMacOS & operator=(CKeyboardMacOS const &)=delete
Assignment operator.
virtual bool init()
Initializes the platform keyboard device.
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