Skip to content

Commit

Permalink
Merge branch '1.04.b' into defender
Browse files Browse the repository at this point in the history
  • Loading branch information
emufreak committed Aug 16, 2014
2 parents 97561ca + cbf7069 commit 9ab3137
Show file tree
Hide file tree
Showing 39 changed files with 865 additions and 1,591 deletions.
2 changes: 1 addition & 1 deletion LatestBuild
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 4 additions & 15 deletions OtherSources/CustomIOSKeyboard/iPad/PKCustomKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,13 @@

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "SDL.h"

@interface PKCustomKeyboard : UIView <UIInputViewAudioFeedback>
@interface PKCustomKeyboard : UIViewController <UIInputViewAudioFeedback>

@property (strong, nonatomic) IBOutlet UIImageView *keyboardBackground;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *characterKeys;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *altButtons;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *shiftButtons;
@property (strong, nonatomic) IBOutlet UIButton *returnButton;
@property (strong, nonatomic) IBOutlet UIButton *deleteButton;
@property (strong, nonatomic) IBOutlet UIButton *dismissButton;
@property (strong) id<UITextInput> textView;

- (IBAction)returnPressed:(id)sender;
- (IBAction)shiftPressed:(id)sender;
- (IBAction)altPressed:(id)sender;
- (IBAction)dismissPressed:(id)sender;
- (IBAction)deletePressed:(id)sender;
- (IBAction)characterPressed:(id)sender;
- (IBAction)unShift;
- (IBAction)keyDown:(id)sender;
- (IBAction)keyUp:(id)sender;

@end
300 changes: 108 additions & 192 deletions OtherSources/CustomIOSKeyboard/iPad/PKCustomKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,79 +14,80 @@ @interface PKCustomKeyboard ()

@end

@implementation PKCustomKeyboard
@synthesize textView = _textView;

#define kFont [UIFont fontWithName:@"GurmukhiMN" size:25]
#define kAltLabel @"!?੧੨੩"
#define kReturnLabel @"ਅਗਲਾ"
#define kChar @[ @"◌ੌ", @"◌ੈ", @"◌ਾ", @"◌ੀ", @"◌ੂ", @"", @"", @"", @"", @"", @"", @"◌ੋ", @"◌ੇ", @"◌੍", @"ਿ◌", @"◌ੁ", @"", @"", @"", @"", @"", @"", @"◌ਂ", @"", @"", @"", @"", @"", @"", @"", @",", @".", @" " ]
#define kChar_shift @[ @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"◌ੰ", @"◌ੱ", @"", @"", @"", @"", @"", @"", @"", @"", @" " ]
#define kChar_alt @[ @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"-", @"/", @":", @";", @"(", @")", @"$", @"£", @"", @"&", @"@", @"", @"", @"", @"", @".", @",", @"?", @"!", @"\'", @"\"", @" " ]

- (id)init {
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
CGRect frame;
@implementation PKCustomKeyboard {
IBOutlet UIButton *bDown;
IBOutlet UIButton *bUp;
IBOutlet UIButton *bLeft;
IBOutlet UIButton *bRight;
IBOutlet UIButton *b0;
IBOutlet UIButton *b1;
IBOutlet UIButton *b2;
IBOutlet UIButton *b3;
IBOutlet UIButton *b4;
IBOutlet UIButton *b5;
IBOutlet UIButton *b6;
IBOutlet UIButton *b7;
IBOutlet UIButton *b8;
IBOutlet UIButton *b9;
IBOutlet UIButton *bBracketleft;
IBOutlet UIButton *bBracketright;
IBOutlet UIButton *bDivide;
IBOutlet UIButton *bMultiply;
IBOutlet UIButton *bMinus;
IBOutlet UIButton *bPlus;
IBOutlet UIButton *bShiftfleft;
IBOutlet UIButton *bShiftright;
IBOutlet UIButton *bAltLeft;
IBOutlet UIButton *bAltRight;
IBOutlet UIButton *bCtrl;
IBOutlet UIButton *bEnter;
IBOutlet UIButton *bAright;
IBOutlet UIButton *bAleft;
IBOutlet UIButton *bPeriod;
IBOutlet UIButton *bSpace;
}

if(UIDeviceOrientationIsLandscape(orientation))
frame = CGRectMake(0, 0, 1024, 352);
else
frame = CGRectMake(0, 0, 768, 264);

self = [super initWithFrame:frame];

if (self) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PKCustomKeyboard" owner:self options:nil];
[[nib objectAtIndex:0] setFrame:frame];
self = [nib objectAtIndex:0];
}

NSMutableArray *buttons = [NSMutableArray arrayWithArray:self.characterKeys];
[buttons addObjectsFromArray:self.altButtons];
[buttons addObject:self.returnButton];
[buttons addObject:self.dismissButton];
[buttons addObject:self.deleteButton];
@synthesize textView = _textView;


for (UIButton *b in buttons) {
[b setBackgroundImage:[PKCustomKeyboard imageFromColor:[UIColor colorWithWhite:0.5 alpha:0.5]]
forState:UIControlStateHighlighted];
b.layer.cornerRadius = 7.0;
b.layer.masksToBounds = YES;
b.layer.borderWidth = 0;
}

for (UIButton *b in self.altButtons)
[b setTitle:kAltLabel forState:UIControlStateNormal];

[self.returnButton setTitle:kReturnLabel forState:UIControlStateNormal];
self.returnButton.titleLabel.adjustsFontSizeToFitWidth = YES;

[self loadCharactersWithArray:kChar];

// Keyboard Customization for iOS 7
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Blank_iOS7.png"]];
for (UIButton *b in self.shiftButtons) {
[b setShowsTouchWhenHighlighted:NO];
}
for (UIButton *b in buttons) {
[b setBackgroundImage:[PKCustomKeyboard imageFromColor:[UIColor colorWithWhite:0.7 alpha:0.5]]
forState:UIControlStateHighlighted];
b.layer.cornerRadius = 6.0;
b.titleLabel.shadowOffset = CGSizeMake(0, 0);
}
}

return self;
-(void)viewDidLoad {
bLeft.tag = SDLK_LEFT;
bRight.tag = SDLK_RIGHT;
bDown.tag = SDLK_DOWN;
bUp.tag = SDLK_UP;
b0.tag = SDLK_KP0;
b1.tag = SDLK_KP1;
b2.tag = SDLK_KP2;
b3.tag = SDLK_KP3;
b4.tag = SDLK_KP4;
b5.tag = SDLK_KP5;
b6.tag = SDLK_KP6;
b7.tag = SDLK_KP7;
b8.tag = SDLK_KP8;
b9.tag = SDLK_KP9;
bBracketleft.tag = SDLK_HOME; //Pseudo Maping SDL Library doesn't know Key with Bracket on Number Block. But Amiga does not have Home Key
bBracketright.tag = SDLK_END; //Pseudo Maping SDL Library doesn't know Key with Bracket on Number Block. But Amiga does not have END Key
bDivide.tag = SDLK_KP_DIVIDE;
bMultiply.tag = SDLK_KP_MULTIPLY;
bMinus.tag = SDLK_KP_MINUS;
bPlus.tag = SDLK_KP_PLUS;
bShiftfleft.tag = SDLK_LSHIFT;
bShiftright.tag = SDLK_RSHIFT;
bAltLeft.tag = SDLK_LALT;
bAltRight.tag = SDLK_RALT;
bCtrl.tag = SDLK_LCTRL;
bEnter.tag = SDLK_KP_ENTER;
bAright.tag = SDLK_RMETA; //Pseudo Maping SDL Library doesn't know Amiga Left. But Amiga does not have RMETA Key
bAleft.tag = SDLK_LMETA; //Pseudo Maping SDL Library doesn't know Key Amiga Right. But Amiga does not have LMETA Key
bPeriod.tag = SDLK_KP_PERIOD;
bSpace.tag = SDLK_SPACE;
}

-(void)setTextView:(id<UITextInput>)textView {

if ([textView isKindOfClass:[UITextView class]])
[(UITextView *)textView setInputView:self];
[(UITextView *)textView setInputView:self.view];
else if ([textView isKindOfClass:[UITextField class]])
[(UITextField *)textView setInputView:self];
[(UITextField *)textView setInputView:self.view];

_textView = textView;
}
Expand All @@ -95,141 +96,56 @@ -(void)setTextView:(id<UITextInput>)textView {
return _textView;
}

-(void)loadCharactersWithArray:(NSArray *)a {
int i = 0;
for (UIButton *b in self.characterKeys) {
[b setTitle:[a objectAtIndex:i] forState:UIControlStateNormal];
if ([b.titleLabel.text characterAtIndex:0] < 128 && ![[b.titleLabel.text substringToIndex:1] isEqualToString:@""])
[b.titleLabel setFont:[UIFont systemFontOfSize:28]];
else
[b.titleLabel setFont:kFont];
i++;
}
}

- (BOOL) enableInputClicksWhenVisible {
return YES;
}

/* IBActions for Keyboard Buttons */

- (IBAction)returnPressed:(id)sender {
[[UIDevice currentDevice] playInputClick];
[self.textView insertText:@"\n"];
if ([self.textView isKindOfClass:[UITextView class]])
[[NSNotificationCenter defaultCenter] postNotificationName:UITextViewTextDidChangeNotification object:self.textView];
else if ([self.textView isKindOfClass:[UITextField class]])
[[NSNotificationCenter defaultCenter] postNotificationName:UITextFieldTextDidChangeNotification object:self.textView];
}

