starRail pointer veloc tweak enchancement
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NativeTouchHandler : UIResponder
|
||||
|
||||
@property (nonatomic, assign) bool XBoundaryReached;
|
||||
@property (nonatomic, assign) bool YBoundaryReached;
|
||||
@property (nonatomic, assign) bool flipFlag;
|
||||
- (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings;
|
||||
|
||||
@end
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
|
||||
[NativeTouchPointer setPointerVelocityDivider:settings.pointerVelocityModeDivider.floatValue];
|
||||
[NativeTouchPointer setPointerVelocityFactor:settings.touchPointerVelocityFactor.floatValue];
|
||||
[NativeTouchPointer initContextWithView:streamView];
|
||||
|
||||
[NativeTouchPointer initContextWithView:self->streamView andNativeTouchHandler:self];
|
||||
_flipFlag = true;
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,15 @@
|
||||
else targetCoords = [touch locationInView:streamView];
|
||||
CGPoint location = [streamView adjustCoordinatesForVideoArea:targetCoords];
|
||||
CGSize videoSize = [streamView getVideoAreaSize];
|
||||
LiSendTouchEvent(touchType,[self retrievePointerIdFromDict:touch],location.x / videoSize.width, location.y / videoSize.height,(touch.force / touch.maximumPossibleForce) / sin(touch.altitudeAngle),0.0f, 0.0f,[streamView getRotationFromAzimuthAngle:[touch azimuthAngleInView:streamView]]);
|
||||
CGFloat normalizedX = location.x / videoSize.width;
|
||||
CGFloat normalizedY = location.y / videoSize.height;
|
||||
uint8_t pointerId = [self retrievePointerIdFromDict:touch];
|
||||
|
||||
_XBoundaryReached = (normalizedX == 1.0f || normalizedX == 0.f);
|
||||
_YBoundaryReached = (normalizedY == 1.0f || normalizedY == 0.f);
|
||||
//if(_XBoundaryReached || _YBoundaryReached) LiSendTouchEvent(LI_TOUCH_EVENT_UP,pointerId, normalizedX, normalizedY, 0, 0, 0, 0);
|
||||
if(_XBoundaryReached || _YBoundaryReached) LiSendTouchEvent(LI_TOUCH_EVENT_UP,pointerId, normalizedX, normalizedY, 0, 0, 0, 0);
|
||||
else LiSendTouchEvent(touchType, pointerId, normalizedX, normalizedY,(touch.force / touch.maximumPossibleForce) / sin(touch.altitudeAngle),0.0f, 0.0f,[streamView getRotationFromAzimuthAngle:[touch azimuthAngleInView:streamView]]);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
//
|
||||
|
||||
#import "StreamView.h"
|
||||
#import "NativeTouchHandler.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NativeTouchPointer : NSObject
|
||||
|
||||
+ (void)initContextWithView:(StreamView *)view;
|
||||
|
||||
+ (void)initContextWithView:(StreamView *)view andNativeTouchHandler:(NativeTouchHandler*)handler;
|
||||
+ (void)setPointerVelocityDivider:(CGFloat)dividerLocation;
|
||||
+ (void)setPointerVelocityFactor:(CGFloat)velocityFactor;
|
||||
+ (void)populatePointerObjIntoDict:(UITouch*)touch;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NativeTouchPointer.h"
|
||||
#import "NativeTouchHandler.h"
|
||||
#include <Limelight.h>
|
||||
|
||||
// native touch pointer ojbect that stores & manipulates touch coordinates
|
||||
@@ -17,6 +18,9 @@ static NSMutableDictionary *pointerObjDict;
|
||||
static CGFloat pointerVelocityFactor;
|
||||
static CGFloat pointerVelocityDivider;
|
||||
static CGFloat pointerVelocityDividerLocationByPoints;
|
||||
static NativeTouchHandler* nativeTouchHandler;
|
||||
static CGFloat halfScreenHeightInPoints;
|
||||
static CGFloat halfScreenWidthInPoints;
|
||||
|
||||
StreamView *streamView;
|
||||
|
||||
@@ -49,12 +53,20 @@ StreamView *streamView;
|
||||
previousPoint = latestPoint;
|
||||
latestPoint = [touch locationInView:streamView];
|
||||
previousRelativePoint = latestRelativePoint;
|
||||
if(nativeTouchHandler.XBoundaryReached || nativeTouchHandler.YBoundaryReached){ // reset
|
||||
previousRelativePoint.x = halfScreenWidthInPoints;
|
||||
previousRelativePoint.y = halfScreenHeightInPoints;
|
||||
}
|
||||
latestRelativePoint.x = previousRelativePoint.x + pointerVelocityFactor * (latestPoint.x - previousPoint.x);
|
||||
latestRelativePoint.y = previousRelativePoint.y + pointerVelocityFactor * (latestPoint.y - previousPoint.y);
|
||||
|
||||
}
|
||||
|
||||
+ (void)initContextWithView:(StreamView *)view{
|
||||
+ (void)initContextWithView:(StreamView *)view andNativeTouchHandler:(NativeTouchHandler*)handler {
|
||||
streamView = view;
|
||||
nativeTouchHandler = handler;
|
||||
halfScreenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds])/2;
|
||||
halfScreenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds])/2;
|
||||
pointerObjDict = [NSMutableDictionary dictionary];
|
||||
pointerVelocityDividerLocationByPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]) * pointerVelocityDivider;
|
||||
NSLog(@"pointerVelocityDivider: %.2f", pointerVelocityDivider);
|
||||
|
||||
Reference in New Issue
Block a user