You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/06 08:55:27 UTC

[GitHub] [incubator-nuttx] no1wudi opened a new pull request, #6576: vncserver: Support pointer event by uinput

no1wudi opened a new pull request, #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576

   ## Summary
   Add pointer support to vncserver to make it possible to run interactive GUI application by VNC
   ## Impact
   New feature
   ## Testing
   Custom boards
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r916414669


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -598,9 +600,39 @@ static inline int vnc_wait_start(int display)
 int up_fbinitialize(int display)
 {
   int ret;
+  FAR struct vnc_session_s *session;
+#ifdef CONFIG_VNCSERVER_TOUCH
+  char devname[NAME_MAX];
+#endif
 
   DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS);
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+
+  ret = snprintf(devname, NAME_MAX, CONFIG_VNCSERVER_TOUCH_DEVNAME "%d",
+                 display);
+
+  if (ret < 0)
+    {
+      gerr("ERROR: Format vnc touch driver path failed.\n");
+      return ret;
+    }
+
+  ret = vnc_touch_register(devname, session);
+
+  if (ret < 0)
+    {
+      gerr("ERROR: Initial vnc touch driver failed.\n");
+      return ret;
+    }
+
+  session->mouseout = vnc_touch_event;
+#endif
+  session->arg      = session;
+
   /* Start the VNC server kernel thread. */
 
   ret = vnc_start_server(display);

Review Comment:
   OK, unregister touch on fail now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915441630


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -610,6 +612,22 @@ int up_fbinitialize(int display)
       return ret;
     }
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+  ret = vnc_touch_register(CONFIG_VNCSERVER_TOUCH_DEVNAME, &session->touch);

Review Comment:
   we need generate the touch device dynamically to support the multiple instance



##########
drivers/video/vnc/vnc_server.h:
##########
@@ -222,6 +223,10 @@ struct vnc_session_s
   vnc_mouseout_t mouseout;     /* Callout when keyboard input is received */
   FAR void *arg;               /* Argument that accompanies the callouts */
 
+#ifdef CONFIG_VNCSERVER_TOUCH
+  FAR struct touch_lowerhalf_s *touch; /* Touch driver instance */

Review Comment:
   why not embed touch directly in vnc_session_s



##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -610,6 +612,22 @@ int up_fbinitialize(int display)
       return ret;
     }
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+  ret = vnc_touch_register(CONFIG_VNCSERVER_TOUCH_DEVNAME, &session->touch);
+
+  if (ret < 0)

Review Comment:
   sorry, look like the background thread is start at line vnc_start_server, so we need move before vnc_start_server



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915418795


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -619,6 +622,22 @@ int up_fbinitialize(int display)
       gerr("ERROR: wait for vnc server start failed: %d\n", ret);
     }
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+  session->touch    = vnc_touch_register(CONFIG_VNCSERVER_TOUCH_DEVNAME);

Review Comment:
   OK, moved before vnc_wait_start



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915718775


##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"

Review Comment:
   move after line 33



##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -598,9 +601,39 @@ static inline int vnc_wait_start(int display)
 int up_fbinitialize(int display)
 {
   int ret;
+  FAR struct vnc_session_s *session;
+#ifdef CONFIG_VNCSERVER_TOUCH
+  char devname[NAME_MAX];
+#endif
 
   DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS);
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+
+  ret = snprintf(devname, NAME_MAX, CONFIG_VNCSERVER_TOUCH_DEVNAME "%d",
+                 display);
+
+  if (ret < 0)
+    {
+      gerr("ERROR: Format vnc touch driver path failed.\n");
+      return ret;
+    }
+
+  ret = vnc_touch_register(devname, session);
+
+  if (ret < 0)
+    {
+      gerr("ERROR: Initial vnc touch driver failed.\n");
+      return ret;
+    }
+
+  session->mouseout = (vnc_mouseout_t)vnc_touch_event;

Review Comment:
   remove the cast



##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -22,9 +22,11 @@
  * Included Files
  ****************************************************************************/
 
+#include <limits.h>

Review Comment:
   remove



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>

Review Comment:
   remove



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>

Review Comment:
   remove



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914653603


##########
drivers/video/vnc/Kconfig:
##########
@@ -139,6 +139,20 @@ config VNCSERVER_KBDENCODE
 		Use a special encoding of keyboard characters as defined in
 		include/nuttx/input/kbd_coded.h.
 
+config VNCSERVER_MOUSE

