🔒 Locked
Input Libraries....
Advertisement
Original Post
what kind of rendering are you trying to do?
it is completely possible to use SDL for input and creation of a window, but use opengl for rendering
if you want to use sdl for input and directx that might be another matter entirely [probaly requiring a change or addition to sdl]
so what are you rendering with now that you want an input library for?
it is completely possible to use SDL for input and creation of a window, but use opengl for rendering
if you want to use sdl for input and directx that might be another matter entirely [probaly requiring a change or addition to sdl]
so what are you rendering with now that you want an input library for?
Well heres my main loop:
The rendering code works fine, but the code for capturing key events doesn't. The checkInput() call simply calls SDL_GetKeyState(NULL). Yet when the enter key is hit, nothing happens. Note that application is windowed, and not running full screen. All the rendering code is straight OpenGL, no SDL video calls at all.
while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message==WM_QUIT) { break; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } else { //get new Dt value updateTimer(); checkInput(); if(Keys[SDLK_RETURN]) MessageBox(NULL,"KeyPressed","KeyPressed",MB_OK|MB_ICONEXCLAMATION); ///then here is the rendering code }The rendering code works fine, but the code for capturing key events doesn't. The checkInput() call simply calls SDL_GetKeyState(NULL). Yet when the enter key is hit, nothing happens. Note that application is windowed, and not running full screen. All the rendering code is straight OpenGL, no SDL video calls at all.
What's wrong with DirectInput?
Quote:
Original post by WilyCoder
I'm aiming for cross platform compatibility. I'm using OpenAL, OpenGL, and SDL. If I was using DirectInput, I'd have no questions to ask, as I've used it before...
You didn't say in this post that you'd already used DirectInput or that you were looking for cross-platform alternatives. I assumed that since you were using the Win32 API that you wouldn't mind being bound to DirectX, also.
What I'd suggest, in that case, is to do your own input layer and just have an interface that stays the same no matter the OS. From there code your own backend to it for each system you port it to.
Rather than making my own, I'm trying to see if it is possible to use SDL ONLY for input handling. I could very well just use Win32 to handle the input, but that would defeat the cross platform reqiurements. I know that UT2004 uses SDL for the linux port, so I know it can be done.
Sadly, it seems that documentation on SDL is lacking. Must I create the OpenGL window using SDL in order to handle the input using SDL?
Sadly, it seems that documentation on SDL is lacking. Must I create the OpenGL window using SDL in order to handle the input using SDL?
Quote:
Original post by WilyCoder
Rather than making my own, I'm trying to see if it is possible to use SDL ONLY for input handling. I could very well just use Win32 to handle the input, but that would defeat the cross platform reqiurements. I know that UT2004 uses SDL for the linux port, so I know it can be done.
Sadly, it seems that documentation on SDL is lacking. Must I create the OpenGL window using SDL in order to handle the input using SDL?
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message==WM_QUIT) { break; } else { TranslateMessage(&msg); DispatchMessage(&msg); }}Did you know that is a Windows game loop? It will not work on other platforms. So, I reccomend you use SDL to setup OpenGL with and then go from there. You won't be using the SDL rendering stuff, only the OpenGL stuff, so it meets your requirements. I have a quick little example showing OpenGL in SDL. as well as numerous threads on input with SDL. Here's a few with lot's of various input examples from many members of the GD community.
Link 1
Link 2
Link 3
You could also take a look into GLFW [smile] I have a little comparsion guide to SDL in my sig.
- Drew
Ok cool. I thought you were using that as your main loop for all platforms [smile]. Yea, it is not that hard to convert over, you have the right ideas.
Quote:
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
if (msg.message==WM_QUIT) {
break;
}
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else {
//get new Dt value
updateTimer();
checkInput();
if(Keys[SDLK_RETURN]) MessageBox(NULL,"KeyPressed","KeyPressed",MB_OK|MB_ICONEXCLAMATION);
///then here is the rendering code
}
Someone correct me if I'm wrong, but I just quickly glanced over your code and I believe that:
-------------
if (PeekMessage() )
{
//if Return Key is down this section will run
}
else
{
//you check for Return Key down here
}
-------------
Pressing the Return Key will cause PeekMessage() to return true - in short you'll never hit the 'else' statement when you press the return key down.
Do you understand what I'm saying?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement