Is mouse and keyboard supported with the Input System for iOS/iPadOS 13+?
If not, why not?
Is mouse and keyboard supported with the Input System for iOS/iPadOS 13+?
If not, why not?
Unity input system does not support keyboard and Mouse functionality in input system.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/SupportedDevices.html
You have to make a native plugin with wrapper using GCKeyboard and GCMouse (just introduced in IOS 14) which will callback to unity code as all the native ads plugin wrappers does.
I think unity should update the input system as iOS 14 supports Keyboard and Mouse.
The only issue I am facing now to lock the pointer inside unity Game.
Hi, from this and your other posts Iâm getting the impression that youâve written a native wrapper for GCKeyboard. Would you be able to share it or sell on Asset Store for example?
Iâm also interested for this
Itâs sad that Unity does not handle this.
I get keyboard events but I need to let the key rest by something like 0.5s between each stroke.
But iâm mostly interested by the mouse support.
Keyboard on iOS works acceptable last time Iâve checked, both old and new systems go through same code, though they go via UIKeyCommand which might introduce some quirks. Iâve tried it via pairing Apple bluetooth keyboard to iPad.
The only downside right now is that weâre not layout independent there, e.g. if you physically change your keyboard input language to something like AZERTY, input system package will fail to correctly recognize Q/A locations, though this setting is hidden very deep in iOS settings (this is different one to your onscreen keyboard language), same story on Android.
Mouse on Android works also.
Mouse on iOS might work, I havenât tried, but itâs likely to be the same way as mouse would work with any iOS application then.
GCKeyboard and GCMouse are not supported as of right now. Would you folks mind reporting a bug via Help->Report a Bug so we can keep track of it? Thanks!
First, thanks for your answer.
I will do a bug report (containing a link to this conversation) about this.
About the keyboard:
https://www.youtube.com/watch?v=EksMYIm9goA
About the mouse:
Have a nice day.
Ok I see, likely UIKeyCommand goes through Cocoa shortcut/combo recognizers or something first and that delays the input. Definitely GCKeyboard should be better here. Thanks for the bug, we will have a look.
I think this issue is also causing issues in the âiOS apps on M1 Macâ scenario, the keyboard inputs arenât recognized properly, although I havenât delved too deep into the cause of this.
@anatolyV is it the same behavior on iOS apps on Mac? aka input of some keys is delayed?
BTW I reported the bug. Case 1369022.
No, sorry. Keyboard inputs are completely ignored under macOS.
@anatolyV would you mind filing a separate bug report for keyboard support for iOS apps running under macOS on M1? Both old and new input systems are driven by same cocoa touch code here, so if one doesnât work for you itâs likely another also doesnât work. Iâve asked around and there is at least one report that it worked a while ago, but we need to recheck then.
Alright, and just as another bit of info, input fields do work as expected. If I file a bug report on this particular, should I submit a repro project as well? Wouldnât be too hard to create one considering what the issue is but I would still need to carve out a bit of time for that.
@anatolyV Yes bug reports do need a repro case so our QAs can test them, I guess something like this will do:
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class TestScript : MonoBehaviour
{
void Update()
{
foreach (var keyCode in (KeyCode[]) Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKeyDown(keyCode))
Debug.Log($"old input, {keyCode} pressed");
if (Input.GetKeyUp(keyCode))
Debug.Log($"old input, {keyCode} released");
}
if (Keyboard.current == null)
return;
foreach (var keyCode in (Key[]) Enum.GetValues(typeof(Key)))
{
if (keyCode == Key.None || keyCode == Key.IMESelected)
continue;
if (Keyboard.current[keyCode].wasPressedThisFrame)
Debug.Log($"new input, {keyCode} pressed");
if (Keyboard.current[keyCode].wasReleasedThisFrame)
Debug.Log($"new input, {keyCode} released");
}
}
}
// and in separate file
using UnityEngine;
public class LogPrinter : MonoBehaviour
{
private string log;
void OnEnable () {
Application.logMessageReceived += HandleLog;
}
void OnDisable () {
Application.logMessageReceived -= HandleLog;
}
void HandleLog(string logString, string stackTrace, LogType type){
log = $"\n{Time.timeAsDouble:F2} {logString}{log}";
if (log.Length > 1000)
log = log.Substring(0, 1000);
}
void OnGUI () {
GUILayout.Label(log);
}
}
I donât immediately have direct access to M1 macbook so unfortunately canât test it right now
After installing iOS 15 on my iPad and iPhone, all external input from a Bluetooth keyboard is ignored unless you are in an active typing field. Tried the legacy input system, the new input system, as well as rewired plugin. They all work in iOS 14.x but once I updated to iOS 15, all keyboard input except for input fields do not register. (as in key being pressed to do something in code vs. typing in a text field) Tried 2019.4.32f1 & 2020.3.21f1.
Old Legacy Input System
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
//Do Something
}
}
New Input System
void Update()
{
var keyboard = Keyboard.current;
if (keyboard == null)
return;
if (keyboard.aKey.wasPressedThisFrame)
{
//Do Something
}
}
I canât get either of these to work in iOS 15 on a Bluetooth keyboard, but they work on macOS, Windows, & Android. and iOS 14.x and earlier.
Is there something Iâm missing?
@Vincent-Parker-WB Hi, would you mind to create a bug report for iOS 15 problem specifically so I can forward it to mobile team? Thanks!
I have the same issue. Our music app uses bluetooth pedal to turn pages.
And after updating to iOS 15 the âUp Arrowâ and âDown Arrowâ commands that come from pedal are ignored and the users are complaining that they can use pedal in other apps, but not in ours.
Weâre using Unity 2020.3.7f1 and
if (Input.GetKeyUp(KeyCode.UpArrow))
Hello! Iâve made a native iOS plugin to make iPad keyboards working in my project (Pixel Studio).
Now itâs available on the Asset Store.
Hi folks, I found where the issue is, because we currently using UIKeyCommand for keyboard input (I know I know, we plan to use GCKeyboard going forward, but itâs still some time into the future), iOS 15 has a change in behavior where system handlers take precedence over ours, so none of the input is reaching any of backends. The current fix is to set âwantsPriorityOverSystemBehaviorâ to YES for all commands. If youâre blocked by this you can do it manually in UnityView+Keyboard.mm that is part of iOS player.
In meanwhile Iâm fixing it as part of Unity Issue Tracker - Keyboard input is not working when using an external keyboard in iOS 15 and will backport to all supported versions.
Good news! Iâll wait for resolution, thanks!