2
2
3
3
import DOM
4
4
import ECMAScript
5
+ import JavaScriptBigIntSupport
5
6
import JavaScriptKit
6
7
import WebAPIBase
7
8
@@ -33,17 +34,17 @@ public class Gamepad: JSBridgedClass {
33
34
34
35
@inlinable public var buttons : [ GamepadButton ] { jsObject [ Strings . buttons] . fromJSValue ( ) ! }
35
36
37
+ @inlinable public var touches : [ GamepadTouch ] { jsObject [ Strings . touches] . fromJSValue ( ) ! }
38
+
39
+ @inlinable public var vibrationActuator : GamepadHapticActuator {
40
+ jsObject [ Strings . vibrationActuator] . fromJSValue ( ) !
41
+ }
42
+
36
43
@inlinable public var hand : GamepadHand { jsObject [ Strings . hand] . fromJSValue ( ) ! }
37
44
38
45
@inlinable public var hapticActuators : [ GamepadHapticActuator ] { jsObject [ Strings . hapticActuators] . fromJSValue ( ) ! }
39
46
40
47
@inlinable public var pose : GamepadPose ? { jsObject [ Strings . pose] . fromJSValue ( ) }
41
-
42
- @inlinable public var touchEvents : [ GamepadTouch ] ? { jsObject [ Strings . touchEvents] . fromJSValue ( ) }
43
-
44
- @inlinable public var vibrationActuator : GamepadHapticActuator ? {
45
- jsObject [ Strings . vibrationActuator] . fromJSValue ( )
46
- }
47
48
}
48
49
49
50
public class GamepadButton : JSBridgedClass {
@@ -64,27 +65,31 @@ open class GamepadEffectParameters: JSDictionaryCompatible {
64
65
public let jsObject : JSObject
65
66
66
67
public convenience init (
67
- duration: Double ? = nil ,
68
- startDelay: Double ? = nil ,
68
+ duration: UInt64 ? = nil ,
69
+ startDelay: UInt64 ? = nil ,
69
70
strongMagnitude: Double ? = nil ,
70
- weakMagnitude: Double ? = nil
71
+ weakMagnitude: Double ? = nil ,
72
+ leftTrigger: Double ? = nil ,
73
+ rightTrigger: Double ? = nil
71
74
) {
72
75
let object = JSObject . global [ Strings . Object] . function!. new ( )
73
76
object [ Strings . duration] = _toJSValue ( duration)
74
77
object [ Strings . startDelay] = _toJSValue ( startDelay)
75
78
object [ Strings . strongMagnitude] = _toJSValue ( strongMagnitude)
76
79
object [ Strings . weakMagnitude] = _toJSValue ( weakMagnitude)
80
+ object [ Strings . leftTrigger] = _toJSValue ( leftTrigger)
81
+ object [ Strings . rightTrigger] = _toJSValue ( rightTrigger)
77
82
78
83
self . init ( unsafelyWrapping: object)
79
84
}
80
85
81
86
public required init ( unsafelyWrapping object: JSObject ) { self . jsObject = object }
82
87
83
- @inlinable public var duration : Double {
88
+ @inlinable public var duration : UInt64 {
84
89
get { jsObject [ Strings . duration] . fromJSValue ( ) ! }
85
90
set { jsObject [ Strings . duration] = _toJSValue ( newValue) }
86
91
}
87
- @inlinable public var startDelay : Double {
92
+ @inlinable public var startDelay : UInt64 {
88
93
get { jsObject [ Strings . startDelay] . fromJSValue ( ) ! }
89
94
set { jsObject [ Strings . startDelay] = _toJSValue ( newValue) }
90
95
}
@@ -96,6 +101,14 @@ open class GamepadEffectParameters: JSDictionaryCompatible {
96
101
get { jsObject [ Strings . weakMagnitude] . fromJSValue ( ) ! }
97
102
set { jsObject [ Strings . weakMagnitude] = _toJSValue ( newValue) }
98
103
}
104
+ @inlinable public var leftTrigger : Double {
105
+ get { jsObject [ Strings . leftTrigger] . fromJSValue ( ) ! }
106
+ set { jsObject [ Strings . leftTrigger] = _toJSValue ( newValue) }
107
+ }
108
+ @inlinable public var rightTrigger : Double {
109
+ get { jsObject [ Strings . rightTrigger] . fromJSValue ( ) ! }
110
+ set { jsObject [ Strings . rightTrigger] = _toJSValue ( newValue) }
111
+ }
99
112
}
100
113
public class GamepadEvent : Event {
101
114
@inlinable public override class var constructor : JSFunction ? { JSObject . global [ Strings . GamepadEvent] . function }
@@ -146,12 +159,7 @@ public class GamepadHapticActuator: JSBridgedClass {
146
159
147
160
public required init ( unsafelyWrapping jsObject: JSObject ) { self . jsObject = jsObject }
148
161
149
- @inlinable public var type : GamepadHapticActuatorType { jsObject [ Strings . type] . fromJSValue ( ) ! }
150
-
151
- @inlinable final public func canPlayEffectType( type: GamepadHapticEffectType ) -> Bool {
152
- let this = jsObject
153
- return this [ Strings . canPlayEffectType] . function!( this: this, arguments: [ _toJSValue ( type) ] ) . fromJSValue ( ) !
154
- }
162
+ @inlinable public var effects : [ GamepadHapticEffectType ] { jsObject [ Strings . effects] . fromJSValue ( ) ! }
155
163
156
164
@inlinable final public func playEffect(
157
165
type: GamepadHapticEffectType ,
@@ -176,6 +184,21 @@ public class GamepadHapticActuator: JSBridgedClass {
176
184
}
177
185
#endif
178
186
187
+ @inlinable final public func reset( ) -> JSPromise {
188
+ let this = jsObject
189
+ return this [ Strings . reset] . function!( this: this, arguments: [ ] ) . fromJSValue ( ) !
190
+ }
191
+
192
+ #if canImport(JavaScriptEventLoop)
193
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * ) @inlinable final public func reset( )
194
+ async throws ( JSException) -> GamepadHapticsResult
195
+ {
196
+ let this = jsObject
197
+ let _promise : JSPromise = this [ Strings . reset] . function!( this: this, arguments: [ ] ) . fromJSValue ( ) !
198
+ return try await _promise. value. fromJSValue ( ) !
199
+ }
200
+ #endif
201
+
179
202
@inlinable final public func pulse( value: Double , duration: Double ) -> JSPromise {
180
203
let this = jsObject
181
204
return this [ Strings . pulse] . function!( this: this, arguments: [ _toJSValue ( value) , _toJSValue ( duration) ] )
@@ -195,38 +218,11 @@ public class GamepadHapticActuator: JSBridgedClass {
195
218
return try await _promise. value. fromJSValue ( ) !
196
219
}
197
220
#endif
198
-
199
- @inlinable final public func reset( ) -> JSPromise {
200
- let this = jsObject
201
- return this [ Strings . reset] . function!( this: this, arguments: [ ] ) . fromJSValue ( ) !
202
- }
203
-
204
- #if canImport(JavaScriptEventLoop)
205
- @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * ) @inlinable final public func reset( )
206
- async throws ( JSException) -> GamepadHapticsResult
207
- {
208
- let this = jsObject
209
- let _promise : JSPromise = this [ Strings . reset] . function!( this: this, arguments: [ ] ) . fromJSValue ( ) !
210
- return try await _promise. value. fromJSValue ( ) !
211
- }
212
- #endif
213
221
}
214
222
215
- public enum GamepadHapticActuatorType : JSString , JSValueCompatible {
216
- case vibration = " vibration "
217
- case dualRumble = " dual-rumble "
218
-
219
- @inlinable public static func construct( from jsValue: JSValue ) -> Self ? {
220
- if let string = jsValue. jsString { return Self ( rawValue: string) }
221
- return nil
222
- }
223
-
224
- @inlinable public init ? ( string: String ) { self . init ( rawValue: JSString ( string) ) }
225
-
226
- @inlinable public var jsValue : JSValue { rawValue. jsValue }
227
- }
228
223
public enum GamepadHapticEffectType : JSString , JSValueCompatible {
229
224
case dualRumble = " dual-rumble "
225
+ case triggerRumble = " trigger-rumble "
230
226
231
227
@inlinable public static func construct( from jsValue: JSValue ) -> Self ? {
232
228
if let string = jsValue. jsString { return Self ( rawValue: string) }
@@ -288,22 +284,43 @@ public class GamepadPose: JSBridgedClass {
288
284
@inlinable public var angularAcceleration : Float32Array ? { jsObject [ Strings . angularAcceleration] . fromJSValue ( ) }
289
285
}
290
286
291
- public class GamepadTouch : JSBridgedClass {
292
- @inlinable public class var constructor : JSFunction ? { JSObject . global [ Strings . GamepadTouch] . function }
293
-
287
+ open class GamepadTouch : JSDictionaryCompatible {
294
288
public let jsObject : JSObject
295
289
296
- public required init ( unsafelyWrapping jsObject: JSObject ) { self . jsObject = jsObject }
297
-
298
- @inlinable public var touchId : UInt32 { jsObject [ Strings . touchId] . fromJSValue ( ) ! }
290
+ public convenience init (
291
+ touchId: UInt32 ? = nil ,
292
+ surfaceId: UInt8 ? = nil ,
293
+ position: DOMPointReadOnly ? = nil ,
294
+ surfaceDimensions: DOMRectReadOnly ?
295
+ ) {
296
+ let object = JSObject . global [ Strings . Object] . function!. new ( )
297
+ object [ Strings . touchId] = _toJSValue ( touchId)
298
+ object [ Strings . surfaceId] = _toJSValue ( surfaceId)
299
+ object [ Strings . position] = _toJSValue ( position)
300
+ object [ Strings . surfaceDimensions] = _toJSValue ( surfaceDimensions)
299
301
300
- @inlinable public var surfaceId : UInt8 { jsObject [ Strings . surfaceId] . fromJSValue ( ) ! }
302
+ self . init ( unsafelyWrapping: object)
303
+ }
301
304
302
- @ inlinable public var position : Float32Array { jsObject [ Strings . position ] . fromJSValue ( ) ! }
305
+ public required init ( unsafelyWrapping object : JSObject ) { self . jsObject = object }
303
306
304
- @inlinable public var surfaceDimensions : Uint32Array ? { jsObject [ Strings . surfaceDimensions] . fromJSValue ( ) }
307
+ @inlinable public var touchId : UInt32 {
308
+ get { jsObject [ Strings . touchId] . fromJSValue ( ) ! }
309
+ set { jsObject [ Strings . touchId] = _toJSValue ( newValue) }
310
+ }
311
+ @inlinable public var surfaceId : UInt8 {
312
+ get { jsObject [ Strings . surfaceId] . fromJSValue ( ) ! }
313
+ set { jsObject [ Strings . surfaceId] = _toJSValue ( newValue) }
314
+ }
315
+ @inlinable public var position : DOMPointReadOnly {
316
+ get { jsObject [ Strings . position] . fromJSValue ( ) ! }
317
+ set { jsObject [ Strings . position] = _toJSValue ( newValue) }
318
+ }
319
+ @inlinable public var surfaceDimensions : DOMRectReadOnly ? {
320
+ get { jsObject [ Strings . surfaceDimensions] . fromJSValue ( ) }
321
+ set { jsObject [ Strings . surfaceDimensions] = _toJSValue ( newValue) }
322
+ }
305
323
}
306
-
307
324
extension Navigator {
308
325
309
326
@inlinable final public func getGamepads( ) -> [ Gamepad ? ] {
@@ -349,16 +366,15 @@ extension WindowEventHandlers {
349
366
@usableFromInline static let `GamepadEvent` : JSString = " GamepadEvent "
350
367
@usableFromInline static let `GamepadHapticActuator` : JSString = " GamepadHapticActuator "
351
368
@usableFromInline static let `GamepadPose` : JSString = " GamepadPose "
352
- @usableFromInline static let `GamepadTouch` : JSString = " GamepadTouch "
353
369
@usableFromInline static let `Navigator` : JSString = " Navigator "
354
370
@usableFromInline static let `Object` : JSString = " Object "
355
371
@usableFromInline static let `angularAcceleration` : JSString = " angularAcceleration "
356
372
@usableFromInline static let `angularVelocity` : JSString = " angularVelocity "
357
373
@usableFromInline static let `axes` : JSString = " axes "
358
374
@usableFromInline static let `buttons` : JSString = " buttons "
359
- @usableFromInline static let `canPlayEffectType` : JSString = " canPlayEffectType "
360
375
@usableFromInline static let `connected` : JSString = " connected "
361
376
@usableFromInline static let `duration` : JSString = " duration "
377
+ @usableFromInline static let `effects` : JSString = " effects "
362
378
@usableFromInline static let `gamepad` : JSString = " gamepad "
363
379
@usableFromInline static let `getGamepads` : JSString = " getGamepads "
364
380
@usableFromInline static let `hand` : JSString = " hand "
@@ -367,6 +383,7 @@ extension WindowEventHandlers {
367
383
@usableFromInline static let `hasPosition` : JSString = " hasPosition "
368
384
@usableFromInline static let `id` : JSString = " id "
369
385
@usableFromInline static let `index` : JSString = " index "
386
+ @usableFromInline static let `leftTrigger` : JSString = " leftTrigger "
370
387
@usableFromInline static let `linearAcceleration` : JSString = " linearAcceleration "
371
388
@usableFromInline static let `linearVelocity` : JSString = " linearVelocity "
372
389
@usableFromInline static let `mapping` : JSString = " mapping "
@@ -379,16 +396,16 @@ extension WindowEventHandlers {
379
396
@usableFromInline static let `pressed` : JSString = " pressed "
380
397
@usableFromInline static let `pulse` : JSString = " pulse "
381
398
@usableFromInline static let `reset` : JSString = " reset "
399
+ @usableFromInline static let `rightTrigger` : JSString = " rightTrigger "
382
400
@usableFromInline static let `startDelay` : JSString = " startDelay "
383
401
@usableFromInline static let `strongMagnitude` : JSString = " strongMagnitude "
384
402
@usableFromInline static let `surfaceDimensions` : JSString = " surfaceDimensions "
385
403
@usableFromInline static let `surfaceId` : JSString = " surfaceId "
386
404
@usableFromInline static let `timestamp` : JSString = " timestamp "
387
405
@usableFromInline static let `toString` : JSString = " toString "
388
- @usableFromInline static let `touchEvents` : JSString = " touchEvents "
389
406
@usableFromInline static let `touchId` : JSString = " touchId "
390
407
@usableFromInline static let `touched` : JSString = " touched "
391
- @usableFromInline static let `type ` : JSString = " type "
408
+ @usableFromInline static let `touches ` : JSString = " touches "
392
409
@usableFromInline static let `value` : JSString = " value "
393
410
@usableFromInline static let `vibrationActuator` : JSString = " vibrationActuator "
394
411
@usableFromInline static let `weakMagnitude` : JSString = " weakMagnitude "
0 commit comments