diff --git a/input/input_state.cpp b/input/input_state.cpp index 2a75fbc2b..af6cc6ae6 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,14 @@ int MapPadButtonFixed(int keycode) { } } +std::vector confirmKeys; +std::vector cancelKeys; + +void SetConfirmCancelKeys(std::vector confirm, std::vector cancel) { + confirmKeys = confirm; + cancelKeys = cancel; +} + 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 fd414b364..f4784d477 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 @@ -175,4 +177,9 @@ private: }; // Platforms should call g_buttonTracker.Process(). -extern ButtonTracker g_buttonTracker; \ No newline at end of file +extern ButtonTracker g_buttonTracker; + +// 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); diff --git a/ui/view.cpp b/ui/view.cpp index 210c5a364..9c09ac97b 100644 --- a/ui/view.cpp +++ b/ui/view.cpp @@ -187,11 +187,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) {