Hi,
How do you cancel the app minimising when the Back button is pressed (but also then minimise it when need)
I can get the key code, but returning positive doesn't handle it, how to please?
Android: cancel back
Re: Android: cancel back
in CIrrDeviceAndroid.cpp around line 510
change
to
and you need return "true" in OnEvent
change
Code: Select all
case AINPUT_EVENT_TYPE_KEY:
{
// irr things
device->postEventFromUser(event); // this line
}
Code: Select all
case AINPUT_EVENT_TYPE_KEY:
{
// irr things
status = device->postEventFromUser(event); // this line
}
Code: Select all
if (event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown && event.KeyInput.Key == irr::KEY_BACK)
{
// your code
return true;
}
Re: Android: cancel back
Oh! That's brilliant, thankyou!
Re: Android: cancel back
You could also try if you can replace the InputHandler after the device was created. You got already the android_app* pointer in your app. It should have an onInputEvent member variable which is of type:
int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event);
So if you backup a pointer to the old onInputEvent you can put int your own function pointer in that structure (it will use the current function pointer in android_app in each call to IrrlichtDevice:run()). And then basically copy some code from CIrrDeviceAndroid::handleInput by calling AInputEvent_getType and checking for AINPUT_EVENT_TYPE_KEY and then return 1 for that specific key. In all other cases call the old onInputEvent function from Irrlicht.
Note - I did not test this, that just should work in theory...
int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event);
So if you backup a pointer to the old onInputEvent you can put int your own function pointer in that structure (it will use the current function pointer in android_app in each call to IrrlichtDevice:run()). And then basically copy some code from CIrrDeviceAndroid::handleInput by calling AInputEvent_getType and checking for AINPUT_EVENT_TYPE_KEY and then return 1 for that specific key. In all other cases call the old onInputEvent function from Irrlicht.
Note - I did not test this, that just should work in theory...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Android: cancel back
Got to love theory!
On the previous... It use's the Backspace key, so added a flag that could check for when softkeyboard is active in case the Backspace was needed.
But, theoretically there's a better method now!
Cheers
On the previous... It use's the Backspace key, so added a flag that could check for when softkeyboard is active in case the Backspace was needed.
But, theoretically there's a better method now!
Cheers