Fixes (mostly for #385)
This commit is contained in:
1 parent
781e643b64
commit
31fee44bf7
2 files changed
+24
-27
No files matched your search
@@ -49,8 +49,8 @@ BOOL slideableHotbar;
|
||||
|
||||
#pragma mark Class TrackedTextField
|
||||
@interface TrackedTextField : UITextField
|
||||
@property int lastTextPos;
|
||||
@property CGFloat lastPointX;
|
||||
@property(nonatomic) int lastTextPos;
|
||||
@property(nonatomic) CGFloat lastPointX;
|
||||
@end
|
||||
|
||||
@implementation TrackedTextField
|
||||
@@ -181,25 +181,25 @@ BOOL slideableHotbar;
|
||||
@interface SurfaceViewController ()<UITextFieldDelegate, UIPointerInteractionDelegate, UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate> {
|
||||
}
|
||||
|
||||
@property NSArray *menuArray;
|
||||
@property UITableView *menuView;
|
||||
@property(nonatomic) NSArray *menuArray;
|
||||
@property(nonatomic) UITableView *menuView;
|
||||
|
||||
@property UIView *ctrlView, *rootView;
|
||||
@property(nonatomic) UIView *ctrlView, *rootView;
|
||||
|
||||
@property TrackedTextField *inputView;
|
||||
@property(nonatomic, strong) NSMutableDictionary* cc_dictionary;
|
||||
@property(nonatomic, strong) NSMutableArray* swipeableButtons;
|
||||
@property ControlButton* swipingButton;
|
||||
@property UITouch *primaryTouch, *hotbarTouch;
|
||||
@property(nonatomic) TrackedTextField *inputView;
|
||||
@property(nonatomic) NSMutableDictionary* cc_dictionary;
|
||||
@property(nonatomic) NSMutableArray* swipeableButtons;
|
||||
@property(nonatomic) ControlButton* swipingButton;
|
||||
@property(nonatomic) UITouch *primaryTouch, *hotbarTouch;
|
||||
|
||||
@property UIView *logOutputView;
|
||||
|
||||
@property id mouseConnectCallback, mouseDisconnectCallback;
|
||||
@property id controllerConnectCallback, controllerDisconnectCallback;
|
||||
@property(nonatomic) id mouseConnectCallback, mouseDisconnectCallback;
|
||||
@property(nonatomic) id controllerConnectCallback, controllerDisconnectCallback;
|
||||
|
||||
@property CGFloat mouseSpeed;
|
||||
@property CGRect clickRange;
|
||||
@property BOOL shouldTriggerClick;
|
||||
@property(nonatomic) CGFloat mouseSpeed;
|
||||
@property(nonatomic) CGRect clickRange;
|
||||
@property(nonatomic) BOOL shouldTriggerClick;
|
||||
|
||||
@end
|
||||
|
||||
@@ -220,12 +220,13 @@ BOOL slideableHotbar;
|
||||
[self.navigationItem setHidesBackButton:YES animated:YES];
|
||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||
|
||||
// Perform Gamepad joystick ticking, while alos controlling frame rate?
|
||||
// Perform Gamepad joystick ticking, while also controlling frame rate?
|
||||
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:ControllerInput.class selector:@selector(tick)];
|
||||
if (@available(iOS 15.0, *)) {
|
||||
displayLink.preferredFrameRateRange = CAFrameRateRangeMake(60, 120, 120);
|
||||
}
|
||||
[displayLink addToRunLoop:NSRunLoop.currentRunLoop forMode:NSRunLoopCommonModes];
|
||||
|
||||
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||
CGFloat screenScale = [[UIScreen mainScreen] scale];
|
||||
|
||||
@@ -1071,10 +1072,6 @@ CallbackBridge_nativeSendKey(keycode, 0, held, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEBUG_VISIBLE_TEXT_FIELD
|
||||
self.inputView.hidden = currentVisibility;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -180,16 +180,16 @@ BOOL leftShiftHeld;
|
||||
lastYValue = yValue;
|
||||
}
|
||||
};
|
||||
gamepad.rightThumbstick.up.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
gamepad.leftThumbstick.up.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
[self sendKeyEvent:GLFW_KEY_W pressed:pressed];
|
||||
};
|
||||
gamepad.rightThumbstick.left.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
gamepad.leftThumbstick.left.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
[self sendKeyEvent:GLFW_KEY_A pressed:pressed];
|
||||
};
|
||||
gamepad.rightThumbstick.down.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
gamepad.leftThumbstick.down.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
[self sendKeyEvent:GLFW_KEY_S pressed:pressed];
|
||||
};
|
||||
gamepad.rightThumbstick.right.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
gamepad.leftThumbstick.right.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
[self sendKeyEvent:GLFW_KEY_D pressed:pressed];
|
||||
};
|
||||
if (@available(iOS 12.1, *)) {
|
||||
@@ -207,21 +207,21 @@ BOOL leftShiftHeld;
|
||||
*/
|
||||
+ (void)tick {
|
||||
// There isn't a convenient way to get ns, use ms at this point
|
||||
CGFloat frameTimeMilis = CACurrentMediaTime();
|
||||
CGFloat frameTime = CACurrentMediaTime();
|
||||
// GameController automatically performs deadzone calculations
|
||||
// so we just take the raw input
|
||||
if (lastFrameTime != 0 && (lastXValue != 0 || lastYValue != 0)) {
|
||||
CGFloat acceleration = MathUtils_dist(0, 0, lastXValue, lastYValue); // magnitude
|
||||
CGFloat deltaX = lastXValue * acceleration * 18;
|
||||
CGFloat deltaY = -lastYValue * acceleration * 18;
|
||||
CGFloat deltaTimeScale = (frameTimeMilis - lastFrameTime) / 0.016666666; // Scale of 1 = 60Hz
|
||||
CGFloat deltaTimeScale = (frameTime - lastFrameTime) / 0.016666666; // Scale of 1 = 60Hz
|
||||
deltaX *= deltaTimeScale;
|
||||
deltaY *= deltaTimeScale;
|
||||
|
||||
SurfaceViewController *vc = (id)(currentWindow().rootViewController);
|
||||
[vc sendTouchPoint:CGPointMake(deltaX, deltaY) withEvent:ACTION_MOVE_MOTION];
|
||||
}
|
||||
lastFrameTime = frameTimeMilis;
|
||||
lastFrameTime = frameTime;
|
||||
}
|
||||
|
||||
+ (void)unregisterControllerCallbacks:(GCController *)controller {
|
||||
|
||||
Reference in new issue
Block a user