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


C++ Key_Event函数代码示例

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


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

示例1: IN_MouseEvent

/*
===========
IN_MouseEvent
===========
*/
void IN_MouseEvent (int mstate)
{
	int		i;

	if (!mouseinitialized)
		return;

// perform button actions
	for (i=0 ; i<mouse_buttons ; i++)
	{
		if ( (mstate & (1<<i)) &&
			!(mouse_oldbuttonstate & (1<<i)) )
		{
			Key_Event (K_MOUSE1 + i, true, sys_msg_time);
		}

		if ( !(mstate & (1<<i)) &&
			(mouse_oldbuttonstate & (1<<i)) )
		{
				Key_Event (K_MOUSE1 + i, false, sys_msg_time);
		}
	}	
		
	mouse_oldbuttonstate = mstate;
}
开发者ID:Izhido,项目名称:qrevpak,代码行数:30,代码来源:in_win.c

示例2: JOY_Command

void
JOY_Command (void)
{
	struct js_event event;

	if (!joy_active || !joy_enable->int_val)
		return;

	while (read (joy_handle, &event, sizeof (struct js_event)) > -1) {
		if (event.type & JS_EVENT_BUTTON) {
			if(event.number >= JOY_MAX_BUTTONS)
				continue;
				
			joy_buttons[event.number].current = event.value;
			
			if (joy_buttons[event.number].current >	joy_buttons[event.number].old) {
				Key_Event(K_AUX1 + event.number, true);
			} else {
				if (joy_buttons[event.number].current <	joy_buttons[event.number].old) {
					Key_Event(K_AUX1 + event.number, false);
				}
			}
			joy_buttons[event.number].old =	joy_buttons[event.number].current;
		} else {
			if (event.type & JS_EVENT_AXIS) {
				if (event.number >= JOY_MAX_AXES)
					continue;
				joy_axes[event.number].current = event.value;
			}
		}
	}
}
开发者ID:luaman,项目名称:qforge-nuq,代码行数:32,代码来源:joy_linux.c

示例3: IN_JoyKeyEvent

/*
================
IN_JoyKeyEvent

Sends a Key_Event if a unpressed -> pressed or pressed -> unpressed transition occurred,
and generates key repeats if the button is held down.

Adapted from DarkPlaces by lordhavoc
================
*/
static void IN_JoyKeyEvent(qboolean wasdown, qboolean isdown, int key, double *timer)
{
	// we can't use `realtime` for key repeats because it is not monotomic
	const double currenttime = Sys_DoubleTime();
	
	if (wasdown)
	{
		if (isdown)
		{
			if (currenttime >= *timer)
			{
				*timer = currenttime + 0.1;
				Key_Event(key, true);
			}
		}
		else
		{
			*timer = 0;
			Key_Event(key, false);
		}
	}
	else
	{
		if (isdown)
		{
			*timer = currenttime + 0.5;
			Key_Event(key, true);
		}
	}
}
开发者ID:aonorin,项目名称:vkQuake,代码行数:40,代码来源:in_sdl.c

示例4: Key_MouseEvent

/*
* Key_MouseEvent
* 
* A wrapper around Key_Event to generate double click events
* A typical sequence of events will look like this:
* +MOUSE1 - user pressed button
* -MOUSE1 - user released button
* +MOUSE1 - user pressed button  (must be within 480 ms or so of the previous down event)
* +MOUSE1DBLCLK - inserted by Key_MouseEvent
* -MOUSE1DBLCLK - inserted by Key_MouseEvent
* -MOUSE1 - user released button
* (This order is not final! We might want to suppress the second pair of 
* mouse1 down/up events, or make +MOUSE1DBLCLK come before +MOUSE1)
*/
void Key_MouseEvent( int key, qboolean down, unsigned time )
{
	static unsigned int last_button1_click = 0;
	// use a lower delay than XP default (480 ms) because we don't support width/height yet
	const unsigned int doubleclick_time = 350;	// milliseconds
	//	static int last_button1_x, last_button1_y; // TODO
	//	const int doubleclick_width = 4;	// TODO
	//	const int doubleclick_height = 4;	// TODO

	if( key == K_MOUSE1 )
	{
		if( down )
		{
			if( last_button1_click && ( (time - last_button1_click) < doubleclick_time ) )
			{
				last_button1_click = 0;
				Key_Event( key, down, time );
				Key_Event( K_MOUSE1DBLCLK, qtrue, time );
				Key_Event( K_MOUSE1DBLCLK, qfalse, time );
				return;
			}
			else
			{
				last_button1_click = time;
			}
		}
	}
	else if( key == K_MOUSE2 || key == K_MOUSE3 )
	{
		last_button1_click = 0;
	}

	Key_Event( key, down, time );
}
开发者ID:ewirch,项目名称:qfusion,代码行数:48,代码来源:keys.c

示例5: raw_mouse_event

