1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-26 00:55:14 +00:00

Add FreeBSD native VGL driver. Right now it is work in progress and to activate

and test it you need the following (5-CURRENT only, BTW):
- fetch a patch for libvgl: http://people.freebsd.org/~sobomax/libvgl.patch,
  apply it, recompile/reinstall libvgl;
- recompile/reinstall sdl-devel (configure script automatically detects
  if right version of libvgl is present);
- set environment variable SDL_VIDEODRIVER=vgl;
- ensure that you have VESA support compiled into kernel or loaded as a kld;
- fire up your favourite SDL app ;).
This commit is contained in:
Maxim Sobolev 2001-01-23 17:28:59 +00:00
parent 7cacb2c79a
commit 1f53fed603
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=37500
30 changed files with 3330 additions and 14 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= sdl-devel
PORTVERSION= 1.1.7
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= devel
MASTER_SITES= http://www.libsdl.org/release/ \
http://www.devolution.com/~slouken/SDL/release/
@ -25,7 +25,8 @@ INSTALLS_SHLIB= yes
USE_LIBTOOL= yes
CONFIGURE_ENV= NASM="${LOCALBASE}/bin/nasm"
CONFIGURE_ARGS= --enable-video-aalib \
--enable-video-svga
--enable-video-svga \
--enable-video-vgl
CFLAGS+= -D_THREAD_SAFE

View File

