Skip to content

Commit

Permalink
Revert "More corrections for hot-key detection in SDL1.2"
Browse files Browse the repository at this point in the history
This reverts commit 5bd79ef.

The patch turns out to break some hotkeys such as the command box (:,
which is shift+. on Latin American keyboards). The author suggests
focusing on the hotkey system rewrite that's part of the SDL 2 port
effort rather than trying to patch the old one on 1.12.
  • Loading branch information
irydacea committed Oct 19, 2015
1 parent 5bd79ef commit 4534767
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/hotkey/hotkey_item.cpp
Expand Up @@ -98,9 +98,11 @@ hotkey::hotkey_item& get_hotkey(int character, int keycode,
bool found = false;

for (itor = hotkeys_.begin(); itor != hotkeys_.end(); ++itor) {
// If character is a letter, make sure it can match its key code. Otherwise combinations like Ctrl+Return/Enter can be mistaken for Ctrl+j or Ctrl+m (CR and LF respectively).
// Other printing characters that aren't alphabetic will be handled by key code matching below.
if (itor->get_character() != -1 && isalpha(character) && character == keycode) {
// Special case for Ctrl+Return/Enter keys, which gets resolved to Ctrl-j and Ctrl-m characters (LF and CR respectively).
// In such cases, do not match by character but go straight to key code.
if (itor->get_character() != -1 &&
!(tolower(character) == 'j' && keycode != SDLK_j) &&
!(tolower(character) == 'm' && keycode != SDLK_m)) {
if (character == itor->get_character()) {
if (ctrl == itor->get_ctrl()
&& cmd == itor->get_cmd()
Expand Down Expand Up @@ -533,9 +535,11 @@ void hotkey_item::set_key(int character, int keycode,

// We handle simple cases by character, others by the actual key.
// @ and ` are exceptions related to the space character. Without these, combinations involving Ctrl or Ctrl+Shift often resolve the character value to null (or @ and `).
// If character is read as a letter, only treat it as a letter if its key code matches that character. This covers cases such as Ctrl+Return/Enter, which would otherwise be mis-read as Ctrl+j or Ctrl+m (CR and LF respectively).
if (character != '@' && character != '`' &&
( (isalpha(character) && islower(character) == keycode) || (!isalpha(character) && isprint(character) && !isspace(character)) )) {
// j and m exceptions are to catch Ctrl+Return/Enter, which is interpreted as Ctrl+j and Ctrl+m characters (LF and CR respectively).
if (isprint(character) && !isspace(character) &&
character != '@' && character != '`' &&
!(tolower(character) == 'j' && keycode != SDLK_j) &&
!(tolower(character) == 'm' && keycode != SDLK_m)) {
character_ = character;
ctrl_ = ctrl;
cmd_ = cmd;
Expand Down

0 comments on commit 4534767

Please sign in to comment.