Can now merge the result from the buttontracker.

This commit is contained in:
Henrik Rydgard 2013-07-15 20:29:50 +02:00
parent 70a5970d45
commit 46c9fd3819
3 changed files with 12 additions and 13 deletions

View File

@ -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;
}

View File

@ -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:

View File

@ -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;
}