Permalink
Browse files

added project files

  • Loading branch information...
0 parents commit f4f17b9987c0dd2037d3df1daac7cf3c8b7e44a3 @WoozleWrangler committed May 24, 2010
Showing with 12,559 additions and 0 deletions.
  1. +41 −0 Classes/SNESControllerAppDelegate.h
  2. +120 −0 Classes/SNESControllerAppDelegate.m
  3. +58 −0 Classes/SNESControllerViewController.h
  4. +355 −0 Classes/SNESControllerViewController.m
  5. +49 −0 Classes/SessionController.h
  6. +277 −0 Classes/SessionController.m
  7. +41 −0 ControlPad-Info.plist
  8. +337 −0 ControlPad.xcodeproj/project.pbxproj
  9. +386 −0 ControlPad.xcodeproj/yusefnapora.pbxuser
  10. +1,490 −0 ControlPad.xcodeproj/yusefnapora.perspectivev3
  11. +8 −0 ControlPad_Prefix.pch
  12. +164 −0 IOKit/IOKitKeys.h
  13. +1,424 −0 IOKit/IOKitLib.h
  14. +137 −0 IOKit/IOReturn.h
  15. +250 −0 IOKit/IOTypes.h
  16. +2,752 −0 IOKit/OSKext.h
  17. +158 −0 IOKit/OSMessageNotification.h
  18. +131 −0 IOKit/hid/IOHIDDisplay.h
  19. +220 −0 IOKit/hid/IOHIDEvent.h
  20. +1,020 −0 IOKit/hid/IOHIDEventData.h
  21. +82 −0 IOKit/hid/IOHIDEventQueue.h
  22. +104 −0 IOKit/hid/IOHIDEventSystem.h
  23. +84 −0 IOKit/hid/IOHIDEventSystemClient.h
  24. +368 −0 IOKit/hid/IOHIDEventTypes.h
  25. +82 −0 IOKit/hid/IOHIDNotification.h
  26. +122 −0 IOKit/hid/IOHIDService.h
  27. +152 −0 IOKit/hid/IOHIDSession.h
  28. +69 −0 IOKit/hid/IOHIDUserDevice.h
  29. +74 −0 Makefile
  30. 0 README
  31. BIN Resources/ConnectedIcon.png
  32. BIN Resources/Default.png
  33. BIN Resources/Icon.png
  34. BIN Resources/MainWindow.nib
  35. +227 −0 Resources/MainWindow.xib
  36. BIN Resources/NotConnectedIcon.png
  37. BIN Resources/SNESControllerViewController.nib
  38. +518 −0 Resources/SNESControllerViewController.xib
  39. BIN Resources/SessionController.nib
  40. +618 −0 Resources/SessionController.xib
  41. +461 −0 Resources/TabController.xib
  42. BIN Resources/grayButton.png
  43. BIN Resources/redButton.png
  44. BIN Resources/snes-1.png
  45. +23 −0 Resources/snes-1.txt
  46. +131 −0 libkern/OSTypes.h
  47. +17 −0 main.m
  48. +9 −0 package-control.txt
