Skip to content

Commit

Permalink
correct handling of uppercase letters and shift+number keys
Browse files Browse the repository at this point in the history
  • Loading branch information
King-Slide committed Aug 28, 2018
1 parent b095c92 commit d09babc
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void input_manager_process_text_input(struct input_manager *input_manager,
return;
}
// || SDL_strdup(event->text) == "\r"
char special_chars[] = " 0123456789abcdefghijklmnopqrstuvwxyz";
if (input_manager->hybrid_key_events && strpbrk(special_chars, SDL_strdup(event->text)) != NULL) {
char raw_characters[] = " 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ";
if (input_manager->hybrid_key_events && strpbrk(raw_characters, SDL_strdup(event->text)) != NULL) {
// we will forward the raw key events instead
return;
}
Expand All @@ -155,16 +155,16 @@ void input_manager_process_text_input(struct input_manager *input_manager,
void input_manager_process_key(struct input_manager *input_manager,
const SDL_KeyboardEvent *event) {
SDL_bool ctrl = event->keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
SDL_bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
SDL_Keycode keycode = event->keysym.sym;

// capture all Ctrl events
if (ctrl) {
SDL_bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
if (shift) {
// currently, there is no shortcut involving SHIFT
return;
}

SDL_Keycode keycode = event->keysym.sym;
int action = event->type == SDL_KEYDOWN ? ACTION_DOWN : ACTION_UP;
SDL_bool repeat = event->repeat;
switch (keycode) {
Expand Down Expand Up @@ -248,6 +248,23 @@ void input_manager_process_key(struct input_manager *input_manager,
return;
}

if (shift && input_manager->hybrid_key_events) {
// shift + numbers shouldn't be handled like raw_key_events in hybrid mode
switch (keycode) {
case SDLK_1:
case SDLK_2:
case SDLK_3:
case SDLK_4:
case SDLK_5:
case SDLK_6:
case SDLK_7:
case SDLK_8:
case SDLK_9:
case SDLK_0:
return;
}
}

struct control_event control_event;
SDL_bool raw_key_events = input_manager->raw_key_events | input_manager->hybrid_key_events;
if (input_key_from_sdl_to_android(event, &control_event, raw_key_events)) {
Expand Down

0 comments on commit d09babc

Please sign in to comment.