void onMouseUp(int button, int x, int y){ flush_keys(); evt.d = 0; evt.buttons &= ~(1<<button); if(evt.pressx == evt.x && evt.pressy == evt.y && evt.pressb == button){ //printf("xdotool mousemove -sync %d %d click %d\n",evt.x, evt.y, button); //evt.clickx = evt.x; evt.clicky = evt.y; evt.clickb = button; evt.pressb = 0; if(evt.clickb == button){ // multiple click same button evt.clickn++; //printf("DEBUG: click +1\n"); }else{ // multiple click different button flushMouse(); evt.clickb = button; evt.clickn = 1; //printf("DEBUG: click =1\n"); } } else { // move and release flushMouse(); //printf("xdotool mousemove -sync %d %d mousedown %d\n", evt.pressx, evt.pressy, evt.pressb); printf("xdotool mousemove -sync %d %d mouseup %d\n", evt.x, evt.y, button); evt.pressb = 0; } //printf("xdotool mousemove -sync %d %d mouseup %d\n",evt.x, evt.y, button); //printf("xdotool mouseup %d\n",button); }
void onMouseMove(int x, int y){ flush_keys(); flushMouse(); if(evt.buttons){ if(evt.d > 13){ //printf("xdotool mousemove -sync %d %d\n",x,y); printf("xdotool mousemove %d %d\n",x,y); evt.d = 0; } } }
void keystroke(KeyCode kc,bool is_pressed){ if(evt.delay > 2000) { flush_keys(); } KeySym ks = XKeycodeToKeysym(disp, kc, 0); if(is_pressed){ // keystack.push_back(kc); if(ks == XK_Shift_L || ks == XK_Shift_R) { evt.hasShift = true; } //printf("keydown %s\n",kchar); }else{ char c; if(ks == XK_Shift_L || ks == XK_Shift_R) { evt.hasShift = false; }else if((c = KeyCode2Char(kc)) != '\0'){ switch(c){ case '\n': keychars += "\\n"; flush_keys(); printf("xdotool key Return\n"); break; case '\t': keychars += "\\t"; flush_keys(); printf("xdotool key Tab\n"); break; default: keychars += c; } }else{ const char *kchar = XKeysymToString(ks); flush_keys(); printf("xdotool keyup %s\n",kchar); } } }
void main() { load_library("/lib/core"); get_lcd_lock(); get_keypad_lock(); screen = screen_allocate(); flush_keys(); main_menu(); initialize(); game_running = true; while (1) { draw(); update(); } }
int last_stage_init(void) { #ifndef CONFIG_SPL_BUILD ccdc_eth_init(); #endif if (tpm_init() || tpm_startup(TPM_ST_CLEAR) || tpm_continue_self_test()) { return 1; } mdelay(37); flush_keys(); load_and_run_keyprog(); return 0; }
// TODO: use a FIFO ??? void onMouseDown(int button, int x, int y){ flush_keys(); evt.d = 0; // reset mouse move distance if(1 && evt.w > 0){ int wx, wy; getMousePosRelativeWindow(evt.x,evt.y,evt.w,wx,wy); std::cout<<"Relative to Window "<<evt.w<<" @ ("<<wx<<','<<wy<<")"<<std::endl; } evt.buttons |= (1<<button); if(evt.pressb != 0 || (evt.clickb!=0 && evt.clickb != button)){ flushMouse(); //printf("DEBUG: flush\n"); //-- printf("xdotool mousemove -sync %d %d mousedown %d\n", evt.pressx, evt.pressy, evt.pressb); } evt.pressx = evt.x; evt.pressy = evt.y; evt.pressb = button; // evt.pressn = 0; // printf("xdotool mousemove -sync %d %d mousedown %d\n",evt.x, evt.y, button); // printf("xdotool mousedown %d\n",button); }
int main(int argc, char * argv[]) { input_init(); std::string path_to_exe(""); { std::string path_with_exe(argv[0]); unsigned found = path_with_exe.find_last_of("/\\"); path_to_exe = path_with_exe.substr(0,found+1); } std::cout<<path_to_exe<<std::endl; SDL_Init( SDL_INIT_EVERYTHING ); TTF_Init(); SDL_Surface * screen = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE); GUI_Init(screen); { std::string font_path(path_to_exe); font_path += "freefont/FreeMono.ttf"; GUI_standard_font = TTF_OpenFont( font_path.c_str(), 15 ); } std::cout<<"fontptr: "<<GUI_standard_font<<std::endl; Area * screen_widget = new Area(0, 0, 640, 480); Area * test_widget = new Area(20, 20, 200, 200, screen_widget); test_widget->set_colour(200, 100, 100); Area * another_test_widget = new Area(240, 20, 200, 200, screen_widget); another_test_widget->set_colour(100, 200, 100); Area * ultra_test_widget = new Area(20, 20, 160, 160, another_test_widget); ultra_test_widget->set_colour(100, 100, 200); Label * test_label = new Label(10, 10, 140, 20, ultra_test_widget); test_label->set_colour(120, 120, 220); test_label->set_text("Hallo Welt!"); Button * test_button = new Button(10, 40, 120, 20, ultra_test_widget); test_button->set_colour(100, 200, 200); test_button->set_text("Test!"); Button * end_button = new Button(20, 240, 120, 20, screen_widget); end_button->set_colour(255, 0, 0); end_button->set_text("Ende!"); Text_Edit * text_edit = new Text_Edit(20, 280, 160, 20, screen_widget); text_edit->set_text("aender mich!"); input_update(); while(!key_hit(SDLK_ESCAPE) && !end_button->released)// && !mouse_hit(1)) { SDL_Surface * screen_surface = screen_widget->get_sdl_surface(); SDL_BlitSurface(screen_surface, NULL, screen, NULL); screen_widget->update(); if(test_button->released) { test_label->set_text("Button geklickt!"); } SDL_Flip(screen); flush_keys(); flush_mouse(); SDL_Delay(1000/60); input_update(); } //SDL_Delay(2000); return 0; }