Adding a generic keyboard to Azura was not that hard. Using proper Win32 documentation. It was easily to register the Events and use them.
Here is the demo showcasing generic keyboard events:
To use a Keyboard Event (Gamepad also, check Scene’s Update Code), We use the CoreManager:
Register Calls
// Register These calls in your game
mCoreManager.OnKeyUp(wParam); // WPARAM wParam
mCoreManager.OnKeyDown(wParam);
// Below is the Win32 Message that you need to listen in WndProc.
case WM_KEYDOWN:
if (game) {
game->OnKeyDown(wParam);
}
break;
case WM_KEYUP:
if (game) {
game->OnKeyUp(wParam);
}
break;
Use the Events
Use the calls in the Update event of your game Scene. Each Scene in Update Phase gets the GameUpdateState (shown below as mGameUpdateState
). A State that contains all the Inputs and other stuff essentially needed for the Update Phase.
// Get Controls & Camera
auto control = mGameUpdateState->GetKeyboard();
// For Gamepad Input use:
// auto control = mGameUpdateState->GetDefaultGamePad();
// Rest Everything stays the same! :D
auto camera = GetActiveCamera();
// Get Values
auto position = camera->GetPosition();
auto value = control->GetHorizontalAxis();
// Modify
position.x += value * 0.05;
// Update the scene
GetActiveCamera()->SetPosition(position);