Quake Source Code Analysis (Draft) .3

xiaoxiao2021-03-06  50

Message Treatment: I divide quake's messages into two categories, one is a message generated by the input device, such as Keyboard, Mouse, JoyStick, etc. The other is the message that caused by the network or local transmission packets. Engage COM_EVENTLOOP () function Responsible for the grabbed message to the corresponding processing function according to the type of event, com_getevent () can get all the unprocessed messages from the COM_EVENTQUEUE and Eventqueue array queue, type {se_none, // evtime is still valid se_key, // evValue is a key code, evValue2 is the down flag SE_CHAR, // evValue is an ascii char SE_MOUSE, // evValue and evValue2 are reletive signed x / y moves SE_JOYSTICK_AXIS, // evValue is an axis number and evValue2 is the current state (-127 to 127) SE_CONSOLE, // evPtr is a char * SE_PACKET // evPtr is a netadr_t followed by data bytes to evPtrLength} sysEventType_t; typedef struct {int evTime; sysEventType_t evType; int evValue, evValue2; int evPtrLength; / / bytes of data pointed to by evPtr, for journaling void * evPtr; // this must be manually freed if not NULL} sysEvent_t; static sysEvent_t com_eventQueue [COM_MAX_EVENTS]; static sysEvent_t eventqueue [SYS_MAX _Events]; From the above declaration, we can see that com_eventqueue and eventqueue are actually an array of SYSEVENT_T structures. Here you may ask, what is the data in COM_EVENTQUEUE coming? When the com_getevent () function finds When there is no data in COM_EVENTQUEUE, such as when the program is just started, it calls COM_GETREALEVENT () to collect unprocessed messages. Then read the event from EventQueue.

COM_GETREALEVENT () àsys_getevent () àsys_pumpevents ()

SYS_PUMPEVENTS () uses a message cycle (WHILE (PEEKMESG, NULL, 0U, 0U, PM_NOREMOVE) {if (! GetMessage (& MSG, NULL, 0, 0)) {sys_quit ();} TranslateMessage (& MSG); DispatchMessage (& MSG);}) First, the message is handled by WndProc (), and then WndProc () is then stored in the global queue EventQueue in the global queue EventQueue by calling the Sys_queEvent () function by calling the sys_queevent () function by calling the sys_queevent () function.

转载请注明原文地址:https://www.9cbs.com/read-108611.html

New Post(0)