docs: def _processEvents():
      """Flushes the event queue from libtcod into the global list _eventQueue"""
      global _mousel, _mousem, _mouser, _eventsflushed, _pushedEvents
      _eventsflushed = True
      events = _pushedEvents # get events from event.push
      _pushedEvents = [] # then clear the pushed events queue
  
      mouse = _ffi.new('TCOD_mouse_t *')
      libkey = _ffi.new('TCOD_key_t *')
      while 1:
          libevent = _lib.TCOD_sys_check_for_event(_lib.TCOD_EVENT_ANY, libkey, mouse)
          if not libevent: # no more events from libtcod
              break
  
          #if mouse.dx or mouse.dy:
          if libevent & _lib.TCOD_EVENT_MOUSE_MOVE:
              events.append(MouseMotion((mouse.x, mouse.y),
                                        (mouse.cx, mouse.cy),
                                        (mouse.dx, mouse.dy),
                                        (mouse.dcx, mouse.dcy)))
  
          mousepos = ((mouse.x, mouse.y), (mouse.cx, mouse.cy))
  
          for oldstate, newstate, released, button in \
              zip((_mousel, _mousem, _mouser),
                  (mouse.lbutton, mouse.mbutton, mouse.rbutton),
                  (mouse.lbutton_pressed, mouse.mbutton_pressed,
                   mouse.rbutton_pressed),
                  (1, 2, 3)):
              if released:
                  if not oldstate:
                      events.append(MouseDown(button, *mousepos))
                  events.append(MouseUp(button, *mousepos))
                  if newstate:
                      events.append(MouseDown(button, *mousepos))
              elif newstate and not oldstate:
                  events.append(MouseDown(button, *mousepos))
  
          if mouse.wheel_up:
              events.append(MouseDown(4, *mousepos))
          if mouse.wheel_down:
              events.append(MouseDown(5, *mousepos))
  
          _mousel = mouse.lbutton
          _mousem = mouse.mbutton
          _mouser = mouse.rbutton
  
          if libkey.vk == _lib.TCODK_NONE:
              break
          if libkey.pressed:
              keyevent = KeyDown
          else:
              keyevent = KeyUp
  
          events.append(
              keyevent(
                  libkey.vk,
                  libkey.c.decode('ascii', errors='ignore'),
                  _ffi.string(libkey.text).decode('utf-8'),
                  libkey.shift,
                  libkey.lalt,
                  libkey.ralt,
                  libkey.lctrl,
                  libkey.rctrl,
                  libkey.lmeta,
                  libkey.rmeta,
                  )
              )
  
      if _lib.TCOD_console_is_window_closed():
          events.append(Quit())
  
      _eventQueue.extend(events)