// Process incoming events static int callback(int device, Finger *data, int nFingers, double timestamp, int frame) { if (!running || !sampling_interval_passed()) { return 0; } tuio_frame_begin(); std::set<int> fingers; // Process incoming events int i; for (i=0; i<nFingers; i++) { Finger *f = &data[i]; int id = f->identifier; float x = f->normalized.pos.x; float y = 1.0f - f->normalized.pos.y; // reverse y axis float size = f->size; if (EXISTS(currentFingers, id)) { // update touch_update(id, x, y, size); } else { // add touch_add(id, x, y, size); } fingers.insert(id); } // Remove old events std::set<int>::iterator iter; FOREACH(currentFingers, iter) { int id = *iter; if (!EXISTS(fingers, id)) { // remove touch_remove(id); } }
// Process incoming events static void callback(MTDeviceRef device, MTTouch touches[], size_t numTouches, double timestamp, size_t frame) { if (!running || !sampling_interval_passed()) { return; } tuio_frame_begin(); std::set<int> fingers; // Process incoming events int i; for (i=0; i<numTouches; i++) { MTTouch *f = &touches[i]; int id = f->pathIndex; float x = f->normalizedVector.position.x; float y = 1.0f - f->normalizedVector.position.y; // reverse y axis if (EXISTS(currentFingers, id)) { // update touch_update(id, x, y); } else { // add touch_add(id, x, y); } fingers.insert(id); } // Remove old events std::set<int>::iterator iter; FOREACH(currentFingers, iter) { int id = *iter; if (!EXISTS(fingers, id)) { // remove touch_remove(id); } }
int main(int _argc, char **_argv) { int framecount=0; int sramcount=0; argc=_argc, argv=_argv; defaultExceptionHandler(); fifoSendValue32(FIFO_USER_06, (u32)ipc_region); DS_init(); //DS init. #ifndef ROM_EMBEDED active_interface = fatInitDefault(); //init file operations to your external card. initNiFi(); #endif EMU_Init(); //emulation init. irqSet(IRQ_VBLANK, vblankinterrupt); irqEnable(IRQ_HBLANK); //fifoSetValue32Handler(FIFO_USER_06, aliveinterrupt, 0); //fifoSetValue32Handler(FIFO_USER_05, reg4015interrupt, 0); IPC_ALIVE = 0; IPC_APUIRQ = 0; IPC_REG4015 = 0; consoleinit(); //init subscreen to show chars. crcinit(); //init the crc table. //pre-alocate memory.... //IPC_FILES = malloc(MAXFILES * 256 + MAXFILES * 4); //IPC_ROM = malloc(ROM_MAX_SIZE); #ifndef ROM_EMBEDED if(!bootext()) { //chdir("/"); do_rommenu(); //show a menu selecting rom files. } #else do_romebd(); #endif //__emuflags |= PALSYNC; while(1) { // main loop to do the emulation framecount++; if(__emuflags & PALTIMING && global_playcount == 0) { framecount--; } if(debuginfo[VBLS]>59) { debuginfo[VBLS]-=60; debuginfo[1] = debuginfo[0]; debuginfo[0] = 0; debuginfo[FPS]=framecount; framecount=0; } scanKeys(); IPC_KEYS = keysCurrent(); //change nsf states if(__emuflags & NSFFILE) { static int oldkey = 0; int keydown = IPC_KEYS & (~oldkey); oldkey = IPC_KEYS; if(keydown & KEY_LEFT) { if(__nsfsongno == 0) { __nsfsongno = nsfheader.TotalSong-1; } else { __nsfsongno--; } } if(keydown & KEY_RIGHT) { if(++__nsfsongno > nsfheader.TotalSong-1) { __nsfsongno = 0; } } if(keydown & KEY_UP) { __nsfplay = 1; __nsfinit = 1; } if(keydown & KEY_DOWN) { __nsfplay = 0; Sound_reset(); } } do_shortcuts(); if((__emuflags & AUTOSRAM)) { if(__emuflags & NEEDSRAM) { sramcount = 1; __emuflags&=~NEEDSRAM; } if(sramcount > 0) sramcount++; if(sramcount > 120) { //need auto save for sram. sramcount = 0; save_sram(); } } touch_update(); // do menu functions. do_menu(); //do control menu. do_multi(); if(nifi_stat == 0 || nifi_stat >= 5) play(); //emulate a frame of the NES game. else swiWaitForVBlank(); } }