summaryrefslogtreecommitdiff
path: root/macosx/plugins/Bladesio1/macsrc
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-04 21:55:52 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-04 21:55:52 +0000
commitb05c91bb3b900edee49546451a0eecf54988a3b7 (patch)
treef1577eb03d855fcf098a3200713026c193ced78a /macosx/plugins/Bladesio1/macsrc
parent887a72f1270ac12e39b08391c280f076b687d95f (diff)
downloadpcsxr-b05c91bb3b900edee49546451a0eecf54988a3b7.tar.gz
This should get the bladesio plug-in building on OS X.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85824 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/Bladesio1/macsrc')
-rw-r--r--macosx/plugins/Bladesio1/macsrc/ARCBridge.h36
-rwxr-xr-xmacosx/plugins/Bladesio1/macsrc/PluginConfigController.h23
-rwxr-xr-xmacosx/plugins/Bladesio1/macsrc/PluginConfigController.m204
-rwxr-xr-xmacosx/plugins/Bladesio1/macsrc/cfg.c50
4 files changed, 313 insertions, 0 deletions
diff --git a/macosx/plugins/Bladesio1/macsrc/ARCBridge.h b/macosx/plugins/Bladesio1/macsrc/ARCBridge.h
new file mode 100644
index 00000000..ea274b84
--- /dev/null
+++ b/macosx/plugins/Bladesio1/macsrc/ARCBridge.h
@@ -0,0 +1,36 @@
+//
+// ARCBridge.h
+// PPMacho
+//
+// Created by C.W. Betts on 12/23/12.
+//
+//
+
+#ifndef PPMacho_ARCBridge_h
+#define PPMacho_ARCBridge_h
+
+#if __has_feature(objc_arc)
+
+#define SUPERDEALLOC
+#define RELEASEOBJ(obj)
+#define RETAINOBJ(obj) obj
+#define RETAINOBJNORETURN(obj)
+#define AUTORELEASEOBJ(obj) obj
+#define AUTORELEASEOBJNORETURN(obj)
+#define BRIDGE(toType, obj) (__bridge toType)(obj)
+#define __arcweak __weak
+
+#else
+
+#define SUPERDEALLOC [super dealloc]
+#define RELEASEOBJ(obj) [obj release]
+#define RETAINOBJ(obj) [obj retain]
+#define RETAINOBJNORETURN(obj) [obj retain]
+#define AUTORELEASEOBJ(obj) [obj autorelease]
+#define AUTORELEASEOBJNORETURN(obj) [obj autorelease]
+#define BRIDGE(toType, obj) (toType)obj
+#define __arcweak
+
+#endif
+
+#endif
diff --git a/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h
new file mode 100755
index 00000000..595dce02
--- /dev/null
+++ b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h
@@ -0,0 +1,23 @@
+#define PluginConfigController Bladesio1PluginConfigController
+
+#import <Cocoa/Cocoa.h>
+
+@interface Bladesio1PluginConfigController : NSWindowController
+{
+ IBOutlet NSButton *enabledButton;
+ IBOutlet NSTextField *ipAddressField;
+ IBOutlet NSTextField *portField;
+ IBOutlet NSPopUpButton *playerMenu;
+ IBOutlet NSBox *configBox;
+
+ NSMutableDictionary *keyValues;
+}
+- (IBAction)cancel:(id)sender;
+- (IBAction)ok:(id)sender;
+- (IBAction)toggleEnabled:(id)sender;
+- (IBAction)resetPreferences:(id)sender;
+
+
+- (void)loadValues;
+
+@end
diff --git a/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m
new file mode 100755
index 00000000..13d9ef6e
--- /dev/null
+++ b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * Based on: Cdrom for Psemu Pro like Emulators
+ * By: linuzappz <linuzappz@hotmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#import "PluginConfigController.h"
+#include "typedefs.h"
+#include "sio1.h"
+#import "ARCBridge.h"
+
+#define APP_ID @"net.pcsxr.Bladesio1"
+#define PrefsKey APP_ID @" Settings"
+
+static PluginConfigController *windowController = nil;
+
+#define kSioEnabled @"SIO Enabled"
+#define kSioPort @"Port"
+#define kSioPlayer @"Player"
+#define kSioIPAddress @"IP address"
+
+void AboutDlgProc()
+{
+ // Get parent application instance
+ NSApplication *app = [NSApplication sharedApplication];
+ NSBundle *bundle = [NSBundle bundleWithIdentifier:APP_ID];
+
+ // Get Credits.rtf
+ NSString *path = [bundle pathForResource:@"Credits" ofType:@"rtf"];
+ NSAttributedString *credits;
+ if (path) {
+ credits = [[NSAttributedString alloc] initWithPath: path
+ documentAttributes:NULL];
+ AUTORELEASEOBJNORETURN(credits);
+
+ } else {
+ credits = AUTORELEASEOBJ([[NSAttributedString alloc] initWithString:@""]);
+ }
+
+ // Get Application Icon
+ NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[bundle bundlePath]];
+ NSSize size = NSMakeSize(64, 64);
+ [icon setSize:size];
+
+ [app orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys:
+ [bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
+ icon, @"ApplicationIcon",
+ [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
+ [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], @"Version",
+ [bundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], @"Copyright",
+ credits, @"Credits",
+ nil]];
+}
+
+void ConfDlgProc()
+{
+ NSWindow *window;
+
+ if (windowController == nil) {
+ windowController = [[PluginConfigController alloc] initWithWindowNibName:@"Bladesio1PluginConfig"];
+ }
+ window = [windowController window];
+
+ [windowController loadValues];
+
+ [window center];
+ [window makeKeyAndOrderFront:nil];
+}
+
+void ReadConfig()
+{
+ NSDictionary *keyValues;
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @NO, kSioEnabled,
+ @((unsigned short)33307), kSioPort,
+ @"127.0.0.1", kSioIPAddress,
+ @(PLAYER_DISABLED), kSioPlayer,
+ nil], PrefsKey, nil]];
+
+ keyValues = [defaults dictionaryForKey:PrefsKey];
+
+ settings.enabled = [[keyValues objectForKey:kSioEnabled] boolValue];
+ settings.port = [[keyValues objectForKey:kSioPort] unsignedShortValue];
+ settings.player = [[keyValues objectForKey:kSioPlayer] intValue];
+ strlcpy(settings.ip, [[keyValues objectForKey:kSioIPAddress] cStringUsingEncoding:NSASCIIStringEncoding], sizeof(settings.ip));
+}
+
+@implementation Bladesio1PluginConfigController
+
+- (IBAction)cancel:(id)sender
+{
+ [self close];
+}
+
+- (IBAction)ok:(id)sender
+{
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+
+ NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:keyValues];
+
+
+ NSString *theAddress = [ipAddressField stringValue];
+ {
+ unsigned char a, b, c, d;
+ if (sscanf([theAddress cStringUsingEncoding:NSASCIIStringEncoding], "%s.%s.%s.%s", &a, &b, &c, &d) != 4) {
+ NSBeginAlertSheet(@"Invalid IP address", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The IP address cannot be a hostname,");
+ }
+ }
+
+ [writeDic setObject:(([enabledButton state] == NSOnState) ? @YES : @NO) forKey:kSioEnabled];
+ [writeDic setObject:[ipAddressField stringValue] forKey:kSioIPAddress];
+ [writeDic setObject:@((unsigned short)[portField intValue]) forKey:kSioPort];
+
+
+ switch ([playerMenu indexOfSelectedItem]) {
+ default:
+ case 0: [writeDic setObject:@(PLAYER_DISABLED) forKey:kSioPlayer]; break;
+ case 1: [writeDic setObject:@(PLAYER_MASTER) forKey:kSioPlayer]; break;
+ case 2: [writeDic setObject:@(PLAYER_SLAVE) forKey:kSioPlayer]; break;
+ }
+
+ // write to defaults
+ [defaults setObject:writeDic forKey:PrefsKey];
+ [defaults synchronize];
+
+ // and set global values accordingly
+ ReadConfig();
+
+ [self close];
+}
+
+- (IBAction)toggleEnabled:(id)sender
+{
+ BOOL isEnabled = [enabledButton state] == NSOnState ? YES : NO;
+
+ for (NSView *subView in [configBox subviews]) {
+ if ([subView isKindOfClass:[NSTextField class]] && ![(NSTextField*)subView isEditable]) {
+ [(NSTextField*)subView setTextColor:isEnabled ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
+ } else {
+ [(NSControl*)subView setEnabled:isEnabled];
+ }
+ }
+}
+
+- (IBAction)resetPreferences:(id)sender
+{
+ [[NSUserDefaults standardUserDefaults] removeObjectForKey:PrefsKey];
+ [self loadValues];
+}
+
+- (void)loadValues
+{
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+
+ ReadConfig();
+
+ // load from preferences
+ RELEASEOBJ(keyValues);
+ keyValues = [[defaults dictionaryForKey:PrefsKey] mutableCopy];
+
+ [enabledButton setState: [[keyValues objectForKey:kSioEnabled] boolValue] ? NSOnState : NSOffState];
+ [ipAddressField setTitleWithMnemonic:[keyValues objectForKey:kSioIPAddress]];
+ [portField setValue:[keyValues objectForKey:kSioPort]];
+
+ switch ([[keyValues objectForKey:kSioPlayer] intValue]) {
+ default:
+ case PLAYER_DISABLED: [playerMenu selectItemAtIndex:0]; break;
+ case PLAYER_MASTER: [playerMenu selectItemAtIndex:1]; break;
+ case PLAYER_SLAVE: [playerMenu selectItemAtIndex:2]; break;
+ }
+}
+
+- (void)awakeFromNib
+{
+}
+
+@end
+
+char* PLUGLOC(char *toloc)
+{
+ NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]];
+ NSString *origString = nil, *transString = nil;
+ origString = [NSString stringWithCString:toloc encoding:NSUTF8StringEncoding];
+ transString = [mainBundle localizedStringForKey:origString value:nil table:nil];
+ return (char*)[transString cStringUsingEncoding:NSUTF8StringEncoding];
+}
+
diff --git a/macosx/plugins/Bladesio1/macsrc/cfg.c b/macosx/plugins/Bladesio1/macsrc/cfg.c
new file mode 100755
index 00000000..65fd5111
--- /dev/null
+++ b/macosx/plugins/Bladesio1/macsrc/cfg.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * Based on: Cdrom for Psemu Pro like Emulators
+ * By: linuzappz <linuzappz@hotmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <string.h>
+#include <stdint.h>
+#include "typedefs.h"
+#include "sio1.h"
+
+void AboutDlgProc();
+void ConfDlgProc();
+void ReadConfig();
+
+Settings settings;
+
+void settingsRead() {
+ settings.player = PLAYER_DISABLED;
+ strcpy(settings.ip, "127.0.0.1");
+ settings.port = 33307;
+
+ ReadConfig();
+}
+
+#if 0
+extern long SIO1configure() {
+ ConfDlgProc();
+ return 0;
+}
+
+extern void SIO1about() {
+ AboutDlgProc();
+}
+#endif