@ -1,6 +1,18 @@
--- configure.orig Thu Dec 21 07:02:47 2000
+++ configure Wed Jan 3 13:37:14 2001
@@ -630,9 +630,9 @@
$FreeBSD$
--- configure.orig Fri Jan 5 22:18:22 2001
+++ configure Sun Jan 21 23:03:55 2001
@@ -80,6 +80,8 @@
ac_help="$ac_help
--enable-video-svga use SVGAlib video driver [default=no]"
ac_help="$ac_help
+ --enable-video-vgl use VGL video driver [default=no]"
+ac_help="$ac_help
--enable-video-aalib use AAlib video driver [default=no]"
ac_help="$ac_help
--enable-video-opengl include OpenGL context creation [default=yes]"
@@ -630,9 +632,9 @@
# libtool versioning
LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
@ -12,7 +24,7 @@
@@ -3022,7 +3022,7 @@
@@ -3022,7 +3024,7 @@
SDL_CFLAGS=""
@ -21,7 +33,73 @@
case "$target" in
@@ -5899,10 +5899,10 @@
@@ -5144,6 +5146,57 @@
fi
}
+CheckVGL()
+{
+ # Check whether --enable-video-vgl or --disable-video-vgl was given.
+if test "${enable_video_vgl+set}" = set; then
+ enableval="$enable_video_vgl"
+ :
+else
+ enable_video_vgl=no
+fi
+
+ if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
+ echo $ac_n "checking for libVGL support""... $ac_c" 1>&6
+echo "configure:5162: checking for libVGL support" >&5
+ video_vgl=no
+ cat > conftest.$ac_ext <<EOF
+#line 5165 "configure"
+#include "confdefs.h"
+
+ #include <sys/fbio.h>
+ #include <sys/consio.h>
+ #include <sys/kbio.h>
+ #include <vgl.h>
+
+int main() {
+
+ VGLMode mode;
+ exit(0);
+
+; return 0; }
+EOF
+if { (eval echo configure:5180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ video_vgl=yes
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ echo "$ac_t""$video_vgl" 1>&6
+ if test x$video_vgl = xyes; then
+ CFLAGS="$CFLAGS -DENABLE_VGL"
+ SYSTEM_LIBS="$SYSTEM_LIBS -lvgl"
+
+ VIDEO_SUBDIRS="$VIDEO_SUBDIRS vgl"
+ VIDEO_DRIVERS="$VIDEO_DRIVERS vgl/libvideo_vgl.la"
+ fi
+ fi
+}
+
CheckAAlib()
{
# Check whether --enable-video-aalib or --disable-video-aalib was given.
@@ -5883,6 +5936,7 @@
CheckX11
CheckDGA
CheckSVGA
+ CheckVGL
CheckAAlib
CheckOpenGL
CheckPTHREAD
@@ -5899,10 +5953,10 @@
cat >>$new <$old
# Set up files for the audio library
@ -36,3 +114,19 @@
# Set up files for the joystick library
# (No joystick support yet)
if test x$enable_joystick = xyes; then
@@ -8412,6 +8466,7 @@
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/svga/Makefile
+src/video/vgl/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
src/video/windib/Makefile
@@ -8621,6 +8676,7 @@
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/svga/Makefile
+src/video/vgl/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
src/video/windib/Makefile

View File

@ -0,0 +1,59 @@
$FreeBSD$
--- configure.in.orig Fri Jan 5 22:18:17 2001
+++ configure.in Sun Jan 21 23:01:12 2001
@@ -600,6 +600,37 @@
fi
}
+dnl Find the VGL includes and libraries
+CheckVGL()
+{
+ AC_ARG_ENABLE(video-vgl,
+[ --enable-video-vgl use VGL video driver [default=no]],
+ , enable_video_vgl=no)
+ if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
+ AC_MSG_CHECKING(for libVGL support)
+ video_vgl=no
+ AC_TRY_COMPILE([
+ #include <sys/fbio.h>
+ #include <sys/consio.h>
+ #include <sys/kbio.h>
+ #include <vgl.h>
+ ],[
+ VGLMode mode;
+ exit(0);
+ ],[
+ video_vgl=yes
+ ])
+ AC_MSG_RESULT($video_vgl)
+ if test x$video_vgl = xyes; then
+ CFLAGS="$CFLAGS -DENABLE_VGL"
+ SYSTEM_LIBS="$SYSTEM_LIBS -lvgl"
+
+ VIDEO_SUBDIRS="$VIDEO_SUBDIRS vgl"
+ VIDEO_DRIVERS="$VIDEO_DRIVERS vgl/libvideo_vgl.la"
+ fi
+ fi
+}
+
dnl Find the AAlib includes
CheckAAlib()
{
@@ -998,6 +1029,7 @@
CheckX11
CheckDGA
CheckSVGA
+ CheckVGL
CheckAAlib
CheckOpenGL
CheckPTHREAD
@@ -1659,6 +1691,7 @@
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/svga/Makefile
+src/video/vgl/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
src/video/windib/Makefile

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- src/video/Makefile.am 2001/01/21 20:09:35 1.1
+++ src/video/Makefile.am 2001/01/21 20:10:15
@@ -7,7 +7,8 @@
SUBDIRS = @VIDEO_SUBDIRS@
DIST_SUBDIRS = x11 dga fbcon svga ggi aalib \
wincommon windib windx5 \
- maccommon macdsp macrom bwindow photon cybergfx
+ maccommon macdsp macrom bwindow photon cybergfx \
+ vgl
DRIVERS = @VIDEO_DRIVERS@

View File

@ -0,0 +1,14 @@
$FreeBSD$
--- src/video/Makefile.in 2001/01/21 20:10:22 1.1
+++ src/video/Makefile.in 2001/01/21 20:10:38
@@ -103,7 +103,7 @@
# Define which subdirectories need to be built
SUBDIRS = @VIDEO_SUBDIRS@
-DIST_SUBDIRS = x11 dga fbcon svga ggi aalib wincommon windib windx5 maccommon macdsp macrom bwindow photon cybergfx
+DIST_SUBDIRS = x11 dga fbcon svga ggi aalib wincommon windib windx5 maccommon macdsp macrom bwindow photon cybergfx vgl
DRIVERS = @VIDEO_DRIVERS@

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- src/video/SDL_sysvideo.h 2001/01/21 20:12:21 1.1
+++ src/video/SDL_sysvideo.h 2001/01/21 20:12:51
@@ -331,6 +331,9 @@
#ifdef ENABLE_SVGALIB
extern VideoBootStrap SVGALIB_bootstrap;
#endif
+#ifdef ENABLE_VGL
+extern VideoBootStrap VGL_bootstrap;
+#endif
#ifdef ENABLE_AALIB
extern VideoBootStrap AALIB_bootstrap;
#endif

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- src/video/SDL_video.c 2001/01/21 20:11:02 1.1
+++ src/video/SDL_video.c 2001/01/21 20:11:59
@@ -60,6 +60,9 @@
#ifdef ENABLE_SVGALIB
&SVGALIB_bootstrap,
#endif
+#ifdef ENABLE_VGL
+ &VGL_bootstrap,
+#endif
#ifdef ENABLE_AALIB
&AALIB_bootstrap,
#endif

View File

@ -0,0 +1,21 @@
$FreeBSD$
--- /dev/null Sun Jan 21 22:16:58 2001
+++ src/video/vgl/Makefile.am Sun Jan 21 22:04:06 2001
@@ -0,0 +1,15 @@
+
+## Makefile.am for SDL using the libVGL video driver
+
+noinst_LTLIBRARIES = libvideo_vgl.la
+libvideo_vgl_la_SOURCES = $(VGL_SRCS)
+
+# The SDL libVGL video driver sources
+VGL_SRCS = \
+ SDL_vglvideo.h \
+ SDL_vglevents.c \
+ SDL_vglevents_c.h \
+ SDL_vglmouse.c \
+ SDL_vglmouse_c.h \
+ SDL_vglvideo.c
+

View File

@ -0,0 +1,328 @@
$FreeBSD$
--- /dev/null Sun Jan 21 22:16:58 2001
+++ src/video/vgl/Makefile.in Sun Jan 21 22:06:20 2001
@@ -0,0 +1,322 @@
+# Makefile.in generated automatically by automake 1.4a from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+ARCH = @ARCH@
+ARTSCCONFIG = @ARTSCCONFIG@
+AS = @AS@
+AUDIO_DRIVERS = @AUDIO_DRIVERS@
+AUDIO_SUBDIRS = @AUDIO_SUBDIRS@
+CC = @CC@
+CXX = @CXX@
+DLLTOOL = @DLLTOOL@
+ESD_CFLAGS = @ESD_CFLAGS@
+ESD_CONFIG = @ESD_CONFIG@
+ESD_LIBS = @ESD_LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAKEINFO = @MAKEINFO@
+NASM = @NASM@
+NASMFLAGS = @NASMFLAGS@
+OBJDUMP = @OBJDUMP@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+SDL_BINARY_AGE = @SDL_BINARY_AGE@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_EXTRADIRS = @SDL_EXTRADIRS@
+SDL_EXTRALIBS = @SDL_EXTRALIBS@
+SDL_INTERFACE_AGE = @SDL_INTERFACE_AGE@
+SDL_LIBS = @SDL_LIBS@
+SDL_MAJOR_VERSION = @SDL_MAJOR_VERSION@
+SDL_MICRO_VERSION = @SDL_MICRO_VERSION@
+SDL_MINOR_VERSION = @SDL_MINOR_VERSION@
+SDL_RLD_FLAGS = @SDL_RLD_FLAGS@
+SDL_VERSION = @SDL_VERSION@
+SYSTEM_LIBS = @SYSTEM_LIBS@
+VERSION = @VERSION@
+VIDEO_DRIVERS = @VIDEO_DRIVERS@
+VIDEO_SUBDIRS = @VIDEO_SUBDIRS@
+
+noinst_LTLIBRARIES = libvideo_vgl.la
+libvideo_vgl_la_SOURCES = $(VGL_SRCS)
+
+# The SDL VGLlib video driver sources
+VGL_SRCS = SDL_vglvideo.h SDL_vglevents.c SDL_vglevents_c.h SDL_vglmouse.c SDL_vglmouse_c.h SDL_vglvideo.c
+
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir)
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+libvideo_vgl_la_LDFLAGS =
+libvideo_vgl_la_LIBADD =
+libvideo_vgl_la_OBJECTS = SDL_vglevents.lo SDL_vglmouse.lo \
+SDL_vglvideo.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+SOURCES = $(libvideo_vgl_la_SOURCES)
+OBJECTS = $(libvideo_vgl_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps src/video/vgl/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLTLIBRARIES:
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+
+distclean-noinstLTLIBRARIES:
+
+maintainer-clean-noinstLTLIBRARIES:
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.c.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+libvideo_vgl.la: $(libvideo_vgl_la_OBJECTS) $(libvideo_vgl_la_DEPENDENCIES)
+ $(LINK) $(libvideo_vgl_la_LDFLAGS) $(libvideo_vgl_la_OBJECTS) $(libvideo_vgl_la_LIBADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = src/video/vgl
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LTLIBRARIES)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \
+ clean-tags clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-noinstLTLIBRARIES distclean-compile \
+ distclean-libtool distclean-tags distclean-generic \
+ clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
+clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

View File

@ -0,0 +1,311 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglevents.c Mon Jan 22 20:02:48 2001
@@ -0,0 +1,305 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglevents.c,v 1.1 2001/01/22 17:35:16 root Exp $";
+#endif
+
+/* Handle the event stream, converting X11 events into SDL events */
+
+#include <stdio.h>
+
+#include <sys/fbio.h>
+#include <sys/consio.h>
+#include <sys/kbio.h>
+#include <vgl.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_vglvideo.h"
+#include "SDL_vglevents_c.h"
+
+/* The translation tables from a console scancode to a SDL keysym */
+/* FIXME: Free the keymap when we shut down the video mode */
+static keymap_t *vga_keymap = NULL;
+static SDLKey keymap[128];
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
+
+static int posted = 0;
+static int oldx = 0;
+static int oldy = 0;
+static struct mouse_info mouseinfo;
+
+/* Ugh, we have to duplicate the kernel's keysym mapping code...
+ Oh, it's not so bad. :-)
+
+ FIXME: Add keyboard LED handling code
+ */
+int VGL_initkeymaps(int fd)
+{
+ vga_keymap = malloc(sizeof(keymap_t));
+ if ( ! vga_keymap ) {
+ SDL_OutOfMemory();
+ return(-1);
+ }
+ if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) {
+ free(vga_keymap);
+ vga_keymap = NULL;
+ SDL_SetError("Unable to get keyboard map");
+ return(-1);
+ }
+ return(0);
+}
+
+static void handle_keyboard(_THIS)
+{
+ SDL_keysym keysym;
+ int c, pressed, scancode;
+
+ while ((c = VGLKeyboardGetCh()) != 0) {
+ scancode = c & 0x7F;
+ if (c & 0x80) {
+ pressed = SDL_RELEASED;
+ } else {
+ pressed = SDL_PRESSED;
+ }
+
+ posted += SDL_PrivateKeyboard(pressed,
+ TranslateKey(scancode, &keysym));
+ }
+}
+
+int VGL_initmouse(int fd)
+{
+ mouseinfo.operation = MOUSE_GETINFO;
+ if (ioctl(fd, CONS_MOUSECTL, &mouseinfo) != 0)
+ return -1;
+ oldx = mouseinfo.u.data.x;
+ oldy = mouseinfo.u.data.y;
+ SDL_PrivateMouseMotion(0, 0, oldx, oldy);
+ return 0;
+}
+
+static void handle_mouse(_THIS)
+{
+ char buttons;
+ int x, y;
+ int button_state, state_changed, state;
+ int i;
+
+ ioctl(0, CONS_MOUSECTL, &mouseinfo);
+ x = mouseinfo.u.data.x;
+ y = mouseinfo.u.data.y;
+ buttons = mouseinfo.u.data.buttons;
+
+ if ((x != oldx) || (y != oldy)) {
+ posted += SDL_PrivateMouseMotion(0, 0, x, y);
+ oldx = x;
+ oldy = y;
+ }
+
+ /* See what's changed */
+ button_state = SDL_GetMouseState(NULL, NULL);
+ state_changed = button_state ^ buttons;
+ for (i = 0; i < 8; i++) {
+ if (state_changed & (1<<i)) {
+ if (buttons & (1<<i)) {
+ state = SDL_PRESSED;
+ } else {
+ state = SDL_RELEASED;
+ }
+ posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
+ }
+ }
+}
+
+
+void VGL_PumpEvents(_THIS)
+{
+ do {
+ posted = 0;
+ handle_keyboard(this);
+ handle_mouse(this);
+ } while (posted != 0);
+}
+
+void VGL_InitOSKeymap(_THIS)
+{
+ int i;
+
+ /* Initialize the BeOS key translation table */
+ for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+ keymap[i] = SDLK_UNKNOWN;
+
+ keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+ keymap[SCANCODE_1] = SDLK_1;
+ keymap[SCANCODE_2] = SDLK_2;
+ keymap[SCANCODE_3] = SDLK_3;
+ keymap[SCANCODE_4] = SDLK_4;
+ keymap[SCANCODE_5] = SDLK_5;
+ keymap[SCANCODE_6] = SDLK_6;
+ keymap[SCANCODE_7] = SDLK_7;
+ keymap[SCANCODE_8] = SDLK_8;
+ keymap[SCANCODE_9] = SDLK_9;
+ keymap[SCANCODE_0] = SDLK_0;
+ keymap[SCANCODE_MINUS] = SDLK_MINUS;
+ keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
+ keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+ keymap[SCANCODE_TAB] = SDLK_TAB;
+ keymap[SCANCODE_Q] = SDLK_q;
+ keymap[SCANCODE_W] = SDLK_w;
+ keymap[SCANCODE_E] = SDLK_e;
+ keymap[SCANCODE_R] = SDLK_r;
+ keymap[SCANCODE_T] = SDLK_t;
+ keymap[SCANCODE_Y] = SDLK_y;
+ keymap[SCANCODE_U] = SDLK_u;
+ keymap[SCANCODE_I] = SDLK_i;
+ keymap[SCANCODE_O] = SDLK_o;
+ keymap[SCANCODE_P] = SDLK_p;
+ keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
+ keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
+ keymap[SCANCODE_ENTER] = SDLK_RETURN;
+ keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+ keymap[SCANCODE_A] = SDLK_a;
+ keymap[SCANCODE_S] = SDLK_s;
+ keymap[SCANCODE_D] = SDLK_d;
+ keymap[SCANCODE_F] = SDLK_f;
+ keymap[SCANCODE_G] = SDLK_g;
+ keymap[SCANCODE_H] = SDLK_h;
+ keymap[SCANCODE_J] = SDLK_j;
+ keymap[SCANCODE_K] = SDLK_k;
+ keymap[SCANCODE_L] = SDLK_l;
+ keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
+ keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
+ keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
+ keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+ keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
+ keymap[SCANCODE_Z] = SDLK_z;
+ keymap[SCANCODE_X] = SDLK_x;
+ keymap[SCANCODE_C] = SDLK_c;
+ keymap[SCANCODE_V] = SDLK_v;
+ keymap[SCANCODE_B] = SDLK_b;
+ keymap[SCANCODE_N] = SDLK_n;
+ keymap[SCANCODE_M] = SDLK_m;
+ keymap[SCANCODE_COMMA] = SDLK_COMMA;
+ keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
+ keymap[SCANCODE_SLASH] = SDLK_SLASH;
+ keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+ keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
+ keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+ keymap[SCANCODE_SPACE] = SDLK_SPACE;
+ keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+ keymap[SCANCODE_F1] = SDLK_F1;
+ keymap[SCANCODE_F2] = SDLK_F2;
+ keymap[SCANCODE_F3] = SDLK_F3;
+ keymap[SCANCODE_F4] = SDLK_F4;
+ keymap[SCANCODE_F5] = SDLK_F5;
+ keymap[SCANCODE_F6] = SDLK_F6;
+ keymap[SCANCODE_F7] = SDLK_F7;
+ keymap[SCANCODE_F8] = SDLK_F8;
+ keymap[SCANCODE_F9] = SDLK_F9;
+ keymap[SCANCODE_F10] = SDLK_F10;
+ keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
+ keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
+ keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
+ keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
+ keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
+ keymap[SCANCODE_CURSORUP] = SDLK_KP8;
+ keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
+ keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
+ keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
+ keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
+ keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
+ keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
+ keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
+ keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
+ keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
+ keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
+ keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
+ keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
+ keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
+ keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
+ keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
+ keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
+ keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
+ keymap[SCANCODE_LESS] = SDLK_LESS;
+ keymap[SCANCODE_F11] = SDLK_F11;
+ keymap[SCANCODE_F12] = SDLK_F12;
+ keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
+ keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
+ keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
+ keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
+ keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
+ keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
+ keymap[SCANCODE_BREAK] = SDLK_BREAK;
+ keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
+ keymap[SCANCODE_HOME] = SDLK_HOME;
+ keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
+ keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
+ keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
+ keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
+ keymap[SCANCODE_END] = SDLK_END;
+ keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
+ keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
+ keymap[SCANCODE_INSERT] = SDLK_INSERT;
+ keymap[SCANCODE_REMOVE] = SDLK_DELETE;
+ keymap[119] = SDLK_PAUSE;
+ keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
+ keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
+ keymap[127] = SDLK_MENU;
+}
+
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+ /* Set the keysym information */
+ keysym->scancode = scancode;
+ keysym->sym = keymap[scancode];
+ keysym->mod = KMOD_NONE;
+
+ /* If UNICODE is on, get the UNICODE value for the key */
+ keysym->unicode = 0;
+ if ( SDL_TranslateUNICODE && vga_keymap ) {
+ int map;
+ SDLMod modstate;
+
+ modstate = SDL_GetModState();
+ map = 0;
+ if ( modstate & KMOD_SHIFT ) {
+ map += 1;
+ }
+ if ( modstate & KMOD_CTRL ) {
+ map += 2;
+ }
+ if ( modstate & KMOD_ALT ) {
+ map += 4;
+ }
+ if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) {
+ keysym->unicode = vga_keymap->key[scancode].map[map];
+ }
+
+ }
+ return(keysym);
+}
+

