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


C++ KeyState函数代码示例

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


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

示例1: KeyState

/*
==============================
AdjustPitch

==============================
*/
void CInput::AdjustPitch( float speed, QAngle& viewangles )
{
	// only allow keyboard looking if mouse look is disabled
	if ( UsingMouselook() == false )
	{
		float	up, down;

		if ( in_klook.state & 1 )
		{
			view->StopPitchDrift ();
			viewangles[PITCH] -= speed*cl_pitchspeed.GetFloat() * KeyState (&in_forward);
			viewangles[PITCH] += speed*cl_pitchspeed.GetFloat() * KeyState (&in_back);
		}

		up		= KeyState ( &in_lookup );
		down	= KeyState ( &in_lookdown );
		
		viewangles[PITCH] -= speed*cl_pitchspeed.GetFloat() * up;
		viewangles[PITCH] += speed*cl_pitchspeed.GetFloat() * down;

		if ( up || down )
		{
			view->StopPitchDrift ();
		}
	}	
}
开发者ID:jimbomcb,项目名称:BirdPoop-Src,代码行数:32,代码来源:in_main.cpp

示例2: KeyState

void InputManager::OnInitialize()
{
    Keys[SDLK_w] = KeyState();
    Keys[SDLK_a] = KeyState();
    Keys[SDLK_s] = KeyState();
    Keys[SDLK_d] = KeyState();
}
开发者ID:kametman,项目名称:aether,代码行数:7,代码来源:inputmanager.cpp

示例3: PrintEvent

static void PrintEvent(const Event& event)
{
    switch (event.Type)
    {
      case Event::EVENT_CLOSED:
        std::cout << "Event: Window Closed" << std::endl;
        break;
      case Event::EVENT_MOVED:
        std::cout << "Event: Window Moved (" << event.Move.X
                  << ", " << event.Move.Y << ")" << std::endl;
        break;
      case Event::EVENT_RESIZED:
        std::cout << "Event: Window Resized (" << event.Size.Width
                  << ", " << event.Size.Height << ")" << std::endl;
        break;
      case Event::EVENT_LOST_FOCUS:
        std::cout << "Event: Window Lost Focus" << std::endl;
        break;
      case Event::EVENT_GAINED_FOCUS:
        std::cout << "Event: Window Gained Focus" << std::endl;
        break;
      case Event::EVENT_TEXT_ENTERED:
        // TODO(cwallez) show the character
        std::cout << "Event: Text Entered" << std::endl;
        break;
      case Event::EVENT_KEY_PRESSED:
        std::cout << "Event: Key Pressed (" << KeyName(event.Key.Code) << KeyState(event.Key) << ")" << std::endl;
        break;
      case Event::EVENT_KEY_RELEASED:
        std::cout << "Event: Key Released (" << KeyName(event.Key.Code) << KeyState(event.Key) << ")" << std::endl;
        break;
      case Event::EVENT_MOUSE_WHEEL_MOVED:
        std::cout << "Event: Mouse Wheel (" << event.MouseWheel.Delta << ")" << std::endl;
        break;
      case Event::EVENT_MOUSE_BUTTON_PRESSED:
        std::cout << "Event: Mouse Button Pressed " << MouseButtonName(event.MouseButton.Button) <<
                  " at (" << event.MouseButton.X << ", " << event.MouseButton.Y << ")" << std::endl;
        break;
      case Event::EVENT_MOUSE_BUTTON_RELEASED:
        std::cout << "Event: Mouse Button Released " << MouseButtonName(event.MouseButton.Button) <<
                  " at (" << event.MouseButton.X << ", " << event.MouseButton.Y << ")" << std::endl;
        break;
      case Event::EVENT_MOUSE_MOVED:
        std::cout << "Event: Mouse Moved (" << event.MouseMove.X
                  << ", " << event.MouseMove.Y << ")" << std::endl;
        break;
      case Event::EVENT_MOUSE_ENTERED:
        std::cout << "Event: Mouse Entered Window" << std::endl;
        break;
      case Event::EVENT_MOUSE_LEFT:
        std::cout << "Event: Mouse Left Window" << std::endl;
        break;
      case Event::EVENT_TEST:
        std::cout << "Event: Test" << std::endl;
        break;
      default:
        UNREACHABLE();
        break;
    }
}
开发者ID:CODECOMMUNITY,项目名称:angle,代码行数:60,代码来源:OSWindow.cpp

