How to connect input to Lumberyard game with C++?

Here is what I’ve tried


#define INPUT_FORWARD_BACK "MoveForwardBack"
#define INPUT_LEFT_RIGHT "MoveLeftRight"
void ClassName::Activate()
{
auto a = AZ::InputEventNotificationId(INPUT_FORWARD_BACK);
AZ::InputEventNotificationBus::Handler::BusConnect(a);
auto b = AZ::InputEventNotificationId(INPUT_LEFT_RIGHT);
AZ::InputEventNotificationBus::Handler::BusConnect(b);
}
void ClassName::OnPressed(float value)
{
AZ_TracePrintf("Debug", "OnPressed\n");
}
void ClassName::OnHeld(float value)
{
AZ_TracePrintf("Debug", "OnHeld\n");
}
void ClassName::OnReleased(float value)
{
AZ_TracePrintf("Debug", "OnReleased\n");
}

But it only works for the last InputEventNotificationId I connect (in this case, it’s INPUT_LEFT_RIGHT, INPUT_FORWARD_BACK doesn’t work). What did I do wrong here?

Thanks.

I figure it out.

Just replace

AZ::InputEventNotificationBus::Handler

With

AZ::InputEventNotificationBus::MultiHandler