OpenZWave Library 1.6.0
Loading...
Searching...
No Matches
HidController.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// HidController.h
4//
5// Cross-platform HID port handler
6//
7// Copyright (c) 2010 Jason Frazier <frazierjason@gmail.com>
8//
9// SOFTWARE NOTICE AND LICENSE
10//
11// This file is part of OpenZWave.
12//
13// OpenZWave is free software: you can redistribute it and/or modify
14// it under the terms of the GNU Lesser General Public License as published
15// by the Free Software Foundation, either version 3 of the License,
16// or (at your option) any later version.
17//
18// OpenZWave is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU Lesser General Public License for more details.
22//
23// You should have received a copy of the GNU Lesser General Public License
24// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25//
26//-----------------------------------------------------------------------------
27
28#ifndef _HidController_H
29#define _HidController_H
30
31#include <string>
32#include "Defs.h"
33#include "platform/Controller.h"
34
35
36struct hid_device_;
37
38typedef struct hid_device_ hid_device;
39
40namespace OpenZWave
41{
42 class Driver;
43 class Msg;
44 class Thread;
45 class Event;
46
47
52 {
53 public:
59
64 virtual ~HidController();
65
72 bool SetVendorId( uint32 const _vendorId );
73
80 bool SetProductId( uint32 const _productId );
81
88 bool SetSerialNumber( string const& _serialNumber );
89
97 bool Open( string const& _hidControllerName );
98
105 bool Close();
106
115 uint32 Write( uint8* _buffer, uint32 _length );
116
117 private:
118 bool Init( uint32 const _attempts );
119 void Read();
120
121 // helpers for internal use only
122
130 int GetFeatureReport( uint32 _length, uint8 _reportId, uint8* _buffer );
131
138 int SendFeatureReport( uint32 _length, const uint8* _data );
139
140 static void ThreadEntryPoint( Event* _exitEvent, void* _context );
141 void ThreadProc( Event* _exitEvent );
142
143 hid_device* m_hHidController;
144 Thread* m_thread;
145 uint32 m_vendorId;
146 uint32 m_productId;
147 string m_serialNumber;
148 string m_hidControllerName;
149 bool m_bOpen;
150 };
151
152} // namespace OpenZWave
153
154#endif //_HidController_H
155
unsigned int uint32
Definition: Defs.h:95
unsigned char uint8
Definition: Defs.h:89
struct hid_device_ hid_device
Definition: HidController.h:38
Represents a USB Controller.
Definition: Controller.h:56
Platform-independent definition of event objects.
Definition: Event.h:41
Interface for controllers that implement a HID emulation.
Definition: HidController.h:52
bool SetVendorId(uint32 const _vendorId)
bool SetProductId(uint32 const _productId)
bool Open(string const &_hidControllerName)
bool SetSerialNumber(string const &_serialNumber)
uint32 Write(uint8 *_buffer, uint32 _length)
Implements a platform-independent thread management class.
Definition: Thread.h:44
Definition: Bitfield.h:35