gForceSDK
gfTypes.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017, OYMotion Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28  * DAMAGE.
29  *
30  */
38 #pragma once
39 
40 
41 #include <iostream>
42 #include <string>
43 #include <memory>
44 
45 #if defined(WIN32)
46 #include "tchar.h"
47 #endif
48 
49 namespace gf {
50 
52  typedef char GF_CHAR;
54  typedef char* GF_PCHAR;
56  typedef const char* GF_CPCHAR;
58  typedef unsigned int GF_UINT;
60  typedef int GF_INT;
62  typedef float GF_FLOAT;
63 
65  typedef unsigned char GF_UINT8;
67  typedef unsigned char* GF_PUINT8;
69  typedef unsigned short GF_UINT16;
71  typedef unsigned short* GF_PUINT16;
73  typedef unsigned int GF_UINT32;
75  typedef unsigned long long GF_UINT64;
76 
78  typedef size_t GF_SIZE;
80  typedef GF_INT GF_STATUS;
82  typedef void* GF_HANDLE;
83 
84 #if defined(UNICODE) || defined(_UNICODE)
85 
87  using tstring = std::wstring;
89  typedef wchar_t tchar;
90 #if ! defined(WIN32) || ! defined(_T)
91 #define _T(x) L ## x
93 #endif
94 
95 #else // UNICODE
96 
98  using tstring = std::string;
100  typedef char tchar;
101 #if ! defined(WIN32) || ! defined(_T)
102 #define _T(x) x
104 #endif
105 
106 #endif // UNICODE
107 
109  template <typename T>
110  using gfwPtr = std::weak_ptr < T >;
112  template <typename T>
113  using gfsPtr = std::shared_ptr < T >;
114 
115  class Device;
120 
123  enum class WorkMode {
128  Freerun,
133  Polling,
134  };
135 
138  enum class GF_RET_CODE : GF_UINT32 {
140  GF_SUCCESS = 0,
142  GF_ERROR,
159  };
160 
163  enum class Gesture : GF_UINT8 {
164  Relax = 0x00,
165  Fist = 0x01,
166  SpreadFingers = 0x02,
167  WaveIn = 0x03,
168  WaveOut = 0x04,
169  Pinch = 0x05,
170  Shoot = 0x06,
171  UserDefine1 = 0x07,
172  UserDefine2 = 0x08,
173  UserDefine3 = 0x09,
174  UserDefine4 = 0x0A,
175  UserDefine5 = 0x0B,
176  UserDefine6 = 0x0C,
177  UserDefine7 = 0x0D,
178  UserDefine8 = 0x0E,
179  UserDefine9 = 0x0F,
180  Undefined = 0xFF
181  };
182 
185  enum class DeviceStatus : GF_UINT8 {
186  None = 0,
187  ReCenter = 1,
188  UsbPlugged = 2,
189  UsbPulled = 3,
190  Motionless = 4,
191  };
192 
195  enum class HubState {
196  Idle,
197  Scanning,
198  Connecting,
199  Disconnected,
200  Unknown
201  };
202 
206  Disconnected,
207  Disconnecting,
208  Connecting,
209  Connected
210  };
211 
214  enum class DeviceDataType : GF_UINT32 {
215  DDT_INVALID = 0,
216  DDT_ACCELERATE,
217  DDT_GYROSCOPE,
218  DDT_MAGNETOMETER,
219  DDT_EULERANGLE,
220  DDT_QUATERNION,
221  DDT_ROTATIONMATRIX,
222  DDT_GESTURE,
223  DDT_EMGRAW,
224  DDT_HIDMOUSE,
225  DDT_HIDJOYSTICK,
226  DDT_DEVICESTATUS,
227  DDT_MAX
228  };
229 
232  enum class ProfileCharType : GF_UINT8 {
233  PROF_SIMPLE_DATA = 0, //simple profile: data char
234  PROF_DATA_CMD, //data profile: cmd char
235  PROF_DATA_NTF, //data profile:nty char
236  PROF_OAD_IDENTIFY, //OAD profile:identify char
237  PROF_OAD_BLOCK, //OAD profile:block char
238  PROF_OAD_FAST //OAD profile:fast char
239  };
240 
241 } // namespace gf
Method returns successfully.
DeviceDataType
Define the data types the device do support.
Definition: gfTypes.h:214
gfsPtr< Device > SPDEVICE
the strong pointer to Device
Definition: gfTypes.h:119
float GF_FLOAT
type definition
Definition: gfTypes.h:62
unsigned short GF_UINT16
type definition
Definition: gfTypes.h:69
DeviceConnectionStatus
Possible gForce device connection status.
Definition: gfTypes.h:205
unsigned short * GF_PUINT16
type definition
Definition: gfTypes.h:71
void * GF_HANDLE
type definition
Definition: gfTypes.h:82
int GF_INT
type definition
Definition: gfTypes.h:60
unsigned int GF_UINT
type definition
Definition: gfTypes.h:58
Target device is busy and cannot fulfill the call.
char tchar
char type definition for ANSI/UNICODE convenience
Definition: gfTypes.h:100
Method is not supported at this time.
gfwPtr< Device > WPDEVICE
the weak pointer to Device
Definition: gfTypes.h:117
Gesture
Gesture types predefined in the gForce device.
Definition: gfTypes.h:163
The abstract class of a gForce device.
Definition: Device.h:53
std::string tstring
std::string type definition for ANSI/UNICODE convenience
Definition: gfTypes.h:98
HubState
Possible Hub states.
Definition: gfTypes.h:195
unsigned int GF_UINT32
type definition
Definition: gfTypes.h:73
The namespace in which all of the gForceSDK project definitions are contained.
Definition: Device.h:42
DeviceStatus
Device status notification of a gForce device.
Definition: gfTypes.h:185
size_t GF_SIZE
type definition
Definition: gfTypes.h:78
WorkMode
Defines how callbacks are called in threads.
Definition: gfTypes.h:123
std::shared_ptr< T > gfsPtr
The strong pointer.
Definition: gfTypes.h:113
Insufficient resource to perform the call.
Method returns with a generic error.
ProfileCharType
Define the gforce profile characteristic type.
Definition: gfTypes.h:232
Hub is busying on device scan and cannot fulfill the call.
unsigned char * GF_PUINT8
type definition
Definition: gfTypes.h:67
GF_INT GF_STATUS
type definition
Definition: gfTypes.h:80
GF_RET_CODE
Defines possible return values of methods.
Definition: gfTypes.h:138
Given parameters are not match required.
char GF_CHAR
type definition
Definition: gfTypes.h:52
Method call is not allowed by the inner state.
char * GF_PCHAR
type definition
Definition: gfTypes.h:54
A preset timer is expired.
The retrieving data is not ready yet.
const char * GF_CPCHAR
type definition
Definition: gfTypes.h:56
std::weak_ptr< T > gfwPtr
The weak pointer.
Definition: gfTypes.h:110
unsigned long long GF_UINT64
type definition
Definition: gfTypes.h:75
unsigned char GF_UINT8
type definition
Definition: gfTypes.h:65