This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HID Finger Swipe Functionality (iPhone)

I’m very familiar with the HID keyboard and mouse profile and have built products using it but need direction on how to replicate the functionality of a up/down/left/right finger swipe on a iPhone. Any guidance will be valuable.  Thanks 

  • Torbjørn & Jefferson,

    I was able to successfully get my test code to work.  It's not pretty but the concept has been proven.  I was able to reverse engineer the remote and combine it with the keyboard report.  The solution was to queue up the packets and send them sequentially after each success TX response.  If I had time I would use the nrf_queue or nrf_ringbuffer library for this solution.

    The final functionality is when you press one of the 4 buttons it will send a stylus/pen swipe sequence.  You can see this in action if you are in a drawing app.

    I want to thank you Torbjørn for taking the time to answer my questions that lead me to the answers I was seeking.  I learned a great deal from this exercise.  I have attached the final code for others to reference if desired.

    All that is left is to break down the packet structure and build a data structure for.  If I get that working I will post the final structure.  All I have to go on is what I wrote in a few post back.

    0167.main.c

  • Hi guys,

    I was facing the same issue than matt_wilson: emulate swipe movement from a custom HID Device.

    From this HID Report (https://devzone.nordicsemi.com/f/nordic-q-a/38587/is-multi-touch-hid-possible-with-nrf51822-chip), i'm able to "customise" my swipe movements. It's a quick fix but it actually works. 

    I start a timer when buttons are pressed, and send the report as this:

    static void swipe_timeout_handler(void * p_context)
    {
    
      switch (swipe_type)
        {
            case LEFT:
                y = 15000;
                x = (30000) - cpt*2500;
                cpt++;
                digitizer_send3(0, 1, x, y, true);
                if(cpt == 5) {
                    digitizer_send3(0, 1, x, y, false);
                    timers_stop();
                    cpt = 0;
                }
                break;
    
            case RIGHT:
                y = 15000;
                x = cpt*2500;
                cpt++;
                digitizer_send3(0, 1, x, y, true);
                if(cpt == 5) {
                    digitizer_send3(0, 1, x, y, false);
                    timers_stop();
                    cpt = 0;
                }
                break;
    
            case UP:
                y = (30000) - cpt*2500;
                x = 0;
                cpt++;
                digitizer_send3(0, 1, x, y, true);
                if(cpt == 5) {
                    digitizer_send3(0, 1, x, y, false);
                    timers_stop();
                    cpt = 0;
                }
                break;
    
            case DOWN:
                y = cpt*2500;
                x = 0;
                cpt++;
                digitizer_send3(0, 1, x, y, true);
                if(cpt == 10) {
                    digitizer_send3(0, 1, x, y, false);
                    timers_stop();
                    cpt = 0;
                }
                break;
    
            default:
                // No implementation needed.
                break;
        }
       
    }

    By doing this way, it is possible to emulate differents kinds of swipe by changing timer, cpt, x, y.

    While writing, i've see the matt solution with queuing. Will try this later...

  • Hi 

    Good to hear you found a working solution Matthew, and thanks for sharing the code Slight smile

    Same to the others chiming in as well, clearly this is something many are trying to do.

    Once you share your final code you can mark you reply as the answer, making it easy for other to find also.  

    Best regards
    Torbjørn

  • Torbjorn,

    Thanks for all your help.  I have been in the process of migrating my work to my project code base.  I have been using the Adafruit Bluefruit52 library because it has simplified my development time.  I would rather do it in Segger Studio but right now I prefer to use this 3rd party library because it handles most of the basic/core functionality of an application.  Of course I ran into issues and if you have time please review this other ticket.  I'm so close to getting this working but reaching out for some final help because I hit a hard wall...

    https://devzone.nordicsemi.com/f/nordic-q-a/58116/hid-digitizer-stylus-integration---adafruit-bluefruit52

  • Hi Matthew

    The case was given to me already, I will take a look next week. 

    I have to warn you that we can't really support software libraries not released by us. Bluefruit52 is an Arduino API I assume and would have to be supported by them, but I will try to help if it's not too time consuming. 

    Best regards
    Torbjørn

Related