--- src/Controller.cxx | 25 +++++++++++++++++++++++++ src/Controller.h | 3 +++ src/MetaState.cxx | 3 +++ 3 files changed, 31 insertions(+) Index: crack-attack-1.1.15-cvs-01/src/Controller.cxx =================================================================== --- crack-attack-1.1.15-cvs-01.orig/src/Controller.cxx +++ crack-attack-1.1.15-cvs-01/src/Controller.cxx @@ -43,10 +43,35 @@ using namespace std; int Controller::state; +int Controller::jstate; void Controller::gameStart ( ) { state = 0; + jstate = 0; +} + +void Controller::joystickPlay ( unsigned int buttonMask, int x, int y, int z ) +{ + int newjstate = 0; + + if( buttonMask & 0x1 ) newjstate |= CC_SWAP; + if( buttonMask & 0x2 ) newjstate |= CC_ADVANCE; + if( buttonMask & 0x4 ) newjstate |= CC_PAUSE; + + if( x<0 ) newjstate |= CC_LEFT; + if( x>0 ) newjstate |= CC_RIGHT; + + if( y<0 ) newjstate |= CC_UP; + if( y>0 ) newjstate |= CC_DOWN; + + if( jstate != newjstate ) + ActionRecorder::addAction(state=jstate=newjstate); +} + +void Controller::joystickMeta ( unsigned int buttonMask, int x, int y, int z ) +{ + if( buttonMask ) MetaState::localKeyPressed(true); } void Controller::keyboardPlay ( unsigned char key, int x, int y ) Index: crack-attack-1.1.15-cvs-01/src/Controller.h =================================================================== --- crack-attack-1.1.15-cvs-01.orig/src/Controller.h +++ crack-attack-1.1.15-cvs-01/src/Controller.h @@ -39,6 +39,8 @@ /* static */ class Controller { public: static void gameStart ( ); + static void joystickPlay ( unsigned int buttonMask, int x, int y, int z ); + static void joystickMeta ( unsigned int buttonMask, int x, int y, int z ); static void keyboardPlay ( unsigned char key, int x, int y ); static void keyboardUpPlay ( unsigned char key, int x, int y ); static void specialPlay ( int key, int x, int y ); @@ -63,6 +65,7 @@ private: static int state; + static int jstate; }; #endif Index: crack-attack-1.1.15-cvs-01/src/MetaState.cxx =================================================================== --- crack-attack-1.1.15-cvs-01.orig/src/MetaState.cxx +++ crack-attack-1.1.15-cvs-01/src/MetaState.cxx @@ -62,6 +62,7 @@ MessageManager::mode = MM_NORMAL; MessageManager::readyMessage(MS_ANYKEY); + glutJoystickFunc(Controller::joystickMeta,50); glutKeyboardFunc(Controller::keyboardMeta); glutSpecialFunc(Controller::specialMeta); glutKeyboardUpFunc(null); @@ -99,6 +100,7 @@ Game::gameStart(); Displayer::gameStart(); + glutJoystickFunc(Controller::joystickPlay,50); glutKeyboardFunc(Controller::keyboardPlay); glutSpecialFunc(Controller::specialPlay); glutKeyboardUpFunc(Controller::keyboardUpPlay); @@ -150,6 +152,7 @@ } else state = MS_CELEBRATION_WAIT | MS_BOTH_KEY_WAIT; + glutJoystickFunc(Controller::joystickMeta, 50); glutKeyboardFunc(Controller::keyboardMeta); glutSpecialFunc(Controller::specialMeta); glutDisplayFunc(Displayer::displayMeta);