I am making use of the WiiRemote library within Xcode on a Mac (lion), I have managed to pair with the wii mote, however when I try to start the IR mode by calling , I get initial output in the debug log which looks promising and shows long output consistent with IR output (based on running the DarwiinRemote app in debug), but then after a while it stops outputting the long string and the only X and Y values I get are -100 and -100 respectively.
What am I doing wrong here?
AppDelegate.h :
//// AppDelegate.h// WiiRawmote//// Created on 02/10/2012.////#import <Cocoa/Cocoa.h>#import <WiiRemote/WiiRemote.h>#import <WiiRemote/WiiRemoteDiscovery.h>@interfaceAppDelegate : NSObject<NSApplicationDelegate>@property(assign)IBOutletNSWindow*window;@property(weak)IBOutletNSTextField*statusTextField;@property(weak)IBOutletNSTextField*xValueTextField;@property(weak)IBOutletNSTextField*yValueTextField;@property(weak)IBOutletNSTextField*zValueTextField;@property(weak)IBOutletNSProgressIndicator*discoverySpinner;@property(weak)IBOutletNSButton*discoverButton;-(IBAction)discoverWiiMotes:(id)sender;-(IBAction)setStatusWithString:(id)sender;-(IBAction)setXDisplayValueFromFloat:(id)sender;-(IBAction)setYDisplayValueFromFloat:(id)sender;-(IBAction)setZDisplayValueFromFloat:(id)sender;@endWiiRemoteDiscovery*discovery;WiiRemote*wii;BOOLspinnerAnimating;
AppDelegate.m :
//// AppDelegate.m// WiiRawmote//// Created by Kingswood on 02/10/2012.////#import "AppDelegate.h"@implementationAppDelegate@synthesizestatusTextField;@synthesizexValueTextField;@synthesizeyValueTextField;@synthesizezValueTextField;@synthesizediscoverySpinner;@synthesizediscoverButton;-(void)applicationDidFinishLaunching:(NSNotification*)aNotification{NSLog(@"applicationDidFinishLaunching");}-(void)awakeFromNib{NSLog(@"awakeFromNib");discovery=[[WiiRemoteDiscoveryalloc]init];[discoverysetDelegate:self];}-(void)dealloc{//apparently ARC is going to take care of all of this :S}-(IBAction)discoverWiiMotes:(id)sender{NSLog(@"find / give up button pressed");if(spinnerAnimating==NO){NSLog(@"starting the discovery process");[selfmakeTheSpinnerGo:YES];[discoverystart];[statusTextFieldsetStringValue:@"trying to connect..."];[discoverButtonsetTitle:@"Give up :("];}else{NSLog(@"stopping the discovery process");[selfmakeTheSpinnerGo:NO];[discoverystop];[statusTextFieldsetStringValue:@""];[statusTextFieldsetToolTip:@"not connected"];[discoverButtonsetTitle:@"Find Wiimotes"];}}-(IBAction)setStatusWithString:(id)sender{}-(IBAction)setXDisplayValueFromFloat:(id)sender{}-(IBAction)setYDisplayValueFromFloat:(id)sender{}-(IBAction)setZDisplayValueFromFloat:(id)sender{}-(void)makeTheSpinnerGo:(BOOL)setGoing{if(setGoing==YES){[discoverySpinnersetHidden:NO];[discoverySpinnerstartAnimation:self];spinnerAnimating=YES;}else{[discoverySpinnersetHidden:YES];[discoverySpinnerstopAnimation:self];spinnerAnimating=NO;}}#pragma mark -#pragma mark WiiRemoteDiscovery delegates-(void)WiiRemoteDiscoveryError:(int)code{[discoverySpinnerstopAnimation:self];NSLog([NSStringstringWithFormat:@"===== WiiRemoteDiscovery error. If clicking Find Wiimote gives this error, try System Preferences > Bluetooth > Devices, delete Nintendo. (%d) =====",code]);}-(void)willStartWiimoteConnections{NSLog(@"\n===== WiiRemote discovered. Opening connection. =====");}-(void)WiiRemoteDiscovered:(WiiRemote*)wiimote{// [discovery stop];// the wiimote must be retained because the discovery provides us with an autoreleased objectwii=wiimote;//wii = [wiimote retain];[wiimotesetDelegate:self];NSLog(@"\n===== Connected to WiiRemote =====");[discoverySpinnerstopAnimation:self];[wiimotesetLEDEnabled1:YESenabled2:NOenabled3:YESenabled4:NO];[wiimotesetMotionSensorEnabled:YES];[wiimotesetIRSensorEnabled:YES];}-(void)irPointMovedX:(float)pxY:(float)py{//NSLog([NSString stringWithFormat:@"x: %f y: %f", px, py]);[xValueTextFieldsetStringValue:[NSStringstringWithFormat:@"%f",px]];[yValueTextFieldsetStringValue:[NSStringstringWithFormat:@"%f",py]];}-(void)rawIRData:(IRData[4])irData{//[outputPanel setString:[NSString stringWithFormat:@"%@\n===== Mouse Mode On (Motion Sensors) =====", [outputPanel setSt]]];NSLog(@"rawIRData");}-(void)buttonChanged:(WiiButtonType)typeisPressed:(BOOL)isPressed{}-(void)accelerationChanged:(WiiAccelerationSensorType)typeaccX:(unsignedshort)accXaccY:(unsignedshort)accYaccZ:(unsignedshort)accZ{}-(void)joyStickChanged:(WiiJoyStickType)typetiltX:(unsignedshort)tiltXtiltY:(unsignedshort)tiltY{}-(void)analogButtonChanged:(WiiButtonType)typeamount:(unsignedshort)press{}-(void)pressureChanged:(WiiPressureSensorType)typepressureTR:(float)bPressureTRpressureBR:(float)bPressureBRpressureTL:(float)bPressureTLpressureBL:(float)bPressureBL{}-(void)batteryLevelChanged:(double)level{}-(void)wiiRemoteDisconnected:(IOBluetoothDevice*)device{}-(void)gotMiiData:(Mii*)mii_data_bufat:(int)slot{}-(void)rawPressureChanged:(WiiBalanceBoardGrid)bbData{}-(void)allPressureChanged:(WiiPressureSensorType)typebbData:(WiiBalanceBoardGrid)bbDatabbDataInKg:(WiiBalanceBoardGrid)bbDataInKg{}-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender{returnYES;}@end
Any help / pointers welcome.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am making use of the WiiRemote library within Xcode on a Mac (lion), I have managed to pair with the wii mote, however when I try to start the IR mode by calling , I get initial output in the debug log which looks promising and shows long output consistent with IR output (based on running the DarwiinRemote app in debug), but then after a while it stops outputting the long string and the only X and Y values I get are -100 and -100 respectively.
What am I doing wrong here?
AppDelegate.h :
AppDelegate.m :
Any help / pointers welcome.
Thanks