mirror of https://github.com/stella-emu/stella.git
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:
parent
89b17f8ab0
commit
d91443ed89
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
|
@ -133,7 +133,7 @@ struct JoyMouse {
|
|||
mapping can take place.
|
||||
|
||||
@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
|
||||
{
|
||||
|
@ -335,6 +335,8 @@ class EventHandler
|
|||
*/
|
||||
void createMouseButtonEvent(int x, int y, int state);
|
||||
|
||||
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
|
||||
|
||||
private:
|
||||
/**
|
||||
Bind a key to an event/action and regenerate the mapping array(s)
|
||||
|
@ -480,8 +482,6 @@ class EventHandler
|
|||
void takeSnapshot();
|
||||
void setEventState(State state);
|
||||
|
||||
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
|
||||
|
||||
private:
|
||||
// Global OSystem object
|
||||
OSystem* myOSystem;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
//============================================================================
|
||||
|
||||
|
@ -78,16 +78,15 @@ OSystemGP2X::OSystemGP2X()
|
|||
setCacheFile(cacheFile);
|
||||
|
||||
// Set hat event handler to a known state
|
||||
for(int i = 0; i < 8; ++i)
|
||||
{
|
||||
myCurrentEvents[i] = myPreviousEvents[i] = 0;
|
||||
myActiveEvents[i] = false;
|
||||
}
|
||||
myPreviousEvents = new uInt8[8]; memset(myPreviousEvents, 0, 8);
|
||||
myCurrentEvents = new uInt8[8]; memset(myCurrentEvents, 0, 8);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystemGP2X::~OSystemGP2X()
|
||||
{
|
||||
delete[] myPreviousEvents;
|
||||
delete[] myCurrentEvents;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -165,10 +164,10 @@ void OSystemGP2X::getScreenDimensions(int& width, int& height)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemGP2X::setDefaultJoymap()
|
||||
{
|
||||
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroUp, 0, 0); // Up
|
||||
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroLeft, 0, 2); // Left
|
||||
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroDown, 0, 4); // Down
|
||||
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroRight, 0, 6); // Right
|
||||
// myEventHandler->setDefaultJoyMapping(Event::JoystickZeroUp, 0, 0); // Up
|
||||
// myEventHandler->setDefaultJoyMapping(Event::JoystickZeroLeft, 0, 2); // Left
|
||||
// myEventHandler->setDefaultJoyMapping(Event::JoystickZeroDown, 0, 4); // Down
|
||||
// myEventHandler->setDefaultJoyMapping(Event::JoystickZeroRight, 0, 6); // Right
|
||||
myEventHandler->setDefaultJoyMapping(Event::LauncherMode, 0, 8); // Start
|
||||
myEventHandler->setDefaultJoyMapping(Event::CmdMenuMode, 0, 9); // Select
|
||||
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);
|
||||
if(myCurrentEvents[i] != myPreviousEvents[i])
|
||||
changeDetected = myActiveEvent[i] = true;
|
||||
changeDetected = true;
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
value |= SDL_HAT_RIGHT;
|
||||
}
|
||||
|
||||
// Now consider diagonal positions
|
||||
if(myActiveEvent[kJDirUpLeft] && myCurrentEvents[kJDirUpLeft]) // up-left
|
||||
if(myCurrentEvents[kJDirUpLeft]) // up-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;
|
||||
}
|
||||
else if(myActiveEvent[kJDirDownLeft] && myCurrentEvents[kJDirDownLeft]) // down-left
|
||||
else if(myCurrentEvents[kJDirDownLeft]) // down-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;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
//============================================================================
|
||||
|
||||
|
@ -66,10 +66,10 @@ class OSystemGP2X : public OSystem
|
|||
void setDefaultJoymap();
|
||||
|
||||
/**
|
||||
This method determines the default mapping of joystick axis to
|
||||
Stella events for for the PSP device.
|
||||
This method determines the default mapping of joystick hats to
|
||||
Stella events for a specific system/platform.
|
||||
*/
|
||||
void setDefaultJoyAxisMap();
|
||||
void setDefaultJoyHatMap();
|
||||
|
||||
/**
|
||||
This method creates events from platform-specific hardware.
|
||||
|
@ -84,10 +84,8 @@ class OSystemGP2X : public OSystem
|
|||
kJDirRight = 6, kJDirUpRight = 7
|
||||
};
|
||||
|
||||
uInt8* myPreviousEvents[8];
|
||||
uInt8* myCurrentEvents[8];
|
||||
Int8* myActiveEvents[8];
|
||||
|
||||
uInt8* myPreviousEvents;
|
||||
uInt8* myCurrentEvents;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -145,7 +145,6 @@ POSIXFilesystemNode::POSIXFilesystemNode(const POSIXFilesystemNode* node)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FSList POSIXFilesystemNode::listDir(ListMode mode) const
|
||||
{
|
||||
assert(_isDirectory);
|
||||
DIR *dirp = opendir(_path.c_str());
|
||||
struct stat st;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
|
@ -26,7 +26,7 @@
|
|||
This class defines UNIX-like OS's (Linux) system specific settings.
|
||||
|
||||
@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
|
||||
{
|
||||
|
@ -47,20 +47,20 @@ class OSystemUNIX : public OSystem
|
|||
may use different timing methods and/or algorithms, this method has
|
||||
been abstracted to each platform.
|
||||
*/
|
||||
virtual void mainLoop();
|
||||
void mainLoop();
|
||||
|
||||
/**
|
||||
This method returns number of ticks in microseconds.
|
||||
|
||||
@return Current time in microseconds.
|
||||
*/
|
||||
virtual uInt32 getTicks();
|
||||
uInt32 getTicks();
|
||||
|
||||
/**
|
||||
This method queries the dimensions of the screen for this hardware.
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue