Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Changing Key Repeat Speed  (Read 9553 times)

0 Members and 2 Guests are viewing this topic.

diddykonga

  • Newbie
  • *
  • Posts: 3
    • View Profile
Changing Key Repeat Speed
« on: November 07, 2010, 10:55:47 pm »
Hi there im new to SFML and wanted to know if there was a way to change the speed at which the keys will start to repeat, cause i need them to repeat immediately after the first key has been pressed, if there is any way of doing this i would be grateful to know how, thank you.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Changing Key Repeat Speed
« Reply #1 on: November 07, 2010, 11:10:05 pm »
Quote from: "diddykonga"
Hi there im new to SFML and wanted to know if there was a way to change the speed at which the keys will start to repeat, cause i need them to repeat immediately after the first key has been pressed, if there is any way of doing this i would be grateful to know how, thank you.


I guess you could use the sf::Input class as it will always return true if a key is pressed.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

diddykonga

  • Newbie
  • *
  • Posts: 3
    • View Profile
Changing Key Repeat Speed
« Reply #2 on: November 08, 2010, 12:14:51 am »
I am using the sf::Input class but it still abides by the key repeat speed :[

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Changing Key Repeat Speed
« Reply #3 on: November 08, 2010, 12:28:24 am »
Currently there is no way to change this repetition speed. And as sf::Input relies sf::Event it won't change anything.

On Unix and OS X you can change this in system settings. But I don't know if there is such feature on Windows.

I'm just wondering why would you need such feature ?
SFML / OS X developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Changing Key Repeat Speed
« Reply #4 on: November 08, 2010, 01:21:28 am »
If you want to define your own repeat rate, you will need to implement your own repeat logic by polling the state of keys each frame instead of relying on the events.

This can be changed in Windows, but I don't think it can be changed on a per-application basis. Wouldn't be surprised if the same was for OS X and *nix.

JCSopko

  • Newbie
  • *
  • Posts: 19
    • View Profile
Changing Key Repeat Speed
« Reply #5 on: November 08, 2010, 01:25:12 am »
For Windows you can change the repeat speed by going to keyboard in control panel and playing with those values, although this probably doesn't help you much.

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Changing Key Repeat Speed
« Reply #6 on: November 08, 2010, 01:33:19 am »
The sf::Input class doesn't "abide" by key repeat speed, there is no such thing. You can test every frame like this:
yourApp.GetInput().IsKeyDown(sf::Key::R);

if your sf::RenderWindow is called yourApp, and you wanted to test whether or not R is pressed on that frame.

Miguel

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Changing Key Repeat Speed
« Reply #7 on: November 08, 2010, 07:08:00 am »
Quote from: "Xorlium"
The sf::Input class doesn't "abide" by key repeat speed, there is no such thing. You can test every frame like this:
yourApp.GetInput().IsKeyDown(sf::Key::R);

if your sf::RenderWindow is called yourApp, and you wanted to test whether or not R is pressed on that frame.

Miguel


Yeah I thought so. The Input class function returns true if a key is pressed down, then it shouldn't matter with repeat speed. Since the key is pressed down. The input instance only needs a internal bool that is set to true when it receives the first "KeyPressed" event and then set to false when "KeyReleased".

If it doesn't, this should be changed so it works like this. As the documentation says:
Quote
Give access to the real-time states of keyboard, mouse and joysticks.

And if it works like Hiura said then that is NOT real-time states of the keyboard, mouse and joysticks.

*EDIT*
Also after looking into the Input.hpp file, it looks like I am correct:
http://sfml-dev.org/documentation/2.0/Input_8hpp-source.htm
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

diddykonga

  • Newbie
  • *
  • Posts: 3
    • View Profile
Changing Key Repeat Speed
« Reply #8 on: November 09, 2010, 12:02:37 am »
Sorry, my bad your right it does just return if its pressed down

I had it in the while(App->GetEvent(Event)) XD

 

anything