Overte C++ Documentation
ConnexionClient.h
1 //==============================================================================
2 
3 #ifndef _H_connexionclient
4 #define _H_connexionclient
5 
6 #include <stdint.h>
7 
8 //==============================================================================
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 //==============================================================================
13 #pragma pack(push,2)
14 //==============================================================================
15 // Client registration modes
16 
17 // Use kConnexionClientWildcard ('****') as the application signature in the
18 // RegisterConnexionClient API to take over the device system-wide in all
19 // applications:
20 
21 #define kConnexionClientWildcard 0x2A2A2A2A
22 
23 // There are two plugin operating modes: one takes over the device
24 // and disables all built-in driver assignments, the other complements
25 // the driver by only executing commands that are meant for plugins:
26 
27 enum {
28  kConnexionClientModeTakeOver = 1, // take over device completely, driver no longer executes assignments
29  kConnexionClientModePlugin = 2 // receive plugin assignments only, let driver take care of its own
30 };
31 
32 //==============================================================================
33 // Client commands
34 
35 // The following assignments must be executed by the client:
36 
37 enum {
38  kConnexionCmdNone = 0,
39  kConnexionCmdHandleRawData = 1,
40  kConnexionCmdHandleButtons = 2,
41  kConnexionCmdHandleAxis = 3,
42 
43  kConnexionCmdAppSpecific = 10
44 };
45 
46 //==============================================================================
47 // Messages
48 
49 // The following messages are forwarded to user space clients:
50 
51 #define kConnexionMsgDeviceState '3dSR' // forwarded device state data
52 #define kConnexionMsgPrefsChanged '3dPC' // notify clients that the current app prefs have changed
53 #define kConnexionMsgCalibrateDevice '3dSC' // device state data to be used for calibration
54 
55 // Control messages for the driver sent via the ConnexionControl API:
56 
57 #define kConnexionCtlSetLEDState '3dsl' // set the LED state, param = (uint8_t)ledState
58 #define kConnexionCtlGetDeviceID '3did' // get vendorID and productID in the high and low words of the result
59 #define kConnexionCtlCalibrate '3dca' // calibrate the device with the current axes values (same as executing the calibrate assignment)
60 #define kConnexionCtlUncalibrate '3dde' // uncalibrate the device (i.e. reset calibration to 0,0,0,0,0,0)
61 #define kConnexionCtlOpenPrefPane '3dop' // open the 3dconnexion preference pane in System Preferences
62 #define kConnexionCtlSetSwitches '3dss' // set the current state of the client-controlled feature switches (bitmap, see masks below)
63 
64 // Client capability mask constants (this mask defines which buttons and controls should be sent to clients, the others are handled by the driver)
65 
66 #define kConnexionMaskButton1 0x0001
67 #define kConnexionMaskButton2 0x0002
68 #define kConnexionMaskButton3 0x0004
69 #define kConnexionMaskButton4 0x0008
70 #define kConnexionMaskButton5 0x0010
71 #define kConnexionMaskButton6 0x0020
72 #define kConnexionMaskButton7 0x0040
73 #define kConnexionMaskButton8 0x0080
74 
75 #define kConnexionMaskAxis1 0x0100
76 #define kConnexionMaskAxis2 0x0200
77 #define kConnexionMaskAxis3 0x0400
78 #define kConnexionMaskAxis4 0x0800
79 #define kConnexionMaskAxis5 0x1000
80 #define kConnexionMaskAxis6 0x2000
81 
82 #define kConnexionMaskButtons 0x00FF // note: this only specifies the first 8 buttons, kept for backwards compatibility
83 #define kConnexionMaskAxisTrans 0x0700
84 #define kConnexionMaskAxisRot 0x3800
85 #define kConnexionMaskAxis 0x3F00
86 #define kConnexionMaskAll 0x3FFF
87 
88 // Added in version 10:0 to support all 32 buttons on the SpacePilot Pro, use with the new SetConnexionClientButtonMask API
89 
90 #define kConnexionMaskButton9 0x00000100
91 #define kConnexionMaskButton10 0x00000200
92 #define kConnexionMaskButton11 0x00000400
93 #define kConnexionMaskButton12 0x00000800
94 #define kConnexionMaskButton13 0x00001000
95 #define kConnexionMaskButton14 0x00002000
96 #define kConnexionMaskButton15 0x00004000
97 #define kConnexionMaskButton16 0x00008000
98 
99 #define kConnexionMaskButton17 0x00010000
100 #define kConnexionMaskButton18 0x00020000
101 #define kConnexionMaskButton19 0x00040000
102 #define kConnexionMaskButton20 0x00080000
103 #define kConnexionMaskButton21 0x00100000
104 #define kConnexionMaskButton22 0x00200000
105 #define kConnexionMaskButton23 0x00400000
106 #define kConnexionMaskButton24 0x00800000
107 
108 #define kConnexionMaskButton25 0x01000000
109 #define kConnexionMaskButton26 0x02000000
110 #define kConnexionMaskButton27 0x04000000
111 #define kConnexionMaskButton28 0x08000000
112 #define kConnexionMaskButton29 0x10000000
113 #define kConnexionMaskButton30 0x20000000
114 #define kConnexionMaskButton31 0x40000000
115 #define kConnexionMaskButton32 0x80000000
116 
117 #define kConnexionMaskAllButtons 0xFFFFFFFF
118 
119 // Masks for client-controlled feature switches
120 
121 #define kConnexionSwitchDominant 0x0002
122 #define kConnexionSwitchEnableAxis1 0x0004
123 #define kConnexionSwitchEnableAxis2 0x0008
124 #define kConnexionSwitchEnableAxis3 0x0010
125 #define kConnexionSwitchEnableAxis4 0x0020
126 #define kConnexionSwitchEnableAxis5 0x0040
127 #define kConnexionSwitchEnableAxis6 0x0080
128 
129 #define kConnexionSwitchEnableTrans 0x001C
130 #define kConnexionSwitchEnableRot 0x00E0
131 #define kConnexionSwitchEnableAll 0x00FC
132 
133 #define kConnexionSwitchZoomOnY 0x0001 // no longer applies, no effect on new driver
134 #define kConnexionSwitchReverseAxis1 0x0100 // no longer applies, no effect on new driver
135 #define kConnexionSwitchReverseAxis2 0x0200 // no longer applies, no effect on new driver
136 #define kConnexionSwitchReverseAxis3 0x0400 // no longer applies, no effect on new driver
137 #define kConnexionSwitchReverseAxis4 0x0800 // no longer applies, no effect on new driver
138 #define kConnexionSwitchReverseAxis5 0x1000 // no longer applies, no effect on new driver
139 #define kConnexionSwitchReverseAxis6 0x2000 // no longer applies, no effect on new driver
140 #define kConnexionSwitchReverseTrans 0x0700 // no longer applies, no effect on new driver
141 #define kConnexionSwitchReverseRot 0x3800 // no longer applies, no effect on new driver
142 #define kConnexionSwitchReverseAll 0x3F00 // no longer applies, no effect on new driver
143 
144 #define kConnexionSwitchesDisabled 0x80000000 // use driver defaults instead of client-controlled switches
145 
146 //==============================================================================
147 // Device state record
148 
149 // Structure type and current version:
150 
151 #define kConnexionDeviceStateType 0x4D53 // 'MS' (Connexion State)
152 #define kConnexionDeviceStateVers 0x6D33 // 'm3' (version 3 includes 32-bit button data in previously unused field, binary compatible with version 2)
153 
154 // This structure is used to forward device data and commands from the kext to the client:
155 
156 typedef struct {
157 // header
158  uint16_t version; // kConnexionDeviceStateVers
159  uint16_t client; // identifier of the target client when sending a state message to all user clients
160 // command
161  uint16_t command; // command for the user-space client
162  int16_t param; // optional parameter for the specified command
163  int32_t value; // optional value for the specified command
164  uint64_t time; // timestamp for this message (clock_get_uptime)
165 // raw report
166  uint8_t report[8]; // raw USB report from the device
167 // processed data
168  uint16_t buttons8; // buttons (first 8 buttons only, for backwards binary compatibility- use "buttons" field instead)
169  int16_t axis[6]; // x, y, z, rx, ry, rz
170  uint16_t address; // USB device address, used to tell one device from the other
171  uint32_t buttons; // buttons
172 } ConnexionDeviceState, *ConnexionDeviceStatePtr;
173 
174 // Size of the above structure:
175 
176 #define kConnexionDeviceStateSize (sizeof(ConnexionDeviceState))
177 
178 //==============================================================================
179 // Device IDs for 3Dconnexion devices with separate and different preferences.
180 // NOTE: These IDs are no longer internally used by the driver, and the
181 // ConnexionGetCurrentDevicePrefs API always returns kDevID_AnyDevice in the
182 // deviceID field. The definitions are kept here for backwards compatibility only.
183 
184 #define kDevID_AnyDevice 0x7FFF // wildcard used to specify any available device
185 
186 //==============================================================================
187 // Device prefs record
188 
189 // Structure type and current version:
190 
191 #define kConnexionDevicePrefsType 0x4D50 // 'MP' (Connexion Prefs)
192 #define kConnexionDevicePrefsVers 0x7031 // 'p1' (version 1)
193 
194 // This structure is used to retrieve the current device prefs from the helper:
195 
196 typedef struct {
197 // header
198  uint16_t type; // kConnexionDevicePrefsType
199  uint16_t version; // kConnexionDevicePrefsVers
200  uint16_t deviceID; // device ID (SpaceNavigator, SpaceNavigatorNB, SpaceExplorer...)
201  uint16_t reserved1; // set to 0
202 // target application
203  uint32_t appSignature; // target application signature
204  uint32_t reserved2; // set to 0
205  uint8_t appName[64]; // target application name (Pascal string with length byte at the beginning)
206 // device preferences
207  uint8_t mainSpeed; // overall speed
208  uint8_t zoomOnY; // use Y axis for zoom, Z axis for un/down pan
209  uint8_t dominant; // only respond to the largest one of all 6 axes values at any given time
210  uint8_t reserved3; // set to 0
211  int8_t mapV[6]; // axes mapping when Zoom direction is on vertical axis (zoomOnY = 0)
212  int8_t mapH[6]; // axes mapping when Zoom direction is on horizontal axis (zoomOnY != 0)
213  uint8_t enabled[6]; // enable or disable individual axes
214  uint8_t reversed[6]; // reverse individual axes
215  uint8_t speed[6]; // speed for individual axes (min 0, max 200, reserved 201-255)
216  uint8_t sensitivity[6]; // sensitivity for individual axes (min 0, max 200, reserved 201-255)
217  int32_t scale[6]; // 10000 * scale and "natural" reverse state for individual axes
218 // added in version 10.0 (build 136)
219  uint32_t gamma; // 1000 * gamma value used to compute nonlinear axis response, use 1000 (1.0) for linear response
220  uint32_t intersect; // intersect value used for gamma computations
221 } ConnexionDevicePrefs, *ConnexionDevicePrefsPtr;
222 
223 // Size of the above structure:
224 
225 #define kConnexionDevicePrefsSize (sizeof(ConnexionDevicePrefs))
226 
227 //==============================================================================
228 #pragma pack(pop)
229 //==============================================================================
230 #ifdef __cplusplus
231 }
232 #endif
233 //==============================================================================
234 
235 #endif // _H_connexionclient
236 
237 //==============================================================================