Skip to content
This repository
Browse code

Merge pull request #2149 from jhsrennie/allowhex

Allow key ids in keyboard.xml to be in hex
  • Loading branch information...
commit 918afb93c4de5356a0749d1636c9917b28e22944 2 parents d70bd10 + 5c4c6f9
John Rennie authored January 31, 2013
14  xbmc/input/ButtonTranslator.cpp
@@ -1268,9 +1268,17 @@ uint32_t CButtonTranslator::TranslateKeyboardButton(TiXmlElement *pButton)
1268 1268
   CStdString strKey = szButton;
1269 1269
   if (strKey.Equals("key"))
1270 1270
   {
1271  
-    int id = 0;
1272  
-    if (pButton->QueryIntAttribute("id", &id) == TIXML_SUCCESS)
1273  
-      button_id = (uint32_t)id;
  1271
+    std::string strID;
  1272
+    if (pButton->QueryValueAttribute("id", &strID) == TIXML_SUCCESS)
  1273
+    {
  1274
+      const char *str = strID.c_str();
  1275
+      char *endptr;
  1276
+      long int id = strtol(str, &endptr, 0);
  1277
+      if (endptr - str != strlen(str) || id <= 0 || id > 0x00FFFFFF)
  1278
+        CLog::Log(LOGDEBUG, "%s - invalid key id %s", __FUNCTION__, strID.c_str());
  1279
+      else
  1280
+        button_id = (uint32_t) id;
  1281
+    }
1274 1282
     else
1275 1283
       CLog::Log(LOGERROR, "Keyboard Translator: `key' button has no id");
1276 1284
   }
4  xbmc/input/KeyboardStat.cpp
@@ -84,7 +84,7 @@ const CKey CKeyboardStat::ProcessKeyDown(XBMC_keysym& keysym)
84 84
   if (keysym.mod & XBMCKMOD_SUPER)
85 85
     modifiers |= CKey::MODIFIER_SUPER;
86 86
 
87  
-  CLog::Log(LOGDEBUG, "Keyboard: scancode: %02x, sym: %04x, unicode: %04x, modifier: %x", keysym.scancode, keysym.sym, keysym.unicode, keysym.mod);
  87
+  CLog::Log(LOGDEBUG, "Keyboard: scancode: 0x%02x, sym: 0x%04x, unicode: 0x%04x, modifier: 0x%x", keysym.scancode, keysym.sym, keysym.unicode, keysym.mod);
88 88
 
89 89
   // The keysym.unicode is usually valid, even if it is zero. A zero
90 90
   // unicode just means this is a non-printing keypress. The ascii and
@@ -211,7 +211,7 @@ CStdString CKeyboardStat::GetKeyName(int KeyID)
211 211
     keyname.append(keytable.keyname);
212 212
   else
213 213
     keyname.AppendFormat("%i", keyid);
214  
-  keyname.AppendFormat(" (%02x)", KeyID);
  214
+  keyname.AppendFormat(" (0x%02x)", KeyID);
215 215
 
216 216
   return keyname;
217 217
 }

0 notes on commit 918afb9

Please sign in to comment.
Something went wrong with that request. Please try again.