Fixing input to return EMPTY.

This commit is contained in:
Ben Vanik 2015-02-10 22:11:45 -08:00
parent 94b8abd816
commit 5876196a2c
2 changed files with 33 additions and 13 deletions

View File

@ -35,47 +35,67 @@ X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags,
X_INPUT_CAPABILITIES* out_caps) { X_INPUT_CAPABILITIES* out_caps) {
SCOPE_profile_cpu_f("hid"); SCOPE_profile_cpu_f("hid");
bool any_connected = false;
for (auto& driver : drivers_) { for (auto& driver : drivers_) {
if (XSUCCEEDED(driver->GetCapabilities(user_index, flags, out_caps))) { X_RESULT result = driver->GetCapabilities(user_index, flags, out_caps);
return X_ERROR_SUCCESS; if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
any_connected = true;
}
if (result == X_ERROR_SUCCESS) {
return result;
} }
} }
return X_ERROR_DEVICE_NOT_CONNECTED; return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
} }
X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) { X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) {
SCOPE_profile_cpu_f("hid"); SCOPE_profile_cpu_f("hid");
bool any_connected = false;
for (auto& driver : drivers_) { for (auto& driver : drivers_) {
if (driver->GetState(user_index, out_state) == X_ERROR_SUCCESS) { X_RESULT result = driver->GetState(user_index, out_state);
return X_ERROR_SUCCESS; if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
any_connected = true;
}
if (result == X_ERROR_SUCCESS) {
return result;
} }
} }
return X_ERROR_DEVICE_NOT_CONNECTED; return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
} }
X_RESULT InputSystem::SetState(uint32_t user_index, X_RESULT InputSystem::SetState(uint32_t user_index,
X_INPUT_VIBRATION* vibration) { X_INPUT_VIBRATION* vibration) {
SCOPE_profile_cpu_f("hid"); SCOPE_profile_cpu_f("hid");
bool any_connected = false;
for (auto& driver : drivers_) { for (auto& driver : drivers_) {
if (XSUCCEEDED(driver->SetState(user_index, vibration))) { X_RESULT result = driver->SetState(user_index, vibration);
return X_ERROR_SUCCESS; if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
any_connected = true;
}
if (result == X_ERROR_SUCCESS) {
return result;
} }
} }
return X_ERROR_DEVICE_NOT_CONNECTED; return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
} }
X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags, X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags,
X_INPUT_KEYSTROKE* out_keystroke) { X_INPUT_KEYSTROKE* out_keystroke) {
SCOPE_profile_cpu_f("hid"); SCOPE_profile_cpu_f("hid");
bool any_connected = false;
for (auto& driver : drivers_) { for (auto& driver : drivers_) {
if (XSUCCEEDED(driver->GetKeystroke(user_index, flags, out_keystroke))) { X_RESULT result = driver->GetKeystroke(user_index, flags, out_keystroke);
return X_ERROR_SUCCESS; if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
any_connected = true;
}
if (result == X_ERROR_SUCCESS) {
return result;
} }
} }
return X_ERROR_DEVICE_NOT_CONNECTED; return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
} }
} // namespace hid } // namespace hid

View File

@ -155,7 +155,7 @@ SHIM_CALL XamInputGetKeystrokeEx_shim(PPCContext* ppc_state,
uint32_t user_index = SHIM_MEM_32(user_index_ptr); uint32_t user_index = SHIM_MEM_32(user_index_ptr);
XELOGD("XamInputGetKeystroke(%.8X(%.d), %.8X, %.8X)", user_index_ptr, XELOGD("XamInputGetKeystrokeEx(%.8X(%d), %.8X, %.8X)", user_index_ptr,
user_index, flags, keystroke_ptr); user_index, flags, keystroke_ptr);
if (!keystroke_ptr) { if (!keystroke_ptr) {