Com EventLoop

From ioquake3 wiki
Jump to: navigation, search

Com_EventLoop() repeatedly retrieves a Template:TypeDoc via Com_GetEvent()Com_GetRealEvent()Sys_GetEvent() (unix link and Windows link) in an infinite loop. For each event returned, it invokes this pseudo-switch statement, based on the type of the event:

switch(event.evType) {
    case SE_NONE:
        return;
    case SE_KEY:
        CL_KeyEvent();
    case SE_CHAR:
        CL_CharEvent();
    case SE_MOUSE:
        CL_MouseEvent();
    case SE_JOYSTICK_AXIS:
        CL_JoystickEvent();
    case SE_CONSOLE:
        Cbuf_AddText(event.evPtr+"\n");
    case SE_PACKET:
        if(com_sv_running) {
            SV_PacketEvent();
        } else {
            CL_PacketEvent();
        }
}