本文整理汇总了C++中scanKeys函数的典型用法代码示例。如果您正苦于以下问题:C++ scanKeys函数的具体用法?C++ scanKeys怎么用?C++ scanKeys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scanKeys函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: device_io
void device_io()
{
if ( render_audio() && --scanDC == 0 )
{
scanDC = bufsPerScan; // reload downcounter to next scan
/* scan keys */
if ( curKey >= 0 )
{
if ( ! readKey( curKey ) )
{
console.postKeyUp( curKey, 0 );
scanKeys();
}
}
else
scanKeys();
/* scan buttons */
for ( byte i = 0; i < NumButs; i++ )
scanBut(i);
/* read next pot */
readPot( nextPot );
if ( ++nextPot >= NumPots )
nextPot = 0;
}
}
示例2: main
int main(void)
{
videoSetMode(MODE_5_2D);
consoleDemoInit();
scanKeys();
int c = keysHeld();
Sfondo();
CreaPG();
while(true)
{
swiWaitForVBlank();
if(c!=0)
{
KeysPress(c);
//iprintf("-key:%i\n",c);
c = 0;
}
else
{//Nessun tasto premuto
scanKeys();
c = keysHeld();
}
}
return 0;
}
示例3: main
int main(void) {
consoleDemoInit();
Keyboard *kbd = keyboardDemoInit();
kbd->OnKeyPressed = OnKeyPressed;
while(1) {
char myName[256];
iprintf("What is your name?\n");
scanf("%s", myName);
iprintf("\nHello %s", myName);
scanKeys();
while(!keysDown())scanKeys();
swiWaitForVBlank();
consoleClear();
}
return 0;
}
示例4: waitfor
void waitfor(int keys)
{
scanKeys();
while((keysDown() & keys) == 0)
{
swiWaitForVBlank();
scanKeys();
}
}
示例5: while
void Menu::NX(int sock)
{
int volume = 77;
while(1) {
consoleClear();
iprintf("\n netxmms-nds\n ___________\n\n"
" A - PLAY\n"
" B - PAUSE\n"
" Y - STOP\n"
" R - NEXT\n"
" L - PREVIOUS\n"
" < - VOLUME-\n"
" > - VOLUME+\n\n"
" VOLUME: %d%%", volume);
while(1) {
swiWaitForVBlank();
scanKeys();
int pressed = keysDown();
int held = keysHeld();
if(pressed & KEY_A) NX::Play(sock);
if(pressed & KEY_B) NX::Pause(sock);
if(pressed & KEY_Y) NX::Stop(sock);
if(pressed & KEY_R) NX::Next(sock);
if(pressed & KEY_L) NX::Previous(sock);
if(pressed & KEY_LID) {
int s = REG_POWERCNT;
REG_POWERCNT = 0;
while(1) {
scanKeys();
if(keysUp() & KEY_LID) {
REG_POWERCNT = s;
break;
}
}
}
if(held & KEY_LEFT && volume > 0) {
volume--;
NX::Volume(sock, volume);
break;
}
else if(held & KEY_RIGHT && volume < 100) {
volume++;
NX::Volume(sock, volume);
break;
}
}
}
}
示例6: Update
void Update()
{
//@NOTE: scanKeys() and keysDown() must only be called once per frame, never more
scanKeys();
gKeysPressed = gRawKeysPressed = keysDown();
gKeysHeld = keysHeld();
if (gKeysPressed & PauseKey)
{
gIsPaused = !gIsPaused;
}
gUnpauseOneFrame = false;
if (gKeysPressed & UnpauseOneFrameKey)
{
gUnpauseOneFrame = true;
}
// Pause key only queryable via IsPaused()
gKeysPressed &= (~PauseKey & ~UnpauseOneFrameKey);
// When paused, for debugging purposes, it's useful to consider
// held keys as pressed keys
if (gIsPaused)
{
gKeysPressed |= gKeysHeld;
}
}
示例7: input
void input(){ //Fonction de test des touches
touchPosition touchXY;
do{
scanKeys();
if(keysHeld() & KEY_A)
iprintf("\x1b[4;0HAppui A"); //Bouton A
else if(keysHeld() & KEY_B)
iprintf("\x1b[5;0HAppui B"); //Bouton B
else if(keysHeld() & KEY_X)
iprintf("\x1b[6;0HAppui X"); //Bouton X
else if(keysHeld() & KEY_Y)
iprintf("\x1b[7;0HAppui Y"); //Bouton Y
else if(keysHeld() & KEY_L)
iprintf("\x1b[8;0HAppui L"); //Bouton L
else if(keysHeld() & KEY_R)
iprintf("\x1b[9;0HAppui R"); //Bouton R
else if(keysHeld() & KEY_START)
iprintf("\x1b[10;0HAppui START"); //Bouton START
else if(keysHeld() & KEY_SELECT)
iprintf("\x1b[11;0HAppui SELECT"); //Bouton SELECT
else{
int i; //Effaçage zone
for(i=4;i<=11;i++){
iprintf("\x1b[%u;0H ",i);
}
}
touchRead(&touchXY);
}while((touchXY.px>=0x00)&&(touchXY.py>=0x00)&&(touchXY.py<0xB4)&&(touchXY.py<0xFF));
}
示例8: updateInput
void updateInput(touchPosition * touch) {
// Update the key registers with current values.
scanKeys();
// Update the touch screen values.
touchRead(touch);
}
示例9: consoleClear
void Menu::Main()
{
consoleClear();
printf("\n netxmms-nds\n ___________\n\n"
" A - CONNECT\n"
" B - CONFIGURE\n\n"
" START - INFORMATION");
while(1) {
swiWaitForVBlank();
scanKeys();
u32 entry = keysDown();
if(entry & KEY_A) {
Menu::ConnectWifi();
return;
}
else if(entry & KEY_B) {
Menu::Configuration();
return;
}
else if(entry & KEY_START) {
Menu::Information();
return;
}
}
}
示例10: draw
LevelId LevelSelector::select_level() {
touchPosition stylus;
level.set_current_level(level.get_level(selected_button).id);
level.load();
draw();
while (true) {
scanKeys();
touchRead(&stylus);
if (button_ok.update(stylus) == BUTTON_CLICKED) {
return level.get_level(selected_button).id;
}
for (u8 current_button = 0; current_button < num_buttons; current_button++) {
if (buttons[current_button]->update(stylus) == BUTTON_CLICKED) {
u8 last_selected_button = selected_button;
set_selected_level(level.get_level(current_button).id);
buttons[last_selected_button]->draw();
buttons[selected_button]->draw();
level.set_current_level(level.get_level(selected_button).id);
level.load();
level.draw(LEVEL_X, LEVEL_Y);
}
}
swiWaitForVBlank();
}
}
示例11: NDS_PumpEvents
void NDS_PumpEvents(_THIS)
{
scanKeys();
int i;
SDL_keysym keysym;
keysym.mod=KMOD_NONE;
for(i=0;i<NDS_NUMKEYS;i++)
{
keysym.scancode=i;
keysym.sym=keymap[i];
if(keysHeld()&(1<<i) && !keymem[i])
{
keymem[i]=1;
//printf("key released %d\n",i);
SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
}
if(!(keysHeld()&(1<<i)) && keymem[i])
{
keymem[i]=0;
//printf("key pressed %d\n",i);
SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
}
}
//touchPosition touch;
//touch=touchReadXY();
//if (touch.px!=0 || touch.py!=0)
// SDL_PrivateMouseMotion(SDL_PRESSED, 0, touch.px, touch.py);
}
示例12: processInput
//-----------------------------------------------------------------
// process input
//-----------------------------------------------------------------
void processInput( void )
//-----------------------------------------------------------------
{
scanKeys();
int keysh = keysHeld();
// process user input
if( keysh & KEY_UP ) // check if UP is pressed
{
if ( g_ball.y == c_platform_level )
g_ball.yvel = -y_tweak;
else if ( (g_ball.yvel < 0) && (g_ball.y < 4 + c_platform_level) )
g_ball.yvel -= y_tweak/14;
}
if( keysh & KEY_DOWN ) // check if DOWN is pressed
{
// tweak y velocity of ball
g_ball.yvel += y_tweak;
}
if( keysh & KEY_LEFT ) // check if LEFT is pressed
{
// tweak x velocity
g_ball.xvel -= x_tweak;
}
if( keysh & KEY_RIGHT ) // check if RIGHT is pressed
{
// tweak y velocity
g_ball.xvel += x_tweak;
}
}
示例13: DS_VBlank_IRQ
/*
DS_VBlank_IRQ
Vertical blank interrupt callback.
*/
LOCALPROC DS_VBlank_IRQ(void)
{
scanKeys();
KeysHeld = keysHeld();
if (++VBlankCounter == 60) {
VBlankCounter = 0;
}
/*
TODO:
Rewrite this at some point, I'm not sure I like it.
*/
if (0 != (KeysHeld & KEY_LEFT)) {
--CursorX;
} else if (0 != (KeysHeld & KEY_RIGHT)) {
++CursorX;
}
if (0 != (KeysHeld & KEY_UP)) {
--CursorY;
} else if (0 != (KeysHeld & KEY_DOWN)) {
++CursorY;
}
CursorX = CursorX < 0 ? 0 : CursorX;
CursorX = CursorX > vMacScreenWidth ? vMacScreenWidth : CursorX;
CursorY = CursorY < 0 ? 0 : CursorY;
CursorY = CursorY > vMacScreenHeight ? vMacScreenHeight : CursorY;
DS_ScrollBackground();
bgUpdate();
}
示例14: main
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
consoleDemoInit(); //setup the sub screen for printing
keyboardDemoInit();
keyboardShow();
while(1) {
int key = keyboardUpdate();
if(key > 0)
iprintf("%c", key);
swiWaitForVBlank();
scanKeys();
int pressed = keysDown();
if(pressed & KEY_START) break;
}
return 0;
}
示例15: connect_ap
/* Try to connect to given AP and get an IP via DHCP */
int connect_ap(Wifi_AccessPoint * ap)
{
int ret;
int status = ASSOCSTATUS_DISCONNECTED;
clear_main();
/* Ask for DHCP */
Wifi_SetIP(0, 0, 0, 0, 0);
ret = Wifi_ConnectAP(ap, WEPMODE_NONE, 0, NULL);
if (ret) {
print_to_debug("error connecting");
return ASSOCSTATUS_CANNOTCONNECT;
}
while (status != ASSOCSTATUS_ASSOCIATED &&
status != ASSOCSTATUS_CANNOTCONNECT) {
int oldStatus = status;
status = Wifi_AssocStatus();
if (oldStatus != status)
printf_to_main("\n%s",
(char *)ASSOCSTATUS_STRINGS[status]);
else
printf_to_main(".");
scanKeys();
if (keysDown() & KEY_B)
break;
swiWaitForVBlank();
}
return status;
}