Remove hasHardwareKeyboard because it's not reliable in iOS

This commit is contained in:
Benau 2020-06-16 08:04:46 +08:00
parent 89a57e6e19
commit 07f6282142
2 changed files with 24 additions and 23 deletions

View File

@ -24,6 +24,7 @@
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/render_info.hpp" #include "graphics/render_info.hpp"
#include "guiengine/message_queue.hpp"
#include "guiengine/widgets/bubble_widget.hpp" #include "guiengine/widgets/bubble_widget.hpp"
#include "guiengine/widgets/kart_stats_widget.hpp" #include "guiengine/widgets/kart_stats_widget.hpp"
#include "guiengine/widgets/model_view_widget.hpp" #include "guiengine/widgets/model_view_widget.hpp"
@ -268,8 +269,6 @@ void KartSelectionScreen::loadedFromFile()
void KartSelectionScreen::beforeAddingWidget() void KartSelectionScreen::beforeAddingWidget()
{ {
m_has_external_keyboard = irr_driver->getDevice()->hasHardwareKeyboard();
m_has_external_gamepad = input_manager->getGamepadCount() > 0;
if (useContinueButton()) if (useContinueButton())
{ {
getWidget("kartlist")->m_properties[GUIEngine::PROP_WIDTH] = "85%"; getWidget("kartlist")->m_properties[GUIEngine::PROP_WIDTH] = "85%";
@ -369,7 +368,9 @@ void KartSelectionScreen::init()
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts"); DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
assert( w != NULL ); assert( w != NULL );
// Only allow keyboard and gamepad to choose kart without continue button in
// multitouch GUI, so mouse (touch) clicking can be used as previewing karts
w->setEventCallbackActive(Input::IT_MOUSEBUTTON, !useContinueButton());
KartHoverListener* karthoverListener = new KartHoverListener(this); KartHoverListener* karthoverListener = new KartHoverListener(this);
w->registerHoverListener(karthoverListener); w->registerHoverListener(karthoverListener);
@ -428,6 +429,10 @@ void KartSelectionScreen::init()
{ {
// Add multiplayer message // Add multiplayer message
addMultiplayerMessage(); addMultiplayerMessage();
#ifdef MOBILE_STK
MessageQueue::addStatic(MessageQueue::MT_GENERIC,
_("Connect a keyboard or gamepad to play splitscreen multiplayer"));
#endif
} }
} }
} // init } // init
@ -436,6 +441,10 @@ void KartSelectionScreen::init()
void KartSelectionScreen::tearDown() void KartSelectionScreen::tearDown()
{ {
#ifdef MOBILE_STK
if (m_multiplayer)
MessageQueue::discardStatic();
#endif
// Reset the 'map fire to select' option of the device manager // Reset the 'map fire to select' option of the device manager
input_manager->getDeviceManager()->mapFireToSelect(false); input_manager->getDeviceManager()->mapFireToSelect(false);
@ -470,6 +479,10 @@ void KartSelectionScreen::unloaded()
// Return true if event was handled successfully // Return true if event was handled successfully
bool KartSelectionScreen::joinPlayer(InputDevice* device, PlayerProfile* p) bool KartSelectionScreen::joinPlayer(InputDevice* device, PlayerProfile* p)
{ {
#ifdef MOBILE_STK
if (m_multiplayer)
MessageQueue::discardStatic();
#endif
bool first_player = m_kart_widgets.size() == 0; bool first_player = m_kart_widgets.size() == 0;
if (UserConfigParams::logGUI()) if (UserConfigParams::logGUI())
@ -1010,16 +1023,8 @@ void KartSelectionScreen::addMultiplayerMessage()
{ {
m_multiplayer_message = new BubbleWidget(); m_multiplayer_message = new BubbleWidget();
m_multiplayer_message->m_properties[PROP_TEXT_ALIGN] = "center"; m_multiplayer_message->m_properties[PROP_TEXT_ALIGN] = "center";
if (!m_has_external_keyboard && !m_has_external_gamepad)
{
m_multiplayer_message->setText(_("Connect a keyboard or "
"gamepad to play splitscreen multiplayer"));
}
else
{
m_multiplayer_message->setText(_("Everyone:\n" m_multiplayer_message->setText(_("Everyone:\n"
"Press the 'Select' button to join the game")); "Press the 'Select' button to join the game"));
}
m_multiplayer_message->m_x = message_x; m_multiplayer_message->m_x = message_x;
m_multiplayer_message->m_y = (int) (fullarea->m_y + fullarea->m_h * 0.3f); m_multiplayer_message->m_y = (int) (fullarea->m_y + fullarea->m_h * 0.3f);
m_multiplayer_message->m_w = (int) (splitWidth * 0.6f); m_multiplayer_message->m_w = (int) (splitWidth * 0.6f);
@ -1130,14 +1135,12 @@ void KartSelectionScreen::eventCallback(Widget* widget,
} }
else if (name == "karts") else if (name == "karts")
{ {
if (!useContinueButton() && if (m_kart_widgets.size() > unsigned(player_id))
m_kart_widgets.size() > unsigned(player_id))
playerConfirm(player_id); playerConfirm(player_id);
} }
else if (name == "continue") else if (name == "continue")
{ {
if (useContinueButton() && if (m_kart_widgets.size() > unsigned(player_id))
m_kart_widgets.size() > unsigned(player_id))
playerConfirm(player_id); playerConfirm(player_id);
} }
else if (name == "back") else if (name == "back")
@ -1592,14 +1595,16 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool KartSelectionScreen::useContinueButton() const bool KartSelectionScreen::useContinueButton() const
{ {
#ifdef MOBILE_STK
if (m_multiplayer) if (m_multiplayer)
return false; return false;
if (m_has_external_keyboard || m_has_external_gamepad)
return false;
bool multitouch_enabled = (UserConfigParams::m_multitouch_active == 1 && bool multitouch_enabled = (UserConfigParams::m_multitouch_active == 1 &&
irr_driver->getDevice()->supportsTouchDevice()) || irr_driver->getDevice()->supportsTouchDevice()) ||
UserConfigParams::m_multitouch_active > 1; UserConfigParams::m_multitouch_active > 1;
return multitouch_enabled; return multitouch_enabled;
#else
return false;
#endif
} // useContinueButton } // useContinueButton
#if 0 #if 0

View File

@ -76,10 +76,6 @@ protected:
*/ */
bool m_game_master_confirmed; bool m_game_master_confirmed;
/** For mobile STK to handle the continue button */
bool m_has_external_keyboard;
bool m_has_external_gamepad;
GUIEngine::PlayerKartWidget* m_removed_widget; GUIEngine::PlayerKartWidget* m_removed_widget;
/** Message shown in multiplayer mode */ /** Message shown in multiplayer mode */