diff --git a/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.h b/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.h index 6363ad07..7e06de4d 100644 --- a/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.h +++ b/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.h @@ -29,7 +29,8 @@ typedef enum { NSUInteger index; BOOL connected; - + BOOL allowsRotation; + JSObjectRef jsAxes; JSObjectRef jsButtons; } diff --git a/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.m b/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.m index 7a87ea90..d920db6c 100644 --- a/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.m +++ b/Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.m @@ -9,7 +9,7 @@ - (id)initWithController:(GCController *)controllerp atIndex:(NSUInteger)indexp controller = [controllerp retain]; index = indexp; connected = YES; - + allowsRotation = YES; controller.playerIndex = index; } return self; @@ -75,10 +75,11 @@ - (void)createWithJSObject:(JSObjectRef)obj scriptView:(EJJavaScriptView *)view mapping[kEJGamepadButtonLeft] = gamepad.dpad.left; mapping[kEJGamepadButtonRight] = gamepad.dpad.right; } - #if TARGET_OS_TV + #if TARGET_OS_TV else if( controller.microGamepad ) { GCMicroGamepad *gamepad = controller.microGamepad; gamepad.reportsAbsoluteDpadValues = YES; + gamepad.allowsRotation = allowsRotation; mapping[kEJGamepadButtonA] = gamepad.buttonA; mapping[kEJGamepadButtonX] = gamepad.buttonX; mapping[kEJGamepadButtonUp] = gamepad.dpad.up; @@ -204,9 +205,19 @@ - (JSObjectRef)jsObject { scriptView.exitOnMenuPress = JSValueToBoolean(ctx, value); } -@end +EJ_BIND_GET(allowsRotation, ctx) { + return JSValueMakeBoolean(ctx, allowsRotation); +} +EJ_BIND_SET(allowsRotation, ctx, value) { + if( controller.microGamepad ) { + allowsRotation = JSValueToBoolean(ctx, value); + GCMicroGamepad *gamepad = controller.microGamepad; + gamepad.allowsRotation = allowsRotation; + } +} +@end