diff options
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/events/androidsdl/androidsdl-events.cpp | 13 | ||||
| -rw-r--r-- | backends/events/dinguxsdl/dinguxsdl-events.cpp | 28 | ||||
| -rw-r--r-- | backends/events/gph/gph-events.cpp | 74 | ||||
| -rw-r--r-- | backends/events/linuxmotosdl/linuxmotosdl-events.cpp | 30 | ||||
| -rw-r--r-- | backends/events/maemosdl/maemosdl-events.cpp | 4 | ||||
| -rw-r--r-- | backends/events/openpandora/op-events.cpp | 14 | ||||
| -rw-r--r-- | backends/events/ps3sdl/ps3sdl-events.cpp | 8 | ||||
| -rw-r--r-- | backends/events/sdl/sdl-events.cpp | 144 | ||||
| -rw-r--r-- | backends/events/sdl/sdl-events.h | 5 | ||||
| -rw-r--r-- | backends/events/symbiansdl/symbiansdl-events.cpp | 36 | ||||
| -rw-r--r-- | backends/events/wincesdl/wincesdl-events.cpp | 8 | ||||
| -rw-r--r-- | backends/platform/androidsdl/androidsdl-sdl.cpp | 96 | ||||
| -rw-r--r-- | backends/platform/androidsdl/androidsdl-sdl.h | 8 | 
13 files changed, 314 insertions, 154 deletions
diff --git a/backends/events/androidsdl/androidsdl-events.cpp b/backends/events/androidsdl/androidsdl-events.cpp index 0adcff817e..125f411289 100644 --- a/backends/events/androidsdl/androidsdl-events.cpp +++ b/backends/events/androidsdl/androidsdl-events.cpp @@ -26,7 +26,6 @@  #include "backends/events/androidsdl/androidsdl-events.h"  #include "backends/platform/androidsdl/androidsdl-sdl.h" -#include <SDL_screenkeyboard.h>  bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {  	if (ev.button.button == SDL_BUTTON_LEFT) @@ -43,16 +42,8 @@ bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &  	else if (ev.button.button == SDL_BUTTON_MIDDLE) {  		event.type = Common::EVENT_MBUTTONDOWN; -		static int show_onscreen = 0; -		if (show_onscreen == 0) { -			SDL_ANDROID_SetScreenKeyboardShown(0); -			show_onscreen++; -		} else if (show_onscreen==1) { -			SDL_ANDROID_SetScreenKeyboardShown(1); -			show_onscreen++; -		} -		if (show_onscreen == 2) -			show_onscreen = 0; +		const bool show_onscreen = g_system->getFeatureState(OSystem::kFeatureOnScreenControl); +		g_system->setFeatureState(OSystem::kFeatureOnScreenControl, !show_onscreen);  	}  #endif  	else diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp index 0492c569e1..7730e8f915 100644 --- a/backends/events/dinguxsdl/dinguxsdl-events.cpp +++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp @@ -72,54 +72,54 @@  bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  	if (ev.key.keysym.sym == PAD_UP) {  		if (ev.type == SDL_KEYDOWN) { -			_km.y_vel = -1; +			_km.y_vel = -1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 0; +			_km.y_vel = 0 * MULTIPLIER;  			_km.y_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == PAD_DOWN) {  		if (ev.type == SDL_KEYDOWN) { -			_km.y_vel = 1; +			_km.y_vel = 1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 0; +			_km.y_vel = 0 * MULTIPLIER;  			_km.y_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == PAD_LEFT) {  		if (ev.type == SDL_KEYDOWN) { -			_km.x_vel = -1; +			_km.x_vel = -1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 0; +			_km.x_vel = 0 * MULTIPLIER;  			_km.x_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == PAD_RIGHT) {  		if (ev.type == SDL_KEYDOWN) { -			_km.x_vel = 1; +			_km.x_vel = 1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 0; +			_km.x_vel = 0 * MULTIPLIER;  			_km.x_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == BUT_Y) { // left mouse button @@ -129,7 +129,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  			event.type = Common::EVENT_LBUTTONUP;  		} -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == BUT_B) { // right mouse button @@ -139,7 +139,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  			event.type = Common::EVENT_RBUTTONUP;  		} -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index 88fc97d3d1..d59d0bead5 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -230,116 +230,116 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {  	switch (ev.jbutton.button) {  	case BUTTON_UP:  		if (_km.y_down_count != 2) { -			_km.y_vel = -1; +			_km.y_vel = -1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = -4; +			_km.y_vel = -4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_DOWN:  		if (_km.y_down_count != 2) { -			_km.y_vel = 1; +			_km.y_vel = 1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 4; +			_km.y_vel = 4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_LEFT:  		if (_km.x_down_count != 2) { -			_km.x_vel = -1; +			_km.x_vel = -1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = -4; +			_km.x_vel = -4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_RIGHT:  		if (_km.x_down_count != 3) { -			_km.x_vel = 1; +			_km.x_vel = 1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 4; +			_km.x_vel = 4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_UPLEFT:  		if (_km.x_down_count != 2) { -			_km.x_vel = -1; +			_km.x_vel = -1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -				_km.x_vel = -4; +				_km.x_vel = -4 * MULTIPLIER;  		}  		if (_km.y_down_count != 2) { -			_km.y_vel = -1; +			_km.y_vel = -1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = -4; +			_km.y_vel = -4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_UPRIGHT:  		if (_km.x_down_count != 2) { -			_km.x_vel = 1; +			_km.x_vel = 1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 4; +			_km.x_vel = 4 * MULTIPLIER;  		}  		if (_km.y_down_count != 2) { -			_km.y_vel = -1; +			_km.y_vel = -1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = -4; +			_km.y_vel = -4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_DOWNLEFT:  		if (_km.x_down_count != 2) { -			_km.x_vel = -1; +			_km.x_vel = -1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = -4; +			_km.x_vel = -4 * MULTIPLIER;  		}  		if (_km.y_down_count != 2) { -			_km.y_vel = 1; +			_km.y_vel = 1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 4; +			_km.y_vel = 4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_DOWNRIGHT:  		if (_km.x_down_count != 2) { -			_km.x_vel = 1; +			_km.x_vel = 1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 4; +			_km.x_vel = 4 * MULTIPLIER;  		}  		if (_km.y_down_count != 2) { -			_km.y_vel = 1; +			_km.y_vel = 1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 4; +			_km.y_vel = 4 * MULTIPLIER;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_B:  	case BUTTON_CLICK:  		event.type = Common::EVENT_LBUTTONDOWN; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_X:  		event.type = Common::EVENT_RBUTTONDOWN; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_L:  		BUTTON_STATE_L = true; @@ -454,16 +454,16 @@ bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {  		_km.x_vel = 0;  		_km.x_down_count = 0;  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_B:  	case BUTTON_CLICK:  		event.type = Common::EVENT_LBUTTONUP; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_X:  		event.type = Common::EVENT_RBUTTONUP; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BUTTON_L:  		BUTTON_STATE_L = false; diff --git a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp index b0d443ff9f..00453a036c 100644 --- a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp +++ b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp @@ -130,53 +130,53 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  // Joystick to Mouse  	else if (ev.key.keysym.sym == SDLK_LEFT) {  		if (ev.type == SDL_KEYDOWN) { -			_km.x_vel = -1; +			_km.x_vel = -1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 0; +			_km.x_vel = 0 * MULTIPLIER;  			_km.x_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == SDLK_RIGHT) {  		if (ev.type == SDL_KEYDOWN) { -			_km.x_vel = 1; +			_km.x_vel = 1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else { -			_km.x_vel = 0; +			_km.x_vel = 0 * MULTIPLIER;  			_km.x_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == SDLK_DOWN) {  		if (ev.type == SDL_KEYDOWN) { -			_km.y_vel = 1; +			_km.y_vel = 1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 0; +			_km.y_vel = 0 * MULTIPLIER;  			_km.y_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == SDLK_UP) {  		if (ev.type == SDL_KEYDOWN) { -			_km.y_vel = -1; +			_km.y_vel = -1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else { -			_km.y_vel = 0; +			_km.y_vel = 0 * MULTIPLIER;  			_km.y_down_count = 0;  		}  		event.type = Common::EVENT_MOUSEMOVE; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == SDLK_RETURN) { @@ -187,7 +187,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  			event.type = Common::EVENT_LBUTTONUP;  		} -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == SDLK_PLUS) { @@ -197,7 +197,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  		} else {  			event.type = Common::EVENT_RBUTTONUP;  		} -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else if (ev.key.keysym.sym == SDLK_MINUS) { @@ -208,7 +208,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  			event.type = Common::EVENT_LBUTTONUP;  		} -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		return true;  	} else { diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 8b7514004a..e864c7d81c 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -96,7 +96,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  				}  			} else if (ev.key.keysym.sym == SDLK_F7) {  				event.type = Common::EVENT_RBUTTONDOWN; -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				 debug(9, "remapping to right click down");  				return true;  			} else if (ev.key.keysym.sym == SDLK_F8) { @@ -134,7 +134,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  				}  			} else if (ev.key.keysym.sym == SDLK_F7) {  				event.type = Common::EVENT_RBUTTONUP; -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  					debug(9, "remapping to right click up");  				return true;  			} else if (ev.key.keysym.sym == SDLK_F8) { diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index b9d5fa8c7b..abb1458d66 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -126,18 +126,18 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  		switch (ev.key.keysym.sym) {  		case SDLK_LEFT:  			event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  		case SDLK_RIGHT:  			event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  #if defined(SDL_BUTTON_MIDDLE)  		case SDLK_UP:  			event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  #endif @@ -150,12 +150,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  		switch (ev.key.keysym.sym) {  		case SDLK_HOME:  			event.type = Common::EVENT_LBUTTONDOWN; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  		case SDLK_END:  			event.type = Common::EVENT_RBUTTONDOWN; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  		case SDLK_PAGEDOWN: @@ -188,12 +188,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  		switch (ev.key.keysym.sym) {  		case SDLK_HOME:  			event.type = Common::EVENT_LBUTTONUP; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  		case SDLK_END:  			event.type = Common::EVENT_RBUTTONUP; -			processMouseEvent(event, _km.x, _km.y); +			processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  			return true;  			break;  		case SDLK_PAGEDOWN: diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp index 1fc10559c2..01cdc2f0f6 100644 --- a/backends/events/ps3sdl/ps3sdl-events.cpp +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -60,11 +60,11 @@ bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event)  	switch (ev.jbutton.button) {  	case BTN_CROSS: // Left mouse button  		event.type = Common::EVENT_LBUTTONDOWN; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BTN_CIRCLE: // Right mouse button  		event.type = Common::EVENT_RBUTTONDOWN; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BTN_TRIANGLE: // Game menu  		event.type = Common::EVENT_KEYDOWN; @@ -98,11 +98,11 @@ bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {  	switch (ev.jbutton.button) {  	case BTN_CROSS: // Left mouse button  		event.type = Common::EVENT_LBUTTONUP; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BTN_CIRCLE: // Right mouse button  		event.type = Common::EVENT_RBUTTONUP; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		break;  	case BTN_TRIANGLE: // Game menu  		event.type = Common::EVENT_KEYUP; diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 5fb66a7ec4..469f1d5a44 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -30,6 +30,10 @@  #include "common/config-manager.h"  #include "common/textconsole.h" +#ifdef JOY_ANALOG +#include "math.h" +#endif +  // FIXME move joystick defines out and replace with confile file options  // we should really allow users to map any key to a joystick button  #define JOY_DEADZONE 3200 @@ -175,15 +179,20 @@ void SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) {  	}  	// Update the "keyboard mouse" coords -	_km.x = x; -	_km.y = y; +	_km.x = x * MULTIPLIER; +	_km.y = y * MULTIPLIER;  } -void SdlEventSource::handleKbdMouse() { +bool SdlEventSource::handleKbdMouse(Common::Event &event) { +	// returns true if an event is generated  	// Skip recording of these events  	uint32 curTime = g_system->getMillis(true);  	if (curTime >= _km.last_time + _km.delay_time) { + +		int16 oldKmX = _km.x; +		int16 oldKmY = _km.y; +  		_km.last_time = curTime;  		if (_km.x_down_count == 1) {  			_km.x_down_time = curTime; @@ -196,60 +205,84 @@ void SdlEventSource::handleKbdMouse() {  		if (_km.x_vel || _km.y_vel) {  			if (_km.x_down_count) { -				if (curTime > _km.x_down_time + _km.delay_time * 12) { +				if (curTime > _km.x_down_time + 300) {  					if (_km.x_vel > 0) -						_km.x_vel++; +						_km.x_vel += MULTIPLIER;  					else -						_km.x_vel--; -				} else if (curTime > _km.x_down_time + _km.delay_time * 8) { +						_km.x_vel -= MULTIPLIER; +				} else if (curTime > _km.x_down_time + 200) {  					if (_km.x_vel > 0) -						_km.x_vel = 5; +						_km.x_vel = 5 * MULTIPLIER;  					else -						_km.x_vel = -5; +						_km.x_vel = -5 * MULTIPLIER;  				}  			}  			if (_km.y_down_count) { -				if (curTime > _km.y_down_time + _km.delay_time * 12) { +				if (curTime > _km.y_down_time + 300) {  					if (_km.y_vel > 0) -						_km.y_vel++; +						_km.y_vel += MULTIPLIER;  					else -						_km.y_vel--; -				} else if (curTime > _km.y_down_time + _km.delay_time * 8) { +						_km.y_vel -= MULTIPLIER; +				} else if (curTime > _km.y_down_time + 200) {  					if (_km.y_vel > 0) -						_km.y_vel = 5; +						_km.y_vel = 5 * MULTIPLIER;  					else -						_km.y_vel = -5; +						_km.y_vel = -5 * MULTIPLIER;  				}  			} -			_km.x += _km.x_vel; -			_km.y += _km.y_vel; +			// - The modifier key makes the mouse movement slower +			// - The extra factor "delay/25" ensures velocities  +			// are independent of the kbdMouse update rate +			// - all velocities were originally chosen +			// at a delay of 25, so that is the reference used here +			// - note: operator order is important to avoid overflow +			if (_km.modifier) { +				_km.x += ((_km.x_vel / 10) * ((int16)_km.delay_time)) / 25; +				_km.y += ((_km.y_vel / 10) * ((int16)_km.delay_time)) / 25; +			} else { +				_km.x += (_km.x_vel * ((int16)_km.delay_time)) / 25; +				_km.y += (_km.y_vel * ((int16)_km.delay_time)) / 25; +			}  			if (_km.x < 0) {  				_km.x = 0; -				_km.x_vel = -1; +				_km.x_vel = -1 * MULTIPLIER;  				_km.x_down_count = 1; -			} else if (_km.x > _km.x_max) { -				_km.x = _km.x_max; -				_km.x_vel = 1; +			} else if (_km.x > _km.x_max * MULTIPLIER) { +				_km.x = _km.x_max * MULTIPLIER; +				_km.x_vel = 1 * MULTIPLIER;  				_km.x_down_count = 1;  			}  			if (_km.y < 0) {  				_km.y = 0; -				_km.y_vel = -1; +				_km.y_vel = -1 * MULTIPLIER;  				_km.y_down_count = 1; -			} else if (_km.y > _km.y_max) { -				_km.y = _km.y_max; -				_km.y_vel = 1; +			} else if (_km.y > _km.y_max * MULTIPLIER) { +				_km.y = _km.y_max * MULTIPLIER; +				_km.y_vel = 1 * MULTIPLIER;  				_km.y_down_count = 1;  			}  			if (_graphicsManager) { -				_graphicsManager->getWindow()->warpMouseInWindow((Uint16)_km.x, (Uint16)_km.y); +				_graphicsManager->getWindow()->warpMouseInWindow((Uint16)(_km.x / MULTIPLIER), (Uint16)(_km.y / MULTIPLIER)); +			} + +			if (_km.x != oldKmX || _km.y != oldKmY) { +				// keep hi-res coordinates since  +				// processMouseEvent will overwrite them with lo-res numbers +				oldKmX = _km.x; +				oldKmY = _km.y; +				event.type = Common::EVENT_MOUSEMOVE; +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); +				_km.x = oldKmX; +				_km.y = oldKmY; +				return true;  			}  		}  	} +	return false;  }  void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { @@ -425,7 +458,6 @@ Common::KeyCode SdlEventSource::SDLToOSystemKeycode(const SDLKey key) {  }  bool SdlEventSource::pollEvent(Common::Event &event) { -	handleKbdMouse();  #if SDL_VERSION_ATLEAST(2, 0, 0)  	// In case we still need to send a key up event for a key down from a @@ -451,6 +483,12 @@ bool SdlEventSource::pollEvent(Common::Event &event) {  		if (dispatchSDLEvent(ev, event))  			return true;  	} + +	// Handle mouse control via analog joystick and keyboard +	if (handleKbdMouse(event)) { +		return true; +	} +  	return false;  } @@ -485,7 +523,7 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {  		// with a mouse wheel event. However, SDL2 does not supply  		// these, thus we use whatever we got last time. It seems  		// these are always stored in _km.x, _km.y. -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  		if (yDir < 0) {  			event.type = Common::EVENT_WHEELDOWN;  			return true; @@ -712,10 +750,10 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {  bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {  	if (ev.jbutton.button == JOY_BUT_LMOUSE) {  		event.type = Common::EVENT_LBUTTONDOWN; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  	} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {  		event.type = Common::EVENT_RBUTTONDOWN; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  	} else {  		event.type = Common::EVENT_KEYDOWN;  		switch (ev.jbutton.button) { @@ -743,10 +781,10 @@ bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {  bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {  	if (ev.jbutton.button == JOY_BUT_LMOUSE) {  		event.type = Common::EVENT_LBUTTONUP; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  	} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {  		event.type = Common::EVENT_RBUTTONUP; -		processMouseEvent(event, _km.x, _km.y); +		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  	} else {  		event.type = Common::EVENT_KEYUP;  		switch (ev.jbutton.button) { @@ -772,23 +810,27 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {  }  bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { +  	int axis = ev.jaxis.value; +#ifdef JOY_ANALOG +	// conversion factor between keyboard mouse and joy axis value +	int vel_to_axis = (1500 / MULTIPLIER); +#else  	if (axis > JOY_DEADZONE) {  		axis -= JOY_DEADZONE; -		event.type = Common::EVENT_MOUSEMOVE;  	} else if (axis < -JOY_DEADZONE) {  		axis += JOY_DEADZONE; -		event.type = Common::EVENT_MOUSEMOVE;  	} else  		axis = 0; +#endif  	if (ev.jaxis.axis == JOY_XAXIS) {  #ifdef JOY_ANALOG -		_km.x_vel = axis / 2000; +		_km.x_vel = axis / vel_to_axis;  		_km.x_down_count = 0;  #else  		if (axis != 0) { -			_km.x_vel = (axis > 0) ? 1:-1; +			_km.x_vel = (axis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER;  			_km.x_down_count = 1;  		} else {  			_km.x_vel = 0; @@ -800,11 +842,11 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {  		axis = -axis;  #endif  #ifdef JOY_ANALOG -		_km.y_vel = -axis / 2000; +		_km.y_vel = -axis / vel_to_axis;  		_km.y_down_count = 0;  #else  		if (axis != 0) { -			_km.y_vel = (-axis > 0) ? 1: -1; +			_km.y_vel = (-axis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER;  			_km.y_down_count = 1;  		} else {  			_km.y_vel = 0; @@ -812,10 +854,27 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {  		}  #endif  	} +#ifdef JOY_ANALOG +	// radial and scaled analog joystick deadzone +	float analogX = (float) (_km.x_vel * vel_to_axis); +	float analogY = (float) (_km.y_vel * vel_to_axis); +	float deadZone = (float) JOY_DEADZONE; +	float scalingFactor = 1.0f; +	float magnitude = 0.0f; + +	magnitude = sqrt(analogX * analogX + analogY * analogY); + +	if (magnitude >= deadZone) { +		scalingFactor = 1.0f / magnitude * (magnitude - deadZone) / (32769.0f - deadZone); +		_km.x_vel = (int16) (analogX * scalingFactor * 32768.0f / vel_to_axis); +		_km.y_vel = (int16) (analogY * scalingFactor * 32768.0f / vel_to_axis); +	} else { +		_km.y_vel = 0; +		_km.x_vel = 0; +	} +#endif -	processMouseEvent(event, _km.x, _km.y); - -	return true; +	return false;  }  bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { @@ -889,8 +948,9 @@ bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  void SdlEventSource::resetKeyboardEmulation(int16 x_max, int16 y_max) {  	_km.x_max = x_max;  	_km.y_max = y_max; -	_km.delay_time = 25; +	_km.delay_time = 12;  	_km.last_time = 0; +	_km.modifier = false;  }  bool SdlEventSource::handleResizeEvent(Common::Event &event, int w, int h) { diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index c43699420b..334bf8acfc 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -28,6 +28,8 @@  #include "common/events.h" +// multiplier used to increase resolution for keyboard/joystick mouse +#define MULTIPLIER 16  /**   * The SDL event source. @@ -60,6 +62,7 @@ protected:  	struct KbdMouse {  		int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count;  		uint32 last_time, delay_time, x_down_time, y_down_time; +		bool modifier;  	};  	KbdMouse _km; @@ -106,7 +109,7 @@ protected:  	virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);  	virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);  	virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event); -	virtual void handleKbdMouse(); +	virtual bool handleKbdMouse(Common::Event &event);  	//@} diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index b0d2c25302..9272cbaf9d 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -56,76 +56,76 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {  			switch (loop) {  			case GUI::ACTION_UP:  				if (ev.type == SDL_KEYDOWN) { -					_km.y_vel = -1; +					_km.y_vel = -1 * MULTIPLIER;  					_km.y_down_count = 1;  				} else { -					_km.y_vel = 0; +					_km.y_vel = 0 * MULTIPLIER;  					_km.y_down_count = 0;  				}  				event.type = Common::EVENT_MOUSEMOVE; -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				return true;  			case GUI::ACTION_DOWN:  				if (ev.type == SDL_KEYDOWN) { -					_km.y_vel = 1; +					_km.y_vel = 1 * MULTIPLIER;  					_km.y_down_count = 1;  				} else { -					_km.y_vel = 0; +					_km.y_vel = 0 * MULTIPLIER;  					_km.y_down_count = 0;  				}  				event.type = Common::EVENT_MOUSEMOVE; -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				return true;  			case GUI::ACTION_LEFT:  				if (ev.type == SDL_KEYDOWN) { -					_km.x_vel = -1; +					_km.x_vel = -1 * MULTIPLIER;  					_km.x_down_count = 1;  				} else { -					_km.x_vel = 0; +					_km.x_vel = 0 * MULTIPLIER;  					_km.x_down_count = 0;  				}  				event.type = Common::EVENT_MOUSEMOVE; -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				return true;  			case GUI::ACTION_RIGHT:  				if (ev.type == SDL_KEYDOWN) { -					_km.x_vel = 1; +					_km.x_vel = 1 * MULTIPLIER;  					_km.x_down_count = 1;  				} else { -					_km.x_vel = 0; +					_km.x_vel = 0 * MULTIPLIER;  					_km.x_down_count = 0;  				}  				event.type = Common::EVENT_MOUSEMOVE; -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				return true;  			case GUI::ACTION_LEFTCLICK:  				event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP); -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				return true;  			case GUI::ACTION_RIGHTCLICK:  				event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP); -				processMouseEvent(event, _km.x, _km.y); +				processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);  				return true;  			case GUI::ACTION_ZONE:  				if (ev.type == SDL_KEYDOWN) {  					for (int i = 0; i < TOTAL_ZONES; i++) -						if (_km.x >= _zones[i].x && _km.y >= _zones[i].y && -							_km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height +						if ( (_km.x / MULTIPLIER) >= _zones[i].x && (_km.y / MULTIPLIER) >= _zones[i].y && +							(_km.x / MULTIPLIER) <= _zones[i].x + _zones[i].width && (_km.y / MULTIPLIER <= _zones[i].y + _zones[i].height  							) { -							_mouseXZone[i] = _km.x; -							_mouseYZone[i] = _km.y; +							_mouseXZone[i] = _km.x / MULTIPLIER; +							_mouseYZone[i] = _km.y / MULTIPLIER;  							break;  						}  						_currentZone++; diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp index d3141ee50c..7001d5fec6 100644 --- a/backends/events/wincesdl/wincesdl-events.cpp +++ b/backends/events/wincesdl/wincesdl-events.cpp @@ -48,8 +48,8 @@ void WINCESdlEventSource::processMouseEvent(Common::Event &event, int x, int y)  	event.mouse.y = y;  	// Update the "keyboard mouse" coords -	_km.x = event.mouse.x; -	_km.y = event.mouse.y; +	_km.x = event.mouse.x * MULTIPLIER; +	_km.y = event.mouse.y * MULTIPLIER;  	// Adjust for the screen scaling  	if (_graphicsMan->_zoomDown) @@ -69,7 +69,9 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {  	memset(&event, 0, sizeof(Common::Event)); -	handleKbdMouse(); +	if (handleKbdMouse(event) { +		return true; +	}  	// If the screen changed, send an Common::EVENT_SCREEN_CHANGED  	int screenID = _graphicsMan->getScreenChangeID(); diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp index d04512475a..920dad2234 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.cpp +++ b/backends/platform/androidsdl/androidsdl-sdl.cpp @@ -27,6 +27,8 @@  #include "backends/platform/androidsdl/androidsdl-sdl.h"  #include "backends/events/androidsdl/androidsdl-events.h"  #include "backends/graphics/androidsdl/androidsdl-graphics.h" +#include <SDL_android.h> +#include <SDL_screenkeyboard.h>  void OSystem_ANDROIDSDL::initBackend() {  	// Create the backend custom managers @@ -42,7 +44,101 @@ void OSystem_ANDROIDSDL::initBackend() {  	if (!ConfMan.hasKey("gfx_mode"))  		ConfMan.set("gfx_mode", "2x"); +	 +	if (!ConfMan.hasKey("swap_menu_and_back_buttons")) +		ConfMan.setBool("swap_menu_and_back_buttons", true); +	else +		swapMenuAndBackButtons(ConfMan.getBool("swap_menu_and_back_buttons")); +	 +	if (!ConfMan.hasKey("touchpad_mouse_mode")) { +		const bool enable = SDL_ANDROID_GetMouseEmulationMode(); +		ConfMan.setBool("touchpad_mouse_mode", enable); +	} else +		touchpadMode(ConfMan.getBool("touchpad_mouse_mode")); +	 +	if (!ConfMan.hasKey("onscreen_control")) { +		const bool enable = SDL_ANDROID_GetScreenKeyboardShown(); +		ConfMan.setBool("onscreen_control", enable); +	} else +		showOnScreenControl(ConfMan.getBool("onscreen_control"));  	// Call parent implementation of this method  	OSystem_POSIX::initBackend();  } + +void OSystem_ANDROIDSDL::showOnScreenControl(bool enable) { +	if (enable) +		SDL_ANDROID_SetScreenKeyboardShown(1); +	else +		SDL_ANDROID_SetScreenKeyboardShown(0); +} + +void OSystem_ANDROIDSDL::touchpadMode(bool enable) { +	if (enable) +		switchToRelativeMouseMode(); +	else +		switchToDirectMouseMode(); +} + +void OSystem_ANDROIDSDL::swapMenuAndBackButtons(bool enable) { +	static int KEYCODE_MENU = 82; +	static int KEYCODE_BACK = 4; +	if (enable) { +		SDL_ANDROID_SetAndroidKeycode(KEYCODE_BACK, SDLK_F13); +		SDL_ANDROID_SetAndroidKeycode(KEYCODE_MENU, SDLK_ESCAPE); +	} else { +		SDL_ANDROID_SetAndroidKeycode(KEYCODE_BACK, SDLK_ESCAPE); +		SDL_ANDROID_SetAndroidKeycode(KEYCODE_MENU, SDLK_F13); +	} +} + +void OSystem_ANDROIDSDL::switchToDirectMouseMode() { +	SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +void OSystem_ANDROIDSDL::switchToRelativeMouseMode() { +	SDL_ANDROID_SetMouseEmulationMode(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +void OSystem_ANDROIDSDL::setFeatureState(Feature f, bool enable) { +	switch (f) { +		case kFeatureTouchpadMode: +			ConfMan.setBool("touchpad_mouse_mode", enable); +			touchpadMode(enable); +			break; +		case kFeatureOnScreenControl: +			ConfMan.setBool("onscreen_control", enable); +			showOnScreenControl(enable); +			break; +		case kFeatureSwapMenuAndBackButtons: +			ConfMan.setBool("swap_menu_and_back_buttons", enable); +			swapMenuAndBackButtons(enable); +			break; +	} +	 +	OSystem_POSIX::setFeatureState(f, enable); +} + +bool OSystem_ANDROIDSDL::getFeatureState(Feature f) { +	switch (f) { +		case kFeatureTouchpadMode: +			return ConfMan.getBool("touchpad_mouse_mode"); +			break; +		case kFeatureOnScreenControl: +			return ConfMan.getBool("onscreen_control"); +			break; +		case kFeatureSwapMenuAndBackButtons: +			return ConfMan.getBool("swap_menu_and_back_buttons"); +			break; +		default: +			return OSystem_POSIX::getFeatureState(f); +			break; +	} +} + +bool OSystem_ANDROIDSDL::hasFeature(Feature f) { +	return (f == kFeatureTouchpadMode || +			f == kFeatureOnScreenControl || +			f == kFeatureSwapMenuAndBackButtons || +			f == OSystem_POSIX::getFeatureState(f)); +} diff --git a/backends/platform/androidsdl/androidsdl-sdl.h b/backends/platform/androidsdl/androidsdl-sdl.h index 6ebe5022eb..e83f610d10 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.h +++ b/backends/platform/androidsdl/androidsdl-sdl.h @@ -28,6 +28,14 @@  class OSystem_ANDROIDSDL : public OSystem_POSIX {  public:  	virtual void initBackend(); +	virtual void setFeatureState(Feature f, bool enable); +	virtual bool getFeatureState(Feature f); +	virtual bool hasFeature(Feature f); +	void touchpadMode(bool enable); +	void swapMenuAndBackButtons(bool enable); +	void switchToDirectMouseMode(); +	void switchToRelativeMouseMode(); +	void showOnScreenControl(bool enable);  #ifdef ENABLE_KEYMAPPER  	// FIXME: This just calls parent methods, is it needed?  | 
