2019-04-19 16:10:13 -07:00
|
|
|
//
|
2020-01-29 20:30:05 -08:00
|
|
|
// Copyright © 2019 osy. All rights reserved.
|
2019-04-19 16:10:13 -07:00
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "VMKeyboardView.h"
|
2025-07-14 01:37:40 -07:00
|
|
|
#import "VMKeyboardMap.h"
|
2019-04-19 16:10:13 -07:00
|
|
|
|
2025-07-14 01:37:40 -07:00
|
|
|
@interface VMKeyboardView ()
|
2019-04-19 16:10:13 -07:00
|
|
|
|
2025-07-14 01:37:40 -07:00
|
|
|
@property (nullable, nonatomic) VMKeyboardMap *keyboardMap;
|
2019-04-19 16:10:13 -07:00
|
|
|
|
2025-07-14 01:37:40 -07:00
|
|
|
@end
|
2019-04-19 16:10:13 -07:00
|
|
|
|
2025-07-14 01:37:40 -07:00
|
|
|
@implementation VMKeyboardView
|
2019-04-19 16:10:13 -07:00
|
|
|
|
2020-02-28 13:58:41 -08:00
|
|
|
- (UIKeyboardType)keyboardType {
|
|
|
|
|
return UIKeyboardTypeASCIICapable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextAutocapitalizationType)autocapitalizationType {
|
|
|
|
|
return UITextAutocapitalizationTypeNone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextAutocorrectionType)autocorrectionType {
|
|
|
|
|
return UITextAutocorrectionTypeNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextSpellCheckingType)spellCheckingType {
|
|
|
|
|
return UITextSpellCheckingTypeNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextSmartQuotesType)smartQuotesType {
|
|
|
|
|
return UITextSmartQuotesTypeNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextSmartDashesType)smartDashesType {
|
|
|
|
|
return UITextSmartDashesTypeNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextSmartInsertDeleteType)smartInsertDeleteType {
|
|
|
|
|
return UITextSmartInsertDeleteTypeNo;
|
|
|
|
|
}
|
2019-04-19 16:10:13 -07:00
|
|
|
|
|
|
|
|
- (BOOL)hasText {
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)deleteBackward {
|
|
|
|
|
[self.delegate keyboardView:self didPressKeyDown:0x0E];
|
2020-03-24 13:41:21 -07:00
|
|
|
[NSThread sleepForTimeInterval:0.05f];
|
2019-04-19 16:10:13 -07:00
|
|
|
[self.delegate keyboardView:self didPressKeyUp:0x0E];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)insertText:(nonnull NSString *)text {
|
2025-07-14 01:37:40 -07:00
|
|
|
if (!self.keyboardMap) {
|
|
|
|
|
self.keyboardMap = [[VMKeyboardMap alloc] init];
|
2019-04-19 16:10:13 -07:00
|
|
|
}
|
2025-07-14 01:37:40 -07:00
|
|
|
[self.keyboardMap mapText:text toKeyUp:^(NSInteger scanCode) {
|
|
|
|
|
[self.delegate keyboardView:self didPressKeyUp:(int)scanCode];
|
|
|
|
|
} keyDown:^(NSInteger scanCode) {
|
|
|
|
|
[self.delegate keyboardView:self didPressKeyDown:(int)scanCode];
|
|
|
|
|
} completion:^(){}];
|
2019-04-19 16:10:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)canBecomeFirstResponder {
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|