当前位置: 首页>>代码示例>>C++>>正文


C++ D_PostEvent函数代码示例

本文整理汇总了C++中D_PostEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ D_PostEvent函数的具体用法?C++ D_PostEvent怎么用?C++ D_PostEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了D_PostEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

//
// RawWin32Mouse::processEvents
//
// Iterates our queue of RAWINPUT events and converts them to Doom event_t
// and posts them for processing by the game internals.
//
void RawWin32Mouse::processEvents()
{
	if (!mActive)
		return;

	event_t movement_event;
	movement_event.type = ev_mouse;
	movement_event.data1 = movement_event.data2 = movement_event.data3 = 0;

	const RAWMOUSE* mouse;
	while (mouse = front())
	{
		popFront();

		// process mouse movement and save it
		processRawMouseMovement(mouse, &movement_event);

		// process mouse button clicks and post the events
		event_t button_event;
		for (int i = 0; i < 5; i++)
		{
			if (processRawMouseButtons(mouse, &button_event, i))
				D_PostEvent(&button_event);
		}

		// process mouse scroll wheel action
		if (processRawMouseScrollWheel(mouse, &button_event))
			D_PostEvent(&button_event);
	}

	// post any mouse movement events
	if (movement_event.data2 || movement_event.data3)
		D_PostEvent(&movement_event);
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:40,代码来源:i_input.cpp

示例2: MapMouseWheelToButtons

static void MapMouseWheelToButtons(SDL_MouseWheelEvent *wheel)
{
    // SDL2 distinguishes button events from mouse wheel events.
    // We want to treat the mouse wheel as two buttons, as per
    // SDL1
    static event_t up, down;
    int button;

    if (wheel->y <= 0)
    {   // scroll down
        button = 4;
    }
    else
    {   // scroll up
        button = 3;
    }

    // post a button down event
    mouse_button_state |= (1 << button);
    down.type = ev_mouse;
    down.data1 = mouse_button_state;
    down.data2 = down.data3 = 0;
    D_PostEvent(&down);

    // post a button up event
    mouse_button_state &= ~(1 << button);
    up.type = ev_mouse;
    up.data1 = mouse_button_state;
    up.data2 = up.data3 = 0;
    D_PostEvent(&up);
}
开发者ID:Azarien,项目名称:chocolate-doom,代码行数:31,代码来源:i_input.c

示例3: postevent

static void postevent(SDL_Event *Event)
{

    event_t event;

    switch (Event->type)
    {

    case SDL_KEYDOWN:
        event.type = ev_keydown;
        event.data1 = getkey(&Event->key.keysym);

        D_PostEvent(&event);

        break;

    case SDL_KEYUP:
        event.type = ev_keyup;
        event.data1 = getkey(&Event->key.keysym);

        D_PostEvent(&event);

        break;

    case SDL_MOUSEBUTTONDOWN:
    case SDL_MOUSEBUTTONUP:
        event.type = ev_mouse;
        event.data1 = getmouse(SDL_GetMouseState(NULL, NULL));
        event.data2 = 0;
        event.data3 = 0;

        D_PostEvent(&event);

        break;

    case SDL_MOUSEMOTION:
        event.type = ev_mouse;
        event.data1 = getmouse(Event->motion.state);
        event.data2 = Event->motion.xrel << 5;
        event.data3 = -Event->motion.yrel << 5;

        D_PostEvent(&event);

        break;

    case SDL_QUIT:
        I_Exit(0);

    default:
        break;

    }

}
开发者ID:jezze,项目名称:doom,代码行数:54,代码来源:i_video.c

示例4: GetMouse

static void GetMouse()
{
  event_t ev;
  int x, y;
  int buttons, dbuttons;
  static int oldbuttons;
  
  r.x.ax = 0xb;
  int86(0x33, &r, &r);

  x = (signed short)r.x.cx;
  y = (signed short)r.x.dx;

  if(x || y)
    {
      ev.type = ev_mouse;
      ev.data1 = 0;
      ev.data2 = x;
      ev.data3 = -y;
  
      D_PostEvent(&ev);
    }

  // check buttons

  r.x.ax = 3;
  int86(0x33, &r, &r);
  
  buttons = r.x.bx;

  dbuttons = buttons ^ oldbuttons;

  if(dbuttons & 1)
    {
      ev.type = (buttons & 1) ? ev_keydown : ev_keyup;
      ev.data1 = KEYD_MOUSE1;
      D_PostEvent(&ev);
    }
  if(dbuttons & 2)
    {
      ev.type = (buttons & 2) ? ev_keydown : ev_keyup;
      ev.data1 = KEYD_MOUSE2;
      D_PostEvent(&ev);
    }
  if(dbuttons & 4)
    {
      ev.type = (buttons & 4) ? ev_keydown : ev_keyup;
      ev.data1 = KEYD_MOUSE3;
      D_PostEvent(&ev);
    }

  oldbuttons = buttons;
}
开发者ID:dorienh,项目名称:smmu,代码行数:53,代码来源:v_vga.c

示例5: gameControls

void gameControls() {

    u32 kDown, kUp;

    struct eventTranslate *translateTable = gameKeyTable;
    int numTranslations = numGameKeys;

    kDown = keysDown();
    kUp   = keysUp();

    if (menuactive)
    {
        translateTable = menuKeyTable;
        numTranslations = numMenuKeys;
    } else if (automapmode & am_active) {
        translateTable = mapKeyTable;
        numTranslations = numMapKeys;
    } else {

        event_t event;

        if (last_weapon_key != 0 && players[displayplayer].pendingweapon != wp_nochange) {
            event.type = ev_keyup;
            event.data1 = last_weapon_key;
            D_PostEvent(&event);
            last_weapon_key = 0;
        }


        if(kDown & KEY_Y) {

            weapontype_t weapon_index = players[displayplayer].readyweapon;

            weapon_index++;
            while(players[displayplayer].weaponowned[weapon_index] == false) {
                weapon_index++;
                if (weapon_index >= NUMWEAPONS) weapon_index = 0;
            }

            last_weapon_key = weapons[weapon_index];
            event.type = ev_keydown;
            event.data1 = last_weapon_key;
            D_PostEvent(&event);
        }
    }

    translateKeys(ev_keydown, kDown, translateTable, numTranslations);

    translateKeys(ev_keyup, kUp, translateTable, numTranslations);


}
开发者ID:WinterMute,项目名称:prboom,代码行数:52,代码来源:i_video.c

示例6: I_GetEvent

void I_GetEvent(void)
{
	// Mappings of DS keys to SRB2 keys
	UINT32 dskeys[] =
	{
		KEY_A,
		KEY_B,
		KEY_X,
		KEY_Y,
		KEY_L,
		KEY_R,
		KEY_START,
		KEY_SELECT
	};

	event_t event;
	UINT32 held, up, down;
	UINT32 i;

	// Check how the state has changed since last time
	scanKeys();

	// For the d-pad, we only care about the current state
	held = keysHeld();
	event.type = ev_joystick;
	event.data1 = 0;	// First (and only) axis set

	if (held & KEY_LEFT) event.data2 = -1;
	else if (held & KEY_RIGHT) event.data2 = 1;
	else event.data2 = 0;

	if (held & KEY_UP) event.data3 = -1;
	else if (held & KEY_DOWN) event.data3 = 1;
	else event.data3 = 0;

	D_PostEvent(&event);

	// For the buttons, we need to report changes in state
	up = keysUp();
	down = keysDown();
	for (i = 0; i < sizeof(dskeys)/sizeof(dskeys[0]); i++)
	{
		// Has this button's state changed?
		if ((up | down) & dskeys[i])
		{
			event.type = (up & dskeys[i]) ? ev_keyup : ev_keydown;
			event.data1 = KEY_JOY1 + i;
			D_PostEvent(&event);
		}
	}
}
开发者ID:Logan-A,项目名称:SRB2-Public,代码行数:51,代码来源:i_system.c

示例7: I_JoystickEvents

//
// I_JoystickEvents
//
// Gathers joystick data and creates an event_t for later processing
// by G_Responder().
//
static void I_JoystickEvents()
{
   HALGamePad::padstate_t *padstate;

   if(!(padstate = I_PollActiveGamePad()))
      return;

   // turn padstate into button input events
   for(int button = 0; button < HALGamePad::MAXBUTTONS; button++)
   {
      edefstructvar(event_t, ev);

      if(padstate->buttons[button] != padstate->prevbuttons[button])
      {
         ev.type  = padstate->buttons[button] ? ev_keydown : ev_keyup;
         ev.data1 = KEYD_JOY01 + button;
         D_PostEvent(&ev);
      }
   }

   // read axes
   for(int axis = 0; axis < HALGamePad::MAXAXES; axis++)
   {
      // fire axis state change events
      if(padstate->axes[axis] != padstate->prevaxes[axis])
      {
         edefstructvar(event_t, ev);

         // if previous state was off, key down
         if(padstate->prevaxes[axis] == 0.0)
            ev.type = ev_keydown;

         // if new state is off, key up
         if(padstate->axes[axis] == 0.0)
            ev.type = ev_keyup;

         ev.data1 = KEYD_AXISON01 + axis;
         D_PostEvent(&ev);
      }

      // post analog axis state
      edefstructvar(event_t, ev);
      ev.type  = ev_joystick;
      ev.data1 = axis;
      ev.data2 = padstate->axes[axis];
      if(axisOrientation[axis]) // may need to flip, if orientation == -1
         ev.data2 *= axisOrientation[axis];
      D_PostEvent(&ev);
   }
}
开发者ID:ioan-chera,项目名称:eternity,代码行数:56,代码来源:i_input.cpp

示例8: I_GetEvent

static void I_GetEvent(SDL_Event *Event)
{
  event_t event;

  switch (Event->type) {
  case SDL_KEYDOWN:
    event.type = ev_keydown;
    event.data1 = I_TranslateKey(&Event->key.keysym);
    D_PostEvent(&event);
    break;

  case SDL_KEYUP:
  {
    event.type = ev_keyup;
    event.data1 = I_TranslateKey(&Event->key.keysym);
    D_PostEvent(&event);
  }
  break;

  case SDL_MOUSEBUTTONDOWN:
  case SDL_MOUSEBUTTONUP:
  if (mouse_enabled) // recognise clicks even if the pointer isn't grabbed
  {
    event.type = ev_mouse;
    event.data1 = I_SDLtoDoomMouseState(SDL_GetMouseState(NULL, NULL));
    event.data2 = event.data3 = 0;
    D_PostEvent(&event);
  }
  break;

  case SDL_MOUSEMOTION:
  if (mouse_currently_grabbed) {
    event.type = ev_mouse;
    event.data1 = I_SDLtoDoomMouseState(Event->motion.state);
    event.data2 = Event->motion.xrel << 5;
    event.data3 = -Event->motion.yrel << 5;
    D_PostEvent(&event);
  }
  break;


  case SDL_QUIT:
    S_StartSound(NULL, sfx_swtchn);
    M_QuitDOOM(0);

  default:
    break;
  }
}
开发者ID:CaptainHIT,项目名称:prboom,代码行数:49,代码来源:i_video.c

示例9: I_ReadMouse

static void I_ReadMouse(void)
{
    int x, y;
    event_t ev;

    SDL_GetRelativeMouseState(&x, &y);

    if (x != 0 || y != 0) 
    {
        ev.type = ev_mouse;
        ev.data1 = mouse_button_state;
        ev.data2 = AccelerateMouse(x);

        if (!novert)
        {
            ev.data3 = -AccelerateMouse(y);
        }
        else
        {
            ev.data3 = 0;
        }
        
        D_PostEvent(&ev);
    }

    if (MouseShouldBeGrabbed())
    {
        CenterMouse();
    }
}
开发者ID:gstark31897,项目名称:chocolate-doom,代码行数:30,代码来源:i_video.c

示例10: I_ReadMouse

//
// Read the change in mouse state to generate mouse motion events
//
// This is to combine all mouse movement for a tic into one mouse
// motion event.
void I_ReadMouse(void)
{
    int x, y;
    event_t ev;

    SDL_GetRelativeMouseState(&x, &y);

    if (x != 0 || y != 0) 
    {
        ev.type = ev_mouse;
        ev.data1 = mouse_button_state;
        ev.data2 = AccelerateMouse(x);

        if (!novert)
        {
            ev.data3 = -AccelerateMouse(y);
        }
        else
        {
            ev.data3 = 0;
        }

        // XXX: undefined behaviour since event is scoped to
        // this function
        D_PostEvent(&ev);
    }
}
开发者ID:Azarien,项目名称:chocolate-doom,代码行数:32,代码来源:i_input.c

示例11: I_RunDeferredEvents

//
// I_RunDeferredEvents
//
// Check the deferred events queue for events that are ready to be posted.
//
static void I_RunDeferredEvents()
{
   DLListItem<deferredevent_t> *rover = i_deferredevents.head;
   static int lasttic;

   // Only run once per tic.
   if(lasttic == gametic)
      return;

   lasttic = gametic;

   while(rover)
   {
      DLListItem<deferredevent_t> *next = rover->dllNext;

      deferredevent_t *de = *rover;
      if(de->tic <= gametic)
      {
         D_PostEvent(&de->ev);
         I_PutDeferredEvent(de);
      }

      rover = next;
   }
}
开发者ID:ioan-chera,项目名称:eternity,代码行数:30,代码来源:i_input.cpp

示例12: I_StartTic

//
// I_StartTic
//
void I_StartTic(void)
{
    event_t event;
    while (sel4doom_poll_event(&event)) {
        D_PostEvent(&event);
    }
}
开发者ID:jm--,项目名称:seL4Doom,代码行数:10,代码来源:i_video.c

示例13: I_StartTic

void I_StartTic (void)
{
  int key;
  event_t event;

  hidScanInput();

  if (saveStringEnter) {
    if (!saveStringCopied) {
      strcpy(keyboard_string,saveOldString);
      saveStringCopied = true;
      if (strcmp(keyboard_string,"empty slot") == 0) keyboard_string[0] = 0;
    }

    key = updateKeyboard();

    if (key == KEYD_ESCAPE || key == KEYD_ENTER) saveStringCopied = false;

    event.type = ev_keydown;
    event.data1 = key;
    D_PostEvent(&event);

  } else {
    gameControls();
  }

}
开发者ID:CaptainHIT,项目名称:prboom,代码行数:27,代码来源:i_video.c

示例14: I_ReadMouse

static void I_ReadMouse(void)
{
    int x, y;
    event_t ev;

#if SDL_VERSION_ATLEAST(1, 3, 0)
    SDL_GetRelativeMouseState(0, &x, &y);
#else
    SDL_GetRelativeMouseState(&x, &y);
#endif

    if (x != 0 || y != 0) 
    {
        ev.type = ev_mouse;
        ev.data1 = MouseButtonState();
        ev.data2 = AccelerateMouse(x);
        ev.data3 = -AccelerateMouse(y);
        
        D_PostEvent(&ev);
    }

    if (MouseShouldBeGrabbed())
    {
        CenterMouse();
    }
}
开发者ID:hifi-unmaintained,项目名称:chocolate-doom-launcher,代码行数:26,代码来源:i_video.c

示例15: I_PollJoystick

void I_PollJoystick(void) {
#if 0
#ifdef HAVE_SDL_JOYSTICKGETAXIS
  event_t ev;
  Sint16 axis_value;

  if (!usejoystick || (!joystick))
      return;

  ev.type = ev_joystick;
  ev.key =   (SDL_JoystickGetButton(joystick, 0) << 0) |
             (SDL_JoystickGetButton(joystick, 1) << 1) |
             (SDL_JoystickGetButton(joystick, 2) << 2) |
             (SDL_JoystickGetButton(joystick, 3) << 3) |
             (SDL_JoystickGetButton(joystick, 4) << 4) |
             (SDL_JoystickGetButton(joystick, 5) << 5) |
             (SDL_JoystickGetButton(joystick, 6) << 6) |
             (SDL_JoystickGetButton(joystick, 7) << 7);
  axis_value = SDL_JoystickGetAxis(joystick, 0) / 3000;
  if (abs(axis_value) < 10)
    axis_value = 0;
  ev.data2 = axis_value;
  axis_value = SDL_JoystickGetAxis(joystick, 1) / 3000;
  if (abs(axis_value) < 10)
    axis_value = 0;
  ev.data3 = axis_value;

  D_PostEvent(&ev);
#endif
#endif
}
开发者ID:camgunz,项目名称:d2k,代码行数:31,代码来源:i_joy.c


注:本文中的D_PostEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。