Improve screen keyboard handling for android (tv)
And remove some android ifdef for wayland on screen keyboard later
This commit is contained in:
parent
f14d8fd921
commit
1814472214
@ -262,7 +262,13 @@ namespace irr
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0;
|
||||
|
||||
//! Returns true if system has touch device
|
||||
virtual bool supportsTouchDevice() =0;
|
||||
virtual bool supportsTouchDevice() const = 0;
|
||||
|
||||
//! Returns true if system has hardware keyboard attached
|
||||
virtual bool hasHardwareKeyboard() const = 0;
|
||||
|
||||
//! Returns true if system has native on screen keyboard
|
||||
virtual bool hasOnScreenKeyboard() const = 0;
|
||||
|
||||
//! Set the current Gamma Value for the Display
|
||||
virtual bool setGammaRamp(f32 red, f32 green, f32 blue,
|
||||
@ -290,11 +296,11 @@ namespace irr
|
||||
virtual E_DEVICE_TYPE getType() const = 0;
|
||||
|
||||
/** Onscreen keyboard addition, to determine how much to move vertically. */
|
||||
virtual u32 getScreenHeight() const { return 0; }
|
||||
virtual u32 getOnScreenKeyboardHeight() const { return 0; }
|
||||
virtual s32 getMovedHeight() const { return 0; }
|
||||
virtual void toggleOnScreenKeyboard(bool show) { }
|
||||
virtual void registerGetMovedHeightFunction(HeightFunc) { }
|
||||
virtual u32 getScreenHeight() const = 0;
|
||||
virtual u32 getOnScreenKeyboardHeight() const = 0;
|
||||
virtual s32 getMovedHeight() const = 0;
|
||||
virtual void toggleOnScreenKeyboard(bool show) = 0;
|
||||
virtual void registerGetMovedHeightFunction(HeightFunc) = 0;
|
||||
|
||||
//! Check if a driver type is supported by the engine.
|
||||
/** Even if true is returned the driver may not be available
|
||||
|
@ -1754,6 +1754,11 @@ bool CIrrDeviceAndroid::isGyroscopeAvailable()
|
||||
return (Gyroscope != NULL);
|
||||
}
|
||||
|
||||
bool CIrrDeviceAndroid::hasHardwareKeyboard() const
|
||||
{
|
||||
int32_t keyboard = AConfiguration_getKeyboard(Android->config);
|
||||
return (keyboard == ACONFIGURATION_KEYBOARD_QWERTY);
|
||||
}
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -75,7 +75,11 @@ namespace irr
|
||||
virtual bool isGyroscopeAvailable();
|
||||
virtual void setTextInputEnabled(bool enabled) {TextInputEnabled = enabled;}
|
||||
virtual void toggleOnScreenKeyboard(bool show);
|
||||
virtual bool supportsTouchDevice() { return HasTouchDevice; }
|
||||
virtual bool supportsTouchDevice() const { return HasTouchDevice; }
|
||||
virtual bool hasHardwareKeyboard() const;
|
||||
// ATM if there is touch device we assume native screen keyboard is
|
||||
// available which for example android tv doesn't
|
||||
virtual bool hasOnScreenKeyboard() const { return HasTouchDevice; }
|
||||
virtual u32 getScreenHeight() const { return m_screen_height; }
|
||||
virtual u32 getOnScreenKeyboardHeight() const;
|
||||
virtual s32 getMovedHeight() const { return m_moved_height; }
|
||||
|
@ -118,9 +118,22 @@ namespace irr
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
||||
|
||||
/** Onscreen keyboard addition, to determine how much to move vertically. */
|
||||
virtual u32 getScreenHeight() const { return 0; }
|
||||
virtual u32 getOnScreenKeyboardHeight() const { return 0; }
|
||||
virtual s32 getMovedHeight() const { return 0; }
|
||||
virtual void toggleOnScreenKeyboard(bool show) {}
|
||||
virtual void registerGetMovedHeightFunction(HeightFunc) {}
|
||||
|
||||
//! Returns true if system has touch device
|
||||
virtual bool supportsTouchDevice() { return false; }
|
||||
virtual bool supportsTouchDevice() const { return false; }
|
||||
|
||||
//! Returns true if system has hardware keyboard attached
|
||||
virtual bool hasHardwareKeyboard() const { return true; }
|
||||
|
||||
//! Returns true if system has native on screen keyboard
|
||||
virtual bool hasOnScreenKeyboard() const { return false; }
|
||||
|
||||
//! Set the current Gamma Value for the Display
|
||||
virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast );
|
||||
|
@ -535,7 +535,7 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( IntUserConfigParam(0, "screen_keyboard_mode",
|
||||
&m_multitouch_group,
|
||||
"Screen keyboard mode: 0 = disabled, 1 = enabled if no hardware "
|
||||
"keyboard, 2 = always enabled, 3 = android keyboard (experimental)") );
|
||||
"keyboard, 2 = always enabled") );
|
||||
|
||||
// ---- GP start order
|
||||
PARAM_PREFIX GroupUserConfigParam m_gp_start_order
|
||||
|
@ -737,7 +737,6 @@ void IrrDriver::initDevice()
|
||||
#endif
|
||||
m_pointer_shown = true;
|
||||
|
||||
#ifdef ANDROID
|
||||
if (ProfileWorld::isNoGraphics())
|
||||
return;
|
||||
|
||||
@ -768,7 +767,6 @@ void IrrDriver::initDevice()
|
||||
}
|
||||
return screen_keyboard_height - element_height;
|
||||
});
|
||||
#endif
|
||||
} // initDevice
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -503,21 +503,20 @@ bool ScreenKeyboard::onEscapePressed()
|
||||
} // onEscapePressed
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** A function that determines if screen keyboard should be activated
|
||||
/** A function that determines if (native) screen keyboard should be activated
|
||||
*/
|
||||
bool ScreenKeyboard::shouldUseScreenKeyboard()
|
||||
{
|
||||
bool use_screen_keyboard = UserConfigParams::m_screen_keyboard == 2;
|
||||
|
||||
#ifdef ANDROID
|
||||
bool always_use_screen_keyboard =
|
||||
UserConfigParams::m_screen_keyboard == 2;
|
||||
|
||||
// Enable if no hardware keyboard
|
||||
if (UserConfigParams::m_screen_keyboard == 1)
|
||||
{
|
||||
int32_t keyboard = AConfiguration_getKeyboard(
|
||||
global_android_app->config);
|
||||
|
||||
use_screen_keyboard = (keyboard != ACONFIGURATION_KEYBOARD_QWERTY);
|
||||
if (irr_driver->getDevice()->hasHardwareKeyboard())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return use_screen_keyboard;
|
||||
|
||||
return always_use_screen_keyboard;
|
||||
}
|
||||
|
@ -127,8 +127,9 @@ CGUIEditBox::~CGUIEditBox()
|
||||
irr_driver->getDevice());
|
||||
dl->setTextInputEnabled(false);
|
||||
}
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
#endif
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -610,9 +611,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ANDROID
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
#endif
|
||||
sendGuiEvent( EGET_EDITBOX_ENTER );
|
||||
}
|
||||
break;
|
||||
@ -1305,14 +1304,12 @@ bool CGUIEditBox::processMouse(const SEvent& event)
|
||||
|
||||
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
|
||||
{
|
||||
openScreenKeyboard();
|
||||
if (irr_driver->getDevice()->hasOnScreenKeyboard())
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(true);
|
||||
else
|
||||
openScreenKeyboard();
|
||||
}
|
||||
#ifdef ANDROID
|
||||
else if (UserConfigParams::m_screen_keyboard == 3)
|
||||
{
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
// move cursor
|
||||
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
|
||||
|
||||
@ -1773,9 +1770,10 @@ void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadW
|
||||
|
||||
void CGUIEditBox::openScreenKeyboard()
|
||||
{
|
||||
if (UserConfigParams::m_screen_keyboard == 3)
|
||||
// If the device has native on screen keyboard, always use it
|
||||
if (irr_driver->getDevice()->hasOnScreenKeyboard())
|
||||
return;
|
||||
|
||||
|
||||
if (GUIEngine::ScreenKeyboard::getCurrent() != NULL)
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user