Skip to contentSkip to conversation

Fix SDL on evdev hosts

RFC PATCH In review Anthony Liguori 4 participants 7 messages Feb 27, 2009 – Mar 10, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Fix SDL on evdev hosts

This patch corrects SDL support on X11 hosts using evdev. It's losely based on the previous patch by Dustin Kirkland and the evdev support code in gtk-vnc written by Daniel Berrange.

I've tried to take into account all past feedback from previous patches posted including a proper set of configure checks. I've tested this on win32 but I'd like some more eyes to look at it.

configure +18 -0
index 62925d8..faacb8d 100755
@@ -187,6 +187,7 @@ kerneldir=""
 aix="no"
 blobs="yes"
 fdt="yes"
+sdl_x11="no"
 
 # OS specific
 if check_define __linux__ ; then
@@ -805,6 +806,21 @@ else
     fi
 fi # -z $sdl
 
+if test "$sdl" = "yes" ; then
+cat > $TMPC <<EOF
+#include <SDL.h>
+#if defined(SDL_VIDEO_DRIVER_X11)
+#include <X11/XKBlib.h>
+#else
+#error No x11 support
+#endif
+int main(void) { return 0; }
+EOF
+    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > /dev/null 2>&1 ; then
+	sdl_x11="yes"
+    fi
+fi
+
 ##########################################
 # VNC TLS detection
 if test "$vnc_tls" = "yes" ; then
@@ -1393,6 +1409,8 @@ if test "$sdl1" = "yes" ; then
   echo "CONFIG_SDL=yes" >> $config_mak
   if test "$target_softmmu" = "no" -o "$static" = "yes"; then
     echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
+  elif test "$sdl_x11" = "yes" ; then
+    echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
   else
     echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
   fi
console.h +0 -3
index 4a2f06f..8f438e9 100644
@@ -292,9 +292,6 @@ void do_info_vnc(void);
 /* curses.c */
 void curses_display_init(DisplayState *ds, int full_screen);
 
-/* x_keymap.c */
-extern uint8_t _translate_keycode(const int key);
-
 /* FIXME: term_printf et al should probably go elsewhere so everything
    does not need to include console.h  */
 /* monitor.c */
sdl.c +56 -2

82 lines not on this page · raw message

x_keymap.c +77 -21

111 lines not on this page · raw message

x_keymap.h new file +33 -0
new file mode 100644
index 0000000..ecc59ab
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#ifndef _QEMU_X_KEYMAP_H
+#define _QEMU_X_KEYMAP_H
+
+extern uint8_t translate_xfree86_keycode(const int key);
+
+extern uint8_t translate_evdev_keycode(const int key);
+
+#endif
+
#1 lore raw
Quoted 9 lines · Anthony Liguori

This patch corrects SDL support on X11 hosts using evdev. It's losely based
on the previous patch by Dustin Kirkland and the evdev support code in gtk-vnc written by Daniel Berrange.

I've tried to take into account all past feedback from previous patches posted including a proper set of configure checks. I've tested this on win32 but I'd like some more eyes to look at it.

Just a micro nitpick:

Quoted 9 lines

+#ifndef _QEMU_X_KEYMAP_H
+#define _QEMU_X_KEYMAP_H
+
+extern uint8_t translate_xfree86_keycode(const int key); +
+extern uint8_t translate_evdev_keycode(const int key); +
+#endif
+

Looks like an extra newline at the end of file? ;-)

The #endif does not have the traditional /* _QEMU_X_KEYMAP_H */ ending, but I don't care much for those.

#2 lore raw
Quoted 26 lines · Blue Swirl
Quoted 10 lines · Anthony Liguori

This patch corrects SDL support on X11 hosts using evdev. It's losely based
on the previous patch by Dustin Kirkland and the evdev support code in gtk-vnc written by Daniel Berrange.

I've tried to take into account all past feedback from previous patches posted including a proper set of configure checks. I've tested this on win32 but I'd like some more eyes to look at it.

Just a micro nitpick:

Quoted 10 lines

+#ifndef _QEMU_X_KEYMAP_H
+#define _QEMU_X_KEYMAP_H
+
+extern uint8_t translate_xfree86_keycode(const int key); +
+extern uint8_t translate_evdev_keycode(const int key); +
+#endif
+

Quoted 2 lines

Looks like an extra newline at the end of file? ;-)

Indeed, and now it's gone :-) Thanks.

Regards,

Anthony Liguori

Quoted 3 lines

The #endif does not have the traditional /* _QEMU_X_KEYMAP_H */ ending, but I don't care much for those.

#3 lore raw
In reply to Blue Swirl
Quoted 5 lines · Blue Swirl
Quoted 4 lines · Anthony Liguori