示例4: KeyState

/*
==============================
ComputeForwardMove

==============================
*/
void CInput::ComputeForwardMove( CUserCmd *cmd )
{
    if ( !(in_klook.state & 1 ) )
    {
        cmd->forwardmove += cl_forwardspeed.GetFloat() * KeyState (&in_forward);
        cmd->forwardmove -= cl_backspeed.GetFloat() * KeyState (&in_back);
    }
}
开发者ID:xsopher,项目名称:VinHax,代码行数:14,代码来源:in_main.cpp

示例5: StopMap

VOID StopMap(BOOL ResetShiftKeys)
{
	AbbrevDeletes = QueuedChars = SequenceLen = PendingDown = 0;
	if (ResetShiftKeys) {
		if (GetKeyState(VK_CONTROL)	< 0) KeyState(VK_CONTROL, FALSE);
		if (GetKeyState(VK_SHIFT)	< 0) KeyState(VK_SHIFT,	  FALSE);
		if (GetKeyState(VK_MENU)	< 0) KeyState(VK_MENU,	  FALSE);
		FinalKeyState = 0;
	}
}
开发者ID:mike2718,项目名称:WinVi,代码行数:10,代码来源:Map.c

示例6: MousePos

	MouseState MouseState::GetState()
	{
		MouseState ms;

		ms.position = MousePos();
		ms.buttons[BUTTON_LEFT]		= KeyState(VK_LBUTTON);
		ms.buttons[BUTTON_MIDDLE]	= KeyState(VK_MBUTTON);
		ms.buttons[BUTTON_RIGHT]	= KeyState(VK_RBUTTON);

		return ms;
	};
开发者ID:SoundAxis,项目名称:Wrench.2014,代码行数:11,代码来源:MouseState.cpp

示例7: int

KeyboardState::KeyboardState()
{
    // NOTE(Wuxiang): Copy from the Key enum value.
    static std::vector<int> sKeyCode = { 32, 39, 44, 45, 46, 47, 48, 49, 50, 51,
                                         52, 53, 54, 55, 56, 57, 59, 61, 65, 66,
                                         67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
                                         77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
                                         87, 88, 89, 90, 91, 92, 93, 96, 161, 162,
                                         256, 257, 258, 259, 260, 261, 262, 263,
                                         264, 265, 266, 267, 268, 269, 280, 281,
                                         282, 283, 284, 290, 291, 292, 293, 294,
                                         295, 296, 297, 298, 299, 300, 301, 302,
                                         303, 304, 305, 306, 307, 308, 309, 310,
                                         311, 312, 313, 314, 320, 321, 322, 323,
                                         324, 325, 326, 327, 328, 329, 330, 331,
                                         332, 333, 334, 335, 336, 340, 341, 342,
                                         343, 344, 345, 346, 347, 348
                                       };

    int keyNum = int(sKeyCode.size());
    for (int keyIndex = 0; keyIndex < keyNum ; ++keyIndex)
    {
        auto key = Key(sKeyCode[keyIndex]);
        insert({ key, KeyState(key) });
    }
}
开发者ID:Lywx,项目名称:FalconEngine,代码行数:26,代码来源:KeyboardState.cpp

示例8: CalcButtonBits

