diff options
| author | Nicolas Bacca | 2002-10-22 22:57:12 +0000 | 
|---|---|---|
| committer | Nicolas Bacca | 2002-10-22 22:57:12 +0000 | 
| commit | 2297129a67d877c778ac7dbe33e22adb4f5c34b3 (patch) | |
| tree | bd7b78e5c57c6116cbbe73530688c45928388247 | |
| parent | 3b8905d1bde4cb07f14d906cac41ba4e5d70130d (diff) | |
| download | scummvm-rg350-2297129a67d877c778ac7dbe33e22adb4f5c34b3.tar.gz scummvm-rg350-2297129a67d877c778ac7dbe33e22adb4f5c34b3.tar.bz2 scummvm-rg350-2297129a67d877c778ac7dbe33e22adb4f5c34b3.zip  | |
New hardware key management
svn-id: r5259
| -rw-r--r-- | backends/wince/gapi_keys.cpp | 94 | ||||
| -rw-r--r-- | backends/wince/gapi_keys.h | 28 | 
2 files changed, 80 insertions, 42 deletions
diff --git a/backends/wince/gapi_keys.cpp b/backends/wince/gapi_keys.cpp index a4d2677573..c9999237bb 100644 --- a/backends/wince/gapi_keys.cpp +++ b/backends/wince/gapi_keys.cpp @@ -29,16 +29,21 @@  #include <sipapi.h>  #include <Aygshell.h>  #include <gx.h> +#include "dynamic_imports.h"  #include "gapi_keys.h"  #include "screen.h" -struct oneAction _actions[NUMBER_ACTIONS]; +struct oneAction _actions[TOTAL_ACTIONS];  struct GXKeyList _portrait_keys;  struct GXKeyList _landscape_keys;  pAction *_action_functions; +void handleSelectGameUp(void); +void handleSelectGameDown(void); +void handleSelectGameButton(void); +  const char* ActionsText[] = {  	"None",  	"Pause", @@ -54,10 +59,10 @@ const char* ActionsText[] = {  	"Boss"  }; -bool _typeExists(int x) { +bool _typeExists(unsigned int x) {  	int i; -	for (i=0; i<NUMBER_ACTIONS; i++) +	for (i=0; i<TOTAL_ACTIONS; i++)  		if (_actions[i].action_type == x)  			return true; @@ -69,23 +74,30 @@ const char* getActionName(int action) {  	return ActionsText[action];  } -void GAPIKeysInit(pAction *functions) { +void GAPIKeysInit() { +	dynamicGXOpenInput(); +	GAPIKeysGetReference(); +} + +void GAPIKeysInitActions(pAction *functions) {  	int i; -	GXOpenInput(); -	for (i=0; i<NUMBER_ACTIONS; i++) { + +	for (i=0; i<TOTAL_ACTIONS; i++) {  		_actions[i].action_key = 0;  	}  	/* Default actions */ +	/*  	_actions[0].action_type = ACTION_PAUSE;  	_actions[1].action_type = ACTION_SAVE;  	_actions[2].action_type = ACTION_QUIT;  	_actions[3].action_type = ACTION_SKIP;  	_actions[4].action_type = ACTION_HIDE; +	*/  	_action_functions = functions; -	GAPIKeysGetReference(); +	  }  void GAPIKeysGetReference() { @@ -97,11 +109,23 @@ void GAPIKeysGetReference() {  	}  	*/ -	_portrait_keys = GXGetDefaultKeys(GX_NORMALKEYS); -	_landscape_keys = GXGetDefaultKeys(GX_LANDSCAPEKEYS); +	_portrait_keys = dynamicGXGetDefaultKeys(GX_NORMALKEYS); +	_landscape_keys = dynamicGXGetDefaultKeys(GX_LANDSCAPEKEYS); +} + +void GAPIKeysHandleSelect(int key) { +	if (key == _portrait_keys.vkUp) +		handleSelectGameUp(); +	if (key == _portrait_keys.vkDown) +		handleSelectGameDown(); +	if (key == _portrait_keys.vkA || +		key == _portrait_keys.vkB || +		key == _portrait_keys.vkC || +		key == _portrait_keys.vkStart) +		handleSelectGameButton();  } -int GAPIKeysTranslate(int key) { +unsigned int GAPIKeysTranslate(unsigned int key) {  /*  	if (key == _landscape_keys.vkUp)  		return _portrait_keys.vkUp; @@ -166,26 +190,26 @@ const unsigned char getGAPIKeyMapping(short key) {  }  */ -const char* getGAPIKeyName(int key) { +const char* getGAPIKeyName(unsigned int key) {  	static char key_name[50];  	if (!key)  		return "Not mapped"; -	if (key == _portrait_keys.vkA) +	if (key == (unsigned int)_portrait_keys.vkA)  		return "Button A"; -	if (key == _portrait_keys.vkB) +	if (key == (unsigned int)_portrait_keys.vkB)  		return "Button B"; -	if (key == _portrait_keys.vkC) +	if (key == (unsigned int)_portrait_keys.vkC)  		return "Button C"; -	if (key == _portrait_keys.vkStart) +	if (key == (unsigned int)_portrait_keys.vkStart)  		return "Button Start"; -	if (key == _portrait_keys.vkUp) +	if (key == (unsigned int)_portrait_keys.vkUp)  		return "Pad Up"; -	if (key == _portrait_keys.vkDown) +	if (key == (unsigned int)_portrait_keys.vkDown)  		return "Pad Down"; -	if (key == _portrait_keys.vkLeft) +	if (key == (unsigned int)_portrait_keys.vkLeft)  		return "Pad Left"; -	if (key == _portrait_keys.vkRight) +	if (key == (unsigned int)_portrait_keys.vkRight)  		return "Pad Right";  	if (key == INTERNAL_KEY_CALENDAR)  		return "Button Calendar"; @@ -237,7 +261,7 @@ struct oneAction* getAction(int action) {  	return &_actions[action];  } -bool processAction (int key) { +bool processAction (unsigned int key) {  	int i;  	/*  	unsigned char GAPI_key; @@ -247,14 +271,23 @@ bool processAction (int key) {  		return;  	*/ -	for (i=0; i<NUMBER_ACTIONS; i++)  +	for (i=0; i<TOTAL_ACTIONS; i++) {  		//if (_actions[i].action_key == GAPI_key && +		/*  		if (_actions[i].action_key == key &&  			_actions[i].action_type != ACTION_NONE &&  			_action_functions[_actions[i].action_type - 1]) {  					_action_functions[_actions[i].action_type - 1]();  					return true;  		} +		*/ +		 +		if (_actions[i].action_key && _actions[i].action_key == key) { +			_action_functions[i](); +			return true; +		} +	} +  	return false;  } @@ -262,17 +295,17 @@ bool processAction (int key) {  void clearActionKey (unsigned char key) {  	int i; -	for (i=0; i<NUMBER_ACTIONS; i++) +	for (i=0; i<TOTAL_ACTIONS; i++)  		if (_actions[i].action_key == key) {  			_actions[i].action_key = 0;  		}  } -const int* getActionKeys() { +const unsigned int* getActionKeys() {  	int i; -	static int actionKeys[NUMBER_ACTIONS]; +	static unsigned int actionKeys[TOTAL_ACTIONS]; -	for (i=0; i<NUMBER_ACTIONS; i++) +	for (i=0; i<TOTAL_ACTIONS; i++)  		actionKeys[i] = _actions[i].action_key;  	return actionKeys; @@ -280,15 +313,16 @@ const int* getActionKeys() {  const unsigned char* getActionTypes() {  	int i; -	static unsigned char actionTypes[NUMBER_ACTIONS]; +	static unsigned char actionTypes[TOTAL_ACTIONS]; -	for (i=0; i<NUMBER_ACTIONS; i++) +	for (i=0; i<TOTAL_ACTIONS; i++)  		actionTypes[i] = _actions[i].action_type;  	return actionTypes;  } +  void setNextType(int action) {  	int start = _actions[action].action_type;  	int current = start; @@ -323,17 +357,17 @@ void setPreviousType(int action) { -void setActionKeys(int *actionKeys) { +void setActionKeys(unsigned int *actionKeys) {  	int i; -	for (i=0; i<NUMBER_ACTIONS; i++) +	for (i=0; i<TOTAL_ACTIONS; i++)  		_actions[i].action_key = actionKeys[i];  }  void setActionTypes(unsigned char *actionTypes) {  	int i; -	for (i=0; i<NUMBER_ACTIONS; i++) +	for (i=0; i<TOTAL_ACTIONS; i++)  		_actions[i].action_type = (ActionType)actionTypes[i];  } diff --git a/backends/wince/gapi_keys.h b/backends/wince/gapi_keys.h index 5eee52e518..0215763130 100644 --- a/backends/wince/gapi_keys.h +++ b/backends/wince/gapi_keys.h @@ -13,19 +13,19 @@ enum ActionType {  	ACTION_SOUND = 7,  	ACTION_RIGHTCLICK = 8,  	ACTION_CURSOR = 9, -	ACTION_SUBTITLES = 10 +	ACTION_SUBTITLES = 10, +	ACTION_BOSS = 11  };  struct oneAction { -	unsigned char	action_key; -	int				action_type; +	unsigned int		action_key; +	unsigned int		action_type;  }; - -#define NUMBER_ACTIONS 10 -#define TOTAL_ACTIONS 10 +#define TOTAL_ACTIONS 12  #define GAPI_KEY_BASE 1000 +/*  #define GAPI_KEY_VKA 1  #define GAPI_KEY_VKB 2  #define GAPI_KEY_VKC 3 @@ -38,25 +38,29 @@ struct oneAction {  #define GAPI_KEY_VKDOWN 10  #define GAPI_KEY_VKLEFT 11  #define GAPI_KEY_VKRIGHT 12 +*/  #define INTERNAL_KEY_CALENDAR 0xc1  #define INTERNAL_KEY_CONTACTS 0xc2  #define INTERNAL_KEY_INBOX 0xc3  #define INTERNAL_KEY_ITASK 0xc4 -void GAPIKeysInit(pAction*); +void GAPIKeysInit(void); +void GAPIKeysInitActions(pAction*);  void GAPIKeysGetReference(void); -const unsigned char getGAPIKeyMapping(short); -const char* getGAPIKeyName(unsigned char); +//const unsigned char getGAPIKeyMapping(short); +const char* getGAPIKeyName(unsigned int);  struct oneAction* getAction(int); -void processAction (short); +bool processAction (unsigned int);  void clearActionKey (unsigned char); -const unsigned char* getActionKeys(void); -void setActionKeys(unsigned char *); +const unsigned int* getActionKeys(void); +void setActionKeys(unsigned int*);  const char* getActionName(int);  void setActionTypes(unsigned char *);  const unsigned char* getActionTypes();  void setNextType(int);  void setPreviousType(int); +unsigned int GAPIKeysTranslate(unsigned int); +void GAPIKeysHandleSelect(int);  #endif  | 