View File

@ -0,0 +1,165 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglevents_c.h Mon Jan 22 19:57:14 2001
@@ -0,0 +1,159 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglevents_c.h,v 1.2.2.2 2000/10/03 16:00:58 hercules Exp $";
+#endif
+
+#include "SDL_vglvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts
+ of the native video subsystem (SDL_sysvideo.c)
+*/
+extern int VGL_initkeymaps(int fd);
+extern int VGL_initmouse(int fd);
+extern void VGL_keyboardcallback(int scancode, int pressed);
+
+extern void VGL_InitOSKeymap(_THIS);
+extern void VGL_PumpEvents(_THIS);
+
+/* Mouse buttons */
+#define MOUSE_LEFTBUTTON 0x01
+#define MOUSE_MIDDLEBUTTON 0x02
+#define MOUSE_RIGHTBUTTON 0x04
+
+/* Scancodes */
+#define SCANCODE_ESCAPE 1
+#define SCANCODE_1 2
+#define SCANCODE_2 3
+#define SCANCODE_3 4
+#define SCANCODE_4 5
+#define SCANCODE_5 6
+#define SCANCODE_6 7
+#define SCANCODE_7 8
+#define SCANCODE_8 9
+#define SCANCODE_9 10
+#define SCANCODE_0 11
+#define SCANCODE_MINUS 12
+#define SCANCODE_EQUAL 13
+#define SCANCODE_BACKSPACE 14
+#define SCANCODE_TAB 15
+#define SCANCODE_Q 16
+#define SCANCODE_W 17
+#define SCANCODE_E 18
+#define SCANCODE_R 19
+#define SCANCODE_T 20
+#define SCANCODE_Y 21
+#define SCANCODE_U 22
+#define SCANCODE_I 23
+#define SCANCODE_O 24
+#define SCANCODE_P 25
+#define SCANCODE_BRACKET_LEFT 26
+#define SCANCODE_BRACKET_RIGHT 27
+#define SCANCODE_ENTER 28
+#define SCANCODE_LEFTCONTROL 29
+#define SCANCODE_A 30
+#define SCANCODE_S 31
+#define SCANCODE_D 32
+#define SCANCODE_F 33
+#define SCANCODE_G 34
+#define SCANCODE_H 35
+#define SCANCODE_J 36
+#define SCANCODE_K 37
+#define SCANCODE_L 38
+#define SCANCODE_SEMICOLON 39
+#define SCANCODE_APOSTROPHE 40
+#define SCANCODE_GRAVE 41
+#define SCANCODE_LEFTSHIFT 42
+#define SCANCODE_BACKSLASH 43
+#define SCANCODE_Z 44
+#define SCANCODE_X 45
+#define SCANCODE_C 46
+#define SCANCODE_V 47
+#define SCANCODE_B 48
+#define SCANCODE_N 49
+#define SCANCODE_M 50
+#define SCANCODE_COMMA 51
+#define SCANCODE_PERIOD 52
+#define SCANCODE_SLASH 53
+#define SCANCODE_RIGHTSHIFT 54
+#define SCANCODE_KEYPADMULTIPLY 55
+#define SCANCODE_LEFTALT 56
+#define SCANCODE_SPACE 57
+#define SCANCODE_CAPSLOCK 58
+#define SCANCODE_F1 59
+#define SCANCODE_F2 60
+#define SCANCODE_F3 61
+#define SCANCODE_F4 62
+#define SCANCODE_F5 63
+#define SCANCODE_F6 64
+#define SCANCODE_F7 65
+#define SCANCODE_F8 66
+#define SCANCODE_F9 67
+#define SCANCODE_F10 68
+#define SCANCODE_NUMLOCK 69
+#define SCANCODE_SCROLLLOCK 70
+#define SCANCODE_KEYPAD7 71
+#define SCANCODE_CURSORUPLEFT 71
+#define SCANCODE_KEYPAD8 72
+#define SCANCODE_CURSORUP 72
+#define SCANCODE_KEYPAD9 73
+#define SCANCODE_CURSORUPRIGHT 73
+#define SCANCODE_KEYPADMINUS 74
+#define SCANCODE_KEYPAD4 75
+#define SCANCODE_CURSORLEFT 75
+#define SCANCODE_KEYPAD5 76
+#define SCANCODE_KEYPAD6 77
+#define SCANCODE_CURSORRIGHT 77
+#define SCANCODE_KEYPADPLUS 78
+#define SCANCODE_KEYPAD1 79
+#define SCANCODE_CURSORDOWNLEFT 79
+#define SCANCODE_KEYPAD2 80
+#define SCANCODE_CURSORDOWN 80
+#define SCANCODE_KEYPAD3 81
+#define SCANCODE_CURSORDOWNRIGHT 81
+#define SCANCODE_KEYPAD0 82
+#define SCANCODE_KEYPADPERIOD 83
+#define SCANCODE_LESS 86
+#define SCANCODE_F11 87
+#define SCANCODE_F12 88
+#define SCANCODE_KEYPADENTER 89
+#define SCANCODE_RIGHTCONTROL 90
+#define SCANCODE_CONTROL 107
+#define SCANCODE_KEYPADDIVIDE 91
+#define SCANCODE_PRINTSCREEN 92
+#define SCANCODE_RIGHTALT 93
+#define SCANCODE_BREAK 104 /* Beware: is 119 */
+#define SCANCODE_BREAK_ALTERNATIVE 104 /* on some keyboards! */
+#define SCANCODE_HOME 94
+#define SCANCODE_CURSORBLOCKUP 95 /* Cursor key block */
+#define SCANCODE_PAGEUP 96
+#define SCANCODE_CURSORBLOCKLEFT 97 /* Cursor key block */
+#define SCANCODE_CURSORBLOCKRIGHT 98 /* Cursor key block */
+#define SCANCODE_END 99
+#define SCANCODE_CURSORBLOCKDOWN 100 /* Cursor key block */
+#define SCANCODE_PAGEDOWN 101
+#define SCANCODE_INSERT 102
+#define SCANCODE_REMOVE 103
+#define SCANCODE_RIGHTWIN 106
+#define SCANCODE_LEFTWIN 105

View File

@ -0,0 +1,72 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglmouse.c Mon Jan 22 16:31:43 2001
@@ -0,0 +1,66 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglmouse.c,v 1.1.2.1 2000/03/16 15:20:39 hercules Exp $";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_vglvideo.h"
+#include "SDL_vglmouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+ int unused;
+};
+
+
+void VGL_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+ return;
+}
+
+WMcursor *VGL_CreateWMCursor(_THIS,
+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+ return(NULL);
+}
+
+int VGL_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+ return(0);
+}
+
+void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+ x += (this->screen->offset % this->screen->pitch) /
+ this->screen->format->BytesPerPixel;
+ y += (this->screen->offset / this->screen->pitch);
+ SDL_PrivateMouseMotion(0, 0, x, y);
+}
+

View File

