本文整理汇总了C++中IsKeyPressed函数的典型用法代码示例。如果您正苦于以下问题:C++ IsKeyPressed函数的具体用法?C++ IsKeyPressed怎么用?C++ IsKeyPressed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsKeyPressed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetKeyboardUpdate
bool Application::GetKeyboardUpdate()
{
if(IsKeyPressed('A'))
{
scene->UpdateCameraStatus('a');
}
if(IsKeyPressed('D'))
{
scene->UpdateCameraStatus('d');
}
if(IsKeyPressed('W'))
{
scene->UpdateCameraStatus('w');
}
else
{
scene->UpdateCameraStatus('w', false);
}
if(IsKeyPressed('S'))
{
scene->UpdateCameraStatus('s');
}
if(IsKeyPressed(32))
{
scene->UpdateCameraStatus(32);
}
return true;
}
示例2: GetHotkeyModifierFlags
//! Returns current modifier keys pressed, using win32 MOD_* flags.
unsigned GetHotkeyModifierFlags() {
unsigned ret = 0;
if (IsKeyPressed(VK_CONTROL)) ret |= MOD_CONTROL;
if (IsKeyPressed(VK_SHIFT)) ret |= MOD_SHIFT;
if (IsKeyPressed(VK_MENU)) ret |= MOD_ALT;
if (IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN)) ret |= MOD_WIN;
return ret;
}
示例3: if
void InputManager::UpdateVirtualAxisFromKeyboard(int i)
{
if (IsKeyPressed(_myVirtualAxis[i].positiveAxis))
_myVirtualAxis[i].state=1.0;
else if (IsKeyPressed(_myVirtualAxis[i].negativeAxis))
_myVirtualAxis[i].state=-1.0;
else
_myVirtualAxis[i].state=0.0;
}
示例4: WaitForKeyRelease
static void WaitForKeyRelease (void)
{
if (IsKeyPressed())
while (IsKeyPressed())
{
BE_ST_BiosScanCode(0);
//getch();
}
}
示例5: RedSquareUpdate
// Update function for this object type
void RedSquareUpdate ( REDSQUARE *self )
{
COLLISION_FLAG flag = CheckHotspotCollision( self->rect_ );
char buffer[100] = { 0 };
// Apply acceleration for keystrokes
// Documentation for physics: http://cecilsunkure.blogspot.com/2012/02/basic-2d-vector-physics.html
// Documentation for collisions: http://cecilsunkure.blogspot.com/2012/07/collision-basic-2d-collision-detection.html
// http://cecilsunkure.blogspot.com/2012/04/binary-collision-maps-platformer.html
if(IsKeyPressed( VK_RIGHT ))
{
self->vel_.x_ += self->accel_ * GetDT( );
}
if(IsKeyPressed( VK_LEFT ))
{
self->vel_.x_ += -self->accel_ * GetDT( );
}
if(IsKeyPressed( VK_UP ))
{
self->vel_.y_ += -self->accel_ * GetDT( );
}
if(IsKeyPressed( VK_DOWN ))
{
self->vel_.y_ += self->accel_ * GetDT( );
}
// Clamp velocity within a max/min range
VelocityClamp( &self->vel_, .02f );
self->rect_.center_.x_ += self->vel_.x_ * GetDT( );
self->rect_.center_.y_ += self->vel_.y_ * GetDT( );
sprintf( buffer, "%.3f, %.3f", self->vel_.x_, self->vel_.y_ );
WriteStringToScreen( buffer, 30, 30 );
if(flag & COLLISION_BOTTOM)
{
SnapToCell( &self->rect_.center_.y_ );
self->vel_.y_ = 0.f;
}
if(flag & COLLISION_TOP)
{
SnapToCell( &self->rect_.center_.y_ );
self->vel_.y_ = 0.f;
}
if(flag & COLLISION_LEFT)
{
SnapToCell( &self->rect_.center_.x_ );
self->vel_.x_ = 0.f;
}
if(flag & COLLISION_RIGHT)
{
SnapToCell( &self->rect_.center_.x_ );
self->vel_.x_ = 0.f;
}
}
示例6: getKeyboardUpdate
bool Application::getKeyboardUpdate()
{
if(IsKeyPressed('W'))
scene->UpdateInput('w');
if(IsKeyPressed('A'))
scene->UpdateInput('a');
if(IsKeyPressed('S'))
scene->UpdateInput('s');
if(IsKeyPressed('D'))
scene->UpdateInput('d');
for (unsigned char i = '1'; i <= '9'; ++i)
{
if (IsKeyPressed(i))
scene->UpdateInput(i);
}
if(IsKeyPressed(VK_SPACE))
scene->UpdateInput(' ');
if(IsKeyPressed(VK_SHIFT))
scene->UpdateInput('S');
if(IsKeyPressed(VK_CONTROL))
scene->UpdateInput('C');
if (IsKeyPressed(VK_RETURN))
scene->UpdateInput('R');
return true;
}
示例7: should_relay_key_restricted
static bool should_relay_key_restricted(UINT p_key) {
switch(p_key) {
case VK_LEFT:
case VK_RIGHT:
case VK_UP:
case VK_DOWN:
return false;
default:
return (p_key >= VK_F1 && p_key <= VK_F24) || IsKeyPressed(VK_CONTROL) || IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN);
}
}
示例8: glfwGetMouseButton
void Controller::UpdateKeys()
{
/** Set all keys to false **/
for(unsigned i = 0; i < TOTAL_CONTROLS; ++i)
myKeys[i] = false;
/**** See which keys are pressed ****/
/** Keyboard **/
for(int i = 0; i <= OPEN; ++i)
{
if(IsKeyPressed(inputChar[i]))
myKeys[i] = true;
}
/** non-keyboard(mouse) **/
mouseLeftButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_LEFT);
mouseRightButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_RIGHT);
if(mouseLeftButton == GLFW_PRESS)
myKeys[SHOOT] = true;
if(mouseRightButton == GLFW_PRESS)
myKeys[AIM] = true;
/** Arrow key **/
if( IsKeyPressed(VK_UP) )
myKeys[ARROW_UP] = true;
if( IsKeyPressed(VK_DOWN) )
myKeys[ARROW_DOWN] = true;
if( IsKeyPressed(VK_LEFT) )
myKeys[ARROW_LEFT] = true;
if( IsKeyPressed(VK_RIGHT) )
myKeys[ARROW_RIGHT] = true;
/** Scrolling **/
GLFWwindow* glfwGetCurrentContext(void);
glfwSetScrollCallback(glfwGetCurrentContext(), scroll);
if(scrollyPos > 0.0)
{
myKeys[SCROLL_UP] = true;
}
else if(scrollyPos < 0.0)
{
myKeys[SCROLL_DOWN] = true;
}
if(scrollyPos != 0.0)
{
scrollyPos = 0.0;
}
}
示例9: CheckKey
virtual KeyAction CheckKey(int key) {
#ifdef MFLD_PRX_KEY_LAYOUT
if (IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) {
#else
if (IsKeyPressed(KEY_VOLUMEDOWN) && key == KEY_VOLUMEUP) {
#endif
return TOGGLE;
}
return ENQUEUE;
}
};
示例10: UpdateGame
// Update game (one frame)
void UpdateGame(void)
{
if (!gameOver)
{
if (IsKeyPressed('P')) pause = !pause;
if (!pause)
{
// Player movement
if (IsKeyDown(KEY_LEFT)) player.position.x -= 5;
if ((player.position.x - player.size.x/2) <= 0) player.position.x = player.size.x/2;
if (IsKeyDown(KEY_RIGHT)) player.position.x += 5;
if ((player.position.x + player.size.x/2) >= screenWidth) player.position.x = screenWidth - player.size.x/2;
// Launch ball
if (!ball.active)
{
if (IsKeyPressed(KEY_SPACE))
{
ball.active = true;
ball.speed = (Vector2){ 0, -5 };
}
}
UpdateBall();
// Game over logic
if (player.life <= 0) gameOver = true;
else
{
gameOver = true;
for (int i = 0; i < LINES_OF_BRICKS; i++)
{
for (int j = 0; j < BRICKS_PER_LINE; j++)
{
if (brick[i][j].active) gameOver = false;
}
}
}
}
}
else
{
if (IsKeyPressed(KEY_ENTER))
{
InitGame();
gameOver = false;
}
}
}
示例11: GameOver
int GameOver(int player)
{
//MOKHTAR,HAITHAM,BRAHIM,SALAH,WASSIM
int FallIndexes[5]= {29,23,47,29,26},selection=0, button_pressed=0;;
IMAGE **Pics;
IMAGE*cadre=load_image("Resources/Images/ingame_bar.png");
switch(player)
{
case 0:
Pics=MokhtarPics;
break;
case 1:
Pics=HaithamPics;
break;
case 2:
Pics=BrahimPics;
break;
case 3:
Pics=SalahPics;
break;
case 4:
Pics=WassimPics;
break;
}
while(!IsKeyPressed(1,ENTER))
{
button_pressed++;
if((IsKeyPressed(1,LEFT) || IsKeyPressed(1,RIGHT)) && button_pressed>10)
{
selection=!selection;
button_pressed=0;
}
draw_text(SharpCurve,"Game Over",20,50,5,CENTER_X,100);
draw_text(Arista,"Continue?",8,50,30,CENTER_X,100);
draw_text(Arista,"YES",8,25,50,CENTER_X,100);
draw_text(Arista,"NO",8,75,50,CENTER_X,100);
draw_image_ex(Pics[FallIndexes[player]],25,30,50,0,NONE,100);
draw_image_ex(cadre,18+selection*50,40,15,30,NONE,100);
next_frame();
}
while(IsKeyPressed(1,ENTER))
rest(1);
return !selection;
}
示例12: CheckKey
// The default CheckKey implementation assumes the device has power,
// volume up, and volume down keys.
//
// - Hold power and press vol-up to toggle display.
// - Press power seven times in a row to reboot.
// - Alternate vol-up and vol-down seven times to mount /system.
RecoveryUI::KeyAction RecoveryUI::CheckKey(int key) {
if (IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) {
return TOGGLE;
}
if (key == KEY_POWER) {
++consecutive_power_keys;
if (consecutive_power_keys >= 7) {
return REBOOT;
}
} else {
consecutive_power_keys = 0;
}
if ((key == KEY_VOLUMEUP &&
(last_key == KEY_VOLUMEDOWN || last_key == -1)) ||
(key == KEY_VOLUMEDOWN &&
(last_key == KEY_VOLUMEUP || last_key == -1))) {
++consecutive_alternate_keys;
if (consecutive_alternate_keys >= 7) {
consecutive_alternate_keys = 0;
return MOUNT_SYSTEM;
}
} else {
consecutive_alternate_keys = 0;
}
last_key = key;
return ENQUEUE;
}
示例13: IsKeyPressed
void InputManager::UpdateVirtualButtons()
{
bool pressed;
for (int i=0; i<(int)_myVirtualButtons.Size();i++)
{
pressed = IsKeyPressed(_myVirtualButtons[i].button);
_myVirtualButtons[i].keyDown=_myVirtualButtons[i].keyUp=false;
if (!_myVirtualButtons[i].keyPress && pressed)
{
_myVirtualButtons[i].keyDown=true;
EventManager::Instance().CallbackVButton(_myVirtualButtons[i].name, Event::buttonDown);
}
else if (_myVirtualButtons[i].keyPress && !pressed)
{
_myVirtualButtons[i].keyUp=true;
EventManager::Instance().CallbackVButton(_myVirtualButtons[i].name,Event::buttonUp);
}
_myVirtualButtons[i].keyPress = pressed;
/*if (pressed)
EventManager::Instance().CallbackVButton(_myVirtualButtons[i].name,
static_cast<int>(EventVButton::buttonPressed));*/
}
}
示例14: IsKeyPressed
BOOL InputClient_State::IsAltPressed() const
{
return IsKeyPressed(EKeyCode::Key_Menu)
//|| IsKeyPressed(EKeyCode::Key_LMenu)
//|| IsKeyPressed(EKeyCode::Key_RMenu)
;
}
示例15: Common_Update
void Common_Update()
{
/*
Capture key input
*/
unsigned int newButtons = 0;
while (IsKeyPressed())
{
unsigned int key = getchar();
if (key == '1') newButtons |= (1 << BTN_ACTION1);
else if (key == '2') newButtons |= (1 << BTN_ACTION2);
else if (key == '3') newButtons |= (1 << BTN_ACTION3);
else if (key == '4') newButtons |= (1 << BTN_ACTION4);
else if (key == 'h') newButtons |= (1 << BTN_LEFT);
else if (key == 'l') newButtons |= (1 << BTN_RIGHT);
else if (key == 'k') newButtons |= (1 << BTN_UP);
else if (key == 'j') newButtons |= (1 << BTN_DOWN);
else if (key == 32) newButtons |= (1 << BTN_MORE);
else if (key == 'q') newButtons |= (1 << BTN_QUIT);
}
gPressedButtons = (gDownButtons ^ newButtons) & newButtons;
gDownButtons = newButtons;
/*
Update the screen
*/
printf("%c[H", 0x1B); // Move cursor to home position
printf("%s", gConsoleText.c_str()); // Terminal console is already double buffered, so just print
printf("%c[J", 0x1B); // Clear the rest of the screen
gConsoleText.clear();
}