123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727 |
- #ifndef __SYS_PUBLIC__
- #define __SYS_PUBLIC__
- #include "../idlib/CmdArgs.h"
- enum cpuid_t {
- CPUID_NONE = 0x00000,
- CPUID_UNSUPPORTED = 0x00001,
- CPUID_GENERIC = 0x00002,
- CPUID_INTEL = 0x00004,
- CPUID_AMD = 0x00008,
- CPUID_MMX = 0x00010,
- CPUID_3DNOW = 0x00020,
- CPUID_SSE = 0x00040,
- CPUID_SSE2 = 0x00080,
- CPUID_SSE3 = 0x00100,
- CPUID_ALTIVEC = 0x00200,
- CPUID_HTT = 0x01000,
- CPUID_CMOV = 0x02000,
- CPUID_FTZ = 0x04000,
- CPUID_DAZ = 0x08000,
- CPUID_XENON = 0x10000,
- CPUID_CELL = 0x20000
- };
- enum fpuExceptions_t {
- FPU_EXCEPTION_INVALID_OPERATION = 1,
- FPU_EXCEPTION_DENORMALIZED_OPERAND = 2,
- FPU_EXCEPTION_DIVIDE_BY_ZERO = 4,
- FPU_EXCEPTION_NUMERIC_OVERFLOW = 8,
- FPU_EXCEPTION_NUMERIC_UNDERFLOW = 16,
- FPU_EXCEPTION_INEXACT_RESULT = 32
- };
- enum fpuPrecision_t {
- FPU_PRECISION_SINGLE = 0,
- FPU_PRECISION_DOUBLE = 1,
- FPU_PRECISION_DOUBLE_EXTENDED = 2
- };
- enum fpuRounding_t {
- FPU_ROUNDING_TO_NEAREST = 0,
- FPU_ROUNDING_DOWN = 1,
- FPU_ROUNDING_UP = 2,
- FPU_ROUNDING_TO_ZERO = 3
- };
- enum joystickAxis_t {
- AXIS_LEFT_X,
- AXIS_LEFT_Y,
- AXIS_RIGHT_X,
- AXIS_RIGHT_Y,
- AXIS_LEFT_TRIG,
- AXIS_RIGHT_TRIG,
- MAX_JOYSTICK_AXIS
- };
- enum sysEventType_t {
- SE_NONE,
- SE_KEY,
- SE_CHAR,
- SE_MOUSE,
- SE_MOUSE_ABSOLUTE,
- SE_MOUSE_LEAVE,
- SE_JOYSTICK,
- SE_CONSOLE
- };
- enum sys_mEvents {
- M_ACTION1,
- M_ACTION2,
- M_ACTION3,
- M_ACTION4,
- M_ACTION5,
- M_ACTION6,
- M_ACTION7,
- M_ACTION8,
- M_DELTAX,
- M_DELTAY,
- M_DELTAZ,
- M_INVALID
- };
- enum sys_jEvents {
- J_ACTION1,
- J_ACTION2,
- J_ACTION3,
- J_ACTION4,
- J_ACTION5,
- J_ACTION6,
- J_ACTION7,
- J_ACTION8,
- J_ACTION9,
- J_ACTION10,
- J_ACTION11,
- J_ACTION12,
- J_ACTION13,
- J_ACTION14,
- J_ACTION15,
- J_ACTION16,
- J_ACTION17,
- J_ACTION18,
- J_ACTION19,
- J_ACTION20,
- J_ACTION21,
- J_ACTION22,
- J_ACTION23,
- J_ACTION24,
- J_ACTION25,
- J_ACTION26,
- J_ACTION27,
- J_ACTION28,
- J_ACTION29,
- J_ACTION30,
- J_ACTION31,
- J_ACTION32,
- J_ACTION_MAX = J_ACTION32,
- J_AXIS_MIN,
- J_AXIS_LEFT_X = J_AXIS_MIN + AXIS_LEFT_X,
- J_AXIS_LEFT_Y = J_AXIS_MIN + AXIS_LEFT_Y,
- J_AXIS_RIGHT_X = J_AXIS_MIN + AXIS_RIGHT_X,
- J_AXIS_RIGHT_Y = J_AXIS_MIN + AXIS_RIGHT_Y,
- J_AXIS_LEFT_TRIG = J_AXIS_MIN + AXIS_LEFT_TRIG,
- J_AXIS_RIGHT_TRIG = J_AXIS_MIN + AXIS_RIGHT_TRIG,
- J_AXIS_MAX = J_AXIS_MIN + MAX_JOYSTICK_AXIS - 1,
- J_DPAD_UP,
- J_DPAD_DOWN,
- J_DPAD_LEFT,
- J_DPAD_RIGHT,
- MAX_JOY_EVENT
- };
- enum keyNum_t {
- K_NONE,
- K_ESCAPE,
- K_1,
- K_2,
- K_3,
- K_4,
- K_5,
- K_6,
- K_7,
- K_8,
- K_9,
- K_0,
- K_MINUS,
- K_EQUALS,
- K_BACKSPACE,
- K_TAB,
- K_Q,
- K_W,
- K_E,
- K_R,
- K_T,
- K_Y,
- K_U,
- K_I,
- K_O,
- K_P,
- K_LBRACKET,
- K_RBRACKET,
- K_ENTER,
- K_LCTRL,
- K_A,
- K_S,
- K_D,
- K_F,
- K_G,
- K_H,
- K_J,
- K_K,
- K_L,
- K_SEMICOLON,
- K_APOSTROPHE,
- K_GRAVE,
- K_LSHIFT,
- K_BACKSLASH,
- K_Z,
- K_X,
- K_C,
- K_V,
- K_B,
- K_N,
- K_M,
- K_COMMA,
- K_PERIOD,
- K_SLASH,
- K_RSHIFT,
- K_KP_STAR,
- K_LALT,
- K_SPACE,
- K_CAPSLOCK,
- K_F1,
- K_F2,
- K_F3,
- K_F4,
- K_F5,
- K_F6,
- K_F7,
- K_F8,
- K_F9,
- K_F10,
- K_NUMLOCK,
- K_SCROLL,
- K_KP_7,
- K_KP_8,
- K_KP_9,
- K_KP_MINUS,
- K_KP_4,
- K_KP_5,
- K_KP_6,
- K_KP_PLUS,
- K_KP_1,
- K_KP_2,
- K_KP_3,
- K_KP_0,
- K_KP_DOT,
- K_F11 = 0x57,
- K_F12 = 0x58,
- K_F13 = 0x64,
- K_F14 = 0x65,
- K_F15 = 0x66,
- K_KANA = 0x70,
- K_CONVERT = 0x79,
- K_NOCONVERT = 0x7B,
- K_YEN = 0x7D,
- K_KP_EQUALS = 0x8D,
- K_CIRCUMFLEX = 0x90,
- K_AT = 0x91,
- K_COLON = 0x92,
- K_UNDERLINE = 0x93,
- K_KANJI = 0x94,
- K_STOP = 0x95,
- K_AX = 0x96,
- K_UNLABELED = 0x97,
- K_KP_ENTER = 0x9C,
- K_RCTRL = 0x9D,
- K_KP_COMMA = 0xB3,
- K_KP_SLASH = 0xB5,
- K_PRINTSCREEN = 0xB7,
- K_RALT = 0xB8,
- K_PAUSE = 0xC5,
- K_HOME = 0xC7,
- K_UPARROW = 0xC8,
- K_PGUP = 0xC9,
- K_LEFTARROW = 0xCB,
- K_RIGHTARROW = 0xCD,
- K_END = 0xCF,
- K_DOWNARROW = 0xD0,
- K_PGDN = 0xD1,
- K_INS = 0xD2,
- K_DEL = 0xD3,
- K_LWIN = 0xDB,
- K_RWIN = 0xDC,
- K_APPS = 0xDD,
- K_POWER = 0xDE,
- K_SLEEP = 0xDF,
-
-
-
- K_JOY1 = 256,
- K_JOY2,
- K_JOY3,
- K_JOY4,
- K_JOY5,
- K_JOY6,
- K_JOY7,
- K_JOY8,
- K_JOY9,
- K_JOY10,
- K_JOY11,
- K_JOY12,
- K_JOY13,
- K_JOY14,
- K_JOY15,
- K_JOY16,
- K_JOY_STICK1_UP,
- K_JOY_STICK1_DOWN,
- K_JOY_STICK1_LEFT,
- K_JOY_STICK1_RIGHT,
- K_JOY_STICK2_UP,
- K_JOY_STICK2_DOWN,
- K_JOY_STICK2_LEFT,
- K_JOY_STICK2_RIGHT,
- K_JOY_TRIGGER1,
- K_JOY_TRIGGER2,
- K_JOY_DPAD_UP,
- K_JOY_DPAD_DOWN,
- K_JOY_DPAD_LEFT,
- K_JOY_DPAD_RIGHT,
-
-
-
- K_MOUSE1,
- K_MOUSE2,
- K_MOUSE3,
- K_MOUSE4,
- K_MOUSE5,
- K_MOUSE6,
- K_MOUSE7,
- K_MOUSE8,
- K_MWHEELDOWN,
- K_MWHEELUP,
- K_LAST_KEY
- };
- struct sysEvent_t {
- sysEventType_t evType;
- int evValue;
- int evValue2;
- int evPtrLength;
- void * evPtr;
- int inputDevice;
- bool IsKeyEvent() const { return evType == SE_KEY; }
- bool IsMouseEvent() const { return evType == SE_MOUSE; }
- bool IsCharEvent() const { return evType == SE_CHAR; }
- bool IsJoystickEvent() const { return evType == SE_JOYSTICK; }
- bool IsKeyDown() const { return evValue2 != 0; }
- keyNum_t GetKey() const { return static_cast< keyNum_t >( evValue ); }
- int GetXCoord() const { return evValue; }
- int GetYCoord() const { return evValue2; }
- };
- struct sysMemoryStats_t {
- int memoryLoad;
- int totalPhysical;
- int availPhysical;
- int totalPageFile;
- int availPageFile;
- int totalVirtual;
- int availVirtual;
- int availExtendedVirtual;
- };
- typedef unsigned long address_t;
- void Sys_Init();
- void Sys_Shutdown();
- void Sys_Error( const char *error, ...);
- const char * Sys_GetCmdLine();
- void Sys_ReLaunch( void * launchData, unsigned int launchDataSize );
- void Sys_Launch( const char * path, idCmdArgs & args, void * launchData, unsigned int launchDataSize );
- void Sys_SetLanguageFromSystem();
- const char * Sys_DefaultLanguage();
- void Sys_Quit();
- bool Sys_AlreadyRunning();
- char * Sys_GetClipboardData();
- void Sys_SetClipboardData( const char *string );
- void Sys_Printf( VERIFY_FORMAT_STRING const char *msg, ... );
- void Sys_DebugPrintf( VERIFY_FORMAT_STRING const char *fmt, ... );
- void Sys_DebugVPrintf( const char *fmt, va_list arg );
- #define SYS_MINSLEEP 20
- void Sys_Sleep( int msec );
- int Sys_Milliseconds();
- uint64 Sys_Microseconds();
- double Sys_GetClockTicks();
- double Sys_ClockTicksPerSecond();
- cpuid_t Sys_GetProcessorId();
- const char * Sys_GetProcessorString();
- bool Sys_FPU_StackIsEmpty();
- void Sys_FPU_ClearStack();
- const char * Sys_FPU_GetState();
- void Sys_FPU_EnableExceptions( int exceptions );
- void Sys_FPU_SetPrecision( int precision );
- void Sys_FPU_SetRounding( int rounding );
- void Sys_FPU_SetFTZ( bool enable );
- void Sys_FPU_SetDAZ( bool enable );
- int Sys_GetSystemRam();
- int Sys_GetVideoRam();
- int Sys_GetDriveFreeSpace( const char *path );
- int64 Sys_GetDriveFreeSpaceInBytes( const char * path );
- void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats );
- void Sys_GetExeLaunchMemoryStatus( sysMemoryStats_t &stats );
- bool Sys_LockMemory( void *ptr, int bytes );
- bool Sys_UnlockMemory( void *ptr, int bytes );
- void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes );
- void Sys_GetCallStack( address_t *callStack, const int callStackSize );
- const char * Sys_GetCallStackStr( const address_t *callStack, const int callStackSize );
- const char * Sys_GetCallStackCurStr( int depth );
- const char * Sys_GetCallStackCurAddressStr( int depth );
- void Sys_ShutdownSymbols();
- int Sys_DLL_Load( const char *dllName );
- void * Sys_DLL_GetProcAddress( int dllHandle, const char *procName );
- void Sys_DLL_Unload( int dllHandle );
- void Sys_GenerateEvents();
- sysEvent_t Sys_GetEvent();
- void Sys_ClearEvents();
- void Sys_InitInput();
- void Sys_ShutdownInput();
- int Sys_PollKeyboardInputEvents();
- int Sys_ReturnKeyboardInputEvent( const int n, int &ch, bool &state );
- void Sys_EndKeyboardInputEvents();
- static const int MAX_MOUSE_EVENTS = 256;
- int Sys_PollMouseInputEvents( int mouseEvents[MAX_MOUSE_EVENTS][2] );
- void Sys_SetRumble( int device, int low, int hi );
- int Sys_PollJoystickInputEvents( int deviceNum );
- int Sys_ReturnJoystickInputEvent( const int n, int &action, int &value );
- void Sys_EndJoystickInputEvents();
- void Sys_GrabMouseCursor( bool grabIt );
- void Sys_ShowWindow( bool show );
- bool Sys_IsWindowVisible();
- void Sys_ShowConsole( int visLevel, bool quitOnClose );
- typedef HANDLE idFileHandle;
- ID_TIME_T Sys_FileTimeStamp( idFileHandle fp );
- const char * Sys_TimeStampToStr( ID_TIME_T timeStamp );
- const char * Sys_SecToStr( int sec );
- const char * Sys_DefaultBasePath();
- const char * Sys_DefaultSavePath();
- void Sys_SetFatalError( const char *error );
- typedef bool ( *execProcessWorkFunction_t )();
- typedef void ( *execOutputFunction_t)( const char * text );
- bool Sys_Exec( const char * appPath, const char * workingPath, const char * args,
- execProcessWorkFunction_t workFn, execOutputFunction_t outputFn, const int waitMS,
- unsigned int & exitCode );
- #define ID_LANG_ENGLISH "english"
- #define ID_LANG_FRENCH "french"
- #define ID_LANG_ITALIAN "italian"
- #define ID_LANG_GERMAN "german"
- #define ID_LANG_SPANISH "spanish"
- #define ID_LANG_JAPANESE "japanese"
- int Sys_NumLangs();
- const char * Sys_Lang( int idx );
- typedef enum {
- NA_BAD,
- NA_LOOPBACK,
- NA_BROADCAST,
- NA_IP
- } netadrtype_t;
- typedef struct {
- netadrtype_t type;
- unsigned char ip[4];
- unsigned short port;
- } netadr_t;
- #define PORT_ANY -1
- class idUDP {
- public:
-
- idUDP();
- virtual ~idUDP();
-
- bool InitForPort( int portNumber );
- int GetPort() const { return bound_to.port; }
- netadr_t GetAdr() const { return bound_to; }
- uint32 GetUIntAdr() const { return ( bound_to.ip[0] | bound_to.ip[1] << 8 | bound_to.ip[2] << 16 | bound_to.ip[3] << 24 ); }
- void Close();
- bool GetPacket( netadr_t &from, void *data, int &size, int maxSize );
-
- bool GetPacketBlocking( netadr_t &from, void *data, int &size, int maxSize,
- int timeout );
- void SendPacket( const netadr_t to, const void *data, int size );
- void SetSilent( bool silent ) { this->silent = silent; }
- bool GetSilent() const { return silent; }
- int packetsRead;
- int bytesRead;
- int packetsWritten;
- int bytesWritten;
- bool IsOpen() const { return netSocket > 0; }
- private:
- netadr_t bound_to;
- int netSocket;
- bool silent;
- };
-
-
-
-
- bool Sys_StringToNetAdr( const char *s, netadr_t *a, bool doDNSResolve );
- const char * Sys_NetAdrToString( const netadr_t a );
- bool Sys_IsLANAddress( const netadr_t a );
- bool Sys_CompareNetAdrBase( const netadr_t a, const netadr_t b );
- int Sys_GetLocalIPCount();
- const char * Sys_GetLocalIP( int i );
- void Sys_InitNetworking();
- void Sys_ShutdownNetworking();
- class idJoystick {
- public:
- virtual ~idJoystick() { }
- virtual bool Init() { return false; }
- virtual void Shutdown() { }
- virtual void Deactivate() { }
- virtual void SetRumble( int deviceNum, int rumbleLow, int rumbleHigh ) { }
- virtual int PollInputEvents( int inputDeviceNum ) { return 0; }
- virtual int ReturnInputEvent( const int n, int &action, int &value ) { return 0; }
- virtual void EndInputEvents() { }
- };
- class idSys {
- public:
- virtual void DebugPrintf( VERIFY_FORMAT_STRING const char *fmt, ... ) = 0;
- virtual void DebugVPrintf( const char *fmt, va_list arg ) = 0;
- virtual double GetClockTicks() = 0;
- virtual double ClockTicksPerSecond() = 0;
- virtual cpuid_t GetProcessorId() = 0;
- virtual const char * GetProcessorString() = 0;
- virtual const char * FPU_GetState() = 0;
- virtual bool FPU_StackIsEmpty() = 0;
- virtual void FPU_SetFTZ( bool enable ) = 0;
- virtual void FPU_SetDAZ( bool enable ) = 0;
- virtual void FPU_EnableExceptions( int exceptions ) = 0;
- virtual bool LockMemory( void *ptr, int bytes ) = 0;
- virtual bool UnlockMemory( void *ptr, int bytes ) = 0;
- virtual void GetCallStack( address_t *callStack, const int callStackSize ) = 0;
- virtual const char * GetCallStackStr( const address_t *callStack, const int callStackSize ) = 0;
- virtual const char * GetCallStackCurStr( int depth ) = 0;
- virtual void ShutdownSymbols() = 0;
- virtual int DLL_Load( const char *dllName ) = 0;
- virtual void * DLL_GetProcAddress( int dllHandle, const char *procName ) = 0;
- virtual void DLL_Unload( int dllHandle ) = 0;
- virtual void DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) = 0;
- virtual sysEvent_t GenerateMouseButtonEvent( int button, bool down ) = 0;
- virtual sysEvent_t GenerateMouseMoveEvent( int deltax, int deltay ) = 0;
- virtual void OpenURL( const char *url, bool quit ) = 0;
- virtual void StartProcess( const char *exePath, bool quit ) = 0;
- };
- extern idSys * sys;
- bool Sys_LoadOpenAL();
- void Sys_FreeOpenAL();
- #endif
|