@ -0,0 +1,42 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:10 2001
+++ src/video/vgl/SDL_vglmouse_c.h Mon Jan 22 16:31:43 2001
@@ -0,0 +1,36 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglmouse_c.h,v 1.2.2.1 2000/03/16 15:20:39 hercules Exp $";
+#endif
+
+#include "SDL_vglvideo.h"
+
+/* Functions to be exported */
+extern void VGL_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *VGL_CreateWMCursor(_THIS,
+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int VGL_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+

View File

@ -0,0 +1,450 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglvideo.c Mon Jan 22 20:04:39 2001
@@ -0,0 +1,444 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglvideo.c,v 1.1 2001/01/20 18:21:25 root Exp root $";
+#endif
+
+/* libvga based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <sys/fbio.h>
+#include <sys/consio.h>
+#include <sys/kbio.h>
+#include <vgl.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_vglvideo.h"
+#include "SDL_vglevents_c.h"
+#include "SDL_vglmouse_c.h"
+
+
+static VGLMode *VGLCurMode = NULL;
+
+/* Initialization/Query functions */
+static int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **VGL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int VGL_SetColors(_THIS, int firstcolor, int ncolors,
+ SDL_Color *colors);
+static void VGL_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int VGL_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int VGL_LockHWSurface(_THIS, SDL_Surface *surface);
+static int VGL_FlipHWSurface(_THIS, SDL_Surface *surface);
+static void VGL_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void VGL_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* VGL driver bootstrap functions */
+
+static int VGL_Available(void)
+{
+ /* Check to see if we are root and stdin is a virtual console */
+ int console;
+
+ console = STDIN_FILENO;
+ if ( console >= 0 ) {
+ struct stat sb;
+ struct vt_mode dummy;
+
+ if ( (fstat(console, &sb) < 0) ||
+ (ioctl(console, VT_GETMODE, &dummy) < 0) ) {
+ console = -1;
+ }
+ }
+ return((geteuid() == 0) && (console >= 0));
+}
+
+static void VGL_DeleteDevice(SDL_VideoDevice *device)
+{
+ free(device->hidden);
+ free(device);
+}
+
+static SDL_VideoDevice *VGL_CreateDevice(int devindex)
+{
+ SDL_VideoDevice *device;
+
+ /* Initialize all variables that we clean on shutdown */
+ device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+ if ( device ) {
+ memset(device, 0, (sizeof *device));
+ device->hidden = (struct SDL_PrivateVideoData *)
+ malloc((sizeof *device->hidden));
+ }
+ if ( (device == NULL) || (device->hidden == NULL) ) {
+ SDL_OutOfMemory();
+ if ( device ) {
+ free(device);
+ }
+ return(0);
+ }
+ memset(device->hidden, 0, (sizeof *device->hidden));
+
+ /* Set the function pointers */
+ device->VideoInit = VGL_VideoInit;
+ device->ListModes = VGL_ListModes;
+ device->SetVideoMode = VGL_SetVideoMode;
+ device->SetColors = VGL_SetColors;
+ device->UpdateRects = NULL;
+ device->VideoQuit = VGL_VideoQuit;
+ device->AllocHWSurface = VGL_AllocHWSurface;
+ device->CheckHWBlit = NULL;
+ device->FillHWRect = NULL;
+ device->SetHWColorKey = NULL;
+ device->SetHWAlpha = NULL;
+ device->LockHWSurface = VGL_LockHWSurface;
+ device->UnlockHWSurface = VGL_UnlockHWSurface;
+ device->FlipHWSurface = NULL;
+ device->FreeHWSurface = VGL_FreeHWSurface;
+ device->SetIcon = NULL;
+ device->SetCaption = NULL;
+ device->GetWMInfo = NULL;
+ device->FreeWMCursor = VGL_FreeWMCursor;
+ device->CreateWMCursor = VGL_CreateWMCursor;
+ device->ShowWMCursor = VGL_ShowWMCursor;
+ device->WarpWMCursor = VGL_WarpWMCursor;
+ device->InitOSKeymap = VGL_InitOSKeymap;
+ device->PumpEvents = VGL_PumpEvents;
+
+ device->free = VGL_DeleteDevice;
+
+ return device;
+}
+
+VideoBootStrap VGL_bootstrap = {
+ "vgl", "FreeBSD libVGL",
+ VGL_Available, VGL_CreateDevice
+};
+
+static int VGL_AddMode(_THIS, VGLMode *inmode)
+{
+ SDL_Rect *mode;
+
+ int i, index;
+ int next_mode;
+
+ /* Check to see if we already have this mode */
+ if (inmode->Depth < 8) { /* Not supported */
+ return 0;
+ }
+ index = ((inmode->Depth + 7) / 8) - 1;
+ for (i=0; i<SDL_nummodes[index]; ++i) {
+ mode = SDL_modelist[index][i];
+ if ((mode->w == inmode->ModeInfo.Xsize) &&
+ (mode->h == inmode->ModeInfo.Ysize))
+ return 0;
+ }
+
+ /* Set up the new video mode rectangle */
+ mode = (SDL_Rect *)malloc(sizeof *mode);
+ if (mode == NULL) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ mode->x = 0;
+ mode->y = 0;
+ mode->w = inmode->ModeInfo.Xsize;
+ mode->h = inmode->ModeInfo.Ysize;
+
+ /* Allocate the new list of modes, and fill in the new mode */
+ next_mode = SDL_nummodes[index];
+ SDL_modelist[index] = (SDL_Rect **)
+ realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+ if (SDL_modelist[index] == NULL) {
+ SDL_OutOfMemory();
+ SDL_nummodes[index] = 0;
+ free(mode);
+ return -1;
+ }
+ SDL_modelist[index][next_mode] = mode;
+ SDL_modelist[index][next_mode+1] = NULL;
+ SDL_nummodes[index]++;
+
+ return 0;
+}
+
+static void VGL_UpdateVideoInfo(_THIS)
+{
+ this->info.wm_available = 0;
+ this->info.hw_available = 1;
+ this->info.video_mem = 0;
+ if (VGLCurMode == NULL) {
+ return;
+ }
+ if (VGLCurMode->ModeInfo.PixelBytes > 0) {
+ this->info.video_mem = VGLCurMode->ModeInfo.PixelBytes *
+ VGLCurMode->ModeInfo.Xsize *
+ VGLCurMode->ModeInfo.Ysize;
+ }
+}
+
+int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+ int i;
+ int total_modes;
+ VGLMode **modes;
+
+ /* Initialize all variables that we clean on shutdown */
+ for ( i=0; i<NUM_MODELISTS; ++i ) {
+ SDL_nummodes[i] = 0;
+ SDL_modelist[i] = NULL;
+ }
+
+ /* Enable mouse and keyboard support */
+ if (VGLKeyboardInit(VGL_CODEKEYS) != 0) {
+ SDL_SetError("Unable to initialize keyboard");
+ return -1;
+ }
+ if (VGL_initkeymaps(STDIN_FILENO) != 0) {
+ SDL_SetError("Unable to initialize keymap");
+ return -1;
+ }
+ if (VGL_initmouse(STDIN_FILENO) != 0) {
+ SDL_SetError("Unable to initialize mouse");
+ return -1;
+ }
+// if (VGLMouseInit(VGL_MOUSEHIDE) != 0) {
+// SDL_SetError("Unable to initialize mouse");
+// return -1;
+// }
+
+ /* Determine the screen depth */
+ if (VGLCurMode != NULL)
+ vformat->BitsPerPixel = VGLCurMode->Depth;
+ else
+ vformat->BitsPerPixel = 16; /* Good default */
+
+ /* Query for the list of available video modes */
+ total_modes = 0;
+ modes = VGLListModes(-1, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
+ for (i = 0; modes[i] != NULL; i++) {
+ if ((modes[i]->ModeInfo.Type == VIDBUF8) ||
+ (modes[i]->ModeInfo.Type == VIDBUF16) ||
+ (modes[i]->ModeInfo.Type == VIDBUF32)) {
+ VGL_AddMode(this, modes[i]);
+ total_modes++;
+ }
+ }
+ if (total_modes == 0) {
+ SDL_SetError("No linear video modes available");
+ return -1;
+ }
+
+ /* Fill in our hardware acceleration capabilities */
+ VGL_UpdateVideoInfo(this);
+
+ /* Create the hardware surface lock mutex */
+ hw_lock = SDL_CreateMutex();
+ if (hw_lock == NULL) {
+ SDL_SetError("Unable to create lock mutex");
+ VGL_VideoQuit(this);
+ return -1;
+ }
+
+ /* We're done! */
+ return 0;
+}
+
+SDL_Rect **VGL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+ return SDL_modelist[((format->BitsPerPixel+7)/8)-1];
+}
+
+/* Various screen update functions available */
+static void VGL_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void VGL_BankedUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current,
+ int width, int height, int bpp, Uint32 flags)
+{
+ int mode_found;
+ int i;
+ VGLMode **modes;
+
+ modes = VGLListModes(bpp, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
+ mode_found = 0;
+ for (i = 0; modes[i] != NULL; i++) {
+ if ((modes[i]->ModeInfo.Xsize == width) &&
+ (modes[i]->ModeInfo.Ysize == height) &&
+ ((modes[i]->ModeInfo.Type == VIDBUF8) ||
+ (modes[i]->ModeInfo.Type == VIDBUF16) ||
+ (modes[i]->ModeInfo.Type == VIDBUF32))) {
+ mode_found = 1;
+ break;
+ }
+ }
+ if (mode_found == 0) {
+ SDL_SetError("No matching video mode found");
+ return NULL;
+ }
+
+ /* Shutdown previous videomode (if any) */
+ if (VGLCurMode != NULL)
+ VGLEnd();
+
+ /* Try to set the requested linear video mode */
+ if (VGLInit(modes[i]->ModeId) != 0) {
+ SDL_SetError("Unable to switch to requested mode");
+ return NULL;
+ }
+ VGLCurMode = realloc(VGLCurMode, sizeof(VGLMode));
+ VGLCurMode->ModeInfo = *VGLDisplay;
+ VGLCurMode->Depth = modes[i]->Depth;
+ VGLCurMode->ModeId = modes[i]->ModeId;
+
+ /* Workaround a bug in libvgl */
+ if (VGLCurMode->ModeInfo.PixelBytes == 0)
+ (VGLCurMode->ModeInfo.PixelBytes = 1);
+
+ current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
+ if (VGLCurMode->ModeInfo.Type == VIDBUF8)
+ current->flags |= SDL_HWPALETTE;
+ current->w = VGLCurMode->ModeInfo.Xsize;
+ current->h = VGLCurMode->ModeInfo.Ysize;
+ current->pixels = VGLCurMode->ModeInfo.Bitmap;
+ current->pitch = VGLCurMode->ModeInfo.Xsize * VGLCurMode->ModeInfo.PixelBytes;
+
+ /* FIXME - should set colormasks for bpp > 8*/
+ if (! SDL_ReallocFormat(current, modes[i]->Depth, 0, 0, 0, 0)) {
+ return NULL;
+ }
+
+ /* Update hardware acceleration info */
+ VGL_UpdateVideoInfo(this);
+
+ /* Set the blit function */
+ this->UpdateRects = VGL_DirectUpdate;
+
+ /* We're done */
+ return current;
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int VGL_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+ return -1;
+}
+static void VGL_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+ return;
+}
+
+/* We need to wait for vertical retrace on page flipped displays */
+static int VGL_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+ if (surface == SDL_VideoSurface) {
+ SDL_mutexP(hw_lock);
+ }
+ return 0;
+}
+static void VGL_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+ if (surface == SDL_VideoSurface) {
+ SDL_mutexV(hw_lock);
+ }
+}
+
+static int VGL_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+ return 0;
+}
+
+static void VGL_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+ return;
+}
+
+static void VGL_BankedUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+ return;
+}
+
+int VGL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+ int i;
+
+ for(i = 0; i < ncolors; i++) {
+ VGLSetPaletteIndex(firstcolor + i,
+ colors[i].r>>2,
+ colors[i].g>>2,
+ colors[i].b>>2);
+ }
+ return 1;
+}
+
+/* Note: If we are terminated, this could be called in the middle of
+ another SDL video routine -- notably UpdateRects.
+*/
+void VGL_VideoQuit(_THIS)
+{
+ int i, j;
+
+ /* Reset the console video mode */
+ VGLKeyboardEnd();
+ VGLEnd();
+ if (VGLCurMode != NULL) {
+ free(VGLCurMode);
+ VGLCurMode = NULL;
+ }
+
+ /* Clear the lock mutex */
+ if (hw_lock != NULL) {
+ SDL_DestroyMutex(hw_lock);
+ hw_lock = NULL;
+ }
+
+ /* Free video mode lists */
+ for (i = 0; i < NUM_MODELISTS; i++) {
+ if (SDL_modelist[i] != NULL) {
+ for (j = 0; SDL_modelist[i][j] != NULL; ++j) {
+ free(SDL_modelist[i][j]);
+ }
+ free(SDL_modelist[i]);
+ SDL_modelist[i] = NULL;
+ }
+ }
+
+ if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
+ /* Direct screen access, not a memory buffer */
+ this->screen->pixels = NULL;
+ }
+}

View File

@ -0,0 +1,56 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:10 2001
+++ src/video/vgl/SDL_vglvideo.h Mon Jan 22 18:16:51 2001
@@ -0,0 +1,50 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglvideo.h,v 1.3.2.1 2000/03/16 15:20:39 hercules Exp $";
+#endif
+
+#ifndef _SDL_vglvideo_h
+#define _SDL_vglvideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_mutex.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
+ int SDL_nummodes[NUM_MODELISTS];
+ SDL_Rect **SDL_modelist[NUM_MODELISTS];
+ SDL_mutex *hw_lock;
+};
+/* Old variable names */
+#define SDL_nummodes (this->hidden->SDL_nummodes)
+#define SDL_modelist (this->hidden->SDL_modelist)
+#define hw_lock (this->hidden->hw_lock)
+
+#endif /* _SDL_vglvideo_h */

