summaryrefslogtreecommitdiff
path: root/src/keycode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/keycode.cpp')
-rw-r--r--src/keycode.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/keycode.cpp b/src/keycode.cpp
index 3551c385a..cedd0803b 100644
--- a/src/keycode.cpp
+++ b/src/keycode.cpp
@@ -246,9 +246,9 @@ static const struct table_key table[] = {
struct table_key lookup_keyname(const char *name)
{
- for (u16 i = 0; i < ARRLEN(table); i++) {
- if (strcmp(table[i].Name, name) == 0)
- return table[i];
+ for (const auto &table_key : table) {
+ if (strcmp(table_key.Name, name) == 0)
+ return table_key;
}
throw UnknownKeycode(name);
@@ -256,9 +256,9 @@ struct table_key lookup_keyname(const char *name)
struct table_key lookup_keykey(irr::EKEY_CODE key)
{
- for (u16 i = 0; i < ARRLEN(table); i++) {
- if (table[i].Key == key)
- return table[i];
+ for (const auto &table_key : table) {
+ if (table_key.Key == key)
+ return table_key;
}
std::ostringstream os;
@@ -268,9 +268,9 @@ struct table_key lookup_keykey(irr::EKEY_CODE key)
struct table_key lookup_keychar(wchar_t Char)
{
- for (u16 i = 0; i < ARRLEN(table); i++) {
- if (table[i].Char == Char)
- return table[i];
+ for (const auto &table_key : table) {
+ if (table_key.Char == Char)
+ return table_key;
}
std::ostringstream os;
@@ -285,7 +285,9 @@ KeyPress::KeyPress(const char *name)
Char = L'\0';
m_name = "";
return;
- } else if (strlen(name) <= 4) {
+ }
+
+ if (strlen(name) <= 4) {
// Lookup by resulting character
int chars_read = mbtowc(&Char, name, 1);
FATAL_ERROR_IF(chars_read != 1, "Unexpected multibyte character");
@@ -339,7 +341,7 @@ const char *KeyPress::sym() const
const char *KeyPress::name() const
{
- if (m_name == "")
+ if (m_name.empty())
return "";
const char *ret;
if (valid_kcode(Key))