- (IBAction)shiftPressed:(id)sender {
[[UIDevice currentDevice] playInputClick];
if (!self.isShifted) {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Shift_iOS7.png"]];
}
else {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Shift.png"]];
}
[self loadCharactersWithArray:kChar_shift];
for (UIButton *b in self.altButtons)
[b setTitle:kAltLabel forState:UIControlStateNormal];
}
}

- (IBAction)unShift {
if (self.isShifted) {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Blank_iOS7.png"]];
}
else {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Blank.png"]];
}
[self loadCharactersWithArray:kChar];
}
if (!self.isShifted)
self.shifted = YES;
else
self.shifted = NO;
}

- (IBAction)altPressed:(id)sender {
- (IBAction)keyDown:(id)sender {
[[UIDevice currentDevice] playInputClick];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Blank_iOS7.png"]];
}
else {
[self.keyboardBackground setImage:[UIImage imageNamed:@"Keyboard_Blank.png"]];
}
self.shifted = NO;
UIButton *button = (UIButton *)sender;

if ([button.titleLabel.text isEqualToString:kAltLabel]) {
[self loadCharactersWithArray:kChar_alt];
for (UIButton *b in self.altButtons)
[b setTitle:[kChar objectAtIndex:18] forState:UIControlStateNormal];
}
else {
[self loadCharactersWithArray:kChar];
for (UIButton *b in self.altButtons)
[b setTitle:kAltLabel forState:UIControlStateNormal];
}
}

- (IBAction)dismissPressed:(id)sender {
[[UIDevice currentDevice] playInputClick];

if ([self.textView isKindOfClass:[UITextView class]])
[(UITextView *)self.textView resignFirstResponder];

else if ([self.textView isKindOfClass:[UITextField class]])
[(UITextField *)self.textView resignFirstResponder];
}

- (IBAction)deletePressed:(id)sender {
[[UIDevice currentDevice] playInputClick];
[self.textView deleteBackward];
[[NSNotificationCenter defaultCenter] postNotificationName:UITextViewTextDidChangeNotification
object:self.textView];
if ([self.textView isKindOfClass:[UITextView class]])
[[NSNotificationCenter defaultCenter] postNotificationName:UITextViewTextDidChangeNotification object:self.textView];
else if ([self.textView isKindOfClass:[UITextField class]])
[[NSNotificationCenter defaultCenter] postNotificationName:UITextFieldTextDidChangeNotification object:self.textView];


NSString *character = [NSString stringWithFormat:@"D%d", button.tag];
[self.textView insertText:character];
}

- (IBAction)characterPressed:(id)sender {
- (IBAction)keyUp:(id)sender {
[[UIDevice currentDevice] playInputClick];
UIButton *button = (UIButton *)sender;
NSString *character = [NSString stringWithString:button.titleLabel.text];

if ([[character substringToIndex:1] isEqualToString:@""])
character = [character substringFromIndex:1];

else if ([[character substringFromIndex:character.length - 1] isEqualToString:@""])
character = [character substringToIndex:character.length - 1];

[self.textView insertText:character];

if (self.isShifted)
[self unShift];

if ([self.textView isKindOfClass:[UITextView class]])
[[NSNotificationCenter defaultCenter] postNotificationName:UITextViewTextDidChangeNotification object:self.textView];
else if ([self.textView isKindOfClass:[UITextField class]])
[[NSNotificationCenter defaultCenter] postNotificationName:UITextFieldTextDidChangeNotification object:self.textView];


NSString *character = [NSString stringWithFormat:@"U%d", button.tag];
[self.textView insertText:character];
}

/* UI Utilities */

+ (UIImage *) imageFromColor:(UIColor *)color {
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
- (void) dealloc {
[super dealloc];

[bDown dealloc];
[bUp dealloc];
[bLeft dealloc];
[bRight dealloc];
[b0 dealloc];
[b1 dealloc];
[b2 dealloc];
[b3 dealloc];
[b4 dealloc];
[b5 dealloc];
[b6 dealloc];
[b7 dealloc];
[b8 dealloc];
[b9 dealloc];
[bBracketleft dealloc];
[bBracketright dealloc];
[bDivide dealloc];
[bMultiply dealloc];
[bMinus dealloc];
[bPlus dealloc];
[bShiftfleft dealloc];
[bShiftright dealloc];
[bAltLeft dealloc];
[bAltRight dealloc];
[bCtrl dealloc];
[bSpace dealloc];
[bAright dealloc];
[bAleft dealloc];
[bEnter dealloc];
}

@end
Loading

0 comments on commit 9ab3137

Please sign in to comment.