00001 /* 00002 ParaGUI - crossplatform widgetset 00003 Copyright (C) 2000,2001,2002 Alexander Pipelka 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 Alexander Pipelka 00020 pipelka@teleweb.at 00021 00022 Last Update: $Author: mbickel $ 00023 Update Date: $Date: 2007-04-13 16:16:00 $ 00024 Source File: $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/src/core/pgsdleventsupplier.cpp,v $ 00025 CVS/RCS Revision: $Revision: 1.2 $ 00026 Status: $State: Exp $ 00027 */ 00028 00029 #include "SDL.h" 00030 00031 #include "pgsdleventsupplier.h" 00032 00033 void PG_SDLEventSupplier::CombineMouseMotionEvents(SDL_Event* event) { 00034 if ( event->type == SDL_MOUSEMOTION ) { 00035 SDL_Event nextEvent; 00036 if ( PeepEvent ( &nextEvent ) ) 00037 if ( nextEvent.type == SDL_MOUSEMOTION ) { 00038 int motionxrel = event->motion.xrel; 00039 int motionyrel = event->motion.yrel; 00040 00041 // get the event from the queue 00042 WaitEvent( event ); 00043 00044 // add the motion distances of the last event 00045 event->motion.xrel += motionxrel; 00046 event->motion.yrel += motionyrel; 00047 } 00048 } 00049 } 00050 00051 bool PG_SDLEventSupplier::PeepEvent(SDL_Event* event) { 00052 return SDL_PeepEvents( event, 1, SDL_PEEKEVENT, 0xffffffff ); 00053 } 00054 00055 00056 bool PG_SDLEventSupplier::PollEvent(SDL_Event* event) { 00057 bool eventAvail = SDL_PollEvent( event ); 00058 if ( eventAvail ) 00059 CombineMouseMotionEvents( event ); 00060 return eventAvail; 00061 } 00062 00063 00064 int PG_SDLEventSupplier::WaitEvent(SDL_Event* event) { 00065 int res = SDL_WaitEvent( event ); 00066 CombineMouseMotionEvents( event ); 00067 return res; 00068 } 00069 00070 int PG_SDLEventSupplier::GetMouseState(int& x, int& y) { 00071 return SDL_GetMouseState(&x, &y); 00072 }
1.4.2