Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 144 lines (131 sloc) 3.811 kB
e5c326f @tomcool420 first commit
authored
1 //
2 // SMFEventConfiguration.m
3 // SMFramework
4 //
5 // Created by Thomas Cool on 11/4/10.
6 // Copyright 2010 tomcool.org. All rights reserved.
7 //
8
9 #import "SMFEventConfiguration.h"
10
11 #import "SMFMenuItem.h"
12
13 @implementation SMFEventConfiguration
14 -(id)init
15 {
16 self=[super init];
17 _listeners=[[[SMFEventManager sharedManager] listeners] retain];
18 [self setListTitle:@"Event Manager"];
19 for(id<SMFEventDelegate> l in _listeners)
20 {
21 SMFMenuItem *it = [SMFMenuItem folderMenuItem];
22 [it setTitle:[l displayName]];
23 [_items addObject:it];
24 [_options addObject:l];
25 }
26 return self;
27 }
28 -(void)itemSelected:(long)row
29 {
30 SMFListenerConfiguration *l = [[SMFListenerConfiguration alloc] initForListener:[_options objectAtIndex:row]];
31 [[self stack] pushController:l];
32 [l release];
33 }
34 @end
35
36 @implementation SMFListenerConfiguration
37
38 -(id)initForListener:(id<SMFEventDelegate>)l
39 {
40 self=[super init];
41 [self setListTitle:[l displayName]];
42 listener=l;
43 _events=[[SMFEventManager sharedManager] eventsForListener:listener];
44 for(NSString *e in _events)
45 {
46 SMFMenuItem *it = [SMFMenuItem folderMenuItem];
47 [it setTitle:e];
48 [_items addObject:it];
49 [_options addObject:e];
50 }
51 return self;
52
53 }
54 -(void)itemSelected:(long)selected
55 {
56 SMFKeySelectMenu *k = [[SMFKeySelectMenu alloc] init];
57 [k setPrimaryText:[_options objectAtIndex:selected]];
58 [k setEvent:[_options objectAtIndex:selected]];
59 [k setSecondaryText:@"Please press a key"];
857c109 @tomcool420 xcodebuild fixes
authored
60 [[self stack] pushController:[k autorelease]];
e5c326f @tomcool420 first commit
authored
61 }
62 @end
63 @implementation SMFKeySelectMenu
64 -(void)setEvent:(NSString *)event
65 {
66 _event=[event retain];
67 }
68 -(id)init
69 {
70 self=[super init];
71 currentAction=0;
72 return self;
73 }
74 -(void)wasPushed
75 {
76 NSLog(@"was Pushed");
77 [[SMFEventManager sharedManager]startLearning];
78 }
79 -(void)wasPopped
80 {
81 NSLog(@"was Popped");
82 [[SMFEventManager sharedManager]stopLearning];
83 }
84 -(BOOL)brEventAction:(BREvent *)action
85 {
86 int c=[action remoteAction];
87
88 NSString *str=nil;
89 if (action.value==0x01) {
90 if (c==47)
91 {
92 str=[[action eventDictionary] objectForKey:@"kBRKeyEventCharactersKey"];
93 if (str!=nil)
94 {
95 if (_currentKey!=nil && [_currentKey isEqualToString:str] && currentAction==47) {
96 //register key here
97 if (_event!=nil) {
98 NSLog(@"event: %@",_event);
99 [[SMFEventManager sharedManager]setKey:str forName:_event];
100
101 }
102 NSLog(@"final key = %@",str);
103 [[self stack]popController];
104 }
105 else {
106 [_currentKey release];
107 _currentKey=nil;
108 currentAction=47;
109 _currentKey=[str retain];
110 [self setSecondaryText:@"Please press same key again"];
111 }
112
113 }
114 else
115 {
116 [_currentKey release];
117 _currentKey=nil;
118 currentAction=0;
119 }
120 }
121 else {
122 if (currentAction==c) {
123 if (_event!=nil) {
124 NSLog(@"event: %@",_event);
125 [[SMFEventManager sharedManager] setRemoteAction:c forName:_event];
126 }
127 NSLog(@"final remoteAction: %d",c);
128 [[self stack] popController];
129 }
130 else
131 {
132 currentAction=c;
133 [self setSecondaryText:@"Please press same key again"];
134 }
135
136 }
137
138 }
139
140
141 NSLog(@"Action Pressed: %d",[action remoteAction]);
142 return NO;
143 }
144 @end
Something went wrong with that request. Please try again.