[Scummvm-cvs-logs] CVS: scummvm/backends/wince gapi_keys.cpp,1.1.1.1,1.2 gapi_keys.h,1.1.1.1,1.2

Nicolas Bacca arisme at users.sourceforge.net
Tue Oct 22 15:58:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/backends/wince
In directory usw-pr-cvs1:/tmp/cvs-serv12203

Modified Files:
	gapi_keys.cpp gapi_keys.h 
Log Message:
New hardware key management

Index: gapi_keys.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/gapi_keys.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- gapi_keys.cpp	21 Aug 2002 16:07:19 -0000	1.1.1.1
+++ gapi_keys.cpp	22 Oct 2002 22:57:12 -0000	1.2
@@ -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 @@
 	"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 @@
 	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 @@
 	}
 	*/
 
-	_portrait_keys = GXGetDefaultKeys(GX_NORMALKEYS);
-	_landscape_keys = GXGetDefaultKeys(GX_LANDSCAPEKEYS);
+	_portrait_keys = dynamicGXGetDefaultKeys(GX_NORMALKEYS);
+	_landscape_keys = dynamicGXGetDefaultKeys(GX_LANDSCAPEKEYS);
 }
 
-int GAPIKeysTranslate(int key) {
+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();
+}
+
+unsigned int GAPIKeysTranslate(unsigned int key) {
 /*
 	if (key == _landscape_keys.vkUp)
 		return _portrait_keys.vkUp;
@@ -166,26 +190,26 @@
 }
 */
 
-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 @@
 	return &_actions[action];
 }
 
-bool processAction (int key) {
+bool processAction (unsigned int key) {
 	int i;
 	/*
 	unsigned char GAPI_key;
@@ -247,14 +271,23 @@
 		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 @@
 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 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 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];
 }
 

Index: gapi_keys.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/gapi_keys.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- gapi_keys.h	21 Aug 2002 16:07:19 -0000	1.1.1.1
+++ gapi_keys.h	22 Oct 2002 22:57:12 -0000	1.2
@@ -13,19 +13,19 @@
 	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 @@
 #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





More information about the Scummvm-git-logs mailing list