Second pass at getting GP2X gamepad working. At least the code compiles

now :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@995 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-01-31 17:26:56 +00:00
parent 89b17f8ab0
commit d91443ed89
5 changed files with 39 additions and 47 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.hxx,v 1.77 2006-01-30 16:20:41 stephena Exp $ // $Id: EventHandler.hxx,v 1.78 2006-01-31 17:26:56 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENTHANDLER_HXX #ifndef EVENTHANDLER_HXX
@ -133,7 +133,7 @@ struct JoyMouse {
mapping can take place. mapping can take place.
@author Stephen Anthony @author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.77 2006-01-30 16:20:41 stephena Exp $ @version $Id: EventHandler.hxx,v 1.78 2006-01-31 17:26:56 stephena Exp $
*/ */
class EventHandler class EventHandler
{ {
@ -335,6 +335,8 @@ class EventHandler
*/ */
void createMouseButtonEvent(int x, int y, int state); void createMouseButtonEvent(int x, int y, int state);
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
private: private:
/** /**
Bind a key to an event/action and regenerate the mapping array(s) Bind a key to an event/action and regenerate the mapping array(s)
@ -480,8 +482,6 @@ class EventHandler
void takeSnapshot(); void takeSnapshot();
void setEventState(State state); void setEventState(State state);
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
private: private:
// Global OSystem object // Global OSystem object
OSystem* myOSystem; OSystem* myOSystem;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemGP2X.cxx,v 1.3 2006-01-30 16:20:41 stephena Exp $ // $Id: OSystemGP2X.cxx,v 1.4 2006-01-31 17:26:56 stephena Exp $
// Modified on 2006/01/06 by Alex Zaballa for use on GP2X // Modified on 2006/01/06 by Alex Zaballa for use on GP2X
//============================================================================ //============================================================================
@ -78,16 +78,15 @@ OSystemGP2X::OSystemGP2X()
setCacheFile(cacheFile); setCacheFile(cacheFile);
// Set hat event handler to a known state // Set hat event handler to a known state
for(int i = 0; i < 8; ++i) myPreviousEvents = new uInt8[8]; memset(myPreviousEvents, 0, 8);
{ myCurrentEvents = new uInt8[8]; memset(myCurrentEvents, 0, 8);
myCurrentEvents[i] = myPreviousEvents[i] = 0;
myActiveEvents[i] = false;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemGP2X::~OSystemGP2X() OSystemGP2X::~OSystemGP2X()
{ {
delete[] myPreviousEvents;
delete[] myCurrentEvents;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -165,10 +164,10 @@ void OSystemGP2X::getScreenDimensions(int& width, int& height)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystemGP2X::setDefaultJoymap() void OSystemGP2X::setDefaultJoymap()
{ {
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroUp, 0, 0); // Up // myEventHandler->setDefaultJoyMapping(Event::JoystickZeroUp, 0, 0); // Up
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroLeft, 0, 2); // Left // myEventHandler->setDefaultJoyMapping(Event::JoystickZeroLeft, 0, 2); // Left
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroDown, 0, 4); // Down // myEventHandler->setDefaultJoyMapping(Event::JoystickZeroDown, 0, 4); // Down
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroRight, 0, 6); // Right // myEventHandler->setDefaultJoyMapping(Event::JoystickZeroRight, 0, 6); // Right
myEventHandler->setDefaultJoyMapping(Event::LauncherMode, 0, 8); // Start myEventHandler->setDefaultJoyMapping(Event::LauncherMode, 0, 8); // Start
myEventHandler->setDefaultJoyMapping(Event::CmdMenuMode, 0, 9); // Select myEventHandler->setDefaultJoyMapping(Event::CmdMenuMode, 0, 9); // Select
myEventHandler->setDefaultJoyMapping(Event::ConsoleReset, 0, 10); // L myEventHandler->setDefaultJoyMapping(Event::ConsoleReset, 0, 10); // L
@ -183,8 +182,12 @@ void OSystemGP2X::setDefaultJoymap()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystemGP2X::setDefaultJoyAxisMap() void OSystemGP2X::setDefaultJoyHatMap()
{ {
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroUp, 0, 0, kJHatUp);
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroLeft, 0, 0, kJHatLeft);
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroDown, 0, 0, kJHatDown);
myEventHandler->setDefaultJoyHatMapping(Event::JoystickZeroRight, 0, 0, kJHatRight);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -207,7 +210,7 @@ void OSystemGP2X::pollEvent()
{ {
myCurrentEvents[i] = SDL_JoystickGetButton(stick, i); myCurrentEvents[i] = SDL_JoystickGetButton(stick, i);
if(myCurrentEvents[i] != myPreviousEvents[i]) if(myCurrentEvents[i] != myPreviousEvents[i])
changeDetected = myActiveEvent[i] = true; changeDetected = true;
} }
// Create an appropriate SDL HAT event for the new state // Create an appropriate SDL HAT event for the new state
@ -216,49 +219,41 @@ void OSystemGP2X::pollEvent()
{ {
// Merge 'in-between' values to the proper direction // Merge 'in-between' values to the proper direction
// For example, if both 'up' and 'upright' are on, turn 'upright' off // For example, if both 'up' and 'upright' are on, turn 'upright' off
if(myActiveEvent[kJDirUp] && myCurrentEvents[kJDirUp]) // up if(myCurrentEvents[kJDirUp]) // up
{ {
myActiveEvent[kJDirUpLeft] = myActiveEvent[kJDirUpRight] = false;
myCurrentEvents[kJDirUpLeft] = myCurrentEvents[kJDirUpRight] = 0; myCurrentEvents[kJDirUpLeft] = myCurrentEvents[kJDirUpRight] = 0;
value |= SDL_HAT_UP; value |= SDL_HAT_UP;
} }
else if(myActiveEvent[kJDirDown] && myCurrentEvents[kJDirDown]) // down else if(myCurrentEvents[kJDirDown]) // down
{ {
myActiveEvent[kJDirDownLeft] = myActiveEvent[kJDirDownRight] = false;
myCurrentEvents[kJDirDownLeft] = myCurrentEvents[kJDirDownRight] = 0; myCurrentEvents[kJDirDownLeft] = myCurrentEvents[kJDirDownRight] = 0;
value |= SDL_HAT_DOWN; value |= SDL_HAT_DOWN;
} }
else if(myActiveEvent[kJDirLeft] && myCurrentEvents[kJDirLeft]) // left else if(myCurrentEvents[kJDirLeft]) // left
{ {
myActiveEvent[kJDirUpLeft] = myActiveEvent[kJDirDownLeft] = false;
myCurrentEvents[kJDirUpLeft] = myCurrentEvents[kJDirDownLeft] = 0; myCurrentEvents[kJDirUpLeft] = myCurrentEvents[kJDirDownLeft] = 0;
value |= SDL_HAT_LEFT; value |= SDL_HAT_LEFT;
} }
else if(myActiveEvent[kJDirRight] && myCurrentEvents[kJDirRight]) // right else if(myCurrentEvents[kJDirRight]) // right
{ {
myActiveEvent[kJDirUpRight] = myActiveEvent[kJDirDownRight] = false;
myCurrentEvents[kJDirUpRight] = myCurrentEvents[kJDirDownRight] = 0; myCurrentEvents[kJDirUpRight] = myCurrentEvents[kJDirDownRight] = 0;
value |= SDL_HAT_RIGHT; value |= SDL_HAT_RIGHT;
} }
// Now consider diagonal positions // Now consider diagonal positions
if(myActiveEvent[kJDirUpLeft] && myCurrentEvents[kJDirUpLeft]) // up-left if(myCurrentEvents[kJDirUpLeft]) // up-left
{ {
value |= SDL_HAT_UP | SDL_HAT_LEFT; value |= SDL_HAT_UP | SDL_HAT_LEFT;
} }
else if(myActiveEvent[kJDirUpRight] && myCurrentEvents[kJDirUpRight]) // up-right else if(myCurrentEvents[kJDirUpRight]) // up-right
{ {
value |= SDL_HAT_UP | SDL_HAT_RIGHT; value |= SDL_HAT_UP | SDL_HAT_RIGHT;
} }
else if(myActiveEvent[kJDirDownLeft] && myCurrentEvents[kJDirDownLeft]) // down-left else if(myCurrentEvents[kJDirDownLeft]) // down-left
{ {
value |= SDL_HAT_DOWN | SDL_HAT_LEFT; value |= SDL_HAT_DOWN | SDL_HAT_LEFT;
} }
else if(myActiveEvent[kJDirDownRight] && myCurrentEvents[kJDirDownRight]) // down-right else if(myCurrentEvents[kJDirDownRight]) // down-right
{ {
value |= SDL_HAT_DOWN | SDL_HAT_RIGHT; value |= SDL_HAT_DOWN | SDL_HAT_RIGHT;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemGP2X.hxx,v 1.3 2006-01-30 16:20:41 stephena Exp $ // $Id: OSystemGP2X.hxx,v 1.4 2006-01-31 17:26:56 stephena Exp $
// Modified by Alex Zaballa on 2006/01/04 for use on GP2X // Modified by Alex Zaballa on 2006/01/04 for use on GP2X
//============================================================================ //============================================================================
@ -66,10 +66,10 @@ class OSystemGP2X : public OSystem
void setDefaultJoymap(); void setDefaultJoymap();
/** /**
This method determines the default mapping of joystick axis to This method determines the default mapping of joystick hats to
Stella events for for the PSP device. Stella events for a specific system/platform.
*/ */
void setDefaultJoyAxisMap(); void setDefaultJoyHatMap();
/** /**
This method creates events from platform-specific hardware. This method creates events from platform-specific hardware.
@ -84,10 +84,8 @@ class OSystemGP2X : public OSystem
kJDirRight = 6, kJDirUpRight = 7 kJDirRight = 6, kJDirUpRight = 7
}; };
uInt8* myPreviousEvents[8]; uInt8* myPreviousEvents;
uInt8* myCurrentEvents[8]; uInt8* myCurrentEvents;
Int8* myActiveEvents[8];
}; };
#endif #endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FSNodePOSIX.cxx,v 1.7 2005-06-16 00:56:00 stephena Exp $ // $Id: FSNodePOSIX.cxx,v 1.8 2006-01-31 17:26:56 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -145,7 +145,6 @@ POSIXFilesystemNode::POSIXFilesystemNode(const POSIXFilesystemNode* node)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FSList POSIXFilesystemNode::listDir(ListMode mode) const FSList POSIXFilesystemNode::listDir(ListMode mode) const
{ {
assert(_isDirectory);
DIR *dirp = opendir(_path.c_str()); DIR *dirp = opendir(_path.c_str());
struct stat st; struct stat st;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemUNIX.hxx,v 1.9 2006-01-08 02:28:04 stephena Exp $ // $Id: OSystemUNIX.hxx,v 1.10 2006-01-31 17:26:56 stephena Exp $
//============================================================================ //============================================================================
#ifndef OSYSTEM_UNIX_HXX #ifndef OSYSTEM_UNIX_HXX
@ -26,7 +26,7 @@
This class defines UNIX-like OS's (Linux) system specific settings. This class defines UNIX-like OS's (Linux) system specific settings.
@author Stephen Anthony @author Stephen Anthony
@version $Id: OSystemUNIX.hxx,v 1.9 2006-01-08 02:28:04 stephena Exp $ @version $Id: OSystemUNIX.hxx,v 1.10 2006-01-31 17:26:56 stephena Exp $
*/ */
class OSystemUNIX : public OSystem class OSystemUNIX : public OSystem
{ {
@ -47,20 +47,20 @@ class OSystemUNIX : public OSystem
may use different timing methods and/or algorithms, this method has may use different timing methods and/or algorithms, this method has
been abstracted to each platform. been abstracted to each platform.
*/ */
virtual void mainLoop(); void mainLoop();
/** /**
This method returns number of ticks in microseconds. This method returns number of ticks in microseconds.
@return Current time in microseconds. @return Current time in microseconds.
*/ */
virtual uInt32 getTicks(); uInt32 getTicks();
/** /**
This method queries the dimensions of the screen for this hardware. This method queries the dimensions of the screen for this hardware.
It is assumed that a UNIX SDL framebuffer is using X11. It is assumed that a UNIX SDL framebuffer is using X11.
*/ */
virtual void getScreenDimensions(int& width, int& height); void getScreenDimensions(int& width, int& height);
}; };
#endif #endif