Jump to content
  • Advertisement
Sign in to follow this  
Ludi83

SDL Input Problem

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a strange Input problem with SDL (Version 1.2.9.). I use the normal while(Pollevent) ... blablabla But I it doesn't recognize a few multiple keyinputs. E.g. in my demo (only a car made of five cubes :)): Up, w: accellerate Down, s: break left, a: steer left right, d: steer right Here are some key combinations Up + Right + Down -> Works Up + Left + Down -> Doesn't Work Up + Left + S ->Works W + A or D + S -> doesn't work W + A or D + Down -> Works Could anyone test it, and say if he has the same problem? download 1.3 mb

Share this post


Link to post
Share on other sites
Advertisement
Your 'Up', and 'Down' do not work at all for me. It's a logic error in your code. Check to see that everything is implemented correctly. SDL does not have any problems with key combinations, I just tested all your cases with my SDL input library I made and there was no problem. That's why I'm sure its a logic error in your code somewhere. Other than that, it works fine in constraint to your system.

I'm thinking it is either your system (try restarting?) or it's working, but just not how you think it should be. (Or it's not working in a manner that I see as working [wink])

Share this post


Link to post
Share on other sites
Sorry, I forgot to put the new config file in the download :)

Could you please add/replace

Input:Bind('LEFT','MOVELEFT')
Input:Bind('RIGHT','MOVERIGHT')
Input:Bind('DOWN','MOVEDOWN')
Input:Bind('UP','MOVEUP')

to config.txt in data/config.txt

Thx :)

Share this post


Link to post
Share on other sites
Ok, now that works a lot better [wink] Nice system BTW, I didn't even see that config file in there, key binding systems are great! Now back to your first post, those combinations work for me. However, I hope you do realize that Up + Left + Down, when you hold down, the car won't move because of the way you have it imlemented. Maybe that's what's making you think it's not working? Hold Up and Left and it works fine, but once you hit down, then the car will stop. Intentional?

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
However, I hope you do realize that Up + Left + Down, when you hold down, the car won't move because of the way you have it imlemented.


I know the car shouldn't move :) But you should still be able to steer. Could you please look at the console window? Do you see a Keydown event, when you hold down W + S and then press D?

Share this post


Link to post
Share on other sites
No events were posted to the console when I pressed any keys. This is the output:

