Try to make touch device a bit more comfortable
This commit is contained in:
parent
ea58a736d5
commit
704d3ea9d9
@ -157,7 +157,6 @@ void MultitouchDevice::addButton(MultitouchButtonType type, int x, int y,
|
|||||||
m_accelerometer_active = true;
|
m_accelerometer_active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} // addButton
|
} // addButton
|
||||||
@ -193,32 +192,38 @@ void MultitouchDevice::updateDeviceState(unsigned int event_id)
|
|||||||
{
|
{
|
||||||
assert(event_id < m_events.size());
|
assert(event_id < m_events.size());
|
||||||
|
|
||||||
MultitouchEvent event = m_events[event_id];
|
MultitouchButton* pressed_button = NULL;
|
||||||
|
|
||||||
for (MultitouchButton* button : m_buttons)
|
for (MultitouchButton* button : m_buttons)
|
||||||
{
|
{
|
||||||
|
if (button->pressed && button->event_id == event_id)
|
||||||
|
{
|
||||||
|
pressed_button = button;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MultitouchButton* button : m_buttons)
|
||||||
|
{
|
||||||
|
if (pressed_button != NULL && button != pressed_button)
|
||||||
|
continue;
|
||||||
|
|
||||||
bool update_controls = false;
|
bool update_controls = false;
|
||||||
bool prev_button_state = button->pressed;
|
bool prev_button_state = button->pressed;
|
||||||
float prev_axis_x = button->axis_x;
|
MultitouchEvent event = m_events[event_id];
|
||||||
float prev_axis_y = button->axis_y;
|
|
||||||
|
|
||||||
if (event.x < button->x || event.x > button->x + button->width ||
|
if (pressed_button != NULL ||
|
||||||
event.y < button->y || event.y > button->y + button->height)
|
(event.x >= button->x && event.x <= button->x + button->width &&
|
||||||
{
|
event.y >= button->y && event.y <= button->y + button->height))
|
||||||
if (button->event_id == event_id)
|
|
||||||
{
|
|
||||||
button->pressed = false;
|
|
||||||
button->event_id = 0;
|
|
||||||
updateButtonAxes(button, 0.0f, 0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
button->pressed = event.touched;
|
button->pressed = event.touched;
|
||||||
button->event_id = event_id;
|
button->event_id = event_id;
|
||||||
|
|
||||||
if (button->type == MultitouchButtonType::BUTTON_STEERING)
|
if (button->type == MultitouchButtonType::BUTTON_STEERING)
|
||||||
{
|
{
|
||||||
|
float prev_axis_x = button->axis_x;
|
||||||
|
float prev_axis_y = button->axis_y;
|
||||||
|
|
||||||
if (button->pressed == true)
|
if (button->pressed == true)
|
||||||
{
|
{
|
||||||
updateButtonAxes(button,
|
updateButtonAxes(button,
|
||||||
|
Loading…
Reference in New Issue
Block a user