How to fire orxEVENT_TYPE_KEYBOARD?

edited May 2012 in Help request
I am trying to handle text box input. I thought I would be able to listen to orxEVENT_TYPE_KEYBOARD and that its payload would contain orxKEYBOARD_EVENT_KEY_PRESSED or orxKEYBOARD_EVENT_KEY_RELEASED.

My event handler never receives the orxEVENT_TYPE_KEYBOARD events. I CAN listen to orxEVENT_TYPE_INPUT and filter it by pressed/released event types.

To do that, I have to create config entries for all the keys I want to receive events for. That's fine, but I was wondering why orxEVENT_TYPE_KEYBOARD never fires. Am I misunderstanding its purpose?

Comments

  • edited May 2012
    Ah yes, it's an old event that is only plug in the old SFML plugin. The way it works with GLFW makes it harder to maintain such events (especially performance-wise) and I thought I removed it at the same time I removed the mouse ones, but apparently I didn't.

    There isn't a great way to handle text inputs for now, registering inputs for each key is currently probably the safest bet.
  • edited May 2012
    Ah, that's fine for now. Good to know I'm not crazy.
  • edited May 2012
    Nope, you're not. I'd love to plug that event back but for now it sounds much more reasonable to remove it for the time being.
  • edited May 2012
    Hi,

    I repared the Android build (it was break since Iarwain removed this event). This event was used by the keyboard android plugin.

    Acksys: If you want to intercept the "back" key of an android device, you can map an input to the KEY_ESCAPE key.

    Just an example, in my game, I use that :
    [GameInput@GeneralInput]
    KEY_ESCAPE	= PauseGame
    

    So, in my case, by pressing the back android key, pause is activated.

    Others keys can be intercepted, if you want to know which one and how, you can take a look at the file in orx/code/plugins/Keyboard/android/orxKeyboard.cpp : orxKeyboard_Android_GetNVKey() or orxKeyboard_Android_GetKey().

    All NV_KEYCODE_XXX correpond to the input managed by the NVEvent library (and so, the android event)
  • edited August 2012
    And now you can easily handle text input with orxKeyboard_ReadKey(), that will return a sequence of key presses since last call, and orxKeyboard_ReadString(), that will return a UTF-8 string made of characters entered since last call. :)

    Both have been implemented in the GLFW plugin for now and will probably make it to Android at some point. Don't expect any SDL/SFML implementation though as those plugins are getting really obsolete anyway.
  • edited August 2012
    Ok, looks good! This should make keyboard input a bit simpler in OrxCraft!
Sign In or Register to comment.