|
@@ -1,11 +1,14 @@
|
|
|
package sdl;
|
|
|
|
|
|
private typedef GameControllerPtr = hl.Abstract<"sdl_gamecontroller">;
|
|
|
+private typedef HapticPtr = hl.Abstract<"sdl_haptic">;
|
|
|
|
|
|
@:hlNative("sdl")
|
|
|
class GameController {
|
|
|
|
|
|
var ptr : GameControllerPtr;
|
|
|
+ var haptic : HapticPtr;
|
|
|
+ var rumbleInitialized : Bool = false;
|
|
|
|
|
|
public var id(get,never) : Int;
|
|
|
public var name(get,never) : String;
|
|
@@ -30,7 +33,23 @@ class GameController {
|
|
|
return @:privateAccess String.fromUTF8( gctrlGetName(ptr) );
|
|
|
}
|
|
|
|
|
|
+ public function rumble( strength : Float, length : Int ) : Bool {
|
|
|
+ if( haptic == null && !rumbleInitialized ){
|
|
|
+ rumbleInitialized = true;
|
|
|
+ haptic = hapticOpen(ptr);
|
|
|
+ if( haptic != null && hapticRumbleInit(haptic) != 0 ){
|
|
|
+ hapticClose(haptic);
|
|
|
+ haptic = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( haptic == null ) return false;
|
|
|
+ return hapticRumblePlay( haptic, strength, length ) == 0;
|
|
|
+ }
|
|
|
+
|
|
|
public function close(){
|
|
|
+ if( haptic != null )
|
|
|
+ hapticClose(haptic);
|
|
|
+ haptic = null;
|
|
|
gctrlClose( ptr );
|
|
|
ptr = null;
|
|
|
}
|
|
@@ -62,4 +81,20 @@ class GameController {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ static function hapticOpen( controller : GameControllerPtr ) : HapticPtr {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ static function hapticClose( haptic : HapticPtr ) : Void {
|
|
|
+ }
|
|
|
+
|
|
|
+ static function hapticRumbleInit( haptic : HapticPtr ) : Int {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ static function hapticRumblePlay( haptic : HapticPtr, strength : Float, length : Int ) : Int {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|