Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed - exception when keyboard is not connected #8

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Assets/EasyTab/Source/EasyTabInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@ public class EasyTabInput

public void GetInput(out float tabPressedTime, out bool isShiftPressed, out bool isEnterPressed)
{
bool tabPressed;

#if ENABLE_INPUT_SYSTEM
var tabPressed = Keyboard.current.tabKey.isPressed;
isShiftPressed = Keyboard.current.shiftKey.isPressed;
isEnterPressed = Keyboard.current.enterKey.wasPressedThisFrame ||
Keyboard.current.numpadEnterKey.wasPressedThisFrame;
var keyboard = Keyboard.current;
if (keyboard != null)
{
tabPressed = keyboard.tabKey.isPressed;
isShiftPressed = keyboard.shiftKey.isPressed;
isEnterPressed = keyboard.enterKey.wasPressedThisFrame ||
keyboard.numpadEnterKey.wasPressedThisFrame;
}
else // if not keyboard. like PS5. https://github.com/dav-sea/EasyTab/issues/7
{
tabPressed = false;
isShiftPressed = false;
isEnterPressed = false;
}
#else
var tabPressed = Input.GetKey(KeyCode.Tab);
tabPressed = Input.GetKey(KeyCode.Tab);
isShiftPressed = Input.GetKey(KeyCode.LeftShift);
isEnterPressed = Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter);
#endif
Expand Down