@@ -0,0 +1,41 @@
+//
+// SNESControllerAppDelegate.h
+// SNESController
+//
+// Created by Yusef Napora on 5/5/10.
+// Copyright __MyCompanyName__ 2010. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <GameKit/GameKit.h>
+
+#ifdef TARGET_OS_IPHONE
+
+#import <AVFoundation/AVFoundation.h>
+#import <MediaPlayer/MediaPlayer.h>
+#import <IOKit/hid/IOHIDEventSystem.h>
+
+#endif
+
+@class SNESControllerViewController;
+@class SessionController;
+
+@interface SNESControllerAppDelegate : NSObject <UIApplicationDelegate, GKSessionDelegate> {
+ UIWindow *window;
+ SNESControllerViewController *viewController;
+ SessionController *sessionController;
+
+#ifdef TARGET_OS_IPHONE
+ MPVolumeView *volumeView;
+ IOHIDEventSystemRef ioEventSystem;
+#endif
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet SNESControllerViewController *viewController;
+@property (nonatomic, retain) SessionController *sessionController;
+
+
+@end
+
+extern SNESControllerAppDelegate *AppDelegate();
@@ -0,0 +1,120 @@
+//
+// SNESControllerAppDelegate.m
+// SNESController
+//
+// Created by Yusef Napora on 5/5/10.
+// Copyright __MyCompanyName__ 2010. All rights reserved.
+//
+
+#import "SNESControllerAppDelegate.h"
+#import "SNESControllerViewController.h"
+#import "SessionController.h"
+
+#define SNES_CONTROLLER_SESSION_ID @"com.snes4iphone.controller"
+
+SNESControllerAppDelegate *AppDelegate()
+{
+ return (SNESControllerAppDelegate *)[[UIApplication sharedApplication] delegate];
+}
+
+#ifdef TARGET_OS_IPHONE
+
+extern unsigned long gp2x_pad_status;
+
+#define VOL_BUTTON_UP 0xe9
+#define VOL_BUTTON_DOWN 0xea
+
+#define L_BUTTON (1<<10)
+#define R_BUTTON (1<<11)
+
+void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) {
+ // handle the events here.
+ //NSLog(@"Received event of type %2d from service %p.", IOHIDEventGetType(event), service);
+ IOHIDEventType type = IOHIDEventGetType(event);
+ if (type == kIOHIDEventTypeKeyboard)
+ {
+ NSLog(@"button event");
+
+ int usagePage = IOHIDEventGetIntegerValue(event, kIOHIDEventFieldKeyboardUsagePage);
+ if (usagePage == 12) {
+ int usage = IOHIDEventGetIntegerValue(event, kIOHIDEventFieldKeyboardUsage);
+ int down = IOHIDEventGetIntegerValue(event, kIOHIDEventFieldKeyboardDown);
+
+ unsigned long buttonMask = 0;
+ if (usage == VOL_BUTTON_UP) {
+ buttonMask = R_BUTTON;
+ } else if (usage == VOL_BUTTON_DOWN) {
+ buttonMask = L_BUTTON;
+ }
+
+ if (buttonMask != 0) {
+ if (down) {
+ gp2x_pad_status |= buttonMask;
+ } else {
+ gp2x_pad_status &= ~buttonMask;
+ }
+ [AppDelegate().sessionController sendPadStatus:gp2x_pad_status];
+ }
+ }
+ }
+}
+
+#endif // TARGET_IPHONE_SIMULATOR
+
+
+@implementation SNESControllerAppDelegate
+
+@synthesize window;
+@synthesize viewController;
+@synthesize sessionController;
+
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+
+#ifdef TARGET_OS_IPHONE
+ NSLog(@"Setting up event handler");
+ // register our event handler callback
+ ioEventSystem = IOHIDEventSystemCreate(NULL);
+ IOHIDEventSystemOpen(ioEventSystem, handle_event, NULL, NULL, NULL);
+
+ // set the audio session category and activate it
+ AVAudioSession *session = [AVAudioSession sharedInstance];
+ [session setCategory:AVAudioSessionCategoryAmbient error:nil];
+ [session setActive:YES error:nil];
+
+ // create a hidden MPVolumeView and add it to our window.
+ // this disables the standard volume overlay display
+ volumeView = [[MPVolumeView alloc] initWithFrame:window.bounds];
+ volumeView.hidden = YES;
+ [window addSubview:volumeView];
+
+#endif
+
+ sessionController = [[SessionController alloc] initWithNibName:@"SessionController" bundle:nil];
+
+
+ [window addSubview:viewController.view];
+ [window makeKeyAndVisible];
+
+
+ return YES;
+}
+
+#ifdef TARGET_OS_IPHONE
+- (void) applicationWillTerminate:(UIApplication *)application
+{
+ // clean up our event handler
+ IOHIDEventSystemClose(ioEventSystem, NULL);
+ CFRelease(ioEventSystem);
+}
+#endif
+
+- (void)dealloc {
+ [viewController release];
+ [window release];
+ [super dealloc];
+}
+
+
+
+@end
@@ -0,0 +1,58 @@
+//
+// SNESControllerViewController.h
+// SNESController
+//
+// Created by Yusef Napora on 5/5/10.
+// Copyright __MyCompanyName__ 2010. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface SNESControllerViewController : UIViewController <UIAlertViewDelegate> {
+ UIImageView *imageView;
+ UIButton *infoButton;
+ UIButton *connectionButton;
+
+ CGRect A;
+ CGRect B;
+ CGRect AB;
+ CGRect Up;
+ CGRect Left;
+ CGRect Down;
+ CGRect Right;
+ CGRect UpLeft;
+ CGRect DownLeft;
+ CGRect UpRight;
+ CGRect DownRight;
+ CGRect Select;
+ CGRect Start;
+ CGRect LPad;
+ CGRect RPad;
+ CGRect LPad2;
+ CGRect RPad2;
+ CGRect Menu;
+ CGRect ButtonUp;
+ CGRect ButtonLeft;
+ CGRect ButtonDown;
+ CGRect ButtonRight;
+ CGRect ButtonUpLeft;
+ CGRect ButtonDownLeft;
+ CGRect ButtonUpRight;
+ CGRect ButtonDownRight;
+
+
+}
+
+@property (nonatomic, retain) IBOutlet UIImageView *imageView;
+@property (nonatomic, retain) IBOutlet UIButton *infoButton;
+@property (nonatomic, retain) IBOutlet UIButton *connectionButton;
+
+- (IBAction) buttonPressed:(id)sender;
+- (void) getControllerCoords;
+- (void) updateConnectionStatus;
+- (void) showDisconnectionAlert;
+
+
+@end
+
Oops, something went wrong.

0 comments on commit f4f17b9

Please sign in to comment.