Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 77794 Details for
Bug 119908
games-sports/xmoto-0.1.10 (new ebuild)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
keyboard-0.1.10.patch
keyboard-0.1.10.patch (text/plain), 12.00 KB, created by
Tommie
on 2006-01-22 04:31:45 UTC
(
hide
)
Description:
keyboard-0.1.10.patch
Filename:
MIME Type:
Creator:
Tommie
Created:
2006-01-22 04:31:45 UTC
Size:
12.00 KB
patch
obsolete
>diff -Nru xmoto-0.1.10-orig/src/Game.cpp xmoto-0.1.10/src/Game.cpp >--- xmoto-0.1.10-orig/src/Game.cpp 2005-12-03 12:02:27.000000000 +0100 >+++ xmoto-0.1.10/src/Game.cpp 2006-01-22 13:04:56.000000000 +0100 >@@ -1263,12 +1263,12 @@ > > /* Controls */ > m_Config.createVar( "ControllerMode1", "Keyboard" ); >- m_Config.createVar( "KeyDrive1", "Up" ); >- m_Config.createVar( "KeyBrake1", "Down" ); >- m_Config.createVar( "KeyFlipLeft1", "Left" ); >- m_Config.createVar( "KeyFlipRight1", "Right" ); >- m_Config.createVar( "KeyChangeDir1", "Space" ); >- >+ m_Config.createVar( "KeyDrive1", "273" ); >+ m_Config.createVar( "KeyBrake1", "274" ); >+ m_Config.createVar( "KeyFlipLeft1", "276" ); >+ m_Config.createVar( "KeyFlipRight1", "275" ); >+ m_Config.createVar( "KeyChangeDir1", "32" ); >+ > m_Config.createVar( "JoyIdx1", "-1" ); > m_Config.createVar( "JoyAxisPrim1", "" ); > m_Config.createVar( "JoyAxisPrimMax1", "" ); >diff -Nru xmoto-0.1.10-orig/src/Game.h xmoto-0.1.10/src/Game.h >--- xmoto-0.1.10-orig/src/Game.h 2005-12-03 12:02:27.000000000 +0100 >+++ xmoto-0.1.10/src/Game.h 2006-01-22 12:31:43.000000000 +0100 >@@ -244,7 +244,7 @@ > > void _SimpleMessage(const std::string &Msg); > >- int _IsKeyInUse(const std::string &Key); >+ int _IsKeyInUse(int nKey); > }; > > }; >diff -Nru xmoto-0.1.10-orig/src/GameMenus.cpp xmoto-0.1.10/src/GameMenus.cpp >--- xmoto-0.1.10-orig/src/GameMenus.cpp 2005-12-03 12:02:27.000000000 +0100 >+++ xmoto-0.1.10/src/GameMenus.cpp 2006-01-22 12:31:20.000000000 +0100 >@@ -662,11 +662,25 @@ > > UIListEntry *p; > >- p = pList->addEntry(GAMETEXT_DRIVE); p->Text.push_back(m_Config.getString("KeyDrive1")); >- p = pList->addEntry(GAMETEXT_BRAKE); p->Text.push_back(m_Config.getString("KeyBrake1")); >- p = pList->addEntry(GAMETEXT_FLIPLEFT); p->Text.push_back(m_Config.getString("KeyFlipLeft1")); >- p = pList->addEntry(GAMETEXT_FLIPRIGHT); p->Text.push_back(m_Config.getString("KeyFlipRight1")); >- p = pList->addEntry(GAMETEXT_CHANGEDIR); p->Text.push_back(m_Config.getString("KeyChangeDir1")); >+ p = pList->addEntry(GAMETEXT_DRIVE); >+ p->pvUser = (void*) m_Config.getInteger("KeyDrive1"); >+ p->Text.push_back(m_InputHandler.keyToString((int) p->pvUser)); >+ >+ p = pList->addEntry(GAMETEXT_BRAKE); >+ p->pvUser = (void*) m_Config.getInteger("KeyBrake1"); >+ p->Text.push_back(m_InputHandler.keyToString((int) p->pvUser)); >+ >+ p = pList->addEntry(GAMETEXT_FLIPLEFT); >+ p->pvUser = (void*) m_Config.getInteger("KeyFlipLeft1"); >+ p->Text.push_back(m_InputHandler.keyToString((int) p->pvUser)); >+ >+ p = pList->addEntry(GAMETEXT_FLIPRIGHT); >+ p->pvUser = (void*) m_Config.getInteger("KeyFlipRight1"); >+ p->Text.push_back(m_InputHandler.keyToString((int) p->pvUser)); >+ >+ p = pList->addEntry(GAMETEXT_CHANGEDIR); >+ p->pvUser = (void*) m_Config.getInteger("KeyChangeDir1"); >+ p->Text.push_back(m_InputHandler.keyToString((int) p->pvUser)); > } > > /*=========================================================================== >@@ -1277,11 +1291,11 @@ > /*=========================================================================== > Change a key config/joystick stuff > ===========================================================================*/ >- int GameApp::_IsKeyInUse(const std::string &Key) { >+ int GameApp::_IsKeyInUse(int nKey) { > UIList *pActionList = (UIList *)m_pOptionsWindow->getChild("OPTIONS_TABS:CONTROLS_TAB:KEY_ACTION_LIST"); > > for(int i=0;i<pActionList->getEntries().size();i++) { >- if(pActionList->getEntries()[i]->Text[1] == Key) return i; >+ if(pActionList->getEntries()[i]->pvUser == (void*) nKey) return i; > } > return -1; > } >@@ -1329,12 +1343,12 @@ > > while(1) { > /* Wait for a key */ >- std::string NewKey = m_InputHandler.waitForKey(); >- if(NewKey == "<<QUIT>>") { >+ int NewKey = m_InputHandler.waitForKey(); >+ if(NewKey < 0) { > /* Quit! */ > quit(); > } >- else if(NewKey == "<<CANCEL>>" || NewKey == "") { >+ else if(NewKey == 0) { > /* Do nothing */ > break; > } >@@ -1343,7 +1357,8 @@ > int nAlreadyUsedBy = _IsKeyInUse(NewKey); > > if(nAlreadyUsedBy<0 || nAlreadyUsedBy == nSel) { >- pActionList->getEntries()[nSel]->Text[1] = NewKey; >+ pActionList->getEntries()[nSel]->pvUser = (void*) NewKey; >+ pActionList->getEntries()[nSel]->Text[1] = m_InputHandler.keyToString(NewKey); > break; > } > else { >@@ -1717,11 +1732,11 @@ > else if(pJoystickControl->getChecked()) m_Config.setString("ControllerMode1","Joystick1"); > > for(int i=0;i<pActionList->getEntries().size();i++) { >- if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_DRIVE) m_Config.setString("KeyDrive1",pActionList->getEntries()[i]->Text[1]); >- else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_BRAKE) m_Config.setString("KeyBrake1",pActionList->getEntries()[i]->Text[1]); >- else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_FLIPLEFT) m_Config.setString("KeyFlipLeft1",pActionList->getEntries()[i]->Text[1]); >- else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_FLIPRIGHT) m_Config.setString("KeyFlipRight1",pActionList->getEntries()[i]->Text[1]); >- else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_CHANGEDIR) m_Config.setString("KeyChangeDir1",pActionList->getEntries()[i]->Text[1]); >+ if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_DRIVE) m_Config.setInteger("KeyDrive1",(int) pActionList->getEntries()[i]->pvUser); >+ else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_BRAKE) m_Config.setInteger("KeyBrake1",(int) pActionList->getEntries()[i]->pvUser); >+ else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_FLIPLEFT) m_Config.setInteger("KeyFlipLeft1",(int) pActionList->getEntries()[i]->pvUser); >+ else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_FLIPRIGHT) m_Config.setInteger("KeyFlipRight1",(int) pActionList->getEntries()[i]->pvUser); >+ else if(pActionList->getEntries()[i]->Text[0] == GAMETEXT_CHANGEDIR) m_Config.setInteger("KeyChangeDir1",(int) pActionList->getEntries()[i]->pvUser); > } > > m_Config.setBool("EngineSoundEnable",pEnableEngineSoundButton->getChecked()); >diff -Nru xmoto-0.1.10-orig/src/Input.cpp xmoto-0.1.10/src/Input.cpp >--- xmoto-0.1.10-orig/src/Input.cpp 2005-12-03 12:02:27.000000000 +0100 >+++ xmoto-0.1.10/src/Input.cpp 2006-01-22 12:36:34.000000000 +0100 >@@ -38,75 +38,12 @@ > "ChangeDirection", ACTION_CHANGEDIR, > NULL > }; >- >- /* Key code to string table */ >- InputKeyMap InputHandler::m_KeyMap[] = { >- "Up", SDLK_UP, >- "Down", SDLK_DOWN, >- "Left", SDLK_LEFT, >- "Right", SDLK_RIGHT, >- "Space", SDLK_SPACE, >- "A", SDLK_a, >- "B", SDLK_b, >- "C", SDLK_c, >- "D", SDLK_d, >- "E", SDLK_e, >- "F", SDLK_f, >- "G", SDLK_g, >- "H", SDLK_h, >- "I", SDLK_i, >- "J", SDLK_j, >- "K", SDLK_k, >- "L", SDLK_l, >- "M", SDLK_m, >- "N", SDLK_n, >- "O", SDLK_o, >- "P", SDLK_p, >- "Q", SDLK_q, >- "R", SDLK_r, >- "S", SDLK_s, >- "T", SDLK_t, >- "U", SDLK_u, >- "V", SDLK_v, >- "W", SDLK_w, >- "X", SDLK_x, >- "Y", SDLK_y, >- "Z", SDLK_z, >- "1", SDLK_1, >- "2", SDLK_2, >- "3", SDLK_3, >- "4", SDLK_4, >- "5", SDLK_5, >- "6", SDLK_6, >- "7", SDLK_7, >- "8", SDLK_8, >- "9", SDLK_9, >- "0", SDLK_0, >- /* TODO: add more */ >- NULL >- }; > > /*=========================================================================== > Easy translation between keys and their codes > ===========================================================================*/ >- std::string InputHandler::_KeyToString(int nKey) { >- int i=0; >- while(m_KeyMap[i].pcKey != NULL) { >- if(m_KeyMap[i].nKey == nKey) return m_KeyMap[i].pcKey; >- i++; >- } >- >- return ""; /* unknown! */ >- } >- >- int InputHandler::_StringToKey(const std::string &s) { >- int i=0; >- while(m_KeyMap[i].pcKey != NULL) { >- if(s == m_KeyMap[i].pcKey) return m_KeyMap[i].nKey; >- i++; >- } >- >- return -1; >+ std::string InputHandler::keyToString(int nKey) { >+ return SDL_GetKeyName((SDLKey) nKey); > } > > /*=========================================================================== >@@ -251,9 +188,9 @@ > /*=========================================================================== > Read configuration > ===========================================================================*/ >- std::string InputHandler::waitForKey(void) { >+ int InputHandler::waitForKey(void) { > /* Start waiting for a key */ >- std::string Ret = ""; >+ int Ret = 0; > > bool bWait = true; > while(bWait) { >@@ -264,12 +201,12 @@ > while(SDL_PollEvent(&Event)) { > switch(Event.type) { > case SDL_QUIT: >- return "<<QUIT>>"; >+ return -1; > case SDL_KEYDOWN: >- if(Event.key.keysym.sym == SDLK_ESCAPE) return "<<CANCEL>>"; >+ if(Event.key.keysym.sym == SDLK_ESCAPE) return 0; > >- Ret = _KeyToString(Event.key.keysym.sym); >- if(Ret != "") bWait = false; >+ Ret = (int) Event.key.keysym.sym; >+ if(Ret != 0) bWait = false; > break; > } > } >@@ -298,11 +235,11 @@ > /* We're using the keyboard */ > m_ControllerModeID1 = CONTROLLER_MODE_KEYBOARD; > >- m_nDriveKey1 = _StringToKey(pConfig->getString("KeyDrive1")); >- m_nBrakeKey1 = _StringToKey(pConfig->getString("KeyBrake1")); >- m_nPullBackKey1 = _StringToKey(pConfig->getString("KeyFlipLeft1")); >- m_nPushForwardKey1 = _StringToKey(pConfig->getString("KeyFlipRight1")); >- m_nChangeDirKey1 = _StringToKey(pConfig->getString("KeyChangeDir1")); >+ m_nDriveKey1 = pConfig->getInteger("KeyDrive1"); >+ m_nBrakeKey1 = pConfig->getInteger("KeyBrake1"); >+ m_nPullBackKey1 = pConfig->getInteger("KeyFlipLeft1"); >+ m_nPushForwardKey1 = pConfig->getInteger("KeyFlipRight1"); >+ m_nChangeDirKey1 = pConfig->getInteger("KeyChangeDir1"); > > /* All good? */ > if(m_nDriveKey1<0 || m_nBrakeKey1<0 || m_nPullBackKey1<0 || >diff -Nru xmoto-0.1.10-orig/src/Input.h xmoto-0.1.10/src/Input.h >--- xmoto-0.1.10-orig/src/Input.h 2005-12-03 12:02:27.000000000 +0100 >+++ xmoto-0.1.10/src/Input.h 2006-01-22 12:27:53.000000000 +0100 >@@ -88,10 +88,13 @@ > /* Methods */ > void configure(UserConfig *pConfig); > void handleInput(InputEventType Type,int nKey,BikeController *pController); >- std::string waitForKey(void); >+ int waitForKey(void); > void updateInput(BikeController *pController); > void init(UserConfig *pConfig); > void uninit(void); >+ >+ /* Helpers */ >+ std::string keyToString(int nKey); > > private: > >@@ -125,10 +128,6 @@ > static InputActionType m_ActionTypeTable[]; > static InputKeyMap m_KeyMap[]; > >- /* Helpers */ >- std::string _KeyToString(int nKey); >- int _StringToKey(const std::string &s); >- > /* Set default config */ > void _SetDefaultConfig(void); > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 119908
:
77793
| 77794