Ja es pot gastar el teclat com a control independent del primer mando
Ja pot jugar un jugador amb teclat i altre amb mando Es pot asignar el teclat a qualsevol dels dos jugadors Continua podentse gastar mando i teclat a l'hora per al mateix jugador
This commit is contained in:
@@ -68,18 +68,13 @@ void Input::bindGameControllerButton(int controller_index, InputType input_targe
|
||||
}
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
bool Input::checkInput(InputType input, bool repeat, int device, int controller_index)
|
||||
bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, int controller_index)
|
||||
{
|
||||
bool success_keyboard = false;
|
||||
bool success_controller = false;
|
||||
const int input_index = static_cast<int>(input);
|
||||
|
||||
if (device == INPUT_USE_ANY)
|
||||
{
|
||||
controller_index = 0;
|
||||
}
|
||||
|
||||
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||
if (device == InputDeviceToUse::KEYBOARD || device == InputDeviceToUse::ANY)
|
||||
{
|
||||
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
@@ -123,8 +118,8 @@ bool Input::checkInput(InputType input, bool repeat, int device, int controller_
|
||||
}
|
||||
}
|
||||
|
||||
if (gameControllerFound() && controller_index < num_gamepads_)
|
||||
if ((device == INPUT_USE_GAMECONTROLLER) || (device == INPUT_USE_ANY))
|
||||
if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_)
|
||||
if ((device == InputDeviceToUse::CONTROLLER) || (device == InputDeviceToUse::ANY))
|
||||
{
|
||||
success_controller = checkAxisInput(input, controller_index);
|
||||
if (!success_controller)
|
||||
@@ -174,14 +169,14 @@ bool Input::checkInput(InputType input, bool repeat, int device, int controller_
|
||||
}
|
||||
|
||||
// Comprueba si hay almenos un input activo
|
||||
bool Input::checkAnyInput(int device, int controller_index)
|
||||
bool Input::checkAnyInput(InputDeviceToUse device, int controller_index)
|
||||
{
|
||||
if (device == INPUT_USE_ANY)
|
||||
if (device == InputDeviceToUse::ANY)
|
||||
{
|
||||
controller_index = 0;
|
||||
}
|
||||
|
||||
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||
if (device == InputDeviceToUse::KEYBOARD || device == InputDeviceToUse::ANY)
|
||||
{
|
||||
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
@@ -197,7 +192,7 @@ bool Input::checkAnyInput(int device, int controller_index)
|
||||
|
||||
if (gameControllerFound())
|
||||
{
|
||||
if (device == INPUT_USE_GAMECONTROLLER || device == INPUT_USE_ANY)
|
||||
if (device == InputDeviceToUse::CONTROLLER || device == InputDeviceToUse::ANY)
|
||||
{
|
||||
for (int i = 0; i < (int)controller_bindings_.size(); ++i)
|
||||
{
|
||||
@@ -217,7 +212,7 @@ bool Input::checkAnyInput(int device, int controller_index)
|
||||
int Input::checkAnyButtonPressed(bool repeat)
|
||||
{
|
||||
// Si está pulsado el botón de servicio, ningún botón se puede considerar pulsado
|
||||
if (checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, INPUT_USE_ANY))
|
||||
if (checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::ANY))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -226,7 +221,7 @@ int Input::checkAnyButtonPressed(bool repeat)
|
||||
for (auto bi : button_inputs_)
|
||||
{
|
||||
// Comprueba el teclado
|
||||
if (checkInput(bi, repeat, INPUT_USE_KEYBOARD))
|
||||
if (checkInput(bi, repeat, InputDeviceToUse::KEYBOARD))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -234,7 +229,7 @@ int Input::checkAnyButtonPressed(bool repeat)
|
||||
// Comprueba los mandos
|
||||
for (int i = 0; i < num_gamepads_; ++i)
|
||||
{
|
||||
if (checkInput(bi, repeat, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (checkInput(bi, repeat, InputDeviceToUse::CONTROLLER, i))
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
@@ -328,14 +323,14 @@ int Input::getJoyIndex(int id) const
|
||||
}
|
||||
|
||||
// Muestra por consola los controles asignados
|
||||
void Input::printBindings(int device, int controller_index) const
|
||||
void Input::printBindings(InputDeviceToUse device, int controller_index) const
|
||||
{
|
||||
if (device == INPUT_USE_ANY || device == INPUT_USE_KEYBOARD)
|
||||
if (device == InputDeviceToUse::ANY || device == InputDeviceToUse::KEYBOARD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (device == INPUT_USE_GAMECONTROLLER)
|
||||
if (device == InputDeviceToUse::CONTROLLER)
|
||||
{
|
||||
if (controller_index >= num_gamepads_)
|
||||
{
|
||||
@@ -416,4 +411,10 @@ bool Input::checkAxisInput(InputType input, int controller_index) const
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el indice de mando que usará el teclado
|
||||
void Input::setKeyboardIndex(int index)
|
||||
{
|
||||
keyboard_index_ = index;
|
||||
}
|
||||
Reference in New Issue
Block a user