Compare commits
2 Commits
14f970011e
...
f11469d06b
| Author | SHA1 | Date | |
|---|---|---|---|
| f11469d06b | |||
| a61dda4875 |
16
main.cpp
16
main.cpp
@@ -93,10 +93,10 @@ int main(int argc, char *argv[])
|
||||
Input *input = new Input(asset->get("gamecontrollerdb.txt"));
|
||||
input->setVerbose(options->console);
|
||||
input->discoverGameController();
|
||||
input->bindKey(input_up, SDL_SCANCODE_UP);
|
||||
input->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||||
input->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||
input->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||||
input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
||||
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
||||
input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
|
||||
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
|
||||
|
||||
// Inicializa el texto
|
||||
Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer);
|
||||
@@ -156,19 +156,19 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
string inputPressed = "";
|
||||
if (input->checkInput(input_left))
|
||||
if (input->checkInput(INPUT_LEFT))
|
||||
{
|
||||
inputPressed = "LEFT";
|
||||
}
|
||||
if (input->checkInput(input_right))
|
||||
if (input->checkInput(INPUT_RIGHT))
|
||||
{
|
||||
inputPressed = "RIGHT";
|
||||
}
|
||||
if (input->checkInput(input_up))
|
||||
if (input->checkInput(INPUT_UP))
|
||||
{
|
||||
inputPressed = "UP";
|
||||
}
|
||||
if (input->checkInput(input_down))
|
||||
if (input->checkInput(INPUT_DOWN))
|
||||
{
|
||||
inputPressed = "DOWN";
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ Input::Input(std::string file)
|
||||
keyBindings_t kb;
|
||||
kb.scancode = 0;
|
||||
kb.active = false;
|
||||
keyBindings.resize(input_number_of_inputs, kb);
|
||||
keyBindings.resize(INPUT_TOTAL, kb);
|
||||
|
||||
GameControllerBindings_t gcb;
|
||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
gcb.active = false;
|
||||
gameControllerBindings.resize(input_number_of_inputs, gcb);
|
||||
gameControllerBindings.resize(INPUT_TOTAL, gcb);
|
||||
|
||||
verbose = true;
|
||||
enabled = true;
|
||||
|
||||
@@ -7,35 +7,44 @@
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
enum inputs_e
|
||||
{
|
||||
// Inputs obligatorios
|
||||
input_null,
|
||||
input_up,
|
||||
input_down,
|
||||
input_left,
|
||||
input_right,
|
||||
input_pause,
|
||||
input_exit,
|
||||
input_accept,
|
||||
input_cancel,
|
||||
// Tipos diferentes de eventos de entrada
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_UP 1
|
||||
#define INPUT_DOWN 2
|
||||
#define INPUT_LEFT 3
|
||||
#define INPUT_RIGHT 4
|
||||
#define INPUT_BUTTON_1 5
|
||||
#define INPUT_BUTTON_2 6
|
||||
#define INPUT_BUTTON_3 7
|
||||
#define INPUT_BUTTON_4 8
|
||||
#define INPUT_BUTTON_5 9
|
||||
#define INPUT_BUTTON_6 10
|
||||
#define INPUT_BUTTON_7 11
|
||||
#define INPUT_BUTTON_8 12
|
||||
#define INPUT_BUTTON_9 13
|
||||
#define INPUT_BUTTON_10 14
|
||||
#define INPUT_BUTTON_11 15
|
||||
#define INPUT_BUTTON_12 16
|
||||
#define INPUT_BUTTON_13 17
|
||||
#define INPUT_BUTTON_14 18
|
||||
#define INPUT_BUTTON_15 19
|
||||
#define INPUT_BUTTON_16 20
|
||||
#define INPUT_BUTTON_17 21
|
||||
#define INPUT_BUTTON_18 22
|
||||
#define INPUT_BUTTON_19 23
|
||||
#define INPUT_BUTTON_20 24
|
||||
#define INPUT_PAUSE 25
|
||||
#define INPUT_EXIT 26
|
||||
#define INPUT_ACCEPT 27
|
||||
#define INPUT_CANCEL 28
|
||||
|
||||
// Inputs personalizados
|
||||
input_jump,
|
||||
input_window_fullscreen,
|
||||
input_window_inc_size,
|
||||
input_window_dec_size,
|
||||
input_toggle_border,
|
||||
input_switch_music,
|
||||
input_swap_palette,
|
||||
|
||||
// Input obligatorio
|
||||
input_number_of_inputs
|
||||
};
|
||||
#define INPUT_TOTAL 29
|
||||
|
||||
// Para saber si el input se puede repetir sin soltarlo
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
|
||||
// Tipo de control asociado
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
@@ -850,7 +850,7 @@ void Menu::setDefaultActionWhenCancel(int item)
|
||||
// Gestiona la entrada de teclado y mando durante el menu
|
||||
void Menu::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_up, REPEAT_FALSE))
|
||||
if (input->checkInput(INPUT_UP, REPEAT_FALSE))
|
||||
{
|
||||
if (decreaseSelectorIndex())
|
||||
{
|
||||
@@ -861,7 +861,7 @@ void Menu::checkInput()
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_down, REPEAT_FALSE))
|
||||
if (input->checkInput(INPUT_DOWN, REPEAT_FALSE))
|
||||
{
|
||||
if (increaseSelectorIndex())
|
||||
{
|
||||
@@ -872,7 +872,7 @@ void Menu::checkInput()
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_accept, REPEAT_FALSE))
|
||||
if (input->checkInput(INPUT_ACCEPT, REPEAT_FALSE))
|
||||
{
|
||||
itemSelected = selector.index;
|
||||
if (soundAccept)
|
||||
@@ -881,7 +881,7 @@ void Menu::checkInput()
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_cancel, REPEAT_FALSE))
|
||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE))
|
||||
{
|
||||
itemSelected = defaultActionWhenCancel;
|
||||
if (soundCancel)
|
||||
|
||||
Reference in New Issue
Block a user