-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhaptic.js
155 lines (152 loc) · 4.25 KB
/
haptic.js
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
const {
e,
Struct,
ArrayType,
push_export
} = require('./api');
e.SDL_HAPTIC_CONSTANT = 1 << 0;
e.SDL_HAPTIC_SINE = 1 << 1;
e.SDL_HAPTIC_LEFTRIGHT = 1 << 2;
e.SDL_HAPTIC_TRIANGLE = 1 << 3;
e.SDL_HAPTIC_SAWTOOTHUP = 1 << 4;
e.SDL_HAPTIC_SAWTOOTHDOWN = 1 << 5;
e.SDL_HAPTIC_RAMP = 1 << 6;
e.SDL_HAPTIC_SPRING = 1 << 7;
e.SDL_HAPTIC_DAMPER = 1 << 8;
e.SDL_HAPTIC_INERTIA = 1 << 9;
e.SDL_HAPTIC_FRICTION = 1 << 10;
e.SDL_HAPTIC_CUSTOM = 1 << 11;
e.SDL_HAPTIC_GAIN = 1 << 12;
e.SDL_HAPTIC_AUTOCENTER = 1 << 13;
e.SDL_HAPTIC_STATUS = 1 << 14;
e.SDL_HAPTIC_PAUSE = 1 << 15;
e.SDL_HAPTIC_POLAR = 0;
e.SDL_HAPTIC_CARTESIAN = 1;
e.SDL_HAPTIC_SPHERICAL = 2;
e.SDL_HAPTIC_STEERING_AXIS = 3;
e.SDL_HAPTIC_INFINITY = 4294967295;
e.SDL_HapticDirection = Struct({
type: 'Uint8',
dir: ArrayType('int32', 3)
});
e.SDL_HapticConstant = Struct({
type: 'Uint16',
direction: e.SDL_HapticDirection,
length: 'Uint32',
delay: 'Uint16',
button: 'Uint16',
interval: 'Uint16',
level: 'int16',
attack_length: 'Uint16',
attack_level: 'Uint16',
fade_length: 'Uint16',
fade_level: 'Uint16'
});
e.SDL_HapticPeriodic = Struct({
type: 'Uint16',
direction: e.SDL_HapticDirection,
length: 'Uint32',
delay: 'Uint16',
button: 'Uint16',
interval: 'Uint16',
period: 'Uint16',
magnitude: 'int16',
offset: 'int16',
phase: 'Uint16',
attack_length: 'Uint16',
attack_level: 'Uint16',
fade_length: 'Uint16',
fade_level: 'Uint16'
});
e.SDL_HapticCondition = Struct({
type: 'Uint16',
direction: e.SDL_HapticDirection,
length: 'Uint32',
delay: 'Uint16',
button: 'Uint16',
interval: 'Uint16',
right_sat: ArrayType('Uint16', 3),
left_sat: ArrayType('Uint16', 3),
right_coeff: ArrayType('int16', 3),
left_coeff: ArrayType('int16', 3),
deadband: ArrayType('Uint16', 3),
center: ArrayType('int16', 3)
});
e.SDL_HapticRamp = Struct({
type: 'Uint16',
direction: e.SDL_HapticDirection,
length: 'Uint32',
delay: 'Uint16',
button: 'Uint16',
interval: 'Uint16',
start: 'int16',
end: 'int16',
attack_length: 'Uint16',
attack_level: 'Uint16',
fade_length: 'Uint16',
fade_level: 'Uint16'
});
e.SDL_HapticLeftRight = Struct({
type: 'Uint16',
length: 'Uint32',
delay: 'Uint16',
large_magnitude: 'Uint16',
small_magnitude: 'Uint16'
});
e.SDL_HapticCustom = Struct({
type: 'Uint16',
direction: e.SDL_HapticDirection,
length: 'Uint32',
delay: 'Uint16',
button: 'Uint16',
interval: 'Uint16',
channels: 'Uint8',
period: 'Uint16',
samples: 'Uint16',
data: 'Uint16*',
attack_length: 'Uint16',
attack_level: 'Uint16',
fade_length: 'Uint16',
fade_level: 'Uint16'
});
e.SDL_HapticEffect = Struct({
type: 'Uint16',
constant: e.SDL_HapticConstant,
periodic: e.SDL_HapticPeriodic,
condition: e.SDL_HapticCondition,
ramp: e.SDL_HapticRamp,
leftright: e.SDL_HapticLeftRight,
custom: e.SDL_HapticCustom
});
push_export({
'SDL_NumHaptics': ['int', []],
'SDL_HapticName': ['string', ['int']],
'SDL_HapticOpen': ['void*', ['int']],
'SDL_HapticOpened': ['int', ['int']],
'SDL_HapticIndex': ['int', ['void*']],
'SDL_MouseIsHaptic': ['int', []],
'SDL_HapticOpenFromMouse': ['void*', []],
'SDL_JoystickIsHaptic': ['int', ['void*']],
'SDL_HapticOpenFromJoystick': ['void*', ['void*']],
'SDL_HapticClose': ['void', ['void*']],
'SDL_HapticNumEffects': ['int', ['void*']],
'SDL_HapticNumEffectsPlaying': ['int', ['void*']],
'SDL_HapticQuery': ['Uint', ['void*']],
'SDL_HapticNumAxes': ['int', ['void*']],
'SDL_HapticEffectSupported': ['int', ['void*', 'void*']],
'SDL_HapticNewEffect': ['int', ['void*', 'void*']],
'SDL_HapticUpdateEffect': ['int', ['void*', 'int', 'void*']],
'SDL_HapticRunEffect': ['int', ['void*', 'int', 'Uint32']],
'SDL_HapticStopEffect': ['int', ['void*', 'int']],
'SDL_HapticDestroyEffect': ['void', ['void*', 'int']],
'SDL_HapticGetEffectStatus': ['int', ['void*', 'int']],
'SDL_HapticSetGain': ['int', ['void*', 'int']],
'SDL_HapticSetAutocenter': ['int', ['void*', 'int']],
'SDL_HapticPause': ['int', ['void*']],
'SDL_HapticUnpause': ['int', ['void*']],
'SDL_HapticStopAll': ['int', ['void*']],
'SDL_HapticRumbleSupported': ['int', ['void*']],
'SDL_HapticRumbleInit': ['int', ['void*']],
'SDL_HapticRumblePlay': ['int', ['void*', 'float', 'Uint32']],
'SDL_HapticRumbleStop': ['int', ['void*']]
});