View File

@ -7,7 +7,7 @@
PORTNAME= sdl-devel
PORTVERSION= 1.1.7
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= devel
MASTER_SITES= http://www.libsdl.org/release/ \
http://www.devolution.com/~slouken/SDL/release/
@ -25,7 +25,8 @@ INSTALLS_SHLIB= yes
USE_LIBTOOL= yes
CONFIGURE_ENV= NASM="${LOCALBASE}/bin/nasm"
CONFIGURE_ARGS= --enable-video-aalib \
--enable-video-svga
--enable-video-svga \
--enable-video-vgl
CFLAGS+= -D_THREAD_SAFE

View File

@ -1,6 +1,18 @@
--- configure.orig Thu Dec 21 07:02:47 2000
+++ configure Wed Jan 3 13:37:14 2001
@@ -630,9 +630,9 @@
$FreeBSD$
--- configure.orig Fri Jan 5 22:18:22 2001
+++ configure Sun Jan 21 23:03:55 2001
@@ -80,6 +80,8 @@
ac_help="$ac_help
--enable-video-svga use SVGAlib video driver [default=no]"
ac_help="$ac_help
+ --enable-video-vgl use VGL video driver [default=no]"
+ac_help="$ac_help
--enable-video-aalib use AAlib video driver [default=no]"
ac_help="$ac_help
--enable-video-opengl include OpenGL context creation [default=yes]"
@@ -630,9 +632,9 @@
# libtool versioning
LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
@ -12,7 +24,7 @@
@@ -3022,7 +3022,7 @@
@@ -3022,7 +3024,7 @@
SDL_CFLAGS=""
@ -21,7 +33,73 @@
case "$target" in
@@ -5899,10 +5899,10 @@
@@ -5144,6 +5146,57 @@
fi
}
+CheckVGL()
+{
+ # Check whether --enable-video-vgl or --disable-video-vgl was given.
+if test "${enable_video_vgl+set}" = set; then
+ enableval="$enable_video_vgl"
+ :
+else
+ enable_video_vgl=no
+fi
+
+ if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
+ echo $ac_n "checking for libVGL support""... $ac_c" 1>&6
+echo "configure:5162: checking for libVGL support" >&5
+ video_vgl=no
+ cat > conftest.$ac_ext <<EOF
+#line 5165 "configure"
+#include "confdefs.h"
+
+ #include <sys/fbio.h>
+ #include <sys/consio.h>
+ #include <sys/kbio.h>
+ #include <vgl.h>
+
+int main() {
+
+ VGLMode mode;
+ exit(0);
+
+; return 0; }
+EOF
+if { (eval echo configure:5180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+
+ video_vgl=yes
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ echo "$ac_t""$video_vgl" 1>&6
+ if test x$video_vgl = xyes; then
+ CFLAGS="$CFLAGS -DENABLE_VGL"
+ SYSTEM_LIBS="$SYSTEM_LIBS -lvgl"
+
+ VIDEO_SUBDIRS="$VIDEO_SUBDIRS vgl"
+ VIDEO_DRIVERS="$VIDEO_DRIVERS vgl/libvideo_vgl.la"
+ fi
+ fi
+}
+
CheckAAlib()
{
# Check whether --enable-video-aalib or --disable-video-aalib was given.
@@ -5883,6 +5936,7 @@
CheckX11
CheckDGA
CheckSVGA
+ CheckVGL
CheckAAlib
CheckOpenGL
CheckPTHREAD
@@ -5899,10 +5953,10 @@
cat >>$new <$old
# Set up files for the audio library
@ -36,3 +114,19 @@
# Set up files for the joystick library
# (No joystick support yet)
if test x$enable_joystick = xyes; then
@@ -8412,6 +8466,7 @@
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/svga/Makefile
+src/video/vgl/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
src/video/windib/Makefile
@@ -8621,6 +8676,7 @@
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/svga/Makefile
+src/video/vgl/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
src/video/windib/Makefile

View File

@ -0,0 +1,59 @@
$FreeBSD$
--- configure.in.orig Fri Jan 5 22:18:17 2001
+++ configure.in Sun Jan 21 23:01:12 2001
@@ -600,6 +600,37 @@
fi
}
+dnl Find the VGL includes and libraries
+CheckVGL()
+{
+ AC_ARG_ENABLE(video-vgl,
+[ --enable-video-vgl use VGL video driver [default=no]],
+ , enable_video_vgl=no)
+ if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
+ AC_MSG_CHECKING(for libVGL support)
+ video_vgl=no
+ AC_TRY_COMPILE([
+ #include <sys/fbio.h>
+ #include <sys/consio.h>
+ #include <sys/kbio.h>
+ #include <vgl.h>
+ ],[
+ VGLMode mode;
+ exit(0);
+ ],[
+ video_vgl=yes
+ ])
+ AC_MSG_RESULT($video_vgl)
+ if test x$video_vgl = xyes; then
+ CFLAGS="$CFLAGS -DENABLE_VGL"
+ SYSTEM_LIBS="$SYSTEM_LIBS -lvgl"
+
+ VIDEO_SUBDIRS="$VIDEO_SUBDIRS vgl"
+ VIDEO_DRIVERS="$VIDEO_DRIVERS vgl/libvideo_vgl.la"
+ fi
+ fi
+}
+
dnl Find the AAlib includes
CheckAAlib()
{
@@ -998,6 +1029,7 @@
CheckX11
CheckDGA
CheckSVGA
+ CheckVGL
CheckAAlib
CheckOpenGL
CheckPTHREAD
@@ -1659,6 +1691,7 @@
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/svga/Makefile
+src/video/vgl/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
src/video/windib/Makefile

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- src/video/Makefile.am 2001/01/21 20:09:35 1.1
+++ src/video/Makefile.am 2001/01/21 20:10:15
@@ -7,7 +7,8 @@
SUBDIRS = @VIDEO_SUBDIRS@
DIST_SUBDIRS = x11 dga fbcon svga ggi aalib \
wincommon windib windx5 \
- maccommon macdsp macrom bwindow photon cybergfx
+ maccommon macdsp macrom bwindow photon cybergfx \
+ vgl
DRIVERS = @VIDEO_DRIVERS@

View File

@ -0,0 +1,14 @@
$FreeBSD$
--- src/video/Makefile.in 2001/01/21 20:10:22 1.1
+++ src/video/Makefile.in 2001/01/21 20:10:38
@@ -103,7 +103,7 @@
# Define which subdirectories need to be built
SUBDIRS = @VIDEO_SUBDIRS@
-DIST_SUBDIRS = x11 dga fbcon svga ggi aalib wincommon windib windx5 maccommon macdsp macrom bwindow photon cybergfx
+DIST_SUBDIRS = x11 dga fbcon svga ggi aalib wincommon windib windx5 maccommon macdsp macrom bwindow photon cybergfx vgl
DRIVERS = @VIDEO_DRIVERS@

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- src/video/SDL_sysvideo.h 2001/01/21 20:12:21 1.1
+++ src/video/SDL_sysvideo.h 2001/01/21 20:12:51
@@ -331,6 +331,9 @@
#ifdef ENABLE_SVGALIB
extern VideoBootStrap SVGALIB_bootstrap;
#endif
+#ifdef ENABLE_VGL
+extern VideoBootStrap VGL_bootstrap;
+#endif
#ifdef ENABLE_AALIB
extern VideoBootStrap AALIB_bootstrap;
#endif

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- src/video/SDL_video.c 2001/01/21 20:11:02 1.1
+++ src/video/SDL_video.c 2001/01/21 20:11:59
@@ -60,6 +60,9 @@
#ifdef ENABLE_SVGALIB
&SVGALIB_bootstrap,
#endif
+#ifdef ENABLE_VGL
+ &VGL_bootstrap,
+#endif
#ifdef ENABLE_AALIB
&AALIB_bootstrap,
#endif

View File

@ -0,0 +1,21 @@
$FreeBSD$
--- /dev/null Sun Jan 21 22:16:58 2001
+++ src/video/vgl/Makefile.am Sun Jan 21 22:04:06 2001
@@ -0,0 +1,15 @@
+
+## Makefile.am for SDL using the libVGL video driver
+
+noinst_LTLIBRARIES = libvideo_vgl.la
+libvideo_vgl_la_SOURCES = $(VGL_SRCS)
+
+# The SDL libVGL video driver sources
+VGL_SRCS = \
+ SDL_vglvideo.h \
+ SDL_vglevents.c \
+ SDL_vglevents_c.h \
+ SDL_vglmouse.c \
+ SDL_vglmouse_c.h \
+ SDL_vglvideo.c
+

View File

@ -0,0 +1,328 @@
$FreeBSD$
--- /dev/null Sun Jan 21 22:16:58 2001
+++ src/video/vgl/Makefile.in Sun Jan 21 22:06:20 2001
@@ -0,0 +1,322 @@
+# Makefile.in generated automatically by automake 1.4a from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+ARCH = @ARCH@
+ARTSCCONFIG = @ARTSCCONFIG@
+AS = @AS@
+AUDIO_DRIVERS = @AUDIO_DRIVERS@
+AUDIO_SUBDIRS = @AUDIO_SUBDIRS@
+CC = @CC@
+CXX = @CXX@
+DLLTOOL = @DLLTOOL@
+ESD_CFLAGS = @ESD_CFLAGS@
+ESD_CONFIG = @ESD_CONFIG@
+ESD_LIBS = @ESD_LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAKEINFO = @MAKEINFO@
+NASM = @NASM@
+NASMFLAGS = @NASMFLAGS@
+OBJDUMP = @OBJDUMP@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+SDL_BINARY_AGE = @SDL_BINARY_AGE@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_EXTRADIRS = @SDL_EXTRADIRS@
+SDL_EXTRALIBS = @SDL_EXTRALIBS@
+SDL_INTERFACE_AGE = @SDL_INTERFACE_AGE@
+SDL_LIBS = @SDL_LIBS@
+SDL_MAJOR_VERSION = @SDL_MAJOR_VERSION@
+SDL_MICRO_VERSION = @SDL_MICRO_VERSION@
+SDL_MINOR_VERSION = @SDL_MINOR_VERSION@
+SDL_RLD_FLAGS = @SDL_RLD_FLAGS@
+SDL_VERSION = @SDL_VERSION@
+SYSTEM_LIBS = @SYSTEM_LIBS@
+VERSION = @VERSION@
+VIDEO_DRIVERS = @VIDEO_DRIVERS@
+VIDEO_SUBDIRS = @VIDEO_SUBDIRS@
+
+noinst_LTLIBRARIES = libvideo_vgl.la
+libvideo_vgl_la_SOURCES = $(VGL_SRCS)
+
+# The SDL VGLlib video driver sources
+VGL_SRCS = SDL_vglvideo.h SDL_vglevents.c SDL_vglevents_c.h SDL_vglmouse.c SDL_vglmouse_c.h SDL_vglvideo.c
+
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir)
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+libvideo_vgl_la_LDFLAGS =
+libvideo_vgl_la_LIBADD =
+libvideo_vgl_la_OBJECTS = SDL_vglevents.lo SDL_vglmouse.lo \
+SDL_vglvideo.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+SOURCES = $(libvideo_vgl_la_SOURCES)
+OBJECTS = $(libvideo_vgl_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps src/video/vgl/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLTLIBRARIES:
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+
+distclean-noinstLTLIBRARIES:
+
+maintainer-clean-noinstLTLIBRARIES:
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.c.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+libvideo_vgl.la: $(libvideo_vgl_la_OBJECTS) $(libvideo_vgl_la_DEPENDENCIES)
+ $(LINK) $(libvideo_vgl_la_LDFLAGS) $(libvideo_vgl_la_OBJECTS) $(libvideo_vgl_la_LIBADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = src/video/vgl
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LTLIBRARIES)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \
+ clean-tags clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-noinstLTLIBRARIES distclean-compile \
+ distclean-libtool distclean-tags distclean-generic \
+ clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
+clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

View File

@ -0,0 +1,311 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglevents.c Mon Jan 22 20:02:48 2001
@@ -0,0 +1,305 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglevents.c,v 1.1 2001/01/22 17:35:16 root Exp $";
+#endif
+
+/* Handle the event stream, converting X11 events into SDL events */
+
+#include <stdio.h>
+
+#include <sys/fbio.h>
+#include <sys/consio.h>
+#include <sys/kbio.h>
+#include <vgl.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_vglvideo.h"
+#include "SDL_vglevents_c.h"
+
+/* The translation tables from a console scancode to a SDL keysym */
+/* FIXME: Free the keymap when we shut down the video mode */
+static keymap_t *vga_keymap = NULL;
+static SDLKey keymap[128];
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
+
+static int posted = 0;
+static int oldx = 0;
+static int oldy = 0;
+static struct mouse_info mouseinfo;
+
+/* Ugh, we have to duplicate the kernel's keysym mapping code...
+ Oh, it's not so bad. :-)
+
+ FIXME: Add keyboard LED handling code
+ */
+int VGL_initkeymaps(int fd)
+{
+ vga_keymap = malloc(sizeof(keymap_t));
+ if ( ! vga_keymap ) {
+ SDL_OutOfMemory();
+ return(-1);
+ }
+ if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) {
+ free(vga_keymap);
+ vga_keymap = NULL;
+ SDL_SetError("Unable to get keyboard map");
+ return(-1);
+ }
+ return(0);
+}
+
+static void handle_keyboard(_THIS)
+{
+ SDL_keysym keysym;
+ int c, pressed, scancode;
+
+ while ((c = VGLKeyboardGetCh()) != 0) {
+ scancode = c & 0x7F;
+ if (c & 0x80) {
+ pressed = SDL_RELEASED;
+ } else {
+ pressed = SDL_PRESSED;
+ }
+
+ posted += SDL_PrivateKeyboard(pressed,
+ TranslateKey(scancode, &keysym));
+ }
+}
+
+int VGL_initmouse(int fd)
+{
+ mouseinfo.operation = MOUSE_GETINFO;
+ if (ioctl(fd, CONS_MOUSECTL, &mouseinfo) != 0)
+ return -1;
+ oldx = mouseinfo.u.data.x;
+ oldy = mouseinfo.u.data.y;
+ SDL_PrivateMouseMotion(0, 0, oldx, oldy);
+ return 0;
+}
+
+static void handle_mouse(_THIS)
+{
+ char buttons;
+ int x, y;
+ int button_state, state_changed, state;
+ int i;
+
+ ioctl(0, CONS_MOUSECTL, &mouseinfo);
+ x = mouseinfo.u.data.x;
+ y = mouseinfo.u.data.y;
+ buttons = mouseinfo.u.data.buttons;
+
+ if ((x != oldx) || (y != oldy)) {
+ posted += SDL_PrivateMouseMotion(0, 0, x, y);
+ oldx = x;
+ oldy = y;
+ }
+
+ /* See what's changed */
+ button_state = SDL_GetMouseState(NULL, NULL);
+ state_changed = button_state ^ buttons;
+ for (i = 0; i < 8; i++) {
+ if (state_changed & (1<<i)) {
+ if (buttons & (1<<i)) {
+ state = SDL_PRESSED;
+ } else {
+ state = SDL_RELEASED;
+ }
+ posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
+ }
+ }
+}
+
+
+void VGL_PumpEvents(_THIS)
+{
+ do {
+ posted = 0;
+ handle_keyboard(this);
+ handle_mouse(this);
+ } while (posted != 0);
+}
+
+void VGL_InitOSKeymap(_THIS)
+{
+ int i;
+
+ /* Initialize the BeOS key translation table */
+ for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+ keymap[i] = SDLK_UNKNOWN;
+
+ keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+ keymap[SCANCODE_1] = SDLK_1;
+ keymap[SCANCODE_2] = SDLK_2;
+ keymap[SCANCODE_3] = SDLK_3;
+ keymap[SCANCODE_4] = SDLK_4;
+ keymap[SCANCODE_5] = SDLK_5;
+ keymap[SCANCODE_6] = SDLK_6;
+ keymap[SCANCODE_7] = SDLK_7;
+ keymap[SCANCODE_8] = SDLK_8;
+ keymap[SCANCODE_9] = SDLK_9;
+ keymap[SCANCODE_0] = SDLK_0;
+ keymap[SCANCODE_MINUS] = SDLK_MINUS;
+ keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
+ keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+ keymap[SCANCODE_TAB] = SDLK_TAB;
+ keymap[SCANCODE_Q] = SDLK_q;
+ keymap[SCANCODE_W] = SDLK_w;
+ keymap[SCANCODE_E] = SDLK_e;
+ keymap[SCANCODE_R] = SDLK_r;
+ keymap[SCANCODE_T] = SDLK_t;
+ keymap[SCANCODE_Y] = SDLK_y;
+ keymap[SCANCODE_U] = SDLK_u;
+ keymap[SCANCODE_I] = SDLK_i;
+ keymap[SCANCODE_O] = SDLK_o;
+ keymap[SCANCODE_P] = SDLK_p;
+ keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
+ keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
+ keymap[SCANCODE_ENTER] = SDLK_RETURN;
+ keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+ keymap[SCANCODE_A] = SDLK_a;
+ keymap[SCANCODE_S] = SDLK_s;
+ keymap[SCANCODE_D] = SDLK_d;
+ keymap[SCANCODE_F] = SDLK_f;
+ keymap[SCANCODE_G] = SDLK_g;
+ keymap[SCANCODE_H] = SDLK_h;
+ keymap[SCANCODE_J] = SDLK_j;
+ keymap[SCANCODE_K] = SDLK_k;
+ keymap[SCANCODE_L] = SDLK_l;
+ keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
+ keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
+ keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
+ keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+ keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
+ keymap[SCANCODE_Z] = SDLK_z;
+ keymap[SCANCODE_X] = SDLK_x;
+ keymap[SCANCODE_C] = SDLK_c;
+ keymap[SCANCODE_V] = SDLK_v;
+ keymap[SCANCODE_B] = SDLK_b;
+ keymap[SCANCODE_N] = SDLK_n;
+ keymap[SCANCODE_M] = SDLK_m;
+ keymap[SCANCODE_COMMA] = SDLK_COMMA;
+ keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
+ keymap[SCANCODE_SLASH] = SDLK_SLASH;
+ keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+ keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
+ keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+ keymap[SCANCODE_SPACE] = SDLK_SPACE;
+ keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+ keymap[SCANCODE_F1] = SDLK_F1;
+ keymap[SCANCODE_F2] = SDLK_F2;
+ keymap[SCANCODE_F3] = SDLK_F3;
+ keymap[SCANCODE_F4] = SDLK_F4;
+ keymap[SCANCODE_F5] = SDLK_F5;
+ keymap[SCANCODE_F6] = SDLK_F6;
+ keymap[SCANCODE_F7] = SDLK_F7;
+ keymap[SCANCODE_F8] = SDLK_F8;
+ keymap[SCANCODE_F9] = SDLK_F9;
+ keymap[SCANCODE_F10] = SDLK_F10;
+ keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
+ keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
+ keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
+ keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
+ keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
+ keymap[SCANCODE_CURSORUP] = SDLK_KP8;
+ keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
+ keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
+ keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
+ keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
+ keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
+ keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
+ keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
+ keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
+ keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
+ keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
+ keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
+ keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
+ keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
+ keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
+ keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
+ keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
+ keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
+ keymap[SCANCODE_LESS] = SDLK_LESS;
+ keymap[SCANCODE_F11] = SDLK_F11;
+ keymap[SCANCODE_F12] = SDLK_F12;
+ keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
+ keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
+ keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
+ keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
+ keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
+ keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
+ keymap[SCANCODE_BREAK] = SDLK_BREAK;
+ keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
+ keymap[SCANCODE_HOME] = SDLK_HOME;
+ keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
+ keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
+ keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
+ keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
+ keymap[SCANCODE_END] = SDLK_END;
+ keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
+ keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
+ keymap[SCANCODE_INSERT] = SDLK_INSERT;
+ keymap[SCANCODE_REMOVE] = SDLK_DELETE;
+ keymap[119] = SDLK_PAUSE;
+ keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
+ keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
+ keymap[127] = SDLK_MENU;
+}
+
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+ /* Set the keysym information */
+ keysym->scancode = scancode;
+ keysym->sym = keymap[scancode];
+ keysym->mod = KMOD_NONE;
+
+ /* If UNICODE is on, get the UNICODE value for the key */
+ keysym->unicode = 0;
+ if ( SDL_TranslateUNICODE && vga_keymap ) {
+ int map;
+ SDLMod modstate;
+
+ modstate = SDL_GetModState();
+ map = 0;
+ if ( modstate & KMOD_SHIFT ) {
+ map += 1;
+ }
+ if ( modstate & KMOD_CTRL ) {
+ map += 2;
+ }
+ if ( modstate & KMOD_ALT ) {
+ map += 4;
+ }
+ if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) {
+ keysym->unicode = vga_keymap->key[scancode].map[map];
+ }
+
+ }
+ return(keysym);
+}
+

