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

Author Topic: More Keys for Press/Release events  (Read 30467 times)

0 Members and 1 Guest are viewing this topic.

TTK-Bandit

  • Newbie
  • *
  • Posts: 21
    • View Profile
More Keys for Press/Release events
« Reply #15 on: March 24, 2008, 02:34:19 am »
yeah, but having it as hex numbers removes the need for drawing all those different characters ingame.

wurzeldrei

  • Newbie
  • *
  • Posts: 6
    • View Profile
More Keys for Press/Release events
« Reply #16 on: June 16, 2008, 11:33:33 am »
What about providing an additional function to fetch raw key codes. I have german keyboard layout and no access to the Umlaut-keys or tilde, dot, comma, plus or minus. If there were a method to fetch raw key codes one could implement a user interface to configure the keys when the game starts for the first time. So we would not have any problems with different systems.
By the way: is it possible to do this on my own in python without having to patch the library?

greetings,
wurzeldrei

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
More Keys for Press/Release events
« Reply #17 on: June 16, 2008, 11:43:41 am »
What do you mean with "fetch raw key codes" ? Can you give an example ?
Laurent Gomila - SFML developer

wurzeldrei

  • Newbie
  • *
  • Posts: 6
    • View Profile
More Keys for Press/Release events
« Reply #18 on: June 16, 2008, 09:19:04 pm »
i think you get key codes from the os (of course os- and locale-specific), if there was a function RawCode containing that os code (from Windows API or X11) i could write

Code: [Select]

while window.GetEvent(event):
if event.Type==sf.Event.Closed:
running=False
if event.Type==sf.Event.KeyPressed:
if event.Key.RawCode==KEY_END:
running=False


and fill KEY_END on first run of my game by user input, sorry if my english is bad, school is long ago..., i'll train

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
More Keys for Press/Release events
« Reply #19 on: June 17, 2008, 03:17:38 am »
Hmm I'm not sure this would be the best solution.

One obvious reason is that you wuoldn't have consistent values across different systems (if you send keys over the network, or save them to configuration files).
Laurent Gomila - SFML developer

wurzeldrei

  • Newbie
  • *
  • Posts: 6
    • View Profile
More Keys for Press/Release events
« Reply #20 on: June 17, 2008, 09:12:35 am »
I think this is not what the additional function would be good for, since if one has to send keys over network (i think, this is not a good idea in general) he can just use the standard method. But most games will provide an interface to change the key bindings for that game, especially for that user on that platform.
I think there are better solutions, but very much harder to implement:
- Provide all keys on all keyboards via the standard method, here we had to add pages of key codes for some systems,
- Provide a complete key binding management that holds the raw key codes in a black box so programmers are not able to do unwanted things with them (sending key codes over network ;-) )
For the last thing i would suggest a BindingManager class that can be used as follows:

Code: [Select]

z=enum{C_GAME_EXIT, C_JUMP, C_RIGHT}
A=BindingManager()
A.Learn(C_GAME_EXIT) %waits for user input and saves raw key code internally


   while window.GetEvent(event):
      if event.Type==sf.Event.Closed:
         running=False
      if event.Type==sf.Event.KeyPressed:
         if A.Get(event)==z.C_GAME_EXIT: %Returns code (z-value) for the event saved in event
            running=False

     

    anything