full portrait support for on-screen widgets & legacy on-screen controls

This commit is contained in:
TrueZhuanjia committed 2025-07-26 01:18:48 +08:00
1 parent 0df5135f0b
commit e301f2af16
6 files changed
+38 -24

No files matched your search

+1
View File
@@ -36,6 +36,7 @@
@property (assign, nonatomic) UIView* streamFrameTopLayerView; @property (assign, nonatomic) UIView* streamFrameTopLayerView;
@property (assign, nonatomic) CGFloat streamAspectRatio; @property (assign, nonatomic) CGFloat streamAspectRatio;
@property (assign, nonatomic) CGRect originalFrame; @property (assign, nonatomic) CGRect originalFrame;
@property (assign, nonatomic) bool widgetToolOpened;
- (void) setupStreamView:(ControllerSupport*)controllerSupport - (void) setupStreamView:(ControllerSupport*)controllerSupport
+6 -3
View File
@@ -350,7 +350,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
- (void) showOnScreenControls { - (void) showOnScreenControls {
#if !TARGET_OS_TV #if !TARGET_OS_TV
[onScreenControls show]; if(!_widgetToolOpened) [onScreenControls show];
#endif #endif
} }
@@ -411,8 +411,11 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
- (CGPoint)denormalizeWidgetPosition:(CGPoint)position { - (CGPoint)denormalizeWidgetPosition:(CGPoint)position {
if(position.x < 1.0 && position.y < 1.0){ if(position.x < 1.0 && position.y < 1.0){
position.x = position.x * self.bounds.size.width; position.x = position.x * streamFrameTopLayerView.bounds.size.width;
position.y = position.y * self.bounds.size.height; position.y = position.y * streamFrameTopLayerView.bounds.size.height;
}
else{
NSLog(@"invalid coords");
} }
return position; return position;
} }
@@ -78,7 +78,14 @@
return position; return position;
} }
- (void) reloadOnScreenWidgetViews { - (void)reloadLegacyOnScreenControls{
[self.layoutOSC updateControls]; // creates and saves a 'Default' OSC profile or loads the o//ne the user selected on the previous screen
[self addInnerAnalogSticksToOuterAnalogLayers];
[self.layoutOSC.layoutChanges removeAllObjects]; // since a new OSC profile is being loaded, this will remove all previous layout changes made from the array
[self OSCLayoutChanged]; // fades the 'Undo Button' out
}
- (void)reloadOnScreenWidgetViews{
NSLog(@"reloadOnScreenWidgets %f", CACurrentMediaTime()); NSLog(@"reloadOnScreenWidgets %f", CACurrentMediaTime());
OnScreenWidgetView.editMode = true; OnScreenWidgetView.editMode = true;
[self clearStickIndicator]; [self clearStickIndicator];
@@ -155,8 +162,9 @@
self.layoutOSC = [[LayoutOnScreenControls alloc] initWithView:self.view controllerSup:nil streamConfig:nil oscLevel:OSCSegmentSelected]; self.layoutOSC = [[LayoutOnScreenControls alloc] initWithView:self.view controllerSup:nil streamConfig:nil oscLevel:OSCSegmentSelected];
self.layoutOSC._level = OnScreenControlsLevelCustom; self.layoutOSC._level = OnScreenControlsLevelCustom;
self.layoutOSC.layoutToolVC = self; self.layoutOSC.layoutToolVC = self;
//[self.layoutOSC show]; // draw on screen controls
[self.layoutOSC show]; // draw on screen controls [self.layoutOSC show]; // draw on screen controls
[self addInnerAnalogSticksToOuterAnalogLayers]; // allows inner and analog sticks to be dragged together around the screen together as one unit which is the expected behavior [self addInnerAnalogSticksToOuterAnalogLayers]; // allows inner and analog sticks to be dragged together around the screen together as one unit which is the expected behavior
self.undoButton.alpha = 0.3; // no changes to undo yet, so fade out the undo button a bit self.undoButton.alpha = 0.3; // no changes to undo yet, so fade out the undo button a bit
@@ -259,11 +267,19 @@
[OSCProfilesManager setOnScreenWidgetViewsSet:self.onScreenWidgetViews]; // pass the keyboard button dict to profiles manager [OSCProfilesManager setOnScreenWidgetViewsSet:self.onScreenWidgetViews]; // pass the keyboard button dict to profiles manager
} }
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{
[self saveTapped:nil];
}
- (void)deviceOrientationDidChange{ - (void)deviceOrientationDidChange{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self performSelector:@selector(handleOrientationChangeForOnScreenWidgets) withObject:self afterDelay:1];
sleep(1); }
[OSCProfilesManager setOnScreenWidgetViewsSet:self.onScreenWidgetViews]; // pass the keyboard button dict to profiles manager
}); - (void)handleOrientationChangeForOnScreenWidgets{
_oscProfilesTableViewController.layoutViewBounds = self.view.bounds;
[OSCProfilesManager setOnScreenWidgetViewsSet:self.onScreenWidgetViews]; // pass the keyboard button dict to profiles manager
[self reloadOnScreenWidgetViews];
[self reloadLegacyOnScreenControls];
} }
/* fades the 'Undo Button' in or out depending on whether the user has any OSC layout changes to undo */ /* fades the 'Undo Button' in or out depending on whether the user has any OSC layout changes to undo */
@@ -1116,12 +1132,9 @@
//this part is just for registration, will not be immediately executed. //this part is just for registration, will not be immediately executed.
self->_oscProfilesTableViewController.needToUpdateOscLayoutTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC profile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the profile and then hide/show and move each OSC button to their appropriate position self->_oscProfilesTableViewController.needToUpdateOscLayoutTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC profile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the profile and then hide/show and move each OSC button to their appropriate position
[self.layoutOSC updateControls]; // creates and saves a 'Default' OSC profile or loads the one the user selected on the previous screen NSLog(@"profile profile");
[self addInnerAnalogSticksToOuterAnalogLayers]; [self reloadLegacyOnScreenControls];
[self.layoutOSC.layoutChanges removeAllObjects]; // since a new OSC profile is being loaded, this will remove all previous layout changes made from the array
[self OSCLayoutChanged]; // fades the 'Undo Button' out
self->_oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; //pass updated OSCLayout to OSCProfileTableView again self->_oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; //pass updated OSCLayout to OSCProfileTableView again
//[self reloadOnScreenKeyboardButtons];
}; };
[self.oscProfilesTableViewController profileViewRefresh]; // execute this will make sure OSCLayout is updated from persisted profile, not any cache. [self.oscProfilesTableViewController profileViewRefresh]; // execute this will make sure OSCLayout is updated from persisted profile, not any cache.
@@ -1144,16 +1157,10 @@
} }
_oscProfilesTableViewController = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"]; _oscProfilesTableViewController = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"];
_oscProfilesTableViewController.streamViewBounds = self.view.bounds; _oscProfilesTableViewController.layoutViewBounds = self.view.bounds;
_oscProfilesTableViewController.needToUpdateOscLayoutTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC ofile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the proffile and then hide/show and move each OSC button to their appropriate position _oscProfilesTableViewController.needToUpdateOscLayoutTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC ofile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the proffile and then hide/show and move each OSC button to their appropriate position
[self.layoutOSC updateControls]; // creates and saves a 'Default' OSC profile or loads the one the user selected on the previous screen [self reloadLegacyOnScreenControls];
[self addInnerAnalogSticksToOuterAnalogLayers];
[self.layoutOSC.layoutChanges removeAllObjects]; // since a new OSC profile is being loaded, this will remove all previous layout changes made from the array
[self OSCLayoutChanged]; // fades the 'Undo Button' out
}; };
self.widgetPanelStack.hidden = YES; self.widgetPanelStack.hidden = YES;
@@ -30,7 +30,7 @@ typedef NS_ENUM(NSUInteger, FileOperation) {
@property (weak, nonatomic) IBOutlet UITableView *tableView; @property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, copy) void (^needToUpdateOscLayoutTVC)(void); @property (nonatomic, copy) void (^needToUpdateOscLayoutTVC)(void);
@property (nonatomic, assign) NSMutableArray *currentOSCButtonLayers; @property (nonatomic, assign) NSMutableArray *currentOSCButtonLayers;
@property (nonatomic, assign) CGRect streamViewBounds; @property (nonatomic, assign) CGRect layoutViewBounds;
@property (weak, nonatomic) IBOutlet UINavigationBar *profileTableViewNavigationBar; @property (weak, nonatomic) IBOutlet UINavigationBar *profileTableViewNavigationBar;
@end @end
@@ -74,7 +74,7 @@ const double NAV_BAR_HEIGHT = 50;
// self.profileTableViewNavigationBar.layer.cornerRadius = 15; // 设置圆角半径 // self.profileTableViewNavigationBar.layer.cornerRadius = 15; // 设置圆角半径
profilesManager = [OSCProfilesManager sharedManager:_streamViewBounds]; profilesManager = [OSCProfilesManager sharedManager:_layoutViewBounds];
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, NAV_BAR_HEIGHT)]; self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, NAV_BAR_HEIGHT)];
@@ -640,6 +640,7 @@
} }
- (void)openWidgetLayoutTool{ - (void)openWidgetLayoutTool{
_streamView.widgetToolOpened = true;
[self->_streamView disableOnScreenControls]; [self->_streamView disableOnScreenControls];
[self->_streamView clearOnScreenWidgets]; // clear all onScreenKeyboardButtons before entering edit mode [self->_streamView clearOnScreenWidgets]; // clear all onScreenKeyboardButtons before entering edit mode
_layoutOnScreenControlsVC.quickSwitchEnabled = false; _layoutOnScreenControlsVC.quickSwitchEnabled = false;
@@ -649,6 +650,7 @@
} }
- (void)switchWidgetProfile{ - (void)switchWidgetProfile{
_streamView.widgetToolOpened = true;
[self->_streamView disableOnScreenControls]; [self->_streamView disableOnScreenControls];
[self->_streamView clearOnScreenWidgets]; // clear all onScreenKeyboardButtons before entering edit mode [self->_streamView clearOnScreenWidgets]; // clear all onScreenKeyboardButtons before entering edit mode
_layoutOnScreenControlsVC.quickSwitchEnabled = true; _layoutOnScreenControlsVC.quickSwitchEnabled = true;
@@ -669,6 +671,7 @@
- (void)oscLayoutClosed{ - (void)oscLayoutClosed{
// Handle the callback // Handle the callback
_streamView.widgetToolOpened = false;
[self->_streamView disableOnScreenControls]; // add this to get realtime back menu working. [self->_streamView disableOnScreenControls]; // add this to get realtime back menu working.
[self->_streamView reloadOnScreenControlsWith:(ControllerSupport*)_controllerSupport [self->_streamView reloadOnScreenControlsWith:(ControllerSupport*)_controllerSupport
andConfig:(StreamConfiguration*)_streamConfig]; andConfig:(StreamConfiguration*)_streamConfig];