[MPlayer-cvslog] r31074 - in trunk: Makefile libvo/gl_common.c libvo/sdl_common.c libvo/sdl_common.h libvo/vo_sdl.c
reimar
subversion at mplayerhq.hu
Sun Apr 25 10:17:23 CEST 2010
Author: reimar
Date: Sun Apr 25 10:17:23 2010
New Revision: 31074
Log:
Add sdl_common file and use it to share the input handling between -vo gl
with SDL backend and -vo sdl.
Added:
trunk/libvo/sdl_common.c
trunk/libvo/sdl_common.h
Modified:
trunk/Makefile
trunk/libvo/gl_common.c
trunk/libvo/vo_sdl.c
Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile Sun Apr 25 09:32:42 2010 (r31073)
+++ trunk/Makefile Sun Apr 25 10:17:23 2010 (r31074)
@@ -558,6 +558,7 @@ SRCS_MPLAYER-$(GGI) += libvo/vo
SRCS_MPLAYER-$(GIF) += libvo/vo_gif89a.c
SRCS_MPLAYER-$(GL) += libvo/gl_common.c libvo/vo_gl.c \
libvo/vo_gl2.c libvo/csputils.c
+SRCS_MPLAYER-$(GL_SDL) += libvo/sdl_common.c
SRCS_MPLAYER-$(GL_WIN32) += libvo/w32_common.c
SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c
SRCS_MPLAYER-$(MATRIXVIEW) += libvo/vo_matrixview.c libvo/matrixview.c
@@ -626,7 +627,7 @@ SRCS_MPLAYER-$(PNM) += libvo/v
SRCS_MPLAYER-$(PULSE) += libao2/ao_pulse.c
SRCS_MPLAYER-$(QUARTZ) += libvo/vo_quartz.c libvo/osx_common.c
SRCS_MPLAYER-$(S3FB) += libvo/vo_s3fb.c
-SRCS_MPLAYER-$(SDL) += libao2/ao_sdl.c libvo/vo_sdl.c
+SRCS_MPLAYER-$(SDL) += libao2/ao_sdl.c libvo/vo_sdl.c libvo/sdl_common.c
SRCS_MPLAYER-$(SGIAUDIO) += libao2/ao_sgi.c
SRCS_MPLAYER-$(SUNAUDIO) += libao2/ao_sun.c
SRCS_MPLAYER-$(SVGA) += libvo/vo_svga.c
Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c Sun Apr 25 09:32:42 2010 (r31073)
+++ trunk/libvo/gl_common.c Sun Apr 25 10:17:23 2010 (r31074)
@@ -1844,11 +1844,7 @@ static int x11_check_events(void) {
#endif
#ifdef CONFIG_GL_SDL
-#ifdef CONFIG_SDL_SDL_H
-#include <SDL/SDL.h>
-#else
-#include <SDL.h>
-#endif
+#include "sdl_common.h"
static void swapGlBuffers_sdl(MPGLContext *ctx) {
SDL_GL_SwapBuffers();
@@ -1863,6 +1859,16 @@ static int setGlWindow_sdl(MPGLContext *
getFunctions(sdlgpa, NULL);
return SET_WINDOW_OK;
}
+
+static int sdl_check_events(void) {
+ int res = 0;
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ res |= sdl_default_handle_event(&event);
+ }
+ return res;
+}
+
#endif
static int setGlWindow_dummy(MPGLContext *ctx) {
@@ -1913,6 +1919,7 @@ int init_mpglcontext(MPGLContext *ctx, e
SDL_Init(SDL_INIT_VIDEO);
ctx->setGlWindow = setGlWindow_sdl;
ctx->swapGlBuffers = swapGlBuffers_sdl;
+ ctx->check_events = sdl_check_events;
return 1;
#endif
default:
Added: trunk/libvo/sdl_common.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libvo/sdl_common.c Sun Apr 25 10:17:23 2010 (r31074)
@@ -0,0 +1,112 @@
+/*
+ * common SDL routines
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "sdl_common.h"
+#include "mp_msg.h"
+#include "mp_fifo.h"
+#include "osdep/keycodes.h"
+#include "input/input.h"
+#include "input/mouse.h"
+#include "video_out.h"
+
+#define shift_key (event->key.keysym.mod==(KMOD_LSHIFT||KMOD_RSHIFT))
+int sdl_default_handle_event(SDL_Event *event)
+{
+ SDLKey keypressed = SDLK_UNKNOWN;
+ switch (event->type) {
+ case SDL_VIDEORESIZE:
+ vo_dwidth = event->resize.w;
+ vo_dheight = event->resize.h;
+ return VO_EVENT_RESIZE;
+ case SDL_MOUSEBUTTONDOWN:
+ if(vo_nomouse_input)
+ break;
+ mplayer_put_key((MOUSE_BTN0 + event->button.button - 1) | MP_KEY_DOWN);
+ break;
+
+ case SDL_MOUSEBUTTONUP:
+ if(vo_nomouse_input)
+ break;
+ mplayer_put_key(MOUSE_BTN0 + event->button.button - 1);
+ break;
+
+ case SDL_KEYDOWN:
+ keypressed = event->key.keysym.sym;
+ mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Key pressed: '%i'\n", keypressed);
+ switch(keypressed) {
+ case SDLK_RETURN: mplayer_put_key(KEY_ENTER);break;
+ case SDLK_ESCAPE: mplayer_put_key(KEY_ESC);break;
+ case SDLK_q: mplayer_put_key('q');break;
+ case SDLK_F1: mplayer_put_key(KEY_F+1);break;
+ case SDLK_F2: mplayer_put_key(KEY_F+2);break;
+ case SDLK_F3: mplayer_put_key(KEY_F+3);break;
+ case SDLK_F4: mplayer_put_key(KEY_F+4);break;
+ case SDLK_F5: mplayer_put_key(KEY_F+5);break;
+ case SDLK_F6: mplayer_put_key(KEY_F+6);break;
+ case SDLK_F7: mplayer_put_key(KEY_F+7);break;
+ case SDLK_F8: mplayer_put_key(KEY_F+8);break;
+ case SDLK_F9: mplayer_put_key(KEY_F+9);break;
+ case SDLK_F10: mplayer_put_key(KEY_F+10);break;
+ case SDLK_F11: mplayer_put_key(KEY_F+11);break;
+ case SDLK_F12: mplayer_put_key(KEY_F+12);break;
+ /*case SDLK_o: mplayer_put_key('o');break;
+ case SDLK_SPACE: mplayer_put_key(' ');break;
+ case SDLK_p: mplayer_put_key('p');break;*/
+ case SDLK_7: mplayer_put_key(shift_key?'/':'7');break;
+ case SDLK_PLUS: mplayer_put_key(shift_key?'*':'+');break;
+ case SDLK_KP_PLUS: mplayer_put_key('+');break;
+ case SDLK_MINUS:
+ case SDLK_KP_MINUS: mplayer_put_key('-');break;
+ case SDLK_TAB: mplayer_put_key('\t');break;
+ case SDLK_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break;
+ case SDLK_PAGEDOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
+ case SDLK_UP: mplayer_put_key(KEY_UP);break;
+ case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break;
+ case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break;
+ case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break;
+ case SDLK_LESS: mplayer_put_key(shift_key?'>':'<'); break;
+ case SDLK_GREATER: mplayer_put_key('>'); break;
+ case SDLK_ASTERISK:
+ case SDLK_KP_MULTIPLY: mplayer_put_key('*'); break;
+ case SDLK_SLASH:
+ case SDLK_KP_DIVIDE: mplayer_put_key('/'); break;
+ case SDLK_KP0: mplayer_put_key(KEY_KP0); break;
+ case SDLK_KP1: mplayer_put_key(KEY_KP1); break;
+ case SDLK_KP2: mplayer_put_key(KEY_KP2); break;
+ case SDLK_KP3: mplayer_put_key(KEY_KP3); break;
+ case SDLK_KP4: mplayer_put_key(KEY_KP4); break;
+ case SDLK_KP5: mplayer_put_key(KEY_KP5); break;
+ case SDLK_KP6: mplayer_put_key(KEY_KP6); break;
+ case SDLK_KP7: mplayer_put_key(KEY_KP7); break;
+ case SDLK_KP8: mplayer_put_key(KEY_KP8); break;
+ case SDLK_KP9: mplayer_put_key(KEY_KP9); break;
+ case SDLK_KP_PERIOD: mplayer_put_key(KEY_KPDEC); break;
+ case SDLK_KP_ENTER: mplayer_put_key(KEY_KPENTER); break;
+ default:
+ //printf("got scancode: %d keysym: %d mod: %d %d\n", event.key.keysym.scancode, keypressed, event.key.keysym.mod);
+ mplayer_put_key(keypressed);
+ }
+
+ break;
+
+ case SDL_QUIT: mplayer_put_key(KEY_CLOSE_WIN);break;
+ }
+ return 0;
+}
Added: trunk/libvo/sdl_common.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libvo/sdl_common.h Sun Apr 25 10:17:23 2010 (r31074)
@@ -0,0 +1,32 @@
+/*
+ * common SDL routines
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_SDL_COMMON_H
+#define MPLAYER_SDL_COMMON_H
+
+#include "config.h"
+#ifdef CONFIG_SDL_SDL_H
+#include <SDL/SDL.h>
+#else
+#include <SDL.h>
+#endif
+int sdl_default_handle_event(SDL_Event *event);
+
+#endif
Modified: trunk/libvo/vo_sdl.c
==============================================================================
--- trunk/libvo/vo_sdl.c Sun Apr 25 09:32:42 2010 (r31073)
+++ trunk/libvo/vo_sdl.c Sun Apr 25 10:17:23 2010 (r31074)
@@ -73,10 +73,7 @@
#include "x11_common.h"
#endif
-#include "input/input.h"
-#include "input/mouse.h"
#include "subopt-helper.h"
-#include "mp_fifo.h"
static const vo_info_t info =
{
@@ -88,11 +85,7 @@ static const vo_info_t info =
const LIBVO_EXTERN(sdl)
-#ifdef CONFIG_SDL_SDL_H
-#include <SDL/SDL.h>
-#else
-#include <SDL.h>
-#endif
+#include "sdl_common.h"
//#include <SDL/SDL_syswm.h>
@@ -1098,9 +1091,6 @@ static int draw_slice(uint8_t *image[],
* returns : doesn't return
**/
-#include "osdep/keycodes.h"
-
-#define shift_key (event.key.keysym.mod==(KMOD_LSHIFT||KMOD_RSHIFT))
static void check_events (void)
{
struct sdl_priv_s *priv = &sdl_priv;
@@ -1124,18 +1114,6 @@ static void check_events (void)
mp_msg(MSGT_VO,MSGL_DBG3, "SDL: Window resize\n");
break;
- case SDL_MOUSEBUTTONDOWN:
- if(vo_nomouse_input)
- break;
- mplayer_put_key((MOUSE_BTN0+event.button.button-1) | MP_KEY_DOWN);
- break;
-
- case SDL_MOUSEBUTTONUP:
- if(vo_nomouse_input)
- break;
- mplayer_put_key(MOUSE_BTN0+event.button.button-1);
- break;
-
/* graphics mode selection shortcuts */
case SDL_KEYDOWN:
keypressed = event.key.keysym.sym;
@@ -1169,66 +1147,13 @@ static void check_events (void)
}
}
- else switch(keypressed){
- case SDLK_RETURN: mplayer_put_key(KEY_ENTER);break;
- case SDLK_ESCAPE: mplayer_put_key(KEY_ESC);break;
- case SDLK_q: mplayer_put_key('q');break;
- case SDLK_F1: mplayer_put_key(KEY_F+1);break;
- case SDLK_F2: mplayer_put_key(KEY_F+2);break;
- case SDLK_F3: mplayer_put_key(KEY_F+3);break;
- case SDLK_F4: mplayer_put_key(KEY_F+4);break;
- case SDLK_F5: mplayer_put_key(KEY_F+5);break;
- case SDLK_F6: mplayer_put_key(KEY_F+6);break;
- case SDLK_F7: mplayer_put_key(KEY_F+7);break;
- case SDLK_F8: mplayer_put_key(KEY_F+8);break;
- case SDLK_F9: mplayer_put_key(KEY_F+9);break;
- case SDLK_F10: mplayer_put_key(KEY_F+10);break;
- case SDLK_F11: mplayer_put_key(KEY_F+11);break;
- case SDLK_F12: mplayer_put_key(KEY_F+12);break;
- /*case SDLK_o: mplayer_put_key('o');break;
- case SDLK_SPACE: mplayer_put_key(' ');break;
- case SDLK_p: mplayer_put_key('p');break;*/
- case SDLK_7: mplayer_put_key(shift_key?'/':'7');break;
- case SDLK_PLUS: mplayer_put_key(shift_key?'*':'+');break;
- case SDLK_KP_PLUS: mplayer_put_key('+');break;
- case SDLK_MINUS:
- case SDLK_KP_MINUS: mplayer_put_key('-');break;
- case SDLK_TAB: mplayer_put_key('\t');break;
- case SDLK_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break;
- case SDLK_PAGEDOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
- case SDLK_UP: mplayer_put_key(KEY_UP);break;
- case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break;
- case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break;
- case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break;
- case SDLK_LESS: mplayer_put_key(shift_key?'>':'<'); break;
- case SDLK_GREATER: mplayer_put_key('>'); break;
- case SDLK_ASTERISK:
- case SDLK_KP_MULTIPLY: mplayer_put_key('*'); break;
- case SDLK_SLASH:
- case SDLK_KP_DIVIDE: mplayer_put_key('/'); break;
- case SDLK_KP0: mplayer_put_key(KEY_KP0); break;
- case SDLK_KP1: mplayer_put_key(KEY_KP1); break;
- case SDLK_KP2: mplayer_put_key(KEY_KP2); break;
- case SDLK_KP3: mplayer_put_key(KEY_KP3); break;
- case SDLK_KP4: mplayer_put_key(KEY_KP4); break;
- case SDLK_KP5: mplayer_put_key(KEY_KP5); break;
- case SDLK_KP6: mplayer_put_key(KEY_KP6); break;
- case SDLK_KP7: mplayer_put_key(KEY_KP7); break;
- case SDLK_KP8: mplayer_put_key(KEY_KP8); break;
- case SDLK_KP9: mplayer_put_key(KEY_KP9); break;
- case SDLK_KP_PERIOD: mplayer_put_key(KEY_KPDEC); break;
- case SDLK_KP_ENTER: mplayer_put_key(KEY_KPENTER); break;
- default:
- //printf("got scancode: %d keysym: %d mod: %d %d\n", event.key.keysym.scancode, keypressed, event.key.keysym.mod);
- mplayer_put_key(keypressed);
- }
+ else sdl_default_handle_event(&event);
break;
- case SDL_QUIT: mplayer_put_key(KEY_CLOSE_WIN);break;
+ default: sdl_default_handle_event(&event); break;
}
}
}
-#undef shift_key
/* Erase (paint it black) the rectangle specified by x, y, w and h in the surface
or overlay which is used for OSD
More information about the MPlayer-cvslog
mailing list