View File

@ -0,0 +1,165 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglevents_c.h Mon Jan 22 19:57:14 2001
@@ -0,0 +1,159 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglevents_c.h,v 1.2.2.2 2000/10/03 16:00:58 hercules Exp $";
+#endif
+
+#include "SDL_vglvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts
+ of the native video subsystem (SDL_sysvideo.c)
+*/
+extern int VGL_initkeymaps(int fd);
+extern int VGL_initmouse(int fd);
+extern void VGL_keyboardcallback(int scancode, int pressed);
+
+extern void VGL_InitOSKeymap(_THIS);
+extern void VGL_PumpEvents(_THIS);
+
+/* Mouse buttons */
+#define MOUSE_LEFTBUTTON 0x01
+#define MOUSE_MIDDLEBUTTON 0x02
+#define MOUSE_RIGHTBUTTON 0x04
+
+/* Scancodes */
+#define SCANCODE_ESCAPE 1
+#define SCANCODE_1 2
+#define SCANCODE_2 3
+#define SCANCODE_3 4
+#define SCANCODE_4 5
+#define SCANCODE_5 6
+#define SCANCODE_6 7
+#define SCANCODE_7 8
+#define SCANCODE_8 9
+#define SCANCODE_9 10
+#define SCANCODE_0 11
+#define SCANCODE_MINUS 12
+#define SCANCODE_EQUAL 13
+#define SCANCODE_BACKSPACE 14
+#define SCANCODE_TAB 15
+#define SCANCODE_Q 16
+#define SCANCODE_W 17
+#define SCANCODE_E 18
+#define SCANCODE_R 19
+#define SCANCODE_T 20
+#define SCANCODE_Y 21
+#define SCANCODE_U 22
+#define SCANCODE_I 23
+#define SCANCODE_O 24
+#define SCANCODE_P 25
+#define SCANCODE_BRACKET_LEFT 26
+#define SCANCODE_BRACKET_RIGHT 27
+#define SCANCODE_ENTER 28
+#define SCANCODE_LEFTCONTROL 29
+#define SCANCODE_A 30
+#define SCANCODE_S 31
+#define SCANCODE_D 32
+#define SCANCODE_F 33
+#define SCANCODE_G 34
+#define SCANCODE_H 35
+#define SCANCODE_J 36
+#define SCANCODE_K 37
+#define SCANCODE_L 38
+#define SCANCODE_SEMICOLON 39
+#define SCANCODE_APOSTROPHE 40
+#define SCANCODE_GRAVE 41
+#define SCANCODE_LEFTSHIFT 42
+#define SCANCODE_BACKSLASH 43
+#define SCANCODE_Z 44
+#define SCANCODE_X 45
+#define SCANCODE_C 46
+#define SCANCODE_V 47
+#define SCANCODE_B 48
+#define SCANCODE_N 49
+#define SCANCODE_M 50
+#define SCANCODE_COMMA 51
+#define SCANCODE_PERIOD 52
+#define SCANCODE_SLASH 53
+#define SCANCODE_RIGHTSHIFT 54
+#define SCANCODE_KEYPADMULTIPLY 55
+#define SCANCODE_LEFTALT 56
+#define SCANCODE_SPACE 57
+#define SCANCODE_CAPSLOCK 58
+#define SCANCODE_F1 59
+#define SCANCODE_F2 60
+#define SCANCODE_F3 61
+#define SCANCODE_F4 62
+#define SCANCODE_F5 63
+#define SCANCODE_F6 64
+#define SCANCODE_F7 65
+#define SCANCODE_F8 66
+#define SCANCODE_F9 67
+#define SCANCODE_F10 68
+#define SCANCODE_NUMLOCK 69
+#define SCANCODE_SCROLLLOCK 70
+#define SCANCODE_KEYPAD7 71
+#define SCANCODE_CURSORUPLEFT 71
+#define SCANCODE_KEYPAD8 72
+#define SCANCODE_CURSORUP 72
+#define SCANCODE_KEYPAD9 73
+#define SCANCODE_CURSORUPRIGHT 73
+#define SCANCODE_KEYPADMINUS 74
+#define SCANCODE_KEYPAD4 75
+#define SCANCODE_CURSORLEFT 75
+#define SCANCODE_KEYPAD5 76
+#define SCANCODE_KEYPAD6 77
+#define SCANCODE_CURSORRIGHT 77
+#define SCANCODE_KEYPADPLUS 78
+#define SCANCODE_KEYPAD1 79
+#define SCANCODE_CURSORDOWNLEFT 79
+#define SCANCODE_KEYPAD2 80
+#define SCANCODE_CURSORDOWN 80
+#define SCANCODE_KEYPAD3 81
+#define SCANCODE_CURSORDOWNRIGHT 81
+#define SCANCODE_KEYPAD0 82
+#define SCANCODE_KEYPADPERIOD 83
+#define SCANCODE_LESS 86
+#define SCANCODE_F11 87
+#define SCANCODE_F12 88
+#define SCANCODE_KEYPADENTER 89
+#define SCANCODE_RIGHTCONTROL 90
+#define SCANCODE_CONTROL 107
+#define SCANCODE_KEYPADDIVIDE 91
+#define SCANCODE_PRINTSCREEN 92
+#define SCANCODE_RIGHTALT 93
+#define SCANCODE_BREAK 104 /* Beware: is 119 */
+#define SCANCODE_BREAK_ALTERNATIVE 104 /* on some keyboards! */
+#define SCANCODE_HOME 94
+#define SCANCODE_CURSORBLOCKUP 95 /* Cursor key block */
+#define SCANCODE_PAGEUP 96
+#define SCANCODE_CURSORBLOCKLEFT 97 /* Cursor key block */
+#define SCANCODE_CURSORBLOCKRIGHT 98 /* Cursor key block */
+#define SCANCODE_END 99
+#define SCANCODE_CURSORBLOCKDOWN 100 /* Cursor key block */
+#define SCANCODE_PAGEDOWN 101
+#define SCANCODE_INSERT 102
+#define SCANCODE_REMOVE 103
+#define SCANCODE_RIGHTWIN 106
+#define SCANCODE_LEFTWIN 105

