AppWizard user input - keyboard and hard key emulation

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • AppWizard user input - keyboard and hard key emulation

      Greetings,

      What is the preferred method for mapping keyboard keys to UI actions in AppWizard?

      For example, I have a UI that will have hard keys mapped to up, down, left, right, select. How can I listen to keyboard keypresses with the Play Mode?

      Cheers,
      Joe
    • Hi,

      currently AppWizard only processes keys when an object is focused, that can receive key input. For example, a focused slider changes its value when the corresponding arrow keys are pressed. So as of right now, AppWizard does not offer an interaction to react on key input.

      We will consider adding such an option to AppWizard with a future release though, as this definitely makes sense for using the AppWizard.

      Best regards,
      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Florian,

      Good to hear that it would make sense for the roadmap!

      In the mean while, what might you recommend for the Play Mode development knowing that the inputs will eventually be hardkeys?

      I see so far that AppWizard has great support for mouse clicks, click-and-drag gestures, and when specific widgets are in focus as you mentioned. So perhaps I can click to focus on an element, then click the element again to select the element for editing.

      Or, I could extend the screen to add some simulated hardkeys as AppWizard buttons. I briefly tried this though could not do it as separate screens and draw both at the same time, so I put them on one screen. Not perfect for the hierarchy, but if it works it may be sufficient to prove the concept.

      Cheers,
      Joe
    • Hi,

      with the current AppWizard version it is not possible to react on custom keys. This means the behavior would have to be implemented in the exported simulation project.

      I made an example application which reacts on the left and right arrow keys. Pressing the keys changes the AppWizard variables of the projects. The VALUECHANGED signal of a variable will trigger a SHIFTSCREEN interaction.

      To react on key input, I added a key hook function to GUIConf.c in the exported simulation project:

      C Source Code

      1. static void _cbHook(const GUI_KEY_STATE * pState) {
      2. I32 v;
      3. if (pState) {
      4. switch(pState->Key) {
      5. case GUI_KEY_LEFT:
      6. if (pState->Pressed == 0) {
      7. v = APPW_GetVarData(ID_VAR_01, NULL) + 1;
      8. APPW_SetVarData(ID_VAR_01, v);
      9. }
      10. break;
      11. case GUI_KEY_RIGHT:
      12. if (pState->Pressed == 0) {
      13. v = APPW_GetVarData(ID_VAR_00, NULL) + 1;
      14. APPW_SetVarData(ID_VAR_00, v);
      15. }
      16. break;
      17. }
      18. }
      19. }
      Display All

      The hook function has to be set in the GUI_X_Config() routine.

      C Source Code

      1. GUI_KEY__SetHook(_cbHook);

      I have added the example project to the attachments. The Simulation folder is missing (since it is too big), so you will have to generate the folder by exporting & saving the project. Finally, you have to replace the GUIConf.c file in Simulation\Config\ with the one in the .zip file.

      Best regards,
      Florian
      Files
      • HardKeyTest.zip

        (12.06 kB, downloaded 411 times, last: )
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • The demo works. Thank you, Florian.

      I did have to tweak the GUIConf.c to make one of the #ifdefs go around the entire GUI_SPY_* block.

      Attached is r2 of the HardKeyTest demo. Same instructions as above to simulate:
      1. Save & Export from AppWizard
      2. Move GUIConf.c to Simulation\Config\
      3. Open solution in Visual Studio
      4. Viola =)
      Cheers,
      Joe
      Files
      • HardKeyTest.zip

        (12.77 kB, downloaded 428 times, last: )