Merge pull request #2612 from daniel-dressler/master

Fix emu screen trashing legacy input path input
This commit is contained in:
Henrik Rydgård 2013-07-04 12:28:03 -07:00
commit 5e24021117
8 changed files with 41 additions and 15 deletions

View File

@ -30,10 +30,10 @@ struct DefaultKeyMap {
static std::map<int,int> init()
{
std::map<int,int> m;
m[KEYCODE_X] = CTRL_SQUARE;
m[KEYCODE_Z] = CTRL_TRIANGLE;
m[KEYCODE_S] = CTRL_CIRCLE;
m[KEYCODE_A] = CTRL_CROSS;
m[KEYCODE_A] = CTRL_SQUARE;
m[KEYCODE_S] = CTRL_TRIANGLE;
m[KEYCODE_X] = CTRL_CIRCLE;
m[KEYCODE_Z] = CTRL_CROSS;
m[KEYCODE_Q] = CTRL_LTRIGGER;
m[KEYCODE_W] = CTRL_RTRIGGER;
m[KEYCODE_SPACE] = CTRL_START;
@ -214,6 +214,15 @@ bool KeyMap::IsMappedKey(int key)
}
bool KeyMap::IsUserDefined(int key)
{
int layer = 0;
int ignored;
FindKeyMapping(key, &layer, &ignored);
return layer == 0; // key found in user settings
}
std::string KeyMap::NamePspButtonFromKey(int key)
{
return KeyMap::GetPspButtonName(KeyMap::KeyToPspButton(key));

View File

@ -62,6 +62,7 @@ namespace KeyMap {
int KeyToPspButton(int);
bool IsMappedKey(int);
bool IsUserDefined(int);
// Might be usful if you want
// to provide hints to users

View File

@ -106,6 +106,7 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true) {
osm.Show(s->T("PressESC", "Press ESC to open the pause menu"), 3.0f);
}
#endif
pressedLastUpdate = 0;
}
EmuScreen::~EmuScreen() {
@ -203,8 +204,6 @@ void EmuScreen::update(InputState &input) {
#endif
// Set Keys ----
__CtrlButtonUp(-1); // blanks all buttons
uint32_t pressed = 0;
// Legacy key mapping
// Then translate pad input into PSP pad input. Also, add in tilt.
@ -224,10 +223,16 @@ void EmuScreen::update(InputState &input) {
};
for (int i = 0; i < 12; i++) {
pressed |= input.pad_buttons_down & mapping[i][0];
if (input.pad_buttons_down & mapping[i][0]) {
__CtrlButtonDown(mapping[i][1]);
}
if (input.pad_buttons_up & mapping[i][0]) {
__CtrlButtonUp(mapping[i][1]);
}
}
// Modern key mapping
uint32_t pressed = 0;
for (int i = 0; i < MAX_KEYQUEUESIZE; i++) {
int key = input.key_queue[i];
if (key == 0)
@ -237,6 +242,8 @@ void EmuScreen::update(InputState &input) {
pressed |= KeyMap::KeyToPspButton(key);
}
__CtrlButtonDown(pressed);
__CtrlButtonUp(pressedLastUpdate & ~pressed);
pressedLastUpdate = pressed;
// End Set Keys --
float stick_x = input.pad_lstick_x;

View File

@ -38,4 +38,5 @@ private:
// Something invalid was loaded, don't try to emulate
bool invalid_;
std::string errorMessage_;
};
uint32_t pressedLastUpdate;
};

View File

@ -1599,7 +1599,9 @@ void KeyMappingNewKeyDialog::render() {
} else {
KeyScale(1.0f);
KeyText(left + stride, top + 2*stride,
keyI18N->T("Error: Key is already used"));
keyI18N->T("Error: Key is already used by"));
KeyText(left + stride, top + 3*stride,
(KeyMap::NamePspButtonFromKey(last_kb_key)).c_str());
}
}

View File

@ -136,11 +136,17 @@ int KeyboardDevice::UpdateState(InputState &input_state) {
if (!GetAsyncKeyState(key_pad_map[i])) {
continue;
}
// TODO: Escape should eventually work with KeyQueueAttemptTranslatedAdd, but it doesn't
// right now.
if (!doAlternate || key_pad_map[i + 1] > PAD_BUTTON_SELECT) {
if(key_pad_map[i] == VK_ESCAPE)
input_state.pad_buttons |= key_pad_map[i + 1];
// TODO: remove once EmuScreen supports virtual keys
switch (key_pad_map[i]) {
case VK_ESCAPE:
case VK_F3:
case VK_PAUSE:
case VK_BACK:
input_state.pad_buttons |= key_pad_map[i + 1];
break;
}
KeyQueueAttemptTranslatedAdd(input_state.key_queue, windowsTransTable, key_pad_map[i]);
}

2
lang

@ -1 +1 @@
Subproject commit 92e5e45e316f73710882bf82ef8fe43f5192d0f2
Subproject commit b05f3f8cac2f7097cac0d5b2d2526614bfda7a81

@ -1 +1 @@
Subproject commit 8b0c30efe52e0c799a99a632e5e743a56375d3ec
Subproject commit d1038e00bdcf48e2ab057616bb2ec973980a7b3f