//This is the magic sauce which forces a message back to the registered proc process* irq_handle(unsigned char irq_number) { DEBUG("\nIRQ "); DEBUG_HD(irq_number); DEBUG(" triggered\n"); irq_number -= 0xE0; //Get the heck out of here if the irq isn't registered if(!irq_process[irq_number - 1]) { DEBUG("Nothing registered for this IRQ"); return (process*)0; } //Otherwise, write a message to the handling process and enter it passMessage(0, irq_process[irq_number - 1]->id, KS_REG_IRQ_1 + irq_number - 1, 0); //Tell the PIC we're ready to accept further interrupts on this channel send_pic_eoi(irq_number); return irq_process[irq_number - 1]; }
//Increment all active timer counters by one (this is fired on the millisecond) //While we're at it, see if any of the timers have surpassed their limit and //return the first one that has. process* find_elapsed_timers() { int i, found = 0; process* ret_p = (process*)0; if(!active_timer_count) return (process*)0; //Look through the timer table and message and return the process of the first //found to exist and have elapsed for(i = 0; i < 10; i++) { if(event_timer[i].p) { event_timer[i].count++; if(event_timer[i].count >= event_timer[i].limit) { //Keep track of the matched process if(!ret_p) { ret_p = event_timer[i].p; //Uninstall the timer now that it's been exhausted active_timer_count--; event_timer[i].p = (process*)0; event_timer[i].count = 0; event_timer[i].limit = 0; //Send the process a timer elapsed message passMessage(0, ret_p->id, KS_TIMER, 1); } } } } return ret_p; }
void Game::run( ) { bool running = true; double startTime = Window::time( ); double previousTime = 0.0; while ( running ) { double currentMs = Window::time( ) - startTime; double deltaMs = currentMs - previousTime; Time time{ static_cast< float >( currentMs ), static_cast< float >( deltaMs ) }; /*double fps = 1000 / deltaMs; LOG( fps << std::endl );*/ previousTime = currentMs; InputMessage msg; while ( _window->popMessage( msg ) ) { switch ( msg.type ) { case InputMessage::Type::Close: { _window->close( ); running = false; break; } case InputMessage::Type::KeyDown: { if ( msg.key.type == Key::F4 && msg.key.lAlt ) { _window->close( ); running = false; break; } else if ( msg.key.type == Key::F1 ) { OpenGl::fillMode( ); } else if ( msg.key.type == Key::F2 ) { OpenGl::wireframeMode( ); } else if ( msg.key.type == Key::F3 ) { OpenGl::pointMode( ); } else { passMessage( msg ); } } case InputMessage::Type::KeyUp: case InputMessage::Type::MouseButtonDown: case InputMessage::Type::MouseButtonUp: case InputMessage::Type::MouseMove: case InputMessage::Type::MouseWheel: { passMessage( msg ); break; } } } if ( running ) { render( time ); update( time ); } } }
void MessageDispatcher::reemitMessage(const char * msg) { emit passMessage(msg); }