+// These tables are used to convert Qt keycodes into human readable form. Note that
+// a lot of these are just filler.
+char ControllerWidget::keyName1[96][16] = {
+ "Space",
+ "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
+ "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
+ "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
+ "[", "\\", "]", "^", "_", "`",
+ "$61", "$62", "$63", "$64", "$65", "$66", "$67", "$68", "$69", "$6A", "$6B", "$6C", "$6D",
+ "$6E", "$6F", "$70", "$71", "$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79", "$7A",
+ "{", "|", "}", "~"
+};
+
+char ControllerWidget::keyName2[64][16] = {
+ "Esc", "Tab", "BTab", "BS", "Ret", "Ent", "Ins", "Del", "Pause", "Prt", "SRq", "Clr",
+ "$C", "$D", "$E", "$F", "Hm", "End", "Lf", "Up", "Rt", "Dn", "PgU", "PgD", "$18",
+ "$19", "$1A", "$1B", "$1C", "$1D", "$1E", "$1F", "Shf", "Ctl", "Mta", "Alt",
+ "Cap", "Num", "ScL", "$27", "$28", "$29", "$2A", "$2B", "$2C", "$2D", "$2E", "$2F",
+ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13",
+ "F14", "F15", "F16"
+};
+
+char ControllerWidget::hatName[4][16] = { "Up", "Rt", "Dn", "Lf" };
+
+char ControllerWidget::axisName[2][8] = { "+", "-" };
+
+// This is hard-coded crap. It's crap-tastic!
+// These are the positions to draw the button names at, ordered by the BUTTON_* sequence
+// found in joystick.h.
+int ControllerWidget::buttonPos[21][2] = { { 74, 32 }, { 71, 67 }, { 53, 49 }, { 93, 49 },
+ { 110, 200 }, { 110, 175 }, { 110, 151 }, { 110, 126 },
+ { 148, 200 }, { 148, 175 }, { 148, 151 }, { 148, 126 },
+ { 186, 200 }, { 186, 175 }, { 186, 151 }, { 186, 126 },
+ { 234, 31 }, { 216, 51 }, { 199, 71 }, { 164-11, 101-30 }, { 141-11, 108+13-30 }
+};
+
+
+ControllerWidget::ControllerWidget(QWidget * parent/*= 0*/): QWidget(parent),
+ controllerPic(":/res/controller.png"), widgetSize(controllerPic.size()),
+ keyToHighlight(-1), mouseDown(false)