How to extract key strokes out of a VNC connection on the server side

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

    • How to extract key strokes out of a VNC connection on the server side

      Hello to all,

      I have a working VNC Client-Server connection. The display is shown fine on the PC.

      Now I want to have some key stroke events from the PC(client) sent to the unit(server).

      However our unit has no keyboard, but only three hardware buttons.
      I programmed all the menu switching and button handling by myself, years ago I just wasn´t aware that emWin offers a keyboard driver...
      So emWin in my my product is only for passive displaying something on the screen. All events are handled in my handmade software.

      My question is:
      How can I have any kind of function called in my application when I hit a key on the PC?
      With this function available I could easily forward this event to my dedicated event handler...

      Any help is much appreciated
      Andy
    • Hi,

      the key input from the client should be sent to the VNC server. In emWin, there are two ways to react on keyboard input. It depends whether you are using the window manager, or not.

      When using the window manager, have to react on the WM_KEY message. This message is sent to the window that has the focus when a key was pressed. If you have something that does not receive input focus (like a normal window), you can just call WM_SetFocus() on it.

      C Source Code

      1. case WM_KEY:
      2. pInfo = (WM_KEY_INFO *)pMsg->Data.p;
      3. if (pInfo) {
      4. //
      5. // React on release
      6. //
      7. if(pInfo->PressedCnt == 0) {
      8. switch (pInfo->Key) {
      9. case GUI_KEY_ENTER:
      10. //
      11. // Do something...
      12. //
      13. break;
      14. }
      15. }
      16. }
      17. break;
      Display All
      A pointer to a WM_KEY_INFO structure is sent with the WM_KEY message. This structure contains the pressed key and the state (PressedCnt). If PressedCnt is above 0, the key is pressed and if it is 0, it has been released.

      If not using the window manager, the WM_KEY_INFO structure can be retrieved by calling GUI_GetKeyState() in the super-loop of your MainTask().

      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.