-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDBTVRemoteControl.m
78 lines (70 loc) · 2.24 KB
/
DBTVRemoteControl.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// DBTVRemoteControl.m
// Vidi
//
// Created by Mitz Pettel on Wed Jan 29 2003.
// Copyright (c) 2003 Mitz Pettel. All rights reserved.
//
#import "DBTVRemoteControl.h"
#import "DBMediumWindowController.h"
#import "DBVidi.h"
@implementation DBTVRemoteControl
- (void)keyDown:(NSEvent *)event
{
NSString *chars = [event characters];
unichar keyChar = [chars characterAtIndex:0];
unsigned int modifierFlags = [event modifierFlags];
DBVidi *vidi = [controller vidi];
switch (keyChar)
{
case '\E': // escape
[NSApp sendAction:@selector(endFullScreen:) to:nil from:self];
break;
case NSEnterCharacter:
if (![vidi isRecording])
[vidi flipChannels];
break;
case NSRightArrowFunctionKey:
if (![vidi isRecording])
[vidi selectNextChannel];
break;
case NSLeftArrowFunctionKey:
if (![vidi isRecording])
[vidi selectPreviousChannel];
break;
case NSUpArrowFunctionKey:
if (modifierFlags & NSAlternateKeyMask)
[vidi setVolume:2.0];
else
[vidi setVolume:MIN(2.0, [vidi volume] + 0.125)];
break;
case NSDownArrowFunctionKey:
if (modifierFlags & NSAlternateKeyMask)
[vidi setVolume:0.0];
else
[vidi setVolume:MAX(0.0, [vidi volume] - 0.125)];
break;
default:
if (modifierFlags & NSNumericPadKeyMask) {
if (keyChar == '0')
[vidi setMuted:![vidi isMuted]];
else if (keyChar > '0' && keyChar <= '9' && ![vidi isRecording]) {
if (modifierFlags & NSShiftKeyMask)
[vidi setCallKey:keyChar-'0' forChannel:[vidi selectedChannel]];
else if ([vidi channelWithCallKey:keyChar - '0'])
[vidi selectChannel:[vidi channelWithCallKey:keyChar-'0']];
}
} else
[super keyDown:event];
break;
}
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (void)setController:(DBMediumWindowController *)newController
{
controller = newController;
}
@end