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/04/06 05:34:39 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #5988: arch/sim: support simulator keyboard devices

xiaoxiang781216 commented on code in PR #5988:
URL: https://github.com/apache/incubator-nuttx/pull/5988#discussion_r843475953


##########
arch/sim/Kconfig:
##########
@@ -349,6 +349,21 @@ config SIM_NOINPUT
 	bool "No input device"
 
 endchoice # Input Device
+
+config SIM_KEYBOARD
+	bool "X11 keyboard"
+	select INPUT_KEYBOARD
+	depends on SIM_X11FB
+	---help---
+		Support an X11 mouse-based keyboard emulation.  Also needs INPUT=y
+
+config CONFIG_SIM_KBD_BUFFSIZE

Review Comment:
   change to SIM_KEYBOARD_BUFFSIZE



##########
arch/sim/src/sim/up_x11eventloop.c:
##########
@@ -116,6 +117,15 @@ void up_x11events(void)
 
       switch (event.type)
         {
+          #ifdef CONFIG_SIM_KEYBOARD
+          case KeyPress:
+            up_kbdevent(XLookupKeysym(&event.xkey, 0), 0);

Review Comment:
   0->KEYBOARD_PRESS



##########
arch/sim/src/sim/up_x11eventloop.c:
##########
@@ -116,6 +117,15 @@ void up_x11events(void)
 
       switch (event.type)
         {
+          #ifdef CONFIG_SIM_KEYBOARD
+          case KeyPress:
+            up_kbdevent(XLookupKeysym(&event.xkey, 0), 0);
+            break;
+          case KeyRelease:
+            up_kbdevent(XLookupKeysym(&event.xkey, 0), 1);

Review Comment:
   1->KEYBOARD_RELEASE



##########
arch/sim/src/sim/up_internal.h:
##########
@@ -231,10 +231,17 @@ int sim_tsc_initialize(int minor);
 int sim_tsc_uninitialize(void);
 #endif
 
+/* up_keyboard.c ************************************************************/
+
+#ifdef CONFIG_SIM_KEYBOARD
+int sim_kbd_initialize(void);
+void up_kbdevent(uint32_t key, int type);

Review Comment:
   int->uint32_t 



##########
arch/sim/src/sim/up_keyboard.c:
##########
@@ -0,0 +1,110 @@
+/****************************************************************************
+ * arch/sim/src/sim/up_keyboard.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 <nuttx/config.h>
+#include <sys/types.h>
+
+#include <assert.h>
+#include <debug.h>
+#include <string.h>
+
+#include <nuttx/input/keyboard.h>
+
+#include "up_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define DEVNAME "/dev/kbd"
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct up_dev_s
+{
+  int eventloop;
+  struct keyboard_lowerhalf_s lower;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* Only one simulated keyboard is supported so the driver state
+ * structure may as well be pre-allocated.
+ */
+
+static struct up_dev_s g_simkeyboard;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sim_kbd_initialize
+ ****************************************************************************/
+
+int sim_kbd_initialize(void)
+{
+  int                  ret;
+  FAR struct up_dev_s *priv = &g_simkeyboard;
+
+  memset(priv, 0, sizeof(*priv));
+
+  /* Register the device as an input device */
+
+  ret = keyboard_register(&priv->lower, DEVNAME, 64);

Review Comment:
   64->CONFIG_SIM_KEYBOARD_BUFFSIZE



-- 
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