From: terencehill Date: Fri, 25 Jun 2010 23:28:04 +0000 (+0200) Subject: Fix the K_KP_* constants, they have different values from the corresponding ones... X-Git-Tag: xonotic-v0.1.0preview~517 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=0d8a90b8360a7f4ce80cb84a67e899d44fd2a2b1 Fix the K_KP_* constants, they have different values from the corresponding ones in the engine file keys.h (where the assignments are implicit). Now that they are correct, allow the use of numpad keys in the menu. --- diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 3e2cf69057..29d2704fd4 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -144,6 +144,7 @@ const float K_RIGHTARROW = 131; const float K_ALT = 132; const float K_CTRL = 133; const float K_SHIFT = 134; + const float K_F1 = 135; const float K_F2 = 136; const float K_F3 = 137; @@ -156,6 +157,7 @@ const float K_F9 = 143; const float K_F10 = 144; const float K_F11 = 145; const float K_F12 = 146; + const float K_INS = 147; const float K_DEL = 148; const float K_PGDN = 149; @@ -163,21 +165,38 @@ const float K_PGUP = 150; const float K_HOME = 151; const float K_END = 152; -const float K_KP_HOME = 160; -const float K_KP_UPARROW = 161; -const float K_KP_PGUP = 162; -const float K_KP_LEFTARROW = 163; -const float K_KP_5 = 164; -const float K_KP_RIGHTARROW = 165; -const float K_KP_END = 166; -const float K_KP_DOWNARROW = 167; -const float K_KP_PGDN = 168; -const float K_KP_ENTER = 169; -const float K_KP_INS = 170; -const float K_KP_DEL = 171; -const float K_KP_SLASH = 172; -const float K_KP_MINUS = 173; -const float K_KP_PLUS = 174; +const float K_NUMLOCK = 154; +const float K_CAPSLOCK = 155; +const float K_SCROLLOCK = 156; + +const float K_KP_0 = 157; +const float K_KP_INS = K_KP_0; +const float K_KP_1 = 158; +const float K_KP_END = K_KP_1; +const float K_KP_2 = 159; +const float K_KP_DOWNARROW = K_KP_2; +const float K_KP_3 = 160; +const float K_KP_PGDN = K_KP_3; +const float K_KP_4 = 161; +const float K_KP_LEFTARROW = K_KP_4; +const float K_KP_5 = 162; +const float K_KP_6 = 163; +const float K_KP_RIGHTARROW = K_KP_6; +const float K_KP_7 = 164; +const float K_KP_HOME = K_KP_7; +const float K_KP_8 = 165; +const float K_KP_UPARROW = K_KP_8; +const float K_KP_9 = 166; +const float K_KP_PGUP = K_KP_9; +const float K_KP_PERIOD = 167; +const float K_KP_DEL = K_KP_PERIOD; +const float K_KP_DIVIDE = 168; +const float K_KP_SLASH = K_KP_DIVIDE; +const float K_KP_MULTIPLY = 169; +const float K_KP_MINUS = 170; +const float K_KP_PLUS = 171; +const float K_KP_ENTER = 172; +const float K_KP_EQUALS = 173; const float K_PAUSE = 255; diff --git a/qcsrc/menu/item/inputbox.c b/qcsrc/menu/item/inputbox.c index cb1b32e8b1..2d64590306 100644 --- a/qcsrc/menu/item/inputbox.c +++ b/qcsrc/menu/item/inputbox.c @@ -96,15 +96,19 @@ float InputBox_keyDown(entity me, float key, float ascii, float shift) } switch(key) { + case K_KP_LEFTARROW: case K_LEFTARROW: me.cursorPos -= 1; return 1; + case K_KP_RIGHTARROW: case K_RIGHTARROW: me.cursorPos += 1; return 1; + case K_KP_HOME: case K_HOME: me.cursorPos = 0; return 1; + case K_KP_END: case K_END: me.cursorPos = strlen(me.text); return 1; @@ -115,6 +119,7 @@ float InputBox_keyDown(entity me, float key, float ascii, float shift) me.setText(me, strcat(substring(me.text, 0, me.cursorPos), substring(me.text, me.cursorPos + 1, strlen(me.text) - me.cursorPos - 1))); } return 1; + case K_KP_DEL: case K_DEL: if(shift & S_CTRL) me.setText(me, ""); diff --git a/qcsrc/menu/item/listbox.c b/qcsrc/menu/item/listbox.c index 3dd873c33a..4d6174cc59 100644 --- a/qcsrc/menu/item/listbox.c +++ b/qcsrc/menu/item/listbox.c @@ -68,20 +68,20 @@ float ListBox_keyDown(entity me, float key, float ascii, float shift) me.scrollPos = min(me.scrollPos + 0.5, me.nItems * me.itemHeight - 1); me.setSelected(me, max(me.selectedItem, ceil(me.scrollPos / me.itemHeight))); } - else if(key == K_PGUP) + else if(key == K_PGUP || key == K_KP_PGUP) me.setSelected(me, me.selectedItem - 1 / me.itemHeight); - else if(key == K_PGDN) + else if(key == K_PGDN || key == K_KP_PGDN) me.setSelected(me, me.selectedItem + 1 / me.itemHeight); - else if(key == K_UPARROW) + else if(key == K_UPARROW || key == K_KP_UPARROW) me.setSelected(me, me.selectedItem - 1); - else if(key == K_DOWNARROW) + else if(key == K_DOWNARROW || key == K_KP_DOWNARROW) me.setSelected(me, me.selectedItem + 1); - else if(key == K_HOME) + else if(key == K_HOME || key == K_KP_HOME) { me.scrollPos = 0; me.setSelected(me, 0); } - else if(key == K_END) + else if(key == K_END || key == K_KP_END) { me.scrollPos = max(0, me.nItems * me.itemHeight - 1); me.setSelected(me, me.nItems - 1); diff --git a/qcsrc/menu/item/slider.c b/qcsrc/menu/item/slider.c index 92f3b55fe1..1f01cb4e2e 100644 --- a/qcsrc/menu/item/slider.c +++ b/qcsrc/menu/item/slider.c @@ -104,7 +104,7 @@ float Slider_keyDown(entity me, float key, float ascii, float shift) if(me.disabled) return 0; inRange = (almost_in_bounds(me.valueMin, me.value, me.valueMax)); - if(key == K_LEFTARROW) + if(key == K_LEFTARROW || key == K_KP_LEFTARROW) { if(inRange) me.setValue(me, median(me.valueMin, me.value - me.valueKeyStep, me.valueMax)); @@ -112,7 +112,7 @@ float Slider_keyDown(entity me, float key, float ascii, float shift) me.setValue(me, me.valueMax); return 1; } - if(key == K_RIGHTARROW) + if(key == K_RIGHTARROW || key == K_KP_RIGHTARROW) { if(inRange) me.setValue(me, median(me.valueMin, me.value + me.valueKeyStep, me.valueMax)); @@ -120,7 +120,7 @@ float Slider_keyDown(entity me, float key, float ascii, float shift) me.setValue(me, me.valueMin); return 1; } - if(key == K_PGUP) + if(key == K_PGUP || key == K_KP_PGUP) { if(inRange) me.setValue(me, median(me.valueMin, me.value - me.valuePageStep, me.valueMax)); @@ -128,7 +128,7 @@ float Slider_keyDown(entity me, float key, float ascii, float shift) me.setValue(me, me.valueMax); return 1; } - if(key == K_PGDN) + if(key == K_PGDN || key == K_KP_PGDN) { if(inRange) me.setValue(me, median(me.valueMin, me.value + me.valuePageStep, me.valueMax)); @@ -136,12 +136,12 @@ float Slider_keyDown(entity me, float key, float ascii, float shift) me.setValue(me, me.valueMin); return 1; } - if(key == K_HOME) + if(key == K_HOME || key == K_KP_HOME) { me.setValue(me, me.valueMin); return 1; } - if(key == K_END) + if(key == K_END || key == K_KP_END) { me.setValue(me, me.valueMax); return 1; diff --git a/qcsrc/menu/xonotic/charmap.c b/qcsrc/menu/xonotic/charmap.c index 21a4aad6f3..a448e3547e 100644 --- a/qcsrc/menu/xonotic/charmap.c +++ b/qcsrc/menu/xonotic/charmap.c @@ -97,26 +97,33 @@ float XonoticCharmap_keyDown(entity me, float key, float ascii, float shift) switch(key) { case K_LEFTARROW: + case K_KP_LEFTARROW: me.selectedCharacterCell = mod(me.selectedCharacterCell + 159, 160); return 1; case K_RIGHTARROW: + case K_KP_RIGHTARROW: me.selectedCharacterCell = mod(me.selectedCharacterCell + 1, 160); return 1; case K_UPARROW: + case K_KP_UPARROW: me.selectedCharacterCell = mod(me.selectedCharacterCell + 144, 160); return 1; case K_DOWNARROW: + case K_KP_DOWNARROW: me.selectedCharacterCell = mod(me.selectedCharacterCell + 16, 160); return 1; case K_HOME: + case K_KP_HOME: me.selectedCharacterCell = 0; return 1; case K_END: + case K_KP_END: me.selectedCharacterCell = 159; return 1; case K_SPACE: case K_ENTER: case K_INS: + case K_KP_INS: me.controlledTextbox.enterText(me.controlledTextbox, CharMap_CellToChar(me.selectedCharacterCell)); return 1; default: diff --git a/qcsrc/menu/xonotic/credits.c b/qcsrc/menu/xonotic/credits.c index 5c2f1585c4..86609a6598 100644 --- a/qcsrc/menu/xonotic/credits.c +++ b/qcsrc/menu/xonotic/credits.c @@ -87,22 +87,21 @@ void XonoticCreditsList_drawListBoxItem(entity me, float i, vector absSize, floa draw_CenterText(me.realUpperMargin * eY + 0.5 * eX, s, me.realFontSize, theColor, theAlpha, 0); } -float XonoticCreditsList_keyDown(entity me, float scan, float ascii, float shift) +float XonoticCreditsList_keyDown(entity me, float key, float ascii, float shift) { float i; me.dragScrollTimer = time; me.scrolling = 0; - - if(scan == K_PGUP) + if(key == K_PGUP || key == K_KP_PGUP) me.scrollPos = max(me.scrollPos - 0.5, 0); - else if(scan == K_PGDN) + else if(key == K_PGDN || key == K_KP_PGDN) me.scrollPos = min(me.scrollPos + 0.5, me.nItems * me.itemHeight - 1); - else if(scan == K_UPARROW) + else if(key == K_UPARROW || key == K_KP_UPARROW) me.scrollPos = max(me.scrollPos - me.itemHeight, 0); - else if(scan == K_DOWNARROW) + else if(key == K_DOWNARROW || key == K_KP_DOWNARROW) me.scrollPos = min(me.scrollPos + me.itemHeight, me.nItems * me.itemHeight - 1); else - return SUPER(XonoticCreditsList).keyDown(me, scan, ascii, shift); + return SUPER(XonoticCreditsList).keyDown(me, key, ascii, shift); i = min(me.selectedItem, floor((me.scrollPos + 1) / me.itemHeight - 1)); i = max(i, ceil(me.scrollPos / me.itemHeight));