diff --git a/input/input_state.h b/input/input_state.h index 27480e4a0e..6c7191269f 100644 --- a/input/input_state.h +++ b/input/input_state.h @@ -26,6 +26,9 @@ enum { PAD_BUTTON_JOY_DOWN = 1<<15, PAD_BUTTON_JOY_LEFT = 1<<16, PAD_BUTTON_JOY_RIGHT = 1<<17, + + PAD_BUTTON_LEFT_THUMB = 1 << 18, // Click left thumb stick on X360 + PAD_BUTTON_RIGHT_THUMB = 1 << 19, // Click right thumb stick on X360 }; #ifndef MAX_POINTERS diff --git a/ui/virtual_input.cpp b/ui/virtual_input.cpp index 27b0205fe5..dbc3924574 100644 --- a/ui/virtual_input.cpp +++ b/ui/virtual_input.cpp @@ -17,15 +17,16 @@ TouchButton::TouchButton(const Atlas *atlas, int imageIndex, int overlayImageInd void TouchButton::update(InputState &input_state) { - bool oldIsDown = isDown_; - isDown_ = false; + bool down = false; for (int i = 0; i < MAX_POINTERS; i++) { if (input_state.pointer_down[i] && isInside(input_state.pointer_x[i], input_state.pointer_y[i])) - isDown_ = true; + down = true; } - if (isDown_) + if (down) input_state.pad_buttons |= button_; + + isDown_ = (input_state.pad_buttons & button_) != 0; } void TouchButton::draw(DrawBuffer &db, uint32_t color, uint32_t colorOverlay) @@ -123,8 +124,7 @@ void TouchStick::update(InputState &input_state) // Ignore outside box if (!dragging_[i] && (fabsf(dx) > 1.4f || fabsf(dy) > 1.4f)) goto skip; - if (!lastPointerDown_[i] && (fabsf(dx) < 1.4f && fabsf(dy) < 1.4f)) - { + if (!lastPointerDown_[i] && (fabsf(dx) < 1.4f && fabsf(dy) < 1.4f)) { dragging_[i] = true; } if (!dragging_[i]) @@ -136,8 +136,6 @@ void TouchStick::update(InputState &input_state) dx /= len; dy /= len; } - stick_delta_x_ = dx; - stick_delta_y_ = dy; if (stick_ == 0) { input_state.pad_lstick_x = dx; input_state.pad_lstick_y = -dy; @@ -151,17 +149,9 @@ void TouchStick::update(InputState &input_state) skip: lastPointerDown_[i] = input_state.pointer_down[i]; } - if (all_up) { - stick_delta_x_ = 0.0f; - stick_delta_y_ = 0.0f; - if (stick_ == 0) { - input_state.pad_lstick_x = 0.0f; - input_state.pad_lstick_y = 0.0f; - } else if (stick_ == 1) { - input_state.pad_rstick_x = 0.0f; - input_state.pad_rstick_y = 0.0f; - } - } + + stick_delta_x_ = input_state.pad_lstick_x; + stick_delta_y_ = -input_state.pad_lstick_y; } void TouchStick::draw(DrawBuffer &db, uint32_t color)