@kmamal/sdl 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -27,6 +27,8 @@ class ControllerInstance extends EventsViaPoll {
|
|
|
27
27
|
|
|
28
28
|
this._device = device
|
|
29
29
|
|
|
30
|
+
this._rumbleTimeout = null
|
|
31
|
+
this._rumbleTriggersTimeout = null
|
|
30
32
|
this._closed = false
|
|
31
33
|
|
|
32
34
|
Globals.controllerInstances.all.add(this)
|
|
@@ -83,10 +85,18 @@ class ControllerInstance extends EventsViaPoll {
|
|
|
83
85
|
if (highFreqRumble < 0 || highFreqRumble > 1) { throw Object.assign(new Error("highFreqRumble must be between 0 and 1"), { highFreqRumble }) }
|
|
84
86
|
if (!Number.isFinite(duration)) { throw Object.assign(new Error("duration must be a number"), { duration }) }
|
|
85
87
|
|
|
88
|
+
Globals.events.poll()
|
|
86
89
|
Bindings.joystick_rumble(this._device.id, lowFreqRumble, highFreqRumble, duration)
|
|
90
|
+
clearTimeout(this._rumbleTimeout)
|
|
91
|
+
this._rumbleTimeout = setTimeout(() => { this.stopRumble() }, duration)
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
stopRumble () {
|
|
94
|
+
stopRumble () {
|
|
95
|
+
clearTimeout(this._rumbleTimeout)
|
|
96
|
+
this._rumbleTimeout = null
|
|
97
|
+
Bindings.joystick_rumble(this._device.id, 0, 0, 0)
|
|
98
|
+
Globals.events.poll()
|
|
99
|
+
}
|
|
90
100
|
|
|
91
101
|
get hasRumbleTriggers () { return this._hasRumbleTriggers }
|
|
92
102
|
rumbleTriggers (leftRumble = 1, rightRumble = 1, duration = 1e3) {
|
|
@@ -98,10 +108,18 @@ class ControllerInstance extends EventsViaPoll {
|
|
|
98
108
|
if (rightRumble < 0 || rightRumble > 1) { throw Object.assign(new Error("rightRumble must be between 0 and 1"), { rightRumble }) }
|
|
99
109
|
if (!Number.isFinite(duration)) { throw Object.assign(new Error("duration must be a number"), { duration }) }
|
|
100
110
|
|
|
111
|
+
Globals.events.poll()
|
|
101
112
|
Bindings.joystick_rumbleTriggers(this._device.id, leftRumble, rightRumble, duration)
|
|
113
|
+
clearTimeout(this._rumbleTriggersTimeout)
|
|
114
|
+
this._rumbleTriggersTimeout = setTimeout(() => { this.stopRumble() }, duration)
|
|
102
115
|
}
|
|
103
116
|
|
|
104
|
-
stopRumbleTriggers () {
|
|
117
|
+
stopRumbleTriggers () {
|
|
118
|
+
clearTimeout(this._rumbleTriggersTimeout)
|
|
119
|
+
this._rumbleTriggersTimeout = null
|
|
120
|
+
Bindings.joystick_rumbleTriggers(this._device.id, 0, 0, 0)
|
|
121
|
+
Globals.events.poll()
|
|
122
|
+
}
|
|
105
123
|
|
|
106
124
|
get closed () { return this._closed }
|
|
107
125
|
close () {
|
|
@@ -68,7 +68,7 @@ const reconcileDevices = (emitter, mainList, currList, compare) => {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
const
|
|
71
|
+
const poll = () => {
|
|
72
72
|
let event
|
|
73
73
|
while ((event = Bindings.events_poll())) {
|
|
74
74
|
const { family, type } = event
|
|
@@ -368,7 +368,7 @@ const handleEvents = () => {
|
|
|
368
368
|
let eventsInterval = null
|
|
369
369
|
|
|
370
370
|
const startPolling = () => {
|
|
371
|
-
eventsInterval = setInterval(
|
|
371
|
+
eventsInterval = setInterval(poll, 0)
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
const stopPolling = () => {
|
|
@@ -379,4 +379,5 @@ const stopPolling = () => {
|
|
|
379
379
|
Globals.events = {
|
|
380
380
|
startPolling,
|
|
381
381
|
stopPolling,
|
|
382
|
+
poll,
|
|
382
383
|
}
|
|
@@ -30,6 +30,8 @@ class JoystickInstance extends EventsViaPoll {
|
|
|
30
30
|
|
|
31
31
|
this._device = device
|
|
32
32
|
|
|
33
|
+
this._rumbleTimeout = null
|
|
34
|
+
this._rumbleTriggersTimeout = null
|
|
33
35
|
this._closed = false
|
|
34
36
|
|
|
35
37
|
Globals.joystickInstances.all.add(this)
|
|
@@ -88,10 +90,18 @@ class JoystickInstance extends EventsViaPoll {
|
|
|
88
90
|
if (highFreqRumble < 0 || highFreqRumble > 1) { throw Object.assign(new Error("highFreqRumble must be between 0 and 1"), { highFreqRumble }) }
|
|
89
91
|
if (!Number.isFinite(duration)) { throw Object.assign(new Error("duration must be a number"), { duration }) }
|
|
90
92
|
|
|
93
|
+
Globals.events.poll()
|
|
91
94
|
Bindings.joystick_rumble(this._device.id, lowFreqRumble, highFreqRumble, duration)
|
|
95
|
+
clearTimeout(this._rumbleTimeout)
|
|
96
|
+
this._rumbleTimeout = setTimeout(() => { this.stopRumble() }, duration)
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
stopRumble () {
|
|
99
|
+
stopRumble () {
|
|
100
|
+
clearTimeout(this._rumbleTimeout)
|
|
101
|
+
this._rumbleTimeout = null
|
|
102
|
+
Bindings.joystick_rumble(this._device.id, 0, 0, 0)
|
|
103
|
+
Globals.events.poll()
|
|
104
|
+
}
|
|
95
105
|
|
|
96
106
|
get hasRumbleTriggers () { return this._hasRumbleTriggers }
|
|
97
107
|
rumbleTriggers (leftRumble = 1, rightRumble = 1, duration = 1e3) {
|
|
@@ -103,10 +113,18 @@ class JoystickInstance extends EventsViaPoll {
|
|
|
103
113
|
if (rightRumble < 0 || rightRumble > 1) { throw Object.assign(new Error("rightRumble must be between 0 and 1"), { rightRumble }) }
|
|
104
114
|
if (!Number.isFinite(duration)) { throw Object.assign(new Error("duration must be a number"), { duration }) }
|
|
105
115
|
|
|
116
|
+
Globals.events.poll()
|
|
106
117
|
Bindings.joystick_rumbleTriggers(this._device.id, leftRumble, rightRumble, duration)
|
|
118
|
+
clearTimeout(this._rumbleTriggersTimeout)
|
|
119
|
+
this._rumbleTriggersTimeout = setTimeout(() => { this.stopRumble() }, duration)
|
|
107
120
|
}
|
|
108
121
|
|
|
109
|
-
stopRumbleTriggers () {
|
|
122
|
+
stopRumbleTriggers () {
|
|
123
|
+
clearTimeout(this._rumbleTriggersTimeout)
|
|
124
|
+
this._rumbleTriggersTimeout = null
|
|
125
|
+
Bindings.joystick_rumbleTriggers(this._device.id, 0, 0, 0)
|
|
126
|
+
Globals.events.poll()
|
|
127
|
+
}
|
|
110
128
|
|
|
111
129
|
get closed () { return this._closed }
|
|
112
130
|
close () {
|
|
@@ -690,6 +690,11 @@ enum_getControllerButtons (Variant & buttons)
|
|
|
690
690
|
ErrorMessage *
|
|
691
691
|
initialize (Variant & object)
|
|
692
692
|
{
|
|
693
|
+
// Hints
|
|
694
|
+
{
|
|
695
|
+
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
|
|
696
|
+
}
|
|
697
|
+
|
|
693
698
|
MAKE_MAP(object);
|
|
694
699
|
|
|
695
700
|
// Init
|
|
@@ -704,11 +709,6 @@ initialize (Variant & object)
|
|
|
704
709
|
}
|
|
705
710
|
}
|
|
706
711
|
|
|
707
|
-
// Hints
|
|
708
|
-
{
|
|
709
|
-
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
|
|
710
|
-
}
|
|
711
|
-
|
|
712
712
|
// Version
|
|
713
713
|
{
|
|
714
714
|
Variant version, compile, runtime;
|