Avoid useless variables initialization
Initialize variables only when necessary.
This commit is contained in:
parent
84ad6633a6
commit
ab780ce26d
1 changed files with 4 additions and 3 deletions
|
@ -130,23 +130,24 @@ void input_manager_process_text_input(struct input_manager *input_manager,
|
||||||
|
|
||||||
void input_manager_process_key(struct input_manager *input_manager,
|
void input_manager_process_key(struct input_manager *input_manager,
|
||||||
const SDL_KeyboardEvent *event) {
|
const SDL_KeyboardEvent *event) {
|
||||||
SDL_Keycode keycode = event->keysym.sym;
|
|
||||||
SDL_bool ctrl = event->keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
|
SDL_bool ctrl = event->keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
|
||||||
SDL_bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
|
|
||||||
SDL_bool repeat = event->repeat;
|
|
||||||
|
|
||||||
// capture all Ctrl events
|
// capture all Ctrl events
|
||||||
if (ctrl) {
|
if (ctrl) {
|
||||||
|
SDL_bool repeat = event->repeat;
|
||||||
|
|
||||||
// only consider keydown events, and ignore repeated events
|
// only consider keydown events, and ignore repeated events
|
||||||
if (repeat || event->type != SDL_KEYDOWN) {
|
if (repeat || event->type != SDL_KEYDOWN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
// currently, there is no shortcut implying SHIFT
|
// currently, there is no shortcut implying SHIFT
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Keycode keycode = event->keysym.sym;
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case SDLK_h:
|
case SDLK_h:
|
||||||
action_home(input_manager->controller);
|
action_home(input_manager->controller);
|
||||||
|
|
Loading…
Reference in a new issue