static void raw_mouse_event( PRAWMOUSE rm ) {
    int i;

    if( rm->usButtonFlags ) {
        for( i = 0; i < MOUSE_BUTTONS; i++ ) {
            if( rm->usButtonFlags & ( 1 << ( i * 2 ) ) ) {
                Key_Event( K_MOUSE1 + i, qtrue, win.lastMsgTime );
            }
            if( rm->usButtonFlags & ( 1 << ( i * 2 + 1 ) ) ) {
                Key_Event( K_MOUSE1 + i, qfalse, win.lastMsgTime );
            }
        }

        if( rm->usButtonFlags & RI_MOUSE_WHEEL ) {
            mouse_wheel_event( ( short )rm->usButtonData );
        }

        // this flag is undocumented, but confirmed to work on Win7
        if( rm->usButtonFlags & 0x0800 ) {
            mouse_hwheel_event( ( short )rm->usButtonData );
        }
    }

    if( ( rm->usFlags & (MOUSE_MOVE_RELATIVE|MOUSE_MOVE_ABSOLUTE) ) == MOUSE_MOVE_RELATIVE ) {
        win.mouse.mx += rm->lLastX;
        win.mouse.my += rm->lLastY;
    }
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:28,代码来源:vid_win.c

示例6: IN_MouseEvent

void IN_MouseEvent (int mstate)
{
	int	i;

	if (mouseactive && !dinput)
	{
	// perform button actions
		for (i=0 ; i<mouse_buttons ; i++)
		{
			if ( (mstate & (1<<i)) &&
				!(mouse_oldbuttonstate & (1<<i)) )
			{
				Key_Event (K_MOUSE1 + i, true);
			}

			if ( !(mstate & (1<<i)) &&
				(mouse_oldbuttonstate & (1<<i)) )
			{
				Key_Event (K_MOUSE1 + i, false);
			}
		}	
			
		mouse_oldbuttonstate = mstate;
	}
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:25,代码来源:in_win.cpp

示例7: IN_CommandsJoystick

void IN_CommandsJoystick (void) {
	int i, key_index;
	DWORD buttonstate;//, povstate;
        struct js_event js;

	if (!joy_avail)
		return;

	if (read (joystick, &js, sizeof (struct js_event)) != sizeof (struct js_event))
          return;

        switch (js.type & ~JS_EVENT_INIT) {
		case JS_EVENT_BUTTON:
			buttonstate = js.value;
			i = js.number;
			if (js.value) {
				key_index = (i < 4) ? K_JOY1 : K_AUX1;
				Key_Event (key_index + i, true);
			}

			if (!js.value) {
				key_index = (i < 4) ? K_JOY1 : K_AUX1;
				Key_Event (key_index + i, false);
			}
			joy_oldbuttonstate = buttonstate;
	} 
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:27,代码来源:in_linux.c

示例8: LowLevelKeyboardProc

STATIC LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ) {
    PKBDLLHOOKSTRUCT kb = ( PKBDLLHOOKSTRUCT )lParam;
    unsigned key;

    if( nCode != HC_ACTION ) {
        goto ignore;
    }

    switch( kb->vkCode ) {
    case VK_LWIN:
        key = K_LWINKEY;
        break;
    case VK_RWIN:
        key = K_RWINKEY;
        break;
    default:
        goto ignore;
    }

    switch( wParam ) {
    case WM_KEYDOWN:
        Key_Event( key, qtrue, kb->time );
        return TRUE;
    case WM_KEYUP:
        Key_Event( key, qfalse, kb->time );
        return TRUE;
    default:
        break;
    }

ignore:
    return CallNextHookEx( NULL, nCode, wParam, lParam );
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:33,代码来源:vid_win.c

示例9: legacy_mouse_event

// this is complicated because Win32 seems to pack multiple mouse events into
// one update sometimes, so we always check all states and look for events
static void legacy_mouse_event( WPARAM wParam ) {
    int i, mask, temp = 0;

    if( wParam & MK_LBUTTON )
        temp |= 1;

    if( wParam & MK_RBUTTON )
        temp |= 2;

    if( wParam & MK_MBUTTON )
        temp |= 4;

    if( wParam & MK_XBUTTON1 )
        temp |= 8;

    if( wParam & MK_XBUTTON2 )
        temp |= 16;

    if( temp == win.mouse.state )
        return;

    // perform button actions
    for( i = 0, mask = 1; i < MOUSE_BUTTONS; i++, mask <<= 1 ) {
        if( ( temp & mask ) && !( win.mouse.state & mask ) ) {
            Key_Event( K_MOUSE1 + i, qtrue, win.lastMsgTime );
        }
        if( !( temp & mask ) && ( win.mouse.state & mask ) ) {
            Key_Event( K_MOUSE1 + i, qfalse, win.lastMsgTime );
        }
    }

    win.mouse.state = temp;
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:35,代码来源:vid_win.c

示例10: Sys_SendKeyEvents

void Sys_SendKeyEvents(void)
{
	int k, next;
	int outkey;

// get key events

	while (keybuf_head != keybuf_tail)
	{

		k = keybuf[keybuf_tail++];
		keybuf_tail &= (KEYBUF_SIZE-1);

		if (k==0xe0)
		{
			continue;    // special / pause keys
		}
		next = keybuf[(keybuf_tail-2)&(KEYBUF_SIZE-1)];
		if (next == 0xe1)
		{
			continue;    // pause key bullshit
		}
		if (k==0xc5 && next == 0x9d)
		{
			Key_Event(K_PAUSE, true);
			continue;
		}

		// extended keyboard shift key bullshit
		if ((k&0x7f)==SC_LSHIFT || (k&0x7f)==SC_RSHIFT)
		{
			if (keybuf[(keybuf_tail-2)&(KEYBUF_SIZE-1)]==0xe0)
			{
				continue;
			}
			k &= 0x80;
			k |= SC_RSHIFT;
		}

		if (k==0xc5 && keybuf[(keybuf_tail-2)&(KEYBUF_SIZE-1)] == 0x9d)
		{
			continue;    // more pause bullshit
		}

		outkey = scantokey[k & 0x7f];

		if (k & 0x80)
		{
			Key_Event(outkey, false);
		}
		else
		{
			Key_Event(outkey, true);
		}

	}

}
开发者ID:carriercomm,项目名称:Doodle,代码行数:58,代码来源:sys_dos.c

示例11: Key_Event_Alt

/*
//=========================
//process touch screen icon touch event
*/
void __inline__ Key_Event_Alt(int key, int action) 
{
	 if(DpadAsturn == 1) 
	 	Key_Event(key, action); 
	 else {
		key = key==K_LEFTARROW ? 0 : 1;
		Key_Event( turnKeysyms[1][key], action);
	 }
} 
开发者ID:xyzr0482,项目名称:quake-android,代码行数:13,代码来源:touchscreenkeyboard.c

示例12: mouse_wheel_event

static void mouse_wheel_event(SDL_MouseWheelEvent *event)
{
	if (event->y > 0) {
		Key_Event(K_MWHEELUP, true);
		Key_Event(K_MWHEELUP, false);
	} else if (event->y < 0) {
		Key_Event(K_MWHEELDOWN, true);
		Key_Event(K_MWHEELDOWN, false);
	}
}
开发者ID:kostya7,项目名称:ezquake-source,代码行数:10,代码来源:vid_sdl2.c

示例13: mouse_wheel_event

static void mouse_wheel_event( SDL_MouseWheelEvent *event )
{
	int key = event->y > 0 ? K_MWHEELUP : K_MWHEELDOWN;
	unsigned sys_msg_time = Sys_Milliseconds();

	if( !mouse_active ) {
		return;
	}

	Key_Event( key, true, sys_msg_time );
	Key_Event( key, false, sys_msg_time );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:12,代码来源:sdl_input.c

示例14: Sys_SendKeyEvents

void Sys_SendKeyEvents (void)
{
	int	k, next;
	int	outkey;

// grab frame time
	sys_msg_time = Sys_Milliseconds();

// get key events

	while (keybuf_head != keybuf_tail)
	{
		k = keybuf[keybuf_tail++];
		keybuf_tail &= (KEYBUF_SIZE - 1);

		if (k == 0xe0)
			continue;		// special / pause keys
		next = keybuf[(keybuf_tail - 2) & (KEYBUF_SIZE - 1)];
		// Pause generates e1 1d 45 e1 9d c5 when pressed, and
		// nothing when released. e1 is generated only for the
		// pause key.
		if (next == 0xe1)
			continue;		// pause key bullshit
		if (k == 0xc5 && next == 0x9d)
		{
			Key_Event (K_PAUSE, true, sys_msg_time);
			continue;
		}

		// extended keyboard shift key bullshit
		if ( (k & 0x7f) == SC_LEFTSHIFT || (k & 0x7f) == SC_RIGHTSHIFT )
		{
			if (keybuf[(keybuf_tail - 2) & (KEYBUF_SIZE - 1)] == 0xe0)
				continue;
			k &= 0x80;
			k |= SC_RIGHTSHIFT;
		}

		if (k == 0xc5 && keybuf[(keybuf_tail - 2) & (KEYBUF_SIZE - 1)] == 0x9d)
			continue;	// more pause bullshit

		outkey = scantokey[k & 0x7f];

		if (k & 0x80)
			Key_Event (outkey, false, sys_msg_time);
		else
			Key_Event (outkey, true, sys_msg_time);
	}

	sys_frame_time = Sys_Milliseconds(); /* FS: Need to update this for input to work properly */
}
开发者ID:basecq,项目名称:q2dos,代码行数:51,代码来源:sys_dos.c

示例15: mousehandler

static void
mousehandler ( int buttonstate, int dx, int dy, int dz, int drx, int dry, int drz )
{
	mouse_buttonstate = buttonstate;
	mx += dx;
	my += dy;
	if (drx > 0) {
		Key_Event(K_MWHEELUP, 1);
		Key_Event(K_MWHEELUP, 0);
	} else if (drx < 0) {
		Key_Event(K_MWHEELDOWN, 1);
		Key_Event(K_MWHEELDOWN, 0);
	}
}
开发者ID:luaman,项目名称:qforge-old,代码行数:14,代码来源:in_svgalib.c


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