From 997c5859d2ab8e7bc613d1c8654335a92c41b0f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20Paul=20K=C3=BChne?= Date: Sat, 16 Sep 2006 15:22:22 +0000 Subject: [PATCH] * various improvements to our Apple Remote bindings by the original author of the inofficial API, Martin Kahr (martin at his surname.com) --- modules/gui/macosx/intf.h | 1 + modules/gui/macosx/intf.m | 46 ++++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index fbc8516e20..cf0e9596d8 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -285,6 +285,7 @@ struct intf_sys_t int i_lastShownVolume; AppleRemote * o_remote; + BOOL b_left_right_remote_button_hold; /* true as long as the user holds the left or right button on the remote control */ } + (VLCMain *)sharedInstance; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index f91947a33d..3a114fa686 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -707,6 +707,28 @@ static VLCMain *_o_sharedMainInstance = nil; [o_remote stopListening: self]; } +/* Helper method for the remote control interface in order to trigger forward/backward as long + as the user holds the left/right button */ +- (void) triggerMovieStepForRemoteButton: (NSNumber*) buttonIdentifierNumber +{ + if (b_left_right_remote_button_hold) { + switch([buttonIdentifierNumber intValue]) { + case kRemoteButtonRight_Hold: + [o_controls forward: self]; + break; + case kRemoteButtonLeft_Hold: + [o_controls backward: self]; + break; + } + if (b_left_right_remote_button_hold) { + /* trigger event */ + [self performSelector:@selector(triggerMovieStepForRemoteButton:) + withObject:buttonIdentifierNumber + afterDelay:0.25]; + } + } +} + /* Apple Remote callback */ - (void)appleRemoteButton:(AppleRemoteEventIdentifier)buttonIdentifier pressedDown:(BOOL)pressedDown @@ -717,10 +739,19 @@ static VLCMain *_o_sharedMainInstance = nil; [o_controls play: self]; break; case kRemoteButtonVolume_Plus: - [o_controls volumeUp: self]; + /* there are two events when the plus or minus button is pressed + one when the button is pressed down and one when the button is released */ + if (pressedDown) + { + [o_controls volumeUp: self]; + } break; case kRemoteButtonVolume_Minus: - [o_controls volumeDown: self]; + /* there are two events when the plus or minus button is pressed + one when the button is pressed down and one when the button is released */ + if (pressedDown) { + [o_controls volumeDown: self]; + } break; case kRemoteButtonRight: [o_controls next: self]; @@ -729,15 +760,18 @@ static VLCMain *_o_sharedMainInstance = nil; [o_controls prev: self]; break; case kRemoteButtonRight_Hold: - [o_controls forward: self]; - break; case kRemoteButtonLeft_Hold: - [o_controls backward: self]; + /* simulate an event as long as the user holds the button */ + b_left_right_remote_button_hold = pressedDown; + if (pressedDown) { + NSNumber* buttonIdentifierNumber = [NSNumber numberWithInt: buttonIdentifier]; + [self performSelector:@selector(triggerMovieStepForRemoteButton:) + withObject:buttonIdentifierNumber]; + } break; case kRemoteButtonMenu: [o_controls windowAction: self]; break; - default: /* Add here whatever you want other buttons to do */ break; -- 2.39.5