• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Key_Event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: mouse_hwheel_event

static void mouse_hwheel_event( int delta ) {
    UINT key;

    // FIXME: handle WHEEL_DELTA and partial scrolls...
    if( delta > 0 ) {
        key = K_MWHEELRIGHT;
    } else if( delta < 0 ) {
        key = K_MWHEELLEFT;
    } else {
        return;
    }

    Key_Event( key, qtrue, win.lastMsgTime );
    Key_Event( key, qfalse, win.lastMsgTime );
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:15,代码来源:vid_win.c


示例17: mouse_button_event

static void mouse_button_event(SDL_MouseButtonEvent *event)
{
	unsigned key;

	switch (event->button) {
	case SDL_BUTTON_LEFT:
		key = K_MOUSE1;
		break;
	case SDL_BUTTON_RIGHT:
		key = K_MOUSE2;
		break;
	case SDL_BUTTON_MIDDLE:
		key = K_MOUSE3;
		break;
	case 8:
	case SDL_BUTTON_X1:
		key = K_MOUSE4;
		break;
	case 9:
	case SDL_BUTTON_X2:
		key = K_MOUSE5;
		break;
	default:
		Com_DPrintf("%s: unknown button %d\n", __func__, event->button);
		return;
	}

	Key_Event(key, event->state);
}
开发者ID:kostya7,项目名称:ezquake-source,代码行数:29,代码来源:vid_sdl2.c


示例18: Handle_KeyMod

static void Handle_KeyMod(UInt32 keymod)
{
	const struct keymod_to_event_s { UInt32 keybit; keynum_t event; } keymod_events [] =
	{
		{ cmdKey,						K_AUX1 },
		{ shiftKey,						K_SHIFT },
		{ alphaLock,					K_CAPSLOCK },
		{ optionKey,					K_ALT },
		{ controlKey,					K_CTRL },
		{ kEventKeyModifierNumLockMask,	K_NUMLOCK },
		{ kEventKeyModifierFnMask,		K_AUX2 }
	};
	static UInt32 prev_keymod = 0;
	unsigned int i;
	UInt32 modChanges;

	modChanges = prev_keymod ^ keymod;
	if (modChanges == 0)
		return;

	for (i = 0; i < sizeof(keymod_events) / sizeof(keymod_events[0]); i++)
	{
		UInt32 keybit = keymod_events[i].keybit;

		if ((modChanges & keybit) != 0)
			Key_Event(keymod_events[i].event, '\0', (keymod & keybit) != 0);
	}

	prev_keymod = keymod;
}
开发者ID:CyberSys,项目名称:darkplaces,代码行数:30,代码来源:vid_agl.c


示例19: handle_button

static void handle_button(XGenericEventCookie *cookie)
{
	XIDeviceEvent *ev = (XIDeviceEvent *)cookie->data;
	qboolean down = cookie->evtype == XI_ButtonPress;
	int button = ev->detail;
	unsigned time = Sys_XTimeToSysTime(ev->time);
	int k_button;

	if(!mouse_active)
		return;

	switch(button) {
		case 1: k_button = K_MOUSE1; break;
		case 2: k_button = K_MOUSE3; break;
		case 3: k_button = K_MOUSE2; break;
		case 4: k_button = K_MWHEELUP; break;
		case 5: k_button = K_MWHEELDOWN; break;
			/* Switch place of MOUSE4-5 with MOUSE6-7 */
		case 6: k_button = K_MOUSE6; break;
		case 7: k_button = K_MOUSE7; break;
		case 8: k_button = K_MOUSE4; break;
		case 9: k_button = K_MOUSE5; break;
			/* End switch */
		case 10: k_button = K_MOUSE8; break;
		default: return;
	}

	Key_Event(k_button, down, time);
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:29,代码来源:unix_input.c


示例20: IN_SendKeyEvents

/**
 * @sa CL_SendCommand
 */
void IN_SendKeyEvents (void)
{
	while (keyq_head != keyq_tail) {
		Key_Event(keyq[keyq_tail].key, keyq[keyq_tail].unicode, keyq[keyq_tail].down, CL_Milliseconds());
		keyq_tail = (keyq_tail + 1) & (MAX_KEYQ - 1);
	}
}
开发者ID:ptitSeb,项目名称:UFO--AI-OpenPandora,代码行数:10,代码来源:cl_input.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Key_GetCatcher函数代码示例发布时间:2022-05-30
下一篇:
C++ Key_ClearStates函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap