8 #import "flutter/shell/platform/darwin/ios/InternalFlutterSwift/InternalFlutterSwift.h" 
   20   kKeyboardModifierAlphaShift = 0x10000,
 
   21   kKeyboardModifierShift = 0x20000,
 
   22   kKeyboardModifierLeftShift = 0x02,
 
   23   kKeyboardModifierRightShift = 0x04,
 
   24   kKeyboardModifierControl = 0x40000,
 
   25   kKeyboardModifierLeftControl = 0x01,
 
   26   kKeyboardModifierRightControl = 0x2000,
 
   27   kKeyboardModifierOption = 0x80000,
 
   28   kKeyboardModifierLeftOption = 0x20,
 
   29   kKeyboardModifierRightOption = 0x40,
 
   30   kKeyboardModifierCommand = 0x100000,
 
   31   kKeyboardModifierLeftCommand = 0x08,
 
   32   kKeyboardModifierRightCommand = 0x10,
 
   33   kKeyboardModifierNumericPad = 0x200000,
 
   34   kKeyboardModifierMask = kKeyboardModifierAlphaShift |    
 
   35                           kKeyboardModifierShift |         
 
   36                           kKeyboardModifierLeftShift |     
 
   37                           kKeyboardModifierRightShift |    
 
   38                           kKeyboardModifierControl |       
 
   39                           kKeyboardModifierLeftControl |   
 
   40                           kKeyboardModifierRightControl |  
 
   41                           kKeyboardModifierOption |        
 
   42                           kKeyboardModifierLeftOption |    
 
   43                           kKeyboardModifierRightOption |   
 
   44                           kKeyboardModifierCommand |       
 
   45                           kKeyboardModifierLeftCommand |   
 
   46                           kKeyboardModifierRightCommand |  
 
   47                           kKeyboardModifierNumericPad,
 
   55   if (characters == nil) {
 
   58   if ([characters length] == 0) {
 
   61   if (@available(iOS 13.4, *)) {
 
   86 - (NSInteger)adjustModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4));
 
   87 - (void)updatePressedModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4));
 
   89 @property(nonatomic) kKeyboardModifier pressedModifiers;
 
   98     _pressedModifiers = 0;
 
  103 - (void)handlePress:(nonnull FlutterUIPressProxy*)press
 
  105   if (@available(iOS 13.4, *)) {
 
  111   switch (press.phase) {
 
  112     case UIPressPhaseBegan:
 
  115     case UIPressPhaseCancelled:
 
  120     case UIPressPhaseEnded:
 
  123     case UIPressPhaseChanged:
 
  126     case UIPressPhaseStationary:
 
  136   NSString* charactersIgnoringModifiers =
 
  138   NSDictionary* keyMessage = @{
 
  141     @"keyCode" : @(press.key.keyCode),
 
  142     @"modifiers" : @([
self adjustModifiers:press]),
 
  143     @"characters" : characters == nil ? 
@"" : characters,
 
  144     @"charactersIgnoringModifiers" : charactersIgnoringModifiers == nil
 
  146         : charactersIgnoringModifiers,
 
  148   [
self.channel sendMessage:keyMessage
 
  150                         bool handled = reply ? [[reply valueForKey:@"handled"] boolValue] : true;
 
  155 #pragma mark - Private 
  157 - (void)updatePressedModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4)) {
 
  158   if (@available(iOS 13.4, *)) {
 
  165   switch (press.phase) {
 
  166     case UIPressPhaseStationary:
 
  167     case UIPressPhaseChanged:
 
  169       NSAssert(
false, 
@"Unexpected key event type received in updatePressedModifiers.");
 
  171     case UIPressPhaseBegan:
 
  174     case UIPressPhaseCancelled:
 
  175     case UIPressPhaseEnded:
 
  180   void (^update)(kKeyboardModifier, bool) = ^(kKeyboardModifier mod, 
bool isOn) {
 
  182       _pressedModifiers |= mod;
 
  184       _pressedModifiers &= ~mod;
 
  187   switch (press.key.keyCode) {
 
  188     case UIKeyboardHIDUsageKeyboardCapsLock:
 
  189       update(kKeyboardModifierAlphaShift, 
isKeyDown);
 
  191     case UIKeyboardHIDUsageKeypadNumLock:
 
  192       update(kKeyboardModifierNumericPad, 
isKeyDown);
 
  194     case UIKeyboardHIDUsageKeyboardLeftShift:
 
  195       update(kKeyboardModifierLeftShift, 
isKeyDown);
 
  197     case UIKeyboardHIDUsageKeyboardRightShift:
 
  198       update(kKeyboardModifierRightShift, 
isKeyDown);
 
  200     case UIKeyboardHIDUsageKeyboardLeftControl:
 
  201       update(kKeyboardModifierLeftControl, 
isKeyDown);
 
  203     case UIKeyboardHIDUsageKeyboardRightControl:
 
  204       update(kKeyboardModifierRightControl, 
isKeyDown);
 
  206     case UIKeyboardHIDUsageKeyboardLeftAlt:
 
  207       update(kKeyboardModifierLeftOption, 
isKeyDown);
 
  209     case UIKeyboardHIDUsageKeyboardRightAlt:
 
  210       update(kKeyboardModifierRightOption, 
isKeyDown);
 
  212     case UIKeyboardHIDUsageKeyboardLeftGUI:
 
  213       update(kKeyboardModifierLeftCommand, 
isKeyDown);
 
  215     case UIKeyboardHIDUsageKeyboardRightGUI:
 
  216       update(kKeyboardModifierRightCommand, 
isKeyDown);
 
  223   update(kKeyboardModifierShift,
 
  224          _pressedModifiers & (kKeyboardModifierRightShift | kKeyboardModifierLeftShift));
 
  225   update(kKeyboardModifierControl,
 
  226          _pressedModifiers & (kKeyboardModifierRightControl | kKeyboardModifierLeftControl));
 
  227   update(kKeyboardModifierOption,
 
  228          _pressedModifiers & (kKeyboardModifierRightOption | kKeyboardModifierLeftOption));
 
  229   update(kKeyboardModifierCommand,
 
  230          _pressedModifiers & (kKeyboardModifierRightCommand | kKeyboardModifierLeftCommand));
 
  236 - (NSInteger)adjustModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4)) {
 
  237   if (@available(iOS 13.4, *)) {
 
  240     return press.key.modifierFlags;
 
  243   [
self updatePressedModifiers:press];
 
  245   return _pressedModifiers | (press.key.modifierFlags & ~kKeyboardModifierMask);
 
void(^ FlutterAsyncKeyCallback)(BOOL handled)
 
UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0))
 
const std::set< uint32_t > functionKeyCodes
 
static bool isKeyDown(FlutterUIPressProxy *press) API_AVAILABLE(ios(13.4))
 
static NSString * getEventCharacters(NSString *characters, UIKeyboardHIDUsage keyCode) API_AVAILABLE(ios(13.4))
 
typedef NS_OPTIONS(NSInteger, kKeyboardModifier)