Fix bug with unthrottle as virtual key. Add button to restore default key mappings.

This commit is contained in:
Henrik Rydgard 2013-07-07 11:14:46 +02:00
parent 1256d5528d
commit 47dae8c004
4 changed files with 9 additions and 2 deletions

View File

@ -412,6 +412,9 @@ void SetKeyMapping(int map, int deviceId, int key, int btn)
controllerMaps[map].keys[KeyDef(deviceId, key)] = btn;
}
void RestoreDefault() {
controllerMaps = DefaultKeyMap::KeyMap;
}
// TODO: Make the ini format nicer.
void LoadFromIni(IniFile &file) {

View File

@ -115,5 +115,6 @@ namespace KeyMap {
void LoadFromIni(IniFile &iniFile);
void SaveToIni(IniFile &iniFile);
void RestoreDefault();
}

View File

@ -207,11 +207,11 @@ void EmuScreen::key(const KeyInput &key) {
int vk = result - VIRTKEY_FIRST;
if (key.flags & KEY_DOWN) {
virtKeys[vk] = true;
onVKeyDown(key.keyCode);
onVKeyDown(result);
}
if (key.flags & KEY_UP) {
virtKeys[vk] = false;
onVKeyUp(key.keyCode);
onVKeyUp(result);
}
} else {
if (key.flags & KEY_DOWN)

View File

@ -1548,6 +1548,9 @@ void ControlsScreen::render() {
if (UIButton(GEN_ID, hlinear, 250, 0, c->T("Key Mapping"), ALIGN_LEFT)) {
screenManager()->push(new KeyMappingScreen());
}
if (UIButton(GEN_ID, hlinear, 250, 0, c->T("Default Mapping"), ALIGN_LEFT)) {
KeyMap::RestoreDefault();
}
UIEnd();
}