Added support for local multiplayer
This commit is contained in:
@@ -26,6 +26,18 @@ void InputSystem::AddDriver(std::unique_ptr<InputDriver> driver) {
|
||||
drivers_.push_back(std::move(driver));
|
||||
}
|
||||
|
||||
void InputSystem::UpdateUsedSlot(uint8_t slot, bool connected) {
|
||||
if (slot == 0xFF) {
|
||||
slot = 0;
|
||||
}
|
||||
|
||||
if (connected) {
|
||||
connected_slot |= (1 << slot);
|
||||
} else {
|
||||
connected_slot &= ~(1 << slot);
|
||||
}
|
||||
}
|
||||
|
||||
X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags,
|
||||
X_INPUT_CAPABILITIES* out_caps) {
|
||||
SCOPE_profile_cpu_f("hid");
|
||||
@@ -37,9 +49,11 @@ X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags,
|
||||
any_connected = true;
|
||||
}
|
||||
if (result == X_ERROR_SUCCESS) {
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
@@ -53,9 +67,11 @@ X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) {
|
||||
any_connected = true;
|
||||
}
|
||||
if (result == X_ERROR_SUCCESS) {
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
@@ -70,9 +86,11 @@ X_RESULT InputSystem::SetState(uint32_t user_index,
|
||||
any_connected = true;
|
||||
}
|
||||
if (result == X_ERROR_SUCCESS) {
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
@@ -87,9 +105,11 @@ X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags,
|
||||
any_connected = true;
|
||||
}
|
||||
if (result == X_ERROR_SUCCESS || result == X_ERROR_EMPTY) {
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
UpdateUsedSlot(user_index, any_connected);
|
||||
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user