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

Author Topic: Get Key ID When Key Is Pressed? (C++)  (Read 8421 times)

0 Members and 1 Guest are viewing this topic.

Ajm113

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • http://www.bombinaid.com
Get Key ID When Key Is Pressed? (C++)
« on: February 21, 2009, 11:34:07 pm »
Hello, SFML community!

Ok, I decided to get my game going on for Linux and Mac from Win32, but I needed a good API that was portable easy and this API looks about right! :wink:


Ok, I got a bool array of 256. What I want to do is so the ID number of a key was pressed like A was pressed row 1 of that array will be set to true and when A is released row 1 is set to false.

How can I do that? Like Wparam and Win32 examples show sometimes.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get Key ID When Key Is Pressed? (C++)
« Reply #1 on: February 22, 2009, 09:13:15 am »
You don't need to do so, sf::Input already keeps track of the keys state.
Laurent Gomila - SFML developer

Ajm113

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • http://www.bombinaid.com
Get Key ID When Key Is Pressed? (C++)
« Reply #2 on: February 22, 2009, 04:15:45 pm »
Alright, I'll play around with it. Its wired its like IntelliSense isn't picking up on your API that well. It seemed to work a while ago now it's Intellisense isn't showing a drop down box .

Any ways I have a couple more questions.

Whats a alternative of timeGetTime from windows in your API? I need it for my performance handler.

How can I set a window's state? I.E Maximize, Minimize, etc?

And how can I get the user's screen x,y cords?

Thank you, Andrew.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get Key ID When Key Is Pressed? (C++)
« Reply #3 on: February 22, 2009, 05:27:58 pm »
Maybe you should just read the documentation and tutorials instead of relying on Intellisense? :wink:
Laurent Gomila - SFML developer

Ajm113

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • http://www.bombinaid.com
Get Key ID When Key Is Pressed? (C++)
« Reply #4 on: February 22, 2009, 09:06:27 pm »
Ok, I got most of what I want converted. How can I display a Messagebox? I looked through your docs. It seems you guys cover everything except that.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get Key ID When Key Is Pressed? (C++)
« Reply #5 on: February 22, 2009, 10:31:06 pm »
There's currently nothing for message boxes in SFML.
Laurent Gomila - SFML developer

Ajm113

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • http://www.bombinaid.com
Get Key ID When Key Is Pressed? (C++)
« Reply #6 on: February 22, 2009, 11:03:56 pm »
Really, why? You guys cover everything, except for a message box?? Can you suggest what to do?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get Key ID When Key Is Pressed? (C++)
« Reply #7 on: February 22, 2009, 11:19:04 pm »
Well, SFML is not a windowing API such as Qt or wxWidgets. All it has to do is providing a window to draw into. Message boxes are not directly related to what you can expect from SFML.

However, you can draw one inside your window using a rectangular shape and a graphical string :)
Laurent Gomila - SFML developer

Ajm113

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • http://www.bombinaid.com
Get Key ID When Key Is Pressed? (C++)
« Reply #8 on: February 23, 2009, 12:05:58 am »
Well whats Linux's Messagebox command?

I thought something like this feature would be no problem to add. If your API can run on different Operating Systems.

dorkfish

  • Newbie
  • *
  • Posts: 38
    • View Profile
Get Key ID When Key Is Pressed? (C++)
« Reply #9 on: February 23, 2009, 04:15:22 am »
It might not be hard to implement, but it's outside of SFML's scope. SFML doesn't provide any GUI elements, and (probably) never will. If you want native message boxes, use a UI toolkit like GTK, QT, or wxWidgets. Like someone else said above, you could also write your own SFML-based message box, with a rectangle or string. Or you could take a look at the wiki, there's the starts of a GUI framework for SFML there. It's called IMGUI.

Ajm113

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • http://www.bombinaid.com
Get Key ID When Key Is Pressed? (C++)
« Reply #10 on: February 23, 2009, 02:45:22 pm »
Ok, I just converted everything and it compiles fine. Its just I get this problem:



I mite go with GTK, I'll just finish what I have going on here and then see by the weekend on getting linux and then compiling the game on it.