Marcus von Appen avatar Marcus von Appen committed c21c202

Initial commit

Comments (0)

Files changed (83)

+syntax: glob
+.settings
+*project
+*.pyc
+*~
+*.class
+*.core
+build
+doc/html
+Authors and contributors:
+Marcus von Appen <marcus@sysfault.org>
+See doc/copying.rst
+graft doc
+graft util
+graft examples
+include *.bat Makefile
+include *.txt
+PYTHON ?= python
+top_srcdir := `pwd`
+PYTHONPATH ?= $(top_srcdir)
+SUBDIRS = \
+	$(top_srcdir)/sdl2 \
+	$(top_srcdir)/sdl2/test \
+	$(top_srcdir)/sdl2/test/util \
+	$(top_srcdir)/doc \
+	$(top_srcdir)/examples
+
+all: clean build
+
+dist: clean docs
+	@echo "Creating dist..."
+	@$(PYTHON) setup.py sdist --format gztar
+	@$(PYTHON) setup.py sdist --format zip
+
+bdist: clean docs
+	@echo "Creating bdist..."
+	@$(PYTHON) setup.py bdist
+
+build:
+	@echo "Running build"
+	@$(PYTHON) setup.py build
+	@echo "Build finished, invoke 'make install' to install."
+
+
+install:
+	@echo "Installing..."
+	@$(PYTHON) setup.py install
+
+clean:
+	@echo "Cleaning up in $(top_srcdir)/ ..."
+	@rm -f *.cache *.core *~ MANIFEST *.pyc *.orig
+	@rm -rf __pycache__
+	@rm -rf build dist doc/html
+
+	@for dir in $(SUBDIRS); do \
+		if test -f $$dir/Makefile; then \
+			make -C $$dir clean; \
+		else \
+			cd $$dir; \
+			echo "Cleaning up in $$dir..."; \
+			rm -f *~ *.cache *.core *.pyc *.orig *py.class; \
+			rm -rf __pycache__; \
+		fi \
+	done
+
+docs:
+	@echo "Creating docs package"
+	@rm -rf doc/html
+	@cd doc && make html
+	@mv doc/_build/html doc/html
+	@rm -rf doc/_build
+	@cd doc && make clean
+
+release: dist
+runtest:
+	@PYTHONPATH=$(PYTHONPATH) $(PYTHON) -B -m sdl2.test.util.runtests
+
+# Do not run these in production environments! They are for testing
+# purposes only!
+
+buildall: clean
+	@python2.7 setup.py build
+	@python3.2 setup.py build
+	@python3.3 setup.py build
+	@pypy2.0 setup.py build
+
+
+installall:
+	@python2.7 setup.py install
+	@python3.2 setup.py install
+	@python3.3 setup.py install
+	@pypy2.0 setup.py install
+
+testall:
+	@-PYTHONPATH=$(PYTHONPATH) python2.7 -B -m sdl2.test.util.runtests
+	@-PYTHONPATH=$(PYTHONPATH) python3.2 -B -m sdl2.test.util.runtests
+	@-PYTHONPATH=$(PYTHONPATH) python3.3 -B -m sdl2.test.util.runtests
+	@-PYTHONPATH=$(PYTHONPATH) pypy2.0 -B -m sdl2.test.util.runtests
+
+testpackage:
+	@python2.7 -c "import sdl2.test; sdl2.test.run()"
+	@python3.2 -c "import sdl2.test; sdl2.test.run()"
+	@python3.3 -c "import sdl2.test; sdl2.test.run()"
+	@pypy2.0 -c "import sdl2.test; sdl2.test.run()"
+
+purge_installs:
+	rm -rf /usr/local/lib/python2.7/site-packages/sdl2*
+	rm -rf /usr/local/lib/python3.2/site-packages/sdl2*
+	rm -rf /usr/local/lib/python3.3/site-packages/sdl2*
+	rm -rf /usr/local/lib/pypy-2.0/site-packages/sdl2*
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	@rm -rf $(BUILDDIR)/*
+	@rm -f modules/*~ tutorial/*~ *~
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Pygame2.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Pygame2.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/Pygame2"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Pygame2"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+# -*- coding: utf-8 -*-
+#
+# PySDL2 documentation build configuration file, created by
+# sphinx-quickstart on Thu Mar 22 07:51:57 2012.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+# sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+# needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.intersphinx',
+              'sphinx.ext.todo',
+              'sphinx.ext.coverage',
+              'sphinx.ext.inheritance_diagram'
+              ]
+
+todo_include_todos = True
+graphviz_output_format = 'png'
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+# source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'PySDL2'
+copyright = u'2013, Marcus von Appen'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.1'
+# The full version, including alpha/beta/rc tags.
+release = '0.1.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+# language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+# today = ''
+# Else, today_fmt is used as the format for a strftime call.
+# today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+# default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+# add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+# add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+# show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+# modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+# html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+# html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+# html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+# html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+# html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+# html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+# html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+# html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+# html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+# html_additional_pages = {}
+
+# If false, no module index is generated.
+# html_domain_indices = True
+
+# If false, no index is generated.
+# html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+# html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+# html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+# html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+# html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+# html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+# html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'PySDL2Doc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+# 'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+# 'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+# 'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'PySDL2.tex', u'PySDL2 Documentation',
+   u'Marcus von Appen', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+# latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+# latex_use_parts = False
+
+# If true, show page references after internal links.
+# latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+# latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+# latex_appendices = []
+
+# If false, no module index is generated.
+# latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'pysdl2', u'PySDL2 Documentation',
+     [u'Marcus von Appen'], 1)
+]
+
+# If true, show URL addresses after external links.
+# man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'PySDL2', u'PySDL2 Documentation',
+   u'Marcus von Appen', 'PySDL2', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+# texinfo_appendices = []
+
+# If false, no module index is generated.
+# texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+# texinfo_show_urls = 'footnote'
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': "python.inv"}
+License
+=======
+ ::
+
+   This software is distributed under the Public Domain.
+
+   In cases, where the law prohibits the recognition of Public Domain
+   software, this software can be licensed under the zlib lincese as
+   stated below:
+
+   Copyright (C) 2012 Marcus von Appen <marcus@sysfault.org>
+
+   This software is provided 'as-is', without any express or implied
+   warranty. In no event will the authors be held liable for any damages
+   arising from the use of this software.
+
+   Permission is granted to anyone to use this software for any purpose,
+   including commercial applications, and to alter it and redistribute it
+   freely, subject to the following restrictions:
+
+   1. The origin of this software must not be misrepresented; you must not
+      claim that you wrote the original software. If you use this software
+      in a product, an acknowledgment in the product documentation would be
+      appreciated but is not required.
+   2. Altered source versions must be plainly marked as such, and must not be
+      misrepresented as being the original software.
+   3. This notice may not be removed or altered from any source distribution.
+Welcome to PySDL2's documentation!
+===================================
+PySDL2 is a wrapper around the SDL2 library and as such similar to the
+discontinued PySDL project. In contrast to PySDL, it has no licensing
+restrictions, nor does it rely on C code, but uses :mod:`ctypes` instead.
+
+Contents
+========
+
+.. toctree::
+   :maxdepth: 2
+
+   install.rst
+   integration.rst
+   sdl.rst
+   news.rst
+
+Further readings:
+
+.. toctree::
+   :maxdepth: 1
+
+   todos.rst
+   copying.rst
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
+
+Documentation TODOs
+===================
+
+.. todolist::
+
+Last generated on: |today|
+Installing PySDL2
+=================
+This section provides an overview and guidance for installing PySDL2 on
+various target platforms.
+
+Prerequisites
+-------------
+PySDL2 relies on some 3rd party packages to be fully usable and to
+provide you full access to all of its features.
+
+You must have at least one of the following Python versions installed:
+
+* Python 2.7, 3.2+     (http://www.python.org)
+* PyPy 1.9.0+          (http://www.pypy.org)
+
+Other Python versions or Python implementations might work, but are
+(currently) not officially tested or supported by the PySDL2
+distribution.
+
+Installation
+------------
+You can either use the python way of installing the package or the make
+command using the Makefile on POSIX-compatible platforms, such as Linux
+or BSD, or the make.bat batch file on Windows platforms.
+
+Simply type ::
+
+  python setup.py install
+
+for the traditional python way or ::
+
+  make install
+
+for using the Makefile or make.bat. Both will try to perform a default
+installation with as many features as possible.
+
+Trying out
+^^^^^^^^^^
+You also can test out PySDL2 without actually installing it. You just
+need to set up your ``PYTHONPATH`` to point to the location of the
+source distribution package. On Windows-based platforms, you might use
+something like ::
+
+   set PYTHONPATH=C:\path\to\pysdl2\:$PYTHONPATH
+
+to define the ``PYTHONPATH`` on a command shell. On Linux/Unix, use ::
+
+   export PYTHONPATH=/path/to/pysdl2:$PYTHONPATH
+
+For bourne shell compatibles or ::
+
+   setenv PYTHONPATH /path/to/pysdl2:$PYTHONPATH
+
+for C shell compatibles. You can omit the `:$PYTHONPATH``, if you did not use
+it so far and if your environment settings do not define it.
+
+.. note::
+
+   If you are using IronPython, use ``IRONPYTHONPATH`` instead of
+   ``PYTHONPATH``.
+
+Notes on Mercurial usage
+^^^^^^^^^^^^^^^^^^^^^^^^
+The Mercurial version of PySDL2 is not intended to be used in a
+production environment. Interfaces may change from one checkin to
+another, methods, classes or modules can be broken and so on. If you
+want more reliable code, please refer to the official releases.

doc/integration.rst

+Integrating PySDL2
+==================
+PySDL2 consists of a single package, :mod:`sdl2`, which is a plain 1:1 API
+wrapper around the SDL2 API.
+
+The package is implemented in a way that shall make it easy for you to
+integrate and deploy it with your own software projects. You can rely on
+PySDL2 as third-party package, so that the user needs to install it
+before he can use your software. Alternatively, you can just copy the
+whole package into your project to ship it within your own project
+bundle.
+
+Importing
+---------
+The :mod:`sdl2` module relies on an external SDL2 library which it can
+access for creating the wrapper functions. This means that the user
+needs to have SDL2 installed or that you ship a SDL2 library with
+your project.
+
+If the user has a SDL2 library installed on the target system, the
+:mod:`ctypes` hooks of :mod:`sdl2` try to find it in the OS-specific
+standard locations via :func:`ctypes.util.find_library`. If you are
+going to ship your own SDL2 library with the project or can not rely
+on the standard mechanism of :mod:`ctypes`, it is also possible to set
+the environment variable :envvar:`PYSDL2_DLL_PATH`, which shall point to the
+directory of the SDL2 library.
+
+.. note::
+
+   :envvar:`PYSDL2_DLL_PATH` is preferred over the standard
+   mechanism. That said, if the module finds a SDL2 library in
+   :envvar:`PYSDL2_DLL_PATH`, it will try to use that one in the first
+   place, before using any SDL2 library installed on the target
+   system.
+
+Let's assume, you ship your own library *SDL2.dll* within your project
+location *fancy_project/third_party*. You can set the environment
+variable :envvar:`PYSDL2_DLL_PATH` before starting Python. ::
+
+  # Win32 platforms
+  set PYSDL2_DLL_PATH=C:\path\to\fancy_project\third_party
+
+  # Unix/Posix-alike environments - bourne shells
+  export PYSDL2_DLL_PATH=/path/to/fancy_project/third_party
+
+  # Unix/Posix-alike environments - C shells
+  setenv PYSDL2_DLL_PATH /path/to/fancy_project/third_party
+
+You also can set the environment variable within Python using
+:data:`os.environ`. ::
+
+  os.environ["PYSDL2_DLL_PATH"] = "C:\\path\\to\\fancy_project\\third_party"
+  os.environ["PYSDL2_DLL_PATH"] = "/path/to/fancy_project/third_party"
+
+.. note::
+
+   If you aim to integrate :mod:`sdl` directly into your software and do
+   not want or are not allowed to change the environment variables, you
+   can also change the ``os.getenv("PYSDL2_DLL_PATH")`` query within the
+   *sdl/dll.py* file to point to the directory, in which you keep
+   the DLL.
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Priddle.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Priddle.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+:end
+Release News
+============
+This describes the latest changes between the PySDL2 releases.
+
+0.1.0
+-----
+Released on 2013-XX-XX.
+
+* Initial Release

Binary file added.

+TODOs
+=====
+
+General
+-------
+* proper unit tests
+@SETLOCAL
+@IF "%PYTHON27_X86%" == "" (
+    SET PYTHON27_X86=c:\Python27-x86\python.exe
+)
+@IF "%PYTHON27_X64%" == "" (
+    SET PYTHON27_X64=c:\Python27-x64\python.exe
+)
+@IF "%PYTHON32_X86%" == "" (
+    SET PYTHON32_X86=c:\Python32-x86\python.exe
+)
+@IF "%PYTHON32_X64%" == "" (
+    SET PYTHON32_X64=c:\Python32-x64\python.exe
+)
+@IF "%PYTHON33_X86%" == "" (
+    SET PYTHON33_X86=c:\Python33-x86\python.exe
+)
+@IF "%PYTHON33_X64%" == "" (
+    SET PYTHON33_X64=c:\Python33-x64\python.exe
+)
+@IF "%PYTHON%" == "" (
+    SET PYTHON=%PYTHON27_X64%
+)
+@IF "%PYPY19%" == "" (
+    SET PYPY19=c:\pypy-1.9\pypy.exe
+)
+@IF "%IRONPYTHON27%" == "" (
+    SET IRONPYTHON27=c:\IronPython-2.7.3\ipy.exe
+)
+
+@IF "%1" == "" (
+    GOTO :all
+)
+@GOTO :%1
+
+:all
+@CALL :clean
+@CALL :build
+@GOTO :eof
+
+:dist
+@ECHO Creating dist...
+@CALL :clean
+@CALL :docs
+@%PYTHON% setup.py sdist --format gztar
+@%PYTHON% setup.py sdist --format zip
+@GOTO :eof
+
+:bdist
+@CALL :clean
+@CALL :docs
+@ECHO Creating bdist...
+@%PYTHON27_X86% setup.py bdist --format=msi
+@%PYTHON32_X86% setup.py bdist --format=msi
+@%PYTHON33_X86% setup.py bdist --format=msi
+@%PYTHON27_X64% setup.py bdist --format=msi
+@%PYTHON32_X64% setup.py bdist --format=msi
+@%PYTHON33_X64% setup.py bdist --format=msi
+@GOTO :eof
+
+:build
+@ECHO Running build
+@%PYTHON% setup.py build
+@ECHO Build finished, invoke 'make install' to install.
+@GOTO :eof
+
+:install
+@ECHO Installing...
+@%PYTHON% setup.py install
+@GOTO :eof
+
+:clean
+@RMDIR /S /Q build
+@RMDIR /S /Q dist
+@FOR /d /r . %%d in (__pycache__) do @IF EXIST "%%d" RMDIR /S /Q "%%d"
+@DEL /S /Q MANIFEST
+@DEL /S /Q *.pyc
+@GOTO :eof
+
+:docs
+@IF "%SPHINXBUILD%" == "" (
+   SET SPHINXBUILD=C:\Python27-x64\Scripts\sphinx-build.exe
+)
+@ECHO Creating docs package
+@RMDIR /S /Q doc\html
+@CD doc
+@CALL make html
+@MOVE /Y _build\html html
+@RMDIR /S /Q _build
+@CALL make clean
+@CD ..
+@GOTO :eof
+
+:release
+@CALL :dist
+@GOTO :eof
+
+:runtest
+@%PYTHON% test\util\runtests.py
+@GOTO :eof
+
+@REM Do not run these in production environments. They are for testing purposes
+@REM only!
+
+:buildall
+@CALL :clean
+@%PYTHON27_X86% setup.py build
+@CALL :clean
+@%PYTHON27_X64% setup.py build
+@CALL :clean
+@%PYTHON32_X86% setup.py build
+@CALL :clean
+@%PYTHON32_X64% setup.py build
+@CALL :clean
+@%PYTHON33_X86% setup.py build
+@CALL :clean
+@%PYTHON33_X64% setup.py build
+@CALL :clean
+@%PYPY19% setup.py build
+@CALL :clean
+@%IRONPYTHON27% setup.py build
+@CALL :clean
+@GOTO :eof
+
+:installall
+@CALL :clean
+@%PYTHON27_X86% setup.py install
+@CALL :clean
+@%PYTHON27_X64% setup.py install
+@CALL :clean
+@%PYTHON32_X86% setup.py install
+@CALL :clean
+@%PYTHON32_X64% setup.py install
+@CALL :clean
+@%PYTHON33_X86% setup.py install
+@CALL :clean
+@%PYTHON33_X64% setup.py install
+@CALL :clean
+@%PYPY19% setup.py install
+@CALL :clean
+@%IRONPYTHON27% setup.py install
+@CALL :clean
+@GOTO :eof
+
+:testall
+@FOR /F "tokens=1 delims=" %%A in ('CHDIR') do @SET PYTHONPATH=%%A && @SET IRONPYTHONPATH=%%A
+@%PYTHON27_X86% test\util\runtests.py
+@DEL /Q test\*.pyc
+@%PYTHON27_X64% test\util\runtests.py
+@DEL /Q test\*.pyc
+@%PYTHON32_X86% test\util\runtests.py
+@DEL /Q test\*.pyc
+@RMDIR /S /Q test\__pycache__
+@%PYTHON32_X64% test\util\runtests.py
+@DEL /Q test\*.pyc
+@RMDIR /S /Q test\__pycache__
+@%PYTHON33_X86% test\util\runtests.py
+@DEL /Q test\*.pyc
+@RMDIR /S /Q test\__pycache__
+@%PYTHON33_X64% test\util\runtests.py
+@DEL /Q test\*.pyc
+@RMDIR /S /Q test\__pycache__
+@%PYPY19% test\util\runtests.py
+@DEL /Q test\*.pyc
+@%IRONPYTHON27% test\util\runtests.py
+@DEL /Q test\*.pyc
+@GOTO :eof
+
+:testall2
+@%PYTHON27_X86% -c "import openal.test; openal.test.run ()"
+@%PYTHON27_X64% -c "import openal.test; openal.test.run ()"
+@%PYTHON32_X86% -c "import openal.test; openal.test.run ()"
+@%PYTHON32_X64% -c "import openal.test; openal.test.run ()"
+@%PYTHON33_X86% -c "import openal.test; openal.test.run ()"
+@%PYTHON33_X64% -c "import openal.test; openal.test.run ()"
+@%PYPY19% -c "import openal.test; openal.test.run ()"
+@%IRONPYTHON27% -c "import openal.test; openal.test.run ()"
+@GOTO :eof
+
+:purge_installs
+@echo Deleting data...
+@RMDIR /S /Q C:\Python27-x86\Lib\site-packages\openal
+@RMDIR /S /Q C:\Python27-x64\Lib\site-packages\openal
+@RMDIR /S /Q C:\Python32-x86\Lib\site-packages\openal
+@RMDIR /S /Q C:\Python32-x64\Lib\site-packages\openal
+@RMDIR /S /Q C:\Python33-x86\Lib\site-packages\openal
+@RMDIR /S /Q C:\Python33-x64\Lib\site-packages\openal
+@RMDIR /S /Q C:\pypy-1.9\site-packages\openal
+@RMDIR /S /Q C:\IronPython-2.7.3\Lib\site-packages\openal
+@echo done
+@GOTO :eof
+
+@ENDLOCAL
+"""SDL2 wrapper package"""
+from .dll import get_dll_file, _bind
+from ctypes import c_int
+from .stdinc import Uint32
+
+SDL_INIT_TIMER = 0x00000001
+SDL_INIT_AUDIO = 0x00000010
+SDL_INIT_VIDEO = 0x00000020
+SDL_INIT_JOYSTICK = 0x00000200
+SDL_INIT_HAPTIC = 0x00001000
+SDL_INIT_GAMECONTROLLER = 0x00002000
+SDL_INIT_NOPARACHUTE = 0x00100000
+SDL_INIT_EVERYTHING = 0x0000FFFF
+
+SDL_Init = _bind("SDL_Init", [Uint32], c_int)
+SDL_InitSubSystem = _bind("SDL_InitSubSystem", [Uint32], c_int)
+SDL_QuitSubSystem = _bind("SDL_QuitSubSystem", [Uint32])
+SDL_WasInit = _bind("SDL_WasInit", [Uint32], Uint32)
+SDL_Quit = _bind("SDL_Quit")
+
+__version__ = "0.1.0"
+version_info = (0, 1, 0, "")
+from ctypes import Structure, c_int, c_char_p, c_double, c_void_p, CFUNCTYPE, \
+    POINTER
+from .dll import _bind
+from .endian import SDL_BYTEORDER, SDL_LIL_ENDIAN
+from .stdinc import Uint8, Uint16, Uint32
+from .rwops import SDL_RWops, SDL_RWFromFile
+
+SDL_AudioFormat = Uint16
+
+SDL_AUDIO_MASK_BITSIZE = 0xFF
+SDL_AUDIO_MASK_DATATYPE = 1 << 8
+SDL_AUDIO_MASK_ENDIAN = 1 << 12
+SDL_AUDIO_MASK_SIGNED = 1 << 15
+SDL_AUDIO_BITSIZE = lambda x: (x & SDL_AUDIO_MASK_BITSIZE)
+SDL_AUDIO_ISFLOAT = lambda x: (x & SDL_AUDIO_MASK_DATATYPE)
+SDL_AUDIO_ISBIGENDIAN = lambda x: (x & SDL_AUDIO_MASK_ENDIAN)
+SDL_AUDIO_ISSIGNED = lambda x: (x & SDL_AUDIO_MASK_SIGNED)
+SDL_AUDIO_ISINT = lambda x: (not SDL_AUDIO_ISFLOAT(x))
+SDL_AUDIO_ISLITTLEENDIAN = lambda x: (not SDL_AUDIO_ISBIGENDIAN(x))
+SDL_AUDIO_ISUNSIGNED = lambda x: (not SDL_AUDIO_ISSIGNED(x))
+
+AUDIO_U8 = 0x0008
+AUDIO_S8 = 0x8008
+AUDIO_U16LSB = 0x0010
+AUDIO_S16LSB = 0x8010
+AUDIO_U16MSB = 0x1010
+AUDIO_S16MSB = 0x9010
+AUDIO_U16 = AUDIO_U16LSB
+AUDIO_S16 = AUDIO_S16LSB
+AUDIO_S32LSB = 0x8020
+AUDIO_S32MSB = 0x9020
+AUDIO_S32 = AUDIO_S32LSB
+AUDIO_F32LSB = 0x8120
+AUDIO_F32MSB = 0x9120
+AUDIO_F32 = AUDIO_F32LSB
+
+if SDL_BYTEORDER == SDL_LIL_ENDIAN:
+    AUDIO_U16SYS = AUDIO_U16LSB
+    AUDIO_S16SYS = AUDIO_S16LSB
+    AUDIO_S32SYS = AUDIO_S32LSB
+    AUDIO_F32SYS = AUDIO_F32LSB
+else:
+    AUDIO_U16SYS = AUDIO_U16MSB
+    AUDIO_S16SYS = AUDIO_S16MSB
+    AUDIO_S32SYS = AUDIO_S32MSB
+    AUDIO_F32SYS = AUDIO_F32MSB
+
+SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001
+SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002
+SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004
+SDL_AUDIO_ALLOW_ANY_CHANGE = (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
+                              SDL_AUDIO_ALLOW_FORMAT_CHANGE |
+                              SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
+
+SDL_AudioCallback = CFUNCTYPE(None, c_void_p, POINTER(Uint8), c_int)
+
+class SDL_AudioSpec(Structure):
+    _fields_ = [("freq", c_int),
+                ("format", SDL_AudioFormat),
+                ("channels", Uint8),
+                ("silence", Uint8),
+                ("samples", Uint16),
+                ("padding", Uint16),
+                ("size", Uint32),
+                ("callback", c_void_p),
+                ("userdata", c_void_p)
+                ]
+    def __init__(self, freq, aformat, channels, samples,
+                 callback=SDL_AudioCallback(), userdata=c_void_p(0)):
+        super(SDL_AudioSpec, self).__init__()
+        self.freq = freq
+        self.format = aformat
+        self.channels = channels
+        self.samples = samples
+        self.callback = callback
+        self.userdata = userdata
+
+class SDL_AudioCVT(Structure):
+    pass
+
+SDL_AudioFilter = CFUNCTYPE(POINTER(SDL_AudioCVT), SDL_AudioFormat)
+
+SDL_AudioCVT._fields_ = [("needed", c_int),
+                         ("src_format", SDL_AudioFormat),
+                         ("dst_format", SDL_AudioFormat),
+                         ("rate_incr", c_double),
+                         ("buf", POINTER(Uint8)),
+                         ("len", c_int),
+                         ("len_cvt", c_int),
+                         ("len_mult", c_int),
+                         ("len_ratio", c_double),
+                         ("filters", (SDL_AudioFilter * 10)),
+                         ("filter_index", c_int)
+                         ]
+
+SDL_GetNumAudioDrivers = _bind("SDL_GetNumAudioDrivers", None, c_int)
+SDL_GetAudioDriver = _bind("SDL_GetAudioDriver", [c_int], c_char_p)
+SDL_AudioInit = _bind("SDL_AudioInit", [c_char_p], c_int)
+SDL_AudioQuit = _bind("SDL_AudioQuit")
+SDL_GetCurrentAudioDriver = _bind("SDL_GetCurrentAudioDriver", None, c_char_p)
+SDL_OpenAudio = _bind("SDL_OpenAudio", [POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec)], c_int)
+SDL_AudioDeviceID = Uint32
+SDL_GetNumAudioDevices = _bind("SDL_GetNumAudioDevices", [c_int], c_int)
+SDL_GetAudioDeviceName = _bind("SDL_GetAudioDeviceName", [c_int, c_int], c_char_p)
+SDL_OpenAudioDevice = _bind("SDL_OpenAudioDevice", [c_char_p, c_int, POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec), c_int], SDL_AudioDeviceID)
+SDL_AUDIO_STOPPED = 0
+SDL_AUDIO_PLAYING = 1
+SDL_AUDIO_PAUSED = 2
+SDL_AudioStatus = c_int
+SDL_GetAudioStatus = _bind("SDL_GetAudioStatus", None, SDL_AudioStatus)
+SDL_GetAudioDeviceStatus = _bind("SDL_GetAudioDeviceStatus", [SDL_AudioDeviceID], SDL_AudioStatus)
+SDL_PauseAudio = _bind("SDL_PauseAudio", [c_int])
+SDL_PauseAudioDevice = _bind("SDL_PauseAudioDevice", [SDL_AudioDeviceID, c_int])
+SDL_LoadWAV_RW = _bind("SDL_LoadWAV_RW", [POINTER(SDL_RWops), c_int, POINTER(SDL_AudioSpec), POINTER(POINTER(Uint8)), POINTER(Uint32)], POINTER(SDL_AudioSpec))
+SDL_LoadWAV = lambda f, s, ab, al: SDL_LoadWAV_RW(SDL_RWFromFile(f, "rb"), 1, s, ab , al)
+SDL_FreeWAV = _bind("SDL_FreeWAV", [POINTER(Uint8)])
+SDL_BuildAudioCVT = _bind("SDL_BuildAudioCVT", [POINTER(SDL_AudioCVT), SDL_AudioFormat, Uint8, c_int, SDL_AudioFormat, Uint8, c_int], c_int)
+SDL_ConvertAudio = _bind("SDL_ConvertAudio", [POINTER(SDL_AudioCVT)], c_int)
+SDL_MIX_MAXVOLUME = 128
+SDL_MixAudio = _bind("SDL_MixAudio", [POINTER(Uint8), POINTER(Uint8), Uint32, c_int])
+SDL_MixAudioFormat = _bind("SDL_MixAudioFormat", [POINTER(Uint8), POINTER(Uint8), SDL_AudioFormat, Uint32, c_int])
+SDL_LockAudio = _bind("SDL_LockAudio")
+SDL_LockAudioDevice = _bind("SDL_LockAudioDevice", [SDL_AudioDeviceID])
+SDL_UnlockAudio = _bind("SDL_UnlockAudio")
+SDL_UnlockAudioDevice = _bind("SDL_UnlockAudioDevice", [SDL_AudioDeviceID])
+SDL_CloseAudio = _bind("SDL_CloseAudio")
+SDL_CloseAudioDevice = _bind("SDL_CloseAudioDevice", [SDL_AudioDeviceID])
+# SDL_AudioDeviceConnected = _bind("SDL_AudioDeviceConnected", [SDL_AudioDeviceID])

sdl2/blendmode.py

+from ctypes import c_int
+
+SDL_BLENDMODE_NONE = 0x00000000
+SDL_BLENDMODE_BLEND = 0x00000001
+SDL_BLENDMODE_ADD = 0x00000002
+SDL_BLENDMODE_MOD = 0x00000004
+SDL_BlendMode = c_int

sdl2/clipboard.py

+from ctypes import c_char_p, c_int
+from .dll import _bind
+from .stdinc import SDL_bool
+
+SDL_SetClipboardText = _bind("SDL_SetClipboardText", [c_char_p], c_int)
+SDL_GetClipboardText = _bind("SDL_GetClipboardText", None, c_char_p)
+SDL_HasClipboardText = _bind("SDL_HasClipboardText", None, SDL_bool)
+from ctypes import c_int
+from .dll import _bind
+from .stdinc import SDL_bool
+
+SDL_CACHELINE_SIZE = 128
+SDL_GetCPUCount = _bind("SDL_GetCPUCount", None, c_int)
+SDL_GetCPUCacheLineSize = _bind("SDL_GetCPUCacheLineSize", None, c_int)
+SDL_HasRDTSC = _bind("SDL_HasRDTSC", None, SDL_bool)
+SDL_HasAltiVec = _bind("SDL_HasAltiVec", None, SDL_bool)
+SDL_HasMMX = _bind("SDL_HasMMX", None, SDL_bool)
+SDL_Has3DNow = _bind("SDL_Has3DNow", None, SDL_bool)
+SDL_HasSSE = _bind("SDL_HasSSE", None, SDL_bool)
+SDL_HasSSE2 = _bind("SDL_HasSSE2", None, SDL_bool)
+SDL_HasSSE3 = _bind("SDL_HasSSE3", None, SDL_bool)
+SDL_HasSSE41 = _bind("SDL_HasSSE41", None, SDL_bool)
+SDL_HasSSE42 = _bind("SDL_HasSSE42", None, SDL_bool)
+"""DLL wrapper"""
+import os
+import sys
+import warnings
+from ctypes import CDLL
+from ctypes.util import find_library
+
+__all__ = ["get_dll_file"]
+
+def _findlib(libnames, path=None):
+    """."""
+    platform = sys.platform
+    if platform in ("win32", "cli"):
+        suffix = ".dll"
+    elif platform == "darwin":
+        suffix = ".dylib"
+    else:
+        suffix = ".so"
+
+    searchfor = libnames
+    if type(libnames) is dict:
+        # different library names for the platforms
+        if platform == "cli" and platform not in libnames:
+            # if not explicitly specified, use the Win32 libs for IronPython
+            platform = "win32"
+        if platform not in libnames:
+            platform = "DEFAULT"
+        searchfor = libnames[platform]
+    results = []
+    if path:
+        for libname in searchfor:
+            dllfile = os.path.join(path, "%s%s" % (libname, suffix))
+            if os.path.exists(dllfile):
+                results.append(dllfile)
+    for libname in searchfor:
+        dllfile = find_library(libname)
+        if dllfile:
+            results.append(dllfile)
+    return results
+
+
+class _DLL(object):
+    """Function wrapper around the different DLL functions. Do not use or
+    instantiate this one directly from your user code.
+    """
+    def __init__(self, libinfo, libnames, path=None):
+        self._dll = None
+        foundlibs = _findlib(libnames, path)
+        if len(foundlibs) == 0:
+            raise RuntimeError("could not find any library for %s" % libinfo)
+        for libfile in foundlibs:
+            try:
+                self._dll = CDLL(libfile)
+                self._libfile = libfile
+                break
+            except Exception as exc:
+                # Could not load it, silently ignore that issue and move
+                # to the next one.
+                warnings.warn(exc, ImportWarning)
+        if self._dll is None:
+            raise RuntimeError("could not load any library for %s" % libinfo)
+
+    def bind_function(self, funcname, args=None, returns=None, optfunc=None):
+        """Binds the passed argument and return value types to the specified
+        function."""
+        func = getattr(self._dll, funcname, None)
+        if not func:
+            func = optfunc
+        func.argtypes = args
+        func.restype = returns
+        return func
+
+    @property
+    def libfile(self):
+        """Gets the filename of the loaded library."""
+        return self._libfile
+
+
+dll = _DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
+
+def get_dll_file():
+    """Gets the file name of the loaded SDL2 library."""
+    return dll.libfile
+
+_bind = dll.bind_function
+import sys
+import array
+
+SDL_LIL_ENDIAN = 1234
+SDL_BIG_ENDIAN = 4321
+if sys.byteorder == "little":
+    SDL_BYTEORDER = SDL_LIL_ENDIAN
+else:
+    SDL_BYTEORDER = SDL_BIG_ENDIAN
+
+SDL_Swap16 = lambda x: ((x << 8 & 0xFF00) | (x >> 8 & 0x00FF))
+SDL_Swap32 = lambda x: (((x << 24) & 0xFF000000) |
+                        ((x << 8) & 0x00FF0000) |
+                        ((x >> 8) & 0x0000FF00) |
+                        ((x >> 24) & 0x000000FF))
+SDL_Swap64 = lambda x: ((SDL_Swap32(x & 0xFFFFFFFF) << 32) |
+                        (SDL_Swap32(x >> 32 & 0xFFFFFFFF)))
+def SDL_SwapFloat(x):
+    ar = array.array("d", (x,))
+    ar.byteswap()
+    return ar[0]
+
+def _nop(x):
+    return x
+if SDL_BYTEORDER == SDL_LIL_ENDIAN:
+    SDL_SwapLE16 = _nop
+    SDL_SwapLE32 = _nop
+    SDL_SwapLE64 = _nop
+    SDL_SwapFloatLE = _nop
+    SDL_SwapBE16 = SDL_Swap16
+    SDL_SwapBE32 = SDL_Swap32
+    SDL_SwapBE64 = SDL_Swap64
+    SDL_SwapFloatBE = SDL_SwapFloat
+else:
+    SDL_SwapLE16 = SDL_Swap16
+    SDL_SwapLE32 = SDL_Swap32
+    SDL_SwapLE64 = SDL_Swap64
+    SDL_SwapFloatLE = SDL_SwapFloat
+    SDL_SwapBE16 = _nop
+    SDL_SwapBE32 = _nop
+    SDL_SwapBE64 = _nop
+    SDL_SwapFloatBE = _nop
+from ctypes import c_char_p, c_int
+from .dll import _bind
+
+SDL_SetError = _bind("SDL_SetError", [c_char_p], c_int)
+SDL_GetError = _bind("SDL_GetError", None, c_char_p)
+SDL_ClearError = _bind("SDL_ClearError")
+
+SDL_ENOMEM = 0
+SDL_EFREAD = 1
+SDL_EFWRITE = 2
+SDL_EFSEEK = 3
+SDL_UNSUPPORTED = 4
+SDL_LASTERROR = 5
+SDL_errorcode = c_int
+SDL_Error = _bind("SDL_Error", [c_int], c_int)
+SDL_OutOfMemory = SDL_Error(SDL_ENOMEM)
+SDL_Unsupported = SDL_Error(SDL_UNSUPPORTED)
+SDL_InvalidParamError = lambda x: SDL_SetError("Parameter '%s' is invalid" % (x))
+from ctypes import c_char, c_char_p, c_float, c_void_p, c_int, Structure, \
+    Union, CFUNCTYPE, POINTER
+from .dll import _bind
+from .stdinc import Sint16, Sint32, Uint8, Uint16, Uint32, SDL_bool
+from .keyboard import SDL_Keysym
+from .joystick import SDL_JoystickID
+from .touch import SDL_FingerID, SDL_TouchID
+from .gesture import SDL_GestureID
+
+SDL_FIRSTEVENT = 0
+SDL_QUIT = 0x100
+SDL_WINDOWEVENT = 0x200
+SDL_SYSWMEVENT = 0x201
+SDL_KEYDOWN = 0x300
+SDL_KEYUP = 0x301
+SDL_TEXTEDITING = 0x302
+SDL_TEXTINPUT = 0x303
+SDL_MOUSEMOTION = 0x400
+SDL_MOUSEBUTTONDOWN = 0x401
+SDL_MOUSEBUTTONUP = 0x402
+SDL_MOUSEWHEEL = 0x403
+SDL_JOYAXISMOTION = 0x600
+SDL_JOYBALLMOTION = 0x601
+SDL_JOYHATMOTION = 0x602
+SDL_JOYBUTTONDOWN = 0x603
+SDL_JOYBUTTONUP = 0x604
+SDL_JOYDEVICEADDED = 0x605
+SDL_JOYDEVICEREMOVED = 0x606
+SDL_CONTROLLERAXISMOTION = 0x650
+SDL_CONTROLLERBUTTONDOWN = 0x651
+SDL_CONTROLLERBUTTONUP = 0x652
+SDL_CONTROLLERDEVICEADDED = 0x653
+SDL_CONTROLLERDEVICEREMOVED = 0x654
+SDL_CONTROLLERDEVICEREMAPPED = 0x655
+SDL_FINGERDOWN = 0x700
+SDL_FINGERUP = 0x701
+SDL_FINGERMOTION = 0x702
+SDL_DOLLARGESTURE = 0x800
+SDL_DOLLARRECORD = 0x801
+SDL_MULTIGESTURE = 0x802
+SDL_CLIPBOARDUPDATE = 0x900
+SDL_DROPFILE = 0x1000
+SDL_USEREVENT = 0x8000
+SDL_LASTEVENT = 0xFFFF
+SDL_EventType = c_int
+
+class SDL_GenericEvent(Structure):
+    _fields_ = [("type", Uint32), ("timestamp", Uint32)]
+
+class SDL_WindowEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("event", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("data1", Sint32),
+                ("data2", Sint32)
+                ]
+
+class SDL_KeyboardEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("state", Uint8),
+                ("repeat", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("keysym", SDL_Keysym)
+                ]
+
+SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
+
+class SDL_TextEditingEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("text", (c_char * SDL_TEXTEDITINGEVENT_TEXT_SIZE)),
+                ("start", Sint32),
+                ("length", Sint32)
+                ]
+
+SDL_TEXTINPUTEVENT_TEXT_SIZE = 32
+class SDL_TextInputEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("text", (c_char * SDL_TEXTINPUTEVENT_TEXT_SIZE))
+                ]
+
+class SDL_MouseMotionEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("which", Uint32),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("x", Sint32),
+                ("y", Sint32),
+                ("xrel", Sint32),
+                ("yrel", Sint32)
+                ]
+
+class SDL_MouseButtonEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("which", Uint32),
+                ("button", Uint8),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("x", Sint32),
+                ("y", Sint32)
+                ]
+
+class SDL_MouseWheelEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("which", Uint32),
+                ("x", Sint32),
+                ("y", Sint32)
+                ]
+
+class SDL_JoyAxisEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("axis", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("value", Sint16),
+                ("padding4", Uint16)
+                ]
+
+class SDL_JoyBallEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("ball", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("xrel", Sint16),
+                ("yrel", Sint16)
+                ]
+
+class SDL_JoyHatEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("hat", Uint8),
+                ("value", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8)
+                ]
+
+class SDL_JoyButtonEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("button", Uint8),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8)
+                ]
+
+class SDL_JoyDeviceEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", Sint32)
+                ]
+
+class SDL_ControllerAxisEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("axis", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("value", Sint16),
+                ("padding4", Uint16)
+                ]
+
+class SDL_ControllerButtonEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("button", Uint8),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8)
+                ]
+
+class SDL_ControllerDeviceEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", Sint32)
+                ]
+
+class SDL_TouchFingerEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("touchId", SDL_TouchID),
+                ("fingerId", SDL_FingerID),
+                ("x", c_float),
+                ("y", c_float),
+                ("dx", c_float),
+                ("dy", c_float),
+                ("pressure", c_float)
+                ]
+
+class SDL_MultiGestureEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("touchId", SDL_TouchID),
+                ("dTheta", c_float),
+                ("dDist", c_float),
+                ("x", c_float),
+                ("y", c_float),
+                ("numFingers", Uint16),
+                ("padding", Uint16)
+                ]
+
+class SDL_DollarGestureEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("touchId", SDL_TouchID),
+                ("gestureId", SDL_GestureID),
+                ("numFingers", Uint32),
+                ("error", c_float),
+                ("x", c_float),
+                ("y", c_float)
+                ]
+
+class SDL_DropEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("file", c_char_p)
+                ]
+
+class SDL_QuitEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32)
+                ]
+
+class SDL_UserEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("code", Sint32),
+                ("data1", c_void_p),
+                ("data2", c_void_p)
+                ]
+
+# TODO
+class SDL_SysWMmsg(Structure):
+    pass
+
+class SDL_SysWMEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("msg", POINTER(SDL_SysWMmsg))
+                ]
+
+class SDL_Event(Union):
+    _fields_ = [("type", Uint32),
+                ("generic", SDL_GenericEvent),
+                ("window", SDL_WindowEvent),
+                ("key", SDL_KeyboardEvent),
+                ("edit", SDL_TextEditingEvent),
+                ("text", SDL_TextInputEvent),
+                ("motion", SDL_MouseMotionEvent),
+                ("button", SDL_MouseButtonEvent),
+                ("wheel", SDL_MouseWheelEvent),
+                ("jaxis", SDL_JoyAxisEvent),
+                ("jball", SDL_JoyBallEvent),
+                ("jhat", SDL_JoyHatEvent),
+                ("jbutton", SDL_JoyButtonEvent),
+                ("jdevice", SDL_JoyDeviceEvent),
+                ("caxis", SDL_ControllerAxisEvent),
+                ("cbutton", SDL_ControllerButtonEvent),
+                ("cdevice", SDL_ControllerDeviceEvent),
+                ("quit", SDL_QuitEvent),
+                ("user", SDL_UserEvent),
+                ("syswm", SDL_SysWMEvent),
+                ("tfinger", SDL_TouchFingerEvent),
+                ("mgesture", SDL_MultiGestureEvent),
+                ("dgesture", SDL_DollarGestureEvent),
+                ("drop", SDL_DropEvent),
+                ("padding", (Uint8 * 56)),
+                ]
+
+SDL_PumpEvents = _bind("SDL_PumpEvents")
+SDL_ADDEVENT = 0
+SDL_PEEKEVENT = 1
+SDL_GETEVENT = 2
+SDL_eventaction = c_int
+SDL_PeepEvents = _bind("SDL_PeepEvents", [POINTER(SDL_Event), c_int, SDL_eventaction, Uint32, Uint32], c_int)
+SDL_HasEvent = _bind("SDL_HasEvent", [Uint32], SDL_bool)
+SDL_HasEvents = _bind("SDL_HasEvents", [Uint32, Uint32], SDL_bool)
+SDL_FlushEvent = _bind("SDL_FlushEvent", [Uint32])
+SDL_FlushEvents = _bind("SDL_FlushEvents", [Uint32, Uint32])
+SDL_PollEvent = _bind("SDL_PollEvent", [POINTER(SDL_Event)], c_int)
+SDL_WaitEvent = _bind("SDL_WaitEvent", [POINTER(SDL_Event)], c_int)
+SDL_WaitEventTimeout = _bind("SDL_WaitEventTimeout", [POINTER(SDL_Event), c_int], c_int)
+SDL_PushEvent = _bind("SDL_PushEvent", [POINTER(SDL_Event)], c_int)
+SDL_EventFilter = CFUNCTYPE(c_int, c_void_p, POINTER(SDL_Event))
+SDL_SetEventFilter = _bind("SDL_SetEventFilter", [SDL_EventFilter, c_void_p])
+SDL_GetEventFilter = _bind("SDL_GetEventFilter", [POINTER(SDL_EventFilter), POINTER(c_void_p)], SDL_bool)
+SDL_AddEventWatch = _bind("SDL_AddEventWatch", [SDL_EventFilter, c_void_p])
+SDL_DelEventWatch = _bind("SDL_DelEventWatch", [SDL_EventFilter, c_void_p])
+SDL_FilterEvents = _bind("SDL_FilterEvents", [SDL_EventFilter, c_void_p])
+SDL_QUERY = -1
+SDL_IGNORE = 0
+SDL_DISABLE = 0
+SDL_ENABLE = 1
+SDL_EventState = _bind("SDL_EventState", [Uint32, c_int], Uint8)
+SDL_GetEventState = lambda t: SDL_EventState(t, SDL_QUERY)
+SDL_RegisterEvents = _bind("SDL_RegisterEvents", [c_int], Uint32)
+
+
+# SDL_quit.h
+def SDL_QuitRequested():
+    SDL_PumpEvents()
+    return SDL_PeepEvents(None, 0, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT) > 0

sdl2/gamecontroller.py

+from ctypes import Structure, Union, c_int, c_char_p, POINTER
+from .dll import _bind
+from .stdinc import SDL_bool, Sint16, Uint8
+from .joystick import SDL_JoystickGUID, SDL_Joystick
+
+class SDL_GameController(Structure):
+    pass
+
+SDL_CONTROLLER_BINDTYPE_NONE = 0
+SDL_CONTROLLER_BINDTYPE_BUTTON = 1
+SDL_CONTROLLER_BINDTYPE_AXIS = 2
+SDL_CONTROLLER_BINDTYPE_HAT = 3
+SDL_GameControllerBindType = c_int
+
+class _gchat(Structure):
+    _fields_ = [("hat", c_int), ("hat_mask", c_int)]
+
+class _gcvalue(Union):
+    _fields_ = [("button", c_int), ("axis", c_int), ("hat", _gchat)]
+
+class SDL_GameControllerButtonBind(Structure):
+    _fields_ = [("bindType", SDL_GameControllerBindType), ("value", _gcvalue)]
+
+SDL_GameControllerAddMapping = _bind("SDL_GameControllerAddMapping", [c_char_p], c_int)
+SDL_GameControllerMappingForGUID = _bind("SDL_GameControllerMappingForGUID", [SDL_JoystickGUID], c_char_p)
+SDL_GameControllerMapping = _bind("SDL_GameControllerMapping", [POINTER(SDL_GameController)], c_char_p)
+SDL_IsGameController = _bind("SDL_IsGameController", [c_int], SDL_bool)
+SDL_GameControllerNameForIndex = _bind("SDL_GameControllerNameForIndex", [c_int], c_char_p)
+SDL_GameControllerOpen = _bind("SDL_GameControllerOpen", [c_int], POINTER(SDL_GameController))
+SDL_GameControllerName = _bind("SDL_GameControllerName", [POINTER(SDL_GameController)], c_char_p)
+SDL_GameControllerGetAttached = _bind("SDL_GameControllerGetAttached", [POINTER(SDL_GameController)], SDL_bool)
+SDL_GameControllerGetJoystick = _bind("SDL_GameControllerGetJoystick", [POINTER(SDL_GameController)], POINTER(SDL_Joystick))
+SDL_GameControllerEventState = _bind("SDL_GameControllerEventState", [c_int], c_int)
+SDL_GameControllerUpdate = _bind("SDL_GameControllerUpdate")
+SDL_CONTROLLER_AXIS_INVALID = -1
+SDL_CONTROLLER_AXIS_LEFTX = 0
+SDL_CONTROLLER_AXIS_LEFTY = 1
+SDL_CONTROLLER_AXIS_RIGHTX = 2
+SDL_CONTROLLER_AXIS_RIGHTY = 3
+SDL_CONTROLLER_AXIS_TRIGGERLEFT = 4
+SDL_CONTROLLER_AXIS_TRIGGERRIGHT = 5
+SDL_CONTROLLER_AXIS_MAX = 6
+SDL_GameControllerAxis = c_int
+SDL_GameControllerGetAxisFromString = _bind("SDL_GameControllerGetAxisFromString", [c_char_p], SDL_GameControllerAxis)
+SDL_GameControllerGetStringForAxis = _bind("SDL_GameControllerGetStringForAxis", [SDL_GameControllerAxis], c_char_p)
+SDL_GameControllerGetBindForAxis = _bind("SDL_GameControllerGetBindForAxis", [POINTER(SDL_GameController), SDL_GameControllerAxis], SDL_GameControllerButtonBind)
+SDL_GameControllerGetAxis = _bind("SDL_GameControllerGetAxis", [POINTER(SDL_GameController), SDL_GameControllerAxis], Sint16)
+SDL_CONTROLLER_BUTTON_INVALID = -1
+SDL_CONTROLLER_BUTTON_A = 0
+SDL_CONTROLLER_BUTTON_B = 1
+SDL_CONTROLLER_BUTTON_X = 2
+SDL_CONTROLLER_BUTTON_Y = 3
+SDL_CONTROLLER_BUTTON_BACK = 4
+SDL_CONTROLLER_BUTTON_GUIDE = 5
+SDL_CONTROLLER_BUTTON_START = 6
+SDL_CONTROLLER_BUTTON_LEFTSTICK = 7
+SDL_CONTROLLER_BUTTON_RIGHTSTICK = 8
+SDL_CONTROLLER_BUTTON_LEFTSHOULDER = 9
+SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = 10
+SDL_CONTROLLER_BUTTON_DPAD_UP = 11
+SDL_CONTROLLER_BUTTON_DPAD_DOWN = 12
+SDL_CONTROLLER_BUTTON_DPAD_LEFT = 13
+SDL_CONTROLLER_BUTTON_DPAD_RIGHT = 14
+SDL_CONTROLLER_BUTTON_MAX = 15
+SDL_GameControllerButton = c_int
+SDL_GameControllerGetButtonFromString = _bind("SDL_GameControllerGetButtonFromString", [c_char_p], SDL_GameControllerButton)
+SDL_GameControllerGetStringForButton = _bind("SDL_GameControllerGetStringForButton", [SDL_GameControllerButton], c_char_p)
+SDL_GameControllerGetBindForButton = _bind("SDL_GameControllerGetBindForButton", [POINTER(SDL_GameController), SDL_GameControllerButton], SDL_GameControllerButtonBind)
+SDL_GameControllerGetButton = _bind("SDL_GameControllerGetButton", [POINTER(SDL_GameController), SDL_GameControllerButton], Uint8)
+SDL_GameControllerClose = _bind("SDL_GameControllerClose", [POINTER(SDL_GameController)])
+from ctypes import c_int, POINTER
+from .dll import _bind
+from .stdinc import Sint64
+from .touch import SDL_TouchID
+from .rwops import SDL_RWops
+
+SDL_GestureID = Sint64
+SDL_RecordGesture = _bind("SDL_RecordGesture", [SDL_TouchID], c_int)
+SDL_SaveAllDollarTemplates = _bind("SDL_SaveAllDollarTemplates", [POINTER(SDL_RWops)], c_int)
+SDL_SaveDollarTemplate = _bind("SDL_SaveDollarTemplate", [SDL_GestureID, POINTER(SDL_RWops)], c_int)
+SDL_LoadDollarTemplates = _bind("SDL_LoadDollarTemplates", [SDL_TouchID, POINTER(SDL_RWops)], c_int)
+from ctypes import Structure, Union, POINTER, c_int, c_uint, c_float, c_char_p
+from .dll import _bind
+from .stdinc import Uint8, Uint16, Uint32, Sint16, Sint32
+from .joystick import SDL_Joystick
+
+class SDL_Haptic(Structure):
+    pass
+
+SDL_HAPTIC_CONSTANT = 1 << 0
+SDL_HAPTIC_SINE = 1 << 1
+SDL_HAPTIC_SQUARE = 1 << 2
+SDL_HAPTIC_TRIANGLE = 1 << 3
+SDL_HAPTIC_SAWTOOTHUP = 1 << 4
+SDL_HAPTIC_SAWTOOTHDOWN = 1 << 5
+SDL_HAPTIC_RAMP = 1 << 6
+SDL_HAPTIC_SPRING = 1 << 7
+SDL_HAPTIC_DAMPER = 1 << 8
+SDL_HAPTIC_INERTIA = 1 << 9
+SDL_HAPTIC_FRICTION = 1 << 10
+SDL_HAPTIC_CUSTOM = 1 << 11
+SDL_HAPTIC_GAIN = 1 << 12
+SDL_HAPTIC_AUTOCENTER = 1 << 13
+SDL_HAPTIC_STATUS = 1 << 14
+SDL_HAPTIC_PAUSE = 1 << 15
+SDL_HAPTIC_POLAR = 0
+SDL_HAPTIC_CARTESIAN = 1
+SDL_HAPTIC_SPHERICAL = 2
+SDL_HAPTIC_INFINITY = 4294967295L
+
+class SDL_HapticDirection(Structure):
+    _fields_ = [("type", Uint8), ("dir", (Sint32 * 3))]
+
+class SDL_HapticConstant(Structure):
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("level", Sint16),
+                ("attack_length", Uint16),
+                ("attack_level", Uint16),
+                ("fade_length", Uint16),
+                ("fade_level", Uint16),
+                ]
+
+
+class SDL_HapticPeriodic(Structure):
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("period", Uint16),
+                ("magnitude", Sint16),
+                ("offset", Sint16),
+                ("phase", Uint16),
+                ("attack_length", Uint16),
+                ("attack_level", Uint16),
+                ("fade_length", Uint16),
+                ("fade_level", Uint16),
+                ]
+
+
+class SDL_HapticCondition(Structure):
+    """A conditionally running effect."""
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("right_sat", (Uint16 * 3)),
+                ("left_sat", (Uint16 * 3)),
+                ("right_coeff", (Sint16 * 3)),
+                ("left_coeff", (Sint16 * 3)),
+                ("deadband", (Uint16 * 3)),
+                ("center", (Sint16 * 3)),
+                ]
+
+
+class SDL_HapticRamp(Structure):
+    """A ramp-like effect."""
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("start", Sint16),
+                ("end", Sint16),
+                ("attack_length", Uint16),
+                ("attack_level", Uint16),
+                ("fade_length", Uint16),
+                ("fade_level", Uint16),
+                ]
+
+
+class SDL_HapticCustom(Structure):
+    """A custom effect."""
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("channels", Uint8),
+                ("period", Uint16),
+                ("samples", Uint16),
+                ("data", POINTER(Uint16)),
+                ("attack_length", Uint16),
+                ("attack_level", Uint16),
+                ("fade_length", Uint16),
+                ("fade_level", Uint16),
+                ]
+
+
+class SDL_HapticEffect(Union):
+    """A generic haptic effect, containing the concrete haptic effect."""
+    _fields_ = [("type", Uint16),
+                ("constant", SDL_HapticConstant),
+                ("periodic", SDL_HapticPeriodic),
+                ("condition", SDL_HapticCondition),
+                ("ramp", SDL_HapticRamp),
+                ("custom", SDL_HapticCustom),
+                ]
+
+SDL_NumHaptics = _bind("SDL_NumHaptics", None, c_int)
+SDL_HapticName = _bind("SDL_HapticName", [c_int], c_char_p)
+SDL_HapticOpen = _bind("SDL_HapticOpen", [c_int], POINTER(SDL_Haptic))
+SDL_HapticOpened = _bind("SDL_HapticOpened", [c_int], c_int)
+SDL_HapticIndex = _bind("SDL_HapticIndex", [POINTER(SDL_Haptic)], c_int)
+SDL_MouseIsHaptic = _bind("SDL_MouseIsHaptic", None, c_int)
+SDL_HapticOpenFromMouse = _bind("SDL_HapticOpenFromMouse", None, POINTER(SDL_Haptic))
+SDL_JoystickIsHaptic = _bind("SDL_JoystickIsHaptic", [POINTER(SDL_Joystick)], c_int)
+SDL_HapticOpenFromJoystick = _bind("SDL_HapticOpenFromJoystick", [POINTER(SDL_Joystick)], POINTER(SDL_Haptic))
+SDL_HapticClose = _bind("SDL_HapticClose", [POINTER(SDL_Haptic)])
+SDL_HapticNumEffects = _bind("SDL_HapticNumEffects", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticNumEffectsPlaying = _bind("SDL_HapticNumEffectsPlaying", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticQuery = _bind("SDL_HapticQuery", [POINTER(SDL_Haptic)], c_uint)
+SDL_HapticNumAxes = _bind("SDL_HapticNumAxes", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticEffectSupported = _bind("SDL_HapticEffectSupported", [POINTER(SDL_Haptic), POINTER(SDL_HapticEffect)], c_int)
+SDL_HapticNewEffect = _bind("SDL_HapticNewEffect", [POINTER(SDL_Haptic), POINTER(SDL_HapticEffect)], c_int)
+SDL_HapticUpdateEffect = _bind("SDL_HapticUpdateEffect", [POINTER(SDL_Haptic), c_int, POINTER(SDL_HapticEffect)], c_int)
+SDL_HapticRunEffect = _bind("SDL_HapticRunEffect", [POINTER(SDL_Haptic), c_int, Uint32], c_int)
+SDL_HapticStopEffect = _bind("SDL_HapticStopEffect", [POINTER(SDL_Haptic), c_int], c_int)
+SDL_HapticDestroyEffect = _bind("SDL_HapticDestroyEffect", [POINTER(SDL_Haptic), c_int])
+SDL_HapticGetEffectStatus = _bind("SDL_HapticGetEffectStatus", [POINTER(SDL_Haptic), c_int], c_int)
+SDL_HapticSetGain = _bind("SDL_HapticSetGain", [POINTER(SDL_Haptic), c_int], c_int)
+SDL_HapticSetAutocenter = _bind("SDL_HapticSetAutocenter", [POINTER(SDL_Haptic), c_int], c_int)
+SDL_HapticPause = _bind("SDL_HapticPause", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticUnpause = _bind("SDL_HapticUnpause", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticStopAll = _bind("SDL_HapticStopAll", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticRumbleSupported = _bind("SDL_HapticRumbleSupported", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticRumbleInit = _bind("SDL_HapticRumbleInit", [POINTER(SDL_Haptic)], c_int)
+SDL_HapticRumblePlay = _bind("SDL_HapticRumblePlay", [POINTER(SDL_Haptic), c_float, Uint32], c_int)
+SDL_HapticRumbleStop = _bind("SDL_HapticRumbleStop", [POINTER(SDL_Haptic)], c_int)
+
+from ctypes import c_int, c_char_p
+from .dll import _bind
+from .stdinc import SDL_bool
+
+SDL_HINT_FRAMEBUFFER_ACCELERATION = b"SDL_FRAMEBUFFER_ACCELERATION"
+SDL_HINT_RENDER_DRIVER = b"SDL_RENDER_DRIVER"
+SDL_HINT_RENDER_OPENGL_SHADERS = b"SDL_RENDER_OPENGL_SHADERS"
+SDL_HINT_RENDER_SCALE_QUALITY = b"SDL_RENDER_SCALE_QUALITY"
+SDL_HINT_RENDER_VSYNC = b"SDL_RENDER_VSYNC"
+SDL_HINT_VIDEO_X11_XVIDMODE = b"SDL_VIDEO_X11_XVIDMODE"
+SDL_HINT_VIDEO_X11_XINERAMA = b"SDL_VIDEO_X11_XINERAMA"
+SDL_HINT_VIDEO_X11_XRANDR = b"SDL_VIDEO_X11_XRANDR"
+SDL_HINT_GRAB_KEYBOARD = b"SDL_GRAB_KEYBOARD"
+SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS = b"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
+SDL_HINT_IDLE_TIMER_DISABLED = b"SDL_IOS_IDLE_TIMER_DISABLED"
+SDL_HINT_ORIENTATIONS = b"SDL_IOS_ORIENTATIONS"
+SD_HINT_XINPUT_ENABLED = b"SDL_XINPUT_ENABLED"
+SDL_HINT_GAMECONTROLLERCONFIG = b"SDL_GAMECONTROLLERCONFIG"
+SDL_HINT_ALLOW_TOPMOST = b"SDL_ALLOW_TOPMOST"
+SDL_HINT_DEFAULT = 0
+SDL_HINT_NORMAL = 1
+SDL_HINT_OVERRIDE = 2
+SDL_HintPriority = c_int
+SDL_SetHintWithPriority = _bind("SDL_SetHintWithPriority", [c_char_p, c_char_p, SDL_HintPriority], SDL_bool)
+SDL_SetHint = _bind("SDL_SetHint", [c_char_p, c_char_p], SDL_bool)
+SDL_GetHint = _bind("SDL_GetHint", [c_char_p], c_char_p)
+SDL_ClearHints = _bind("SDL_ClearHints")
+from ctypes import Structure, c_int, c_char_p, POINTER
+from .dll import _bind
+from .stdinc import Sint16, Sint32, Uint8, SDL_bool
+
+class SDL_Joystick(Structure):
+    pass
+
+class SDL_JoystickGUID(Structure):
+    _fields_ = [("data", (Uint8 * 16))]
+
+SDL_JoystickID = Sint32
+
+SDL_NumJoysticks = _bind("SDL_NumJoysticks", None, c_int)
+SDL_JoystickNameForIndex = _bind("SDL_JoystickNameForIndex", [c_int], c_char_p)
+SDL_JoystickOpen = _bind("SDL_JoystickOpen", [c_int], POINTER(SDL_Joystick))
+SDL_JoystickName = _bind("SDL_JoystickName", [POINTER(SDL_Joystick)], c_char_p)
+SDL_JoystickGetDeviceGUID = _bind("SDL_JoystickGetDeviceGUID", [c_int], SDL_JoystickGUID)
+SDL_JoystickGetGUID = _bind("SDL_JoystickGetGUID", [POINTER(SDL_Joystick)], SDL_JoystickGUID)
+SDL_JoystickGetGUIDString = _bind("SDL_JoystickGetGUIDString", [SDL_JoystickGUID, c_char_p, c_int])
+SDL_JoystickGetGUIDFromString = _bind("SDL_JoystickGetGUIDFromString", [c_char_p], SDL_JoystickGUID)
+SDL_JoystickGetAttached = _bind("SDL_JoystickGetAttached", [POINTER(SDL_Joystick)], SDL_bool)
+SDL_JoystickInstanceID = _bind("SDL_JoystickInstanceID", [POINTER(SDL_Joystick)], SDL_JoystickID)
+SDL_JoystickNumAxes = _bind("SDL_JoystickNumAxes", [POINTER(SDL_Joystick)], c_int)
+SDL_JoystickNumBalls = _bind("SDL_JoystickNumBalls", [POINTER(SDL_Joystick)], c_int)
+SDL_JoystickNumHats = _bind("SDL_JoystickNumHats", [POINTER(SDL_Joystick)], c_int)
+SDL_JoystickNumButtons = _bind("SDL_JoystickNumButtons", [POINTER(SDL_Joystick)], c_int)
+SDL_JoystickUpdate = _bind("SDL_JoystickUpdate")
+SDL_JoystickEventState = _bind("SDL_JoystickEventState", [c_int], c_int)
+SDL_JoystickGetAxis = _bind("SDL_JoystickGetAxis", [POINTER(SDL_Joystick), c_int], Sint16)
+SDL_HAT_CENTERED = 0x00
+SDL_HAT_UP = 0x01
+SDL_HAT_RIGHT = 0x02
+SDL_HAT_DOWN = 0x04
+SDL_HAT_LEFT = 0x08
+SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP
+SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN
+SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP
+SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN
+SDL_JoystickGetHat = _bind("SDL_JoystickGetHat", [POINTER(SDL_Joystick), c_int], Uint8)
+SDL_JoystickGetBall = _bind("SDL_JoystickGetBall", [POINTER(SDL_Joystick), c_int, POINTER(c_int), POINTER(c_int)], c_int)
+SDL_JoystickGetButton = _bind("SDL_JoystickGetButton", [POINTER(SDL_Joystick), c_int], Uint8)
+SDL_JoystickClose = _bind("SDL_JoystickClose", [POINTER(SDL_Joystick)])
+from ctypes import Structure, c_int, c_char_p, POINTER
+from .dll import _bind
+from .stdinc import Uint8, Uint16, Uint32, SDL_bool
+from .keycode import SDL_Keycode, SDL_Keymod
+from .scancode import SDL_Scancode
+from .rect import SDL_Rect
+from .video import SDL_Window
+
+class SDL_Keysym(Structure):
+    _fields_ = [("scancode", SDL_Scancode),
+                ("sym", SDL_Keycode),
+                ("mod", Uint16),
+                ("unicode", Uint32)
+                ]
+
+SDL_GetKeyboardFocus = _bind("SDL_GetKeyboardFocus", None, POINTER(SDL_Window))
+SDL_GetKeyboardState = _bind("SDL_GetKeyboardState", [POINTER(c_int)], POINTER(Uint8))
+SDL_GetModState = _bind("SDL_GetModState", None, SDL_Keymod)
+SDL_SetModState = _bind("SDL_SetModState", [SDL_Keymod])
+SDL_GetKeyFromScancode = _bind("SDL_GetKeyFromScancode", [SDL_Scancode], SDL_Keycode)
+SDL_GetScancodeFromKey = _bind("SDL_GetScancodeFromKey", [SDL_Keycode], SDL_Scancode)
+SDL_GetScancodeName = _bind("SDL_GetScancodeName", [SDL_Scancode], c_char_p)
+SDL_GetScancodeFromName = _bind("SDL_GetScancodeFromName", [c_char_p], SDL_Scancode)
+SDL_GetKeyName = _bind("SDL_GetKeyName", [SDL_Keycode], c_char_p)
+SDL_GetKeyFromName = _bind("SDL_GetKeyFromName", [c_char_p], SDL_Keycode)
+SDL_StartTextInput = _bind("SDL_StartTextInput")
+SDL_IsTextInputActive = _bind("SDL_IsTextInputActive", None, SDL_bool)
+SDL_StopTextInput = _bind("SDL_StopTextInput")
+SDL_SetTextInputRect = _bind("SDL_SetTextInputRect", [POINTER(SDL_Rect)])
+SDL_HasScreenKeyboardSupport = _bind("SDL_HasScreenKeyboardSupport", None, SDL_bool)
+SDL_IsScreenKeyboardShown = _bind("SDL_IsScreenKeyboardShown", [POINTER(SDL_Window)], SDL_bool)
+from .stdinc import Sint32
+from .scancode import *
+
+SDL_Keycode = Sint32
+SDLK_SCANCODE_MASK = 1 << 30
+SDL_SCANCODE_TO_KEYCODE = lambda x: (x | SDLK_SCANCODE_MASK)
+
+SDL_Keymod = c_int
+
+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
+
+KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL
+KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT
+KMOD_ALT = KMOD_LALT | KMOD_RALT
+KMOD_GUI = KMOD_LGUI | KMOD_RGUI
+
+SDLK_UNKNOWN = 0
+
+SDLK_RETURN = ord('\r')
+SDLK_ESCAPE = ord('\033')
+SDLK_BACKSPACE = ord('\b')