     return device.realDevice.description
   }
 
+  /**
+   * Compares the detected dimensions of the current device to those of devices with known keyboard dimensions, returning
+   * the largest device smaller than or equal to the detected dimensions.
+   */
+  private static func getUnknownDeviceMapping() -> Device {
+    let _screenSize = UIScreen.main.bounds
+
+    // Shouldn't happen, but just in case.
+    if _screenSize == CGRect.zero {
+      log.error("Cannot detect device dimensions; defaulting to smallest device for form factor.")
+    }
+
+    // Convert to CGSize in portrait orientation.
+    var screenSize: CGSize
+    if _screenSize.width > _screenSize.height {
+      screenSize = CGSize(width: _screenSize.height, height: _screenSize.width)
+    } else {
+      screenSize = CGSize(width: _screenSize.width, height: _screenSize.height)
+    }
+
+    // Array for search is determined by form-factor.
+    var searchSet: [Device]
+    if(UIDevice.current.userInterfaceIdiom == .phone) {
+      searchSet = KeyboardScaleMap.shared.phoneScalingThresholds
+    } else {
+      searchSet = KeyboardScaleMap.shared.tabletScalingThresholds
+    }
+
+    // Okay, now that we've got the important values, it's time to search.
+    let potentialMatches = searchSet.compactMap { device in
+      let matchSize = KeyboardScaleMap.shared.pointSizes[KeyboardScaleMap.hashKey(for: device)]!
+      if matchSize.width > screenSize.width ||  // if searchSet's device is wider
+         matchSize.height > screenSize.height { // or taller
+        return nil as Device?                   // it's not a permitted match for mapping uses.
+      } else {
+        return device
+      }
+    } as [Device]
+
+    if potentialMatches.count == 0 {
+      return searchSet[0] // in case no matches can be found (like the screenSize == CGRect.zero case) - use smallest
+    } else {
+      // Use the largest potential device, which is the last one returned from the mapping (b/c we presorted the base array)
+      return searchSet.last!
+    }
+  }
+
   static func getDeviceDefaultKeyboardScale(forPortrait: Bool) -> KeyboardSize? {
     let device = Device.current
 

      return forPortrait ? scaling.portrait : scaling.landscape
    }

    switch device {
      case .unknown(_):
        // The expected case; applies to future models of iPhone and iPad.  DeviceKit is of no help here.

        // VERY temporary stop-gap.  A better rule-of-thumb is needed.
        let dev = UIDevice.current
        var scaling: Scaling

        if(dev.userInterfaceIdiom == .phone) {
          scaling = shared.scalings[KeyboardScaleMap.hashKey(for: Device.iPhoneSE)]!
        } else {
          scaling = shared.scalings[KeyboardScaleMap.hashKey(for: Device.iPad5)]!
        }

        return forPortrait ? scaling.portrait : scaling.landscape
      default:
        log.error("Keyboard scaling definition missing for device \(device.description)")
        return nil
    }
  }
}

    scalings[KeyboardScaleMap.hashKey(for: Device.iPhone8Plus)] = Scaling(portrait: KeyboardSize(w: 414, h: 226, b: 45), landscape: KeyboardSize(w: 736, h: 162, b: 38))  // does not use full width in landscape

    // Start:  'safe area insets', which are not counted (here) as part of a keyboard's height.
    //         Note that the widths reported for notched phones exclude part of the area to the sides in landscape b/c
    //         of safe-area guidelines.  It's not exact, though, as the system globe & dictation keys go beyond those guides.
    scalings[KeyboardScaleMap.hashKey(for: Device.iPhoneX)]  = Scaling(portrait: KeyboardSize(w: 375, h: 216, b: 45), landscape: KeyboardSize(w: 724, h: 150, b: 38))  // insets:  p: 34, l: 21
    scalings[KeyboardScaleMap.hashKey(for: Device.iPhoneXR)]  = Scaling(portrait: KeyboardSize(w: 414, h: 226, b: 45), landscape: KeyboardSize(w: 808, h: 150, b: 38))  // insets:  p: 34, l: 21
    scalings[KeyboardScaleMap.hashKey(for: Device.iPhoneXS)]  = Scaling(portrait: KeyboardSize(w: 414, h: 216, b: 44), landscape: KeyboardSize(w: 724, h: 150, b: 38))  // insets:  p: 34, l: 21.  And yeah, that '44' isn't a typo.
