I'm using SFML 1.4 on Ubuntu 9.04.
It seems when I use this code:
if (Input.IsKeyDown(sf::Key::A))
OffsetDirection(1);
if (Input.IsKeyDown(sf::Key::D))
OffsetDirection(-1);
and press and hold the 'D' or 'A' key, it calls OffsetDirection once, pauses, then calls it continuously as if I was holding the key down (which I am). But I don't want it to pause. Is this normal behavior for sf::Input? If it is, is there something I can use as an alternative that doesn't pause?
By the way, if I configure my computer to have no delay between key press repeating through System>Preferences>Keyboard, then this problem goes away. But I don't want to have to have anybody that wants to use my program to have to toggle their system preferences.
I've tried doing this as an alternative:
// outside the main loop
struct KeysPressed {
bool A;
bool B;
} KeysPressed;
...
// inside the main loop
if (Event.Type == sf::Event::KeyPressed)
{
switch (Event.Key.Code)
{
case sf::Key::A:
KeysPressed.A = true;
break;
case sf::Key::D:
KeysPressed.D = true;
break;
default:
break;
}
}
else if (Event.Type == sf::Event::KeyReleased)
{
switch (Event.Key.Code)
{
case sf::Key::A:
KeysPressed.A = false;
break;
case sf::Key::D:
KeysPressed.D = false;
break;
default:
break;
}
}
if (KeysPressed.A == true)
OffsetDirection(1);
if (KeysPressed.D == true)
OffsetDirection(-1);
But the problem persists.
Any help would be appreciated.
Thanks,
Jordy
EDIT: I deleted this from System and reposted here, because I realized I posted in the wrong section. Sorry.