/*
============
GetButtonBits

Returns appropriate button info for keyboard and mouse state
Set bResetState to 1 to clear old state info
============
*/
int CInput::GetButtonBits( int bResetState )
{
	int bits = 0;

	CalcButtonBits( bits, IN_SPEED, s_ClearInputState, &in_speed, bResetState );
	CalcButtonBits( bits, IN_WALK, s_ClearInputState, &in_walk, bResetState );
	CalcButtonBits( bits, IN_ATTACK, s_ClearInputState, &in_attack, bResetState );
	CalcButtonBits( bits, IN_DUCK, s_ClearInputState, &in_duck, bResetState );
	CalcButtonBits( bits, IN_JUMP, s_ClearInputState, &in_jump, bResetState );
	CalcButtonBits( bits, IN_FORWARD, s_ClearInputState, &in_forward, bResetState );
	CalcButtonBits( bits, IN_BACK, s_ClearInputState, &in_back, bResetState );
	CalcButtonBits( bits, IN_USE, s_ClearInputState, &in_use, bResetState );
	CalcButtonBits( bits, IN_LEFT, s_ClearInputState, &in_left, bResetState );
	CalcButtonBits( bits, IN_RIGHT, s_ClearInputState, &in_right, bResetState );
	CalcButtonBits( bits, IN_MOVELEFT, s_ClearInputState, &in_moveleft, bResetState );
	CalcButtonBits( bits, IN_MOVERIGHT, s_ClearInputState, &in_moveright, bResetState );
	CalcButtonBits( bits, IN_ATTACK2, s_ClearInputState, &in_attack2, bResetState );
	CalcButtonBits( bits, IN_RELOAD, s_ClearInputState, &in_reload, bResetState );
	CalcButtonBits( bits, IN_ALT1, s_ClearInputState, &in_alt1, bResetState );
	CalcButtonBits( bits, IN_ALT2, s_ClearInputState, &in_alt2, bResetState );
	CalcButtonBits( bits, IN_SCORE, s_ClearInputState, &in_score, bResetState );
	CalcButtonBits( bits, IN_ZOOM, s_ClearInputState, &in_zoom, bResetState );
	CalcButtonBits( bits, IN_GRENADE1, s_ClearInputState, &in_grenade1, bResetState );
	CalcButtonBits( bits, IN_GRENADE2, s_ClearInputState, &in_grenade2, bResetState );
	CalcButtonBits( bits, IN_TOPSPIN, s_ClearInputState, &in_topspin, bResetState );
	CalcButtonBits( bits, IN_BACKSPIN, s_ClearInputState, &in_backspin, bResetState);
	CalcButtonBits( bits, IN_SKILL, s_ClearInputState, &in_skill, bResetState );
	CalcButtonBits( bits, IN_GESTURE, s_ClearInputState, &in_gesture, bResetState );

	if ( KeyState(&in_ducktoggle) )
	{
		bits |= IN_DUCK;
	}

	// Cancel is a special flag
	if (in_cancel)
	{
		bits |= IN_CANCEL;
	}

	if ( gHUD.m_iKeyBits & IN_WEAPON1 )
	{
		bits |= IN_WEAPON1;
	}

	if ( gHUD.m_iKeyBits & IN_WEAPON2 )
	{
		bits |= IN_WEAPON2;
	}

	// Clear out any residual
	bits &= ~s_ClearInputState;

	if ( bResetState )
	{
		s_ClearInputState = 0;
	}

	return bits;
}
开发者ID:iosoccer,项目名称:iosoccer-game,代码行数:68,代码来源:in_main.cpp

示例9: switch

bool KeyStateListener::eventFilter (QObject *obj, QEvent *event)
{
    switch (event-> type())
    {
        case QEvent::KeyPress:
            press_key_ (KeyState (static_cast <QKeyEvent *> (event)));
            return false;

        case QEvent::KeyRelease:
            release_key_ (KeyState (static_cast <QKeyEvent *> (event)));
            return false;

        default:
            return QObject::eventFilter (obj, event);
    }
}
开发者ID:sempuki,项目名称:code,代码行数:16,代码来源:main.cpp

示例10: RenderStreamToSurface

bool SINMOVIE::RenderStreamToSurface()
{
if (KeyState(VK_RETURN)) {  MovieState=2; ShutDown();return false; } 
if (pSample->Update(0, NULL, NULL, 0) != S_OK) {  MovieState=2; ShutDown(); return 
false; } 
pMovieSurface->Blt(&DRect, pSurface, &SRect, DDBLT_WAIT, NULL); 
return true;
}
开发者ID:rafaellincoln,项目名称:Source-Priston-Tale,代码行数:8,代码来源:sinMedia.cpp

示例11: while