This patch corrects SDL support on X11 hosts using evdev. It's losely based
on the previous patch by Dustin Kirkland and the evdev support code in gtk-vnc written by Daniel Berrange.

Quoted 9 lines
Quoted 5 lines

I've tried to take into account all past feedback from previous patches posted including a proper set of configure checks. I've tested this on win32 but I'd like some more eyes to look at it.

Just a micro nitpick:

Quoted 2 lines

+#ifndef _QEMU_X_KEYMAP_H
+#define _QEMU_X_KEYMAP_H

And it should be QEMU_X_KEYMAP_H.

Quoted 14 lines
Quoted 7 lines

+
+extern uint8_t translate_xfree86_keycode(const int key); +
+extern uint8_t translate_evdev_keycode(const int key); +
+#endif
+

Looks like an extra newline at the end of file? ;-)

The #endif does not have the traditional /* _QEMU_X_KEYMAP_H */ ending, but I don't care much for those.

Signature · 1 line
mailto:[email protected]
#4 lore raw
In reply to Anthony Liguori
Quoted 10 lines · Anthony Liguori

This patch corrects SDL support on X11 hosts using evdev. It's losely based on the previous patch by Dustin Kirkland and the evdev support code in gtk-vnc written by Daniel Berrange.

I've tried to take into account all past feedback from previous patches posted including a proper set of configure checks. I've tested this on win32 but I'd like some more eyes to look at it.

[..snip..]

configure if test "$sdl1" = "yes" ; then · line 1413

Quoted 10 lines
configure +3 -0
+
 ##########################################
 # VNC TLS detection
 if test "$vnc_tls" = "yes" ; then
@@ -1393,6 +1409,8 @@ if test "$sdl1" = "yes" ; then
   echo "CONFIG_SDL=yes" >> $config_mak
   if test "$target_softmmu" = "no" -o "$static" = "yes"; then
     echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
+  elif test "$sdl_x11" = "yes" ; then
+    echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak

^^^^^ this broke the
build over here, X11 on this box with this installation of OS and X puts libX11 into /usr/X11R6/lib.

[..snip..]

Signature · 1 line
mailto:[email protected]
#5 lore raw
Quoted 6 lines · malc
Quoted 6 lines
configure +1 -0
+
 ##########################################
 # VNC TLS detection
 if test "$vnc_tls" = "yes" ; then
@@ -1393,6 +1409,8 @@ if test "$sdl1" = "yes" ; then
   echo "CONFIG_SDL=yes" >> $config_mak
Quoted 9 lines

configure if test "$sdl1" = "yes" ; then

Quoted 5 lines
configure +2 -0
   if test "$target_softmmu" = "no" -o "$static" = "yes"; then
     echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
+  elif test "$sdl_x11" = "yes" ; then
+    echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
 

^^^^^ this broke the
build over here, X11 on this box with this installation of OS and X puts libX11 into /usr/X11R6/lib.

This is a non-Linux unix, right? Is the X install actually xfree86?

We can either add the -lX11 flag to the build test which would effectively disable this code on your system or we could add a hard coded /usr/X11R6/lib to the search path. In general, I don't know of a way to detect the location of X11 :-/

If it's not xfree86 though, the code probably isn't useful anyway in which case, we can just disable it.

Regards,

Anthony Liguori

Quoted 3 lines

[..snip..]

#6 lore raw
Quoted 17 lines · Anthony Liguori
Quoted 6 lines · malc
Quoted 6 lines
configure +1 -0
+
 ##########################################
 # VNC TLS detection
 if test "$vnc_tls" = "yes" ; then
@@ -1393,6 +1409,8 @@ if test "$sdl1" = "yes" ; then
   echo "CONFIG_SDL=yes" >> $config_mak
Quoted 9 lines

configure if test "$sdl1" = "yes" ; then

Quoted 5 lines
configure +2 -0
   if test "$target_softmmu" = "no" -o "$static" = "yes"; then
     echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
+  elif test "$sdl_x11" = "yes" ; then
+    echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
 

^^^^^ this broke the
build over here, X11 on this box with this installation of OS and X puts libX11 into /usr/X11R6/lib.

Quoted 1 line

This is a non-Linux unix, right? Is the X install actually xfree86?

This is a Linux.

~$ sed -n 2p /var/log/Xorg.0.log
X Window System Version 6.9.0

Quoted 5 lines

We can either add the -lX11 flag to the build test which would effectively disable this code on your system or we could add a hard coded /usr/X11R6/lib to the search path. In general, I don't know of a way to detect the location of X11 :-/

Nowadays it's either /usr/lib/libX11* or /usr/X11R6/lib/libX11* a simple test for the latter should probably suffice.

Quoted 3 lines

If it's not xfree86 though, the code probably isn't useful anyway in which case, we can just disable it.

Signature · 1 line
mailto:[email protected]