Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef enum {

NSUInteger index;
BOOL connected;

BOOL allowsRotation;

JSObjectRef jsAxes;
JSObjectRef jsButtons;
}
Expand Down
17 changes: 14 additions & 3 deletions Source/Ejecta/EJUtils/Gamepad/EJBindingGamepad.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand 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