void GeneratorPersistenceH::doStorageHome(IR__::StorageHomeDef_ptr storagehome) { IR__::StorageTypeDef_var storagetype = storagehome->managed_storagetype(); // achtung: wenn kein modul, sollte vielleicht PSS_ der prefix für alle pss sein? out << "\n\n"; open_module(out, storagetype, ""); out << "\n\n"; out << "class " << std::string(storagetype->name()) << ";\n"; out << "class " << std::string(storagetype->name()) << "Ref;\n\n"; std::string strClassName = std::string(storagehome->name()); strActBasename_ = strClassName; out << "class " << strClassName << "\n"; out.indent(); IR__::StorageHomeDef_var base_storagehome = storagehome->base_storagehome(); if(base_storagehome) out << ": public virtual " << base_storagehome->name() << "\n"; else out << ": public virtual StorageHomeBaseImpl\n"; IR__::InterfaceDefSeq_var supported_infs = storagehome->supported_interfaces(); for(CORBA::ULong i=0; i<supported_infs->length(); i++) out << ", public virtual " << ((*supported_infs)[i])->name() << "\n"; out.unindent(); out << "{\n\npublic:\n\n"; out.indent(); out << strClassName << "();\n"; out << "~" << strClassName << "();\n\n"; genCreateOperation(storagehome, false); genCreateOperation(storagehome, true); // //generate find_(ref)_by_primary_key, which is appropriate to find_by_primary_key from home // if( composition_->lifecycle()==CIDL::lc_Entity ) { IR__::HomeDef_var home = composition_->ccm_home(); IR__::PrimaryKeyDef_var pkey = IR__::PrimaryKeyDef::_duplicate(home->primary_key()); if( !CORBA::is_nil(pkey) ) { out << map_psdl_return_type(storagetype, false) << " find_by_primary_key(" << mapFullNamePK(pkey) << "* pkey)\n"; out.indent(); out << "throw(CosPersistentState::NotFound);\n"; out.unindent(); } } for(CORBA::ULong i=0; i<supported_infs->length(); i++) { IR__::AbstractStorageHomeDef_var abs_storagehome_inh; abs_storagehome_inh = IR__::AbstractStorageHomeDef::_narrow((*supported_infs)[i]); genAbstractObjsForConcreteHome(abs_storagehome_inh); }; bAbstract_ = false; bASHKey_ = false; handleAttribute(storagehome); handleOperation(storagehome); handleFactory(storagehome); handleKey(storagehome); //generate _duplicate and _downcast operation //genDuplAndDown(strClassName); out.unindent(); out << "};\n\n\n"; out << "typedef HomeFactoryTemplate<" << storagehome->name() << "> " << storagehome->name() << "Factory;\n\n"; close_module(out, storagetype); }
// process events on the system event queue MAEvent Controller::processEvents(int ms, int untilType) { MAEvent event; MAExtent screenSize; int loadPathSize = _loadPath.length(); if (ms < 0 && untilType != -1) { // flush the display before pausing for target event if (isRunning()) { _output->flush(true); } maWait(ms); ms = EVENT_WAIT_NONE; } while (!isBreak() && maGetEvent(&event)) { switch (event.type) { case EVENT_TYPE_OPTIONS_BOX_BUTTON_CLICKED: if (_systemMenu) { handleMenu(event.optionsBoxButtonIndex); ms = EVENT_WAIT_NONE; } else if (isRunning()) { if (!_output->optionSelected(event.optionsBoxButtonIndex)) { dev_pushkey(event.optionsBoxButtonIndex); } } break; case EVENT_TYPE_SCREEN_CHANGED: screenSize = maGetScrSize(); _output->resize(EXTENT_X(screenSize), EXTENT_Y(screenSize)); os_graf_mx = _output->getWidth(); os_graf_my = _output->getHeight(); handleKey(SB_PKEY_SIZE_CHG); break; case EVENT_TYPE_POINTER_PRESSED: _touchX = _touchCurX = event.point.x; _touchY = _touchCurY = event.point.y; handleKey(SB_KEY_MK_PUSH); _output->pointerTouchEvent(event); break; case EVENT_TYPE_POINTER_DRAGGED: _touchCurX = event.point.x; _touchCurY = event.point.y; _output->pointerMoveEvent(event); break; case EVENT_TYPE_POINTER_RELEASED: _touchX = _touchY = _touchCurX = _touchCurY = -1; handleKey(SB_KEY_MK_RELEASE); _output->pointerReleaseEvent(event); break; case EVENT_TYPE_CLOSE: setExit(true); break; case EVENT_TYPE_KEY_PRESSED: handleKey(event.key); break; } if (untilType == EVENT_TYPE_EXIT_ANY || untilType == event.type || loadPathSize != _loadPath.length()) { // skip next maWait() - found target event or loadPath changed ms = EVENT_WAIT_NONE; break; } } if (ms != EVENT_WAIT_NONE) { maWait(ms); } return event; }
void Game::keyPressed(int key){ handleKey(key, true); }
bool GPG_Application::processEvent(GHOST_IEvent* event) { bool handled = true; switch (event->getType()) { case GHOST_kEventUnknown: break; case GHOST_kEventButtonDown: handled = handleButton(event, true); break; case GHOST_kEventButtonUp: handled = handleButton(event, false); break; case GHOST_kEventWheel: handled = handleWheel(event); break; case GHOST_kEventCursorMove: handled = handleCursorMove(event); break; case GHOST_kEventKeyDown: handleKey(event, true); break; case GHOST_kEventKeyUp: handleKey(event, false); break; case GHOST_kEventWindowClose: case GHOST_kEventQuit: m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; break; case GHOST_kEventWindowActivate: handled = false; break; case GHOST_kEventWindowDeactivate: handled = false; break; case GHOST_kEventWindowUpdate: { GHOST_IWindow* window = event->getWindow(); if (!m_system->validWindow(window)) break; // Update the state of the game engine if (m_kxsystem && !m_exitRequested) { // Proceed to next frame window->activateDrawingContext(); // first check if we want to exit m_exitRequested = m_ketsjiengine->GetExitCode(); // kick the engine bool renderFrame = m_ketsjiengine->NextFrame(); if (renderFrame) { // render the frame m_ketsjiengine->Render(); } } m_exitString = m_ketsjiengine->GetExitString(); } break; case GHOST_kEventWindowSize: { GHOST_IWindow* window = event->getWindow(); if (!m_system->validWindow(window)) break; if (m_canvas) { GHOST_Rect bnds; window->getClientBounds(bnds); m_canvas->Resize(bnds.getWidth(), bnds.getHeight()); } } break; default: handled = false; break; } return handled; }
int main(int argc, char **argv) { int window_width = 640; int window_height = 480; //Create the render window sfRenderWindow *window = NULL; if(!(window = sfRenderWindow_create((sfVideoMode) {window_width, window_height, 32}, "Mettle", sfClose|sfResize, NULL))) { printf("Unable to create RenderWindow\n"); exit(EXIT_FAILURE); } //Create a queue of inputs actionQueue *actions = actionQueue_create(); playerAction action = actionQueue_next(actions); //Load the hero sprite sfTexture *hero_texture = NULL; static const char *hero_texture_location = "data/img/leatherarmor.png"; if(!(hero_texture = sfTexture_createFromFile(hero_texture_location, NULL))) { printf("Unable to load %s\n", hero_texture_location); exit(EXIT_FAILURE); } entity *hero = entity_createPlayer((sfVector2i) {0, 0}, &action, hero_texture); //Create the "map" sfTexture *map_texture = NULL; static const char *map_texture_location = "data/img/tilesheet.png"; if(!(map_texture = sfTexture_createFromFile(map_texture_location, NULL))) { printf("Unable to load %s\n", map_texture_location); exit(EXIT_FAILURE); } int map_width = (int) ceilf((float) (window_width / TILE_SIZE)); int map_height = (int) ceilf((float) (window_height / TILE_SIZE)); //Allocate space sfSprite *tile = NULL; if(!(tile = sfSprite_create())) { printf("Unable to create sprite\n"); exit(EXIT_FAILURE); } //Initialize the tile sfSprite_setTexture(tile, map_texture, sfFalse); sfSprite_setTextureRect(tile, XY_TO_RECT(4, 2, TILE_SIZE, TILE_SIZE)); //Event holder sfEvent event; //Window active variable sfBool window_active = sfFalse; //Main loop while(sfRenderWindow_isOpen(window)) { //Process events while(sfRenderWindow_pollEvent(window, &event)) { switch(event.type) { //Handle keyboard input case(sfEvtKeyPressed): case(sfEvtKeyReleased): { playerAction action = handleKey(&event.key); if(action) { actionQueue_add(actions, action); } break; } case(sfEvtClosed): sfRenderWindow_close(window); break; case(sfEvtGainedFocus): window_active = sfTrue; break; case(sfEvtLostFocus): window_active = sfFalse; default: break; } } //While there are still actions to do while(action = actionQueue_next(actions)) { hero->ai->think(hero->ai); } //Clear the screen and render sfRenderWindow_clear(window, sfMagenta); //Draw the map int x,y; for(x = 0; x < map_width; x++) { for(y = 0; y < map_height; y++) { sfSprite_setPosition(tile, (sfVector2f) {x * TILE_SIZE, y * TILE_SIZE}); sfRenderWindow_drawSprite(window, tile, NULL); } } //Draw the hero displayComp_draw(hero->display, window); sfRenderWindow_display(window); #ifdef DEBUG sfVector2f pos = sfSprite_getPosition(hero->display->sprite); printf("\rPlayer at %d,%d (%f.0px, %f.0px)", hero->x, hero->y, pos.x, pos.y); fflush(stdout); #endif } //Cleanup sfRenderWindow_destroy(window); return EXIT_SUCCESS; }
void MapSizeCalculator::handleInt64(const CharSequence& key, int64_t /*value*/) { handleKey(key); size += 1/*typecode*/ + 8/*value*/; }
void Keyboard::listen() { while (process_->isActive() && isConnected()) { struct KeyData keyData = pollDevice(1); handleKey(&keyData); } }
bool CPetConversations::KeyCharMsg(CKeyCharMsg *msg) { Common::KeyState keyState; keyState.ascii = msg->_key; return handleKey(keyState); }
/*! return true if the event should be removed from the queue false otherwise */ static bool handleEvent(const SDL_Event &event) { switch (event.type) { case SDL_QUIT: Input::quitHandler(); return true; case SDL_KEYDOWN: case SDL_KEYUP: if (!handleDevKey(event.key,0)) if (!handleDevKey(event.key,1)) handleKey(event.key); return true; case SDL_MOUSEMOTION: // mouseMotion.emit(event.motion); return true; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: // mouseButton.emit(event.button); return true; case SDL_JOYAXISMOTION: handleJoyMotion(event.jaxis); return true; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: handleJoyButton(event.jbutton); return true; case SDL_VIDEORESIZE: #ifndef NEED_RESIZE_HACK handleResize(event.resize); return true; #else std::cerr << "got resize: "<<event.resize<<" and "; if (expectResize) { // we assume if we get the right size - this is the event we (unfortunately) produced if ((expected.w==event.resize.w)&&(expected.h==event.resize.h)) { std::cerr << "this was the expected resize event\n"; expectResize=false; return true; }else{ std::cerr << "this was NOT the expected resize event\n"; if (eventQueue->size()>2) { std::cerr << "since there are many events pending i stop waiting for this event - i assume it was lost\n"; expectResize=false; return true; } return false; } }else{ std::cerr << "we do not expect a resize event\n"; handleResize(event.resize); expectResize=true; expected=event.resize; return true; } #endif default: std::cerr << "Got unknown event => we drop it\n"; return true; } }
/* * LostFileCheck - check if there are any lost files out there */ bool LostFileCheck( void ) { char path[FILENAME_MAX]; vi_key key; char ch; int off; int handle = 0; MakeTmpPath( path, lockFileName ); off = strlen( path ) - 5; for( ch = START_CHAR; ch <= END_CHAR; ch++ ) { path[off] = ch; handle = sopen3( path, O_RDONLY | O_TEXT, SH_DENYRW ); if( handle > 0 ) { MakeTmpPath( path, checkFileName ); path[off] = ch; if( access( path, F_OK ) == -1 ) { MakeTmpPath( path, lockFileName ); path[off] = ch; close( handle ); handle = -1; remove( path ); } else { break; } } } if( handle > 0 ) { close( handle ); if( !EditFlags.RecoverLostFiles ) { if( !EditFlags.IgnoreLostFiles ) { #ifdef __WIN__ CloseStartupDialog(); key = GetAutosaveResponse(); handleKey( key ); ShowStartupDialog(); return( true ); #else SetPosToMessageLine(); MyPrintf( "Files have been lost since your last session, do you wish to:\n" ); MyPrintf( "\ti)gnore\n\tr)ecover\n\tq)uit\n" ); for( ;; ) { key = GetKeyboard(); if( handleKey( key ) ) { return( true ); } } #endif } else { remove( path ); return( false ); } } } else { if( EditFlags.RecoverLostFiles ) { EditFlags.RecoverLostFiles = false; EditFlags.NoInitialFileLoad = false; } } return( false ); } /* LostFileCheck */
int main(int argc, char* argv[]){ SNDFMT* smpls = gen_sin_buffer(); // smpls = snd_load("/media/c5bcf67f-e9eb-4e12-be75-d8b6e09e27ba/olivier/hti/ginf/cpu-emu/cpu-emu/sin.table"); /* // start SDL with audio support */ if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) exit (-1); atexit (SDL_Quit); screen = SDL_SetVideoMode (640, 480, 16, SDL_HWSURFACE); if (screen == NULL) exit (-1); // open SMPFREQ, signed 8bit, system byte order, // stereo audio, using 1024 byte chunks if(Mix_OpenAudio(SMPFREQ, AUDIO_S8, 1, WAVEFORM_LENGTH)==-1) { printf("Mix_OpenAudio: %s\n", Mix_GetError()); exit(2); } Mix_AllocateChannels(SID_VOICES_NR); Mix_Chunk *sound = NULL; sound = Mix_QuickLoad_RAW(smpls,WAVEFORM_LENGTH); if(sound == NULL) { fprintf(stderr, "Unable to load WAV file: %s\n", Mix_GetError()); } int channel; int channel2; channel = Mix_PlayChannel(-1, sound, -1); // channel2 = Mix_PlayChannel(-1, sound, -1); if(channel == -1) { fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError()); } init_SID(&sid); if(!Mix_RegisterEffect(channel, adsrEffect0, NULL, sid.voicea )) { printf("Mix_RegisterEffect: %s\n", Mix_GetError()); } /* if(!Mix_RegisterEffect(channel, adsrEffect0, NULL, sid.voiceb )) { printf("Mix_RegisterEffect: %s\n", Mix_GetError()); } if(!Mix_RegisterEffect(channel, adsrEffect0, NULL, sid.voicec )) { printf("Mix_RegisterEffect: %s\n", Mix_GetError()); } */ /* play time */ struct sid_6581_voice *voicea = sid.voicea; struct sid_6581_voice *voiceb = sid.voiceb; struct sid_6581_voice *voicec = sid.voicec; int i=0,j=0; for(i=0;i<3;i++){ voicea->frequency = 23436; voicea->control = voicea->control | SID_GATE ; SDL_Delay (50); voicea->frequency = 7382; voicea->attack=200; voicea->decay=20; voicea->sustain = 8; voicea->release=20; voicea->attack = 200; voicea->control = voicea->control & ~SID_GATE ; SDL_Delay (500); voicea->frequency = 14764; voicea->attack=200; voicea->decay=20; voicea->sustain = 6; voicea->release=1000; voicea->control = voicea->control | SID_GATE ; for(j=0;j<10;j++){ SDL_Delay (10); voicea->frequency = 14764+14764*j*1/100; } voicea->control = voicea->control & ~SID_GATE ; voicea->control = voicea->control | SID_GATE ; SDL_Delay (50); voicea->control = voicea->control & ~SID_GATE ; SDL_Delay (50); voicea->frequency = 10440; voicea->control = voicea->control | SID_GATE ; SDL_Delay (50); voicea->control = ((((voicea->control & ~SID_GATE) | SID_SAWT ) & ~SID_PULS ) & ~SID_TRIA ) & ~SID_NOIS ; SDL_Delay (50); voicea->frequency = 7382; voicea->control = voicea->control | SID_GATE ; SDL_Delay (50); voicea->control = voicea->control & ~SID_GATE ; SDL_Delay (50); } /* two voices */ voicea->frequency = 7382; voicea->attack=200; voicea->decay=200; voicea->sustain = 6; voicea->release=1000; voiceb->frequency = 9301; voiceb->attack=120; voiceb->decay=20; voiceb->sustain = 6; voiceb->release=1000; voicea->control = voicea->control | SID_GATE | SID_PULS ; voiceb->control = voiceb->control | SID_GATE | SID_SAWT ; SDL_Delay(400); voicea->control = voicea->control & ~SID_GATE ; voiceb->control = voiceb->control & ~SID_GATE ; SDL_Delay(300); sid.voicea->frequency = 7382; sid.voiceb->frequency = 8286; sid.voicea->control = voicea->control | SID_GATE ; sid.voiceb->control = voiceb->control | SID_GATE ; SDL_Delay(400); sid.voicea->control = voicea->control & ~SID_GATE ; sid.voiceb->control = voiceb->control & ~SID_GATE ; SDL_Delay(300); sid.voicea->frequency = 7382; sid.voiceb->frequency = 8779; sid.voicea->control = voicea->control | SID_GATE ; sid.voiceb->control = voiceb->control | SID_GATE ; SDL_Delay(400); sid.voicea->control = voicea->control & ~SID_GATE ; sid.voiceb->control = voiceb->control & ~SID_GATE ; SDL_Delay(300); sid.voicea->frequency = 7382; sid.voiceb->frequency = 9301; sid.voicea->control = voicea->control | SID_GATE ; sid.voiceb->control = voiceb->control | SID_GATE ; SDL_Delay(400); sid.voicea->control = voicea->control & ~SID_GATE ; sid.voiceb->control = voiceb->control & ~SID_GATE ; SDL_Delay(300); SDL_Event event; int done=0; interface_voice = sid.voicea; while(!done) { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym){ case SDLK_LEFT: (sid.filter->volume - 1) < 0 ? 0 : sid.filter->volume--; volume-=10; Mix_VolumeChunk(sound, volume); // Mix_VolumeChunk(sound, (volume>MIX_MAX_VOLUME-10) ? (volume = MIX_MAX_VOLUME):(volume-=10) ); printf("SDLK_LEFT volume: %i\n",volume); break; case SDLK_RIGHT: (sid.filter->volume + 1) >16 ? 15 : sid.filter->volume++; volume+=10; Mix_VolumeChunk(sound, volume ); // Mix_VolumeChunk(sound, (volume<10) ? (volume = 0): (volume+=10) ); printf("SDLK_RIGHT volume: %i\n",volume); break; case SDLK_UP: printf("up active\n"); break; case SDLK_DOWN: printf("down active\n"); break; default: handleKey(event.key); break; } break; case SDL_KEYUP: switch(event.key.keysym.sym){ case SDLK_LEFT: break; case SDLK_RIGHT: break; case SDLK_UP: interface_voice->frequency = interface_voice->frequency + interface_voice->frequency*1/100; printf("up in-active\n"); break; case SDLK_DOWN: interface_voice->frequency = interface_voice->frequency - interface_voice->frequency*1/100; printf("down in-active\n"); break; default: handleKey(event.key); break; } break; case SDL_QUIT: done = 1; printf("SDL_QUIT\n"); break; case SDL_MOUSEBUTTONUP: switch(event.button.button){ case SDL_BUTTON_WHEELUP: interface_voice->frequency = interface_voice->frequency + interface_voice->frequency*1/100; break; case SDL_BUTTON_WHEELDOWN: interface_voice->frequency = interface_voice->frequency - interface_voice->frequency*1/100; break; } break; default: /* do nothing */ break; } } // SDL_Flip(screen); SDL_Delay (50); } Mix_FreeChunk(sound); Mix_CloseAudio(); SDL_Quit(); return 0; }
int gSampleChannel::keyPress(int e) { return handleKey(e, ch->key); }
void Game::keyReleased(int key){ handleKey(key, false); }
bool GPG_Application::processEvent(GHOST_IEvent* event) { bool handled = true; switch (event->getType()) { case GHOST_kEventUnknown: break; case GHOST_kEventButtonDown: handled = handleButton(event, true); break; case GHOST_kEventButtonUp: handled = handleButton(event, false); break; case GHOST_kEventWheel: handled = handleWheel(event); break; case GHOST_kEventCursorMove: handled = handleCursorMove(event); break; case GHOST_kEventKeyDown: handleKey(event, true); break; case GHOST_kEventKeyUp: handleKey(event, false); break; case GHOST_kEventWindowClose: case GHOST_kEventQuit: m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; break; case GHOST_kEventWindowActivate: handled = false; break; case GHOST_kEventWindowDeactivate: handled = false; break; // The player now runs as often as it can (repsecting vsync and fixedtime). // This allows the player to break 100fps, but this code is being left here // as reference. (see EngineNextFrame) //case GHOST_kEventWindowUpdate: // { // GHOST_IWindow* window = event->getWindow(); // if (!m_system->validWindow(window)) break; // // Update the state of the game engine // if (m_kxsystem && !m_exitRequested) // { // // Proceed to next frame // window->activateDrawingContext(); // // first check if we want to exit // m_exitRequested = m_ketsjiengine->GetExitCode(); // // // kick the engine // bool renderFrame = m_ketsjiengine->NextFrame(); // if (renderFrame) // { // // render the frame // m_ketsjiengine->Render(); // } // } // m_exitString = m_ketsjiengine->GetExitString(); // } // break; // case GHOST_kEventWindowSize: { GHOST_IWindow* window = event->getWindow(); if (!m_system->validWindow(window)) break; if (m_canvas) { GHOST_Rect bnds; window->getClientBounds(bnds); m_canvas->Resize(bnds.getWidth(), bnds.getHeight()); m_ketsjiengine->Resize(); } } break; default: handled = false; break; } return handled; }
void JSONHandler::handle(const JSONEntity& value) { switch(value.type()) { case JSONEntity::JSON_T_ARRAY_BEGIN: handleArrayBegin(); setKey(false); incrementLevel(); break; case JSONEntity::JSON_T_ARRAY_END: poco_assert(!isKey()); if (level() > 0) decrementLevel(); handleArrayEnd(); break; case JSONEntity::JSON_T_OBJECT_BEGIN: handleObjectBegin(); setKey(false); incrementLevel(); break; case JSONEntity::JSON_T_OBJECT_END: poco_assert(!isKey()); if (level() > 0) decrementLevel(); handleObjectEnd(); break; case JSONEntity::JSON_T_VALUE_SEPARATOR: handleValueSeparator(); setKey(false); break; case JSONEntity::JSON_T_INTEGER: handleInteger(value); setKey(false); break; case JSONEntity::JSON_T_FLOAT: handleFloat(value); setKey(false); break; case JSONEntity::JSON_T_NULL: handleNull(); setKey(false); break; case JSONEntity::JSON_T_TRUE: handleTrue(); setKey(false); break; case JSONEntity::JSON_T_FALSE: handleFalse(); setKey(false); break; case JSONEntity::JSON_T_KEY: setKey(true); handleKey(value); break; case JSONEntity::JSON_T_STRING: handleString(value); setKey(false); break; default: poco_assert (false); break; } }
Common::Error SkyEngine::go() { _keyPressed.reset(); uint16 result = 0; if (ConfMan.hasKey("save_slot")) { int saveSlot = ConfMan.getInt("save_slot"); if (saveSlot >= 0 && saveSlot <= 999) result = _skyControl->quickXRestore(ConfMan.getInt("save_slot")); } if (result != GAME_RESTORED) { bool introSkipped = false; if (_systemVars.gameVersion > 272) { // don't do intro for floppydemos Intro *skyIntro = new Intro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system); bool floppyIntro = ConfMan.getBool("alt_intro"); introSkipped = !skyIntro->doIntro(floppyIntro); delete skyIntro; } if (!shouldQuit()) { _skyLogic->initScreen0(); if (introSkipped) _skyControl->restartGame(); } } _lastSaveTime = _system->getMillis(); uint32 delayCount = _system->getMillis(); while (!shouldQuit()) { _debugger->onFrame(); if (shouldPerformAutoSave(_lastSaveTime)) { if (_skyControl->loadSaveAllowed()) { _lastSaveTime = _system->getMillis(); _skyControl->doAutoSave(); } else _lastSaveTime += 30 * 1000; // try again in 30 secs } _skySound->checkFxQueue(); _skyMouse->mouseEngine(); handleKey(); if (_systemVars.paused) { do { _system->updateScreen(); delay(50); handleKey(); } while (_systemVars.paused); delayCount = _system->getMillis(); } _skyLogic->engine(); _skyScreen->processSequence(); _skyScreen->recreate(); _skyScreen->spriteEngine(); if (_debugger->showGrid()) { uint8 *grid = _skyLogic->_skyGrid->giveGrid(Logic::_scriptVariables[SCREEN]); if (grid) { _skyScreen->showGrid(grid); _skyScreen->forceRefresh(); } } _skyScreen->flip(); if (_fastMode & 2) delay(0); else if (_fastMode & 1) delay(10); else { delayCount += _systemVars.gameSpeed; int needDelay = delayCount - (int)_system->getMillis(); if ((needDelay < 0) || (needDelay > _systemVars.gameSpeed)) { needDelay = 0; delayCount = _system->getMillis(); } delay(needDelay); } } _skyControl->showGameQuitMsg(); _skyMusic->stopMusic(); ConfMan.flushToDisk(); delay(1500); return Common::kNoError; }
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) { printf("3DS Controller Server %.1f\n", VERSION); DWORD screenWidth = GetSystemMetrics(SM_CXSCREEN); DWORD screenHeight = GetSystemMetrics(SM_CYSCREEN); double widthMultiplier = screenWidth / 320.0; double heightMultiplier = screenHeight / 240.0; //screenshot(SCREENSHOT_NAMEL, TRUE, 0, 0, 18); bool vJoy = true; UINT iInterface = 1; iReport.wAxisZ = JOY_MIDDLE; iReport.wAxisXRot = JOY_MIDDLE; iReport.wAxisYRot = JOY_MIDDLE; iReport.wAxisZRot = JOY_MIDDLE; iReport.wSlider = JOY_MIDDLE; iReport.lButtons = 0; iReport.bHats = -1; if(vJoy && !vJoyEnabled()) { printf("vJoy failed (1)! Buttons will still work, but joy stick won't work.\n"); vJoy = false; } enum VjdStat status = GetVJDStatus(iInterface); if(vJoy && (status == VJD_STAT_OWN || (status == VJD_STAT_FREE && !AcquireVJD(iInterface)))) { printf("vJoy failed (2)! Buttons will still work, but joy stick won't work.\n"); vJoy = false; } ContPovNumber = GetVJDContPovNumber(iInterface); //int DiscPovNumber = GetVJDDiscPovNumber(iInterface); if(vJoy && !updateJoystick()) { printf("vJoy failed (3)! Buttons will still work, but joystick won't work.\n"); vJoy = false; } if(!readSettings()) { printf("Couldn't read settings file, using default key bindings.\n"); } initNetwork(); printf("Port: %d\n", settings.port); printf("Running on: %s\n", hostName); printf("Your local IP(s):\n"); printIPs(); printf("\n"); startListening(); while(1) { memset(&buffer, 0, sizeof(struct packet)); while(receiveBuffer(sizeof(struct packet)) <= 0) { // Waiting Sleep(settings.throttle); } keyboardActive = buffer.keyboardActive; switch(buffer.command) { case CONNECT: lastKeys = 0; currentKeys = 0; circlePad.x = 0; circlePad.y = 0; lastTouch.x = 0; lastTouch.y = 0; currentTouch.x = 0; currentTouch.y = 0; buffer.command = CONNECT; printf("3DS Connected!\n"); Sleep(50); sendBuffer(1); Sleep(50); sendBuffer(1); Sleep(50); sendBuffer(1); break; case KEYS: lastKeys = currentKeys; if(currentKeys & KEY_TOUCH) lastTouch = currentTouch; memcpy(¤tKeys, &buffer.keys, 4); memcpy(&circlePad, &buffer.circlePad, 4); memcpy(¤tTouch, &buffer.touch, 4); handleKey(KEY_A, settings.A); handleKey(KEY_B, settings.B); handleKey(KEY_SELECT, settings.Select); handleKey(KEY_START, settings.Start); handleKey(KEY_DRIGHT, settings.Right); handleKey(KEY_DLEFT, settings.Left); handleKey(KEY_DUP, settings.Up); handleKey(KEY_DDOWN, settings.Down); handleKey(KEY_R, settings.R); handleKey(KEY_L, settings.L); handleKey(KEY_X, settings.X); handleKey(KEY_Y, settings.Y); //handleKey(KEY_LID, 'I'); if(newpress(KEY_TOUCH)) { lastTouch.x = currentTouch.x; lastTouch.y = currentTouch.y; } if((currentKeys & KEY_TOUCH)) { if(keyboardActive) { if(newpress(KEY_TOUCH)) { char letter = currentKeyboardKey(); if(letter) { simulateKeyNewpress(letter); simulateKeyRelease(letter); } } } else if(settings.touch == mouse) { if(settings.mouseSpeed) { POINT p; GetCursorPos(&p); SetCursorPos(p.x + (currentTouch.x - lastTouch.x) * settings.mouseSpeed, p.y + (currentTouch.y - lastTouch.y) * settings.mouseSpeed); } else { SetCursorPos((int)((double)currentTouch.x * widthMultiplier), (int)((double)currentTouch.y * heightMultiplier)); } } else if(settings.touch == joystick) { joyX = (currentTouch.x) * 128; joyY = (currentTouch.y) * 128; } else { handleKey(KEY_TOUCH, settings.Tap); } } if(settings.circlePad == mouse) { if(abs(circlePad.x) < settings.mouseSpeed * 3) circlePad.x = 0; if(abs(circlePad.y) < settings.mouseSpeed * 3) circlePad.y = 0; POINT p; GetCursorPos(&p); SetCursorPos(p.x + (circlePad.x * settings.mouseSpeed) / 32, p.y - (circlePad.y * settings.mouseSpeed) / 32); } else if(settings.circlePad == joystick) { joyX = (circlePad.x + 128) * 128; joyY = (128 - circlePad.y) * 128; } break; } if(vJoy) updateJoystick(); //sendScreenshot(); } error("accept()"); return 0; }
bool CPetConversations::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return handleKey(msg->_keyState); }
int main(int argc, char* argv[]){ foutp=fopen("data.out", "w"); close(foutp); //smpls = gen_triangle_buffer(); // smpls = gen_sawtooth_buffer(); smpls = snd_load("/media/c5bcf67f-e9eb-4e12-be75-d8b6e09e27ba/olivier/hti/ginf/cpu-emu/cpu-emu/sin.table"); /* //sound_buffer = malloc(sizeof(SNDFMT)*512); */ /* // mem[0] = malloc(sizeof(SNDFMT)*mem0size); */ /* // mem[1] = malloc(sizeof(SNDFMT)*mem1size); */ /* // init without mixer init_sdl (); */ /* // start SDL with audio support */ if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) exit (-1); atexit (SDL_Quit); screen = SDL_SetVideoMode (640, 480, 16, SDL_HWSURFACE); if (screen == NULL) exit (-1); // open SMPFREQ, signed 8bit, system byte order, // stereo audio, using 1024 byte chunks if(Mix_OpenAudio(SMPFREQ, AUDIO_S8, 1, WAVEFORM_LENGTH)==-1) { printf("Mix_OpenAudio: %s\n", Mix_GetError()); exit(2); } Mix_Chunk *sound = NULL; sound = Mix_QuickLoad_RAW(smpls,WAVEFORM_LENGTH); if(sound == NULL) { fprintf(stderr, "Unable to load WAV file: %s\n", Mix_GetError()); } int channel; channel = Mix_PlayChannel(-1, sound, -1); if(channel == -1) { fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError()); } //while(Mix_Playing(channel) != 0); int len = WAVEFORM_LENGTH; smpls = gen_sin_buffer(); save("sin.out",smpls,len); smpls = gen_triangle_buffer(); save("triangle.out",smpls,len); smpls = gen_sawtooth_buffer(); save("sawtooth.out",smpls,len); smpls = gen_square_buffer(); save("square.out",smpls,len); smpls = gen_pwm_buffer(0.2); save("pwm.out",smpls,len); // violine int attack = 500; int decay = 300; int sustain = 10; int sustainlength0 = (attack / 1000.0) * SMPFREQ; int sustain_max = 15; // 4 Bit 0-15 float sustain0 = (float) sustain * ((float)1.0)/(float)sustain_max; float sustain_level = sustain0; int release = 750; int release0 = (release / 1000.0) * SMPFREQ; int attack0 = (attack / 1000.0) * SMPFREQ; int decay0 = (decay / 1000.0) * SMPFREQ; int t1 = attack0; int t2 = t1 + decay0; int t3 = t2 + sustainlength0; int t4 = t3 + release0; instrument[0].a_attack = ((float)1.0/(float)attack0); instrument[0].a_decay = ((float) ( 1.0 - sustain0)) / (float) ( t1-t2) ; instrument[0].b_decay = (float)1.0 - ((float)instrument[0].a_decay*(float)attack0); instrument[0].a_release = sustain_level / (float) (t3-t4) ; instrument[0].b_release = sustain_level - (float)instrument[0].a_release * (float)t3; instrument[0].adsr_counter = 0; instrument[0].gate=0; adsr_length = gen_adsr_buffer(&adsr_buffer); saveadsr("data.out",adsr_buffer,adsr_length); savebuffer = malloc(sizeof(float)*adsr_length); // register adsrEffect as a mix processor if(!Mix_RegisterEffect(channel, adsrEffect, NULL, &(instrument[0]) )) { printf("Mix_RegisterEffect: %s\n", Mix_GetError()); } /* Mix_VolumeChunk(sound, volume); */ /* printf("volume: %d\n", volume); */ /* Hz=440; */ /* // main_synthesiser(1, NULL); */ /* printf("start play\n"); */ /* // play (); */ /* // SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME); */ int i=0; SDL_Event event; int done=0; int hzinc=0,amplitudeinc; /* float* adsrptr; int len; saveadsr("data.out",adsrptr,len); if(smp_index < WAVEFORM_LENGTH){ for(i = 0; i < len; i++){ adsrptr[i] = adsrptr[i] * smpls[(int)smp_index]; // smp_index +=freq; smp_index++; if(smp_index >= WAVEFORM_LENGTH) smp_index = 0; } } Mix_CloseAudio(); SDL_Quit(); return 0; */ while(!done) { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym){ case SDLK_LEFT: volume-=10; Mix_VolumeChunk(sound, volume); // Mix_VolumeChunk(sound, (volume>MIX_MAX_VOLUME-10) ? (volume = MIX_MAX_VOLUME):(volume-=10) ); printf("SDLK_LEFT volume: %i\n",volume); amplitudeinc = -1; break; case SDLK_RIGHT: volume+=10; Mix_VolumeChunk(sound, volume ); // Mix_VolumeChunk(sound, (volume<10) ? (volume = 0): (volume+=10) ); printf("SDLK_RIGHT volume: %i\n",volume); amplitudeinc = +1;; break; case SDLK_UP: hzinc = 1; printf("up active\n"); break; case SDLK_DOWN: hzinc = -1; printf("down active\n"); break; default: handleKey(event.key); break; } break; case SDL_KEYUP: switch(event.key.keysym.sym){ case SDLK_LEFT: amplitudeinc = 0; break; case SDLK_RIGHT: amplitudeinc = 0; break; case SDLK_UP: tonstufe++; hzinc = 0; printf("up in-active\n"); break; case SDLK_DOWN: tonstufe--; hzinc = 0; printf("down in-active\n"); break; default: handleKey(event.key); break; } break; case SDL_QUIT: done = 1; printf("SDL_QUIT\n"); break; case SDL_MOUSEBUTTONUP: switch(event.button.button){ case SDL_BUTTON_WHEELUP: Hz += 1; break; case SDL_BUTTON_WHEELDOWN: Hz -= 1; break; } break; default: /* do nothing */ break; } } freq += hzinc; //Hz= 2*Hz; Hz = Hz + hzinc; amplitude = amplitude + amplitudeinc; // printf("Hz: %f\n",Hz); //% Hz = frequency(music[i++%10]); int y; // SDL_Flip(screen); SDL_Delay (50); } // save("sndout6.snd"); saveadsr("adsr.out",savebuffer,adsr_length); Mix_FreeChunk(sound); Mix_CloseAudio(); SDL_Quit(); return 0; }
bool ExtCamControl::start(JSON* pJson) { g_pExtCamControl = this; //Init Camera m_pCamFront = new _CamStream(); CHECK_FATAL(m_pCamFront->init(pJson, "FRONTL")); //Init Marker Detector m_pMD = new _MarkerDetector(); CHECK_FATAL(m_pMD->init(pJson, "RED_CIRCLE")); m_pMD->m_pCamStream = m_pCamFront; m_pCamFront->m_bHSV = true; //Init BgFg Detector m_pBgFgD = new _BgFgDetector(); CHECK_FATAL(m_pBgFgD->init(pJson, "")); m_pBgFgD->m_pCamStream = m_pCamFront; //Init Autopilot /* m_pAP = new _AutoPilot(); CHECK_FATAL(m_pAP->setup(&m_Json, "")); m_pAP->init(); m_pAP->setCamStream(m_pCamFront, CAM_FRONT); m_pAP->m_pOD = m_pOD; m_pAP->m_pFD = m_pFD; // m_pMD = m_pAP->m_pCamStream[CAM_FRONT].m_pCam->m_pMarkerDetect; */ //Connect to Mavlink /* m_pMavlink = new _MavlinkInterface(); CHECK_FATAL(m_pMavlink->setup(&m_Json, "FC")); CHECK_INFO(m_pMavlink->open()); */ //Main window m_pShow = new CamFrame(); m_pMat = new CamFrame(); m_pMat2 = new CamFrame(); //Init UI Monitor m_pUIMonitor = new UIMonitor(); m_pUIMonitor->init("OpenKAI demo", pJson); m_pUIMonitor->addFullFrame(m_pShow); //Start threads m_pCamFront->start(); // m_pMavlink->start(); // m_pDF->start(); m_pMD->start(); // m_pAP->start(); m_pBgFgD->start(); //UI thread m_bRun = true; namedWindow(APP_NAME, CV_WINDOW_NORMAL); setWindowProperty(APP_NAME, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); setMouseCallback(APP_NAME, onMouseExtCamControl, NULL); while (m_bRun) { // Mavlink_Messages mMsg; // mMsg = m_pMavlink->current_messages; // m_pCamFront->m_pCamL->m_bGimbal = true; // m_pCamFront->m_pCamL->setAttitude(mMsg.attitude.roll, 0, mMsg.time_stamps.attitude); if(!showScreenMarkerDetector()) { showScreenBgFgDetector(); } //Handle key input m_key = waitKey(30); handleKey(m_key); } // m_pAP->stop(); m_pMD->stop(); // m_pMavlink->stop(); m_pBgFgD->stop(); m_pMD->complete(); m_pBgFgD->complete(); // m_pDF->complete(); // m_pAP->complete(); // m_pCamFront->complete(); // m_pMavlink->complete(); // m_pMavlink->close(); // delete m_pAP; // delete m_pMavlink; // delete m_pDF; delete m_pCamFront; return 0; }
bool Compose::handle_qkey(const QKeyEvent *event) { int qstate = event->modifiers(); unsigned int xstate = 0; if (qstate & Qt::ShiftModifier) xstate |= ShiftMask; if (qstate & Qt::ControlModifier) xstate |= ControlMask; if (qstate & Qt::AltModifier) xstate |= Mod1Mask; // XXX if (qstate & Qt::MetaModifier) xstate |= Mod1Mask; // XXX int qkey = event->key(); unsigned int xkeysym; if (qkey >= 0x20 && qkey <= 0xff) { if (isascii(qkey) && isprint(qkey)) { QString str = event->text(); int ascii = str.length() ? str.unicode()->toLatin1() : 0; if (isalpha(ascii)) xkeysym = ascii; else if ((qstate & Qt::ControlModifier) && (ascii >= 0x01 && ascii <= 0x1a)) if (qstate & Qt::ShiftModifier) xkeysym = ascii + 0x40; else xkeysym = ascii + 0x60; else xkeysym = qkey; } else { xkeysym = qkey; } } else if (qkey >= Qt::Key_Dead_Grave && qkey <= Qt::Key_Dead_Horn) { xkeysym = qkey + 0xec00 - 0x01000000; } else { switch (qkey) { case Qt::Key_Escape: xkeysym = XK_Escape; break; case Qt::Key_Tab: xkeysym = XK_Tab; break; case Qt::Key_Backspace: xkeysym = XK_BackSpace; break; case Qt::Key_Return: xkeysym = XK_Return; break; case Qt::Key_Insert: xkeysym = XK_Insert; break; case Qt::Key_Delete: xkeysym = XK_Delete; break; case Qt::Key_Pause: xkeysym = XK_Pause; break; case Qt::Key_Print: xkeysym = XK_Print; break; case Qt::Key_SysReq: xkeysym = XK_Sys_Req; break; case Qt::Key_Clear: xkeysym = XK_Clear; break; case Qt::Key_Home: xkeysym = XK_Home; break; case Qt::Key_End: xkeysym = XK_End; break; case Qt::Key_Left: xkeysym = XK_Left; break; case Qt::Key_Up: xkeysym = XK_Up; break; case Qt::Key_Right: xkeysym = XK_Right; break; case Qt::Key_Down: xkeysym = XK_Down; break; case Qt::Key_PageUp: xkeysym = XK_Prior; break; case Qt::Key_PageDown: xkeysym = XK_Next; break; case Qt::Key_Shift: xkeysym = XK_Shift_L; break; case Qt::Key_Control: xkeysym = XK_Control_L; break; case Qt::Key_Meta: xkeysym = XK_Meta_L; break; case Qt::Key_Alt: xkeysym = XK_Alt_L; break; case Qt::Key_CapsLock: xkeysym = XK_Caps_Lock; break; case Qt::Key_NumLock: xkeysym = XK_Num_Lock; break; case Qt::Key_ScrollLock: xkeysym = XK_Scroll_Lock; break; case Qt::Key_F1: xkeysym = XK_F1; break; case Qt::Key_F2: xkeysym = XK_F2; break; case Qt::Key_F3: xkeysym = XK_F3; break; case Qt::Key_F4: xkeysym = XK_F4; break; case Qt::Key_F5: xkeysym = XK_F5; break; case Qt::Key_F6: xkeysym = XK_F6; break; case Qt::Key_F7: xkeysym = XK_F7; break; case Qt::Key_F8: xkeysym = XK_F8; break; case Qt::Key_F9: xkeysym = XK_F9; break; case Qt::Key_F10: xkeysym = XK_F10; break; case Qt::Key_F11: xkeysym = XK_F11; break; case Qt::Key_F12: xkeysym = XK_F12; break; case Qt::Key_F13: xkeysym = XK_F13; break; case Qt::Key_F14: xkeysym = XK_F14; break; case Qt::Key_F15: xkeysym = XK_F15; break; case Qt::Key_F16: xkeysym = XK_F16; break; case Qt::Key_F17: xkeysym = XK_F17; break; case Qt::Key_F18: xkeysym = XK_F18; break; case Qt::Key_F19: xkeysym = XK_F19; break; case Qt::Key_F20: xkeysym = XK_F20; break; case Qt::Key_F21: xkeysym = XK_F21; break; case Qt::Key_F22: xkeysym = XK_F22; break; case Qt::Key_F23: xkeysym = XK_F23; break; case Qt::Key_F24: xkeysym = XK_F24; break; case Qt::Key_F25: xkeysym = XK_F25; break; case Qt::Key_F26: xkeysym = XK_F26; break; case Qt::Key_F27: xkeysym = XK_F27; break; case Qt::Key_F28: xkeysym = XK_F28; break; case Qt::Key_F29: xkeysym = XK_F29; break; case Qt::Key_F30: xkeysym = XK_F30; break; case Qt::Key_F31: xkeysym = XK_F31; break; case Qt::Key_F32: xkeysym = XK_F32; break; case Qt::Key_F33: xkeysym = XK_F33; break; case Qt::Key_F34: xkeysym = XK_F34; break; case Qt::Key_F35: xkeysym = XK_F35; break; case Qt::Key_Super_L: xkeysym = XK_Super_L; break; case Qt::Key_Super_R: xkeysym = XK_Super_R; break; case Qt::Key_Menu: xkeysym = XK_Menu; break; case Qt::Key_Hyper_L: xkeysym = XK_Hyper_L; break; case Qt::Key_Hyper_R: xkeysym = XK_Hyper_R; break; case Qt::Key_Help: xkeysym = XK_Help; break; case Qt::Key_Multi_key: xkeysym = XK_Multi_key; break; case Qt::Key_Codeinput: xkeysym = XK_Codeinput; break; case Qt::Key_SingleCandidate: xkeysym = XK_SingleCandidate; break; case Qt::Key_PreviousCandidate: xkeysym = XK_PreviousCandidate; break; case Qt::Key_Mode_switch: xkeysym = XK_Mode_switch; break; case Qt::Key_Kanji: xkeysym = XK_Kanji; break; case Qt::Key_Muhenkan: xkeysym = XK_Muhenkan; break; case Qt::Key_Henkan: xkeysym = XK_Henkan_Mode; break; case Qt::Key_Romaji: xkeysym = XK_Romaji; break; case Qt::Key_Hiragana: xkeysym = XK_Hiragana; break; case Qt::Key_Katakana: xkeysym = XK_Katakana; break; case Qt::Key_Hiragana_Katakana: xkeysym = XK_Hiragana_Katakana; break; case Qt::Key_Zenkaku: xkeysym = XK_Zenkaku; break; case Qt::Key_Hankaku: xkeysym = XK_Hankaku; break; case Qt::Key_Zenkaku_Hankaku: xkeysym = XK_Zenkaku_Hankaku; break; case Qt::Key_Touroku: xkeysym = XK_Touroku; break; case Qt::Key_Massyo: xkeysym = XK_Massyo; break; case Qt::Key_Kana_Lock: xkeysym = XK_Kana_Lock; break; case Qt::Key_Kana_Shift: xkeysym = XK_Kana_Shift; break; case Qt::Key_Eisu_Shift: xkeysym = XK_Eisu_Shift; break; case Qt::Key_Eisu_toggle: xkeysym = XK_Eisu_toggle; break; case Qt::Key_Hangul: xkeysym = XK_Hangul; break; case Qt::Key_Hangul_Start: xkeysym = XK_Hangul_Start; break; case Qt::Key_Hangul_End: xkeysym = XK_Hangul_End; break; case Qt::Key_Hangul_Jamo: xkeysym = XK_Hangul_Jamo; break; case Qt::Key_Hangul_Romaja: xkeysym = XK_Hangul_Romaja; break; case Qt::Key_Hangul_Jeonja: xkeysym = XK_Hangul_Jeonja; break; case Qt::Key_Hangul_Banja: xkeysym = XK_Hangul_Banja; break; case Qt::Key_Hangul_PreHanja: xkeysym = XK_Hangul_PreHanja; break; case Qt::Key_Hangul_PostHanja: xkeysym = XK_Hangul_PostHanja; break; case Qt::Key_Hangul_Special: xkeysym = XK_Hangul_Special; break; default: xkeysym = qkey; break; } } int type = event->type(); bool press = (type == QEvent::KeyPress); return handleKey(xkeysym, xstate, press); }
void MapSizeCalculator::handleFloat(const CharSequence& key, float /*value*/) { handleKey(key); size += 1/*typecode*/ + 4/*value*/; }
int handleKey(TDA_Task* task, char** key, char** content) { int out = -1; if (strcmp(*key, "data") == 0) { match(content, "{"); openBrackets++; out = parse(content, key); while (out > -1) { out = handleKey(task, key, content); if (!out) { // out == 0, Stop condition return out; } else if (out < 0) { return out; } else { out = parse(content, key); } } } else if (strcmp(*key, "assignee") == 0) { NamedObject n; out = readNamedObject(content, key, &n); setTaskAssignee(task, &n); } else if (strcmp(*key, "id") == 0) { out = getInt(content, key); setTaskId(task, *key); } else if (strcmp(*key, "name") == 0) { out = getString(content, key); setTaskName(task, *key); } else if (strcmp(*key, "notes") == 0) { out = getString(content, key); setTaskNotes(task, *key); } else if (strcmp(*key, "created_at") == 0) { out = getDate(content, key); setTaskCreationDate(task, *key); } else if (strcmp(*key, "modified_at") == 0) { out = getDate(content, key); setTaskModificationDate(task, *key); } else if (strcmp(*key, "completed_at") == 0) { out = getDate(content, key); setTaskCompletionDate(task, *key); } else if (strcmp(*key, "due_on") == 0) { out = getDate(content, key); setTaskDueDate(task, *key); } else if (strcmp(*key, "completed") == 0) { out = getBool(content, key); if (out > -1) setTaskCompleted(task, (bool) out); out = 2; // Can't return out, because it's 0 on false and 0 is parsing complete } else if (strcmp(*key, "tags") == 0) { out = match(content, "["); while(out > -1 && out != ']') { NamedObject n; out = readNamedObject(content, key, &n); addTaskTag(task, &n); } out = match(content, ","); } else { out = skipField(content); if (out == 0) { return 0; } } return out; }