void setPriority(){ char *tempPtr = NULL; //Temporary Input Character Pointer for PCB Name char *tempPtr2 = NULL; //Temporary Input Character Pointer for New Priority PCBitem *tempPCB; //Temporary PCB Item int charCount = 0; //Number of Characters in Process Name int newPriority = 0; //New Priority value //Get PCB name printf("Please enter the name of the PCB to Set the Priority: "); tempPtr = keyboardInput(0); //Gets process name from User tempPtr = pointer2Str(tempPtr); //Convert Character Pointer to Character String charCount = sizeOfPointer(tempPtr); //Get Name Size if((charCount >= 8)){ //Check that the Name is Valid (Check to see if at least 8 chars. + Null Terminator) tempPCB = find_PCB(tempPtr); if(tempPCB != NULL){ //Check that the PCB Exists //Get New Priority from User printf("Please enter a number between -128 & +127 to set the new Priority: "); tempPtr = keyboardInput(0); //Gets process name from User newPriority = pointer2Int(tempPtr); //Convert Character Pointer to Int if((new_pPriority >= -128) || (new_pPriority <= 127)){ //Check that the new priority is valid (-128 to 127) tempPCB->pPriority = new_pPriority; //Set new PCB Priority //If the PCB is in the ready state, you will need to change the position of the PCB in the queue based upon its new priority if(tempPCB->state == READY){ error = remove_PCB(tempPCB->state, tempPCB); //Remove PCB from Ready Queue error = errorCheck(error); //Perform Error Check error = insert_PCB(tempPCB->state, tempPCB); //Insert PCB into Ready Queue (so as to adjust for new Priority) error = errorCheck(error); //Perform Error Check }//end if }//end if //Display appropriate error or success message. if(error == 0){ printf("The PCB Process has been successfully blocked.\n"); }//end if } else{ printf("Process Name does not exist.\n"); }//end if } else{ printf("Process Name is Invalid. Process Name must be at least 8 characters in length.\n"); }//end if }//end setPriority
void WindowInputSource::handleRawInput(WPARAM wParam, LPARAM lParam) { // Only process input when the application is on the foreground. if (wParam != RIM_INPUT) return; RAWINPUT input; UINT szData = sizeof(input), szHeader = sizeof(RAWINPUTHEADER); HRAWINPUT handle = reinterpret_cast<HRAWINPUT>(lParam); UINT bytesWritten = GetRawInputData(handle, RID_INPUT, &input, &szData, szHeader); ASSERT(bytesWritten <= szData, "Unexpected return value from GetRawInputData."); ASSERT(bytesWritten != UINT(-1), "GetRawInputData returned error."); switch (input.header.dwType) { case RIM_TYPEMOUSE: mouseInput(input.data.mouse); break; case RIM_TYPEKEYBOARD: keyboardInput(input.data.keyboard); break; } }
/* Name: XIO::update Purpose: Used in an event loop to update internal IO states. Input: Nothing Output: Nothing */ void XIO::update() { keyboardInput(); if (g_bKeyExc & 8) { updateCoinCounter(); } updateInputState(); updateHandleState(); updatePedalState(); }
void Player::update(sf::Time timeElasped){ keyboardInput(timeElasped); genAnimFrame(timeElasped); CheckCollision(timeElasped); m_Position.x += m_Velocity.x * timeElasped.asSeconds(); m_Position.y += m_Velocity.y * timeElasped.asSeconds(); m_Sprite->setPosition(m_Position); }
/** Procedure: handler_display_mpx Purpose: Displays Directory of Available MPX Process Files Parameters: None Return value: None Calls: sizeOfPointer, sys_open_dir, sys_close_dir, sys_get_entry Globals: error Errors: Invalid Directory, Directory Not Open, No More Directory Entries, Read Failed, Name To Long For Buffer, No Directory Is Open. **/ void handler_display_mpx(){ char *Buffer= NULL; char BufferArray[80] = {0}; char currentFile[40]; long j = 0; int error, i = 0; int nameSize = 40; printf("\nWelcome to mpx"); printf("\nPlease enter the directory to be opened it cannot contain spaces\n"); Buffer = keyboardInput(0); while(i<sizeOfPointer(Buffer)){ //printf("%c",Buffer[i]); BufferArray[i] = Buffer[i]; i++; } if(sizeOfPointer(Buffer)==0){ //printf("success"); getcwd(BufferArray,80); } error = sys_open_dir(BufferArray); errorCheck(error); //printf("%s",BufferArray); if(error ==0){ i = 0; printConstant =0; while(error == 0){ error = sys_get_entry(currentFile,nameSize,&j); if(error == 0){ i++; printf("\nFilename:%s \tBuffersize:%d\tFile Size:%ld",currentFile,nameSize,j); printInterrupt(); } //printf("\n%d",error); } if(error != -113){ errorCheck(error); } else{ error = sys_close_dir(); errorCheck(error); //printf("\n%d",error); if(i == 0){ if(Buffer[0] == 10){ printf("The current directory contains no mpx files\n"); } else{ printf("No mpx files are in that directory\n"); } } } } printf("\n"); }
/** * * Function to put the iRobot into manual control in putty * will be used to control the iRobot through the course */ void courseMode() { // stay in this loop until course is finished while(isFinished != 0) { // move the iRobot with the putty/keyboard, wasd controls keyboardInput(serial_getc()); // separate each command serial_puts("------------------------------------------------------"); } }
void GameOver::update() { timer++; mouse = currentMouse.getPosition(); if (fadeIn) { screenFadeIn(); } if (fadeOut) { screenFadeOut(); } for (int i = 0; i < numButtons; i++) { if ((mouse.x >= m_buttonPositions[i].x && mouse.x <= m_buttonPositions[i].x + m_buttonWidth) && (mouse.y >= m_buttonPositions[i].y && mouse.y <= m_buttonPositions[i].y + m_buttonHeight)) { if (currentMouse.isButtonPressed(sf::Mouse::Left) && !previousMouse) { m_buttons[i].setScale(2.5f, 2.5f); if (i == 0) { quitPressed = true; } previousMouse = true; } else { previousMouse = false; } currentHighlighted = i; } else { m_buttons[i].setScale(2.0f, 2.0f); } } keyboardInput(); if (quitPressed) { screenFadeOut(); } m_buttons[currentHighlighted].setScale(2.5f, 2.5f); }
void resume(){ char *tempPtr = NULL; //Temporary Input Character Pointer PCBitem *tempPCB; //Temporary PCB Item int charCount = 0; // Get PCB name from the user printf("Please enter the name of the PCB to resume: "); tempPtr = keyboardInput(0); //Gets process name from User tempPtr = pointer2Str(tempPtr); //Convert Character Pointer to Character String charCount = sizeOfPointer(tempPtr); //Get Name Size if((charCount >= 8)){ //Check that Name is Valid (Check to see if at least 8 chars. + Null Terminator) tempPCB = find_PCB(tempPtr); if(tempPCB != NULL){ //Check if Name Exists if(tempPCB->state == RUNNING){ printf("Error: There is no need to resume an already running process.\n"); } else if(tempPCB->state == READY){ printf("Error: This process is READY but not suspended.\n"); } else if(tempPCB->state == BLOCKED){ printf("Error: This process is Blocked but not suspended.\n"); } else{ // Should remove the process from the SUSREADY or SUSBLOCKED queue (by calling remove_PCB) error = remove_PCB(tempPCB->state, tempPCB); error = errorCheck(error); // Puts the PCB in the unsuspended state if(tempPCB->state == SUSREADY){ tempPCB->state = READY; } else if(tempPCB->state == SUSBLOCKED){ tempPCB->state = BLOCKED; }//end if // Might require changing queues (from ready to suspended ready, for example) if 4 queues are used error = insert_PCB(tempPCB->state, tempPCB); error = errorCheck(error); // Display appropriate error or success message if(error == 0){ printf("The PCB Process has been successfully resumed.\n"); }//end if }//end if }else{ printf("Process Name does not exist.\n"); }//end if }else{ printf("Process Name is Invalid. Process Name must be at least 8 characters in length.\n"); }//end if }//end resume
/** Procedure: change_prompt Purpose: Allows User to Change the Prompt Character Parameters: None Return value: None Calls: keyboardInput, sizeOfPointer Globals: prompt Errors: Invalid New Prompt **/ void change_prompt(){ char *newPrompt; int i= 0, newPromptSize; printf("\nEnter New Prompt String(Max 4 characters)\n"); newPrompt = keyboardInput(0); newPromptSize = sizeOfPointer(newPrompt); while(i<4){ //printf("\nWord:%c Buff:%c",prompt[i],newPrompt[i]); if(i<newPromptSize){ prompt[i] = newPrompt[i]; } else { prompt[i] = 0; } //printf("\nWord:%c Buff:%c",prompt[i],newPrompt[i]); i++; } }
/** Procedure: handler_terminate_mpx Purpose: Terminate MPX & Return to Host OS Parameters: None Return value: None Calls: keyboardInput, cmpP2S Globals: comDone Errors: None **/ void handler_terminate_mpx(){ int flag = 0; char *userAns; //n is No, y is Yes while(flag ==0){ printf("\nAre you sure you would like to exit the system (y or n):\n"); userAns = keyboardInput(0); //Chang this to sys_req------------------------------------------------- if(cmpP2S(userAns,"y")==1){ comDone = 1; flag = 1; } else if(cmpP2S(userAns,"n") !=1){ printf("Invalid input. Input is case sensitive.\n"); } else{ flag = 1; }//end if } }//end handler_terminate_mpx
int main( void ) { //debug:: lets find the path #ifdef CRAP_COMPILER_MSVC crap::string256 data_path("../../../data/"); #else crap::string256 data_path("../data/"); #endif //logger crap::logger< crap::log_time_time, crap::log_channel_core, crap::log_type_debug, crap::log_target_cout, 512 > unit_logger; //system crap::System system; //lets config crap::string256 ini_path = data_path + "configuration.ini"; crap::Configuration config( 1024*10, 100 ); config.load( ini_path.c_str() ); //set config as subsystem crap::SubSystem config_sys( "Configuration", &config, &system ); //taskmanager const uint32_t tasksMaxNumber = config.getValue<uint32_t>("TASKS_MAX_NUM"); const uint32_t tasksDeattachedMaxNumber = config.getValue<uint32_t>("TASKS_DEATTACHED_MAX_NUM"); crap::TaskManager taskManager( tasksMaxNumber, tasksDeattachedMaxNumber ); //set TaskManager as Subsystem crap::SubSystem tasks_sys( "TaskManager", &taskManager, &system ); //eventsystem const uint32_t eventMaxNumber = config.getValue<uint32_t>("EVENTS_MAX_NUM"); crap::EventSystem eventSystem( eventMaxNumber ); //set EventSystem as SubSystem crap::SubSystem events_sys( "EventSystem", &eventSystem, &system ); //resourcemanager const uint32_t resoureMemory = config.getValue<uint32_t>("RESOURCE_MEMORY"); const uint32_t resoureNumber = config.getValue<uint32_t>("RESOURCE_NUMBER"); const crap::string64 resourceFile = config.getValue<crap::string64>("RESOURCE_FILE"); const bool resourceXML = config.getValue<uint32_t>("RESOURCE_XML") == 1; crap::ResourceManager resourceManager( resoureMemory, resoureNumber, data_path, &system ); if( resourceXML ) resourceManager.loadXML( resourceFile ); else resourceManager.loadPackage( resourceFile ); // set resourcemanager as subsystem crap::SubSystem resource_sys( "ResourceManager", &resourceManager, &system ); //AudioSystem const uint32_t audioBufferNumber = config.getValue<uint32_t>("AUDIO_BUFFER_NUM"); const uint32_t audioSourceNumber = config.getValue<uint32_t>("AUDIO_SOURCE_NUM"); crap::AudioSystem AudioSystem(audioBufferNumber, audioSourceNumber); //set AudioSystem as subsystem crap::SubSystem audio_sys( "AudioSystem", &AudioSystem, &system ); //componentsystem const uint32_t componentMemory = config.getValue<uint32_t>("COMPONENT_MEMORY"); const uint32_t componentMaxNodes = config.getValue<uint32_t>("COMPONENT_MAX_NODES"); crap::ComponentSystem componentSystem( componentMemory, componentMaxNodes , &system ); //set componentsystem as subsystem crap::SubSystem component_sys( "ComponentSystem", &componentSystem, &system ); //renderwindow const crap::string64 windowName = config.getValue<crap::string64>("RENDER_WINDOW_NAME"); const uint32_t windowWidth = config.getValue<uint32_t>("RENDER_WINDOW_WIDTH"); const uint32_t windowHeight = config.getValue<uint32_t>("RENDER_WINDOW_HEIGHT"); const bool windowFullscreen = config.getValue<uint32_t>("RENDER_WINDOW_FULLSCREEN") == 1; const uint32_t windowMaxCallbacks = config.getValue<uint32_t>("RENDER_WINDOW_MAX_CALLBACKS"); crap::RenderWindow renderWindow( windowMaxCallbacks ); renderWindow.create( windowName.c_str(), windowWidth, windowHeight, windowFullscreen ); //renderer crap::RenderSystem renderer( &renderWindow ); renderer.init(); //set renderer as subsystem crap::SubSystem renderer_sys("Renderer", &renderer, &system ); //inputmanager const uint32_t inputMemory = config.getValue<uint32_t>("INPUT_MEMORY"); crap::InputManager inputManager( inputMemory, renderWindow.getHandle() ); //add keyboard crap::KeyboardInput keyboardInput("Keyboard", 20, &inputManager ); keyboardInput.addListener<&exitFunc>( thekey, 0, true ); //add mouse crap::MouseInput mouseInput("Mouse", 20, 20, 20, 20, &inputManager ); mouseInput.addButtonListener<&clickFunc>( 0, 0, true ); mouseInput.addPositionListener<&posFunc>( true ); mouseInput.addScrollListener<&scrollFunc>( true ); mouseInput.addEnterListener<&enterFunc>( true ); //controller crap::ControllerInput controllerInput("Controller", 8, &inputManager ); uint32_t joyID = controllerInput.leaseJoystickID(); controllerInput.addAxisListener<&joyAxis>( joyID ); controllerInput.addButtonListener<&joyButton>( joyID ); /* Add directory update to taskmanager */ taskManager.addTask<crap::InputManager, &crap::InputManager::update>("InputPolling", &inputManager, 50, true, false ); /* Physic system 2D */ crap::PhysicSystem2D physicSystem2D( 1000, 0.f, 10.f, 8, 2, 1.f/200.f ); crap::SubSystem physic_sys2d( "PhysicSystem2D", &physicSystem2D, &system ); taskManager.addTask< crap::PhysicSystem2D, &crap::PhysicSystem2D::update>( "Physic2DUpdate", &physicSystem2D, 20, true, false ); //pluginmanager const uint32_t pluginNumber = config.getValue<uint32_t>("PLUGIN_NUMBER"); const uint32_t pluginMemory = config.getValue<uint32_t>("PLUGIN_MEMORY"); crap::PluginManager pluginManager(pluginNumber, pluginMemory, &system ); //set pluginmanager as subsystem crap::SubSystem plugin_sys( "PluginManager", &pluginManager, &system ); //set Directory listener const uint32_t pluginFunctionNumber = config.getValue<uint32_t>("PLUGIN_FUNCTION_NUM"); const uint32_t pluginFileNumber = config.getValue<uint32_t>("PLUGIN_FILES_NUM"); const crap::string256 pluginDir = data_path + config.getValue<crap::string64>("PLUGIN_SUBDIRECTORY"); crap::DirectoryListener pluginDirectoryListener( pluginFunctionNumber, pluginFileNumber, pluginDir, false ); pluginDirectoryListener.addCallback<crap::PluginManager, &crap::PluginManager::callbackFunction>( &pluginManager ); /* Add directory update to taskmanager */ taskManager.addTask<crap::DirectoryListener, &crap::DirectoryListener::update>("PluginPath", &pluginDirectoryListener, 1000, true, false ); //init this.. (do that at last) pluginDirectoryListener.init(); crap::Configuration* testconf = system.getSubSystem<crap::Configuration>( "Configuration" ); if( testconf != 0 ) { std::cout << "I've worked! " << testconf->getValue<crap::string64>("SOUND_VOLUME") << std::endl; } float32_t zero[3] = {0.f, 0.f, 0.f}; float32_t one[3] = {1.f, 1.f, 1.f}; float32_t dir[6] = {0.f, 0.f, 1.f, 0.f, 1.f, 0.f }; crap::AudioSystem* am = system.getSubSystem<crap::AudioSystem>( "AudioSystem" ); resourceManager.loadResource( "Nagut" ); uint32_t sid = am->leaseSource( "Nagut" ); am->setListenerData( zero, zero, dir ); am->playSource( sid ); // while( am->getIsPlaying(sid) ) // crap::sleep_mil_sec(100); crap::log( LOG_CHANNEL_CORE | LOG_TYPE_INFO | LOG_TARGET_COUT, "We're done!" ); crap::Renderer2D renderer2D( &renderWindow, 10, 10, 100 ); crap::SubSystem renderer2d_sys( "Renderer2D", &renderer2D, &system ); crap::Context2D* gc = renderer2D.getContext(); resourceManager.loadResource( "Hasi" ); resourceManager.loadResource( "Mieze" ); uint32_t guiImage = renderer2D.getImage2D("Hasi"); uint32_t guiImage2 = renderer2D.getImage2D("Mieze"); resourceManager.loadResource("CalcFont"); crap::Font2D font2d = renderer2D.getFont2D("CalcFont"); crap::Node* cnode = componentSystem.createNode(); crap::Component* trans2d = componentSystem.createComponent("Attributes2D", cnode ); componentSystem.setComponentMember( trans2d, "posX", "600" ); componentSystem.setComponentMember( trans2d, "posY", "600" ); componentSystem.setComponentMember( trans2d, "rotation", "20" ); componentSystem.setComponentMember( trans2d, "scale", "1.f" ); trans2d->init( &system ); crap::color_argb colorf; colorf.r = 0; colorf.b = 0; colorf.g = 255; colorf.a = 128; crap::color_argb colorb; //black colorb.r = 0; colorb.b = 0; colorb.g = 0; colorb.a = 255; crap::color_argb col = crap::argb::black; crap::string64 colstr("AABBCCDD"); uint32_t lolali = strtol("AABBCCDD", 0, 16 ); crap::color_argb colorino = crap::convert<crap::string64, crap::color_argb>( colstr ); crap::string64 popo = crap::convert<crap::color_argb, crap::string64>( crap::argb::orange ); crap::string64 buff = crap::convert<crap::color_argb, crap::string64>(colorf); crap::string64 bufb = crap::convert<crap::color_argb, crap::string64>(colorb); crap::Component* circle2d = componentSystem.createComponent("RoundedRectangle2D", cnode ); componentSystem.setComponentMember( circle2d, "width", "150" ); componentSystem.setComponentMember( circle2d, "height", "200" ); componentSystem.setComponentMember( circle2d, "corner", "20" ); componentSystem.setComponentMember( circle2d, "color", buff ); componentSystem.setComponentMember( circle2d, "border", "5" ); componentSystem.setComponentMember( circle2d, "borderColor", bufb ); circle2d->init(&system); crap::Node* tnode = componentSystem.createNode(); crap::Component* trans2dt = componentSystem.createComponent("Attributes2D", tnode ); componentSystem.setComponentMember( trans2dt, "posX", "200" ); componentSystem.setComponentMember( trans2dt, "posY", "600" ); componentSystem.setComponentMember( trans2dt, "rotation", "0" ); componentSystem.setComponentMember( trans2dt, "scale", "1.f" ); trans2d->init( &system ); crap::Component* text2d = componentSystem.createComponent("Text2D", tnode ); componentSystem.setComponentMember( text2d, "fontName", "CalcFont" ); componentSystem.setComponentMember( text2d, "text", "Hallo ich bin ein Test" ); componentSystem.setComponentMember( text2d, "fontSize", "50" ); componentSystem.setComponentMember( text2d, "color", bufb ); componentSystem.setComponentMember( text2d, "blur", "1" ); text2d->init(&system); //physic test crap::Node* pnode = componentSystem.createNode(); crap::Component* ptrans2d = componentSystem.createComponent("Attributes2D", pnode ); componentSystem.setComponentMember( ptrans2d, "posX", "770" ); componentSystem.setComponentMember( ptrans2d, "posY", "550" ); componentSystem.setComponentMember( ptrans2d, "rotation", "-0.3f" ); componentSystem.setComponentMember( ptrans2d, "scale", "1.f" ); crap::Component* rect2d = componentSystem.createComponent("Rectangle2D", pnode ); componentSystem.setComponentMember( rect2d, "width", "300" ); componentSystem.setComponentMember( rect2d, "height", "50" ); componentSystem.setComponentMember( rect2d, "color", buff ); componentSystem.setComponentMember( rect2d, "border", "0" ); componentSystem.setComponentMember( rect2d, "borderColor", bufb ); crap::Component* phys2d = componentSystem.createComponent("Rectangle2DPhysic", pnode ); componentSystem.setComponentMember( phys2d, "width", "300" ); componentSystem.setComponentMember( phys2d, "height", "50" ); componentSystem.setComponentMember( phys2d, "density", "1.f" ); componentSystem.setComponentMember( phys2d, "friction", "1.f" ); componentSystem.setComponentMember( phys2d, "dynamic", "0" ); ptrans2d->init(&system); rect2d->init(&system); phys2d->init(&system); //solid crap::Node* pnode2 = componentSystem.createNode(); crap::Component* ptrans2d2 = componentSystem.createComponent("Attributes2D", pnode2 ); componentSystem.setComponentMember( ptrans2d2, "posX", "550" ); componentSystem.setComponentMember( ptrans2d2, "posY", "400" ); componentSystem.setComponentMember( ptrans2d2, "rotation", "0.2" ); componentSystem.setComponentMember( ptrans2d2, "scale", "1.f" ); crap::Component* rect2d2 = componentSystem.createComponent("Rectangle2D", pnode2 ); componentSystem.setComponentMember( rect2d2, "width", "300" ); componentSystem.setComponentMember( rect2d2, "height", "50" ); componentSystem.setComponentMember( rect2d2, "color", bufb ); componentSystem.setComponentMember( rect2d2, "border", "0" ); componentSystem.setComponentMember( rect2d2, "borderColor", bufb ); crap::Component* phys2d2 = componentSystem.createComponent("Rectangle2DPhysic", pnode2 ); componentSystem.setComponentMember( phys2d2, "width", "300" ); componentSystem.setComponentMember( phys2d2, "height", "50" ); componentSystem.setComponentMember( phys2d2, "density", "1.f" ); componentSystem.setComponentMember( phys2d2, "friction", "1.f" ); componentSystem.setComponentMember( phys2d2, "dynamic", "0" ); ptrans2d2->init(&system); rect2d2->init(&system); phys2d2->init(&system); //circle crap::Node* pnode3 = componentSystem.createNode(); crap::Component* ptrans2d3 = componentSystem.createComponent("Attributes2D", pnode3 ); componentSystem.setComponentMember( ptrans2d3, "posX", "600" ); componentSystem.setComponentMember( ptrans2d3, "posY", "50" ); componentSystem.setComponentMember( ptrans2d3, "rotation", "0" ); componentSystem.setComponentMember( ptrans2d3, "scale", "1.f" ); crap::Component* rect2d3 = componentSystem.createComponent("Circle2D", pnode3 ); componentSystem.setComponentMember( rect2d3, "radius", "20" ); componentSystem.setComponentMember( rect2d3, "color", "FF0080FF" ); componentSystem.setComponentMember( rect2d3, "border", "0" ); componentSystem.setComponentMember( rect2d3, "borderColor", "FF0000F" ); crap::Component* phys2d3 = componentSystem.createComponent("Cirlce2DPhysic", pnode3 ); componentSystem.setComponentMember( phys2d3, "radius", "20" ); componentSystem.setComponentMember( phys2d3, "density", "1.f" ); componentSystem.setComponentMember( phys2d3, "friction", "1.f" ); componentSystem.setComponentMember( phys2d3, "dynamic", "1" ); ptrans2d3->init(&system); rect2d3->init(&system); phys2d3->init(&system); crap::color_argb bord; bord.value = 0; float32_t rot = 0.f; while( running && !renderWindow.shouldClose() ) { renderer.drawBegin(); renderer2D.drawBegin(); // crap::drawColoredRectangle( gc, 100.f, 100.f, 100.f, 100.f, -rot*0.1, 255, 0, 255, 255 ); // //crap::drawColoredCircle( gc, 500.f, (int32_t)(rot*100) % renderWindow.getHeight(), 50.f, 255, 0, 0, 255 ); // rot += 0.1f; // crap::drawColoredRoundedRectangle( gc, 150.f, 150.f, 200.f, 200.f, rot, 0, 0, 255, 128, 20.f ); // // crap::drawColorTriangle( gc, 400, 400, 140, 100, 0.f, 0, 255, 0, 255 ); // // crap::drawImageRectangle( gc, (int32_t)(rot*10) % renderWindow.getWidth(), 400, 100, 100, rot*0.1, guiImage, 100.f, 100.f, 0.f, 0.f, 0.f, 1.f ); // // crap::drawImageCircle( gc, 600, 200, 50, guiImage2, 255, 100.f, 100.f, 0.f, -10,10-rot*2, 0.3f); // // crap::drawText(gc, 400, 400, font2d, "Hallo, du Welt.", 30.f ,0.f , 0, 255, 0, 255, 0, 1, 10.f, crap::align::left); bord.value++; bord.value %= 100; componentSystem.setComponentMember( circle2d, "corner", crap::convert<crap::color_argb, crap::string64>(bord) ); componentSystem.setComponentMember( text2d, "fontSize", "100" ); renderer2D.render(); renderer2D.drawEnd(); renderer.drawEnd(); //renderWindow.swap(); taskManager.update(); } renderer2D.removeImage2D( "Mieze" ); renderer2D.removeImage2D( "Hasi" ); renderWindow.destroy(); #ifdef CRAP_COMPILER_MSVC // std::cout << "Press a button" << std::endl; // getchar(); #endif pluginDirectoryListener.removeCallback<crap::PluginManager, &crap::PluginManager::callbackFunction>( &pluginManager ); pluginManager.unloadAll(); return 0; }
/** Procedure: handler_set_date Purpose: Sets System Date Parameters: None Return value: 0 Calls: keyboardInput, sys_set_date, sys_get_date, errorCheck Globals: None Errors: Invalid Date, Date Not Changed **/ int handler_set_date(){ char *Buffer; int month; int day; int year; int flag = 0; int leapYear; int i = 0; printf("Enter the date in mmddyyyy format with no slashes or dashes: \n"); Buffer = keyboardInput(0); while(i<8){ if(Buffer[i] < 48 || Buffer[i] > 57){ //printf("The date you entered is invalid!"); flag = 1; } i++; } if(flag == 0){ month = (Buffer[0] - 48)*10 + Buffer[1] - 48; day = (Buffer[2] - 48)*10 + Buffer[3] - 48; year = (Buffer[4] - 48)*1000 + (Buffer[5] - 48)*100 + (Buffer[6] - 48)*10 + Buffer[7] - 48; if(year%4 == 0 && year%100 ==0 && year% 400 == 0){ leapYear = 1; } if(month > 12|| day < 1 || month < 1){ flag = 1; } if(leapYear==0){ if(month < 13 && month == 02 && day > 28){ flag = 1; }else if(month <13 && month == 1 && day > 31){ flag = 1; }else if(month <13 && month == 3 && day > 31){ flag = 1; }else if(month <13 && month == 5 && day > 31){ flag = 1; }else if(month <13 && month == 7 && day > 31){ flag = 1; }else if(month <13 && month == 8 && day > 31){ flag = 1; }else if(month <13 && month == 10 && day > 31){ flag = 1; }else if(month <13 && month == 12 && day > 31){ flag = 1; }else if(month <13 && month == 4 && day > 30){ flag = 1; }else if(month <13 && month == 6 && day > 30){ flag = 1; }else if(month <13 && month == 9 && day > 30){ flag = 1; }else if(month <13 && month == 11 && day > 30){ flag = 1; } }else{ if(month < 13 && month == 02 && day > 29){ flag = 1; }else if(month <13 && month == 1 && day > 31){ flag = 1; }else if(month <13 && month == 3 && day > 31){ flag = 1; }else if(month <13 && month == 5 && day > 31){ flag = 1; }else if(month <13 && month == 7 && day > 31){ flag = 1; }else if(month <13 && month == 8 && day > 31){ flag = 1; }else if(month <13 && month == 10 && day > 31){ flag = 1; }else if(month <13 && month == 12 && day > 31){ flag = 1; }else if(month <13 && month == 4 && day > 30){ flag = 1; }else if(month <13 && month == 6 && day > 30){ flag = 1; }else if(month <13 && month == 9 && day > 30){ flag = 1; }else if(month <13 && month == 11 && day > 30){ flag = 1; } } } if(flag == 0){ date_rec date; date.month = month; date.day = day; date.year = year; sys_set_date(&date); sys_get_date(&date); if(date.month != month || date.day != day || date.year != year){ errorCheck(-109); } } else{ errorCheck(-108); } return 0; }
/** Procedure: commandHandler Purpose: Handles User Commands & Command Execution Parameters: None Return value: None Calls: displayWelcome, keyboardInput, cmpP2S, handler_help, handler_version, handler_set_date, handler_get_date, handler_display_mpx, handler_display_history, handler_terminate_mpx, change_prompt, handler_help_function, handler_create_pcb, handler_delete_pcb, handler_block, handler_unblock, handler_suspend, handler_resume, handler_set_priority, handler_show_pcb, handler_show, displayClosing, commandCleanup, sys_exit Globals: comDone, userCommand Errors: None **/ void commandHandler(){ int userCommandSize; displayWelcome(); //2.1 Display the Welcome Message while(comDone !=1){ //2.2 Begin While Loop for User Commands userCommand = NULL; printf("\nPlease enter the command to be executed(case sensitive).\n"); userCommand = keyboardInput(0); //2.2.1 Request User Input & Accept Command from User printf("\n"); //Decision Statement if(cmpP2S(userCommand, "help") == 1 || cmpP2S(userCommand, "/?") == 1){ handler_help(); } else if(cmpP2S(userCommand, "version") == 1){ handler_version(); } else if(cmpP2S(userCommand, "set_date") == 1){ handler_set_date(); //fix = 1; } else if(cmpP2S(userCommand, "get_date") == 1){ handler_get_date(); } else if(cmpP2S(userCommand, "display_mpx") == 1){ handler_display_mpx(); } //else if(cmpP2S(userCommand, "display_history") == 1){ // handler_display_history(); //} else if(cmpP2S(userCommand, "terminate_mpx") == 1||cmpP2S(userCommand, "exit") == 1||cmpP2S(userCommand, "quit") == 1){ handler_terminate_mpx(); } else if(cmpP2S(userCommand, "change_prompt") == 1){ change_prompt(); //fix = 1; } else if(cmpP2S(userCommand, "help_version")==1){ handler_help_function("version"); } else if(cmpP2S(userCommand, "help_set_date")==1){ handler_help_function("set_date"); } else if(cmpP2S(userCommand, "help_get_date")==1){ handler_help_function("get_date"); } else if(cmpP2S(userCommand, "help_display_mpx")==1){ handler_help_function("display_mpx"); } else if(cmpP2S(userCommand, "help_terminate_mpx")==1){ handler_help_function("terminate_mpx"); } else if(cmpP2S(userCommand, "help_change_prompt")==1){ handler_help_function("change_prompt"); } else if(cmpP2S(userCommand, "help_create_pcb")==1){ handler_help_function("create_pcb"); } else if(cmpP2S(userCommand, "create_pcb")==1){ handler_create_pcb(); } else if(cmpP2S(userCommand, "help_delete_pcb")==1){ handler_help_function("delete_pcb"); } else if(cmpP2S(userCommand, "delete_pcb")==1){ handler_delete_pcb(); } else if(cmpP2S(userCommand, "help_block")==1){ handler_help_function("block"); } else if(cmpP2S(userCommand, "block")==1){ handler_block(); } else if(cmpP2S(userCommand, "help_unblock")==1){ handler_help_function("unblock"); } else if(cmpP2S(userCommand, "unblock")==1){ handler_unblock(); } else if(cmpP2S(userCommand, "help_suspend")==1){ handler_help_function("suspend"); } else if(cmpP2S(userCommand, "suspend")==1){ handler_suspend(); } else if(cmpP2S(userCommand, "help_resume")==1){ handler_help_function("resume"); } else if(cmpP2S(userCommand, "resume")==1){ handler_resume(); } else if(cmpP2S(userCommand, "help_set_priority")==1){ handler_help_function("set_priority"); } else if(cmpP2S(userCommand, "set_priority")==1){ handler_set_priority(); } else if(cmpP2S(userCommand, "help_show_pcb")==1){ handler_help_function("show_pcb"); } else if(cmpP2S(userCommand, "show_pcb")==1){ handler_show_pcb(); } else if(cmpP2S(userCommand, "help_show_all")==1){ handler_help_function("show_all"); } else if(cmpP2S(userCommand, "show_all")==1){ handler_show(0); } else if(cmpP2S(userCommand, "help_show_ready")==1){ handler_help_function("show_ready"); } else if(cmpP2S(userCommand, "show_ready")==1){ handler_show(4); handler_show(6); } else if(cmpP2S(userCommand, "help_show_blocked")==1){ handler_help_function("show_blocked"); } else if(cmpP2S(userCommand, "show_blocked")==1){ handler_show(5); handler_show(7); } else { printf("Invalid Command.\n"); }//end if - Decision }//end while displayClosing(); //2.2.4 Display closing message commandCleanup(); //2.2.5 Cleanup Allocated Memory keyboardInput(0); sys_exit(); //2.2.6 Return to host system }