View File

@ -0,0 +1,72 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglmouse.c Mon Jan 22 16:31:43 2001
@@ -0,0 +1,66 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglmouse.c,v 1.1.2.1 2000/03/16 15:20:39 hercules Exp $";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_vglvideo.h"
+#include "SDL_vglmouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+ int unused;
+};
+
+
+void VGL_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+ return;
+}
+
+WMcursor *VGL_CreateWMCursor(_THIS,
+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+ return(NULL);
+}
+
+int VGL_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+ return(0);
+}
+
+void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+ x += (this->screen->offset % this->screen->pitch) /
+ this->screen->format->BytesPerPixel;
+ y += (this->screen->offset / this->screen->pitch);
+ SDL_PrivateMouseMotion(0, 0, x, y);
+}
+

View File

@ -0,0 +1,42 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:10 2001
+++ src/video/vgl/SDL_vglmouse_c.h Mon Jan 22 16:31:43 2001
@@ -0,0 +1,36 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglmouse_c.h,v 1.2.2.1 2000/03/16 15:20:39 hercules Exp $";
+#endif
+
+#include "SDL_vglvideo.h"
+
+/* Functions to be exported */
+extern void VGL_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *VGL_CreateWMCursor(_THIS,
+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int VGL_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+

View File

@ -0,0 +1,450 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:09 2001
+++ src/video/vgl/SDL_vglvideo.c Mon Jan 22 20:04:39 2001
@@ -0,0 +1,444 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglvideo.c,v 1.1 2001/01/20 18:21:25 root Exp root $";
+#endif
+
+/* libvga based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <sys/fbio.h>
+#include <sys/consio.h>
+#include <sys/kbio.h>
+#include <vgl.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_vglvideo.h"
+#include "SDL_vglevents_c.h"
+#include "SDL_vglmouse_c.h"
+
+
+static VGLMode *VGLCurMode = NULL;
+
+/* Initialization/Query functions */
+static int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **VGL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int VGL_SetColors(_THIS, int firstcolor, int ncolors,
+ SDL_Color *colors);
+static void VGL_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int VGL_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int VGL_LockHWSurface(_THIS, SDL_Surface *surface);
+static int VGL_FlipHWSurface(_THIS, SDL_Surface *surface);
+static void VGL_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void VGL_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* VGL driver bootstrap functions */
+
+static int VGL_Available(void)
+{
+ /* Check to see if we are root and stdin is a virtual console */
+ int console;
+
+ console = STDIN_FILENO;
+ if ( console >= 0 ) {
+ struct stat sb;
+ struct vt_mode dummy;
+
+ if ( (fstat(console, &sb) < 0) ||
+ (ioctl(console, VT_GETMODE, &dummy) < 0) ) {
+ console = -1;
+ }
+ }
+ return((geteuid() == 0) && (console >= 0));
+}
+
+static void VGL_DeleteDevice(SDL_VideoDevice *device)
+{
+ free(device->hidden);
+ free(device);
+}
+
+static SDL_VideoDevice *VGL_CreateDevice(int devindex)
+{
+ SDL_VideoDevice *device;
+
+ /* Initialize all variables that we clean on shutdown */
+ device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+ if ( device ) {
+ memset(device, 0, (sizeof *device));
+ device->hidden = (struct SDL_PrivateVideoData *)
+ malloc((sizeof *device->hidden));
+ }
+ if ( (device == NULL) || (device->hidden == NULL) ) {
+ SDL_OutOfMemory();
+ if ( device ) {
+ free(device);
+ }
+ return(0);
+ }
+ memset(device->hidden, 0, (sizeof *device->hidden));
+
+ /* Set the function pointers */
+ device->VideoInit = VGL_VideoInit;
+ device->ListModes = VGL_ListModes;
+ device->SetVideoMode = VGL_SetVideoMode;
+ device->SetColors = VGL_SetColors;
+ device->UpdateRects = NULL;
+ device->VideoQuit = VGL_VideoQuit;
+ device->AllocHWSurface = VGL_AllocHWSurface;
+ device->CheckHWBlit = NULL;
+ device->FillHWRect = NULL;
+ device->SetHWColorKey = NULL;
+ device->SetHWAlpha = NULL;
+ device->LockHWSurface = VGL_LockHWSurface;
+ device->UnlockHWSurface = VGL_UnlockHWSurface;
+ device->FlipHWSurface = NULL;
+ device->FreeHWSurface = VGL_FreeHWSurface;
+ device->SetIcon = NULL;
+ device->SetCaption = NULL;
+ device->GetWMInfo = NULL;
+ device->FreeWMCursor = VGL_FreeWMCursor;
+ device->CreateWMCursor = VGL_CreateWMCursor;
+ device->ShowWMCursor = VGL_ShowWMCursor;
+ device->WarpWMCursor = VGL_WarpWMCursor;
+ device->InitOSKeymap = VGL_InitOSKeymap;
+ device->PumpEvents = VGL_PumpEvents;
+
+ device->free = VGL_DeleteDevice;
+
+ return device;
+}
+
+VideoBootStrap VGL_bootstrap = {
+ "vgl", "FreeBSD libVGL",
+ VGL_Available, VGL_CreateDevice
+};
+
+static int VGL_AddMode(_THIS, VGLMode *inmode)
+{
+ SDL_Rect *mode;
+
+ int i, index;
+ int next_mode;
+
+ /* Check to see if we already have this mode */
+ if (inmode->Depth < 8) { /* Not supported */
+ return 0;
+ }
+ index = ((inmode->Depth + 7) / 8) - 1;
+ for (i=0; i<SDL_nummodes[index]; ++i) {
+ mode = SDL_modelist[index][i];
+ if ((mode->w == inmode->ModeInfo.Xsize) &&
+ (mode->h == inmode->ModeInfo.Ysize))
+ return 0;
+ }
+
+ /* Set up the new video mode rectangle */
+ mode = (SDL_Rect *)malloc(sizeof *mode);
+ if (mode == NULL) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ mode->x = 0;
+ mode->y = 0;
+ mode->w = inmode->ModeInfo.Xsize;
+ mode->h = inmode->ModeInfo.Ysize;
+
+ /* Allocate the new list of modes, and fill in the new mode */
+ next_mode = SDL_nummodes[index];
+ SDL_modelist[index] = (SDL_Rect **)
+ realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+ if (SDL_modelist[index] == NULL) {
+ SDL_OutOfMemory();
+ SDL_nummodes[index] = 0;
+ free(mode);
+ return -1;
+ }
+ SDL_modelist[index][next_mode] = mode;
+ SDL_modelist[index][next_mode+1] = NULL;
+ SDL_nummodes[index]++;
+
+ return 0;
+}
+
+static void VGL_UpdateVideoInfo(_THIS)
+{
+ this->info.wm_available = 0;
+ this->info.hw_available = 1;
+ this->info.video_mem = 0;
+ if (VGLCurMode == NULL) {
+ return;
+ }
+ if (VGLCurMode->ModeInfo.PixelBytes > 0) {
+ this->info.video_mem = VGLCurMode->ModeInfo.PixelBytes *
+ VGLCurMode->ModeInfo.Xsize *
+ VGLCurMode->ModeInfo.Ysize;
+ }
+}
+
+int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+ int i;
+ int total_modes;
+ VGLMode **modes;
+
+ /* Initialize all variables that we clean on shutdown */
+ for ( i=0; i<NUM_MODELISTS; ++i ) {
+ SDL_nummodes[i] = 0;
+ SDL_modelist[i] = NULL;
+ }
+
+ /* Enable mouse and keyboard support */
+ if (VGLKeyboardInit(VGL_CODEKEYS) != 0) {
+ SDL_SetError("Unable to initialize keyboard");
+ return -1;
+ }
+ if (VGL_initkeymaps(STDIN_FILENO) != 0) {
+ SDL_SetError("Unable to initialize keymap");
+ return -1;
+ }
+ if (VGL_initmouse(STDIN_FILENO) != 0) {
+ SDL_SetError("Unable to initialize mouse");
+ return -1;
+ }
+// if (VGLMouseInit(VGL_MOUSEHIDE) != 0) {
+// SDL_SetError("Unable to initialize mouse");
+// return -1;
+// }
+
+ /* Determine the screen depth */
+ if (VGLCurMode != NULL)
+ vformat->BitsPerPixel = VGLCurMode->Depth;
+ else
+ vformat->BitsPerPixel = 16; /* Good default */
+
+ /* Query for the list of available video modes */
+ total_modes = 0;
+ modes = VGLListModes(-1, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
+ for (i = 0; modes[i] != NULL; i++) {
+ if ((modes[i]->ModeInfo.Type == VIDBUF8) ||
+ (modes[i]->ModeInfo.Type == VIDBUF16) ||
+ (modes[i]->ModeInfo.Type == VIDBUF32)) {
+ VGL_AddMode(this, modes[i]);
+ total_modes++;
+ }
+ }
+ if (total_modes == 0) {
+ SDL_SetError("No linear video modes available");
+ return -1;
+ }
+
+ /* Fill in our hardware acceleration capabilities */
+ VGL_UpdateVideoInfo(this);
+
+ /* Create the hardware surface lock mutex */
+ hw_lock = SDL_CreateMutex();
+ if (hw_lock == NULL) {
+ SDL_SetError("Unable to create lock mutex");
+ VGL_VideoQuit(this);
+ return -1;
+ }
+
+ /* We're done! */
+ return 0;
+}
+
+SDL_Rect **VGL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+ return SDL_modelist[((format->BitsPerPixel+7)/8)-1];
+}
+
+/* Various screen update functions available */
+static void VGL_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void VGL_BankedUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current,
+ int width, int height, int bpp, Uint32 flags)
+{
+ int mode_found;
+ int i;
+ VGLMode **modes;
+
+ modes = VGLListModes(bpp, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
+ mode_found = 0;
+ for (i = 0; modes[i] != NULL; i++) {
+ if ((modes[i]->ModeInfo.Xsize == width) &&
+ (modes[i]->ModeInfo.Ysize == height) &&
+ ((modes[i]->ModeInfo.Type == VIDBUF8) ||
+ (modes[i]->ModeInfo.Type == VIDBUF16) ||
+ (modes[i]->ModeInfo.Type == VIDBUF32))) {
+ mode_found = 1;
+ break;
+ }
+ }
+ if (mode_found == 0) {
+ SDL_SetError("No matching video mode found");
+ return NULL;
+ }
+
+ /* Shutdown previous videomode (if any) */
+ if (VGLCurMode != NULL)
+ VGLEnd();
+
+ /* Try to set the requested linear video mode */
+ if (VGLInit(modes[i]->ModeId) != 0) {
+ SDL_SetError("Unable to switch to requested mode");
+ return NULL;
+ }
+ VGLCurMode = realloc(VGLCurMode, sizeof(VGLMode));
+ VGLCurMode->ModeInfo = *VGLDisplay;
+ VGLCurMode->Depth = modes[i]->Depth;
+ VGLCurMode->ModeId = modes[i]->ModeId;
+
+ /* Workaround a bug in libvgl */
+ if (VGLCurMode->ModeInfo.PixelBytes == 0)
+ (VGLCurMode->ModeInfo.PixelBytes = 1);
+
+ current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
+ if (VGLCurMode->ModeInfo.Type == VIDBUF8)
+ current->flags |= SDL_HWPALETTE;
+ current->w = VGLCurMode->ModeInfo.Xsize;
+ current->h = VGLCurMode->ModeInfo.Ysize;
+ current->pixels = VGLCurMode->ModeInfo.Bitmap;
+ current->pitch = VGLCurMode->ModeInfo.Xsize * VGLCurMode->ModeInfo.PixelBytes;
+
+ /* FIXME - should set colormasks for bpp > 8*/
+ if (! SDL_ReallocFormat(current, modes[i]->Depth, 0, 0, 0, 0)) {
+ return NULL;
+ }
+
+ /* Update hardware acceleration info */
+ VGL_UpdateVideoInfo(this);
+
+ /* Set the blit function */
+ this->UpdateRects = VGL_DirectUpdate;
+
+ /* We're done */
+ return current;
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int VGL_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+ return -1;
+}
+static void VGL_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+ return;
+}
+
+/* We need to wait for vertical retrace on page flipped displays */
+static int VGL_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+ if (surface == SDL_VideoSurface) {
+ SDL_mutexP(hw_lock);
+ }
+ return 0;
+}
+static void VGL_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+ if (surface == SDL_VideoSurface) {
+ SDL_mutexV(hw_lock);
+ }
+}
+
+static int VGL_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+ return 0;
+}
+
+static void VGL_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+ return;
+}
+
+static void VGL_BankedUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+ return;
+}
+
+int VGL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+ int i;
+
+ for(i = 0; i < ncolors; i++) {
+ VGLSetPaletteIndex(firstcolor + i,
+ colors[i].r>>2,
+ colors[i].g>>2,
+ colors[i].b>>2);
+ }
+ return 1;
+}
+
+/* Note: If we are terminated, this could be called in the middle of
+ another SDL video routine -- notably UpdateRects.
+*/
+void VGL_VideoQuit(_THIS)
+{
+ int i, j;
+
+ /* Reset the console video mode */
+ VGLKeyboardEnd();
+ VGLEnd();
+ if (VGLCurMode != NULL) {
+ free(VGLCurMode);
+ VGLCurMode = NULL;
+ }
+
+ /* Clear the lock mutex */
+ if (hw_lock != NULL) {
+ SDL_DestroyMutex(hw_lock);
+ hw_lock = NULL;
+ }
+
+ /* Free video mode lists */
+ for (i = 0; i < NUM_MODELISTS; i++) {
+ if (SDL_modelist[i] != NULL) {
+ for (j = 0; SDL_modelist[i][j] != NULL; ++j) {
+ free(SDL_modelist[i][j]);
+ }
+ free(SDL_modelist[i]);
+ SDL_modelist[i] = NULL;
+ }
+ }
+
+ if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
+ /* Direct screen access, not a memory buffer */
+ this->screen->pixels = NULL;
+ }
+}

View File

@ -0,0 +1,56 @@
$FreeBSD$
--- /dev/null Mon Jan 22 20:53:10 2001
+++ src/video/vgl/SDL_vglvideo.h Mon Jan 22 18:16:51 2001
@@ -0,0 +1,50 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_vglvideo.h,v 1.3.2.1 2000/03/16 15:20:39 hercules Exp $";
+#endif
+
+#ifndef _SDL_vglvideo_h
+#define _SDL_vglvideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_mutex.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
+ int SDL_nummodes[NUM_MODELISTS];
+ SDL_Rect **SDL_modelist[NUM_MODELISTS];
+ SDL_mutex *hw_lock;
+};
+/* Old variable names */
+#define SDL_nummodes (this->hidden->SDL_nummodes)
+#define SDL_modelist (this->hidden->SDL_modelist)
+#define hw_lock (this->hidden->hw_lock)
+
+#endif /* _SDL_vglvideo_h */