//file for builtin implementations relevent to only clientside VMs (menu+csqc).
#include"quakedef.h"
#include"pr_common.h"
#include"shader.h"
#if defined(CSQC_DAT) || defined(MENU_DAT)
//these two global qcinput variables are the current scan code being passed to qc, if valid. this protects against protected apis where the qc just passes stuff through.
intqcinput_scan;
intqcinput_unicode;
//QC key codes are based upon DP's keycode constants. This is on account of menu.dat coming first.
intMP_TranslateFTEtoQCCodes(intcode)
{
switch(code)
{
caseK_TAB:return9;
caseK_ENTER:return13;
caseK_ESCAPE:return27;
caseK_SPACE:return32;
caseK_BACKSPACE:return127;
caseK_UPARROW:return128;
caseK_DOWNARROW:return129;
caseK_LEFTARROW:return130;
caseK_RIGHTARROW:return131;
caseK_LALT:return132;
caseK_RALT:return-K_RALT;
caseK_LCTRL:return133;
caseK_RCTRL:return-K_RCTRL;
caseK_LSHIFT:return134;
caseK_RSHIFT:return-K_RSHIFT;
caseK_F1:return135;
caseK_F2:return136;
caseK_F3:return137;
caseK_F4:return138;
caseK_F5:return139;
caseK_F6:return140;
caseK_F7:return141;
caseK_F8:return142;
caseK_F9:return143;
caseK_F10:return144;
caseK_F11:return145;
caseK_F12:return146;
caseK_INS:return147;
caseK_DEL:return148;
caseK_PGDN:return149;
caseK_PGUP:return150;
caseK_HOME:return151;
caseK_END:return152;
caseK_PAUSE:return153;
caseK_KP_NUMLOCK:return154;
caseK_CAPSLOCK:return155;
caseK_SCRLCK:return156;
caseK_KP_INS:return157;
caseK_KP_END:return158;
caseK_KP_DOWNARROW:return159;
caseK_KP_PGDN:return160;
caseK_KP_LEFTARROW:return161;
caseK_KP_5:return162;
caseK_KP_RIGHTARROW:return163;
caseK_KP_HOME:return164;
caseK_KP_UPARROW:return165;
caseK_KP_PGUP:return166;
caseK_KP_DEL:return167;
caseK_KP_SLASH:return168;
caseK_KP_STAR:return169;
caseK_KP_MINUS:return170;
caseK_KP_PLUS:return171;
caseK_KP_ENTER:return172;
caseK_KP_EQUALS:return173;
caseK_PRINTSCREEN:return174;
caseK_MOUSE1:return512;
caseK_MOUSE2:return513;
caseK_MOUSE3:return514;
caseK_MWHEELUP:return515;
caseK_MWHEELDOWN:return516;
caseK_MOUSE4:return517;
caseK_MOUSE5:return518;
caseK_MOUSE6:return519;
caseK_MOUSE7:return520;
caseK_MOUSE8:return521;
caseK_MOUSE9:return522;
caseK_MOUSE10:return523;
// case K_MOUSE11: return 524;
// case K_MOUSE12: return 525;
// case K_MOUSE13: return 526;
// case K_MOUSE14: return 527;
// case K_MOUSE15: return 528;
// case K_MOUSE16: return 529;
caseK_JOY1:return768;
caseK_JOY2:return769;
caseK_JOY3:return770;
caseK_JOY4:return771;
// case K_JOY5: return 772;
// case K_JOY6: return 773;
// case K_JOY7: return 774;
// case K_JOY8: return 775;
// case K_JOY9: return 776;
// case K_JOY10: return 777;
// case K_JOY11: return 778;
// case K_JOY12: return 779;
// case K_JOY13: return 780;
// case K_JOY14: return 781;
// case K_JOY15: return 782;
// case K_JOY16: return 783;
caseK_AUX1:return784;
caseK_AUX2:return785;
caseK_AUX3:return786;
caseK_AUX4:return787;
caseK_AUX5:return788;
caseK_AUX6:return789;
caseK_AUX7:return790;
caseK_AUX8:return791;
caseK_AUX9:return792;
caseK_AUX10:return793;
caseK_AUX11:return794;
caseK_AUX12:return795;
caseK_AUX13:return796;
caseK_AUX14:return797;
caseK_AUX15:return798;
caseK_AUX16:return799;
caseK_AUX17:return800;
caseK_AUX18:return801;
caseK_AUX19:return802;
caseK_AUX20:return803;
caseK_AUX21:return804;
caseK_AUX22:return805;
caseK_AUX23:return806;
caseK_AUX24:return807;
caseK_AUX25:return808;
caseK_AUX26:return809;
caseK_AUX27:return810;
caseK_AUX28:return811;
caseK_AUX29:return812;
caseK_AUX30:return813;
caseK_AUX31:return814;
caseK_AUX32:return815;
caseK_VOLUP:return-code;
caseK_VOLDOWN:return-code;
caseK_APP:return-code;
caseK_SEARCH:return-code;
default:returncode;
}
}
intMP_TranslateQCtoFTECodes(intcode)
{
switch(code)
{
case9:returnK_TAB;
case13:returnK_ENTER;
case27:returnK_ESCAPE;
case32:returnK_SPACE;
case127:returnK_BACKSPACE;
case128:returnK_UPARROW;
case129:returnK_DOWNARROW;
case130:returnK_LEFTARROW;
case131:returnK_RIGHTARROW;
case132:returnK_LALT;
case133:returnK_LCTRL;
case134:returnK_LSHIFT;
case135:returnK_F1;
case136:returnK_F2;
case137:returnK_F3;
case138:returnK_F4;
case139:returnK_F5;
case140:returnK_F6;
case141:returnK_F7;
case142:returnK_F8;
case143:returnK_F9;
case144:returnK_F10;
case145:returnK_F11;
case146:returnK_F12;
case147:returnK_INS;
case148:returnK_DEL;
case149:returnK_PGDN;
case150:returnK_PGUP;
case151:returnK_HOME;
case152:returnK_END;
case153:returnK_PAUSE;
case154:returnK_KP_NUMLOCK;
case155:returnK_CAPSLOCK;
case156:returnK_SCRLCK;
case157:returnK_KP_INS;
case158:returnK_KP_END;
case159:returnK_KP_DOWNARROW;
case160:returnK_KP_PGDN;
case161:returnK_KP_LEFTARROW;
case162:returnK_KP_5;
case163:returnK_KP_RIGHTARROW;
case164:returnK_KP_HOME;
case165:returnK_KP_UPARROW;
case166:returnK_KP_PGUP;
case167:returnK_KP_DEL;
case168:returnK_KP_SLASH;
case169:returnK_KP_STAR;
case170:returnK_KP_MINUS;
case171:returnK_KP_PLUS;
case172:returnK_KP_ENTER;
case173:returnK_KP_EQUALS;
case174:returnK_PRINTSCREEN;
case512:returnK_MOUSE1;
case513:returnK_MOUSE2;
case514:returnK_MOUSE3;
case515:returnK_MWHEELUP;
case516:returnK_MWHEELDOWN;
case517:returnK_MOUSE4;
case518:returnK_MOUSE5;
case519:returnK_MOUSE6;
case520:returnK_MOUSE7;
case521:returnK_MOUSE8;
case522:returnK_MOUSE9;
case523:returnK_MOUSE10;
// case 524: return K_MOUSE11;
// case 525: return K_MOUSE12;
// case 526: return K_MOUSE13;
// case 527: return K_MOUSE14;
// case 528: return K_MOUSE15;
// case 529: return K_MOUSE16;
case768:returnK_JOY1;
case769:returnK_JOY2;
case770:returnK_JOY3;
case771:returnK_JOY4;
// case 772: return K_JOY5;
// case 773: return K_JOY6;
// case 774: return K_JOY7;
// case 775: return K_JOY8;
// case 776: return K_JOY9;
// case 777: return K_JOY10;
// case 778: return K_JOY11;
// case 779: return K_JOY12;
// case 780: return K_JOY13;
// case 781: return K_JOY14;
// case 782: return K_JOY15;
// case 783: return K_JOY16;
case784:returnK_AUX1;
case785:returnK_AUX2;
case786:returnK_AUX3;
case787:returnK_AUX4;
case788:returnK_AUX5;
case789:returnK_AUX6;
case790:returnK_AUX7;
case791:returnK_AUX8;
case792:returnK_AUX9;
case793:returnK_AUX10;
case794:returnK_AUX11;
case795:returnK_AUX12;
case796:returnK_AUX13;
case797:returnK_AUX14;
case798:returnK_AUX15;
case799:returnK_AUX16;
case800:returnK_AUX17;
case801:returnK_AUX18;
case802:returnK_AUX19;
case803:returnK_AUX20;
case804:returnK_AUX21;
case805:returnK_AUX22;
case806:returnK_AUX23;
case807:returnK_AUX24;
case808:returnK_AUX25;
case809:returnK_AUX26;
case810:returnK_AUX27;
case811:returnK_AUX28;
case812:returnK_AUX29;
case813:returnK_AUX30;
case814:returnK_AUX31;
case815:returnK_AUX32;
default:
if(code<0)//negative values are 'fte-native' keys, for stuff that the api lacks.
G_FLOAT(OFS_RETURN)=0.5;//give some half-way value if we're singleplayer. NOTE: DP returns 0 in this case, which is kinda useless for things like deciding whether a 'save' menu option can be used.
// qboolean fixedmodes = (prinst->callargc >= 2)?!G_FLOAT(OFS_PARM1):false; //if true, we should return sane-sized modes suitable for a window... or the mod could make up its own, but whatever.