Skip to content

Commit 44946f8

Browse files
committed
Merge pull request #202 from RITAccess/release/v0.1.2
Release/v0.1.2 - Updated keyboard functionality, backspace on left side of keyboard. Shift is also on left and shifts when pressed with a "keystroke". Enter on right side. - Redesigned instructions menu - Impemented TTS in instructions - Added tests to Text Adventure - Bug fixes and improvements
2 parents f0bc67e + 673a35b commit 44946f8

37 files changed

+903
-868
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// ABBrailleInterpreter.h
3+
// AccessBraille
4+
//
5+
// Created by Michael Timbrook on 8/8/13.
6+
// Copyright (c) 2013 RIT. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "KeyboardResponder.h"
11+
#import "ABTypes.h"
12+
13+
// Prefix constants
14+
static NSString *const ABPrefixLevelOne = @"001111";
15+
static NSString *const ABPrefixNumber = @"001111";
16+
static NSString *const ABPrefixLevelTwo = @"000010";
17+
static NSString *const ABPrefixLevelThree = @"000111";
18+
static NSString *const ABPrefixLevelFour = @"000101";
19+
static NSString *const ABPrefixLevelFive = @"000011";
20+
static NSString *const ABPrefixLevelSix = @"000001";
21+
static NSString *const ABPrefixLevelSeven = @"000110";
22+
23+
@interface ABBrailleInterpreter : NSObject
24+
25+
/* The array of letters that build a word */
26+
@property NSMutableArray *wordGraph;
27+
28+
/* Responder for class */
29+
@property (retain, nonatomic) id<KeyboardResponder> responder;
30+
31+
/* Grade */
32+
@property ABGrade grade;
33+
34+
/**
35+
* Process the braille string recieved from the braille typer and passes the
36+
* found character to the keyboard responder, default shift is NO
37+
*/
38+
- (void)processBrailleString:(NSString *)braille;
39+
- (void)processBrailleString:(NSString *)braille isShift:(BOOL)shift;
40+
41+
/**
42+
* Resets the state of the Interpreter
43+
*/
44+
- (void)reset;
45+
46+
/**
47+
* Removes one off the end of the word graph
48+
*/
49+
- (void)dropEndOffGraph;
50+
51+
/**
52+
* Gets the current "Build" of the word
53+
*/
54+
- (NSString *)getCurrentWord;
55+
56+
/**
57+
* Checks if a braille string is a prefix
58+
*/
59+
+ (BOOL)isValidPrefix:(NSString *)braille;
60+
61+
@end
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
//
2+
// ABBrailleInterpreter.m
3+
// AccessBraille
4+
//
5+
// Created by Michael Timbrook on 8/8/13.
6+
// Copyright (c) 2013 RIT. All rights reserved.
7+
//
8+
9+
#import "ABBrailleInterpreter.h"
10+
11+
@implementation ABBrailleInterpreter
12+
{
13+
// Look ups
14+
NSDictionary *grade2Lookup;
15+
NSDictionary *numberLookup;
16+
NSDictionary *prefixLevelTwo;
17+
NSDictionary *prefixLevelThree;
18+
NSDictionary *prefixLevelFour;
19+
NSDictionary *prefixLevelFive;
20+
NSDictionary *prefixLevelSix;
21+
NSDictionary *prefixLevelSeven;
22+
NSDictionary *shortHandlookup;
23+
}
24+
25+
- (instancetype)init
26+
{
27+
self = [super init];
28+
if (self) {
29+
// Load in dictionaries
30+
NSString *path = [[NSBundle mainBundle] bundlePath];
31+
grade2Lookup = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"grade2lookup.plist"]];
32+
numberLookup = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"numberLookup.plist"]];
33+
prefixLevelTwo = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"prefixLevelTwo.plist"]];
34+
prefixLevelThree = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"prefixLevelThree.plist"]];
35+
prefixLevelFour = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"prefixLevelFour.plist"]];
36+
prefixLevelFive = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"prefixLevelFive.plist"]];
37+
prefixLevelSix = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"prefixLevelSix.plist"]];
38+
prefixLevelSeven = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"prefixLevelSeven.plist"]];
39+
shortHandlookup = [[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingPathComponent:@"shortHandLookup.plist"]];
40+
// Init wordgraph
41+
_wordGraph = [NSMutableArray new];
42+
// Set default grade
43+
_grade = ABGradeTwo;
44+
}
45+
return self;
46+
}
47+
48+
#pragma mark Processing
49+
50+
- (void)processBrailleString:(NSString *)braille
51+
{
52+
[self processBrailleString:braille isShift:NO];
53+
}
54+
- (void)processBrailleString:(NSString *)braille isShift:(BOOL)shift
55+
{
56+
if (_grade == ABGradeOne)
57+
goto gradeLookup;
58+
59+
if ([ABBrailleInterpreter isValidPrefix:braille]) {
60+
[_wordGraph addObject:braille];
61+
return;
62+
}
63+
64+
if (_wordGraph.count == 0) {
65+
if ([[grade2Lookup allKeys] containsObject:braille]) {
66+
NSString *ch = grade2Lookup[braille];
67+
ch = shift ? ch.uppercaseString : ch.lowercaseString;
68+
[_wordGraph addObject:ch];
69+
[self passToResponder:ch];
70+
}
71+
return;
72+
}
73+
74+
if ([ABBrailleInterpreter isValidPrefix:_wordGraph.lastObject]) {
75+
NSString *ch = [self getPostfixCharacter:braille withPrefix:_wordGraph.lastObject];
76+
ch = shift ? ch.uppercaseString : ch.lowercaseString;
77+
[_wordGraph addObject:ch];
78+
[self passToResponder:ch];
79+
return;
80+
}
81+
82+
gradeLookup:
83+
84+
if ([[grade2Lookup allKeys] containsObject:braille]) {
85+
NSString *ch = grade2Lookup[braille];
86+
ch = shift ? ch.uppercaseString : ch.lowercaseString;
87+
[_wordGraph addObject:ch];
88+
if (_grade == ABGradeOne && ch.length == 1) {
89+
[self passToResponder:ch];
90+
} else {
91+
[self passToResponder:ch];
92+
}
93+
}
94+
95+
}
96+
97+
- (NSString *)getPostfixCharacter:(NSString *)brailleString withPrefix:(NSString *)prefix
98+
{
99+
NSString *postfixChar = @"";
100+
if ([prefix isEqualToString:ABPrefixNumber] && [[numberLookup allKeys] containsObject:brailleString]) {
101+
postfixChar = numberLookup[brailleString];
102+
} else if ([prefix isEqualToString:ABPrefixLevelTwo] && [[prefixLevelTwo allKeys] containsObject:brailleString]) {
103+
postfixChar = prefixLevelTwo[brailleString];
104+
} else if ([prefix isEqualToString:ABPrefixLevelThree] && [[prefixLevelThree allKeys] containsObject:brailleString]) {
105+
postfixChar = prefixLevelThree[brailleString];
106+
} else if ([prefix isEqualToString:ABPrefixLevelFour] && [[prefixLevelFour allKeys] containsObject:brailleString]) {
107+
postfixChar = prefixLevelFour[brailleString];
108+
} else if ([prefix isEqualToString:ABPrefixLevelFive] && [[prefixLevelFive allKeys] containsObject:brailleString]) {
109+
postfixChar = prefixLevelFive[brailleString];
110+
} else if ([prefix isEqualToString:ABPrefixLevelSix] && [[prefixLevelSix allKeys] containsObject:brailleString]) {
111+
postfixChar = prefixLevelSix[brailleString];
112+
} else if ([prefix isEqualToString:ABPrefixLevelSeven] && [[prefixLevelSeven allKeys] containsObject:brailleString]) {
113+
postfixChar = prefixLevelSeven[brailleString];
114+
}
115+
return postfixChar;
116+
}
117+
118+
- (void)passToResponder:(NSString *)character
119+
{
120+
if ([_responder respondsToSelector:@selector(newCharacterFromInterpreter:)]) {
121+
[_responder newCharacterFromInterpreter:character];
122+
}
123+
}
124+
125+
- (void)reset
126+
{
127+
[_wordGraph removeAllObjects];
128+
}
129+
130+
- (void)dropEndOffGraph
131+
{
132+
if (_wordGraph.count > 0) {
133+
[_wordGraph removeLastObject];
134+
}
135+
}
136+
137+
- (NSString *)getCurrentWord;
138+
{
139+
NSString *word = @"";
140+
for (NSString *str in _wordGraph) {
141+
if (![ABBrailleInterpreter isValidPrefix:str]) {
142+
word = [word stringByAppendingString:str];
143+
}
144+
}
145+
return word;
146+
}
147+
148+
#pragma mark Helpers
149+
150+
/**
151+
* Checks if a braille string is a prefix
152+
*/
153+
+ (BOOL)isValidPrefix:(NSString *)braille
154+
{
155+
return ([braille isEqualToString:ABPrefixLevelOne] ||
156+
[braille isEqualToString:ABPrefixLevelTwo] ||
157+
[braille isEqualToString:ABPrefixLevelThree] ||
158+
[braille isEqualToString:ABPrefixLevelFour] ||
159+
[braille isEqualToString:ABPrefixLevelFive] ||
160+
[braille isEqualToString:ABPrefixLevelSix] ||
161+
[braille isEqualToString:ABPrefixLevelSeven]);
162+
}
163+
164+
@end

AccessBraille/ABKeyboard/ABBrailleReader.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)