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

Author Topic: Reading input globally  (Read 2025 times)

0 Members and 1 Guest are viewing this topic.

svrtgujbhk

  • Newbie
  • *
  • Posts: 20
    • View Profile
Reading input globally
« on: June 07, 2011, 04:59:35 pm »
The way my engine is set up right now, input events are entirely separate from the view/window (they are two unrelated modules).

From what I've seen, input in SFML can only be read through a specific Window; this is a bit at odds with how my engine works. Is there a way to read input globally in SFML (ie. not through a Window)?

I could solve the problem by having a singleton wrapper over the SFML Window, but I'd rather avoid that if possible.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Reading input globally
« Reply #1 on: June 07, 2011, 05:39:34 pm »
There's no way to do so, a sf::Input provides the input states of a particular window, not the global ones.

It's not just different technically, it's two different things: window inputs only reflect what happens when the window has the focus, while global inputs reflect the global mouse/keyboard states.
Laurent Gomila - SFML developer

svrtgujbhk

  • Newbie
  • *
  • Posts: 20
    • View Profile
Reading input globally
« Reply #2 on: June 07, 2011, 06:04:42 pm »
Okay, thanks.  Guess I'll have to resort to the singleton.

I was thinking something like an aggregate of all input occurring on all Window objects, not global as in operating system global.

Out of curiosity, is it hard for you to implement something like this in SFML (an aggregate of all Window inputs)? It's not a request, just a question. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Reading input globally
« Reply #3 on: June 07, 2011, 07:40:50 pm »
Quote
Out of curiosity, is it hard for you to implement something like this in SFML (an aggregate of all Window inputs)?

Probably not.
Laurent Gomila - SFML developer