MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_gamepad_delegate_iokit_hid.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_GAMEPAD_DELEGATE_IOKIT_HID_H_1610181163
12#define INCGUARD_MGL_GAMEPAD_DELEGATE_IOKIT_HID_H_1610181163
13
14#include <mgl/mgl_environment.h>
15#if defined(MGL_GAMEPAD_DELEGATE_ENABLE_IOKIT_HID)
16
17#include <mutex>
18
19#include <IOKit/hid/IOHIDManager.h>
20
25
26namespace MGL::Input
27{
29class IOKitHIDGamepadDelegate : public GamepadDelegate
30{
31public:
32 IOKitHIDGamepadDelegate(GamepadServer &server) noexcept;
33 ~IOKitHIDGamepadDelegate() noexcept;
34
35 bool Initialize() noexcept override;
36 void UpdateState() noexcept override;
37
38private:
39 struct IOKitHIDState
40 {
41 PadState *state;
42 STL::unique_ptr<IOKitHID::GamepadDriver> driver;
43 IOHIDDeviceRef device;
44
45 IOKitHIDState()
46 : state(nullptr)
47 , driver(nullptr)
48 , device(nullptr)
49 {}
50 };
51
52 static void CallbackDeviceMatching(void *inContext, IOReturn inResult, void *inSender, IOHIDDeviceRef inIOHIDDeviceRef) noexcept;
53 static void CallbackDeviceRemoval(void *inContext, IOReturn inResult, void *inSender, IOHIDDeviceRef inIOHIDDeviceRef) noexcept;
54
55 bool AddDevice(IOHIDDeviceRef device) noexcept;
56 void RemoveDevice(IOHIDDeviceRef device) noexcept;
57
58 bool GetDevicePropertyValue(int32_t &value, const IOHIDDeviceRef device, const CFStringRef key) const noexcept;
59 bool GetDevicePropertyString(STL::string &string, const IOHIDDeviceRef device, const CFStringRef key) const noexcept;
60
61 IOHIDManagerRef _hidManager;
62 PadPriority _priority;
63
64 STL::list<STL::unique_ptr<IOKitHIDState>> _hidStateList;
65 std::mutex _mutex;
66};
67} // namespace MGL::Input
68
69#endif // MGL_GAMEPAD_DELEGATE_ENABLE_IOKIT_HID
70#endif // INCGUARD_MGL_GAMEPAD_DELEGATE_IOKIT_HID_H_1610181163
71
72// vim: et ts=4 sw=4 sts=4
MGL 環境定義
PadPriority
パッドのプライオリティ
Definition mgl_gamepad_defs.h:192
MGL ゲームパッド用デリゲート基底クラス
MGL ゲームパッドステート
MGL IOKit HID ゲームパッドドライバ
MGL STLコンテナの代替