Com EventLoop

From ioquake3 wiki
Jump to navigation Jump to search

Com_EventLoop() repeatedly retrieves a Template:TypeDoc via {{#ifexist:Com_GetEvent|Com_GetEvent()|Com_GetEvent()}} → {{#ifexist:Com_GetRealEvent|Com_GetRealEvent()|Com_GetRealEvent()}} → {{#ifexist:Sys_GetEvent|Sys_GetEvent()|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:
        {{#ifexist:CL_KeyEvent|CL_KeyEvent()|CL_KeyEvent()}};
    case SE_CHAR:
        {{#ifexist:CL_CharEvent|CL_CharEvent()|CL_CharEvent()}};
    case SE_MOUSE:
        {{#ifexist:CL_MouseEvent|CL_MouseEvent()|CL_MouseEvent()}};
    case SE_JOYSTICK_AXIS:
        {{#ifexist:CL_JoystickEvent|CL_JoystickEvent()|CL_JoystickEvent()}};
    case SE_CONSOLE:
        {{#ifexist:Cbuf_AddText|Cbuf_AddText|Cbuf_AddText}}(event.evPtr+"\n");
    case SE_PACKET:
        if(com_sv_running) {
            {{#ifexist:SV_PacketEvent|SV_PacketEvent()|SV_PacketEvent()}};
        } else {
            {{#ifexist:CL_PacketEvent|CL_PacketEvent()|CL_PacketEvent()}};
        }
}