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

Author Topic: [Solved] Input Problem!  (Read 6112 times)

0 Members and 1 Guest are viewing this topic.

Metaby

  • Newbie
  • *
  • Posts: 23
    • View Profile
[Solved] Input Problem!
« on: June 24, 2008, 07:22:15 pm »
Hello, since i downloaded and used sfml 1.3, it looks like that my input's dont workt..
in sfml 1.2 i used input:
Code: [Select]
void Player::MainMenu(RenderWindow *Game)
{
MousePosX = Game->GetInput().GetMouseX();
MousePosY = Game->GetInput().GetMouseY();
// ... my quellcode
}

this worked in sfml 1.2 very good!
but in sfml 1.3 my programm dont react on any input event
no key control
no mouse control
....
i looked into the Doc and the Tutorials but i don't get it working!

Im working on Windows XP Prof. with Visual Studio 2005 Express Edition

please need help >.<
and sorry for my bad english :P
I hacked 127.0.0.1 *g*

nuvw

  • Newbie
  • *
  • Posts: 5
    • View Profile
[Solved] Input Problem!
« Reply #1 on: June 26, 2008, 09:14:09 pm »
I've got exactly the same problem since sfml 1.3.

I'm working on Ubuntu 8.04 with g++.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[Solved] Input Problem!
« Reply #2 on: June 26, 2008, 09:42:40 pm »
I'm using the same code you are to get hold on the mouse position, works perfectly (SFML 1.3).

Metaby

  • Newbie
  • *
  • Posts: 23
    • View Profile
[Solved] Input Problem!
« Reply #3 on: June 27, 2008, 11:59:10 am »
hm.. ok, it seems like, that my RenderWindow hangs-up
my console works although..
have anybody an idea?
need help pls..
I hacked 127.0.0.1 *g*

vurentjie

  • Newbie
  • *
  • Posts: 31
    • View Profile
[Solved] Input Problem!
« Reply #4 on: June 27, 2008, 01:56:58 pm »
i dont know if you are having the same problem as me, if you look at the recent thread about "mouse coords out until resize" you can see what i am experiencing, i am going to try sort it out this weekend,

just to check, are you running in fullscreen? or desktopmode?? i have experienced problems with these specifically and am trying to track down the bug.

nuvw

  • Newbie
  • *
  • Posts: 5
    • View Profile
[Solved] Input Problem!
« Reply #5 on: June 27, 2008, 05:14:50 pm »
I don't know whether any two of us have got the same problem. :roll: But after having played around with my code I have found at least a solution for me. Maybe it helps one of you ...

Following function does not work how I want it to (it always returns false):

Code: [Select]
bool IsADown()
{
  const sf::Input& input = myWindow->GetInput();    // myWindow is a pointer to my RenderWindow

  if( input.IsKeyDown(sf::Key::A) )
  {
    return true;     // never happens
  }

  return false;  
}


Note: The Input instance always seems to return default values (all keys are released, mouse coordinates are 0/0, etc.)

If I expand my function with some (in my eyes needless) code, it works flawlessly:

Code: [Select]
bool IsADown()
{
  sf::Event event;
  myWindow->GetEvent(event);      // this seems to make the difference

  const sf::Input& input = myWindow->GetInput();

  if( input.IsKeyDown(sf::Key::A) )
  {
    return true;     // now it works perfectly
  }

  return false;  
}


Question: Is it really intentional that one has to call GetEvent(event) before accessing the Input instance?


Apart from that: Great library, I love it! Keep up the great work  :)

SirJulio

  • Full Member
  • ***
  • Posts: 241
    • View Profile
[Solved] Input Problem!
« Reply #6 on: June 27, 2008, 05:40:14 pm »
Hi,

yeap it's intentional. If you don't call GetEvent, Input array (mouse position, keys states etc) will never be updated, so whether you use or not Event structure, you must call GetEvent in your game loop. =)

Metaby

  • Newbie
  • *
  • Posts: 23
    • View Profile
[Solved] Input Problem!
« Reply #7 on: June 28, 2008, 12:13:17 am »
Yeah! Thanks all =D
it works =D
I hacked 127.0.0.1 *g*

 

anything