Skip to main content
gamedev.net
🔒 Locked

SDL Input Problem

Started by Ludi83 8 replies 1.1k views
Original Post
Ludi83
Ludi83
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
Drew_Benton
Drew_Benton
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])
Ludi83
Ludi83
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 :)
Drew_Benton
Drew_Benton
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?
Ludi83
Ludi83
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?

Drew_Benton
Drew_Benton
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.zipGerman translation for 1 not found.Taking English translation.No translation for id 2 foundExecuting ... autoexec.txtHello from AUTOEXEC!!!!!Executing ... config.txtBind 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 1set v_fullscreen to falseset i_mousespeed to 0.500000set s_musicvolume to 0.973333-- Starting Renderer ------------------OpenGL 2.0 SupportMax Anisotropic Level: 16.000000-- Starting Texture Manager -----------Found File textures/tnf.tga in data/daten.ziptextures/tnf.tga ist RGBA-- Starting Camera -------------------Found File GUI/GUILayout.xml in data/daten.zipFound File textures/ArialSmall.tga in data/daten.ziptextures/ArialSmall.tga ist RGBAFound File textures/ArialSmall.tga in data/daten.ziptextures/ArialSmall.tga ist RGBAFlushed textures count -> 1Found File textures/CourierNew.tga in data/daten.ziptextures/CourierNew.tga ist RGBAFound File textures/CourierNew.tga in data/daten.ziptextures/CourierNew.tga ist RGBAFlushed textures count -> 1Found File textures/ArialBlack.tga in data/daten.ziptextures/ArialBlack.tga ist RGBAFound File textures/ArialBlack.tga in data/daten.ziptextures/ArialBlack.tga ist RGBAFlushed textures count -> 1Found File textures/GUIElements.tga in data/daten.ziptextures/GUIElements.tga ist RGBAFound File GUI/MusicTab.xml in data/daten.zipNeed a <name> or <callbackString> attribute, check LabelFound File GUI/InputTab.xml in data/daten.zipFound File GUI/FPSMonitor.xml in data/daten.zipFound File GUI/Console.xml in data/daten.zipNeed a <name> or <callbackString> attribute, check PanelFound File GUI/Messages.xml in data/daten.zipFound File textures/GUIElements.tga in data/daten.ziptextures/GUIElements.tga ist RGBAFound File music/music.txt in data/daten.zipExecuting ... music/music.txtFound File textures/TerrainMap.tga in data/daten.ziptextures/TerrainMap.tga ist RGBAFound File textures/TerrainTex.tga in data/daten.ziptextures/TerrainTex.tga ist RGB!Found File textures/Detail.tga in data/daten.ziptextures/Detail.tga ist RGB!---------------------------------------------------|  Min :   Avg :   Max :   Time:   # : Profile Name (0.002s, 499.8 FPS)---------------------------------------------------|100.0 : 100.0 : 100.0 :   0.0 :   1 : MAINLOOPFlushed textures count -> 1Flushed textures count -> 1-- Closing Renderer --------------------- Closing Camera ---------------------- Closing Texture Manager ------------Deleting Texture textures/tnf.tgaDeleting Texture textures/TerrainTex.tgaDeleting 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.
Ludi83
Ludi83
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 :(

Ludi83
Ludi83
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
barkholt
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).
-- barkholt
Ludi83
Ludi83
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.