OpenZWave Library 1.2
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
48 {
49 public:
55
60 virtual ~HidController();
61
68 bool SetVendorId( uint32 const _vendorId );
69
76 bool SetProductId( uint32 const _productId );
77
84 bool SetSerialNumber( string const& _serialNumber );
85
93 bool Open( string const& _hidControllerName );
94
101 bool Close();
102
111 uint32 Write( uint8* _buffer, uint32 _length );
112
113 private:
114 bool Init( uint32 const _attempts );
115 void Read();
116
117 // helpers for internal use only
118
126 int GetFeatureReport( uint32 _length, uint8 _reportId, uint8* _buffer );
127
134 int SendFeatureReport( uint32 _length, const uint8* _data );
135
136 static void ThreadEntryPoint( Event* _exitEvent, void* _context );
137 void ThreadProc( Event* _exitEvent );
138
139 hid_device* m_hHidController;
140 Thread* m_thread;
141 uint32 m_vendorId;
142 uint32 m_productId;
143 string m_serialNumber;
144 string m_hidControllerName;
145 bool m_bOpen;
146 };
147
148} // namespace OpenZWave
149
150#endif //_HidController_H
151
unsigned int uint32
Definition: Defs.h:69
unsigned char uint8
Definition: Defs.h:63
struct hid_device_ hid_device
Definition: HidController.h:38
Definition: Controller.h:42
Platform-independent definition of event objects.
Definition: Event.h:40
Definition: HidController.h:48
uint32 Write(uint8 *_buffer, uint32 _length)
Definition: HidController.cpp:457
HidController()
Definition: HidController.cpp:52
virtual ~HidController()
Definition: HidController.cpp:69
bool SetVendorId(uint32 const _vendorId)
Definition: HidController.cpp:79
bool Open(string const &_hidControllerName)
Definition: HidController.cpp:133
bool Close()
Definition: HidController.cpp:164
bool SetProductId(uint32 const _productId)
Definition: HidController.cpp:97
bool SetSerialNumber(string const &_serialNumber)
Definition: HidController.cpp:115
Implements a platform-independent thread management class.
Definition: Thread.h:43
Definition: Bitfield.h:35