F:\Downloads\test>3d
-- Starting Logfile -------------------
-- Starting Filesystem ----------------
Adding Pakfile: data/daten.zip
-- Starting Scriptengine --------------
-- Starting Input ---------------------
Found File language.xml in data/daten.zip
German translation for 1 not found.
Taking English translation.
No translation for id 2 found
Executing ... autoexec.txt
Hello from AUTOEXEC!!!!!
Executing ... config.txt
Bind GUI:Toggle("Setup") as SCRIPT!
Bind GUI:Toggle("Console") as SCRIPT!
Bind GUI:Toggle("Stats") as SCRIPT!
Bind MOVELEFT as CALLBACK!
Bind MOVERIGHT as CALLBACK!
Bind MOVEDOWN as CALLBACK!
Bind MOVEUP as CALLBACK!
Bind MOVEUP as CALLBACK!
Bind MOVEDOWN as CALLBACK!
Bind MOVELEFT as CALLBACK!
Bind MOVERIGHT as CALLBACK!
Bind MOVERIGHT as CALLBACK!
Bind MOVELEFT as CALLBACK!
Bind QUIT as CALLBACK!
Bind CAMERAZOOMOUT as CALLBACK!
Bind CAMERAZOOMIN as CALLBACK!
Bind QUIT as CALLBACK!
Bind ATTACK as CALLBACK!
set v_mode to 1
set v_fullscreen to false
set i_mousespeed to 0.500000
set s_musicvolume to 0.973333
-- Starting Renderer ------------------
OpenGL 2.0 Support
Max Anisotropic Level: 16.000000
-- Starting Texture Manager -----------
Found File textures/tnf.tga in data/daten.zip
textures/tnf.tga ist RGBA
-- Starting Camera -------------------
Found File GUI/GUILayout.xml in data/daten.zip
Found File textures/ArialSmall.tga in data/daten.zip
textures/ArialSmall.tga ist RGBA
Found File textures/ArialSmall.tga in data/daten.zip
textures/ArialSmall.tga ist RGBA
Flushed textures count -> 1
Found File textures/CourierNew.tga in data/daten.zip
textures/CourierNew.tga ist RGBA
Found File textures/CourierNew.tga in data/daten.zip
textures/CourierNew.tga ist RGBA
Flushed textures count -> 1
Found File textures/ArialBlack.tga in data/daten.zip
textures/ArialBlack.tga ist RGBA
Found File textures/ArialBlack.tga in data/daten.zip
textures/ArialBlack.tga ist RGBA
Flushed textures count -> 1
Found File textures/GUIElements.tga in data/daten.zip
textures/GUIElements.tga ist RGBA
Found File GUI/MusicTab.xml in data/daten.zip
Need a <name> or <callbackString> attribute, check Label
Found File GUI/InputTab.xml in data/daten.zip
Found File GUI/FPSMonitor.xml in data/daten.zip
Found File GUI/Console.xml in data/daten.zip
Need a <name> or <callbackString> attribute, check Panel
Found File GUI/Messages.xml in data/daten.zip
Found File textures/GUIElements.tga in data/daten.zip
textures/GUIElements.tga ist RGBA
Found File music/music.txt in data/daten.zip
Executing ... music/music.txt
Found File textures/TerrainMap.tga in data/daten.zip
textures/TerrainMap.tga ist RGBA
Found File textures/TerrainTex.tga in data/daten.zip
textures/TerrainTex.tga ist RGB!
Found File textures/Detail.tga in data/daten.zip
textures/Detail.tga ist RGB!
---------------------------------------------------
| Min : Avg : Max : Time: # : Profile Name (0.002s, 499.8 FPS)
---------------------------------------------------
|100.0 : 100.0 : 100.0 : 0.0 : 1 : MAINLOOP
Flushed textures count -> 1
Flushed textures count -> 1
-- Closing Renderer -------------------
-- Closing Camera --------------------
-- Closing Texture Manager ------------
Deleting Texture textures/tnf.tga
Deleting Texture textures/TerrainTex.tga
Deleting Texture textures/Detail.tga
-- Closing Scriptengine ---------------
-- Closing Input ----------------------
-- Closing Filesystem -----------------
-- Closing Logfile --------------------

F:\Downloads\test>



Also on my computer I could steer at the same time when using those keys combos.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
Also on my computer I could steer at the same time when using those keys combos.


Okay, good to hear that :) But why does it not work on my PC? I don't understand this :(

Share this post


Link to post
Share on other sites
Okay, I've written a really small SDL test.


#include <stdio.h>
#include <SDL/SDL.h>


int main (int argc, char *argv[]) {

SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode (640, 480, 16, SDL_SWSURFACE);
SDL_WM_SetCaption ("SDL", NULL);

bool done = false;
int i = 0;
SDL_Event event;

while (!done) {

while (SDL_PollEvent (&event)) {

switch (event.type) {
case SDL_KEYDOWN:
printf("Keydown %i\n", ++i);
break;
case SDL_QUIT:
done = true;
break;
default:
break;
}
}
}
SDL_Quit();
return 0;
}




And I have still the same Problem. When I press e.g. W and S at the same time, I can't press any other Keys (i don't get a keydown event).

Here at home, I tried it at 3 PCs, and it doesn't work, Drew said it worked for him. Could other people please try it too? Here is the small demo for windows: download

Share this post


Link to post
Share on other sites
Quote:
Original post by Ludi83
But I it doesn't recognize a few multiple keyinputs.


Just shooting from the hip here, but not all keyboard can register so many simultaneous keypresses - it is a hardware restriction. Try with some other keyboard to see if that's your problem (or try your experiment in some other game).

Share this post


Link to post
Share on other sites
Quote:
Original post by barkholt
Quote:
Original post by Ludi83
But I it doesn't recognize a few multiple keyinputs.


Just shooting from the hip here, but not all keyboard can register so many simultaneous keypresses - it is a hardware restriction. Try with some other keyboard to see if that's your problem (or try your experiment in some other game).


You are right. I tried it under Windows and with Half-Life 2. You can't press W+S and e.g. A at the same Time :) Funny, I've never noticed that before :)

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!