From 46c9fd38199263700ca721366923863d0d2cc025 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 15 Jul 2013 20:29:50 +0200 Subject: [PATCH] Can now merge the result from the buttontracker. --- input/input_state.cpp | 9 +++++---- input/input_state.h | 4 ++-- ui/viewgroup.cpp | 12 +++++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/input/input_state.cpp b/input/input_state.cpp index 9f1e8798db..f8bb1144ae 100644 --- a/input/input_state.cpp +++ b/input/input_state.cpp @@ -40,10 +40,10 @@ int MapPadButtonFixed(int keycode) { } } -void ButtonTracker::Update(InputState &input_state) { +uint32_t ButtonTracker::Update() { pad_buttons_ |= pad_buttons_async_set; pad_buttons_ &= ~pad_buttons_async_clear; - input_state.pad_buttons = pad_buttons_; + return pad_buttons_; } void ButtonTracker::Process(const KeyInput &input) { @@ -64,8 +64,9 @@ void ButtonTracker::Process(const KeyInput &input) { ButtonTracker g_buttonTracker; -void UpdateInputState(InputState *input) { - g_buttonTracker.Update(*input); +void UpdateInputState(InputState *input, bool merge) { + uint32_t btns = g_buttonTracker.Update(); + input->pad_buttons = merge ? (input->pad_buttons | btns) : btns; input->pad_buttons_down = (input->pad_last_buttons ^ input->pad_buttons) & input->pad_buttons; input->pad_buttons_up = (input->pad_last_buttons ^ input->pad_buttons) & input->pad_last_buttons; } diff --git a/input/input_state.h b/input/input_state.h index 735d81e0f5..fd414b3646 100644 --- a/input/input_state.h +++ b/input/input_state.h @@ -109,7 +109,7 @@ private: DISALLOW_COPY_AND_ASSIGN(InputState); }; -void UpdateInputState(InputState *input); +void UpdateInputState(InputState *input, bool merge = false); void EndInputState(InputState *input); enum { @@ -165,7 +165,7 @@ public: pad_buttons_async_clear = 0; } void Process(const KeyInput &input); - void Update(InputState &input_state); + uint32_t Update(); uint32_t GetPadButtons() const { return pad_buttons_; } private: diff --git a/ui/viewgroup.cpp b/ui/viewgroup.cpp index 1a0a3b6fc2..eee28a923e 100644 --- a/ui/viewgroup.cpp +++ b/ui/viewgroup.cpp @@ -102,8 +102,6 @@ float GetDirectionScore(View *origin, View *destination, FocusDirection directio if (destination->GetVisibility() != V_VISIBLE) return 0.0f; - // Point originPos = origin->GetBounds().Center(); - // Point destPos = destination->GetBounds().Center(); Point originPos = origin->GetFocusPosition(direction); Point destPos = destination->GetFocusPosition(Opposite(direction)); @@ -116,24 +114,24 @@ float GetDirectionScore(View *origin, View *destination, FocusDirection directio switch (direction) { case FOCUS_LEFT: - distance = -dirX / distance; + distance = -dirX / sqrtf(distance); //if (dirX > 0.0f) return 0.0f; //if (fabsf(dirY) > fabsf(dirX)) return 0.0f; break; case FOCUS_UP: - distance = -dirY / distance; + distance = -dirY / sqrtf(distance); //if (dirY > 0.0f) return 0.0f; //if (fabsf(dirX) > fabsf(dirY)) return 0.0f; break; case FOCUS_RIGHT: //if (dirX < 0.0f) return 0.0f; //if (fabsf(dirY) > fabsf(dirX)) return 0.0f; - distance = dirX / distance; + distance = dirX / sqrtf(distance); break; case FOCUS_DOWN: //if (dirY < 0.0f) return 0.0f; //if (fabsf(dirX) > fabsf(dirY)) return 0.0f; - distance = dirY / distance; + distance = dirY / sqrtf(distance); break; } @@ -524,7 +522,7 @@ bool ScrollView::SubviewFocused(View *view) { ScrollTo(scrollPos_ + vBounds.y2() - bounds_.y2()); } if (vBounds.y < bounds_.y) { - ScrollTo(scrollPos_ + (vBounds.y - bounds_.y - 30)); + ScrollTo(scrollPos_ + (vBounds.y - bounds_.y)); } break; }