* Add support for the input buffer
This commit is contained in:
jean.chalard
2008-11-21 13:20:16 +00:00
parent 31a2202036
commit 03e8d636fc
+54 -31
View File
@@ -63,7 +63,7 @@ static u32 gOldButtons = 0;
static u32 gPSPKeyMasks[17] = static u32 gPSPKeyMasks[17] =
{ {
PSP_CTRL_SELECT, PSP_CTRL_SELECT,
PSP_CTRL_START, PSP_CTRL_START,
PSP_CTRL_UP, PSP_CTRL_UP,
@@ -81,11 +81,11 @@ static u32 gPSPKeyMasks[17] =
PSP_CTRL_NOTE, PSP_CTRL_NOTE,
PSP_CTRL_CIRCLE, PSP_CTRL_CIRCLE,
PSP_CTRL_START, PSP_CTRL_START,
}; };
static u32 gWinKeyCodes[17] = static u32 gWinKeyCodes[17] =
{ {
VK_CONTROL, VK_CONTROL,
VK_RETURN, VK_RETURN,
'Z', 'Z',
@@ -104,7 +104,7 @@ static u32 gWinKeyCodes[17] =
VK_SPACE, VK_SPACE,
VK_ESCAPE VK_ESCAPE
}; };
void JGEControl() void JGEControl()
{ {
@@ -144,10 +144,10 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
height=1; // Making Height Equal One height=1; // Making Height Equal One
} }
actualWidth = width; actualWidth = width;
actualHeight = height; actualHeight = height;
glScissor(0, 0, width, height); glScissor(0, 0, width, height);
glViewport (0, 0, width, height); // Reset The Current Viewport glViewport (0, 0, width, height); // Reset The Current Viewport
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix glLoadIdentity (); // Reset The Projection Matrix
@@ -210,8 +210,8 @@ int InitGame(GLvoid)
void DestroyGame(GLvoid) void DestroyGame(GLvoid)
{ {
// JParticleSystem::Destroy(); // JParticleSystem::Destroy();
// JMotionSystem::Destroy(); // JMotionSystem::Destroy();
g_engine->SetApp(NULL); g_engine->SetApp(NULL);
if (g_app) if (g_app)
@@ -231,14 +231,14 @@ void DestroyGame(GLvoid)
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{ {
// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer // glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
// glLoadIdentity (); // Reset The Modelview Matrix // glLoadIdentity (); // Reset The Modelview Matrix
//if (g_app) //if (g_app)
// g_app->Render(); // g_app->Render();
g_engine->Render(); g_engine->Render();
// glFlush (); // glFlush ();
return TRUE; // Everything Went OK return TRUE; // Everything Went OK
} }
@@ -309,8 +309,8 @@ GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{ {
actualWidth = width; actualWidth = width;
actualHeight = height; actualHeight = height;
GLuint PixelFormat; // Holds The Results After Searching For A Match GLuint PixelFormat; // Holds The Results After Searching For A Match
@@ -491,6 +491,27 @@ actualHeight = height;
return TRUE; // Success return TRUE; // Success
} }
u32 JGEReadKey()
{
if (gKeyBuffer.empty()) return 0;
u32 val = gKeyBuffer.front().first;
gKeyBuffer.pop();
return val;
}
u32 JGEReadLocalKey()
{
if (gKeyBuffer.empty()) return 0;
u32 val = gKeyBuffer.front().second;
gKeyBuffer.pop();
return val;
}
void JGEResetInput()
{
while (!gKeyBuffer.empty()) gKeyBuffer.pop();
}
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information WPARAM wParam, // Additional Message Information
@@ -537,7 +558,9 @@ 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
return 0; // Return for (signed int i = sizeof(gWinKeyCodes)/sizeof(gWinKeyCodes[0]); i > 0; --i)
if (gWinKeyCodes[i] == wParam) { gKeyBuffer.push(make_pair(gPSPKeyMasks[i],0x8000+key)); return 0; }
return 0;
} }
break; // Break break; // Break
@@ -571,7 +594,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
// Mint2D::SetMousePosition(LOWORD(lParam), HIWORD(lParam)); // Mint2D::SetMousePosition(LOWORD(lParam), HIWORD(lParam));
return 0; return 0;
} }
@@ -599,10 +622,10 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
int dt; int dt;
// Ask The User Which Screen Mode They Prefer // Ask The User Which Screen Mode They Prefer
// if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO) // if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
// { // {
// fullscreen=FALSE; // Windowed Mode // fullscreen=FALSE; // Windowed Mode
// } // }
g_launcher = new JGameLauncher(); g_launcher = new JGameLauncher();
@@ -654,17 +677,17 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
} }
} }
// if (keys[VK_F1]) // Is F1 Being Pressed? // if (keys[VK_F1]) // Is F1 Being Pressed?
// { // {
// keys[VK_F1]=FALSE; // If So Make Key FALSE // keys[VK_F1]=FALSE; // If So Make Key FALSE
// KillGLWindow(); // Kill Our Current Window // KillGLWindow(); // Kill Our Current Window
// fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode // fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
// // Recreate Our OpenGL Window // // Recreate Our OpenGL Window
// if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen)) // if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
// { // {
// return 0; // Quit If Window Was Not Created // return 0; // Quit If Window Was Not Created
// } // }
// } // }
} }
} }