本文整理汇总了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 ();
}
}
}
示例2: KeyState
void InputManager::OnInitialize()
{
Keys[SDLK_w] = KeyState();
Keys[SDLK_a] = KeyState();
Keys[SDLK_s] = KeyState();
Keys[SDLK_d] = KeyState();
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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;
};
示例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) });
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}