void SINMOVIE::RenderStreamToSurfaceAll()
{
while (1)
{
  if (KeyState(VK_RETURN)) {  MovieState=2; ShutDown(); return; } 
  if (pSample->Update(0, NULL, NULL, 0) != S_OK) {  MovieState=2; ShutDown(); return; } 
  pMovieSurface->Blt(&DRect, pSurface, &SRect, DDBLT_WAIT, NULL); 
}
}
开发者ID:rafaellincoln,项目名称:Source-Priston-Tale,代码行数:9,代码来源:sinMedia.cpp

示例12: WndProc

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
		case WM_MOVE:
		case WM_SIZE:
			Utility::resize();
			break;
		case WM_CHAR:
			DeveloperConsole::catchCharacter((wchar_t)wParam);
			break;
		case WM_KEYDOWN:
			// check which key is pressed
			InputManager::keyDown(KeyState(wParam, lParam));
			switch(wParam)
			{
				case VK_F5:
					dx.toggleFullScreen();	
					break;
				case VK_F4: 
					killProgram();
					break;
			}
			break;
		case WM_COMMAND:
			wmId    = LOWORD(wParam);
			wmEvent = HIWORD(wParam);
			// Parse the menu selections:
			switch (wmId)
			{
			case IDM_ABOUT:
				DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
				break;
			case IDM_EXIT:
				DestroyWindow(hWnd);
				break;
			default:
				return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			// Add any drawing code here...
			EndPaint(hWnd, &ps);
			break;
		case WM_DESTROY:
			killProgram();
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
开发者ID:mcmonkey,项目名称:cglory,代码行数:67,代码来源:BaseCode.cpp

示例13: AnimData

GameScene::GameScene(const std::string& level)
{
    background_data_ = new AnimData("assets/background");
    background_ = new Animation(*background_data_);

    music_notes_.push_back(new Entity("musicnote0"));
    music_notes_.push_back(new Entity("musicnote1"));
    music_notes_.push_back(new Entity("musicnote2"));

    player_keys_.left = KeyState(sf::Key::Left);
    player_keys_.right = KeyState(sf::Key::Right);
    player_keys_.up = KeyState(sf::Key::Up);
    player_keys_.down = KeyState(sf::Key::Down);
    player_keys_.action = KeyState(sf::Key::Space);

    level_name_ = level;

    music_note_timer_ = 0.0f;
}
开发者ID:nlguillemot,项目名称:rock-n-roll-soul,代码行数:19,代码来源:gamescene.cpp

示例14: KeyScan

void KeyScan(){
  if(~PINC&0b00000111){ // обработчик нажатия
    flags.KeyReleased=0;
        if (++i > 5 ) {      //короткое нажатие 100-250 миллисекунд
            if (!flags.KeyPressed){flags.KeyPressed = 1;flags.KeyPin=(~PINC&0b00000111);}
               if ( i > 100 ){  //длинное нажатие 1-3 секунды
                 if (!flags.KeyPushLong){

                    flags.KeyPushLong=1;
                    KeyState();
                 }
               }
        }
    }
    else {
        i=0;
        if (!flags.KeyReleased) {flags.KeyReleased=1;}
        KeyState();
    }
        AddTask(KeyScan,25);
}
开发者ID:4glk,项目名称:at8_ct,代码行数:21,代码来源:kbd.c

示例15: KeyScan

void KeyScan(){
    volatile static uint8_t k=0;
  if(KEY_CODE){ // обработчик нажатия
    flags.KeyReleased=0;
        if (++k >=2 ) {      //короткое нажатие 100-250 миллисекунд
            if (!flags.KeyPressed){flags.KeyPressed = 1;flags.KeyPin=(KEY_CODE);}
               if ( k > 100 ){  //длинное нажатие 1-3 секунды
                 if (!flags.KeyPushLong){
                    k=0;                // проблема с этой переменной , конфликтует с енумом кнопок (((
                    flags.KeyPushLong=1;
                    KeyState();
                 }
               }
        }
    }
    else {
        k=0;
        if (!flags.KeyReleased) {flags.KeyReleased=1;}
        KeyState();
    }
    AddTask(KeyScan,50);
}
开发者ID:4glk,项目名称:low_temp,代码行数:22,代码来源:kbd.c


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