uint8_t Keyboard__get_report(USB_KeyboardReport_Data_t *report_data) { reset(); #ifdef STDOUT_TO_KBREPORT if (!stdout_is_empty()) stdout_to_report_queue(); #endif KeyboardReport *report = NULL; if (ReportQueue__is_empty()) { scan_matrix(); init_active_keys(); if (!kb.error_roll_over && (report = ReportQueue__push())) { do update_bindings(report); while (momentary_mode_engaged() || modifier_keys_engaged(report)); process_keys(report); } } report = ReportQueue__pop(); return fill_report(report, report_data); }
MDS_DATA StopwatchMsgProc(void *obj, int message, MDS_DATA extra_data) { Stopwatch *stopwatch = (Stopwatch *)obj; if (!stopwatch->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(stopwatch->pos.x, stopwatch->pos.y); if (extra_data.integer == 0) { char *buffer = (char *)malloc(stopwatch->size.x + 1); int s = stopwatch->msec / 1000; if (buffer == NULL) break; sprintf(buffer, "%02i:%02i:%02i", s / 3600, (s % 3600) / 60, s % 60); if (stopwatch->active) con_outTxt("<%*s>", stopwatch->size.x-2, buffer); else con_outTxt("[%*s]", stopwatch->size.x-2, buffer); free(buffer); } else con_outTxt("%*s", stopwatch->size.x, ""); break; case MESSAGE_MOVE: move_object((Object *)stopwatch, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: process_keys((Object *)stopwatch, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)stopwatch, extra_data.integer); break; case MESSAGE_STOPWATCH_START: stopwatch->running = !stopwatch->running; if (stopwatch->running) { ++(stopwatch->msg_id.integer); MDS_postMessage(stopwatch, MESSAGE_STOPWATCH_INC, stopwatch->msg_id, STOPWATCH_INC); } break; case MESSAGE_STOPWATCH_INC: if (extra_data.integer == stopwatch->msg_id.integer) { stopwatch->msec += STOPWATCH_INC; if (stopwatch->running) MDS_postMessage(stopwatch, MESSAGE_STOPWATCH_INC, stopwatch->msg_id, STOPWATCH_INC); } break; } return NULL_DATA; }
/** main program */ int main(int argc, char* argv[]) { if(argc != 6) { usage(); } if(strcmp(argv[1], "NSEC3PARAM") == 0) { process_nsec3(argc, argv); return 0; } process_keys(argc, argv); return 0; }
void press_key(int c){ spkb_state_changed = 1; int ki; if ( c == 'E' ) ki = KS_TO_KEY(SK_KP_Enter); else if (c == 'S' ) ki = KS_TO_KEY(SK_KP_Space); else ki = KS_TO_KEY(c); spkb_kbstate[ki].state = 1; process_keys(); }
static t_bool bentor(t_shell *shell, int *i, char *c, char *buff) { if (complete_part(shell, buff, i, c) == FALSE) return (FALSE); if (g_sigint == 1) { bzero(buff, sizeof(char) * BUFF_SIZE); shell->history_on = FALSE; shell->com.on = FALSE; aff_prompt(shell); g_sigint = 0; return (FALSE); } process_keys(shell, i, c, buff); aff_cmd(shell, buff, i); return (TRUE); }
/** * @brief Renderer::render render a single frame, then return * @return true if the user wants to quit the application */ bool Renderer::render(){ process_keys(SDL_GetKeyboardState(NULL)); SDL_Event e; while(SDL_PollEvent(&e)){ if(e.type == SDL_QUIT){ printf("received SDL_QUIT\n"); quit_flag = true; } else if(e.type == SDL_MOUSEMOTION){ mousemove_event(e.motion.xrel, e.motion.yrel); } else if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_RESIZED){ resize_event(e.window.data1, e.window.data2); std::cout << "window resized" << std::endl; } } glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); world_to_camera_matrix = look_matrix(camera_vertical, camera_horizontal, camera_position); camera_to_clip_matrix = glm::mat4( glm::vec4(frustum_scale/(width/(float)height), 0.0, 0.0, 0.0), glm::vec4(0.0, frustum_scale, 0.0, 0.0), glm::vec4(0.0, 0.0, (z_far + z_near)/(z_near - z_far), (2*z_far*z_near)/(z_near - z_far)), glm::vec4(0.0, 0.0, -1.0, 0.0)); // update uniforms for all shaders now (no UBOs in 2.x, unfortunately...) axes_shader->set_camera_to_clip(camera_to_clip_matrix); axes_shader->set_world_to_camera(world_to_camera_matrix); render_axes(); trails_shader->set_camera_to_clip(camera_to_clip_matrix); trails_shader->set_world_to_camera(world_to_camera_matrix); render_trails(); pointsprites_shader->set_camera_to_clip(camera_to_clip_matrix); pointsprites_shader->set_world_to_camera(world_to_camera_matrix); pointsprites_shader->set_uniform("camera_position", camera_position); render_pointsprites(); render_center_of_mass(); SDL_GL_SwapWindow(win); //SDL_Delay(1000/60.0); // limit to 60FPS return quit_flag; }
MDS_DATA ClockMsgProc(void *obj, int message, MDS_DATA extra_data) { Clock *clock = (Clock *)obj; if (!clock->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(clock->pos.x, clock->pos.y); if (extra_data.integer == 0) { time_t curr_time; struct tm * curr_time_tm; char *buffer = (char *)malloc(clock->size.x + 1); if (buffer == NULL) break; time(&curr_time); curr_time_tm = localtime(&curr_time); strftime(buffer, clock->size.x + 1, "%H:%M:%S", curr_time_tm); if (clock->active) con_outTxt("<%*s>", clock->size.x-2, buffer); else con_outTxt("[%*s]", clock->size.x-2, buffer); free(buffer); } else con_outTxt("%*s", clock->size.x, ""); break; case MESSAGE_MOVE: move_object((Object *)clock, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: process_keys((Object *)clock, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)clock, extra_data.integer); break; } return NULL_DATA; }
void* ppmoutput_thread( void *arg ) { framebuffer_t *frame; stream_node_t *node; hthread_time_t start; hthread_time_t end; Huint frames; // Get the argument to the thread node = (stream_node_t*)arg; // Check that the node has been setup correctly ppmoutput_check_buffers( node ); // Initialize the FPS counter frames = 0; // Capture the current time hthread_time_get( &start ); // Run the input thread while( 1 ) { process_keys(); // Get an image to output from the input buffer frame = buffer_remove( node->input ); // Determine if we should stop processing if( frame == NULL ) break; // Output the ppm image //ppmoutput_write_file( frame ); // Show the FPS that we are handling ppmoutput_capture_time( &start, &end, &frames ); // Clean up the processed frame ppmoutput_cleanup_frame( node, frame ); } // Finish running the thread return NULL; }
MDS_DATA BufferMsgProc(void *obj, int message, MDS_DATA extra_data) { Buffer *buffer = (Buffer *)obj; if (!buffer->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(buffer->pos.x, buffer->pos.y); if (extra_data.integer == -1) { con_outTxt("%*s", buffer->size.x, ""); } else { if (buffer->active) con_outTxt("<%*s>", buffer->text_len, buffer->text); else con_outTxt("[%*s]", buffer->text_len, buffer->text); } break; case MESSAGE_MOVE: move_object((Object *)buffer, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)buffer, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: if (!process_keys((Object *)buffer, extra_data.integer)) { if (extra_data.integer >= 32 && extra_data.integer <= 255) add_char(buffer, extra_data.integer); else if (extra_data.integer == CON_KEY_BACKSPACE) del_char(buffer); } break; } return NULL_DATA; }
void handler() { process_keys(); update_projectiles(); update_animations(); step_monsters(); game.player.light->update_flicker(); process_sight(); draw_lights(game.fov_light, &game.map.block, game.map.lights); { lightsource *k = game.map.lights.head(); for (; k; k = k->next()) { k->update_flicker(); draw_light(game.fov_light, &game.map.block, k); } } u32 keys = keysHeld(); u32 down = keysDown(); touchPosition touch = touchReadXY(); if (down & KEY_TOUCH && keys & KEY_R && touch.px != 0 && touch.py != 0) { luxel *l = torch.buf.luxat(torch.buf.scroll.x + touch.px/8, torch.buf.scroll.y + touch.py/8); iprintf("c:%d,%d,%d v:%d, low:%d\n", l->lr, l->lg, l->lb, l->lval, torch.get_low_luminance()); } refresh(&game.map.block); if (game.player.hp <= 0) { playerdeath(); game.player.clear(); new_game(); } if (game.cooldown <= 0) game.player.regenerate(); statusbar(); }
void opt_nowrap_engine(void) { uint8_t src, dst, col, result, rowpair; uint8_t A, B, A1, A2, A3, A4, A5, A6, A7, A8, A9, B1, B2, B3, CV; register uint8_t *rowptr, *aboveptr, *belowptr; uint8_t *dstptr; uint16_t *srcpage, *dstpage, *belowsrc, *abovesrc; while (1) { for (src=0; src < 2; src++) { if (process_keys()) return; dst = !src; abovesrc = pageabove[src]; srcpage = gr_page[src]; belowsrc = pagebelow[src]; dstpage = gr_page[dst]; for (rowpair=0; rowpair < MAXROWPAIRCNT; rowpair++) { // row specific metadata need only be set up once per row aboveptr = abovesrc[rowpair]; rowptr = srcpage[rowpair]; belowptr = belowsrc[rowpair]; dstptr = dstpage[rowpair]; // examine leftmost column: A1 = 0; A2 = (rowpair == 0) ? 0 : (aboveptr[0] & ODD_ROW_MASK ? 1 : 0); A3 = (rowpair == 0) ? 0 : (aboveptr[1] & ODD_ROW_MASK ? 1 : 0); A4 = 0; A5 = rowptr[0] & EVEN_ROW_MASK ? 1 : 0; A6 = rowptr[1] & EVEN_ROW_MASK ? 1 : 0; A7 = 0; A8 = rowptr[0] & ODD_ROW_MASK ? 1 : 0; A9 = rowptr[1] & ODD_ROW_MASK ? 1 : 0; B1 = 0; B2 = (rowpair == MAXROWPAIRIDX ) ? 0 : (belowptr[0] & EVEN_ROW_MASK ? 1 : 0); B3 = (rowpair == MAXROWPAIRIDX ) ? 0 : (belowptr[1] & EVEN_ROW_MASK ? 1 : 0); // CV is a value common to the sum of A and B, add it once CV = A4 + A6 + A7 + A9; A = A1 + A2 + A3 + CV + A8; B = A5 + B1 + B2 + B3 + CV; //start by presuming everything is dead result = 0; // upper cell is centered on A5 if ((A5 && ((A == 2) || (A == 3))) || ((A5 == 0) && (A == 3))) { //even row is alive result = EVEN_ROW_MASK; } // lower cell is centered on A8 if ((A8 && ((B == 2) || (B == 3))) || ((A8 == 0) && (B == 3))) { //odd row is alive result |= ODD_ROW_MASK; } // save new upper and lower cell together dstptr[0]=result; // shift a 4x3 grid one cell to the right, allowing // us to reuse the counted values from the left 2 // columns. only the right column is new information. for (col = 1; col < MAXCOLCNT - 1; col++) { A1 = A2; A2 = A3; A3 = (rowpair == 0) ? 0 : (aboveptr[col+1] & ODD_ROW_MASK ? 1 : 0); A4 = A5; A5 = A6; A6 = rowptr[col+1] & EVEN_ROW_MASK ? 1 : 0; A7 = A8; A8 = A9; A9 = rowptr[col+1] & ODD_ROW_MASK ? 1 : 0; B1 = B2; B2 = B3; B3 = (rowpair == MAXROWPAIRIDX) ? 0 : (belowptr[col+1] & EVEN_ROW_MASK ? 1 : 0); CV = A4 + A6 + A7 + A9; A = A1 + A2 + A3 + CV + A8; B = A5 + B1 + B2 + B3 + CV; result = 0; if ((A5 && ((A == 2) || (A == 3))) || ((A5 == 0) && (A == 3))) { result = EVEN_ROW_MASK; } if ((A8 && ((B == 2) || (B == 3))) || ((A8 == 0) && (B == 3))) { result |= ODD_ROW_MASK; } dstptr[col]=result; } // on the rightmost examination, there are no new // cells to examine! skip A3, A6, A9, and B3! A1 = A2; A2 = A3; //A3 = 0; A4 = A5; A5 = A6; //A6 = 0; A7 = A8; A8 = A9; //A9 = 0; B1 = B2; B2 = B3; //B3 = 0; CV = A4 + A7; A = A1 + A2 + CV + A8; B = A5 + B1 + B2 + CV; result = 0; if ((A5 && ((A == 2) || (A == 3))) || ((A5 == 0) && (A == 3))) { result = EVEN_ROW_MASK; } if ((A8 && ((B == 2) || (B == 3))) || ((A8 == 0) && (B == 3))) { result |= ODD_ROW_MASK; } dstptr[MAXCOLIDX]=result; } // flip the graphics page softsw(dst + SS_PAGE2OFF); } } }
int main() { PRINTF("%s","Hello ACN World\n"); /* note, this may not work in all cases. 1) all systems might boot at the same time 2) when they get to this point, they may not have an ip yet */ /* init our acn stack */ acn_port_protect_startup(); #if CONFIG_NSK srand(microsecsonds_since_midnight_GMT() + netx_getmyip(0)); netx_init(); netx_startup(); #endif #if CONFIG_SLP slp_init(); slp_open(); slp_active_discovery_start(); #endif #if CONFIG_RLP rlp_init(); #if CONFIG_SDT sdt_init(); sdt_startup(true); #endif /* dmp_startup(); */ #endif /* RLP */ pthread_create(&timer_thread_id, NULL, timer_funct, NULL); pthread_create(&recv_thread_id, NULL, recv_funct, NULL); process_keys(); /* shut things down - these require the threads to continue run... */ #if CONFIG_SDT sdt_shutdown(); #endif #if CONFIG_SLP slp_close(); #endif /* dmp_shutdown() */ /* close threads */ pthread_cancel(recv_thread_id); pthread_join(recv_thread_id, NULL); pthread_cancel(timer_thread_id); pthread_join(timer_thread_id, NULL); #if CONFIG_NSK netx_shutdown(); #endif acn_port_protect_shutdown(); slp_stats(); sdt_stats(); PRINTF("%s","========================\n"); PRINTF("%s","Done...\n"); return 0; }
void client_loop (void) { long VfTime = 0; long VendSleep = 0; struct timeval VlastClk; struct timeval VnewClk; int wait = 0; #if 0 int drawed = 0; int display = 1; #endif client = 1; load_rc (); init_menu (); Ready (); #ifdef XSUPPORT nopause = 1; #endif gamemode = MENU; gettimeofday (&VlastClk, NULL); gettimeofday (&VnewClk, NULL); VendSleep = VlastClk.tv_usec; VfTime = 1000000 / 25; dispframes = 25 * 4; realdisplayed = 25; GetPos (); dispframes = 0; realdisplayed = 0; while (1) { if (nodisplayco) nodisplayco--; SetTimeout (0, 0); nodata++; while (SocketReadable (sock)) process_message (); gettimeofday (&VnewClk, NULL); if (VnewClk.tv_usec < VendSleep) VendSleep -= 1000000; wait = (VfTime - VnewClk.tv_usec + VendSleep); allframes++; if (fadedout) rframe = 1; process_keys (); if ((wait > 0 || tbreak)) { /*display=0; */ csendbuffer (); realdisplayed++; client_loop2 (rframe && (!nodisplayco)); rframe = 0; } else { csendbuffer (); client_loop2 (0); } if (allframes == 25 || tbreak) { /*printf ("Displayed frames:%i really:%i\n", dispframes / 4, realdisplayed); */ if (tbreak) realdisplayed = 25; GetPos (); allframes = 0; dispframes = 0; realdisplayed = 0; } SendControls (); #ifndef HAVEUSLEEP do { /*my emulation of usleep isn't reiable on HP-UX machines when sockets are comming :( */ #endif gettimeofday (&VnewClk, NULL); if (VnewClk.tv_usec < VendSleep) VendSleep -= 1000000; wait = (VfTime - VnewClk.tv_usec + VendSleep); if (tbreak) wait = VfTime; if (wait > 0) usleep (wait); #ifndef HAVEUSLEEP } while (wait > 10 && !tbreak); #endif VendSleep = VnewClk.tv_usec + wait; gettimeofday (&VlastClk, NULL); if (tbreak) VendSleep = VlastClk.tv_usec; tbreak = 0; } }
void spkb_process_events( int evenframe ) { if(evenframe){ int ki; #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ (CONFIG_KEYPAD == IPOD_1G2G_PAD) if (rb->button_hold()) { #if defined(HAVE_ADJUSTABLE_CPU_FREQ) rb->cpu_boost(false); #endif exit_requested=1; #ifdef USE_GREY grey_show(false); #endif return; } #endif int buttons = rb->button_status(); if ( buttons == previous_state ) return; previous_state = buttons; #if (CONFIG_KEYPAD != IPOD_4G_PAD) && (CONFIG_KEYPAD != IPOD_3G_PAD) && \ (CONFIG_KEYPAD != IPOD_1G2G_PAD) if (buttons & ZX_MENU) { #if defined(HAVE_ADJUSTABLE_CPU_FREQ) rb->cpu_boost(false); #endif exit_requested=1; #ifdef USE_GREY grey_show(false); #endif return; } #endif spkb_state_changed = 1; if (settings.kempston){ if ( buttons & ZX_RIGHT ){ ki = KS_TO_KEY(SK_KP_Right); spkb_kbstate[ki].state = 1; } else if (buttons & ZX_LEFT){ ki = KS_TO_KEY(SK_KP_Left); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(SK_KP_Right); spkb_kbstate[ki].state = 0; ki = KS_TO_KEY(SK_KP_Left); spkb_kbstate[ki].state = 0; } if ( buttons & ZX_UP ){ ki = KS_TO_KEY(SK_KP_Up); spkb_kbstate[ki].state = 1; } else if (buttons & ZX_DOWN){ ki = KS_TO_KEY(SK_KP_Down); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(SK_KP_Up); spkb_kbstate[ki].state = 0; ki = KS_TO_KEY(SK_KP_Down); spkb_kbstate[ki].state = 0; } if ( buttons & ZX_SELECT ){ ki = KS_TO_KEY(SK_KP_Insert); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(SK_KP_Insert); spkb_kbstate[ki].state = 0; } } else { if ( buttons & ZX_RIGHT ){ ki = KS_TO_KEY(intkeys[3]); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(intkeys[3]); spkb_kbstate[ki].state = 0; } if ( buttons & ZX_LEFT ){ ki = KS_TO_KEY(intkeys[2]); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(intkeys[2]); spkb_kbstate[ki].state = 0; } if ( buttons & ZX_UP ){ ki = KS_TO_KEY(intkeys[0]); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(intkeys[0]); spkb_kbstate[ki].state = 0; } if ( buttons & ZX_DOWN ){ ki = KS_TO_KEY(intkeys[1]); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(intkeys[1]); spkb_kbstate[ki].state = 0; } if ( buttons & ZX_SELECT ){ ki = KS_TO_KEY(intkeys[4]); spkb_kbstate[ki].state = 1; } else{ ki = KS_TO_KEY(intkeys[4]); spkb_kbstate[ki].state = 0; } } process_keys(); } }
/** * The main render loop of the GUI */ void GUI::render() { if(m_sleeping) { // process_keys(); return; } if(m_displaying_dialog) { if(m_dialog_buzz) buzzer_nonblocking_buzz(1); return; } if(m_displaying_dialog_complete) { m_displaying_dialog_complete=false; m_pause_display_updates = false; display_clear(0); clear_pending_keys(); redraw(); } if(m_repeating) { // This would be better incremented in a timer, but I don't want to use another timer. if(m_repeat_time == m_repeat_delay) { // verify button still pressed if(cap_ispressed(m_repeat_key) == false) { m_repeating=false; m_repeat_time=0; } else { if(m_repeat_key == KEY_DOWN) { receive_key(KEY_DOWN,KEY_PRESSED); } if(m_repeat_key == KEY_UP ) { receive_key(KEY_UP ,KEY_PRESSED); } m_repeat_time = 0; m_repeated = true; } } m_repeat_time++; } // following two items really need to be atomic... int32_t cscreen = current_screen; if(clear_next_render) { clear_next_render=false; clear_screen(clear_screen_screen,clear_screen_selected); first_render=true; } bool do_redraw = false; if(m_redraw) do_redraw = true; m_redraw = false; render_lock(m_screen_lock); for(int32_t n=0;n<screens_layout[cscreen].item_count;n++) { if(first_render) { if(screens_layout[current_screen].items[n].type == ITEM_TYPE_ACTION) { receive_gui_events.receive_gui_event(screens_layout[cscreen].items[n].text, screens_layout[cscreen].items[n].text); } } //bool selected = false; bool select_render = false; if(n == selected_item ) select_render = true; if(n == last_selected_item) select_render = true; if(first_render || select_render || do_redraw) { //bool do_render = true; // don't render labels, just because they are near other things... //if(!first_render && select_render && (screens_layout[cscreen].items[n].type == ITEM_TYPE_LABEL)) { // do_render = false; //} //if(do_render) bool selected = false; if(selected_item == n) selected=true; render_item(screens_layout[cscreen].items[n],selected); } } //last_selected_item = selected_item; first_render=false; process_keys(); }
MDS_DATA ButtonMsgProc(void *obj, int message, MDS_DATA extra_data) { Button *button = (Button *)obj; if (!button->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 if (extra_data.integer == -1) { int i; for (i = 0; i < button->size.y; ++i) { con_gotoXY(button->pos.x, button->pos.y + i); con_outTxt("%*s", button->size.x, ""); } } else { char borders[5]; char *buf = (char *)malloc(button->size.x-2 + 1); if (buf == NULL) return NULL_DATA; // border format: // 02222221 // 3 text 3 // 12222220 if (button->active) strcpy(borders, " --"); else strcpy(borders, "/\\-|"); memset(buf, borders[2], button->size.x-2); buf[button->size.x-2] = '\0'; con_gotoXY(button->pos.x, button->pos.y); con_outTxt("%c%s%c", borders[0], buf, borders[1]); con_gotoXY(button->pos.x, button->pos.y + 1); con_outTxt("%c %s %c", borders[3], button->caption, borders[3]); con_gotoXY(button->pos.x, button->pos.y + 2); con_outTxt("%c%s%c", borders[1], buf, borders[0]); free(buf); } break; case MESSAGE_MOVE: move_object((Object *)button, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)button, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: if (!process_keys((Object *)button, extra_data.integer)) if (extra_data.integer == ' ') MDS_postMessage(button->msg.receiver, button->msg.message, button->msg.extra_data, 0); break; } return NULL_DATA; }
void* rotate_thread( void *arg ) { int res; framebuffer_t *dst; framebuffer_t *frame; stream_node_t *node; // Get the argument to the thread node = (stream_node_t*)arg; // Make sure that the input buffer is valid if( node->input == NULL ) { fprintf(stderr,"sobel node must be used with a valid input buffer\n"); exit(1 ); } // Make sure that the output buffer is valid if( node->output == NULL ) { fprintf(stderr,"sobel node must be used with a valid output buffer\n"); exit(1 ); } // By default we have no frame for the destination image dst = NULL; // Run the sobel thread while( 1 ) { process_keys(); // Get an image from the input buffer frame = buffer_remove( node->input ); // Determine if we should stop processing if( frame == NULL ) break; // Create a destination image if needed if( dst == NULL ) { dst = (framebuffer_t*)malloc( sizeof(framebuffer_t) ); if( dst != NULL ) { res = framebuffer_create( dst, frame->width, frame->height ); if( res != 0 ) { free(dst); dst = NULL; } } } // Process the image if we can otherwise pass on the input image if( dst != NULL && rotate_run ) { // Perform the filter framebuffer_rotate( dst, frame ); // Place the image on the output buffer buffer_insert( node->output, dst ); // Store the current frame for use as the destination next time dst = frame; } else { // Place the image on the output buffer unmodified buffer_insert( node->output, frame ); } } // Destroy our temporary storage free( dst ); // Finish running the thread return NULL; }
void UserMain(void * pd) { int x; DWORD flag = 0; int cnt; InitializeStack(); GetDHCPAddressIfNecessary(); if (EthernetIP == 0) GetDHCPAddress(); OSChangePrio(MAIN_PRIO); EnableAutoUpdate(); #ifdef _DEBUG /* InitializeNetworkGDB_and_Wait(); */ InitializeNetworkGDB(); #endif /* note, this may not work in all cases. 1) all systems might boot at the same time 2) when they get to this point, they may not have an ip yet */ /* init our acn stack */ acn_port_protect_startup(); #if CONFIG_NSK srand(GetPreciseTime() + netx_getmyip(0)); netx_init(); netx_startup(); #endif #if CONFIG_SLP slp_init(); slp_open(); slp_active_discovery_start(); #endif #if CONFIG_RLP rlp_init(); #if CONFIG_SDT sdt_init(); /* indirectly calls sdtm_init(), rlp_init(), rlpm_init() */ sdt_startup(true); #endif #if CONFIG_DMP /* dmp_startup(); */ #endif #endif /* RLP */ CreateTasks(); x = OSChangePrio( DEBUG_TERM_PRIORITY ); if (x) { PRINTF("%s","OUCH\n"); } PRINTF("%s","Hello ACN World\n"); ioctl( 0, IOCTL_CLR | IOCTL_RX_ECHO ); /* turn sdtin echo off */ process_keys(); /* shut things down - these require the threads to continue run... */ #if CONFIG_SDT sdt_shutdown(); #endif #if CONFIG_SLP slp_close(); #endif #if CONFIG_DMP /* dmp_shutdown() */ #endif /* shut down receive thread */ OSFlagClear(&recv_flag, 1); PRINTF("%s","Waiting for task to recv to shut down.."); cnt = 0; flag = 0; while (!flag) { cnt++; if (cnt == 80) { cnt = 0; PRINTF("%s","\n"); } PRINTF("%s","."); flag = OSFlagState(&recv_flag); } /* shut down tick thread */ OSFlagClear(&tick_flag, 1); PRINTF("%s","Waiting for task to tick to shut down.."); cnt = 0; flag = 0; while (!flag) { cnt++; if (cnt == 80) { cnt = 0; PRINTF("%s","\n"); } PRINTF("%s","."); flag = OSFlagState(&tick_flag); } #if CONFIG_NSK netx_shutdown(); #endif acn_port_protect_shutdown(); slp_stats(); sdt_stats(); PRINTF("%s","========================\n"); PRINTF("%s","\nDone....\n"); while (1) { OSTimeDly(20); } }