Commit 18a6d284adf2d2aacca902ad683c94389e447b15
1 parent
ada89ce6
enabled wheel mouse support (initial patch by Volker Ruppert)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1229 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
13 additions
and
12 deletions
sdl.c
@@ -279,9 +279,9 @@ static void sdl_grab_end(void) | @@ -279,9 +279,9 @@ static void sdl_grab_end(void) | ||
279 | sdl_update_caption(); | 279 | sdl_update_caption(); |
280 | } | 280 | } |
281 | 281 | ||
282 | -static void sdl_send_mouse_event(void) | 282 | +static void sdl_send_mouse_event(int dz) |
283 | { | 283 | { |
284 | - int dx, dy, dz, state, buttons; | 284 | + int dx, dy, state, buttons; |
285 | state = SDL_GetRelativeMouseState(&dx, &dy); | 285 | state = SDL_GetRelativeMouseState(&dx, &dy); |
286 | buttons = 0; | 286 | buttons = 0; |
287 | if (state & SDL_BUTTON(SDL_BUTTON_LEFT)) | 287 | if (state & SDL_BUTTON(SDL_BUTTON_LEFT)) |
@@ -290,14 +290,6 @@ static void sdl_send_mouse_event(void) | @@ -290,14 +290,6 @@ static void sdl_send_mouse_event(void) | ||
290 | buttons |= MOUSE_EVENT_RBUTTON; | 290 | buttons |= MOUSE_EVENT_RBUTTON; |
291 | if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) | 291 | if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) |
292 | buttons |= MOUSE_EVENT_MBUTTON; | 292 | buttons |= MOUSE_EVENT_MBUTTON; |
293 | - /* XXX: test wheel */ | ||
294 | - dz = 0; | ||
295 | -#ifdef SDL_BUTTON_WHEELUP | ||
296 | - if (state & SDL_BUTTON(SDL_BUTTON_WHEELUP)) | ||
297 | - dz--; | ||
298 | - if (state & SDL_BUTTON(SDL_BUTTON_WHEELDOWN)) | ||
299 | - dz++; | ||
300 | -#endif | ||
301 | kbd_mouse_event(dx, dy, dz, buttons); | 293 | kbd_mouse_event(dx, dy, dz, buttons); |
302 | } | 294 | } |
303 | 295 | ||
@@ -426,7 +418,7 @@ static void sdl_refresh(DisplayState *ds) | @@ -426,7 +418,7 @@ static void sdl_refresh(DisplayState *ds) | ||
426 | break; | 418 | break; |
427 | case SDL_MOUSEMOTION: | 419 | case SDL_MOUSEMOTION: |
428 | if (gui_grab) { | 420 | if (gui_grab) { |
429 | - sdl_send_mouse_event(); | 421 | + sdl_send_mouse_event(0); |
430 | } | 422 | } |
431 | break; | 423 | break; |
432 | case SDL_MOUSEBUTTONDOWN: | 424 | case SDL_MOUSEBUTTONDOWN: |
@@ -440,7 +432,16 @@ static void sdl_refresh(DisplayState *ds) | @@ -440,7 +432,16 @@ static void sdl_refresh(DisplayState *ds) | ||
440 | sdl_grab_start(); | 432 | sdl_grab_start(); |
441 | } | 433 | } |
442 | } else { | 434 | } else { |
443 | - sdl_send_mouse_event(); | 435 | + int dz; |
436 | + dz = 0; | ||
437 | +#ifdef SDL_BUTTON_WHEELUP | ||
438 | + if (bev->button == SDL_BUTTON_WHEELUP) { | ||
439 | + dz = -1; | ||
440 | + } else if (bev->button == SDL_BUTTON_WHEELDOWN) { | ||
441 | + dz = 1; | ||
442 | + } | ||
443 | +#endif | ||
444 | + sdl_send_mouse_event(dz); | ||
444 | } | 445 | } |
445 | } | 446 | } |
446 | break; | 447 | break; |