Binary files AppleRemoteSource_R80.orig/.DS_Store and AppleRemoteSource_R80/.DS_Store differ Common subdirectories: AppleRemoteSource_R80.orig/AppleRemote.xcodeproj and AppleRemoteSource_R80/AppleRemote.xcodeproj Common subdirectories: AppleRemoteSource_R80.orig/English.lproj and AppleRemoteSource_R80/English.lproj Common subdirectories: AppleRemoteSource_R80.orig/Japanese.lproj and AppleRemoteSource_R80/Japanese.lproj diff -Nu AppleRemoteSource_R80.orig/MPlayerNetworkController.h AppleRemoteSource_R80/MPlayerNetworkController.h --- AppleRemoteSource_R80.orig/MPlayerNetworkController.h 1970-01-01 01:00:00.000000000 +0100 +++ AppleRemoteSource_R80/MPlayerNetworkController.h 2007-02-08 10:21:30.000000000 +0000 @@ -0,0 +1,22 @@ +// +// MPlayerNetworkController.h +// AppleRemote +// +// Created by Alastair on 08/02/2007. +// Copyright 2007 liquidx.net. All rights reserved. +// + +#import + + +@interface MPlayerNetworkController : NSObject { + NSString *address; + short port; +} + +- (void) volumeUp; +- (void) volumeDown; +- (void) channelLeft; +- (void) channelRight; + +@end diff -Nu AppleRemoteSource_R80.orig/MPlayerNetworkController.m AppleRemoteSource_R80/MPlayerNetworkController.m --- AppleRemoteSource_R80.orig/MPlayerNetworkController.m 1970-01-01 01:00:00.000000000 +0100 +++ AppleRemoteSource_R80/MPlayerNetworkController.m 2007-02-11 17:21:40.000000000 +0000 @@ -0,0 +1,92 @@ +// +// MPlayerNetworkController.m +// AppleRemote +// +// Created by Alastair on 08/02/2007. +// Copyright 2007 liquidx.net. All rights reserved. +// + +#import "MPlayerNetworkController.h" +#include +#include +#include +#include + + +@implementation MPlayerNetworkController + +- (id)init +{ + self = [super init]; + if (self != nil) { + address = [@"qoo.local" retain]; + port = 8070; + } + return self; +} + +- (void) dealloc +{ + [address release]; + [super dealloc]; +} + +- (int) sendMessage:(NSString *)message +{ + int remoteSocket; + int bytes; + struct sockaddr_in socketAddress; + struct hostent *server; + + if ((remoteSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + NSLog(@"Socket creation failed."); + return -1; + } + + memset(&socketAddress, 0, sizeof(socketAddress)); + socketAddress.sin_family = AF_INET; + socketAddress.sin_port = htons(port); + + server = gethostbyname((const char *)[address cString]); + + if (server == NULL) { + NSLog(@"Unable to resolve hostname"); + return -1; + } + + memcpy((char *)&socketAddress.sin_addr.s_addr, (char *)server->h_addr, + server->h_length); + + bytes = sendto(remoteSocket, + [message cString], + [message cStringLength] + 1, + 0, + (const struct sockaddr *)&socketAddress, + sizeof(socketAddress)); + + close(remoteSocket); + return bytes; +} + +- (void) volumeUp +{ + [self sendMessage:@"run /home/teevee/mic_up\n"]; +} + +- (void) volumeDown +{ + [self sendMessage:@"run /home/teevee/mic_down\n"]; +} + +- (void) channelLeft +{ + [self sendMessage:@"tv_step_channel -1\n"]; +} + +- (void) channelRight +{ + [self sendMessage:@"tv_step_channel 1\n"]; +} + + +@end diff -Nu AppleRemoteSource_R80.orig/MainController.h AppleRemoteSource_R80/MainController.h --- AppleRemoteSource_R80.orig/MainController.h 2006-04-30 22:35:09.000000000 +0100 +++ AppleRemoteSource_R80/MainController.h 2007-02-08 10:19:24.000000000 +0000 @@ -8,10 +8,12 @@ #import #import "AppleRemote.h" +#import "MPlayerNetworkController.h" @interface MainController : NSObject { IBOutlet NSView* feedbackView; IBOutlet NSTextField* feedbackText; + MPlayerNetworkController *mplayerControl; } - (AppleRemote*) appleRemote; diff -Nu AppleRemoteSource_R80.orig/MainController.m AppleRemoteSource_R80/MainController.m --- AppleRemoteSource_R80.orig/MainController.m 2006-05-03 13:12:55.000000000 +0100 +++ AppleRemoteSource_R80/MainController.m 2007-02-08 10:37:24.000000000 +0000 @@ -14,6 +14,8 @@ - (void) awakeFromNib { [[AppleRemote sharedRemote] setDelegate: self]; + [[self appleRemote] setListeningToRemote:YES]; + mplayerControl = [[MPlayerNetworkController alloc] init]; } - (AppleRemote*) appleRemote @@ -32,22 +34,32 @@ case kRemoteButtonVolume_Plus: buttonName = @"Volume up"; if (pressedDown) pressed = @"(down)"; else pressed = @"(up)"; + + if (!pressedDown) + [mplayerControl volumeUp]; + break; case kRemoteButtonVolume_Minus: buttonName = @"Volume down"; if (pressedDown) pressed = @"(down)"; else pressed = @"(up)"; + + if (!pressedDown) + [mplayerControl volumeDown]; + break; case kRemoteButtonMenu: buttonName = @"Menu"; break; case kRemoteButtonPlay: buttonName = @"Play"; - break; + break; case kRemoteButtonRight: buttonName = @"Right"; + [mplayerControl channelRight]; break; case kRemoteButtonLeft: buttonName = @"Left"; + [mplayerControl channelLeft]; break; case kRemoteButtonRight_Hold: buttonName = @"Right holding"; Common subdirectories: AppleRemoteSource_R80.orig/build and AppleRemoteSource_R80/build