Skip to content

Commit

Permalink
Disable caps lock mapping on iOS 13
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Feb 18, 2020
1 parent ba78d23 commit efc4876
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
26 changes: 26 additions & 0 deletions app/AboutExternalKeyboardViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,30 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0 && ![self.class capsLockMappingSupported])
return 0;
return [super tableView:tableView numberOfRowsInSection:section];
}

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
if (section == 0 && ![self.class capsLockMappingSupported])
return @"Caps Lock mapping is broken in iOS 13.\n\n"
@"Since iOS 13.4, Caps Lock can be remapped in Settings → General → Keyboard → Hardware Keyboard → Modifier Keys.";
return [super tableView:tableView titleForFooterInSection:section];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0 && ![self.class capsLockMappingSupported])
return @"";
return [super tableView:tableView titleForHeaderInSection:section];
}

+ (BOOL)capsLockMappingSupported {
if (@available(iOS 13, *)) {
return NO;
}
return YES;
}

@end
10 changes: 6 additions & 4 deletions app/TerminalView.m
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,12 @@ - (void)handleKeyCommand:(UIKeyCommand *)command {
[self addKey:specialKey withModifiers:0];
}
if (UserPreferences.shared.capsLockMapping != CapsLockMapNone) {
[self addKeys:controlKeys withModifiers:UIKeyModifierAlphaShift];
[self addKeys:alphabet withModifiers:0];
[self addKeys:alphabet withModifiers:UIKeyModifierShift];
[self addKey:@"" withModifiers:UIKeyModifierAlphaShift]; // otherwise tap of caps lock can switch layouts
if (@available(iOS 13, *)); else {
[self addKeys:controlKeys withModifiers:UIKeyModifierAlphaShift];
[self addKeys:alphabet withModifiers:0];
[self addKeys:alphabet withModifiers:UIKeyModifierShift];
[self addKey:@"" withModifiers:UIKeyModifierAlphaShift]; // otherwise tap of caps lock can switch layouts
}
}
if (UserPreferences.shared.optionMapping == OptionMapEsc) {
[self addKeys:metaKeys withModifiers:UIKeyModifierAlternate];
Expand Down

0 comments on commit efc4876

Please sign in to comment.