I have been working on developing Virtual Reality Keyboard for Google Cardboard. I am facing issues with 2 keys of Keyboard.
Space Key
Delete Key
I am getting wrong inputs from these two keys when I test Keyboard over my Phone. If I check in Unreal Editor, It all works fine. Also for Vive and Oculus it all works fine. But for Android, I am getting wrong inputs.
We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.
I think it is a bug, and what i meant with my answer is the following:
get the text from the text input, convert text to string, chop the last character from the string using LeftChop, and finally convert the string to text
It’s a bug - Android has a different mapping of special keys to TCHARs, but FSlateEditableTextLayout has hardcoded the Windows values.
See FSlateEditableTextLayout::HandleKeyChar.
I’m doing the following as a workaround, since Epic will probably never fix this.
For space, just send " " as a KeyChar, backspace is “\b”, don’t know about delete etc.
void UVRKeyboardLibrary::PropagateSpecialKeyEvent(FKey InKey)
{
// Hacky workaround for Backspace on android becoming 'C' (because backspace on Android is 67, which is ANSI value for 'C').
// And FSlateEditableTextLayout::HandleKeyChar has a hardcoded check for '\b'.
// On windows, we can also just send \b for backspace and it works fine...
if (InKey == EKeys::BackSpace)
{
KeyboardWidgetInteractor->SendKeyChar("\b");
}
else
{
KeyboardWidgetInteractor->PressAndReleaseKey(InKey);
}
}
Do a check for Android, add a sequence to Event Begin Play, and do “Get Platform Name” and do Equals Exactly (===) and compare with “Android” and set the bool to “IsAndroid” or similar.
Then in the “Use Modifier Button” function, for SpaceBar and Backspace, drag off of the “Key” input and select the “Select” node, where you can input the “IsAndroid” variable to the Index node. For Space Bar, on false select “Space Bar”, and for true, put “D”. For Backspace, on false, put “Backspace”, and for true, put “1”. For Enter, on false, put Enter, and on true, put “5”.
2 notes:
This is for cross platform games. If you are ONLY using Quest, you can skip all of these steps and just change the keys to 1, D, and 5. as described above.
It is 1, D and 5, due to ANSI TCHARs remapping Android when FSlateEditableTextLayout has hardcoded the Windows values, but I can confirm that it does work!