Review Comment:
   the driver implement touch interface, should we name the new feature touch instead mouse?



##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -470,6 +472,42 @@ static int up_waitforsync(FAR struct fb_vtable_s *vtable)
 }
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+
+/****************************************************************************
+ * Name: vnc_uinput_mousein
+ ****************************************************************************/
+
+static int vnc_uinput_mouseout(FAR void *arg, int16_t x,
+                               int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if ((buttons & MOUSE_BUTTON_1) != 0)
+    {
+      sample.point[0].flags = TOUCH_DOWN |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+  else
+    {
+      sample.point[0].flags = TOUCH_UP |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+
+  return nx_write(session->fd_mouse, (void *)&sample, sizeof(sample));

Review Comment:
   But touch screen driver support the upper/lower half in the recent update, which mean writing a touch screen driver isn't complex than send the event through uinput.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915380274


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -50,6 +50,8 @@
 #include <nuttx/kthread.h>
 #include <nuttx/video/fb.h>
 #include <nuttx/video/vnc.h>
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>

Review Comment:
   `mouse.h` is essential since it provides `MOUSE_BUTTON_1`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915401862


##########
drivers/video/vnc/vnc_server.h:
##########
@@ -503,6 +508,36 @@ int vnc_raw(FAR struct vnc_session_s *session, FAR struct fb_area_s *rect);
 void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym,
                  bool keydown);
 
+#ifdef CONFIG_VNCSERVER_TOUCH
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ *
+ * Description:
+ *   Register touch device to fetch touch event from VNC client.
+ *
+ * Input Parameters:
+ *   devpath - Device path for this device
+ *
+ * Returned Value:
+ *   Driver instance
+ *
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath);

Review Comment:
   int vnc_touch_register(FAR const char *devpath, FAR struct touch_lowerhalf_s **lower);



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915436927


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -610,6 +612,22 @@ int up_fbinitialize(int display)
       return ret;
     }
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+  ret = vnc_touch_register(CONFIG_VNCSERVER_TOUCH_DEVNAME, &session->touch);
+
+  if (ret < 0)
+    {
+      gerr("Initial vnc touch driver failed.\n");
+      return ERROR;

Review Comment:
   return ret



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914626305


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -470,6 +472,42 @@ static int up_waitforsync(FAR struct fb_vtable_s *vtable)
 }
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+
+/****************************************************************************
+ * Name: vnc_uinput_mousein
+ ****************************************************************************/
+
+static int vnc_uinput_mouseout(FAR void *arg, int16_t x,
+                               int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if ((buttons & MOUSE_BUTTON_1) != 0)
+    {
+      sample.point[0].flags = TOUCH_DOWN |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+  else
+    {
+      sample.point[0].flags = TOUCH_UP |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+
+  return nx_write(session->fd_mouse, (void *)&sample, sizeof(sample));

Review Comment:
   why not implement and register a mouse driver directly?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915385651


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -619,6 +622,22 @@ int up_fbinitialize(int display)
       gerr("ERROR: wait for vnc server start failed: %d\n", ret);
     }
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+  session->touch    = vnc_touch_register(CONFIG_VNCSERVER_TOUCH_DEVNAME);

Review Comment:
   should we call vnc_touch_register before vnc_wait_start? otherwise, the background thread may reference touch before we register the driver.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914853489


##########
drivers/video/vnc/Kconfig:
##########
@@ -139,6 +139,20 @@ config VNCSERVER_KBDENCODE
 		Use a special encoding of keyboard characters as defined in
 		include/nuttx/input/kbd_coded.h.
 
+config VNCSERVER_MOUSE

Review Comment:
   OK



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914952666


##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;
+  int ret;
+
+  vnc_lower = kmm_zalloc(sizeof(struct touch_lowerhalf_s));
+
+  if (vnc_lower == NULL)
+    {
+      gerr("Alloc VNC touch driver instance failed.\n");
+      return NULL;
+    }
+
+  ret = touch_register(vnc_lower, devpath, 1);
+
+  if (ret < 0)
+    {
+      gerr("Register VNC touch driver failed.\n");
+      return NULL;
+    }
+
+  return vnc_lower;
+}
+
+/****************************************************************************
+ * Name: vnc_touch_event
+ ****************************************************************************/
+
+int vnc_touch_event(FAR void *arg, int16_t x,
+                    int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if ((buttons & MOUSE_BUTTON_1) != 0)
+    {
+      sample.point[0].flags = TOUCH_DOWN |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+  else
+    {
+      sample.point[0].flags = TOUCH_UP |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;

Review Comment:
   move TOUCH_ID_VALID | TOUCH_POS_VALID; out of if/else to avoid the code dup



##########
drivers/video/vnc/vnc_server.h:
##########
@@ -503,6 +508,37 @@ int vnc_raw(FAR struct vnc_session_s *session, FAR struct fb_area_s *rect);
 void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym,
                  bool keydown);
 
+#ifdef CONFIG_VNCSERVER_TOUCH
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ *
+ * Description:
+ *   Register touch device to fetch touch event from VNC client.
+ *
+ * Input Parameters:
+ *   devpath - Device path for this device
+ *
+ * Returned Value:
+ *   Driver instance
+ *
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath);
+
+/****************************************************************************
+ * Name: vnc_touch_event
+ *
+ * Description:
+ *   Report a touch event from vnc client.
+ *
+ ****************************************************************************/
+
+int vnc_touch_event(FAR void *arg, int16_t x,
+                    int16_t y, uint8_t buttons);

Review Comment:
   merge to previous line



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;
+  int ret;
+
+  vnc_lower = kmm_zalloc(sizeof(struct touch_lowerhalf_s));
+
+  if (vnc_lower == NULL)
+    {
+      gerr("Alloc VNC touch driver instance failed.\n");
+      return NULL;
+    }
+
+  ret = touch_register(vnc_lower, devpath, 1);
+
+  if (ret < 0)
+    {
+      gerr("Register VNC touch driver failed.\n");
+      return NULL;
+    }
+
+  return vnc_lower;
+}
+
+/****************************************************************************
+ * Name: vnc_touch_event
+ ****************************************************************************/
+
+int vnc_touch_event(FAR void *arg, int16_t x,
+                    int16_t y, uint8_t buttons)

Review Comment:
   merge to previous line



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,99 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+ /****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;
+  int ret;
+
+  vnc_lower = kmm_zalloc(sizeof(struct touch_lowerhalf_s));
+
+  if (vnc_lower == NULL)
+    {
+      gerr("Alloc VNC touch driver instance failed.\n");
+      return NULL;
+    }
+
+  ret = touch_register(vnc_lower, devpath, 1);
+
+  if (ret < 0)
+    {
+      gerr("Register VNC touch driver failed.\n");
+      return NULL;
+    }
+
+  return vnc_lower;
+}
+
+
+/****************************************************************************
+ * Name: vnc_touch_event
+ ****************************************************************************/
+
+int vnc_touch_event(FAR void *arg, int16_t x,
+                           int16_t y, uint8_t buttons)

Review Comment:
   merge to previous line?



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;
+  int ret;
+
+  vnc_lower = kmm_zalloc(sizeof(struct touch_lowerhalf_s));
+
+  if (vnc_lower == NULL)
+    {
+      gerr("Alloc VNC touch driver instance failed.\n");
+      return NULL;
+    }
+
+  ret = touch_register(vnc_lower, devpath, 1);
+
+  if (ret < 0)
+    {
+      gerr("Register VNC touch driver failed.\n");

Review Comment:
   kmm_free(vnc_lower)



##########
drivers/video/vnc/Kconfig:
##########
@@ -139,6 +139,20 @@ config VNCSERVER_KBDENCODE
 		Use a special encoding of keyboard characters as defined in
 		include/nuttx/input/kbd_coded.h.
 
+config VNCSERVER_TOUCH
+	bool "Enable touch input"
+	default n
+	select INPUT_TOUCHSCREEN
+	---help---
+		Use uinput based mouse driver

Review Comment:
   touchscreen



##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -50,6 +50,8 @@
 #include <nuttx/kthread.h>
 #include <nuttx/video/fb.h>
 #include <nuttx/video/vnc.h>
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>

Review Comment:
   remove mouse.h



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;

Review Comment:
   vnc_lower->lower



##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;
+  int ret;
+
+  vnc_lower = kmm_zalloc(sizeof(struct touch_lowerhalf_s));
+
+  if (vnc_lower == NULL)
+    {
+      gerr("Alloc VNC touch driver instance failed.\n");
+      return NULL;
+    }
+
+  ret = touch_register(vnc_lower, devpath, 1);
+
+  if (ret < 0)
+    {
+      gerr("Register VNC touch driver failed.\n");
+      return NULL;
+    }
+
+  return vnc_lower;
+}
+
+/****************************************************************************
+ * Name: vnc_touch_event
+ ****************************************************************************/
+
+int vnc_touch_event(FAR void *arg, int16_t x,

Review Comment:
   int->void



##########
drivers/video/vnc/Kconfig:
##########
@@ -139,6 +139,20 @@ config VNCSERVER_KBDENCODE
 		Use a special encoding of keyboard characters as defined in
 		include/nuttx/input/kbd_coded.h.
 
+config VNCSERVER_TOUCH
+	bool "Enable touch input"
+	default n
+	select INPUT_TOUCHSCREEN
+	---help---
+		Use uinput based mouse driver
+
+config VNCSERVER_TOUCH_DEVNAME
+	string "Touch input device name"
+	default "/dev/vnctouch"
+	depends on VNCSERVER_TOUCH
+	---help---
+		Device name

Review Comment:
   Touch device name



##########
drivers/video/vnc/vnc_server.c:
##########
@@ -284,6 +285,19 @@ int vnc_server(int argc, FAR char *argv[])
   nxsem_set_protocol(&session->vsyncsem, SEM_PRIO_NONE);
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+  ret = nx_open(CONFIG_VNCSERVER_MOUSE_DEVNAME, O_WRONLY);

Review Comment:
   revert the change in this file



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915385045


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -50,6 +50,8 @@
 #include <nuttx/kthread.h>
 #include <nuttx/video/fb.h>
 #include <nuttx/video/vnc.h>
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>

Review Comment:
   Yes, but you don't need reference MOUSE_BUTTON_1 in this file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915446386


##########
drivers/video/vnc/Kconfig:
##########
@@ -139,6 +139,21 @@ config VNCSERVER_KBDENCODE
 		Use a special encoding of keyboard characters as defined in
 		include/nuttx/input/kbd_coded.h.
 
+config VNCSERVER_TOUCH
+	bool "Enable touch input"
+	default n
+	select INPUT
+	select INPUT_TOUCHSCREEN
+	---help---
+		Use touchscreen based input driver
+
+config VNCSERVER_TOUCH_DEVNAME
+	string "Touch input device name"
+	default "/dev/vnctouch"

Review Comment:
   look like we need use /dev/inputx like other driver to improve the compatibility.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914645092


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -470,6 +472,42 @@ static int up_waitforsync(FAR struct fb_vtable_s *vtable)
 }
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+
+/****************************************************************************
+ * Name: vnc_uinput_mousein
+ ****************************************************************************/
+
+static int vnc_uinput_mouseout(FAR void *arg, int16_t x,
+                               int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if ((buttons & MOUSE_BUTTON_1) != 0)
+    {
+      sample.point[0].flags = TOUCH_DOWN |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+  else
+    {
+      sample.point[0].flags = TOUCH_UP |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+
+  return nx_write(session->fd_mouse, (void *)&sample, sizeof(sample));

Review Comment:
   This causes VNC mouse driver's private data and VNC session to be coupled together.
   And write to uinput is more simple (it's logic is very similar to uinput).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914601174


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -470,6 +472,42 @@ static int up_waitforsync(FAR struct fb_vtable_s *vtable)
 }
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+
+/****************************************************************************
+ * Name: vnc_uinput_mousein
+ ****************************************************************************/
+
+static int vnc_uinput_mouseout(FAR void *arg, int16_t x,
+                               int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if (buttons & MOUSE_BUTTON_1)
+    {
+      sample.point[0].flags = TOUCH_DOWN |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+  else
+    {
+      sample.point[0].flags = TOUCH_UP |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+
+  return write(session->fd_mouse, (void *)&sample, sizeof(sample));

Review Comment:
   ```suggestion
     return nx_write(session->fd_mouse, (void *)&sample, sizeof(sample));
   ```



##########
drivers/video/vnc/vnc_server.c:
##########
@@ -284,6 +285,19 @@ int vnc_server(int argc, FAR char *argv[])
   nxsem_set_protocol(&session->vsyncsem, SEM_PRIO_NONE);
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+  ret = open(CONFIG_VNCSERVER_MOUSE_DEVNAME, O_WRONLY);

Review Comment:
   ```suggestion
     ret = nx_open(CONFIG_VNCSERVER_MOUSE_DEVNAME, O_WRONLY);
   ```



##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -470,6 +472,42 @@ static int up_waitforsync(FAR struct fb_vtable_s *vtable)
 }
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+
+/****************************************************************************
+ * Name: vnc_uinput_mousein
+ ****************************************************************************/
+
+static int vnc_uinput_mouseout(FAR void *arg, int16_t x,
+                               int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if (buttons & MOUSE_BUTTON_1)

Review Comment:
   Optional
   ```suggestion
     if ((buttons & MOUSE_BUTTON_1) != 0)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r914942729


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -470,6 +472,42 @@ static int up_waitforsync(FAR struct fb_vtable_s *vtable)
 }
 #endif
 
+#ifdef CONFIG_VNCSERVER_MOUSE
+
+/****************************************************************************
+ * Name: vnc_uinput_mousein
+ ****************************************************************************/
+
+static int vnc_uinput_mouseout(FAR void *arg, int16_t x,
+                               int16_t y, uint8_t buttons)
+{
+  FAR struct vnc_session_s *session = arg;
+  struct touch_sample_s sample;
+
+  DEBUGASSERT(session);
+
+  sample.npoints = 1;
+  sample.point[0].x = x;
+  sample.point[0].y = y;
+
+  if ((buttons & MOUSE_BUTTON_1) != 0)
+    {
+      sample.point[0].flags = TOUCH_DOWN |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+  else
+    {
+      sample.point[0].flags = TOUCH_UP |
+                              TOUCH_ID_VALID |
+                              TOUCH_POS_VALID;
+    }
+
+  return nx_write(session->fd_mouse, (void *)&sample, sizeof(sample));

Review Comment:
   OK, a touchscreen based driver implemented.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r916398372


##########
drivers/video/vnc/vnc_fbdev.c:
##########
@@ -598,9 +600,39 @@ static inline int vnc_wait_start(int display)
 int up_fbinitialize(int display)
 {
   int ret;
+  FAR struct vnc_session_s *session;
+#ifdef CONFIG_VNCSERVER_TOUCH
+  char devname[NAME_MAX];
+#endif
 
   DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS);
 
+  /* Save the input callout function information in the session structure. */
+
+  session           = g_vnc_sessions[display];
+#ifdef CONFIG_VNCSERVER_TOUCH
+
+  ret = snprintf(devname, NAME_MAX, CONFIG_VNCSERVER_TOUCH_DEVNAME "%d",
+                 display);
+
+  if (ret < 0)
+    {
+      gerr("ERROR: Format vnc touch driver path failed.\n");
+      return ret;
+    }
+
+  ret = vnc_touch_register(devname, session);
+
+  if (ret < 0)
+    {
+      gerr("ERROR: Initial vnc touch driver failed.\n");
+      return ret;
+    }
+
+  session->mouseout = vnc_touch_event;
+#endif
+  session->arg      = session;
+
   /* Start the VNC server kernel thread. */
 
   ret = vnc_start_server(display);

Review Comment:
   let's unregister touch screen driver in case of fail



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] no1wudi commented on a diff in pull request #6576: vncserver: Support pointer event by uinput

Posted by GitBox <gi...@apache.org>.
no1wudi commented on code in PR #6576:
URL: https://github.com/apache/incubator-nuttx/pull/6576#discussion_r915381063


##########
drivers/video/vnc/vnc_touch.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * drivers/video/vnc/vnc_touch.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "vnc_server.h"
+
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/input/touchscreen.h>
+#include <nuttx/input/mouse.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vnc_touch_register
+ ****************************************************************************/
+
+FAR struct touch_lowerhalf_s *vnc_touch_register(FAR const char *devpath)
+{
+  FAR struct touch_lowerhalf_s *vnc_lower;
+  int ret;
+
+  vnc_lower = kmm_zalloc(sizeof(struct touch_lowerhalf_s));
+
+  if (vnc_lower == NULL)
+    {
+      gerr("Alloc VNC touch driver instance failed.\n");
+      return NULL;
+    }
+
+  ret = touch_register(vnc_lower, devpath, 1);
+
+  if (ret < 0)
+    {
+      gerr("Register VNC touch driver failed.\n");
+      return NULL;
+    }
+
+  return vnc_lower;
+}
+
+/****************************************************************************
+ * Name: vnc_touch_event
+ ****************************************************************************/
+
+int vnc_touch_event(FAR void *arg, int16_t x,

Review Comment:
   Use int here to fit callback prototype `vnc_mouseout_t`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org