From deb4ba83235a86491d073db73a1e5bab2a5ce523 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 19 Jun 2013 22:18:05 +0200 Subject: [PATCH] Still need to clamp to a square, sigh. --- ui/virtual_input.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/virtual_input.cpp b/ui/virtual_input.cpp index a5862ae577..cf1ff447b9 100644 --- a/ui/virtual_input.cpp +++ b/ui/virtual_input.cpp @@ -1,4 +1,6 @@ #include +#include + #include "base/logging.h" #include "gfx_es2/draw_buffer.h" #include "gfx/texture_atlas.h" @@ -139,6 +141,10 @@ void TouchStick::update(InputState &input_state) // dy /= len; //} + // Still need to clamp to a square + dx = std::min(1.0f, std::max(-1.0f, dx)); + dy = std::min(1.0f, std::max(-1.0f, dy)); + if (stick_ == 0) { input_state.pad_lstick_x = dx; input_state.pad_lstick_y = -dy; @@ -146,6 +152,7 @@ void TouchStick::update(InputState &input_state) input_state.pad_rstick_x = dx; input_state.pad_rstick_y = -dy; } + } else { dragging_[i] = false; }