diff --git a/input/input_state.cpp b/input/input_state.cpp index 2a75fbc2bb..bb8f1bacfc 100644 --- a/input/input_state.cpp +++ b/input/input_state.cpp @@ -1,5 +1,6 @@ #include "input/input_state.h" #include "input/keycodes.h" +#include const char *GetDeviceName(int deviceId) { switch (deviceId) { @@ -41,6 +42,22 @@ int MapPadButtonFixed(int keycode) { } } +std::vector confirmKeys; +std::vector cancelKeys; + +void SetConfirmCancelKeys(std::vector confirm, std::vector cancel) { + confirmKeys = confirm; + cancelKeys = cancel; +} + +void AddConfirmKey(keycode_t confirmKey) { + confirmKeys.push_back(confirmKey); +} + +void AddCancelKey(keycode_t cancelKey) { + cancelKeys.push_back(cancelKey); +} + uint32_t ButtonTracker::Update() { pad_buttons_ |= pad_buttons_async_set; pad_buttons_ &= ~pad_buttons_async_clear; diff --git a/input/input_state.h b/input/input_state.h index fd414b3646..95bb5855f3 100644 --- a/input/input_state.h +++ b/input/input_state.h @@ -11,7 +11,9 @@ #include "math/lin/vec3.h" #include "base/mutex.h" #include "base/basictypes.h" +#include "input/keycodes.h" #include +#include // Default device IDs @@ -112,6 +114,13 @@ private: void UpdateInputState(InputState *input, bool merge = false); void EndInputState(InputState *input); +// Is there a nicer place for this stuff? It's here to avoid dozens of linking errors in UnitTest.. +extern std::vector confirmKeys; +extern std::vector cancelKeys; +void SetConfirmCancelKeys(std::vector confirm, std::vector cancel); +void AddConfirmKey(keycode_t confirmKey); +void AddCancelKey(keycode_t confirmKey); + enum { TOUCH_MOVE = 1, TOUCH_DOWN = 2, diff --git a/ui/view.cpp b/ui/view.cpp index 210c5a364c..9f593b8e89 100644 --- a/ui/view.cpp +++ b/ui/view.cpp @@ -27,7 +27,6 @@ struct DispatchQueueItem { std::queue g_dispatchQueue; - void EventTriggered(Event *e, EventParams params) { lock_guard guard(mutex_); @@ -187,11 +186,11 @@ void Clickable::Touch(const TouchInput &input) { // TODO: O/X confirm preference for xperia play? bool IsAcceptKeyCode(int keyCode) { - return keyCode == NKCODE_SPACE || keyCode == NKCODE_ENTER || keyCode == NKCODE_Z || keyCode == NKCODE_BUTTON_A || keyCode == NKCODE_BUTTON_CROSS || keyCode == NKCODE_BUTTON_1; + return std::find(confirmKeys.begin(), confirmKeys.end(), (keycode_t)keyCode) != confirmKeys.end(); } bool IsEscapeKeyCode(int keyCode) { - return keyCode == NKCODE_ESCAPE || keyCode == NKCODE_BACK || keyCode == NKCODE_BUTTON_CIRCLE || keyCode == NKCODE_BUTTON_B || keyCode == NKCODE_BUTTON_2; + return std::find(cancelKeys.begin(), cancelKeys.end(), (keycode_t)keyCode) != cancelKeys.end(); } void Clickable::Key(const KeyInput &key) {