2007-05-30 21:56:52 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
2004-01-26 08:20:26 +00:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2005-10-18 01:30:26 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2004-01-26 08:20:26 +00:00
*
2006-02-11 12:47:47 +00:00
* $ URL $
* $ Id $
2004-01-26 08:20:26 +00:00
*
*/
# ifndef WINCE_SDL_H
# define WINCE_SDL_H
# include "common/scummsys.h"
# include "common/system.h"
2006-06-06 19:31:49 +00:00
# include "graphics/scaler.h"
2007-09-26 19:12:17 +00:00
# include "backends/platform/sdl/sdl.h"
2004-01-26 08:20:26 +00:00
2006-10-08 18:15:18 +00:00
# include "CEGUI.h"
# include "CEKeys.h"
2004-01-26 08:20:26 +00:00
# include "CEDevice.h"
# include "CEScaler.h"
# include <SDL.h>
2004-12-23 01:15:27 +00:00
# define TOTAL_ZONES 3
2006-10-10 15:15:00 +00:00
// defines used for implementing the raw frame buffer access method (2003+)
# define GETRAWFRAMEBUFFER 0x00020001
# define FORMAT_565 1
# define FORMAT_555 2
# define FORMAT_OTHER 3
# if defined(_WIN32_WCE) && _WIN32_WCE <= 300
typedef struct _RawFrameBufferInfo
{
WORD wFormat ;
WORD wBPP ;
VOID * pFramePointer ;
int cxStride ;
int cyStride ;
int cxPixels ;
int cyPixels ;
} RawFrameBufferInfo ;
# endif
2004-03-28 20:31:18 +00:00
class OSystem_WINCE3 : public OSystem_SDL {
2004-01-26 08:20:26 +00:00
public :
OSystem_WINCE3 ( ) ;
// Update the dirty areas of the screen
2004-03-28 20:31:18 +00:00
void internUpdateScreen ( ) ;
2004-01-26 08:20:26 +00:00
2009-01-04 16:07:19 +00:00
void setGraphicsModeIntern ( ) ;
2009-08-21 22:29:28 +00:00
void initSize ( uint w , uint h , const Graphics : : PixelFormat * format ) ;
2006-06-06 19:31:49 +00:00
void initBackend ( ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend (toolbar handling)
2007-03-17 19:02:05 +00:00
bool pollEvent ( Common : : Event & event ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend (toolbar handling)
2004-12-11 00:41:31 +00:00
void drawMouse ( ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend (mouse and new scaler handling)
2007-03-17 19:02:05 +00:00
void fillMouseEvent ( Common : : Event & event , int x , int y ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend (new scaler handling)
2005-03-16 22:27:11 +00:00
void addDirtyRect ( int x , int y , int w , int h , bool mouseRect = false ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend (new scaler handling)
2004-03-28 16:30:50 +00:00
void warpMouse ( int x , int y ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend
2004-01-26 08:20:26 +00:00
void quit ( ) ;
2008-12-18 08:06:08 +00:00
// Overloaded from SDL backend (master volume and sample rate subtleties)
2008-06-28 15:28:29 +00:00
void setupMixer ( ) ;
2006-11-12 11:47:43 +00:00
// Overloaded from OSystem
2009-07-12 15:59:27 +00:00
void engineInit ( ) ;
2009-10-08 19:41:38 +00:00
void getTimeAndDate ( TimeDate & t ) const ;
2009-01-23 03:30:40 +00:00
virtual Common : : SeekableReadStream * createConfigReadStream ( ) ;
virtual Common : : WriteStream * createConfigWriteStream ( ) ;
2008-12-18 08:06:08 +00:00
2004-01-26 08:20:26 +00:00
2005-10-16 22:52:46 +00:00
// Overloaded from SDL_Common (FIXME)
2009-09-28 07:21:56 +00:00
void setMouseCursor ( const byte * buf , uint w , uint h , int hotspot_x , int hotspot_y , uint32 keycolor , int cursorTargetScale , const Graphics : : PixelFormat * format ) ; // overloaded by CE backend
2005-10-16 22:52:46 +00:00
void undrawMouse ( ) ;
void blitCursor ( ) ;
2009-08-06 18:05:50 +00:00
bool showMouse ( bool visible ) ;
2005-10-16 22:52:46 +00:00
void setMousePos ( int x , int y ) ;
2006-11-12 11:47:43 +00:00
void copyRectToScreen ( const byte * src , int pitch , int x , int y , int w , int h ) ; // overloaded by CE backend (FIXME)
2005-10-16 22:52:46 +00:00
void copyRectToOverlay ( const OverlayColor * buf , int pitch , int x , int y , int w , int h ) ;
void showOverlay ( ) ;
void hideOverlay ( ) ;
2007-06-19 22:39:59 +00:00
Graphics : : Surface * lockScreen ( ) ;
void unlockScreen ( ) ;
2005-10-16 22:52:46 +00:00
2004-01-26 08:20:26 +00:00
// GUI and action stuff
void swap_panel_visibility ( ) ;
void swap_panel ( ) ;
void swap_sound_master ( ) ;
2004-12-21 00:31:58 +00:00
void add_right_click ( bool pushed ) ;
2004-01-26 08:20:26 +00:00
void swap_mouse_visibility ( ) ;
void swap_freeLook ( ) ;
2004-05-09 15:02:10 +00:00
void swap_zoom_up ( ) ;
void swap_zoom_down ( ) ;
2006-06-10 11:16:43 +00:00
void swap_smartphone_keyboard ( ) ;
2004-05-09 15:02:10 +00:00
2004-12-21 00:31:58 +00:00
//#ifdef WIN32_PLATFORM_WFSP
2004-05-09 15:02:10 +00:00
// Smartphone actions
2005-03-15 09:43:38 +00:00
2004-12-23 01:15:27 +00:00
void initZones ( ) ;
2006-06-10 11:16:43 +00:00
void loadDeviceConfigurationElement ( String element , int & value , int defaultValue ) ;
void loadDeviceConfiguration ( ) ;
2004-12-21 00:31:58 +00:00
void add_left_click ( bool pushed ) ;
2004-05-09 15:02:10 +00:00
void move_cursor_up ( ) ;
void move_cursor_down ( ) ;
void move_cursor_left ( ) ;
void move_cursor_right ( ) ;
void switch_zone ( ) ;
2006-06-10 11:16:43 +00:00
void smartphone_rotate_display ( ) ;
2004-12-21 00:31:58 +00:00
//#endif
2004-05-09 15:02:10 +00:00
2004-05-30 13:24:51 +00:00
static int getScreenWidth ( ) ;
static int getScreenHeight ( ) ;
static void initScreenInfos ( ) ;
static bool isOzone ( ) ;
2004-01-26 08:20:26 +00:00
protected :
2008-12-04 08:10:32 +00:00
bool loadGFXMode ( ) ;
2004-12-11 00:41:31 +00:00
void unloadGFXMode ( ) ;
2008-12-04 08:10:32 +00:00
bool hotswapGFXMode ( ) ;
2004-12-11 00:41:31 +00:00
bool saveScreenshot ( const char * filename ) ;
2004-01-26 08:20:26 +00:00
2005-07-30 21:11:48 +00:00
const GraphicsMode * getSupportedGraphicsModes ( ) const ;
2004-05-09 15:02:10 +00:00
bool setGraphicsMode ( int mode ) ;
2005-07-30 21:11:48 +00:00
//int getGraphicsMode() const;
2004-05-09 15:02:10 +00:00
int getDefaultGraphicsMode ( ) const ;
2004-01-26 08:20:26 +00:00
2004-05-09 15:02:10 +00:00
bool openCD ( int drive ) ;
int getOutputSampleRate ( ) const ;
2004-01-26 08:20:26 +00:00
2004-05-09 15:02:10 +00:00
bool hasFeature ( Feature f ) ;
void setFeatureState ( Feature f , bool enable ) ;
bool getFeatureState ( Feature f ) ;
2004-01-26 08:20:26 +00:00
2005-10-16 22:52:46 +00:00
void internDrawMouse ( ) ;
2006-06-10 11:16:43 +00:00
void drawToolbarMouse ( SDL_Surface * surf , bool draw ) ;
2005-10-16 22:52:46 +00:00
2004-01-26 08:20:26 +00:00
private :
2004-01-26 22:38:08 +00:00
# ifdef USE_VORBIS
bool checkOggHighSampleRate ( ) ;
# endif
2004-01-26 08:20:26 +00:00
static void private_sound_proc ( void * param , byte * buf , int len ) ;
2004-05-09 15:02:10 +00:00
bool update_scalers ( ) ;
2004-01-26 08:20:26 +00:00
void create_toolbar ( ) ;
void update_game_settings ( ) ;
2004-01-28 01:12:48 +00:00
void check_mappings ( ) ;
2008-06-28 15:28:29 +00:00
void compute_sample_rate ( ) ;
2004-01-26 08:20:26 +00:00
2004-05-09 15:02:10 +00:00
void retrieve_mouse_location ( int & x , int & y ) ;
2004-01-26 08:20:26 +00:00
CEGUI : : ToolbarHandler _toolbarHandler ;
2004-01-28 01:12:48 +00:00
SDL_Surface * _toolbarLow ; // toolbar 320x40
2006-11-12 21:06:56 +00:00
SDL_Surface * _toolbarHigh ; // toolbar 640x80
2004-01-28 01:12:48 +00:00
bool _toolbarHighDrawn ; // cache toolbar 640x80
2006-11-12 21:06:56 +00:00
uint16 _sampleRate ; // current audio sample rate
2004-01-26 22:38:08 +00:00
2006-11-12 21:06:56 +00:00
bool _freeLook ; // freeLook mode (do not send mouse button events)
2004-01-26 08:20:26 +00:00
bool _forceHideMouse ; // force invisible mouse cursor
2006-11-12 21:06:56 +00:00
bool _forcePanelInvisible ; // force panel visibility for some cases
bool _panelVisible ; // panel visibility
2004-01-26 08:20:26 +00:00
bool _panelStateForced ; // panel visibility forced by external call
2005-07-30 21:11:48 +00:00
2004-01-26 08:20:26 +00:00
bool _panelInitialized ; // only initialize the toolbar once
2007-06-03 19:29:13 +00:00
bool _unfilteredkeys ; // discard key mapping temporarily (agi pred. dialog)
2004-01-26 08:20:26 +00:00
static bool _soundMaster ; // turn off sound after all calculations
// static since needed by the SDL callback
2006-06-10 11:16:43 +00:00
int _orientationLandscape ; // current orientation
int _newOrientation ; // new orientation
2004-01-26 08:20:26 +00:00
bool _saveToolbarState ; // save visibility when forced
String _saveActiveToolbar ; // save active toolbar when forced
2005-07-30 21:11:48 +00:00
bool _saveToolbarZoom ; // save visibility when zooming
2006-11-12 21:06:56 +00:00
bool _zoomUp ; // zooming up mode
bool _zoomDown ; // zooming down mode
2004-05-09 15:02:10 +00:00
2009-01-01 15:06:43 +00:00
bool _noDoubleTapRMB ; // disable double tap -> rmb click
2006-11-12 21:06:56 +00:00
bool _rbutton ; // double tap -> right button simulation
2007-12-16 20:21:19 +00:00
bool _closeClick ; // flag when taps are spatially close together
2006-06-10 11:16:43 +00:00
bool _usesEmulatedMouse ; // emulated mousemove ever been used in this session
2009-03-01 22:13:48 +00:00
bool _canBeAspectScaled ; // game screen size allows for aspect scaling
2006-11-12 21:06:56 +00:00
int _scaleFactorXm ; // scaler X *
int _scaleFactorXd ; // scaler X /
int _scaleFactorYm ; // scaler Y *
int _scaleFactorYd ; // scaler Y /
2007-04-28 22:37:42 +00:00
SDL_Rect _dirtyRectOut [ NUM_DIRTY_RECT ] ;
2005-07-30 21:11:48 +00:00
bool _scalersChanged ;
2007-04-28 17:42:12 +00:00
bool _hasfocus ; // scummvm has the top window
2004-05-30 13:24:51 +00:00
static int _platformScreenWidth ;
static int _platformScreenHeight ;
2005-07-30 21:11:48 +00:00
static bool _isOzone ; // true if running on Windows 2003 SE
2004-12-21 00:31:58 +00:00
2005-10-16 22:52:46 +00:00
// Keyboard tap
int _tapX ;
int _tapY ;
long _tapTime ;
// Mouse
2006-06-06 19:31:49 +00:00
int _mouseHotspotX , _mouseHotspotY ;
2005-10-16 22:52:46 +00:00
byte * _mouseBackupOld ;
2006-06-10 11:16:43 +00:00
uint16 * _mouseBackupToolbar ;
2007-02-12 17:25:36 +00:00
uint16 _mouseBackupDim ;
2005-10-16 22:52:46 +00:00
2004-12-21 00:31:58 +00:00
// Smartphone specific variables
2006-11-12 21:06:56 +00:00
int _lastKeyPressed ; // last key pressed
2004-12-21 00:31:58 +00:00
int _keyRepeat ; // number of time the last key was repeated
int _keyRepeatTime ; // elapsed time since the key was pressed
2006-11-12 21:06:56 +00:00
int _keyRepeatTrigger ; // minimum time to consider the key was repeated
2004-12-21 00:31:58 +00:00
int _repeatX ; // repeat trigger for left and right cursor moves
int _repeatY ; // repeat trigger for up and down cursor moves
int _stepX1 ; // offset for left and right cursor moves (slowest)
int _stepX2 ; // offset for left and right cursor moves (faster)
int _stepX3 ; // offset for left and right cursor moves (fastest)
int _stepY1 ; // offset for up and down cursor moves (slowest)
int _stepY2 ; // offset for up and down cursor moves (faster)
int _stepY3 ; // offset for up and down cursor moves (fastest)
2004-12-23 01:15:27 +00:00
int _mouseXZone [ TOTAL_ZONES ] ;
int _mouseYZone [ TOTAL_ZONES ] ;
int _currentZone ;
typedef struct zoneDesc {
2005-03-15 09:43:38 +00:00
int x ;
int y ;
int width ;
int height ;
2004-12-23 01:15:27 +00:00
} zoneDesc ;
static zoneDesc _zones [ TOTAL_ZONES ] ;
2004-01-26 08:20:26 +00:00
} ;
2004-05-30 13:30:29 +00:00
# endif