Merge branch 'feature/input-revamp' into medusa

This commit is contained in:
Vicki Pfau 2017-04-07 16:56:35 -07:00
commit 891b7aac96
1 changed files with 12 additions and 0 deletions

View File

@ -230,6 +230,9 @@ void InputController::saveConfiguration() {
void InputController::saveConfiguration(uint32_t type) { void InputController::saveConfiguration(uint32_t type) {
for (auto& inputMap : m_inputMaps) { for (auto& inputMap : m_inputMaps) {
if (!inputMap.info) {
continue;
}
mInputMapSave(&inputMap, type, m_config->input()); mInputMapSave(&inputMap, type, m_config->input());
} }
m_config->write(); m_config->write();
@ -491,6 +494,9 @@ QSet<QPair<int, GamepadAxisEvent::Direction>> InputController::activeGamepadAxes
} }
void InputController::bindKey(mPlatform platform, uint32_t type, int key, int coreKey) { void InputController::bindKey(mPlatform platform, uint32_t type, int key, int coreKey) {
if (m_inputMaps.find(platform) == m_inputMaps.end() || coreKey >= m_inputMaps[platform].info->nKeys) {
return;
}
QModelIndex index = m_inputModel->index(coreKey, 0, m_inputMenuIndices[platform]); QModelIndex index = m_inputModel->index(coreKey, 0, m_inputMenuIndices[platform]);
bool signalsBlocked = m_inputModel->blockSignals(true); bool signalsBlocked = m_inputModel->blockSignals(true);
if (type != KEYBOARD) { if (type != KEYBOARD) {
@ -503,6 +509,9 @@ void InputController::bindKey(mPlatform platform, uint32_t type, int key, int co
} }
void InputController::bindAxis(mPlatform platform, uint32_t type, int axis, GamepadAxisEvent::Direction direction, int key) { void InputController::bindAxis(mPlatform platform, uint32_t type, int axis, GamepadAxisEvent::Direction direction, int key) {
if (m_inputMaps.find(platform) == m_inputMaps.end() || key >= m_inputMaps[platform].info->nKeys) {
return;
}
QModelIndex index = m_inputModel->index(key, 0, m_inputMenuIndices[platform]); QModelIndex index = m_inputModel->index(key, 0, m_inputMenuIndices[platform]);
bool signalsBlocked = m_inputModel->blockSignals(true); bool signalsBlocked = m_inputModel->blockSignals(true);
m_inputModel->updateAxis(index, axis, direction); m_inputModel->updateAxis(index, axis, direction);
@ -566,6 +575,9 @@ QSet<QPair<int, GamepadHatEvent::Direction>> InputController::activeGamepadHats(
} }
void InputController::bindHat(mPlatform platform, uint32_t type, int hat, GamepadHatEvent::Direction direction, int coreKey) { void InputController::bindHat(mPlatform platform, uint32_t type, int hat, GamepadHatEvent::Direction direction, int coreKey) {
if (m_inputMaps.find(platform) == m_inputMaps.end() || coreKey >= m_inputMaps[platform].info->nKeys) {
return;
}
QModelIndex index = m_inputModel->index(coreKey, 0, m_inputMenuIndices[platform]); QModelIndex index = m_inputModel->index(coreKey, 0, m_inputMenuIndices[platform]);
//m_inputModel->updateHat(index, hat, direction); //m_inputModel->updateHat(index, hat, direction);