Announcement

Collapse
No announcement yet.

Custom keypad handling?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom keypad handling?

    Hi

    I'm trying to implement a custom keyboard on a gen4-iod-24t module. I have found the keyboard demo example on https://github.com/4dsystems/GFX4d/t.../IoDkBTestAuto, but it doesn't work as I expect. I only get -1 returned from both ImageTouchedAuto() and DecodeKeypad(), regardless from where I touch. I can't find documentation on either ImageTouchedAuto() or DecodeKeypad(). Looking at the source, it would seem that I shouldn't call it inside my own if block checking for a touch update:

    Code:
    if (gfx.touch_Update()) {
      screenState.prevTouched = screenState.touched;
      screenState.touched = gfx.touch_GetPen() == TOUCH_PRESSED;
      if (!screenState.prevTouched && screenState.touched) { // Touch action initiated: screen was not touched previous iteration
        switch (screenState.currentScreen) {
        case IDX_MAIN_VIEW:
          handleMainScreenTouch();
          break;
        case IDX_FREQ_EDIT:
          handleFreqEditTouch(); // This is my form with a keyboard for user input. handleFreqEditTouch() handles a touch action while that form is active.
          break;
        }
      }
    }
    because it is calling touch_Update() itself, which might cause it to miss touch events since I already got the update in my code?

    How is this supposed to work? What are the preconditions and constraints on parameters for above 2 functions? Are they meant to work on custom keypads?
    Last edited by L0uisc; 20 July 2021, 09:24 PM. Reason: Made code snippet clearer

  • #2
    Hi,

    Welcome to the forum,

    Thank you for pointing this out, there is an error in the example which I will make sure is updated today but in the meantime you can add this line in setup

    gfx.touch_Set(TOUCH_ENABLE);

    Earlier versions of GFX4d booted with TOUCH_ENABLE already set but has now been changed hence why it is not in the example.

    I will do some tests to see what impact the ImageTouchedAuto() has on normal touch routines

    Best regards

    Paul

    Comment


    • #3
      Hi Paul

      I have already called gfx.touch_Set(TOUCH_ENABLE); in setup. My main form works as expected. I think I might not be enabling touch on the keys? Do I need to enable touch on each individual key image (i.e. iKeyboard_0, iKeyboard_1, etc.?)

      Comment


      • #4
        It would only be necessary to touch enable the keys if they had been touch disabled previously. You do need to touch disable the main keyboard image file though,

        gfx.imageTouchEnable(iKeyboard1, false) ;

        Paul

        Comment


        • #5
          I did do gfx.imageTouchEnable(iKeyboard1, false) ; as well as part of my switch to the new form. I do think it has something to do with enabling/disabling touch though, because I had an issue that my main form's objects would register touch when I touch the keyboard form. So I enable touch on all touchable objects (buttons, etc.) on the new form when I switch and disable touch on all other forms' objects.

          Does that give you an idea as to what my issue can be? I still get -1 returned from both ImageTouchedAuto() and DecodeKeyboard().

          Comment


          • #6
            Ok thanks for the info,

            In that case then maybe yes, you may need to enable all keys you can do it like this

            gfx.imageTouchEnable(-1, false) ; // touch disable everything
            for(int i = iKeyboard1_0; i <= iKeyboard1_59; i++) {
            gfx.imageTouchEnable(i, true) ;
            }

            Comment


            • #7
              Hi Paul

              I think I figured out what was the issue. I think it was indeed the case that my call to gfx.touch_Update() made imageTouchedAuto() misbehave. When I moved it outside that loop and made sure to enable all keys, I got the update events. However, since I switched forms and drew the keyboard in reaction to a button press on the main window, I got a key press event on the keyboard from the finger still touching the screen. So I decided to go the manual route and check my keys in my own function. It is only 14 keys, so I am happy to do that.

              I'd be glad if you could do the following though:
              1. document ImageTouchedAuto(), including that it calls touch_Update() internally, so it will not work as expected if you already called touch_Update().
              2. document DecodeKeypad()
              3. document the meaning of -1 as first argument to imageTouchEnable()
              I think that should already help anybody along the line quite substantially.

              Thanks

              Comment

              Working...
              X