qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 03/10] sdl2: move keyboard input code to new sdl


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH 03/10] sdl2: move keyboard input code to new sdl2-input.c
Date: Thu, 11 Dec 2014 15:00:54 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 2014-12-11 at 11:49, Gerd Hoffmann wrote:
Signed-off-by: Gerd Hoffmann <address@hidden>
---
  include/ui/sdl2.h |   4 +++
  ui/Makefile.objs  |   2 +-
  ui/sdl2-input.c   | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
  ui/sdl2.c         |  75 ++------------------------------------
  4 files changed, 114 insertions(+), 73 deletions(-)
  create mode 100644 ui/sdl2-input.c

diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index 7f91a75..e1c304a 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -9,3 +9,7 @@ struct sdl2_console {
      int x, y;
      int hidden;
  };
+
+void sdl2_reset_keys(struct sdl2_console *scon);
+void sdl2_process_key(struct sdl2_console *scon,
+                      SDL_KeyboardEvent *ev);
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index b25e85f..011c5bb 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -20,7 +20,7 @@ ifeq ($(CONFIG_SDLABI),1.2)
  sdl.mo-objs := sdl.o sdl_zoom.o
  endif
  ifeq ($(CONFIG_SDLABI),2.0)
-sdl.mo-objs := sdl2.o
+sdl.mo-objs := sdl2.o sdl2-input.o
  endif
  sdl.mo-cflags := $(SDL_CFLAGS)
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
new file mode 100644
index 0000000..6702e8e
--- /dev/null
+++ b/ui/sdl2-input.c
@@ -0,0 +1,106 @@
+/*
+ * QEMU SDL display driver
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */
+
+/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */
+#undef WIN32_LEAN_AND_MEAN
+
+#include <SDL.h>
+#include <SDL_syswm.h>
+
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "ui/input.h"
+#include "ui/sdl2.h"
+#include "sysemu/sysemu.h"
+
+#include "sdl2-keymap.h"
+
+static uint8_t modifiers_state[SDL_NUM_SCANCODES];
+
+void sdl2_reset_keys(struct sdl2_console *scon)
+{
+    QemuConsole *con = scon ? scon->dcl.con : NULL;
+    int i;
+
+    for (i = 0; i < 256; i++) {

Should this be SDL_NUM_SCANCODES?

+        if (modifiers_state[i]) {
+            int qcode = sdl2_scancode_to_qcode[i];
+            qemu_input_event_send_key_qcode(con, qcode, false);
+            modifiers_state[i] = 0;
+        }
+    }
+}

Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]