mirror of
https://github.com/DrBeef/DVR.git
synced 2025-02-15 00:11:21 +00:00
Got sound working
and removed unused SDL
This commit is contained in:
parent
61058cab74
commit
e14bb87afb
526 changed files with 35 additions and 173292 deletions
|
@ -1,47 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
###########################
|
||||
#
|
||||
# SDL shared library
|
||||
#
|
||||
###########################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := SDL
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_CFLAGS := -O3 -ffast-math
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(subst $(LOCAL_PATH)/,, \
|
||||
$(wildcard $(LOCAL_PATH)/src/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
|
||||
$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
|
||||
$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
|
||||
$(wildcard $(LOCAL_PATH)/src/core/android/*.cpp) \
|
||||
$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/events/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/file/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/render/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
|
||||
|
||||
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
|
@ -1,47 +0,0 @@
|
|||
|
||||
Simple DirectMedia Layer
|
||||
|
||||
(SDL)
|
||||
|
||||
Version 1.3
|
||||
|
||||
---
|
||||
http://www.libsdl.org/
|
||||
|
||||
This is the Simple DirectMedia Layer, a general API that provides low
|
||||
level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
|
||||
and 2D framebuffer across multiple platforms.
|
||||
|
||||
The current version supports Windows, Windows CE, Mac OS X, Linux, FreeBSD,
|
||||
NetBSD, OpenBSD, BSD/OS, Solaris, iOS, and Android. The code contains
|
||||
support for other operating systems but those are not officially supported.
|
||||
|
||||
SDL is written in C, but works with C++ natively, and has bindings to
|
||||
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
|
||||
Go, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
|
||||
Pike, Pliant, Python, Ruby, and Smalltalk.
|
||||
|
||||
This library is distributed under GNU LGPL version 2, which can be
|
||||
found in the file "COPYING". This license allows you to use SDL
|
||||
freely in commercial programs as long as you link with the dynamic
|
||||
library.
|
||||
|
||||
The best way to learn how to use SDL is to check out the header files in
|
||||
the "include" subdirectory and the programs in the "test" subdirectory.
|
||||
The header files and test programs are well commented and always up to date.
|
||||
More documentation is available in HTML format in "docs/index.html", and
|
||||
a documentation wiki is available online at:
|
||||
http://www.libsdl.org/cgi/docwiki.cgi
|
||||
|
||||
The test programs in the "test" subdirectory are in the public domain.
|
||||
|
||||
Frequently asked questions are answered online:
|
||||
http://www.libsdl.org/faq.php
|
||||
|
||||
If you need help with the library, or just want to discuss SDL related
|
||||
issues, you can join the developers mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
Please distribute this file with the SDL runtime environment:
|
||||
|
||||
The Simple DirectMedia Layer (SDL for short) is a cross-platfrom library
|
||||
designed to make it easy to write multi-media software, such as games and
|
||||
emulators.
|
||||
|
||||
The Simple DirectMedia Layer library source code is available from:
|
||||
http://www.libsdl.org/
|
||||
|
||||
This library is distributed under the terms of the GNU LGPL license:
|
||||
http://www.gnu.org/copyleft/lesser.html
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
================================================================================
|
||||
Simple DirectMedia Layer for Android
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
Android SDK
|
||||
http://developer.android.com/sdk/index.html
|
||||
|
||||
Android NDK r4 or later
|
||||
http://developer.android.com/sdk/ndk/index.html
|
||||
|
||||
|
||||
================================================================================
|
||||
How the port works
|
||||
================================================================================
|
||||
|
||||
- Android applications are Java-based, optionally with parts written in C
|
||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||
the SDL library
|
||||
- This means that your application C code must be placed inside an android
|
||||
Java project, along with some C support code that communicates with Java
|
||||
- This eventually produces a standard Android .apk package
|
||||
|
||||
The Android Java code implements an "activity" and can be found in:
|
||||
android-project/src/org/libsdl/app/SDLActivity.java
|
||||
|
||||
The Java code loads your game code, the SDL shared library, and
|
||||
dispatches to native functions implemented in the SDL library:
|
||||
src/SDL_android.cpp
|
||||
|
||||
Your project must include some glue code that starts your main() routine:
|
||||
src/main/android/SDL_android_main.cpp
|
||||
|
||||
|
||||
================================================================================
|
||||
Building an app
|
||||
================================================================================
|
||||
|
||||
Instructions:
|
||||
1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project.
|
||||
2. Move this SDL directory into the <project>/jni directory
|
||||
3. Place your application source files in the <project>/jni/src directory
|
||||
4. Edit <project>/jni/src/Android.mk to include your source files
|
||||
5. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
|
||||
|
||||
If you want to use the Eclipse IDE, skip to the Eclipse section below.
|
||||
|
||||
6. Edit <project>/local.properties to point to the Android SDK directory
|
||||
7. Run 'ant debug' in android/project. This compiles the .java and eventually
|
||||
creates a .apk with the native code embedded
|
||||
8. 'ant install' will push the apk to the device or emulator (if connected)
|
||||
|
||||
Here's an explanation of the files in the Android project, so you can customize them:
|
||||
|
||||
android-project/
|
||||
AndroidManifest.xml - package manifest, do not modify
|
||||
build.properties - empty
|
||||
build.xml - build description file, used by ant
|
||||
default.properties - holds the ABI for the application, currently android-4 which corresponds to the Android 1.6 system image
|
||||
local.properties - holds the SDK path, you should change this to the path to your SDK
|
||||
jni/ - directory holding native code
|
||||
jni/Android.mk - Android makefile that includes all subdirectories
|
||||
jni/SDL/ - directory holding the SDL library files
|
||||
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
||||
jni/src/ - directory holding your C/C++ source
|
||||
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
|
||||
res/ - directory holding resources for your application
|
||||
res/drawable-* - directories holding icons for different phone hardware
|
||||
res/layout/main.xml - place holder for the main screen layout, overridden by the SDL video output
|
||||
res/values/strings.xml - strings used in your application, including the application name shown on the phone.
|
||||
src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation.
|
||||
|
||||
|
||||
================================================================================
|
||||
Additional documentation
|
||||
================================================================================
|
||||
|
||||
The documentation in the NDK docs directory is very helpful in understanding the build process and how to work with native code on the Android platform.
|
||||
|
||||
The best place to start is with docs/OVERVIEW.TXT
|
||||
|
||||
|
||||
================================================================================
|
||||
Using Eclipse
|
||||
================================================================================
|
||||
|
||||
First make sure that you've installed Eclipse and the Android extensions as described here:
|
||||
http://developer.android.com/sdk/eclipse-adt.html
|
||||
|
||||
Once you've copied the SDL android project and customized it, you can create an Eclipse project from it:
|
||||
* File -> New -> Other
|
||||
* Select the Android -> Android Project wizard and click Next
|
||||
* Enter the name you'd like your project to have
|
||||
* Select "Create project from existing source" and browse for your project directory
|
||||
* Make sure the Build Target is set to Android 1.6
|
||||
* Click Finish
|
||||
|
||||
|
||||
================================================================================
|
||||
Loading files and resources
|
||||
================================================================================
|
||||
|
||||
NEED CONTENT
|
||||
|
||||
|
||||
================================================================================
|
||||
Troubleshooting
|
||||
================================================================================
|
||||
|
||||
You can create and run an emulator from the Eclipse IDE:
|
||||
* Window -> Android SDK and AVD Manager
|
||||
|
||||
You can see if adb can see any devices with the following command:
|
||||
adb devices
|
||||
|
||||
You can see the output of log messages on the default device with:
|
||||
adb logcat
|
||||
|
||||
You can push files to the device with:
|
||||
adb push local_file remote_path_and_file
|
||||
|
||||
You can push files to the SD Card at /sdcard, for example:
|
||||
adb push moose.dat /sdcard/moose.dat
|
||||
|
||||
You can see the files on the SD card with a shell command:
|
||||
adb shell ls /sdcard/
|
||||
|
||||
You can start a command shell on the default device with:
|
||||
adb shell
|
||||
|
||||
You can do a clean build with the following commands:
|
||||
ndk-build clean
|
||||
ndk-build
|
||||
|
||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||
ndk-build V=1
|
||||
|
||||
If your application crashes in native code, you can use addr2line to convert the addresses in the stack trace to lines in your code.
|
||||
|
||||
For example, if your crash looks like this:
|
||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||
|
||||
You can see that there's a crash in the C library being called from the main code. I run addr2line with the debug version of my code:
|
||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||
000014bc
|
||||
|
||||
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
||||
|
||||
You can add logging to your code to help show what's happening:
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
||||
|
||||
If you need to build without optimization turned on, you can create a file called "Application.mk" in the jni directory, with the following line in it:
|
||||
APP_OPTIM := debug
|
||||
|
||||
|
||||
================================================================================
|
||||
Known issues
|
||||
================================================================================
|
||||
|
||||
- SDL audio (although it's mostly written, just not working properly yet)
|
||||
- TODO. I'm sure there's a bunch more stuff I haven't thought of
|
|
@ -1,113 +0,0 @@
|
|||
Summary: Simple DirectMedia Layer
|
||||
Name: SDL
|
||||
Version: 1.3.0
|
||||
Release: 1
|
||||
Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz
|
||||
URL: http://www.libsdl.org/
|
||||
License: LGPL
|
||||
Group: System Environment/Libraries
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
|
||||
Prefix: %{_prefix}
|
||||
%ifos linux
|
||||
Provides: libSDL-1.2.so.0
|
||||
%endif
|
||||
|
||||
%define __defattr %defattr(-,root,root)
|
||||
%define __soext so
|
||||
|
||||
%description
|
||||
This is the Simple DirectMedia Layer, a generic API that provides low
|
||||
level access to audio, keyboard, mouse, and display framebuffer across
|
||||
multiple platforms.
|
||||
|
||||
%package devel
|
||||
Summary: Libraries, includes and more to develop SDL applications.
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}
|
||||
|
||||
%description devel
|
||||
This is the Simple DirectMedia Layer, a generic API that provides low
|
||||
level access to audio, keyboard, mouse, and display framebuffer across
|
||||
multiple platforms.
|
||||
|
||||
This is the libraries, include files and other resources you can use
|
||||
to develop SDL applications.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
%ifos linux
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --disable-video-directfb
|
||||
%else
|
||||
%configure
|
||||
%endif
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%ifos linux
|
||||
make install prefix=$RPM_BUILD_ROOT%{prefix} \
|
||||
bindir=$RPM_BUILD_ROOT%{_bindir} \
|
||||
libdir=$RPM_BUILD_ROOT%{_libdir} \
|
||||
includedir=$RPM_BUILD_ROOT%{_includedir} \
|
||||
datadir=$RPM_BUILD_ROOT%{_datadir} \
|
||||
mandir=$RPM_BUILD_ROOT%{_mandir}
|
||||
ln -s libSDL-1.2.so.0 $RPM_BUILD_ROOT%{_libdir}/libSDL-1.1.so.0
|
||||
%else
|
||||
%makeinstall
|
||||
%endif
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%{__defattr}
|
||||
%doc README-SDL.txt COPYING CREDITS BUGS
|
||||
%{_libdir}/lib*.%{__soext}.*
|
||||
|
||||
%files devel
|
||||
%{__defattr}
|
||||
%doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew
|
||||
%doc docs/index.html docs/html
|
||||
%{_bindir}/*-config
|
||||
%{_libdir}/lib*.a
|
||||
%{_libdir}/lib*.la
|
||||
%{_libdir}/lib*.%{__soext}
|
||||
%dir %{_includedir}/SDL
|
||||
%{_includedir}/SDL/*.h
|
||||
%{_libdir}/pkgconfig/sdl.pc
|
||||
%{_datadir}/aclocal/*
|
||||
%{_mandir}/man3/*
|
||||
|
||||
%changelog
|
||||
* Tue May 16 2006 Sam Lantinga <slouken@libsdl.org>
|
||||
- Removed support for Darwin, due to build problems on ps2linux
|
||||
|
||||
* Mon Jan 03 2004 Anders Bjorklund <afb@algonet.se>
|
||||
- Added support for Darwin, updated spec file
|
||||
|
||||
* Wed Jan 19 2000 Sam Lantinga <slouken@libsdl.org>
|
||||
- Re-integrated spec file into SDL distribution
|
||||
- 'name' and 'version' come from configure
|
||||
- Some of the documentation is devel specific
|
||||
- Removed SMP support from %build - it doesn't work with libtool anyway
|
||||
|
||||
* Tue Jan 18 2000 Hakan Tandogan <hakan@iconsult.com>
|
||||
- Hacked Mandrake sdl spec to build 1.1
|
||||
|
||||
* Sun Dec 19 1999 John Buswell <johnb@mandrakesoft.com>
|
||||
- Build Release
|
||||
|
||||
* Sat Dec 18 1999 John Buswell <johnb@mandrakesoft.com>
|
||||
- Add symlink for libSDL-1.0.so.0 required by sdlbomber
|
||||
- Added docs
|
||||
|
||||
* Thu Dec 09 1999 Lenny Cartier <lenny@mandrakesoft.com>
|
||||
- v 1.0.0
|
||||
|
||||
* Mon Nov 1 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
|
||||
- First spec file for Mandrake distribution.
|
||||
|
||||
# end of file
|
|
@ -1,113 +0,0 @@
|
|||
Summary: Simple DirectMedia Layer
|
||||
Name: SDL
|
||||
Version: @SDL_VERSION@
|
||||
Release: 1
|
||||
Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz
|
||||
URL: http://www.libsdl.org/
|
||||
License: LGPL
|
||||
Group: System Environment/Libraries
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
|
||||
Prefix: %{_prefix}
|
||||
%ifos linux
|
||||
Provides: libSDL-1.2.so.0
|
||||
%endif
|
||||
|
||||
%define __defattr %defattr(-,root,root)
|
||||
%define __soext so
|
||||
|
||||
%description
|
||||
This is the Simple DirectMedia Layer, a generic API that provides low
|
||||
level access to audio, keyboard, mouse, and display framebuffer across
|
||||
multiple platforms.
|
||||
|
||||
%package devel
|
||||
Summary: Libraries, includes and more to develop SDL applications.
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}
|
||||
|
||||
%description devel
|
||||
This is the Simple DirectMedia Layer, a generic API that provides low
|
||||
level access to audio, keyboard, mouse, and display framebuffer across
|
||||
multiple platforms.
|
||||
|
||||
This is the libraries, include files and other resources you can use
|
||||
to develop SDL applications.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
%ifos linux
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --disable-video-directfb
|
||||
%else
|
||||
%configure
|
||||
%endif
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%ifos linux
|
||||
make install prefix=$RPM_BUILD_ROOT%{prefix} \
|
||||
bindir=$RPM_BUILD_ROOT%{_bindir} \
|
||||
libdir=$RPM_BUILD_ROOT%{_libdir} \
|
||||
includedir=$RPM_BUILD_ROOT%{_includedir} \
|
||||
datadir=$RPM_BUILD_ROOT%{_datadir} \
|
||||
mandir=$RPM_BUILD_ROOT%{_mandir}
|
||||
ln -s libSDL-1.2.so.0 $RPM_BUILD_ROOT%{_libdir}/libSDL-1.1.so.0
|
||||
%else
|
||||
%makeinstall
|
||||
%endif
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%{__defattr}
|
||||
%doc README-SDL.txt COPYING CREDITS BUGS
|
||||
%{_libdir}/lib*.%{__soext}.*
|
||||
|
||||
%files devel
|
||||
%{__defattr}
|
||||
%doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew
|
||||
%doc docs/index.html docs/html
|
||||
%{_bindir}/*-config
|
||||
%{_libdir}/lib*.a
|
||||
%{_libdir}/lib*.la
|
||||
%{_libdir}/lib*.%{__soext}
|
||||
%dir %{_includedir}/SDL
|
||||
%{_includedir}/SDL/*.h
|
||||
%{_libdir}/pkgconfig/sdl.pc
|
||||
%{_datadir}/aclocal/*
|
||||
%{_mandir}/man3/*
|
||||
|
||||
%changelog
|
||||
* Tue May 16 2006 Sam Lantinga <slouken@libsdl.org>
|
||||
- Removed support for Darwin, due to build problems on ps2linux
|
||||
|
||||
* Mon Jan 03 2004 Anders Bjorklund <afb@algonet.se>
|
||||
- Added support for Darwin, updated spec file
|
||||
|
||||
* Wed Jan 19 2000 Sam Lantinga <slouken@libsdl.org>
|
||||
- Re-integrated spec file into SDL distribution
|
||||
- 'name' and 'version' come from configure
|
||||
- Some of the documentation is devel specific
|
||||
- Removed SMP support from %build - it doesn't work with libtool anyway
|
||||
|
||||
* Tue Jan 18 2000 Hakan Tandogan <hakan@iconsult.com>
|
||||
- Hacked Mandrake sdl spec to build 1.1
|
||||
|
||||
* Sun Dec 19 1999 John Buswell <johnb@mandrakesoft.com>
|
||||
- Build Release
|
||||
|
||||
* Sat Dec 18 1999 John Buswell <johnb@mandrakesoft.com>
|
||||
- Add symlink for libSDL-1.0.so.0 required by sdlbomber
|
||||
- Added docs
|
||||
|
||||
* Thu Dec 09 1999 Lenny Cartier <lenny@mandrakesoft.com>
|
||||
- v 1.0.0
|
||||
|
||||
* Mon Nov 1 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
|
||||
- First spec file for Mandrake distribution.
|
||||
|
||||
# end of file
|
|
@ -1,163 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL.h
|
||||
*
|
||||
* Main include header for the SDL library
|
||||
*/
|
||||
|
||||
/**
|
||||
* \mainpage Simple DirectMedia Layer (SDL)
|
||||
*
|
||||
* http://www.libsdl.org/
|
||||
*
|
||||
* \section intro_sec Introduction
|
||||
*
|
||||
* This is the Simple DirectMedia Layer, a general API that provides low
|
||||
* level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
|
||||
* and 2D framebuffer across multiple platforms.
|
||||
*
|
||||
* SDL is written in C, but works with C++ natively, and has bindings to
|
||||
* several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
|
||||
* Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
|
||||
* Pike, Pliant, Python, Ruby, and Smalltalk.
|
||||
*
|
||||
* This library is distributed under GNU LGPL version 2, which can be
|
||||
* found in the file "COPYING". This license allows you to use SDL
|
||||
* freely in commercial programs as long as you link with the dynamic
|
||||
* library.
|
||||
*
|
||||
* The best way to learn how to use SDL is to check out the header files in
|
||||
* the "include" subdirectory and the programs in the "test" subdirectory.
|
||||
* The header files and test programs are well commented and always up to date.
|
||||
* More documentation is available in HTML format in "docs/index.html", and
|
||||
* a documentation wiki is available online at:
|
||||
* http://www.libsdl.org/cgi/docwiki.cgi
|
||||
*
|
||||
* The test programs in the "test" subdirectory are in the public domain.
|
||||
*
|
||||
* Frequently asked questions are answered online:
|
||||
* http://www.libsdl.org/faq.php
|
||||
*
|
||||
* If you need help with the library, or just want to discuss SDL related
|
||||
* issues, you can join the developers mailing list:
|
||||
* http://www.libsdl.org/mailing-list.php
|
||||
*
|
||||
* Enjoy!
|
||||
* Sam Lantinga (slouken@libsdl.org)
|
||||
*/
|
||||
|
||||
#ifndef _SDL_H
|
||||
#define _SDL_H
|
||||
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_atomic.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_clipboard.h"
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_power.h"
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_version.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_compat.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* As of version 0.5, SDL is loaded dynamically into the application */
|
||||
|
||||
/**
|
||||
* \name SDL_INIT_*
|
||||
*
|
||||
* These are the flags which may be passed to SDL_Init(). You should
|
||||
* specify the subsystems which you will be using in your application.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_INIT_TIMER 0x00000001
|
||||
#define SDL_INIT_AUDIO 0x00000010
|
||||
#define SDL_INIT_VIDEO 0x00000020
|
||||
#define SDL_INIT_JOYSTICK 0x00000200
|
||||
#define SDL_INIT_HAPTIC 0x00001000
|
||||
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */
|
||||
#define SDL_INIT_EVERYTHING 0x0000FFFF
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* This function initializes the subsystems specified by \c flags
|
||||
* Unless the ::SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
|
||||
* signal handlers for some commonly ignored fatal signals (like SIGSEGV).
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function initializes specific SDL subsystems
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function cleans up specific SDL subsystems
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function returns a mask of the specified subsystems which have
|
||||
* previously been initialized.
|
||||
*
|
||||
* If \c flags is 0, it returns a mask of all initialized subsystems.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function cleans up all initialized subsystems. You should
|
||||
* call it upon all exit conditions.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Quit(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,243 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_assert_h
|
||||
#define _SDL_assert_h
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#ifndef SDL_ASSERT_LEVEL
|
||||
#ifdef SDL_DEFAULT_ASSERT_LEVEL
|
||||
#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
|
||||
#elif defined(_DEBUG) || defined(DEBUG) || \
|
||||
(defined(__GNUC__) && !defined(__OPTIMIZE__))
|
||||
#define SDL_ASSERT_LEVEL 2
|
||||
#else
|
||||
#define SDL_ASSERT_LEVEL 1
|
||||
#endif
|
||||
#endif /* SDL_ASSERT_LEVEL */
|
||||
|
||||
/*
|
||||
These are macros and not first class functions so that the debugger breaks
|
||||
on the assertion line and not in some random guts of SDL, and so each
|
||||
assert can have unique static variables associated with it.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
/* Don't include intrin.h here because it contains C++ code */
|
||||
extern void __cdecl __debugbreak(void);
|
||||
#define SDL_TriggerBreakpoint() __debugbreak()
|
||||
#elif (defined(__GNUC__) && ((__i386__) || (__x86_64__)))
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
|
||||
#elif defined(HAVE_SIGNAL_H)
|
||||
#include <signal.h>
|
||||
#define SDL_TriggerBreakpoint() raise(SIGTRAP)
|
||||
#else
|
||||
/* How do we trigger breakpoints on this platform? */
|
||||
#define SDL_TriggerBreakpoint()
|
||||
#endif
|
||||
|
||||
#if (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
|
||||
# define SDL_FUNCTION __func__
|
||||
#elif ((__GNUC__ >= 2) || defined(_MSC_VER))
|
||||
# define SDL_FUNCTION __FUNCTION__
|
||||
#else
|
||||
# define SDL_FUNCTION "???"
|
||||
#endif
|
||||
#define SDL_FILE __FILE__
|
||||
#define SDL_LINE __LINE__
|
||||
|
||||
/*
|
||||
sizeof (x) makes the compiler still parse the expression even without
|
||||
assertions enabled, so the code is always checked at compile time, but
|
||||
doesn't actually generate code for it, so there are no side effects or
|
||||
expensive checks at run time, just the constant size of what x WOULD be,
|
||||
which presumably gets optimized out as unused.
|
||||
This also solves the problem of...
|
||||
|
||||
int somevalue = blah();
|
||||
SDL_assert(somevalue == 1);
|
||||
|
||||
...which would cause compiles to complain that somevalue is unused if we
|
||||
disable assertions.
|
||||
*/
|
||||
|
||||
#define SDL_disabled_assert(condition) \
|
||||
do { (void) sizeof ((condition)); } while (0)
|
||||
|
||||
#if (SDL_ASSERT_LEVEL > 0)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */
|
||||
SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */
|
||||
SDL_ASSERTION_ABORT, /**< Terminate the program. */
|
||||
SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
|
||||
SDL_ASSERTION_ALWAYS_IGNORE, /**< Ignore the assert from now on. */
|
||||
} SDL_assert_state;
|
||||
|
||||
typedef struct SDL_assert_data
|
||||
{
|
||||
int always_ignore;
|
||||
unsigned int trigger_count;
|
||||
const char *condition;
|
||||
const char *filename;
|
||||
int linenum;
|
||||
const char *function;
|
||||
const struct SDL_assert_data *next;
|
||||
} SDL_assert_data;
|
||||
|
||||
/* Never call this directly. Use the SDL_assert* macros. */
|
||||
extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
|
||||
const char *,
|
||||
const char *, int);
|
||||
|
||||
/* the do {} while(0) avoids dangling else problems:
|
||||
if (x) SDL_assert(y); else blah();
|
||||
... without the do/while, the "else" could attach to this macro's "if".
|
||||
We try to handle just the minimum we need here in a macro...the loop,
|
||||
the static vars, and break points. The heavy lifting is handled in
|
||||
SDL_ReportAssertion(), in SDL_assert.c.
|
||||
*/
|
||||
#define SDL_enabled_assert(condition) \
|
||||
do { \
|
||||
while ( !(condition) ) { \
|
||||
static struct SDL_assert_data assert_data = { \
|
||||
0, 0, #condition, 0, 0, 0, 0 \
|
||||
}; \
|
||||
const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \
|
||||
SDL_FUNCTION, \
|
||||
SDL_FILE, \
|
||||
SDL_LINE); \
|
||||
if (state == SDL_ASSERTION_RETRY) { \
|
||||
continue; /* go again. */ \
|
||||
} else if (state == SDL_ASSERTION_BREAK) { \
|
||||
SDL_TriggerBreakpoint(); \
|
||||
} \
|
||||
break; /* not retrying. */ \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* enabled assertions support code */
|
||||
|
||||
/* Enable various levels of assertions. */
|
||||
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
|
||||
# define SDL_assert(condition) SDL_disabled_assert(condition)
|
||||
# define SDL_assert_release(condition) SDL_disabled_assert(condition)
|
||||
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
|
||||
#elif SDL_ASSERT_LEVEL == 1 /* release settings. */
|
||||
# define SDL_assert(condition) SDL_disabled_assert(condition)
|
||||
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
|
||||
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
|
||||
#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */
|
||||
# define SDL_assert(condition) SDL_enabled_assert(condition)
|
||||
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
|
||||
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
|
||||
#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */
|
||||
# define SDL_assert(condition) SDL_enabled_assert(condition)
|
||||
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
|
||||
# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
|
||||
#else
|
||||
# error Unknown assertion level.
|
||||
#endif
|
||||
|
||||
|
||||
typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
|
||||
const SDL_assert_data *, void *userdata);
|
||||
|
||||
/**
|
||||
* \brief Set an application-defined assertion handler.
|
||||
*
|
||||
* This allows an app to show its own assertion UI and/or force the
|
||||
* response to an assertion failure. If the app doesn't provide this, SDL
|
||||
* will try to do the right thing, popping up a system-specific GUI dialog,
|
||||
* and probably minimizing any fullscreen windows.
|
||||
*
|
||||
* This callback may fire from any thread, but it runs wrapped in a mutex, so
|
||||
* it will only fire from one thread at a time.
|
||||
*
|
||||
* Setting the callback to NULL restores SDL's original internal handler.
|
||||
*
|
||||
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
|
||||
*
|
||||
* \return SDL_assert_state value of how to handle the assertion failure.
|
||||
*
|
||||
* \param handler Callback function, called when an assertion fails.
|
||||
* \param userdata A pointer passed to the callback as-is.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
|
||||
SDL_AssertionHandler handler,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* \brief Get a list of all assertion failures.
|
||||
*
|
||||
* Get all assertions triggered since last call to SDL_ResetAssertionReport(),
|
||||
* or the start of the program.
|
||||
*
|
||||
* The proper way to examine this data looks something like this:
|
||||
*
|
||||
* <code>
|
||||
* const SDL_assert_data *item = SDL_GetAssertionReport();
|
||||
* while (item->condition) {
|
||||
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
|
||||
* item->condition, item->function, item->filename,
|
||||
* item->linenum, item->trigger_count,
|
||||
* item->always_ignore ? "yes" : "no");
|
||||
* item = item->next;
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* \return List of all assertions. This never returns NULL,
|
||||
* even if there are no items.
|
||||
* \sa SDL_ResetAssertionReport
|
||||
*/
|
||||
extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
|
||||
|
||||
/**
|
||||
* \brief Reset the list of all assertion failures.
|
||||
*
|
||||
* Reset list of all assertions triggered.
|
||||
*
|
||||
* \sa SDL_GetAssertionReport
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_assert_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,319 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_atomic.h
|
||||
*
|
||||
* Atomic operations.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* If you are not an expert in concurrent lockless programming, you should
|
||||
* only be using the atomic lock and reference counting functions in this
|
||||
* file. In all other cases you should be protecting your data structures
|
||||
* with full mutexes.
|
||||
*
|
||||
* The list of "safe" functions to use are:
|
||||
* SDL_AtomicLock()
|
||||
* SDL_AtomicUnlock()
|
||||
* SDL_AtomicIncRef()
|
||||
* SDL_AtomicDecRef()
|
||||
*
|
||||
* Seriously, here be dragons!
|
||||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
*
|
||||
* You can find out a little more about lockless programming and the
|
||||
* subtle issues that can arise here:
|
||||
* http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
|
||||
*
|
||||
* There's also lots of good information here:
|
||||
* http://www.1024cores.net/home/lock-free-algorithms
|
||||
*
|
||||
* These operations may or may not actually be implemented using
|
||||
* processor specific atomic operations. When possible they are
|
||||
* implemented as true processor specific atomic operations. When that
|
||||
* is not possible the are implemented using locks that *do* use the
|
||||
* available atomic operations.
|
||||
*
|
||||
* All of the atomic operations that modify memory are full memory barriers.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_atomic_h_
|
||||
#define _SDL_atomic_h_
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_platform.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
|
||||
/* Need to do this here because intrin.h has C++ code in it */
|
||||
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)
|
||||
#include <intrin.h>
|
||||
#define HAVE_MSC_ATOMICS 1
|
||||
#endif
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name SDL AtomicLock
|
||||
*
|
||||
* The atomic locks are efficient spinlocks using CPU instructions,
|
||||
* but are vulnerable to starvation and can spin forever if a thread
|
||||
* holding a lock has been terminated. For this reason you should
|
||||
* minimize the code executed inside an atomic lock and never do
|
||||
* expensive things like API or system calls while holding them.
|
||||
*
|
||||
* The atomic locks are not safe to lock recursively.
|
||||
*
|
||||
* Porting Note:
|
||||
* The spin lock functions and type are required and can not be
|
||||
* emulated because they are used in the atomic emulation code.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
typedef int SDL_SpinLock;
|
||||
|
||||
/**
|
||||
* \brief Try to lock a spin lock by setting it to a non-zero value.
|
||||
*
|
||||
* \param lock Points to the lock.
|
||||
*
|
||||
* \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
|
||||
|
||||
/**
|
||||
* \brief Lock a spin lock by setting it to a non-zero value.
|
||||
*
|
||||
* \param lock Points to the lock.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
|
||||
|
||||
/**
|
||||
* \brief Unlock a spin lock by setting it to 0. Always returns immediately
|
||||
*
|
||||
* \param lock Points to the lock.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
|
||||
|
||||
/*@}*//*SDL AtomicLock*/
|
||||
|
||||
|
||||
/**
|
||||
* The compiler barrier prevents the compiler from reordering
|
||||
* reads and writes to globally visible variables across the call.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
void _ReadWriteBarrier(void);
|
||||
#pragma intrinsic(_ReadWriteBarrier)
|
||||
#define SDL_CompilerBarrier() _ReadWriteBarrier()
|
||||
#elif defined(__GNUC__)
|
||||
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
|
||||
#else
|
||||
#define SDL_CompilerBarrier() \
|
||||
({ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); })
|
||||
#endif
|
||||
|
||||
/* Platform specific optimized versions of the atomic functions,
|
||||
* you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
|
||||
*/
|
||||
#if SDL_ATOMIC_DISABLED
|
||||
#define SDL_DISABLE_ATOMIC_INLINE
|
||||
#endif
|
||||
#ifndef SDL_DISABLE_ATOMIC_INLINE
|
||||
|
||||
#ifdef HAVE_MSC_ATOMICS
|
||||
|
||||
#define SDL_AtomicSet(a, v) _InterlockedExchange((long*)&(a)->value, (v))
|
||||
#define SDL_AtomicAdd(a, v) _InterlockedExchangeAdd((long*)&(a)->value, (v))
|
||||
#define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange((long*)&(a)->value, (newval), (oldval)) == (oldval))
|
||||
#define SDL_AtomicSetPtr(a, v) _InterlockedExchangePointer((a), (v))
|
||||
#if _M_IX86
|
||||
#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval))
|
||||
#else
|
||||
#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchangePointer((a), (newval), (oldval)) == (oldval))
|
||||
#endif
|
||||
|
||||
#elif defined(__MACOSX__)
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
#define SDL_AtomicCAS(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((oldval), (newval), &(a)->value)
|
||||
#if SIZEOF_VOIDP == 4
|
||||
#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((int32_t)(oldval), (int32_t)(newval), (int32_t*)(a))
|
||||
#elif SIZEOF_VOIDP == 8
|
||||
#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap64Barrier((int64_t)(oldval), (int64_t)(newval), (int64_t*)(a))
|
||||
#endif
|
||||
|
||||
#elif defined(HAVE_GCC_ATOMICS)
|
||||
|
||||
#define SDL_AtomicSet(a, v) __sync_lock_test_and_set(&(a)->value, v)
|
||||
#define SDL_AtomicAdd(a, v) __sync_fetch_and_add(&(a)->value, v)
|
||||
#define SDL_AtomicSetPtr(a, v) __sync_lock_test_and_set(a, v)
|
||||
#define SDL_AtomicCAS(a, oldval, newval) __sync_bool_compare_and_swap(&(a)->value, oldval, newval)
|
||||
#define SDL_AtomicCASPtr(a, oldval, newval) __sync_bool_compare_and_swap(a, oldval, newval)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !SDL_DISABLE_ATOMIC_INLINE */
|
||||
|
||||
|
||||
/**
|
||||
* \brief A type representing an atomic integer value. It is a struct
|
||||
* so people don't accidentally use numeric operations on it.
|
||||
*/
|
||||
#ifndef SDL_atomic_t_defined
|
||||
typedef struct { int value; } SDL_atomic_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Set an atomic variable to a new value if it is currently an old value.
|
||||
*
|
||||
* \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
|
||||
*
|
||||
* \note If you don't know what this function is for, you shouldn't use it!
|
||||
*/
|
||||
#ifndef SDL_AtomicCAS
|
||||
#define SDL_AtomicCAS SDL_AtomicCAS_
|
||||
#endif
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS_(SDL_atomic_t *a, int oldval, int newval);
|
||||
|
||||
/**
|
||||
* \brief Set an atomic variable to a value.
|
||||
*
|
||||
* \return The previous value of the atomic variable.
|
||||
*/
|
||||
#ifndef SDL_AtomicSet
|
||||
static __inline__ int SDL_AtomicSet(SDL_atomic_t *a, int v)
|
||||
{
|
||||
int value;
|
||||
do {
|
||||
value = a->value;
|
||||
} while (!SDL_AtomicCAS(a, value, v));
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Get the value of an atomic variable
|
||||
*/
|
||||
#ifndef SDL_AtomicGet
|
||||
static __inline__ int SDL_AtomicGet(SDL_atomic_t *a)
|
||||
{
|
||||
int value = a->value;
|
||||
SDL_CompilerBarrier();
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Add to an atomic variable.
|
||||
*
|
||||
* \return The previous value of the atomic variable.
|
||||
*
|
||||
* \note This same style can be used for any number operation
|
||||
*/
|
||||
#ifndef SDL_AtomicAdd
|
||||
static __inline__ int SDL_AtomicAdd(SDL_atomic_t *a, int v)
|
||||
{
|
||||
int value;
|
||||
do {
|
||||
value = a->value;
|
||||
} while (!SDL_AtomicCAS(a, value, (value + v)));
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Increment an atomic variable used as a reference count.
|
||||
*/
|
||||
#ifndef SDL_AtomicIncRef
|
||||
#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Decrement an atomic variable used as a reference count.
|
||||
*
|
||||
* \return SDL_TRUE if the variable reached zero after decrementing,
|
||||
* SDL_FALSE otherwise
|
||||
*/
|
||||
#ifndef SDL_AtomicDecRef
|
||||
#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Set a pointer to a new value if it is currently an old value.
|
||||
*
|
||||
* \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
|
||||
*
|
||||
* \note If you don't know what this function is for, you shouldn't use it!
|
||||
*/
|
||||
#ifndef SDL_AtomicCASPtr
|
||||
#define SDL_AtomicCASPtr SDL_AtomicCASPtr_
|
||||
#endif
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr_(void* *a, void *oldval, void *newval);
|
||||
|
||||
/**
|
||||
* \brief Set a pointer to a value atomically.
|
||||
*
|
||||
* \return The previous value of the pointer.
|
||||
*/
|
||||
#ifndef SDL_AtomicSetPtr
|
||||
static __inline__ void* SDL_AtomicSetPtr(void* *a, void* v)
|
||||
{
|
||||
void* value;
|
||||
do {
|
||||
value = *a;
|
||||
} while (!SDL_AtomicCASPtr(a, value, v));
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Get the value of a pointer atomically.
|
||||
*/
|
||||
#ifndef SDL_AtomicGetPtr
|
||||
static __inline__ void* SDL_AtomicGetPtr(void* *a)
|
||||
{
|
||||
void* value = *a;
|
||||
SDL_CompilerBarrier();
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_atomic_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,510 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_audio.h
|
||||
*
|
||||
* Access to the raw audio mixing buffer for the SDL library.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_audio_h
|
||||
#define _SDL_audio_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Audio format flags.
|
||||
*
|
||||
* These are what the 16 bits in SDL_AudioFormat currently mean...
|
||||
* (Unspecified bits are always zero).
|
||||
*
|
||||
* \verbatim
|
||||
++-----------------------sample is signed if set
|
||||
||
|
||||
|| ++-----------sample is bigendian if set
|
||||
|| ||
|
||||
|| || ++---sample is float if set
|
||||
|| || ||
|
||||
|| || || +---sample bit size---+
|
||||
|| || || | |
|
||||
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
||||
\endverbatim
|
||||
*
|
||||
* There are macros in SDL 1.3 and later to query these bits.
|
||||
*/
|
||||
typedef Uint16 SDL_AudioFormat;
|
||||
|
||||
/**
|
||||
* \name Audio flags
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
#define SDL_AUDIO_MASK_BITSIZE (0xFF)
|
||||
#define SDL_AUDIO_MASK_DATATYPE (1<<8)
|
||||
#define SDL_AUDIO_MASK_ENDIAN (1<<12)
|
||||
#define SDL_AUDIO_MASK_SIGNED (1<<15)
|
||||
#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE)
|
||||
#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE)
|
||||
#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN)
|
||||
#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED)
|
||||
#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x))
|
||||
#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x))
|
||||
#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x))
|
||||
|
||||
/**
|
||||
* \name Audio format flags
|
||||
*
|
||||
* Defaults to LSB byte order.
|
||||
*/
|
||||
/*@{*/
|
||||
#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */
|
||||
#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */
|
||||
#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */
|
||||
#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */
|
||||
#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */
|
||||
#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */
|
||||
#define AUDIO_U16 AUDIO_U16LSB
|
||||
#define AUDIO_S16 AUDIO_S16LSB
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name int32 support
|
||||
*
|
||||
* New to SDL 1.3.
|
||||
*/
|
||||
/*@{*/
|
||||
#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */
|
||||
#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */
|
||||
#define AUDIO_S32 AUDIO_S32LSB
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name float32 support
|
||||
*
|
||||
* New to SDL 1.3.
|
||||
*/
|
||||
/*@{*/
|
||||
#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */
|
||||
#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */
|
||||
#define AUDIO_F32 AUDIO_F32LSB
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Native audio byte ordering
|
||||
*/
|
||||
/*@{*/
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define AUDIO_U16SYS AUDIO_U16LSB
|
||||
#define AUDIO_S16SYS AUDIO_S16LSB
|
||||
#define AUDIO_S32SYS AUDIO_S32LSB
|
||||
#define AUDIO_F32SYS AUDIO_F32LSB
|
||||
#else
|
||||
#define AUDIO_U16SYS AUDIO_U16MSB
|
||||
#define AUDIO_S16SYS AUDIO_S16MSB
|
||||
#define AUDIO_S32SYS AUDIO_S32MSB
|
||||
#define AUDIO_F32SYS AUDIO_F32MSB
|
||||
#endif
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Allow change flags
|
||||
*
|
||||
* Which audio format changes are allowed when opening a device.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001
|
||||
#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002
|
||||
#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004
|
||||
#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
|
||||
/*@}*/
|
||||
|
||||
/*@}*//*Audio flags*/
|
||||
|
||||
/**
|
||||
* This function is called when the audio device needs more data.
|
||||
*
|
||||
* \param userdata An application-specific parameter saved in
|
||||
* the SDL_AudioSpec structure
|
||||
* \param stream A pointer to the audio data buffer.
|
||||
* \param len The length of that buffer in bytes.
|
||||
*
|
||||
* Once the callback returns, the buffer will no longer be valid.
|
||||
* Stereo samples are stored in a LRLRLR ordering.
|
||||
*/
|
||||
typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* The calculated values in this structure are calculated by SDL_OpenAudio().
|
||||
*/
|
||||
typedef struct SDL_AudioSpec
|
||||
{
|
||||
int freq; /**< DSP frequency -- samples per second */
|
||||
SDL_AudioFormat format; /**< Audio data format */
|
||||
Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */
|
||||
Uint8 silence; /**< Audio buffer silence value (calculated) */
|
||||
Uint16 samples; /**< Audio buffer size in samples (power of 2) */
|
||||
Uint16 padding; /**< Necessary for some compile environments */
|
||||
Uint32 size; /**< Audio buffer size in bytes (calculated) */
|
||||
SDL_AudioCallback callback;
|
||||
void *userdata;
|
||||
} SDL_AudioSpec;
|
||||
|
||||
|
||||
struct SDL_AudioCVT;
|
||||
typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
|
||||
SDL_AudioFormat format);
|
||||
|
||||
/**
|
||||
* A structure to hold a set of audio conversion filters and buffers.
|
||||
*/
|
||||
typedef struct SDL_AudioCVT
|
||||
{
|
||||
int needed; /**< Set to 1 if conversion possible */
|
||||
SDL_AudioFormat src_format; /**< Source audio format */
|
||||
SDL_AudioFormat dst_format; /**< Target audio format */
|
||||
double rate_incr; /**< Rate conversion increment */
|
||||
Uint8 *buf; /**< Buffer to hold entire audio data */
|
||||
int len; /**< Length of original audio buffer */
|
||||
int len_cvt; /**< Length of converted audio buffer */
|
||||
int len_mult; /**< buffer must be len*len_mult big */
|
||||
double len_ratio; /**< Given len, final size is len*len_ratio */
|
||||
SDL_AudioFilter filters[10]; /**< Filter list */
|
||||
int filter_index; /**< Current audio conversion function */
|
||||
} SDL_AudioCVT;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \name Driver discovery functions
|
||||
*
|
||||
* These functions return the list of built in audio drivers, in the
|
||||
* order that they are normally initialized by default.
|
||||
*/
|
||||
/*@{*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Initialization and cleanup
|
||||
*
|
||||
* \internal These functions are used internally, and should not be used unless
|
||||
* you have a specific need to specify the audio driver you want to
|
||||
* use. You should normally use SDL_Init() or SDL_InitSubSystem().
|
||||
*/
|
||||
/*@{*/
|
||||
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
|
||||
extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* This function returns the name of the current audio driver, or NULL
|
||||
* if no driver has been initialized.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
|
||||
|
||||
/**
|
||||
* This function opens the audio device with the desired parameters, and
|
||||
* returns 0 if successful, placing the actual hardware parameters in the
|
||||
* structure pointed to by \c obtained. If \c obtained is NULL, the audio
|
||||
* data passed to the callback function will be guaranteed to be in the
|
||||
* requested format, and will be automatically converted to the hardware
|
||||
* audio format if necessary. This function returns -1 if it failed
|
||||
* to open the audio device, or couldn't set up the audio thread.
|
||||
*
|
||||
* When filling in the desired audio spec structure,
|
||||
* - \c desired->freq should be the desired audio frequency in samples-per-
|
||||
* second.
|
||||
* - \c desired->format should be the desired audio format.
|
||||
* - \c desired->samples is the desired size of the audio buffer, in
|
||||
* samples. This number should be a power of two, and may be adjusted by
|
||||
* the audio driver to a value more suitable for the hardware. Good values
|
||||
* seem to range between 512 and 8096 inclusive, depending on the
|
||||
* application and CPU speed. Smaller values yield faster response time,
|
||||
* but can lead to underflow if the application is doing heavy processing
|
||||
* and cannot fill the audio buffer in time. A stereo sample consists of
|
||||
* both right and left channels in LR ordering.
|
||||
* Note that the number of samples is directly related to time by the
|
||||
* following formula: \code ms = (samples*1000)/freq \endcode
|
||||
* - \c desired->size is the size in bytes of the audio buffer, and is
|
||||
* calculated by SDL_OpenAudio().
|
||||
* - \c desired->silence is the value used to set the buffer to silence,
|
||||
* and is calculated by SDL_OpenAudio().
|
||||
* - \c desired->callback should be set to a function that will be called
|
||||
* when the audio device is ready for more data. It is passed a pointer
|
||||
* to the audio buffer, and the length in bytes of the audio buffer.
|
||||
* This function usually runs in a separate thread, and so you should
|
||||
* protect data structures that it accesses by calling SDL_LockAudio()
|
||||
* and SDL_UnlockAudio() in your code.
|
||||
* - \c desired->userdata is passed as the first parameter to your callback
|
||||
* function.
|
||||
*
|
||||
* The audio device starts out playing silence when it's opened, and should
|
||||
* be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready
|
||||
* for your audio callback function to be called. Since the audio driver
|
||||
* may modify the requested size of the audio buffer, you should allocate
|
||||
* any local mixing buffers after you open the audio device.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
|
||||
SDL_AudioSpec * obtained);
|
||||
|
||||
/**
|
||||
* SDL Audio Device IDs.
|
||||
*
|
||||
* A successful call to SDL_OpenAudio() is always device id 1, and legacy
|
||||
* SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
|
||||
* always returns devices >= 2 on success. The legacy calls are good both
|
||||
* for backwards compatibility and when you don't care about multiple,
|
||||
* specific, or capture devices.
|
||||
*/
|
||||
typedef Uint32 SDL_AudioDeviceID;
|
||||
|
||||
/**
|
||||
* Get the number of available devices exposed by the current driver.
|
||||
* Only valid after a successfully initializing the audio subsystem.
|
||||
* Returns -1 if an explicit list of devices can't be determined; this is
|
||||
* not an error. For example, if SDL is set up to talk to a remote audio
|
||||
* server, it can't list every one available on the Internet, but it will
|
||||
* still allow a specific host to be specified to SDL_OpenAudioDevice().
|
||||
*
|
||||
* In many common cases, when this function returns a value <= 0, it can still
|
||||
* successfully open the default device (NULL for first argument of
|
||||
* SDL_OpenAudioDevice()).
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
|
||||
|
||||
/**
|
||||
* Get the human-readable name of a specific audio device.
|
||||
* Must be a value between 0 and (number of audio devices-1).
|
||||
* Only valid after a successfully initializing the audio subsystem.
|
||||
* The values returned by this function reflect the latest call to
|
||||
* SDL_GetNumAudioDevices(); recall that function to redetect available
|
||||
* hardware.
|
||||
*
|
||||
* The string returned by this function is UTF-8 encoded, read-only, and
|
||||
* managed internally. You are not to free it. If you need to keep the
|
||||
* string for any length of time, you should make your own copy of it, as it
|
||||
* will be invalid next time any of several other SDL functions is called.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
|
||||
int iscapture);
|
||||
|
||||
|
||||
/**
|
||||
* Open a specific audio device. Passing in a device name of NULL requests
|
||||
* the most reasonable default (and is equivalent to calling SDL_OpenAudio()).
|
||||
*
|
||||
* The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
|
||||
* some drivers allow arbitrary and driver-specific strings, such as a
|
||||
* hostname/IP address for a remote audio server, or a filename in the
|
||||
* diskaudio driver.
|
||||
*
|
||||
* \return 0 on error, a valid device ID that is >= 2 on success.
|
||||
*
|
||||
* SDL_OpenAudio(), unlike this function, always acts on device ID 1.
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char
|
||||
*device,
|
||||
int iscapture,
|
||||
const
|
||||
SDL_AudioSpec *
|
||||
desired,
|
||||
SDL_AudioSpec *
|
||||
obtained,
|
||||
int
|
||||
allowed_changes);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \name Audio state
|
||||
*
|
||||
* Get the current audio state.
|
||||
*/
|
||||
/*@{*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_AUDIO_STOPPED = 0,
|
||||
SDL_AUDIO_PLAYING,
|
||||
SDL_AUDIO_PAUSED
|
||||
} SDL_AudioStatus;
|
||||
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
|
||||
|
||||
extern DECLSPEC SDL_AudioStatus SDLCALL
|
||||
SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
|
||||
/*@}*//*Audio State*/
|
||||
|
||||
/**
|
||||
* \name Pause audio functions
|
||||
*
|
||||
* These functions pause and unpause the audio callback processing.
|
||||
* They should be called with a parameter of 0 after opening the audio
|
||||
* device to start playing sound. This is so you can safely initialize
|
||||
* data for your callback function after opening the audio device.
|
||||
* Silence will be written to the audio device during the pause.
|
||||
*/
|
||||
/*@{*/
|
||||
extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
|
||||
extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
|
||||
int pause_on);
|
||||
/*@}*//*Pause audio functions*/
|
||||
|
||||
/**
|
||||
* This function loads a WAVE from the data source, automatically freeing
|
||||
* that source if \c freesrc is non-zero. For example, to load a WAVE file,
|
||||
* you could do:
|
||||
* \code
|
||||
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
|
||||
* \endcode
|
||||
*
|
||||
* If this function succeeds, it returns the given SDL_AudioSpec,
|
||||
* filled with the audio data format of the wave data, and sets
|
||||
* \c *audio_buf to a malloc()'d buffer containing the audio data,
|
||||
* and sets \c *audio_len to the length of that audio buffer, in bytes.
|
||||
* You need to free the audio buffer with SDL_FreeWAV() when you are
|
||||
* done with it.
|
||||
*
|
||||
* This function returns NULL and sets the SDL error message if the
|
||||
* wave file cannot be opened, uses an unknown data format, or is
|
||||
* corrupt. Currently raw and MS-ADPCM WAVE files are supported.
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
|
||||
int freesrc,
|
||||
SDL_AudioSpec * spec,
|
||||
Uint8 ** audio_buf,
|
||||
Uint32 * audio_len);
|
||||
|
||||
/**
|
||||
* Loads a WAV from a file.
|
||||
* Compatibility convenience function.
|
||||
*/
|
||||
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
|
||||
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
|
||||
|
||||
/**
|
||||
* This function frees data previously allocated with SDL_LoadWAV_RW()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
|
||||
|
||||
/**
|
||||
* This function takes a source format and rate and a destination format
|
||||
* and rate, and initializes the \c cvt structure with information needed
|
||||
* by SDL_ConvertAudio() to convert a buffer of audio data from one format
|
||||
* to the other.
|
||||
*
|
||||
* \return -1 if the format conversion is not supported, 0 if there's
|
||||
* no conversion needed, or 1 if the audio filter is set up.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||
SDL_AudioFormat src_format,
|
||||
Uint8 src_channels,
|
||||
int src_rate,
|
||||
SDL_AudioFormat dst_format,
|
||||
Uint8 dst_channels,
|
||||
int dst_rate);
|
||||
|
||||
/**
|
||||
* Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(),
|
||||
* created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of
|
||||
* audio data in the source format, this function will convert it in-place
|
||||
* to the desired format.
|
||||
*
|
||||
* The data conversion may expand the size of the audio data, so the buffer
|
||||
* \c cvt->buf should be allocated after the \c cvt structure is initialized by
|
||||
* SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt);
|
||||
|
||||
#define SDL_MIX_MAXVOLUME 128
|
||||
/**
|
||||
* This takes two audio buffers of the playing audio format and mixes
|
||||
* them, performing addition, volume adjustment, and overflow clipping.
|
||||
* The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME
|
||||
* for full audio volume. Note this does not change hardware volume.
|
||||
* This is provided for convenience -- you can mix your own audio data.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
|
||||
Uint32 len, int volume);
|
||||
|
||||
/**
|
||||
* This works like SDL_MixAudio(), but you specify the audio format instead of
|
||||
* using the format of audio device 1. Thus it can be used when no audio
|
||||
* device is open at all.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
|
||||
const Uint8 * src,
|
||||
SDL_AudioFormat format,
|
||||
Uint32 len, int volume);
|
||||
|
||||
/**
|
||||
* \name Audio lock functions
|
||||
*
|
||||
* The lock manipulated by these functions protects the callback function.
|
||||
* During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
|
||||
* the callback function is not running. Do not call these from the callback
|
||||
* function or you will cause deadlock.
|
||||
*/
|
||||
/*@{*/
|
||||
extern DECLSPEC void SDLCALL SDL_LockAudio(void);
|
||||
extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
|
||||
/*@}*//*Audio lock functions*/
|
||||
|
||||
/**
|
||||
* This function shuts down audio processing and closes the audio device.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
|
||||
extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
|
||||
|
||||
/**
|
||||
* \return 1 if audio device is still functioning, zero if not, -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AudioDeviceConnected(SDL_AudioDeviceID dev);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_audio_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_blendmode.h
|
||||
*
|
||||
* Header file declaring the SDL_BlendMode enumeration
|
||||
*/
|
||||
|
||||
#ifndef _SDL_blendmode_h
|
||||
#define _SDL_blendmode_h
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */
|
||||
SDL_BLENDMODE_BLEND = 0x00000001, /**< dst = (src * A) + (dst * (1-A)) */
|
||||
SDL_BLENDMODE_ADD = 0x00000002, /**< dst = (src * A) + dst */
|
||||
SDL_BLENDMODE_MOD = 0x00000004 /**< dst = src * dst */
|
||||
} SDL_BlendMode;
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_video_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_clipboard.h
|
||||
*
|
||||
* Include file for SDL clipboard handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_clipboard_h
|
||||
#define _SDL_clipboard_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Put UTF-8 text into the clipboard
|
||||
*
|
||||
* \sa SDL_GetClipboardText()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
|
||||
|
||||
/**
|
||||
* \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
|
||||
*
|
||||
* \sa SDL_SetClipboardText()
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
|
||||
|
||||
/**
|
||||
* \brief Returns whether the clipboard has text
|
||||
*
|
||||
* \sa SDL_GetClipboardText()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_clipboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,366 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup Compatibility SDL 1.2 Compatibility API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* \file SDL_compat.h
|
||||
*
|
||||
* This file contains functions for backwards compatibility with SDL 1.2.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def SDL_NO_COMPAT
|
||||
*
|
||||
* #define SDL_NO_COMPAT to prevent SDL_compat.h from being included.
|
||||
* SDL_NO_COMPAT is intended to make it easier to covert SDL 1.2 code to
|
||||
* SDL 1.3/2.0.
|
||||
*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef SDL_NO_COMPAT
|
||||
#define _SDL_compat_h
|
||||
#endif
|
||||
|
||||
#ifndef _SDL_compat_h
|
||||
#define _SDL_compat_h
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup Compatibility
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/* Platform */
|
||||
#ifdef __WIN32__
|
||||
#undef __WIN32__
|
||||
#define __WIN32__ 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name Surface flags
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_SWSURFACE 0x00000000 /**< \note Not used */
|
||||
#define SDL_SRCALPHA 0x00010000
|
||||
#define SDL_SRCCOLORKEY 0x00020000
|
||||
#define SDL_ANYFORMAT 0x00100000
|
||||
#define SDL_HWPALETTE 0x00200000
|
||||
#define SDL_DOUBLEBUF 0x00400000
|
||||
#define SDL_FULLSCREEN 0x00800000
|
||||
#define SDL_RESIZABLE 0x01000000
|
||||
#define SDL_NOFRAME 0x02000000
|
||||
#define SDL_OPENGL 0x04000000
|
||||
#define SDL_HWSURFACE 0x08000001 /**< \note Not used */
|
||||
#define SDL_ASYNCBLIT 0x08000000 /**< \note Not used */
|
||||
#define SDL_RLEACCELOK 0x08000000 /**< \note Not used */
|
||||
#define SDL_HWACCEL 0x08000000 /**< \note Not used */
|
||||
/*@}*//*Surface flags*/
|
||||
|
||||
#define SDL_APPMOUSEFOCUS 0x01
|
||||
#define SDL_APPINPUTFOCUS 0x02
|
||||
#define SDL_APPACTIVE 0x04
|
||||
|
||||
#define SDL_LOGPAL 0x01
|
||||
#define SDL_PHYSPAL 0x02
|
||||
|
||||
#define SDL_ACTIVEEVENT SDL_EVENT_COMPAT1
|
||||
#define SDL_VIDEORESIZE SDL_EVENT_COMPAT2
|
||||
#define SDL_VIDEOEXPOSE SDL_EVENT_COMPAT3
|
||||
#define SDL_ACTIVEEVENTMASK SDL_ACTIVEEVENT, SDL_ACTIVEEVENT
|
||||
#define SDL_VIDEORESIZEMASK SDL_VIDEORESIZE, SDL_VIDEORESIZE
|
||||
#define SDL_VIDEOEXPOSEMASK SDL_VIDEOEXPOSE, SDL_VIDEOEXPOSE
|
||||
#define SDL_WINDOWEVENTMASK SDL_WINDOWEVENT, SDL_WINDOWEVENT
|
||||
#define SDL_KEYDOWNMASK SDL_KEYDOWN, SDL_KEYDOWN
|
||||
#define SDL_KEYUPMASK SDL_KEYUP, SDL_KEYUP
|
||||
#define SDL_KEYEVENTMASK SDL_KEYDOWN, SDL_KEYUP
|
||||
#define SDL_TEXTEDITINGMASK SDL_TEXTEDITING, SDL_TEXTEDITING
|
||||
#define SDL_TEXTINPUTMASK SDL_TEXTINPUT, SDL_TEXTINPUT
|
||||
#define SDL_MOUSEMOTIONMASK SDL_MOUSEMOTION, SDL_MOUSEMOTION
|
||||
#define SDL_MOUSEBUTTONDOWNMASK SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN
|
||||
#define SDL_MOUSEBUTTONUPMASK SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONUP
|
||||
#define SDL_MOUSEWHEELMASK SDL_MOUSEWHEEL, SDL_MOUSEWHEEL
|
||||
#define SDL_MOUSEEVENTMASK SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP
|
||||
#define SDL_JOYAXISMOTIONMASK SDL_JOYAXISMOTION, SDL_JOYAXISMOTION
|
||||
#define SDL_JOYBALLMOTIONMASK SDL_JOYBALLMOTION, SDL_JOYBALLMOTION
|
||||
#define SDL_JOYHATMOTIONMASK SDL_JOYHATMOTION, SDL_JOYHATMOTION
|
||||
#define SDL_JOYBUTTONDOWNMASK SDL_JOYBUTTONDOWN, SDL_JOYBUTTONDOWN
|
||||
#define SDL_JOYBUTTONUPMASK SDL_JOYBUTTONUP, SDL_JOYBUTTONUP
|
||||
#define SDL_JOYEVENTMASK SDL_JOYAXISMOTION, SDL_JOYBUTTONUP
|
||||
#define SDL_QUITMASK SDL_QUIT, SDL_QUIT
|
||||
#define SDL_SYSWMEVENTMASK SDL_SYSWMEVENT, SDL_SYSWMEVENT
|
||||
#define SDL_PROXIMITYINMASK SDL_PROXIMITYIN, SDL_PROXIMITYIN
|
||||
#define SDL_PROXIMITYOUTMASK SDL_PROXIMITYOUT, SDL_PROXIMITYOUT
|
||||
#define SDL_ALLEVENTS SDL_FIRSTEVENT, SDL_LASTEVENT
|
||||
|
||||
#define SDL_BUTTON_WHEELUP 4
|
||||
#define SDL_BUTTON_WHEELDOWN 5
|
||||
|
||||
#define SDL_DEFAULT_REPEAT_DELAY 500
|
||||
#define SDL_DEFAULT_REPEAT_INTERVAL 30
|
||||
|
||||
typedef struct SDL_VideoInfo
|
||||
{
|
||||
Uint32 hw_available:1;
|
||||
Uint32 wm_available:1;
|
||||
Uint32 UnusedBits1:6;
|
||||
Uint32 UnusedBits2:1;
|
||||
Uint32 blit_hw:1;
|
||||
Uint32 blit_hw_CC:1;
|
||||
Uint32 blit_hw_A:1;
|
||||
Uint32 blit_sw:1;
|
||||
Uint32 blit_sw_CC:1;
|
||||
Uint32 blit_sw_A:1;
|
||||
Uint32 blit_fill:1;
|
||||
Uint32 UnusedBits3:16;
|
||||
Uint32 video_mem;
|
||||
|
||||
SDL_PixelFormat *vfmt;
|
||||
|
||||
int current_w;
|
||||
int current_h;
|
||||
} SDL_VideoInfo;
|
||||
|
||||
/**
|
||||
* \name Overlay formats
|
||||
*
|
||||
* The most common video overlay formats.
|
||||
*
|
||||
* For an explanation of these pixel formats, see:
|
||||
* http://www.webartz.com/fourcc/indexyuv.htm
|
||||
*
|
||||
* For information on the relationship between color spaces, see:
|
||||
* http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */
|
||||
#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */
|
||||
#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
/*@}*//*Overlay formats*/
|
||||
|
||||
/**
|
||||
* The YUV hardware video overlay.
|
||||
*/
|
||||
typedef struct SDL_Overlay
|
||||
{
|
||||
Uint32 format; /**< Read-only */
|
||||
int w, h; /**< Read-only */
|
||||
int planes; /**< Read-only */
|
||||
Uint16 *pitches; /**< Read-only */
|
||||
Uint8 **pixels; /**< Read-write */
|
||||
|
||||
/**
|
||||
* \name Hardware-specific surface info
|
||||
*/
|
||||
/*@{*/
|
||||
struct private_yuvhwfuncs *hwfuncs;
|
||||
struct private_yuvhwdata *hwdata;
|
||||
/*@}*//*Hardware-specific surface info*/
|
||||
|
||||
/**
|
||||
* \name Special flags
|
||||
*/
|
||||
/*@{*/
|
||||
Uint32 hw_overlay:1; /**< Flag: This overlay hardware accelerated? */
|
||||
Uint32 UnusedBits:31;
|
||||
/*@}*//*Special flags*/
|
||||
} SDL_Overlay;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_GRAB_QUERY = -1,
|
||||
SDL_GRAB_OFF = 0,
|
||||
SDL_GRAB_ON = 1
|
||||
} SDL_GrabMode;
|
||||
|
||||
struct SDL_SysWMinfo;
|
||||
|
||||
/**
|
||||
* \name Obsolete or renamed key codes
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
#define SDL_keysym SDL_Keysym
|
||||
#define SDL_KeySym SDL_Keysym
|
||||
#define SDL_scancode SDL_Scancode
|
||||
#define SDL_ScanCode SDL_Scancode
|
||||
#define SDLKey SDL_Keycode
|
||||
#define SDLMod SDL_Keymod
|
||||
|
||||
/**
|
||||
* \name Renamed keys
|
||||
*
|
||||
* These key constants were renamed for clarity or consistency.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDLK_KP0 SDLK_KP_0
|
||||
#define SDLK_KP1 SDLK_KP_1
|
||||
#define SDLK_KP2 SDLK_KP_2
|
||||
#define SDLK_KP3 SDLK_KP_3
|
||||
#define SDLK_KP4 SDLK_KP_4
|
||||
#define SDLK_KP5 SDLK_KP_5
|
||||
#define SDLK_KP6 SDLK_KP_6
|
||||
#define SDLK_KP7 SDLK_KP_7
|
||||
#define SDLK_KP8 SDLK_KP_8
|
||||
#define SDLK_KP9 SDLK_KP_9
|
||||
#define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
|
||||
#define SDLK_SCROLLOCK SDLK_SCROLLLOCK
|
||||
#define SDLK_PRINT SDLK_PRINTSCREEN
|
||||
#define SDLK_LMETA SDLK_LGUI
|
||||
#define SDLK_RMETA SDLK_RGUI
|
||||
/*@}*//*Renamed keys*/
|
||||
|
||||
/**
|
||||
* \name META modifier
|
||||
*
|
||||
* The META modifier is equivalent to the GUI modifier from the USB standard.
|
||||
*/
|
||||
/*@{*/
|
||||
#define KMOD_LMETA KMOD_LGUI
|
||||
#define KMOD_RMETA KMOD_RGUI
|
||||
#define KMOD_META KMOD_GUI
|
||||
/*@}*//*META modifier*/
|
||||
|
||||
/**
|
||||
* \name Not in USB
|
||||
*
|
||||
* These keys don't appear in the USB specification (or at least not under
|
||||
* those names). I'm unsure if the following assignments make sense or if these
|
||||
* codes should be defined as actual additional SDLK_ constants.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDLK_LSUPER SDLK_LMETA
|
||||
#define SDLK_RSUPER SDLK_RMETA
|
||||
#define SDLK_COMPOSE SDLK_APPLICATION
|
||||
#define SDLK_BREAK SDLK_STOP
|
||||
#define SDLK_EURO SDLK_2
|
||||
/*@}*//*Not in USB*/
|
||||
|
||||
/*@}*//*Obsolete or renamed key codes*/
|
||||
|
||||
#define SDL_SetModuleHandle(x)
|
||||
#define SDL_AllocSurface SDL_CreateRGBSurface
|
||||
|
||||
extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
|
||||
extern DECLSPEC const char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
|
||||
extern DECLSPEC const char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
|
||||
extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
|
||||
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
|
||||
int height,
|
||||
int bpp, Uint32 flags);
|
||||
extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
|
||||
format, Uint32 flags);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
|
||||
int bpp, Uint32 flags);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
|
||||
extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
|
||||
int numrects, SDL_Rect * rects);
|
||||
extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
|
||||
Sint32 x,
|
||||
Sint32 y, Uint32 w, Uint32 h);
|
||||
extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
|
||||
extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
|
||||
Uint32 flag, Uint8 alpha);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
|
||||
surface);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
|
||||
const char *icon);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
|
||||
const char **icon);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
|
||||
extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
|
||||
extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
|
||||
extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
|
||||
extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
|
||||
int flags,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
|
||||
extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
|
||||
int height,
|
||||
Uint32 format,
|
||||
SDL_Surface *
|
||||
display);
|
||||
extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
|
||||
extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
|
||||
SDL_Rect * dstrect);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
|
||||
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
|
||||
extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
|
||||
extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red,
|
||||
const Uint16 * green,
|
||||
const Uint16 * blue);
|
||||
extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
|
||||
Uint16 * blue);
|
||||
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
|
||||
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
|
||||
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
|
||||
|
||||
typedef SDL_Window* SDL_WindowID;
|
||||
|
||||
#define SDL_KillThread(X)
|
||||
|
||||
/* The timeslice and timer resolution are no longer relevant */
|
||||
#define SDL_TIMESLICE 10
|
||||
#define TIMER_RESOLUTION 10
|
||||
|
||||
typedef Uint32 (SDLCALL * SDL_OldTimerCallback) (Uint32 interval);
|
||||
extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback);
|
||||
|
||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||
|
||||
/*@}*//*Compatibility*/
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_compat_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/**
|
||||
* \file SDL_config.h
|
||||
*
|
||||
* SDL_config.h for any platform that doesn't build using the configure system.
|
||||
*/
|
||||
|
||||
/* Add any platform that doesn't build using the configure system. */
|
||||
#if defined(__WIN32__)
|
||||
#include "SDL_config_windows.h"
|
||||
#elif defined(__MACOSX__)
|
||||
#include "SDL_config_macosx.h"
|
||||
#elif defined(__IPHONEOS__)
|
||||
#include "SDL_config_iphoneos.h"
|
||||
#elif defined(__ANDROID__)
|
||||
#include "SDL_config_android.h"
|
||||
#elif defined(__NINTENDODS__)
|
||||
#include "SDL_config_nintendods.h"
|
||||
#else
|
||||
#include "SDL_config_minimal.h"
|
||||
#endif /* platform config */
|
||||
|
||||
#endif /* _SDL_config_h */
|
|
@ -1,309 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
/**
|
||||
* \file SDL_config.h.in
|
||||
*
|
||||
* This is a set of defines to configure the SDL features
|
||||
*/
|
||||
|
||||
/* General platform specific identifiers */
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* Make sure that this isn't included by Visual C++ */
|
||||
#ifdef _MSC_VER
|
||||
#error You should run hg revert SDL_config.h
|
||||
#endif
|
||||
|
||||
/* C language features */
|
||||
#undef const
|
||||
#undef inline
|
||||
#undef volatile
|
||||
|
||||
/* C datatypes */
|
||||
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
|
||||
#undef size_t
|
||||
#undef int8_t
|
||||
#undef uint8_t
|
||||
#undef int16_t
|
||||
#undef uint16_t
|
||||
#undef int32_t
|
||||
#undef uint32_t
|
||||
#undef int64_t
|
||||
#undef uint64_t
|
||||
#undef uintptr_t
|
||||
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
||||
|
||||
#undef SIZEOF_VOIDP
|
||||
#undef SDL_HAS_64BIT_TYPE
|
||||
#undef HAVE_GCC_ATOMICS
|
||||
#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||
|
||||
/* Comment this if you want to build without any C library requirements */
|
||||
#undef HAVE_LIBC
|
||||
#if HAVE_LIBC
|
||||
|
||||
/* Useful headers */
|
||||
#undef HAVE_ALLOCA_H
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
#undef HAVE_STDIO_H
|
||||
#undef STDC_HEADERS
|
||||
#undef HAVE_STDLIB_H
|
||||
#undef HAVE_STDARG_H
|
||||
#undef HAVE_MALLOC_H
|
||||
#undef HAVE_MEMORY_H
|
||||
#undef HAVE_STRING_H
|
||||
#undef HAVE_STRINGS_H
|
||||
#undef HAVE_INTTYPES_H
|
||||
#undef HAVE_STDINT_H
|
||||
#undef HAVE_CTYPE_H
|
||||
#undef HAVE_MATH_H
|
||||
#undef HAVE_ICONV_H
|
||||
#undef HAVE_SIGNAL_H
|
||||
#undef HAVE_ALTIVEC_H
|
||||
|
||||
/* C library functions */
|
||||
#undef HAVE_MALLOC
|
||||
#undef HAVE_CALLOC
|
||||
#undef HAVE_REALLOC
|
||||
#undef HAVE_FREE
|
||||
#undef HAVE_ALLOCA
|
||||
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
|
||||
#undef HAVE_GETENV
|
||||
#undef HAVE_SETENV
|
||||
#undef HAVE_PUTENV
|
||||
#undef HAVE_UNSETENV
|
||||
#endif
|
||||
#undef HAVE_QSORT
|
||||
#undef HAVE_ABS
|
||||
#undef HAVE_BCOPY
|
||||
#undef HAVE_MEMSET
|
||||
#undef HAVE_MEMCPY
|
||||
#undef HAVE_MEMMOVE
|
||||
#undef HAVE_MEMCMP
|
||||
#undef HAVE_STRLEN
|
||||
#undef HAVE_STRLCPY
|
||||
#undef HAVE_STRLCAT
|
||||
#undef HAVE_STRDUP
|
||||
#undef HAVE__STRREV
|
||||
#undef HAVE__STRUPR
|
||||
#undef HAVE__STRLWR
|
||||
#undef HAVE_INDEX
|
||||
#undef HAVE_RINDEX
|
||||
#undef HAVE_STRCHR
|
||||
#undef HAVE_STRRCHR
|
||||
#undef HAVE_STRSTR
|
||||
#undef HAVE_ITOA
|
||||
#undef HAVE__LTOA
|
||||
#undef HAVE__UITOA
|
||||
#undef HAVE__ULTOA
|
||||
#undef HAVE_STRTOL
|
||||
#undef HAVE_STRTOUL
|
||||
#undef HAVE__I64TOA
|
||||
#undef HAVE__UI64TOA
|
||||
#undef HAVE_STRTOLL
|
||||
#undef HAVE_STRTOULL
|
||||
#undef HAVE_STRTOD
|
||||
#undef HAVE_ATOI
|
||||
#undef HAVE_ATOF
|
||||
#undef HAVE_STRCMP
|
||||
#undef HAVE_STRNCMP
|
||||
#undef HAVE__STRICMP
|
||||
#undef HAVE_STRCASECMP
|
||||
#undef HAVE__STRNICMP
|
||||
#undef HAVE_STRNCASECMP
|
||||
#undef HAVE_SSCANF
|
||||
#undef HAVE_SNPRINTF
|
||||
#undef HAVE_VSNPRINTF
|
||||
#undef HAVE_M_PI
|
||||
#undef HAVE_ATAN
|
||||
#undef HAVE_ATAN2
|
||||
#undef HAVE_CEIL
|
||||
#undef HAVE_COPYSIGN
|
||||
#undef HAVE_COS
|
||||
#undef HAVE_COSF
|
||||
#undef HAVE_FABS
|
||||
#undef HAVE_FLOOR
|
||||
#undef HAVE_LOG
|
||||
#undef HAVE_POW
|
||||
#undef HAVE_SCALBN
|
||||
#undef HAVE_SIN
|
||||
#undef HAVE_SINF
|
||||
#undef HAVE_SQRT
|
||||
#undef HAVE_SIGACTION
|
||||
#undef HAVE_SETJMP
|
||||
#undef HAVE_NANOSLEEP
|
||||
#undef HAVE_SYSCONF
|
||||
#undef HAVE_SYSCTLBYNAME
|
||||
#undef HAVE_CLOCK_GETTIME
|
||||
#undef HAVE_GETPAGESIZE
|
||||
#undef HAVE_MPROTECT
|
||||
#undef HAVE_ICONV
|
||||
|
||||
#else
|
||||
/* We may need some replacement for stdarg.h here */
|
||||
#include <stdarg.h>
|
||||
#endif /* HAVE_LIBC */
|
||||
|
||||
/* SDL internal assertion support */
|
||||
#undef SDL_DEFAULT_ASSERT_LEVEL
|
||||
|
||||
/* Allow disabling of core subsystems */
|
||||
#undef SDL_ATOMIC_DISABLED
|
||||
#undef SDL_AUDIO_DISABLED
|
||||
#undef SDL_CPUINFO_DISABLED
|
||||
#undef SDL_EVENTS_DISABLED
|
||||
#undef SDL_FILE_DISABLED
|
||||
#undef SDL_JOYSTICK_DISABLED
|
||||
#undef SDL_HAPTIC_DISABLED
|
||||
#undef SDL_LOADSO_DISABLED
|
||||
#undef SDL_RENDER_DISABLED
|
||||
#undef SDL_THREADS_DISABLED
|
||||
#undef SDL_TIMERS_DISABLED
|
||||
#undef SDL_VIDEO_DISABLED
|
||||
#undef SDL_POWER_DISABLED
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#undef SDL_AUDIO_DRIVER_ALSA
|
||||
#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_ARTS
|
||||
#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_PULSEAUDIO
|
||||
#undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_BEOSAUDIO
|
||||
#undef SDL_AUDIO_DRIVER_BSD
|
||||
#undef SDL_AUDIO_DRIVER_COREAUDIO
|
||||
#undef SDL_AUDIO_DRIVER_DISK
|
||||
#undef SDL_AUDIO_DRIVER_DUMMY
|
||||
#undef SDL_AUDIO_DRIVER_DSOUND
|
||||
#undef SDL_AUDIO_DRIVER_ESD
|
||||
#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_NAS
|
||||
#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_NDS
|
||||
#undef SDL_AUDIO_DRIVER_OSS
|
||||
#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
|
||||
#undef SDL_AUDIO_DRIVER_PAUDIO
|
||||
#undef SDL_AUDIO_DRIVER_QSA
|
||||
#undef SDL_AUDIO_DRIVER_SUNAUDIO
|
||||
#undef SDL_AUDIO_DRIVER_WINWAVEOUT
|
||||
#undef SDL_AUDIO_DRIVER_FUSIONSOUND
|
||||
#undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC
|
||||
|
||||
/* Enable various input drivers */
|
||||
#undef SDL_INPUT_LINUXEV
|
||||
#undef SDL_INPUT_TSLIB
|
||||
#undef SDL_JOYSTICK_BEOS
|
||||
#undef SDL_JOYSTICK_DINPUT
|
||||
#undef SDL_JOYSTICK_DUMMY
|
||||
#undef SDL_JOYSTICK_IOKIT
|
||||
#undef SDL_JOYSTICK_LINUX
|
||||
#undef SDL_JOYSTICK_NDS
|
||||
#undef SDL_JOYSTICK_WINMM
|
||||
#undef SDL_JOYSTICK_USBHID
|
||||
#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
|
||||
#undef SDL_HAPTIC_DUMMY
|
||||
#undef SDL_HAPTIC_LINUX
|
||||
#undef SDL_HAPTIC_IOKIT
|
||||
#undef SDL_HAPTIC_DINPUT
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#undef SDL_LOADSO_BEOS
|
||||
#undef SDL_LOADSO_DLCOMPAT
|
||||
#undef SDL_LOADSO_DLOPEN
|
||||
#undef SDL_LOADSO_DUMMY
|
||||
#undef SDL_LOADSO_LDG
|
||||
#undef SDL_LOADSO_WINDOWS
|
||||
|
||||
/* Enable various threading systems */
|
||||
#undef SDL_THREAD_BEOS
|
||||
#undef SDL_THREAD_NDS
|
||||
#undef SDL_THREAD_PTHREAD
|
||||
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
|
||||
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
|
||||
#undef SDL_THREAD_SPROC
|
||||
#undef SDL_THREAD_WINDOWS
|
||||
|
||||
/* Enable various timer systems */
|
||||
#undef SDL_TIMER_BEOS
|
||||
#undef SDL_TIMER_DUMMY
|
||||
#undef SDL_TIMER_NDS
|
||||
#undef SDL_TIMER_UNIX
|
||||
#undef SDL_TIMER_WINDOWS
|
||||
#undef SDL_TIMER_WINCE
|
||||
|
||||
/* Enable various video drivers */
|
||||
#undef SDL_VIDEO_DRIVER_BWINDOW
|
||||
#undef SDL_VIDEO_DRIVER_COCOA
|
||||
#undef SDL_VIDEO_DRIVER_DIRECTFB
|
||||
#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
|
||||
#undef SDL_VIDEO_DRIVER_DUMMY
|
||||
#undef SDL_VIDEO_DRIVER_NDS
|
||||
#undef SDL_VIDEO_DRIVER_WINDOWS
|
||||
#undef SDL_VIDEO_DRIVER_X11
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE
|
||||
#undef SDL_VIDEO_DRIVER_X11_XCURSOR
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINPUT
|
||||
#undef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
#undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER
|
||||
#undef SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
#undef SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
|
||||
#undef SDL_VIDEO_RENDER_D3D
|
||||
#undef SDL_VIDEO_RENDER_OGL
|
||||
#undef SDL_VIDEO_RENDER_OGL_ES
|
||||
#undef SDL_VIDEO_RENDER_DIRECTFB
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#undef SDL_VIDEO_OPENGL
|
||||
#undef SDL_VIDEO_OPENGL_ES
|
||||
#undef SDL_VIDEO_OPENGL_BGL
|
||||
#undef SDL_VIDEO_OPENGL_CGL
|
||||
#undef SDL_VIDEO_OPENGL_GLX
|
||||
#undef SDL_VIDEO_OPENGL_WGL
|
||||
#undef SDL_VIDEO_OPENGL_OSMESA
|
||||
#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
|
||||
|
||||
/* Enable system power support */
|
||||
#undef SDL_POWER_LINUX
|
||||
#undef SDL_POWER_WINDOWS
|
||||
#undef SDL_POWER_MACOSX
|
||||
#undef SDL_POWER_BEOS
|
||||
#undef SDL_POWER_NINTENDODS
|
||||
#undef SDL_POWER_HARDWIRED
|
||||
|
||||
/* Enable assembly routines */
|
||||
#undef SDL_ASSEMBLY_ROUTINES
|
||||
#undef SDL_ALTIVEC_BLITTERS
|
||||
|
||||
#endif /* _SDL_config_h */
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_android_h
|
||||
#define _SDL_config_android_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/**
|
||||
* \file SDL_config_android.h
|
||||
*
|
||||
* This is a configuration that can be used to build SDL for Android
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/*
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
*/
|
||||
|
||||
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRLCPY 1
|
||||
#define HAVE_STRLCAT 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_M_PI 1
|
||||
#define HAVE_ATAN 1
|
||||
#define HAVE_ATAN2 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FLOOR 1
|
||||
#define HAVE_LOG 1
|
||||
#define HAVE_POW 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SIN 1
|
||||
#define HAVE_SINF 1
|
||||
#define HAVE_SQRT 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
#define SIZEOF_VOIDP 4
|
||||
|
||||
typedef unsigned int size_t;
|
||||
//typedef unsigned long uintptr_t;
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_ANDROID 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_ANDROID 1
|
||||
#define SDL_HAPTIC_DUMMY 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_DLOPEN 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_PTHREAD 1
|
||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_UNIX 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_ANDROID 1
|
||||
|
||||
/* Enable OpenGL ES */
|
||||
#define SDL_VIDEO_OPENGL_ES 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES2 0
|
||||
//#define SDL_VIDEO_RENDER_OGL_ES2 1
|
||||
|
||||
#endif /* _SDL_config_minimal_h */
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_iphoneos_h
|
||||
#define _SDL_config_iphoneos_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
||||
|
||||
#ifdef __LP64__
|
||||
#define SIZEOF_VOIDP 8
|
||||
#else
|
||||
#define SIZEOF_VOIDP 4
|
||||
#endif
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
#define HAVE_GCC_ATOMICS 1
|
||||
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRLCPY 1
|
||||
#define HAVE_STRLCAT 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_M_PI 1
|
||||
#define HAVE_ATAN 1
|
||||
#define HAVE_ATAN2 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FLOOR 1
|
||||
#define HAVE_LOG 1
|
||||
#define HAVE_POW 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SIN 1
|
||||
#define HAVE_SINF 1
|
||||
#define HAVE_SQRT 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_SYSCTLBYNAME 1
|
||||
|
||||
/* enable iPhone version of Core Audio driver */
|
||||
#define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1
|
||||
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
|
||||
#define SDL_HAPTIC_DISABLED 1
|
||||
|
||||
/* Enable Unix style SO loading */
|
||||
/* Technically this works, but it violates the iPhone developer agreement */
|
||||
/* #define SDL_LOADSO_DLOPEN 1 */
|
||||
|
||||
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
|
||||
#define SDL_LOADSO_DISABLED 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_PTHREAD 1
|
||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_UNIX 1
|
||||
|
||||
/* Supported video drivers */
|
||||
#define SDL_VIDEO_DRIVER_UIKIT 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
|
||||
/* enable OpenGL ES */
|
||||
#define SDL_VIDEO_OPENGL_ES 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES2 1
|
||||
|
||||
/* Enable system power support */
|
||||
#define SDL_POWER_UIKIT 1
|
||||
|
||||
/* enable iPhone keyboard support */
|
||||
#define SDL_IPHONE_KEYBOARD 1
|
||||
|
||||
/* Set max recognized G-force from accelerometer
|
||||
See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed
|
||||
*/
|
||||
#define SDL_IPHONE_MAX_GFORCE 5.0
|
||||
|
||||
#endif /* _SDL_config_iphoneos_h */
|
|
@ -1,175 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_macosx_h
|
||||
#define _SDL_config_macosx_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#ifdef __LP64__
|
||||
#define SIZEOF_VOIDP 8
|
||||
#else
|
||||
#define SIZEOF_VOIDP 4
|
||||
#endif
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */
|
||||
#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) )
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#endif
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRLCPY 1
|
||||
#define HAVE_STRLCAT 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FLOOR 1
|
||||
#define HAVE_LOG 1
|
||||
#define HAVE_POW 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SIN 1
|
||||
#define HAVE_SINF 1
|
||||
#define HAVE_SQRT 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_SYSCTLBYNAME 1
|
||||
#define HAVE_ATAN 1
|
||||
#define HAVE_ATAN2 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_IOKIT 1
|
||||
#define SDL_HAPTIC_IOKIT 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_DLOPEN 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_PTHREAD 1
|
||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_UNIX 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_COCOA 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_X11 1
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT "/usr/X11R6/lib/libXi.6.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
|
||||
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XINPUT 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XRANDR 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
|
||||
|
||||
#ifndef SDL_VIDEO_RENDER_OGL
|
||||
#define SDL_VIDEO_RENDER_OGL 1
|
||||
#endif
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#ifndef SDL_VIDEO_OPENGL
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_OPENGL_CGL
|
||||
#define SDL_VIDEO_OPENGL_CGL 1
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_OPENGL_GLX
|
||||
#define SDL_VIDEO_OPENGL_GLX 1
|
||||
#endif
|
||||
|
||||
/* Enable system power support */
|
||||
#define SDL_POWER_MACOSX 1
|
||||
|
||||
/* Enable assembly routines */
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
#ifdef __ppc__
|
||||
#define SDL_ALTIVEC_BLITTERS 1
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_config_macosx_h */
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_minimal_h
|
||||
#define _SDL_config_minimal_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/**
|
||||
* \file SDL_config_minimal.h
|
||||
*
|
||||
* This is the minimal configuration that can be used to build SDL.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
|
||||
typedef unsigned int size_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE
|
||||
#ifdef __GNUC__
|
||||
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
|
||||
#endif
|
||||
|
||||
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
|
||||
#define SDL_JOYSTICK_DISABLED 1
|
||||
|
||||
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
|
||||
#define SDL_HAPTIC_DISABLED 1
|
||||
|
||||
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
|
||||
#define SDL_LOADSO_DISABLED 1
|
||||
|
||||
/* Enable the stub thread support (src/thread/generic/\*.c) */
|
||||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
/* Enable the stub timer support (src/timer/dummy/\*.c) */
|
||||
#define SDL_TIMERS_DISABLED 1
|
||||
|
||||
/* Enable the dummy video driver (src/video/dummy/\*.c) */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
|
||||
#endif /* _SDL_config_minimal_h */
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_nintendods_h
|
||||
#define _SDL_config_nintendods_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
/* LiF: __PTRDIFF_TYPE__ was causing errors of conflicting typedefs with the
|
||||
<stdint.h> shipping with devkitARM. copied a similar ifdef from it. */
|
||||
#ifndef __PTRDIFF_TYPE__
|
||||
typedef unsigned long uintptr_t;
|
||||
#else
|
||||
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
|
||||
#endif
|
||||
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
||||
|
||||
#define SIZEOF_VOIDP 4
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_INDEX 1
|
||||
#define HAVE_RINDEX 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRICMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* DS isn't that sophisticated */
|
||||
#define LACKS_SYS_MMAN_H 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_NDS 1
|
||||
/*#define SDL_AUDIO_DRIVER_DUMMY 1 TODO: uncomment this later*/
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_NDS 1
|
||||
/*#define SDL_JOYSTICK_DUMMY 1 TODO: uncomment this later*/
|
||||
|
||||
/* DS has no dynamic linking afaik */
|
||||
#define SDL_LOADSO_DISABLED 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
/*#define SDL_THREAD_NDS 1*/
|
||||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_NDS 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_NDS 1
|
||||
#ifdef USE_HW_RENDERER
|
||||
#define SDL_VIDEO_RENDER_NDS 1
|
||||
#else
|
||||
#define SDL_VIDEO_RENDER_NDS 0
|
||||
#endif
|
||||
|
||||
/* Enable system power support */
|
||||
#define SDL_POWER_NINTENDODS 1
|
||||
|
||||
/* Enable haptic support */
|
||||
#define SDL_HAPTIC_NDS 1
|
||||
|
||||
#define SDL_BYTEORDER SDL_LIL_ENDIAN
|
||||
|
||||
#endif /* _SDL_config_nintendods_h */
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
/* General platform specific identifiers */
|
||||
#include "SDL_platform.h"
|
||||
|
||||
#ifdef __LP64__
|
||||
#define SIZEOF_VOIDP 8
|
||||
#else
|
||||
#define SIZEOF_VOIDP 4
|
||||
#endif
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
#define SDL_BYTEORDER 1234
|
||||
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_MALLOC_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_ICONV_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_M_PI 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FLOOR 1
|
||||
#define HAVE_LOG 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SIN 1
|
||||
#define HAVE_SINF 1
|
||||
#define HAVE_SQRT 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
#define SDL_AUDIO_DRIVER_OSS 1
|
||||
|
||||
#define SDL_INPUT_LINUXEV 1
|
||||
#define SDL_INPUT_TSLIB 1
|
||||
#define SDL_JOYSTICK_LINUX 1
|
||||
#define SDL_HAPTIC_LINUX 1
|
||||
|
||||
#define SDL_LOADSO_DLOPEN 1
|
||||
|
||||
#define SDL_THREAD_PTHREAD 1
|
||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
|
||||
|
||||
#define SDL_TIMER_UNIX 1
|
||||
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_X11 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XINPUT 1
|
||||
#define SDL_VIDEO_DRIVER_PANDORA 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
||||
#define SDL_VIDEO_OPENGL_ES 1
|
||||
|
||||
#endif /* _SDL_config_h */
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_windows_h
|
||||
#define _SDL_config_windows_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
|
||||
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
|
||||
#define HAVE_STDINT_H 1
|
||||
#elif defined(_MSC_VER)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#ifndef _UINTPTR_T_DEFINED
|
||||
#ifdef _WIN64
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
#define _UINTPTR_T_DEFINED
|
||||
#endif
|
||||
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
|
||||
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
|
||||
#define DWORD_PTR DWORD
|
||||
#endif
|
||||
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
|
||||
#define LONG_PTR LONG
|
||||
#endif
|
||||
#else /* !__GNUC__ && !_MSC_VER */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#ifndef _SIZE_T_DEFINED_
|
||||
#define _SIZE_T_DEFINED_
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif /* __GNUC__ || _MSC_VER */
|
||||
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
||||
|
||||
#ifdef _WIN64
|
||||
# define SIZEOF_VOIDP 8
|
||||
#else
|
||||
# define SIZEOF_VOIDP 4
|
||||
#endif
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Enabled for SDL 1.2 (binary compatibility) */
|
||||
//#define HAVE_LIBC 1
|
||||
#ifdef HAVE_LIBC
|
||||
/* Useful headers */
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#ifndef _WIN32_WCE
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#endif
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE__STRREV 1
|
||||
#define HAVE__STRUPR 1
|
||||
#define HAVE__STRLWR 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_ITOA 1
|
||||
#define HAVE__LTOA 1
|
||||
#define HAVE__ULTOA 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE__STRICMP 1
|
||||
#define HAVE__STRNICMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_M_PI 1
|
||||
#define HAVE_ATAN 1
|
||||
#define HAVE_ATAN2 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FLOOR 1
|
||||
#define HAVE_LOG 1
|
||||
#define HAVE_POW 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SIN 1
|
||||
#define HAVE_SINF 1
|
||||
#define HAVE_SQRT 1
|
||||
#else
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDDEF_H 1
|
||||
#endif
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#ifndef _WIN32_WCE
|
||||
#define SDL_AUDIO_DRIVER_DSOUND 1
|
||||
#endif
|
||||
#define SDL_AUDIO_DRIVER_WINWAVEOUT 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_JOYSTICK_DISABLED 1
|
||||
#define SDL_HAPTIC_DUMMY 1
|
||||
#else
|
||||
#define SDL_JOYSTICK_DINPUT 1
|
||||
#define SDL_HAPTIC_DINPUT 1
|
||||
#endif
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_WINDOWS 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_WINDOWS 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_TIMER_WINCE 1
|
||||
#else
|
||||
#define SDL_TIMER_WINDOWS 1
|
||||
#endif
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_WINDOWS 1
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#ifndef SDL_VIDEO_RENDER_D3D
|
||||
#define SDL_VIDEO_RENDER_D3D 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#ifndef _WIN32_WCE
|
||||
#ifndef SDL_VIDEO_OPENGL
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_OPENGL_WGL
|
||||
#define SDL_VIDEO_OPENGL_WGL 1
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_RENDER_OGL
|
||||
#define SDL_VIDEO_RENDER_OGL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Enable system power support */
|
||||
#define SDL_POWER_WINDOWS 1
|
||||
|
||||
/* Enable assembly routines (Win64 doesn't have inline asm) */
|
||||
#ifndef _WIN64
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_config_windows_h */
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
/* General platform specific identifiers */
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* Make sure that this isn't included by Visual C++ */
|
||||
#ifdef _MSC_VER
|
||||
#error You should copy include/SDL_config.h.default to include/SDL_config.h
|
||||
#endif
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
#define SDL_BYTEORDER 1234
|
||||
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_MALLOC_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_ICONV_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_M_PI 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FLOOR 1
|
||||
#define HAVE_LOG 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SIN 1
|
||||
#define HAVE_SINF 1
|
||||
#define HAVE_SQRT 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SETJMP 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_POW 1
|
||||
|
||||
#define SDL_CDROM_DISABLED 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
#define SDL_AUDIO_DRIVER_OSS 1
|
||||
|
||||
#define SDL_INPUT_LINUXEV 1
|
||||
#define SDL_INPUT_TSLIB 1
|
||||
#define SDL_JOYSTICK_LINUX 1
|
||||
#define SDL_HAPTIC_LINUX 1
|
||||
|
||||
#define SDL_LOADSO_DLOPEN 1
|
||||
|
||||
#define SDL_THREAD_PTHREAD 1
|
||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
|
||||
|
||||
#define SDL_TIMER_UNIX 1
|
||||
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_PANDORA 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
||||
#define SDL_VIDEO_OPENGL_ES 1
|
||||
|
||||
#endif /* _SDL_config_h */
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_cpuinfo.h
|
||||
*
|
||||
* CPU feature detection for SDL.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_cpuinfo_h
|
||||
#define _SDL_cpuinfo_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/* Need to do this here because intrin.h has C++ code in it */
|
||||
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)
|
||||
#include <intrin.h>
|
||||
#ifndef _WIN64
|
||||
#define __MMX__
|
||||
#define __3dNOW__
|
||||
#endif
|
||||
#define __SSE__
|
||||
#define __SSE2__
|
||||
#elif defined(__MINGW64_VERSION_MAJOR)
|
||||
#include <intrin.h>
|
||||
#else
|
||||
#ifdef __ALTIVEC__
|
||||
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
|
||||
#include <altivec.h>
|
||||
#undef pixel
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __MMX__
|
||||
#include <mmintrin.h>
|
||||
#endif
|
||||
#ifdef __3dNOW__
|
||||
#include <mm3dnow.h>
|
||||
#endif
|
||||
#ifdef __SSE__
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
#ifdef __SSE2__
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* This is a guess for the cacheline size used for padding.
|
||||
* Most x86 processors have a 64 byte cache line.
|
||||
* The 64-bit PowerPC processors have a 128 byte cache line.
|
||||
* We'll use the larger value to be generally safe.
|
||||
*/
|
||||
#define SDL_CACHELINE_SIZE 128
|
||||
|
||||
/**
|
||||
* This function returns the number of CPU cores available.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
|
||||
|
||||
/**
|
||||
* This function returns the L1 cache line size of the CPU
|
||||
*
|
||||
* This is useful for determining multi-threaded structure padding
|
||||
* or SIMD prefetch sizes.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has the RDTSC instruction.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has AltiVec features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has MMX features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has 3DNow! features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE2 features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE3 features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE4.1 features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE4.2 features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_cpuinfo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,258 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_endian.h
|
||||
*
|
||||
* Functions for reading and writing endian-specific values
|
||||
*/
|
||||
|
||||
#ifndef _SDL_endian_h
|
||||
#define _SDL_endian_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/**
|
||||
* \name The two types of endianness
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_LIL_ENDIAN 1234
|
||||
#define SDL_BIG_ENDIAN 4321
|
||||
/*@}*/
|
||||
|
||||
#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
|
||||
#ifdef __linux__
|
||||
#include <endian.h>
|
||||
#define SDL_BYTEORDER __BYTE_ORDER
|
||||
#else /* __linux __ */
|
||||
#if defined(__hppa__) || \
|
||||
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
|
||||
(defined(__MIPS__) && defined(__MISPEB__)) || \
|
||||
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
|
||||
defined(__sparc__)
|
||||
#define SDL_BYTEORDER SDL_BIG_ENDIAN
|
||||
#else
|
||||
#define SDL_BYTEORDER SDL_LIL_ENDIAN
|
||||
#endif
|
||||
#endif /* __linux __ */
|
||||
#endif /* !SDL_BYTEORDER */
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \file SDL_endian.h
|
||||
*
|
||||
* Uses inline functions for compilers that support them, and static
|
||||
* functions for those that do not. Because these functions become
|
||||
* static for compilers that do not support inline functions, this
|
||||
* header should only be included in files that actually use them.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__i386__) && \
|
||||
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
Uint16 result;
|
||||
|
||||
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
|
||||
return result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswap %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswapl %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
Uint32 result;
|
||||
|
||||
__asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x));
|
||||
__asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x));
|
||||
__asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x));
|
||||
return result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
|
||||
((x >> 8) & 0x0000FF00) | (x >> 24)));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
static __inline__ Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Uint32 a, b;
|
||||
} s;
|
||||
Uint64 u;
|
||||
} v;
|
||||
v.u = x;
|
||||
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a),
|
||||
"1"(v.s.
|
||||
b));
|
||||
return v.u;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
__asm__("bswapq %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
Uint32 hi, lo;
|
||||
|
||||
/* Separate into high and low 32-bit values and swap them */
|
||||
lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
|
||||
x >>= 32;
|
||||
hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
|
||||
x = SDL_Swap32(lo);
|
||||
x <<= 32;
|
||||
x |= SDL_Swap32(hi);
|
||||
return (x);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
/**
|
||||
* This is mainly to keep compilers from complaining in SDL code.
|
||||
* If there is no real 64-bit datatype, then compilers will complain about
|
||||
* the fake 64-bit datatype that SDL provides when it compiles user code.
|
||||
*/
|
||||
#define SDL_Swap64(X) (X)
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
||||
|
||||
static __inline__ float
|
||||
SDL_SwapFloat(float x)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
Uint32 ui32;
|
||||
} swapper;
|
||||
swapper.f = x;
|
||||
swapper.ui32 = SDL_Swap32(swapper.ui32);
|
||||
return swapper.f;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \name Swap to native
|
||||
* Byteswap item from the specified endianness to the native endianness.
|
||||
*/
|
||||
/*@{*/
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define SDL_SwapLE16(X) (X)
|
||||
#define SDL_SwapLE32(X) (X)
|
||||
#define SDL_SwapLE64(X) (X)
|
||||
#define SDL_SwapFloatLE(X) (X)
|
||||
#define SDL_SwapBE16(X) SDL_Swap16(X)
|
||||
#define SDL_SwapBE32(X) SDL_Swap32(X)
|
||||
#define SDL_SwapBE64(X) SDL_Swap64(X)
|
||||
#define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
|
||||
#else
|
||||
#define SDL_SwapLE16(X) SDL_Swap16(X)
|
||||
#define SDL_SwapLE32(X) SDL_Swap32(X)
|
||||
#define SDL_SwapLE64(X) SDL_Swap64(X)
|
||||
#define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
|
||||
#define SDL_SwapBE16(X) (X)
|
||||
#define SDL_SwapBE32(X) (X)
|
||||
#define SDL_SwapBE64(X) (X)
|
||||
#define SDL_SwapFloatBE(X) (X)
|
||||
#endif
|
||||
/*@}*//*Swap to native*/
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_endian_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_error.h
|
||||
*
|
||||
* Simple error message routines for SDL.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_error_h
|
||||
#define _SDL_error_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Public functions */
|
||||
extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetError(void);
|
||||
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
||||
|
||||
/**
|
||||
* \name Internal error functions
|
||||
*
|
||||
* \internal
|
||||
* Private error reporting function - used internally.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
|
||||
#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
|
||||
typedef enum
|
||||
{
|
||||
SDL_ENOMEM,
|
||||
SDL_EFREAD,
|
||||
SDL_EFWRITE,
|
||||
SDL_EFSEEK,
|
||||
SDL_UNSUPPORTED,
|
||||
SDL_LASTERROR
|
||||
} SDL_errorcode;
|
||||
extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
|
||||
/*@}*//*Internal error functions*/
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_error_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,640 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_events.h
|
||||
*
|
||||
* Include file for SDL event handling.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_events_h
|
||||
#define _SDL_events_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_keyboard.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_quit.h"
|
||||
#include "SDL_gesture.h"
|
||||
#include "SDL_touch.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* General keyboard/mouse state definitions */
|
||||
#define SDL_RELEASED 0
|
||||
#define SDL_PRESSED 1
|
||||
|
||||
/**
|
||||
* \brief The types of events that can be delivered.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
|
||||
|
||||
/* Application events */
|
||||
SDL_QUIT = 0x100, /**< User-requested quit */
|
||||
|
||||
/* Window events */
|
||||
SDL_WINDOWEVENT = 0x200, /**< Window state change */
|
||||
SDL_SYSWMEVENT, /**< System specific event */
|
||||
|
||||
/* Keyboard events */
|
||||
SDL_KEYDOWN = 0x300, /**< Key pressed */
|
||||
SDL_KEYUP, /**< Key released */
|
||||
SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
|
||||
SDL_TEXTINPUT, /**< Keyboard text input */
|
||||
|
||||
/* Mouse events */
|
||||
SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
|
||||
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
|
||||
SDL_MOUSEBUTTONUP, /**< Mouse button released */
|
||||
SDL_MOUSEWHEEL, /**< Mouse wheel motion */
|
||||
|
||||
/* Tablet or multiple mice input device events */
|
||||
SDL_INPUTMOTION = 0x500, /**< Input moved */
|
||||
SDL_INPUTBUTTONDOWN, /**< Input button pressed */
|
||||
SDL_INPUTBUTTONUP, /**< Input button released */
|
||||
SDL_INPUTWHEEL, /**< Input wheel motion */
|
||||
SDL_INPUTPROXIMITYIN, /**< Input pen entered proximity */
|
||||
SDL_INPUTPROXIMITYOUT, /**< Input pen left proximity */
|
||||
|
||||
/* Joystick events */
|
||||
SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
|
||||
SDL_JOYBALLMOTION, /**< Joystick trackball motion */
|
||||
SDL_JOYHATMOTION, /**< Joystick hat position change */
|
||||
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
|
||||
SDL_JOYBUTTONUP, /**< Joystick button released */
|
||||
|
||||
/* Touch events */
|
||||
SDL_FINGERDOWN = 0x700,
|
||||
SDL_FINGERUP,
|
||||
SDL_FINGERMOTION,
|
||||
SDL_TOUCHBUTTONDOWN,
|
||||
SDL_TOUCHBUTTONUP,
|
||||
|
||||
/* Gesture events */
|
||||
SDL_DOLLARGESTURE = 0x800,
|
||||
SDL_DOLLARRECORD,
|
||||
SDL_MULTIGESTURE,
|
||||
|
||||
/* Clipboard events */
|
||||
|
||||
SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
|
||||
|
||||
/* Obsolete events */
|
||||
SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
|
||||
SDL_EVENT_COMPAT2,
|
||||
SDL_EVENT_COMPAT3,
|
||||
|
||||
|
||||
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
||||
* and should be allocated with SDL_RegisterEvents()
|
||||
*/
|
||||
SDL_USEREVENT = 0x8000,
|
||||
|
||||
/**
|
||||
* This last event is only for bounding internal arrays
|
||||
*/
|
||||
SDL_LASTEVENT = 0xFFFF
|
||||
} SDL_EventType;
|
||||
|
||||
/**
|
||||
* \brief Window state change event data (event.window.*)
|
||||
*/
|
||||
typedef struct SDL_WindowEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_WINDOWEVENT */
|
||||
Uint32 windowID; /**< The associated window */
|
||||
Uint8 event; /**< ::SDL_WindowEventID */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
int data1; /**< event dependent data */
|
||||
int data2; /**< event dependent data */
|
||||
} SDL_WindowEvent;
|
||||
|
||||
/**
|
||||
* \brief Keyboard button event structure (event.key.*)
|
||||
*/
|
||||
typedef struct SDL_KeyboardEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 repeat; /**< Non-zero if this is a key repeat */
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
SDL_Keysym keysym; /**< The key that was pressed or released */
|
||||
} SDL_KeyboardEvent;
|
||||
|
||||
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
|
||||
/**
|
||||
* \brief Keyboard text editing event structure (event.edit.*)
|
||||
*/
|
||||
typedef struct SDL_TextEditingEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_TEXTEDITING */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
|
||||
int start; /**< The start cursor of selected editing text */
|
||||
int length; /**< The length of selected editing text */
|
||||
} SDL_TextEditingEvent;
|
||||
|
||||
|
||||
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
|
||||
/**
|
||||
* \brief Keyboard text input event structure (event.text.*)
|
||||
*/
|
||||
typedef struct SDL_TextInputEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_TEXTINPUT */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
|
||||
} SDL_TextInputEvent;
|
||||
|
||||
/**
|
||||
* \brief Mouse motion event structure (event.motion.*)
|
||||
*/
|
||||
typedef struct SDL_MouseMotionEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_MOUSEMOTION */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
Uint8 state; /**< The current button state */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
int x; /**< X coordinate, relative to window */
|
||||
int y; /**< Y coordinate, relative to window */
|
||||
int xrel; /**< The relative motion in the X direction */
|
||||
int yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_MouseMotionEvent;
|
||||
|
||||
/**
|
||||
* \brief Mouse button event structure (event.button.*)
|
||||
*/
|
||||
typedef struct SDL_MouseButtonEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
Uint8 button; /**< The mouse button index */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
int x; /**< X coordinate, relative to window */
|
||||
int y; /**< Y coordinate, relative to window */
|
||||
} SDL_MouseButtonEvent;
|
||||
|
||||
/**
|
||||
* \brief Mouse wheel event structure (event.wheel.*)
|
||||
*/
|
||||
typedef struct SDL_MouseWheelEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_MOUSEWHEEL */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
int x; /**< The amount scrolled horizontally */
|
||||
int y; /**< The amount scrolled vertically */
|
||||
} SDL_MouseWheelEvent;
|
||||
|
||||
/**
|
||||
* \brief Joystick axis motion event structure (event.jaxis.*)
|
||||
*/
|
||||
typedef struct SDL_JoyAxisEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_JOYAXISMOTION */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 axis; /**< The joystick axis index */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
int value; /**< The axis value (range: -32768 to 32767) */
|
||||
} SDL_JoyAxisEvent;
|
||||
|
||||
/**
|
||||
* \brief Joystick trackball motion event structure (event.jball.*)
|
||||
*/
|
||||
typedef struct SDL_JoyBallEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 ball; /**< The joystick trackball index */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
int xrel; /**< The relative motion in the X direction */
|
||||
int yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_JoyBallEvent;
|
||||
|
||||
/**
|
||||
* \brief Joystick hat position change event structure (event.jhat.*)
|
||||
*/
|
||||
typedef struct SDL_JoyHatEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_JOYHATMOTION */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 hat; /**< The joystick hat index */
|
||||
Uint8 value; /**< The hat position value.
|
||||
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
|
||||
* \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
|
||||
* \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
|
||||
*
|
||||
* Note that zero means the POV is centered.
|
||||
*/
|
||||
Uint8 padding1;
|
||||
} SDL_JoyHatEvent;
|
||||
|
||||
/**
|
||||
* \brief Joystick button event structure (event.jbutton.*)
|
||||
*/
|
||||
typedef struct SDL_JoyButtonEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 button; /**< The joystick button index */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
} SDL_JoyButtonEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Touch finger motion/finger event structure (event.tmotion.*)
|
||||
*/
|
||||
typedef struct SDL_TouchFingerEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_FINGERMOTION OR
|
||||
SDL_FINGERDOWN OR SDL_FINGERUP*/
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_FingerID fingerId;
|
||||
Uint8 state; /**< The current button state */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
Sint16 dx;
|
||||
Sint16 dy;
|
||||
Uint16 pressure;
|
||||
} SDL_TouchFingerEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Touch finger motion/finger event structure (event.tmotion.*)
|
||||
*/
|
||||
typedef struct SDL_TouchButtonEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device index */
|
||||
Uint8 state; /**< The current button state */
|
||||
Uint8 button; /**< The button changing state */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_TouchButtonEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Multiple Finger Gesture Event (event.mgesture.*)
|
||||
*/
|
||||
typedef struct SDL_MultiGestureEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_MULTIGESTURE */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device index */
|
||||
float dTheta;
|
||||
float dDist;
|
||||
float x; //currently 0...1. Change to screen coords?
|
||||
float y;
|
||||
Uint16 numFingers;
|
||||
Uint16 padding;
|
||||
} SDL_MultiGestureEvent;
|
||||
|
||||
/* (event.dgesture.*) */
|
||||
typedef struct SDL_DollarGestureEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_DOLLARGESTURE */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device index */
|
||||
SDL_GestureID gestureId;
|
||||
Uint32 numFingers;
|
||||
float error;
|
||||
/*
|
||||
//TODO: Enable to give location?
|
||||
float x; //currently 0...1. Change to screen coords?
|
||||
float y;
|
||||
*/
|
||||
} SDL_DollarGestureEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief The "quit requested" event
|
||||
*/
|
||||
typedef struct SDL_QuitEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_QUIT */
|
||||
} SDL_QuitEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief A user-defined event type (event.user.*)
|
||||
*/
|
||||
typedef struct SDL_UserEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
|
||||
Uint32 windowID; /**< The associated window if any */
|
||||
int code; /**< User defined event code */
|
||||
void *data1; /**< User defined data pointer */
|
||||
void *data2; /**< User defined data pointer */
|
||||
} SDL_UserEvent;
|
||||
|
||||
|
||||
struct SDL_SysWMmsg;
|
||||
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
|
||||
|
||||
/**
|
||||
* \brief A video driver dependent system event (event.syswm.*)
|
||||
*
|
||||
* \note If you want to use this event, you should include SDL_syswm.h.
|
||||
*/
|
||||
typedef struct SDL_SysWMEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_SYSWMEVENT */
|
||||
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
|
||||
} SDL_SysWMEvent;
|
||||
|
||||
#ifndef SDL_NO_COMPAT
|
||||
/**
|
||||
* \addtogroup Compatibility
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* \name Typedefs for backwards compatibility
|
||||
*/
|
||||
/*@{*/
|
||||
typedef struct SDL_ActiveEvent
|
||||
{
|
||||
Uint32 type;
|
||||
Uint8 gain;
|
||||
Uint8 state;
|
||||
} SDL_ActiveEvent;
|
||||
|
||||
typedef struct SDL_ResizeEvent
|
||||
{
|
||||
Uint32 type;
|
||||
int w;
|
||||
int h;
|
||||
} SDL_ResizeEvent;
|
||||
/*@}*/
|
||||
|
||||
/*@}*//*Compatibility*/
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief General event structure
|
||||
*/
|
||||
typedef union SDL_Event
|
||||
{
|
||||
Uint32 type; /**< Event type, shared with all events */
|
||||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||
SDL_TextInputEvent text; /**< Text input event data */
|
||||
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
|
||||
SDL_MouseButtonEvent button; /**< Mouse button event data */
|
||||
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
|
||||
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
|
||||
SDL_JoyBallEvent jball; /**< Joystick ball event data */
|
||||
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
|
||||
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
|
||||
SDL_QuitEvent quit; /**< Quit request event data */
|
||||
SDL_UserEvent user; /**< Custom event data */
|
||||
SDL_SysWMEvent syswm; /**< System dependent window event data */
|
||||
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
|
||||
SDL_TouchButtonEvent tbutton; /**< Touch button event data */
|
||||
SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
|
||||
SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
|
||||
|
||||
/** Temporarily here for backwards compatibility */
|
||||
/*@{*/
|
||||
#ifndef SDL_NO_COMPAT
|
||||
SDL_ActiveEvent active;
|
||||
SDL_ResizeEvent resize;
|
||||
#endif
|
||||
/*@}*/
|
||||
} SDL_Event;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* Pumps the event loop, gathering events from the input devices.
|
||||
*
|
||||
* This function updates the event queue and internal input device state.
|
||||
*
|
||||
* This should only be run in the thread that sets the video mode.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
|
||||
|
||||
/*@{*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_ADDEVENT,
|
||||
SDL_PEEKEVENT,
|
||||
SDL_GETEVENT
|
||||
} SDL_eventaction;
|
||||
|
||||
/**
|
||||
* Checks the event queue for messages and optionally returns them.
|
||||
*
|
||||
* If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
|
||||
* the back of the event queue.
|
||||
*
|
||||
* If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
|
||||
* of the event queue, within the specified minimum and maximum type,
|
||||
* will be returned and will not be removed from the queue.
|
||||
*
|
||||
* If \c action is ::SDL_GETEVENT, up to \c numevents events at the front
|
||||
* of the event queue, within the specified minimum and maximum type,
|
||||
* will be returned and will be removed from the queue.
|
||||
*
|
||||
* \return The number of events actually stored, or -1 if there was an error.
|
||||
*
|
||||
* This function is thread-safe.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
|
||||
SDL_eventaction action,
|
||||
Uint32 minType, Uint32 maxType);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Checks to see if certain event types are in the event queue.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
|
||||
|
||||
/**
|
||||
* This function clears events from the event queue
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
|
||||
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
|
||||
|
||||
/**
|
||||
* \brief Polls for currently pending events.
|
||||
*
|
||||
* \return 1 if there are any pending events, or 0 if there are none available.
|
||||
*
|
||||
* \param event If not NULL, the next event is removed from the queue and
|
||||
* stored in that area.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
|
||||
|
||||
/**
|
||||
* \brief Waits indefinitely for the next available event.
|
||||
*
|
||||
* \return 1, or 0 if there was an error while waiting for events.
|
||||
*
|
||||
* \param event If not NULL, the next event is removed from the queue and
|
||||
* stored in that area.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
|
||||
|
||||
/**
|
||||
* \brief Waits until the specified timeout (in milliseconds) for the next
|
||||
* available event.
|
||||
*
|
||||
* \return 1, or 0 if there was an error while waiting for events.
|
||||
*
|
||||
* \param event If not NULL, the next event is removed from the queue and
|
||||
* stored in that area.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
|
||||
int timeout);
|
||||
|
||||
/**
|
||||
* \brief Add an event to the event queue.
|
||||
*
|
||||
* \return 1 on success, 0 if the event was filtered, or -1 if the event queue
|
||||
* was full or there was some other error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
|
||||
|
||||
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
|
||||
|
||||
/**
|
||||
* Sets up a filter to process all events before they change internal state and
|
||||
* are posted to the internal event queue.
|
||||
*
|
||||
* The filter is protypted as:
|
||||
* \code
|
||||
* int SDL_EventFilter(void *userdata, SDL_Event * event);
|
||||
* \endcode
|
||||
*
|
||||
* If the filter returns 1, then the event will be added to the internal queue.
|
||||
* If it returns 0, then the event will be dropped from the queue, but the
|
||||
* internal state will still be updated. This allows selective filtering of
|
||||
* dynamically arriving events.
|
||||
*
|
||||
* \warning Be very careful of what you do in the event filter function, as
|
||||
* it may run in a different thread!
|
||||
*
|
||||
* There is one caveat when dealing with the ::SDL_QUITEVENT event type. The
|
||||
* event filter is only called when the window manager desires to close the
|
||||
* application window. If the event filter returns 1, then the window will
|
||||
* be closed, otherwise the window will remain open if possible.
|
||||
*
|
||||
* If the quit event is generated by an interrupt signal, it will bypass the
|
||||
* internal queue and be delivered to the application at the next event poll.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Return the current event filter - can be used to "chain" filters.
|
||||
* If there is no event filter set, this function returns SDL_FALSE.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
|
||||
void **userdata);
|
||||
|
||||
/**
|
||||
* Add a function which is called when an event is added to the queue.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Remove an event watch function added with SDL_AddEventWatch()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Run the filter function on the current event queue, removing any
|
||||
* events for which the filter returns 0.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/*@{*/
|
||||
#define SDL_QUERY -1
|
||||
#define SDL_IGNORE 0
|
||||
#define SDL_DISABLE 0
|
||||
#define SDL_ENABLE 1
|
||||
|
||||
/**
|
||||
* This function allows you to set the state of processing certain events.
|
||||
* - If \c state is set to ::SDL_IGNORE, that event will be automatically
|
||||
* dropped from the event queue and will not event be filtered.
|
||||
* - If \c state is set to ::SDL_ENABLE, that event will be processed
|
||||
* normally.
|
||||
* - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the
|
||||
* current processing state of the specified event.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
|
||||
/*@}*/
|
||||
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
|
||||
|
||||
/**
|
||||
* This function allocates a set of user-defined events, and returns
|
||||
* the beginning event number for that set of events.
|
||||
*
|
||||
* If there aren't enough user-defined events left, this function
|
||||
* returns (Uint32)-1
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_events_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_gesture.h
|
||||
*
|
||||
* Include file for SDL gesture event handling.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_gesture_h
|
||||
#define _SDL_gesture_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "SDL_touch.h"
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
typedef Sint64 SDL_GestureID;
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Begin Recording a gesture on the specified touch, or all touches (-1)
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Save all currently loaded Dollar Gesture templates
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src);
|
||||
|
||||
/**
|
||||
* \brief Save a currently loaded Dollar Gesture template
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load Dollar Gesture templates from a file
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_gesture_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
File diff suppressed because it is too large
Load diff
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DihintsMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_hints.h
|
||||
*
|
||||
* Official documentation for SDL configuration variables
|
||||
*
|
||||
* This file contains functions to set and get configuration hints,
|
||||
* as well as listing each of them alphabetically.
|
||||
*
|
||||
* The convention for naming hints is SDL_HINT_X, where "SDL_X" is
|
||||
* the environment variable that can be used to override the default.
|
||||
*
|
||||
* In general these hints are just that - they may or may not be
|
||||
* supported or applicable on any given platform, but they provide
|
||||
* a way for an application or user to give the library a hint as
|
||||
* to how they would like the library to work.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_hints_h
|
||||
#define _SDL_hints_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief A variable controlling how 3D acceleration is used to accelerate the SDL 1.2 screen surface.
|
||||
*
|
||||
* SDL can try to accelerate the SDL 1.2 screen surface by using streaming
|
||||
* textures with a 3D rendering engine. This variable controls whether and
|
||||
* how this is done.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - Disable 3D acceleration
|
||||
* "1" - Enable 3D acceleration, using the default renderer.
|
||||
* "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.)
|
||||
*
|
||||
* By default SDL tries to make a best guess for each platform whether
|
||||
* to use acceleration or not.
|
||||
*/
|
||||
#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION"
|
||||
|
||||
/**
|
||||
* \brief A variable specifying which render driver to use.
|
||||
*
|
||||
* If the application doesn't pick a specific renderer to use, this variable
|
||||
* specifies the name of the preferred renderer. If the preferred renderer
|
||||
* can't be initialized, the normal default renderer is used.
|
||||
*
|
||||
* This variable is case insensitive and can be set to the following values:
|
||||
* "direct3d"
|
||||
* "opengl"
|
||||
* "opengles2"
|
||||
* "opengles"
|
||||
* "software"
|
||||
*
|
||||
* The default varies by platform, but it's the first one in the list that
|
||||
* is available on the current platform.
|
||||
*/
|
||||
#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the OpenGL render driver uses shaders if they are available.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - Disable shaders
|
||||
* "1" - Enable shaders
|
||||
*
|
||||
* By default shaders are used if OpenGL supports them.
|
||||
*/
|
||||
#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling the scaling quality
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" or "nearest" - Nearest pixel sampling
|
||||
* "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D)
|
||||
* "2" or "best" - Anisotropic filtering (supported by Direct3D)
|
||||
*
|
||||
* By default nearest pixel sampling is used
|
||||
*/
|
||||
#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether updates to the SDL 1.2 screen surface should be synchronized with the vertical refresh, to avoid tearing.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - Disable vsync
|
||||
* "1" - Enable vsync
|
||||
*
|
||||
* By default SDL does not sync screen surface updates with vertical refresh.
|
||||
*/
|
||||
#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC"
|
||||
|
||||
|
||||
/**
|
||||
* \brief An enumeration of hint priorities
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_HINT_DEFAULT,
|
||||
SDL_HINT_NORMAL,
|
||||
SDL_HINT_OVERRIDE
|
||||
} SDL_HintPriority;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set a hint with a specific priority
|
||||
*
|
||||
* The priority controls the behavior when setting a hint that already
|
||||
* has a value. Hints will replace existing hints of their priority and
|
||||
* lower. Environment variables are considered to have override priority.
|
||||
*
|
||||
* \return SDL_TRUE if the hint was set, SDL_FALSE otherwise
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name,
|
||||
const char *value,
|
||||
SDL_HintPriority priority);
|
||||
|
||||
/**
|
||||
* \brief Set a hint with normal priority
|
||||
*
|
||||
* \return SDL_TRUE if the hint was set, SDL_FALSE otherwise
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name,
|
||||
const char *value);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get a hint
|
||||
*
|
||||
* \return The string value of a hint variable.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name);
|
||||
|
||||
/**
|
||||
* \brief Clear all hints
|
||||
*
|
||||
* This function is called during SDL_Quit() to free stored hints.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ClearHints(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_hints_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_input.h
|
||||
*
|
||||
* Include file for lowlevel SDL input device handling.
|
||||
*
|
||||
* This talks about individual devices, and not the system cursor. If you
|
||||
* just want to know when the user moves the pointer somewhere in your
|
||||
* window, this is NOT the API you want. This one handles things like
|
||||
* multi-touch, drawing tablets, and multiple, separate mice.
|
||||
*
|
||||
* The other API is in SDL_mouse.h
|
||||
*/
|
||||
|
||||
#ifndef _SDL_input_h
|
||||
#define _SDL_input_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/* !!! FIXME: real documentation
|
||||
* - Redetect devices
|
||||
* - This invalidates all existing device information from previous queries!
|
||||
* - There is an implicit (re)detect upon SDL_Init().
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RedetectInputDevices(void);
|
||||
|
||||
/**
|
||||
* \brief Get the number of mouse input devices available.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumInputDevices(void);
|
||||
|
||||
/**
|
||||
* \brief Gets the name of a device with the given index.
|
||||
*
|
||||
* \param index is the index of the device, whose name is to be returned.
|
||||
*
|
||||
* \return the name of the device with the specified index
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetInputDeviceName(int index);
|
||||
|
||||
|
||||
extern DECLSPEC int SDLCALL SDL_IsDeviceDisconnected(int index);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,209 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_joystick.h
|
||||
*
|
||||
* Include file for SDL joystick event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_joystick_h
|
||||
#define _SDL_joystick_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \file SDL_joystick.h
|
||||
*
|
||||
* In order to use these functions, SDL_Init() must have been called
|
||||
* with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
||||
* for joysticks, and load appropriate drivers.
|
||||
*/
|
||||
|
||||
/* The joystick structure used to identify an SDL joystick */
|
||||
struct _SDL_Joystick;
|
||||
typedef struct _SDL_Joystick SDL_Joystick;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
/**
|
||||
* Count the number of joysticks attached to the system
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
||||
|
||||
/**
|
||||
* Get the implementation dependent name of a joystick.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If no name can be found, this function returns NULL.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index);
|
||||
|
||||
/**
|
||||
* Open a joystick for use.
|
||||
* The index passed as an argument refers tothe N'th joystick on the system.
|
||||
* This index is the value which will identify this joystick in future joystick
|
||||
* events.
|
||||
*
|
||||
* \return A joystick identifier, or NULL if an error occurred.
|
||||
*/
|
||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
|
||||
|
||||
/**
|
||||
* Returns 1 if the joystick has been opened, or 0 if it has not.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
|
||||
|
||||
/**
|
||||
* Get the device index of an opened joystick.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the number of general axis controls on a joystick.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the number of trackballs on a joystick.
|
||||
*
|
||||
* Joystick trackballs have only relative motion events associated
|
||||
* with them and their state cannot be polled.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the number of POV hats on a joystick.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the number of buttons on a joystick.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Update the current state of the open joysticks.
|
||||
*
|
||||
* This is called automatically by the event loop if any joystick
|
||||
* events are enabled.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
|
||||
|
||||
/**
|
||||
* Enable/disable joystick event polling.
|
||||
*
|
||||
* If joystick events are disabled, you must call SDL_JoystickUpdate()
|
||||
* yourself and check the state of the joystick when you want joystick
|
||||
* information.
|
||||
*
|
||||
* The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
|
||||
|
||||
/**
|
||||
* Get the current state of an axis control on a joystick.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767.
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
|
||||
int axis);
|
||||
|
||||
/**
|
||||
* \name Hat positions
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_HAT_CENTERED 0x00
|
||||
#define SDL_HAT_UP 0x01
|
||||
#define SDL_HAT_RIGHT 0x02
|
||||
#define SDL_HAT_DOWN 0x04
|
||||
#define SDL_HAT_LEFT 0x08
|
||||
#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
|
||||
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
|
||||
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
|
||||
#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Get the current state of a POV hat on a joystick.
|
||||
*
|
||||
* The hat indices start at index 0.
|
||||
*
|
||||
* \return The return value is one of the following positions:
|
||||
* - ::SDL_HAT_CENTERED
|
||||
* - ::SDL_HAT_UP
|
||||
* - ::SDL_HAT_RIGHT
|
||||
* - ::SDL_HAT_DOWN
|
||||
* - ::SDL_HAT_LEFT
|
||||
* - ::SDL_HAT_RIGHTUP
|
||||
* - ::SDL_HAT_RIGHTDOWN
|
||||
* - ::SDL_HAT_LEFTUP
|
||||
* - ::SDL_HAT_LEFTDOWN
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
|
||||
int hat);
|
||||
|
||||
/**
|
||||
* Get the ball axis change since the last poll.
|
||||
*
|
||||
* \return 0, or -1 if you passed it invalid parameters.
|
||||
*
|
||||
* The ball indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
|
||||
int ball, int *dx, int *dy);
|
||||
|
||||
/**
|
||||
* Get the current state of a button on a joystick.
|
||||
*
|
||||
* The button indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
|
||||
int button);
|
||||
|
||||
/**
|
||||
* Close a joystick previously opened with SDL_JoystickOpen().
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_joystick_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,170 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_keyboard.h
|
||||
*
|
||||
* Include file for SDL keyboard event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keyboard_h
|
||||
#define _SDL_keyboard_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_keycode.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The SDL keysym structure, used in key events.
|
||||
*/
|
||||
typedef struct SDL_Keysym
|
||||
{
|
||||
SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
|
||||
SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */
|
||||
Uint16 mod; /**< current key modifiers */
|
||||
Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
|
||||
} SDL_Keysym;
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the window which currently has keyboard focus.
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
|
||||
|
||||
/**
|
||||
* \brief Get a snapshot of the current state of the keyboard.
|
||||
*
|
||||
* \param numkeys if non-NULL, receives the length of the returned array.
|
||||
*
|
||||
* \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values.
|
||||
*
|
||||
* \b Example:
|
||||
* \code
|
||||
* Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||
* if ( state[SDL_SCANCODE_RETURN] ) {
|
||||
* printf("<RETURN> is pressed.\n");
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
|
||||
|
||||
/**
|
||||
* \brief Get the current key modifier state for the keyboard.
|
||||
*/
|
||||
extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
|
||||
|
||||
/**
|
||||
* \brief Set the current key modifier state for the keyboard.
|
||||
*
|
||||
* \note This does not change the keyboard state, only the key modifier flags.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
|
||||
|
||||
/**
|
||||
* \brief Get the key code corresponding to the given scancode according
|
||||
* to the current keyboard layout.
|
||||
*
|
||||
* See ::SDL_Keycode for details.
|
||||
*
|
||||
* \sa SDL_GetKeyName()
|
||||
*/
|
||||
extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);
|
||||
|
||||
/**
|
||||
* \brief Get the scancode corresponding to the given key code according to the
|
||||
* current keyboard layout.
|
||||
*
|
||||
* See ::SDL_Scancode for details.
|
||||
*
|
||||
* \sa SDL_GetScancodeName()
|
||||
*/
|
||||
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
|
||||
|
||||
/**
|
||||
* \brief Get a human-readable name for a scancode.
|
||||
*
|
||||
* \return A pointer to a UTF-8 string that stays valid at least until the next
|
||||
* call to this function. If you need it around any longer, you must
|
||||
* copy it. If the scancode doesn't have a name, this function returns
|
||||
* an empty string ("").
|
||||
*
|
||||
* \sa SDL_Scancode
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode
|
||||
scancode);
|
||||
|
||||
/**
|
||||
* \brief Get a human-readable name for a key.
|
||||
*
|
||||
* \return A pointer to a UTF-8 string that stays valid at least until the next
|
||||
* call to this function. If you need it around any longer, you must
|
||||
* copy it. If the key doesn't have a name, this function returns an
|
||||
* empty string ("").
|
||||
*
|
||||
* \sa SDL_Key
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
|
||||
|
||||
/**
|
||||
* \brief Start accepting Unicode text input events.
|
||||
*
|
||||
* \sa SDL_StopTextInput()
|
||||
* \sa SDL_SetTextInputRect()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
|
||||
|
||||
/**
|
||||
* \brief Stop receiving any text input events.
|
||||
*
|
||||
* \sa SDL_StartTextInput()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
|
||||
|
||||
/**
|
||||
* \brief Set the rectangle used to type Unicode text inputs.
|
||||
*
|
||||
* \sa SDL_StartTextInput()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_keyboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,342 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_keycode.h
|
||||
*
|
||||
* Defines constants which identify keyboard keys and modifiers.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keycode_h
|
||||
#define _SDL_keycode_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_scancode.h"
|
||||
|
||||
/**
|
||||
* \brief The SDL virtual key representation.
|
||||
*
|
||||
* Values of this type are used to represent keyboard keys using the current
|
||||
* layout of the keyboard. These values include Unicode values representing
|
||||
* the unmodified character that would be generated by pressing the key, or
|
||||
* an SDLK_* constant for those keys that do not generate characters.
|
||||
*/
|
||||
typedef Sint32 SDL_Keycode;
|
||||
|
||||
#define SDLK_SCANCODE_MASK (1<<30)
|
||||
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
|
||||
|
||||
enum
|
||||
{
|
||||
SDLK_UNKNOWN = 0,
|
||||
|
||||
SDLK_RETURN = '\r',
|
||||
SDLK_ESCAPE = '\033',
|
||||
SDLK_BACKSPACE = '\b',
|
||||
SDLK_TAB = '\t',
|
||||
SDLK_SPACE = ' ',
|
||||
SDLK_EXCLAIM = '!',
|
||||
SDLK_QUOTEDBL = '"',
|
||||
SDLK_HASH = '#',
|
||||
SDLK_PERCENT = '%',
|
||||
SDLK_DOLLAR = '$',
|
||||
SDLK_AMPERSAND = '&',
|
||||
SDLK_QUOTE = '\'',
|
||||
SDLK_LEFTPAREN = '(',
|
||||
SDLK_RIGHTPAREN = ')',
|
||||
SDLK_ASTERISK = '*',
|
||||
SDLK_PLUS = '+',
|
||||
SDLK_COMMA = ',',
|
||||
SDLK_MINUS = '-',
|
||||
SDLK_PERIOD = '.',
|
||||
SDLK_SLASH = '/',
|
||||
SDLK_0 = '0',
|
||||
SDLK_1 = '1',
|
||||
SDLK_2 = '2',
|
||||
SDLK_3 = '3',
|
||||
SDLK_4 = '4',
|
||||
SDLK_5 = '5',
|
||||
SDLK_6 = '6',
|
||||
SDLK_7 = '7',
|
||||
SDLK_8 = '8',
|
||||
SDLK_9 = '9',
|
||||
SDLK_COLON = ':',
|
||||
SDLK_SEMICOLON = ';',
|
||||
SDLK_LESS = '<',
|
||||
SDLK_EQUALS = '=',
|
||||
SDLK_GREATER = '>',
|
||||
SDLK_QUESTION = '?',
|
||||
SDLK_AT = '@',
|
||||
/*
|
||||
Skip uppercase letters
|
||||
*/
|
||||
SDLK_LEFTBRACKET = '[',
|
||||
SDLK_BACKSLASH = '\\',
|
||||
SDLK_RIGHTBRACKET = ']',
|
||||
SDLK_CARET = '^',
|
||||
SDLK_UNDERSCORE = '_',
|
||||
SDLK_BACKQUOTE = '`',
|
||||
SDLK_a = 'a',
|
||||
SDLK_b = 'b',
|
||||
SDLK_c = 'c',
|
||||
SDLK_d = 'd',
|
||||
SDLK_e = 'e',
|
||||
SDLK_f = 'f',
|
||||
SDLK_g = 'g',
|
||||
SDLK_h = 'h',
|
||||
SDLK_i = 'i',
|
||||
SDLK_j = 'j',
|
||||
SDLK_k = 'k',
|
||||
SDLK_l = 'l',
|
||||
SDLK_m = 'm',
|
||||
SDLK_n = 'n',
|
||||
SDLK_o = 'o',
|
||||
SDLK_p = 'p',
|
||||
SDLK_q = 'q',
|
||||
SDLK_r = 'r',
|
||||
SDLK_s = 's',
|
||||
SDLK_t = 't',
|
||||
SDLK_u = 'u',
|
||||
SDLK_v = 'v',
|
||||
SDLK_w = 'w',
|
||||
SDLK_x = 'x',
|
||||
SDLK_y = 'y',
|
||||
SDLK_z = 'z',
|
||||
|
||||
SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK),
|
||||
|
||||
SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1),
|
||||
SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2),
|
||||
SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3),
|
||||
SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4),
|
||||
SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5),
|
||||
SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6),
|
||||
SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7),
|
||||
SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8),
|
||||
SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9),
|
||||
SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10),
|
||||
SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11),
|
||||
SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12),
|
||||
|
||||
SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN),
|
||||
SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK),
|
||||
SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE),
|
||||
SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT),
|
||||
SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME),
|
||||
SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP),
|
||||
SDLK_DELETE = '\177',
|
||||
SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END),
|
||||
SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN),
|
||||
SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT),
|
||||
SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT),
|
||||
SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN),
|
||||
SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP),
|
||||
|
||||
SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR),
|
||||
SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE),
|
||||
SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY),
|
||||
SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS),
|
||||
SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS),
|
||||
SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER),
|
||||
SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1),
|
||||
SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2),
|
||||
SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3),
|
||||
SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4),
|
||||
SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5),
|
||||
SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6),
|
||||
SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7),
|
||||
SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8),
|
||||
SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9),
|
||||
SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0),
|
||||
SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD),
|
||||
|
||||
SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION),
|
||||
SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER),
|
||||
SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS),
|
||||
SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13),
|
||||
SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14),
|
||||
SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15),
|
||||
SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16),
|
||||
SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17),
|
||||
SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18),
|
||||
SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19),
|
||||
SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20),
|
||||
SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21),
|
||||
SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22),
|
||||
SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23),
|
||||
SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24),
|
||||
SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE),
|
||||
SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP),
|
||||
SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU),
|
||||
SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT),
|
||||
SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP),
|
||||
SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN),
|
||||
SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO),
|
||||
SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT),
|
||||
SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY),
|
||||
SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE),
|
||||
SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND),
|
||||
SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE),
|
||||
SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP),
|
||||
SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN),
|
||||
SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA),
|
||||
SDLK_KP_EQUALSAS400 =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400),
|
||||
|
||||
SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE),
|
||||
SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ),
|
||||
SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL),
|
||||
SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR),
|
||||
SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR),
|
||||
SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2),
|
||||
SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR),
|
||||
SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT),
|
||||
SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER),
|
||||
SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN),
|
||||
SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL),
|
||||
SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL),
|
||||
|
||||
SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00),
|
||||
SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000),
|
||||
SDLK_THOUSANDSSEPARATOR =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR),
|
||||
SDLK_DECIMALSEPARATOR =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR),
|
||||
SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT),
|
||||
SDLK_CURRENCYSUBUNIT =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT),
|
||||
SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN),
|
||||
SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN),
|
||||
SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE),
|
||||
SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE),
|
||||
SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB),
|
||||
SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE),
|
||||
SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A),
|
||||
SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B),
|
||||
SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C),
|
||||
SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D),
|
||||
SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E),
|
||||
SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F),
|
||||
SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR),
|
||||
SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER),
|
||||
SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT),
|
||||
SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS),
|
||||
SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER),
|
||||
SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND),
|
||||
SDLK_KP_DBLAMPERSAND =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND),
|
||||
SDLK_KP_VERTICALBAR =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR),
|
||||
SDLK_KP_DBLVERTICALBAR =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR),
|
||||
SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON),
|
||||
SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH),
|
||||
SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE),
|
||||
SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT),
|
||||
SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM),
|
||||
SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE),
|
||||
SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL),
|
||||
SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR),
|
||||
SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD),
|
||||
SDLK_KP_MEMSUBTRACT =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT),
|
||||
SDLK_KP_MEMMULTIPLY =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY),
|
||||
SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE),
|
||||
SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS),
|
||||
SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR),
|
||||
SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY),
|
||||
SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY),
|
||||
SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL),
|
||||
SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL),
|
||||
SDLK_KP_HEXADECIMAL =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL),
|
||||
|
||||
SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL),
|
||||
SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT),
|
||||
SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT),
|
||||
SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI),
|
||||
SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL),
|
||||
SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT),
|
||||
SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT),
|
||||
SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI),
|
||||
|
||||
SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE),
|
||||
|
||||
SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT),
|
||||
SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV),
|
||||
SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP),
|
||||
SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY),
|
||||
SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE),
|
||||
SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT),
|
||||
SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW),
|
||||
SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL),
|
||||
SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR),
|
||||
SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER),
|
||||
SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH),
|
||||
SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME),
|
||||
SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK),
|
||||
SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD),
|
||||
SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP),
|
||||
SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH),
|
||||
SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS),
|
||||
|
||||
SDLK_BRIGHTNESSDOWN =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN),
|
||||
SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP),
|
||||
SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH),
|
||||
SDLK_KBDILLUMTOGGLE =
|
||||
SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE),
|
||||
SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN),
|
||||
SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP),
|
||||
SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT),
|
||||
SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP)
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Enumeration of valid key mods (possibly OR'd together).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT = 0x0001,
|
||||
KMOD_RSHIFT = 0x0002,
|
||||
KMOD_LCTRL = 0x0040,
|
||||
KMOD_RCTRL = 0x0080,
|
||||
KMOD_LALT = 0x0100,
|
||||
KMOD_RALT = 0x0200,
|
||||
KMOD_LGUI = 0x0400,
|
||||
KMOD_RGUI = 0x0800,
|
||||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000
|
||||
} SDL_Keymod;
|
||||
|
||||
#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
|
||||
#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)
|
||||
#define KMOD_ALT (KMOD_LALT|KMOD_RALT)
|
||||
#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI)
|
||||
|
||||
#endif /* _SDL_keycode_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_loadso.h
|
||||
*
|
||||
* System dependent library loading routines
|
||||
*
|
||||
* Some things to keep in mind:
|
||||
* \li These functions only work on C function names. Other languages may
|
||||
* have name mangling and intrinsic language support that varies from
|
||||
* compiler to compiler.
|
||||
* \li Make sure you declare your function pointers with the same calling
|
||||
* convention as the actual library function. Your code will crash
|
||||
* mysteriously if you do not do this.
|
||||
* \li Avoid namespace collisions. If you load a symbol from the library,
|
||||
* it is not defined whether or not it goes into the global symbol
|
||||
* namespace for the application. If it does and it conflicts with
|
||||
* symbols in your code or other shared libraries, you will not get
|
||||
* the results you expect. :)
|
||||
*/
|
||||
|
||||
#ifndef _SDL_loadso_h
|
||||
#define _SDL_loadso_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function dynamically loads a shared object and returns a pointer
|
||||
* to the object handle (or NULL if there was an error).
|
||||
* The 'sofile' parameter is a system dependent name of the object file.
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
|
||||
|
||||
/**
|
||||
* Given an object handle, this function looks up the address of the
|
||||
* named function in the shared object and returns it. This address
|
||||
* is no longer valid after calling SDL_UnloadObject().
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Unload a shared object from memory.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_loadso_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,212 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_log.h
|
||||
*
|
||||
* Simple log messages with categories and priorities.
|
||||
*
|
||||
* By default logs are quiet, but if you're debugging SDL you might want:
|
||||
*
|
||||
* SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
|
||||
*
|
||||
* Here's where the messages go on different platforms:
|
||||
* Windows: debug output stream
|
||||
* Android: log output
|
||||
* Others: standard error output (stderr)
|
||||
*/
|
||||
|
||||
#ifndef _SDL_log_h
|
||||
#define _SDL_log_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief The maximum size of a log message
|
||||
*
|
||||
* Messages longer than the maximum size will be truncated
|
||||
*/
|
||||
#define SDL_MAX_LOG_MESSAGE 4096
|
||||
|
||||
/**
|
||||
* \brief The predefined log categories
|
||||
*
|
||||
* By default the application category is enabled at the INFO level,
|
||||
* and all other categories are enabled at the CRITICAL level.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
SDL_LOG_CATEGORY_ERROR,
|
||||
SDL_LOG_CATEGORY_SYSTEM,
|
||||
SDL_LOG_CATEGORY_AUDIO,
|
||||
SDL_LOG_CATEGORY_VIDEO,
|
||||
SDL_LOG_CATEGORY_RENDER,
|
||||
SDL_LOG_CATEGORY_INPUT,
|
||||
|
||||
/* Reserved for future SDL library use */
|
||||
SDL_LOG_CATEGORY_RESERVED1,
|
||||
SDL_LOG_CATEGORY_RESERVED2,
|
||||
SDL_LOG_CATEGORY_RESERVED3,
|
||||
SDL_LOG_CATEGORY_RESERVED4,
|
||||
SDL_LOG_CATEGORY_RESERVED5,
|
||||
SDL_LOG_CATEGORY_RESERVED6,
|
||||
SDL_LOG_CATEGORY_RESERVED7,
|
||||
SDL_LOG_CATEGORY_RESERVED8,
|
||||
SDL_LOG_CATEGORY_RESERVED9,
|
||||
SDL_LOG_CATEGORY_RESERVED10,
|
||||
|
||||
/* Beyond this point is reserved for application use, e.g.
|
||||
enum {
|
||||
MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
|
||||
MYAPP_CATEGORY_AWESOME2,
|
||||
MYAPP_CATEGORY_AWESOME3,
|
||||
...
|
||||
};
|
||||
*/
|
||||
SDL_LOG_CATEGORY_CUSTOM
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief The predefined log priorities
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_LOG_PRIORITY_VERBOSE = 1,
|
||||
SDL_LOG_PRIORITY_DEBUG,
|
||||
SDL_LOG_PRIORITY_INFO,
|
||||
SDL_LOG_PRIORITY_WARN,
|
||||
SDL_LOG_PRIORITY_ERROR,
|
||||
SDL_LOG_PRIORITY_CRITICAL,
|
||||
SDL_NUM_LOG_PRIORITIES
|
||||
} SDL_LogPriority;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the priority of all log categories
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
|
||||
|
||||
/**
|
||||
* \brief Set the priority of a particular log category
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
|
||||
SDL_LogPriority priority);
|
||||
|
||||
/**
|
||||
* \brief Set the priority of a particular log category
|
||||
*/
|
||||
extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
|
||||
|
||||
/**
|
||||
* \brief Reset all priorities to default.
|
||||
*
|
||||
* \note This is called in SDL_Quit().
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_DEBUG
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_INFO
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_WARN
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_ERROR
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with the specified category and priority.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
|
||||
SDL_LogPriority priority,
|
||||
const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* \brief Log a message with the specified category and priority.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
|
||||
SDL_LogPriority priority,
|
||||
const char *fmt, va_list ap);
|
||||
|
||||
/**
|
||||
* \brief The prototype for the log output function
|
||||
*/
|
||||
typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
|
||||
|
||||
/**
|
||||
* \brief Get the current log output function.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
|
||||
|
||||
/**
|
||||
* \brief This function allows you to replace the default log output
|
||||
* function with one of your own.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_log_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_main_h
|
||||
#define _SDL_main_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/**
|
||||
* \file SDL_main.h
|
||||
*
|
||||
* Redefine main() on some platforms so that it is called by SDL.
|
||||
*/
|
||||
|
||||
#if defined(__WIN32__) || defined(__IPHONEOS__) || defined(__ANDROID__)
|
||||
#ifndef SDL_MAIN_HANDLED
|
||||
#define SDL_MAIN_NEEDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define C_LINKAGE "C"
|
||||
#else
|
||||
#define C_LINKAGE
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* \file SDL_main.h
|
||||
*
|
||||
* The application's main() function must be called with C linkage,
|
||||
* and should be declared like this:
|
||||
* \code
|
||||
* #ifdef __cplusplus
|
||||
* extern "C"
|
||||
* #endif
|
||||
* int main(int argc, char *argv[])
|
||||
* {
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
#ifdef SDL_MAIN_NEEDED
|
||||
#define main SDL_main
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The prototype for the application's main() function
|
||||
*/
|
||||
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
/**
|
||||
* This can be called to set the application class at startup
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style,
|
||||
void *hInst);
|
||||
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
||||
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_main_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_mouse.h
|
||||
*
|
||||
* Include file for SDL mouse event handling.
|
||||
*
|
||||
* Please note that this ONLY discusses "mice" with the notion of the
|
||||
* desktop GUI. You (usually) have one system cursor, and the OS hides
|
||||
* the hardware details from you. If you plug in 10 mice, all ten move that
|
||||
* one cursor. For many applications and games, this is perfect, and this
|
||||
* API has served hundreds of SDL programs well since its birth.
|
||||
*
|
||||
* It's not the whole picture, though. If you want more lowlevel control,
|
||||
* SDL offers a different API, that gives you visibility into each input
|
||||
* device, multi-touch interfaces, etc.
|
||||
*
|
||||
* Those two APIs are incompatible, and you usually should not use both
|
||||
* at the same time. But for legacy purposes, this API refers to a "mouse"
|
||||
* when it actually means the system pointer and not a physical mouse.
|
||||
*
|
||||
* The other API is in SDL_input.h
|
||||
*/
|
||||
|
||||
#ifndef _SDL_mouse_h
|
||||
#define _SDL_mouse_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the window which currently has mouse focus.
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the current state of the mouse.
|
||||
*
|
||||
* The current button state is returned as a button bitmask, which can
|
||||
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
||||
* mouse cursor position relative to the focus window for the currently
|
||||
* selected mouse. You can pass NULL for either x or y.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the relative state of the mouse.
|
||||
*
|
||||
* The current button state is returned as a button bitmask, which can
|
||||
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
||||
* mouse deltas since the last call to SDL_GetRelativeMouseState().
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Moves the mouse to the given position within the window.
|
||||
*
|
||||
* \param window The window to move the mouse into, or NULL for the current mouse focus
|
||||
* \param x The x coordinate within the window
|
||||
* \param y The y coordinate within the window
|
||||
*
|
||||
* \note This function generates a mouse motion event
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
|
||||
int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Set relative mouse mode.
|
||||
*
|
||||
* \param enabled Whether or not to enable relative mode
|
||||
*
|
||||
* \return 0 on success, or -1 if relative mode is not supported.
|
||||
*
|
||||
* While the mouse is in relative mode, the cursor is hidden, and the
|
||||
* driver will try to report continuous motion in the current window.
|
||||
* Only relative motion events will be delivered, the mouse position
|
||||
* will not change.
|
||||
*
|
||||
* \note This function will flush any pending mouse motion.
|
||||
*
|
||||
* \sa SDL_GetRelativeMouseMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* \brief Query whether relative mouse mode is enabled.
|
||||
*
|
||||
* \sa SDL_SetRelativeMouseMode()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
|
||||
|
||||
/**
|
||||
* \brief Create a cursor, using the specified bitmap data and
|
||||
* mask (in MSB format).
|
||||
*
|
||||
* The cursor width must be a multiple of 8 bits.
|
||||
*
|
||||
* The cursor is created in black and white according to the following:
|
||||
* <table>
|
||||
* <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
|
||||
* <tr><td> 0 </td><td> 1 </td><td> White </td></tr>
|
||||
* <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>
|
||||
* <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>
|
||||
* <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black
|
||||
* if not. </td></tr>
|
||||
* </table>
|
||||
*
|
||||
* \sa SDL_FreeCursor()
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
|
||||
const Uint8 * mask,
|
||||
int w, int h, int hot_x,
|
||||
int hot_y);
|
||||
|
||||
/**
|
||||
* \brief Create a color cursor.
|
||||
*
|
||||
* \sa SDL_FreeCursor()
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
|
||||
int hot_x,
|
||||
int hot_y);
|
||||
|
||||
/**
|
||||
* \brief Set the active cursor.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
|
||||
|
||||
/**
|
||||
* \brief Return the active cursor.
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
|
||||
|
||||
/**
|
||||
* \brief Frees a cursor created with SDL_CreateCursor().
|
||||
*
|
||||
* \sa SDL_CreateCursor()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
|
||||
|
||||
/**
|
||||
* \brief Toggle whether or not the cursor is shown.
|
||||
*
|
||||
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
|
||||
* state.
|
||||
*
|
||||
* \return 1 if the cursor is shown, or 0 if the cursor is hidden.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
||||
|
||||
/**
|
||||
* Used as a mask when testing buttons in buttonstate.
|
||||
* - Button 1: Left mouse button
|
||||
* - Button 2: Middle mouse button
|
||||
* - Button 3: Right mouse button
|
||||
*/
|
||||
#define SDL_BUTTON(X) (1 << ((X)-1))
|
||||
#define SDL_BUTTON_LEFT 1
|
||||
#define SDL_BUTTON_MIDDLE 2
|
||||
#define SDL_BUTTON_RIGHT 3
|
||||
#define SDL_BUTTON_X1 4
|
||||
#define SDL_BUTTON_X2 5
|
||||
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
|
||||
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
|
||||
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
|
||||
#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
|
||||
#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,249 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_mutex_h
|
||||
#define _SDL_mutex_h
|
||||
|
||||
/**
|
||||
* \file SDL_mutex.h
|
||||
*
|
||||
* Functions to provide thread synchronization primitives.
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Synchronization functions which can time out return this value
|
||||
* if they time out.
|
||||
*/
|
||||
#define SDL_MUTEX_TIMEDOUT 1
|
||||
|
||||
/**
|
||||
* This is the timeout value which corresponds to never time out.
|
||||
*/
|
||||
#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
|
||||
|
||||
|
||||
/**
|
||||
* \name Mutex functions
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/* The SDL mutex structure, defined in SDL_mutex.c */
|
||||
struct SDL_mutex;
|
||||
typedef struct SDL_mutex SDL_mutex;
|
||||
|
||||
/**
|
||||
* Create a mutex, initialized unlocked.
|
||||
*/
|
||||
extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
|
||||
|
||||
/**
|
||||
* Lock the mutex.
|
||||
*
|
||||
* \return 0, or -1 on error.
|
||||
*/
|
||||
#define SDL_LockMutex(m) SDL_mutexP(m)
|
||||
extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex * mutex);
|
||||
|
||||
/**
|
||||
* Unlock the mutex.
|
||||
*
|
||||
* \return 0, or -1 on error.
|
||||
*
|
||||
* \warning It is an error to unlock a mutex that has not been locked by
|
||||
* the current thread, and doing so results in undefined behavior.
|
||||
*/
|
||||
#define SDL_UnlockMutex(m) SDL_mutexV(m)
|
||||
extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex * mutex);
|
||||
|
||||
/**
|
||||
* Destroy a mutex.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
|
||||
|
||||
/*@}*//*Mutex functions*/
|
||||
|
||||
|
||||
/**
|
||||
* \name Semaphore functions
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/* The SDL semaphore structure, defined in SDL_sem.c */
|
||||
struct SDL_semaphore;
|
||||
typedef struct SDL_semaphore SDL_sem;
|
||||
|
||||
/**
|
||||
* Create a semaphore, initialized with value, returns NULL on failure.
|
||||
*/
|
||||
extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
|
||||
|
||||
/**
|
||||
* Destroy a semaphore.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* This function suspends the calling thread until the semaphore pointed
|
||||
* to by \c sem has a positive count. It then atomically decreases the
|
||||
* semaphore count.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* Non-blocking variant of SDL_SemWait().
|
||||
*
|
||||
* \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would
|
||||
* block, and -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* Variant of SDL_SemWait() with a timeout in milliseconds.
|
||||
*
|
||||
* \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not
|
||||
* succeed in the allotted time, and -1 on error.
|
||||
*
|
||||
* \warning On some platforms this function is implemented by looping with a
|
||||
* delay of 1 ms, and so should be avoided if possible.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
|
||||
|
||||
/**
|
||||
* Atomically increases the semaphore's count (not blocking).
|
||||
*
|
||||
* \return 0, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* Returns the current count of the semaphore.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
|
||||
|
||||
/*@}*//*Semaphore functions*/
|
||||
|
||||
|
||||
/**
|
||||
* \name Condition variable functions
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/* The SDL condition variable structure, defined in SDL_cond.c */
|
||||
struct SDL_cond;
|
||||
typedef struct SDL_cond SDL_cond;
|
||||
|
||||
/**
|
||||
* Create a condition variable.
|
||||
*
|
||||
* Typical use of condition variables:
|
||||
*
|
||||
* Thread A:
|
||||
* SDL_LockMutex(lock);
|
||||
* while ( ! condition ) {
|
||||
* SDL_CondWait(cond, lock);
|
||||
* }
|
||||
* SDL_UnlockMutex(lock);
|
||||
*
|
||||
* Thread B:
|
||||
* SDL_LockMutex(lock);
|
||||
* ...
|
||||
* condition = true;
|
||||
* ...
|
||||
* SDL_CondSignal(cond);
|
||||
* SDL_UnlockMutex(lock);
|
||||
*
|
||||
* There is some discussion whether to signal the condition variable
|
||||
* with the mutex locked or not. There is some potential performance
|
||||
* benefit to unlocking first on some platforms, but there are some
|
||||
* potential race conditions depending on how your code is structured.
|
||||
*
|
||||
* In general it's safer to signal the condition variable while the
|
||||
* mutex is locked.
|
||||
*/
|
||||
extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
|
||||
|
||||
/**
|
||||
* Destroy a condition variable.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
|
||||
|
||||
/**
|
||||
* Restart one of the threads that are waiting on the condition variable.
|
||||
*
|
||||
* \return 0 or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
|
||||
|
||||
/**
|
||||
* Restart all threads that are waiting on the condition variable.
|
||||
*
|
||||
* \return 0 or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
|
||||
|
||||
/**
|
||||
* Wait on the condition variable, unlocking the provided mutex.
|
||||
*
|
||||
* \warning The mutex must be locked before entering this function!
|
||||
*
|
||||
* The mutex is re-locked once the condition variable is signaled.
|
||||
*
|
||||
* \return 0 when it is signaled, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
|
||||
|
||||
/**
|
||||
* Waits for at most \c ms milliseconds, and returns 0 if the condition
|
||||
* variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not
|
||||
* signaled in the allotted time, and -1 on error.
|
||||
*
|
||||
* \warning On some platforms this function is implemented by looping with a
|
||||
* delay of 1 ms, and so should be avoided if possible.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
|
||||
SDL_mutex * mutex, Uint32 ms);
|
||||
|
||||
/*@}*//*Condition variable functions*/
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mutex_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
#ifndef _SDLname_h_
|
||||
#define _SDLname_h_
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define NeedFunctionPrototypes 1
|
||||
#endif
|
||||
|
||||
#define SDL_NAME(X) SDL_##X
|
||||
|
||||
#endif /* _SDLname_h_ */
|
File diff suppressed because it is too large
Load diff
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_opengles.h
|
||||
*
|
||||
* This is a simple file to encapsulate the OpenGL ES 1.X API headers.
|
||||
*/
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#include <OpenGLES/ES1/glext.h>
|
||||
#else
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#endif
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_opengles.h
|
||||
*
|
||||
* This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
|
||||
*/
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
|
@ -1,424 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_pixels.h
|
||||
*
|
||||
* Header for the enumerated pixel format definitions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_pixels_h
|
||||
#define _SDL_pixels_h
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name Transparency definitions
|
||||
*
|
||||
* These define alpha as the opacity of a surface.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_ALPHA_OPAQUE 255
|
||||
#define SDL_ALPHA_TRANSPARENT 0
|
||||
/*@}*/
|
||||
|
||||
/** Pixel type. */
|
||||
enum
|
||||
{
|
||||
SDL_PIXELTYPE_UNKNOWN,
|
||||
SDL_PIXELTYPE_INDEX1,
|
||||
SDL_PIXELTYPE_INDEX4,
|
||||
SDL_PIXELTYPE_INDEX8,
|
||||
SDL_PIXELTYPE_PACKED8,
|
||||
SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PIXELTYPE_ARRAYU8,
|
||||
SDL_PIXELTYPE_ARRAYU16,
|
||||
SDL_PIXELTYPE_ARRAYU32,
|
||||
SDL_PIXELTYPE_ARRAYF16,
|
||||
SDL_PIXELTYPE_ARRAYF32
|
||||
};
|
||||
|
||||
/** Bitmap pixel order, high bit -> low bit. */
|
||||
enum
|
||||
{
|
||||
SDL_BITMAPORDER_NONE,
|
||||
SDL_BITMAPORDER_4321,
|
||||
SDL_BITMAPORDER_1234
|
||||
};
|
||||
|
||||
/** Packed component order, high bit -> low bit. */
|
||||
enum
|
||||
{
|
||||
SDL_PACKEDORDER_NONE,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDORDER_RGBX,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDORDER_BGRX,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDORDER_BGRA
|
||||
};
|
||||
|
||||
/** Array component order, low byte -> high byte. */
|
||||
enum
|
||||
{
|
||||
SDL_ARRAYORDER_NONE,
|
||||
SDL_ARRAYORDER_RGB,
|
||||
SDL_ARRAYORDER_RGBA,
|
||||
SDL_ARRAYORDER_ARGB,
|
||||
SDL_ARRAYORDER_BGR,
|
||||
SDL_ARRAYORDER_BGRA,
|
||||
SDL_ARRAYORDER_ABGR
|
||||
};
|
||||
|
||||
/** Packed component layout. */
|
||||
enum
|
||||
{
|
||||
SDL_PACKEDLAYOUT_NONE,
|
||||
SDL_PACKEDLAYOUT_332,
|
||||
SDL_PACKEDLAYOUT_4444,
|
||||
SDL_PACKEDLAYOUT_1555,
|
||||
SDL_PACKEDLAYOUT_5551,
|
||||
SDL_PACKEDLAYOUT_565,
|
||||
SDL_PACKEDLAYOUT_8888,
|
||||
SDL_PACKEDLAYOUT_2101010,
|
||||
SDL_PACKEDLAYOUT_1010102
|
||||
};
|
||||
|
||||
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
|
||||
|
||||
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
|
||||
((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
|
||||
((bits) << 8) | ((bytes) << 0))
|
||||
|
||||
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
|
||||
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
|
||||
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
|
||||
#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
|
||||
#define SDL_BYTESPERPIXEL(X) \
|
||||
(SDL_ISPIXELFORMAT_FOURCC(X) ? \
|
||||
((((X) == SDL_PIXELFORMAT_YUY2) || \
|
||||
((X) == SDL_PIXELFORMAT_UYVY) || \
|
||||
((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
|
||||
|
||||
#define SDL_ISPIXELFORMAT_INDEXED(format) \
|
||||
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
|
||||
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
|
||||
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
|
||||
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
|
||||
|
||||
#define SDL_ISPIXELFORMAT_ALPHA(format) \
|
||||
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
|
||||
((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
|
||||
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
|
||||
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
|
||||
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
|
||||
|
||||
#define SDL_ISPIXELFORMAT_FOURCC(format) \
|
||||
((format) && !((format) & 0x80000000))
|
||||
|
||||
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
|
||||
enum
|
||||
{
|
||||
SDL_PIXELFORMAT_UNKNOWN,
|
||||
SDL_PIXELFORMAT_INDEX1LSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
|
||||
1, 0),
|
||||
SDL_PIXELFORMAT_INDEX1MSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
|
||||
1, 0),
|
||||
SDL_PIXELFORMAT_INDEX4LSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
|
||||
4, 0),
|
||||
SDL_PIXELFORMAT_INDEX4MSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
|
||||
4, 0),
|
||||
SDL_PIXELFORMAT_INDEX8 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
|
||||
SDL_PIXELFORMAT_RGB332 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_332, 8, 1),
|
||||
SDL_PIXELFORMAT_RGB444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_4444, 12, 2),
|
||||
SDL_PIXELFORMAT_RGB555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_BGR555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_ARGB4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_RGBA4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_ABGR4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_BGRA4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_ARGB1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2),
|
||||
SDL_PIXELFORMAT_RGBA5551 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_5551, 16, 2),
|
||||
SDL_PIXELFORMAT_ABGR1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2),
|
||||
SDL_PIXELFORMAT_BGRA5551 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_5551, 16, 2),
|
||||
SDL_PIXELFORMAT_RGB565 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2),
|
||||
SDL_PIXELFORMAT_BGR565 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2),
|
||||
SDL_PIXELFORMAT_RGB24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
|
||||
24, 3),
|
||||
SDL_PIXELFORMAT_BGR24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
|
||||
24, 3),
|
||||
SDL_PIXELFORMAT_RGB888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_BGR888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_ARGB8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_RGBA8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_ABGR8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_BGRA8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_ARGB2101010 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_2101010, 32, 4),
|
||||
|
||||
SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
||||
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
|
||||
SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
|
||||
SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
|
||||
SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
|
||||
};
|
||||
|
||||
typedef struct SDL_Color
|
||||
{
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 unused;
|
||||
} SDL_Color;
|
||||
#define SDL_Colour SDL_Color
|
||||
|
||||
typedef struct SDL_Palette
|
||||
{
|
||||
int ncolors;
|
||||
SDL_Color *colors;
|
||||
Uint32 version;
|
||||
int refcount;
|
||||
} SDL_Palette;
|
||||
|
||||
/**
|
||||
* \note Everything in the pixel format structure is read-only.
|
||||
*/
|
||||
typedef struct SDL_PixelFormat
|
||||
{
|
||||
Uint32 format;
|
||||
SDL_Palette *palette;
|
||||
Uint8 BitsPerPixel;
|
||||
Uint8 BytesPerPixel;
|
||||
Uint8 padding[2];
|
||||
Uint32 Rmask;
|
||||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
Uint8 Rloss;
|
||||
Uint8 Gloss;
|
||||
Uint8 Bloss;
|
||||
Uint8 Aloss;
|
||||
Uint8 Rshift;
|
||||
Uint8 Gshift;
|
||||
Uint8 Bshift;
|
||||
Uint8 Ashift;
|
||||
int refcount;
|
||||
struct SDL_PixelFormat *next;
|
||||
} SDL_PixelFormat;
|
||||
|
||||
/**
|
||||
* \brief Get the human readable name of a pixel format
|
||||
*/
|
||||
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
|
||||
|
||||
/**
|
||||
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
|
||||
*
|
||||
* \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
|
||||
*
|
||||
* \sa SDL_MasksToPixelFormatEnum()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
|
||||
int *bpp,
|
||||
Uint32 * Rmask,
|
||||
Uint32 * Gmask,
|
||||
Uint32 * Bmask,
|
||||
Uint32 * Amask);
|
||||
|
||||
/**
|
||||
* \brief Convert a bpp and RGBA masks to an enumerated pixel format.
|
||||
*
|
||||
* \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion
|
||||
* wasn't possible.
|
||||
*
|
||||
* \sa SDL_PixelFormatEnumToMasks()
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
|
||||
Uint32 Rmask,
|
||||
Uint32 Gmask,
|
||||
Uint32 Bmask,
|
||||
Uint32 Amask);
|
||||
|
||||
/**
|
||||
* \brief Create an SDL_PixelFormat structure from a pixel format enum.
|
||||
*/
|
||||
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
|
||||
|
||||
/**
|
||||
* \brief Free an SDL_PixelFormat structure.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
|
||||
|
||||
/**
|
||||
* \brief Create a palette structure with the specified number of color
|
||||
* entries.
|
||||
*
|
||||
* \return A new palette, or NULL if there wasn't enough memory.
|
||||
*
|
||||
* \note The palette entries are initialized to white.
|
||||
*
|
||||
* \sa SDL_FreePalette()
|
||||
*/
|
||||
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
|
||||
|
||||
/**
|
||||
* \brief Set the palette for a pixel format structure.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
|
||||
SDL_Palette *palette);
|
||||
|
||||
/**
|
||||
* \brief Set a range of colors in a palette.
|
||||
*
|
||||
* \param palette The palette to modify.
|
||||
* \param colors An array of colors to copy into the palette.
|
||||
* \param firstcolor The index of the first palette entry to modify.
|
||||
* \param ncolors The number of entries to modify.
|
||||
*
|
||||
* \return 0 on success, or -1 if not all of the colors could be set.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
* \brief Free a palette created with SDL_AllocPalette().
|
||||
*
|
||||
* \sa SDL_AllocPalette()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
|
||||
|
||||
/**
|
||||
* \brief Maps an RGB triple to an opaque pixel value for a given pixel format.
|
||||
*
|
||||
* \sa SDL_MapRGBA
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
|
||||
Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
/**
|
||||
* \brief Maps an RGBA quadruple to a pixel value for a given pixel format.
|
||||
*
|
||||
* \sa SDL_MapRGB
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
|
||||
Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a);
|
||||
|
||||
/**
|
||||
* \brief Get the RGB components from a pixel of the specified format.
|
||||
*
|
||||
* \sa SDL_GetRGBA
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b);
|
||||
|
||||
/**
|
||||
* \brief Get the RGBA components from a pixel of the specified format.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b,
|
||||
Uint8 * a);
|
||||
|
||||
/**
|
||||
* \brief Calculate a 256 entry gamma ramp for a gamma value.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_pixels_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_platform.h
|
||||
*
|
||||
* Try to get a standard set of platform defines.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_platform_h
|
||||
#define _SDL_platform_h
|
||||
|
||||
#if defined(_AIX)
|
||||
#undef __AIX__
|
||||
#define __AIX__ 1
|
||||
#endif
|
||||
#if defined(__BEOS__)
|
||||
#undef __BEOS__
|
||||
#define __BEOS__ 1
|
||||
#endif
|
||||
#if defined(__HAIKU__)
|
||||
#undef __HAIKU__
|
||||
#define __HAIKU__ 1
|
||||
#endif
|
||||
#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
|
||||
#undef __BSDI__
|
||||
#define __BSDI__ 1
|
||||
#endif
|
||||
#if defined(_arch_dreamcast)
|
||||
#undef __DREAMCAST__
|
||||
#define __DREAMCAST__ 1
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
||||
#undef __FREEBSD__
|
||||
#define __FREEBSD__ 1
|
||||
#endif
|
||||
#if defined(hpux) || defined(__hpux) || defined(__hpux__)
|
||||
#undef __HPUX__
|
||||
#define __HPUX__ 1
|
||||
#endif
|
||||
#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
|
||||
#undef __IRIX__
|
||||
#define __IRIX__ 1
|
||||
#endif
|
||||
#if defined(linux) || defined(__linux) || defined(__linux__)
|
||||
#undef __LINUX__
|
||||
#define __LINUX__ 1
|
||||
#endif
|
||||
#if defined(ANDROID)
|
||||
#undef __ANDROID__
|
||||
#undef __LINUX__ /*do we need to do this?*/
|
||||
#define __ANDROID__ 1
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* lets us know what version of Mac OS X we're compiling on */
|
||||
#include "AvailabilityMacros.h"
|
||||
#include "TargetConditionals.h"
|
||||
#ifndef MAC_OS_X_VERSION_10_4
|
||||
#define MAC_OS_X_VERSION_10_4 1040
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
#define MAC_OS_X_VERSION_10_5 1050
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_6
|
||||
#define MAC_OS_X_VERSION_10_6 1060
|
||||
#endif
|
||||
#if TARGET_OS_IPHONE
|
||||
/* if compiling for iPhone */
|
||||
#undef __IPHONEOS__
|
||||
#define __IPHONEOS__ 1
|
||||
#undef __MACOSX__
|
||||
#else
|
||||
/* if not compiling for iPhone */
|
||||
#undef __MACOSX__
|
||||
#define __MACOSX__ 1
|
||||
#endif /* TARGET_OS_IPHONE */
|
||||
#endif /* defined(__APPLE__) */
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#undef __NETBSD__
|
||||
#define __NETBSD__ 1
|
||||
#endif
|
||||
#if defined(__OpenBSD__)
|
||||
#undef __OPENBSD__
|
||||
#define __OPENBSD__ 1
|
||||
#endif
|
||||
#if defined(__OS2__)
|
||||
#undef __OS2__
|
||||
#define __OS2__ 1
|
||||
#endif
|
||||
#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
|
||||
#undef __OSF__
|
||||
#define __OSF__ 1
|
||||
#endif
|
||||
#if defined(__QNXNTO__)
|
||||
#undef __QNXNTO__
|
||||
#define __QNXNTO__ 1
|
||||
#endif
|
||||
#if defined(riscos) || defined(__riscos) || defined(__riscos__)
|
||||
#undef __RISCOS__
|
||||
#define __RISCOS__ 1
|
||||
#endif
|
||||
#if defined(__SVR4)
|
||||
#undef __SOLARIS__
|
||||
#define __SOLARIS__ 1
|
||||
#endif
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#undef __WIN32__
|
||||
#define __WIN32__ 1
|
||||
#endif
|
||||
|
||||
#if defined(__NDS__)
|
||||
#undef __NINTENDODS__
|
||||
#define __NINTENDODS__ 1
|
||||
#endif
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Gets the name of the platform.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_platform_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_power_h
|
||||
#define _SDL_power_h
|
||||
|
||||
/**
|
||||
* \file SDL_power.h
|
||||
*
|
||||
* Header for the SDL power management routines.
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The basic state for the system's power supply.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */
|
||||
SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
|
||||
SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
|
||||
SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */
|
||||
SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
||||
} SDL_PowerState;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the current power supply details.
|
||||
*
|
||||
* \param secs Seconds of battery life left. You can pass a NULL here if
|
||||
* you don't care. Will return -1 if we can't determine a
|
||||
* value, or we're not running on a battery.
|
||||
*
|
||||
* \param pct Percentage of battery life left, between 0 and 100. You can
|
||||
* pass a NULL here if you don't care. Will return -1 if we
|
||||
* can't determine a value, or we're not running on a battery.
|
||||
*
|
||||
* \return The state of the battery (if any).
|
||||
*/
|
||||
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_power_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_quit.h
|
||||
*
|
||||
* Include file for SDL quit event handling.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_quit_h
|
||||
#define _SDL_quit_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
/**
|
||||
* \file SDL_quit.h
|
||||
*
|
||||
* An ::SDL_QUIT event is generated when the user tries to close the application
|
||||
* window. If it is ignored or filtered out, the window will remain open.
|
||||
* If it is not ignored or filtered, it is queued normally and the window
|
||||
* is allowed to close. When the window is closed, screen updates will
|
||||
* complete, but have no effect.
|
||||
*
|
||||
* SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
|
||||
* and SIGTERM (system termination request), if handlers do not already
|
||||
* exist, that generate ::SDL_QUIT events as well. There is no way
|
||||
* to determine the cause of an ::SDL_QUIT event, but setting a signal
|
||||
* handler in your application will override the default generation of
|
||||
* quit events for that signal.
|
||||
*
|
||||
* \sa SDL_Quit()
|
||||
*/
|
||||
|
||||
/* There are no functions directly affecting the quit event */
|
||||
|
||||
#define SDL_QuitRequested() \
|
||||
(SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK))
|
||||
|
||||
#endif /* _SDL_quit_h */
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_rect.h
|
||||
*
|
||||
* Header file for SDL_rect definition and management functions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rect_h
|
||||
#define _SDL_rect_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The structure that defines a point
|
||||
*
|
||||
* \sa SDL_EnclosePoints
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} SDL_Point;
|
||||
|
||||
/**
|
||||
* \brief A rectangle, with the origin at the upper left.
|
||||
*
|
||||
* \sa SDL_RectEmpty
|
||||
* \sa SDL_RectEquals
|
||||
* \sa SDL_HasIntersection
|
||||
* \sa SDL_IntersectRect
|
||||
* \sa SDL_UnionRect
|
||||
* \sa SDL_EnclosePoints
|
||||
*/
|
||||
typedef struct SDL_Rect
|
||||
{
|
||||
int x, y;
|
||||
int w, h;
|
||||
} SDL_Rect;
|
||||
|
||||
/**
|
||||
* \brief Returns true if the rectangle has no area.
|
||||
*/
|
||||
#define SDL_RectEmpty(X) (((X)->w <= 0) || ((X)->h <= 0))
|
||||
|
||||
/**
|
||||
* \brief Returns true if the two rectangles are equal.
|
||||
*/
|
||||
#define SDL_RectEquals(A, B) (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
|
||||
((A)->w == (B)->w) && ((A)->h == (B)->h))
|
||||
|
||||
/**
|
||||
* \brief Determine whether two rectangles intersect.
|
||||
*
|
||||
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
|
||||
const SDL_Rect * B);
|
||||
|
||||
/**
|
||||
* \brief Calculate the intersection of two rectangles.
|
||||
*
|
||||
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
|
||||
const SDL_Rect * B,
|
||||
SDL_Rect * result);
|
||||
|
||||
/**
|
||||
* \brief Calculate the union of two rectangles.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
|
||||
const SDL_Rect * B,
|
||||
SDL_Rect * result);
|
||||
|
||||
/**
|
||||
* \brief Calculate a minimal rectangle enclosing a set of points
|
||||
*
|
||||
* \return SDL_TRUE if any points were within the clipping rect
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
|
||||
int count,
|
||||
const SDL_Rect * clip,
|
||||
SDL_Rect * result);
|
||||
|
||||
/**
|
||||
* \brief Calculate the intersection of a rectangle and line segment.
|
||||
*
|
||||
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
|
||||
rect, int *X1,
|
||||
int *Y1, int *X2,
|
||||
int *Y2);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_rect_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,611 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_render.h
|
||||
*
|
||||
* Header file for SDL 2D rendering functions.
|
||||
*
|
||||
* This API supports the following features:
|
||||
* * single pixel points
|
||||
* * single pixel lines
|
||||
* * filled rectangles
|
||||
* * texture images
|
||||
*
|
||||
* The primitives may be drawn in opaque, blended, or additive modes.
|
||||
*
|
||||
* The texture images may be drawn in opaque, blended, or additive modes.
|
||||
* They can have an additional color tint or alpha modulation applied to
|
||||
* them, and may also be stretched with linear interpolation.
|
||||
*
|
||||
* This API is designed to accelerate simple 2D operations. You may
|
||||
* want more functionality such as rotation and particle effects and
|
||||
* in that case you should use SDL's OpenGL/Direct3D support or one
|
||||
* of the many good 3D engines.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_render_h
|
||||
#define _SDL_render_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Flags used when creating a rendering context
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */
|
||||
SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware
|
||||
acceleration */
|
||||
SDL_RENDERER_PRESENTVSYNC = 0x00000004 /**< Present is synchronized
|
||||
with the refresh rate */
|
||||
} SDL_RendererFlags;
|
||||
|
||||
/**
|
||||
* \brief Information on the capabilities of a render driver or context.
|
||||
*/
|
||||
typedef struct SDL_RendererInfo
|
||||
{
|
||||
const char *name; /**< The name of the renderer */
|
||||
Uint32 flags; /**< Supported ::SDL_RendererFlags */
|
||||
Uint32 num_texture_formats; /**< The number of available texture formats */
|
||||
Uint32 texture_formats[16]; /**< The available texture formats */
|
||||
int max_texture_width; /**< The maximimum texture width */
|
||||
int max_texture_height; /**< The maximimum texture height */
|
||||
} SDL_RendererInfo;
|
||||
|
||||
/**
|
||||
* \brief The access pattern allowed for a texture.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
|
||||
SDL_TEXTUREACCESS_STREAMING /**< Changes frequently, lockable */
|
||||
} SDL_TextureAccess;
|
||||
|
||||
/**
|
||||
* \brief The texture channel modulation used in SDL_RenderCopy().
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */
|
||||
SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */
|
||||
SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */
|
||||
} SDL_TextureModulate;
|
||||
|
||||
/**
|
||||
* \brief A structure representing rendering state
|
||||
*/
|
||||
struct SDL_Renderer;
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
|
||||
/**
|
||||
* \brief An efficient driver-specific representation of pixel data
|
||||
*/
|
||||
struct SDL_Texture;
|
||||
typedef struct SDL_Texture SDL_Texture;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the number of 2D rendering drivers available for the current
|
||||
* display.
|
||||
*
|
||||
* A render driver is a set of code that handles rendering and texture
|
||||
* management on a particular display. Normally there is only one, but
|
||||
* some drivers may have several available with different capabilities.
|
||||
*
|
||||
* \sa SDL_GetRenderDriverInfo()
|
||||
* \sa SDL_CreateRenderer()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
|
||||
|
||||
/**
|
||||
* \brief Get information about a specific 2D rendering driver for the current
|
||||
* display.
|
||||
*
|
||||
* \param index The index of the driver to query information about.
|
||||
* \param info A pointer to an SDL_RendererInfo struct to be filled with
|
||||
* information on the rendering driver.
|
||||
*
|
||||
* \return 0 on success, -1 if the index was out of range.
|
||||
*
|
||||
* \sa SDL_CreateRenderer()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
|
||||
SDL_RendererInfo * info);
|
||||
|
||||
/**
|
||||
* \brief Create a 2D rendering context for a window.
|
||||
*
|
||||
* \param window The window where rendering is displayed.
|
||||
* \param index The index of the rendering driver to initialize, or -1 to
|
||||
* initialize the first one supporting the requested flags.
|
||||
* \param flags ::SDL_RendererFlags.
|
||||
*
|
||||
* \return A valid rendering context or NULL if there was an error.
|
||||
*
|
||||
* \sa SDL_CreateSoftwareRenderer()
|
||||
* \sa SDL_GetRendererInfo()
|
||||
* \sa SDL_DestroyRenderer()
|
||||
*/
|
||||
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
|
||||
int index, Uint32 flags);
|
||||
|
||||
/**
|
||||
* \brief Create a 2D software rendering context for a surface.
|
||||
*
|
||||
* \param surface The surface where rendering is done.
|
||||
*
|
||||
* \return A valid rendering context or NULL if there was an error.
|
||||
*
|
||||
* \sa SDL_CreateRenderer()
|
||||
* \sa SDL_DestroyRenderer()
|
||||
*/
|
||||
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
|
||||
|
||||
/**
|
||||
* \brief Get information about a rendering context.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
|
||||
SDL_RendererInfo * info);
|
||||
|
||||
/**
|
||||
* \brief Create a texture for a rendering context.
|
||||
*
|
||||
* \param format The format of the texture.
|
||||
* \param access One of the enumerated values in ::SDL_TextureAccess.
|
||||
* \param w The width of the texture in pixels.
|
||||
* \param h The height of the texture in pixels.
|
||||
*
|
||||
* \return The created texture is returned, or 0 if no rendering context was
|
||||
* active, the format was unsupported, or the width or height were out
|
||||
* of range.
|
||||
*
|
||||
* \sa SDL_QueryTexture()
|
||||
* \sa SDL_UpdateTexture()
|
||||
* \sa SDL_DestroyTexture()
|
||||
*/
|
||||
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
|
||||
Uint32 format,
|
||||
int access, int w,
|
||||
int h);
|
||||
|
||||
/**
|
||||
* \brief Create a texture from an existing surface.
|
||||
*
|
||||
* \param surface The surface containing pixel data used to fill the texture.
|
||||
*
|
||||
* \return The created texture is returned, or 0 on error.
|
||||
*
|
||||
* \note The surface is not modified or freed by this function.
|
||||
*
|
||||
* \sa SDL_QueryTexture()
|
||||
* \sa SDL_DestroyTexture()
|
||||
*/
|
||||
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
|
||||
|
||||
/**
|
||||
* \brief Query the attributes of a texture
|
||||
*
|
||||
* \param texture A texture to be queried.
|
||||
* \param format A pointer filled in with the raw format of the texture. The
|
||||
* actual format may differ, but pixel transfers will use this
|
||||
* format.
|
||||
* \param access A pointer filled in with the actual access to the texture.
|
||||
* \param w A pointer filled in with the width of the texture in pixels.
|
||||
* \param h A pointer filled in with the height of the texture in pixels.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
|
||||
Uint32 * format, int *access,
|
||||
int *w, int *h);
|
||||
|
||||
/**
|
||||
* \brief Set an additional color value used in render copy operations.
|
||||
*
|
||||
* \param texture The texture to update.
|
||||
* \param r The red color value multiplied into copy operations.
|
||||
* \param g The green color value multiplied into copy operations.
|
||||
* \param b The blue color value multiplied into copy operations.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid or color modulation
|
||||
* is not supported.
|
||||
*
|
||||
* \sa SDL_GetTextureColorMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
|
||||
Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the additional color value used in render copy operations.
|
||||
*
|
||||
* \param texture The texture to query.
|
||||
* \param r A pointer filled in with the current red color value.
|
||||
* \param g A pointer filled in with the current green color value.
|
||||
* \param b A pointer filled in with the current blue color value.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid.
|
||||
*
|
||||
* \sa SDL_SetTextureColorMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
|
||||
Uint8 * r, Uint8 * g,
|
||||
Uint8 * b);
|
||||
|
||||
/**
|
||||
* \brief Set an additional alpha value used in render copy operations.
|
||||
*
|
||||
* \param texture The texture to update.
|
||||
* \param alpha The alpha value multiplied into copy operations.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid or alpha modulation
|
||||
* is not supported.
|
||||
*
|
||||
* \sa SDL_GetTextureAlphaMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
|
||||
Uint8 alpha);
|
||||
|
||||
/**
|
||||
* \brief Get the additional alpha value used in render copy operations.
|
||||
*
|
||||
* \param texture The texture to query.
|
||||
* \param alpha A pointer filled in with the current alpha value.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid.
|
||||
*
|
||||
* \sa SDL_SetTextureAlphaMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
|
||||
Uint8 * alpha);
|
||||
|
||||
/**
|
||||
* \brief Set the blend mode used for texture copy operations.
|
||||
*
|
||||
* \param texture The texture to update.
|
||||
* \param blendMode ::SDL_BlendMode to use for texture blending.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid or the blend mode is
|
||||
* not supported.
|
||||
*
|
||||
* \note If the blend mode is not supported, the closest supported mode is
|
||||
* chosen.
|
||||
*
|
||||
* \sa SDL_GetTextureBlendMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
|
||||
SDL_BlendMode blendMode);
|
||||
|
||||
/**
|
||||
* \brief Get the blend mode used for texture copy operations.
|
||||
*
|
||||
* \param texture The texture to query.
|
||||
* \param blendMode A pointer filled in with the current blend mode.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid.
|
||||
*
|
||||
* \sa SDL_SetTextureBlendMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
|
||||
SDL_BlendMode *blendMode);
|
||||
|
||||
/**
|
||||
* \brief Update the given texture rectangle with new pixel data.
|
||||
*
|
||||
* \param texture The texture to update
|
||||
* \param rect A pointer to the rectangle of pixels to update, or NULL to
|
||||
* update the entire texture.
|
||||
* \param pixels The raw pixel data.
|
||||
* \param pitch The number of bytes between rows of pixel data.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid.
|
||||
*
|
||||
* \note This is a fairly slow function.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const void *pixels, int pitch);
|
||||
|
||||
/**
|
||||
* \brief Lock a portion of the texture for pixel access.
|
||||
*
|
||||
* \param texture The texture to lock for access, which was created with
|
||||
* ::SDL_TEXTUREACCESS_STREAMING.
|
||||
* \param rect A pointer to the rectangle to lock for access. If the rect
|
||||
* is NULL, the entire texture will be locked.
|
||||
* \param pixels This is filled in with a pointer to the locked pixels,
|
||||
* appropriately offset by the locked area.
|
||||
* \param pitch This is filled in with the pitch of the locked pixels.
|
||||
*
|
||||
* \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
|
||||
*
|
||||
* \sa SDL_UnlockTexture()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
void **pixels, int *pitch);
|
||||
|
||||
/**
|
||||
* \brief Unlock a texture, uploading the changes to video memory, if needed.
|
||||
*
|
||||
* \sa SDL_LockTexture()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
|
||||
|
||||
/**
|
||||
* \brief Set the drawing area for rendering on the current target.
|
||||
*
|
||||
* \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
|
||||
*
|
||||
* The x,y of the viewport rect represents the origin for rendering.
|
||||
*
|
||||
* \note When the window is resized, the current viewport is automatically
|
||||
* centered within the new window size.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
|
||||
const SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Get the drawing area for the current target.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
|
||||
SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Set the color used for drawing operations (Fill and Line).
|
||||
*
|
||||
* \param r The red value used to draw on the rendering target.
|
||||
* \param g The green value used to draw on the rendering target.
|
||||
* \param b The blue value used to draw on the rendering target.
|
||||
* \param a The alpha value used to draw on the rendering target, usually
|
||||
* ::SDL_ALPHA_OPAQUE (255).
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer,
|
||||
Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a);
|
||||
|
||||
/**
|
||||
* \brief Get the color used for drawing operations (Fill and Line).
|
||||
*
|
||||
* \param r A pointer to the red value used to draw on the rendering target.
|
||||
* \param g A pointer to the green value used to draw on the rendering target.
|
||||
* \param b A pointer to the blue value used to draw on the rendering target.
|
||||
* \param a A pointer to the alpha value used to draw on the rendering target,
|
||||
* usually ::SDL_ALPHA_OPAQUE (255).
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b,
|
||||
Uint8 * a);
|
||||
|
||||
/**
|
||||
* \brief Set the blend mode used for drawing operations (Fill and Line).
|
||||
*
|
||||
* \param blendMode ::SDL_BlendMode to use for blending.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*
|
||||
* \note If the blend mode is not supported, the closest supported mode is
|
||||
* chosen.
|
||||
*
|
||||
* \sa SDL_GetRenderDrawBlendMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
|
||||
SDL_BlendMode blendMode);
|
||||
|
||||
/**
|
||||
* \brief Get the blend mode used for drawing operations.
|
||||
*
|
||||
* \param blendMode A pointer filled in with the current blend mode.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*
|
||||
* \sa SDL_SetRenderDrawBlendMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
|
||||
SDL_BlendMode *blendMode);
|
||||
|
||||
/**
|
||||
* \brief Clear the current rendering target with the drawing color
|
||||
*
|
||||
* This function clears the entire rendering target, ignoring the viewport.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
|
||||
|
||||
/**
|
||||
* \brief Draw a point on the current rendering target.
|
||||
*
|
||||
* \param x The x coordinate of the point.
|
||||
* \param y The y coordinate of the point.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
|
||||
int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Draw multiple points on the current rendering target.
|
||||
*
|
||||
* \param points The points to draw
|
||||
* \param count The number of points to draw
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
const SDL_Point * points,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* \brief Draw a line on the current rendering target.
|
||||
*
|
||||
* \param x1 The x coordinate of the start point.
|
||||
* \param y1 The y coordinate of the start point.
|
||||
* \param x2 The x coordinate of the end point.
|
||||
* \param y2 The y coordinate of the end point.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
|
||||
int x1, int y1, int x2, int y2);
|
||||
|
||||
/**
|
||||
* \brief Draw a series of connected lines on the current rendering target.
|
||||
*
|
||||
* \param points The points along the lines
|
||||
* \param count The number of points, drawing count-1 lines
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
|
||||
const SDL_Point * points,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* \brief Draw a rectangle on the current rendering target.
|
||||
*
|
||||
* \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
|
||||
const SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Draw some number of rectangles on the current rendering target.
|
||||
*
|
||||
* \param rects A pointer to an array of destination rectangles.
|
||||
* \param count The number of rectangles.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
|
||||
const SDL_Rect * rects,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* \brief Fill a rectangle on the current rendering target with the drawing color.
|
||||
*
|
||||
* \param rect A pointer to the destination rectangle, or NULL for the entire
|
||||
* rendering target.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
|
||||
const SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Fill some number of rectangles on the current rendering target with the drawing color.
|
||||
*
|
||||
* \param rects A pointer to an array of destination rectangles.
|
||||
* \param count The number of rectangles.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
|
||||
const SDL_Rect * rects,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* \brief Copy a portion of the texture to the current rendering target.
|
||||
*
|
||||
* \param texture The source texture.
|
||||
* \param srcrect A pointer to the source rectangle, or NULL for the entire
|
||||
* texture.
|
||||
* \param dstrect A pointer to the destination rectangle, or NULL for the
|
||||
* entire rendering target.
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect,
|
||||
const SDL_Rect * dstrect);
|
||||
|
||||
/**
|
||||
* \brief Read pixels from the current rendering target.
|
||||
*
|
||||
* \param rect A pointer to the rectangle to read, or NULL for the entire
|
||||
* render target.
|
||||
* \param format The desired format of the pixel data, or 0 to use the format
|
||||
* of the rendering target
|
||||
* \param pixels A pointer to be filled in with the pixel data
|
||||
* \param pitch The pitch of the pixels parameter.
|
||||
*
|
||||
* \return 0 on success, or -1 if pixel reading is not supported.
|
||||
*
|
||||
* \warning This is a very slow operation, and should not be used frequently.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
|
||||
const SDL_Rect * rect,
|
||||
Uint32 format,
|
||||
void *pixels, int pitch);
|
||||
|
||||
/**
|
||||
* \brief Update the screen with rendering performed.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
|
||||
|
||||
/**
|
||||
* \brief Destroy the specified texture.
|
||||
*
|
||||
* \sa SDL_CreateTexture()
|
||||
* \sa SDL_CreateTextureFromSurface()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
|
||||
|
||||
/**
|
||||
* \brief Destroy the rendering context for a window and free associated
|
||||
* textures.
|
||||
*
|
||||
* \sa SDL_CreateRenderer()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_render_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,2 +0,0 @@
|
|||
#define SDL_REVISION "hg-0:aaaaaaaaaaah"
|
||||
#define SDL_REVISION_NUMBER 0
|
|
@ -1,206 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_rwops.h
|
||||
*
|
||||
* This file provides a general interface for SDL to read and write
|
||||
* data streams. It can easily be extended to files, memory, etc.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rwops_h
|
||||
#define _SDL_rwops_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the read/write operation structure -- very basic.
|
||||
*/
|
||||
typedef struct SDL_RWops
|
||||
{
|
||||
/**
|
||||
* Seek to \c offset relative to \c whence, one of stdio's whence values:
|
||||
* RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
|
||||
*
|
||||
* \return the final offset in the data stream.
|
||||
*/
|
||||
long (SDLCALL * seek) (struct SDL_RWops * context, long offset,
|
||||
int whence);
|
||||
|
||||
/**
|
||||
* Read up to \c maxnum objects each of size \c size from the data
|
||||
* stream to the area pointed at by \c ptr.
|
||||
*
|
||||
* \return the number of objects read, or 0 at error or end of file.
|
||||
*/
|
||||
size_t(SDLCALL * read) (struct SDL_RWops * context, void *ptr,
|
||||
size_t size, size_t maxnum);
|
||||
|
||||
/**
|
||||
* Write exactly \c num objects each of size \c size from the area
|
||||
* pointed at by \c ptr to data stream.
|
||||
*
|
||||
* \return the number of objects written, or 0 at error or end of file.
|
||||
*/
|
||||
size_t(SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
|
||||
size_t size, size_t num);
|
||||
|
||||
/**
|
||||
* Close and free an allocated SDL_RWops structure.
|
||||
*
|
||||
* \return 0 if successful or -1 on write error when flushing data.
|
||||
*/
|
||||
int (SDLCALL * close) (struct SDL_RWops * context);
|
||||
|
||||
Uint32 type;
|
||||
union
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
struct
|
||||
{
|
||||
SDL_bool append;
|
||||
void *h;
|
||||
struct
|
||||
{
|
||||
void *data;
|
||||
size_t size;
|
||||
size_t left;
|
||||
} buffer;
|
||||
} windowsio;
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
struct
|
||||
{
|
||||
SDL_bool autoclose;
|
||||
FILE *fp;
|
||||
} stdio;
|
||||
#endif
|
||||
struct
|
||||
{
|
||||
Uint8 *base;
|
||||
Uint8 *here;
|
||||
Uint8 *stop;
|
||||
} mem;
|
||||
struct
|
||||
{
|
||||
void *data1;
|
||||
} unknown;
|
||||
} hidden;
|
||||
|
||||
} SDL_RWops;
|
||||
|
||||
|
||||
/**
|
||||
* \name RWFrom functions
|
||||
*
|
||||
* Functions to create SDL_RWops structures from various data streams.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
|
||||
const char *mode);
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp,
|
||||
SDL_bool autoclose);
|
||||
#else
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp,
|
||||
SDL_bool autoclose);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem,
|
||||
int size);
|
||||
|
||||
/*@}*//*RWFrom functions*/
|
||||
|
||||
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
|
||||
|
||||
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */
|
||||
#define RW_SEEK_CUR 1 /**< Seek relative to current read point */
|
||||
#define RW_SEEK_END 2 /**< Seek relative to the end of data */
|
||||
|
||||
/**
|
||||
* \name Read/write macros
|
||||
*
|
||||
* Macros to easily read and write from an SDL_RWops structure.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
|
||||
#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
|
||||
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
|
||||
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
|
||||
#define SDL_RWclose(ctx) (ctx)->close(ctx)
|
||||
/*@}*//*Read/write macros*/
|
||||
|
||||
|
||||
/**
|
||||
* \name Read endian functions
|
||||
*
|
||||
* Read an item of the specified endianness and return in native format.
|
||||
*/
|
||||
/*@{*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src);
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src);
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
|
||||
/*@}*//*Read endian functions*/
|
||||
|
||||
/**
|
||||
* \name Write endian functions
|
||||
*
|
||||
* Write an item of native format to the specified endianness.
|
||||
*/
|
||||
/*@{*/
|
||||
extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
|
||||
extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
|
||||
extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
|
||||
extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value);
|
||||
extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value);
|
||||
extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value);
|
||||
/*@}*//*Write endian functions*/
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_rwops_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,399 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_scancode.h
|
||||
*
|
||||
* Defines keyboard scancodes.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_scancode_h
|
||||
#define _SDL_scancode_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/**
|
||||
* \brief The SDL keyboard scancode representation.
|
||||
*
|
||||
* Values of this type are used to represent keyboard keys, among other places
|
||||
* in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the
|
||||
* SDL_Event structure.
|
||||
*
|
||||
* The values in this enumeration are based on the USB usage page standard:
|
||||
* http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_SCANCODE_UNKNOWN = 0,
|
||||
|
||||
/**
|
||||
* \name Usage page 0x07
|
||||
*
|
||||
* These values are from usage page 0x07 (USB keyboard page).
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
SDL_SCANCODE_A = 4,
|
||||
SDL_SCANCODE_B = 5,
|
||||
SDL_SCANCODE_C = 6,
|
||||
SDL_SCANCODE_D = 7,
|
||||
SDL_SCANCODE_E = 8,
|
||||
SDL_SCANCODE_F = 9,
|
||||
SDL_SCANCODE_G = 10,
|
||||
SDL_SCANCODE_H = 11,
|
||||
SDL_SCANCODE_I = 12,
|
||||
SDL_SCANCODE_J = 13,
|
||||
SDL_SCANCODE_K = 14,
|
||||
SDL_SCANCODE_L = 15,
|
||||
SDL_SCANCODE_M = 16,
|
||||
SDL_SCANCODE_N = 17,
|
||||
SDL_SCANCODE_O = 18,
|
||||
SDL_SCANCODE_P = 19,
|
||||
SDL_SCANCODE_Q = 20,
|
||||
SDL_SCANCODE_R = 21,
|
||||
SDL_SCANCODE_S = 22,
|
||||
SDL_SCANCODE_T = 23,
|
||||
SDL_SCANCODE_U = 24,
|
||||
SDL_SCANCODE_V = 25,
|
||||
SDL_SCANCODE_W = 26,
|
||||
SDL_SCANCODE_X = 27,
|
||||
SDL_SCANCODE_Y = 28,
|
||||
SDL_SCANCODE_Z = 29,
|
||||
|
||||
SDL_SCANCODE_1 = 30,
|
||||
SDL_SCANCODE_2 = 31,
|
||||
SDL_SCANCODE_3 = 32,
|
||||
SDL_SCANCODE_4 = 33,
|
||||
SDL_SCANCODE_5 = 34,
|
||||
SDL_SCANCODE_6 = 35,
|
||||
SDL_SCANCODE_7 = 36,
|
||||
SDL_SCANCODE_8 = 37,
|
||||
SDL_SCANCODE_9 = 38,
|
||||
SDL_SCANCODE_0 = 39,
|
||||
|
||||
SDL_SCANCODE_RETURN = 40,
|
||||
SDL_SCANCODE_ESCAPE = 41,
|
||||
SDL_SCANCODE_BACKSPACE = 42,
|
||||
SDL_SCANCODE_TAB = 43,
|
||||
SDL_SCANCODE_SPACE = 44,
|
||||
|
||||
SDL_SCANCODE_MINUS = 45,
|
||||
SDL_SCANCODE_EQUALS = 46,
|
||||
SDL_SCANCODE_LEFTBRACKET = 47,
|
||||
SDL_SCANCODE_RIGHTBRACKET = 48,
|
||||
SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return
|
||||
* key on ISO keyboards and at the right end
|
||||
* of the QWERTY row on ANSI keyboards.
|
||||
* Produces REVERSE SOLIDUS (backslash) and
|
||||
* VERTICAL LINE in a US layout, REVERSE
|
||||
* SOLIDUS and VERTICAL LINE in a UK Mac
|
||||
* layout, NUMBER SIGN and TILDE in a UK
|
||||
* Windows layout, DOLLAR SIGN and POUND SIGN
|
||||
* in a Swiss German layout, NUMBER SIGN and
|
||||
* APOSTROPHE in a German layout, GRAVE
|
||||
* ACCENT and POUND SIGN in a French Mac
|
||||
* layout, and ASTERISK and MICRO SIGN in a
|
||||
* French Windows layout.
|
||||
*/
|
||||
SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code
|
||||
* instead of 49 for the same key, but all
|
||||
* OSes I've seen treat the two codes
|
||||
* identically. So, as an implementor, unless
|
||||
* your keyboard generates both of those
|
||||
* codes and your OS treats them differently,
|
||||
* you should generate SDL_SCANCODE_BACKSLASH
|
||||
* instead of this code. As a user, you
|
||||
* should not rely on this code because SDL
|
||||
* will never generate it with most (all?)
|
||||
* keyboards.
|
||||
*/
|
||||
SDL_SCANCODE_SEMICOLON = 51,
|
||||
SDL_SCANCODE_APOSTROPHE = 52,
|
||||
SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI
|
||||
* and ISO keyboards). Produces GRAVE ACCENT and
|
||||
* TILDE in a US Windows layout and in US and UK
|
||||
* Mac layouts on ANSI keyboards, GRAVE ACCENT
|
||||
* and NOT SIGN in a UK Windows layout, SECTION
|
||||
* SIGN and PLUS-MINUS SIGN in US and UK Mac
|
||||
* layouts on ISO keyboards, SECTION SIGN and
|
||||
* DEGREE SIGN in a Swiss German layout (Mac:
|
||||
* only on ISO keyboards), CIRCUMFLEX ACCENT and
|
||||
* DEGREE SIGN in a German layout (Mac: only on
|
||||
* ISO keyboards), SUPERSCRIPT TWO and TILDE in a
|
||||
* French Windows layout, COMMERCIAL AT and
|
||||
* NUMBER SIGN in a French Mac layout on ISO
|
||||
* keyboards, and LESS-THAN SIGN and GREATER-THAN
|
||||
* SIGN in a Swiss German, German, or French Mac
|
||||
* layout on ANSI keyboards.
|
||||
*/
|
||||
SDL_SCANCODE_COMMA = 54,
|
||||
SDL_SCANCODE_PERIOD = 55,
|
||||
SDL_SCANCODE_SLASH = 56,
|
||||
|
||||
SDL_SCANCODE_CAPSLOCK = 57,
|
||||
|
||||
SDL_SCANCODE_F1 = 58,
|
||||
SDL_SCANCODE_F2 = 59,
|
||||
SDL_SCANCODE_F3 = 60,
|
||||
SDL_SCANCODE_F4 = 61,
|
||||
SDL_SCANCODE_F5 = 62,
|
||||
SDL_SCANCODE_F6 = 63,
|
||||
SDL_SCANCODE_F7 = 64,
|
||||
SDL_SCANCODE_F8 = 65,
|
||||
SDL_SCANCODE_F9 = 66,
|
||||
SDL_SCANCODE_F10 = 67,
|
||||
SDL_SCANCODE_F11 = 68,
|
||||
SDL_SCANCODE_F12 = 69,
|
||||
|
||||
SDL_SCANCODE_PRINTSCREEN = 70,
|
||||
SDL_SCANCODE_SCROLLLOCK = 71,
|
||||
SDL_SCANCODE_PAUSE = 72,
|
||||
SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but
|
||||
does send code 73, not 117) */
|
||||
SDL_SCANCODE_HOME = 74,
|
||||
SDL_SCANCODE_PAGEUP = 75,
|
||||
SDL_SCANCODE_DELETE = 76,
|
||||
SDL_SCANCODE_END = 77,
|
||||
SDL_SCANCODE_PAGEDOWN = 78,
|
||||
SDL_SCANCODE_RIGHT = 79,
|
||||
SDL_SCANCODE_LEFT = 80,
|
||||
SDL_SCANCODE_DOWN = 81,
|
||||
SDL_SCANCODE_UP = 82,
|
||||
|
||||
SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards
|
||||
*/
|
||||
SDL_SCANCODE_KP_DIVIDE = 84,
|
||||
SDL_SCANCODE_KP_MULTIPLY = 85,
|
||||
SDL_SCANCODE_KP_MINUS = 86,
|
||||
SDL_SCANCODE_KP_PLUS = 87,
|
||||
SDL_SCANCODE_KP_ENTER = 88,
|
||||
SDL_SCANCODE_KP_1 = 89,
|
||||
SDL_SCANCODE_KP_2 = 90,
|
||||
SDL_SCANCODE_KP_3 = 91,
|
||||
SDL_SCANCODE_KP_4 = 92,
|
||||
SDL_SCANCODE_KP_5 = 93,
|
||||
SDL_SCANCODE_KP_6 = 94,
|
||||
SDL_SCANCODE_KP_7 = 95,
|
||||
SDL_SCANCODE_KP_8 = 96,
|
||||
SDL_SCANCODE_KP_9 = 97,
|
||||
SDL_SCANCODE_KP_0 = 98,
|
||||
SDL_SCANCODE_KP_PERIOD = 99,
|
||||
|
||||
SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
|
||||
* keyboards have over ANSI ones,
|
||||
* located between left shift and Y.
|
||||
* Produces GRAVE ACCENT and TILDE in a
|
||||
* US or UK Mac layout, REVERSE SOLIDUS
|
||||
* (backslash) and VERTICAL LINE in a
|
||||
* US or UK Windows layout, and
|
||||
* LESS-THAN SIGN and GREATER-THAN SIGN
|
||||
* in a Swiss German, German, or French
|
||||
* layout. */
|
||||
SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */
|
||||
SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag,
|
||||
* not a physical key - but some Mac keyboards
|
||||
* do have a power key. */
|
||||
SDL_SCANCODE_KP_EQUALS = 103,
|
||||
SDL_SCANCODE_F13 = 104,
|
||||
SDL_SCANCODE_F14 = 105,
|
||||
SDL_SCANCODE_F15 = 106,
|
||||
SDL_SCANCODE_F16 = 107,
|
||||
SDL_SCANCODE_F17 = 108,
|
||||
SDL_SCANCODE_F18 = 109,
|
||||
SDL_SCANCODE_F19 = 110,
|
||||
SDL_SCANCODE_F20 = 111,
|
||||
SDL_SCANCODE_F21 = 112,
|
||||
SDL_SCANCODE_F22 = 113,
|
||||
SDL_SCANCODE_F23 = 114,
|
||||
SDL_SCANCODE_F24 = 115,
|
||||
SDL_SCANCODE_EXECUTE = 116,
|
||||
SDL_SCANCODE_HELP = 117,
|
||||
SDL_SCANCODE_MENU = 118,
|
||||
SDL_SCANCODE_SELECT = 119,
|
||||
SDL_SCANCODE_STOP = 120,
|
||||
SDL_SCANCODE_AGAIN = 121, /**< redo */
|
||||
SDL_SCANCODE_UNDO = 122,
|
||||
SDL_SCANCODE_CUT = 123,
|
||||
SDL_SCANCODE_COPY = 124,
|
||||
SDL_SCANCODE_PASTE = 125,
|
||||
SDL_SCANCODE_FIND = 126,
|
||||
SDL_SCANCODE_MUTE = 127,
|
||||
SDL_SCANCODE_VOLUMEUP = 128,
|
||||
SDL_SCANCODE_VOLUMEDOWN = 129,
|
||||
/* not sure whether there's a reason to enable these */
|
||||
/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
|
||||
/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
|
||||
/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
|
||||
SDL_SCANCODE_KP_COMMA = 133,
|
||||
SDL_SCANCODE_KP_EQUALSAS400 = 134,
|
||||
|
||||
SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see
|
||||
footnotes in USB doc */
|
||||
SDL_SCANCODE_INTERNATIONAL2 = 136,
|
||||
SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */
|
||||
SDL_SCANCODE_INTERNATIONAL4 = 138,
|
||||
SDL_SCANCODE_INTERNATIONAL5 = 139,
|
||||
SDL_SCANCODE_INTERNATIONAL6 = 140,
|
||||
SDL_SCANCODE_INTERNATIONAL7 = 141,
|
||||
SDL_SCANCODE_INTERNATIONAL8 = 142,
|
||||
SDL_SCANCODE_INTERNATIONAL9 = 143,
|
||||
SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */
|
||||
SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */
|
||||
SDL_SCANCODE_LANG3 = 146, /**< Katakana */
|
||||
SDL_SCANCODE_LANG4 = 147, /**< Hiragana */
|
||||
SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */
|
||||
SDL_SCANCODE_LANG6 = 149, /**< reserved */
|
||||
SDL_SCANCODE_LANG7 = 150, /**< reserved */
|
||||
SDL_SCANCODE_LANG8 = 151, /**< reserved */
|
||||
SDL_SCANCODE_LANG9 = 152, /**< reserved */
|
||||
|
||||
SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */
|
||||
SDL_SCANCODE_SYSREQ = 154,
|
||||
SDL_SCANCODE_CANCEL = 155,
|
||||
SDL_SCANCODE_CLEAR = 156,
|
||||
SDL_SCANCODE_PRIOR = 157,
|
||||
SDL_SCANCODE_RETURN2 = 158,
|
||||
SDL_SCANCODE_SEPARATOR = 159,
|
||||
SDL_SCANCODE_OUT = 160,
|
||||
SDL_SCANCODE_OPER = 161,
|
||||
SDL_SCANCODE_CLEARAGAIN = 162,
|
||||
SDL_SCANCODE_CRSEL = 163,
|
||||
SDL_SCANCODE_EXSEL = 164,
|
||||
|
||||
SDL_SCANCODE_KP_00 = 176,
|
||||
SDL_SCANCODE_KP_000 = 177,
|
||||
SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
|
||||
SDL_SCANCODE_DECIMALSEPARATOR = 179,
|
||||
SDL_SCANCODE_CURRENCYUNIT = 180,
|
||||
SDL_SCANCODE_CURRENCYSUBUNIT = 181,
|
||||
SDL_SCANCODE_KP_LEFTPAREN = 182,
|
||||
SDL_SCANCODE_KP_RIGHTPAREN = 183,
|
||||
SDL_SCANCODE_KP_LEFTBRACE = 184,
|
||||
SDL_SCANCODE_KP_RIGHTBRACE = 185,
|
||||
SDL_SCANCODE_KP_TAB = 186,
|
||||
SDL_SCANCODE_KP_BACKSPACE = 187,
|
||||
SDL_SCANCODE_KP_A = 188,
|
||||
SDL_SCANCODE_KP_B = 189,
|
||||
SDL_SCANCODE_KP_C = 190,
|
||||
SDL_SCANCODE_KP_D = 191,
|
||||
SDL_SCANCODE_KP_E = 192,
|
||||
SDL_SCANCODE_KP_F = 193,
|
||||
SDL_SCANCODE_KP_XOR = 194,
|
||||
SDL_SCANCODE_KP_POWER = 195,
|
||||
SDL_SCANCODE_KP_PERCENT = 196,
|
||||
SDL_SCANCODE_KP_LESS = 197,
|
||||
SDL_SCANCODE_KP_GREATER = 198,
|
||||
SDL_SCANCODE_KP_AMPERSAND = 199,
|
||||
SDL_SCANCODE_KP_DBLAMPERSAND = 200,
|
||||
SDL_SCANCODE_KP_VERTICALBAR = 201,
|
||||
SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
|
||||
SDL_SCANCODE_KP_COLON = 203,
|
||||
SDL_SCANCODE_KP_HASH = 204,
|
||||
SDL_SCANCODE_KP_SPACE = 205,
|
||||
SDL_SCANCODE_KP_AT = 206,
|
||||
SDL_SCANCODE_KP_EXCLAM = 207,
|
||||
SDL_SCANCODE_KP_MEMSTORE = 208,
|
||||
SDL_SCANCODE_KP_MEMRECALL = 209,
|
||||
SDL_SCANCODE_KP_MEMCLEAR = 210,
|
||||
SDL_SCANCODE_KP_MEMADD = 211,
|
||||
SDL_SCANCODE_KP_MEMSUBTRACT = 212,
|
||||
SDL_SCANCODE_KP_MEMMULTIPLY = 213,
|
||||
SDL_SCANCODE_KP_MEMDIVIDE = 214,
|
||||
SDL_SCANCODE_KP_PLUSMINUS = 215,
|
||||
SDL_SCANCODE_KP_CLEAR = 216,
|
||||
SDL_SCANCODE_KP_CLEARENTRY = 217,
|
||||
SDL_SCANCODE_KP_BINARY = 218,
|
||||
SDL_SCANCODE_KP_OCTAL = 219,
|
||||
SDL_SCANCODE_KP_DECIMAL = 220,
|
||||
SDL_SCANCODE_KP_HEXADECIMAL = 221,
|
||||
|
||||
SDL_SCANCODE_LCTRL = 224,
|
||||
SDL_SCANCODE_LSHIFT = 225,
|
||||
SDL_SCANCODE_LALT = 226, /**< alt, option */
|
||||
SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */
|
||||
SDL_SCANCODE_RCTRL = 228,
|
||||
SDL_SCANCODE_RSHIFT = 229,
|
||||
SDL_SCANCODE_RALT = 230, /**< alt gr, option */
|
||||
SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */
|
||||
|
||||
SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered
|
||||
* by any of the above, but since there's a
|
||||
* special KMOD_MODE for it I'm adding it here
|
||||
*/
|
||||
|
||||
/*@}*//*Usage page 0x07*/
|
||||
|
||||
/**
|
||||
* \name Usage page 0x0C
|
||||
*
|
||||
* These values are mapped from usage page 0x0C (USB consumer page).
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
SDL_SCANCODE_AUDIONEXT = 258,
|
||||
SDL_SCANCODE_AUDIOPREV = 259,
|
||||
SDL_SCANCODE_AUDIOSTOP = 260,
|
||||
SDL_SCANCODE_AUDIOPLAY = 261,
|
||||
SDL_SCANCODE_AUDIOMUTE = 262,
|
||||
SDL_SCANCODE_MEDIASELECT = 263,
|
||||
SDL_SCANCODE_WWW = 264,
|
||||
SDL_SCANCODE_MAIL = 265,
|
||||
SDL_SCANCODE_CALCULATOR = 266,
|
||||
SDL_SCANCODE_COMPUTER = 267,
|
||||
SDL_SCANCODE_AC_SEARCH = 268,
|
||||
SDL_SCANCODE_AC_HOME = 269,
|
||||
SDL_SCANCODE_AC_BACK = 270,
|
||||
SDL_SCANCODE_AC_FORWARD = 271,
|
||||
SDL_SCANCODE_AC_STOP = 272,
|
||||
SDL_SCANCODE_AC_REFRESH = 273,
|
||||
SDL_SCANCODE_AC_BOOKMARKS = 274,
|
||||
|
||||
/*@}*//*Usage page 0x0C*/
|
||||
|
||||
/**
|
||||
* \name Walther keys
|
||||
*
|
||||
* These are values that Christian Walther added (for mac keyboard?).
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
SDL_SCANCODE_BRIGHTNESSDOWN = 275,
|
||||
SDL_SCANCODE_BRIGHTNESSUP = 276,
|
||||
SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display
|
||||
switch, video mode switch */
|
||||
SDL_SCANCODE_KBDILLUMTOGGLE = 278,
|
||||
SDL_SCANCODE_KBDILLUMDOWN = 279,
|
||||
SDL_SCANCODE_KBDILLUMUP = 280,
|
||||
SDL_SCANCODE_EJECT = 281,
|
||||
SDL_SCANCODE_SLEEP = 282,
|
||||
|
||||
/*@}*//*Walther keys*/
|
||||
|
||||
/* Add any other keys here. */
|
||||
|
||||
SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes
|
||||
for array bounds */
|
||||
} SDL_Scancode;
|
||||
|
||||
#endif /* _SDL_scancode_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef _SDL_shape_h
|
||||
#define _SDL_shape_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/** \file SDL_shape.h
|
||||
*
|
||||
* Header file for the shaped window API.
|
||||
*/
|
||||
|
||||
#define SDL_NONSHAPEABLE_WINDOW -1
|
||||
#define SDL_INVALID_SHAPE_ARGUMENT -2
|
||||
#define SDL_WINDOW_LACKS_SHAPE -3
|
||||
|
||||
/**
|
||||
* \brief Create a window that can be shaped with the specified position, dimensions, and flags.
|
||||
*
|
||||
* \param title The title of the window, in UTF-8 encoding.
|
||||
* \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param w The width of the window.
|
||||
* \param h The height of the window.
|
||||
* \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following:
|
||||
* ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED,
|
||||
* ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_RESIZABLE,
|
||||
* ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED,
|
||||
* ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
|
||||
*
|
||||
* \return The window created, or NULL if window creation failed.
|
||||
*
|
||||
* \sa SDL_DestroyWindow()
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
|
||||
|
||||
/**
|
||||
* \brief Return whether the given window is a shaped window.
|
||||
*
|
||||
* \param window The window to query for being shaped.
|
||||
*
|
||||
* \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
|
||||
* \sa SDL_CreateShapedWindow
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
|
||||
|
||||
/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
|
||||
typedef enum {
|
||||
/** \brief The default mode, a binarized alpha cutoff of 1. */
|
||||
ShapeModeDefault,
|
||||
/** \brief A binarized alpha cutoff with a given integer value. */
|
||||
ShapeModeBinarizeAlpha,
|
||||
/** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
|
||||
ShapeModeReverseBinarizeAlpha,
|
||||
/** \brief A color key is applied. */
|
||||
ShapeModeColorKey
|
||||
} WindowShapeMode;
|
||||
|
||||
#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
|
||||
|
||||
/** \brief A union containing parameters for shaped windows. */
|
||||
typedef union {
|
||||
/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
|
||||
Uint8 binarizationCutoff;
|
||||
SDL_Color colorKey;
|
||||
} SDL_WindowShapeParams;
|
||||
|
||||
/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
|
||||
typedef struct SDL_WindowShapeMode {
|
||||
/** \brief The mode of these window-shape parameters. */
|
||||
WindowShapeMode mode;
|
||||
/** \brief Window-shape parameters. */
|
||||
SDL_WindowShapeParams parameters;
|
||||
} SDL_WindowShapeMode;
|
||||
|
||||
/**
|
||||
* \brief Set the shape and parameters of a shaped window.
|
||||
*
|
||||
* \param window The shaped window whose parameters should be set.
|
||||
* \param shape A surface encoding the desired shape for the window.
|
||||
* \param shape_mode The parameters to set for the shaped window.
|
||||
*
|
||||
* \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
|
||||
* if the SDL_Window* given does not reference a valid shaped window.
|
||||
*
|
||||
* \sa SDL_WindowShapeMode
|
||||
* \sa SDL_GetShapedWindowMode.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
|
||||
|
||||
/**
|
||||
* \brief Get the shape parameters of a shaped window.
|
||||
*
|
||||
* \param window The shaped window whose parameters should be retrieved.
|
||||
* \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
|
||||
*
|
||||
* \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
|
||||
* data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
|
||||
* the SDL_Window* given is a shapeable window currently lacking a shape.
|
||||
*
|
||||
* \sa SDL_WindowShapeMode
|
||||
* \sa SDL_SetWindowShape
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_shape_h */
|
|
@ -1,779 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_stdinc.h
|
||||
*
|
||||
* This is a general header that includes C language support.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_stdinc_h
|
||||
#define _SDL_stdinc_h
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#if defined(STDC_HEADERS)
|
||||
# include <stdlib.h>
|
||||
# include <stddef.h>
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined(HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
# elif defined(HAVE_MALLOC_H)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# if defined(HAVE_STDDEF_H)
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# if defined(HAVE_STDARG_H)
|
||||
# include <stdarg.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
# include <inttypes.h>
|
||||
#elif defined(HAVE_STDINT_H)
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_MATH_H
|
||||
# include <math.h>
|
||||
#endif
|
||||
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
||||
# include <iconv.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The number of elements in an array.
|
||||
*/
|
||||
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
|
||||
#define SDL_TABLESIZE(table) SDL_arraysize(table)
|
||||
|
||||
/**
|
||||
* \name Cast operators
|
||||
*
|
||||
* Use proper C++ casts when compiled as C++ to be compatible with the option
|
||||
* -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
|
||||
*/
|
||||
/*@{*/
|
||||
#ifdef __cplusplus
|
||||
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
|
||||
#define SDL_static_cast(type, expression) static_cast<type>(expression)
|
||||
#else
|
||||
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
|
||||
#define SDL_static_cast(type, expression) ((type)(expression))
|
||||
#endif
|
||||
/*@}*//*Cast operators*/
|
||||
|
||||
/* Define a four character code as a Uint32 */
|
||||
#define SDL_FOURCC(A, B, C, D) \
|
||||
((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
|
||||
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
|
||||
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
|
||||
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
|
||||
|
||||
/**
|
||||
* \name Basic data types
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_FALSE = 0,
|
||||
SDL_TRUE = 1
|
||||
} SDL_bool;
|
||||
|
||||
/**
|
||||
* \brief A signed 8-bit integer type.
|
||||
*/
|
||||
typedef int8_t Sint8;
|
||||
/**
|
||||
* \brief An unsigned 8-bit integer type.
|
||||
*/
|
||||
typedef uint8_t Uint8;
|
||||
/**
|
||||
* \brief A signed 16-bit integer type.
|
||||
*/
|
||||
typedef int16_t Sint16;
|
||||
/**
|
||||
* \brief An unsigned 16-bit integer type.
|
||||
*/
|
||||
typedef uint16_t Uint16;
|
||||
/**
|
||||
* \brief A signed 32-bit integer type.
|
||||
*/
|
||||
typedef int32_t Sint32;
|
||||
/**
|
||||
* \brief An unsigned 32-bit integer type.
|
||||
*/
|
||||
typedef uint32_t Uint32;
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
/**
|
||||
* \brief A signed 64-bit integer type.
|
||||
* \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
|
||||
*/
|
||||
typedef int64_t Sint64;
|
||||
/**
|
||||
* \brief An unsigned 64-bit integer type.
|
||||
* \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
|
||||
*/
|
||||
typedef uint64_t Uint64;
|
||||
#else
|
||||
/* This is really just a hack to prevent the compiler from complaining */
|
||||
typedef Sint32 Sint64;
|
||||
typedef Uint32 Uint64;
|
||||
#endif
|
||||
|
||||
/*@}*//*Basic data types*/
|
||||
|
||||
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
|
||||
/** \cond */
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
||||
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
|
||||
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
|
||||
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
|
||||
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
||||
#endif
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
/** \endcond */
|
||||
|
||||
/* Check to make sure enums are the size of ints, for structure packing.
|
||||
For both Watcom C/C++ and Borland C/C++ the compiler option that makes
|
||||
enums having the size of an int must be enabled.
|
||||
This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
|
||||
*/
|
||||
/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
|
||||
#ifdef __MWERKS__
|
||||
#pragma enumsalwaysint on
|
||||
#endif
|
||||
|
||||
/** \cond */
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
#if !defined(__NINTENDODS__) && !defined(__ANDROID__)
|
||||
/* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
|
||||
typedef enum
|
||||
{
|
||||
DUMMY_ENUM_VALUE
|
||||
} SDL_DUMMY_ENUM;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
|
||||
#endif
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
/** \endcond */
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC
|
||||
#define SDL_malloc malloc
|
||||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CALLOC
|
||||
#define SDL_calloc calloc
|
||||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REALLOC
|
||||
#define SDL_realloc realloc
|
||||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FREE
|
||||
#define SDL_free free
|
||||
#else
|
||||
extern DECLSPEC void SDLCALL SDL_free(void *mem);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ALLOCA) && !defined(alloca)
|
||||
# if defined(HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# elif defined(__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined(_MSC_VER)
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined(__WATCOMC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__BORLANDC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__DMC__)
|
||||
# include <stdlib.h>
|
||||
# elif defined(__AIX__)
|
||||
#pragma alloca
|
||||
# elif defined(__MRC__)
|
||||
void *alloca(unsigned);
|
||||
# else
|
||||
char *alloca();
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_ALLOCA
|
||||
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
|
||||
#define SDL_stack_free(data)
|
||||
#else
|
||||
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
|
||||
#define SDL_stack_free(data) SDL_free(data)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETENV
|
||||
#define SDL_getenv getenv
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
|
||||
#endif
|
||||
|
||||
/* SDL_putenv() has moved to SDL_compat. */
|
||||
#ifdef HAVE_SETENV
|
||||
#define SDL_setenv setenv
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value,
|
||||
int overwrite);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QSORT
|
||||
#define SDL_qsort qsort
|
||||
#else
|
||||
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
|
||||
int (*compare) (const void *,
|
||||
const void *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ABS
|
||||
#define SDL_abs abs
|
||||
#else
|
||||
#define SDL_abs(X) ((X) < 0 ? -(X) : (X))
|
||||
#endif
|
||||
|
||||
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#define SDL_isdigit(X) isdigit(X)
|
||||
#define SDL_isspace(X) isspace(X)
|
||||
#define SDL_toupper(X) toupper(X)
|
||||
#define SDL_tolower(X) tolower(X)
|
||||
#else
|
||||
#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9'))
|
||||
#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
|
||||
#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
|
||||
#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMSET
|
||||
#define SDL_memset memset
|
||||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
|
||||
#endif
|
||||
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
|
||||
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
|
||||
|
||||
#if defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memset4(dst, val, len) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; stosl\n\t" \
|
||||
: "=&D" (u0), "=&a" (u1), "=&c" (u2) \
|
||||
: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \
|
||||
: "memory" ); \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_memset4
|
||||
#define SDL_memset4(dst, val, len) \
|
||||
do { \
|
||||
unsigned _count = (len); \
|
||||
unsigned _n = (_count + 3) / 4; \
|
||||
Uint32 *_p = SDL_static_cast(Uint32 *, dst); \
|
||||
Uint32 _val = (val); \
|
||||
if (len == 0) break; \
|
||||
switch (_count % 4) { \
|
||||
case 0: do { *_p++ = _val; \
|
||||
case 3: *_p++ = _val; \
|
||||
case 2: *_p++ = _val; \
|
||||
case 1: *_p++ = _val; \
|
||||
} while ( --_n ); \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/* We can count on memcpy existing on Mac OS X and being well-tuned. */
|
||||
#if defined(__MACOSX__)
|
||||
#define SDL_memcpy memcpy
|
||||
#elif defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memcpy(dst, src, len) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; movsl\n\t" \
|
||||
"testb $2,%b4\n\t" \
|
||||
"je 1f\n\t" \
|
||||
"movsw\n" \
|
||||
"1:\ttestb $1,%b4\n\t" \
|
||||
"je 2f\n\t" \
|
||||
"movsb\n" \
|
||||
"2:" \
|
||||
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
|
||||
: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
|
||||
: "memory" ); \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_memcpy
|
||||
#ifdef HAVE_MEMCPY
|
||||
#define SDL_memcpy memcpy
|
||||
#elif defined(HAVE_BCOPY)
|
||||
#define SDL_memcpy(d, s, n) bcopy((s), (d), (n))
|
||||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
|
||||
size_t len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* We can count on memcpy existing on Mac OS X and being well-tuned. */
|
||||
#if defined(__MACOSX__)
|
||||
#define SDL_memcpy4(dst, src, len) SDL_memcpy((dst), (src), (len) << 2)
|
||||
#elif defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memcpy4(dst, src, len) \
|
||||
do { \
|
||||
int ecx, edi, esi; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; movsl" \
|
||||
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
|
||||
: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \
|
||||
: "memory" ); \
|
||||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_memcpy4
|
||||
#define SDL_memcpy4(dst, src, len) SDL_memcpy((dst), (src), (len) << 2)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMMOVE
|
||||
#define SDL_memmove memmove
|
||||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src,
|
||||
size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMCMP
|
||||
#define SDL_memcmp memcmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
|
||||
size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLEN
|
||||
#define SDL_strlen strlen
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WCSLEN
|
||||
#define SDL_wcslen wcslen
|
||||
#else
|
||||
#if !defined(wchar_t) && defined(__NINTENDODS__)
|
||||
#define wchar_t short /* TODO: figure out why libnds doesn't have this */
|
||||
#endif
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WCSLCPY
|
||||
#define SDL_wcslcpy wcslcpy
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WCSLCAT
|
||||
#define SDL_wcslcat wcslcat
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_STRLCPY
|
||||
#define SDL_strlcpy strlcpy
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src,
|
||||
size_t dst_bytes);
|
||||
|
||||
#ifdef HAVE_STRLCAT
|
||||
#define SDL_strlcat strlcat
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRDUP
|
||||
#define SDL_strdup strdup
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRREV
|
||||
#define SDL_strrev _strrev
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRUPR
|
||||
#define SDL_strupr _strupr
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRLWR
|
||||
#define SDL_strlwr _strlwr
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCHR
|
||||
#define SDL_strchr strchr
|
||||
#elif defined(HAVE_INDEX)
|
||||
#define SDL_strchr index
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRRCHR
|
||||
#define SDL_strrchr strrchr
|
||||
#elif defined(HAVE_RINDEX)
|
||||
#define SDL_strrchr rindex
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRSTR
|
||||
#define SDL_strstr strstr
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
|
||||
const char *needle);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ITOA
|
||||
#define SDL_itoa itoa
|
||||
#else
|
||||
#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__LTOA
|
||||
#define SDL_ltoa _ltoa
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__UITOA
|
||||
#define SDL_uitoa _uitoa
|
||||
#else
|
||||
#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__ULTOA
|
||||
#define SDL_ultoa _ultoa
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
|
||||
int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOL
|
||||
#define SDL_strtol strtol
|
||||
#else
|
||||
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
|
||||
int base);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOUL
|
||||
#define SDL_strtoul strtoul
|
||||
#else
|
||||
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
|
||||
char **endp, int base);
|
||||
#endif
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
|
||||
#ifdef HAVE__I64TOA
|
||||
#define SDL_lltoa _i64toa
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
|
||||
int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__UI64TOA
|
||||
#define SDL_ulltoa _ui64toa
|
||||
#else
|
||||
extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
|
||||
int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOLL
|
||||
#define SDL_strtoll strtoll
|
||||
#else
|
||||
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
|
||||
int base);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOULL
|
||||
#define SDL_strtoull strtoull
|
||||
#else
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
|
||||
int base);
|
||||
#endif
|
||||
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
||||
#ifdef HAVE_STRTOD
|
||||
#define SDL_strtod strtod
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATOI
|
||||
#define SDL_atoi atoi
|
||||
#else
|
||||
#define SDL_atoi(X) SDL_strtol(X, NULL, 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATOF
|
||||
#define SDL_atof atof
|
||||
#else
|
||||
#define SDL_atof(X) SDL_strtod(X, NULL)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCMP
|
||||
#define SDL_strcmp strcmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCMP
|
||||
#define SDL_strncmp strncmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCASECMP
|
||||
#define SDL_strcasecmp strcasecmp
|
||||
#elif defined(HAVE__STRICMP)
|
||||
#define SDL_strcasecmp _stricmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
|
||||
const char *str2);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCASECMP
|
||||
#define SDL_strncasecmp strncasecmp
|
||||
#elif defined(HAVE__STRNICMP)
|
||||
#define SDL_strncasecmp _strnicmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
|
||||
const char *str2, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SSCANF
|
||||
#define SDL_sscanf sscanf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
|
||||
...);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
#define SDL_snprintf snprintf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
|
||||
const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
#define SDL_vsnprintf vsnprintf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
|
||||
const char *fmt, va_list ap);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATAN
|
||||
#define SDL_atan atan
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_atan(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATAN2
|
||||
#define SDL_atan2 atan2
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_atan2(double y, double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CEIL
|
||||
#define SDL_ceil ceil
|
||||
#else
|
||||
#define SDL_ceil(x) ((double)(int)((x)+0.5))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COPYSIGN
|
||||
#define SDL_copysign copysign
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COS
|
||||
#define SDL_cos cos
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_cos(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COSF
|
||||
#define SDL_cosf cosf
|
||||
#else
|
||||
#define SDL_cosf(x) (float)SDL_cos((double)x)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FABS
|
||||
#define SDL_fabs fabs
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_fabs(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FLOOR
|
||||
#define SDL_floor floor
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_floor(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOG
|
||||
#define SDL_log log
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_log(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POW
|
||||
#define SDL_pow pow
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SCALBN
|
||||
#define SDL_scalbn scalbn
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIN
|
||||
#define SDL_sin sin
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_sin(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SINF
|
||||
#define SDL_sinf sinf
|
||||
#else
|
||||
#define SDL_sinf(x) (float)SDL_sin((double)x)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SQRT
|
||||
#define SDL_sqrt sqrt
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_sqrt(double x);
|
||||
#endif
|
||||
|
||||
/* The SDL implementation of iconv() returns these error codes */
|
||||
#define SDL_ICONV_ERROR (size_t)-1
|
||||
#define SDL_ICONV_E2BIG (size_t)-2
|
||||
#define SDL_ICONV_EILSEQ (size_t)-3
|
||||
#define SDL_ICONV_EINVAL (size_t)-4
|
||||
|
||||
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
||||
#define SDL_iconv_t iconv_t
|
||||
#define SDL_iconv_open iconv_open
|
||||
#define SDL_iconv_close iconv_close
|
||||
#else
|
||||
typedef struct _SDL_iconv_t *SDL_iconv_t;
|
||||
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
|
||||
const char *fromcode);
|
||||
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
|
||||
#endif
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
|
||||
size_t * inbytesleft, char **outbuf,
|
||||
size_t * outbytesleft);
|
||||
/**
|
||||
* This function converts a string between encodings in one pass, returning a
|
||||
* string that must be freed with SDL_free() or NULL on error.
|
||||
*/
|
||||
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
|
||||
const char *fromcode,
|
||||
const char *inbuf,
|
||||
size_t inbytesleft);
|
||||
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_stdinc_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,490 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_surface.h
|
||||
*
|
||||
* Header file for ::SDL_surface definition and management functions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_surface_h
|
||||
#define _SDL_surface_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_blendmode.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name Surface flags
|
||||
*
|
||||
* These are the currently supported flags for the ::SDL_surface.
|
||||
*
|
||||
* \internal
|
||||
* Used internally (read-only).
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */
|
||||
#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */
|
||||
#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */
|
||||
/*@}*//*Surface flags*/
|
||||
|
||||
/**
|
||||
* Evaluates to true if the surface needs to be locked before access.
|
||||
*/
|
||||
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
|
||||
|
||||
/**
|
||||
* \brief A collection of pixels used in software blitting.
|
||||
*
|
||||
* \note This structure should be treated as read-only, except for \c pixels,
|
||||
* which, if not NULL, contains the raw pixel data for the surface.
|
||||
*/
|
||||
typedef struct SDL_Surface
|
||||
{
|
||||
Uint32 flags; /**< Read-only */
|
||||
SDL_PixelFormat *format; /**< Read-only */
|
||||
int w, h; /**< Read-only */
|
||||
int pitch; /**< Read-only */
|
||||
void *pixels; /**< Read-write */
|
||||
|
||||
/** Application data associated with the surface */
|
||||
void *userdata; /**< Read-write */
|
||||
|
||||
/** information needed for surfaces requiring locks */
|
||||
int locked; /**< Read-only */
|
||||
void *lock_data; /**< Read-only */
|
||||
|
||||
/** clipping information */
|
||||
SDL_Rect clip_rect; /**< Read-only */
|
||||
|
||||
/** info for fast blit mapping to other surfaces */
|
||||
struct SDL_BlitMap *map; /**< Private */
|
||||
|
||||
/** Reference count -- used when freeing surface */
|
||||
int refcount; /**< Read-mostly */
|
||||
} SDL_Surface;
|
||||
|
||||
/**
|
||||
* \brief The type of function used for surface blitting functions.
|
||||
*/
|
||||
typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
|
||||
struct SDL_Surface * dst, SDL_Rect * dstrect);
|
||||
|
||||
/**
|
||||
* Allocate and free an RGB surface.
|
||||
*
|
||||
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
|
||||
* If the depth is greater than 8 bits, the pixel format is set using the
|
||||
* flags '[RGB]mask'.
|
||||
*
|
||||
* If the function runs out of memory, it will return NULL.
|
||||
*
|
||||
* \param flags The \c flags are obsolete and should be set to 0.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
int pitch,
|
||||
Uint32 Rmask,
|
||||
Uint32 Gmask,
|
||||
Uint32 Bmask,
|
||||
Uint32 Amask);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
|
||||
|
||||
/**
|
||||
* \brief Set the palette used by a surface.
|
||||
*
|
||||
* \return 0, or -1 if the surface format doesn't use a palette.
|
||||
*
|
||||
* \note A single palette can be shared with many surfaces.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
|
||||
SDL_Palette * palette);
|
||||
|
||||
/**
|
||||
* \brief Sets up a surface for directly accessing the pixels.
|
||||
*
|
||||
* Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
|
||||
* to and read from \c surface->pixels, using the pixel format stored in
|
||||
* \c surface->format. Once you are done accessing the surface, you should
|
||||
* use SDL_UnlockSurface() to release it.
|
||||
*
|
||||
* Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
|
||||
* to 0, then you can read and write to the surface at any time, and the
|
||||
* pixel format of the surface will not change.
|
||||
*
|
||||
* No operating system or library calls should be made between lock/unlock
|
||||
* pairs, as critical system locks may be held during this time.
|
||||
*
|
||||
* SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
|
||||
*
|
||||
* \sa SDL_UnlockSurface()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
|
||||
/** \sa SDL_LockSurface() */
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
|
||||
|
||||
/**
|
||||
* Load a surface from a seekable SDL data stream (memory or file).
|
||||
*
|
||||
* If \c freesrc is non-zero, the stream will be closed after being read.
|
||||
*
|
||||
* The new surface should be freed with SDL_FreeSurface().
|
||||
*
|
||||
* \return the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
|
||||
int freesrc);
|
||||
|
||||
/**
|
||||
* Load a surface from a file.
|
||||
*
|
||||
* Convenience macro.
|
||||
*/
|
||||
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
|
||||
|
||||
/**
|
||||
* Save a surface to a seekable SDL data stream (memory or file).
|
||||
*
|
||||
* If \c freedst is non-zero, the stream will be closed after being written.
|
||||
*
|
||||
* \return 0 if successful or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
|
||||
(SDL_Surface * surface, SDL_RWops * dst, int freedst);
|
||||
|
||||
/**
|
||||
* Save a surface to a file.
|
||||
*
|
||||
* Convenience macro.
|
||||
*/
|
||||
#define SDL_SaveBMP(surface, file) \
|
||||
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
|
||||
|
||||
/**
|
||||
* \brief Sets the RLE acceleration hint for a surface.
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid
|
||||
*
|
||||
* \note If RLE is enabled, colorkey and alpha blending blits are much faster,
|
||||
* but the surface must be locked before directly accessing the pixels.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
|
||||
int flag);
|
||||
|
||||
/**
|
||||
* \brief Sets the color key (transparent pixel) in a blittable surface.
|
||||
*
|
||||
* \param surface The surface to update
|
||||
* \param flag Non-zero to enable colorkey and 0 to disable colorkey
|
||||
* \param key The transparent pixel in the native surface format
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
|
||||
int flag, Uint32 key);
|
||||
|
||||
/**
|
||||
* \brief Gets the color key (transparent pixel) in a blittable surface.
|
||||
*
|
||||
* \param surface The surface to update
|
||||
* \param key A pointer filled in with the transparent pixel in the native
|
||||
* surface format
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid or colorkey is not
|
||||
* enabled.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
|
||||
Uint32 * key);
|
||||
|
||||
/**
|
||||
* \brief Set an additional color value used in blit operations.
|
||||
*
|
||||
* \param surface The surface to update.
|
||||
* \param r The red color value multiplied into blit operations.
|
||||
* \param g The green color value multiplied into blit operations.
|
||||
* \param b The blue color value multiplied into blit operations.
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid.
|
||||
*
|
||||
* \sa SDL_GetSurfaceColorMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
|
||||
Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the additional color value used in blit operations.
|
||||
*
|
||||
* \param surface The surface to query.
|
||||
* \param r A pointer filled in with the current red color value.
|
||||
* \param g A pointer filled in with the current green color value.
|
||||
* \param b A pointer filled in with the current blue color value.
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid.
|
||||
*
|
||||
* \sa SDL_SetSurfaceColorMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
|
||||
Uint8 * r, Uint8 * g,
|
||||
Uint8 * b);
|
||||
|
||||
/**
|
||||
* \brief Set an additional alpha value used in blit operations.
|
||||
*
|
||||
* \param surface The surface to update.
|
||||
* \param alpha The alpha value multiplied into blit operations.
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid.
|
||||
*
|
||||
* \sa SDL_GetSurfaceAlphaMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
|
||||
Uint8 alpha);
|
||||
|
||||
/**
|
||||
* \brief Get the additional alpha value used in blit operations.
|
||||
*
|
||||
* \param surface The surface to query.
|
||||
* \param alpha A pointer filled in with the current alpha value.
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid.
|
||||
*
|
||||
* \sa SDL_SetSurfaceAlphaMod()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
|
||||
Uint8 * alpha);
|
||||
|
||||
/**
|
||||
* \brief Set the blend mode used for blit operations.
|
||||
*
|
||||
* \param surface The surface to update.
|
||||
* \param blendMode ::SDL_BlendMode to use for blit blending.
|
||||
*
|
||||
* \return 0 on success, or -1 if the parameters are not valid.
|
||||
*
|
||||
* \sa SDL_GetSurfaceBlendMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
|
||||
SDL_BlendMode blendMode);
|
||||
|
||||
/**
|
||||
* \brief Get the blend mode used for blit operations.
|
||||
*
|
||||
* \param surface The surface to query.
|
||||
* \param blendMode A pointer filled in with the current blend mode.
|
||||
*
|
||||
* \return 0 on success, or -1 if the surface is not valid.
|
||||
*
|
||||
* \sa SDL_SetSurfaceBlendMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
|
||||
SDL_BlendMode *blendMode);
|
||||
|
||||
/**
|
||||
* Sets the clipping rectangle for the destination surface in a blit.
|
||||
*
|
||||
* If the clip rectangle is NULL, clipping will be disabled.
|
||||
*
|
||||
* If the clip rectangle doesn't intersect the surface, the function will
|
||||
* return SDL_FALSE and blits will be completely clipped. Otherwise the
|
||||
* function returns SDL_TRUE and blits to the surface will be clipped to
|
||||
* the intersection of the surface area and the clipping rectangle.
|
||||
*
|
||||
* Note that blits are automatically clipped to the edges of the source
|
||||
* and destination surfaces.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
|
||||
const SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* Gets the clipping rectangle for the destination surface in a blit.
|
||||
*
|
||||
* \c rect must be a pointer to a valid rectangle which will be filled
|
||||
* with the correct values.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
|
||||
SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* Creates a new surface of the specified format, and then copies and maps
|
||||
* the given surface to it so the blit of the converted surface will be as
|
||||
* fast as possible. If this function fails, it returns NULL.
|
||||
*
|
||||
* The \c flags parameter is passed to SDL_CreateRGBSurface() and has those
|
||||
* semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and
|
||||
* SDL will try to RLE accelerate colorkey and alpha blits in the resulting
|
||||
* surface.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
|
||||
(SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
|
||||
(SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
|
||||
|
||||
/**
|
||||
* \brief Copy a block of pixels of one format to another format
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
|
||||
Uint32 src_format,
|
||||
const void * src, int src_pitch,
|
||||
Uint32 dst_format,
|
||||
void * dst, int dst_pitch);
|
||||
|
||||
/**
|
||||
* Performs a fast fill of the given rectangle with \c color.
|
||||
*
|
||||
* If \c rect is NULL, the whole surface will be filled with \c color.
|
||||
*
|
||||
* The color should be a pixel of the format used by the surface, and
|
||||
* can be generated by the SDL_MapRGB() function.
|
||||
*
|
||||
* \return 0 on success, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_FillRect
|
||||
(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
|
||||
extern DECLSPEC int SDLCALL SDL_FillRects
|
||||
(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
|
||||
|
||||
/**
|
||||
* Performs a fast blit from the source surface to the destination surface.
|
||||
*
|
||||
* This assumes that the source and destination rectangles are
|
||||
* the same size. If either \c srcrect or \c dstrect are NULL, the entire
|
||||
* surface (\c src or \c dst) is copied. The final blit rectangles are saved
|
||||
* in \c srcrect and \c dstrect after all clipping is performed.
|
||||
*
|
||||
* \return If the blit is successful, it returns 0, otherwise it returns -1.
|
||||
*
|
||||
* The blit function should not be called on a locked surface.
|
||||
*
|
||||
* The blit semantics for surfaces with and without alpha and colorkey
|
||||
* are defined as follows:
|
||||
* \verbatim
|
||||
RGBA->RGB:
|
||||
SDL_SRCALPHA set:
|
||||
alpha-blend (using alpha-channel).
|
||||
SDL_SRCCOLORKEY ignored.
|
||||
SDL_SRCALPHA not set:
|
||||
copy RGB.
|
||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
RGB values of the source colour key, ignoring alpha in the
|
||||
comparison.
|
||||
|
||||
RGB->RGBA:
|
||||
SDL_SRCALPHA set:
|
||||
alpha-blend (using the source per-surface alpha value);
|
||||
set destination alpha to opaque.
|
||||
SDL_SRCALPHA not set:
|
||||
copy RGB, set destination alpha to source per-surface alpha value.
|
||||
both:
|
||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
source colour key.
|
||||
|
||||
RGBA->RGBA:
|
||||
SDL_SRCALPHA set:
|
||||
alpha-blend (using the source alpha channel) the RGB values;
|
||||
leave destination alpha untouched. [Note: is this correct?]
|
||||
SDL_SRCCOLORKEY ignored.
|
||||
SDL_SRCALPHA not set:
|
||||
copy all of RGBA to the destination.
|
||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
RGB values of the source colour key, ignoring alpha in the
|
||||
comparison.
|
||||
|
||||
RGB->RGB:
|
||||
SDL_SRCALPHA set:
|
||||
alpha-blend (using the source per-surface alpha value).
|
||||
SDL_SRCALPHA not set:
|
||||
copy RGB.
|
||||
both:
|
||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
source colour key.
|
||||
\endverbatim
|
||||
*
|
||||
* You should call SDL_BlitSurface() unless you know exactly how SDL
|
||||
* blitting works internally and how to use the other blit functions.
|
||||
*/
|
||||
#define SDL_BlitSurface SDL_UpperBlit
|
||||
|
||||
/**
|
||||
* This is the public blit function, SDL_BlitSurface(), and it performs
|
||||
* rectangle validation and clipping before passing it to SDL_LowerBlit()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_UpperBlit
|
||||
(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect);
|
||||
|
||||
/**
|
||||
* This is a semi-private blit function and it performs low-level surface
|
||||
* blitting only.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LowerBlit
|
||||
(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect);
|
||||
|
||||
/**
|
||||
* \brief Perform a fast, low quality, stretch blit between two surfaces of the
|
||||
* same pixel format.
|
||||
*
|
||||
* \note This function uses a static buffer, and is not thread-safe.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
|
||||
const SDL_Rect * srcrect,
|
||||
SDL_Surface * dst,
|
||||
const SDL_Rect * dstrect);
|
||||
|
||||
/**
|
||||
* \brief Perform a fast, low quality, stretch blit between two surfaces of the
|
||||
* different pixel formats.
|
||||
*
|
||||
* \note This function calls SDL_SoftStretch or SDL_LowerBlit.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_BlitScaled
|
||||
(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, const SDL_Rect * dstrect);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_surface_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,242 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_syswm.h
|
||||
*
|
||||
* Include file for SDL custom system window manager hooks.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_syswm_h
|
||||
#define _SDL_syswm_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \file SDL_syswm.h
|
||||
*
|
||||
* Your application has access to a special type of event ::SDL_SYSWMEVENT,
|
||||
* which contains window-manager specific information and arrives whenever
|
||||
* an unhandled window event occurs. This event is ignored by default, but
|
||||
* you can enable it with SDL_EventState().
|
||||
*/
|
||||
#ifdef SDL_PROTOTYPES_ONLY
|
||||
struct SDL_SysWMinfo;
|
||||
#else
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* This is the structure for custom window manager events */
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* conflicts with Quickdraw.h */
|
||||
#define Cursor X11Cursor
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* matches the re-define above */
|
||||
#undef Cursor
|
||||
#endif
|
||||
|
||||
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
|
||||
#include <directfb.h>
|
||||
#endif
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
#ifdef __OBJC__
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#else
|
||||
typedef struct _NSWindow NSWindow;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_UIKIT)
|
||||
#ifdef __OBJC__
|
||||
#include <UIKit/UIKit.h>
|
||||
#else
|
||||
typedef struct _UIWindow UIWindow;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* These are the various supported windowing subsystems
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_SYSWM_UNKNOWN,
|
||||
SDL_SYSWM_WINDOWS,
|
||||
SDL_SYSWM_X11,
|
||||
SDL_SYSWM_DIRECTFB,
|
||||
SDL_SYSWM_COCOA,
|
||||
SDL_SYSWM_UIKIT,
|
||||
} SDL_SYSWM_TYPE;
|
||||
|
||||
/**
|
||||
* The custom event structure.
|
||||
*/
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union
|
||||
{
|
||||
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
|
||||
struct {
|
||||
HWND hwnd; /**< The window for the message */
|
||||
UINT msg; /**< The type of message */
|
||||
WPARAM wParam; /**< WORD message parameter */
|
||||
LPARAM lParam; /**< LONG message parameter */
|
||||
} win;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
struct {
|
||||
XEvent event;
|
||||
} x11;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
|
||||
struct {
|
||||
DFBEvent event;
|
||||
} dfb;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
struct
|
||||
{
|
||||
/* No Cocoa window events yet */
|
||||
} cocoa;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_UIKIT)
|
||||
struct
|
||||
{
|
||||
/* No UIKit window events yet */
|
||||
} uikit;
|
||||
#endif
|
||||
/* Can't have an empty union */
|
||||
int dummy;
|
||||
} msg;
|
||||
};
|
||||
|
||||
/**
|
||||
* The custom window manager information structure.
|
||||
*
|
||||
* When this structure is returned, it holds information about which
|
||||
* low level system it is using, and will be one of SDL_SYSWM_TYPE.
|
||||
*/
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union
|
||||
{
|
||||
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
|
||||
struct
|
||||
{
|
||||
HWND window; /**< The window handle */
|
||||
} win;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
struct
|
||||
{
|
||||
Display *display; /**< The X11 display */
|
||||
Window window; /**< The X11 window */
|
||||
} x11;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
|
||||
struct
|
||||
{
|
||||
IDirectFB *dfb; /**< The directfb main interface */
|
||||
IDirectFBWindow *window; /**< The directfb window handle */
|
||||
IDirectFBSurface *surface; /**< The directfb client surface */
|
||||
} dfb;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
struct
|
||||
{
|
||||
NSWindow *window; /* The Cocoa window */
|
||||
} cocoa;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_UIKIT)
|
||||
struct
|
||||
{
|
||||
UIWindow *window; /* The UIKit window */
|
||||
} uikit;
|
||||
#endif
|
||||
/* Can't have an empty union */
|
||||
int dummy;
|
||||
} info;
|
||||
};
|
||||
|
||||
#endif /* SDL_PROTOTYPES_ONLY */
|
||||
|
||||
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
|
||||
/* Function prototypes */
|
||||
/**
|
||||
* \brief This function allows access to driver-dependent window information.
|
||||
*
|
||||
* \param window The window about which information is being requested
|
||||
* \param info This structure must be initialized with the SDL version, and is
|
||||
* then filled in with information about the given window.
|
||||
*
|
||||
* \return SDL_TRUE if the function is implemented and the version member of
|
||||
* the \c info struct is valid, SDL_FALSE otherwise.
|
||||
*
|
||||
* You typically use this function like this:
|
||||
* \code
|
||||
* SDL_SysWMinfo info;
|
||||
* SDL_VERSION(&info.version);
|
||||
* if ( SDL_GetWindowWMInfo(&info) ) { ... }
|
||||
* \endcode
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
|
||||
SDL_SysWMinfo * info);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_syswm_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_thread_h
|
||||
#define _SDL_thread_h
|
||||
|
||||
/**
|
||||
* \file SDL_thread.h
|
||||
*
|
||||
* Header for the SDL thread management routines.
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
/* Thread synchronization primitives */
|
||||
#include "SDL_mutex.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* The SDL thread structure, defined in SDL_thread.c */
|
||||
struct SDL_Thread;
|
||||
typedef struct SDL_Thread SDL_Thread;
|
||||
|
||||
/* The SDL thread ID */
|
||||
typedef unsigned long SDL_threadID;
|
||||
|
||||
/* The function passed to SDL_CreateThread()
|
||||
It is passed a void* user context parameter and returns an int.
|
||||
*/
|
||||
typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
||||
|
||||
#if defined(__WIN32__) && !defined(HAVE_LIBC)
|
||||
/**
|
||||
* \file SDL_thread.h
|
||||
*
|
||||
* We compile SDL into a DLL. This means, that it's the DLL which
|
||||
* creates a new thread for the calling process with the SDL_CreateThread()
|
||||
* API. There is a problem with this, that only the RTL of the SDL.DLL will
|
||||
* be initialized for those threads, and not the RTL of the calling
|
||||
* application!
|
||||
*
|
||||
* To solve this, we make a little hack here.
|
||||
*
|
||||
* We'll always use the caller's _beginthread() and _endthread() APIs to
|
||||
* start a new thread. This way, if it's the SDL.DLL which uses this API,
|
||||
* then the RTL of SDL.DLL will be used to create the new thread, and if it's
|
||||
* the application, then the RTL of the application will be used.
|
||||
*
|
||||
* So, in short:
|
||||
* Always use the _beginthread() and _endthread() of the calling runtime
|
||||
* library!
|
||||
*/
|
||||
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
||||
#ifndef _WIN32_WCE
|
||||
#include <process.h> /* This has _beginthread() and _endthread() defined! */
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned
|
||||
(__stdcall *
|
||||
func) (void *),
|
||||
void *arg,
|
||||
unsigned,
|
||||
unsigned
|
||||
*threadID);
|
||||
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
||||
#else
|
||||
typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned (__stdcall *
|
||||
func) (void
|
||||
*),
|
||||
void *arg, unsigned,
|
||||
unsigned *threadID);
|
||||
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create a thread.
|
||||
*/
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
|
||||
/**
|
||||
* Create a thread.
|
||||
*/
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Create a thread.
|
||||
*/
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
|
||||
|
||||
#endif
|
||||
#else
|
||||
|
||||
/**
|
||||
* Create a thread.
|
||||
*/
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, void *data);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the thread identifier for the current thread.
|
||||
*/
|
||||
extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
|
||||
|
||||
/**
|
||||
* Get the thread identifier for the specified thread.
|
||||
*
|
||||
* Equivalent to SDL_ThreadID() if the specified thread is NULL.
|
||||
*/
|
||||
extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
|
||||
|
||||
/**
|
||||
* Wait for a thread to finish.
|
||||
*
|
||||
* The return code for the thread function is placed in the area
|
||||
* pointed to by \c status, if \c status is not NULL.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_thread_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#ifndef _SDL_timer_h
|
||||
#define _SDL_timer_h
|
||||
|
||||
/**
|
||||
* \file SDL_timer.h
|
||||
*
|
||||
* Header for the SDL time management routines.
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Get the number of milliseconds since the SDL library initialization.
|
||||
*
|
||||
* \note This value wraps if the program runs for more than ~49 days.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
|
||||
|
||||
/**
|
||||
* \brief Wait a specified number of milliseconds before returning.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
|
||||
|
||||
/**
|
||||
* Function prototype for the timer callback function.
|
||||
*
|
||||
* The callback function is passed the current timer interval and returns
|
||||
* the next timer interval. If the returned value is the same as the one
|
||||
* passed in, the periodic alarm continues, otherwise a new alarm is
|
||||
* scheduled. If the callback returns 0, the periodic alarm is cancelled.
|
||||
*/
|
||||
typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
|
||||
|
||||
/**
|
||||
* Definition of the timer ID type.
|
||||
*/
|
||||
typedef int SDL_TimerID;
|
||||
|
||||
/**
|
||||
* \brief Add a new timer to the pool of timers already running.
|
||||
*
|
||||
* \return A timer ID, or NULL when an error occurs.
|
||||
*/
|
||||
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
|
||||
SDL_TimerCallback callback,
|
||||
void *param);
|
||||
|
||||
/**
|
||||
* \brief Remove a timer knowing its ID.
|
||||
*
|
||||
* \return A boolean value indicating success or failure.
|
||||
*
|
||||
* \warning It is not safe to remove a timer multiple times.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_timer_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_touch.h
|
||||
*
|
||||
* Include file for SDL touch event handling.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_touch_h
|
||||
#define _SDL_touch_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
|
||||
typedef Sint64 SDL_TouchID;
|
||||
typedef Sint64 SDL_FingerID;
|
||||
|
||||
|
||||
struct SDL_Finger {
|
||||
SDL_FingerID id;
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
Uint16 pressure;
|
||||
Uint16 xdelta;
|
||||
Uint16 ydelta;
|
||||
Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */
|
||||
SDL_bool down;
|
||||
};
|
||||
|
||||
typedef struct SDL_Touch SDL_Touch;
|
||||
typedef struct SDL_Finger SDL_Finger;
|
||||
|
||||
|
||||
struct SDL_Touch {
|
||||
|
||||
/* Free the touch when it's time */
|
||||
void (*FreeTouch) (SDL_Touch * touch);
|
||||
|
||||
/* data common for tablets */
|
||||
float pressure_max, pressure_min;
|
||||
float x_max,x_min;
|
||||
float y_max,y_min;
|
||||
Uint16 xres,yres,pressureres;
|
||||
float native_xres,native_yres,native_pressureres;
|
||||
float tilt; /* for future use */
|
||||
float rotation; /* for future use */
|
||||
|
||||
/* Data common to all touch */
|
||||
SDL_TouchID id;
|
||||
SDL_Window *focus;
|
||||
|
||||
char *name;
|
||||
Uint8 buttonstate;
|
||||
SDL_bool relative_mode;
|
||||
SDL_bool flush_motion;
|
||||
|
||||
int num_fingers;
|
||||
int max_fingers;
|
||||
SDL_Finger** fingers;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the touch object at the given id.
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the finger object of the given touch, at the given id.
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern
|
||||
DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_types.h
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
|
||||
/* DEPRECATED */
|
||||
#include "SDL_stdinc.h"
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_version.h
|
||||
*
|
||||
* This header defines the current SDL version.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_version_h
|
||||
#define _SDL_version_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Information the version of SDL in use.
|
||||
*
|
||||
* Represents the library's version as three levels: major revision
|
||||
* (increments with massive changes, additions, and enhancements),
|
||||
* minor revision (increments with backwards-compatible changes to the
|
||||
* major revision), and patchlevel (increments with fixes to the minor
|
||||
* revision).
|
||||
*
|
||||
* \sa SDL_VERSION
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
typedef struct SDL_version
|
||||
{
|
||||
Uint8 major; /**< major version */
|
||||
Uint8 minor; /**< minor version */
|
||||
Uint8 patch; /**< update version */
|
||||
} SDL_version;
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 1
|
||||
#define SDL_MINOR_VERSION 3
|
||||
#define SDL_PATCHLEVEL 0
|
||||
|
||||
/**
|
||||
* \brief Macro to determine SDL version program was compiled against.
|
||||
*
|
||||
* This macro fills in a SDL_version structure with the version of the
|
||||
* library you compiled against. This is determined by what header the
|
||||
* compiler uses. Note that if you dynamically linked the library, you might
|
||||
* have a slightly newer or older version at runtime. That version can be
|
||||
* determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
|
||||
* is not a macro.
|
||||
*
|
||||
* \param x A pointer to a SDL_version struct to initialize.
|
||||
*
|
||||
* \sa SDL_version
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
#define SDL_VERSION(x) \
|
||||
{ \
|
||||
(x)->major = SDL_MAJOR_VERSION; \
|
||||
(x)->minor = SDL_MINOR_VERSION; \
|
||||
(x)->patch = SDL_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/**
|
||||
* This macro turns the version numbers into a numeric value:
|
||||
* \verbatim
|
||||
(1,2,3) -> (1203)
|
||||
\endverbatim
|
||||
*
|
||||
* This assumes that there will never be more than 100 patchlevels.
|
||||
*/
|
||||
#define SDL_VERSIONNUM(X, Y, Z) \
|
||||
((X)*1000 + (Y)*100 + (Z))
|
||||
|
||||
/**
|
||||
* This is the version number macro for the current SDL version.
|
||||
*/
|
||||
#define SDL_COMPILEDVERSION \
|
||||
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
|
||||
|
||||
/**
|
||||
* This macro will evaluate to true if compiled with SDL at least X.Y.Z.
|
||||
*/
|
||||
#define SDL_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/**
|
||||
* \brief Get the version of SDL that is linked against your program.
|
||||
*
|
||||
* If you are linking to SDL dynamically, then it is possible that the
|
||||
* current version will be different than the version you compiled against.
|
||||
* This function returns the current version, while SDL_VERSION() is a
|
||||
* macro that tells you what version you compiled with.
|
||||
*
|
||||
* \code
|
||||
* SDL_version compiled;
|
||||
* SDL_version linked;
|
||||
*
|
||||
* SDL_VERSION(&compiled);
|
||||
* SDL_GetVersion(&linked);
|
||||
* printf("We compiled against SDL version %d.%d.%d ...\n",
|
||||
* compiled.major, compiled.minor, compiled.patch);
|
||||
* printf("But we linked against SDL version %d.%d.%d.\n",
|
||||
* linked.major, linked.minor, linked.patch);
|
||||
* \endcode
|
||||
*
|
||||
* This function may be called safely at any time, even before SDL_Init().
|
||||
*
|
||||
* \sa SDL_VERSION
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
|
||||
|
||||
/**
|
||||
* \brief Get the code revision of SDL that is linked against your program.
|
||||
*
|
||||
* Returns an arbitrary string (a hash value) uniquely identifying the
|
||||
* exact revision of the SDL library in use, and is only useful in comparing
|
||||
* against other revisions. It is NOT an incrementing number.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
|
||||
|
||||
/**
|
||||
* \brief Get the revision number of SDL that is linked against your program.
|
||||
*
|
||||
* Returns a number uniquely identifying the exact revision of the SDL
|
||||
* library in use. It is an incrementing number based on commits to
|
||||
* hg.libsdl.org.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_version_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,818 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_video.h
|
||||
*
|
||||
* Header file for SDL video functions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_video_h
|
||||
#define _SDL_video_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_surface.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The structure that defines a display mode
|
||||
*
|
||||
* \sa SDL_GetNumDisplayModes()
|
||||
* \sa SDL_GetDisplayMode()
|
||||
* \sa SDL_GetDesktopDisplayMode()
|
||||
* \sa SDL_GetCurrentDisplayMode()
|
||||
* \sa SDL_GetClosestDisplayMode()
|
||||
* \sa SDL_SetWindowDisplayMode()
|
||||
* \sa SDL_GetWindowDisplayMode()
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Uint32 format; /**< pixel format */
|
||||
int w; /**< width */
|
||||
int h; /**< height */
|
||||
int refresh_rate; /**< refresh rate (or zero for unspecified) */
|
||||
void *driverdata; /**< driver-specific data, initialize to 0 */
|
||||
} SDL_DisplayMode;
|
||||
|
||||
/**
|
||||
* \brief The type used to identify a window
|
||||
*
|
||||
* \sa SDL_CreateWindow()
|
||||
* \sa SDL_CreateWindowFrom()
|
||||
* \sa SDL_DestroyWindow()
|
||||
* \sa SDL_GetWindowData()
|
||||
* \sa SDL_GetWindowFlags()
|
||||
* \sa SDL_GetWindowGrab()
|
||||
* \sa SDL_GetWindowPosition()
|
||||
* \sa SDL_GetWindowSize()
|
||||
* \sa SDL_GetWindowTitle()
|
||||
* \sa SDL_HideWindow()
|
||||
* \sa SDL_MaximizeWindow()
|
||||
* \sa SDL_MinimizeWindow()
|
||||
* \sa SDL_RaiseWindow()
|
||||
* \sa SDL_RestoreWindow()
|
||||
* \sa SDL_SetWindowData()
|
||||
* \sa SDL_SetWindowFullscreen()
|
||||
* \sa SDL_SetWindowGrab()
|
||||
* \sa SDL_SetWindowIcon()
|
||||
* \sa SDL_SetWindowPosition()
|
||||
* \sa SDL_SetWindowSize()
|
||||
* \sa SDL_SetWindowTitle()
|
||||
* \sa SDL_ShowWindow()
|
||||
*/
|
||||
typedef struct SDL_Window SDL_Window;
|
||||
|
||||
/**
|
||||
* \brief The flags on a window
|
||||
*
|
||||
* \sa SDL_GetWindowFlags()
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */
|
||||
SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
|
||||
SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */
|
||||
SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
|
||||
SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
|
||||
SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
|
||||
SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
|
||||
SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
|
||||
SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */
|
||||
SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
|
||||
SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
|
||||
SDL_WINDOW_FOREIGN = 0x00000800 /**< window not created by SDL */
|
||||
} SDL_WindowFlags;
|
||||
|
||||
/**
|
||||
* \brief Used to indicate that you don't care what the window position is.
|
||||
*/
|
||||
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000
|
||||
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
|
||||
#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
|
||||
#define SDL_WINDOWPOS_ISUNDEFINED(X) \
|
||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
|
||||
|
||||
/**
|
||||
* \brief Used to indicate that the window position should be centered.
|
||||
*/
|
||||
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000
|
||||
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
|
||||
#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
|
||||
#define SDL_WINDOWPOS_ISCENTERED(X) \
|
||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
||||
|
||||
/**
|
||||
* \brief Event subtype for window events
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_WINDOWEVENT_NONE, /**< Never used */
|
||||
SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
|
||||
SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
|
||||
SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
|
||||
redrawn */
|
||||
SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
|
||||
*/
|
||||
SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
|
||||
SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */
|
||||
SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
|
||||
SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
|
||||
SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
|
||||
and position */
|
||||
SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
|
||||
SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
|
||||
SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
|
||||
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
|
||||
SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the
|
||||
window be closed */
|
||||
} SDL_WindowEventID;
|
||||
|
||||
/**
|
||||
* \brief An opaque handle to an OpenGL context.
|
||||
*/
|
||||
typedef void *SDL_GLContext;
|
||||
|
||||
/**
|
||||
* \brief OpenGL configuration attributes
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_GL_RED_SIZE,
|
||||
SDL_GL_GREEN_SIZE,
|
||||
SDL_GL_BLUE_SIZE,
|
||||
SDL_GL_ALPHA_SIZE,
|
||||
SDL_GL_BUFFER_SIZE,
|
||||
SDL_GL_DOUBLEBUFFER,
|
||||
SDL_GL_DEPTH_SIZE,
|
||||
SDL_GL_STENCIL_SIZE,
|
||||
SDL_GL_ACCUM_RED_SIZE,
|
||||
SDL_GL_ACCUM_GREEN_SIZE,
|
||||
SDL_GL_ACCUM_BLUE_SIZE,
|
||||
SDL_GL_ACCUM_ALPHA_SIZE,
|
||||
SDL_GL_STEREO,
|
||||
SDL_GL_MULTISAMPLEBUFFERS,
|
||||
SDL_GL_MULTISAMPLESAMPLES,
|
||||
SDL_GL_ACCELERATED_VISUAL,
|
||||
SDL_GL_RETAINED_BACKING,
|
||||
SDL_GL_CONTEXT_MAJOR_VERSION,
|
||||
SDL_GL_CONTEXT_MINOR_VERSION
|
||||
} SDL_GLattr;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the number of video drivers compiled into SDL
|
||||
*
|
||||
* \sa SDL_GetVideoDriver()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
|
||||
|
||||
/**
|
||||
* \brief Get the name of a built in video driver.
|
||||
*
|
||||
* \note The video drivers are presented in the order in which they are
|
||||
* normally checked during initialization.
|
||||
*
|
||||
* \sa SDL_GetNumVideoDrivers()
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
|
||||
|
||||
/**
|
||||
* \brief Initialize the video subsystem, optionally specifying a video driver.
|
||||
*
|
||||
* \param driver_name Initialize a specific driver by name, or NULL for the
|
||||
* default video driver.
|
||||
*
|
||||
* \return 0 on success, -1 on error
|
||||
*
|
||||
* This function initializes the video subsystem; setting up a connection
|
||||
* to the window manager, etc, and determines the available display modes
|
||||
* and pixel formats, but does not initialize a window or graphics mode.
|
||||
*
|
||||
* \sa SDL_VideoQuit()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name);
|
||||
|
||||
/**
|
||||
* \brief Shuts down the video subsystem.
|
||||
*
|
||||
* This function closes all windows, and restores the original video mode.
|
||||
*
|
||||
* \sa SDL_VideoInit()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
|
||||
|
||||
/**
|
||||
* \brief Returns the name of the currently initialized video driver.
|
||||
*
|
||||
* \return The name of the current video driver or NULL if no driver
|
||||
* has been initialized
|
||||
*
|
||||
* \sa SDL_GetNumVideoDrivers()
|
||||
* \sa SDL_GetVideoDriver()
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
|
||||
|
||||
/**
|
||||
* \brief Returns the number of available video displays.
|
||||
*
|
||||
* \sa SDL_GetDisplayBounds()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
|
||||
|
||||
/**
|
||||
* \brief Get the desktop area represented by a display, with the primary
|
||||
* display located at 0,0
|
||||
*
|
||||
* \return 0 on success, or -1 if the index is out of range.
|
||||
*
|
||||
* \sa SDL_GetNumVideoDisplays()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Returns the number of available display modes.
|
||||
*
|
||||
* \sa SDL_GetDisplayMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
|
||||
|
||||
/**
|
||||
* \brief Fill in information about a specific display mode.
|
||||
*
|
||||
* \note The display modes are sorted in this priority:
|
||||
* \li bits per pixel -> more colors to fewer colors
|
||||
* \li width -> largest to smallest
|
||||
* \li height -> largest to smallest
|
||||
* \li refresh rate -> highest to lowest
|
||||
*
|
||||
* \sa SDL_GetNumDisplayModes()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
|
||||
SDL_DisplayMode * mode);
|
||||
|
||||
/**
|
||||
* \brief Fill in information about the desktop display mode.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode);
|
||||
|
||||
/**
|
||||
* \brief Fill in information about the current display mode.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the closest match to the requested display mode.
|
||||
*
|
||||
* \param mode The desired display mode
|
||||
* \param closest A pointer to a display mode to be filled in with the closest
|
||||
* match of the available display modes.
|
||||
*
|
||||
* \return The passed in value \c closest, or NULL if no matching video mode
|
||||
* was available.
|
||||
*
|
||||
* The available display modes are scanned, and \c closest is filled in with the
|
||||
* closest mode matching the requested mode and returned. The mode format and
|
||||
* refresh_rate default to the desktop mode if they are 0. The modes are
|
||||
* scanned with size being first priority, format being second priority, and
|
||||
* finally checking the refresh_rate. If all the available modes are too
|
||||
* small, then NULL is returned.
|
||||
*
|
||||
* \sa SDL_GetNumDisplayModes()
|
||||
* \sa SDL_GetDisplayMode()
|
||||
*/
|
||||
extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
|
||||
|
||||
/**
|
||||
* \brief Get the display index associated with a window.
|
||||
*
|
||||
* \return the display index of the display containing the center of the
|
||||
* window, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetWindowDisplay(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the display mode used when a fullscreen window is visible.
|
||||
*
|
||||
* By default the window's dimensions and the desktop format and refresh rate
|
||||
* are used.
|
||||
*
|
||||
* \param mode The mode to use, or NULL for the default mode.
|
||||
*
|
||||
* \return 0 on success, or -1 if setting the display mode failed.
|
||||
*
|
||||
* \sa SDL_GetWindowDisplayMode()
|
||||
* \sa SDL_SetWindowFullscreen()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
|
||||
const SDL_DisplayMode
|
||||
* mode);
|
||||
|
||||
/**
|
||||
* \brief Fill in information about the display mode used when a fullscreen
|
||||
* window is visible.
|
||||
*
|
||||
* \sa SDL_SetWindowDisplayMode()
|
||||
* \sa SDL_SetWindowFullscreen()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
|
||||
SDL_DisplayMode * mode);
|
||||
|
||||
/**
|
||||
* \brief Get the pixel format associated with the window.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Create a window with the specified position, dimensions, and flags.
|
||||
*
|
||||
* \param title The title of the window, in UTF-8 encoding.
|
||||
* \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param w The width of the window.
|
||||
* \param h The height of the window.
|
||||
* \param flags The flags for the window, a mask of any of the following:
|
||||
* ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL,
|
||||
* ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_BORDERLESS,
|
||||
* ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED,
|
||||
* ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED.
|
||||
*
|
||||
* \return The id of the window created, or zero if window creation failed.
|
||||
*
|
||||
* \sa SDL_DestroyWindow()
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
|
||||
int x, int y, int w,
|
||||
int h, Uint32 flags);
|
||||
|
||||
/**
|
||||
* \brief Create an SDL window from an existing native window.
|
||||
*
|
||||
* \param data A pointer to driver-dependent window creation data
|
||||
*
|
||||
* \return The id of the window created, or zero if window creation failed.
|
||||
*
|
||||
* \sa SDL_DestroyWindow()
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data);
|
||||
|
||||
/**
|
||||
* \brief Get the numeric ID of a window, for logging purposes.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Get a window from a stored ID, or NULL if it doesn't exist.
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
|
||||
|
||||
/**
|
||||
* \brief Get the window flags.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the title of a window, in UTF-8 format.
|
||||
*
|
||||
* \sa SDL_GetWindowTitle()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
|
||||
const char *title);
|
||||
|
||||
/**
|
||||
* \brief Get the title of a window, in UTF-8 format.
|
||||
*
|
||||
* \sa SDL_SetWindowTitle()
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the icon for a window.
|
||||
*
|
||||
* \param icon The icon for the window.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
|
||||
SDL_Surface * icon);
|
||||
|
||||
/**
|
||||
* \brief Associate an arbitrary named pointer with a window.
|
||||
*
|
||||
* \param window The window to associate with the pointer.
|
||||
* \param name The name of the pointer.
|
||||
* \param userdata The associated pointer.
|
||||
*
|
||||
* \return The previous value associated with 'name'
|
||||
*
|
||||
* \note The name is case-sensitive.
|
||||
*
|
||||
* \sa SDL_GetWindowData()
|
||||
*/
|
||||
extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
|
||||
const char *name,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the data pointer associated with a window.
|
||||
*
|
||||
* \param window The window to query.
|
||||
* \param name The name of the pointer.
|
||||
*
|
||||
* \return The value associated with 'name'
|
||||
*
|
||||
* \sa SDL_SetWindowData()
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* \brief Set the position of a window.
|
||||
*
|
||||
* \param window The window to reposition.
|
||||
* \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
::SDL_WINDOWPOS_UNDEFINED.
|
||||
*
|
||||
* \note The window coordinate origin is the upper left of the display.
|
||||
*
|
||||
* \sa SDL_GetWindowPosition()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
|
||||
int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Get the position of a window.
|
||||
*
|
||||
* \sa SDL_SetWindowPosition()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
|
||||
int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Set the size of a window's client area.
|
||||
*
|
||||
* \note You can't change the size of a fullscreen window, it automatically
|
||||
* matches the size of the display mode.
|
||||
*
|
||||
* \sa SDL_GetWindowSize()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
|
||||
int h);
|
||||
|
||||
/**
|
||||
* \brief Get the size of a window's client area.
|
||||
*
|
||||
* \sa SDL_SetWindowSize()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
||||
int *h);
|
||||
|
||||
/**
|
||||
* \brief Show a window.
|
||||
*
|
||||
* \sa SDL_HideWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Hide a window.
|
||||
*
|
||||
* \sa SDL_ShowWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Raise a window above other windows and set the input focus.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Make a window as large as possible.
|
||||
*
|
||||
* \sa SDL_RestoreWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Minimize a window to an iconic representation.
|
||||
*
|
||||
* \sa SDL_RestoreWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Restore the size and position of a minimized or maximized window.
|
||||
*
|
||||
* \sa SDL_MaximizeWindow()
|
||||
* \sa SDL_MinimizeWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set a window's fullscreen state.
|
||||
*
|
||||
* \return 0 on success, or -1 if setting the display mode failed.
|
||||
*
|
||||
* \sa SDL_SetWindowDisplayMode()
|
||||
* \sa SDL_GetWindowDisplayMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
|
||||
SDL_bool fullscreen);
|
||||
|
||||
/**
|
||||
* \brief Get an SDL surface associated with the window.
|
||||
*
|
||||
* \return A surface in the optimal format for the window, or NULL on error.
|
||||
*
|
||||
* \note You may not combine this with 3D or the rendering API on this window.
|
||||
*
|
||||
* \sa SDL_UpdateWindowSurface()
|
||||
* \sa SDL_UpdateWindowSurfaceRects()
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Copy the window surface to the screen.
|
||||
*
|
||||
* \return 0 on success, or -1 on error.
|
||||
*
|
||||
* \sa SDL_GetWindowSurface()
|
||||
* \sa SDL_UpdateWindowSurfaceRects()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Copy a number of rectangles on the window surface to the screen.
|
||||
*
|
||||
* \return 0 on success, or -1 on error.
|
||||
*
|
||||
* \sa SDL_GetWindowSurface()
|
||||
* \sa SDL_UpdateWindowSurfaceRect()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
|
||||
SDL_Rect * rects,
|
||||
int numrects);
|
||||
|
||||
/**
|
||||
* \brief Set a window's input grab mode.
|
||||
*
|
||||
* \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input.
|
||||
*
|
||||
* \sa SDL_GetWindowGrab()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
|
||||
SDL_bool grabbed);
|
||||
|
||||
/**
|
||||
* \brief Get a window's input grab mode.
|
||||
*
|
||||
* \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise.
|
||||
*
|
||||
* \sa SDL_SetWindowGrab()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the brightness (gamma correction) for a window.
|
||||
*
|
||||
* \return 0 on success, or -1 if setting the brightness isn't supported.
|
||||
*
|
||||
* \sa SDL_GetWindowBrightness()
|
||||
* \sa SDL_SetWindowGammaRamp()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness);
|
||||
|
||||
/**
|
||||
* \brief Get the brightness (gamma correction) for a window.
|
||||
*
|
||||
* \return The last brightness value passed to SDL_SetWindowBrightness()
|
||||
*
|
||||
* \sa SDL_SetWindowBrightness()
|
||||
*/
|
||||
extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the gamma ramp for a window.
|
||||
*
|
||||
* \param red The translation table for the red channel, or NULL.
|
||||
* \param green The translation table for the green channel, or NULL.
|
||||
* \param blue The translation table for the blue channel, or NULL.
|
||||
*
|
||||
* \return 0 on success, or -1 if gamma ramps are unsupported.
|
||||
*
|
||||
* Set the gamma translation table for the red, green, and blue channels
|
||||
* of the video hardware. Each table is an array of 256 16-bit quantities,
|
||||
* representing a mapping between the input and output for that channel.
|
||||
* The input is the index into the array, and the output is the 16-bit
|
||||
* gamma value at that index, scaled to the output color precision.
|
||||
*
|
||||
* \sa SDL_SetWindowGammaRamp()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window,
|
||||
const Uint16 * red,
|
||||
const Uint16 * green,
|
||||
const Uint16 * blue);
|
||||
|
||||
/**
|
||||
* \brief Get the gamma ramp for a window.
|
||||
*
|
||||
* \param red A pointer to a 256 element array of 16-bit quantities to hold
|
||||
* the translation table for the red channel, or NULL.
|
||||
* \param green A pointer to a 256 element array of 16-bit quantities to hold
|
||||
* the translation table for the green channel, or NULL.
|
||||
* \param blue A pointer to a 256 element array of 16-bit quantities to hold
|
||||
* the translation table for the blue channel, or NULL.
|
||||
*
|
||||
* \return 0 on success, or -1 if gamma ramps are unsupported.
|
||||
*
|
||||
* \sa SDL_SetWindowGammaRamp()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window,
|
||||
Uint16 * red,
|
||||
Uint16 * green,
|
||||
Uint16 * blue);
|
||||
|
||||
/**
|
||||
* \brief Destroy a window.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Returns whether the screensaver is currently enabled (default on).
|
||||
*
|
||||
* \sa SDL_EnableScreenSaver()
|
||||
* \sa SDL_DisableScreenSaver()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void);
|
||||
|
||||
/**
|
||||
* \brief Allow the screen to be blanked by a screensaver
|
||||
*
|
||||
* \sa SDL_IsScreenSaverEnabled()
|
||||
* \sa SDL_DisableScreenSaver()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void);
|
||||
|
||||
/**
|
||||
* \brief Prevent the screen from being blanked by a screensaver
|
||||
*
|
||||
* \sa SDL_IsScreenSaverEnabled()
|
||||
* \sa SDL_EnableScreenSaver()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void);
|
||||
|
||||
|
||||
/**
|
||||
* \name OpenGL support functions
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* \brief Dynamically load an OpenGL library.
|
||||
*
|
||||
* \param path The platform dependent OpenGL library name, or NULL to open the
|
||||
* default OpenGL library.
|
||||
*
|
||||
* \return 0 on success, or -1 if the library couldn't be loaded.
|
||||
*
|
||||
* This should be done after initializing the video driver, but before
|
||||
* creating any OpenGL windows. If no OpenGL library is loaded, the default
|
||||
* library will be loaded upon creation of the first OpenGL window.
|
||||
*
|
||||
* \note If you do this, you need to retrieve all of the GL functions used in
|
||||
* your program from the dynamic library using SDL_GL_GetProcAddress().
|
||||
*
|
||||
* \sa SDL_GL_GetProcAddress()
|
||||
* \sa SDL_GL_UnloadLibrary()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
|
||||
|
||||
/**
|
||||
* \brief Get the address of an OpenGL function.
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
|
||||
|
||||
/**
|
||||
* \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
|
||||
*
|
||||
* \sa SDL_GL_LoadLibrary()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
|
||||
|
||||
/**
|
||||
* \brief Return true if an OpenGL extension is supported for the current
|
||||
* context.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char
|
||||
*extension);
|
||||
|
||||
/**
|
||||
* \brief Set an OpenGL window attribute before window creation.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
|
||||
/**
|
||||
* \brief Get the actual value for an attribute from the current context.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
|
||||
|
||||
/**
|
||||
* \brief Create an OpenGL context for use with an OpenGL window, and make it
|
||||
* current.
|
||||
*
|
||||
* \sa SDL_GL_DeleteContext()
|
||||
*/
|
||||
extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
|
||||
window);
|
||||
|
||||
/**
|
||||
* \brief Set up an OpenGL context for rendering into an OpenGL window.
|
||||
*
|
||||
* \note The context must have been created with a compatible window.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window,
|
||||
SDL_GLContext context);
|
||||
|
||||
/**
|
||||
* \brief Set the swap interval for the current OpenGL context.
|
||||
*
|
||||
* \param interval 0 for immediate updates, 1 for updates synchronized with the
|
||||
* vertical retrace.
|
||||
*
|
||||
* \return 0 on success, or -1 if setting the swap interval is not supported.
|
||||
*
|
||||
* \sa SDL_GL_GetSwapInterval()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
|
||||
|
||||
/**
|
||||
* \brief Get the swap interval for the current OpenGL context.
|
||||
*
|
||||
* \return 0 if there is no vertical retrace synchronization, 1 if the buffer
|
||||
* swap is synchronized with the vertical retrace, and -1 if getting
|
||||
* the swap interval is not supported.
|
||||
*
|
||||
* \sa SDL_GL_SetSwapInterval()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);
|
||||
|
||||
/**
|
||||
* \brief Swap the OpenGL buffers for a window, if double-buffering is
|
||||
* supported.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Delete an OpenGL context.
|
||||
*
|
||||
* \sa SDL_GL_CreateContext()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
|
||||
|
||||
/*@}*//*OpenGL support functions*/
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_video_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file begin_code.h
|
||||
*
|
||||
* This file sets things up for C dynamic library function definitions,
|
||||
* static inlined functions, and structures aligned at 4-byte alignment.
|
||||
* If you don't like ugly C preprocessor code, don't look at this file. :)
|
||||
*/
|
||||
|
||||
/* This shouldn't be nested -- included it around code only. */
|
||||
#ifdef _begin_code_h
|
||||
#error Nested inclusion of begin_code.h
|
||||
#endif
|
||||
#define _begin_code_h
|
||||
|
||||
/* Some compilers use a special export keyword */
|
||||
#ifndef DECLSPEC
|
||||
# if defined(__BEOS__) || defined(__HAIKU__)
|
||||
# if defined(__GNUC__)
|
||||
# define DECLSPEC __declspec(dllexport)
|
||||
# else
|
||||
# define DECLSPEC __declspec(export)
|
||||
# endif
|
||||
# elif defined(__WIN32__)
|
||||
# ifdef __BORLANDC__
|
||||
# ifdef BUILD_SDL
|
||||
# define DECLSPEC
|
||||
# else
|
||||
# define DECLSPEC __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define DECLSPEC __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define DECLSPEC __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define DECLSPEC
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* By default SDL uses the C calling convention */
|
||||
#ifndef SDLCALL
|
||||
#if defined(__WIN32__) && !defined(__GNUC__)
|
||||
#define SDLCALL __cdecl
|
||||
#else
|
||||
#define SDLCALL
|
||||
#endif
|
||||
#endif /* SDLCALL */
|
||||
|
||||
/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
|
||||
#ifdef __SYMBIAN32__
|
||||
#undef DECLSPEC
|
||||
#define DECLSPEC
|
||||
#endif /* __SYMBIAN32__ */
|
||||
|
||||
/* Force structure packing at 4 byte alignment.
|
||||
This is necessary if the header is included in code which has structure
|
||||
packing set to an alternate value, say for loading structures from disk.
|
||||
The packing is reset to the previous value in close_code.h
|
||||
*/
|
||||
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4103)
|
||||
#endif
|
||||
#ifdef __BORLANDC__
|
||||
#pragma nopackwarning
|
||||
#endif
|
||||
#pragma pack(push,4)
|
||||
#endif /* Compiler needs structure packing set */
|
||||
|
||||
/* Set up compiler-specific options for inlining functions */
|
||||
#ifndef SDL_INLINE_OKAY
|
||||
#ifdef __GNUC__
|
||||
#define SDL_INLINE_OKAY
|
||||
#else
|
||||
/* Add any special compiler-specific cases here */
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
|
||||
defined(__DMC__) || defined(__SC__) || \
|
||||
defined(__WATCOMC__) || defined(__LCC__) || \
|
||||
defined(__DECC)
|
||||
#ifndef __inline__
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
#define SDL_INLINE_OKAY
|
||||
#else
|
||||
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
|
||||
#ifndef __inline__
|
||||
#define __inline__ inline
|
||||
#endif
|
||||
#define SDL_INLINE_OKAY
|
||||
#endif /* Not a funky compiler */
|
||||
#endif /* Visual C++ */
|
||||
#endif /* GNU C */
|
||||
#endif /* SDL_INLINE_OKAY */
|
||||
|
||||
/* If inlining isn't supported, remove "__inline__", turning static
|
||||
inlined functions into static functions (resulting in code bloat
|
||||
in all files which include the offending header files)
|
||||
*/
|
||||
#ifndef SDL_INLINE_OKAY
|
||||
#define __inline__
|
||||
#endif
|
||||
|
||||
/* Apparently this is needed by several Windows compilers */
|
||||
#if !defined(__MACH__)
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif /* NULL */
|
||||
#endif /* ! Mac OS X - breaks precompiled headers */
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file close_code.h
|
||||
*
|
||||
* This file reverses the effects of begin_code.h and should be included
|
||||
* after you finish any function and structure declarations in your headers
|
||||
*/
|
||||
|
||||
#undef _begin_code_h
|
||||
|
||||
/* Reset structure packing at previous byte alignment */
|
||||
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
|
||||
#ifdef __BORLANDC__
|
||||
#pragma nopackwarning
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
#endif /* Compiler needs structure packing set */
|
File diff suppressed because it is too large
Load diff
|
@ -1,60 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
exec_prefix_set=no
|
||||
libdir=@libdir@
|
||||
|
||||
@ENABLE_STATIC_FALSE@usage="\
|
||||
@ENABLE_STATIC_FALSE@Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs]"
|
||||
@ENABLE_STATIC_TRUE@usage="\
|
||||
@ENABLE_STATIC_TRUE@Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]"
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) optarg= ;;
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
if test $exec_prefix_set = no ; then
|
||||
exec_prefix=$optarg
|
||||
fi
|
||||
;;
|
||||
--prefix)
|
||||
echo $prefix
|
||||
;;
|
||||
--exec-prefix=*)
|
||||
exec_prefix=$optarg
|
||||
exec_prefix_set=yes
|
||||
;;
|
||||
--exec-prefix)
|
||||
echo $exec_prefix
|
||||
;;
|
||||
--version)
|
||||
echo @SDL_VERSION@
|
||||
;;
|
||||
--cflags)
|
||||
echo -I@includedir@/SDL @SDL_CFLAGS@
|
||||
;;
|
||||
@ENABLE_SHARED_TRUE@ --libs)
|
||||
@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@
|
||||
@ENABLE_SHARED_TRUE@ ;;
|
||||
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs)
|
||||
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs)
|
||||
@ENABLE_STATIC_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_STATIC_LIBS@
|
||||
@ENABLE_STATIC_TRUE@ ;;
|
||||
*)
|
||||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
|
@ -1,327 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Initialization code for SDL */
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_revision.h"
|
||||
#include "SDL_fatal.h"
|
||||
#include "SDL_assert_c.h"
|
||||
#include "haptic/SDL_haptic_c.h"
|
||||
#include "joystick/SDL_joystick_c.h"
|
||||
|
||||
/* Initialization/Cleanup routines */
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
extern void SDL_StartTicks(void);
|
||||
extern int SDL_TimerInit(void);
|
||||
extern void SDL_TimerQuit(void);
|
||||
#endif
|
||||
#if defined(__WIN32__)
|
||||
extern int SDL_HelperWindowCreate(void);
|
||||
extern int SDL_HelperWindowDestroy(void);
|
||||
#endif
|
||||
|
||||
|
||||
/* The initialized subsystems */
|
||||
static Uint32 SDL_initialized = 0;
|
||||
static Uint32 ticks_started = 0;
|
||||
|
||||
|
||||
int
|
||||
SDL_InitSubSystem(Uint32 flags)
|
||||
{
|
||||
#if !SDL_VIDEO_DISABLED
|
||||
/* Initialize the video/event subsystem */
|
||||
if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
|
||||
if (SDL_VideoInit(NULL) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_VIDEO;
|
||||
}
|
||||
#else
|
||||
if (flags & SDL_INIT_VIDEO) {
|
||||
SDL_SetError("SDL not built with video support");
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_AUDIO_DISABLED
|
||||
/* Initialize the audio subsystem */
|
||||
if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) {
|
||||
if (SDL_AudioInit(NULL) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_AUDIO;
|
||||
}
|
||||
#else
|
||||
if (flags & SDL_INIT_AUDIO) {
|
||||
SDL_SetError("SDL not built with audio support");
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
/* Initialize the timer subsystem */
|
||||
if (!ticks_started) {
|
||||
SDL_StartTicks();
|
||||
ticks_started = 1;
|
||||
}
|
||||
if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) {
|
||||
if (SDL_TimerInit() < 0) {
|
||||
return (-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_TIMER;
|
||||
}
|
||||
#else
|
||||
if (flags & SDL_INIT_TIMER) {
|
||||
SDL_SetError("SDL not built with timer support");
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
/* Initialize the joystick subsystem */
|
||||
if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) {
|
||||
if (SDL_JoystickInit() < 0) {
|
||||
return (-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_JOYSTICK;
|
||||
}
|
||||
#else
|
||||
if (flags & SDL_INIT_JOYSTICK) {
|
||||
SDL_SetError("SDL not built with joystick support");
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !SDL_HAPTIC_DISABLED
|
||||
/* Initialize the haptic subsystem */
|
||||
if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) {
|
||||
if (SDL_HapticInit() < 0) {
|
||||
return (-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_HAPTIC;
|
||||
}
|
||||
#else
|
||||
if (flags & SDL_INIT_HAPTIC) {
|
||||
SDL_SetError("SDL not built with haptic (force feedback) support");
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_Init(Uint32 flags)
|
||||
{
|
||||
if (SDL_AssertionsInit() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Clear the error message */
|
||||
SDL_ClearError();
|
||||
|
||||
#if defined(__WIN32__)
|
||||
if (SDL_HelperWindowCreate() < 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the desired subsystems */
|
||||
if (SDL_InitSubSystem(flags) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Everything is initialized */
|
||||
if (!(flags & SDL_INIT_NOPARACHUTE)) {
|
||||
SDL_InstallParachute();
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_QuitSubSystem(Uint32 flags)
|
||||
{
|
||||
/* Shut down requested initialized subsystems */
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) {
|
||||
SDL_JoystickQuit();
|
||||
SDL_initialized &= ~SDL_INIT_JOYSTICK;
|
||||
}
|
||||
#endif
|
||||
#if !SDL_HAPTIC_DISABLED
|
||||
if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) {
|
||||
SDL_HapticQuit();
|
||||
SDL_initialized &= ~SDL_INIT_HAPTIC;
|
||||
}
|
||||
#endif
|
||||
#if !SDL_TIMERS_DISABLED
|
||||
if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
|
||||
SDL_TimerQuit();
|
||||
SDL_initialized &= ~SDL_INIT_TIMER;
|
||||
}
|
||||
#endif
|
||||
#if !SDL_AUDIO_DISABLED
|
||||
if ((flags & SDL_initialized & SDL_INIT_AUDIO)) {
|
||||
SDL_AudioQuit();
|
||||
SDL_initialized &= ~SDL_INIT_AUDIO;
|
||||
}
|
||||
#endif
|
||||
#if !SDL_VIDEO_DISABLED
|
||||
if ((flags & SDL_initialized & SDL_INIT_VIDEO)) {
|
||||
SDL_VideoQuit();
|
||||
SDL_initialized &= ~SDL_INIT_VIDEO;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_WasInit(Uint32 flags)
|
||||
{
|
||||
if (!flags) {
|
||||
flags = SDL_INIT_EVERYTHING;
|
||||
}
|
||||
return (SDL_initialized & flags);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Quit(void)
|
||||
{
|
||||
/* Quit all subsystems */
|
||||
#if defined(__WIN32__)
|
||||
SDL_HelperWindowDestroy();
|
||||
#endif
|
||||
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
|
||||
|
||||
/* Uninstall any parachute signal handlers */
|
||||
SDL_UninstallParachute();
|
||||
|
||||
SDL_ClearHints();
|
||||
SDL_AssertionsQuit();
|
||||
SDL_LogResetPriorities();
|
||||
}
|
||||
|
||||
/* Get the library version number */
|
||||
void
|
||||
SDL_GetVersion(SDL_version * ver)
|
||||
{
|
||||
SDL_VERSION(ver);
|
||||
}
|
||||
|
||||
/* Get the library source revision */
|
||||
const char *
|
||||
SDL_GetRevision(void)
|
||||
{
|
||||
return SDL_REVISION;
|
||||
}
|
||||
|
||||
/* Get the library source revision number */
|
||||
int
|
||||
SDL_GetRevisionNumber(void)
|
||||
{
|
||||
return SDL_REVISION_NUMBER;
|
||||
}
|
||||
|
||||
/* Get the name of the platform */
|
||||
const char *
|
||||
SDL_GetPlatform()
|
||||
{
|
||||
#if __AIX__
|
||||
return "AIX";
|
||||
#elif __HAIKU__
|
||||
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
|
||||
return "Haiku";
|
||||
#elif __BEOS__
|
||||
return "BeOS";
|
||||
#elif __BSDI__
|
||||
return "BSDI";
|
||||
#elif __DREAMCAST__
|
||||
return "Dreamcast";
|
||||
#elif __FREEBSD__
|
||||
return "FreeBSD";
|
||||
#elif __HPUX__
|
||||
return "HP-UX";
|
||||
#elif __IRIX__
|
||||
return "Irix";
|
||||
#elif __LINUX__
|
||||
return "Linux";
|
||||
#elif __MINT__
|
||||
return "Atari MiNT";
|
||||
#elif __MACOS__
|
||||
return "MacOS Classic";
|
||||
#elif __MACOSX__
|
||||
return "Mac OS X";
|
||||
#elif __NETBSD__
|
||||
return "NetBSD";
|
||||
#elif __NDS__
|
||||
return "Nintendo DS";
|
||||
#elif __OPENBSD__
|
||||
return "OpenBSD";
|
||||
#elif __OS2__
|
||||
return "OS/2";
|
||||
#elif __OSF__
|
||||
return "OSF/1";
|
||||
#elif __QNXNTO__
|
||||
return "QNX Neutrino";
|
||||
#elif __RISCOS__
|
||||
return "RISC OS";
|
||||
#elif __SOLARIS__
|
||||
return "Solaris";
|
||||
#elif __WIN32__
|
||||
#ifdef _WIN32_WCE
|
||||
return "Windows CE";
|
||||
#else
|
||||
return "Windows";
|
||||
#endif
|
||||
#elif __IPHONEOS__
|
||||
return "iPhone OS";
|
||||
#else
|
||||
return "Unknown (see SDL_platform.h)";
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__WIN32__)
|
||||
|
||||
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
|
||||
/* Need to include DllMain() on Watcom C for some reason.. */
|
||||
#include "core/windows/SDL_windows.h"
|
||||
|
||||
BOOL APIENTRY
|
||||
_DllMainCRTStartup(HANDLE hModule,
|
||||
DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* building DLL with Watcom C */
|
||||
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,488 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_atomic.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_assert_c.h"
|
||||
#include "video/SDL_sysvideo.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#include "core/windows/SDL_windows.h"
|
||||
|
||||
#ifndef WS_OVERLAPPEDWINDOW
|
||||
#define WS_OVERLAPPEDWINDOW 0
|
||||
#endif
|
||||
#else /* fprintf, _exit(), etc. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static SDL_assert_state
|
||||
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
|
||||
|
||||
/*
|
||||
* We keep all triggered assertions in a singly-linked list so we can
|
||||
* generate a report later.
|
||||
*/
|
||||
static SDL_assert_data assertion_list_terminator = { 0, 0, 0, 0, 0, 0, 0 };
|
||||
static SDL_assert_data *triggered_assertions = &assertion_list_terminator;
|
||||
|
||||
static SDL_mutex *assertion_mutex = NULL;
|
||||
static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
|
||||
static void *assertion_userdata = NULL;
|
||||
|
||||
#ifdef __GNUC__
|
||||
static void
|
||||
debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
|
||||
#endif
|
||||
|
||||
static void
|
||||
debug_print(const char *fmt, ...)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
/* Format into a buffer for OutputDebugStringA(). */
|
||||
char buf[1024];
|
||||
char *startptr;
|
||||
char *ptr;
|
||||
LPTSTR tstr;
|
||||
int len;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
len = (int) SDL_vsnprintf(buf, sizeof (buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* Visual C's vsnprintf() may not null-terminate the buffer. */
|
||||
if ((len >= sizeof (buf)) || (len < 0)) {
|
||||
buf[sizeof (buf) - 1] = '\0';
|
||||
}
|
||||
|
||||
/* Write it, sorting out the Unix newlines... */
|
||||
startptr = buf;
|
||||
for (ptr = startptr; *ptr; ptr++) {
|
||||
if (*ptr == '\n') {
|
||||
*ptr = '\0';
|
||||
tstr = WIN_UTF8ToString(startptr);
|
||||
OutputDebugString(tstr);
|
||||
SDL_free(tstr);
|
||||
OutputDebugString(TEXT("\r\n"));
|
||||
startptr = ptr+1;
|
||||
}
|
||||
}
|
||||
|
||||
/* catch that last piece if it didn't have a newline... */
|
||||
if (startptr != ptr) {
|
||||
tstr = WIN_UTF8ToString(startptr);
|
||||
OutputDebugString(tstr);
|
||||
SDL_free(tstr);
|
||||
}
|
||||
#else
|
||||
/* Unix has it easy. Just dump it to stderr. */
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef __WIN32__
|
||||
static SDL_assert_state SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
|
||||
static const SDL_assert_data *SDL_Windows_AssertData = NULL;
|
||||
|
||||
static LRESULT CALLBACK
|
||||
SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
/* !!! FIXME: all this code stinks. */
|
||||
const SDL_assert_data *data = SDL_Windows_AssertData;
|
||||
char buf[1024];
|
||||
LPTSTR tstr;
|
||||
const int w = 100;
|
||||
const int h = 25;
|
||||
const int gap = 10;
|
||||
int x = gap;
|
||||
int y = 50;
|
||||
int len;
|
||||
int i;
|
||||
static const struct {
|
||||
LPCTSTR name;
|
||||
SDL_assert_state state;
|
||||
} buttons[] = {
|
||||
{TEXT("Abort"), SDL_ASSERTION_ABORT },
|
||||
{TEXT("Break"), SDL_ASSERTION_BREAK },
|
||||
{TEXT("Retry"), SDL_ASSERTION_RETRY },
|
||||
{TEXT("Ignore"), SDL_ASSERTION_IGNORE },
|
||||
{TEXT("Always Ignore"), SDL_ASSERTION_ALWAYS_IGNORE },
|
||||
};
|
||||
|
||||
len = (int) SDL_snprintf(buf, sizeof (buf),
|
||||
"Assertion failure at %s (%s:%d), triggered %u time%s:\r\n '%s'",
|
||||
data->function, data->filename, data->linenum,
|
||||
data->trigger_count, (data->trigger_count == 1) ? "" : "s",
|
||||
data->condition);
|
||||
if ((len < 0) || (len >= sizeof (buf))) {
|
||||
buf[sizeof (buf) - 1] = '\0';
|
||||
}
|
||||
|
||||
tstr = WIN_UTF8ToString(buf);
|
||||
CreateWindow(TEXT("STATIC"), tstr,
|
||||
WS_VISIBLE | WS_CHILD | SS_LEFT,
|
||||
x, y, 550, 100,
|
||||
hwnd, (HMENU) 1, NULL, NULL);
|
||||
SDL_free(tstr);
|
||||
y += 110;
|
||||
|
||||
for (i = 0; i < (sizeof (buttons) / sizeof (buttons[0])); i++) {
|
||||
CreateWindow(TEXT("BUTTON"), buttons[i].name,
|
||||
WS_VISIBLE | WS_CHILD,
|
||||
x, y, w, h,
|
||||
hwnd, (HMENU) buttons[i].state, NULL, NULL);
|
||||
x += w + gap;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
SDL_Windows_AssertChoice = ((SDL_assert_state) (LOWORD(wParam)));
|
||||
SDL_Windows_AssertData = NULL;
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
SDL_Windows_AssertData = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
static SDL_assert_state
|
||||
SDL_PromptAssertion_windows(const SDL_assert_data *data)
|
||||
{
|
||||
HINSTANCE hInstance = 0; /* !!! FIXME? */
|
||||
HWND hwnd;
|
||||
MSG msg;
|
||||
WNDCLASS wc = {0};
|
||||
|
||||
SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
|
||||
SDL_Windows_AssertData = data;
|
||||
|
||||
wc.lpszClassName = TEXT("SDL_assert");
|
||||
wc.hInstance = hInstance ;
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||
wc.lpfnWndProc = SDL_Assertion_WndProc;
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
|
||||
RegisterClass(&wc);
|
||||
hwnd = CreateWindow(wc.lpszClassName, TEXT("SDL assertion failure"),
|
||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
150, 150, 570, 260, 0, 0, hInstance, 0);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0) && (SDL_Windows_AssertData != NULL)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
UnregisterClass(wc.lpszClassName, hInstance);
|
||||
return SDL_Windows_AssertChoice;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void SDL_AddAssertionToReport(SDL_assert_data *data)
|
||||
{
|
||||
/* (data) is always a static struct defined with the assert macros, so
|
||||
we don't have to worry about copying or allocating them. */
|
||||
if (data->next == NULL) { /* not yet added? */
|
||||
data->next = triggered_assertions;
|
||||
triggered_assertions = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void SDL_GenerateAssertionReport(void)
|
||||
{
|
||||
const SDL_assert_data *item;
|
||||
|
||||
/* only do this if the app hasn't assigned an assertion handler. */
|
||||
if (assertion_handler != SDL_PromptAssertion)
|
||||
return;
|
||||
|
||||
item = SDL_GetAssertionReport();
|
||||
if (item->condition)
|
||||
{
|
||||
debug_print("\n\nSDL assertion report.\n");
|
||||
debug_print("All SDL assertions between last init/quit:\n\n");
|
||||
|
||||
while (item->condition) {
|
||||
debug_print(
|
||||
"'%s'\n"
|
||||
" * %s (%s:%d)\n"
|
||||
" * triggered %u time%s.\n"
|
||||
" * always ignore: %s.\n",
|
||||
item->condition, item->function, item->filename,
|
||||
item->linenum, item->trigger_count,
|
||||
(item->trigger_count == 1) ? "" : "s",
|
||||
item->always_ignore ? "yes" : "no");
|
||||
item = item->next;
|
||||
}
|
||||
debug_print("\n");
|
||||
|
||||
SDL_ResetAssertionReport();
|
||||
}
|
||||
}
|
||||
|
||||
static void SDL_ExitProcess(int exitcode)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
ExitProcess(42);
|
||||
#else
|
||||
_exit(42);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SDL_AbortAssertion(void)
|
||||
{
|
||||
SDL_Quit();
|
||||
SDL_ExitProcess(42);
|
||||
}
|
||||
|
||||
|
||||
static SDL_assert_state
|
||||
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
|
||||
{
|
||||
const char *envr;
|
||||
SDL_assert_state state = SDL_ASSERTION_ABORT;
|
||||
SDL_Window *window;
|
||||
|
||||
(void) userdata; /* unused in default handler. */
|
||||
|
||||
debug_print("\n\n"
|
||||
"Assertion failure at %s (%s:%d), triggered %u time%s:\n"
|
||||
" '%s'\n"
|
||||
"\n",
|
||||
data->function, data->filename, data->linenum,
|
||||
data->trigger_count, (data->trigger_count == 1) ? "" : "s",
|
||||
data->condition);
|
||||
|
||||
/* let env. variable override, so unit tests won't block in a GUI. */
|
||||
envr = SDL_getenv("SDL_ASSERT");
|
||||
if (envr != NULL) {
|
||||
if (SDL_strcmp(envr, "abort") == 0) {
|
||||
return SDL_ASSERTION_ABORT;
|
||||
} else if (SDL_strcmp(envr, "break") == 0) {
|
||||
return SDL_ASSERTION_BREAK;
|
||||
} else if (SDL_strcmp(envr, "retry") == 0) {
|
||||
return SDL_ASSERTION_RETRY;
|
||||
} else if (SDL_strcmp(envr, "ignore") == 0) {
|
||||
return SDL_ASSERTION_IGNORE;
|
||||
} else if (SDL_strcmp(envr, "always_ignore") == 0) {
|
||||
return SDL_ASSERTION_ALWAYS_IGNORE;
|
||||
} else {
|
||||
return SDL_ASSERTION_ABORT; /* oh well. */
|
||||
}
|
||||
}
|
||||
|
||||
/* Leave fullscreen mode, if possible (scary!) */
|
||||
window = SDL_GetFocusWindow();
|
||||
if (window) {
|
||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
|
||||
SDL_MinimizeWindow(window);
|
||||
} else {
|
||||
/* !!! FIXME: ungrab the input if we're not fullscreen? */
|
||||
/* No need to mess with the window */
|
||||
window = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* platform-specific UI... */
|
||||
|
||||
#ifdef __WIN32__
|
||||
state = SDL_PromptAssertion_windows(data);
|
||||
|
||||
#elif __MACOSX__
|
||||
/* This has to be done in an Objective-C (*.m) file, so we call out. */
|
||||
extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *);
|
||||
state = SDL_PromptAssertion_cocoa(data);
|
||||
|
||||
#else
|
||||
/* this is a little hacky. */
|
||||
for ( ; ; ) {
|
||||
char buf[32];
|
||||
fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
||||
fflush(stderr);
|
||||
if (fgets(buf, sizeof (buf), stdin) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (SDL_strcmp(buf, "a") == 0) {
|
||||
state = SDL_ASSERTION_ABORT;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "b") == 0) {
|
||||
state = SDL_ASSERTION_BREAK;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "r") == 0) {
|
||||
state = SDL_ASSERTION_RETRY;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "i") == 0) {
|
||||
state = SDL_ASSERTION_IGNORE;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "A") == 0) {
|
||||
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Re-enter fullscreen mode */
|
||||
if (window) {
|
||||
SDL_RestoreWindow(window);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
SDL_assert_state
|
||||
SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
|
||||
int line)
|
||||
{
|
||||
static int assertion_running = 0;
|
||||
static SDL_SpinLock spinlock = 0;
|
||||
SDL_assert_state state = SDL_ASSERTION_IGNORE;
|
||||
|
||||
SDL_AtomicLock(&spinlock);
|
||||
if (assertion_mutex == NULL) { /* never called SDL_Init()? */
|
||||
assertion_mutex = SDL_CreateMutex();
|
||||
if (assertion_mutex == NULL) {
|
||||
SDL_AtomicUnlock(&spinlock);
|
||||
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
|
||||
}
|
||||
}
|
||||
SDL_AtomicUnlock(&spinlock);
|
||||
|
||||
if (SDL_LockMutex(assertion_mutex) < 0) {
|
||||
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
|
||||
}
|
||||
|
||||
/* doing this because Visual C is upset over assigning in the macro. */
|
||||
if (data->trigger_count == 0) {
|
||||
data->function = func;
|
||||
data->filename = file;
|
||||
data->linenum = line;
|
||||
}
|
||||
|
||||
SDL_AddAssertionToReport(data);
|
||||
|
||||
data->trigger_count++;
|
||||
|
||||
assertion_running++;
|
||||
if (assertion_running > 1) { /* assert during assert! Abort. */
|
||||
if (assertion_running == 2) {
|
||||
SDL_AbortAssertion();
|
||||
} else if (assertion_running == 3) { /* Abort asserted! */
|
||||
SDL_ExitProcess(42);
|
||||
} else {
|
||||
while (1) { /* do nothing but spin; what else can you do?! */ }
|
||||
}
|
||||
}
|
||||
|
||||
if (!data->always_ignore) {
|
||||
state = assertion_handler(data, assertion_userdata);
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case SDL_ASSERTION_ABORT:
|
||||
SDL_AbortAssertion();
|
||||
return SDL_ASSERTION_IGNORE; /* shouldn't return, but oh well. */
|
||||
|
||||
case SDL_ASSERTION_ALWAYS_IGNORE:
|
||||
state = SDL_ASSERTION_IGNORE;
|
||||
data->always_ignore = 1;
|
||||
break;
|
||||
|
||||
case SDL_ASSERTION_IGNORE:
|
||||
case SDL_ASSERTION_RETRY:
|
||||
case SDL_ASSERTION_BREAK:
|
||||
break; /* macro handles these. */
|
||||
}
|
||||
|
||||
assertion_running--;
|
||||
SDL_UnlockMutex(assertion_mutex);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
int SDL_AssertionsInit(void)
|
||||
{
|
||||
/* this is a no-op at the moment. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_AssertionsQuit(void)
|
||||
{
|
||||
SDL_GenerateAssertionReport();
|
||||
if (assertion_mutex != NULL) {
|
||||
SDL_DestroyMutex(assertion_mutex);
|
||||
assertion_mutex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)
|
||||
{
|
||||
if (handler != NULL) {
|
||||
assertion_handler = handler;
|
||||
assertion_userdata = userdata;
|
||||
} else {
|
||||
assertion_handler = SDL_PromptAssertion;
|
||||
assertion_userdata = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const SDL_assert_data *SDL_GetAssertionReport(void)
|
||||
{
|
||||
return triggered_assertions;
|
||||
}
|
||||
|
||||
void SDL_ResetAssertionReport(void)
|
||||
{
|
||||
SDL_assert_data *item = triggered_assertions;
|
||||
SDL_assert_data *next = NULL;
|
||||
for (item = triggered_assertions; item->condition; item = next) {
|
||||
next = (SDL_assert_data *) item->next;
|
||||
item->always_ignore = SDL_FALSE;
|
||||
item->trigger_count = 0;
|
||||
item->next = NULL;
|
||||
}
|
||||
|
||||
triggered_assertions = &assertion_list_terminator;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
extern int SDL_AssertionsInit(void);
|
||||
extern void SDL_AssertionsQuit(void);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
File diff suppressed because it is too large
Load diff
|
@ -1,259 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Simple error handling in SDL */
|
||||
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_error_c.h"
|
||||
|
||||
|
||||
/* Routine to get the thread-specific error variable */
|
||||
#if SDL_THREADS_DISABLED
|
||||
/* The default (non-thread-safe) global error variable */
|
||||
static SDL_error SDL_global_error;
|
||||
#define SDL_GetErrBuf() (&SDL_global_error)
|
||||
#else
|
||||
extern SDL_error *SDL_GetErrBuf(void);
|
||||
#endif /* SDL_THREADS_DISABLED */
|
||||
|
||||
#define SDL_ERRBUFIZE 1024
|
||||
|
||||
/* Private functions */
|
||||
|
||||
static const char *
|
||||
SDL_LookupString(const char *key)
|
||||
{
|
||||
/* FIXME: Add code to lookup key in language string hash-table */
|
||||
return key;
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
|
||||
void
|
||||
SDL_SetError(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
SDL_error *error;
|
||||
|
||||
/* Copy in the key, mark error as valid */
|
||||
error = SDL_GetErrBuf();
|
||||
error->error = 1;
|
||||
SDL_strlcpy((char *) error->key, fmt, sizeof(error->key));
|
||||
|
||||
va_start(ap, fmt);
|
||||
error->argc = 0;
|
||||
while (*fmt) {
|
||||
if (*fmt++ == '%') {
|
||||
while (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) {
|
||||
++fmt;
|
||||
}
|
||||
switch (*fmt++) {
|
||||
case 0: /* Malformed format string.. */
|
||||
--fmt;
|
||||
break;
|
||||
case 'c':
|
||||
case 'i':
|
||||
case 'd':
|
||||
case 'u':
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
error->args[error->argc++].value_i = va_arg(ap, int);
|
||||
break;
|
||||
case 'f':
|
||||
error->args[error->argc++].value_f = va_arg(ap, double);
|
||||
break;
|
||||
case 'p':
|
||||
error->args[error->argc++].value_ptr = va_arg(ap, void *);
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
int i = error->argc;
|
||||
const char *str = va_arg(ap, const char *);
|
||||
if (str == NULL)
|
||||
str = "(null)";
|
||||
SDL_strlcpy((char *) error->args[i].buf, str,
|
||||
ERR_MAX_STRLEN);
|
||||
error->argc++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (error->argc >= ERR_MAX_ARGS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
/* If we are in debug mode, print out an error message */
|
||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
|
||||
}
|
||||
|
||||
/* This function has a bit more overhead than most error functions
|
||||
so that it supports internationalization and thread-safe errors.
|
||||
*/
|
||||
static char *
|
||||
SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
/* Clear the error string */
|
||||
*errstr = '\0';
|
||||
--maxlen;
|
||||
|
||||
/* Get the thread-safe error, and print it out */
|
||||
error = SDL_GetErrBuf();
|
||||
if (error->error) {
|
||||
const char *fmt;
|
||||
char *msg = errstr;
|
||||
int len;
|
||||
int argi;
|
||||
|
||||
fmt = SDL_LookupString(error->key);
|
||||
argi = 0;
|
||||
while (*fmt && (maxlen > 0)) {
|
||||
if (*fmt == '%') {
|
||||
char tmp[32], *spot = tmp;
|
||||
*spot++ = *fmt++;
|
||||
while ((*fmt == '.' || (*fmt >= '0' && *fmt <= '9'))
|
||||
&& spot < (tmp + SDL_arraysize(tmp) - 2)) {
|
||||
*spot++ = *fmt++;
|
||||
}
|
||||
*spot++ = *fmt++;
|
||||
*spot++ = '\0';
|
||||
switch (spot[-2]) {
|
||||
case '%':
|
||||
*msg++ = '%';
|
||||
maxlen -= 1;
|
||||
break;
|
||||
case 'c':
|
||||
case 'i':
|
||||
case 'd':
|
||||
case 'u':
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_i);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'f':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_f);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'p':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_ptr);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 's':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
SDL_LookupString(error->args[argi++].
|
||||
buf));
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
*msg++ = *fmt++;
|
||||
maxlen -= 1;
|
||||
}
|
||||
}
|
||||
*msg = 0; /* NULL terminate the string */
|
||||
}
|
||||
return (errstr);
|
||||
}
|
||||
|
||||
/* Available for backwards compatibility */
|
||||
const char *
|
||||
SDL_GetError(void)
|
||||
{
|
||||
static char errmsg[SDL_ERRBUFIZE];
|
||||
|
||||
return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ClearError(void)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
error = SDL_GetErrBuf();
|
||||
error->error = 0;
|
||||
}
|
||||
|
||||
/* Very common errors go here */
|
||||
void
|
||||
SDL_Error(SDL_errorcode code)
|
||||
{
|
||||
switch (code) {
|
||||
case SDL_ENOMEM:
|
||||
SDL_SetError("Out of memory");
|
||||
break;
|
||||
case SDL_EFREAD:
|
||||
SDL_SetError("Error reading from datastream");
|
||||
break;
|
||||
case SDL_EFWRITE:
|
||||
SDL_SetError("Error writing to datastream");
|
||||
break;
|
||||
case SDL_EFSEEK:
|
||||
SDL_SetError("Error seeking in datastream");
|
||||
break;
|
||||
case SDL_UNSUPPORTED:
|
||||
SDL_SetError("That operation is not supported");
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown SDL error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_ERROR
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char buffer[BUFSIZ + 1];
|
||||
|
||||
SDL_SetError("Hi there!");
|
||||
printf("Error 1: %s\n", SDL_GetError());
|
||||
SDL_ClearError();
|
||||
SDL_memset(buffer, '1', BUFSIZ);
|
||||
buffer[BUFSIZ] = 0;
|
||||
SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
|
||||
printf("Error 2: %s\n", SDL_GetError());
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This file defines a structure that carries language-independent
|
||||
error messages
|
||||
*/
|
||||
|
||||
#ifndef _SDL_error_c_h
|
||||
#define _SDL_error_c_h
|
||||
|
||||
#define ERR_MAX_STRLEN 128
|
||||
#define ERR_MAX_ARGS 5
|
||||
|
||||
typedef struct SDL_error
|
||||
{
|
||||
/* This is a numeric value corresponding to the current error */
|
||||
int error;
|
||||
|
||||
/* This is a key used to index into a language hashtable containing
|
||||
internationalized versions of the SDL error messages. If the key
|
||||
is not in the hashtable, or no hashtable is available, the key is
|
||||
used directly as an error message format string.
|
||||
*/
|
||||
char key[ERR_MAX_STRLEN];
|
||||
|
||||
/* These are the arguments for the error functions */
|
||||
int argc;
|
||||
union
|
||||
{
|
||||
void *value_ptr;
|
||||
#if 0 /* What is a character anyway? (UNICODE issues) */
|
||||
unsigned char value_c;
|
||||
#endif
|
||||
int value_i;
|
||||
double value_f;
|
||||
char buf[ERR_MAX_STRLEN];
|
||||
} args[ERR_MAX_ARGS];
|
||||
} SDL_error;
|
||||
|
||||
#endif /* _SDL_error_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* General fatal signal handling code for SDL */
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_fatal.h"
|
||||
|
||||
/* This installs some signal handlers for the more common fatal signals,
|
||||
so that if the programmer is lazy, the app doesn't die so horribly if
|
||||
the program crashes.
|
||||
*/
|
||||
|
||||
static void
|
||||
SDL_Parachute(int sig)
|
||||
{
|
||||
signal(sig, SIG_DFL);
|
||||
SDL_Quit();
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
static const int SDL_fatal_signals[] = {
|
||||
SIGSEGV,
|
||||
#ifdef SIGBUS
|
||||
SIGBUS,
|
||||
#endif
|
||||
#ifdef SIGFPE
|
||||
SIGFPE,
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
SIGQUIT,
|
||||
#endif
|
||||
0
|
||||
};
|
||||
|
||||
void
|
||||
SDL_InstallParachute(void)
|
||||
{
|
||||
/* Set a handler for any fatal signal not already handled */
|
||||
int i;
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction action;
|
||||
|
||||
for (i = 0; SDL_fatal_signals[i]; ++i) {
|
||||
sigaction(SDL_fatal_signals[i], NULL, &action);
|
||||
if (action.sa_handler == SIG_DFL) {
|
||||
action.sa_handler = SDL_Parachute;
|
||||
sigaction(SDL_fatal_signals[i], &action, NULL);
|
||||
}
|
||||
}
|
||||
#ifdef SIGALRM
|
||||
/* Set SIGALRM to be ignored -- necessary on Solaris */
|
||||
sigaction(SIGALRM, NULL, &action);
|
||||
if (action.sa_handler == SIG_DFL) {
|
||||
action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGALRM, &action, NULL);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
void (*ohandler) (int);
|
||||
|
||||
for (i = 0; SDL_fatal_signals[i]; ++i) {
|
||||
ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
|
||||
if (ohandler != SIG_DFL) {
|
||||
signal(SDL_fatal_signals[i], ohandler);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SIGACTION */
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_UninstallParachute(void)
|
||||
{
|
||||
/* Remove a handler for any fatal signal handled */
|
||||
int i;
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction action;
|
||||
|
||||
for (i = 0; SDL_fatal_signals[i]; ++i) {
|
||||
sigaction(SDL_fatal_signals[i], NULL, &action);
|
||||
if (action.sa_handler == SDL_Parachute) {
|
||||
action.sa_handler = SIG_DFL;
|
||||
sigaction(SDL_fatal_signals[i], &action, NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void (*ohandler) (int);
|
||||
|
||||
for (i = 0; SDL_fatal_signals[i]; ++i) {
|
||||
ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
|
||||
if (ohandler != SDL_Parachute) {
|
||||
signal(SDL_fatal_signals[i], ohandler);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SIGACTION */
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* No signals on this platform, nothing to do.. */
|
||||
|
||||
void
|
||||
SDL_InstallParachute(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_UninstallParachute(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* HAVE_SIGNAL_H */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* General fatal signal handling code for SDL */
|
||||
|
||||
extern void SDL_InstallParachute(void);
|
||||
extern void SDL_UninstallParachute(void);
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_hints.h"
|
||||
|
||||
|
||||
/* Assuming there aren't many hints set and they aren't being queried in
|
||||
critical performance paths, we'll just use a linked list here.
|
||||
*/
|
||||
typedef struct SDL_Hint {
|
||||
char *name;
|
||||
char *value;
|
||||
SDL_HintPriority priority;
|
||||
struct SDL_Hint *next;
|
||||
} SDL_Hint;
|
||||
|
||||
static SDL_Hint *SDL_hints;
|
||||
|
||||
|
||||
SDL_bool
|
||||
SDL_SetHintWithPriority(const char *name, const char *value,
|
||||
SDL_HintPriority priority)
|
||||
{
|
||||
const char *env;
|
||||
SDL_Hint *prev, *hint;
|
||||
|
||||
if (!name || !value) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
env = SDL_getenv(name);
|
||||
if (env && priority < SDL_HINT_OVERRIDE) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
prev = NULL;
|
||||
for (hint = SDL_hints; hint; prev = hint, hint = hint->next) {
|
||||
if (SDL_strcmp(name, hint->name) == 0) {
|
||||
if (priority < hint->priority) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (SDL_strcmp(hint->value, value) != 0) {
|
||||
SDL_free(hint->value);
|
||||
hint->value = SDL_strdup(value);
|
||||
}
|
||||
hint->priority = priority;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Couldn't find the hint, add a new one */
|
||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||
if (!hint) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
hint->name = SDL_strdup(name);
|
||||
hint->value = SDL_strdup(value);
|
||||
hint->priority = priority;
|
||||
hint->next = SDL_hints;
|
||||
SDL_hints = hint;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_SetHint(const char *name, const char *value)
|
||||
{
|
||||
return SDL_SetHintWithPriority(name, value, SDL_HINT_NORMAL);
|
||||
}
|
||||
|
||||
const char *
|
||||
SDL_GetHint(const char *name)
|
||||
{
|
||||
const char *env;
|
||||
SDL_Hint *hint;
|
||||
|
||||
env = SDL_getenv(name);
|
||||
for (hint = SDL_hints; hint; hint = hint->next) {
|
||||
if (SDL_strcmp(name, hint->name) == 0) {
|
||||
if (!env || hint->priority == SDL_HINT_OVERRIDE) {
|
||||
return hint->value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
void SDL_ClearHints(void)
|
||||
{
|
||||
SDL_Hint *hint;
|
||||
|
||||
while (SDL_hints) {
|
||||
hint = SDL_hints;
|
||||
SDL_hints = hint->next;
|
||||
|
||||
SDL_free(hint->name);
|
||||
SDL_free(hint->value);
|
||||
SDL_free(hint);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,330 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Simple log messages in SDL */
|
||||
|
||||
#include "SDL_log.h"
|
||||
|
||||
#if HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include "core/windows/SDL_windows.h"
|
||||
#elif defined(__ANDROID__)
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL
|
||||
#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO
|
||||
|
||||
typedef struct SDL_LogLevel
|
||||
{
|
||||
int category;
|
||||
SDL_LogPriority priority;
|
||||
struct SDL_LogLevel *next;
|
||||
} SDL_LogLevel;
|
||||
|
||||
/* The default log output function */
|
||||
static void SDL_LogOutput(void *userdata,
|
||||
int category, SDL_LogPriority priority,
|
||||
const char *message);
|
||||
|
||||
static SDL_LogLevel *SDL_loglevels;
|
||||
static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
|
||||
static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
|
||||
static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
|
||||
static void *SDL_log_userdata = NULL;
|
||||
|
||||
static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = {
|
||||
NULL,
|
||||
"VERBOSE",
|
||||
"DEBUG",
|
||||
"INFO",
|
||||
"WARN",
|
||||
"ERROR",
|
||||
"CRITICAL"
|
||||
};
|
||||
|
||||
#ifdef __ANDROID__
|
||||
static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = {
|
||||
"APP",
|
||||
"ERROR",
|
||||
"SYSTEM",
|
||||
"AUDIO",
|
||||
"VIDEO",
|
||||
"RENDER",
|
||||
"INPUT"
|
||||
};
|
||||
|
||||
static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
|
||||
ANDROID_LOG_VERBOSE,
|
||||
ANDROID_LOG_DEBUG,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_FATAL
|
||||
};
|
||||
#endif /* __ANDROID__ */
|
||||
|
||||
|
||||
void
|
||||
SDL_LogSetAllPriority(SDL_LogPriority priority)
|
||||
{
|
||||
SDL_LogLevel *entry;
|
||||
|
||||
for (entry = SDL_loglevels; entry; entry = entry->next) {
|
||||
entry->priority = priority;
|
||||
}
|
||||
SDL_application_priority = SDL_default_priority = priority;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogSetPriority(int category, SDL_LogPriority priority)
|
||||
{
|
||||
SDL_LogLevel *entry;
|
||||
|
||||
for (entry = SDL_loglevels; entry; entry = entry->next) {
|
||||
if (entry->category == category) {
|
||||
entry->priority = priority;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new entry */
|
||||
entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry));
|
||||
if (entry) {
|
||||
entry->category = category;
|
||||
entry->priority = priority;
|
||||
entry->next = SDL_loglevels;
|
||||
SDL_loglevels = entry;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_LogPriority
|
||||
SDL_LogGetPriority(int category)
|
||||
{
|
||||
SDL_LogLevel *entry;
|
||||
|
||||
for (entry = SDL_loglevels; entry; entry = entry->next) {
|
||||
if (entry->category == category) {
|
||||
return entry->priority;
|
||||
}
|
||||
}
|
||||
|
||||
if (category == SDL_LOG_CATEGORY_APPLICATION) {
|
||||
return SDL_application_priority;
|
||||
} else {
|
||||
return SDL_default_priority;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogResetPriorities(void)
|
||||
{
|
||||
SDL_LogLevel *entry;
|
||||
|
||||
while (SDL_loglevels) {
|
||||
entry = SDL_loglevels;
|
||||
SDL_loglevels = entry->next;
|
||||
SDL_free(entry);
|
||||
}
|
||||
|
||||
SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
|
||||
SDL_default_priority = DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogVerbose(int category, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogDebug(int category, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogInfo(int category, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogWarn(int category, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogError(int category, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogCritical(int category, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_LogMessageV(category, priority, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
static const char *
|
||||
GetCategoryPrefix(int category)
|
||||
{
|
||||
if (category < SDL_LOG_CATEGORY_RESERVED1) {
|
||||
return SDL_category_prefixes[category];
|
||||
}
|
||||
if (category < SDL_LOG_CATEGORY_CUSTOM) {
|
||||
return "RESERVED";
|
||||
}
|
||||
return "CUSTOM";
|
||||
}
|
||||
#endif /* __ANDROID__ */
|
||||
|
||||
void
|
||||
SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
|
||||
{
|
||||
char *message;
|
||||
|
||||
/* Nothing to do if we don't have an output function */
|
||||
if (!SDL_log_function) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure we don't exceed array bounds */
|
||||
if (priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* See if we want to do anything with this message */
|
||||
if (priority < SDL_LogGetPriority(category)) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap);
|
||||
SDL_log_function(SDL_log_userdata, category, priority, message);
|
||||
SDL_stack_free(message);
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
|
||||
const char *message)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
/* Way too many allocations here, urgh */
|
||||
{
|
||||
char *output;
|
||||
size_t length;
|
||||
LPTSTR tstr;
|
||||
|
||||
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1;
|
||||
output = SDL_stack_alloc(char, length);
|
||||
SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message);
|
||||
tstr = WIN_UTF8ToString(output);
|
||||
OutputDebugString(tstr);
|
||||
SDL_free(tstr);
|
||||
SDL_stack_free(output);
|
||||
}
|
||||
#elif defined(__ANDROID__)
|
||||
{
|
||||
char tag[32];
|
||||
|
||||
SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
|
||||
__android_log_write(SDL_android_priority[priority], tag, message);
|
||||
}
|
||||
#endif
|
||||
#if HAVE_STDIO_H
|
||||
fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
|
||||
{
|
||||
if (callback) {
|
||||
*callback = SDL_log_function;
|
||||
}
|
||||
if (userdata) {
|
||||
*userdata = SDL_log_userdata;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
|
||||
{
|
||||
SDL_log_function = callback;
|
||||
SDL_log_userdata = userdata;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "SDL_atomic.h"
|
||||
|
||||
/* Note that we undefine the atomic operations here, in case they are
|
||||
defined as compiler intrinsics while building SDL but the library user
|
||||
doesn't have that compiler. That way we always have a working set of
|
||||
atomic operations built into the library.
|
||||
*/
|
||||
|
||||
/*
|
||||
If any of the operations are not provided then we must emulate some
|
||||
of them. That means we need a nice implementation of spin locks
|
||||
that avoids the "one big lock" problem. We use a vector of spin
|
||||
locks and pick which one to use based on the address of the operand
|
||||
of the function.
|
||||
|
||||
To generate the index of the lock we first shift by 3 bits to get
|
||||
rid on the zero bits that result from 32 and 64 bit allignment of
|
||||
data. We then mask off all but 5 bits and use those 5 bits as an
|
||||
index into the table.
|
||||
|
||||
Picking the lock this way insures that accesses to the same data at
|
||||
the same time will go to the same lock. OTOH, accesses to different
|
||||
data have only a 1/32 chance of hitting the same lock. That should
|
||||
pretty much eliminate the chances of several atomic operations on
|
||||
different data from waiting on the same "big lock". If it isn't
|
||||
then the table of locks can be expanded to a new size so long as
|
||||
the new size is a power of two.
|
||||
|
||||
Contributed by Bob Pendleton, bob@pendleton.com
|
||||
*/
|
||||
|
||||
static SDL_SpinLock locks[32];
|
||||
|
||||
static __inline__ void
|
||||
enterLock(void *a)
|
||||
{
|
||||
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
|
||||
|
||||
SDL_AtomicLock(&locks[index]);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
leaveLock(void *a)
|
||||
{
|
||||
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
|
||||
|
||||
SDL_AtomicUnlock(&locks[index]);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_AtomicCAS_(SDL_atomic_t *a, int oldval, int newval)
|
||||
{
|
||||
SDL_bool retval = SDL_FALSE;
|
||||
|
||||
enterLock(a);
|
||||
if (a->value == oldval) {
|
||||
a->value = newval;
|
||||
retval = SDL_TRUE;
|
||||
}
|
||||
leaveLock(a);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_AtomicCASPtr_(void **a, void *oldval, void *newval)
|
||||
{
|
||||
SDL_bool retval = SDL_FALSE;
|
||||
|
||||
enterLock(a);
|
||||
if (*a == oldval) {
|
||||
*a = newval;
|
||||
retval = SDL_TRUE;
|
||||
}
|
||||
leaveLock(a);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "SDL_atomic.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_timer.h"
|
||||
|
||||
/* Don't do the check for Visual Studio 2005, it's safe here */
|
||||
#ifdef __WIN32__
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
/* This function is where all the magic happens... */
|
||||
SDL_bool
|
||||
SDL_AtomicTryLock(SDL_SpinLock *lock)
|
||||
{
|
||||
#if SDL_ATOMIC_DISABLED
|
||||
/* Terrible terrible damage */
|
||||
static SDL_mutex *_spinlock_mutex;
|
||||
|
||||
if (!_spinlock_mutex) {
|
||||
/* Race condition on first lock... */
|
||||
_spinlock_mutex = SDL_CreateMutex();
|
||||
}
|
||||
SDL_mutexP(_spinlock_mutex);
|
||||
if (*lock == 0) {
|
||||
*lock = 1;
|
||||
SDL_mutexV(_spinlock_mutex);
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_mutexV(_spinlock_mutex);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
|
||||
return (InterlockedExchange((long*)lock, 1) == 0);
|
||||
|
||||
#elif defined(__MACOSX__)
|
||||
return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
|
||||
|
||||
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||
return (__sync_lock_test_and_set(lock, 1) == 0);
|
||||
|
||||
#elif defined(__GNUC__) && defined(__arm__) && \
|
||||
(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \
|
||||
defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__))
|
||||
int result;
|
||||
__asm__ __volatile__ (
|
||||
"swp %0, %1, [%2]\n"
|
||||
: "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory");
|
||||
return (result == 0);
|
||||
|
||||
#elif defined(__GNUC__) && defined(__arm__)
|
||||
int result;
|
||||
__asm__ __volatile__ (
|
||||
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
|
||||
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
|
||||
return (result == 0);
|
||||
|
||||
#else
|
||||
/* Need CPU instructions for spinlock here! */
|
||||
__need_spinlock_implementation__
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
SDL_AtomicLock(SDL_SpinLock *lock)
|
||||
{
|
||||
/* FIXME: Should we have an eventual timeout? */
|
||||
while (!SDL_AtomicTryLock(lock)) {
|
||||
SDL_Delay(0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_AtomicUnlock(SDL_SpinLock *lock)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
_ReadWriteBarrier();
|
||||
*lock = 0;
|
||||
|
||||
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||
__sync_lock_release(lock);
|
||||
|
||||
#else
|
||||
*lock = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
File diff suppressed because it is too large
Load diff
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
|
||||
|
||||
/* Functions to get a list of "close" audio formats */
|
||||
extern SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format);
|
||||
extern SDL_AudioFormat SDL_NextAudioFormat(void);
|
||||
|
||||
/* Function to calculate the size and silence for a SDL_AudioSpec */
|
||||
extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
|
||||
|
||||
/* The actual mixing thread function */
|
||||
extern int SDLCALL SDL_RunAudio(void *audiop);
|
||||
|
||||
/* this is used internally to access some autogenerated code. */
|
||||
typedef struct
|
||||
{
|
||||
SDL_AudioFormat src_fmt;
|
||||
SDL_AudioFormat dst_fmt;
|
||||
SDL_AudioFilter filter;
|
||||
} SDL_AudioTypeFilters;
|
||||
extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
|
||||
|
||||
/* this is used internally to access some autogenerated code. */
|
||||
typedef struct
|
||||
{
|
||||
SDL_AudioFormat fmt;
|
||||
int channels;
|
||||
int upsample;
|
||||
int multiple;
|
||||
SDL_AudioFilter filter;
|
||||
} SDL_AudioRateFilters;
|
||||
extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
File diff suppressed because it is too large
Load diff
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Get the name of the audio device we use for output */
|
||||
|
||||
#if SDL_AUDIO_DRIVER_BSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h> /* For close() */
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audiodev_c.h"
|
||||
|
||||
#ifndef _PATH_DEV_DSP
|
||||
#if defined(__NETBSD__) || defined(__OPENBSD__)
|
||||
#define _PATH_DEV_DSP "/dev/audio"
|
||||
#else
|
||||
#define _PATH_DEV_DSP "/dev/dsp"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _PATH_DEV_DSP24
|
||||
#define _PATH_DEV_DSP24 "/dev/sound/dsp"
|
||||
#endif
|
||||
#ifndef _PATH_DEV_AUDIO
|
||||
#define _PATH_DEV_AUDIO "/dev/audio"
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
test_device(const char *fname, int flags, int (*test) (int fd),
|
||||
char ***devices, int *devCount)
|
||||
{
|
||||
struct stat sb;
|
||||
if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
|
||||
int audio_fd = open(fname, flags, 0);
|
||||
if ((audio_fd >= 0) && (test(audio_fd))) {
|
||||
void *p =
|
||||
SDL_realloc(*devices, ((*devCount) + 1) * sizeof(char *));
|
||||
if (p != NULL) {
|
||||
size_t len = strlen(fname) + 1;
|
||||
char *str = (char *) SDL_malloc(len);
|
||||
*devices = (char **) p;
|
||||
if (str != NULL) {
|
||||
SDL_strlcpy(str, fname, len);
|
||||
(*devices)[(*devCount)++] = str;
|
||||
}
|
||||
}
|
||||
close(audio_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_FreeUnixAudioDevices(char ***devices, int *devCount)
|
||||
{
|
||||
int i = *devCount;
|
||||
if ((i > 0) && (*devices != NULL)) {
|
||||
while (i--) {
|
||||
SDL_free((*devices)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (*devices != NULL) {
|
||||
SDL_free(*devices);
|
||||
}
|
||||
|
||||
*devices = NULL;
|
||||
*devCount = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_stub(int fd)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd),
|
||||
char ***devices, int *devCount)
|
||||
{
|
||||
const char *audiodev;
|
||||
char audiopath[1024];
|
||||
|
||||
if (test == NULL)
|
||||
test = test_stub;
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) &&
|
||||
((audiodev = SDL_getenv("AUDIODEV")) == NULL)) {
|
||||
if (classic) {
|
||||
audiodev = _PATH_DEV_AUDIO;
|
||||
} else {
|
||||
struct stat sb;
|
||||
|
||||
/* Added support for /dev/sound/\* in Linux 2.4 */
|
||||
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode))
|
||||
&& ((stat(_PATH_DEV_DSP24, &sb) == 0)
|
||||
&& S_ISCHR(sb.st_mode))) {
|
||||
audiodev = _PATH_DEV_DSP24;
|
||||
} else {
|
||||
audiodev = _PATH_DEV_DSP;
|
||||
}
|
||||
}
|
||||
}
|
||||
test_device(audiodev, flags, test, devices, devCount);
|
||||
|
||||
if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
|
||||
int instance = 0;
|
||||
while (instance++ <= 64) {
|
||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance);
|
||||
test_device(audiopath, flags, test, devices, devCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Audio driver selection */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
void SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd),
|
||||
char ***devs, int *count);
|
||||
void SDL_FreeUnixAudioDevices(char ***devices, int *devCount);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#define SDL_AllocAudioMem SDL_malloc
|
||||
#define SDL_FreeAudioMem SDL_free
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
File diff suppressed because it is too large
Load diff
|
@ -1,365 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This provides the default mixing callback for the SDL audio routines */
|
||||
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
#include "SDL_mixer_MMX.h"
|
||||
#include "SDL_mixer_MMX_VC.h"
|
||||
#include "SDL_mixer_m68k.h"
|
||||
|
||||
/* This table is used to add two sound values together and pin
|
||||
* the value to avoid overflow. (used with permission from ARDI)
|
||||
* Changed to use 0xFE instead of 0xFF for better sound quality.
|
||||
*/
|
||||
static const Uint8 mix8[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
|
||||
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
|
||||
0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
|
||||
0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
|
||||
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
|
||||
0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
|
||||
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
|
||||
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
|
||||
0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
|
||||
0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
|
||||
0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
|
||||
0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
|
||||
0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
|
||||
0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
|
||||
0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
|
||||
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
|
||||
0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
|
||||
0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
|
||||
};
|
||||
|
||||
/* The volume ranges from 0 - 128 */
|
||||
#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
|
||||
#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
|
||||
|
||||
|
||||
void
|
||||
SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
|
||||
Uint32 len, int volume)
|
||||
{
|
||||
if (volume == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
|
||||
case AUDIO_U8:
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_U8((char *) dst, (char *) src,
|
||||
(unsigned long) len, (long) volume,
|
||||
(char *) mix8);
|
||||
#else
|
||||
Uint8 src_sample;
|
||||
|
||||
while (len--) {
|
||||
src_sample = *src;
|
||||
ADJUST_VOLUME_U8(src_sample, volume);
|
||||
*dst = mix8[*dst + src_sample];
|
||||
++dst;
|
||||
++src;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8:
|
||||
{
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S8((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S8_VC((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S8((char *) dst, (char *) src,
|
||||
(unsigned long) len, (long) volume);
|
||||
#else
|
||||
{
|
||||
Sint8 *dst8, *src8;
|
||||
Sint8 src_sample;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1 << (8 - 1)) - 1);
|
||||
const int min_audioval = -(1 << (8 - 1));
|
||||
|
||||
src8 = (Sint8 *) src;
|
||||
dst8 = (Sint8 *) dst;
|
||||
while (len--) {
|
||||
src_sample = *src8;
|
||||
ADJUST_VOLUME(src_sample, volume);
|
||||
dst_sample = *dst8 + src_sample;
|
||||
if (dst_sample > max_audioval) {
|
||||
*dst8 = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
*dst8 = min_audioval;
|
||||
} else {
|
||||
*dst8 = dst_sample;
|
||||
}
|
||||
++dst8;
|
||||
++src8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16LSB:
|
||||
{
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S16((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S16_VC((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16LSB((short *) dst, (short *) src,
|
||||
(unsigned long) len, (long) volume);
|
||||
#else
|
||||
{
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1 << (16 - 1)) - 1);
|
||||
const int min_audioval = -(1 << (16 - 1));
|
||||
|
||||
len /= 2;
|
||||
while (len--) {
|
||||
src1 = ((src[1]) << 8 | src[0]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[1]) << 8 | dst[0]);
|
||||
src += 2;
|
||||
dst_sample = src1 + src2;
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[0] = dst_sample & 0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[1] = dst_sample & 0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16MSB:
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16MSB((short *) dst, (short *) src,
|
||||
(unsigned long) len, (long) volume);
|
||||
#else
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1 << (16 - 1)) - 1);
|
||||
const int min_audioval = -(1 << (16 - 1));
|
||||
|
||||
len /= 2;
|
||||
while (len--) {
|
||||
src1 = ((src[0]) << 8 | src[1]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[0]) << 8 | dst[1]);
|
||||
src += 2;
|
||||
dst_sample = src1 + src2;
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[1] = dst_sample & 0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[0] = dst_sample & 0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S32LSB:
|
||||
{
|
||||
const Uint32 *src32 = (Uint32 *) src;
|
||||
Uint32 *dst32 = (Uint32 *) dst;
|
||||
Sint64 src1, src2;
|
||||
Sint64 dst_sample;
|
||||
const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
|
||||
const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
|
||||
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
src1 = (Sint64) ((Sint32) SDL_SwapLE32(*src32));
|
||||
src32++;
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = (Sint64) ((Sint32) SDL_SwapLE32(*dst32));
|
||||
dst_sample = src1 + src2;
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
*(dst32++) = SDL_SwapLE32((Uint32) ((Sint32) dst_sample));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S32MSB:
|
||||
{
|
||||
const Uint32 *src32 = (Uint32 *) src;
|
||||
Uint32 *dst32 = (Uint32 *) dst;
|
||||
Sint64 src1, src2;
|
||||
Sint64 dst_sample;
|
||||
const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
|
||||
const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
|
||||
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
src1 = (Sint64) ((Sint32) SDL_SwapBE32(*src32));
|
||||
src32++;
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = (Sint64) ((Sint32) SDL_SwapBE32(*dst32));
|
||||
dst_sample = src1 + src2;
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
*(dst32++) = SDL_SwapBE32((Uint32) ((Sint32) dst_sample));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_F32LSB:
|
||||
{
|
||||
const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
|
||||
const float fvolume = (float) volume;
|
||||
const float *src32 = (float *) src;
|
||||
float *dst32 = (float *) dst;
|
||||
float src1, src2;
|
||||
double dst_sample;
|
||||
/* !!! FIXME: are these right? */
|
||||
const double max_audioval = 3.402823466e+38F;
|
||||
const double min_audioval = -3.402823466e+38F;
|
||||
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume);
|
||||
src2 = SDL_SwapFloatLE(*dst32);
|
||||
src32++;
|
||||
|
||||
dst_sample = ((double) src1) + ((double) src2);
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
*(dst32++) = SDL_SwapFloatLE((float) dst_sample);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_F32MSB:
|
||||
{
|
||||
const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
|
||||
const float fvolume = (float) volume;
|
||||
const float *src32 = (float *) src;
|
||||
float *dst32 = (float *) dst;
|
||||
float src1, src2;
|
||||
double dst_sample;
|
||||
/* !!! FIXME: are these right? */
|
||||
const double max_audioval = 3.402823466e+38F;
|
||||
const double min_audioval = -3.402823466e+38F;
|
||||
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume);
|
||||
src2 = SDL_SwapFloatBE(*dst32);
|
||||
src32++;
|
||||
|
||||
dst_sample = ((double) src1) + ((double) src2);
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
*(dst32++) = SDL_SwapFloatBE((float) dst_sample);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* If this happens... FIXME! */
|
||||
SDL_SetError("SDL_MixAudio(): unknown audio format");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************
|
||||
* Mixing for 16 bit signed buffers
|
||||
***********************************************/
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void
|
||||
SDL_MixAudio_MMX_S16(char *dst, char *src, unsigned int size, int volume)
|
||||
{
|
||||
__asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
" shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */
|
||||
" jz .endS16\n" " pxor %%mm0,%%mm0\n" " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */
|
||||
".align 8\n" " .mixloopS16:\n" " movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
|
||||
" movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */
|
||||
" movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */
|
||||
/* pré charger le buffer dst dans mm7 */
|
||||
" movq (%0),%%mm7\n" /* mm7 = dst[0] */
|
||||
/* multiplier par le volume */
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
" pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */
|
||||
" movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */
|
||||
" pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
" pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
" punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */
|
||||
" movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
" punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */
|
||||
" punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */
|
||||
" punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */
|
||||
/* pré charger le buffer dst dans mm5 */
|
||||
" movq 8(%0),%%mm5\n" /* mm5 = dst[1] */
|
||||
/* diviser par 128 */
|
||||
" psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */
|
||||
" add $16,%1\n" " psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
|
||||
" psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */
|
||||
/* mm1 = le sample avec le volume modifié */
|
||||
" packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */
|
||||
" psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */
|
||||
" paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */
|
||||
/* mm4 = le sample avec le volume modifié */
|
||||
" packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */
|
||||
" movq %%mm3,(%0)\n" " paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
|
||||
" movq %%mm6,8(%0)\n"
|
||||
" add $16,%0\n"
|
||||
" dec %%edx\n"
|
||||
" jnz .mixloopS16\n"
|
||||
" emms\n"
|
||||
".endS16:\n"::"r"(dst), "r"(src),
|
||||
"m"(size), "m"(volume):"eax", "edx", "memory");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////// */
|
||||
/* Mixing for 8 bit signed buffers */
|
||||
/*////////////////////////////////////////////// */
|
||||
|
||||
void
|
||||
SDL_MixAudio_MMX_S8(char *dst, char *src, unsigned int size, int volume)
|
||||
{
|
||||
__asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */
|
||||
" movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " movl %2,%%edx\n" /* edx = size */
|
||||
" shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */
|
||||
" cmp $0,%%edx\n" " je .endS8\n" ".align 8\n" " .mixloopS8:\n" " pxor %%mm2,%%mm2\n" /* mm2 = 0 */
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */
|
||||
/* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */
|
||||
" pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */
|
||||
" punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */
|
||||
" punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */
|
||||
" movq (%0),%%mm2\n" /* mm2 = destination */
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */
|
||||
" add $8,%1\n" " pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */
|
||||
" psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */
|
||||
" psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
" packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
" paddsb %%mm2,%%mm3\n" /* add to destination buffer */
|
||||
" movq %%mm3,(%0)\n" /* store back to ram */
|
||||
" add $8,%0\n"
|
||||
" dec %%edx\n"
|
||||
" jnz .mixloopS8\n"
|
||||
".endS8:\n"
|
||||
" emms\n"::"r"(dst), "r"(src), "m"(size),
|
||||
"m"(volume):"eax", "edx", "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_BUGGY_MMX_MIXERS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
headers for MMX assembler version of SDL_MixAudio
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void SDL_MixAudio_MMX_S16(char *, char *, unsigned int, int);
|
||||
void SDL_MixAudio_MMX_S8(char *, char *, unsigned int, int);
|
||||
#endif
|
||||
#endif /* SDL_BUGGY_MMX_MIXERS */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_mixer_MMX_VC.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
|
||||
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
// Converted to Intel ASM notation by Cth
|
||||
// This code is licensed under the LGPL (see COPYING for details)
|
||||
//
|
||||
// Assumes buffer size in bytes is a multiple of 16
|
||||
// Assumes SDL_MIX_MAXVOLUME = 128
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 16 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm
|
||||
{
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov edi, dst // edi = dst
|
||||
mov esi, src // esi = src
|
||||
mov eax, volume // eax = volume
|
||||
mov ebx, nSize // ebx = size
|
||||
shr ebx, 4 // process 16 bytes per iteration = 8 samples
|
||||
jz endS16
|
||||
|
||||
pxor mm0, mm0
|
||||
movd mm0, eax //%%eax,%%mm0
|
||||
movq mm1, mm0 //%%mm0,%%mm1
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0 // mm0 = vol|vol|vol|vol
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
align 16
|
||||
#endif
|
||||
mixloopS16:
|
||||
movq mm1, [esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d
|
||||
movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d
|
||||
movq mm4, [esi + 8] //8(%%esi),%%mm4\n" // mm4 = e|f|g|h
|
||||
// pre charger le buffer dst dans mm7
|
||||
movq mm7, [edi] //(%%edi),%%mm7\n" // mm7 = dst[0]"
|
||||
// multiplier par le volume
|
||||
pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
|
||||
pmulhw mm2, mm0 //%%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v)
|
||||
movq mm5, mm4 //%%mm4,%%mm5\n" // mm5 = e|f|g|h
|
||||
pmullw mm4, mm0 //%%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
|
||||
pmulhw mm5, mm0 //%%mm0,%%mm5\n" // mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v)
|
||||
movq mm3, mm1 //%%mm1,%%mm3\n" // mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
|
||||
punpckhwd mm1, mm2 //%%mm2,%%mm1\n" // mm1 = a*v|b*v
|
||||
movq mm6, mm4 //%%mm4,%%mm6\n" // mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
|
||||
punpcklwd mm3, mm2 //%%mm2,%%mm3\n" // mm3 = c*v|d*v
|
||||
punpckhwd mm4, mm5 //%%mm5,%%mm4\n" // mm4 = e*f|f*v
|
||||
punpcklwd mm6, mm5 //%%mm5,%%mm6\n" // mm6 = g*v|h*v
|
||||
// pre charger le buffer dst dans mm5
|
||||
movq mm5, [edi + 8] //8(%%edi),%%mm5\n" // mm5 = dst[1]
|
||||
// diviser par 128
|
||||
psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME
|
||||
add esi, 16 //$16,%%esi\n"
|
||||
psrad mm3, 7 //$7,%%mm3\n" // mm3 = c*v/128|d*v/128
|
||||
psrad mm4, 7 //$7,%%mm4\n" // mm4 = e*v/128|f*v/128
|
||||
// mm1 = le sample avec le volume modifie
|
||||
packssdw mm3, mm1 //%%mm1,%%mm3\n" // mm3 = s(a*v|b*v|c*v|d*v)
|
||||
psrad mm6, 7 //$7,%%mm6\n" // mm6= g*v/128|h*v/128
|
||||
paddsw mm3, mm7 //%%mm7,%%mm3\n" // mm3 = adjust_volume(src)+dst
|
||||
// mm4 = le sample avec le volume modifie
|
||||
packssdw mm6, mm4 //%%mm4,%%mm6\n" // mm6 = s(e*v|f*v|g*v|h*v)
|
||||
movq [edi], mm3 //%%mm3,(%%edi)\n"
|
||||
paddsw mm6, mm5 //%%mm5,%%mm6\n" // mm6 = adjust_volume(src)+dst
|
||||
movq [edi + 8], mm6 //%%mm6,8(%%edi)\n"
|
||||
add edi, 16 //$16,%%edi\n"
|
||||
dec ebx //%%ebx\n"
|
||||
jnz mixloopS16
|
||||
|
||||
endS16:
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 8 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
_asm
|
||||
{
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov edi, dst //movl %0,%%edi // edi = dst
|
||||
mov esi, src //%1,%%esi // esi = src
|
||||
mov eax, volume //%3,%%eax // eax = volume
|
||||
|
||||
movd mm0, eax //%%eax,%%mm0
|
||||
movq mm1, mm0 //%%mm0,%%mm1
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
|
||||
mov ebx, nSize //%2,%%ebx // ebx = size
|
||||
shr ebx, 3 //$3,%%ebx // process 8 bytes per iteration = 8 samples
|
||||
cmp ebx, 0 //$0,%%ebx
|
||||
je endS8
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
align 16
|
||||
#endif
|
||||
mixloopS8:
|
||||
pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0
|
||||
movq mm1, [esi] //(%%esi),%%mm1 // mm1 = a|b|c|d|e|f|g|h
|
||||
movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h
|
||||
// on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0
|
||||
pcmpgtb mm2, mm1 //%%mm1,%%mm2 // mm2 = 11111111|00000000|00000000....
|
||||
punpckhbw mm1, mm2 //%%mm2,%%mm1 // mm1 = 0|a|0|b|0|c|0|d
|
||||
punpcklbw mm3, mm2 //%%mm2,%%mm3 // mm3 = 0|e|0|f|0|g|0|h
|
||||
movq mm2, [edi] //(%%edi),%%mm2 // mm2 = destination
|
||||
pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d
|
||||
add esi, 8 //$8,%%esi
|
||||
pmullw mm3, mm0 //%%mm0,%%mm3 // mm3 = v*e|v*f|v*g|v*h
|
||||
psraw mm1, 7 //$7,%%mm1 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128
|
||||
psraw mm3, 7 //$7,%%mm3 // mm3 = v*e/128|v*f/128|v*g/128|v*h/128
|
||||
packsswb mm3, mm1 //%%mm1,%%mm3 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128
|
||||
paddsb mm3, mm2 //%%mm2,%%mm3 // add to destination buffer
|
||||
movq [edi], mm3 //%%mm3,(%%edi) // store back to ram
|
||||
add edi, 8 //$8,%%edi
|
||||
dec ebx //%%ebx
|
||||
jnz mixloopS8
|
||||
|
||||
endS8:
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
#endif /* SDL_ASSEMBLY_ROUTINES */
|
||||
#endif /* SDL_BUGGY_MMX_MIXERS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
/* headers for MMX assembler version of SDL_MixAudio
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
Converted to Intel ASM notation by Cth
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
void SDL_MixAudio_MMX_S16_VC(char *, char *, unsigned int, int);
|
||||
void SDL_MixAudio_MMX_S8_VC(char *, char *, unsigned int, int);
|
||||
#endif
|
||||
#endif /* SDL_BUGGY_MMX_MIXERS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
m68k assembly mix routines
|
||||
|
||||
Patrice Mandin
|
||||
*/
|
||||
|
||||
#if defined(__M68000__) && !defined(__mcoldfire__) && defined(__GNUC__)
|
||||
void
|
||||
SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, char *mix8)
|
||||
{
|
||||
__asm__ __volatile__("tstl %2\n" " beqs stoploop_u8\n" "mixloop_u8:\n"
|
||||
/* Mix a sample */
|
||||
" moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" sub #128,%%d0\n" /* d0 -= 128 */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" add #128,%%d0\n" /* d0 += 128 */
|
||||
" add %%d1,%%d0\n"
|
||||
" moveb %4@(%%d0:w),%0@+\n"
|
||||
/* Loop till done */
|
||||
" subql #1,%2\n" " bhis mixloop_u8\n" "stoploop_u8:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8): /* clobbered registers */
|
||||
"d0", "d1", "cc", "memory");
|
||||
}
|
||||
|
||||
void
|
||||
SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__("tstl %2\n"
|
||||
" beqs stoploop_s8\n"
|
||||
" moveq #-128,%%d2\n"
|
||||
" moveq #127,%%d3\n" "mixloop_s8:\n"
|
||||
/* Mix a sample */
|
||||
" moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" add %%d1,%%d0\n"
|
||||
" cmp %%d2,%%d0\n"
|
||||
" bges lower_limit_s8\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s8:\n"
|
||||
" cmp %%d3,%%d0\n"
|
||||
" bles upper_limit_s8\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s8:\n" " moveb %%d0,%0@+\n"
|
||||
/* Loop till done */
|
||||
" subql #1,%2\n" " bhis mixloop_s8\n" "stoploop_s8:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory");
|
||||
}
|
||||
|
||||
void
|
||||
SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__("tstl %2\n"
|
||||
" beqs stoploop_s16msb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n" "mixloop_s16msb:\n"
|
||||
/* Mix a sample */
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" addl %%d1,%%d0\n"
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16msb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16msb:\n"
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16msb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16msb:\n" " move %%d0,%0@+\n"
|
||||
/* Loop till done */
|
||||
" subql #1,%2\n" " bhis mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory");
|
||||
}
|
||||
|
||||
void
|
||||
SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__("tstl %2\n"
|
||||
" beqs stoploop_s16lsb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n" "mixloop_s16lsb:\n"
|
||||
/* Mix a sample */
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" rorw #8,%%d0\n" " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" rorw #8,%%d1\n" " extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" addl %%d1,%%d0\n"
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16lsb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16lsb:\n"
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16lsb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16lsb:\n"
|
||||
" rorw #8,%%d0\n" " move %%d0,%0@+\n"
|
||||
/* Loop till done */
|
||||
" subql #1,%2\n" " bhis mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory");
|
||||
}
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
m68k assembly mix routines
|
||||
|
||||
Patrice Mandin
|
||||
*/
|
||||
|
||||
#if defined(__M68000__) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume,
|
||||
char *mix8);
|
||||
void SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume);
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume);
|
||||
void SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume);
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is SDL_free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_sysaudio_h
|
||||
#define _SDL_sysaudio_h
|
||||
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* The SDL audio driver */
|
||||
typedef struct SDL_AudioDevice SDL_AudioDevice;
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
|
||||
typedef struct SDL_AudioDriverImpl
|
||||
{
|
||||
int (*DetectDevices) (int iscapture);
|
||||
const char *(*GetDeviceName) (int index, int iscapture);
|
||||
int (*OpenDevice) (_THIS, const char *devname, int iscapture);
|
||||
void (*ThreadInit) (_THIS); /* Called by audio thread at start */
|
||||
void (*WaitDevice) (_THIS);
|
||||
void (*PlayDevice) (_THIS);
|
||||
Uint8 *(*GetDeviceBuf) (_THIS);
|
||||
void (*WaitDone) (_THIS);
|
||||
void (*CloseDevice) (_THIS);
|
||||
void (*LockDevice) (_THIS);
|
||||
void (*UnlockDevice) (_THIS);
|
||||
void (*Deinitialize) (void);
|
||||
|
||||
/* Some flags to push duplicate code into the core and reduce #ifdefs. */
|
||||
int ProvidesOwnCallbackThread:1;
|
||||
int SkipMixerLock:1;
|
||||
int HasCaptureSupport:1;
|
||||
int OnlyHasDefaultOutputDevice:1;
|
||||
int OnlyHasDefaultInputDevice:1;
|
||||
} SDL_AudioDriverImpl;
|
||||
|
||||
|
||||
typedef struct SDL_AudioDriver
|
||||
{
|
||||
/* * * */
|
||||
/* The name of this audio driver */
|
||||
const char *name;
|
||||
|
||||
/* * * */
|
||||
/* The description of this audio driver */
|
||||
const char *desc;
|
||||
|
||||
SDL_AudioDriverImpl impl;
|
||||
} SDL_AudioDriver;
|
||||
|
||||
|
||||
/* Streamer */
|
||||
typedef struct
|
||||
{
|
||||
Uint8 *buffer;
|
||||
int max_len; /* the maximum length in bytes */
|
||||
int read_pos, write_pos; /* the position of the write and read heads in bytes */
|
||||
} SDL_AudioStreamer;
|
||||
|
||||
|
||||
/* Define the SDL audio driver structure */
|
||||
struct SDL_AudioDevice
|
||||
{
|
||||
/* * * */
|
||||
/* Data common to all devices */
|
||||
|
||||
/* The current audio specification (shared with audio thread) */
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
/* An audio conversion block for audio format emulation */
|
||||
SDL_AudioCVT convert;
|
||||
|
||||
/* The streamer, if sample rate conversion necessitates it */
|
||||
int use_streamer;
|
||||
SDL_AudioStreamer streamer;
|
||||
|
||||
/* Current state flags */
|
||||
int iscapture;
|
||||
int enabled;
|
||||
int paused;
|
||||
int opened;
|
||||
|
||||
/* Fake audio buffer for when the audio hardware is busy */
|
||||
Uint8 *fake_stream;
|
||||
|
||||
/* A semaphore for locking the mixing buffers */
|
||||
SDL_mutex *mixer_lock;
|
||||
|
||||
/* A thread to feed the audio device */
|
||||
SDL_Thread *thread;
|
||||
SDL_threadID threadid;
|
||||
|
||||
/* * * */
|
||||
/* Data private to this driver */
|
||||
struct SDL_PrivateAudioData *hidden;
|
||||
};
|
||||
#undef _THIS
|
||||
|
||||
typedef struct AudioBootStrap
|
||||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*init) (SDL_AudioDriverImpl * impl);
|
||||
int demand_only:1; /* 1==request explicitly, or it won't be available. */
|
||||
} AudioBootStrap;
|
||||
|
||||
#endif /* _SDL_sysaudio_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,636 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Microsoft WAVE file loading routines */
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_wave.h"
|
||||
|
||||
|
||||
static int ReadChunk(SDL_RWops * src, Chunk * chunk);
|
||||
|
||||
struct MS_ADPCM_decodestate
|
||||
{
|
||||
Uint8 hPredictor;
|
||||
Uint16 iDelta;
|
||||
Sint16 iSamp1;
|
||||
Sint16 iSamp2;
|
||||
};
|
||||
static struct MS_ADPCM_decoder
|
||||
{
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
Uint16 wNumCoef;
|
||||
Sint16 aCoeff[7][2];
|
||||
/* * * */
|
||||
struct MS_ADPCM_decodestate state[2];
|
||||
} MS_ADPCM_state;
|
||||
|
||||
static int
|
||||
InitMS_ADPCM(WaveFMT * format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
Uint16 extra_info;
|
||||
int i;
|
||||
|
||||
/* Set the rogue pointer to the MS_ADPCM specific data */
|
||||
MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
MS_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *) format + sizeof(*format);
|
||||
if (sizeof(*format) == 16) {
|
||||
extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.wNumCoef = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
if (MS_ADPCM_state.wNumCoef != 7) {
|
||||
SDL_SetError("Unknown set of MS_ADPCM coefficients");
|
||||
return (-1);
|
||||
}
|
||||
for (i = 0; i < MS_ADPCM_state.wNumCoef; ++i) {
|
||||
MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static Sint32
|
||||
MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||||
Uint8 nybble, Sint16 * coeff)
|
||||
{
|
||||
const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
|
||||
const Sint32 min_audioval = -(1 << (16 - 1));
|
||||
const Sint32 adaptive[] = {
|
||||
230, 230, 230, 230, 307, 409, 512, 614,
|
||||
768, 614, 512, 409, 307, 230, 230, 230
|
||||
};
|
||||
Sint32 new_sample, delta;
|
||||
|
||||
new_sample = ((state->iSamp1 * coeff[0]) +
|
||||
(state->iSamp2 * coeff[1])) / 256;
|
||||
if (nybble & 0x08) {
|
||||
new_sample += state->iDelta * (nybble - 0x10);
|
||||
} else {
|
||||
new_sample += state->iDelta * nybble;
|
||||
}
|
||||
if (new_sample < min_audioval) {
|
||||
new_sample = min_audioval;
|
||||
} else if (new_sample > max_audioval) {
|
||||
new_sample = max_audioval;
|
||||
}
|
||||
delta = ((Sint32) state->iDelta * adaptive[nybble]) / 256;
|
||||
if (delta < 16) {
|
||||
delta = 16;
|
||||
}
|
||||
state->iDelta = (Uint16) delta;
|
||||
state->iSamp2 = state->iSamp1;
|
||||
state->iSamp1 = (Sint16) new_sample;
|
||||
return (new_sample);
|
||||
}
|
||||
|
||||
static int
|
||||
MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
||||
{
|
||||
struct MS_ADPCM_decodestate *state[2];
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
Sint8 nybble, stereo;
|
||||
Sint16 *coeff[2];
|
||||
Sint32 new_sample;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len / MS_ADPCM_state.wavefmt.blockalign) *
|
||||
MS_ADPCM_state.wSamplesPerBlock *
|
||||
MS_ADPCM_state.wavefmt.channels * sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *) SDL_malloc(*audio_len);
|
||||
if (*audio_buf == NULL) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return (-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
stereo = (MS_ADPCM_state.wavefmt.channels == 2);
|
||||
state[0] = &MS_ADPCM_state.state[0];
|
||||
state[1] = &MS_ADPCM_state.state[stereo];
|
||||
while (encoded_len >= MS_ADPCM_state.wavefmt.blockalign) {
|
||||
/* Grab the initial information for this block */
|
||||
state[0]->hPredictor = *encoded++;
|
||||
if (stereo) {
|
||||
state[1]->hPredictor = *encoded++;
|
||||
}
|
||||
state[0]->iDelta = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if (stereo) {
|
||||
state[1]->iDelta = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp1 = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if (stereo) {
|
||||
state[1]->iSamp1 = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp2 = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if (stereo) {
|
||||
state[1]->iSamp2 = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
|
||||
coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
|
||||
|
||||
/* Store the two initial samples we start with */
|
||||
decoded[0] = state[0]->iSamp2 & 0xFF;
|
||||
decoded[1] = state[0]->iSamp2 >> 8;
|
||||
decoded += 2;
|
||||
if (stereo) {
|
||||
decoded[0] = state[1]->iSamp2 & 0xFF;
|
||||
decoded[1] = state[1]->iSamp2 >> 8;
|
||||
decoded += 2;
|
||||
}
|
||||
decoded[0] = state[0]->iSamp1 & 0xFF;
|
||||
decoded[1] = state[0]->iSamp1 >> 8;
|
||||
decoded += 2;
|
||||
if (stereo) {
|
||||
decoded[0] = state[1]->iSamp1 & 0xFF;
|
||||
decoded[1] = state[1]->iSamp1 >> 8;
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (MS_ADPCM_state.wSamplesPerBlock - 2) *
|
||||
MS_ADPCM_state.wavefmt.channels;
|
||||
while (samplesleft > 0) {
|
||||
nybble = (*encoded) >> 4;
|
||||
new_sample = MS_ADPCM_nibble(state[0], nybble, coeff[0]);
|
||||
decoded[0] = new_sample & 0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample & 0xFF;
|
||||
decoded += 2;
|
||||
|
||||
nybble = (*encoded) & 0x0F;
|
||||
new_sample = MS_ADPCM_nibble(state[1], nybble, coeff[1]);
|
||||
decoded[0] = new_sample & 0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample & 0xFF;
|
||||
decoded += 2;
|
||||
|
||||
++encoded;
|
||||
samplesleft -= 2;
|
||||
}
|
||||
encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
SDL_free(freeable);
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct IMA_ADPCM_decodestate
|
||||
{
|
||||
Sint32 sample;
|
||||
Sint8 index;
|
||||
};
|
||||
static struct IMA_ADPCM_decoder
|
||||
{
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
/* * * */
|
||||
struct IMA_ADPCM_decodestate state[2];
|
||||
} IMA_ADPCM_state;
|
||||
|
||||
static int
|
||||
InitIMA_ADPCM(WaveFMT * format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
Uint16 extra_info;
|
||||
|
||||
/* Set the rogue pointer to the IMA_ADPCM specific data */
|
||||
IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
IMA_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *) format + sizeof(*format);
|
||||
if (sizeof(*format) == 16) {
|
||||
extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static Sint32
|
||||
IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
|
||||
{
|
||||
const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
|
||||
const Sint32 min_audioval = -(1 << (16 - 1));
|
||||
const int index_table[16] = {
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8,
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8
|
||||
};
|
||||
const Sint32 step_table[89] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
|
||||
34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
|
||||
143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
|
||||
449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
|
||||
1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
|
||||
3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
|
||||
9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
|
||||
22385, 24623, 27086, 29794, 32767
|
||||
};
|
||||
Sint32 delta, step;
|
||||
|
||||
/* Compute difference and new sample value */
|
||||
step = step_table[state->index];
|
||||
delta = step >> 3;
|
||||
if (nybble & 0x04)
|
||||
delta += step;
|
||||
if (nybble & 0x02)
|
||||
delta += (step >> 1);
|
||||
if (nybble & 0x01)
|
||||
delta += (step >> 2);
|
||||
if (nybble & 0x08)
|
||||
delta = -delta;
|
||||
state->sample += delta;
|
||||
|
||||
/* Update index value */
|
||||
state->index += index_table[nybble];
|
||||
if (state->index > 88) {
|
||||
state->index = 88;
|
||||
} else if (state->index < 0) {
|
||||
state->index = 0;
|
||||
}
|
||||
|
||||
/* Clamp output sample */
|
||||
if (state->sample > max_audioval) {
|
||||
state->sample = max_audioval;
|
||||
} else if (state->sample < min_audioval) {
|
||||
state->sample = min_audioval;
|
||||
}
|
||||
return (state->sample);
|
||||
}
|
||||
|
||||
/* Fill the decode buffer with a channel block of data (8 samples) */
|
||||
static void
|
||||
Fill_IMA_ADPCM_block(Uint8 * decoded, Uint8 * encoded,
|
||||
int channel, int numchannels,
|
||||
struct IMA_ADPCM_decodestate *state)
|
||||
{
|
||||
int i;
|
||||
Sint8 nybble;
|
||||
Sint32 new_sample;
|
||||
|
||||
decoded += (channel * 2);
|
||||
for (i = 0; i < 4; ++i) {
|
||||
nybble = (*encoded) & 0x0F;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample & 0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample & 0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
nybble = (*encoded) >> 4;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample & 0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample & 0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
++encoded;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
||||
{
|
||||
struct IMA_ADPCM_decodestate *state;
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
unsigned int c, channels;
|
||||
|
||||
/* Check to make sure we have enough variables in the state array */
|
||||
channels = IMA_ADPCM_state.wavefmt.channels;
|
||||
if (channels > SDL_arraysize(IMA_ADPCM_state.state)) {
|
||||
SDL_SetError("IMA ADPCM decoder can only handle %d channels",
|
||||
SDL_arraysize(IMA_ADPCM_state.state));
|
||||
return (-1);
|
||||
}
|
||||
state = IMA_ADPCM_state.state;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len / IMA_ADPCM_state.wavefmt.blockalign) *
|
||||
IMA_ADPCM_state.wSamplesPerBlock *
|
||||
IMA_ADPCM_state.wavefmt.channels * sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *) SDL_malloc(*audio_len);
|
||||
if (*audio_buf == NULL) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return (-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
while (encoded_len >= IMA_ADPCM_state.wavefmt.blockalign) {
|
||||
/* Grab the initial information for this block */
|
||||
for (c = 0; c < channels; ++c) {
|
||||
/* Fill the state information for this block */
|
||||
state[c].sample = ((encoded[1] << 8) | encoded[0]);
|
||||
encoded += 2;
|
||||
if (state[c].sample & 0x8000) {
|
||||
state[c].sample -= 0x10000;
|
||||
}
|
||||
state[c].index = *encoded++;
|
||||
/* Reserved byte in buffer header, should be 0 */
|
||||
if (*encoded++ != 0) {
|
||||
/* Uh oh, corrupt data? Buggy code? */ ;
|
||||
}
|
||||
|
||||
/* Store the initial sample we start with */
|
||||
decoded[0] = (Uint8) (state[c].sample & 0xFF);
|
||||
decoded[1] = (Uint8) (state[c].sample >> 8);
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (IMA_ADPCM_state.wSamplesPerBlock - 1) * channels;
|
||||
while (samplesleft > 0) {
|
||||
for (c = 0; c < channels; ++c) {
|
||||
Fill_IMA_ADPCM_block(decoded, encoded,
|
||||
c, channels, &state[c]);
|
||||
encoded += 4;
|
||||
samplesleft -= 8;
|
||||
}
|
||||
decoded += (channels * 8 * 2);
|
||||
}
|
||||
encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
SDL_free(freeable);
|
||||
return (0);
|
||||
}
|
||||
|
||||
SDL_AudioSpec *
|
||||
SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
||||
SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len)
|
||||
{
|
||||
int was_error;
|
||||
Chunk chunk;
|
||||
int lenread;
|
||||
int IEEE_float_encoded, MS_ADPCM_encoded, IMA_ADPCM_encoded;
|
||||
int samplesize;
|
||||
|
||||
/* WAV magic header */
|
||||
Uint32 RIFFchunk;
|
||||
Uint32 wavelen = 0;
|
||||
Uint32 WAVEmagic;
|
||||
Uint32 headerDiff = 0;
|
||||
|
||||
/* FMT chunk */
|
||||
WaveFMT *format = NULL;
|
||||
|
||||
/* Make sure we are passed a valid data source */
|
||||
was_error = 0;
|
||||
if (src == NULL) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Check the magic header */
|
||||
RIFFchunk = SDL_ReadLE32(src);
|
||||
wavelen = SDL_ReadLE32(src);
|
||||
if (wavelen == WAVE) { /* The RIFFchunk has already been read */
|
||||
WAVEmagic = wavelen;
|
||||
wavelen = RIFFchunk;
|
||||
RIFFchunk = RIFF;
|
||||
} else {
|
||||
WAVEmagic = SDL_ReadLE32(src);
|
||||
}
|
||||
if ((RIFFchunk != RIFF) || (WAVEmagic != WAVE)) {
|
||||
SDL_SetError("Unrecognized file type (not WAVE)");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
headerDiff += sizeof(Uint32); /* for WAVE */
|
||||
|
||||
/* Read the audio data format chunk */
|
||||
chunk.data = NULL;
|
||||
do {
|
||||
if (chunk.data != NULL) {
|
||||
SDL_free(chunk.data);
|
||||
chunk.data = NULL;
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if (lenread < 0) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ((chunk.magic == FACT) || (chunk.magic == LIST));
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *) chunk.data;
|
||||
if (chunk.magic != FMT) {
|
||||
SDL_SetError("Complex WAVE files not supported");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
IEEE_float_encoded = MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
|
||||
switch (SDL_SwapLE16(format->encoding)) {
|
||||
case PCM_CODE:
|
||||
/* We can understand this */
|
||||
break;
|
||||
case IEEE_FLOAT_CODE:
|
||||
IEEE_float_encoded = 1;
|
||||
/* We can understand this */
|
||||
break;
|
||||
case MS_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if (InitMS_ADPCM(format) < 0) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = 1;
|
||||
break;
|
||||
case IMA_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if (InitIMA_ADPCM(format) < 0) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
IMA_ADPCM_encoded = 1;
|
||||
break;
|
||||
case MP3_CODE:
|
||||
SDL_SetError("MPEG Layer 3 data not supported",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
default:
|
||||
SDL_SetError("Unknown WAVE data format: 0x%.4x",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
SDL_memset(spec, 0, (sizeof *spec));
|
||||
spec->freq = SDL_SwapLE32(format->frequency);
|
||||
|
||||
if (IEEE_float_encoded) {
|
||||
if ((SDL_SwapLE16(format->bitspersample)) != 32) {
|
||||
was_error = 1;
|
||||
} else {
|
||||
spec->format = AUDIO_F32;
|
||||
}
|
||||
} else {
|
||||
switch (SDL_SwapLE16(format->bitspersample)) {
|
||||
case 4:
|
||||
if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
|
||||
spec->format = AUDIO_S16;
|
||||
} else {
|
||||
was_error = 1;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
spec->format = AUDIO_U8;
|
||||
break;
|
||||
case 16:
|
||||
spec->format = AUDIO_S16;
|
||||
break;
|
||||
case 32:
|
||||
spec->format = AUDIO_S32;
|
||||
break;
|
||||
default:
|
||||
was_error = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (was_error) {
|
||||
SDL_SetError("Unknown %d-bit PCM data format",
|
||||
SDL_SwapLE16(format->bitspersample));
|
||||
goto done;
|
||||
}
|
||||
spec->channels = (Uint8) SDL_SwapLE16(format->channels);
|
||||
spec->samples = 4096; /* Good default buffer size */
|
||||
|
||||
/* Read the audio data chunk */
|
||||
*audio_buf = NULL;
|
||||
do {
|
||||
if (*audio_buf != NULL) {
|
||||
SDL_free(*audio_buf);
|
||||
*audio_buf = NULL;
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if (lenread < 0) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
*audio_len = lenread;
|
||||
*audio_buf = chunk.data;
|
||||
if (chunk.magic != DATA)
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while (chunk.magic != DATA);
|
||||
headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
|
||||
|
||||
if (MS_ADPCM_encoded) {
|
||||
if (MS_ADPCM_decode(audio_buf, audio_len) < 0) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (IMA_ADPCM_encoded) {
|
||||
if (IMA_ADPCM_decode(audio_buf, audio_len) < 0) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't return a buffer that isn't a multiple of samplesize */
|
||||
samplesize = ((SDL_AUDIO_BITSIZE(spec->format)) / 8) * spec->channels;
|
||||
*audio_len &= ~(samplesize - 1);
|
||||
|
||||
done:
|
||||
if (format != NULL) {
|
||||
SDL_free(format);
|
||||
}
|
||||
if (src) {
|
||||
if (freesrc) {
|
||||
SDL_RWclose(src);
|
||||
} else {
|
||||
/* seek to the end of the file (given by the RIFF chunk) */
|
||||
SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
|
||||
}
|
||||
}
|
||||
if (was_error) {
|
||||
spec = NULL;
|
||||
}
|
||||
return (spec);
|
||||
}
|
||||
|
||||
/* Since the WAV memory is allocated in the shared library, it must also
|
||||
be freed here. (Necessary under Win32, VC++)
|
||||
*/
|
||||
void
|
||||
SDL_FreeWAV(Uint8 * audio_buf)
|
||||
{
|
||||
if (audio_buf != NULL) {
|
||||
SDL_free(audio_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ReadChunk(SDL_RWops * src, Chunk * chunk)
|
||||
{
|
||||
chunk->magic = SDL_ReadLE32(src);
|
||||
chunk->length = SDL_ReadLE32(src);
|
||||
chunk->data = (Uint8 *) SDL_malloc(chunk->length);
|
||||
if (chunk->data == NULL) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return (-1);
|
||||
}
|
||||
if (SDL_RWread(src, chunk->data, chunk->length, 1) != 1) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
SDL_free(chunk->data);
|
||||
chunk->data = NULL;
|
||||
return (-1);
|
||||
}
|
||||
return (chunk->length);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is SDL_free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* WAVE files are little-endian */
|
||||
|
||||
/*******************************************/
|
||||
/* Define values for Microsoft WAVE format */
|
||||
/*******************************************/
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
#define FACT 0x74636166 /* "fact" */
|
||||
#define LIST 0x5453494c /* "LIST" */
|
||||
#define FMT 0x20746D66 /* "fmt " */
|
||||
#define DATA 0x61746164 /* "data" */
|
||||
#define PCM_CODE 0x0001
|
||||
#define MS_ADPCM_CODE 0x0002
|
||||
#define IEEE_FLOAT_CODE 0x0003
|
||||
#define IMA_ADPCM_CODE 0x0011
|
||||
#define MP3_CODE 0x0055
|
||||
#define WAVE_MONO 1
|
||||
#define WAVE_STEREO 2
|
||||
|
||||
/* Normally, these three chunks come consecutively in a WAVE file */
|
||||
typedef struct WaveFMT
|
||||
{
|
||||
/* Not saved in the chunk we read:
|
||||
Uint32 FMTchunk;
|
||||
Uint32 fmtlen;
|
||||
*/
|
||||
Uint16 encoding;
|
||||
Uint16 channels; /* 1 = mono, 2 = stereo */
|
||||
Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
|
||||
Uint32 byterate; /* Average bytes per second */
|
||||
Uint16 blockalign; /* Bytes per sample block */
|
||||
Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
|
||||
} WaveFMT;
|
||||
|
||||
/* The general chunk found in the WAVE file */
|
||||
typedef struct Chunk
|
||||
{
|
||||
Uint32 magic;
|
||||
Uint32 length;
|
||||
Uint8 *data;
|
||||
} Chunk;
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,691 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Allow access to a raw mixing buffer */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h> /* For kill() */
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audiomem.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "SDL_alsa_audio.h"
|
||||
|
||||
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
|
||||
#include "SDL_loadso.h"
|
||||
#endif
|
||||
|
||||
/* The tag name used by ALSA audio */
|
||||
#define DRIVER_NAME "alsa"
|
||||
|
||||
static int (*ALSA_snd_pcm_open)
|
||||
(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
|
||||
static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm);
|
||||
static snd_pcm_sframes_t(*ALSA_snd_pcm_writei)
|
||||
(snd_pcm_t *, const void *, snd_pcm_uframes_t);
|
||||
static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int);
|
||||
static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *);
|
||||
static int (*ALSA_snd_pcm_drain) (snd_pcm_t *);
|
||||
static const char *(*ALSA_snd_strerror) (int);
|
||||
static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void);
|
||||
static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void);
|
||||
static void (*ALSA_snd_pcm_hw_params_copy)
|
||||
(snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *);
|
||||
static int (*ALSA_snd_pcm_hw_params_any) (snd_pcm_t *, snd_pcm_hw_params_t *);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_access)
|
||||
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_format)
|
||||
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_channels)
|
||||
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_channels)
|
||||
(const snd_pcm_hw_params_t *, unsigned int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_rate_near)
|
||||
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_period_size_near)
|
||||
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_period_size)
|
||||
(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_periods_near)
|
||||
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_periods)
|
||||
(const snd_pcm_hw_params_t *, unsigned int *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)
|
||||
(snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_buffer_size)
|
||||
(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
|
||||
static int (*ALSA_snd_pcm_hw_params) (snd_pcm_t *, snd_pcm_hw_params_t *);
|
||||
static int (*ALSA_snd_pcm_sw_params_current) (snd_pcm_t *,
|
||||
snd_pcm_sw_params_t *);
|
||||
static int (*ALSA_snd_pcm_sw_params_set_start_threshold)
|
||||
(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
|
||||
static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *);
|
||||
static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int);
|
||||
static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int);
|
||||
|
||||
|
||||
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
|
||||
#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
|
||||
#define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof
|
||||
|
||||
static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
|
||||
static void *alsa_handle = NULL;
|
||||
|
||||
static int
|
||||
load_alsa_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(alsa_handle, fn);
|
||||
if (*addr == NULL) {
|
||||
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
|
||||
#define SDL_ALSA_SYM(x) \
|
||||
if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1
|
||||
#else
|
||||
#define SDL_ALSA_SYM(x) ALSA_##x = x
|
||||
#endif
|
||||
|
||||
static int
|
||||
load_alsa_syms(void)
|
||||
{
|
||||
SDL_ALSA_SYM(snd_pcm_open);
|
||||
SDL_ALSA_SYM(snd_pcm_close);
|
||||
SDL_ALSA_SYM(snd_pcm_writei);
|
||||
SDL_ALSA_SYM(snd_pcm_recover);
|
||||
SDL_ALSA_SYM(snd_pcm_prepare);
|
||||
SDL_ALSA_SYM(snd_pcm_drain);
|
||||
SDL_ALSA_SYM(snd_strerror);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_sizeof);
|
||||
SDL_ALSA_SYM(snd_pcm_sw_params_sizeof);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_copy);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_any);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_access);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_format);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_channels);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_channels);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_rate_near);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_period_size_near);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_period_size);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_periods_near);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_periods);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_buffer_size_near);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_buffer_size);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params);
|
||||
SDL_ALSA_SYM(snd_pcm_sw_params_current);
|
||||
SDL_ALSA_SYM(snd_pcm_sw_params_set_start_threshold);
|
||||
SDL_ALSA_SYM(snd_pcm_sw_params);
|
||||
SDL_ALSA_SYM(snd_pcm_nonblock);
|
||||
SDL_ALSA_SYM(snd_pcm_wait);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef SDL_ALSA_SYM
|
||||
|
||||
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
|
||||
|
||||
static void
|
||||
UnloadALSALibrary(void)
|
||||
{
|
||||
if (alsa_handle != NULL) {
|
||||
SDL_UnloadObject(alsa_handle);
|
||||
alsa_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
LoadALSALibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
if (alsa_handle == NULL) {
|
||||
alsa_handle = SDL_LoadObject(alsa_library);
|
||||
if (alsa_handle == NULL) {
|
||||
retval = -1;
|
||||
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
|
||||
} else {
|
||||
retval = load_alsa_syms();
|
||||
if (retval < 0) {
|
||||
UnloadALSALibrary();
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void
|
||||
UnloadALSALibrary(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
LoadALSALibrary(void)
|
||||
{
|
||||
load_alsa_syms();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
|
||||
|
||||
static const char *
|
||||
get_audio_device(int channels)
|
||||
{
|
||||
const char *device;
|
||||
|
||||
device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */
|
||||
if (device == NULL) {
|
||||
switch (channels) {
|
||||
case 6:
|
||||
device = "plug:surround51";
|
||||
break;
|
||||
case 4:
|
||||
device = "plug:surround40";
|
||||
break;
|
||||
default:
|
||||
device = "default";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void
|
||||
ALSA_WaitDevice(_THIS)
|
||||
{
|
||||
/* We're in blocking mode, so there's nothing to do here */
|
||||
}
|
||||
|
||||
|
||||
/* !!! FIXME: is there a channel swizzler in alsalib instead? */
|
||||
/*
|
||||
* http://bugzilla.libsdl.org/show_bug.cgi?id=110
|
||||
* "For Linux ALSA, this is FL-FR-RL-RR-C-LFE
|
||||
* and for Windows DirectX [and CoreAudio], this is FL-FR-C-LFE-RL-RR"
|
||||
*/
|
||||
#define SWIZ6(T) \
|
||||
T *ptr = (T *) this->hidden->mixbuf; \
|
||||
Uint32 i; \
|
||||
for (i = 0; i < this->spec.samples; i++, ptr += 6) { \
|
||||
T tmp; \
|
||||
tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \
|
||||
tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_64bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint64);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_32bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint32);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_16bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint16);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_8bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint8);
|
||||
}
|
||||
|
||||
#undef SWIZ6
|
||||
|
||||
|
||||
/*
|
||||
* Called right before feeding this->hidden->mixbuf to the hardware. Swizzle
|
||||
* channels from Windows/Mac order to the format alsalib will want.
|
||||
*/
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels(_THIS)
|
||||
{
|
||||
if (this->spec.channels == 6) {
|
||||
const Uint16 fmtsize = (this->spec.format & 0xFF); /* bits/channel. */
|
||||
if (fmtsize == 16)
|
||||
swizzle_alsa_channels_6_16bit(this);
|
||||
else if (fmtsize == 8)
|
||||
swizzle_alsa_channels_6_8bit(this);
|
||||
else if (fmtsize == 32)
|
||||
swizzle_alsa_channels_6_32bit(this);
|
||||
else if (fmtsize == 64)
|
||||
swizzle_alsa_channels_6_64bit(this);
|
||||
}
|
||||
|
||||
/* !!! FIXME: update this for 7.1 if needed, later. */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ALSA_PlayDevice(_THIS)
|
||||
{
|
||||
int status;
|
||||
const Uint8 *sample_buf = (const Uint8 *) this->hidden->mixbuf;
|
||||
const int frame_size = (((int) (this->spec.format & 0xFF)) / 8) *
|
||||
this->spec.channels;
|
||||
snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t) this->spec.samples);
|
||||
|
||||
swizzle_alsa_channels(this);
|
||||
|
||||
while ( frames_left > 0 && this->enabled ) {
|
||||
/* !!! FIXME: This works, but needs more testing before going live */
|
||||
/*ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1);*/
|
||||
status = ALSA_snd_pcm_writei(this->hidden->pcm_handle,
|
||||
sample_buf, frames_left);
|
||||
|
||||
if (status < 0) {
|
||||
if (status == -EAGAIN) {
|
||||
/* Apparently snd_pcm_recover() doesn't handle this case -
|
||||
does it assume snd_pcm_wait() above? */
|
||||
SDL_Delay(1);
|
||||
continue;
|
||||
}
|
||||
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
||||
if (status < 0) {
|
||||
/* Hmm, not much we can do - abort */
|
||||
fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
this->enabled = 0;
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
sample_buf += status * frame_size;
|
||||
frames_left -= status;
|
||||
}
|
||||
}
|
||||
|
||||
static Uint8 *
|
||||
ALSA_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
ALSA_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
if (this->hidden->mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
this->hidden->mixbuf = NULL;
|
||||
}
|
||||
if (this->hidden->pcm_handle) {
|
||||
ALSA_snd_pcm_drain(this->hidden->pcm_handle);
|
||||
ALSA_snd_pcm_close(this->hidden->pcm_handle);
|
||||
this->hidden->pcm_handle = NULL;
|
||||
}
|
||||
SDL_free(this->hidden);
|
||||
this->hidden = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ALSA_finalize_hardware(_THIS, snd_pcm_hw_params_t *hwparams, int override)
|
||||
{
|
||||
int status;
|
||||
snd_pcm_uframes_t bufsize;
|
||||
|
||||
/* "set" the hardware with the desired parameters */
|
||||
status = ALSA_snd_pcm_hw_params(this->hidden->pcm_handle, hwparams);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Get samples for the actual buffer size */
|
||||
status = ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
if ( !override && bufsize != this->spec.samples * 2 ) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* !!! FIXME: Is this safe to do? */
|
||||
this->spec.samples = bufsize / 2;
|
||||
|
||||
/* This is useful for debugging */
|
||||
if ( SDL_getenv("SDL_AUDIO_ALSA_DEBUG") ) {
|
||||
snd_pcm_uframes_t persize = 0;
|
||||
unsigned int periods = 0;
|
||||
|
||||
ALSA_snd_pcm_hw_params_get_period_size(hwparams, &persize, NULL);
|
||||
ALSA_snd_pcm_hw_params_get_periods(hwparams, &periods, NULL);
|
||||
|
||||
fprintf(stderr,
|
||||
"ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
|
||||
persize, periods, bufsize);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int
|
||||
ALSA_set_period_size(_THIS, snd_pcm_hw_params_t *params, int override)
|
||||
{
|
||||
const char *env;
|
||||
int status;
|
||||
snd_pcm_hw_params_t *hwparams;
|
||||
snd_pcm_uframes_t frames;
|
||||
unsigned int periods;
|
||||
|
||||
/* Copy the hardware parameters for this setup */
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
ALSA_snd_pcm_hw_params_copy(hwparams, params);
|
||||
|
||||
if ( !override ) {
|
||||
env = SDL_getenv("SDL_AUDIO_ALSA_SET_PERIOD_SIZE");
|
||||
if ( env ) {
|
||||
override = SDL_atoi(env);
|
||||
if ( override == 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frames = this->spec.samples;
|
||||
status = ALSA_snd_pcm_hw_params_set_period_size_near(
|
||||
this->hidden->pcm_handle, hwparams, &frames, NULL);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
periods = 2;
|
||||
status = ALSA_snd_pcm_hw_params_set_periods_near(
|
||||
this->hidden->pcm_handle, hwparams, &periods, NULL);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return ALSA_finalize_hardware(this, hwparams, override);
|
||||
}
|
||||
|
||||
static int
|
||||
ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override)
|
||||
{
|
||||
const char *env;
|
||||
int status;
|
||||
snd_pcm_hw_params_t *hwparams;
|
||||
snd_pcm_uframes_t frames;
|
||||
|
||||
/* Copy the hardware parameters for this setup */
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
ALSA_snd_pcm_hw_params_copy(hwparams, params);
|
||||
|
||||
if ( !override ) {
|
||||
env = SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE");
|
||||
if ( env ) {
|
||||
override = SDL_atoi(env);
|
||||
if ( override == 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frames = this->spec.samples * 2;
|
||||
status = ALSA_snd_pcm_hw_params_set_buffer_size_near(
|
||||
this->hidden->pcm_handle, hwparams, &frames);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return ALSA_finalize_hardware(this, hwparams, override);
|
||||
}
|
||||
|
||||
static int
|
||||
ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
{
|
||||
int status = 0;
|
||||
snd_pcm_t *pcm_handle = NULL;
|
||||
snd_pcm_hw_params_t *hwparams = NULL;
|
||||
snd_pcm_sw_params_t *swparams = NULL;
|
||||
snd_pcm_format_t format = 0;
|
||||
SDL_AudioFormat test_format = 0;
|
||||
unsigned int rate = 0;
|
||||
unsigned int channels = 0;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
if (this->hidden == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
/* Open the audio device */
|
||||
/* Name of device should depend on # channels in spec */
|
||||
status = ALSA_snd_pcm_open(&pcm_handle,
|
||||
get_audio_device(this->spec.channels),
|
||||
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't open audio device: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
this->hidden->pcm_handle = pcm_handle;
|
||||
|
||||
/* Figure out what the hardware is capable of */
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
status = ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't get hardware config: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* SDL only uses interleaved sample output */
|
||||
status = ALSA_snd_pcm_hw_params_set_access(pcm_handle, hwparams,
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't set interleaved access: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Try for a closest match on audio format */
|
||||
status = -1;
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
test_format && (status < 0);) {
|
||||
status = 0; /* if we can't support a format, it'll become -1. */
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
format = SND_PCM_FORMAT_U8;
|
||||
break;
|
||||
case AUDIO_S8:
|
||||
format = SND_PCM_FORMAT_S8;
|
||||
break;
|
||||
case AUDIO_S16LSB:
|
||||
format = SND_PCM_FORMAT_S16_LE;
|
||||
break;
|
||||
case AUDIO_S16MSB:
|
||||
format = SND_PCM_FORMAT_S16_BE;
|
||||
break;
|
||||
case AUDIO_U16LSB:
|
||||
format = SND_PCM_FORMAT_U16_LE;
|
||||
break;
|
||||
case AUDIO_U16MSB:
|
||||
format = SND_PCM_FORMAT_U16_BE;
|
||||
break;
|
||||
case AUDIO_S32LSB:
|
||||
format = SND_PCM_FORMAT_S32_LE;
|
||||
break;
|
||||
case AUDIO_S32MSB:
|
||||
format = SND_PCM_FORMAT_S32_BE;
|
||||
break;
|
||||
case AUDIO_F32LSB:
|
||||
format = SND_PCM_FORMAT_FLOAT_LE;
|
||||
break;
|
||||
case AUDIO_F32MSB:
|
||||
format = SND_PCM_FORMAT_FLOAT_BE;
|
||||
break;
|
||||
default:
|
||||
status = -1;
|
||||
break;
|
||||
}
|
||||
if (status >= 0) {
|
||||
status = ALSA_snd_pcm_hw_params_set_format(pcm_handle,
|
||||
hwparams, format);
|
||||
}
|
||||
if (status < 0) {
|
||||
test_format = SDL_NextAudioFormat();
|
||||
}
|
||||
}
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't find any hardware audio formats");
|
||||
return 0;
|
||||
}
|
||||
this->spec.format = test_format;
|
||||
|
||||
/* Set the number of channels */
|
||||
status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams,
|
||||
this->spec.channels);
|
||||
channels = this->spec.channels;
|
||||
if (status < 0) {
|
||||
status = ALSA_snd_pcm_hw_params_get_channels(hwparams, &channels);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't set audio channels");
|
||||
return 0;
|
||||
}
|
||||
this->spec.channels = channels;
|
||||
}
|
||||
|
||||
/* Set the audio rate */
|
||||
rate = this->spec.freq;
|
||||
status = ALSA_snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams,
|
||||
&rate, NULL);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't set audio frequency: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
this->spec.freq = rate;
|
||||
|
||||
/* Set the buffer size, in samples */
|
||||
if ( ALSA_set_period_size(this, hwparams, 0) < 0 &&
|
||||
ALSA_set_buffer_size(this, hwparams, 0) < 0 ) {
|
||||
/* Failed to set desired buffer size, do the best you can... */
|
||||
if ( ALSA_set_period_size(this, hwparams, 1) < 0 ) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("Couldn't set hardware audio parameters: %s", ALSA_snd_strerror(status));
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
/* Set the software parameters */
|
||||
snd_pcm_sw_params_alloca(&swparams);
|
||||
status = ALSA_snd_pcm_sw_params_current(pcm_handle, swparams);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't get software config: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
status =
|
||||
ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("ALSA: Couldn't set start threshold: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
status = ALSA_snd_pcm_sw_params(pcm_handle, swparams);
|
||||
if (status < 0) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_SetError("Couldn't set software audio parameters: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Calculate the final parameters for this audio specification */
|
||||
SDL_CalculateAudioSpec(&this->spec);
|
||||
|
||||
/* Allocate mixing buffer */
|
||||
this->hidden->mixlen = this->spec.size;
|
||||
this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
|
||||
if (this->hidden->mixbuf == NULL) {
|
||||
ALSA_CloseDevice(this);
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
|
||||
|
||||
/* Switch to blocking mode for playback */
|
||||
ALSA_snd_pcm_nonblock(pcm_handle, 0);
|
||||
|
||||
/* We're ready to rock and roll. :-) */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ALSA_Deinitialize(void)
|
||||
{
|
||||
UnloadALSALibrary();
|
||||
}
|
||||
|
||||
static int
|
||||
ALSA_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
if (LoadALSALibrary() < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = ALSA_OpenDevice;
|
||||
impl->WaitDevice = ALSA_WaitDevice;
|
||||
impl->GetDeviceBuf = ALSA_GetDeviceBuf;
|
||||
impl->PlayDevice = ALSA_PlayDevice;
|
||||
impl->CloseDevice = ALSA_CloseDevice;
|
||||
impl->Deinitialize = ALSA_Deinitialize;
|
||||
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
|
||||
AudioBootStrap ALSA_bootstrap = {
|
||||
DRIVER_NAME, "ALSA PCM audio", ALSA_Init, 0
|
||||
};
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _ALSA_PCM_audio_h
|
||||
#define _ALSA_PCM_audio_h
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The audio device handle */
|
||||
snd_pcm_t *pcm_handle;
|
||||
|
||||
/* Raw mixing buffer */
|
||||
Uint8 *mixbuf;
|
||||
int mixlen;
|
||||
};
|
||||
|
||||
#endif /* _ALSA_PCM_audio_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Output audio to Android */
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "SDL_androidaudio.h"
|
||||
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
static void * audioDevice;
|
||||
|
||||
static int
|
||||
AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_AudioFormat test_format;
|
||||
int valid_datatype = 0;
|
||||
|
||||
if (iscapture) {
|
||||
//TODO: implement capture
|
||||
SDL_SetError("Capture not supported on Android");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (audioDevice != NULL) {
|
||||
SDL_SetError("Only one audio device at a time please!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
audioDevice = this;
|
||||
|
||||
this->hidden = SDL_malloc(sizeof(*(this->hidden)));
|
||||
if (!this->hidden) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
while (test_format != 0) { // no "UNKNOWN" constant
|
||||
if ((test_format == AUDIO_U8) || (test_format == AUDIO_S16LSB)) {
|
||||
this->spec.format = test_format;
|
||||
break;
|
||||
}
|
||||
test_format = SDL_NextAudioFormat();
|
||||
}
|
||||
|
||||
if (test_format == 0) {
|
||||
// Didn't find a compatible format :(
|
||||
SDL_SetError("No compatible audio format!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this->spec.channels > 1) {
|
||||
this->spec.channels = 2;
|
||||
} else {
|
||||
this->spec.channels = 1;
|
||||
}
|
||||
|
||||
if (this->spec.freq < 8000) {
|
||||
this->spec.freq = 8000;
|
||||
}
|
||||
if (this->spec.freq > 48000) {
|
||||
this->spec.freq = 48000;
|
||||
}
|
||||
|
||||
// TODO: pass in/return a (Java) device ID, also whether we're opening for input or output
|
||||
this->spec.samples = Android_JNI_OpenAudioDevice(this->spec.freq, this->spec.format == AUDIO_U8 ? 0 : 1, this->spec.channels, this->spec.samples);
|
||||
SDL_CalculateAudioSpec(&this->spec);
|
||||
|
||||
if (this->spec.samples == 0) {
|
||||
// Init failed?
|
||||
SDL_SetError("Java-side initialization failed!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
AndroidAUD_PlayDevice(_THIS)
|
||||
{
|
||||
Android_JNI_WriteAudioBuffer();
|
||||
}
|
||||
|
||||
static Uint8 *
|
||||
AndroidAUD_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return Android_JNI_GetAudioBuffer();
|
||||
}
|
||||
|
||||
static void
|
||||
AndroidAUD_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
SDL_free(this->hidden);
|
||||
this->hidden = NULL;
|
||||
}
|
||||
Android_JNI_CloseAudioDevice();
|
||||
|
||||
if (audioDevice == this) {
|
||||
audioDevice = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
AndroidAUD_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = AndroidAUD_OpenDevice;
|
||||
impl->PlayDevice = AndroidAUD_PlayDevice;
|
||||
impl->GetDeviceBuf = AndroidAUD_GetDeviceBuf;
|
||||
impl->CloseDevice = AndroidAUD_CloseDevice;
|
||||
|
||||
/* and the capabilities */
|
||||
impl->ProvidesOwnCallbackThread = 1;
|
||||
impl->HasCaptureSupport = 0; //TODO
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
impl->OnlyHasDefaultInputDevice = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
AudioBootStrap ANDROIDAUD_bootstrap = {
|
||||
"android", "SDL Android audio driver", AndroidAUD_Init, 0 /*1? */
|
||||
};
|
||||
|
||||
/* Called by the Java code to start the audio processing on a thread */
|
||||
void
|
||||
Android_RunAudioThread()
|
||||
{
|
||||
SDL_RunAudio(audioDevice);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_androidaudio_h
|
||||
#define _SDL_androidaudio_h
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
};
|
||||
|
||||
#endif /* _SDL_androidaudio_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue