1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
|
#ifndef IHFXPARAM_H_
#define IHFXPARAM_H_
#include ".\\HFXConfig.h"
class IHapticEffect;
typedef IHapticEffect IHFXEffect;
#ifdef HFX_64BIT
#define HFX_NULL_HANDLE ((IHFXEffect*)(unsigned long)0x000000000000001)
#else
#define HFX_NULL_HANDLE ((IHFXEffect*)(unsigned long)0x00000001)
#endif
static IHFXEffect *hfxNoHandle=HFX_NULL_HANDLE;
typedef unsigned __int32 HFXParamID;
typedef unsigned __int32 HFXEffectID;
// if a invalid char is added it will show up as '`'
// if a '?' it will be the same as a '_'
// any upper case chars will be converted to lowercase.
#define HFX_PARAM_ENCODE_CHAR_LOWER(lowercase_alpha_or_underscore) \
(lowercase_alpha_or_underscore ? ( ( lowercase_alpha_or_underscore < ('~'+1) ) ? \
( (lowercase_alpha_or_underscore)-('^') ) : 2 ) : 0)
#define HFX_PARAM_ENCODE_CHAR_UPPER(upper_alpha) \
(upper_alpha!=0 ? ( (upper_alpha>'>') ? \
((upper_alpha)-('>')) : ( ((upper_alpha>'/')&&(upper_alpha<':')) ? \
((upper_alpha + 32)-('>')) : (2) ) \
) : 0)
#define HFX_PARAM_ENCODE_CHAR(alpha_or_underscore) \
(alpha_or_underscore ?(alpha_or_underscore < '_') ? \
HFX_PARAM_ENCODE_CHAR_UPPER(alpha_or_underscore) : \
HFX_PARAM_ENCODE_CHAR_LOWER(alpha_or_underscore):0 )
#define HFX_PARAM_PACK_CHAR(char, index) \
( char ? ((char) << (index * 5)) : 0 )
#define HFX_PARAM_ENCODE_STRING_CHAR(char) ( (char < '_') ? (HFX_PARAM_ENCODE_CHAR_UPPER(char)) : (HFX_PARAM_ENCODE_CHAR_LOWER(char)) )
#define HFX_PARAM_ENCODE_AND_PACK_CHAR(char, index) \
HFX_PARAM_PACK_CHAR(HFX_PARAM_ENCODE_CHAR(char), index)
#define TC unsigned int
#define HFX_PARAM_ENCODE_STRING(ConstCharPtr7) \
( ConstCharPtr7 ? \
(ConstCharPtr7[0]!=0 ? \
((HFX_PARAM_ENCODE_STRING_CHAR((ConstCharPtr7)[0])) << 0) | \
(ConstCharPtr7[1]!=0 ? \
((HFX_PARAM_ENCODE_STRING_CHAR((ConstCharPtr7)[1])) << 5) | \
(ConstCharPtr7[2]!=0 ? \
((HFX_PARAM_ENCODE_STRING_CHAR((ConstCharPtr7)[2])) << 10) | \
(ConstCharPtr7[3]!=0 ? \
((HFX_PARAM_ENCODE_STRING_CHAR((ConstCharPtr7)[3])) << 15) | \
(ConstCharPtr7[4]!=0 ? \
((HFX_PARAM_ENCODE_STRING_CHAR((ConstCharPtr7)[4])) << 20) | \
(ConstCharPtr7[5]!=0 ? \
((HFX_PARAM_ENCODE_STRING_CHAR((ConstCharPtr7)[5])) << 25) \
: (unsigned)0) \
: (unsigned)0) \
: (unsigned)0) \
: (unsigned)0) \
: (unsigned)0) \
: (unsigned)0) \
: (unsigned)0)
#define HFX_PARAM_ENCODE_6(c1,c2,c3,c4,c5,c6) \
((HFXParamID)\
( HFX_PARAM_ENCODE_AND_PACK_CHAR(c1,0) | HFX_PARAM_ENCODE_AND_PACK_CHAR(c2,1) | HFX_PARAM_ENCODE_AND_PACK_CHAR(c3,2) \
| HFX_PARAM_ENCODE_AND_PACK_CHAR(c4,3) | HFX_PARAM_ENCODE_AND_PACK_CHAR(c5,4) | HFX_PARAM_ENCODE_AND_PACK_CHAR(c6,5) ))
#define HFX_PARAM_ENCODE_5(c1,c2,c3,c4,c5) \
HFX_PARAM_ENCODE_6(c1,c2,c3,c4,c5,0)
#define HFX_PARAM_ENCODE_4(c1,c2,c3,c4) \
HFX_PARAM_ENCODE_6(c1,c2,c3,c4,0,0)
#define HFX_PARAM_ENCODE_3(c1,c2,c3) \
HFX_PARAM_ENCODE_6(c1,c2,c3,0,0,0)
#define HFX_PARAM_ENCODE_2(c1,c2) \
HFX_PARAM_ENCODE_6(c1,c2,0,0,0,0)
#define HFX_PARAM_ENCODE_1(c1) \
HFX_PARAM_ENCODE_6(c1,0,0,0,0,0)
#define HFX_PARAM_DECODE_TO(char7, hfxparamid) \
(char7)[0] = HFX_CHAR_ID(hfxparamid, 0); \
(char7)[1] = (char7)[0] ? HFX_CHAR_ID(hfxparamid, 1) : 0; \
(char7)[2] = (char7)[1] ? HFX_CHAR_ID(hfxparamid, 2) : 0; \
(char7)[3] = (char7)[2] ? HFX_CHAR_ID(hfxparamid, 3) : 0; \
(char7)[4] = (char7)[3] ? HFX_CHAR_ID(hfxparamid, 4) : 0; \
(char7)[5] = (char7)[4] ? HFX_CHAR_ID(hfxparamid, 5) : 0; \
(char7)[6] = 0
HFX_INLINE HFXParamID HFX_PARAM_ENCODE_VA(char c1, char c2=0, char c3=0, char c4=0, char c5=0, char c6=0)
{
return HFX_PARAM_ENCODE_6(c1,c2,c3,c4,c5,c6);
}
#if HFX_MSVC > 7
//max of 6!
#define HFX_PARAM_ENCODE(...) HFX_PARAM_ENCODE_VA(__VA_ARGS__)
#else
#define HFX_PARAM_ENCODE HFX_PARAM_ENCODE_VA
#endif
#define HFX_PARAM_ENCODE_4(c1,c2,c3,c4) HFX_PARAM_ENCODE_6(c1,c2,c3,c4,0,0)
#define HFX_5BIT_MASK ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4))
#define HFX_MASK_ID(paramid, index)((paramid>>(index*5)) & (HFX_5BIT_MASK))
#define HFX_CHAR_ID(paramid, index) \
(HFX_MASK_ID(paramid,index)?HFX_MASK_ID(paramid,index)+'^':0)
// usage : char hfxParamText[] = HFX_PARAMETER_DECODE(hfxParamID);
#define HFX_PARAM_DECODE(hfxparam) { \
HFX_CHAR_ID(hfxparam,0), \
HFX_CHAR_ID(hfxparam,1), \
HFX_CHAR_ID(hfxparam,2), \
HFX_CHAR_ID(hfxparam,3), \
HFX_CHAR_ID(hfxparam,4), \
HFX_CHAR_ID(hfxparam,5),0}
enum HFXParamType
{
HFXPARAM_NULL = 0,
HFXPARAM_INT = 'i',
HFXPARAM_FLOAT = 'f',
HFXPARAM_DOUBLE = 'd',
HFXPARAM_BOOL = 'b',
HFXPARAM_INT_ARRAY = 'I',
HFXPARAM_FLOAT_ARRAY = 'F',
HFXPARAM_DOUBLE_ARRAY = 'D',
HFXPARAM_BOOL_ARRAY = 'B',
};
typedef unsigned char HFXPARAM;
enum HFXArray
{
HFXARRAY_NOTARRAY=0,
HFXARRAY_COPY=1,//
HFXARRAY_INDEX=2,
};
typedef unsigned char HFXARRAY;
typedef void *HFXVarValue;
struct HFX_PURE_INTERFACE IHapticEffectParamGroup
{
#ifndef HFX_NO_PARAMETER_CLASS_MACROS
// declare this inside user implementated parametergroup class definitions.
#define HFX_PARAMETER_GROUP(classname, baseclass, defaultEffect) \
typedef classname ParameterGroup; \
typedef baseclass SuperGroup; \
typedef defaultEffect EffectClass; \
using SuperGroup::SetVar; \
using SuperGroup::GetVar; \
using SuperGroup::SetVarFloat; \
using SuperGroup::SetVarInt; \
using SuperGroup::SetVarDouble; \
using SuperGroup::GetVarBool; \
using SuperGroup::GetVarFloat; \
using SuperGroup::GetVarInt; \
using SuperGroup::GetVarDouble;
#define HFX_PARAMETER_ID(name, type) \
static const HFXParamID ID_##name; \
static const char * const ID_##name##_String;
// declare this inside user implementated parametergroup class definitions
// for each variable you want to be accessible through
// parameter filetypes or set/get functions. These macros will make the variable
// you specify.
// specify a seperate membername for readability.
// REMEMBER: name should be no longer than 6 letters, membername can be as long as you want.
#define HFX_PARAMETER_FLOAT(name, membername) \
HFX_PARAMETER_ID(float_##name); \
union{float name; float m_fl##name; float membername;}; \
static const float ID_float_##name##_Default;
#define HFX_PARAMETER_DOUBLE(name, membername) \
HFX_PARAMETER_ID(double_##name); \
union{double name; double m_dbl##name; double membername;}; \
static const bool ID_double_##name##_Default
#define HFX_PARAMETER_BOOL(name, membername) \
HFX_PARAMETER_ID(bool_##name); \
union{bool name:1; bool m_b##name:1; bool membername:1;}; \
static const bool ID_bool_##name##_Default;
#define HFX_PARAMETER_INT(name, membername) \
HFX_PARAMETER_ID(int_##name); \
union{int name; int m_i##name; int membername;}; \
static const int ID_int_##name##_Default;
#define HFX_PARAMETER_FLOAT_ARRAY(size, name, membername) \
HFX_PARAMETER_ID(float##size##_##name); \
union{float name; float m_fl##size##name; float membername;}; \
static const float ID_float##size##_##name##_Default[size];
#define HFX_PARAMETER_DOUBLE_ARRAY(size, name, membername) \
HFX_PARAMETER_ID(double##size##_##name); \
union{double name[size]; double m_dbl##size##name[size]; double membername[size];}; \
static const bool ID_double##size##_##name##_Default[size];
#define HFX_PARAMETER_BOOL_ARRAY(size, name, membername) \
HFX_PARAMETER_ID(bool##size##_##name); \
union{bool name[size]; bool m_b##size##name[size]; bool membername[size];}; \
static const bool ID_bool##size##_##name##_Default[size];
#define HFX_PARAMETER_INT_ARRAY(size, name, membername) \
HFX_PARAMETER_ID(int##size##_##name); \
union{int name[size]; int m_i##name[size]; int membername[size];}; \
static const int ID_int##size##_##name##_Default;
#endif
//virtual bool RunSetCommand( char *cmd ) = 0;
//virtual HFXEffectID StandardEffectName() const = 0;
// ACTUAL OVERRIDES!
virtual bool SetVar(const HFXParamID id, void *value, HFXParamType t,
HFXARRAY settype=HFXARRAY_NOTARRAY, unsigned int indexORcount=0, bool allowMake=false) = 0;
virtual bool GetVar(const HFXParamID id, void *value, HFXParamType t,
HFXARRAY gettype=HFXARRAY_NOTARRAY, unsigned int indexORcount=0 )const = 0;
#ifndef HFX_NO_OVERLOADED_PARAMETER
HFX_INLINE bool SetVarByName(const char *name, HFXVarValue value, HFXParamType t,
bool allowMake )
{return SetVar(HFX_PARAM_ENCODE_STRING(name), value, t, HFXARRAY_NOTARRAY, 0, allowMake);}
HFX_INLINE bool SetVar(const HFXParamID name, HFXVarValue value, HFXParamType t,
bool allowMake )
{return SetVar(name, value, t, HFXARRAY_NOTARRAY, 0, allowMake);}
HFX_INLINE bool SetVarByName(const char *name, HFXVarValue value, HFXParamType t,
HFXARRAY settype, unsigned int indexORcount, bool allowMake )
{return SetVar(HFX_PARAM_ENCODE_STRING(name), value, t, settype, indexORcount, allowMake);}
HFX_INLINE bool SetVarByName(const char *name, const double value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_DOUBLE, allowMake);}
HFX_INLINE bool SetVar(const HFXParamID name, const double value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_DOUBLE, allowMake);}
HFX_INLINE bool SetVarByName(const char *name, const bool value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_BOOL, allowMake);}
HFX_INLINE bool SetVar(const HFXParamID name, const bool value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_BOOL, allowMake);}
HFX_INLINE bool SetVarByName(const char *name, const float value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_FLOAT, allowMake);}
HFX_INLINE bool SetVar(const HFXParamID name, const float value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_FLOAT, allowMake);}
HFX_INLINE bool SetVarByName(const char *name, const int value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_INT, allowMake);}
HFX_INLINE bool SetVar(const HFXParamID name, const int value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_INT, allowMake);}
HFX_INLINE bool SetVarArrayByName(const char *name, unsigned int arraySize, const double *value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArray(const HFXParamID name, unsigned int arraySize, const double *value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArrayByName(const char *name, unsigned int arraySize, const bool *value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArray(const HFXParamID name, unsigned int arraySize, const bool *value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArrayByName(const char *name, unsigned int arraySize, const float *value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArray(const HFXParamID name, unsigned int arraySize, const float *value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArrayByName(const char *name, unsigned int arraySize, const int *value, bool allowMake=false)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
HFX_INLINE bool SetVarArray(const HFXParamID name, unsigned int arraySize, const int *value, bool allowMake=false)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_COPY, arraySize, allowMake);}
template<typename T, int S>
HFX_INLINE bool SetVarTypeArrayByName(const char *name, const T (value)[S], bool allowMake = false)
{return SetVarArrayByName(name, S, (const T*)value, allowMake);}
template<typename T, int S>
HFX_INLINE bool SetVarTypeArray(const HFXParamID name, const T (value)[S], bool allowMake = false)
{return SetVarArray(name, S, (const T*)value, allowMake);}
HFX_INLINE bool SetVarElementByName(const char *name, unsigned int arrayIndex, const double value)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElement(const HFXParamID name, unsigned int arrayIndex, const double value)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElementByName(const char *name, unsigned int arrayIndex, const bool value)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElement(const HFXParamID name, unsigned int arrayIndex, const bool value)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElementByName(const char *name, unsigned int arrayIndex, const float value)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElement(const HFXParamID name, unsigned int arrayIndex, const float value)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElementByName(const char *name, unsigned int arrayIndex, const int value)
{return SetVarByName(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool SetVarElement(const HFXParamID name, unsigned int arrayIndex, const int value)
{return SetVar(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_INDEX, arrayIndex, false);}
HFX_INLINE bool GetVarByName(const char *name, void *value, HFXParamType t,
HFXARRAY gettype=HFXARRAY_NOTARRAY, unsigned int indexORcount=0 )const
{return GetVar(HFX_PARAM_ENCODE_STRING(name), value, t, gettype, indexORcount);}
HFX_INLINE bool GetVarByName(const char *name, float &value )const
{return GetVarByName(name, (void*)&value, HFXPARAM_FLOAT);}
HFX_INLINE bool GetVar( const HFXParamID name, float &value )const
{return GetVar(name, (void*)&value, HFXPARAM_FLOAT);}
HFX_INLINE bool GetVarByName(const char *name, double &value )const
{return GetVarByName(name, (void*)&value, HFXPARAM_DOUBLE);}
HFX_INLINE bool GetVar( const HFXParamID name, double &value )const
{return GetVar(name, (void*)&value, HFXPARAM_DOUBLE);}
HFX_INLINE bool GetVarByName(const char *name, int &value )const
{return GetVarByName(name, (void*)&value, HFXPARAM_INT);}
HFX_INLINE bool GetVar( const HFXParamID name, int &value )const
{return GetVar(name, (void*)&value, HFXPARAM_INT);}
HFX_INLINE bool GetVarByName(const char *name, bool &value )const
{return GetVarByName(name, (void*)&value, HFXPARAM_BOOL);}
HFX_INLINE bool GetVar( const HFXParamID name, bool &value )const
{return GetVar(name, (void*)&value, HFXPARAM_BOOL);}
HFX_INLINE bool GetVarElementByName(const char *name, unsigned int arrayIndex, float &value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElement(const HFXParamID name, unsigned int arrayIndex, float &value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElementByName(const char *name, unsigned int arrayIndex, double &value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElement(const HFXParamID name, unsigned int arrayIndex, double &value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElementByName(const char *name, unsigned int arrayIndex, bool &value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElement(const HFXParamID name, unsigned int arrayIndex, bool &value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElementByName(const char *name, unsigned int arrayIndex, int &value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarElement(const HFXParamID name, unsigned int arrayIndex, int &value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_INDEX, arrayIndex);}
HFX_INLINE bool GetVarArrayByName(const char *name, unsigned int arraySize, int *&value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArrayByName(const char *name, unsigned int arraySize, float *&value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArrayByName(const char *name, unsigned int arraySize, double *&value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArrayByName(const char *name, unsigned int arraySize, bool *&value)const
{return GetVarByName(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArray(const HFXParamID name, unsigned int arraySize, float *&value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_FLOAT_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArray(const HFXParamID name, unsigned int arraySize, double *&value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_DOUBLE_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArray(const HFXParamID name, unsigned int arraySize, bool *&value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_BOOL_ARRAY, HFXARRAY_COPY, arraySize);}
HFX_INLINE bool GetVarArray(const HFXParamID name, unsigned int arraySize, int *&value)const
{return GetVar(name, (HFXVarValue)&value, HFXPARAM_INT_ARRAY, HFXARRAY_COPY, arraySize);}
template<typename T, int S>
HFX_INLINE bool GetVarTypeArrayByName(const char *name, T (value)[S])const
{return GetVarArrayByName(name, S, (T*&)value);}
template<typename T, int S>
HFX_INLINE bool GetVarTypeArray(const HFXParamID name, T (value)[S])const
{return GetVarArray(name, S, (T*&)value);}
//strict access start. (ensures type is set) use these for typing or parsing.
HFX_INLINE bool SetVarFloatByName(const char *name, const float value, bool allowMake=false)
{ return SetVarByName(name, value, allowMake); }
HFX_INLINE bool SetVarFloat(const HFXParamID name, const float value, bool allowMake=false)
{ return SetVar(name, value, allowMake); }
HFX_INLINE bool SetVarDoubleByName(const char *name, const double value, bool allowMake=false)
{ return SetVarByName(name, value, allowMake); }
HFX_INLINE bool SetVarDouble(const HFXParamID name, const double value, bool allowMake=false)
{ return SetVar(name, value, allowMake); }
HFX_INLINE bool SetVarIntByName(const char *name, const int value, bool allowMake=false)
{ return SetVarByName(name, value, allowMake); }
HFX_INLINE bool SetVarInt(const HFXParamID name, const int value, bool allowMake=false)
{ return SetVar(name, value, allowMake); }
HFX_INLINE bool SetVarBoolByName(const char *name, const bool value, bool allowMake=false)
{ return SetVarByName(name, value, allowMake); }
HFX_INLINE bool SetVarBool(const HFXParamID name, const bool value, bool allowMake=false)
{ return SetVar(name, value, allowMake); }
HFX_INLINE bool SetVarDoubleArrayByName(const char * name, unsigned int size, const double *value, bool allowMake=false)
{ return SetVarArrayByName(name, size, value, allowMake); }
HFX_INLINE bool SetVarDoubleArray(const HFXParamID name, unsigned int size, const double *value, bool allowMake=false)
{ return SetVarArray(name, size, value, allowMake); }
HFX_INLINE bool SetVarFloatArrayByName(const char * name, unsigned int size, const float *value, bool allowMake=false)
{ return SetVarArrayByName(name, size, value, allowMake); }
HFX_INLINE bool SetVarFloatArray(const HFXParamID name, unsigned int size, const float *value, bool allowMake=false)
{ return SetVarArray(name, size, value, allowMake); }
HFX_INLINE bool SetVarIntArrayByName(const char * name, unsigned int size, const int *value, bool allowMake=false)
{ return SetVarArrayByName(name, size, value, allowMake); }
HFX_INLINE bool SetVarIntArray(const HFXParamID name, unsigned int size, const int *value, bool allowMake=false)
{ return SetVarArray(name, size, value, allowMake); }
HFX_INLINE bool SetVarBoolArrayByName(const char * name, unsigned int size, const bool *value, bool allowMake=false)
{ return SetVarArrayByName(name, size, value, allowMake); }
HFX_INLINE bool SetVarBoolArray(const HFXParamID name, unsigned int size, const bool *value, bool allowMake=false)
{ return SetVarArray(name, size, value, allowMake); }
HFX_INLINE bool SetVarFloatElementByName(const char * name, unsigned int index, const float value)
{ return SetVarElementByName(name, index, value); }
HFX_INLINE bool SetVarFloatElement(const HFXParamID name, unsigned int index, const float value)
{ return SetVarElement(name, index, value); }
HFX_INLINE bool SetVarIntElementByName(const char * name, unsigned int index, const int value)
{ return SetVarElementByName(name, index, value); }
HFX_INLINE bool SetVarIntElement(const HFXParamID name, unsigned int index, const int value)
{ return SetVarElement(name, index, value); }
HFX_INLINE bool SetVarBoolElementByName(const char * name, unsigned int index, const bool value)
{ return SetVarElementByName(name, index, value); }
HFX_INLINE bool SetVarBoolElement(const HFXParamID name, unsigned int index, const bool value)
{ return SetVarElement(name, index, value); }
HFX_INLINE bool SetVarDoubleElementByName(const char * name, unsigned int index, const double value)
{ return SetVarElementByName(name, index, value); }
HFX_INLINE bool SetVarDoubleElement(const HFXParamID name, unsigned int index, const double value)
{ return SetVarElement(name, index, value); }
HFX_INLINE bool SetVarDoubleArrayByFloatArray(const HFXParamID name, unsigned int size, const float *value, bool allowMake=false)
{
double *__d_ = new double[size];
for(unsigned int i=0;i!=size;i++)
__d_[i]=(double)value[i];
bool retval;
retval = SetVarDoubleArray(name, size, __d_, allowMake);
delete [] __d_;
return retval;
}
HFX_INLINE bool SetVarDoubleArrayByFloatArrayByName(const char *name, unsigned int size, const float *value, bool allowMake=false)
{ return SetVarDoubleArrayByFloatArray(HFX_PARAM_ENCODE_STRING(name),size,value,allowMake); }
HFX_INLINE bool GetVarFloatByName(const char *name, float &value)const
{ return GetVarByName(name, value); }
HFX_INLINE bool GetVarDoubleByName(const char *name, double &value)const
{ return GetVarByName(name, value); }
HFX_INLINE bool GetVarIntByName(const char *name, int &value)const
{ return GetVarByName(name, value); }
HFX_INLINE bool GetVarBoolByName(const char *name, bool &value)const
{ return GetVarByName(name, value); }
HFX_INLINE bool GetVarFloatElementByName(const char *name, unsigned int index, float &value)const
{ return GetVarElementByName(name, index, value); }
HFX_INLINE bool GetVarDoubleElementByName(const char *name, unsigned int index, double &value)const
{ return GetVarElementByName(name, index, value); }
HFX_INLINE bool GetVarIntElementByName(const char *name, unsigned int index, int &value)const
{ return GetVarElementByName(name, index, value); }
HFX_INLINE bool GetVarBoolElementByName(const char *name, unsigned int index, bool &value)const
{ return GetVarElementByName(name, index, value); }
HFX_INLINE bool GetVarFloatArrayByName(const char *name, unsigned int size, float *&value)const
{ return GetVarArrayByName(name, size, value); }
HFX_INLINE bool GetVarDoubleArrayByName(const char *name, unsigned int size, double *&value)const
{ return GetVarArrayByName(name, size, value); }
HFX_INLINE bool GetVarIntArrayByName(const char *name, unsigned int size, int *&value)const
{ return GetVarArrayByName(name, size, value); }
HFX_INLINE bool GetVarBoolArrayByName(const char *name, unsigned int size, bool *&value)const
{ return GetVarArrayByName(name, size, value); }
HFX_INLINE bool GetVarFloat(const HFXParamID name, float &value)const
{ return GetVar(name, value); }
HFX_INLINE bool GetVarDouble(const HFXParamID name, double &value)const
{ return GetVar(name, value); }
HFX_INLINE bool GetVarInt(const HFXParamID name, int &value)const
{ return GetVar(name, value); }
HFX_INLINE bool GetVarBool(const HFXParamID name, bool &value)const
{ return GetVar(name, value); }
HFX_INLINE bool GetVarFloatElement(const HFXParamID name, unsigned int index, float &value)const
{ return GetVarElement(name, index, value); }
HFX_INLINE bool GetVarDoubleElement(const HFXParamID name, unsigned int index, double &value)const
{ return GetVarElement(name, index, value); }
HFX_INLINE bool GetVarIntElement(const HFXParamID name, unsigned int index, int &value)const
{ return GetVarElement(name, index, value); }
HFX_INLINE bool GetVarBoolElement(const HFXParamID name, unsigned int index, bool &value)const
{ return GetVarElement(name, index, value); }
HFX_INLINE bool GetVarFloatArray(const HFXParamID name, unsigned int size, float *&value)const
{ return GetVarArray(name, size, value); }
HFX_INLINE bool GetVarDoubleArray(const HFXParamID name, unsigned int size, double *&value)const
{ return GetVarArray(name, size, value); }
HFX_INLINE bool GetVarIntArray(const HFXParamID name, unsigned int size, int *&value)const
{ return GetVarArray(name, size, value); }
HFX_INLINE bool GetVarBoolArray(const HFXParamID name, unsigned int size, bool *&value)const
{ return GetVarArray(name, size, value); }
HFX_INLINE bool GetVarDoubleArrayByFloatArray(const HFXParamID name, unsigned int size, float *&value) const
{
double *__d_ = new double[size];
for(unsigned int i=0;i!=size;i++)
__d_[i]=(double)value[i];
bool retval;
if(retval = GetVarDoubleArray(name, size, __d_))
for(unsigned int i = 0;i!=size;i++)
value[i]=(float)__d_[i];
delete [] __d_;
return retval;
}
HFX_INLINE bool GetVarDoubleArrayByFloatArrayByName(const char *name, unsigned int size, float *&value) const
{ return GetVarDoubleArrayByFloatArray(HFX_PARAM_ENCODE_STRING(name),size,value); }
// util helpers
// Vec3 and Vec3f
HFX_INLINE bool SetVarVec3ByName(const char *name, const double *hfxVect3, bool bAllowMake=false)
{return SetVarDoubleArrayByName(name, 3, hfxVect3, bAllowMake);}
HFX_INLINE bool SetVarVec3(const HFXParamID name, const double *hfxVect3, bool bAllowMake=false)
{return SetVarDoubleArray(name, 3, hfxVect3, bAllowMake);}
HFX_INLINE bool GetVarVec3ByName(const char *name, double *&hfxVect3) const
{return GetVarDoubleArrayByName(name, 3, hfxVect3);}
HFX_INLINE bool GetVarVec3(const HFXParamID name, double *&hfxVect3) const
{return GetVarDoubleArray(name, 3, hfxVect3);}
HFX_INLINE bool SetVarVec3fByName(const char *name, const float *hfxVect3f, bool bAllowMake=false)
{return SetVarFloatArrayByName(name, 3, hfxVect3f, bAllowMake);}
HFX_INLINE bool SetVarVec3f(const HFXParamID name, const float *hfxVect3f, bool bAllowMake=false)
{return SetVarFloatArray(name, 3, hfxVect3f, bAllowMake);}
HFX_INLINE bool GetVarVec3fByName(const char *name, float *&hfxVect3f) const
{return GetVarFloatArrayByName(name, 3, hfxVect3f);}
HFX_INLINE bool GetVarVec3f(const HFXParamID name, float *&hfxVect3f) const
{return GetVarFloatArray(name, 3, hfxVect3f);}
//strict access end.
#endif
/*
virtual bool SetVar(HFXParamID id, const char *value, HFXParamType t,
HFXARRAY settype=HFXARRAY_NOTARRAY, unsigned int indexORcount=0) = 0;
virtual bool GetVar(HFXParamID id, const char *value, HFXParamType t,
HFXARRAY gettype=HFXARRAY_NOTARRAY, unsigned int indexORcount=0 )const = 0;
*/
virtual class IStack *GetDefaultStack() const=0;
virtual void SetDefaultStack(class IStack *stack)=0;
virtual bool Copy(IHapticEffectParamGroup *&group) const=0;
virtual HFXEffectID StandardEffectID() const=0;
virtual void ChangeStandardEffectID(const HFXEffectID type)=0;
// creation
virtual bool CreateStandardEffect( IHFXEffect *&pHandle, class IStack *createOnStack=0, const char *customName=0 )=0;
HFX_INLINE bool CreateStandardEffect( IStack *createOnStack )
{
return CreateStandardEffect(hfxNoHandle, createOnStack, 0);
}
template<typename T>
HFX_INLINE bool CreateStandardEffect( T *&pHandle, class IStack *createOnStack=0, const char *customName=0)
{
return CreateStandardEffect((IHFXEffect *&)pHandle, createOnStack, customName);
}
HFX_INLINE HFXParamType GetVarTypeByName(const char *param, unsigned int *arraysize=0) const{ return GetVarType(HFX_PARAM_ENCODE_STRING(param), arraysize); }
virtual HFXParamType GetVarType(const HFXParamID param, unsigned int *arraysize=0) const=0;
};
typedef IHapticEffectParamGroup IHFXParamGroup;
#define HFX_PARAMETER_INIT(classname, type, name, defaultvalue) \
const char * const classname::ID_##type##name##_String = #name; \
const HFXParamID classname::ID_##type##name = HFX_PARAM_ENCODE_STRING(classname::ID_##type##name##_String); \
const type classname::ID_##type##name##_Default = defaultvalue;
typedef void (*HFXPGCreate_t)(IHFXParamGroup*&ptr);
typedef void (*HFXPGDestroy_t)(IHFXParamGroup*&ptr);
template<typename T>
void HFXDefaultAllocateParameterGroup(IHFXParamGroup *&ptr){ptr = new T;};
template<typename T>
void HFXDefaultDeallocateParameterGroup(IHFXParamGroup *&ptr){if(!ptr)return; delete ((T*)ptr); ptr=0;};
#endif
|