[Opentnl-cvs] tnl/zap UIInstructions.cpp,1.9,1.10 UIMenus.cpp,1.26,1.27 game.h,1.68,1.69 gameType.cp
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-10-08 00:18:09
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11621/zap Modified Files: UIInstructions.cpp UIMenus.cpp game.h gameType.cpp gameType.h huntersGame.cpp huntersGame.h input.cpp input.h quickChat.cpp winJoystick.cpp Log Message: Added objective rendering to Hunters game type Added support for Logitech's Dual Action controller Incremented game version Index: input.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/input.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input.h 28 Sep 2004 17:34:13 -0000 1.3 --- input.h 8 Oct 2004 00:17:47 -0000 1.4 *************** *** 33,43 **** { ! enum JoystickType { LogitechWingman, SaitekDualAnalog, PS2DualShock, XBoxController, XBoxControllerOnXBox, }; --- 33,45 ---- { ! enum ControllerTypeType { LogitechWingman, + LogitechDualAction, SaitekDualAnalog, PS2DualShock, XBoxController, XBoxControllerOnXBox, + ControllerTypeCount, }; *************** *** 54,63 **** ControllerButtonRightTrigger = 1 << 7, ControllerGameButtonCount = 8, ! ControllerButtonStart = 1 << 16, ! ControllerButtonBack = 1 << 17, ! ControllerButtonDPadUp = 1 << 18, ! ControllerButtonDPadDown = 1 << 19, ! ControllerButtonDPadLeft = 1 << 20, ! ControllerButtonDPadRight = 1 << 21, }; --- 56,65 ---- ControllerButtonRightTrigger = 1 << 7, ControllerGameButtonCount = 8, ! ControllerButtonStart = 1 << 8, ! ControllerButtonBack = 1 << 9, ! ControllerButtonDPadUp = 1 << 10, ! ControllerButtonDPadDown = 1 << 11, ! ControllerButtonDPadLeft = 1 << 12, ! ControllerButtonDPadRight = 1 << 13, }; *************** *** 71,75 **** S32 autodetectJoystickType(); void ShutdownJoystick(); ! bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask); }; --- 73,77 ---- S32 autodetectJoystickType(); void ShutdownJoystick(); ! bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask, U32 &hatMask); }; Index: gameType.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** gameType.cpp 5 Oct 2004 23:41:59 -0000 1.62 --- gameType.cpp 8 Oct 2004 00:17:47 -0000 1.63 *************** *** 241,264 **** nearestPoint.y = r.min.y; ! Point rp = gClientGame->worldToScreenPoint(nearestPoint); ! Point center(400, 300); ! Point arrowDir = rp - center; ! /* ! if(rp.x > UserInterface::horizMargin && ! rp.x < UserInterface::canvasWidth - UserInterface::horizMargin && ! rp.y > UserInterface::vertMargin && ! rp.y < UserInterface::canvasHeight - UserInterface::vertMargin) return; ! if(rp.x < UserInterface::horizMargin) ! rp.x = UserInterface::horizMargin; ! if(rp.x > UserInterface::canvasWidth - UserInterface::horizMargin) ! rp.x = UserInterface::canvasWidth - UserInterface::horizMargin; ! if(rp.y < UserInterface::vertMargin) ! rp.y = UserInterface::vertMargin; ! if(rp.y > UserInterface::canvasHeight - UserInterface::vertMargin) ! rp.y = UserInterface::canvasHeight - UserInterface::vertMargin; ! */ F32 er = arrowDir.x * arrowDir.x / (350 * 350) + arrowDir.y * arrowDir.y / (250 * 250); --- 241,259 ---- nearestPoint.y = r.min.y; ! renderObjectiveArrow(nearestPoint, c, alphaMod); ! } ! void GameType::renderObjectiveArrow(Point nearestPoint, Color c, F32 alphaMod) ! { ! GameConnection *gc = gClientGame->getConnectionToServer(); ! GameObject *co = NULL; ! if(gc) ! co = gc->getControlObject(); ! if(!co) return; ! Point rp = gClientGame->worldToScreenPoint(nearestPoint); ! Point center(400, 300); ! Point arrowDir = rp - center; F32 er = arrowDir.x * arrowDir.x / (350 * 350) + arrowDir.y * arrowDir.y / (250 * 250); Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** game.h 5 Oct 2004 23:41:59 -0000 1.68 --- game.h 8 Oct 2004 00:17:47 -0000 1.69 *************** *** 236,240 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.4.6" }; --- 236,240 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.4.7" }; Index: quickChat.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/quickChat.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** quickChat.cpp 28 Sep 2004 18:45:25 -0000 1.17 --- quickChat.cpp 8 Oct 2004 00:17:47 -0000 1.18 *************** *** 35,38 **** --- 35,39 ---- namespace Zap { + void renderControllerButton(F32 x, F32 y, U32 buttonIndex, U32 keyIndex); VChatHelper::VChatNode VChatHelper::mChatTree[] = *************** *** 100,204 **** }; - extern void drawCircle(Point pos, F32 radius); - void renderControllerButton(F32 x, F32 y, U32 buttonIndex, U32 keyIndex) - { - S32 joy = OptionsMenuUserInterface::joystickType; - - if(joy == -1) - UserInterface::drawStringf(x, y, 15, "%c", keyIndex); - else if(joy == LogitechWingman) - { - glColor3f(1,1,1); - const char buttons[] = "ABCXYZ"; - drawCircle(Point(x + 8, y + 8), 8); - UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); - } - else if(joy == SaitekDualAnalog) - { - glColor3f(1,1,1); - const char buttons[] = "123456"; - drawCircle(Point(x + 8, y + 8), 8); - UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); - } - else if(joy == PS2DualShock) - { - static F32 color[6][3] = { { 0.5, 0.5, 1 }, - { 1, 0.5, 0.5 }, - { 1, 0.5, 1 }, - { 0.5, 1, 0.5 }, - { 0.7, 0.7, 0.7 }, - { 0.7, 0.7, 0.7 } - }; - Color c(color[buttonIndex][0], color[buttonIndex][1], color[buttonIndex][2]); - glColor3f(1.0, 1.0, 1.0); - Point center(x + 8, y + 8); - if(buttonIndex < 4) - { - drawCircle(center, 8); - glColor(c); - switch(buttonIndex) - { - case 0: - glBegin(GL_LINES); - glVertex(center + Point(-5, -5)); - glVertex(center + Point(5, 5)); - glVertex(center + Point(-5, 5)); - glVertex(center + Point(5, -5)); - glEnd(); - break; - case 1: - drawCircle(center, 5); - break; - case 2: - glBegin(GL_LINE_LOOP); - glVertex(center + Point(-5, -5)); - glVertex(center + Point(-5, 5)); - glVertex(center + Point(5, 5)); - glVertex(center + Point(5, -5)); - glEnd(); - break; - case 3: - glBegin(GL_LINE_LOOP); - glVertex(center + Point(0, -5)); - glVertex(center + Point(5, 3)); - glVertex(center + Point(-5, 3)); - glEnd(); - break; - } - } - else - { - glBegin(GL_LINE_LOOP); - glVertex(center + Point(-8, -8)); - glVertex(center + Point(-8, 8)); - glVertex(center + Point(10, 8)); - glVertex(center + Point(10, -8)); - glEnd(); - static const char *buttonIndexString[4] = { - "L2", "R2", "L1", "R1" - }; - UserInterface::drawString(x + 2, y + 2, 11, buttonIndexString[buttonIndex - 4]); - } - } - else if(joy == XBoxController || joy == XBoxControllerOnXBox) - { - static F32 color[6][3] = { { 0, 1, 0 }, - { 1, 0, 0 }, - { 0, 0, 1 }, - { 1, 1, 0 }, - { 1, 1, 1 }, - { 0, 0, 0} }; - Color c(color[buttonIndex][0], color[buttonIndex][1], color[buttonIndex][2]); - - glColor(c * 0.8f); - fillCircle(Point(x + 8, y + 8), 8); - const char buttons[] = "ABXY "; - glColor3f(1,1,1); - drawCircle(Point(x + 8, y + 8), 8); - glColor(c); - UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); - } - } - VChatHelper::VChatHelper() { --- 101,104 ---- Index: huntersGame.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/huntersGame.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** huntersGame.h 24 Jun 2004 22:50:19 -0000 1.5 --- huntersGame.h 8 Oct 2004 00:17:47 -0000 1.6 *************** *** 47,50 **** --- 47,57 ---- Timer mNexusCapTimer; + struct YardSaleWaypoint + { + Timer timeLeft; + Point pos; + }; + Vector<YardSaleWaypoint> mYardSaleWaypoints; + SafePtr<HuntersNexusObject> mNexus; public: bool mCanNexusCap; *************** *** 53,56 **** --- 60,64 ---- void processArguments(S32 argc, const char **argv); + void addNexus(HuntersNexusObject *theObject); void shipTouchNexus(Ship *theShip, HuntersNexusObject *theNexus); void onGhostAvailable(GhostConnection *theConnection); *************** *** 64,67 **** --- 72,81 ---- enum { + DefaultNexusReturnDelay = 60000, + DefaultNexusCapDelay = 15000, + YardSaleWaypointTime = 5000, + YardSaleCount = 8, + }; + enum { HuntersMsgScore, HuntersMsgYardSale, *************** *** 70,73 **** --- 84,88 ---- }; + TNL_DECLARE_RPC(s2cAddYardSaleWaypoint, (F32 x, F32 y)); TNL_DECLARE_RPC(s2cSetNexusTimer, (U32 nexusTime, bool canCap)); TNL_DECLARE_RPC(s2cHuntersMessage, (U32 msgIndex, StringTableEntryRef clientName, U32 flagCount)); Index: winJoystick.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/winJoystick.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** winJoystick.cpp 29 Sep 2004 23:53:21 -0000 1.21 --- winJoystick.cpp 8 Oct 2004 00:17:47 -0000 1.22 *************** *** 124,132 **** return DIENUM_CONTINUE; strcpy(gJoystickName, pdidInstance->tszProductName); return DIENUM_STOP; } ! bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask) { // mark: it's ok --- 124,133 ---- return DIENUM_CONTINUE; strcpy(gJoystickName, pdidInstance->tszProductName); + logprintf("Joystick found: %s", gJoystickName); return DIENUM_STOP; } ! bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask, U32 &hatMask) { // mark: it's ok *************** *** 178,203 **** { case 0: ! buttonMask |= ControllerButtonDPadUp; break; case 4500: ! buttonMask |= ControllerButtonDPadUp | ControllerButtonDPadRight; break; case 9000: ! buttonMask |= ControllerButtonDPadRight; ! break; case 13500: ! buttonMask |= ControllerButtonDPadRight | ControllerButtonDPadDown; break; case 18000: ! buttonMask |= ControllerButtonDPadDown; break; case 22500: ! buttonMask |= ControllerButtonDPadDown | ControllerButtonDPadLeft; break; case 27000: ! buttonMask |= ControllerButtonDPadLeft; break; case 31500: ! buttonMask |= ControllerButtonDPadLeft | ControllerButtonDPadUp; break; } --- 179,204 ---- { case 0: ! hatMask |= ControllerButtonDPadUp; break; case 4500: ! hatMask |= ControllerButtonDPadUp | ControllerButtonDPadRight; break; case 9000: ! hatMask |= ControllerButtonDPadRight; ! break; case 13500: ! hatMask |= ControllerButtonDPadRight | ControllerButtonDPadDown; break; case 18000: ! hatMask |= ControllerButtonDPadDown; break; case 22500: ! hatMask |= ControllerButtonDPadDown | ControllerButtonDPadLeft; break; case 27000: ! hatMask |= ControllerButtonDPadLeft; break; case 31500: ! hatMask |= ControllerButtonDPadLeft | ControllerButtonDPadUp; break; } Index: UIMenus.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIMenus.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** UIMenus.cpp 5 Oct 2004 23:41:59 -0000 1.26 --- UIMenus.cpp 8 Oct 2004 00:17:47 -0000 1.27 *************** *** 34,37 **** --- 34,38 ---- #include "UIEditor.h" #include "UIInstructions.h" + #include "input.h" #include "glutInclude.h" *************** *** 285,301 **** menuItems.push_back(MenuItem("INPUT: KEYBOARD + MOUSE",2)); break; ! case 0: menuItems.push_back(MenuItem("INPUT: LOGITECH WINGMAN DUAL-ANALOG",2)); break; ! case 1: menuItems.push_back(MenuItem("INPUT: SAITEK P-880 DUAL-ANALOG",2)); break; ! case 2: menuItems.push_back(MenuItem("INPUT: PS2 DUALSHOCK USB",2)); break; ! case 3: menuItems.push_back(MenuItem("INPUT: XBOX CONTROLLER USB",2)); break; ! case 4: menuItems.push_back(MenuItem("INPUT: XBOX CONTROLLER",2)); break; --- 286,305 ---- menuItems.push_back(MenuItem("INPUT: KEYBOARD + MOUSE",2)); break; ! case LogitechWingman: menuItems.push_back(MenuItem("INPUT: LOGITECH WINGMAN DUAL-ANALOG",2)); break; ! case LogitechDualAction: ! menuItems.push_back(MenuItem("INPUT: LOGITECH DUAL ACTION",2)); ! break; ! case SaitekDualAnalog: menuItems.push_back(MenuItem("INPUT: SAITEK P-880 DUAL-ANALOG",2)); break; ! case PS2DualShock: menuItems.push_back(MenuItem("INPUT: PS2 DUALSHOCK USB",2)); break; ! case XBoxController: menuItems.push_back(MenuItem("INPUT: XBOX CONTROLLER USB",2)); break; ! case XBoxControllerOnXBox: menuItems.push_back(MenuItem("INPUT: XBOX CONTROLLER",2)); break; *************** *** 334,338 **** case 2: joystickType++; ! if(joystickType > 3) joystickType = -1; break; --- 338,342 ---- case 2: joystickType++; ! if(joystickType > XBoxController) joystickType = -1; break; Index: huntersGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/huntersGame.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** huntersGame.cpp 25 Sep 2004 01:26:37 -0000 1.11 --- huntersGame.cpp 8 Oct 2004 00:17:47 -0000 1.12 *************** *** 39,42 **** --- 39,43 ---- TNL_IMPLEMENT_NETOBJECT(HuntersGameType); + TNL_IMPLEMENT_NETOBJECT_RPC(HuntersGameType, s2cSetNexusTimer, (U32 nexusTime, bool canCap), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) *************** *** 46,49 **** --- 47,58 ---- } + GAMETYPE_RPC_S2C(HuntersGameType, s2cAddYardSaleWaypoint, (F32 x, F32 y)) + { + YardSaleWaypoint w; + w.timeLeft.reset(YardSaleWaypointTime); + w.pos.set(x,y); + mYardSaleWaypoints.push_back(w); + } + TNL_IMPLEMENT_NETOBJECT_RPC(HuntersGameType, s2cHuntersMessage, (U32 msgIndex, StringTableEntryRef clientName, U32 flagCount), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) *************** *** 88,91 **** --- 97,105 ---- } + void HuntersGameType::addNexus(HuntersNexusObject *nexus) + { + mNexus = nexus; + } + void HuntersGameType::processArguments(S32 argc, const char **argv) { *************** *** 150,153 **** --- 164,174 ---- { mNexusReturnTimer.update(deltaT); + for(S32 i = 0; i < mYardSaleWaypoints.size();) + { + if(mYardSaleWaypoints[i].timeLeft.update(deltaT)) + mYardSaleWaypoints.erase_fast(i); + else + i++; + } return; } *************** *** 158,161 **** --- 179,186 ---- mCanNexusCap = true; s2cSetNexusTimer(mNexusCapTimer.getCurrent(), mCanNexusCap); + static StringTableEntry msg("The Nexus is now OPEN!"); + for(S32 i = 0; i < mClientList.size(); i++) + mClientList[i]->clientConnection->s2cDisplayMessage( + GameConnection::ColorNuclearGreen, SFXFlagSnatch, msg); } else if(mNexusCapTimer.update(deltaT)) *************** *** 164,167 **** --- 189,196 ---- mCanNexusCap = false; s2cSetNexusTimer(mNexusReturnTimer.getCurrent(), mCanNexusCap); + static StringTableEntry msg("The Nexus is now CLOSED."); + for(S32 i = 0; i < mClientList.size(); i++) + mClientList[i]->clientConnection->s2cDisplayMessage( + GameConnection::ColorNuclearGreen, SFXFlagDrop, msg); } } *************** *** 177,180 **** --- 206,212 ---- UserInterface::drawStringf(UserInterface::canvasWidth - UserInterface::horizMargin - 65, UserInterface::canvasHeight - UserInterface::vertMargin - 45, 20, "%02d:%02d", minsRemaining, secsRemaining); + for(S32 i = 0; i < mYardSaleWaypoints.size(); i++) + renderObjectiveArrow(mYardSaleWaypoints[i].pos, Color(1,1,1)); + renderObjectiveArrow(mNexus, mCanNexusCap ? Color(0,1,0) : Color(0.5, 0, 0)); } *************** *** 194,199 **** if(theFlag) { ! if(theFlag->getFlagCount() > 2) s2cHuntersMessage(HuntersMsgYardSale, theShip->mPlayerName.getString(), 0); return; --- 226,235 ---- if(theFlag) { ! if(theFlag->getFlagCount() >= YardSaleCount) ! { ! Point pos = theFlag->getActualPos(); ! s2cAddYardSaleWaypoint(pos.x, pos.y); s2cHuntersMessage(HuntersMsgYardSale, theShip->mPlayerName.getString(), 0); + } return; *************** *** 375,390 **** if(!isGhost()) setScopeAlways(); } void HuntersNexusObject::render() { ! F32 alpha = 0.2; HuntersGameType *theGameType = dynamic_cast<HuntersGameType *>(getGame()->getGameType()); if(theGameType && theGameType->mCanNexusCap) ! alpha = 0.5; ! Color theColor = getGame()->getGameType()->mTeams[0].color; ! glColor(theColor * alpha); glBegin(GL_POLYGON); glVertex2f(nexusBounds.min.x, nexusBounds.min.y); glVertex2f(nexusBounds.min.x, nexusBounds.max.y); --- 411,435 ---- if(!isGhost()) setScopeAlways(); + ((HuntersGameType *) theGame->getGameType())->addNexus(this); } void HuntersNexusObject::render() { ! Color c; HuntersGameType *theGameType = dynamic_cast<HuntersGameType *>(getGame()->getGameType()); if(theGameType && theGameType->mCanNexusCap) ! c.set(0,1,0); ! else ! c.set(0.5, 0, 0); ! glColor(c * 0.5); glBegin(GL_POLYGON); + glVertex2f(nexusBounds.min.x, nexusBounds.min.y); + glVertex2f(nexusBounds.min.x, nexusBounds.max.y); + glVertex2f(nexusBounds.max.x, nexusBounds.max.y); + glVertex2f(nexusBounds.max.x, nexusBounds.min.y); + glEnd(); + glColor(c); + glBegin(GL_LINE_LOOP); glVertex2f(nexusBounds.min.x, nexusBounds.min.y); glVertex2f(nexusBounds.min.x, nexusBounds.max.y); *************** *** 397,401 **** --- 442,448 ---- { polyPoints.push_back(nexusBounds.min); + polyPoints.push_back(Point(nexusBounds.max.x, nexusBounds.min.y)); polyPoints.push_back(nexusBounds.max); + polyPoints.push_back(Point(nexusBounds.min.x, nexusBounds.max.y)); return true; } Index: gameType.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** gameType.h 5 Oct 2004 23:41:59 -0000 1.36 --- gameType.h 8 Oct 2004 00:17:47 -0000 1.37 *************** *** 156,159 **** --- 156,160 ---- virtual void renderInterfaceOverlay(bool scoreboardVisible); void renderObjectiveArrow(GameObject *target, Color c, F32 alphaMod = 1.0f); + void renderObjectiveArrow(Point p, Color c, F32 alphaMod = 1.0f); void renderTimeLeft(); Index: UIInstructions.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIInstructions.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** UIInstructions.cpp 5 Oct 2004 23:41:59 -0000 1.9 --- UIInstructions.cpp 8 Oct 2004 00:17:47 -0000 1.10 *************** *** 177,181 **** glColor3f(1,1,1); drawString(col1, y, 20, controls[i].controlString); ! if(OptionsMenuUserInterface::joystickType == PS2DualShock && (i == 2 || i == 3)) renderControllerButton(col2, y + 4, i + 4, i + 4); else if(gamepad && !controls[i].primaryControl[0]) --- 177,181 ---- glColor3f(1,1,1); drawString(col1, y, 20, controls[i].controlString); ! if((OptionsMenuUserInterface::joystickType == LogitechDualAction || OptionsMenuUserInterface::joystickType == PS2DualShock) && (i == 2 || i == 3)) renderControllerButton(col2, y + 4, i + 4, i + 4); else if(gamepad && !controls[i].primaryControl[0]) Index: input.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/input.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** input.cpp 1 Oct 2004 00:21:40 -0000 1.5 --- input.cpp 8 Oct 2004 00:17:47 -0000 1.6 *************** *** 32,39 **** --- 32,253 ---- #include <math.h> #include "glutInclude.h" + #include "gameObjectRender.h" namespace Zap { + extern void drawCircle(Point pos, F32 radius); + void renderControllerButton(F32 x, F32 y, U32 buttonIndex, U32 keyIndex) + { + S32 joy = OptionsMenuUserInterface::joystickType; + + if(joy == -1) + UserInterface::drawStringf(x, y, 15, "%c", keyIndex); + else if(joy == LogitechWingman) + { + glColor3f(1,1,1); + const char buttons[] = "ABCXYZ"; + drawCircle(Point(x + 8, y + 8), 8); + UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); + } + else if(joy == LogitechDualAction) + { + glColor3f(1,1,1); + const char buttons[] = "12347856"; + drawCircle(Point(x + 8, y + 8), 8); + UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); + } + else if(joy == SaitekDualAnalog) + { + glColor3f(1,1,1); + const char buttons[] = "123456"; + drawCircle(Point(x + 8, y + 8), 8); + UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); + } + else if(joy == PS2DualShock) + { + static F32 color[6][3] = { { 0.5, 0.5, 1 }, + { 1, 0.5, 0.5 }, + { 1, 0.5, 1 }, + { 0.5, 1, 0.5 }, + { 0.7, 0.7, 0.7 }, + { 0.7, 0.7, 0.7 } + }; + Color c(color[buttonIndex][0], color[buttonIndex][1], color[buttonIndex][2]); + glColor3f(1.0, 1.0, 1.0); + Point center(x + 8, y + 8); + if(buttonIndex < 4) + { + drawCircle(center, 8); + glColor(c); + switch(buttonIndex) + { + case 0: + glBegin(GL_LINES); + glVertex(center + Point(-5, -5)); + glVertex(center + Point(5, 5)); + glVertex(center + Point(-5, 5)); + glVertex(center + Point(5, -5)); + glEnd(); + break; + case 1: + drawCircle(center, 5); + break; + case 2: + glBegin(GL_LINE_LOOP); + glVertex(center + Point(-5, -5)); + glVertex(center + Point(-5, 5)); + glVertex(center + Point(5, 5)); + glVertex(center + Point(5, -5)); + glEnd(); + break; + case 3: + glBegin(GL_LINE_LOOP); + glVertex(center + Point(0, -5)); + glVertex(center + Point(5, 3)); + glVertex(center + Point(-5, 3)); + glEnd(); + break; + } + } + else + { + glBegin(GL_LINE_LOOP); + glVertex(center + Point(-8, -8)); + glVertex(center + Point(-8, 8)); + glVertex(center + Point(10, 8)); + glVertex(center + Point(10, -8)); + glEnd(); + static const char *buttonIndexString[4] = { + "L2", "R2", "L1", "R1" + }; + UserInterface::drawString(x + 2, y + 2, 11, buttonIndexString[buttonIndex - 4]); + } + } + else if(joy == XBoxController || joy == XBoxControllerOnXBox) + { + static F32 color[6][3] = { { 0, 1, 0 }, + { 1, 0, 0 }, + { 0, 0, 1 }, + { 1, 1, 0 }, + { 1, 1, 1 }, + { 0, 0, 0} }; + Color c(color[buttonIndex][0], color[buttonIndex][1], color[buttonIndex][2]); + + glColor(c * 0.8f); + fillCircle(Point(x + 8, y + 8), 8); + const char buttons[] = "ABXY "; + glColor3f(1,1,1); + drawCircle(Point(x + 8, y + 8), 8); + glColor(c); + UserInterface::drawStringf(x + 4, y + 2, 12, "%c", buttons[buttonIndex]); + } + } + + static U32 gShootAxisRemaps[ControllerTypeCount][2] = + { + { 5, 6 }, { 2, 5 }, { 5, 2 }, { 2, 5 }, { 3, 4 }, { 3, 4 }, + }; + + static U32 gControllerButtonRemaps[ControllerTypeCount][MaxJoystickButtons] = + { + { // LogitechWingman + ControllerButton1, + ControllerButton2, + ControllerButton3, + ControllerButton4, + ControllerButton5, + ControllerButton6, + ControllerButtonLeftTrigger, + ControllerButtonRightTrigger, + ControllerButtonBack, + 0, + 0, + 0, + 0, + 0, + }, + { // LogitechDualAction + ControllerButton1, + ControllerButton2, + ControllerButton3, + ControllerButton4, + ControllerButtonLeftTrigger, + ControllerButtonRightTrigger, + ControllerButton5, + ControllerButton6, + ControllerButtonBack, + ControllerButtonStart, + 0, + 0, + 0, + 0, + }, + { // SaitekDualAnalog + ControllerButton1, + ControllerButton2, + ControllerButton3, + ControllerButton4, + ControllerButton5, + ControllerButton6, + ControllerButtonLeftTrigger, + ControllerButtonRightTrigger, + 0, + 0, + ControllerButtonBack, + 0, + 0, + 0, + }, + { // PS2DualShock + ControllerButton4, + ControllerButton2, + ControllerButton1, + ControllerButton3, + ControllerButton5, + ControllerButton6, + ControllerButtonLeftTrigger, + ControllerButtonRightTrigger, + ControllerButtonBack, + 0, + 0, + ControllerButtonStart, + 0, + 0, + }, + { // XBoxController + ControllerButton1, + ControllerButton2, + ControllerButton3, + ControllerButton4, + ControllerButton6, + ControllerButton5, + ControllerButtonStart, + ControllerButtonBack, + 0, + 0, + ControllerButtonLeftTrigger, + ControllerButtonRightTrigger, + 0, + 0, + }, + { // XBoxControllerOnXBox + 1 << 0, + 1 << 1, + 1 << 2, + 1 << 3, + 1 << 4, + 1 << 5, + 1 << 6, + 1 << 7, + 1 << 8, + 1 << 9, + 1 << 10, + 1 << 11, + 1 << 12, + 1 << 13, + } + }; + static bool updateMoveInternal( Move *theMove, U32 &buttonMask ) { *************** *** 41,46 **** static F32 minValues[2] = { - 0.5, -0.5 }; static F32 maxValues[2] = { 0.5, 0.5 }; ! ! if(!ReadJoystick(axes, buttonMask)) return false; --- 255,260 ---- static F32 minValues[2] = { - 0.5, -0.5 }; static F32 maxValues[2] = { 0.5, 0.5 }; ! U32 hatMask = 0; ! if(!ReadJoystick(axes, buttonMask, hatMask)) return false; *************** *** 93,116 **** controls[1] = dir.y; } ! switch(OptionsMenuUserInterface::joystickType) ! { ! case LogitechWingman: ! controls[2] = axes[5]; ! controls[3] = axes[6]; ! break; ! case SaitekDualAnalog: ! controls[2] = axes[5]; ! controls[3] = axes[2]; ! break; ! case PS2DualShock: ! controls[2] = axes[2]; ! controls[3] = axes[5]; ! break; ! case XBoxController: ! case XBoxControllerOnXBox: ! controls[2] = axes[3]; ! controls[3] = axes[4]; ! break; ! } for(U32 i = 0; i < 4; i++) --- 307,312 ---- controls[1] = dir.y; } ! controls[2] = axes[gShootAxisRemaps[OptionsMenuUserInterface::joystickType][0]]; ! controls[3] = axes[gShootAxisRemaps[OptionsMenuUserInterface::joystickType][1]]; for(U32 i = 0; i < 4; i++) *************** *** 156,235 **** theMove->fire = false; ! ! // Remap crazy xbox inputs... ! if(OptionsMenuUserInterface::joystickType == LogitechWingman) ! { ! if(buttonMask & (1 << 8)) ! { ! buttonMask |= ControllerButtonBack; ! buttonMask &= ~(1 << 8); ! } ! } ! else if(OptionsMenuUserInterface::joystickType == SaitekDualAnalog) ! { ! static U32 retMasks[12] = { ! ControllerButton1, ! ControllerButton2, ! ControllerButton3, ! ControllerButton4, ! ControllerButton5, ! ControllerButton6, ! ControllerButtonLeftTrigger, ! ControllerButtonRightTrigger, ! 0, ! 0, ! ControllerButtonBack, ! 0, ! }; ! U32 retMask = 0; ! for(S32 i = 0; i < 12; i++) ! if(buttonMask & (1 << i)) ! retMask |= retMasks[i]; ! buttonMask = retMask; ! } ! else if(OptionsMenuUserInterface::joystickType == PS2DualShock) ! { ! static U32 retMasks[12] = { ! ControllerButton4, ! ControllerButton2, ! ControllerButton1, ! ControllerButton3, ! ControllerButton5, ! ControllerButton6, ! ControllerButtonLeftTrigger, ! ControllerButtonRightTrigger, ! ControllerButtonBack, ! 0, ! 0, ! ControllerButtonStart, ! }; ! U32 retMask = 0; ! for(S32 i = 0; i < 12; i++) ! if(buttonMask & (1 << i)) ! retMask |= retMasks[i]; ! buttonMask = retMask; ! } ! else if(OptionsMenuUserInterface::joystickType == XBoxController) ! { ! static U32 retMasks[12] = { ! ControllerButton1, ! ControllerButton2, ! ControllerButton3, ! ControllerButton4, ! ControllerButton6, ! ControllerButton5, ! ControllerButtonStart, ! ControllerButtonBack, ! 0, ! 0, ! ControllerButtonLeftTrigger, ! ControllerButtonRightTrigger, ! }; ! U32 retMask = 0; ! for(S32 i = 0; i < 12; i++) ! if(buttonMask & (1 << i)) ! retMask |= retMasks[i]; ! buttonMask = retMask; ! } return true; } --- 352,361 ---- theMove->fire = false; ! // remap button inputs ! U32 retMask = 0; ! for(S32 i = 0; i < MaxJoystickButtons; i++) ! if(buttonMask & (1 << i)) ! retMask |= gControllerButtonRemaps[OptionsMenuUserInterface::joystickType][i]; ! buttonMask = retMask | hatMask; return true; } *************** *** 253,256 **** --- 379,384 ---- else if(strstr(joystickName, "P880")) ret = SaitekDualAnalog; + else if(strstr(joystickName, "Logitech Dual Action")) + ret = LogitechDualAction; TNL_JOURNAL_WRITE_BLOCK(JoystickAutodetect, TNL_JOURNAL_WRITE((ret)); |