Android: Fix pressed buttons not beeing cleared on opening menu
parent
9eee3c3f46
commit
6a7e1667f6
17
src/game.cpp
17
src/game.cpp
|
@ -2569,7 +2569,17 @@ void Game::processUserInput(VolatileRunFlags *flags,
|
||||||
|| noMenuActive() == false
|
|| noMenuActive() == false
|
||||||
|| guienv->hasFocus(gui_chat_console)) {
|
|| guienv->hasFocus(gui_chat_console)) {
|
||||||
input->clear();
|
input->clear();
|
||||||
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
g_touchscreengui->Hide();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
else if (g_touchscreengui) {
|
||||||
|
/* on touchscreengui step may generate own input events which ain't
|
||||||
|
* what we want in case we just did clear them */
|
||||||
|
g_touchscreengui->step(dtime);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen()) {
|
if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen()) {
|
||||||
gui_chat_console->closeConsoleAtOnce();
|
gui_chat_console->closeConsoleAtOnce();
|
||||||
|
@ -2578,13 +2588,6 @@ void Game::processUserInput(VolatileRunFlags *flags,
|
||||||
// Input handler step() (used by the random input generator)
|
// Input handler step() (used by the random input generator)
|
||||||
input->step(dtime);
|
input->step(dtime);
|
||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
|
||||||
|
|
||||||
if (g_touchscreengui) {
|
|
||||||
g_touchscreengui->step(dtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
|
|
||||||
if (current_formspec != 0)
|
if (current_formspec != 0)
|
||||||
|
|
|
@ -417,6 +417,57 @@ void TouchScreenGUI::ButtonEvent(touch_gui_button_id button,
|
||||||
delete translated;
|
delete translated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TouchScreenGUI::handleReleaseEvent(int evt_id)
|
||||||
|
{
|
||||||
|
touch_gui_button_id button = getButtonID(evt_id);
|
||||||
|
|
||||||
|
/* handle button events */
|
||||||
|
if (button != after_last_element_id) {
|
||||||
|
ButtonEvent(button, evt_id, false);
|
||||||
|
}
|
||||||
|
/* handle hud button events */
|
||||||
|
else if (isReleaseHUDButton(evt_id)) {
|
||||||
|
/* nothing to do here */
|
||||||
|
}
|
||||||
|
/* handle the point used for moving view */
|
||||||
|
else if (evt_id == m_move_id) {
|
||||||
|
m_move_id = -1;
|
||||||
|
|
||||||
|
/* if this pointer issued a mouse event issue symmetric release here */
|
||||||
|
if (m_move_sent_as_mouse_event) {
|
||||||
|
SEvent* translated = new SEvent;
|
||||||
|
memset(translated,0,sizeof(SEvent));
|
||||||
|
translated->EventType = EET_MOUSE_INPUT_EVENT;
|
||||||
|
translated->MouseInput.X = m_move_downlocation.X;
|
||||||
|
translated->MouseInput.Y = m_move_downlocation.Y;
|
||||||
|
translated->MouseInput.Shift = false;
|
||||||
|
translated->MouseInput.Control = false;
|
||||||
|
translated->MouseInput.ButtonStates = 0;
|
||||||
|
translated->MouseInput.Event = EMIE_LMOUSE_LEFT_UP;
|
||||||
|
m_receiver->OnEvent(*translated);
|
||||||
|
delete translated;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* do double tap detection */
|
||||||
|
doubleTapDetection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
infostream
|
||||||
|
<< "TouchScreenGUI::translateEvent released unknown button: "
|
||||||
|
<< evt_id << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::vector<id_status>::iterator iter = m_known_ids.begin();
|
||||||
|
iter != m_known_ids.end(); ++iter) {
|
||||||
|
if (iter->id == evt_id) {
|
||||||
|
m_known_ids.erase(iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TouchScreenGUI::translateEvent(const SEvent &event)
|
void TouchScreenGUI::translateEvent(const SEvent &event)
|
||||||
{
|
{
|
||||||
if (!m_visible) {
|
if (!m_visible) {
|
||||||
|
@ -470,52 +521,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
|
||||||
else if (event.TouchInput.Event == ETIE_LEFT_UP) {
|
else if (event.TouchInput.Event == ETIE_LEFT_UP) {
|
||||||
verbosestream << "Up event for pointerid: " << event.TouchInput.ID << std::endl;
|
verbosestream << "Up event for pointerid: " << event.TouchInput.ID << std::endl;
|
||||||
|
|
||||||
touch_gui_button_id button = getButtonID(event.TouchInput.ID);
|
handleReleaseEvent(event.TouchInput.ID);
|
||||||
|
|
||||||
/* handle button events */
|
|
||||||
if (button != after_last_element_id) {
|
|
||||||
ButtonEvent(button,event.TouchInput.ID,false);
|
|
||||||
}
|
|
||||||
/* handle hud button events */
|
|
||||||
else if (isReleaseHUDButton(event.TouchInput.ID)) {
|
|
||||||
/* nothing to do here */
|
|
||||||
}
|
|
||||||
/* handle the point used for moving view */
|
|
||||||
else if (event.TouchInput.ID == m_move_id) {
|
|
||||||
m_move_id = -1;
|
|
||||||
|
|
||||||
/* if this pointer issued a mouse event issue symmetric release here */
|
|
||||||
if (m_move_sent_as_mouse_event) {
|
|
||||||
SEvent* translated = new SEvent;
|
|
||||||
memset(translated,0,sizeof(SEvent));
|
|
||||||
translated->EventType = EET_MOUSE_INPUT_EVENT;
|
|
||||||
translated->MouseInput.X = m_move_downlocation.X;
|
|
||||||
translated->MouseInput.Y = m_move_downlocation.Y;
|
|
||||||
translated->MouseInput.Shift = false;
|
|
||||||
translated->MouseInput.Control = false;
|
|
||||||
translated->MouseInput.ButtonStates = 0;
|
|
||||||
translated->MouseInput.Event = EMIE_LMOUSE_LEFT_UP;
|
|
||||||
m_receiver->OnEvent(*translated);
|
|
||||||
delete translated;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* do double tap detection */
|
|
||||||
doubleTapDetection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
infostream
|
|
||||||
<< "TouchScreenGUI::translateEvent released unknown button: "
|
|
||||||
<< event.TouchInput.ID << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (std::vector<id_status>::iterator iter = m_known_ids.begin();
|
|
||||||
iter != m_known_ids.end(); ++iter) {
|
|
||||||
if (iter->id == event.TouchInput.ID) {
|
|
||||||
m_known_ids.erase(iter);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(event.TouchInput.Event == ETIE_MOVED);
|
assert(event.TouchInput.Event == ETIE_MOVED);
|
||||||
|
@ -765,14 +771,27 @@ void TouchScreenGUI::Toggle(bool visible)
|
||||||
btn->guibutton->setVisible(visible);
|
btn->guibutton->setVisible(visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clear all active buttons */
|
||||||
|
if (!visible) {
|
||||||
|
while (m_known_ids.size() > 0) {
|
||||||
|
handleReleaseEvent(m_known_ids.begin()->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenGUI::Hide()
|
void TouchScreenGUI::Hide()
|
||||||
{
|
{
|
||||||
|
if (!m_visible)
|
||||||
|
return;
|
||||||
|
|
||||||
Toggle(false);
|
Toggle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenGUI::Show()
|
void TouchScreenGUI::Show()
|
||||||
{
|
{
|
||||||
|
if (m_visible)
|
||||||
|
return;
|
||||||
|
|
||||||
Toggle(true);
|
Toggle(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,9 @@ private:
|
||||||
/* handle double taps */
|
/* handle double taps */
|
||||||
bool doubleTapDetection();
|
bool doubleTapDetection();
|
||||||
|
|
||||||
|
/* handle release event */
|
||||||
|
void handleReleaseEvent(int evt_id);
|
||||||
|
|
||||||
/* doubleclick detection variables */
|
/* doubleclick detection variables */
|
||||||
struct key_event {
|
struct key_event {
|
||||||
unsigned int down_time;
|
unsigned int down_time;
|
||||||
|
|
Loading…
Reference in New Issue