Remove hard-coded accept and cancel buttons.

This commit is contained in:
The Dax 2013-08-22 06:45:45 -04:00
parent 92dd9cd798
commit a8b45a68b9
3 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#include "input/input_state.h"
#include "input/keycodes.h"
#include <vector>
const char *GetDeviceName(int deviceId) {
switch (deviceId) {
@ -41,6 +42,14 @@ int MapPadButtonFixed(int keycode) {
}
}
std::vector<keycode_t> confirmKeys;
std::vector<keycode_t> cancelKeys;
void SetConfirmCancelKeys(std::vector<keycode_t> confirm, std::vector<keycode_t> cancel) {
confirmKeys = confirm;
cancelKeys = cancel;
}
uint32_t ButtonTracker::Update() {
pad_buttons_ |= pad_buttons_async_set;
pad_buttons_ &= ~pad_buttons_async_clear;

View File

@ -11,7 +11,9 @@
#include "math/lin/vec3.h"
#include "base/mutex.h"
#include "base/basictypes.h"
#include "input/keycodes.h"
#include <map>
#include <vector>
// Default device IDs
@ -175,4 +177,9 @@ private:
};
// Platforms should call g_buttonTracker.Process().
extern ButtonTracker g_buttonTracker;
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<keycode_t> confirmKeys;
extern std::vector<keycode_t> cancelKeys;
void SetConfirmCancelKeys(std::vector<keycode_t> confirm, std::vector<keycode_t> cancel);

View File

@ -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) {