J :
* Add support for the input buffer
This commit is contained in:
+54
-31
@@ -63,7 +63,7 @@ static u32 gOldButtons = 0;
|
||||
|
||||
|
||||
static u32 gPSPKeyMasks[17] =
|
||||
{
|
||||
{
|
||||
PSP_CTRL_SELECT,
|
||||
PSP_CTRL_START,
|
||||
PSP_CTRL_UP,
|
||||
@@ -81,11 +81,11 @@ static u32 gPSPKeyMasks[17] =
|
||||
PSP_CTRL_NOTE,
|
||||
PSP_CTRL_CIRCLE,
|
||||
PSP_CTRL_START,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
static u32 gWinKeyCodes[17] =
|
||||
{
|
||||
{
|
||||
VK_CONTROL,
|
||||
VK_RETURN,
|
||||
'Z',
|
||||
@@ -104,7 +104,7 @@ static u32 gWinKeyCodes[17] =
|
||||
VK_SPACE,
|
||||
VK_ESCAPE
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
void JGEControl()
|
||||
{
|
||||
@@ -144,10 +144,10 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
|
||||
height=1; // Making Height Equal One
|
||||
}
|
||||
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
|
||||
glScissor(0, 0, width, height);
|
||||
glScissor(0, 0, width, height);
|
||||
glViewport (0, 0, width, height); // Reset The Current Viewport
|
||||
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
|
||||
glLoadIdentity (); // Reset The Projection Matrix
|
||||
@@ -210,8 +210,8 @@ int InitGame(GLvoid)
|
||||
|
||||
void DestroyGame(GLvoid)
|
||||
{
|
||||
// JParticleSystem::Destroy();
|
||||
// JMotionSystem::Destroy();
|
||||
// JParticleSystem::Destroy();
|
||||
// JMotionSystem::Destroy();
|
||||
|
||||
g_engine->SetApp(NULL);
|
||||
if (g_app)
|
||||
@@ -231,14 +231,14 @@ void DestroyGame(GLvoid)
|
||||
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
|
||||
// glLoadIdentity (); // Reset The Modelview Matrix
|
||||
// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
|
||||
// glLoadIdentity (); // Reset The Modelview Matrix
|
||||
|
||||
//if (g_app)
|
||||
// g_app->Render();
|
||||
g_engine->Render();
|
||||
|
||||
// glFlush ();
|
||||
// glFlush ();
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
|
||||
|
||||
GLuint PixelFormat; // Holds The Results After Searching For A Match
|
||||
@@ -491,6 +491,27 @@ actualHeight = height;
|
||||
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
|
||||
UINT uMsg, // Message For This Window
|
||||
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?
|
||||
{
|
||||
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
|
||||
|
||||
@@ -571,7 +594,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
// Mint2D::SetMousePosition(LOWORD(lParam), HIWORD(lParam));
|
||||
// Mint2D::SetMousePosition(LOWORD(lParam), HIWORD(lParam));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -599,10 +622,10 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
|
||||
int dt;
|
||||
|
||||
// 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)
|
||||
// {
|
||||
// fullscreen=FALSE; // Windowed Mode
|
||||
// }
|
||||
// if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
|
||||
// {
|
||||
// fullscreen=FALSE; // Windowed Mode
|
||||
// }
|
||||
|
||||
g_launcher = new JGameLauncher();
|
||||
|
||||
@@ -654,17 +677,17 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
|
||||
}
|
||||
}
|
||||
|
||||
// if (keys[VK_F1]) // Is F1 Being Pressed?
|
||||
// {
|
||||
// keys[VK_F1]=FALSE; // If So Make Key FALSE
|
||||
// KillGLWindow(); // Kill Our Current Window
|
||||
// fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
|
||||
// // Recreate Our OpenGL Window
|
||||
// if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
|
||||
// {
|
||||
// return 0; // Quit If Window Was Not Created
|
||||
// }
|
||||
// }
|
||||
// if (keys[VK_F1]) // Is F1 Being Pressed?
|
||||
// {
|
||||
// keys[VK_F1]=FALSE; // If So Make Key FALSE
|
||||
// KillGLWindow(); // Kill Our Current Window
|
||||
// fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
|
||||
// // Recreate Our OpenGL Window
|
||||
// if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
|
||||
// {
|
||||
// return 0; // Quit If Window Was Not Created
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user