Commit 997c5859 authored by Felix Paul Kühne's avatar Felix Paul Kühne

* various improvements to our Apple Remote bindings by the original author of...

* various improvements to our Apple Remote bindings by the original author of the inofficial API, Martin Kahr (martin at his surname.com)
parent 27bf3d0c
...@@ -285,6 +285,7 @@ struct intf_sys_t ...@@ -285,6 +285,7 @@ struct intf_sys_t
int i_lastShownVolume; int i_lastShownVolume;
AppleRemote * o_remote; 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; + (VLCMain *)sharedInstance;
......
...@@ -707,6 +707,28 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -707,6 +707,28 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_remote stopListening: self]; [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 */ /* Apple Remote callback */
- (void)appleRemoteButton:(AppleRemoteEventIdentifier)buttonIdentifier - (void)appleRemoteButton:(AppleRemoteEventIdentifier)buttonIdentifier
pressedDown:(BOOL)pressedDown pressedDown:(BOOL)pressedDown
...@@ -717,10 +739,19 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -717,10 +739,19 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_controls play: self]; [o_controls play: self];
break; break;
case kRemoteButtonVolume_Plus: case kRemoteButtonVolume_Plus:
/* 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]; [o_controls volumeUp: self];
}
break; break;
case kRemoteButtonVolume_Minus: case kRemoteButtonVolume_Minus:
/* 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]; [o_controls volumeDown: self];
}
break; break;
case kRemoteButtonRight: case kRemoteButtonRight:
[o_controls next: self]; [o_controls next: self];
...@@ -729,15 +760,18 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -729,15 +760,18 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_controls prev: self]; [o_controls prev: self];
break; break;
case kRemoteButtonRight_Hold: case kRemoteButtonRight_Hold:
[o_controls forward: self];
break;
case kRemoteButtonLeft_Hold: 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; break;
case kRemoteButtonMenu: case kRemoteButtonMenu:
[o_controls windowAction: self]; [o_controls windowAction: self];
break; break;
default: default:
/* Add here whatever you want other buttons to do */ /* Add here whatever you want other buttons to do */
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment