From 2f6eacb8778158a33dfcf65fa030099b07fe81db Mon Sep 17 00:00:00 2001 From: Todd Laney Date: Sun, 21 Feb 2021 09:40:35 -0800 Subject: [PATCH 1/2] fix ugly tvOS icons/symbols in Settings on tvOS 13.x --- iOS/EmulatorController.m | 1 - xcode/MAME4iOS/SystemImage.m | 18 ++++++++++++++---- xcode/MAME4iOS/TVOptionsController.m | 25 ++++++++++++++++++------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/iOS/EmulatorController.m b/iOS/EmulatorController.m index bebc20ab..f71e2712 100644 --- a/iOS/EmulatorController.m +++ b/iOS/EmulatorController.m @@ -4529,7 +4529,6 @@ -(void)showControllerHUD:(GCController*)controller { NSString* title = [NSString stringWithFormat:@":%@:%@", menu.unmappedSfSymbolsName ?: @"line.horizontal.3.circle", name]; UIImage* image = [UIImage imageWithString:title withFont:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]]; - image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [g_menuHUD addImage:image]; [g_menuHUD addSeparator]; diff --git a/xcode/MAME4iOS/SystemImage.m b/xcode/MAME4iOS/SystemImage.m index 55b4ae53..aee7407b 100644 --- a/xcode/MAME4iOS/SystemImage.m +++ b/xcode/MAME4iOS/SystemImage.m @@ -64,11 +64,12 @@ +(nullable UIImage*)systemImageNamed:(NSString*)name withFont:(UIFont*)font return [self systemImageNamed:name]; } -// convert text to a UIImaage, replacing any strings of the form ":symbol:" with a systemImage +// convert text to a UIImage, replacing any strings of the form ":symbol:" with a systemImage // :symbol-name: - return a UIImage created from [UIImage systemImageNamed] or [UIImage imageNamed] // :symbol-name:fallback: - return symbol as UIImage or fallback text if image not found // :symbol-name:text - return symbol + text -// :symbol-name:fallback:text - return symbol or fallback text + text +// :symbol-name:fallback:text - return (symbol or fallback) + text +// text:symbol-name:text - return text + symbol + text + (UIImage*)imageWithString:(NSString*)text withFont:(UIFont*)_font { UIImage* image; @@ -88,13 +89,17 @@ + (UIImage*)imageWithString:(NSString*)text withFont:(UIFont*)_font { } // if we have both text and an image, combine image + text - if (image == nil || text.length > 0) { + if (image == nil || text.length > 0 || [arr.firstObject length] > 0) { CGFloat spacing = 4.0; NSDictionary* attributes = @{NSFontAttributeName:font}; CGSize textSize = [text boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size; CGSize size = CGSizeMake(ceil(textSize.width), ceil(textSize.height)); + if (arr.count > 2 && [arr.firstObject length] > 0) { + size.width += [arr.firstObject boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size.width + spacing; + } + if (image != nil) { size.width += image.size.width + spacing; size.height = MAX(size.height, image.size.height); @@ -103,6 +108,11 @@ + (UIImage*)imageWithString:(NSString*)text withFont:(UIFont*)_font { image = [[[UIGraphicsImageRenderer alloc] initWithSize:size] imageWithActions:^(UIGraphicsImageRendererContext * context) { CGPoint point = CGPointZero; + if (arr.count > 2 && [arr.firstObject length] > 0) { + [arr.firstObject drawAtPoint:CGPointMake(point.x, (size.height - textSize.height)/2) withAttributes:attributes]; + point.x += [arr.firstObject boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size.width + spacing; + } + if (image != nil) { // TODO: align to baseline? [image drawAtPoint:CGPointMake(point.x, (size.height - image.size.height)/2)]; @@ -113,7 +123,7 @@ + (UIImage*)imageWithString:(NSString*)text withFont:(UIFont*)_font { }]; } - return image; + return [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } + (UIImage*)imageWithString:(NSString*)text { diff --git a/xcode/MAME4iOS/TVOptionsController.m b/xcode/MAME4iOS/TVOptionsController.m index 1c41197a..054870b3 100644 --- a/xcode/MAME4iOS/TVOptionsController.m +++ b/xcode/MAME4iOS/TVOptionsController.m @@ -85,6 +85,17 @@ -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteg return @""; } + +// helper to get a systemImage to use in the UI +// HACK: on tvOS 13.x an image in a UITableViewCell will overhand on the left edge of the cell and look ugly, so add a space! +- (UIImage*)systemImageNamed:(NSString*)name withFont:(UIFont*)font { + if (@available(tvOS 14.0, *)) + return [UIImage systemImageNamed:name withFont:font]; + else if (@available(tvOS 13.0, *)) + return [UIImage imageWithString:[NSString stringWithFormat:@" :%@:", name] withFont:font]; + else + return nil; +} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -100,7 +111,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N Options* op = [[Options alloc] init]; - CGFloat size = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline].pointSize; + UIFont* font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; if ( indexPath.section == kFilterSection ) { if ( indexPath.row == 0 ) { @@ -113,27 +124,27 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } else if ( indexPath.section == kImportSection ) { if ( indexPath.row == 0 ) { cell.textLabel.text = @"Start Web Server"; - cell.imageView.image = [UIImage systemImageNamed:@"arrow.up.arrow.down.circle" withPointSize:size]; + cell.imageView.image = [self systemImageNamed:@"arrow.up.arrow.down.circle" withFont:font]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } if ( indexPath.row == 1 ) { cell.textLabel.text = @"Export to iCloud"; - cell.imageView.image = [UIImage systemImageNamed:@"icloud.and.arrow.up" withPointSize:size]; + cell.imageView.image = [self systemImageNamed:@"icloud.and.arrow.up" withFont:font]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } if ( indexPath.row == 2 ) { cell.textLabel.text = @"Import from iCloud"; - cell.imageView.image = [UIImage systemImageNamed:@"icloud.and.arrow.down" withPointSize:size]; + cell.imageView.image = [self systemImageNamed:@"icloud.and.arrow.down" withFont:font]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } if ( indexPath.row == 3 ) { cell.textLabel.text = @"Sync with iCloud"; - cell.imageView.image = [UIImage systemImageNamed:@"arrow.clockwise.icloud" withPointSize:size]; + cell.imageView.image = [self systemImageNamed:@"arrow.clockwise.icloud" withFont:font]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } if ( indexPath.row == 4 ) { cell.textLabel.text = @"Erase iCloud"; - cell.imageView.image = [UIImage systemImageNamed:@"xmark.icloud" withPointSize:size]; + cell.imageView.image = [self systemImageNamed:@"xmark.icloud" withFont:font]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } } else if ( indexPath.section == kScreenSection ) { @@ -222,7 +233,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } } else if ( indexPath.section == kInputSection ) { cell.textLabel.text = @"Game Input"; - cell.imageView.image = [UIImage systemImageNamed:@"gamecontroller" withPointSize:size]; + cell.imageView.image = [self systemImageNamed:@"gamecontroller" withFont:font]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } else if ( indexPath.section == kResetSection ) { cell.textLabel.text = @"Reset to Defaults"; From cf2ba0c62fb6364bd79fcfcce295eede3e19d5a8 Mon Sep 17 00:00:00 2001 From: Todd Laney Date: Mon, 22 Feb 2021 14:50:09 -0800 Subject: [PATCH 2/2] do some settings and globals gardening (mostly pruning) remove from the Settings UI old settings that are not needed anymore, also if possible remove the myosd global too. --- iOS-res/help.md | 52 ++-- iOS/Bootstrapper.m | 13 +- iOS/EmulatorController.m | 66 +---- iOS/Globals.h | 2 - iOS/InputOptionController.m | 24 +- iOS/ListOptionController.h | 5 - iOS/ListOptionController.m | 330 ++-------------------- iOS/NetplayController.m | 10 +- iOS/OptionsController.h | 29 -- iOS/OptionsController.m | 148 +++------- iOS/iCadeView.h | 2 +- iOS/iCadeView.m | 12 +- src/emu/uimenu.c | 149 +--------- src/emu/video.c | 6 + src/osd/droid-ios/myosd.h | 19 -- src/osd/droid-ios/osd-ios.c | 17 +- src/osd/droid-ios/osdinput.c | 6 +- src/osd/droid-ios/osdmain.c | 107 ------- xcode/MAME4iOS/Options.h | 32 --- xcode/MAME4iOS/Options.m | 142 +--------- xcode/MAME4iOS/TVInputOptionsController.m | 2 +- xcode/MAME4iOS/TVOptionsController.h | 34 --- xcode/MAME4iOS/TVOptionsController.m | 48 +--- 23 files changed, 142 insertions(+), 1113 deletions(-) diff --git a/iOS-res/help.md b/iOS-res/help.md index 5df52bca..62ed805c 100755 --- a/iOS-res/help.md +++ b/iOS-res/help.md @@ -71,14 +71,24 @@ The emulator controls are the following ones: - **Nearest** Dont appy any filtering, aka `FatBits` - **Linear** Apply a smoothing image filter over the emulator screen. -**Border** a border that will surround the emulator screen. -- **Light** - a bright thick border -- **Dark** - a think dark border -- **Solid** - a blue solid border, with rounded corners. +**Skin** choose the artwork and layout of the onscreen controlls. +- **Default** - the default MAME4iOS look. +- **Light Border** - Default + a bright thick border +- **Dark Border** - Default + a think dark border +- **Classic** - the old MAME4iOS look. + +**Screen Shader** effect to apply to the emulator screen. +- **None** dont use any effect. +- **Default** use the default `simpleTron`. +- **simpleTron** simple CRT effect. +- **megaTron** more advanced CRT effect. +- **ulTron** even more advanced CRT effect. + +**Vector Shader** effect to apply to vector games. +- **None** dont use any effect. +- **Default** use the default `lineTron`. +- **lineTron** simple vector effect with fade out. -**Effects** a cool/retro effect to apply to the emulator screen. -- **CRT** Apply a CRT like filter over the image. -- **Scanline** Apply a scanline filter over the image. **Colorspace** the [color space](https://en.wikipedia.org/wiki/Color_space) to use. - **DeviceRGB** just use the color space of the device. @@ -129,40 +139,14 @@ The emulator controls are the following ones: **Cheats** Enables the reading of the cheat database, if present, and the Cheat menu in the user interface. -**Force 60hz sync** If enabled, forces 60Hz video emulatiob for smoother gameplay in some games (use with caution since it could broke other games like cave ones). - **Save Hiscores** If enabled, saves hiscores on some games not saving on NVRAM. It could cause problems with some games or save states. -**Native TV-OUT** If you want native iOS TVOUT mirror or you use and external 3rd party TVOUT app, you can turn off MAME4iOS native TVOUT. - -**Threaded video** Enable video threading for better performance on multicore devices. - -**Video Thread Priority** Sets the video thread priority if video thread is also enabled. - -**Double buffer** Avoids flickering. - -**Main Thread Priority** Sets the main thread priority. - **Show FPS** Shows ON/OFF fps. -**Emulated Resolution** Force MAME internal drawing resolution, use hires resolution to improve artwork rendering at the expense of performance. - -**Throttle** Configures the default thottling setting. When throttling is on, MAME attempts to keep the game running at the game's intended speed. When throttling is off, MAME runs the game as fast as it can. - -**Frame Skip** Specifies the frameskip value. This is the number of frames out of every 12 to drop when running. For example, if you say -frameskip 2,then MAME will display 10 out of every 12 frames. By skipping those frames, you may be able to get full speed in a game that requires more horsepower than your device has. The default value is autoframekip that Automatically determines the frameskip level while you're playing the game, adjusting it constantly in a frantic attempt to keep the game running at full speed. - **Force Pixel Aspect** Enable it to force pixel aspect ratio bypassing MAME video selection. -**Sleep on idle** Allows MAME to give time back to the system (sleep) when running with -throttle. This allows other programs to have some CPU time, assuming that the game isn't taxing 100% of your CPU resources. This option can potentially cause hiccups in performance if other demanding programs are running. - **Show Info/Warnings** Shows Game Info and any warnings when a game is selected. -**Low Latency Audio** Uses no queues (AudioUnit) to play audio with low latency. - -**Native TV-OUT** If you want native iOS TVOUT mirror or you use and external 3rd party TVOUT app, you can turn off MAME4iOS native TVOUT. - -**Overscan TV-OUT** You can set the amount of TV overscan correction. - ## FAVORITES You can mark (or unmark) your ROMS in the MAME4iOS game selection window as favorites by long pressing to get a context menu. @@ -233,8 +217,6 @@ we suppoprt a small subset of the keys supported by the command line MAME. ⌘+Z | TOGGLE FPS DISPLAY ⌘+H | TOGGLE HUD DISPLAY ⌘+F | TOGGLE FILTER (Nearest and Linear) - ⌘+T | TOGGLE THROTTLE - ⌘+V | TOGGLE VSYNC ⌘+P | TOGGLE PAUSE ⌘+A | TOGGLE `Keep Aspect Ratio` ⌘+X | TOGGLE `Force Pixel Aspect` diff --git a/iOS/Bootstrapper.m b/iOS/Bootstrapper.m index aa78006e..07031ac4 100644 --- a/iOS/Bootstrapper.m +++ b/iOS/Bootstrapper.m @@ -150,12 +150,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( externalWindow = [[UIWindow alloc] initWithFrame:CGRectZero]; externalWindow.hidden = YES; - if(g_pref_nativeTVOUT) - { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(prepareScreen) name:UIScreenDidConnectNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(prepareScreen) name:UIScreenDidDisconnectNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateScreen) name:UIScreenModeDidChangeNotification object:nil]; - } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(prepareScreen) name:UIScreenDidConnectNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(prepareScreen) name:UIScreenDidDisconnectNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateScreen) name:UIScreenModeDidChangeNotification object:nil]; [self prepareScreen]; #endif @@ -284,7 +281,7 @@ - (void)prepareScreen return; } - if ([[UIScreen screens] count] > 1 && g_pref_nativeTVOUT) { + if ([[UIScreen screens] count] > 1) { // Internal display is 0, external is 1. UIScreen* externalScreen = [[UIScreen screens] objectAtIndex:1]; @@ -328,7 +325,7 @@ - (void)setupScreen:(UIScreen*)screen { if (screen != nil) { - [screen setOverscanCompensation:UIScreenOverscanCompensationNone]; + [screen setOverscanCompensation:UIScreenOverscanCompensationInsetBounds]; [externalWindow setScreen:screen]; for (UIView *view in externalWindow.subviews) diff --git a/iOS/EmulatorController.m b/iOS/EmulatorController.m index f71e2712..ed483f8f 100644 --- a/iOS/EmulatorController.m +++ b/iOS/EmulatorController.m @@ -145,7 +145,6 @@ -(GCControllerButtonInput*)buttonOptionsSafe {return [self respondsToSelector:@s NSString* g_pref_skin; NSString* g_pref_colorspace; -int g_pref_metal = 0; int g_pref_integer_scale_only = 0; int g_pref_showFPS = 0; @@ -175,9 +174,6 @@ -(GCControllerButtonInput*)buttonOptionsSafe {return [self respondsToSelector:@s int g_pref_nintendoBAYX = 0; -int g_pref_nativeTVOUT = 1; -int g_pref_overscanTVOUT = 1; - int g_pref_lightgun_enabled = 1; int g_pref_lightgun_bottom_reload = 0; @@ -193,8 +189,6 @@ -(GCControllerButtonInput*)buttonOptionsSafe {return [self respondsToSelector:@s float g_buttons_size = 1.0f; float g_stick_size = 1.0f; -int global_low_latency_sound = 0; - int prev_myosd_light_gun = 0; int prev_myosd_mouse = 0; @@ -713,6 +707,7 @@ - (void)runMenu:(int)player from:(UIView*)view } } [menu addAction:[UIAlertAction actionWithTitle:@"Settings" style:UIAlertActionStyleDefault image:[UIImage systemImageNamed:@"gear" withPointSize:size] handler:^(UIAlertAction* action) { + [self hideMenuHUD]; [self runSettings]; }]]; @@ -917,7 +912,6 @@ -(void)updateOptions{ [skinManager setCurrentSkin:g_pref_skin]; g_pref_integer_scale_only = op.integerScalingOnly; - g_pref_metal = TRUE; g_pref_showFPS = [op showFPS]; g_pref_showHUD = [op showHUD]; @@ -929,9 +923,6 @@ -(void)updateOptions{ myosd_pxasp1 = [op p1aspx]; - g_pref_nativeTVOUT = [op tvoutNative]; - g_pref_overscanTVOUT = [op overscanValue]; - g_pref_input_touch_type = [op touchtype]; g_pref_analog_DZ_value = [op analogDeadZoneValue]; g_pref_ext_control_type = [op controltype]; @@ -946,12 +937,8 @@ -(void)updateOptions{ default:myosd_sound_value=-1;} - myosd_throttle = [op throttle]; myosd_cheat = [op cheats]; - myosd_vsync = [op vsync] == 1 ? 6000 : -1; - myosd_sleep = [op sleep]; - g_pref_nintendoBAYX = [op nintendoBAYX]; g_pref_full_num_buttons = [op numbuttons] - 1; // -1 == Auto @@ -986,24 +973,11 @@ -(void)updateOptions{ myosd_waysStick = 8; } - if([op fsvalue] == 0) - { - myosd_frameskip_value = -1; - } - else - { - myosd_frameskip_value = [op fsvalue]-1; - } - myosd_force_pxaspect = [op forcepxa]; - myosd_res = [op emures]+1; - myosd_filter_clones = op.filterClones; myosd_filter_not_working = op.filterNotWorking; - global_low_latency_sound = [op lowlsound]; - myosd_autofire = [op autofire]; myosd_hiscore = [op hiscore]; @@ -1053,13 +1027,6 @@ -(void)updateOptions{ turboBtnEnabled[BTN_L1] = [op turboLEnabled]; turboBtnEnabled[BTN_R1] = [op turboREnabled]; - // ignore some settings in the Metal case - if (g_pref_metal && [MetalScreenView isSupported]) { - myosd_sleep = 1; // sleep to let Metal get work done. - myosd_vsync = -1; // dont force 60Hz, just use the machine value, let MAME frameskip do what it can. - myosd_frameskip_value = -1; // AUTO frameskip - } - #if TARGET_OS_IOS g_pref_lightgun_enabled = [op lightgunEnabled]; g_pref_lightgun_bottom_reload = [op lightgunBottomScreenReload]; @@ -1081,23 +1048,11 @@ -(void)updateOptions{ // DONE button on Settings dialog -(void)done:(id)sender { - Options *op = [[Options alloc] init]; - // have the parent of the options/setting dialog dismiss // we present settings two ways, from in-game menu (we are parent) and from ChooseGameUI (it is the parent) UIViewController* parent = self.topViewController.presentingViewController; [(parent ?: self) dismissViewControllerAnimated:YES completion:^{ - if(global_low_latency_sound != [op lowlsound]) - { - if(myosd_sound_value!=-1) - { - myosd_closeSound(); - global_low_latency_sound = [op lowlsound]; - myosd_openSound(myosd_sound_value, 1); - } - } - // if we are at the root menu, exit and restart. if (myosd_inGame == 0 || g_mame_reset) myosd_exitGame = 1; @@ -2594,23 +2549,11 @@ - (void)buildScreenView { [self setNeedsUpdateOfHomeIndicatorAutoHidden]; if (externalView != nil) - { r = externalView.window.screen.bounds; - - CGFloat overscan = (g_pref_overscanTVOUT * 0.025f); - CGFloat overscan_x = ceil(r.size.width * overscan / 2.0); - CGFloat overscan_y = ceil(r.size.height * overscan / 2.0); - - r = CGRectInset(r, overscan_x, overscan_y); - } else if (g_device_is_fullscreen) - { r = rFrames[g_device_is_landscape ? LANDSCAPE_VIEW_FULL : PORTRAIT_VIEW_FULL]; - } else - { r = rFrames[g_device_is_landscape ? LANDSCAPE_VIEW_NOT_FULL : PORTRAIT_VIEW_NOT_FULL]; - } // Handle Safe Area (iPhone X and above) adjust the view down away from the notch, before adjusting for aspect if ( externalView == nil ) { @@ -2952,10 +2895,6 @@ -(void)commandKey:(char)key { [self changeUI]; break; } - case 'T': - myosd_throttle = !myosd_throttle; - [self changeUI]; - break; case 'X': myosd_force_pxaspect = !myosd_force_pxaspect; [self changeUI]; @@ -3879,9 +3818,6 @@ -(void)moveROMS { // tell the SkinManager new files have arived. [self->skinManager reload]; - // reset MAME last game selected... - myosd_last_game_selected = 0; - // reload the MAME menu.... [self reload]; diff --git a/iOS/Globals.h b/iOS/Globals.h index d4a647fe..b823d65f 100644 --- a/iOS/Globals.h +++ b/iOS/Globals.h @@ -125,8 +125,6 @@ extern int g_pref_analog_DZ_value; extern int g_pref_input_touch_type; extern int g_pref_ext_control_type; extern int g_pref_nintendoBAYX; -extern int g_pref_nativeTVOUT; -extern int g_pref_overscanTVOUT; extern float g_buttons_size; extern float g_stick_size; diff --git a/iOS/InputOptionController.m b/iOS/InputOptionController.m index 5dab075e..17e952c1 100644 --- a/iOS/InputOptionController.m +++ b/iOS/InputOptionController.m @@ -527,50 +527,45 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath NSUInteger row = [indexPath row]; NSUInteger section = [indexPath section]; + UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; if(section==1 && row==0) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped type:kTypeTouchType list:arrayTouchType]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"touchtype" list:arrayTouchType title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } if(section==1 && row==1) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeStickType list:arrayStickType]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"sticktype" list:arrayStickType title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } if(section==1 && row==2) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeStickSizeValue list:arrayStickSizeValue]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"stickSize" list:arrayStickSizeValue title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } if(section==2 && row==0) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeNumButtons list:arrayNumbuttons]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"numbuttons" list:arrayNumbuttons title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } if(section==2 && row==2) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeAutofireValue list:arrayAutofireValue]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"autofire" list:arrayAutofireValue title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } if(section==2 && row==3) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeButtonSizeValue list:arrayButtonSizeValue]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"buttonSize" list:arrayButtonSizeValue title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } if(section==3 && row==0) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeControlType list:Options.arrayControlType]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"controltype" list:Options.arrayControlType title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } @@ -586,8 +581,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath if(section==6 && row==0) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeAnalogDZValue list:arrayAnalogDZValue]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"analogDeadZoneValue" list:arrayAnalogDZValue title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } diff --git a/iOS/ListOptionController.h b/iOS/ListOptionController.h index 6e6f8da6..f34c8a83 100644 --- a/iOS/ListOptionController.h +++ b/iOS/ListOptionController.h @@ -49,14 +49,9 @@ NS_ASSUME_NONNULL_BEGIN @interface ListOptionController : OptionsTableViewController -- (instancetype)initWithType:(NSInteger)typeValue list:(NSArray *)listValue; - - (instancetype)initWithKey:(NSString*)keyValue list:(NSArray*)listValue; - (instancetype)initWithKey:(NSString*)keyValue list:(NSArray*)listValue title:(NSString*)titleValue; -// old code is calling this, use just initWithType:list: or initWithKey:list: instead -- (instancetype)initWithStyle:(UITableViewStyle)style type:(NSInteger)typeValue list:(NSArray*)listValue; - @end NS_ASSUME_NONNULL_END diff --git a/iOS/ListOptionController.m b/iOS/ListOptionController.m index 47c659c9..ff0f1df0 100644 --- a/iOS/ListOptionController.m +++ b/iOS/ListOptionController.m @@ -44,48 +44,18 @@ #import "ListOptionController.h" #import "Options.h" -#if TARGET_OS_IOS -#import "OptionsController.h" -#elif TARGET_OS_TV -#import "TVOptionsController.h" -#endif - -#define kTypeKeyValue -1 @implementation ListOptionController { - NSInteger type; - NSString* key; // for kTypeKeyValue + NSString* key; NSArray *list; NSInteger value; - NSArray *sections; } -- (id)initWithStyle:(UITableViewStyle)style type:(NSInteger)typeValue list:(NSArray *)listValue{ - - if(self = [super initWithStyle:style]) - { - type = typeValue; - list = listValue; - - switch (type) { - case kTypeManufacturerValue: - case kTypeDriverSourceValue: - case kTypeCategoryValue: - sections = @[@"#", @"a", @"b", @"c", @"d", @"e", @"f", @"g", @"h", @"i", @"j", @"k", @"l", @"m", @"n", @"o", @"p", @"q", @"r", @"s", @"t", @"u", @"v", @"w", @"x", @"y", @"z"]; - break; - } - } - return self; -} -- (id)initWithType:(NSInteger)typeValue list:(NSArray *)listValue { - return [self initWithStyle:UITableViewStyleGrouped type:typeValue list:listValue]; -} - (instancetype)initWithKey:(NSString*)keyValue list:(NSArray*)listValue { if (self = [super initWithStyle:UITableViewStyleGrouped]) { NSAssert([[[Options alloc] init] valueForKey:keyValue] != nil, @"bad key"); - type = kTypeKeyValue; key = keyValue; list = [listValue mutableCopy]; // if the list items are of the form "Name : Data", we only want to show "Name" to the user. @@ -101,154 +71,30 @@ - (instancetype)initWithKey:(NSString*)keyValue list:(NSArray*)listVa } - (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; Options *op = [[Options alloc] init]; - // get the current value and set the title - switch (type) { - case kTypeNumButtons: - self.title = @"Number Of Buttons"; - value = op.numbuttons; - break; - case kTypeEmuRes: - self.title = @"Emulated Resolution"; - value = op.emures; - break; - case kTypeStickType: - self.title = @"Ways Stick"; - value = op.sticktype; - break; - case kTypeTouchType: - self.title = @"Touch Type"; - value = op.touchtype; - break; - case kTypeControlType: - self.title = @"External Controller"; - value = op.controltype; - break; - case kTypeAnalogDZValue: - self.title = @"Stick Touch DZ"; - value = op.analogDeadZoneValue; - break; - case kTypeSoundValue: - self.title = @"Sound"; - value = op.soundValue; - break; - case kTypeFSValue: - self.title = @"Frame Skip"; - value = op.fsvalue; - break; - case kTypeOverscanValue: - self.title = @"Overscan TV-OUT"; - value = op.overscanValue; - break; - case kTypeManufacturerValue: - self.title = @"Manufacturer"; - value = op.manufacturerValue; - break; - case kTypeYearGTEValue: - self.title = @"Year >="; - value = op.yearGTEValue; - break; - case kTypeYearLTEValue: - self.title = @"Year <="; - value = op.yearLTEValue; - break; - case kTypeDriverSourceValue: - self.title = @"Driver Source"; - value = op.driverSourceValue; - break; - case kTypeCategoryValue: - self.title = @"Category"; - value = op.categoryValue; - break; - case kTypeVideoPriorityValue: - self.title = @"Video Thread Priority"; - value = op.videoPriority; - break; - case kTypeMainPriorityValue: - self.title = @"Main Thread Priority"; - value = op.mainPriority; - break; - case kTypeAutofireValue: - self.title = @"A as Autofire"; - value = op.autofire; - break; - case kTypeButtonSizeValue: - self.title = @"Buttons Size"; - value = op.buttonSize; - break; - case kTypeStickSizeValue: - self.title = @"Fullscreen Stick Size"; - value = op.stickSize; - break; - case kTypeArrayWPANtype: - self.title = @"WPAN mode"; - value = op.wpantype; - break; - case kTypeWFframeSync: - self.title = @"Wi-Fi Frame Sync"; - value = op.wfframesync; - break; - case kTypeBTlatency: - self.title = @"Bluetooth Latency"; - value = op.btlatency; - break; - case kTypeEmuSpeed: - self.title = @"Emulation Speed"; - value = op.emuspeed; - break; - case kTypeVideoThreadTypeValue: - self.title = @"Video Thread Type"; - value = op.videoThreadType; - break; - case kTypeMainThreadTypeValue: - self.title = @"Main Thread Type"; - value = op.mainThreadType; - break; - case kTypeKeyValue: - { - id val = [op valueForKey:key]; - - if ([val isKindOfClass:[NSString class]]) - value = [list indexOfOption:val]; - else if ([val isKindOfClass:[NSNumber class]]) - value = [val intValue]; - else - value = 0; - break; - } - default: - NSAssert(FALSE, @"bad list type"); - break; - } + id val = [op valueForKey:key]; + + if ([val isKindOfClass:[NSString class]]) + value = [list indexOfOption:val]; + else if ([val isKindOfClass:[NSNumber class]]) + value = [val intValue]; + else + value = 0; if (value == NSNotFound || value >= [list count]) { NSLog(@"list value out of range, setting to 0"); value = 0; } - - [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (value > 10) { NSIndexPath *scrollIndexPath=nil; - if(sections != nil) - { - NSString *s = [list optionAtIndex:value]; - NSString *l = [[s substringToIndex:1] lowercaseString]; - int sec = (uint32_t)[sections indexOfObject:l]; - NSArray *sectionArray = [list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", [sections objectAtIndex: sec]]]; - int row = (uint32_t)[sectionArray indexOfObject:s]; - scrollIndexPath = [NSIndexPath indexPathForRow:row inSection:sec]; - } - else - { - scrollIndexPath = [NSIndexPath indexPathForRow:(value) inSection:0]; - - } + scrollIndexPath = [NSIndexPath indexPathForRow:(value) inSection:0]; [[self tableView] scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; } } @@ -259,124 +105,23 @@ - (void)viewWillDisappear:(BOOL)animated { Options *op = [[Options alloc] init]; int value = (int)self->value; - // set the current value, in the kTypeCustom case call the handler to do it. - switch (type) { - case kTypeNumButtons: - op.numbuttons =value; - break; - case kTypeEmuRes: - op.emures =value; - break; - case kTypeTouchType: - op.touchtype =value; - break; - case kTypeStickType: - op.sticktype =value; - break; - case kTypeControlType: - op.controltype =value; - break; - case kTypeAnalogDZValue: - op.analogDeadZoneValue =value; - break; - case kTypeSoundValue: - op.soundValue =value; - break; - case kTypeFSValue: - op.fsvalue =value; - break; - case kTypeOverscanValue: - op.overscanValue =value; - break; - case kTypeManufacturerValue: - op.manufacturerValue =value; - break; - case kTypeYearGTEValue: - op.yearGTEValue =value; - break; - case kTypeYearLTEValue: - op.yearLTEValue =value; - break; - case kTypeDriverSourceValue: - op.driverSourceValue =value; - break; - case kTypeCategoryValue: - op.categoryValue =value; - break; - case kTypeVideoPriorityValue: - op.videoPriority =value; - break; - case kTypeMainPriorityValue: - op.mainPriority =value; - break; - case kTypeAutofireValue: - op.autofire =value; - break; - case kTypeButtonSizeValue: - op.buttonSize =value; - break; - case kTypeStickSizeValue: - op.stickSize =value; - break; - case kTypeArrayWPANtype: - op.wpantype =value; - break; - case kTypeWFframeSync: - op.wfframesync =value; - break; - case kTypeBTlatency: - op.btlatency =value; - break; - case kTypeEmuSpeed: - op.emuspeed =value; - break; - case kTypeMainThreadTypeValue: - op.mainThreadType =value; - break; - case kTypeVideoThreadTypeValue: - op.videoThreadType =value; - break; - case kTypeKeyValue: - { - id val = [op valueForKey:key]; + id val = [op valueForKey:key]; - if ([val isKindOfClass:[NSString class]]) - [op setValue:[list optionAtIndex:value] forKey:key]; - else if ([val isKindOfClass:[NSNumber class]]) - [op setValue:@(value) forKey:key]; - - NSLog(@"LIST SELECT: %@ = %@", key, [op valueForKey:key]); - break; - } - default: - NSAssert(FALSE, @"bad type"); - break; - } + if ([val isKindOfClass:[NSString class]]) + [op setValue:[list optionAtIndex:value] forKey:key]; + else if ([val isKindOfClass:[NSNumber class]]) + [op setValue:@(value) forKey:key]; + NSLog(@"LIST SELECT: %@ = %@", key, [op valueForKey:key]); [op saveOptions]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - if (sections != nil) - return [sections count]; - else - return 1; -} - -- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { - return sections; -} - -- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { - return nil; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - - if (sections != nil) - return [[list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", [sections objectAtIndex:section]]] count]; - else - return [list count]; + return [list count]; } @@ -388,45 +133,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } NSUInteger row = [indexPath row]; - if (sections != nil) - { - NSString *txt = [self retrieveIndexedCellText:indexPath]; - cell.textLabel.text = txt; - cell.accessoryType = ([list indexOfObject:txt] == value) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; - } - else - { - cell.textLabel.text = [list objectAtIndex:row]; - cell.accessoryType = (row == value) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; - } - + cell.textLabel.text = [list objectAtIndex:row]; + cell.accessoryType = (row == value) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - - if (sections != nil) - { - NSInteger curr = [list indexOfObject:[self retrieveIndexedCellText:indexPath]]; - if(curr!=value) { - value = curr; - } - } - else - { - int row = (uint32_t)[indexPath row]; - if (row != value) { - value = row; - } + int row = (uint32_t)[indexPath row]; + if (row != value) { + value = row; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; [self.tableView reloadData]; } -- (NSString *)retrieveIndexedCellText:(NSIndexPath *)indexPath{ - NSUInteger row = [indexPath row]; - NSArray *sectionArray = [list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", [sections objectAtIndex:[indexPath section] ]]]; - return [sectionArray objectAtIndex:row]; -} - @end diff --git a/iOS/NetplayController.m b/iOS/NetplayController.m index da873da7..789bb8a2 100644 --- a/iOS/NetplayController.m +++ b/iOS/NetplayController.m @@ -314,6 +314,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath NSUInteger row = [indexPath row]; NSUInteger section = [indexPath section]; + UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; netplay_t *handle = netplay_get_handle(); Options *op = [[Options alloc] init]; @@ -371,8 +372,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [tableView reloadData]; } else if (section == 1 && row==0){ - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeArrayWPANtype list:arrayWPANtype]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"wpantype" list:arrayWPANtype title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } else if(section == 2 && (row==1 || row==2)) @@ -382,14 +382,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } else if(section == 2 && row==3) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeWFframeSync list:arrayWFframeSync]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"wfframesync" list:arrayWFframeSync title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } else if(section == 3 && row==0) { - ListOptionController *listController = [[ListOptionController alloc] initWithStyle:UITableViewStyleGrouped - type:kTypeBTlatency list:arrayBTlatency]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"btlatency" list:arrayBTlatency title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } } diff --git a/iOS/OptionsController.h b/iOS/OptionsController.h index 77e439c3..2298335b 100644 --- a/iOS/OptionsController.h +++ b/iOS/OptionsController.h @@ -60,35 +60,6 @@ enum OptionSections kNumSections }; -enum ListOptionType -{ - kTypeNumButtons, - kTypeEmuRes, - kTypeStickType, - kTypeTouchType, - kTypeControlType, - kTypeAnalogDZValue, - kTypeSoundValue, - kTypeFSValue, - kTypeOverscanValue, - kTypeManufacturerValue, - kTypeYearGTEValue, - kTypeYearLTEValue, - kTypeDriverSourceValue, - kTypeCategoryValue, - kTypeVideoPriorityValue, - kTypeMainPriorityValue, - kTypeAutofireValue, - kTypeStickSizeValue, - kTypeButtonSizeValue, - kTypeArrayWPANtype, - kTypeWFframeSync, - kTypeBTlatency, - kTypeEmuSpeed, - kTypeVideoThreadTypeValue, - kTypeMainThreadTypeValue -}; - @interface OptionsController : OptionsTableViewController @end diff --git a/iOS/OptionsController.m b/iOS/OptionsController.m index a77287a0..55b0fb3f 100644 --- a/iOS/OptionsController.m +++ b/iOS/OptionsController.m @@ -158,31 +158,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N break; } case 5: - { - cell.textLabel.text = @"Emulated Resolution"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arrayEmuRes optionAtIndex:op.emures]; - break; - } - case 6: - { - cell.textLabel.text = @"Use Metal"; - cell.accessoryView = [self optionSwitchForKey:@"useMetal"]; - break; - } - case 7: { cell.textLabel.text = @"Keep Aspect Ratio"; cell.accessoryView = [self optionSwitchForKey:@"keepAspectRatio"]; break; } - case 8: + case 6: { cell.textLabel.text = @"Integer Scaling Only"; cell.accessoryView = [self optionSwitchForKey:@"integerScalingOnly"]; break; } - case 9: + case 7: { cell.textLabel.text = @"Force Pixel Aspect"; cell.accessoryView = [self optionSwitchForKey:@"forcepxa"]; @@ -246,94 +233,49 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N { switch (indexPath.row) { - case 0: - { - cell.textLabel.text = @"Show FPS"; - cell.accessoryView = [self optionSwitchForKey:@"showFPS"]; - break; - } - case 1: - { - cell.textLabel.text = @"Show HUD"; - cell.accessoryView = [self optionSwitchForKey:@"showHUD"]; - break; - } - case 2: - { - cell.textLabel.text = @"Show Info/Warnings"; - cell.accessoryView = [self optionSwitchForKey:@"showINFO"]; - break; - } - case 3: + case 0: { - cell.textLabel.text = @"Throttle"; - cell.accessoryView = [self optionSwitchForKey:@"throttle"]; + cell.textLabel.text = @"Show FPS"; + cell.accessoryView = [self optionSwitchForKey:@"showFPS"]; break; } - case 4: + case 1: { - cell.textLabel.text = @"Frame Skip"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arrayFSValue optionAtIndex:op.fsvalue]; + cell.textLabel.text = @"Show HUD"; + cell.accessoryView = [self optionSwitchForKey:@"showHUD"]; break; } - case 5: + case 2: { - cell.textLabel.text = @"Overscan TV-OUT"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arrayOverscanValue optionAtIndex:op.overscanValue]; + cell.textLabel.text = @"Show Info/Warnings"; + cell.accessoryView = [self optionSwitchForKey:@"showINFO"]; break; } - - case 6: - { - cell.textLabel.text = @"Emulated Speed"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arrayEmuSpeed optionAtIndex:op.emuspeed]; - break; - } - case 7: - { - cell.textLabel.text = @"Sleep on Idle"; - cell.accessoryView = [self optionSwitchForKey:@"sleep"]; - break; - } - case 8: - { - cell.textLabel.text = @"Low Latency Audio"; - cell.accessoryView = [self optionSwitchForKey:@"lowlsound"]; - break; - } - case 9: - { - cell.textLabel.text = @"Sound"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arraySoundValue optionAtIndex:op.soundValue]; - break; - } - case 10: - { - cell.textLabel.text = @"Cheats"; - cell.accessoryView = [self optionSwitchForKey:@"cheats"]; - break; - } - case 11: - { - cell.textLabel.text = @"Force 60Hz Sync"; - cell.accessoryView = [self optionSwitchForKey:@"vsync"]; - break; - } - case 12: - { - cell.textLabel.text = @"Save Hiscores"; - cell.accessoryView = [self optionSwitchForKey:@"hiscore"]; - break; - } - case 13: + case 3: { - cell.textLabel.text = @"Native TV-OUT"; - cell.accessoryView = [self optionSwitchForKey:@"tvoutNative"]; - break; + cell.textLabel.text = @"Cheats"; + cell.accessoryView = [self optionSwitchForKey:@"cheats"]; + break; + } + case 4: + { + cell.textLabel.text = @"Save Hiscores"; + cell.accessoryView = [self optionSwitchForKey:@"hiscore"]; + break; + } + case 5: + { + cell.textLabel.text = @"Emulated Speed"; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.detailTextLabel.text = [Options.arrayEmuSpeed optionAtIndex:op.emuspeed]; + break; + } + case 6: + { + cell.textLabel.text = @"Sound"; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.detailTextLabel.text = [Options.arraySoundValue optionAtIndex:op.soundValue]; + break; } } break; @@ -506,9 +448,9 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger case kFullscreenSection: return 3; // only show the netplay option if we are being prestenting from main game, not from choose game ui case kOtherSection: return (self.presentingViewController == self.emuController) ? 2 : 1; - case kVideoSection: return 10; + case kVideoSection: return 8; case kVectorSection: return 3; - case kMiscSection: return 14; + case kMiscSection: return 7; case kFilterSection: return 2; case kImportSection: return 4; case kCloudImportSection: @@ -580,27 +522,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"colorSpace" list:Options.arrayColorSpace title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } - if (row==5){ - ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"emures" list:Options.arrayEmuRes title:cell.textLabel.text]; - [[self navigationController] pushViewController:listController animated:YES]; - } break; } case kMiscSection: { - if (row==4){ - ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"fsvalue" list:Options.arrayFSValue title:cell.textLabel.text]; - [[self navigationController] pushViewController:listController animated:YES]; - } - if (row==5){ - ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"overscanValue" list:Options.arrayOverscanValue title:cell.textLabel.text]; - [[self navigationController] pushViewController:listController animated:YES]; - } - if (row==6) { + if (row==5) { ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"emuspeed" list:Options.arrayEmuSpeed title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } - if (row==9) { + if (row==6) { ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"soundValue" list:Options.arraySoundValue title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } diff --git a/iOS/iCadeView.h b/iOS/iCadeView.h index 19f2b041..c3f427d4 100644 --- a/iOS/iCadeView.h +++ b/iOS/iCadeView.h @@ -47,7 +47,7 @@ #import "Globals.h" #import "EmulatorController.h" -@interface iCadeView : UIView { +@interface iCadeView : UIView { UIView *inputView;//This is to show a fake invisible keyboard EmulatorController *emuController; } diff --git a/iOS/iCadeView.m b/iOS/iCadeView.m index 8fcb29e2..32268337 100644 --- a/iOS/iCadeView.m +++ b/iOS/iCadeView.m @@ -109,6 +109,16 @@ - (UIView*) inputView { return inputView; } +#pragma mark UIKeyInput + +- (BOOL) hasText { + return NO; +} +- (void)insertText:(NSString *)text { +} +- (void)deleteBackward { +} + #pragma mark handle iCade key // iCade keys @@ -932,6 +942,4 @@ -(UIKeyCommand *)_keyCommandForEvent:(UIEvent *)event { // UIPhysicalKeyboardEve #endif - - @end diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index add9d8ea..f5ee0423 100755 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -3794,9 +3794,6 @@ static void menu_select_game_populate(running_machine *machine, ui_menu *menu, s return; } - //if(myosd_filter_keyword[0]!=0) - //strcpy(menustate->search,myosd_filter_keyword); - /* otherwise, rebuild the match list */ if (menustate->search[0] != 0 || menustate->matchlist[0] == NULL || menustate->rerandomize) driver_list_get_approx_matches(menustate->driverlist, menustate->search, matchcount, menustate->matchlist); @@ -3876,27 +3873,12 @@ static void menu_select_game_build_driver_list(ui_menu *menu, select_game_state int drivnum, listnum; mame_path *path; UINT8 *found; - -//DAV HACK - categories_read(); + //DAV HACK + categories_read(); favorites_read(); - - //fixup filters - if(myosd_filter_manufacturer>=0) - { - if(strcmp(myosd_array_main_manufacturers[myosd_filter_manufacturer],"Other")==0) - myosd_filter_manufacturer = -2; - } - - if(myosd_filter_driver_source>=0) - { - if(strcmp(myosd_array_main_driver_source[myosd_filter_driver_source],"Other")==0) - myosd_filter_driver_source = -2; - } - -////DAV HACK - + ////DAV HACK + /* create a sorted copy of the main driver list */ memcpy((void *)menustate->driverlist, drivers, driver_count * sizeof(menustate->driverlist[0])); qsort((void *)menustate->driverlist, driver_count, sizeof(menustate->driverlist[0]), menu_select_game_driver_compare); @@ -3933,69 +3915,13 @@ static void menu_select_game_build_driver_list(ui_menu *menu, select_game_state int skip = found_driver == NULL; -//DAV HACK +//DAV HACK if(!skip && myosd_filter_clones) { const game_driver *cloneof = driver_get_clone(*found_driver); skip = cloneof!=NULL && !(cloneof->flags & GAME_IS_BIOS_ROOT); } if(!skip) skip = myosd_filter_not_working && (*found_driver)->flags & GAME_NOT_WORKING; - if(!skip) skip = myosd_filter_favorites && !isFavorite(drivername) ; - if(!skip && myosd_filter_manufacturer != -1) - { - if(myosd_filter_manufacturer==-2) - { - int i=0; - while(!skip && myosd_array_main_manufacturers[i][0]!='\0') - { - skip = strstr((*found_driver)->manufacturer,myosd_array_main_manufacturers[i])!=NULL; - i++; - } - } - else - skip = strstr((*found_driver)->manufacturer,myosd_array_main_manufacturers[myosd_filter_manufacturer])==NULL; - } - - if(!skip && myosd_filter_gte_year!=-1) - { - const char *year = (*found_driver)->year; - skip = strcmp(year,"19??")==0 || strcmp(year,"197?")==0 || strcmp(year,"198?")==0 || strcmp(year,"200?")==0 || strcmp(year,myosd_array_years[myosd_filter_gte_year]) < 0; - } - if(!skip && myosd_filter_lte_year!=-1) - { - const char *year = (*found_driver)->year; - skip = strcmp(year,"19??")==0 || strcmp(year,"197?")==0 || strcmp(year,"198?")==0 || strcmp(year,"200?")==0 || strcmp(year,myosd_array_years[myosd_filter_lte_year]) > 0; - } - - if(!skip && myosd_filter_driver_source != -1) - { - astring source_name; - core_filename_extract_base(&source_name,(*found_driver)->source_file,true); - const char *sname= source_name.cstr(); - - if(myosd_filter_driver_source==-2) - { - int i=0; - while(!skip && myosd_array_main_driver_source[i][0]!='\0') - { - skip = strcmp(sname,myosd_array_main_driver_source[i])==0; - i++; - } - } - else - skip = strcmp(sname,myosd_array_main_driver_source[myosd_filter_driver_source])!=0; - } - - if(!skip && myosd_filter_keyword[0] != '\0') - skip = mystristr((*found_driver)->name,myosd_filter_keyword)==NULL && mystristr((*found_driver)->description,myosd_filter_keyword)==NULL; - - if(!skip && myosd_filter_category != -1) - { - char *category = find_category((*found_driver)->name); - - skip = category==NULL || strstr(category,myosd_array_categories[myosd_filter_category])==NULL; - } - //DAV HACK /* if found, mark the corresponding entry in the array */ if (!skip) @@ -4040,59 +3966,12 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me int line; //DAV HACK - int nroms = menu->numitems > 3 ? menu->numitems -3 : 0; //DAV HACK /* display the current typeahead */ if (menustate->search[0] != 0) sprintf(&tempbuf[0][0], "Type name or select: %s_", menustate->search); -//DAV HACK - else if(/*myosd_filter_clones!=0 || myosd_filter_favorites!=0 || myosd_filter_not_working!=0 ||*/ - myosd_filter_manufacturer!=-1 || myosd_filter_gte_year!=-1 || myosd_filter_lte_year!=-1 || myosd_filter_driver_source!=-1 - || myosd_filter_keyword[0]!= '\0' || myosd_filter_category!=-1 ) - { - char tempstr[255]; - strcpy(tempstr, "Filter: "); - - if (myosd_filter_keyword[0]!='\0'){ - strcat(tempstr, myosd_filter_keyword); - strcat(tempstr, "/"); - } - - if (myosd_filter_gte_year>=0) { - strcat(tempstr, ">="); - strcat(tempstr, myosd_array_years[myosd_filter_gte_year]); - strcat(tempstr, "/"); - } - if (myosd_filter_lte_year>=0) { - strcat(tempstr, "<="); - strcat(tempstr, myosd_array_years[myosd_filter_lte_year]); - strcat(tempstr, "/"); - } - - if (myosd_filter_manufacturer>=0) { - strcat(tempstr, myosd_array_main_manufacturers[myosd_filter_manufacturer]); - strcat(tempstr, "/"); - } - if (myosd_filter_manufacturer==-2) - strcat(tempstr, "Other Manufact/"); - - if (myosd_filter_driver_source>=0) { - strcat(tempstr, myosd_array_main_driver_source[myosd_filter_driver_source]); - strcat(tempstr, "/"); - } - if (myosd_filter_driver_source==-2) - strcat(tempstr, "Other DrvSrc/"); - - if (myosd_filter_category>=0) { - strcat(tempstr, myosd_array_categories[myosd_filter_category]); - strcat(tempstr, "/"); - } - - tempstr[strlen(tempstr)-1] = '\0'; - sprintf(&tempbuf[0][0], "%s. Game: %d/%d",tempstr,MIN(myosd_last_game_selected+1,nroms), nroms); - } else { //sprintf(&tempbuf[0][0], "Type name or select: _"); @@ -4186,10 +4065,6 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me soundstat = "OK"; sprintf(&tempbuf[3][0], "%s: Gfx: %s, Sound: %s",overall, gfxstat, soundstat); - -//DAV HACK - strcpy(myosd_selected_game,driver->name); -//END DAV HACK } else { @@ -4214,9 +4089,6 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me if (*s != 0) s++; } - //DAV HACK - strcpy(myosd_selected_game,""); - //END DAV HACK } /* get the size of the text */ @@ -4288,16 +4160,7 @@ static void menu_alt_game(running_machine *machine, ui_menu *menu, void *paramet { if(isFavorite(name)) { favorites_remove(name); - if(myosd_filter_favorites==-1) - { - ui_menu_stack_pop(menu->machine); - } - else - { - machine->schedule_exit(); - ui_menu_stack_reset(machine); - } - + ui_menu_stack_pop(menu->machine); } else { favorites_add(name); ui_menu_stack_pop(menu->machine); diff --git a/src/emu/video.c b/src/emu/video.c index 8b7fb8e3..7f44327f 100755 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -53,6 +53,12 @@ #include "myosd.h" #include "netplay.h" +// default these old myosd globals to defaults +#define myosd_sleep 1 +#define myosd_frameskip_value -1 +#define myosd_throttle 1 +#define myosd_vsync -1 + static int old_speed; diff --git a/src/osd/droid-ios/myosd.h b/src/osd/droid-ios/myosd.h index 33329d35..4d9e8df2 100644 --- a/src/osd/droid-ios/myosd.h +++ b/src/osd/droid-ios/myosd.h @@ -32,22 +32,18 @@ enum { MYOSD_UP=0x1, MYOSD_LEFT=0x4, MYOSD_DOWN=0x10, MYOSD_RIGHT MYOSD_EXIT=1<<20, MYOSD_OPTION=1<<21, MYOSD_HOME=1<<22, MYOSD_MENU=1<<23, }; -#define MAX_FILTER_KEYWORD 30 #define MAX_GAME_NAME 14 #define NETPLAY_PORT 55435 #define NUM_JOY 4 extern int myosd_fps; extern int myosd_showinfo; -extern int myosd_sleep; extern int myosd_exitGame; extern int myosd_pause; extern int myosd_exitPause; extern int myosd_autosave; extern int myosd_cheat; extern int myosd_sound_value; -extern int myosd_frameskip_value; -extern int myosd_throttle; extern int myosd_savestate; extern int myosd_loadstate; extern int myosd_waysStick; @@ -58,7 +54,6 @@ extern int myosd_vis_video_height; extern int myosd_display_width; // display width,height is the screen output resolution extern int myosd_display_height; // ...set in the iOS app, to pick a good default render target size. extern int myosd_in_menu; -extern int myosd_res; extern int myosd_force_pxaspect; extern int myosd_num_of_joys; extern int myosd_pxasp1; @@ -97,16 +92,8 @@ extern unsigned short myosd_ext_status; extern int myosd_last_game_selected; -extern int myosd_filter_favorites; extern int myosd_filter_clones; extern int myosd_filter_not_working; -extern int myosd_filter_manufacturer; -extern int myosd_filter_gte_year; -extern int myosd_filter_lte_year; -extern int myosd_filter_driver_source; -extern int myosd_filter_category; -extern char myosd_filter_keyword[MAX_FILTER_KEYWORD]; -extern int myosd_reset_filter; extern int myosd_num_buttons; extern int myosd_num_ways; @@ -114,7 +101,6 @@ extern int myosd_num_players; extern int myosd_num_coins; extern int myosd_num_inputs; -extern int myosd_vsync; extern int myosd_autofire; extern int myosd_hiscore; @@ -137,11 +123,6 @@ extern void myosd_openSound(int rate,int stereo); extern void myosd_sound_play(void *buff, int len); extern void myosd_check_pause(void); -extern const char *myosd_array_main_manufacturers[]; -extern const char *myosd_array_years[]; -extern const char *myosd_array_main_driver_source[]; -extern const char *myosd_array_categories[]; - // myosd output enum myosd_output_channel { diff --git a/src/osd/droid-ios/osd-ios.c b/src/osd/droid-ios/osd-ios.c index 72662b5d..06989286 100644 --- a/src/osd/droid-ios/osd-ios.c +++ b/src/osd/droid-ios/osd-ios.c @@ -32,7 +32,6 @@ int myosd_exitGame = 0; int myosd_pause = 0; int myosd_exitPause = 0; int myosd_last_game_selected = 0; -int myosd_frameskip_value = -1; int myosd_sound_value = 44100; int myosd_throttle = 1; int myosd_cheat = 1; @@ -47,7 +46,6 @@ int myosd_vis_video_height = 240; int myosd_display_width; int myosd_display_height; int myosd_in_menu = 0; -int myosd_res = 1; int myosd_force_pxaspect = 0; int myosd_pxasp1 = 1; @@ -60,27 +58,14 @@ int myosd_light_gun = 0; int myosd_num_of_joys=0; -int myosd_filter_favorites = 0; int myosd_filter_clones = 0; int myosd_filter_not_working = 0; - -int myosd_filter_manufacturer = -1; -int myosd_filter_gte_year = -1; -int myosd_filter_lte_year = -1; -int myosd_filter_driver_source= -1; -int myosd_filter_category = -1; -char myosd_filter_keyword[MAX_FILTER_KEYWORD] = {'\0'}; - -int myosd_reset_filter = 0; - int myosd_num_buttons = 0; int myosd_num_ways = 8; int myosd_num_players = 0; int myosd_num_coins = 0; int myosd_num_inputs = 0; - -int myosd_vsync = -1; int myosd_autofire=1; int myosd_hiscore=1; @@ -124,7 +109,7 @@ static pthread_mutex_t cond_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t condition_var = PTHREAD_COND_INITIALIZER; static pthread_mutex_t sound_mutex = PTHREAD_MUTEX_INITIALIZER; -extern int global_low_latency_sound; +static int global_low_latency_sound = 1; // OSD functions located in the iOS/tvOS app extern "C" void iphone_Reset_Views(void); diff --git a/src/osd/droid-ios/osdinput.c b/src/osd/droid-ios/osdinput.c index 12ca1ea3..366ee519 100644 --- a/src/osd/droid-ios/osdinput.c +++ b/src/osd/droid-ios/osdinput.c @@ -283,6 +283,8 @@ void my_poll_ports(running_machine *machine) mame_printf_debug("Num PLAYERS %d\n",myosd_num_players); mame_printf_debug("Num COINS %d\n",myosd_num_coins); mame_printf_debug("Num INPUTS %d\n",myosd_num_inputs); + mame_printf_debug("Num MOUSE %d\n",myosd_mouse); + mame_printf_debug("Num GUN %d\n",myosd_light_gun); } } @@ -396,10 +398,6 @@ void droid_ios_poll_input(running_machine *machine) else { keyboard_state[KEY_ESCAPE] = 0; - - if(myosd_reset_filter==1){ - myosd_exitGame= 1; - } } // SERVICE key diff --git a/src/osd/droid-ios/osdmain.c b/src/osd/droid-ios/osdmain.c index e8bc933f..c97fd517 100644 --- a/src/osd/droid-ios/osdmain.c +++ b/src/osd/droid-ios/osdmain.c @@ -49,85 +49,9 @@ void mylog(char * msg){ // GLOBALS //============================================================ -int isGridlee = 0; - -const char *myosd_array_main_manufacturers[] = { - "Alpha Denshi","Amcoe","American Laser Games","Arcadia Systems","Aristocrat","Atari","Atlus", - "Barcrest","Bally/Sente","Banpresto","BFM","C.M.C.","Cal Omega", - "Capcom","Century Electronics","Cinematronics","Comad","Data East","Dooyong", - "Dynax","Exidy","Eolith","Face","Gaelco","Gremlin","Greyhound Electronics","Gottlieb", - "High Video","Home Data","Igrosoft","Incredible Technologies","Impera","Irem","IGS", - "IGT","Jaleco","JPM","Leland","Kaneko","Konami","Merit","Metro", - "Midway","Mitchell","Namco","Nichibutsu","Nintendo","NMK","Noraut","Playmark","Psikyo","Rare","Raizing / Eighting", - "Sammy","Sega","Seibu Kaihatsu","SemiCom", - "Seta","SNK","Status Games","Stern","Subsino","Success","Sun Electronics","SunA","TAB Austria","TAD Corporation", - "Taito","Technos","Tecmo","Tehran","Toaplan", - "Universal","UPL","V-System","Video System","Visco","Williams","Yun Sung","Zaccaria", - "Other","" -}; - - -const char *myosd_array_years[] ={ - "1975","1976","1977","1978","1979","1980","1981","1982","1983","1984","1985", - "1986","1987","1988","1989","1990","1991","1992","1993","1994","1995","1996", - "1997","1998","1999","2000","2001","2002","2003","2004","2005","2006","2007", - "" -}; - -const char *myosd_array_main_driver_source[] = { - "8080bw","aerofgt","alpha68k","arcadia","aristmk4","armedf","astrocde","asuka","atarisy1","atarisy2","ataxx", - "bagman","balsente","bfm_sc2","blockade","btime","calomega","cave","cclimber","centiped","champbas","cinemat", - "cischeat","cojag","cosmic","cps1","cps2","cps3","cubocd32","cvs","ddenlovr","ddragon","dec0","dec8","deco32", - "decocass","djmain","dkong","docastle","dooyong","dynax","eolith","equites","esd16","exidy","exidy440","fastfred", - "fromance","funworld","galaxold","galdrvr","galpanic","gameplan","gei","goldnpkr","goldstar","gottlieb","harddriv", - "highvdeo","homedata","igs011","igspoker","itech32","itech8","jack","jalmah","jpmimpct","kaneko16","konamigv", - "konamigx","ksys573","kyugo","ladybug","leland","lethalj","liberate","m62","m72","m90","m92","mappy","marineb", - "maxaflex","mcr","mcr3","mcr68","megaplay","megasys1","merit","meritm","metro","midtunit","midwunit","midyunit", - "mitchell","ms32","multfish","multigam","mw8080bw","mystwarr","namcona1","namconb1","namcos1","namcos11","namcos12", - "namcos2","namcos22","namcos86","nbmj8688","nbmj8891","nbmj8991","nbmj9195","nemesis","neodrvr","ninjakd2","nmg5", - "nmk16","norautp","ojankohs","pacman","paradise","peplus","pgm","playch10","playmark","psikyo","psikyo4","psikyosh", - "qix","rallyx","royalmah","scobra","scramble","seattle","segac2","segae","segag80r","segag80v","segas16a", - "segas16b","segas18","segas24","segas32","segaxbd","segaybd","seibuspi","seta","seta2","sfbonus","simpl156", - "snesb","snk","snk6502","snowbros","srmp2","ssv","statriv2","stv","subsino","suprnova","system1","taito_b", - "taito_f2","taito_f3","taito_l","taito_x","taito_z","taitogn","taitosj","tetrisp2","thepit","tickee","tmaster", - "tmnt","tnzs","toaplan1","toaplan2","tsamurai","tumbleb","usgames","vamphalf","vicdual","vsnes","warpwarp","williams", - "zaxxon","zn","zodiack", - "Other","" -}; - -const char *myosd_array_categories[] = { - "Ball & Paddle","Breakout","Casino","Climbing", - "Driving","Driving / 1st Person","Driving / Boat","Driving / Plane","Driving / Race","Driving / Race (chase view)", - "Driving / Race (chase view) Bike","Driving / Race 1st P Bike","Driving / Race 1st Person","Driving / Race Bike","Driving / Race Track", - "Fighter","Fighter / 2.5D","Fighter / 2D","Fighter / 3D","Fighter / Field","Fighter / Misc.","Fighter / Multiplay","Fighter / Versus", - "Fighter / Versus Co-op","Fighter / Vertical", - "Maze","Maze / Digging","Maze / Driving","Maze / Fighter","Maze / Outline","Maze / Shooter Large","Maze / Shooter Small","Maze / Surround", - "Mini-Games","Misc.","Multiplay", - "Pinball","Platform","Platform / Fighter","Platform / Fighter Scrolling","Platform / Run Jump","Platform / Run Jump Scrolling", - "Platform / Shooter","Platform / Shooter Scrolling", - "Puzzle","Puzzle / Cards","Puzzle / Drop","Puzzle / Match","Puzzle / Maze","Puzzle / Outline","Puzzle / Sliding","Puzzle / Toss", - "Quiz","Quiz / Chinese","Quiz / English","Quiz / French","Quiz / German","Quiz / Italian","Quiz / Japanese","Quiz / Korean", - "Quiz / Music English","Quiz / Music Japanese","Quiz / Spanish", - "Rhythm","Rhythm / Dance","Rhythm / Instruments", - "Shooter","Shooter / 1st Person","Shooter / 3rd Person","Shooter / Command","Shooter / Driving","Shooter / Driving (chase view)", - "Shooter / Driving 1st Person","Shooter / Driving Diagonal","Shooter / Driving Horizontal","Shooter / Driving Vertical", - "Shooter / Field","Shooter / Flying","Shooter / Flying (chase view)","Shooter / Flying 1st Person", - "Shooter / Flying Diagonal","Shooter / Flying Horizontal","Shooter / Flying Vertical","Shooter / Gallery","Shooter / Gun", - "Shooter / Misc.","Shooter / Misc. Horizontal","Shooter / Misc. Vertical","Shooter / Versus","Shooter / Walking","Sports", - "Sports / Armwrestling","Sports / Baseball","Sports / Basketball","Sports / Bowling","Sports / Boxing","Sports / Bull Fighting", - "Sports / Darts","Sports / Dodgeball","Sports / Fishing","Sports / Football Amer.","Sports / Football Rugby","Sports / Golf", - "Sports / Handball","Sports / Hang Gliding","Sports / Hockey","Sports / Horse Racing","Sports / Horseshoes","Sports / Multiplay", - "Sports / Ping pong","Sports / Pool","Sports / Shuffleboard","Sports / Skateboarding","Sports / Skiing","Sports / SkyDiving", - "Sports / Soccer","Sports / Sumo","Sports / Swimming","Sports / Tennis","Sports / Track & Field","Sports / VolleyBall", - "Sports / Wrestling", - "Tabletop","Tabletop / Hanafuda","Tabletop / Mahjong","Tabletop / Othello","Tabletop / Renju","Tabletop / Shougi", - "" -}; - // a single rendering target static render_target *our_target; - static const options_entry droid_mame_options[] = { { "initpath", ".;/mame", 0, "path to ini files" }, @@ -199,10 +123,6 @@ int main(int argc, char **argv) //args[n]= (char *)"-joystick_deadzone"; n++;args[n]= (char *)"0.0"; n++; args[n]= (char *)"-nocoinlock"; n++; - if(isGridlee){ - args[n]= (char *)"gridlee"; n++; - } - netplay_t *handle = netplay_get_handle(); if(handle->has_connection) { @@ -224,34 +144,7 @@ int main(int argc, char **argv) } } - if(myosd_reset_filter==0) - { - f=fopen("mame4x.cfg","r"); - if (f) { - fscanf(f,"%d",&myosd_last_game_selected); - fclose(f); - } - } - else - { - myosd_last_game_selected = 0; - f=fopen("mame4x.cfg","w"); - if (f) { - fprintf(f,"%d",myosd_last_game_selected); - fclose(f); - sync(); - } - myosd_reset_filter = 0; - } - ret = cli_execute(n, args, droid_mame_options); - - f=fopen("mame4x.cfg","w"); - if (f) { - fprintf(f,"%d",myosd_last_game_selected); - fclose(f); - sync(); - } } myosd_deinit(); diff --git a/xcode/MAME4iOS/Options.h b/xcode/MAME4iOS/Options.h index d5364b97..c985f223 100644 --- a/xcode/MAME4iOS/Options.h +++ b/xcode/MAME4iOS/Options.h @@ -20,9 +20,6 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly, strong) NSString* optionsFile; -@property (class, readonly, strong) NSArray* arrayEmuRes; -@property (class, readonly, strong) NSArray* arrayFSValue; -@property (class, readonly, strong) NSArray* arrayOverscanValue; @property (class, readonly, strong) NSArray* arrayEmuSpeed; @property (class, readonly, strong) NSArray* arrayControlType; @property (class, readonly, strong) NSArray* arraySkin; @@ -40,7 +37,6 @@ NS_ASSUME_NONNULL_BEGIN @property (readwrite,strong) NSString *lineShader; @property (readwrite,strong) NSString *colorSpace; -@property (readwrite,assign) int useMetal; @property (readwrite,assign) int integerScalingOnly; @property (readwrite,assign) int showFPS; @@ -50,9 +46,6 @@ NS_ASSUME_NONNULL_BEGIN @property (readwrite,assign) int fullscreenPortrait; @property (readwrite,assign) int fullscreenJoystick; -@property (readwrite,assign) int overscanValue; -@property (readwrite,assign) int tvoutNative; - @property (readwrite,assign) int touchtype; @property (readwrite,assign) int analogDeadZoneValue; @@ -61,39 +54,18 @@ NS_ASSUME_NONNULL_BEGIN @property (readwrite,assign) int soundValue; -@property (readwrite,assign) int throttle; -@property (readwrite,assign) int fsvalue; @property (readwrite,assign) int sticktype; @property (readwrite,assign) int numbuttons; @property (readwrite,assign) int aplusb; @property (readwrite,assign) int cheats; -@property (readwrite,assign) int sleep; @property (readwrite,assign) int forcepxa; -@property (readwrite,assign) int emures; @property (readwrite,assign) int p1aspx; @property (readwrite,assign) int filterClones; -@property (readwrite,assign) int filterFavorites; @property (readwrite,assign) int filterNotWorking; -@property (readwrite,assign) int manufacturerValue; -@property (readwrite,assign) int yearGTEValue; -@property (readwrite,assign) int yearLTEValue; -@property (readwrite,assign) int driverSourceValue; -@property (readwrite,assign) int categoryValue; - -@property (readwrite,strong,nullable) NSString *filterKeyword; - -@property (readwrite,assign) int lowlsound; -@property (readwrite,assign) int vsync; -@property (readwrite,assign) int threaded; -@property (readwrite,assign) int dblbuff; - -@property (readwrite,assign) int mainPriority; -@property (readwrite,assign) int videoPriority; @property (readwrite,assign) int autofire; - @property (readwrite,assign) int hiscore; @property (readwrite,assign) int buttonSize; @@ -131,10 +103,6 @@ NS_ASSUME_NONNULL_BEGIN @property (readwrite,assign) CGFloat touchControlsOpacity; -@property (readwrite,assign) int mainThreadType; -@property (readwrite,assign) int videoThreadType; - - @end @interface NSArray (optionAtIndex) diff --git a/xcode/MAME4iOS/Options.m b/xcode/MAME4iOS/Options.m index de27b836..9e41aafa 100644 --- a/xcode/MAME4iOS/Options.m +++ b/xcode/MAME4iOS/Options.m @@ -16,21 +16,8 @@ @implementation Options #pragma mark - class properties -+ (NSArray*)arrayEmuRes { - return @[@"Auto",@"320x200",@"320x240",@"400x300",@"480x300",@"512x384",@"640x400",@"640x480 (SD)",@"800x600",@"1024x768",@"1280x960", - @"1440x1080 (HD)",@"1600x1200",@"1920x1440",@"2048x1536",@"2880x2160 (UHD)"]; -} -+ (NSArray*)arrayFSValue { - return [[NSArray alloc] initWithObjects:@"Auto",@"None", @"1", @"2", @"3",@"4", @"5", @"6", @"7", @"8", @"9", @"10", nil]; -} -+ (NSArray*)arrayOverscanValue { - return [[NSArray alloc] initWithObjects:@"None",@"1", @"2", @"3",@"4", @"5", @"6", nil]; -} + (NSArray*)arrayEmuSpeed { - return [[NSArray alloc] initWithObjects: @"Default", - @"50%", @"60%", @"70%", @"80%", @"85%",@"90%",@"95%",@"100%", - @"105%", @"110%", @"115%", @"120%", @"130%",@"140%",@"150%", - nil]; + return @[@"Default",@"50%",@"60%",@"70%",@"80%",@"85%",@"90%",@"95%",@"100%",@"105%",@"110%",@"115%",@"120%",@"130%",@"140%",@"150%"]; } + (NSArray*)arrayControlType { return @[@"Keyboard",@"iCade or compatible",@"iCP, Gametel",@"iMpulse", @"8BitDo Zero"]; @@ -124,7 +111,6 @@ - (void)loadOptions _lineShader = @""; _colorSpace = @""; - _useMetal = 1; _integerScalingOnly = 0; @@ -143,9 +129,6 @@ - (void)loadOptions _fullscreenJoystick = 1; #endif - _overscanValue = 0; - _tvoutNative = 1; - _touchtype = 1; _analogDeadZoneValue = 2; @@ -153,36 +136,16 @@ - (void)loadOptions _soundValue = 5; - _throttle = 1; - _fsvalue = 0; _sticktype = 0; _numbuttons = 0; _aplusb = 0; _cheats = 1; - _sleep = 1; _forcepxa = 0; - _emures = 0; _p1aspx = 0; _filterClones=0; - _filterFavorites=0; _filterNotWorking=1; - _manufacturerValue=0; - _yearGTEValue=0; - _yearLTEValue=0; - _driverSourceValue=0; - _categoryValue=0; - - _filterKeyword = nil; - - _lowlsound = 1; - _vsync = 1; - _threaded = 1; - _dblbuff = 1; - - _mainPriority = 5; - _videoPriority = 5; _autofire = 0; _hiscore = 1; @@ -203,9 +166,6 @@ - (void)loadOptions _emuspeed = 0; - _mainThreadType = 0; - _videoThreadType = 0; - _lightgunEnabled = 1; _lightgunBottomScreenReload = 0; @@ -236,7 +196,6 @@ - (void)loadOptions _lineShader = [optionsDict objectForKey:@"line-shader"] ?: @""; _colorSpace = [optionsDict objectForKey:@"sourceColorSpace"] ?: @""; - _useMetal = [([optionsDict objectForKey:@"useMetal"] ?: @(TRUE)) boolValue]; _integerScalingOnly = [[optionsDict objectForKey:@"integerScalingOnly"] boolValue]; @@ -270,61 +229,25 @@ - (void)loadOptions _touchDirectionalEnabled = [[optionsDict objectForKey:@"touchDirectionalEnabled"] intValue]; - _overscanValue = [[optionsDict objectForKey:@"overscanValue"] intValue]; - _tvoutNative = [[optionsDict objectForKey:@"tvoutNative"] intValue]; - _touchtype = [[optionsDict objectForKey:@"inputTouchType"] intValue]; _analogDeadZoneValue = [[optionsDict objectForKey:@"analogDeadZoneValue"] intValue]; _controltype = [[optionsDict objectForKey:@"controlType"] intValue]; _soundValue = [[optionsDict objectForKey:@"soundValue"] intValue]; - _throttle = [[optionsDict objectForKey:@"throttle"] intValue]; - _fsvalue = [[optionsDict objectForKey:@"fsvalue"] intValue]; _sticktype = [[optionsDict objectForKey:@"sticktype"] intValue]; _numbuttons = [[optionsDict objectForKey:@"numbuttons"] intValue]; _aplusb = [[optionsDict objectForKey:@"aplusb"] intValue]; _cheats = [[optionsDict objectForKey:@"cheats"] intValue]; - _sleep = [[optionsDict objectForKey:@"sleep"] intValue]; _forcepxa = [[optionsDict objectForKey:@"forcepxa"] intValue]; - _emures = [[optionsDict objectForKey:@"emures"] intValue]; _p1aspx = [[optionsDict objectForKey:@"p1aspx"] intValue]; _filterClones = [[optionsDict objectForKey:@"filterClones"] intValue]; - _filterFavorites = [[optionsDict objectForKey:@"filterFavorites"] intValue]; _filterNotWorking = [[optionsDict objectForKey:@"filterNotWorking"] intValue]; - _manufacturerValue = [[optionsDict objectForKey:@"manufacturerValue"] intValue]; - _yearGTEValue = [[optionsDict objectForKey:@"yearGTEValue"] intValue]; - _yearLTEValue = [[optionsDict objectForKey:@"yearLTEValue"] intValue]; - _driverSourceValue = [[optionsDict objectForKey:@"driverSourceValue"] intValue]; - _categoryValue = [[optionsDict objectForKey:@"categoryValue"] intValue]; - - _filterKeyword = [optionsDict objectForKey:@"filterKeyword"]; - - _lowlsound = [[optionsDict objectForKey:@"lowlsound"] intValue]; - _vsync = [[optionsDict objectForKey:@"vsync"] intValue]; - -#if 0 // leave these values set to the defaults, there is no UI anymore to change them. - // ...and they only apply to CoreGraphics not Metal - _threaded = [[optionsDict objectForKey:@"threaded"] intValue]; - _dblbuff = [[optionsDict objectForKey:@"dblbuff"] intValue]; - _mainPriority = [[optionsDict objectForKey:@"mainPriority"] intValue]; - _videoPriority = [[optionsDict objectForKey:@"videoPriority"] intValue]; - _mainThreadType = [[optionsDict objectForKey:@"mainThreadType"] intValue]; - _videoThreadType = [[optionsDict objectForKey:@"videoThreadType"] intValue]; -#else - _threaded = 1; - _dblbuff = 1; - _mainPriority = 5; - _videoPriority = 5; - _mainThreadType = 0; - _videoThreadType = 0; -#endif _autofire = [[optionsDict objectForKey:@"autofire"] intValue]; - _hiscore = [[optionsDict objectForKey:@"hiscore"] intValue]; _buttonSize = [[optionsDict objectForKey:@"buttonSize"] intValue]; @@ -339,8 +262,6 @@ - (void)loadOptions if([_wfpeeraddr isEqualToString:@""]) _wfpeeraddr = nil; - if([_filterKeyword isEqualToString:@""]) - _filterKeyword = nil; _vbean2x = [[optionsDict objectForKey:@"vbean2x"] intValue]; _vantialias = [[optionsDict objectForKey:@"vantialias"] intValue]; @@ -362,7 +283,6 @@ - (void)saveOptions _lineShader, @"line-shader", _colorSpace, @"sourceColorSpace", - [NSString stringWithFormat:@"%d", _useMetal], @"useMetal", [NSString stringWithFormat:@"%d", _integerScalingOnly], @"integerScalingOnly", @@ -392,9 +312,6 @@ - (void)saveOptions [NSString stringWithFormat:@"%d", _fullscreenPortrait], @"fullPort", [NSString stringWithFormat:@"%d", _fullscreenJoystick], @"fullJoy", - [NSString stringWithFormat:@"%d", _overscanValue], @"overscanValue", - [NSString stringWithFormat:@"%d", _tvoutNative], @"tvoutNative", - [NSString stringWithFormat:@"%d", _touchtype], @"inputTouchType", [NSString stringWithFormat:@"%d", _analogDeadZoneValue], @"analogDeadZoneValue", @@ -402,34 +319,18 @@ - (void)saveOptions [NSString stringWithFormat:@"%d", _soundValue], @"soundValue", - [NSString stringWithFormat:@"%d", _throttle], @"throttle", - [NSString stringWithFormat:@"%d", _fsvalue], @"fsvalue", [NSString stringWithFormat:@"%d", _sticktype], @"sticktype", [NSString stringWithFormat:@"%d", _numbuttons], @"numbuttons", [NSString stringWithFormat:@"%d", _aplusb], @"aplusb", [NSString stringWithFormat:@"%d", _cheats], @"cheats", - [NSString stringWithFormat:@"%d", _sleep], @"sleep", [NSString stringWithFormat:@"%d", _forcepxa], @"forcepxa", - [NSString stringWithFormat:@"%d", _emures], @"emures", [NSString stringWithFormat:@"%d", _p1aspx], @"p1aspx", [NSString stringWithFormat:@"%d", _filterClones], @"filterClones", - [NSString stringWithFormat:@"%d", _filterFavorites], @"filterFavorites", [NSString stringWithFormat:@"%d", _filterNotWorking], @"filterNotWorking", - [NSString stringWithFormat:@"%d", _manufacturerValue], @"manufacturerValue", - [NSString stringWithFormat:@"%d", _yearGTEValue], @"yearGTEValue", - [NSString stringWithFormat:@"%d", _yearLTEValue], @"yearLTEValue", - [NSString stringWithFormat:@"%d", _driverSourceValue], @"driverSourceValue", - [NSString stringWithFormat:@"%d", _categoryValue], @"categoryValue", - [NSString stringWithFormat:@"%d", _lowlsound], @"lowlsound", - [NSString stringWithFormat:@"%d", _vsync], @"vsync", - [NSString stringWithFormat:@"%d", _threaded], @"threaded", - [NSString stringWithFormat:@"%d", _dblbuff], @"dblbuff", - - [NSString stringWithFormat:@"%d", _mainPriority], @"mainPriority", - [NSString stringWithFormat:@"%d", _videoPriority], @"videoPriority", + [NSString stringWithFormat:@"%d", _autofire], @"autofire", [NSString stringWithFormat:@"%d", _hiscore], @"hiscore", @@ -444,51 +345,18 @@ - (void)saveOptions [NSString stringWithFormat:@"%d", _btlatency], @"btlatency", (_wfpeeraddr ?: @""), @"wfpeeraddr", - (_filterKeyword ?: @""), @"filterKeyword", - [NSString stringWithFormat:@"%d", _vbean2x], @"vbean2x", [NSString stringWithFormat:@"%d", _vantialias], @"vantialias", [NSString stringWithFormat:@"%d", _vflicker], @"vflicker", [NSString stringWithFormat:@"%d", _emuspeed], @"emuspeed", - [NSString stringWithFormat:@"%d", _mainThreadType], @"mainThreadType", - [NSString stringWithFormat:@"%d", _videoThreadType], @"videoThreadType", - nil]; - NSString *path=[NSString stringWithUTF8String:get_documents_path("iOS/options_v23.bin")]; - - NSData *plistData; - - NSError *error = nil; - - plistData = [NSPropertyListSerialization dataWithPropertyList:@[optionsDict] - format:NSPropertyListBinaryFormat_v1_0 - options:0 - error:&error]; - - if(plistData) - { - //NSError*err; - - BOOL b = [plistData writeToFile:path atomically:NO]; - //BOOL b = [plistData writeToFile:path options:0 error:&err]; - if(!b) - { - UIAlertController *errAlert = [UIAlertController alertControllerWithTitle:@"Error saving preferences!" message:@"Preferences cannot be saved.\n Check for write permissions. 'chmod -R 777 /var/mobile/Media/ROMs' if needed. Look at the help for details!." preferredStyle:UIAlertControllerStyleAlert]; - [errAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - - }]]; - UIViewController *controller = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; - [controller presentViewController:errAlert animated:YES completion:nil]; - } - } - else - { - NSLog(@"%@",error); - } + NSData* data = [NSPropertyListSerialization dataWithPropertyList:optionsDict format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil]; + NSParameterAssert(data != nil); + [data writeToFile:Options.optionsPath atomically:NO]; } @end diff --git a/xcode/MAME4iOS/TVInputOptionsController.m b/xcode/MAME4iOS/TVInputOptionsController.m index 827277ea..5f7d1054 100644 --- a/xcode/MAME4iOS/TVInputOptionsController.m +++ b/xcode/MAME4iOS/TVInputOptionsController.m @@ -127,7 +127,7 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath * if ( indexPath.section == 0 ) { if ( indexPath.row == 1 ) { - ListOptionController *listController = [[ListOptionController alloc] initWithType:kTypeControlType list:Options.arrayControlType]; + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"controltype" list:Options.arrayControlType title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } } else if (indexPath.section == 1) { diff --git a/xcode/MAME4iOS/TVOptionsController.h b/xcode/MAME4iOS/TVOptionsController.h index 2b44cfc1..e20899b6 100644 --- a/xcode/MAME4iOS/TVOptionsController.h +++ b/xcode/MAME4iOS/TVOptionsController.h @@ -25,40 +25,6 @@ enum OptionSections kNumSections }; -enum ListOptionType -{ - kTypeNumButtons, - kTypeEmuRes, - kTypeStickType, - kTypeTouchType, - kTypeControlType, - kTypeAnalogDZValue, - kTypeBTDZValue, - kTypeSoundValue, - kTypeFSValue, - kTypeOverscanValue, - kTypeManufacturerValue, - kTypeYearGTEValue, - kTypeYearLTEValue, - kTypeDriverSourceValue, - kTypeCategoryValue, - kTypeVideoPriorityValue, - kTypeMainPriorityValue, - kTypeAutofireValue, - kTypeStickSizeValue, - kTypeButtonSizeValue, - kTypeArrayWPANtype, - kTypeWFframeSync, - kTypeBTlatency, - kTypeEmuSpeed, - kTypeVideoThreadTypeValue, - kTypeMainThreadTypeValue -}; - -NS_ASSUME_NONNULL_BEGIN - @interface TVOptionsController : OptionsTableViewController @end - -NS_ASSUME_NONNULL_END diff --git a/xcode/MAME4iOS/TVOptionsController.m b/xcode/MAME4iOS/TVOptionsController.m index 054870b3..eb1e6575 100644 --- a/xcode/MAME4iOS/TVOptionsController.m +++ b/xcode/MAME4iOS/TVOptionsController.m @@ -43,11 +43,11 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger if ( section == kFilterSection ) { return 2; } else if ( section == kScreenSection ) { - return 9; + return 8; } else if ( section == kVectorSection ) { return 3; } else if ( section == kMiscSection ) { - return 11; + return 6; } else if ( section == kInputSection ) { return 1; } else if ( section == kImportSection ) { @@ -169,15 +169,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.detailTextLabel.text = [Options.arrayColorSpace optionName:op.colorSpace]; } else if ( indexPath.row == 5 ) { - cell.textLabel.text = @"Use Metal"; - cell.accessoryView = [self optionSwitchForKey:@"useMetal"]; - } else if ( indexPath.row == 6 ) { cell.textLabel.text = @"Keep Aspect Ratio"; cell.accessoryView = [self optionSwitchForKey:@"keepAspectRatio"]; - } else if ( indexPath.row == 7 ) { + } else if ( indexPath.row == 6 ) { cell.textLabel.text = @"Integer Scaling Only"; cell.accessoryView = [self optionSwitchForKey:@"integerScalingOnly"]; - } else if ( indexPath.row == 8 ) { + } else if ( indexPath.row == 7 ) { cell.textLabel.text = @"Force Pixel Aspect"; cell.accessoryView = [self optionSwitchForKey:@"forcepxa"]; } @@ -200,36 +197,19 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.textLabel.text = @"Show Info/Warnings"; cell.accessoryView = [self optionSwitchForKey:@"showINFO"]; } else if ( indexPath.row == 2 ) { - cell.textLabel.text = @"Emulated Resolution"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arrayEmuRes optionAtIndex:op.emures]; + cell.textLabel.text = @"Cheats"; + cell.accessoryView = [self optionSwitchForKey:@"cheats"]; } else if ( indexPath.row == 3 ) { + cell.textLabel.text = @"Save Hiscores"; + cell.accessoryView = [self optionSwitchForKey:@"hiscore"]; + } else if ( indexPath.row == 4 ) { cell.textLabel.text = @"Emulated Speed"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.detailTextLabel.text = [Options.arrayEmuSpeed optionAtIndex:op.emuspeed]; - } else if ( indexPath.row == 4 ) { - cell.textLabel.text = @"Throttle"; - cell.accessoryView = [self optionSwitchForKey:@"throttle"]; } else if ( indexPath.row == 5 ) { - cell.textLabel.text = @"Frame Skip"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = [Options.arrayFSValue optionAtIndex:op.fsvalue]; - } else if ( indexPath.row == 6 ) { - cell.textLabel.text = @"Low Latency Audio"; - cell.accessoryView = [self optionSwitchForKey:@"lowlsound"]; - } else if ( indexPath.row == 7 ) { cell.textLabel.text = @"Sound"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.detailTextLabel.text = [Options.arraySoundValue optionAtIndex:op.soundValue]; - } else if ( indexPath.row == 8 ) { - cell.textLabel.text = @"Cheats"; - cell.accessoryView = [self optionSwitchForKey:@"cheats"]; - } else if ( indexPath.row == 9 ) { - cell.textLabel.text = @"Force 60Hz Sync"; - cell.accessoryView = [self optionSwitchForKey:@"vsync"]; - } else if ( indexPath.row == 10 ) { - cell.textLabel.text = @"Save Hiscores"; - cell.accessoryView = [self optionSwitchForKey:@"hiscore"]; } } else if ( indexPath.section == kInputSection ) { cell.textLabel.text = @"Game Input"; @@ -289,16 +269,10 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath * [[self navigationController] pushViewController:listController animated:YES]; } } else if ( indexPath.section == kMiscSection ) { - if ( indexPath.row == 2 ) { - ListOptionController *listController = [[ListOptionController alloc] initWithType:kTypeEmuRes list:Options.arrayEmuRes]; - [[self navigationController] pushViewController:listController animated:YES]; - } else if ( indexPath.row == 3 ) { - ListOptionController *listController = [[ListOptionController alloc] initWithType:kTypeEmuSpeed list:Options.arrayEmuSpeed]; + if ( indexPath.row == 4 ) { + ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"emuspeed" list:Options.arrayEmuSpeed title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; } else if ( indexPath.row == 5 ) { - ListOptionController *listController = [[ListOptionController alloc] initWithType:kTypeFSValue list:Options.arrayFSValue]; - [[self navigationController] pushViewController:listController animated:YES]; - } else if ( indexPath.row == 7 ) { ListOptionController *listController = [[ListOptionController alloc] initWithKey:@"soundValue" list:Options.arraySoundValue title:cell.textLabel.text]; [[self navigationController] pushViewController:listController animated:YES]; }