[Scummvm-cvs-logs] CVS: scummvm/backends/wince CEActionsPocket.cpp,1.3,1.4 CEActionsSmartphone.cpp,1.2,1.3 wince-sdl.cpp,1.18,1.19 wince-sdl.h,1.12,1.13

Nicolas Bacca arisme at users.sourceforge.net
Mon Dec 20 16:33:01 CET 2004


Update of /cvsroot/scummvm/scummvm/backends/wince
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8412

Modified Files:
	CEActionsPocket.cpp CEActionsSmartphone.cpp wince-sdl.cpp 
	wince-sdl.h 
Log Message:
Cleanup mouseclick emulation (and make the new about dialog happy)

Index: CEActionsPocket.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/CEActionsPocket.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CEActionsPocket.cpp	20 Dec 2004 23:52:16 -0000	1.3
+++ CEActionsPocket.cpp	21 Dec 2004 00:31:58 -0000	1.4
@@ -160,8 +160,14 @@
 }
 
 bool CEActionsPocket::perform(ActionType action, bool pushed) {
-	if (!pushed)
+	if (!pushed) {
+		switch(action) {
+			case POCKET_ACTION_RIGHTCLICK:
+				_mainSystem->add_right_click(false);
+				return true;
+		}
 		return false;
+	}
 
 	switch (action) {
 		case POCKET_ACTION_PAUSE:
@@ -179,7 +185,7 @@
 			_mainSystem->swap_sound_master();
 			return true;
 		case POCKET_ACTION_RIGHTCLICK:
-			_mainSystem->add_right_click();
+			_mainSystem->add_right_click(true);
 			return true;
 		case POCKET_ACTION_CURSOR:
 			_mainSystem->swap_mouse_visibility();

Index: CEActionsSmartphone.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/CEActionsSmartphone.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CEActionsSmartphone.cpp	20 Dec 2004 23:52:16 -0000	1.2
+++ CEActionsSmartphone.cpp	21 Dec 2004 00:31:58 -0000	1.3
@@ -146,6 +146,14 @@
 
 bool CEActionsSmartphone::perform(ActionType action, bool pushed) {
 	if (!pushed) {
+		switch (action) {
+			case SMARTPHONE_ACTION_RIGHTCLICK:
+				_mainSystem->add_right_click(false);
+				return true;
+			case SMARTPHONE_ACTION_LEFTCLICK:
+				_mainSystem->add_left_click(false);
+				return true;
+		}
 		return false;
 	}
 
@@ -155,10 +163,10 @@
 			EventsBuffer::simulateKey(&_key_action[action]);
 			return true;
 		case SMARTPHONE_ACTION_RIGHTCLICK:
-			_mainSystem->add_right_click();
+			_mainSystem->add_right_click(true);
 			return true;
 		case SMARTPHONE_ACTION_LEFTCLICK:
-			_mainSystem->add_left_click();
+			_mainSystem->add_left_click(true);
 			return true;
 		case SMARTPHONE_ACTION_UP:
 			_mainSystem->move_cursor_up();

Index: wince-sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/wince-sdl.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- wince-sdl.cpp	11 Dec 2004 15:18:36 -0000	1.18
+++ wince-sdl.cpp	21 Dec 2004 00:31:58 -0000	1.19
@@ -75,6 +75,8 @@
 bool OSystem_WINCE3::_soundMaster = true;
 OSystem::SoundProc OSystem_WINCE3::_originalSoundProc = NULL;
 
+bool _isSmartphone = false;
+
 // Graphics mode consts
 
 // Low end devices 240x320
@@ -106,6 +108,12 @@
 
 // ********************************************************************************************
 
+bool isSmartphone() {
+	return _isSmartphone;
+}
+
+// ********************************************************************************************
+
 // MAIN
 
 extern "C" int scummvm_main(GameDetector &gameDetector, int argc, char **argv);
@@ -113,29 +121,37 @@
 void handleException(EXCEPTION_POINTERS *exceptionPointers) {
 	CEException::writeException(TEXT("\\scummvmCrash"), exceptionPointers);
 	drawError("Unrecoverable exception occurred - see crash dump in latest \\scummvmCrash file");
-	exit(1);
+	fclose(stdout_file);
+	fclose(stderr_file);
+	CEDevice::end();
+	SDL_Quit();
+	exit(0);
 }
 
 int SDL_main(int argc, char **argv) {
+	CEDevice::init();
 	OSystem_WINCE3::initScreenInfos();
 	/* Sanity check */
-#ifndef WIN32_PLATFORM_WFSP
-	if (CEDevice::hasSmartphoneResolution()) {
-		MessageBox(NULL, TEXT("This build was not compiled with Smartphone support"), TEXT("ScummVM error"), MB_OK | MB_ICONERROR);
-		return 0;
-	}
-#endif
+//#ifndef WIN32_PLATFORM_WFSP
+//	if (CEDevice::hasSmartphoneResolution()) {
+//		MessageBox(NULL, TEXT("This build was not compiled with Smartphone support"), TEXT("ScummVM error"), MB_OK | MB_ICONERROR);
+//		return 0;
+//	}
+//#endif
 	/* Avoid print problems - this file will be put in RAM anyway */
 	stdout_file = fopen("\\scummvm_stdout.txt", "w");
 	stderr_file = fopen("\\scummvm_stderr.txt", "w");
 	CEActions::init(_gameDetector);
+
 	__try {
 		return scummvm_main(_gameDetector, argc, argv);
 	}
 	__except (handleException(GetExceptionInformation())) {
 	}
+
+	return 0;
 }    
-   
+
 // ********************************************************************************************
 
 
@@ -157,10 +173,6 @@
 	pumpMessages();
 }
 
-bool isSmartphone(void) {
-	return CEDevice::hasSmartphoneResolution();
-}
-
 // ********************************************************************************************
 
 int OSystem_WINCE3::getScreenWidth() {
@@ -199,9 +211,23 @@
 	_orientationLandscape(false), _newOrientation(false), _panelInitialized(false),
 	_panelVisible(false), _panelStateForced(false), _forceHideMouse(false),
 	_freeLook(false), _toolbarHighDrawn(false), _zoomUp(false), _zoomDown(false),
-	_scalersChanged(false)
+	_scalersChanged(false), _monkeyKeyboard(false), _lastKeyPressed(0)
 {
+	_isSmartphone = CEDevice::hasSmartphoneResolution();
+	memset(&_mouseCurState, 0, sizeof(_mouseCurState));
+	if (_isSmartphone) {
+		_mouseCurState.x = 20;
+		_mouseCurState.y = 20;
+	}
 	create_toolbar();
+	// Initialize global key mapping for Smartphones
+	CEActions::Instance()->initInstanceMain(this);	
+	CEActions::Instance()->loadMapping();
+
+	if (_isSmartphone) {
+		loadSmartphoneConfiguration();
+	}
+
 }
 
 void OSystem_WINCE3::swap_panel_visibility() {
@@ -233,10 +259,10 @@
 		_toolbarHandler.forceRedraw(); // redraw sound icon
 }
 
-void OSystem_WINCE3::add_right_click() {
+void OSystem_WINCE3::add_right_click(bool pushed) {
 	int x, y;
 	retrieve_mouse_location(x, y);
-	EventsBuffer::simulateMouseRightClick(x, y);
+	EventsBuffer::simulateMouseRightClick(x, y, pushed);
 }
 
 void OSystem_WINCE3::swap_mouse_visibility() {
@@ -311,36 +337,117 @@
 	internUpdateScreen();
 }
 
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
 // Smartphone actions
 
-void OSystem_WINCE3::add_left_click() {
-	_addLeftClickDown = true;
+void OSystem_WINCE3::loadSmartphoneConfigurationElement(String element, int &value, int defaultValue) {
+	value = ConfMan.getInt(element, "smartphone");
+	if (!value) {
+		value = defaultValue;
+		ConfMan.set(element, value, "smartphone");
+	}
+}
+
+void OSystem_WINCE3::loadSmartphoneConfiguration() {
+	loadSmartphoneConfigurationElement("repeatTrigger", _keyRepeatTrigger, 200);
+	loadSmartphoneConfigurationElement("repeatX", _repeatX, 4);
+	loadSmartphoneConfigurationElement("repeatY", _repeatY, 4);
+	loadSmartphoneConfigurationElement("stepX1", _stepX1, 2);
+	loadSmartphoneConfigurationElement("stepX2", _stepX2, 10);
+	loadSmartphoneConfigurationElement("stepX3", _stepX3, 40);
+	loadSmartphoneConfigurationElement("stepY1", _stepY1, 2);
+	loadSmartphoneConfigurationElement("stepY2", _stepY2, 10);
+	loadSmartphoneConfigurationElement("stepY3", _stepY3, 20);
+	ConfMan.flushToDisk();
+}
+
+void OSystem_WINCE3::add_left_click(bool pushed) {
+	int x, y;
+	retrieve_mouse_location(x, y);
+	EventsBuffer::simulateMouseLeftClick(x, y, pushed);
 }
 
 void OSystem_WINCE3::move_cursor_up() {
+	int x,y;
+	retrieve_mouse_location(x, y);
+	if (_keyRepeat > _repeatY)
+		y -= _stepY3;
+	else
+	if (_keyRepeat)
+		y -= _stepY2;
+	else
+		y -= _stepY1;
+
+	if (y < 0)
+		y = 0;
+
+	EventsBuffer::simulateMouseMove(x, y);
 }
 
 void OSystem_WINCE3::move_cursor_down() {
+	int x,y;
+	retrieve_mouse_location(x, y);
+	if (_keyRepeat > _repeatY)
+		y += _stepY3;
+	else
+	if (_keyRepeat)
+		y += _stepY2;
+	else
+		y += _stepY1;
+
+	if (y > 200)
+		y = 200;
+
+	EventsBuffer::simulateMouseMove(x, y);	
 }
 
 void OSystem_WINCE3::move_cursor_left() {
+	int x,y;
+	retrieve_mouse_location(x, y);
+	if (_keyRepeat > _repeatX)
+		x -= _stepX3;
+	else
+	if (_keyRepeat)
+		x -= _stepX2; 
+	else
+		x -= _stepX1;
+
+	if (x < 0)
+		x = 0;
+
+	EventsBuffer::simulateMouseMove(x, y);
 }
 
 void OSystem_WINCE3::move_cursor_right() {
+	int x,y;
+	retrieve_mouse_location(x, y);
+	if (_keyRepeat > _repeatX)
+		x += _stepX3;
+	else
+	if (_keyRepeat)
+		x += _stepX2;
+	else
+		x += _stepX1;
+
+	if (x > 320)
+		x = 320;
+
+	EventsBuffer::simulateMouseMove(x, y);
 }
 
 void OSystem_WINCE3::switch_zone() {
 }
-#endif
+//#endif
 
 
 void OSystem_WINCE3::create_toolbar() {
 	PanelKeyboard *keyboard;
 
 	// Add the keyboard
-	keyboard = new PanelKeyboard(PANEL_KEYBOARD);
-	_toolbarHandler.add(NAME_PANEL_KEYBOARD, *keyboard);
+	if (!_isSmartphone) {
+		keyboard = new PanelKeyboard(PANEL_KEYBOARD);
+		_toolbarHandler.add(NAME_PANEL_KEYBOARD, *keyboard);
+	}
 
 }
 
@@ -428,6 +535,8 @@
 		case kFeatureFullscreenMode:
 			return;
 		case kFeatureVirtualKeyboard:
+			if (_isSmartphone)
+				return;
 			_toolbarHighDrawn = false;
 			if (enable) {
 				_panelStateForced = true;
@@ -498,13 +607,7 @@
 		if (!_gameDetector._targetName.size() || CEActions::Instance()->initialized())
 			return;
 
-		CEActions::Instance()->initInstance(this);
-		// Load key mapping
-		CEActions::Instance()->loadMapping();
-
-		if (CEDevice::hasSmartphoneResolution())
-			return;
-
+		CEActions::Instance()->initInstanceGame();
 		instance = (CEActionsPocket*)CEActions::Instance();
 
 		// Some games need to map the right click button, signal it here if it wasn't done
@@ -549,6 +652,7 @@
 			GUI::MessageDialog alert("Don't forget to map a key to 'Hide Toolbar' action to see the whole inventory");
 			alert.runModal();
 		}
+
 }
 
 void OSystem_WINCE3::update_game_settings() {
@@ -566,6 +670,7 @@
 		// sound
 		panel->add(NAME_ITEM_SOUND, new ItemSwitch(ITEM_SOUND_OFF, ITEM_SOUND_ON, &_soundMaster)); 
 		// portrait/landscape - screen dependant
+		// FIXME : will still display the portrait/landscape icon when using a scaler (but will be disabled)
 		if (_screenWidth <= 320 && (isOzone() || !CEDevice::hasDesktopResolution())) {
 			_newOrientation = _orientationLandscape = (ConfMan.hasKey("landscape") ? ConfMan.getBool("landscape") : false);
 			panel->add(NAME_ITEM_ORIENTATION, new ItemSwitch(ITEM_VIEW_LANDSCAPE, ITEM_VIEW_PORTRAIT, &_newOrientation));
@@ -573,7 +678,7 @@
 		_toolbarHandler.add(NAME_MAIN_PANEL, *panel);
 		_toolbarHandler.setActive(NAME_MAIN_PANEL);
 
-		// Keyboard is active for Monkey 1 or 2
+		// Keyboard is active for Monkey 1 or 2 initial copy-protection
 		if (strncmp(_gameDetector._targetName.c_str(), "monkey", 6) == 0) {
 			_monkeyKeyboard = true;
 			_toolbarHandler.setActive(NAME_PANEL_KEYBOARD);
@@ -583,19 +688,42 @@
 			setGraphicsMode(GFX_NORMAL);
 			hotswapGFXMode();
 		}
+
+		if (_isSmartphone)
+			panel->setVisible(false);
 	}
  
 	get_sample_rate();
 }
 
 void OSystem_WINCE3::initSize(uint w, uint h) {
-	if (w == 320 && h == 200)
+
+		if (_isSmartphone && h == 240)
+			h = 200;  // mainly for the launcher
+
+        switch (_transactionMode) {
+			case kTransactionActive:
+                _transactionDetails.w = w;
+                _transactionDetails.wChanged = true;
+                _transactionDetails.h = h;
+                _transactionDetails.hChanged = true;
+                return;
+                break;
+			case kTransactionCommit:
+                break;
+			default:
+                break;
+        }
+
+	if (w == 320 && h == 200 && !_isSmartphone)
 		h = 240; // use the extra 40 pixels height for the toolbar
 
-	if (h == 240)
-		_toolbarHandler.setOffset(200);
-	else
-		_toolbarHandler.setOffset(400);	
+	if (!_isSmartphone) {
+		if (h == 240)
+			_toolbarHandler.setOffset(200);
+		else
+			_toolbarHandler.setOffset(400);	
+	}
 
 	if (w != _screenWidth || h != _screenHeight)
 		_scalersChanged = false;
@@ -649,8 +777,8 @@
 		return true;
 	}
 
-#ifdef WIN32_PLATFORM_WFSP
-	if (CEDevice::hasSmartphoneResolution()) {
+//#ifdef WIN32_PLATFORM_WFSP
+	if (_isSmartphone) {
 		if (_screenWidth > 320) 
 			error("Game resolution not supported on Smartphone");
 		_scaleFactorXm = 2;
@@ -661,12 +789,25 @@
 		_modeFlags = 0;
 		return true;
 	}
-#endif
+//#endif
 
 	return false;
 }
 
 bool OSystem_WINCE3::setGraphicsMode(int mode) {
+
+    switch (_transactionMode) {
+			case kTransactionActive:
+                _transactionDetails.mode = mode;
+                _transactionDetails.modeChanged = true;
+                return true;
+                break;
+	        case kTransactionCommit:
+                break;
+		    default:
+                break;
+    }
+
 	Common::StackLock lock(_graphicsMutex);
 	int oldScaleFactorXm = _scaleFactorXm;
 	int oldScaleFactorXd = _scaleFactorXd;
@@ -776,6 +917,7 @@
 	else
 		_scalersChanged = false;
 
+
 	return true;
 
 }
@@ -1301,6 +1443,8 @@
 	SDL_Event ev;
 	byte b = 0;
 	Event temp_event;
+	DWORD currentTime;
+	bool keyEvent = false;
 
 	memset(&temp_event, 0, sizeof(Event));
 	memset(&event, 0, sizeof(Event));
@@ -1314,9 +1458,21 @@
 		return true;
 	}
 
+	CEDevice::wakeUp();
+
+	if (isSmartphone)
+		currentTime = GetTickCount();
+
 	while(SDL_PollEvent(&ev)) {
 		switch(ev.type) {
 		case SDL_KEYDOWN:
+			if (_isSmartphone) {
+				keyEvent = true;			
+				_lastKeyPressed = ev.key.keysym.sym;
+				_keyRepeatTime = currentTime;
+				_keyRepeat = 0;
+			}
+
 			if (CEActions::Instance()->performMapped(ev.key.keysym.sym, true))
 				return true;
 
@@ -1330,6 +1486,11 @@
 			return true;
 	
 		case SDL_KEYUP:			
+			if (_isSmartphone) {
+				keyEvent = true;
+				_lastKeyPressed = 0;
+			}
+
 			if (CEActions::Instance()->performMapped(ev.key.keysym.sym, false))
 				return true;
 			
@@ -1361,7 +1522,7 @@
 			if (_toolbarHandler.action(temp_event.mouse.x, temp_event.mouse.y, true)) {
 				if (!_toolbarHandler.drawn())
 					internUpdateScreen();
-				if (_newOrientation != _orientationLandscape) {
+				if (_newOrientation != _orientationLandscape && _mode == GFX_NORMAL) {
 					_orientationLandscape = _newOrientation;
 					ConfMan.set("landscape", _orientationLandscape);
 					ConfMan.flushToDisk();
@@ -1406,6 +1567,22 @@
 			return true;
 		}
 	}
+
+	// Simulate repeated key for Smartphones
+
+	if (!keyEvent) {
+		if (_isSmartphone) {
+
+			if (_lastKeyPressed) {
+				if (currentTime > _keyRepeatTime + _keyRepeatTrigger) {
+					_keyRepeatTime = currentTime;
+					_keyRepeat++;
+					CEActions::Instance()->performMapped(_lastKeyPressed, true);
+				}
+			}
+		}
+	}
+
 	return false;
 }
 
@@ -1416,6 +1593,7 @@
 		DeleteFile(TEXT("\\scummvm_stdout.txt"));
 		DeleteFile(TEXT("\\scummvm_stderr.txt"));
 	}
+	CEDevice::end();
 	OSystem_SDL::quit();
 }
 

Index: wince-sdl.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/wince-sdl.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- wince-sdl.h	11 Dec 2004 00:41:31 -0000	1.12
+++ wince-sdl.h	21 Dec 2004 00:31:58 -0000	1.13
@@ -64,21 +64,23 @@
 	void swap_panel_visibility();
 	void swap_panel();
 	void swap_sound_master();
-	void add_right_click();
+	void add_right_click(bool pushed);
 	void swap_mouse_visibility();
 	void swap_freeLook();
 	void swap_zoom_up();
 	void swap_zoom_down();
 
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
 	// Smartphone actions
-	void add_left_click();
+	void loadSmartphoneConfigurationElement(String element, int &value, int defaultValue);
+	void loadSmartphoneConfiguration();
+	void add_left_click(bool pushed);
 	void move_cursor_up();
 	void move_cursor_down();
 	void move_cursor_left();
 	void move_cursor_right();
 	void switch_zone();
-#endif
+//#endif
 
 	static int getScreenWidth();
 	static int getScreenHeight();
@@ -154,15 +156,31 @@
 	bool _zoomUp;				// zooming up mode
 	bool _zoomDown;				// zooming down mode
 
-	int _scaleFactorXm;
-	int _scaleFactorXd;
-	int _scaleFactorYm;
-	int _scaleFactorYd;
-	bool _scalersChanged;
+	int _scaleFactorXm;			// scaler X *
+	int _scaleFactorXd;			// scaler X /
+	int _scaleFactorYm;			// scaler Y *
+	int _scaleFactorYd;			// scaler Y /
+	bool _scalersChanged;		
 
 	static int _platformScreenWidth;
 	static int _platformScreenHeight;
-	static bool _isOzone;
+	static bool _isOzone;		// true if running on Windows 2003 SE 
+
+	// Smartphone specific variables
+
+	int _lastKeyPressed;		// last key pressed
+	int _keyRepeat;				// number of time the last key was repeated
+	int _keyRepeatTime;			// elapsed time since the key was pressed
+	int _keyRepeatTrigger;		// minimum time to consider the key was repeated
+
+	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)
 };
 
 #endif





More information about the Scummvm-git-logs mailing list