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); }
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; }
void handleInput() { controle.updateOld (); controle.reset (); if (keysHeld() & KEY_UP) { controle.up = true; } else if (keysHeld() & KEY_DOWN) { controle.down = true ; } if (keysHeld() & KEY_LEFT) { controle.left = true ; } else if (keysHeld() & KEY_RIGHT) { controle.right = true ; } if (keysHeld() & KEY_A) { controle.a = true ; } }
void midicctrack::flowpress(void) { if (keysDown() & KEY_START) { if (activepatterns[currenteditpattern] == 0) { activepatterns[currenteditpattern] = 1; } else if (activepatterns[currenteditpattern] == 1) { activepatterns[currenteditpattern] = 0; } } touchPosition touch; if ((keysDown() & KEY_TOUCH) || (keysHeld() & KEY_TOUCH)) { touchRead(&touch); int yval = touch.py; int xval = touch.px; if (yval < 128) { if (keysDown() & KEY_TOUCH) { prevx = xval; prevy = yval; patterns[currenteditpattern][xval] = (127 - yval); } else if (keysHeld() & KEY_TOUCH) { if ((xval != prevx) && (yval != prevy)) { linealg(prevx, prevy, xval, yval); prevx = xval; prevy = yval; } } } else if ((yval > 127) && (yval < 160)) { xval = xval / 32; currenteditpattern = xval; } } }
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)); }
void checkKeys() { // Only for inside sound loops scanKeys(); touchPosition touch = touchReadXYNew(); if((keysHeld() & KEY_TOUCH) && hasTouched) { // Do the move event queueControls(touch.px, touch.py, CE_MOVE); return; } queueHotKeys(keysDown(), keysHeld()); }
static void get_pen_delta( int *dx, int *dy ) { static int prev_pen[2] = { 0x7FFFFFFF, 0x7FFFFFFF }; touchPosition touchXY; u32 keys = keysHeld(); if( keys & KEY_TOUCH ) { touchRead(&touchXY); if( prev_pen[0] != 0x7FFFFFFF ) { *dx = (prev_pen[0] - touchXY.rawx); *dy = (prev_pen[1] - touchXY.rawy); } else { *dx = *dy = 0; } prev_pen[0] = touchXY.rawx; prev_pen[1] = touchXY.rawy; } else { prev_pen[0] = prev_pen[1] = 0x7FFFFFFF; *dx = *dy = 0; } }
//----------------------------------------------------------------- // 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; } }
void Button::update_state(touchPosition stylus) { bool stylus_on_button = stylus_on(stylus); bool stylus_down = keysDown() & KEY_TOUCH; bool stylus_up = keysUp() & KEY_TOUCH; bool stylus_held = keysHeld() & KEY_TOUCH; switch (state) { case BUTTON_NORMAL: if (stylus_down && stylus_on_button) { state = BUTTON_PRESSED; } break; case BUTTON_PRESSED: if (stylus_up && stylus_on(last_stylus)) { state = BUTTON_CLICKED; } else if (stylus_held && !stylus_on_button) { state = BUTTON_NORMAL; } break; case BUTTON_CLICKED: state = BUTTON_NORMAL; break; default: break; } last_stylus = stylus; }
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; } }
void MainMenu::update(touchPosition* touch) { if (justSwitched) { if (keysHeld() & KEY_TOUCH) { return; } else { justSwitched = false; } } Screen::update(); for (MainMenuButton* button : buttons) { if (button->update(touch)) return; } if (keysDown() & KEY_B) { if (Gui::showChoiceMessage(i18n::localize("SAVE_CHANGES_1"), i18n::localize("SAVE_CHANGES_2"), doTimer ? 250000000 : 0)) // Half second { TitleLoader::saveChanges(); } Gui::screenBack(); return; } }
/* 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(); }
bool InputManager::moveToPosition(Vector3<s16>* currentPosition, float32 speed, Vector3<s16>& destinationOut) { s16 from_x = currentPosition->x(); s16 from_y = currentPosition->y(); touchPosition heldPosition; if(keysHeld() & KEY_TOUCH){ touchRead(&heldPosition); s16 diff_x = (heldPosition.px - from_x); s16 diff_y = (heldPosition.py - from_y); u32 magnitude = sqrt32(diff_x * diff_x + diff_y * diff_y); if (magnitude < 2) return NULL; diff_x = round(diff_x * speed / magnitude); diff_y = round(diff_y * speed / magnitude); destinationOut.setX((u16)(from_x + diff_x)); destinationOut.setY((u16)(from_y + diff_y)); return true; } else { destinationOut = *currentPosition; return false; } }
u16 nds_keysHeld() { while (nds_power_state() == POWER_STATE_ASLEEP) { swiWaitForVBlank(); } return _nds_handedness_swap(keysHeld()); }
static void neoSystemDoFrame() { u32 keys; u32 input; ASSERT(g_neo->cpuClockDivide == 2 || g_neo->cpuClockDivide == 3); profilerPush(NEOPROFILE_CPU); g_neo->scanline = 0; cpuExecute(CPU_CLOCKS_PER_SCANLINE); profilerPop(); //do frame g_neo->frameCount++; pd4990a_addretrace(); neoAudioStreamProcess(); g_neo->watchdogCounter++; /*if(g_neo->watchdogCounter > 10) { systemWriteLine("WATCHDOG!!!!"); neoSystemReset(); return; }*/ keys = keysHeld(); //arrow keys are not configurable input = 0xff; if(keys & KEY_UP) input &= ~(1 << 0); if(keys & KEY_DOWN) input &= ~(1 << 1); if(keys & KEY_LEFT) input &= ~(1 << 2); if(keys & KEY_RIGHT) input &= ~(1 << 3); g_neo->ctrl1Reg = 0x00ff | ((u16)input << 8); g_neo->ctrl2Reg = 0xffff; //input = 0x05; //if(keys & KEY_START) input &= ~(1 << 0); //mask with 0x7000 to disable memory card g_neo->ctrl3Reg = 0xcf00;//0x8A00 | 0x7000 | ((u16)input << 8); //input = 0x03; //if(keys & KEY_SELECT) input &= ~(1 << 0); //set audio command to 01 to hack out sound g_neo->coinReg = 0x0007 | //0x0004 | input | (read_4990_testbit() << 6) | (read_4990_databit() << 7);// | //((u16)NEOIPC->audioResult << 8); /*if(!NEOIPC->globalAudioEnabled) { //hack audio ready bit g_neo->coinReg |= (1 << 8); }*/ g_neo->ctrl4Reg = 0xff80; neoSystemDoKeys(keys); }
void EventHandler::Update() { scanKeys(); touchRead(&m_touchPos); m_held = keysHeld(); m_pressed = keysDown(); }
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; } } } }
bool checkSleepState() { if(getLCDState() == LCD_OFF) { if(!(keysHeld() & KEY_LID)) { setLCDState(LCD_ON); return true; } } else { if(keysHeld() & KEY_LID) { setLCDState(LCD_OFF); return true; } } return false; }
void advRotating(void) { videoSetMode(MODE_5_2D); vramSetBankA(VRAM_A_MAIN_BG); int bg = bgInit(3, BgType_ExRotation, BgSize_ER_256x256, 0,1); dmaCopy(TextBackgroundsTiles, bgGetGfxPtr(bg), sizeof(TextBackgroundsTiles)); dmaCopy(TextBackgroundsPal, BG_PALETTE, sizeof(TextBackgroundsPal)); dmaCopy(Layer256x256Map, bgGetMapPtr(bg), Layer256x256MapLen); bgMosaicEnable(bg); int keys = 0; int angle = 0; int center_x = 0; int center_y = 0; while(!(keys & KEY_B)) { scanKeys(); keys = keysHeld(); if(keys & KEY_UP) center_y--; if(keys & KEY_DOWN) center_y++; if(keys & KEY_LEFT) center_x--; if(keys & KEY_RIGHT) center_x++; if(keys & KEY_L) angle-=40; if(keys & KEY_R) angle+=40; if(center_x > 256) center_x = 256; if(center_x < 0) center_x = 0; if(center_y > 192) center_y = 192; if(center_y < 0) center_y = 0; swiWaitForVBlank(); bgSetRotate(bg, angle); bgSetScroll(bg, center_x, center_y); bgSetCenter(bg, center_x, center_y); bgUpdate(); consoleClear(); iprintf("Press B to exit.n"); iprintf("Angle: %d \ncenter X: %d center Y: %d", angleToDegrees(angle), center_x, center_y); } }
void I_GetEvent(void) { // Mappings of DS keys to SRB2 keys UINT32 dskeys[] = { KEY_A, KEY_B, KEY_X, KEY_Y, KEY_L, KEY_R, KEY_START, KEY_SELECT }; event_t event; UINT32 held, up, down; UINT32 i; // Check how the state has changed since last time scanKeys(); // For the d-pad, we only care about the current state held = keysHeld(); event.type = ev_joystick; event.data1 = 0; // First (and only) axis set if (held & KEY_LEFT) event.data2 = -1; else if (held & KEY_RIGHT) event.data2 = 1; else event.data2 = 0; if (held & KEY_UP) event.data3 = -1; else if (held & KEY_DOWN) event.data3 = 1; else event.data3 = 0; D_PostEvent(&event); // For the buttons, we need to report changes in state up = keysUp(); down = keysDown(); for (i = 0; i < sizeof(dskeys)/sizeof(dskeys[0]); i++) { // Has this button's state changed? if ((up | down) & dskeys[i]) { event.type = (up & dskeys[i]) ? ev_keyup : ev_keydown; event.data1 = KEY_JOY1 + i; D_PostEvent(&event); } } }
void lose(Board *b){ credits(); int s = 0; playGenericSound(lose_raw, lose_raw_size); //Wait for them to release a key while( keysHeld() ){ scanKeys(); loseRender(b, s++); swiWaitForVBlank(); } //Let them stew for a few seconds for ( int f = 0; f < 180; f++ ){ loseRender(b, s++); swiWaitForVBlank(); } //wait for a keypress while( !keysHeld() ){ loseRender(b, s++); scanKeys(); swiWaitForVBlank(); } }
void roomEditorControls(void) { //TEMP CONTROLS // if(keysHeld() & KEY_R)editorScale+=inttof32(2); // if(keysHeld() & KEY_L)editorScale-=inttof32(2); if(keysHeld() & KEY_R)moveCameraImmediate(&editorCamera, vect(0,0,inttof32(1)/32)); if(keysHeld() & KEY_L)moveCameraImmediate(&editorCamera, vect(0,0,-inttof32(1)/32)); if(keysHeld() & KEY_UP)moveCameraImmediate(&editorCamera, vect(0,inttof32(1)/32,0)); else if(keysHeld() & KEY_DOWN)moveCameraImmediate(&editorCamera, vect(0,-inttof32(1)/32,0)); if(keysHeld() & KEY_RIGHT)moveCameraImmediate(&editorCamera, vect(inttof32(1)/32,0,0)); else if(keysHeld() & KEY_LEFT)moveCameraImmediate(&editorCamera, vect(-inttof32(1)/32,0,0)); if(keysHeld() & KEY_Y)rotateMatrixY(editorCamera.transformationMatrix, 256, true); if(keysHeld() & KEY_A)rotateMatrixY(editorCamera.transformationMatrix, -256, true); if(keysHeld() & KEY_B)rotateMatrixX(editorCamera.transformationMatrix, 256, false); if(keysHeld() & KEY_X)rotateMatrixX(editorCamera.transformationMatrix, -256, false); // if(keysHeld() & KEY_START){writeMapEditor(&editorRoom, "fat:/test.map");} if(keysDown() & KEY_SELECT){switchScreens();} // if((keysHeld() & KEY_R) && (keysHeld() & KEY_L))changeState(&editorState); }
void loop() { //u16 i,j; copy_comic_to_buffer(&comics[current_comic], main_buffer); while (1) { scanKeys(); consoleSelect(&top_screen); consoleClear(); puts("Made by Lennart Kroes, s1062295"); //scroll_comic(); /* for(j = 0; j < SCREEN_HEIGHT; j++) for(i = 0; i < SCREEN_WIDTH; i++) sub_buffer[(j * SCREEN_WIDTH) + i] = ( RGB15(17,8,28) | (1 << 15) ); */ handle_button( scroll ); handle_button( next ); if(keysHeld() & KEY_RIGHT) scroll_comic(); if(keysHeld() & KEY_LEFT) scroll_comic(); if(keysHeld() & KEY_UP) scroll_comic(); if(keysHeld() & KEY_DOWN) scroll_comic(); copy_buffers(); swiWaitForVBlank(); } }
void Manager_Input::process_inputs() { int i = 0; scanKeys(); //Refresh snapshot of inputs this->keys = keysHeld(); //Get the snapshot of inputs while(this->lst_keys[i]!=0) { if (this->keys & this->lst_keys[i]) //some button dragged { if ( !(this->keys_bak & this->lst_keys[i]) ) //some button just pressed { this->button_pressed(this->lst_keys[i]); } this->button_dragged(this->lst_keys[i]); } else if (this->keys_bak & this->lst_keys[i]) { this->button_unpressed(this->lst_keys[i]); } i++; } if (this->keys & KEY_TOUCH) { //this->tp = touchReadXY(); touchRead(&this->tp); if ( !(this->keys_bak & KEY_TOUCH) ){ this->tp_bak = this->tp; this->touchscreen_pressed(); } this->touchscreen_dragged(); } else if (this->keys_bak & KEY_TOUCH) { this->touchscreen_unpressed(); } keys_bak = keys; }
void NDS_PumpEvents(_THIS) { scanKeys(); /* TODO: defer click-age */ if (keysDown() & KEY_TOUCH) { SDL_SendMouseButton(0, SDL_PRESSED, 0); } else if (keysUp() & KEY_TOUCH) { SDL_SendMouseButton(0, SDL_RELEASED, 0); } if (keysHeld() & KEY_TOUCH) { touchPosition t = touchReadXY(); SDL_SendMouseMotion(0, 0, t.px, t.py, 1); /* last arg is pressure, hardcoded 1 for now */ } }
//Same as keys pressed but returns true as long as a key is being held. Resolve //the event if it fires to figure out what keys are being held/pressed int blu_impl::Input_KeysHeld(){ bluVent keyVent; scanKeys(); unsigned int keys = keysHeld(); if(!keys){ keyVent.msg = NO_MSG; AddToTailQueue(keyVent); return 0; } keyVent.msg = KEYHELD; keyVent.keys = keys; AddToTailQueue(keyVent); return 1; }
void updateControl(controlInput_type ci) { switch(ci) { case INPUT_DOUBLETAP: if(keysDown() & KEY_TOUCH) { if(!touchCnt)touchCnt=16; else if(controlFunctions[currentConfiguration[ci]]){controlFunctions[currentConfiguration[ci]](getPlayer(),true,true);touchCnt=0;} } if(touchCnt)touchCnt--; break; default: if((keysHeld() & inputMasks[ci]) && controlFunctions[currentConfiguration[ci]]){controlFunctions[currentConfiguration[ci]](getPlayer(),(keysDown()&inputMasks[ci]),(keysHeld()&inputMasks[ci]));} break; } }
void UIManager::ProcessInput() { touchPosition disp_point; scanKeys(); uint16_t keyData = keysHeld(); touchRead(&disp_point); if(!(mLastButtonState & KEY_TOUCH) && (keyData & KEY_TOUCH))//PenDown { PointerListEntry* sliceNode = mSliceList; while (sliceNode != NULL) { if(((UISlice*)sliceNode->ptr)->OnPenDown(mContext, disp_point.px, disp_point.py)) break; sliceNode = sliceNode->next; } if(sliceNode == NULL && mOnPenDownFunc != NULL) //no slice has done anything, let's pass the event through mOnPenDownFunc(mContext, disp_point.px, disp_point.py); } else if((mLastButtonState & KEY_TOUCH) && (keyData & KEY_TOUCH) && (mLastTouchState.px != disp_point.px || mLastTouchState.py != disp_point.py))//PenMove { PointerListEntry* sliceNode = mSliceList; while (sliceNode != NULL) { if(((UISlice*)sliceNode->ptr)->OnPenMove(mContext, disp_point.px, disp_point.py)) break; sliceNode = sliceNode->next; } if(sliceNode == NULL && mOnPenMoveFunc != NULL) //no slice has done anything, let's pass the event through mOnPenMoveFunc(mContext, disp_point.px, disp_point.py); } else if((mLastButtonState & KEY_TOUCH) && !(keyData & KEY_TOUCH))//PenUp { PointerListEntry* sliceNode = mSliceList; while (sliceNode != NULL) { if(((UISlice*)sliceNode->ptr)->OnPenUp(mContext, mLastTouchState.px, mLastTouchState.py)) break; sliceNode = sliceNode->next; } if(sliceNode == NULL && mOnPenUpFunc != NULL) //no slice has done anything, let's pass the event through mOnPenUpFunc(mContext, mLastTouchState.px, mLastTouchState.py); } mLastTouchState = disp_point; mLastButtonState = keyData; }
static void receiveInput() { bool modelChanged = false; scanKeys(); u16 pressed = keysDown(); u16 held = keysHeld(); if (held & KEY_LEFT) rotateCameraY(50); if (held & KEY_RIGHT) rotateCameraY(-50); if (held & KEY_UP) rotateCameraX(50); if (held & KEY_DOWN) rotateCameraX(-50); if (held & KEY_X) rotateCameraZ(30); if (pressed & KEY_L) { selectedModel--; modelChanged = true; } if (pressed & KEY_R) { selectedModel++; modelChanged = true; } if (modelChanged) { if (selectedModel >= NUM_MODELS) selectedModel = NUM_MODELS-1; if (selectedModel < 0) selectedModel = 0; updateConsole(); lookAtSelectedModel(); } if (pressed & KEY_A) drawMode = !drawMode; if (pressed & KEY_START) lookAtSelectedModel(); }
void EventDispatcher::dispatchEvents(void) { Event* currentEvent; uint32 downKeys = keysDown(); uint32 heldKeys = keysHeld(); uint32 upKeys = keysUp(); /* This might be an infinite loop if there exists two events that fire each other */ for (; startPointer != endPointer; startPointer = getNext(startPointer)) { currentEvent = events[startPointer]; if (currentEvent->enabled) { void* args = NULL; bool callFunc = false; /* Build the args here */ switch (currentEvent->type) { case BUTTON_PRESS: if (downKeys != 0) { callFunc = true; } break; case BUTTON_HOLD: if (heldKeys != 0) { callFunc = true; } break; case BUTTON_RELEASE: if (upKeys != 0) { callFunc = true; } break; case FRAME_CHANGE: callFunc = true; break; } if (callFunc == true) { /* Call that shit */ currentEvent->eventCallback(args); } } } }