* Some adjustments, code fixes, cleaning
This commit is contained in:
jean.chalard
2008-11-21 15:22:21 +00:00
parent 176e551f2f
commit 15f74fbc5a
2 changed files with 20 additions and 17 deletions
+14 -8
View File
@@ -360,7 +360,7 @@ void initGlut(int* argc, char* argv[])
void specialKey(int key, int x __attribute__((unused)), int y __attribute((unused))) void specialKey(int key, int x __attribute__((unused)), int y __attribute((unused)))
{ {
for (signed int i = sizeof(gGlutKeyCodes)/sizeof(gGlutKeyCodes[0]); i > 0; --i) for (signed int i = sizeof(gGlutKeyCodes)/sizeof(gGlutKeyCodes[0]) - 1; i > 0; --i)
if (gGlutKeyCodes[i] == key) if (gGlutKeyCodes[i] == key)
{ {
if (false == gThisFrame[i]) if (false == gThisFrame[i])
@@ -375,14 +375,10 @@ void specialKey(int key, int x __attribute__((unused)), int y __attribute((unuse
} }
void specialUp(int key, int x __attribute__((unused)), int y __attribute((unused))) void specialUp(int key, int x __attribute__((unused)), int y __attribute((unused)))
{ {
for (signed int i = sizeof(gGlutKeyCodes)/sizeof(gGlutKeyCodes[0]); i > 0; --i) for (signed int i = sizeof(gGlutKeyCodes)/sizeof(gGlutKeyCodes[0]) - 1; i > 0; --i)
if (gGlutKeyCodes[i] == key) if (gGlutKeyCodes[i] == key)
{ {
if (false == gThisFrame[i]) gButtons &= ~gPSPKeyMasks[i];
{
gThisFrame[i] = true;
gButtons &= ~gPSPKeyMasks[i];
}
return; return;
} }
} }
@@ -408,7 +404,17 @@ void normalKey(unsigned char key, int x __attribute__((unused)), int y __attribu
} }
} }
for (signed int i = sizeof(gNonGlutKeyCodes)/sizeof(gNonGlutKeyCodes[0]); i > 0; --i) for (signed int i = sizeof(gNonGlutKeyCodes)/sizeof(gNonGlutKeyCodes[0]); i > 0; --i)
if (gNonGlutKeyCodes[i] == key) { gButtons |= gPSPKeyMasks[i]; gKeyPresses |= gPSPKeyMasks[i]; gKeyBuffer.push(make_pair(gPSPKeyMasks[i],key)); return; } if (gNonGlutKeyCodes[i] == key)
{
if (false == gThisFrame[i])
{
gThisFrame[i] = true;
gButtons |= gPSPKeyMasks[i];
gKeyPresses |= gPSPKeyMasks[i];
gKeyBuffer.push(make_pair(gPSPKeyMasks[i],key));
}
return;
}
} }
void normalUp(unsigned char key, int x __attribute__((unused)), int y __attribute((unused))) void normalUp(unsigned char key, int x __attribute__((unused)), int y __attribute((unused)))
{ {
+6 -9
View File
@@ -583,16 +583,13 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
if ((wParam >= 0) && (wParam <= 255)) // Is Key (wParam) In A Valid Range? if ((wParam >= 0) && (wParam <= 255)) // Is Key (wParam) In A Valid Range?
{ {
g_keys[wParam] = TRUE; // Set The Selected Key (wParam) To True g_keys[wParam] = TRUE; // Set The Selected Key (wParam) To True
for (signed int i = sizeof(gWinKeyCodes)/sizeof(gWinKeyCodes[0]); i > 0; --i) for (signed int i = sizeof(gWinKeyCodes)/sizeof(gWinKeyCodes[0]) - 1; i > 0; --i)
if (gWinKeyCodes[i] == wParam) if (gWinKeyCodes[i] == wParam)
{ if (false == gThisFrame[i])
if (false == gThisFrame[i]) {
{ gThisFrame[i] = true;
gThisFrame[i] = true; gKeyBuffer.push(make_pair(gPSPKeyMasks[i], wParam));
gKeyBuffer.push(make_pair(gPSPKeyMasks[i],0x8000+wParam)); }
}
return 0;
}
return 0; return 0;
} }
break; // Break break; // Break