#include #include #include "global.h" #include "elwindows.h" #include "keys.h" #include "update.h" #ifndef WINDOWS #include #endif int adding_mark = 0; int mark_x , mark_y; int max_mark = 0; marking marks[200]; int mod_key_status; //Uint32 last_turn_around=0; int shift_on; int alt_on; int ctrl_on; int meta_on; void quick_use(int use_id) { Uint8 quick_use_str[3]; int i; for(i=0; itype == SDL_NOEVENT) return 0; mod_key_status = SDL_GetModState(); if (mod_key_status & KMOD_SHIFT) shift_on = 1; else shift_on = 0; if (mod_key_status & KMOD_ALT && !(mod_key_status & KMOD_MODE)) alt_on = 1; else alt_on = 0; if (mod_key_status & KMOD_CTRL) ctrl_on = 1; else ctrl_on = 0; if (mod_key_status & KMOD_META) meta_on = 1; else meta_on = 0; switch( event->type ) { #if !defined(WINDOWS) && !defined(OSX) case SDL_SYSWMEVENT: if(event->syswm.msg->event.xevent.type == SelectionNotify) finishpaste(event->syswm.msg->event.xevent.xselection); break; #endif case SDL_KEYDOWN: if(!(SDL_GetAppState() & SDL_APPINPUTFOCUS)){ break; //don't have focus, so we shouldn't be getting keystrokes } key=(Uint16)event->key.keysym.sym; //use the modifiers that were on when the key was pressed, not when we go to check if (event->key.keysym.mod & KMOD_SHIFT) key |= ELW_SHIFT; if (event->key.keysym.mod & KMOD_CTRL) key |= ELW_CTRL; if (event->key.keysym.mod & KMOD_ALT && !(event->key.keysym.mod & KMOD_MODE)) key |= ELW_ALT; //if (event->key.keysym.mod & KMOD_META) key |= ELW_something_if_needed_later; if (afk_time) last_action_time = cur_time; // Set the latest event... Don't let the modifiers ALT, CTRL and SHIFT change the state keypress_in_windows (mouse_x, mouse_y, key, event->key.keysym.unicode); break; case SDL_VIDEORESIZE: window_width = event->resize.w; window_height = event->resize.h; resize_root_window (); break; case SDL_QUIT: done = 1; break; case SDL_ACTIVEEVENT: SDL_SetModState(KMOD_NONE); // force ALL keys up, else you can 'catch' the alt/ctrl keys due to an SDL bug break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: // make sure the mouse button is our window, or else we ignore it if(event->button.x >= window_width || event->button.y >= window_height || !(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { break; } if (afk_time) last_action_time = cur_time; // Set the latest events - don't make mousemotion set the afk_time... (if you prefer that mouse motion sets/resets the afk_time, then move this one step below... case SDL_MOUSEMOTION: if(event->type==SDL_MOUSEMOTION) { mouse_x= event->motion.x; mouse_y= event->motion.y; mouse_delta_x= event->motion.xrel; mouse_delta_y= event->motion.yrel; } else { mouse_x= event->button.x; mouse_y= event->button.y; mouse_delta_x= mouse_delta_y= 0; } if (event->type == SDL_MOUSEBUTTONDOWN) { if(event->button.button==SDL_BUTTON_LEFT) left_click++; } else if (event->type == SDL_MOUSEMOTION && (event->motion.state & SDL_BUTTON(SDL_BUTTON_LEFT))) left_click++; else { if (left_click) end_drag_windows(); left_click = 0; } if (event->type == SDL_MOUSEBUTTONDOWN) { if (event->button.button == SDL_BUTTON_RIGHT) right_click++; } else if (event->type == SDL_MOUSEMOTION && (event->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT))) right_click++; else right_click= 0; if (event->type == SDL_MOUSEBUTTONDOWN) { if (event->button.button == SDL_BUTTON_MIDDLE) middle_click++; } else if (event->type == SDL_MOUSEMOTION && (event->motion.state & (SDL_BUTTON(SDL_BUTTON_MIDDLE) || meta_on))) middle_click++; else middle_click= 0; if ( SDL_GetMouseState (NULL, NULL) & SDL_BUTTON(2) ) { camera_rotation_speed = normal_camera_rotation_speed * mouse_delta_x / 220; camera_rotation_frames = 40; camera_tilt_speed = normal_camera_rotation_speed * mouse_delta_y / 220; camera_tilt_frames = 40; } if (shift_on) flags |= ELW_SHIFT; if (alt_on) flags |= ELW_ALT; if (ctrl_on) flags |= ELW_CTRL; if (left_click) flags |= ELW_LEFT_MOUSE; if (middle_click || meta_on) flags |= ELW_MID_MOUSE; if (right_click) flags |= ELW_RIGHT_MOUSE; if (event->type == SDL_MOUSEBUTTONDOWN) { if (event->button.button == SDL_BUTTON_WHEELUP) flags |= ELW_WHEEL_UP; else if (event->button.button == SDL_BUTTON_WHEELDOWN) flags |= ELW_WHEEL_DOWN; } if (left_click >= 1) { if (drag_windows (mouse_x, mouse_y, mouse_delta_x, mouse_delta_y) >= 0) return done; if (drag_in_windows (mouse_x, mouse_y, flags, mouse_delta_x, mouse_delta_y) >= 0) return done; } if ( left_click==1 || right_click==1 || (flags & (ELW_WHEEL_UP | ELW_WHEEL_DOWN) ) ) click_in_windows (mouse_x, mouse_y, flags); break; case SDL_USEREVENT: switch(event->user.code){ case EVENT_MOVEMENT_TIMER: pf_move(); break; case EVENT_UPDATE_CAMERA: update_camera(); break; case EVENT_ANIMATE_ACTORS: animate_actors(); break; case EVENT_UPDATE_PARTICLES: update_particles(); break; case EVENT_UPDATES_DOWNLOADED: handle_update_download((struct http_get_struct *)event->user.data1); break; case EVENT_DOWNLOAD_COMPLETE: handle_file_download((struct http_get_struct *)event->user.data1); break; } } return(done); }