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

Author Topic: [BUG] SFML polls input from another window  (Read 2196 times)

0 Members and 1 Guest are viewing this topic.

kitstainedheart

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
[BUG] SFML polls input from another window
« on: May 30, 2016, 10:21:09 pm »
Hello and good afternoon,
I am having to deal with a SFML bug that is rather annoying on Windows 10, and I would like help if possible...
So, my application is made on C++, it consists 1 classical SFML RenderWindow and 1 classical STD console output window(for debugging and such), input detection is made through "sf::Keyboard::isKeyPressed", however, SFML is using the CONSOLE WINDOW to detect my key presses, even on the default SFML boiler plate code...
I have tried compiling the library myself, but it does NOT change anything, the binaries provided by the site give me the same result...
Its really troublesome because, the same code works on Linux...
I am using SFML 2.3.2, on MinGW GCC DW2 32bit, on Windows 10 64bit (but the application is 32bit)~~
Can anyone give me support on this?
TESTING CODE IF ANYONE NEEDS IT:
#include <iostream>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Event.hpp>

using namespace std;

int main(int argc, char *argv[])
{
        cout << "Hello World!" << endl;
        bool isPlaying = true;
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFMLInputTest");
        sf::Event gameEvent;
        while (isPlaying){
                while (window.pollEvent(gameEvent)){
                        if (gameEvent.type == sf::Event::Closed){
                                isPlaying = false;
                        }
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::B))
                        isPlaying = false;
                window.clear();
                window.display();
        }
        return 0;
}
 
Thanks in advance...

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: [BUG] SFML polls input from another window
« Reply #1 on: May 30, 2016, 10:26:18 pm »
sf::Keyboard checks the state of the keyboard. A key is either pressed or not pressed, regardless of which window has the focus.
If you want to check events (ex: "a key has been pressed") related to your window, use events.

kitstainedheart

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: [BUG] SFML polls input from another window
« Reply #2 on: May 30, 2016, 10:29:28 pm »
yes, sorry i dont exactly know the exact term, but here, with sf::Keyboard::isKeyPressed() it only works when the console window has focus, the code I posted above is literally ALL the code of the application

kitstainedheart

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: [BUG] SFML polls input from another window
« Reply #3 on: May 30, 2016, 10:45:40 pm »
ALRIGHT! I have found what the issue is...
So, I use an application called "Synergy" to share keyboards and mice across different computers...
Apparently, this application was interfering with SFML's calls to the Windows API...
(Funny enough, it does NOT interfere with SFML's window event-based input methods though? o-O)
Closing the application "Synergy" solves the issue :)
Thanks for the support anyways though~~
Have a nice day!

 

anything