neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
hid_device.hpp
Go to the documentation of this file.
1// i_hid_device.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
26
27namespace neogfx
28{
29 template <typename HidInterface>
30 class hid_device : public reference_counted<HidInterface>
31 {
32 public:
35 public:
36 typedef HidInterface abstract_type;
37 public:
38 hid_device(hid_device_type aType, hid_device_class aClass, hid_device_subclass aSubclass, const hid_device_uuid& aProductId = {}, const hid_device_uuid& aInstanceId = {}) :
39 iType{ aType },
40 iClass{ aClass },
41 iSubclass{ aSubclass },
42 iProductId{ aProductId },
43 iInstanceId{ aInstanceId },
44 iEnabled{ true }
45 {
46 }
47 public:
49 {
50 return iType;
51 }
53 {
54 return iClass;
55 }
57 {
58 return iSubclass;
59 }
60 hid_device_uuid product_id() const override
61 {
62 return iProductId;
63 }
65 {
66 return iInstanceId;
67 }
68 bool is_enabled() const override
69 {
70 return iEnabled;
71 }
72 void enable() override
73 {
74 if (!iEnabled)
75 {
76 iEnabled = true;
77 Enabled.trigger();
78 }
79 }
80 void disable() override
81 {
82 if (iEnabled)
83 {
84 iEnabled = false;
85 Disabled.trigger();
86 }
87 }
88 public:
89 const i_string& product_name() const override
90 {
91 return service<i_hid_devices>().product_name(device_class(), product_id());
92 }
93 private:
94 hid_device_type const iType;
95 hid_device_class const iClass;
96 hid_device_subclass const iSubclass;
97 hid_device_uuid const iProductId;
98 hid_device_uuid const iInstanceId;
99 bool iEnabled;
100 };
101}
hid_device(hid_device_type aType, hid_device_class aClass, hid_device_subclass aSubclass, const hid_device_uuid &aProductId={}, const hid_device_uuid &aInstanceId={})
hid_device_uuid product_id() const override
bool is_enabled() const override
HidInterface abstract_type
hid_device_uuid instance_id() const override
void disable() override
hid_device_class device_class() const override
define_declared_event(Enabled, enabled) define_declared_event(Disabled
hid_device_subclass device_subclass() const override
void enable() override
hid_device_type device_type() const override
const i_string & product_name() const override
#define define_declared_event(name, declName,...)
Definition event.hpp:195