mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch SRB2:next into expose-thrust-funcs-to-lua
This commit is contained in:
commit
3ef47897e3
915 changed files with 155241 additions and 101261 deletions
|
@ -1,9 +1,9 @@
|
|||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
working_directory: /root/SRB2
|
||||
working_directory: /home/circleci/SRB2
|
||||
docker:
|
||||
- image: debian:stretch
|
||||
- image: cimg/base:current
|
||||
environment:
|
||||
CC: ccache gcc -m32
|
||||
PKG_CONFIG_LIBDIR: /usr/lib/i386-linux-gnu/pkgconfig
|
||||
|
@ -11,7 +11,7 @@ jobs:
|
|||
LIBGME_LDFLAGS: -lgme
|
||||
CCACHE_COMPRESS: true
|
||||
WFLAGS: -Wno-unsuffixed-float-constants
|
||||
GCC49: true
|
||||
GCC81: true
|
||||
#- image: ubuntu:trusty
|
||||
# environment:
|
||||
# CC: ccache gcc -m32
|
||||
|
@ -21,54 +21,69 @@ jobs:
|
|||
# CCACHE_COMPRESS: true
|
||||
# WFLAGS: -Wno-unsuffixed-float-constants
|
||||
# GCC48: true
|
||||
resource_class: large
|
||||
steps:
|
||||
- run:
|
||||
name: Add i386 arch
|
||||
command: dpkg --add-architecture i386
|
||||
command: sudo dpkg --add-architecture i386
|
||||
- run:
|
||||
name: Add STJr PPA
|
||||
command: |
|
||||
apt-get -qq update
|
||||
apt-get -qq -y install dirmngr
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6
|
||||
echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" >> /etc/apt/sources.list
|
||||
sudo apt-get -qq update
|
||||
sudo apt-get -qq -y install dirmngr
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6
|
||||
echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list
|
||||
- run:
|
||||
name: Make APT cache folder
|
||||
command: mkdir -p /home/circleci/.cache/apt/archives/partial
|
||||
- run:
|
||||
name: Make APT cache usage by _apt
|
||||
command: sudo chown -Rv _apt:root /home/circleci/.cache/apt/archives/partial
|
||||
- run:
|
||||
name: Update APT listing
|
||||
command: apt-get -qq update
|
||||
command: sudo apt-get -qq update
|
||||
- run:
|
||||
name: Support S3 upload
|
||||
command: apt-get -qq -y install ca-certificates
|
||||
command: sudo apt-get -qq -y install ca-certificates
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-SRB2-APT
|
||||
- run:
|
||||
name: Install SDK
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
|
||||
name: Uninstall amd64 SDK
|
||||
command: sudo apt-get -o Dir::Cache="/home/circleci/.cache/apt" -qq -y --no-install-recommends remove libcurl4-openssl-dev:amd64
|
||||
- run:
|
||||
name: Install i386 SDK
|
||||
command: sudo apt-get -o Dir::Cache="/home/circleci/.cache/apt" -qq -y --no-install-recommends install git build-essential libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
- run:
|
||||
name: make md5sum
|
||||
command: sudo find /home/circleci/.cache/apt/archives -type f -print0 | sort -z | sudo xargs -r0 md5sum > /home/circleci/.cache/apt_archives.md5
|
||||
- save_cache:
|
||||
key: v1-SRB2-APT
|
||||
key: v1-SRB2-APT-{{ checksum "/home/circleci/.cache/apt_archives.md5" }}
|
||||
paths:
|
||||
- /var/cache/apt/archives
|
||||
- /home/circleci/.cache/apt
|
||||
- checkout
|
||||
- run:
|
||||
name: Compile without network support
|
||||
command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1
|
||||
command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 -j4
|
||||
- run:
|
||||
name: wipe build
|
||||
command: make -C src LINUX=1 cleandep
|
||||
- run:
|
||||
name: rebuild depend
|
||||
command: make -C src LINUX=1 clean
|
||||
- run:
|
||||
name: make master depend file
|
||||
command: find make/linux/SDL/deps/ -type f -print0 | sort -z | xargs -r0 cat > make/linux/SDL.deps
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }}
|
||||
- v1-SRB2-{{ .Branch }}-{{ checksum "make/linux/SDL.deps" }}
|
||||
- run:
|
||||
name: Compile
|
||||
command: make -C src LINUX=1 ERRORMODE=1 -k
|
||||
command: make -C src LINUX=1 ERRORMODE=1 -k -j4
|
||||
- store_artifacts:
|
||||
path: /root/SRB2/bin/Linux/Release/
|
||||
path: /home/circleci/SRB2/bin/
|
||||
destination: bin
|
||||
- save_cache:
|
||||
key: v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }}
|
||||
key: v1-SRB2-{{ .Branch }}-{{ checksum "make/linux/SDL.deps" }}
|
||||
paths:
|
||||
- /root/.ccache
|
||||
- /home/circleci/.ccache
|
||||
|
|
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -1,15 +1,17 @@
|
|||
#Source code
|
||||
/Makefile text=auto
|
||||
/src/*.c text=auto
|
||||
/src/*.h text=auto
|
||||
/src/*.s text=auto
|
||||
/src/*.m text=auto
|
||||
/src/*.xpm text=auto
|
||||
/src/Makefile text=auto
|
||||
/tools/Makefile text=auto
|
||||
/src/Make*.cfg text=auto
|
||||
/src/CMakeLists.txt text=auto
|
||||
*.mk -whitespace text=auto
|
||||
# Windows EOL
|
||||
*.cs -crlf -whitespace
|
||||
*.mk -crlf -whitespace
|
||||
*.bat -crlf -whitespace
|
||||
*.dev -crlf -whitespace
|
||||
*.dsp -crlf -whitespace
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -21,3 +21,6 @@ Win32_LIB_ASM_Release
|
|||
/assets/debian
|
||||
/make
|
||||
/bin
|
||||
/build
|
||||
/build/*
|
||||
/CMakeUserPresets.json
|
434
.gitlab-ci.yml
Normal file
434
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,434 @@
|
|||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_PATH
|
||||
|
||||
default:
|
||||
image: debian:stable-slim
|
||||
|
||||
cache:
|
||||
- key: ccache-$CI_PROJECT_PATH_SLUG-$CI_JOB_NAME_SLUG
|
||||
fallback_keys:
|
||||
- cache-$CI_PROJECT_PATH_SLUG-$CI_DEFAULT_BRANCH
|
||||
- cache-$CI_PROJECT_PATH_SLUG-default
|
||||
paths:
|
||||
- ccache
|
||||
- ccache_statslog
|
||||
|
||||
- key: apt-$CI_JOB_IMAGE
|
||||
paths:
|
||||
- apt-cache
|
||||
unprotect: true
|
||||
|
||||
before_script:
|
||||
- - |
|
||||
# debconf
|
||||
echo -e "\e[0Ksection_start:`date +%s`:debconf[collapsed=true]\r\e[0KSetup debconf's environment"
|
||||
- export DEBIAN_FRONTEND="noninteractive"
|
||||
- export DEBIAN_PRIORITY="low"
|
||||
- export DEBCONF_NONINTERACTIVE_SEEN="true"
|
||||
- |
|
||||
# debconf
|
||||
echo -e "\e[0Ksection_end:`date +%s`:debconf\r\e[0K"
|
||||
- - |
|
||||
# dpkg_aa
|
||||
echo -e "\e[0Ksection_start:`date +%s`:dpkg_aa[collapsed=true]\r\e[0KAdding architectures to dpkg"
|
||||
- dpkg --add-architecture i386
|
||||
- dpkg --add-architecture amd64
|
||||
- dpkg --add-architecture arm64
|
||||
- |
|
||||
# dpkg_aa
|
||||
echo -e "\e[0Ksection_end:`date +%s`:dpkg_aa\r\e[0K"
|
||||
- - |
|
||||
# apt_conf
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_conf[collapsed=true]\r\e[0KSetting up APT conf"
|
||||
- export APT_CACHE_DIR=`pwd`/apt-cache
|
||||
- mkdir --parents --verbose $APT_CACHE_DIR/partial/
|
||||
- touch /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# apt.conf
|
||||
echo Adding options to apt.conf':'
|
||||
- |
|
||||
# APT::Install-Recommends
|
||||
echo APT::Install-Recommends "false"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# quit
|
||||
echo quiet "1"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# APT::Get::Assume-Yes
|
||||
echo APT::Get::Assume-Yes "true"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# Dir::Cache::Archives
|
||||
echo Dir::Cache::Archives "$APT_CACHE_DIR"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# apt_conf
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_conf\r\e[0K"
|
||||
- - |
|
||||
# apt_update
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_update[collapsed=true]\r\e[0KUpdating APT listing"
|
||||
- apt-get update
|
||||
- |
|
||||
# apt_update
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_update\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_pre
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_pre[collapsed=true]\r\e[0KInstalling pre packages"
|
||||
- apt-get install apt-utils
|
||||
- |
|
||||
# apt_pre
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_pre\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_upgrade
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_upgrade[collapsed=true]\r\e[0KUpdating existing packages"
|
||||
- apt-get upgrade
|
||||
- |
|
||||
# apt_update
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_upgrade\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_common
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_common[collapsed=true]\r\e[0KInstalling common packages"
|
||||
- apt-get install make git ccache nasm
|
||||
- |
|
||||
# apt_common
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_common\r\e[0K"
|
||||
|
||||
- - |
|
||||
# ccache_config
|
||||
echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
|
||||
- mkdir --parents --verbose ~/.ccache/
|
||||
- touch ~/.ccache/ccache.conf
|
||||
- |
|
||||
# cache.conf
|
||||
echo Adding ccache configution option
|
||||
- |
|
||||
# base_dir
|
||||
echo base_dir = $PWD | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# cache_dir
|
||||
echo cache_dir = $PWD/ccache | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# compiler_check
|
||||
echo compiler_check = content | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# stats_log
|
||||
echo stats_log = $PWD/ccache_statslog | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# max_size
|
||||
echo max_size = 50M | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# ccache_config
|
||||
echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
|
||||
|
||||
- - |
|
||||
# cache_reset
|
||||
echo -e "\e[0Ksection_start:`date +%s`:ccache_reset[collapsed=true]\r\e[0KResetting ccache statistics"
|
||||
- ccache --zero-stats
|
||||
- ccache --show-stats
|
||||
- |
|
||||
# ccache_reset
|
||||
echo -e "\e[0Ksection_end:`date +%s`:ccache_reset\r\e[0K"
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG"
|
||||
|
||||
after_script:
|
||||
- - |
|
||||
# apt_clean
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_clean[collapsed=true]\r\e[0KCleaning of unneeded APT packages"
|
||||
- apt-get autoclean
|
||||
- |
|
||||
# apt_clean
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_clean\r\e[0K"
|
||||
|
||||
- - |
|
||||
# ccache_stats
|
||||
echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:"
|
||||
- ccache --show-stats --verbose
|
||||
- ccache --show-log-stats --verbose
|
||||
- |
|
||||
# ccahe_stats
|
||||
echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K"
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
Debian testing GCC:
|
||||
stage: build
|
||||
image: debian:testing-slim
|
||||
|
||||
allow_failure: true
|
||||
|
||||
artifacts:
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-gcc"
|
||||
|
||||
variables:
|
||||
CC: gcc
|
||||
LDFLAGS: -Wl,-fuse-ld=gold
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev libopenmpt-dev
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Windows x86:
|
||||
stage: build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Win32"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Win32"
|
||||
|
||||
variables:
|
||||
PREFIX: i686-w64-mingw32
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-mingw-w64-i686-win32
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW=1 SDL=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW=1 SDL=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable:amd64:
|
||||
stage: build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian amd64"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-x86-64"
|
||||
|
||||
variables:
|
||||
CC: x86_64-linux-gnu-gcc
|
||||
LDFLAGS: -Wl,-fuse-ld=gold
|
||||
OBJCOPY: x86_64-linux-gnu-objcopy
|
||||
OBJDUMP: x86_64-linux-gnu-objdump
|
||||
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-x86-64-linux-gnu || apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev:amd64 libpng-dev:amd64 libcurl4-openssl-dev:amd64 libgme-dev:amd64 libopenmpt-dev:amd64
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable:i386:
|
||||
stage: build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian i386"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-i686"
|
||||
|
||||
variables:
|
||||
CC: i686-linux-gnu-gcc
|
||||
OBJCOPY: i686-linux-gnu-objcopy
|
||||
OBJDUMP: i686-linux-gnu-objdump
|
||||
PKG_CONFIG_PATH: /usr/lib/i386-linux-gnu/pkgconfig
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-i686-linux-gnu || apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgme-dev:i386 libopenmpt-dev:i386
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable:arm64:
|
||||
stage: build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian arm64"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-aarch64"
|
||||
|
||||
variables:
|
||||
CC: aarch64-linux-gnu-gcc
|
||||
LDFLAGS: -Wl,-fuse-ld=gold
|
||||
OBJCOPY: aarch64-linux-gnu-objcopy
|
||||
OBJDUMP: aarch64-linux-gnu-objdump
|
||||
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-aarch64-linux-gnu || apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libgme-dev:arm64 libopenmpt-dev:arm64
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 NONX86=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Windows x64:
|
||||
stage: build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Win64"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Win64"
|
||||
|
||||
variables:
|
||||
PREFIX: x86_64-w64-mingw32
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-mingw-w64-x86-64-win32
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW64=1 SDL=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW64=1 SDL=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable Clang:
|
||||
stage: build
|
||||
|
||||
allow_failure: true
|
||||
|
||||
artifacts:
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang"
|
||||
|
||||
variables:
|
||||
CC: clang
|
||||
WFLAGS: -Wno-cast-align
|
||||
CFLAGS: -Wno-cast-align
|
||||
LDFLAGS: -Wl,-fuse-ld=gold
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install clang
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev libopenmpt-dev
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian testing Clang:
|
||||
extends: Debian stable Clang
|
||||
|
||||
image: debian:testing-slim
|
||||
|
||||
artifacts:
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-clang"
|
||||
|
||||
variables:
|
||||
CC: clang
|
||||
WFLAGS: -Wno-cast-align -Wno-deprecated-non-prototype
|
||||
CFLAGS: -Wno-cast-align -Wno-deprecated-non-prototype
|
||||
LDFLAGS: -Wl,-fuse-ld=gold
|
300
CMakeLists.txt
300
CMakeLists.txt
|
@ -1,17 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
# Enable CCache early
|
||||
set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache")
|
||||
if (${SRB2_USE_CCACHE})
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
message(STATUS "Found CCache: ${CCACHE_PROGRAM}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
||||
else()
|
||||
message(WARNING "You have specified to use CCACHE but it was not found. Object files will not be cached.")
|
||||
endif()
|
||||
if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
message(FATAL_ERROR "In-source builds are blocked. Please build from a separate directory.")
|
||||
endif()
|
||||
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
include(CMakeDependentOption)
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
file(STRINGS src/version.h SRB2_VERSION)
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
|
||||
|
||||
|
@ -19,127 +17,18 @@ string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
|
|||
# Version change is fine.
|
||||
project(SRB2
|
||||
VERSION ${SRB2_VERSION}
|
||||
LANGUAGES C)
|
||||
|
||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
|
||||
endif()
|
||||
|
||||
if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang"))
|
||||
message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.")
|
||||
endif()
|
||||
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
### Useful functions
|
||||
|
||||
# Add sources from Sourcefile
|
||||
function(target_sourcefile type)
|
||||
file(STRINGS Sourcefile list
|
||||
REGEX "[-0-9A-Za-z_]+\.${type}")
|
||||
target_sources(SRB2SDL2 PRIVATE ${list})
|
||||
endfunction()
|
||||
|
||||
# Macro to add OSX framework
|
||||
macro(add_framework fwname appname)
|
||||
find_library(FRAMEWORK_${fwname}
|
||||
NAMES ${fwname}
|
||||
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
|
||||
${CMAKE_OSX_SYSROOT}/Library
|
||||
/System/Library
|
||||
/Library
|
||||
ATH_SUFFIXES Frameworks
|
||||
NO_DEFAULT_PATH)
|
||||
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
|
||||
MESSAGE(ERROR ": Framework ${fwname} not found")
|
||||
else()
|
||||
TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}")
|
||||
MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Macro to copy Windows DLLs to Debug/Release folder for easy debugging
|
||||
# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though
|
||||
macro(copy_files_to_build_dir target dlllist_var)
|
||||
if(MSVC)
|
||||
# http://stackoverflow.com/a/26983405/3064195
|
||||
foreach(dlllist_item ${${dlllist_var}})
|
||||
get_filename_component(dllname ${dlllist_item} NAME)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${dlllist_item}
|
||||
$<TARGET_FILE_DIR:${target}>/${dllname}
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# bitness check
|
||||
set(SRB2_SYSTEM_BITS 0)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Target is 64-bit")
|
||||
set(SRB2_SYSTEM_BITS 64)
|
||||
endif()
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
message(STATUS "Target is 32-bit")
|
||||
set(SRB2_SYSTEM_BITS 32)
|
||||
endif()
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 0)
|
||||
message(STATUS "Target bitness is unknown")
|
||||
endif()
|
||||
|
||||
# OS macros
|
||||
if (UNIX)
|
||||
add_definitions(-DUNIXCOMMON)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
find_program(OBJCOPY objcopy)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES "Linux")
|
||||
add_definitions(-DLINUX)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
add_definitions(-DLINUX64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES "Darwin")
|
||||
add_definitions(-DMACOSX)
|
||||
endif()
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
# Set EXE names so the assets CMakeLists can refer to its target
|
||||
set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(assets)
|
||||
|
||||
|
||||
## config.h generation
|
||||
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
||||
include(GitUtilities)
|
||||
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
|
||||
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
|
||||
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
|
||||
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
||||
LANGUAGES C CXX)
|
||||
|
||||
##### PACKAGE CONFIGURATION #####
|
||||
|
||||
set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.")
|
||||
|
||||
if("${SRB2_CPACK_GENERATOR}" STREQUAL "")
|
||||
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||
set(SRB2_CPACK_GENERATOR "ZIP")
|
||||
elseif(${CMAKE_SYSTEM} MATCHES "Linux")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(SRB2_CPACK_GENERATOR "TGZ")
|
||||
elseif(${CMAKE_SYSTEM} MATCHES "Darwin")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
set(SRB2_CPACK_GENERATOR "TGZ")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -155,3 +44,166 @@ set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
|
|||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
|
||||
SET(CPACK_OUTPUT_FILE_PREFIX package)
|
||||
include(CPack)
|
||||
|
||||
# Options
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
|
||||
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON)
|
||||
else()
|
||||
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
# Clang tidy options will be ignored if CMAKE_<LANG>_CLANG_TIDY are set.
|
||||
option(SRB2_CONFIG_ENABLE_CLANG_TIDY_C "Enable default clang-tidy check configuration for C" OFF)
|
||||
option(SRB2_CONFIG_ENABLE_CLANG_TIDY_CXX "Enable default clang-tidy check configuration for C++" OFF)
|
||||
option(
|
||||
SRB2_CONFIG_SYSTEM_LIBRARIES
|
||||
"Link dependencies using CMake's find_package and do not use internal builds"
|
||||
${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
|
||||
)
|
||||
option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" ON)
|
||||
# This option isn't recommended for distribution builds and probably won't work (yet).
|
||||
cmake_dependent_option(
|
||||
SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
|
||||
"Use dynamic libraries when compiling internal dependencies"
|
||||
OFF "NOT SRB2_CONFIG_SYSTEM_LIBRARIES"
|
||||
OFF
|
||||
)
|
||||
option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON)
|
||||
option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF)
|
||||
option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF)
|
||||
option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF)
|
||||
option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF)
|
||||
option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF)
|
||||
option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
|
||||
# SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting.
|
||||
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
|
||||
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
|
||||
|
||||
if(SRB2_CONFIG_ENABLE_TESTS)
|
||||
# https://github.com/catchorg/Catch2
|
||||
CPMAddPackage(
|
||||
NAME Catch2
|
||||
VERSION 3.4.0
|
||||
GITHUB_REPOSITORY catchorg/Catch2
|
||||
OPTIONS
|
||||
"CATCH_INSTALL_DOCS OFF"
|
||||
)
|
||||
list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
add_executable(srb2tests)
|
||||
# To add tests, use target_sources to add individual test files to the target in subdirs.
|
||||
target_link_libraries(srb2tests PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
|
||||
target_compile_features(srb2tests PRIVATE c_std_11 cxx_std_17)
|
||||
catch_discover_tests(srb2tests)
|
||||
endif()
|
||||
|
||||
# Enable CCache
|
||||
# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
|
||||
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
|
||||
option(USE_CCACHE "Enable ccache support" OFF)
|
||||
|
||||
if(USE_CCACHE)
|
||||
find_program(CCACHE_TOOL_PATH ccache)
|
||||
if(CCACHE_TOOL_PATH)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
|
||||
else()
|
||||
message(WARNING "USE_CCACHE was set but ccache is not found (set CCACHE_TOOL_PATH)")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
CPMAddPackage(
|
||||
NAME Ccache.cmake
|
||||
GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
||||
VERSION 1.2
|
||||
)
|
||||
endif()
|
||||
|
||||
# Dependencies
|
||||
add_subdirectory(thirdparty)
|
||||
|
||||
if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_mixer REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(OPENMPT REQUIRED)
|
||||
|
||||
# libgme defaults to "Nuked" YM2612 emulator, which is
|
||||
# very SLOW. The system library probably uses the
|
||||
# default so just always build it.
|
||||
#find_package(GME REQUIRED)
|
||||
endif()
|
||||
|
||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
|
||||
endif()
|
||||
|
||||
if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang"))
|
||||
message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.")
|
||||
endif()
|
||||
|
||||
# bitness check
|
||||
set(SRB2_SYSTEM_BITS 0)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Target is 64-bit")
|
||||
set(SRB2_SYSTEM_BITS 64)
|
||||
endif()
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
message(STATUS "Target is 32-bit")
|
||||
set(SRB2_SYSTEM_BITS 32)
|
||||
endif()
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 0)
|
||||
message(STATUS "Target bitness is unknown")
|
||||
endif()
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
# Set EXE names so the assets CMakeLists can refer to its target
|
||||
set(SRB2_SDL2_EXE_NAME "" CACHE STRING "Override executable binary output name")
|
||||
set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(assets)
|
||||
|
||||
|
||||
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
||||
include(GitUtilities)
|
||||
|
||||
if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
|
||||
# cause a reconfigure if the branch changes
|
||||
get_git_dir(SRB2_GIT_DIR)
|
||||
configure_file("${SRB2_GIT_DIR}/HEAD" HEAD COPYONLY)
|
||||
|
||||
git_current_branch(SRB2_GIT_REVISION)
|
||||
|
||||
if("${SRB2_GIT_REVISION}" STREQUAL "")
|
||||
# use abbreviated commit hash if on detached HEAD
|
||||
git_latest_commit(SRB2_GIT_REVISION)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||
list(APPEND EXE_NAME_PARTS "srb2win")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
list(APPEND EXE_NAME_PARTS "lsdlsrb2")
|
||||
else()
|
||||
list(APPEND EXE_NAME_PARTS "srb2")
|
||||
endif()
|
||||
|
||||
if(NOT "${SRB2_GIT_REVISION}" STREQUAL "master")
|
||||
list(APPEND EXE_NAME_PARTS ${SRB2_GIT_REVISION})
|
||||
endif()
|
||||
else()
|
||||
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME})
|
||||
endif()
|
||||
|
||||
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_SUFFIX})
|
||||
|
||||
list(JOIN EXE_NAME_PARTS "_" EXE_NAME)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${EXE_NAME})
|
||||
|
|
29
CMakePresets.json
Normal file
29
CMakePresets.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"version": 3,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"description": "Build using default generator",
|
||||
"binaryDir": "build",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_FLAGS": "-fdiagnostics-color",
|
||||
"CMAKE_CXX_FLAGS": "-fdiagnostics-color",
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"description": "Build for development (no optimizations)",
|
||||
"inherits": "default",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
[Sonic Robo Blast 2](https://srb2.org/) is a 3D Sonic the Hedgehog fangame based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/).
|
||||
|
||||
## Dependencies
|
||||
- NASM (x86 builds only)
|
||||
- SDL2 (Linux/OS X only)
|
||||
- SDL2-Mixer (Linux/OS X only)
|
||||
- libupnp (Linux/OS X only)
|
||||
|
|
18
SRB2.cbp
18
SRB2.cbp
|
@ -1992,24 +1992,6 @@ HW3SOUND for 3D hardware sound support
|
|||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/v_video.h" />
|
||||
<Unit filename="src/vid_copy.s">
|
||||
<Option compilerVar="CC" />
|
||||
<Option compiler="avrgcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="gnu_gcc_compiler_for_mingw32" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="gnu_gcc_compiler_for_mingw64" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="armelfgcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="tricoregcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="ppcgcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="gcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option target="Debug Native/SDL" />
|
||||
<Option target="Release Native/SDL" />
|
||||
<Option target="Debug Linux/SDL" />
|
||||
<Option target="Release Linux/SDL" />
|
||||
<Option target="Debug Mingw/SDL" />
|
||||
<Option target="Release Mingw/SDL" />
|
||||
<Option target="Debug Mingw/DirectX" />
|
||||
<Option target="Release Mingw/DirectX" />
|
||||
</Unit>
|
||||
<Unit filename="src/w_wad.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x86'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>USEASM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
|
|
52
Srb2.dev
52
Srb2.dev
|
@ -5,7 +5,7 @@ Ver=3
|
|||
IsCpp=0
|
||||
Type=0
|
||||
UnitCount=279
|
||||
Folders=A_Asm,B_Bot,BLUA,D_Doom,F_Frame,G_Game,H_Hud,Hw_Hardware,Hw_Hardware/r_opengl,I_Interface,I_Interface/Dummy,I_Interface/SDL,I_Interface/Win32,LUA,M_Misc,P_Play,R_Rend,S_Sounds,W_Wad
|
||||
Folders=B_Bot,BLUA,D_Doom,F_Frame,G_Game,H_Hud,Hw_Hardware,Hw_Hardware/r_opengl,I_Interface,I_Interface/Dummy,I_Interface/SDL,I_Interface/Win32,LUA,M_Misc,P_Play,R_Rend,S_Sounds,W_Wad
|
||||
CommandLine=
|
||||
CompilerSettings=00000000000100000111e1
|
||||
PchHead=-1
|
||||
|
@ -1473,36 +1473,6 @@ Priority=1000
|
|||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit149]
|
||||
FileName=src\tmap.nas
|
||||
Folder=A_Asm
|
||||
Compile=0
|
||||
CompileCpp=0
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=1
|
||||
BuildCmd=nasm.exe -g -o $@ -f win32 src/tmap.nas
|
||||
|
||||
[Unit150]
|
||||
FileName=src\asm_defs.inc
|
||||
Folder=A_Asm
|
||||
Compile=0
|
||||
CompileCpp=0
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit151]
|
||||
FileName=src\vid_copy.s
|
||||
Folder=A_Asm
|
||||
Compile=1
|
||||
CompileCpp=0
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=1
|
||||
BuildCmd=$(CC) $(CFLAGS) -x assembler-with-cpp -c src/vid_copy.s -o $@
|
||||
|
||||
[Unit152]
|
||||
FileName=src\y_inter.h
|
||||
Folder=H_Hud
|
||||
|
@ -1543,26 +1513,6 @@ Priority=1000
|
|||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit156]
|
||||
FileName=src\p5prof.h
|
||||
Folder=A_Asm
|
||||
Compile=1
|
||||
CompileCpp=0
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit157]
|
||||
FileName=src\tmap_mmx.nas
|
||||
Folder=A_Asm
|
||||
Compile=0
|
||||
CompileCpp=0
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=1
|
||||
BuildCmd=nasm.exe -g -o $@ -f win32 src/tmap_mmx.nas
|
||||
|
||||
[Unit159]
|
||||
FileName=src\lzf.h
|
||||
Folder=W_Wad
|
||||
|
|
29
alias-bootstrap.sh
Executable file
29
alias-bootstrap.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# All these commands can be run from anywhere in the git
|
||||
# tree, not just the top level.
|
||||
|
||||
# Usage: git cmake
|
||||
#
|
||||
# Same usage as standard CMake command.
|
||||
#
|
||||
git config 'alias.cmake' '!cmake'
|
||||
|
||||
# Usage: git build <build preset> [options]
|
||||
# Usage: git build [options]
|
||||
#
|
||||
# In the second usage, when no preset is given, the
|
||||
# "default" build preset is used.
|
||||
#
|
||||
# Available options can be found by running:
|
||||
#
|
||||
# git cmake --build
|
||||
#
|
||||
git config 'alias.build' '!p="${1##-*}"; [ "$p" ] && shift; git cmake --build --preset "${p:-default}"'
|
||||
|
||||
# Usage: git crossmake
|
||||
#
|
||||
# Shortcut to i686-w64-mingw32-cmake (CMake cross
|
||||
# compiler)
|
||||
#
|
||||
git config 'alias.crossmake' '!i686-w64-mingw32-cmake'
|
10
appveyor.yml
10
appveyor.yml
|
@ -1,4 +1,4 @@
|
|||
version: 2.2.9.{branch}-{build}
|
||||
version: 2.2.13.{branch}-{build}
|
||||
os: MinGW
|
||||
|
||||
environment:
|
||||
|
@ -7,8 +7,6 @@ environment:
|
|||
# c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead
|
||||
MINGW_SDK: c:\msys64\mingw32
|
||||
CFLAGS: -Wno-implicit-fallthrough
|
||||
NASM_ZIP: nasm-2.12.01
|
||||
NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip
|
||||
UPX_ZIP: upx391w
|
||||
UPX_URL: http://upx.sourceforge.net/download/upx391w.zip
|
||||
CCACHE_EXE: ccache.exe
|
||||
|
@ -40,17 +38,12 @@ environment:
|
|||
ASSET_CLEAN: 0
|
||||
|
||||
cache:
|
||||
- nasm-2.12.01.zip
|
||||
- upx391w.zip
|
||||
- ccache.exe
|
||||
- C:\Users\appveyor\.ccache
|
||||
- C:\Users\appveyor\srb2_cache
|
||||
|
||||
install:
|
||||
- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip"
|
||||
- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0
|
||||
|
||||
- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip"
|
||||
- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0
|
||||
|
@ -65,7 +58,6 @@ configuration:
|
|||
before_build:
|
||||
- set "Path=%MINGW_SDK%\bin;%Path%"
|
||||
- mingw32-make --version
|
||||
- nasm -v
|
||||
- if not [%NOUPX%] == [1] ( upx -V )
|
||||
- ccache -V
|
||||
- ccache -s
|
||||
|
|
|
@ -1,72 +1,51 @@
|
|||
## Assets Target Configuration ##
|
||||
|
||||
# For prepending the current source path, later
|
||||
FUNCTION(PREPEND var prefix)
|
||||
SET(listVar "")
|
||||
FOREACH(f ${ARGN})
|
||||
LIST(APPEND listVar "${prefix}/${f}")
|
||||
ENDFOREACH(f)
|
||||
SET(${var} "${listVar}" PARENT_SCOPE)
|
||||
ENDFUNCTION(PREPEND)
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
# Asset installation isn't part of the Linux target
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer"
|
||||
CACHE STRING "Path to directory that contains all asset files for the installer.")
|
||||
if("${SRB2_CONFIG_ASSET_DIRECTORY}" STREQUAL "")
|
||||
message(WARNING "SRB2_CONFIG_ASSET_DIRECTORY is not set, so installation will not contain data files.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(SRB2_ASSET_INSTALL ON
|
||||
CACHE BOOL "Insert asset files into the install directory or package.")
|
||||
get_filename_component(SRB2_ASSET_DIRECTORY_ABSOLUTE "${SRB2_CONFIG_ASSET_DIRECTORY}" ABSOLUTE)
|
||||
|
||||
set(SRB2_ASSETS_DOCS
|
||||
"README.txt"
|
||||
"README-SDL.txt"
|
||||
"LICENSE.txt"
|
||||
"LICENSE-3RD-PARTY.txt"
|
||||
)
|
||||
list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "/")
|
||||
list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
|
||||
|
||||
####################
|
||||
# POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list!
|
||||
####################
|
||||
|
||||
set(SRB2_ASSET_HASHED
|
||||
"srb2.pk3;\
|
||||
player.dta;\
|
||||
zones.pk3;\
|
||||
patch.pk3"
|
||||
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
|
||||
set(SRB2_ASSETS_GAME
|
||||
"srb2.pk3"
|
||||
"player.dta"
|
||||
"zones.pk3"
|
||||
"patch.pk3"
|
||||
"music.dta"
|
||||
"models.dat"
|
||||
)
|
||||
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/")
|
||||
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
|
||||
|
||||
set(SRB2_ASSET_DOCS
|
||||
"README.txt;\
|
||||
LICENSE.txt;\
|
||||
LICENSE-3RD-PARTY.txt;\
|
||||
README-SDL.txt"
|
||||
CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!"
|
||||
)
|
||||
|
||||
PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS})
|
||||
|
||||
foreach(SRB2_ASSET ${SRB2_ASSET_HASHED})
|
||||
file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH")
|
||||
set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE)
|
||||
endforeach()
|
||||
set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME})
|
||||
|
||||
# Installation
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
get_target_property(outname SRB2SDL2 OUTPUT_NAME)
|
||||
if(${SRB2_ASSET_INSTALL})
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
|
||||
DESTINATION "${outname}.app/Contents/Resources"
|
||||
)
|
||||
endif()
|
||||
# Always install the doc files, even in non-asset packages.
|
||||
install(FILES ${SRB2_ASSET_DOCS}
|
||||
DESTINATION .
|
||||
OPTIONAL
|
||||
)
|
||||
install(FILES ${SRB2_ASSETS} DESTINATION "${outname}.app/Contents/Resources")
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION "${outname}.app/Contents/Resources")
|
||||
install(FILES ${SRB2_ASSETS_DOCS} DESTINATION .)
|
||||
else()
|
||||
if(${SRB2_ASSET_INSTALL})
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
|
||||
DESTINATION .
|
||||
)
|
||||
# Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install them in their own call.
|
||||
else()
|
||||
# Always install the doc files, even in non-asset packages.
|
||||
install(FILES ${SRB2_ASSET_DOCS}
|
||||
DESTINATION .
|
||||
OPTIONAL
|
||||
)
|
||||
endif()
|
||||
install(FILES ${SRB2_ASSETS} DESTINATION .)
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .)
|
||||
endif()
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
SONIC ROBO BLAST 2
|
||||
|
||||
Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame based on a
|
||||
modified version of Doom Legacy.
|
||||
Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame, based on a modified version of Doom Legacy.
|
||||
|
||||
https://www.srb2.org
|
||||
|
||||
LICENSE
|
||||
|
||||
The source code for SRB2 is licensed under the GNU General Public
|
||||
License, Version 2. See LICENSE.txt for the full text of this license.
|
||||
The source code for SRB2 is licensed under the GNU General Public License, Version 2. See LICENSE.txt for the full text of this license.
|
||||
|
||||
SRB2 uses various third-party libraries, including SDL, SDL Mixer, and
|
||||
their dependencies. See LICENSE-3RD-PARTY.txt for the licenses of these
|
||||
libraries.
|
||||
SRB2 uses various third-party libraries, including SDL, SDL Mixer, and their dependencies. See LICENSE-3RD-PARTY.txt for the licenses of these libraries.
|
||||
|
||||
SOURCE CODE
|
||||
|
||||
You may obtain the source code for SRB2, including the source code for
|
||||
specific version releases, at the following web sites:
|
||||
You may obtain the source code for SRB2, including the source code for specific version releases, at the following web sites:
|
||||
|
||||
STJr GitLab:
|
||||
https://git.magicalgirl.moe/STJr/SRB2
|
||||
https://git.do.srb2.org/STJr/SRB2
|
||||
|
||||
GitHub:
|
||||
https://github.com/STJr/SRB2
|
||||
|
@ -27,25 +24,27 @@ CONTACT
|
|||
|
||||
You may contact Sonic Team Junior via the following web sites:
|
||||
|
||||
SRB2.ORG:
|
||||
https://www.srb2.org
|
||||
|
||||
SRB2 Message Board:
|
||||
https://mb.srb2.org
|
||||
|
||||
SRB2 Official Discord:
|
||||
https://discord.gg/pYDXzpX (13+)
|
||||
https://discord.gg/b3BGb8A
|
||||
|
||||
Twitter:
|
||||
https://twitter.com/SonicTeamJr
|
||||
|
||||
Facebook:
|
||||
https://facebook.com/SonicRoboBlast2
|
||||
|
||||
|
||||
COPYRIGHT AND DISCLAIMER
|
||||
|
||||
Design and content on SRB2 is copyright 1998-2019 by Sonic Team Junior.
|
||||
All non-original material on SRB2.ORG is copyrighted by their
|
||||
respective owners, and no copyright infringement is intended. The owner
|
||||
of the SRB2.ORG domain is only acting as an ISP, and is therefore not
|
||||
responsible for any content on SRB2.ORG under the 1998 DMCA. This
|
||||
site, its webmaster, and its staff make no profit whatsoever (in fact,
|
||||
we lose money). Sonic Team Junior assumes no responsibility for the
|
||||
content on any Sonic Team Junior fan sites.
|
||||
Design and content in Sonic Robo Blast 2 is copyright 1998-2023 by Sonic Team Jr.
|
||||
|
||||
Sonic Team Junior is in no way affiliated with SEGA or Sonic Team. We do
|
||||
not claim ownership of any of SEGA's intellectual property used in SRB2.
|
||||
All original material in this game is copyrighted by their respective owners, and no copyright infringement is intended. Sonic Team Jr. is in no way affiliated with SEGA or Sonic Team, and we do not claim ownership of any of SEGA's intellectual property used in SRB2.
|
||||
|
||||
Sonic Robo Blast 2 is not commercial software. If you purchased this game, you have been scammed! Sonic Team Jr.'s staff makes no profit whatsoever (in fact, we lose money).
|
||||
|
||||
The owner of the srb2.org domain is only acting as an ISP, and is therefore not responsible for any content on srb2.org under the 1998 DMCA. Sonic Team Jr. assumes no responsibility for the content on any Sonic Team Jr. fan sites.
|
||||
|
||||
This software is provided as-is with no warranty whatsoever.
|
||||
|
|
21
cmake/CPM.cmake
Normal file
21
cmake/CPM.cmake
Normal file
|
@ -0,0 +1,21 @@
|
|||
set(CPM_DOWNLOAD_VERSION 0.36.0)
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
|
||||
file(DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION}
|
||||
)
|
||||
endif()
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
32
cmake/Comptime.cmake
Normal file
32
cmake/Comptime.cmake
Normal file
|
@ -0,0 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
|
||||
set(CMAKE_BINARY_DIR "${BINARY_DIR}")
|
||||
set(CMAKE_CURRENT_BINARY_DIR "${BINARY_DIR}")
|
||||
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
include(GitUtilities)
|
||||
|
||||
git_current_branch(SRB2_COMP_BRANCH)
|
||||
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED)
|
||||
|
||||
git_latest_commit(SRB2_COMP_REVISION)
|
||||
git_subject(subject)
|
||||
string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_NOTE "${subject}")
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE None)
|
||||
endif()
|
||||
|
||||
# These build types enable optimizations of some kind by default.
|
||||
set(optimized_build_types "MINSIZEREL;RELEASE;RELWITHDEBINFO")
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
||||
if("${build_type}" IN_LIST optimized_build_types)
|
||||
set(SRB2_COMP_OPTIMIZED TRUE)
|
||||
else()
|
||||
set(SRB2_COMP_OPTIMIZED FALSE)
|
||||
endif()
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/config.h")
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# support for the yasm assembler
|
||||
|
||||
set(CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS nasm yasm asm)
|
||||
|
||||
if(NOT CMAKE_ASM_YASM_OBJECT_FORMAT)
|
||||
if(WIN32)
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT win64)
|
||||
else()
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT win32)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT macho64)
|
||||
else()
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT macho)
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT elf64)
|
||||
else()
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT elf)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_ASM_YASM_COMPILE_OBJECT "<CMAKE_ASM_YASM_COMPILER> <FLAGS> -f ${CMAKE_ASM_YASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
|
||||
|
||||
# Load the generic ASMInformation file:
|
||||
set(ASM_DIALECT "_YASM")
|
||||
include(CMakeASMInformation)
|
||||
set(ASM_DIALECT)
|
|
@ -1,27 +0,0 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible
|
||||
|
||||
set(CMAKE_ASM_YASM_COMPILER_LIST nasm yasm)
|
||||
|
||||
if(NOT CMAKE_ASM_YASM_COMPILER)
|
||||
find_program(CMAKE_ASM_YASM_COMPILER yasm
|
||||
"$ENV{ProgramFiles}/YASM")
|
||||
endif()
|
||||
|
||||
# Load the generic DetermineASM compiler file with the DIALECT set properly:
|
||||
set(ASM_DIALECT "_YASM")
|
||||
include(CMakeDetermineASMCompiler)
|
||||
set(ASM_DIALECT)
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# This file is used by EnableLanguage in cmGlobalGenerator to
|
||||
# determine that the selected ASM_NASM "compiler" works.
|
||||
# For assembler this can only check whether the compiler has been found,
|
||||
# because otherwise there would have to be a separate assembler source file
|
||||
# for each assembler on every architecture.
|
||||
|
||||
set(ASM_DIALECT "_YASM")
|
||||
include(CMakeTestASMCompiler)
|
||||
set(ASM_DIALECT)
|
|
@ -20,4 +20,14 @@ find_library(GME_LIBRARY
|
|||
|
||||
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
|
||||
set(GME_PROCESS_LIBS GME_LIBRARY)
|
||||
libfind_process(GME)
|
||||
libfind_process(GME)
|
||||
|
||||
if(GME_FOUND AND NOT TARGET gme)
|
||||
add_library(gme UNKNOWN IMPORTED)
|
||||
set_target_properties(
|
||||
gme
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${GME_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${GME_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -20,4 +20,14 @@ find_library(OPENMPT_LIBRARY
|
|||
|
||||
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
|
||||
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
|
||||
libfind_process(OPENMPT)
|
||||
libfind_process(OPENMPT)
|
||||
|
||||
if(OPENMPT_FOUND AND NOT TARGET openmpt)
|
||||
add_library(openmpt UNKNOWN IMPORTED)
|
||||
set_target_properties(
|
||||
openmpt
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${OPENMPT_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENMPT_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -31,3 +31,13 @@ find_library(SDL2_LIBRARY
|
|||
set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR)
|
||||
set(SDL2_PROCESS_LIBS SDL2_LIBRARY)
|
||||
libfind_process(SDL2)
|
||||
|
||||
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
|
||||
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
|
||||
set_target_properties(
|
||||
SDL2::SDL2
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -32,3 +32,13 @@ find_library(SDL2_MIXER_LIBRARY
|
|||
set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR)
|
||||
set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY)
|
||||
libfind_process(SDL2_MIXER)
|
||||
|
||||
if(SDL2_MIXER_FOUND AND NOT TARGET SDL2_mixer::SDL2_mixer)
|
||||
add_library(SDL2_mixer::SDL2_mixer UNKNOWN IMPORTED)
|
||||
set_target_properties(
|
||||
SDL2_mixer::SDL2_mixer
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -6,38 +6,54 @@ endif()
|
|||
|
||||
set(__GitUtilities ON)
|
||||
|
||||
function(git_describe variable path)
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
macro(_git_command)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" ${ARGN}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endmacro()
|
||||
|
||||
macro(_git_easy_command)
|
||||
_git_command(${ARGN})
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endmacro()
|
||||
|
||||
function(git_current_branch variable)
|
||||
_git_command(symbolic-ref -q --short HEAD)
|
||||
|
||||
# If a detached head, a ref could still be resolved.
|
||||
if("${output}" STREQUAL "")
|
||||
_git_command(describe --all --exact-match)
|
||||
|
||||
# Get the ref, in the form heads/master or
|
||||
# remotes/origin/master so isolate the final part.
|
||||
string(REGEX REPLACE ".*/" "" output "${output}")
|
||||
endif()
|
||||
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_current_branch variable path)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
function(git_latest_commit variable)
|
||||
_git_easy_command(rev-parse --short HEAD)
|
||||
endfunction()
|
||||
|
||||
function(git_latest_commit variable path)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
function(git_working_tree_dirty variable)
|
||||
_git_command(status --porcelain -uno)
|
||||
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
if(output STREQUAL "")
|
||||
set(${variable} FALSE PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(git_subject variable)
|
||||
_git_easy_command(log -1 --format=%s)
|
||||
endfunction()
|
||||
|
||||
function(get_git_dir variable)
|
||||
_git_easy_command(rev-parse --git-dir)
|
||||
endfunction()
|
||||
|
|
21
cmake/Modules/clang-tidy-default.cmake
Normal file
21
cmake/Modules/clang-tidy-default.cmake
Normal file
|
@ -0,0 +1,21 @@
|
|||
find_program(CLANG_TIDY clang-tidy)
|
||||
|
||||
# Note: Apple Clang does not ship with clang tools. If you want clang-tidy on
|
||||
# macOS, it's best to install the Homebrew llvm bottle and set CLANG_TIDY
|
||||
# in your build directory. The llvm package is keg-only, so it will not
|
||||
# collide with Apple Clang.
|
||||
|
||||
function(target_set_default_clang_tidy target lang checks)
|
||||
if("${CLANG_TIDY}" STREQUAL "CLANG_TIDY-NOTFOUND")
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_target_property(c_clang_tidy_prop SRB2SDL2 C_CLANG_TIDY)
|
||||
if(NOT ("${c_clang_tidy_prop}" STREQUAL "c_clang_tidy_prop-NOTFOUND"))
|
||||
return()
|
||||
endif()
|
||||
|
||||
set_target_properties("${target}" PROPERTIES
|
||||
${lang}_CLANG_TIDY "${CLANG_TIDY};-checks=${checks}"
|
||||
)
|
||||
endfunction()
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
export CCACHE_CPP2=true
|
||||
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
export CCACHE_CPP2=true
|
||||
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"
|
54
comptime.sh
54
comptime.sh
|
@ -1,54 +1,44 @@
|
|||
#!/bin/bash -e
|
||||
#!/bin/sh
|
||||
path="."
|
||||
if [ x"$1" != x ]; then
|
||||
path="$1"
|
||||
fi
|
||||
|
||||
versiongit() {
|
||||
gitbranch=`git rev-parse --abbrev-ref HEAD`
|
||||
gitversion=`git rev-parse HEAD`
|
||||
cat <<EOF > $path/comptime.h
|
||||
version() {
|
||||
cat <<EOF > "$path/comptime.h"
|
||||
|
||||
// Do not edit! This file was autogenerated
|
||||
// by the $0 script with git
|
||||
//
|
||||
const char* compbranch = "$gitbranch";
|
||||
const char* comprevision = "${gitversion:0:8}";
|
||||
const char* compbranch = "$1";
|
||||
const char* comprevision = "$2";
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
versiongit() {
|
||||
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
gitversion="$(git rev-parse HEAD | cut -c -8)"
|
||||
version "$gitbranch" "$gitversion";
|
||||
exit 0
|
||||
}
|
||||
|
||||
versionsvn() {
|
||||
svnrevision=`svnversion -n $1`
|
||||
cat <<EOF > $path/comptime.h
|
||||
|
||||
// Do not edit! This file was autogenerated
|
||||
// by the $0 script with subversion
|
||||
//
|
||||
const char* compbranch = "Subversion";
|
||||
const char* comprevision = "r$svnrevision";
|
||||
EOF
|
||||
exit 0
|
||||
svnrevision="$(svnversion -n "$1")"
|
||||
version "Subversion" "r$svnrevision";
|
||||
exit 0
|
||||
}
|
||||
|
||||
versionfake() {
|
||||
cat <<EOF > $path/comptime.h
|
||||
|
||||
// Do not edit! This file was autogenerated
|
||||
// by the $0 script with an unknown or nonexist SCM
|
||||
//
|
||||
const char* compbranch = "Unknown";
|
||||
const char* comprevision = "illegal";
|
||||
EOF
|
||||
version "Unknown" "illegal";
|
||||
}
|
||||
|
||||
compversion() {
|
||||
touch $path/comptime.c
|
||||
versionfake
|
||||
test -d $path/.svn && versionsvn
|
||||
test -d $path/../.git && versiongit
|
||||
exit 1
|
||||
touch "$path/comptime.c"
|
||||
versionfake
|
||||
[ -d "$path/.svn" ] && versionsvn "$@"
|
||||
[ -d "$path/../.git" ] && versiongit
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -f $path/comptime.c && compversion
|
||||
[ -f "$path/comptime.c" ] && compversion "$@"
|
||||
exit 2
|
||||
|
|
|
@ -3,12 +3,12 @@ ifdef ComSpec
|
|||
COMSPEC=$(ComSpec)
|
||||
endif
|
||||
ifdef COMSPEC
|
||||
OBJCOPY=objcopy.exe
|
||||
OBJDUMP=objdump.exe
|
||||
OBJCOPY?=objcopy.exe
|
||||
OBJDUMP?=objdump.exe
|
||||
GZIP?=gzip.exe
|
||||
else
|
||||
OBJCOPY=objcopy
|
||||
OBJDUMP=objdump
|
||||
OBJCOPY?=objcopy
|
||||
OBJDUMP?=objdump
|
||||
GZIP?=gzip
|
||||
endif
|
||||
DBGNAME=$(BIN).debug
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@ common
|
|||
ignoredextensions = "wad pk3 pk7 bak backup1 backup2 backup3 zip rar 7z";
|
||||
|
||||
// Default testing parameters
|
||||
testparameters = "-file \"%AP\" \"%F\" -warp %L";
|
||||
testparameters = "-folder \"%AF\" -file \"%AA\" \"%F\" -warp %L";
|
||||
testshortpaths = true;
|
||||
|
||||
// Action special help
|
||||
|
@ -26,7 +26,7 @@ common
|
|||
generalizedsectors = true;
|
||||
|
||||
// Maximum safe map size check (0 means skip check)
|
||||
safeboundary = 1;
|
||||
safeboundary = 0;
|
||||
|
||||
// Map boundaries. Map objects can only be placed within these boundaries
|
||||
leftboundary = -32768;
|
||||
|
@ -40,6 +40,8 @@ common
|
|||
defaultflatscale = 1.0f;
|
||||
scaledtextureoffsets = true;
|
||||
|
||||
maxcolormapalpha = 25;
|
||||
|
||||
// Thing number for start position in 3D Mode
|
||||
start3dmode = 3328;
|
||||
|
||||
|
@ -68,131 +70,6 @@ common
|
|||
}
|
||||
}
|
||||
|
||||
mapformat_doom
|
||||
{
|
||||
// The format interface handles the map data format
|
||||
formatinterface = "DoomMapSetIO";
|
||||
|
||||
// Default nodebuilder configurations
|
||||
defaultsavecompiler = "zennode_normal";
|
||||
defaulttestcompiler = "zennode_fast";
|
||||
|
||||
/*
|
||||
GAME DETECT PATTERN
|
||||
Used to guess the game for which a WAD file is made.
|
||||
|
||||
1 = One of these lumps must exist
|
||||
2 = None of these lumps must exist
|
||||
3 = All of these lumps must exist
|
||||
*/
|
||||
|
||||
gamedetect
|
||||
{
|
||||
EXTENDED = 2;
|
||||
|
||||
|
||||
BEHAVIOR = 2;
|
||||
|
||||
E#M# = 2;
|
||||
|
||||
MAP?? = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
MAP LUMP NAMES
|
||||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
blindcopy = Lump will be copied along with the map blindly. (usefull for lumps Doom Builder doesn't use)
|
||||
nodebuild = The nodebuilder generates this lump.
|
||||
allowempty = The nodebuilder is allowed to leave this lump empty.
|
||||
script = This lump is a text-based script. Specify the filename of the script configuration to use.
|
||||
*/
|
||||
|
||||
maplumpnames
|
||||
{
|
||||
include("SRB222_misc.cfg", "doommaplumpnames");
|
||||
}
|
||||
|
||||
// When this is set to true, sectors with the same tag will light up when a line is highlighted
|
||||
linetagindicatesectors = true;
|
||||
|
||||
// Special linedefs
|
||||
include("SRB222_misc.cfg", "speciallinedefs");
|
||||
|
||||
// Default flags for first new thing
|
||||
defaultthingflags
|
||||
{
|
||||
}
|
||||
|
||||
// DEFAULT SECTOR BRIGHTNESS LEVELS
|
||||
sectorbrightness
|
||||
{
|
||||
include("SRB222_misc.cfg", "sectorbrightness");
|
||||
}
|
||||
|
||||
// SECTOR TYPES
|
||||
sectortypes
|
||||
{
|
||||
include("SRB222_sectors.cfg", "sectortypes");
|
||||
}
|
||||
|
||||
// GENERALISED SECTOR TYPES
|
||||
gen_sectortypes
|
||||
{
|
||||
include("SRB222_sectors.cfg", "gen_sectortypes");
|
||||
}
|
||||
|
||||
// LINEDEF FLAGS
|
||||
linedefflags
|
||||
{
|
||||
include("SRB222_misc.cfg", "linedefflags");
|
||||
}
|
||||
|
||||
// Linedef flags UDMF translation table
|
||||
// This is needed for copy/paste and prefabs to work properly
|
||||
// When the UDMF field name is prefixed with ! it is inverted
|
||||
linedefflagstranslation
|
||||
{
|
||||
include("SRB222_misc.cfg", "linedefflagstranslation");
|
||||
}
|
||||
|
||||
// LINEDEF ACTIVATIONS
|
||||
linedefactivations
|
||||
{
|
||||
}
|
||||
|
||||
// LINEDEF TYPES
|
||||
linedeftypes
|
||||
{
|
||||
include("SRB222_linedefs.cfg", "doom");
|
||||
}
|
||||
|
||||
// THING FLAGS
|
||||
thingflags
|
||||
{
|
||||
include("SRB222_misc.cfg", "thingflags");
|
||||
}
|
||||
|
||||
// Thing flags UDMF translation table
|
||||
// This is needed for copy/paste and prefabs to work properly
|
||||
// When the UDMF field name is prefixed with ! it is inverted
|
||||
thingflagstranslation
|
||||
{
|
||||
include("SRB222_misc.cfg", "thingflagstranslation");
|
||||
}
|
||||
|
||||
// THING FLAGS ERROR MASK
|
||||
// Mask for the thing flags which indicates the options
|
||||
// that make the same thing appear in the same modes
|
||||
thingflagsmask1 = 7; // 1 + 2 + 4
|
||||
thingflagsmask2 = 0;
|
||||
}
|
||||
|
||||
mapformat_udmf
|
||||
{
|
||||
// The format interface handles the map data format
|
||||
|
@ -216,9 +93,17 @@ mapformat_udmf
|
|||
{
|
||||
include("SRB222_misc.cfg", "universalfields");
|
||||
}
|
||||
|
||||
// Disable Doom-related modes that don't make sense for SRB2
|
||||
soundsupport = false;
|
||||
automapsupport = false;
|
||||
|
||||
// When this is set to true, sectors with the same tag will light up when a line is highlighted
|
||||
linetagindicatesectors = false;
|
||||
localsidedeftextureoffsets = true;
|
||||
distinctfloorandceilingbrightness = true;
|
||||
|
||||
planeequationsupport = true;
|
||||
|
||||
// Special linedefs
|
||||
include("SRB222_misc.cfg", "speciallinedefs_udmf");
|
||||
|
@ -234,23 +119,19 @@ mapformat_udmf
|
|||
include("SRB222_misc.cfg", "sectorflags");
|
||||
}
|
||||
|
||||
sectorflagscategories
|
||||
{
|
||||
include("SRB222_misc.cfg", "sectorflagscategories");
|
||||
}
|
||||
|
||||
// DEFAULT SECTOR BRIGHTNESS LEVELS
|
||||
sectorbrightness
|
||||
{
|
||||
include("SRB222_misc.cfg", "sectorbrightness");
|
||||
}
|
||||
|
||||
// SECTOR TYPES
|
||||
sectortypes
|
||||
{
|
||||
include("SRB222_sectors.cfg", "sectortypes");
|
||||
}
|
||||
|
||||
// GENERALISED SECTOR TYPES
|
||||
gen_sectortypes
|
||||
{
|
||||
include("SRB222_sectors.cfg", "gen_sectortypes");
|
||||
}
|
||||
damagetypes = "Generic Water Fire Lava Electric Spike DeathPitTilt DeathPitNoTilt Instakill SpecialStage";
|
||||
triggerertypes = "Player AllPlayers Mobj";
|
||||
|
||||
// LINEDEF FLAGS
|
||||
linedefflags
|
||||
|
@ -264,10 +145,10 @@ mapformat_udmf
|
|||
}
|
||||
|
||||
// LINEDEF RENDERSTYLES
|
||||
/*linedefrenderstyles
|
||||
linedefrenderstyles
|
||||
{
|
||||
include("SRB222_misc.cfg", "linedefrenderstyles");
|
||||
}*/
|
||||
}
|
||||
|
||||
// THING FLAGS
|
||||
thingflags
|
||||
|
@ -286,7 +167,12 @@ mapformat_udmf
|
|||
// How to compare thing flags (for the stuck things error checker)
|
||||
thingflagscompare
|
||||
{
|
||||
include("UDMF_misc.cfg", "thingflagscompare");
|
||||
}
|
||||
|
||||
// THING TYPES
|
||||
thingtypes
|
||||
{
|
||||
include("SRB222_things.cfg", "udmf");
|
||||
}
|
||||
|
||||
// LINEDEF TYPES
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,3 @@
|
|||
linedefflags
|
||||
{
|
||||
1 = "[0] Impassable";
|
||||
2 = "[1] Block Enemies";
|
||||
4 = "[2] Double-Sided";
|
||||
8 = "[3] Upper Unpegged";
|
||||
16 = "[4] Lower Unpegged";
|
||||
32 = "[5] Slope Skew (E1)";
|
||||
64 = "[6] Not Climbable";
|
||||
128 = "[7] No Midtexture Skew (E2)";
|
||||
256 = "[8] Peg Midtexture (E3)";
|
||||
512 = "[9] Solid Midtexture (E4)";
|
||||
1024 = "[10] Repeat Midtexture (E5)";
|
||||
2048 = "[11] Netgame Only";
|
||||
4096 = "[12] No Netgame";
|
||||
8192 = "[13] Effect 6";
|
||||
16384 = "[14] Bouncy Wall";
|
||||
32768 = "[15] Transfer Line";
|
||||
}
|
||||
|
||||
|
||||
// Linedef flags UDMF translation table
|
||||
// This is needed for copy/paste and prefabs to work properly
|
||||
// When the UDMF field name is prefixed with ! it is inverted
|
||||
|
@ -42,7 +21,6 @@ linedefflagstranslation
|
|||
32768 = "transfer";
|
||||
}
|
||||
|
||||
|
||||
linedefflags_udmf
|
||||
{
|
||||
blocking = "Impassable";
|
||||
|
@ -58,42 +36,99 @@ linedefflags_udmf
|
|||
wrapmidtex = "Repeat Midtexture";
|
||||
netonly = "Netgame Only";
|
||||
nonet = "No Netgame";
|
||||
effect6 = "Effect 6";
|
||||
bouncy = "Bouncy Wall";
|
||||
transfer = "Transfer Line";
|
||||
}
|
||||
|
||||
/*linedefrenderstyles
|
||||
linedefrenderstyles
|
||||
{
|
||||
translucent = "Translucent";
|
||||
add = "Add";
|
||||
subtract = "Subtract";
|
||||
reversesubtract = "Reverse subtract";
|
||||
modulate = "Modulate";
|
||||
fog = "Fog";
|
||||
}*/
|
||||
}
|
||||
|
||||
sectorflags
|
||||
{
|
||||
colormapfog = "Fog Planes in Colormap";
|
||||
colormapfadesprites = "Fade Fullbright in Colormap";
|
||||
colormapprotected = "Protected Colormap";
|
||||
invertprecip = "Invert Precipitation";
|
||||
gravityflip = "Flip Objects in Reverse Gravity";
|
||||
heatwave = "Heat Wave";
|
||||
noclipcamera = "Intangible to the Camera";
|
||||
colormapfog = "Fog Planes";
|
||||
colormapfadesprites = "Fade Fullbright";
|
||||
colormapprotected = "Protected from Tagging";
|
||||
outerspace = "Space Countdown";
|
||||
doublestepup = "Ramp Sector (double step-up/down)";
|
||||
nostepdown = "Non-Ramp Sector (No step-down)";
|
||||
speedpad = "Speed Pad";
|
||||
starpostactivator = "Star Post Activator";
|
||||
exit = "Exit";
|
||||
specialstagepit = "Special Stage Pit";
|
||||
returnflag = "Return Flag";
|
||||
redteambase = "Red Team Base";
|
||||
blueteambase = "Blue Team Base";
|
||||
fan = "Fan Sector";
|
||||
supertransform = "Super Sonic Transform";
|
||||
forcespin = "Force Spin";
|
||||
zoomtubestart = "Zoom Tube Start";
|
||||
zoomtubeend = "Zoom Tube End";
|
||||
finishline = "Circuit Finish Line";
|
||||
ropehang = "Rope Hang";
|
||||
jumpflip = "Flip Gravity on Jump";
|
||||
gravityoverride = "Make Reverse Gravity Temporary";
|
||||
flipspecial_nofloor = "No Trigger on Floor Touch";
|
||||
flipspecial_ceiling = "Trigger on Ceiling Touch";
|
||||
triggerspecial_touch = "Trigger on Edge Touch";
|
||||
triggerspecial_headbump = "Trigger on Headbump";
|
||||
triggerline_plane = "Linedef Trigger Requires Plane Touch";
|
||||
triggerline_mobj = "Non-Pushables Can Trigger Linedef";
|
||||
}
|
||||
|
||||
thingflags
|
||||
sectorflagscategories
|
||||
{
|
||||
1 = "[1] Extra";
|
||||
2 = "[2] Flip";
|
||||
4 = "[4] Special";
|
||||
8 = "[8] Ambush";
|
||||
invertprecip = "regular";
|
||||
gravityflip = "regular";
|
||||
heatwave = "regular";
|
||||
noclipcamera = "regular";
|
||||
colormapfog = "colormap";
|
||||
colormapfadesprites = "colormap";
|
||||
colormapprotected = "colormap";
|
||||
outerspace = "special";
|
||||
doublestepup = "special";
|
||||
nostepdown = "special";
|
||||
speedpad = "special";
|
||||
starpostactivator = "special";
|
||||
exit = "special";
|
||||
specialstagepit = "special";
|
||||
returnflag = "special";
|
||||
redteambase = "special";
|
||||
blueteambase = "special";
|
||||
fan = "special";
|
||||
supertransform = "special";
|
||||
forcespin = "special";
|
||||
zoomtubestart = "special";
|
||||
zoomtubeend = "special";
|
||||
finishline = "special";
|
||||
ropehang = "special";
|
||||
jumpflip = "special";
|
||||
gravityoverride = "special";
|
||||
flipspecial_nofloor = "trigger";
|
||||
flipspecial_ceiling = "trigger";
|
||||
triggerspecial_touch = "trigger";
|
||||
triggerspecial_headbump = "trigger";
|
||||
triggerline_plane = "trigger";
|
||||
triggerline_mobj = "trigger";
|
||||
}
|
||||
|
||||
// THING FLAGS
|
||||
thingflags_udmf
|
||||
{
|
||||
extra = "Extra";
|
||||
flip = "Flip";
|
||||
special = "Special";
|
||||
ambush = "Ambush";
|
||||
absolutez = "Absolute Z height";
|
||||
}
|
||||
|
||||
|
||||
// Thing flags UDMF translation table
|
||||
// This is needed for copy/paste and prefabs to work properly
|
||||
// When the UDMF field name is prefixed with ! it is inverted
|
||||
|
@ -103,9 +138,9 @@ thingflagstranslation
|
|||
2 = "flip";
|
||||
4 = "special";
|
||||
8 = "ambush";
|
||||
16 = "absolutez";
|
||||
}
|
||||
|
||||
|
||||
// DEFAULT SECTOR BRIGHTNESS LEVELS
|
||||
sectorbrightness
|
||||
{
|
||||
|
@ -144,6 +179,8 @@ sectorbrightness
|
|||
0;
|
||||
}
|
||||
|
||||
numbrightnesslevels = 32;
|
||||
|
||||
/*
|
||||
TEXTURES AND FLAT SOURCES
|
||||
This tells Doom Builder where to find the information for textures
|
||||
|
@ -194,68 +231,14 @@ universalfields
|
|||
{
|
||||
sector
|
||||
{
|
||||
lightalpha
|
||||
{
|
||||
type = 0;
|
||||
default = 25;
|
||||
}
|
||||
|
||||
fadealpha
|
||||
{
|
||||
type = 0;
|
||||
default = 25;
|
||||
}
|
||||
|
||||
fadestart
|
||||
{
|
||||
type = 0;
|
||||
default = 0;
|
||||
}
|
||||
|
||||
fadeend
|
||||
{
|
||||
type = 0;
|
||||
default = 33;
|
||||
}
|
||||
|
||||
foglighting
|
||||
{
|
||||
type = 3;
|
||||
default = false;
|
||||
}
|
||||
}
|
||||
|
||||
linedef
|
||||
{
|
||||
arg5
|
||||
{
|
||||
type = 0;
|
||||
default = 0;
|
||||
}
|
||||
stringarg0
|
||||
{
|
||||
type = 2;
|
||||
default = "";
|
||||
}
|
||||
stringarg1
|
||||
{
|
||||
type = 2;
|
||||
default = "";
|
||||
}
|
||||
executordelay
|
||||
{
|
||||
type = 0;
|
||||
default = 0;
|
||||
}
|
||||
}
|
||||
|
||||
sidedef
|
||||
{
|
||||
repeatcnt
|
||||
{
|
||||
type = 0;
|
||||
default = 0;
|
||||
}
|
||||
}
|
||||
|
||||
thing
|
||||
|
@ -278,87 +261,6 @@ allowempty = The nodebuilder is allowed to leave this lump empty.
|
|||
scriptbuild = This lump is a text-based script, which should be compiled using current script compiler;
|
||||
script = This lump is a text-based script. Specify the filename of the script configuration to use.
|
||||
*/
|
||||
|
||||
doommaplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
nodebuild = true;
|
||||
allowempty = true;
|
||||
}
|
||||
|
||||
LINEDEFS
|
||||
{
|
||||
required = true;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
SIDEDEFS
|
||||
{
|
||||
required = true;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
VERTEXES
|
||||
{
|
||||
required = true;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
SEGS
|
||||
{
|
||||
required = false;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
SSECTORS
|
||||
{
|
||||
required = false;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
NODES
|
||||
{
|
||||
required = false;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
SECTORS
|
||||
{
|
||||
required = true;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
REJECT
|
||||
{
|
||||
required = false;
|
||||
nodebuild = true;
|
||||
allowempty = false;
|
||||
}
|
||||
|
||||
BLOCKMAP
|
||||
{
|
||||
required = false;
|
||||
nodebuild = true;
|
||||
allowempty = true;
|
||||
}
|
||||
}
|
||||
|
||||
udmfmaplumpnames
|
||||
{
|
||||
ZNODES
|
||||
|
@ -406,6 +308,12 @@ enums
|
|||
1 = "Yes";
|
||||
}
|
||||
|
||||
setadd
|
||||
{
|
||||
0 = "Set";
|
||||
1 = "Add";
|
||||
}
|
||||
|
||||
onoff
|
||||
{
|
||||
0 = "On";
|
||||
|
@ -437,6 +345,13 @@ enums
|
|||
2 = "Back";
|
||||
}
|
||||
|
||||
frontbackboth
|
||||
{
|
||||
0 = "Front";
|
||||
1 = "Back";
|
||||
2 = "Front and back";
|
||||
}
|
||||
|
||||
tangibility
|
||||
{
|
||||
1 = "Intangible from top";
|
||||
|
@ -444,6 +359,100 @@ enums
|
|||
4 = "Don't block players";
|
||||
8 = "Don't block non-players";
|
||||
}
|
||||
|
||||
floorceiling
|
||||
{
|
||||
0 = "Floor";
|
||||
1 = "Ceiling";
|
||||
2 = "Both";
|
||||
}
|
||||
|
||||
scrollcarry
|
||||
{
|
||||
0 = "Scroll and carry";
|
||||
1 = "Scroll";
|
||||
2 = "Carry";
|
||||
}
|
||||
|
||||
scrolltype
|
||||
{
|
||||
0 = "Regular";
|
||||
1 = "Accelerative";
|
||||
2 = "Displacement";
|
||||
}
|
||||
|
||||
comparison
|
||||
{
|
||||
0 = "Equal";
|
||||
1 = "Less than or equal";
|
||||
2 = "Greater than or equal";
|
||||
}
|
||||
|
||||
triggertype
|
||||
{
|
||||
0 = "Continuous";
|
||||
1 = "Once";
|
||||
2 = "Each time on entry";
|
||||
3 = "Each time on entry/exit";
|
||||
}
|
||||
|
||||
xtriggertype
|
||||
{
|
||||
0 = "Continuous";
|
||||
1 = "Each time on entry";
|
||||
2 = "Each time on entry/exit";
|
||||
}
|
||||
|
||||
team
|
||||
{
|
||||
0 = "Red";
|
||||
1 = "Blue";
|
||||
}
|
||||
|
||||
flagcheck
|
||||
{
|
||||
0 = "Has all";
|
||||
1 = "Has any";
|
||||
2 = "Has exactly";
|
||||
3 = "Doesn't have all";
|
||||
4 = "Doesn't have any";
|
||||
}
|
||||
|
||||
maceflags
|
||||
{
|
||||
1 = "Double size";
|
||||
2 = "No sounds";
|
||||
4 = "Player-turnable chain";
|
||||
8 = "Swing instead of spin";
|
||||
16 = "Make chain from end item";
|
||||
32 = "Spawn link at origin";
|
||||
64 = "Clip inside ground";
|
||||
128 = "No distance check";
|
||||
}
|
||||
|
||||
pushablebehavior
|
||||
{
|
||||
0 = "Normal";
|
||||
1 = "Slide";
|
||||
2 = "Immovable";
|
||||
3 = "Classic";
|
||||
}
|
||||
|
||||
monitorrespawn
|
||||
{
|
||||
0 = "Same item";
|
||||
1 = "Random (Weak)";
|
||||
2 = "Random (Strong)";
|
||||
}
|
||||
|
||||
blendmodes
|
||||
{
|
||||
0 = "Translucent";
|
||||
1 = "Add";
|
||||
2 = "Subtract";
|
||||
3 = "Reverse subtract";
|
||||
4 = "Modulate";
|
||||
}
|
||||
}
|
||||
|
||||
//Default things filters
|
||||
|
@ -475,48 +484,32 @@ thingsfilters
|
|||
|
||||
}
|
||||
|
||||
//filter3
|
||||
//{
|
||||
// name = "Normal Gravity";
|
||||
// category = "";
|
||||
// type = -1;
|
||||
//
|
||||
// fields
|
||||
// {
|
||||
// 2 = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
filter3
|
||||
{
|
||||
name = "Normal Gravity";
|
||||
category = "";
|
||||
type = -1;
|
||||
|
||||
fields
|
||||
{
|
||||
2 = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
filter4
|
||||
{
|
||||
name = "Reverse Gravity";
|
||||
category = "";
|
||||
type = -1;
|
||||
|
||||
fields
|
||||
{
|
||||
2 = true;
|
||||
}
|
||||
|
||||
}
|
||||
//filter4
|
||||
//{
|
||||
// name = "Reverse Gravity";
|
||||
// category = "";
|
||||
// type = -1;
|
||||
//
|
||||
// fields
|
||||
// {
|
||||
// 2 = true;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
// Special linedefs
|
||||
speciallinedefs
|
||||
{
|
||||
soundlinedefflag = 64; // See linedefflags
|
||||
singlesidedflag = 1; // See linedefflags
|
||||
doublesidedflag = 4; // See linedefflags
|
||||
impassableflag = 1;
|
||||
upperunpeggedflag = 8;
|
||||
lowerunpeggedflag = 16;
|
||||
repeatmidtextureflag = 1024;
|
||||
pegmidtextureflag = 256;
|
||||
}
|
||||
|
||||
speciallinedefs_udmf
|
||||
{
|
||||
soundlinedefflag = "noclimb";
|
||||
|
@ -527,6 +520,8 @@ speciallinedefs_udmf
|
|||
lowerunpeggedflag = "dontpegbottom";
|
||||
repeatmidtextureflag = "wrapmidtex";
|
||||
pegmidtextureflag = "midpeg";
|
||||
slopeskewflag = "skewtd";
|
||||
nomidtextureskewflag = "noskew";
|
||||
}
|
||||
|
||||
scriptlumpnames
|
||||
|
@ -622,4 +617,4 @@ flats
|
|||
start = "F_START";
|
||||
end = "FF_END";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
sectortypes
|
||||
{
|
||||
0 = "Normal";
|
||||
1 = "Damage";
|
||||
2 = "Damage (Water)";
|
||||
3 = "Damage (Fire)";
|
||||
4 = "Damage (Electrical)";
|
||||
5 = "Spikes";
|
||||
6 = "Death Pit (Camera Tilt)";
|
||||
7 = "Death Pit (No Camera Tilt)";
|
||||
8 = "Instant Kill";
|
||||
9 = "Ring Drainer (Floor Touch)";
|
||||
10 = "Ring Drainer (Anywhere in Sector)";
|
||||
11 = "Special Stage Damage";
|
||||
12 = "Space Countdown";
|
||||
13 = "Ramp Sector (double step-up/down)";
|
||||
14 = "Non-Ramp Sector (no step-down)";
|
||||
15 = "Bouncy FOF";
|
||||
16 = "Trigger Line Ex. (Pushable Objects)";
|
||||
32 = "Trigger Line Ex. (Anywhere, All Players)";
|
||||
48 = "Trigger Line Ex. (Floor Touch, All Players)";
|
||||
64 = "Trigger Line Ex. (Anywhere in Sector)";
|
||||
80 = "Trigger Line Ex. (Floor Touch)";
|
||||
96 = "Trigger Line Ex. (Emerald Check)";
|
||||
112 = "Trigger Line Ex. (NiGHTS Mare)";
|
||||
128 = "Check for Linedef Executor on FOFs";
|
||||
144 = "Egg Capsule";
|
||||
160 = "Special Stage Time/Spheres Parameters";
|
||||
176 = "Custom Global Gravity";
|
||||
512 = "Wind/Current";
|
||||
1024 = "Conveyor Belt";
|
||||
1280 = "Speed Pad";
|
||||
4096 = "Star Post Activator";
|
||||
8192 = "Exit/Special Stage Pit/Return Flag";
|
||||
12288 = "CTF Red Team Base";
|
||||
16384 = "CTF Blue Team Base";
|
||||
20480 = "Fan Sector";
|
||||
24576 = "Super Sonic Transform";
|
||||
28672 = "Force Spin";
|
||||
32768 = "Zoom Tube Start";
|
||||
36864 = "Zoom Tube End";
|
||||
40960 = "Circuit Finish Line";
|
||||
45056 = "Rope Hang";
|
||||
49152 = "Intangible to the Camera";
|
||||
}
|
||||
|
||||
gen_sectortypes
|
||||
{
|
||||
first
|
||||
{
|
||||
0 = "Normal";
|
||||
1 = "Damage";
|
||||
2 = "Damage (Water)";
|
||||
3 = "Damage (Fire)";
|
||||
4 = "Damage (Electrical)";
|
||||
5 = "Spikes";
|
||||
6 = "Death Pit (Camera Tilt)";
|
||||
7 = "Death Pit (No Camera Tilt)";
|
||||
8 = "Instant Kill";
|
||||
9 = "Ring Drainer (Floor Touch)";
|
||||
10 = "Ring Drainer (Anywhere in Sector)";
|
||||
11 = "Special Stage Damage";
|
||||
12 = "Space Countdown";
|
||||
13 = "Ramp Sector (double step-up/down)";
|
||||
14 = "Non-Ramp Sector (no step-down)";
|
||||
15 = "Bouncy FOF";
|
||||
}
|
||||
|
||||
second
|
||||
{
|
||||
0 = "Normal";
|
||||
16 = "Trigger Line Ex. (Pushable Objects)";
|
||||
32 = "Trigger Line Ex. (Anywhere, All Players)";
|
||||
48 = "Trigger Line Ex. (Floor Touch, All Players)";
|
||||
64 = "Trigger Line Ex. (Anywhere in Sector)";
|
||||
80 = "Trigger Line Ex. (Floor Touch)";
|
||||
96 = "Trigger Line Ex. (Emerald Check)";
|
||||
112 = "Trigger Line Ex. (NiGHTS Mare)";
|
||||
128 = "Check for Linedef Executor on FOFs";
|
||||
144 = "Egg Capsule";
|
||||
160 = "Special Stage Time/Spheres Parameters";
|
||||
176 = "Custom Global Gravity";
|
||||
}
|
||||
|
||||
third
|
||||
{
|
||||
0 = "Normal";
|
||||
512 = "Wind/Current";
|
||||
1024 = "Conveyor Belt";
|
||||
1280 = "Speed Pad";
|
||||
}
|
||||
|
||||
fourth
|
||||
{
|
||||
0 = "Normal";
|
||||
4096 = "Star Post Activator";
|
||||
8192 = "Exit/Special Stage Pit/Return Flag";
|
||||
12288 = "CTF Red Team Base";
|
||||
16384 = "CTF Blue Team Base";
|
||||
20480 = "Fan Sector";
|
||||
24576 = "Super Sonic Transform";
|
||||
28672 = "Force Spin";
|
||||
32768 = "Zoom Tube Start";
|
||||
36864 = "Zoom Tube End";
|
||||
40960 = "Circuit Finish Line";
|
||||
45056 = "Rope Hang";
|
||||
49152 = "Intangible to the Camera";
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,38 +0,0 @@
|
|||
/************************************************************************\
|
||||
Ultimate Doom Builder Game Configuration for Sonic Robo Blast 2 Version 2.2
|
||||
\************************************************************************/
|
||||
|
||||
// This is required to prevent accidental use of a different configuration
|
||||
type = "Doom Builder 2 Game Configuration";
|
||||
|
||||
// This is the title to show for this game
|
||||
game = "Sonic Robo Blast 2 - 2.2 (Doom format)";
|
||||
|
||||
// This is the simplified game engine/sourceport name
|
||||
engine = "zdoom";
|
||||
|
||||
// Settings common to all games and all map formats
|
||||
include("Includes\\SRB222_common.cfg", "common");
|
||||
|
||||
// Settings common to Doom map format
|
||||
include("Includes\\SRB222_common.cfg", "mapformat_doom");
|
||||
|
||||
include("Includes\\Game_SRB222.cfg");
|
||||
|
||||
// Script lumps detection
|
||||
scriptlumpnames
|
||||
{
|
||||
include("Includes\\SRB222_misc.cfg", "scriptlumpnames");
|
||||
}
|
||||
|
||||
// THING TYPES
|
||||
thingtypes
|
||||
{
|
||||
include("Includes\\SRB222_things.cfg");
|
||||
}
|
||||
|
||||
//Default things filters
|
||||
thingsfilters
|
||||
{
|
||||
include("Includes\\SRB222_misc.cfg", "thingsfilters");
|
||||
}
|
|
@ -25,12 +25,6 @@ scriptlumpnames
|
|||
include("Includes\\SRB222_misc.cfg", "scriptlumpnames");
|
||||
}
|
||||
|
||||
// THING TYPES
|
||||
thingtypes
|
||||
{
|
||||
include("Includes\\SRB222_things.cfg");
|
||||
}
|
||||
|
||||
//Default things filters
|
||||
thingsfilters
|
||||
{
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<IncludePath>$(SolutionDir)libs\fmodex\inc;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)libs\fmodex\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup />
|
||||
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>fmodexL64_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x86'">
|
||||
<Link>
|
||||
<AdditionalDependencies>fmodexL_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Bugs are now managed in the SDL bug tracker, here:
|
||||
Bugs are now managed in the SDL issue tracker, here:
|
||||
|
||||
https://bugzilla.libsdl.org/
|
||||
https://github.com/libsdl-org/SDL/issues
|
||||
|
||||
You may report bugs there, and search to see if a given issue has already
|
||||
been reported, discussed, and maybe even fixed.
|
||||
|
@ -11,6 +11,6 @@ You may also find help at the SDL forums/mailing list:
|
|||
|
||||
https://discourse.libsdl.org/
|
||||
|
||||
Bug reports are welcome here, but we really appreciate if you use Bugzilla, as
|
||||
bugs discussed on the mailing list may be forgotten or missed.
|
||||
Bug reports are welcome here, but we really appreciate if you use the issue
|
||||
tracker, as bugs discussed on the mailing list may be forgotten or missed.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.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
|
||||
|
|
|
@ -1,6 +1,247 @@
|
|||
|
||||
This is a list of major changes in SDL's version history.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.20:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
General:
|
||||
* SDL_RenderGeometryRaw() takes a pointer to SDL_Color, not int. You can cast color data in SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888 on little endian systems) for this parameter.
|
||||
* Improved accuracy of horizontal and vertical line drawing when using OpenGL or OpenGLES
|
||||
* Added the hint SDL_HINT_RENDER_LINE_METHOD to control the method of line drawing used, to select speed, correctness, and compatibility.
|
||||
|
||||
Windows:
|
||||
* Fixed size of custom cursors
|
||||
|
||||
Linux:
|
||||
* Fixed hotplug controller detection, broken in 2.0.18
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.18:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
General:
|
||||
* The SDL wiki documentation and development headers are automatically kept in sync
|
||||
* Each function has information about in which version of SDL it was introduced
|
||||
* SDL-specific CMake options are now prefixed with 'SDL_'. Be sure to update your CMake build scripts accordingly!
|
||||
* Added the hint SDL_HINT_APP_NAME to let SDL know the name of your application for various places it might show up in system information
|
||||
* Added SDL_RenderGeometry() and SDL_RenderGeometryRaw() to allow rendering of arbitrary shapes using the SDL 2D render API
|
||||
* Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate application data with an SDL texture
|
||||
* Added SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() to convert between window coordinates and logical render coordinates
|
||||
* Added SDL_RenderSetVSync() to change whether a renderer present is synchronized with vblank at runtime
|
||||
* Added SDL_PremultiplyAlpha() to premultiply alpha on a block of SDL_PIXELFORMAT_ARGB8888 pixels
|
||||
* Added a window event SDL_WINDOWEVENT_DISPLAY_CHANGED which is sent when a window changes what display it's centered on
|
||||
* Added SDL_GetWindowICCProfile() to query a window's ICC profile, and a window event SDL_WINDOWEVENT_ICCPROF_CHANGED that is sent when it changes
|
||||
* Added the hint SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY to allow EGL windows to be transparent instead of opaque
|
||||
* SDL_WaitEvent() has been redesigned to use less CPU in most cases
|
||||
* Added SDL_SetWindowMouseRect() and SDL_GetWindowMouseRect() to confine the mouse cursor to an area of a window
|
||||
* You can now read precise mouse wheel motion using 'preciseX' and 'preciseY' event fields
|
||||
* Added SDL_GameControllerHasRumble() and SDL_GameControllerHasRumbleTriggers() to query whether a game controller supports rumble
|
||||
* Added SDL_JoystickHasRumble() and SDL_JoystickHasRumbleTriggers() to query whether a joystick supports rumble
|
||||
* SDL's hidapi implementation is now available as a public API in SDL_hidapi.h
|
||||
|
||||
Windows:
|
||||
* Improved relative mouse motion over Windows Remote Desktop
|
||||
* Added the hint SDL_HINT_IME_SHOW_UI to show native UI components instead of hiding them (defaults off)
|
||||
|
||||
Windows/UWP:
|
||||
* WGI is used instead of XInput for better controller support in UWP apps
|
||||
|
||||
Linux:
|
||||
* Added the hint SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME to set the activity that's displayed by the system when the screensaver is disabled
|
||||
* Added the hint SDL_HINT_LINUX_JOYSTICK_CLASSIC to control whether /dev/input/js* or /dev/input/event* are used as joystick devices
|
||||
* Added the hint SDL_HINT_JOYSTICK_DEVICE to allow the user to specify devices that will be opened in addition to the normal joystick detection
|
||||
* Added SDL_LinuxSetThreadPriorityAndPolicy() for more control over a thread priority on Linux
|
||||
|
||||
Android:
|
||||
* Added support for audio output and capture using AAudio on Android 8.1 and newer
|
||||
* Steam Controller support is disabled by default, and can be enabled by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init()
|
||||
|
||||
Apple Arcade:
|
||||
* Added SDL_GameControllerGetAppleSFSymbolsNameForButton() and SDL_GameControllerGetAppleSFSymbolsNameForAxis() to support Apple Arcade titles
|
||||
|
||||
iOS:
|
||||
* Added documentation that the UIApplicationSupportsIndirectInputEvents key must be set to true in your application's Info.plist in order to get real Bluetooth mouse events.
|
||||
* Steam Controller support is disabled by default, and can be enabled by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init()
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.16:
|
||||
---------------------------------------------------------------------------
|
||||
General:
|
||||
* Added SDL_FlashWindow() to get a user's attention
|
||||
* Added SDL_GetAudioDeviceSpec() to get the preferred audio format of a device
|
||||
* Added SDL_SetWindowAlwaysOnTop() to dynamically change the SDL_WINDOW_ALWAYS_ON_TOP flag for a window
|
||||
* Added SDL_SetWindowKeyboardGrab() to support grabbing the keyboard independently of the mouse
|
||||
* Added SDL_SoftStretchLinear() to do bilinear scaling between 32-bit software surfaces
|
||||
* Added SDL_UpdateNVTexture() to update streaming NV12/21 textures
|
||||
* Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow sending custom trigger effects to the DualSense controller
|
||||
* Added SDL_GameControllerGetSensorDataRate() to get the sensor data rate for PlayStation and Nintendo Switch controllers
|
||||
* Added support for the Amazon Luna game controller
|
||||
* Added rumble support for the Google Stadia controller using the HIDAPI driver
|
||||
* Added SDL_GameControllerType constants for the Amazon Luna and Google Stadia controllers
|
||||
* Added analog rumble for Nintendo Switch Pro controllers using the HIDAPI driver
|
||||
* Reduced CPU usage when using SDL_WaitEvent() and SDL_WaitEventTimeout()
|
||||
|
||||
Windows:
|
||||
* Added SDL_SetWindowsMessageHook() to set a function that is called for all Windows messages
|
||||
* Added SDL_RenderGetD3D11Device() to get the D3D11 device used by the SDL renderer
|
||||
|
||||
Linux:
|
||||
* Greatly improved Wayland support
|
||||
* Added support for audio output and capture using Pipewire
|
||||
* Added the hint SDL_HINT_AUDIO_INCLUDE_MONITORS to control whether PulseAudio recording should include monitor devices
|
||||
* Added the hint SDL_HINT_AUDIO_DEVICE_STREAM_ROLE to describe the role of your application for audio control panels
|
||||
|
||||
Android:
|
||||
* Added SDL_AndroidShowToast() to show a lightweight notification
|
||||
|
||||
iOS:
|
||||
* Added support for mouse relative mode on iOS 14.1 and newer
|
||||
* Added support for the Xbox Series X controller
|
||||
|
||||
tvOS:
|
||||
* Added support for the Xbox Series X controller
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.14:
|
||||
---------------------------------------------------------------------------
|
||||
General:
|
||||
* Added support for PS5 DualSense and Xbox Series X controllers to the HIDAPI controller driver
|
||||
* Added game controller button constants for paddles and new buttons
|
||||
* Added game controller functions to get additional information:
|
||||
* SDL_GameControllerGetSerial()
|
||||
* SDL_GameControllerHasAxis()
|
||||
* SDL_GameControllerHasButton()
|
||||
* SDL_GameControllerGetNumTouchpads()
|
||||
* SDL_GameControllerGetNumTouchpadFingers()
|
||||
* SDL_GameControllerGetTouchpadFinger()
|
||||
* SDL_GameControllerHasSensor()
|
||||
* SDL_GameControllerSetSensorEnabled()
|
||||
* SDL_GameControllerIsSensorEnabled()
|
||||
* SDL_GameControllerGetSensorData()
|
||||
* SDL_GameControllerRumbleTriggers()
|
||||
* SDL_GameControllerHasLED()
|
||||
* SDL_GameControllerSetLED()
|
||||
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_PS5 to control whether the HIDAPI driver for PS5 controllers should be used.
|
||||
* Added joystick functions to get additional information:
|
||||
* SDL_JoystickGetSerial()
|
||||
* SDL_JoystickRumbleTriggers()
|
||||
* SDL_JoystickHasLED()
|
||||
* SDL_JoystickSetLED()
|
||||
* Added an API to allow the application to create virtual joysticks:
|
||||
* SDL_JoystickAttachVirtual()
|
||||
* SDL_JoystickDetachVirtual()
|
||||
* SDL_JoystickIsVirtual()
|
||||
* SDL_JoystickSetVirtualAxis()
|
||||
* SDL_JoystickSetVirtualButton()
|
||||
* SDL_JoystickSetVirtualHat()
|
||||
* Added SDL_LockSensors() and SDL_UnlockSensors() to guarantee exclusive access to the sensor list
|
||||
* Added SDL_HAPTIC_STEERING_AXIS to play an effect on the steering wheel
|
||||
* Added the hint SDL_HINT_MOUSE_RELATIVE_SCALING to control whether relative motion is scaled by the screen DPI or renderer logical size
|
||||
* The default value for SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS is now false for better compatibility with modern window managers
|
||||
* Added SDL_GetPreferredLocales() to get the application's current locale setting
|
||||
* Added the hint SDL_HINT_PREFERRED_LOCALES to override your application's default locale setting
|
||||
* Added SDL_OpenURL() to open a URL in the system's default browser
|
||||
* Added SDL_HasSurfaceRLE() to tell whether a surface is currently using RLE encoding
|
||||
* Added SDL_SIMDRealloc() to reallocate memory obtained from SDL_SIMDAlloc()
|
||||
* Added SDL_GetErrorMsg() to get the last error in a thread-safe way
|
||||
* Added SDL_crc32(), SDL_wcscasecmp(), SDL_wcsncasecmp(), SDL_trunc(), SDL_truncf()
|
||||
* Added clearer names for RGB pixel formats, e.g. SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, etc.
|
||||
|
||||
Windows:
|
||||
* Added the RAWINPUT controller driver to support more than 4 Xbox controllers simultaneously
|
||||
* Added the hint SDL_HINT_JOYSTICK_RAWINPUT to control whether the RAWINPUT driver should be used
|
||||
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_CORRELATE_XINPUT to control whether XInput and WGI should be used to for complete controller functionality with the RAWINPUT driver.
|
||||
|
||||
macOS:
|
||||
* Added the SDL_WINDOW_METAL flag to specify that a window should be created with a Metal view
|
||||
* Added SDL_Metal_GetLayer() to get the CAMetalLayer backing a Metal view
|
||||
* Added SDL_Metal_GetDrawableSize() to get the size of a window's drawable, in pixels
|
||||
|
||||
Linux:
|
||||
* Added the hint SDL_HINT_AUDIO_DEVICE_APP_NAME to specify the name that shows up in PulseAudio for your application
|
||||
* Added the hint SDL_HINT_AUDIO_DEVICE_STREAM_NAME to specify the name that shows up in PulseAudio associated with your audio stream
|
||||
* Added the hint SDL_HINT_LINUX_JOYSTICK_DEADZONES to control whether HID defined dead zones should be respected on Linux
|
||||
* Added the hint SDL_HINT_THREAD_PRIORITY_POLICY to specify the thread scheduler policy
|
||||
* Added the hint SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL to allow time critical threads to use a realtime scheduling policy
|
||||
|
||||
Android:
|
||||
* Added SDL_AndroidRequestPermission() to request a specific system permission
|
||||
* Added the hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO to control whether audio will pause when the application goes intot he background
|
||||
|
||||
OS/2:
|
||||
* Added support for OS/2, see docs/README-os2.md for details
|
||||
|
||||
Emscripten (running in a web browser):
|
||||
* Added the hint SDL_HINT_EMSCRIPTEN_ASYNCIFY to control whether SDL should call emscripten_sleep internally
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.12:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
General:
|
||||
* Added SDL_GetTextureScaleMode() and SDL_SetTextureScaleMode() to get and set the scaling mode used for a texture
|
||||
* Added SDL_LockTextureToSurface(), similar to SDL_LockTexture() but the locked area is exposed as a SDL surface.
|
||||
* Added new blend mode, SDL_BLENDMODE_MUL, which does a modulate and blend operation
|
||||
* Added the hint SDL_HINT_DISPLAY_USABLE_BOUNDS to override the results of SDL_GetDisplayUsableBounds() for display index 0.
|
||||
* Added the window underneath the finger to the SDL_TouchFingerEvent
|
||||
* Added SDL_GameControllerTypeForIndex(), SDL_GameControllerGetType() to return the type of a game controller (Xbox 360, Xbox One, PS3, PS4, or Nintendo Switch Pro)
|
||||
* Added the hint SDL_HINT_GAMECONTROLLERTYPE to override the automatic game controller type detection
|
||||
* Added SDL_JoystickFromPlayerIndex() and SDL_GameControllerFromPlayerIndex() to get the device associated with a player index
|
||||
* Added SDL_JoystickSetPlayerIndex() and SDL_GameControllerSetPlayerIndex() to set the player index associated with a device
|
||||
* Added the hint SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to specify whether Nintendo Switch Pro controllers should use the buttons as labeled or swapped to match positional layout. The default is to use the buttons as labeled.
|
||||
* Added support for Nintendo GameCube controllers to the HIDAPI driver, and a hint SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE to control whether this is used.
|
||||
* Improved support for Xbox 360 and Xbox One controllers when using the HIDAPI driver
|
||||
* Added support for many game controllers, including:
|
||||
* 8BitDo FC30 Pro
|
||||
* 8BitDo M30 GamePad
|
||||
* BDA PS4 Fightpad
|
||||
* HORI Fighting Commander
|
||||
* Hyperkin Duke
|
||||
* Hyperkin X91
|
||||
* MOGA XP5-A Plus
|
||||
* NACON GC-400ES
|
||||
* NVIDIA Controller v01.04
|
||||
* PDP Versus Fighting Pad
|
||||
* Razer Raion Fightpad for PS4
|
||||
* Razer Serval
|
||||
* Stadia Controller
|
||||
* SteelSeries Stratus Duo
|
||||
* Victrix Pro Fight Stick for PS4
|
||||
* Xbox One Elite Series 2
|
||||
* Fixed blocking game controller rumble calls when using the HIDAPI driver
|
||||
* Added SDL_zeroa() macro to zero an array of elements
|
||||
* Added SDL_HasARMSIMD() which returns true if the CPU has ARM SIMD (ARMv6+) features
|
||||
|
||||
Windows:
|
||||
* Fixed crash when using the release SDL DLL with applications built with gcc
|
||||
* Fixed performance regression in event handling introduced in 2.0.10
|
||||
* Added support for SDL_SetThreadPriority() for UWP applications
|
||||
|
||||
Linux:
|
||||
* Added the hint SDL_HINT_VIDEO_X11_WINDOW_VISUALID to specify the visual chosen for new X11 windows
|
||||
* Added the hint SDL_HINT_VIDEO_X11_FORCE_EGL to specify whether X11 should use GLX or EGL by default
|
||||
|
||||
iOS / tvOS / macOS:
|
||||
* Added SDL_Metal_CreateView() and SDL_Metal_DestroyView() to create CAMetalLayer-backed NSView/UIView and attach it to the specified window.
|
||||
|
||||
iOS/ tvOS:
|
||||
* Added support for Bluetooth Steam Controllers as game controllers
|
||||
|
||||
tvOS:
|
||||
* Fixed support for surround sound on Apple TV
|
||||
|
||||
Android:
|
||||
* Added SDL_GetAndroidSDKVersion() to return the API level of the current device
|
||||
* Added support for audio capture using OpenSL-ES
|
||||
* Added support for Bluetooth Steam Controllers as game controllers
|
||||
* Fixed rare crashes when the app goes into the background or terminates
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.10:
|
||||
---------------------------------------------------------------------------
|
||||
|
|
|
@ -10,8 +10,7 @@ If you are using the older ant build process, it is no longer officially
|
|||
supported, but you can use the "android-project-ant" directory as a template.
|
||||
|
||||
|
||||
================================================================================
|
||||
Requirements
|
||||
Requirements
|
||||
================================================================================
|
||||
|
||||
Android SDK (version 26 or later)
|
||||
|
@ -23,8 +22,7 @@ https://developer.android.com/tools/sdk/ndk/index.html
|
|||
Minimum API level supported by SDL: 16 (Android 4.1)
|
||||
|
||||
|
||||
================================================================================
|
||||
How the port works
|
||||
How the port works
|
||||
================================================================================
|
||||
|
||||
- Android applications are Java-based, optionally with parts written in C
|
||||
|
@ -42,8 +40,7 @@ dispatches to native functions implemented in the SDL library:
|
|||
src/core/android/SDL_android.c
|
||||
|
||||
|
||||
================================================================================
|
||||
Building an app
|
||||
Building an app
|
||||
================================================================================
|
||||
|
||||
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
||||
|
@ -82,6 +79,23 @@ For more complex projects, follow these instructions:
|
|||
|
||||
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
||||
|
||||
|
||||
If you already have a project that uses CMake, the instructions change somewhat:
|
||||
|
||||
1. Do points 1 and 2 from the instruction above.
|
||||
2. Edit "<project>/app/build.gradle" to comment out or remove sections containing ndk-build
|
||||
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
|
||||
3. Edit "<project>/app/jni/CMakeLists.txt" to include your project (it defaults to
|
||||
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
||||
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
||||
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
|
||||
add_executable() for the target containing your "main" function.
|
||||
|
||||
If you wish to use Android Studio, you can skip the last step.
|
||||
|
||||
4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
|
||||
connected Android device
|
||||
|
||||
Here's an explanation of the files in the Android project, so you can customize them:
|
||||
|
||||
android-project/app
|
||||
|
@ -90,10 +104,12 @@ Here's an explanation of the files in the Android project, so you can customize
|
|||
jni/ - directory holding native code
|
||||
jni/Application.mk - Application JNI settings, including target platform and STL library
|
||||
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
|
||||
jni/CMakeLists.txt - Top-level CMake project that adds SDL as a subproject
|
||||
jni/SDL/ - (symlink to) 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
|
||||
jni/src/CMakeLists.txt - CMake file that you may customize to include your source code and any library references
|
||||
src/main/assets/ - directory holding asset files for your application
|
||||
src/main/res/ - directory holding resources for your application
|
||||
src/main/res/mipmap-* - directories holding icons for different phone hardware
|
||||
|
@ -101,8 +117,7 @@ Here's an explanation of the files in the Android project, so you can customize
|
|||
src/main/java/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. You should instead subclass this for your application.
|
||||
|
||||
|
||||
================================================================================
|
||||
Customizing your application name
|
||||
Customizing your application name
|
||||
================================================================================
|
||||
|
||||
To customize your application name, edit AndroidManifest.xml and replace
|
||||
|
@ -132,8 +147,7 @@ Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
|||
class, .e.g. "MyGame"
|
||||
|
||||
|
||||
================================================================================
|
||||
Customizing your application icon
|
||||
Customizing your application icon
|
||||
================================================================================
|
||||
|
||||
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
||||
|
@ -141,8 +155,7 @@ the drawable directories under the res directory. There are several directories
|
|||
for different screen sizes.
|
||||
|
||||
|
||||
================================================================================
|
||||
Loading assets
|
||||
Loading assets
|
||||
================================================================================
|
||||
|
||||
Any files you put in the "app/src/main/assets" directory of your project
|
||||
|
@ -170,8 +183,7 @@ disable this behaviour, see for example:
|
|||
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
||||
|
||||
|
||||
================================================================================
|
||||
Pause / Resume behaviour
|
||||
Pause / Resume behaviour
|
||||
================================================================================
|
||||
|
||||
If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default),
|
||||
|
@ -186,13 +198,37 @@ app can continue to operate as it was.
|
|||
|
||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||
where the GL context can not be restored. In that case you have to listen for
|
||||
a specific message, (which is not yet implemented!) and restore your textures
|
||||
manually or quit the app (which is actually the kind of behaviour you'll see
|
||||
under iOS, if the OS can not restore your GL context it will just kill your app)
|
||||
a specific message (SDL_RENDER_DEVICE_RESET) and restore your textures
|
||||
manually or quit the app.
|
||||
|
||||
You should not use the SDL renderer API while the app going in background:
|
||||
- SDL_APP_WILLENTERBACKGROUND:
|
||||
after you read this message, GL context gets backed-up and you should not
|
||||
use the SDL renderer API.
|
||||
|
||||
- SDL_APP_DIDENTERFOREGROUND:
|
||||
GL context is restored, and the SDL renderer API is available (unless you
|
||||
receive SDL_RENDER_DEVICE_RESET).
|
||||
|
||||
Mouse / Touch events
|
||||
================================================================================
|
||||
Threads and the Java VM
|
||||
|
||||
In some case, SDL generates synthetic mouse (resp. touch) events for touch
|
||||
(resp. mouse) devices.
|
||||
To enable/disable this behavior, see SDL_hints.h:
|
||||
- SDL_HINT_TOUCH_MOUSE_EVENTS
|
||||
- SDL_HINT_MOUSE_TOUCH_EVENTS
|
||||
|
||||
Misc
|
||||
================================================================================
|
||||
|
||||
For some device, it appears to works better setting explicitly GL attributes
|
||||
before creating a window:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
|
||||
Threads and the Java VM
|
||||
================================================================================
|
||||
|
||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||
|
@ -207,8 +243,17 @@ your thread automatically anyway (when you make an SDL call), but it'll never
|
|||
detach it.
|
||||
|
||||
|
||||
================================================================================
|
||||
Using STL
|
||||
If you ever want to use JNI in a native thread (created by "SDL_CreateThread()"),
|
||||
it won't be able to find your java class and method because of the java class loader
|
||||
which is different for native threads, than for java threads (eg your "main()").
|
||||
|
||||
the work-around is to find class/method, in you "main()" thread, and to use them
|
||||
in your native thread.
|
||||
|
||||
see:
|
||||
https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
|
||||
|
||||
Using STL
|
||||
================================================================================
|
||||
|
||||
You can use STL in your project by creating an Application.mk file in the jni
|
||||
|
@ -220,8 +265,7 @@ For more information go here:
|
|||
https://developer.android.com/ndk/guides/cpp-support
|
||||
|
||||
|
||||
================================================================================
|
||||
Using the emulator
|
||||
Using the emulator
|
||||
================================================================================
|
||||
|
||||
There are some good tips and tricks for getting the most out of the
|
||||
|
@ -233,8 +277,7 @@ Notice that this software emulator is incredibly slow and needs a lot of disk sp
|
|||
Using a real device works better.
|
||||
|
||||
|
||||
================================================================================
|
||||
Troubleshooting
|
||||
Troubleshooting
|
||||
================================================================================
|
||||
|
||||
You can see if adb can see any devices with the following command:
|
||||
|
@ -313,8 +356,7 @@ If you need to build without optimization turned on, you can create a file calle
|
|||
APP_OPTIM := debug
|
||||
|
||||
|
||||
================================================================================
|
||||
Memory debugging
|
||||
Memory debugging
|
||||
================================================================================
|
||||
|
||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||
|
@ -365,8 +407,7 @@ When you're done instrumenting with valgrind, you can disable the wrapper:
|
|||
adb shell setprop wrap.org.libsdl.app ""
|
||||
|
||||
|
||||
================================================================================
|
||||
Graphics debugging
|
||||
Graphics debugging
|
||||
================================================================================
|
||||
|
||||
If you are developing on a compatible Tegra-based tablet, NVidia provides
|
||||
|
@ -379,8 +420,7 @@ The Tegra Graphics Debugger is available from NVidia here:
|
|||
https://developer.nvidia.com/tegra-graphics-debugger
|
||||
|
||||
|
||||
================================================================================
|
||||
Why is API level 16 the minimum required?
|
||||
Why is API level 16 the minimum required?
|
||||
================================================================================
|
||||
|
||||
The latest NDK toolchain doesn't support targeting earlier than API level 16.
|
||||
|
@ -389,8 +429,7 @@ about 99% of the Android devices accessing Google Play support API level 16 or
|
|||
higher (January 2018).
|
||||
|
||||
|
||||
================================================================================
|
||||
A note regarding the use of the "dirty rectangles" rendering technique
|
||||
A note regarding the use of the "dirty rectangles" rendering technique
|
||||
================================================================================
|
||||
|
||||
If your app uses a variation of the "dirty rectangles" rendering technique,
|
||||
|
@ -408,8 +447,7 @@ screen each frame.
|
|||
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
||||
|
||||
|
||||
================================================================================
|
||||
Ending your application
|
||||
Ending your application
|
||||
================================================================================
|
||||
|
||||
Two legitimate ways:
|
||||
|
@ -426,8 +464,7 @@ Don't call exit() as it stops the activity badly.
|
|||
NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode
|
||||
SDLK_AC_BACK, for any purpose.
|
||||
|
||||
================================================================================
|
||||
Known issues
|
||||
Known issues
|
||||
================================================================================
|
||||
|
||||
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
||||
|
|
|
@ -15,7 +15,7 @@ platforms:
|
|||
* Linux
|
||||
* VS.NET 2010
|
||||
* MinGW and Msys
|
||||
* OS X with support for XCode
|
||||
* macOS, iOS, and tvOS, with support for XCode
|
||||
|
||||
|
||||
================================================================================
|
||||
|
@ -30,3 +30,55 @@ Assuming the source for SDL is located at ~/sdl
|
|||
cmake ../sdl
|
||||
|
||||
This will build the static and dynamic versions of SDL in the ~/build directory.
|
||||
|
||||
|
||||
================================================================================
|
||||
Usage, iOS/tvOS
|
||||
================================================================================
|
||||
|
||||
CMake 3.14+ natively includes support for iOS and tvOS. SDL binaries may be built
|
||||
using Xcode or Make, possibly among other build-systems.
|
||||
|
||||
When using a recent version of CMake (3.14+), it should be possible to:
|
||||
|
||||
- build SDL for iOS, both static and dynamic
|
||||
- build SDL test apps (as iOS/tvOS .app bundles)
|
||||
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
|
||||
|
||||
To use, set the following CMake variables when running CMake's configuration stage:
|
||||
|
||||
- `CMAKE_SYSTEM_NAME=<OS>` (either `iOS` or `tvOS`)
|
||||
- `CMAKE_OSX_SYSROOT=<SDK>` (examples: `iphoneos`, `iphonesimulator`, `iphoneos12.4`, `/full/path/to/iPhoneOS.sdk`,
|
||||
`appletvos`, `appletvsimulator`, `appletvos12.4`, `/full/path/to/AppleTVOS.sdk`, etc.)
|
||||
- `CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures>` (example: "arm64;armv7s;x86_64")
|
||||
|
||||
|
||||
### Examples (for iOS/tvOS):
|
||||
|
||||
- for iOS-Simulator, using the latest, installed SDK:
|
||||
|
||||
`cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64`
|
||||
|
||||
- for iOS-Device, using the latest, installed SDK, 64-bit only
|
||||
|
||||
`cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64`
|
||||
|
||||
- for iOS-Device, using the latest, installed SDK, mixed 32/64 bit
|
||||
|
||||
`cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"`
|
||||
|
||||
- for iOS-Device, using a specific SDK revision (iOS 12.4, in this example):
|
||||
|
||||
`cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64`
|
||||
|
||||
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
||||
|
||||
`cmake ~/sdl -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64`
|
||||
|
||||
- for tvOS-Simulator, using the latest, installed SDK:
|
||||
|
||||
`cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_ARCHITECTURES=x86_64`
|
||||
|
||||
- for tvOS-Device, using the latest, installed SDK:
|
||||
|
||||
`cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
Dynamic API
|
||||
================================================================================
|
||||
Originally posted by Ryan at:
|
||||
https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U
|
||||
# Dynamic API
|
||||
|
||||
Originally posted on Ryan's Google+ account.
|
||||
|
||||
Background:
|
||||
|
||||
|
@ -35,10 +34,12 @@ So here's what we did:
|
|||
SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
||||
now looks like:
|
||||
|
||||
UInt32 SDL_Init(Uint32 flags)
|
||||
{
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```c
|
||||
UInt32 SDL_Init(Uint32 flags)
|
||||
{
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```
|
||||
|
||||
Except that is all done with a bunch of macro magic so we don't have to maintain
|
||||
every one of these.
|
||||
|
@ -47,22 +48,26 @@ What is jump_table.SDL_init()? Eventually, that's a function pointer of the real
|
|||
SDL_Init() that you've been calling all this time. But at startup, it looks more
|
||||
like this:
|
||||
|
||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||
{
|
||||
SDL_InitDynamicAPI();
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```c
|
||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||
{
|
||||
SDL_InitDynamicAPI();
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```
|
||||
|
||||
SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function
|
||||
pointers, which means that this _DEFAULT function never gets called again.
|
||||
pointers, which means that this `_DEFAULT` function never gets called again.
|
||||
First call to any SDL function sets the whole thing up.
|
||||
|
||||
So you might be asking, what was the value in that? Isn't this what the operating
|
||||
system's dynamic loader was supposed to do for us? Yes, but now we've got this
|
||||
level of indirection, we can do things like this:
|
||||
|
||||
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
||||
./MyGameThatIsStaticallyLinkedToSDL2
|
||||
```bash
|
||||
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
||||
./MyGameThatIsStaticallyLinkedToSDL2
|
||||
```
|
||||
|
||||
And now, this game that is statically linked to SDL, can still be overridden
|
||||
with a newer, or better, SDL. The statically linked one will only be used as
|
||||
|
@ -94,7 +99,9 @@ SDL's function pointers (which might be statically linked into a program, or in
|
|||
a shared library of its own). If so, it loads that library and looks for and
|
||||
calls a single function:
|
||||
|
||||
SInt32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
||||
```c
|
||||
SInt32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
||||
```
|
||||
|
||||
That function takes a version number (more on that in a moment), the address of
|
||||
the jump table, and the size, in bytes, of the table.
|
||||
|
@ -116,6 +123,7 @@ Steam Client, this isn't a bad option.
|
|||
|
||||
Finally, I'm sure some people are reading this and thinking,
|
||||
"I don't want that overhead in my project!"
|
||||
|
||||
To which I would point out that the extra function call through the jump table
|
||||
probably wouldn't even show up in a profile, but lucky you: this can all be
|
||||
disabled. You can build SDL without this if you absolutely must, but we would
|
||||
|
|
19
libs/SDL2/docs/README-git.md
Normal file
19
libs/SDL2/docs/README-git.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
git
|
||||
=========
|
||||
|
||||
The latest development version of SDL is available via git.
|
||||
Git allows you to get up-to-the-minute fixes and enhancements;
|
||||
as a developer works on a source tree, you can use "git" to mirror that
|
||||
source tree instead of waiting for an official release. Please look
|
||||
at the Git website ( https://git-scm.com/ ) for more
|
||||
information on using git, where you can also download software for
|
||||
macOS, Windows, and Unix systems.
|
||||
|
||||
git clone https://github.com/libsdl-org/SDL
|
||||
|
||||
If you are building SDL via configure, you will need to run autogen.sh
|
||||
before running configure.
|
||||
|
||||
There is a web interface to the Git repository at:
|
||||
http://github.com/libsdl-org/SDL/
|
||||
|
|
@ -1,22 +1,4 @@
|
|||
Mercurial
|
||||
=========
|
||||
We are no longer hosted in Mercurial. Please see README-git.md for details.
|
||||
|
||||
The latest development version of SDL is available via Mercurial.
|
||||
Mercurial allows you to get up-to-the-minute fixes and enhancements;
|
||||
as a developer works on a source tree, you can use "hg" to mirror that
|
||||
source tree instead of waiting for an official release. Please look
|
||||
at the Mercurial website ( https://www.mercurial-scm.org/ ) for more
|
||||
information on using hg, where you can also download software for
|
||||
Mac OS X, Windows, and Unix systems.
|
||||
|
||||
hg clone http://hg.libsdl.org/SDL
|
||||
|
||||
If you are building SDL via configure, you will need to run autogen.sh
|
||||
before running configure.
|
||||
|
||||
There is a web interface to the subversion repository at:
|
||||
http://hg.libsdl.org/SDL/
|
||||
|
||||
There is an RSS feed available at that URL, for those that want to
|
||||
track commits in real time.
|
||||
Thanks!
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
iOS
|
||||
======
|
||||
|
||||
==============================================================================
|
||||
Building the Simple DirectMedia Layer for iOS 5.1+
|
||||
==============================================================================
|
||||
|
||||
|
@ -9,57 +8,29 @@ Requirements: Mac OS X 10.8 or later and the iOS 7+ SDK.
|
|||
|
||||
Instructions:
|
||||
|
||||
1. Open SDL.xcodeproj (located in Xcode-iOS/SDL) in Xcode.
|
||||
2. Select your desired target, and hit build.
|
||||
|
||||
There are three build targets:
|
||||
- libSDL.a:
|
||||
Build SDL as a statically linked library
|
||||
- testsdl:
|
||||
Build a test program (there are known test failures which are fine)
|
||||
- Template:
|
||||
Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
|
||||
1. Open SDL.xcodeproj (located in Xcode/SDL) in Xcode.
|
||||
2. Select your desired target, and hit build.
|
||||
|
||||
|
||||
==============================================================================
|
||||
Build SDL for iOS from the command line
|
||||
==============================================================================
|
||||
|
||||
1. cd (PATH WHERE THE SDL CODE IS)/build-scripts
|
||||
2. ./iosbuild.sh
|
||||
|
||||
If everything goes fine, you should see a build/ios directory, inside there's
|
||||
two directories "lib" and "include".
|
||||
"include" contains a copy of the SDL headers that you'll need for your project,
|
||||
make sure to configure XCode to look for headers there.
|
||||
"lib" contains find two files, libSDL2.a and libSDL2main.a, you have to add both
|
||||
to your XCode project. These libraries contain three architectures in them,
|
||||
armv6 for legacy devices, armv7, and i386 (for the simulator).
|
||||
By default, iosbuild.sh will autodetect the SDK version you have installed using
|
||||
xcodebuild -showsdks, and build for iOS >= 3.0, you can override this behaviour
|
||||
by setting the MIN_OS_VERSION variable, ie:
|
||||
|
||||
MIN_OS_VERSION=4.2 ./iosbuild.sh
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer for iOS
|
||||
==============================================================================
|
||||
|
||||
FIXME: This needs to be updated for the latest methods
|
||||
1. Run Xcode and create a new project using the iOS Game template, selecting the Objective C language and Metal game technology.
|
||||
2. In the main view, delete all files except for Assets and LaunchScreen
|
||||
3. Right click the project in the main view, select "Add Files...", and add the SDL project, Xcode/SDL/SDL.xcodeproj
|
||||
4. Select the project in the main view, go to the "Info" tab and under "Custom iOS Target Properties" remove the line "Main storyboard file base name"
|
||||
5. Select the project in the main view, go to the "Build Settings" tab, select "All", and edit "Header Search Path" and drag over the SDL "Public Headers" folder from the left
|
||||
6. Select the project in the main view, go to the "Build Phases" tab, select "Link Binary With Libraries", and add SDL2.framework from "Framework-iOS"
|
||||
7. Select the project in the main view, go to the "General" tab, scroll down to "Frameworks, Libraries, and Embedded Content", and select "Embed & Sign" for the SDL library.
|
||||
8. In the main view, expand SDL -> Library Source -> main -> uikit and drag SDL_uikit_main.c into your game files
|
||||
9. Add the source files that you would normally have for an SDL program, making sure to have #include "SDL.h" at the top of the file containing your main() function.
|
||||
10. Add any assets that your application needs.
|
||||
11. Enjoy!
|
||||
|
||||
Here is the easiest method:
|
||||
1. Build the SDL library (libSDL2.a) and the iPhone SDL Application template.
|
||||
2. Install the iPhone SDL Application template by copying it to one of Xcode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/Xcode/Project Templates/" and placing it there.
|
||||
3. Start a new project using the template. The project should be immediately ready for use with SDL.
|
||||
|
||||
Here is a more manual method:
|
||||
1. Create a new iOS view based application.
|
||||
2. Build the SDL static library (libSDL2.a) for iOS and include them in your project. Xcode will ignore the library that is not currently of the correct architecture, hence your app will work both on iOS and in the iOS Simulator.
|
||||
3. Include the SDL header files in your project.
|
||||
4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iOS provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iOS produces its user interface programmatically.
|
||||
5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell Xcode not to use the project prefix file, as it includes Objective-C code.
|
||||
TODO: Add information regarding App Store requirements such as icons, etc.
|
||||
|
||||
|
||||
==============================================================================
|
||||
Notes -- Retina / High-DPI and window sizes
|
||||
==============================================================================
|
||||
|
||||
|
@ -88,7 +59,7 @@ orthographic projection matrix using the size in screen coordinates
|
|||
(SDL_GetWindowSize()) can be used in order to display content at the same scale
|
||||
no matter whether a Retina device is used or not.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Notes -- Application events
|
||||
==============================================================================
|
||||
|
||||
|
@ -151,7 +122,6 @@ e.g.
|
|||
}
|
||||
|
||||
|
||||
==============================================================================
|
||||
Notes -- Accelerometer as Joystick
|
||||
==============================================================================
|
||||
|
||||
|
@ -159,7 +129,7 @@ SDL for iPhone supports polling the built in accelerometer as a joystick device.
|
|||
|
||||
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Notes -- OpenGL ES
|
||||
==============================================================================
|
||||
|
||||
|
@ -179,7 +149,7 @@ OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided i
|
|||
|
||||
The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
|
||||
|
||||
==============================================================================
|
||||
|
||||
Notes -- Keyboard
|
||||
==============================================================================
|
||||
|
||||
|
@ -195,7 +165,12 @@ SDL_bool SDL_IsTextInputActive()
|
|||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||
|
||||
|
||||
Notes -- Mouse
|
||||
==============================================================================
|
||||
|
||||
iOS now supports Bluetooth mice on iPad, but by default will provide the mouse input as touch. In order for SDL to see the real mouse events, you should set the key UIApplicationSupportsIndirectInputEvents to true in your Info.plist
|
||||
|
||||
|
||||
Notes -- Reading and Writing files
|
||||
==============================================================================
|
||||
|
||||
|
@ -215,7 +190,7 @@ When your SDL based iPhone application starts up, it sets the working directory
|
|||
More information on this subject is available here:
|
||||
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
||||
|
||||
==============================================================================
|
||||
|
||||
Notes -- iPhone SDL limitations
|
||||
==============================================================================
|
||||
|
||||
|
@ -228,7 +203,23 @@ Textures:
|
|||
Loading Shared Objects:
|
||||
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h.
|
||||
|
||||
|
||||
Notes -- CoreBluetooth.framework
|
||||
==============================================================================
|
||||
|
||||
SDL_JOYSTICK_HIDAPI is disabled by default. It can give you access to a lot
|
||||
more game controller devices, but it requires permission from the user before
|
||||
your app will be able to talk to the Bluetooth hardware. "Made For iOS"
|
||||
branded controllers do not need this as we don't have to speak to them
|
||||
directly with raw bluetooth, so many apps can live without this.
|
||||
|
||||
You'll need to link with CoreBluetooth.framework and add something like this
|
||||
to your Info.plist:
|
||||
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
|
||||
|
||||
|
||||
Game Center
|
||||
==============================================================================
|
||||
|
||||
|
@ -266,7 +257,7 @@ e.g.
|
|||
return 0;
|
||||
}
|
||||
|
||||
==============================================================================
|
||||
|
||||
Deploying to older versions of iOS
|
||||
==============================================================================
|
||||
|
||||
|
|
27
libs/SDL2/docs/README-kmsbsd.md
Normal file
27
libs/SDL2/docs/README-kmsbsd.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
KMSDRM on *BSD
|
||||
==================================================
|
||||
|
||||
KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. NetBSD isn't supported yet because the application will crash when creating the KMSDRM screen.
|
||||
|
||||
WSCONS support has been brought back, but only as an input backend. It will not be brought back as a video backend to ease maintenance.
|
||||
|
||||
OpenBSD note: Note that the video backend assumes that the user has read/write permissions to the /dev/drm* devices.
|
||||
|
||||
|
||||
SDL2 WSCONS input backend features
|
||||
===================================================
|
||||
1. It is keymap-aware; it will work properly with different keymaps.
|
||||
2. It has mouse support.
|
||||
3. Accent input is supported.
|
||||
4. Compose keys are supported.
|
||||
5. AltGr and Meta Shift keys work as intended.
|
||||
|
||||
Partially working or no input on OpenBSD/NetBSD.
|
||||
==================================================
|
||||
|
||||
The WSCONS input backend needs read/write access to the /dev/wskbd* devices, without which it will not work properly. /dev/wsmouse must also be read/write accessible, otherwise mouse input will not work.
|
||||
|
||||
Partially working or no input on FreeBSD.
|
||||
==================================================
|
||||
|
||||
The evdev devices are only accessible to the root user by default. Edit devfs rules to allow access to such devices. The /dev/kbd* devices are also only accessible to the root user by default. Edit devfs rules to allow access to such devices.
|
|
@ -9,25 +9,35 @@ at runtime, and you won't get a missing library error, at least with the
|
|||
default configuration parameters.
|
||||
|
||||
|
||||
================================================================================
|
||||
Build Dependencies
|
||||
================================================================================
|
||||
|
||||
Ubuntu 13.04, all available features enabled:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
sudo apt-get install build-essential mercurial make cmake autoconf automake \
|
||||
libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \
|
||||
libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \
|
||||
libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \
|
||||
libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \
|
||||
fcitx-libs-dev libsamplerate0-dev libsndio-dev
|
||||
Ubuntu 20.04, all available features enabled:
|
||||
|
||||
Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols"
|
||||
to that command line for Wayland support.
|
||||
sudo apt-get install build-essential git make cmake autoconf automake \
|
||||
libtool pkg-config libasound2-dev libpulse-dev libaudio-dev libjack-dev \
|
||||
libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev \
|
||||
libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev libdbus-1-dev \
|
||||
libudev-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \
|
||||
fcitx-libs-dev libsamplerate0-dev libsndio-dev libwayland-dev \
|
||||
libxkbcommon-dev libdrm-dev libgbm-dev
|
||||
|
||||
Fedora 35, all available features enabled:
|
||||
|
||||
sudo yum install gcc git-core make cmake autoconf automake libtool \
|
||||
alsa-lib-devel pulseaudio-libs-devel nas-devel pipewire-devel \
|
||||
libX11-devel libXext-devel libXrandr-devel libXcursor-devel libXfixes-devel \
|
||||
libXi-devel libXinerama-devel libXxf86vm-devel libXScrnSaver-devel \
|
||||
dbus-devel ibus-devel fcitx-devel systemd-devel mesa-libGL-devel \
|
||||
libxkbcommon-devel mesa-libGLES-devel mesa-libEGL-devel vulkan-devel \
|
||||
wayland-devel wayland-protocols-devel libdrm-devel mesa-libgbm-devel \
|
||||
libusb-devel pipewire-jack-audio-connection-kit-devel libdecor-devel \
|
||||
libsamplerate-devel
|
||||
|
||||
NOTES:
|
||||
- This includes all the audio targets except arts, because Ubuntu pulled the
|
||||
artsc0-dev package, but in theory SDL still supports it.
|
||||
- This includes all the audio targets except arts and esd, because Ubuntu
|
||||
(and/or Debian) pulled their packages, but in theory SDL still supports them.
|
||||
The sndio audio target is also unavailable on Fedora.
|
||||
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
|
||||
for higher-quality audio resampling. SDL will work without it if the library
|
||||
is missing, so it's safe to build in support even if the end user doesn't
|
||||
|
@ -37,9 +47,8 @@ NOTES:
|
|||
configure script to include DirectFB support. Send patches. :)
|
||||
|
||||
|
||||
================================================================================
|
||||
Joystick does not work
|
||||
================================================================================
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
If you compiled or are using a version of SDL with udev support (and you should!)
|
||||
there's a few issues that may cause SDL to fail to detect your joystick. To
|
||||
|
@ -69,8 +78,8 @@ you need to set up an udev rule to force this variable.
|
|||
A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
|
||||
like:
|
||||
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
||||
You can set up similar rules for your device by changing the values listed in
|
||||
idProduct and idVendor. To obtain these values, try:
|
||||
|
|
286
libs/SDL2/docs/README-macos.md
Normal file
286
libs/SDL2/docs/README-macos.md
Normal file
|
@ -0,0 +1,286 @@
|
|||
# Mac OS X (aka macOS).
|
||||
|
||||
These instructions are for people using Apple's Mac OS X (pronounced
|
||||
"ten"), which in newer versions is just referred to as "macOS".
|
||||
|
||||
From the developer's point of view, macOS is a sort of hybrid Mac and
|
||||
Unix system, and you have the option of using either traditional
|
||||
command line tools or Apple's IDE Xcode.
|
||||
|
||||
# Command Line Build
|
||||
|
||||
To build SDL using the command line, use the standard configure and make
|
||||
process:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
CMake is also known to work, although it continues to be a work in progress:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
|
||||
You can also build SDL as a Universal library (a single binary for both
|
||||
64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh
|
||||
script.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
CC=$PWD/../build-scripts/clang-fat.sh ../configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
This script builds SDL with 10.6 ABI compatibility on 64-bit Intel and 11.0
|
||||
ABI compatibility on ARM64 architectures. For best compatibility you
|
||||
should compile your application the same way.
|
||||
|
||||
Please note that building SDL requires at least Xcode 4.6 and the 10.7 SDK
|
||||
(even if you target back to 10.6 systems). PowerPC support for Mac OS X has
|
||||
been officially dropped as of SDL 2.0.2. 32-bit Intel, using an older Xcode
|
||||
release, is still supported at the time of this writing, but current Xcode
|
||||
releases no longer support it, and eventually neither will SDL.
|
||||
|
||||
To use the library once it's built, you essential have two possibilities:
|
||||
use the traditional autoconf/automake/make method, or use Xcode.
|
||||
|
||||
|
||||
# Caveats for using SDL with Mac OS X
|
||||
|
||||
If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
||||
SDL will not register its own. This means that SDL will not terminate using
|
||||
SDL_Quit if it receives a termination request, it will terminate like a
|
||||
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
||||
file with the app. To solve these issues, put the following code in your
|
||||
NSApplicationDelegate implementation:
|
||||
|
||||
|
||||
```objc
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_DROPFILE;
|
||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||
return (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
```
|
||||
|
||||
# Using the Simple DirectMedia Layer with a traditional Makefile
|
||||
|
||||
An existing autoconf/automake build system for your SDL app has good chances
|
||||
to work almost unchanged on macOS. However, to produce a "real" Mac binary
|
||||
that you can distribute to users, you need to put the generated binary into a
|
||||
so called "bundle", which is basically a fancy folder with a name like
|
||||
"MyCoolGame.app".
|
||||
|
||||
To get this build automatically, add something like the following rule to
|
||||
your Makefile.am:
|
||||
|
||||
```make
|
||||
bundle_contents = APP_NAME.app/Contents
|
||||
APP_NAME_bundle: EXE_NAME
|
||||
mkdir -p $(bundle_contents)/MacOS
|
||||
mkdir -p $(bundle_contents)/Resources
|
||||
echo "APPL????" > $(bundle_contents)/PkgInfo
|
||||
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
||||
```
|
||||
|
||||
You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is
|
||||
what will be visible to the user in the Finder. Usually it will be the same
|
||||
as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME`
|
||||
usually is "TestGame". You might also want to use `@PACKAGE@` to use the
|
||||
package name as specified in your configure.ac file.
|
||||
|
||||
If your project builds more than one application, you will have to do a bit
|
||||
more. For each of your target applications, you need a separate rule.
|
||||
|
||||
If you want the created bundles to be installed, you may want to add this
|
||||
rule to your Makefile.am:
|
||||
|
||||
```make
|
||||
install-exec-hook: APP_NAME_bundle
|
||||
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
||||
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
||||
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
||||
```
|
||||
|
||||
This rule takes the Bundle created by the rule from step 3 and installs them
|
||||
into "$(DESTDIR)$(prefix)/Applications/".
|
||||
|
||||
Again, if you want to install multiple applications, you will have to augment
|
||||
the make rule accordingly.
|
||||
|
||||
But beware! That is only part of the story! With the above, you end up with
|
||||
a barebones .app bundle, which is double-clickable from the Finder. But
|
||||
there are some more things you should do before shipping your product...
|
||||
|
||||
1. The bundle right now probably is dynamically linked against SDL. That
|
||||
means that when you copy it to another computer, *it will not run*,
|
||||
unless you also install SDL on that other computer. A good solution
|
||||
for this dilemma is to static link against SDL. On OS X, you can
|
||||
achieve that by linking against the libraries listed by
|
||||
|
||||
```bash
|
||||
sdl-config --static-libs
|
||||
```
|
||||
|
||||
instead of those listed by
|
||||
|
||||
```bash
|
||||
sdl-config --libs
|
||||
```
|
||||
|
||||
Depending on how exactly SDL is integrated into your build systems, the
|
||||
way to achieve that varies, so I won't describe it here in detail
|
||||
|
||||
2. Add an 'Info.plist' to your application. That is a special XML file which
|
||||
contains some meta-information about your application (like some copyright
|
||||
information, the version of your app, the name of an optional icon file,
|
||||
and other things). Part of that information is displayed by the Finder
|
||||
when you click on the .app, or if you look at the "Get Info" window.
|
||||
More information about Info.plist files can be found on Apple's homepage.
|
||||
|
||||
|
||||
As a final remark, let me add that I use some of the techniques (and some
|
||||
variations of them) in [Exult](https://github.com/exult/exult) and
|
||||
[ScummVM](https://github.com/scummvm/scummvm); both are available in source on
|
||||
the net, so feel free to take a peek at them for inspiration!
|
||||
|
||||
|
||||
# Using the Simple DirectMedia Layer with Xcode
|
||||
|
||||
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
||||
|
||||
## First steps
|
||||
|
||||
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
||||
top level SDL directory (where the Xcode.tar.gz archive resides).
|
||||
Because Stuffit Expander will unpack the archive into a subdirectory,
|
||||
you should unpack the archive manually from the command line:
|
||||
|
||||
```bash
|
||||
cd [path_to_SDL_source]
|
||||
tar zxf Xcode.tar.gz
|
||||
```
|
||||
|
||||
This will create a new folder called Xcode, which you can browse
|
||||
normally from the Finder.
|
||||
|
||||
## Building the Framework
|
||||
|
||||
The SDL Library is packaged as a framework bundle, an organized
|
||||
relocatable folder hierarchy of executable code, interface headers,
|
||||
and additional resources. For practical purposes, you can think of a
|
||||
framework as a more user and system-friendly shared library, whose library
|
||||
file behaves more or less like a standard UNIX shared library.
|
||||
|
||||
To build the framework, simply open the framework project and build it.
|
||||
By default, the framework bundle "SDL.framework" is installed in
|
||||
/Library/Frameworks. Therefore, the testers and project stationary expect
|
||||
it to be located there. However, it will function the same in any of the
|
||||
following locations:
|
||||
|
||||
* ~/Library/Frameworks
|
||||
* /Local/Library/Frameworks
|
||||
* /System/Library/Frameworks
|
||||
|
||||
## Build Options
|
||||
|
||||
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
||||
"Deployment" should be used if you aren't tweaking the SDL library.
|
||||
"Development" should be used to debug SDL apps or the library itself.
|
||||
|
||||
## Building the Testers
|
||||
|
||||
Open the SDLTest project and build away!
|
||||
|
||||
## Using the Project Stationary
|
||||
|
||||
Copy the stationary to the indicated folders to access it from
|
||||
the "New Project" and "Add target" menus. What could be easier?
|
||||
|
||||
## Setting up a new project by hand
|
||||
|
||||
Some of you won't want to use the Stationary so I'll give some tips:
|
||||
|
||||
(this is accurate as of Xcode 12.5.)
|
||||
|
||||
* Click "File" -> "New" -> "Project...
|
||||
* Choose "macOS" and then "App" from the "Application" section.
|
||||
* Fill out the options in the next window. User interface is "XIB" and
|
||||
Language is "Objective-C".
|
||||
* Remove "main.m" from your project
|
||||
* Remove "MainMenu.xib" from your project
|
||||
* Remove "AppDelegates.*" from your project
|
||||
* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
||||
* Add "\$(HOME)/Library/Frameworks" to the frameworks search path
|
||||
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
||||
* Add your files
|
||||
* Clean and build
|
||||
|
||||
## Building from command line
|
||||
|
||||
Use `xcode-build` in the same directory as your .pbxproj file
|
||||
|
||||
## Running your app
|
||||
|
||||
You can send command line args to your app by either invoking it from
|
||||
the command line (in *.app/Contents/MacOS) or by entering them in the
|
||||
Executables" panel of the target settings.
|
||||
|
||||
# Implementation Notes
|
||||
|
||||
Some things that may be of interest about how it all works...
|
||||
|
||||
## Working directory
|
||||
|
||||
In SDL 1.2, the working directory of your SDL app is by default set to its
|
||||
parent, but this is no longer the case in SDL 2.0. SDL2 does change the
|
||||
working directory, which means it'll be whatever the command line prompt
|
||||
that launched the program was using, or if launched by double-clicking in
|
||||
the finger, it will be "/", the _root of the filesystem_. Plan accordingly!
|
||||
You can use SDL_GetBasePath() to find where the program is running from and
|
||||
chdir() there directly.
|
||||
|
||||
|
||||
## You have a Cocoa App!
|
||||
|
||||
Your SDL app is essentially a Cocoa application. When your app
|
||||
starts up and the libraries finish loading, a Cocoa procedure is called,
|
||||
which sets up the working directory and calls your main() method.
|
||||
You are free to modify your Cocoa app with generally no consequence
|
||||
to SDL. You cannot, however, easily change the SDL window itself.
|
||||
Functionality may be added in the future to help this.
|
||||
|
||||
# Bug reports
|
||||
|
||||
Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/).
|
||||
Please feel free to report bugs there!
|
||||
|
92
libs/SDL2/docs/README-os2.md
Normal file
92
libs/SDL2/docs/README-os2.md
Normal file
|
@ -0,0 +1,92 @@
|
|||
Simple DirectMedia Layer 2 for OS/2 & eComStation
|
||||
================================================================================
|
||||
SDL port for OS/2, authored by Andrey Vasilkin <digi@os2.snc.ru>, 2016
|
||||
|
||||
|
||||
OpenGL and audio capture not supported by this port.
|
||||
|
||||
Additional optional environment variables:
|
||||
|
||||
SDL_AUDIO_SHARE
|
||||
Values: 0 or 1, default is 0
|
||||
Initializes the device as shareable or exclusively acquired.
|
||||
|
||||
SDL_VIDEODRIVER
|
||||
Values: DIVE or VMAN, default is DIVE
|
||||
Use video subsystem: Direct interface video extensions (DIVE) or
|
||||
Video Manager (VMAN).
|
||||
|
||||
You may significantly increase video output speed with OS4 kernel and patched
|
||||
files vman.dll and dive.dll or with latest versions of ACPI support and video
|
||||
driver Panorama.
|
||||
|
||||
Latest versions of OS/4 kernel:
|
||||
http://gus.biysk.ru/os4/
|
||||
(Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4)
|
||||
|
||||
Patched files vman.dll and dive.dll:
|
||||
http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see:
|
||||
https://github.com/open-watcom/ and https://open-watcom.github.io
|
||||
WATCOM environment variable must to be set to the Open Watcom install
|
||||
directory. To compile, run: wmake -f Makefile.os2
|
||||
|
||||
|
||||
Installing:
|
||||
-----------
|
||||
|
||||
- eComStation:
|
||||
|
||||
If you have previously installed SDL2, make a Backup copy of SDL2.dll
|
||||
located in D:\ecs\dll (where D: is disk on which installed eComStation).
|
||||
Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll
|
||||
|
||||
- OS/2:
|
||||
|
||||
Copy SDL2.dll to any directory on your LIBPATH. If you have a previous
|
||||
version installed, close all SDL2 applications before replacing the old
|
||||
copy. Also make sure that any other older versions of DLLs are removed
|
||||
from your system.
|
||||
|
||||
|
||||
Joysticks in SDL2:
|
||||
------------------
|
||||
|
||||
The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version.
|
||||
Here is the original documentation from SDL-1.2:
|
||||
|
||||
The Joystick detection only works for standard joysticks (2 buttons, 2 axes
|
||||
and the like). Therefore, if you use a non-standard joystick, you should
|
||||
specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
|
||||
file or CONFIG.SYS, so SDL applications can provide full capability to your
|
||||
device. The syntax is:
|
||||
|
||||
SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]
|
||||
|
||||
So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
|
||||
the line should be:
|
||||
|
||||
SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0
|
||||
|
||||
If you want to add spaces in your joystick name, just surround it with
|
||||
quotes or double-quotes:
|
||||
|
||||
SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0
|
||||
|
||||
or
|
||||
|
||||
SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0
|
||||
|
||||
Note however that Balls and Hats are not supported under OS/2, and the
|
||||
value will be ignored... but it is wise to define these correctly because
|
||||
in the future those can be supported.
|
||||
|
||||
Also the number of buttons is limited to 2 when using two joysticks,
|
||||
4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
|
||||
and 8 when using a joystick with 2 axes. Notice however these are limitations
|
||||
of the Joystick Port hardware, not OS/2.
|
|
@ -9,10 +9,22 @@ Credit to
|
|||
|
||||
Building
|
||||
--------
|
||||
To build for the PSP, make sure psp-config is in the path and run:
|
||||
To build SDL2 library for the PSP, make sure psp-config is in the path and run:
|
||||
make -f Makefile.psp
|
||||
|
||||
|
||||
Getting PSP toolchain
|
||||
---------------------
|
||||
https://github.com/pspdev/psptoolchain
|
||||
|
||||
Running on PPSSPP Emulator
|
||||
--------------------------
|
||||
https://github.com/hrydgard/ppsspp
|
||||
( https://github.com/hrydgard/ppsspp/wiki/Build-instructions )
|
||||
|
||||
Compiling an HelloWorld
|
||||
-----------------------
|
||||
https://psp-dev.org/doku.php?id=tutorial:hello_world
|
||||
|
||||
To Do
|
||||
------
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
Raspberry Pi
|
||||
================================================================================
|
||||
============
|
||||
|
||||
Requirements:
|
||||
|
||||
Raspbian (other Linux distros may work as well).
|
||||
|
||||
================================================================================
|
||||
Features
|
||||
================================================================================
|
||||
Features
|
||||
--------
|
||||
|
||||
* Works without X11
|
||||
* Hardware accelerated OpenGL ES 2.x
|
||||
|
@ -16,9 +15,8 @@ Raspbian (other Linux distros may work as well).
|
|||
* Hotplugging of input devices via UDEV
|
||||
|
||||
|
||||
================================================================================
|
||||
Raspbian Build Dependencies
|
||||
================================================================================
|
||||
Raspbian Build Dependencies
|
||||
---------------------------
|
||||
|
||||
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
||||
|
||||
|
@ -28,18 +26,17 @@ OpenGL ES 2.x, it usually comes pre-installed, but in any case:
|
|||
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
||||
|
||||
|
||||
================================================================================
|
||||
NEON
|
||||
================================================================================
|
||||
NEON
|
||||
----
|
||||
|
||||
If your Pi has NEON support, make sure you add -mfpu=neon to your CFLAGS so
|
||||
that SDL will select some otherwise-disabled highly-optimized code. The
|
||||
original Pi units don't have NEON, the Pi2 probably does, and the Pi3
|
||||
definitely does.
|
||||
|
||||
================================================================================
|
||||
Cross compiling from x86 Linux
|
||||
================================================================================
|
||||
|
||||
Cross compiling from x86 Linux
|
||||
------------------------------
|
||||
|
||||
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
||||
Raspbian system root and the cross compilation tools. We'll assume these tools
|
||||
|
@ -92,9 +89,8 @@ To be able to deploy this to /usr/local in the Raspbian system you need to fix u
|
|||
|
||||
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
||||
|
||||
================================================================================
|
||||
Apps don't work or poor video/audio performance
|
||||
================================================================================
|
||||
Apps don't work or poor video/audio performance
|
||||
-----------------------------------------------
|
||||
|
||||
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
||||
update the RPi's firmware. Note that doing so will fix these problems, but it
|
||||
|
@ -108,17 +104,15 @@ See here how to configure this setting: http://elinux.org/RPiconfig
|
|||
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
||||
firmware, using CMA probably won't work, at least it's the current case).
|
||||
|
||||
================================================================================
|
||||
No input
|
||||
================================================================================
|
||||
No input
|
||||
--------
|
||||
|
||||
Make sure you belong to the "input" group.
|
||||
|
||||
sudo usermod -aG input `whoami`
|
||||
|
||||
================================================================================
|
||||
No HDMI Audio
|
||||
================================================================================
|
||||
No HDMI Audio
|
||||
-------------
|
||||
|
||||
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
||||
|
||||
|
@ -128,9 +122,8 @@ to your config.txt file and reboot.
|
|||
|
||||
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
||||
|
||||
================================================================================
|
||||
Text Input API support
|
||||
================================================================================
|
||||
Text Input API support
|
||||
----------------------
|
||||
|
||||
The Text Input API is supported, with translation of scan codes done via the
|
||||
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
||||
|
@ -160,9 +153,9 @@ this determining the CAPS LOCK behavior:
|
|||
|
||||
sudo dpkg-reconfigure locales
|
||||
|
||||
================================================================================
|
||||
OpenGL problems
|
||||
================================================================================
|
||||
|
||||
OpenGL problems
|
||||
---------------
|
||||
|
||||
If you have desktop OpenGL headers installed at build time in your RPi or cross
|
||||
compilation environment, support for it will be built in. However, the chipset
|
||||
|
@ -177,9 +170,8 @@ environment variable:
|
|||
|
||||
export SDL_RENDER_DRIVER=opengles2
|
||||
|
||||
================================================================================
|
||||
Notes
|
||||
================================================================================
|
||||
Notes
|
||||
-----
|
||||
|
||||
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
||||
leaking into the console only if it has root privileges. Launching apps locally
|
||||
|
|
41
libs/SDL2/docs/README-riscos.md
Normal file
41
libs/SDL2/docs/README-riscos.md
Normal file
|
@ -0,0 +1,41 @@
|
|||
RISC OS
|
||||
=======
|
||||
|
||||
Requirements:
|
||||
|
||||
* RISC OS 3.5 or later.
|
||||
* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm).
|
||||
* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support.
|
||||
* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions.
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported.
|
||||
|
||||
The following commands can be used to build SDL2 for RISC OS using autoconf:
|
||||
|
||||
./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics
|
||||
make
|
||||
make install
|
||||
|
||||
The following commands can be used to build SDL2 for RISC OS using CMake:
|
||||
|
||||
cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF
|
||||
cmake --build build-riscos
|
||||
cmake --build build-riscos --target install
|
||||
|
||||
|
||||
Current level of implementation
|
||||
-------------------------------
|
||||
|
||||
The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported.
|
||||
|
||||
The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions.
|
||||
|
||||
The audio, loadso, thread and timer APIs are currently provided by UnixLib.
|
||||
|
||||
GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake.
|
||||
|
||||
The joystick, locale and power APIs are not yet implemented.
|
114
libs/SDL2/docs/README-visualc.md
Normal file
114
libs/SDL2/docs/README-visualc.md
Normal file
|
@ -0,0 +1,114 @@
|
|||
Using SDL with Microsoft Visual C++
|
||||
===================================
|
||||
|
||||
### by [Lion Kimbro](mailto:snowlion@sprynet.com) with additions by [James Turk](mailto:james@conceptofzero.net)
|
||||
|
||||
You can either use the precompiled libraries from the [SDL](https://www.libsdl.org/download.php) web site, or you can build SDL
|
||||
yourself.
|
||||
|
||||
### Building SDL
|
||||
|
||||
0. To build SDL, your machine must, at a minimum, have the DirectX9.0c SDK installed. It may or may not be retrievable from
|
||||
the [Microsoft](https://www.microsoft.com) website, so you might need to locate it [online](https://duckduckgo.com/?q=directx9.0c+sdk+download&t=h_&ia=web).
|
||||
_Editor's note: I've been able to successfully build SDL using Visual Studio 2019 **without** the DX9.0c SDK_
|
||||
|
||||
1. Open the Visual Studio solution file at `./VisualC/SDL.sln`.
|
||||
|
||||
2. Your IDE will likely prompt you to upgrade this solution file to whatever later version of the IDE you're using. In the `Retarget Projects` dialog,
|
||||
all of the affected project files should be checked allowing you to use the latest `Windows SDK Version` you have installed, along with
|
||||
the `Platform Toolset`.
|
||||
|
||||
If you choose *NOT* to upgrade to use the latest `Windows SDK Version` or `Platform Toolset`, then you'll need the `Visual Studio 2010 Platform Toolset`.
|
||||
|
||||
3. Build the `.dll` and `.lib` files by right clicking on each project in turn (Projects are listed in the _Workspace_
|
||||
panel in the _FileView_ tab), and selecting `Build`.
|
||||
|
||||
You may get a few warnings, but you should not get any errors.
|
||||
|
||||
Later, we will refer to the following `.lib` and `.dll` files that have just been generated:
|
||||
|
||||
- `./VisualC/Win32/Debug/SDL2.dll` or `./VisualC/Win32/Release/SDL2.dll`
|
||||
- `./VisualC/Win32/Debug/SDL2.lib` or `./VisualC/Win32/Release/SDL2.lib`
|
||||
- `./VisualC/Win32/Debug/SDL2main.lib` or `./VisualC/Win32/Release/SDL2main.lib`
|
||||
|
||||
_Note for the `x64` versions, just replace `Win32` in the path with `x64`_
|
||||
|
||||
### Creating a Project with SDL
|
||||
|
||||
- Create a project as a `Win32 Application`.
|
||||
|
||||
- Create a C++ file for your project.
|
||||
|
||||
- Set the C runtime to `Multi-threaded DLL` in the menu:
|
||||
`Project|Settings|C/C++ tab|Code Generation|Runtime Library `.
|
||||
|
||||
- Add the SDL `include` directory to your list of includes in the menu:
|
||||
`Project|Settings|C/C++ tab|Preprocessor|Additional include directories `
|
||||
|
||||
*VC7 Specific: Instead of doing this, I find it easier to add the
|
||||
include and library directories to the list that VC7 keeps. Do this by
|
||||
selecting Tools|Options|Projects|VC++ Directories and under the "Show
|
||||
Directories For:" dropbox select "Include Files", and click the "New
|
||||
Directory Icon" and add the [SDLROOT]\\include directory (e.g. If you
|
||||
installed to c:\\SDL\\ add c:\\SDL\\include). Proceed to change the
|
||||
dropbox selection to "Library Files" and add [SDLROOT]\\lib.*
|
||||
|
||||
The "include directory" I am referring to is the `./include` folder.
|
||||
|
||||
Now we're going to use the files that we had created earlier in the *Build SDL* step.
|
||||
|
||||
Copy the following file into your Project directory:
|
||||
|
||||
- `SDL2.dll`
|
||||
|
||||
Add the following files to your project (It is not necessary to copy them to your project directory):
|
||||
|
||||
- `SDL2.lib`
|
||||
- `SDL2main.lib`
|
||||
|
||||
To add them to your project, right click on your project, and select
|
||||
`Add files to project`.
|
||||
|
||||
**Instead of adding the files to your project, it is more desirable to add them to the linker options: Project|Properties|Linker|Command Line
|
||||
and type the names of the libraries to link with in the "Additional Options:" box. Note: This must be done for each build configuration
|
||||
(e.g. Release,Debug).**
|
||||
|
||||
### Hello SDL2
|
||||
|
||||
Here's a sample SDL snippet to verify everything is setup in your IDE:
|
||||
|
||||
```
|
||||
#include "SDL.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
const int WIDTH = 640;
|
||||
const int HEIGHT = 480;
|
||||
SDL_Window* window = NULL;
|
||||
SDL_Renderer* renderer = NULL;
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### That's it!
|
||||
|
||||
I hope that this document has helped you get through the most difficult part of using the SDL: installing it.
|
||||
Suggestions for improvements should be posted to the [Github Issues](https://github.com/libsdl-org/SDL/issues).
|
||||
|
||||
### Credits
|
||||
|
||||
Thanks to [Paulus Esterhazy](mailto:pesterhazy@gmx.net), for the work on VC++ port.
|
||||
|
||||
This document was originally called "VisualC.txt", and was written by [Sam Lantinga](mailto:slouken@libsdl.org).
|
||||
|
||||
Later, it was converted to HTML and expanded into the document that you see today by [Lion Kimbro](mailto:snowlion@sprynet.com).
|
||||
|
||||
Minor Fixes and Visual C++ 7 Information (In Green) was added by [James Turk](mailto:james@conceptofzero.net)
|
30
libs/SDL2/docs/README-vita.md
Normal file
30
libs/SDL2/docs/README-vita.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
PS Vita
|
||||
=======
|
||||
SDL port for the Sony Playstation Vita and Sony Playstation TV
|
||||
|
||||
Credit to
|
||||
* xerpi and rsn8887 for initial (vita2d) port
|
||||
* vitasdk/dolcesdk devs
|
||||
* CBPS discord (Namely Graphene and SonicMastr)
|
||||
|
||||
Building
|
||||
--------
|
||||
To build for the PSVita, make sure you have vitasdk and cmake installed and run:
|
||||
```
|
||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON`
|
||||
These renderers support 720p and 1080i resolutions. These can be specified with:
|
||||
`SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);`
|
||||
* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON`
|
||||
* By default SDL emits mouse events for touch events on every touchscreen.
|
||||
Vita has two touchscreens, so it's recommended to use `SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");` and handle touch events instead.
|
||||
Individual touchscreens can be disabled with:
|
||||
`SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);`
|
||||
* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita.
|
|
@ -352,38 +352,41 @@ source file, such as, "main.cpp".
|
|||
your project, and open the file in Visual C++'s text editor.
|
||||
7. Copy and paste the following code into the new file, then save it.
|
||||
|
||||
|
||||
#include <SDL.h>
|
||||
```c
|
||||
#include <SDL.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
SDL_Window * window = NULL;
|
||||
SDL_Renderer * renderer = NULL;
|
||||
SDL_Event evt;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
SDL_Window * window = NULL;
|
||||
SDL_Renderer * renderer = NULL;
|
||||
SDL_Event evt;
|
||||
SDL_bool keep_going = SDL_TRUE;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
return 1;
|
||||
} else if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
|
||||
return 1;
|
||||
} else if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
return 1;
|
||||
while (keep_going) {
|
||||
while (SDL_PollEvent(&evt)) {
|
||||
if ((evt.type == SDL_KEYDOWN) && (evt.key.keysym.sym == SDLK_ESCAPE)) {
|
||||
keep_going = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
while (SDL_PollEvent(&evt)) {
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
#### 6.B. Adding code and assets ####
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ SDL is written in C, works natively with C++, and there are bindings
|
|||
available for several other languages, including C# and Python.
|
||||
|
||||
This library is distributed under the zlib license, which can be found
|
||||
in the file "COPYING.txt".
|
||||
in the file "LICENSE.txt".
|
||||
|
||||
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.
|
||||
|
@ -35,10 +35,11 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd
|
|||
- [DynAPI](README-dynapi.md)
|
||||
- [Emscripten](README-emscripten.md)
|
||||
- [Gesture](README-gesture.md)
|
||||
- [Mercurial](README-hg.md)
|
||||
- [Git](README-git.md)
|
||||
- [iOS](README-ios.md)
|
||||
- [Linux](README-linux.md)
|
||||
- [OS X](README-macosx.md)
|
||||
- [OS/2](README-os2.md)
|
||||
- [Native Client](README-nacl.md)
|
||||
- [Pandora](README-pandora.md)
|
||||
- [Supported Platforms](README-platforms.md)
|
||||
|
@ -49,15 +50,16 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd
|
|||
- [WinCE](README-wince.md)
|
||||
- [Windows](README-windows.md)
|
||||
- [WinRT](README-winrt.md)
|
||||
- [PSVita](README-vita.md)
|
||||
|
||||
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)
|
||||
issues, you can join the [SDL Discourse](https://discourse.libsdl.org/),
|
||||
which can be used as a web forum or a mailing list, at your preference.
|
||||
|
||||
If you want to report bugs or contribute patches, please submit them to
|
||||
[bugzilla](https://bugzilla.libsdl.org/)
|
||||
[our bug tracker](https://github.com/libsdl-org/SDL/issues)
|
||||
|
||||
Enjoy!
|
||||
|
||||
|
||||
Sam Lantinga <mailto:slouken@libsdl.org>
|
||||
|
||||
|
|
Binary file not shown.
|
@ -39,7 +39,7 @@ while test $# -gt 0; do
|
|||
echo $exec_prefix
|
||||
;;
|
||||
--version)
|
||||
echo 2.0.10
|
||||
echo 2.0.20
|
||||
;;
|
||||
--cflags)
|
||||
echo -I${prefix}/include/SDL2 -Dmain=SDL_main
|
||||
|
@ -49,7 +49,7 @@ while test $# -gt 0; do
|
|||
;;
|
||||
--static-libs)
|
||||
# --libs|--static-libs)
|
||||
echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc
|
||||
echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid
|
||||
;;
|
||||
*)
|
||||
echo "${usage}" 1>&2
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -42,11 +42,13 @@
|
|||
#include "SDL_filesystem.h"
|
||||
#include "SDL_gamecontroller.h"
|
||||
#include "SDL_haptic.h"
|
||||
#include "SDL_hidapi.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_messagebox.h"
|
||||
#include "SDL_metal.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_power.h"
|
||||
#include "SDL_render.h"
|
||||
|
@ -58,6 +60,8 @@
|
|||
#include "SDL_timer.h"
|
||||
#include "SDL_version.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_locale.h"
|
||||
#include "SDL_misc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
|
@ -90,37 +94,130 @@ extern "C" {
|
|||
/* @} */
|
||||
|
||||
/**
|
||||
* This function initializes the subsystems specified by \c flags
|
||||
* Initialize the SDL library.
|
||||
*
|
||||
* SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
|
||||
* two may be used interchangeably. Though for readability of your code
|
||||
* SDL_InitSubSystem() might be preferred.
|
||||
*
|
||||
* The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread)
|
||||
* subsystems are initialized by default. Message boxes
|
||||
* (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
|
||||
* video subsystem, in hopes of being useful in showing an error dialog when
|
||||
* SDL_Init fails. You must specifically initialize other subsystems if you
|
||||
* use them in your application.
|
||||
*
|
||||
* Logging (such as SDL_Log) works without initialization, too.
|
||||
*
|
||||
* `flags` may be any of the following OR'd together:
|
||||
*
|
||||
* - `SDL_INIT_TIMER`: timer subsystem
|
||||
* - `SDL_INIT_AUDIO`: audio subsystem
|
||||
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
|
||||
* subsystem
|
||||
* - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
|
||||
* events subsystem
|
||||
* - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
|
||||
* - `SDL_INIT_GAMECONTROLLER`: controller subsystem; automatically
|
||||
* initializes the joystick subsystem
|
||||
* - `SDL_INIT_EVENTS`: events subsystem
|
||||
* - `SDL_INIT_EVERYTHING`: all of the above subsystems
|
||||
* - `SDL_INIT_NOPARACHUTE`: compatibility; this flag is ignored
|
||||
*
|
||||
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
|
||||
* for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
|
||||
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
|
||||
* this call will increase the ref-count and return.
|
||||
*
|
||||
* \param flags subsystem initialization flags
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_InitSubSystem
|
||||
* \sa SDL_Quit
|
||||
* \sa SDL_SetMainReady
|
||||
* \sa SDL_WasInit
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function initializes specific SDL subsystems
|
||||
* Compatibility function to initialize the SDL library.
|
||||
*
|
||||
* Subsystem initialization is ref-counted, you must call
|
||||
* SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
|
||||
* shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
|
||||
* If a subsystem is already loaded then this call will
|
||||
* increase the ref-count and return.
|
||||
* In SDL2, this function and SDL_Init() are interchangeable.
|
||||
*
|
||||
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Init
|
||||
* \sa SDL_Quit
|
||||
* \sa SDL_QuitSubSystem
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function cleans up specific SDL subsystems
|
||||
* Shut down specific SDL subsystems.
|
||||
*
|
||||
* If you start a subsystem using a call to that subsystem's init function
|
||||
* (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
|
||||
* SDL_QuitSubSystem() and SDL_WasInit() will not work. You will need to use
|
||||
* that subsystem's quit function (SDL_VideoQuit()) directly instead. But
|
||||
* generally, you should not be using those functions directly anyhow; use
|
||||
* SDL_Init() instead.
|
||||
*
|
||||
* You still need to call SDL_Quit() even if you close all open subsystems
|
||||
* with SDL_QuitSubSystem().
|
||||
*
|
||||
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_InitSubSystem
|
||||
* \sa SDL_Quit
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function returns a mask of the specified subsystems which have
|
||||
* previously been initialized.
|
||||
* Get a mask of the specified subsystems which are currently initialized.
|
||||
*
|
||||
* If \c flags is 0, it returns a mask of all initialized subsystems.
|
||||
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||
* \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
|
||||
* returns the initialization status of the specified subsystems.
|
||||
*
|
||||
* The return value does not include SDL_INIT_NOPARACHUTE.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Init
|
||||
* \sa SDL_InitSubSystem
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function cleans up all initialized subsystems. You should
|
||||
* call it upon all exit conditions.
|
||||
* Clean up all initialized subsystems.
|
||||
*
|
||||
* You should call this function even if you have already shutdown each
|
||||
* initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
|
||||
* function even in the case of errors in initialization.
|
||||
*
|
||||
* If you start a subsystem using a call to that subsystem's init function
|
||||
* (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
|
||||
* then you must use that subsystem's quit function (SDL_VideoQuit()) to shut
|
||||
* it down before calling SDL_Quit(). But generally, you should not be using
|
||||
* those functions directly anyhow; use SDL_Init() instead.
|
||||
*
|
||||
* You can use this function with atexit() to ensure that it is run when your
|
||||
* application is shutdown, but it is not wise to do this from a library or
|
||||
* other dynamically loaded code.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Init
|
||||
* \sa SDL_QuitSubSystem
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Quit(void);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -53,6 +53,10 @@ assert can have unique static variables associated with it.
|
|||
#define SDL_TriggerBreakpoint() __debugbreak()
|
||||
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
|
||||
#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
|
||||
#elif defined(__APPLE__) && defined(__arm__)
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
|
||||
#elif defined(__386__) && defined(__WATCOMC__)
|
||||
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
|
||||
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
|
||||
|
@ -185,92 +189,121 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
|
|||
#define SDL_assert_always(condition) SDL_enabled_assert(condition)
|
||||
|
||||
|
||||
/**
|
||||
* A callback that fires when an SDL assertion fails.
|
||||
*
|
||||
* \param data a pointer to the SDL_AssertData structure corresponding to the
|
||||
* current assertion
|
||||
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler()
|
||||
* \returns an SDL_AssertState value indicating how to handle the failure.
|
||||
*/
|
||||
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
|
||||
const SDL_AssertData* data, void* userdata);
|
||||
|
||||
/**
|
||||
* \brief Set an application-defined assertion handler.
|
||||
* 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 function allows an application to show its own assertion UI and/or
|
||||
* force the response to an assertion failure. If the application 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.
|
||||
* 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()!
|
||||
*
|
||||
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
|
||||
* \param handler the SDL_AssertionHandler function to call when an assertion
|
||||
* fails or NULL for the default handler
|
||||
* \param userdata a pointer that is passed to `handler`
|
||||
*
|
||||
* Return SDL_AssertState value of how to handle the assertion failure.
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \param handler Callback function, called when an assertion fails.
|
||||
* \param userdata A pointer passed to the callback as-is.
|
||||
* \sa SDL_GetAssertionHandler
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
|
||||
SDL_AssertionHandler handler,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* \brief Get the default assertion handler.
|
||||
* Get the default assertion handler.
|
||||
*
|
||||
* This returns the function pointer that is called by default when an
|
||||
* assertion is triggered. This is an internal function provided by SDL,
|
||||
* that is used for assertions when SDL_SetAssertionHandler() hasn't been
|
||||
* used to provide a different function.
|
||||
* This returns the function pointer that is called by default when an
|
||||
* assertion is triggered. This is an internal function provided by SDL, that
|
||||
* is used for assertions when SDL_SetAssertionHandler() hasn't been used to
|
||||
* provide a different function.
|
||||
*
|
||||
* \return The default SDL_AssertionHandler that is called when an assert triggers.
|
||||
* \returns the default SDL_AssertionHandler that is called when an assert
|
||||
* triggers.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_GetAssertionHandler
|
||||
*/
|
||||
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
|
||||
|
||||
/**
|
||||
* \brief Get the current assertion handler.
|
||||
* Get the current assertion handler.
|
||||
*
|
||||
* This returns the function pointer that is called when an assertion is
|
||||
* triggered. This is either the value last passed to
|
||||
* SDL_SetAssertionHandler(), or if no application-specified function is
|
||||
* set, is equivalent to calling SDL_GetDefaultAssertionHandler().
|
||||
* This returns the function pointer that is called when an assertion is
|
||||
* triggered. This is either the value last passed to
|
||||
* SDL_SetAssertionHandler(), or if no application-specified function is set,
|
||||
* is equivalent to calling SDL_GetDefaultAssertionHandler().
|
||||
*
|
||||
* \param puserdata Pointer to a void*, which will store the "userdata"
|
||||
* pointer that was passed to SDL_SetAssertionHandler().
|
||||
* This value will always be NULL for the default handler.
|
||||
* If you don't care about this data, it is safe to pass
|
||||
* a NULL pointer to this function to ignore it.
|
||||
* \return The SDL_AssertionHandler that is called when an assert triggers.
|
||||
* The parameter `puserdata` is a pointer to a void*, which will store the
|
||||
* "userdata" pointer that was passed to SDL_SetAssertionHandler(). This value
|
||||
* will always be NULL for the default handler. If you don't care about this
|
||||
* data, it is safe to pass a NULL pointer to this function to ignore it.
|
||||
*
|
||||
* \param puserdata pointer which is filled with the "userdata" pointer that
|
||||
* was passed to SDL_SetAssertionHandler()
|
||||
* \returns the SDL_AssertionHandler that is called when an assert triggers.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_SetAssertionHandler
|
||||
*/
|
||||
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
|
||||
|
||||
/**
|
||||
* \brief Get a list of all assertion failures.
|
||||
* Get a list of all assertion failures.
|
||||
*
|
||||
* Get all assertions triggered since last call to SDL_ResetAssertionReport(),
|
||||
* or the start of the program.
|
||||
* This function gets all assertions triggered since the last call to
|
||||
* SDL_ResetAssertionReport(), or the start of the program.
|
||||
*
|
||||
* The proper way to examine this data looks something like this:
|
||||
* The proper way to examine this data looks something like this:
|
||||
*
|
||||
* <code>
|
||||
* const SDL_AssertData *item = SDL_GetAssertionReport();
|
||||
* while (item) {
|
||||
* 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>
|
||||
* ```c
|
||||
* const SDL_AssertData *item = SDL_GetAssertionReport();
|
||||
* while (item) {
|
||||
* 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;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* \return List of all assertions.
|
||||
* \sa SDL_ResetAssertionReport
|
||||
* \returns a list of all failed assertions or NULL if the list is empty. This
|
||||
* memory should not be modified or freed by the application.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_ResetAssertionReport
|
||||
*/
|
||||
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
|
||||
|
||||
/**
|
||||
* \brief Reset the list of all assertion failures.
|
||||
* Clear the list of all assertion failures.
|
||||
*
|
||||
* Reset list of all assertions triggered.
|
||||
* This function will clear the list of all assertions triggered up to that
|
||||
* point. Immediately following this call, SDL_GetAssertionReport will return
|
||||
* no items. In addition, any previously-triggered assertions will be reset to
|
||||
* a trigger_count of zero, and their always_ignore state will be false.
|
||||
*
|
||||
* \sa SDL_GetAssertionReport
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetAssertionReport
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -89,25 +89,51 @@ extern "C" {
|
|||
typedef int SDL_SpinLock;
|
||||
|
||||
/**
|
||||
* \brief Try to lock a spin lock by setting it to a non-zero value.
|
||||
* Try to lock a spin lock by setting it to a non-zero value.
|
||||
*
|
||||
* \param lock Points to the lock.
|
||||
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||
* doing. Please be careful using any sort of spinlock!***
|
||||
*
|
||||
* \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held.
|
||||
* \param lock a pointer to a lock variable
|
||||
* \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already
|
||||
* held.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicLock
|
||||
* \sa SDL_AtomicUnlock
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
|
||||
|
||||
/**
|
||||
* \brief Lock a spin lock by setting it to a non-zero value.
|
||||
* Lock a spin lock by setting it to a non-zero value.
|
||||
*
|
||||
* \param lock Points to the lock.
|
||||
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||
* doing. Please be careful using any sort of spinlock!***
|
||||
*
|
||||
* \param lock a pointer to a lock variable
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicTryLock
|
||||
* \sa SDL_AtomicUnlock
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
|
||||
|
||||
/**
|
||||
* \brief Unlock a spin lock by setting it to 0. Always returns immediately
|
||||
* Unlock a spin lock by setting it to 0.
|
||||
*
|
||||
* \param lock Points to the lock.
|
||||
* Always returns immediately.
|
||||
*
|
||||
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||
* doing. Please be careful using any sort of spinlock!***
|
||||
*
|
||||
* \param lock a pointer to a lock variable
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicLock
|
||||
* \sa SDL_AtomicTryLock
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
|
||||
|
||||
|
@ -126,7 +152,7 @@ void _ReadWriteBarrier(void);
|
|||
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
|
||||
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
|
||||
#elif defined(__WATCOMC__)
|
||||
extern _inline void SDL_CompilerBarrier (void);
|
||||
extern __inline void SDL_CompilerBarrier(void);
|
||||
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
|
||||
#else
|
||||
#define SDL_CompilerBarrier() \
|
||||
|
@ -137,20 +163,22 @@ extern _inline void SDL_CompilerBarrier (void);
|
|||
* Memory barriers are designed to prevent reads and writes from being
|
||||
* reordered by the compiler and being seen out of order on multi-core CPUs.
|
||||
*
|
||||
* A typical pattern would be for thread A to write some data and a flag,
|
||||
* and for thread B to read the flag and get the data. In this case you
|
||||
* would insert a release barrier between writing the data and the flag,
|
||||
* A typical pattern would be for thread A to write some data and a flag, and
|
||||
* for thread B to read the flag and get the data. In this case you would
|
||||
* insert a release barrier between writing the data and the flag,
|
||||
* guaranteeing that the data write completes no later than the flag is
|
||||
* written, and you would insert an acquire barrier between reading the
|
||||
* flag and reading the data, to ensure that all the reads associated
|
||||
* with the flag have completed.
|
||||
* written, and you would insert an acquire barrier between reading the flag
|
||||
* and reading the data, to ensure that all the reads associated with the flag
|
||||
* have completed.
|
||||
*
|
||||
* In this pattern you should always see a release barrier paired with
|
||||
* an acquire barrier and you should gate the data reads/writes with a
|
||||
* single flag variable.
|
||||
* In this pattern you should always see a release barrier paired with an
|
||||
* acquire barrier and you should gate the data reads/writes with a single
|
||||
* flag variable.
|
||||
*
|
||||
* For more information on these semantics, take a look at the blog post:
|
||||
* http://preshing.com/20120913/acquire-and-release-semantics
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
|
||||
extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
|
||||
|
@ -216,32 +244,73 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
|
|||
typedef struct { int value; } SDL_atomic_t;
|
||||
|
||||
/**
|
||||
* \brief Set an atomic variable to a new value if it is currently an old value.
|
||||
* 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!***
|
||||
*
|
||||
* \note If you don't know what this function is for, you shouldn't use it!
|
||||
*/
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified
|
||||
* \param oldval the old value
|
||||
* \param newval the new value
|
||||
* \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCASPtr
|
||||
* \sa SDL_AtomicGet
|
||||
* \sa SDL_AtomicSet
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval);
|
||||
|
||||
/**
|
||||
* \brief Set an atomic variable to a value.
|
||||
* Set an atomic variable to a value.
|
||||
*
|
||||
* \return The previous value of the atomic variable.
|
||||
* This function also acts as a full memory barrier.
|
||||
*
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified
|
||||
* \param v the desired value
|
||||
* \returns the previous value of the atomic variable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_AtomicGet
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
|
||||
|
||||
/**
|
||||
* \brief Get the value of an atomic variable
|
||||
* Get the value of an atomic variable.
|
||||
*
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable
|
||||
* \returns the current value of an atomic variable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_AtomicSet
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
|
||||
|
||||
/**
|
||||
* \brief Add to an atomic variable.
|
||||
* Add to an atomic variable.
|
||||
*
|
||||
* \return The previous value of the atomic variable.
|
||||
* This function also acts as a full memory barrier.
|
||||
*
|
||||
* \note This same style can be used for any number operation
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified
|
||||
* \param v the desired value to add
|
||||
* \returns the previous value of the atomic variable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_AtomicDecRef
|
||||
* \sa SDL_AtomicIncRef
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
|
||||
|
||||
|
@ -263,23 +332,54 @@ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
|
|||
#endif
|
||||
|
||||
/**
|
||||
* \brief Set a pointer to a new value if it is currently an old value.
|
||||
* 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!***
|
||||
*
|
||||
* \note If you don't know what this function is for, you shouldn't use it!
|
||||
*/
|
||||
* \param a a pointer to a pointer
|
||||
* \param oldval the old pointer value
|
||||
* \param newval the new pointer value
|
||||
* \returns SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCAS
|
||||
* \sa SDL_AtomicGetPtr
|
||||
* \sa SDL_AtomicSetPtr
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval);
|
||||
|
||||
/**
|
||||
* \brief Set a pointer to a value atomically.
|
||||
* Set a pointer to a value atomically.
|
||||
*
|
||||
* \return The previous value of the pointer.
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to a pointer
|
||||
* \param v the desired pointer value
|
||||
* \returns the previous value of the pointer.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_AtomicCASPtr
|
||||
* \sa SDL_AtomicGetPtr
|
||||
*/
|
||||
extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
|
||||
|
||||
/**
|
||||
* \brief Get the value of a pointer atomically.
|
||||
* Get the value of a pointer atomically.
|
||||
*
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to a pointer
|
||||
* \returns the current value of a pointer.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_AtomicCASPtr
|
||||
* \sa SDL_AtomicSetPtr
|
||||
*/
|
||||
extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -45,13 +45,12 @@ extern "C" {
|
|||
* with 0. This operation can also be stated as "count leading zeroes" and
|
||||
* "log base 2".
|
||||
*
|
||||
* \return Index of the most significant bit, or -1 if the value is 0.
|
||||
* \return the index of the most significant bit, or -1 if the value is 0.
|
||||
*/
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
extern _inline int _SDL_clz_watcom (Uint32);
|
||||
#pragma aux _SDL_clz_watcom = \
|
||||
extern __inline int _SDL_bsr_watcom(Uint32);
|
||||
#pragma aux _SDL_bsr_watcom = \
|
||||
"bsr eax, eax" \
|
||||
"xor eax, 31" \
|
||||
parm [eax] nomemory \
|
||||
value [eax] \
|
||||
modify exact [eax] nomemory;
|
||||
|
@ -72,7 +71,13 @@ SDL_MostSignificantBitIndex32(Uint32 x)
|
|||
if (x == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 31 - _SDL_clz_watcom(x);
|
||||
return _SDL_bsr_watcom(x);
|
||||
#elif defined(_MSC_VER)
|
||||
unsigned long index;
|
||||
if (_BitScanReverse(&index, x)) {
|
||||
return index;
|
||||
}
|
||||
return -1;
|
||||
#else
|
||||
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson
|
||||
* <seander@cs.stanford.edu>, released in the public domain.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -50,6 +50,9 @@ typedef enum
|
|||
SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate
|
||||
dstRGB = srcRGB * dstRGB
|
||||
dstA = dstA */
|
||||
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
|
||||
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
|
||||
dstA = (srcA * dstA) + (dstA * (1-srcA)) */
|
||||
SDL_BLENDMODE_INVALID = 0x7FFFFFFF
|
||||
|
||||
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
|
||||
|
@ -88,19 +91,96 @@ typedef enum
|
|||
} SDL_BlendFactor;
|
||||
|
||||
/**
|
||||
* \brief Create a custom blend mode, which may or may not be supported by a given renderer
|
||||
* Compose a custom blend mode for renderers.
|
||||
*
|
||||
* \param srcColorFactor source color factor
|
||||
* \param dstColorFactor destination color factor
|
||||
* \param colorOperation color operation
|
||||
* \param srcAlphaFactor source alpha factor
|
||||
* \param dstAlphaFactor destination alpha factor
|
||||
* \param alphaOperation alpha operation
|
||||
* The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept
|
||||
* the SDL_BlendMode returned by this function if the renderer supports it.
|
||||
*
|
||||
* The result of the blend mode operation will be:
|
||||
* dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor
|
||||
* and
|
||||
* dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor
|
||||
* A blend mode controls how the pixels from a drawing operation (source) get
|
||||
* combined with the pixels from the render target (destination). First, the
|
||||
* components of the source and destination pixels get multiplied with their
|
||||
* blend factors. Then, the blend operation takes the two products and
|
||||
* calculates the result that will get stored in the render target.
|
||||
*
|
||||
* Expressed in pseudocode, it would look like this:
|
||||
*
|
||||
* ```c
|
||||
* dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor);
|
||||
* dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor);
|
||||
* ```
|
||||
*
|
||||
* Where the functions `colorOperation(src, dst)` and `alphaOperation(src,
|
||||
* dst)` can return one of the following:
|
||||
*
|
||||
* - `src + dst`
|
||||
* - `src - dst`
|
||||
* - `dst - src`
|
||||
* - `min(src, dst)`
|
||||
* - `max(src, dst)`
|
||||
*
|
||||
* The red, green, and blue components are always multiplied with the first,
|
||||
* second, and third components of the SDL_BlendFactor, respectively. The
|
||||
* fourth component is not used.
|
||||
*
|
||||
* The alpha component is always multiplied with the fourth component of the
|
||||
* SDL_BlendFactor. The other components are not used in the alpha
|
||||
* calculation.
|
||||
*
|
||||
* Support for these blend modes varies for each renderer. To check if a
|
||||
* specific SDL_BlendMode is supported, create a renderer and pass it to
|
||||
* either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will
|
||||
* return with an error if the blend mode is not supported.
|
||||
*
|
||||
* This list describes the support of custom blend modes for each renderer in
|
||||
* SDL 2.0.6. All renderers support the four blend modes listed in the
|
||||
* SDL_BlendMode enumeration.
|
||||
*
|
||||
* - **direct3d**: Supports `SDL_BLENDOPERATION_ADD` with all factors.
|
||||
* - **direct3d11**: Supports all operations with all factors. However, some
|
||||
* factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and
|
||||
* `SDL_BLENDOPERATION_MAXIMUM`.
|
||||
* - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all
|
||||
* factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with SDL
|
||||
* 2.0.6.
|
||||
* - **opengles**: Supports the `SDL_BLENDOPERATION_ADD` operation with all
|
||||
* factors. Color and alpha factors need to be the same. OpenGL ES 1
|
||||
* implementation specific: May also support `SDL_BLENDOPERATION_SUBTRACT`
|
||||
* and `SDL_BLENDOPERATION_REV_SUBTRACT`. May support color and alpha
|
||||
* operations being different from each other. May support color and alpha
|
||||
* factors being different from each other.
|
||||
* - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`,
|
||||
* `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT`
|
||||
* operations with all factors.
|
||||
* - **psp**: No custom blend mode support.
|
||||
* - **software**: No custom blend mode support.
|
||||
*
|
||||
* Some renderers do not provide an alpha component for the default render
|
||||
* target. The `SDL_BLENDFACTOR_DST_ALPHA` and
|
||||
* `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this
|
||||
* case.
|
||||
*
|
||||
* \param srcColorFactor the SDL_BlendFactor applied to the red, green, and
|
||||
* blue components of the source pixels
|
||||
* \param dstColorFactor the SDL_BlendFactor applied to the red, green, and
|
||||
* blue components of the destination pixels
|
||||
* \param colorOperation the SDL_BlendOperation used to combine the red,
|
||||
* green, and blue components of the source and
|
||||
* destination pixels
|
||||
* \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of
|
||||
* the source pixels
|
||||
* \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of
|
||||
* the destination pixels
|
||||
* \param alphaOperation the SDL_BlendOperation used to combine the alpha
|
||||
* component of the source and destination pixels
|
||||
* \returns an SDL_BlendMode that represents the chosen factors and
|
||||
* operations.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawBlendMode
|
||||
* \sa SDL_GetRenderDrawBlendMode
|
||||
* \sa SDL_SetTextureBlendMode
|
||||
* \sa SDL_GetTextureBlendMode
|
||||
*/
|
||||
extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor,
|
||||
SDL_BlendFactor dstColorFactor,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -39,23 +39,46 @@ extern "C" {
|
|||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Put UTF-8 text into the clipboard
|
||||
* Put UTF-8 text into the clipboard.
|
||||
*
|
||||
* \sa SDL_GetClipboardText()
|
||||
* \param text the text to store in the clipboard
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetClipboardText
|
||||
* \sa SDL_HasClipboardText
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
|
||||
|
||||
/**
|
||||
* \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
|
||||
* Get UTF-8 text from the clipboard, which must be freed with SDL_free().
|
||||
*
|
||||
* \sa SDL_SetClipboardText()
|
||||
* This functions returns empty string if there was not enough memory left for
|
||||
* a copy of the clipboard's content.
|
||||
*
|
||||
* \returns the clipboard text on success or an empty string on failure; call
|
||||
* SDL_GetError() for more information. Caller must call SDL_free()
|
||||
* on the returned pointer when done with it (even if there was an
|
||||
* error).
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HasClipboardText
|
||||
* \sa SDL_SetClipboardText
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
|
||||
|
||||
/**
|
||||
* \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty
|
||||
* Query whether the clipboard exists and contains a non-empty text string.
|
||||
*
|
||||
* \sa SDL_GetClipboardText()
|
||||
* \returns SDL_TRUE if the clipboard has text, or SDL_FALSE if it does not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetClipboardText
|
||||
* \sa SDL_SetClipboardText
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -25,10 +25,23 @@
|
|||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* winsdkver.h defines _WIN32_MAXVER for SDK version detection. It is present since at least the Windows 7 SDK,
|
||||
* but out of caution we'll only use it if the compiler supports __has_include() to confirm its presence.
|
||||
* If your compiler doesn't support __has_include() but you have winsdkver.h, define HAVE_WINSDKVER_H. */
|
||||
#if !defined(HAVE_WINSDKVER_H) && defined(__has_include)
|
||||
#if __has_include(<winsdkver.h>)
|
||||
#define HAVE_WINSDKVER_H 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINSDKVER_H
|
||||
#include <winsdkver.h>
|
||||
#endif
|
||||
|
||||
/* 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__)
|
||||
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__clang__) || defined(__BORLANDC__) || defined(__CODEGEARC__)
|
||||
#define HAVE_STDINT_H 1
|
||||
#elif defined(_MSC_VER)
|
||||
typedef signed __int8 int8_t;
|
||||
|
@ -82,9 +95,23 @@ typedef unsigned int uintptr_t;
|
|||
#define HAVE_DSOUND_H 1
|
||||
#define HAVE_DXGI_H 1
|
||||
#define HAVE_XINPUT_H 1
|
||||
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */
|
||||
#define HAVE_WINDOWS_GAMING_INPUT_H 1
|
||||
#endif
|
||||
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0602 /* Windows 8 SDK */
|
||||
#define HAVE_D3D11_H 1
|
||||
#endif
|
||||
#define HAVE_MMDEVICEAPI_H 1
|
||||
#define HAVE_AUDIOCLIENT_H 1
|
||||
#define HAVE_ENDPOINTVOLUME_H 1
|
||||
#define HAVE_TPCSHRD_H 1
|
||||
#define HAVE_SENSORSAPI_H 1
|
||||
#if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
#define HAVE_IMMINTRIN_H 1
|
||||
#elif defined(__has_include) && (defined(__i386__) || defined(__x86_64))
|
||||
# if __has_include(<immintrin.h>)
|
||||
# define HAVE_IMMINTRIN_H 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
|
||||
#ifdef HAVE_LIBC
|
||||
|
@ -118,6 +145,7 @@ typedef unsigned int uintptr_t;
|
|||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
/* #undef HAVE_STRTOK_R */
|
||||
/* These functions have security warnings, so we won't use them */
|
||||
/* #undef HAVE__LTOA */
|
||||
/* #undef HAVE__ULTOA */
|
||||
|
@ -130,6 +158,9 @@ typedef unsigned int uintptr_t;
|
|||
#define HAVE_STRNCMP 1
|
||||
#define HAVE__STRICMP 1
|
||||
#define HAVE__STRNICMP 1
|
||||
#define HAVE__WCSICMP 1
|
||||
#define HAVE__WCSNICMP 1
|
||||
#define HAVE__WCSDUP 1
|
||||
#define HAVE_ACOS 1
|
||||
#define HAVE_ACOSF 1
|
||||
#define HAVE_ASIN 1
|
||||
|
@ -139,7 +170,7 @@ typedef unsigned int uintptr_t;
|
|||
#define HAVE_ATAN2 1
|
||||
#define HAVE_ATAN2F 1
|
||||
#define HAVE_CEILF 1
|
||||
#define HAVE__COPYSIGN 1
|
||||
#define HAVE__COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_EXP 1
|
||||
|
@ -166,9 +197,16 @@ typedef unsigned int uintptr_t;
|
|||
/* These functions were added with the VC++ 2013 C runtime library */
|
||||
#if _MSC_VER >= 1800
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_VSSCANF 1
|
||||
#define HAVE_LROUND 1
|
||||
#define HAVE_LROUNDF 1
|
||||
#define HAVE_ROUND 1
|
||||
#define HAVE_ROUNDF 1
|
||||
#define HAVE_SCALBN 1
|
||||
#define HAVE_SCALBNF 1
|
||||
#define HAVE_SCALBNF 1
|
||||
#define HAVE_TRUNC 1
|
||||
#define HAVE_TRUNCF 1
|
||||
#endif
|
||||
/* This function is available with at least the VC++ 2008 C runtime library */
|
||||
#if _MSC_VER >= 1400
|
||||
|
@ -192,18 +230,26 @@ typedef unsigned int uintptr_t;
|
|||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_DINPUT 1
|
||||
#define SDL_JOYSTICK_XINPUT 1
|
||||
#define SDL_JOYSTICK_HIDAPI 1
|
||||
#ifndef __WINRT__
|
||||
#define SDL_JOYSTICK_RAWINPUT 1
|
||||
#endif
|
||||
#define SDL_JOYSTICK_VIRTUAL 1
|
||||
#ifdef HAVE_WINDOWS_GAMING_INPUT_H
|
||||
#define SDL_JOYSTICK_WGI 1
|
||||
#endif
|
||||
#define SDL_JOYSTICK_XINPUT 1
|
||||
#define SDL_HAPTIC_DINPUT 1
|
||||
#define SDL_HAPTIC_XINPUT 1
|
||||
|
||||
/* Enable the dummy sensor driver */
|
||||
#define SDL_SENSOR_DUMMY 1
|
||||
/* Enable the sensor driver */
|
||||
#define SDL_SENSOR_WINDOWS 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_WINDOWS 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
#define SDL_THREAD_GENERIC_COND_SUFFIX 1
|
||||
#define SDL_THREAD_WINDOWS 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
|
@ -216,8 +262,8 @@ typedef unsigned int uintptr_t;
|
|||
#ifndef SDL_VIDEO_RENDER_D3D
|
||||
#define SDL_VIDEO_RENDER_D3D 1
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_RENDER_D3D11
|
||||
#define SDL_VIDEO_RENDER_D3D11 0
|
||||
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
|
||||
#define SDL_VIDEO_RENDER_D3D11 1
|
||||
#endif
|
||||
|
||||
/* Enable OpenGL support */
|
||||
|
@ -255,3 +301,5 @@ typedef unsigned int uintptr_t;
|
|||
#endif
|
||||
|
||||
#endif /* SDL_config_windows_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -34,11 +34,20 @@
|
|||
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
|
||||
#ifdef __clang__
|
||||
/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */
|
||||
#undef __MMX__
|
||||
#undef __SSE__
|
||||
#undef __SSE2__
|
||||
#else
|
||||
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
|
||||
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
|
||||
|
||||
#ifndef __PRFCHWINTRIN_H
|
||||
#define __PRFCHWINTRIN_H
|
||||
|
||||
static __inline__ void __attribute__((__always_inline__, __nodebug__))
|
||||
_m_prefetch(void *__P)
|
||||
{
|
||||
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
|
||||
}
|
||||
|
||||
#endif /* __PRFCHWINTRIN_H */
|
||||
#endif /* __clang__ */
|
||||
#include <intrin.h>
|
||||
#ifndef _WIN64
|
||||
#ifndef __MMX__
|
||||
|
@ -54,9 +63,14 @@
|
|||
#ifndef __SSE2__
|
||||
#define __SSE2__
|
||||
#endif
|
||||
#endif /* __clang__ */
|
||||
#ifndef __SSE3__
|
||||
#define __SSE3__
|
||||
#endif
|
||||
#elif defined(__MINGW64_VERSION_MAJOR)
|
||||
#include <intrin.h>
|
||||
#if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#else
|
||||
/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
|
||||
#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
|
||||
|
@ -73,12 +87,14 @@
|
|||
# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
|
||||
# endif
|
||||
# if defined (_M_ARM64)
|
||||
# include <armintr.h>
|
||||
# include <arm_neon.h>
|
||||
# include <arm64intr.h>
|
||||
# include <arm64_neon.h>
|
||||
# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif /* compiler version */
|
||||
|
||||
#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
|
||||
#include <mm3dnow.h>
|
||||
#endif
|
||||
|
@ -98,7 +114,6 @@
|
|||
#include <pmmintrin.h>
|
||||
#endif
|
||||
#endif /* HAVE_IMMINTRIN_H */
|
||||
#endif /* compiler version */
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
|
@ -114,151 +129,425 @@ extern "C" {
|
|||
#define SDL_CACHELINE_SIZE 128
|
||||
|
||||
/**
|
||||
* This function returns the number of CPU cores available.
|
||||
* Get the number of CPU cores available.
|
||||
*
|
||||
* \returns the total number of logical CPU cores. On CPUs that include
|
||||
* technologies such as hyperthreading, the number of logical cores
|
||||
* may be more than the number of physical cores.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
|
||||
|
||||
/**
|
||||
* This function returns the L1 cache line size of the CPU
|
||||
* Determine the L1 cache line size of the CPU.
|
||||
*
|
||||
* This is useful for determining multi-threaded structure padding
|
||||
* or SIMD prefetch sizes.
|
||||
* This is useful for determining multi-threaded structure padding or SIMD
|
||||
* prefetch sizes.
|
||||
*
|
||||
* \returns the L1 cache line size of the CPU, in bytes.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has the RDTSC instruction.
|
||||
* Determine whether the CPU has the RDTSC instruction.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has the RDTSC instruction or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has AltiVec features.
|
||||
* Determine whether the CPU has AltiVec features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using PowerPC instruction
|
||||
* sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has AltiVec features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has MMX features.
|
||||
* Determine whether the CPU has MMX features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has MMX features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has 3DNow! features.
|
||||
* Determine whether the CPU has 3DNow! features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using AMD instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE features.
|
||||
* Determine whether the CPU has SSE features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has SSE features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE2 features.
|
||||
* Determine whether the CPU has SSE2 features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has SSE2 features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE3 features.
|
||||
* Determine whether the CPU has SSE3 features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has SSE3 features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE4.1 features.
|
||||
* Determine whether the CPU has SSE4.1 features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has SSE4.1 features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has SSE4.2 features.
|
||||
* Determine whether the CPU has SSE4.2 features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has SSE4.2 features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has AVX features.
|
||||
* Determine whether the CPU has AVX features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has AVX features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX2
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has AVX2 features.
|
||||
* Determine whether the CPU has AVX2 features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has AVX2 features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*
|
||||
* \sa SDL_Has3DNow
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasAVX
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasRDTSC
|
||||
* \sa SDL_HasSSE
|
||||
* \sa SDL_HasSSE2
|
||||
* \sa SDL_HasSSE3
|
||||
* \sa SDL_HasSSE41
|
||||
* \sa SDL_HasSSE42
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has AVX-512F (foundation) features.
|
||||
* Determine whether the CPU has AVX-512F (foundation) features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has AVX-512F features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*
|
||||
* \sa SDL_HasAVX
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has NEON (ARM SIMD) features.
|
||||
* Determine whether the CPU has ARM SIMD (ARMv6) features.
|
||||
*
|
||||
* This is different from ARM NEON, which is a different instruction set.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using ARM instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has ARM SIMD features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*
|
||||
* \sa SDL_HasNEON
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void);
|
||||
|
||||
/**
|
||||
* Determine whether the CPU has NEON (ARM SIMD) features.
|
||||
*
|
||||
* This always returns false on CPUs that aren't using ARM instruction sets.
|
||||
*
|
||||
* \returns SDL_TRUE if the CPU has ARM NEON features or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
|
||||
|
||||
/**
|
||||
* This function returns the amount of RAM configured in the system, in MB.
|
||||
* Get the amount of RAM configured in the system.
|
||||
*
|
||||
* \returns the amount of RAM configured in the system in MB.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.1.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
|
||||
|
||||
/**
|
||||
* \brief Report the alignment this system needs for SIMD allocations.
|
||||
* Report the alignment this system needs for SIMD allocations.
|
||||
*
|
||||
* This will return the minimum number of bytes to which a pointer must be
|
||||
* aligned to be compatible with SIMD instructions on the current machine.
|
||||
* For example, if the machine supports SSE only, it will return 16, but if
|
||||
* it supports AVX-512F, it'll return 64 (etc). This only reports values for
|
||||
* instruction sets SDL knows about, so if your SDL build doesn't have
|
||||
* SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and
|
||||
* not 64 for the AVX-512 instructions that exist but SDL doesn't know about.
|
||||
* Plan accordingly.
|
||||
* aligned to be compatible with SIMD instructions on the current machine. For
|
||||
* example, if the machine supports SSE only, it will return 16, but if it
|
||||
* supports AVX-512F, it'll return 64 (etc). This only reports values for
|
||||
* instruction sets SDL knows about, so if your SDL build doesn't have
|
||||
* SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and
|
||||
* not 64 for the AVX-512 instructions that exist but SDL doesn't know about.
|
||||
* Plan accordingly.
|
||||
*
|
||||
* \returns the alignment in bytes needed for available, known SIMD
|
||||
* instructions.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.10.
|
||||
*/
|
||||
extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void);
|
||||
|
||||
/**
|
||||
* \brief Allocate memory in a SIMD-friendly way.
|
||||
* Allocate memory in a SIMD-friendly way.
|
||||
*
|
||||
* This will allocate a block of memory that is suitable for use with SIMD
|
||||
* instructions. Specifically, it will be properly aligned and padded for
|
||||
* the system's supported vector instructions.
|
||||
* instructions. Specifically, it will be properly aligned and padded for the
|
||||
* system's supported vector instructions.
|
||||
*
|
||||
* The memory returned will be padded such that it is safe to read or write
|
||||
* an incomplete vector at the end of the memory block. This can be useful
|
||||
* so you don't have to drop back to a scalar fallback at the end of your
|
||||
* SIMD processing loop to deal with the final elements without overflowing
|
||||
* the allocated buffer.
|
||||
* The memory returned will be padded such that it is safe to read or write an
|
||||
* incomplete vector at the end of the memory block. This can be useful so you
|
||||
* don't have to drop back to a scalar fallback at the end of your SIMD
|
||||
* processing loop to deal with the final elements without overflowing the
|
||||
* allocated buffer.
|
||||
*
|
||||
* You must free this memory with SDL_FreeSIMD(), not free() or SDL_free()
|
||||
* or delete[], etc.
|
||||
* You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() or
|
||||
* delete[], etc.
|
||||
*
|
||||
* Note that SDL will only deal with SIMD instruction sets it is aware of;
|
||||
* for example, SDL 2.0.8 knows that SSE wants 16-byte vectors
|
||||
* (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't
|
||||
* know that AVX-512 wants 64. To be clear: if you can't decide to use an
|
||||
* instruction set with an SDL_Has*() function, don't use that instruction
|
||||
* set with memory allocated through here.
|
||||
* Note that SDL will only deal with SIMD instruction sets it is aware of; for
|
||||
* example, SDL 2.0.8 knows that SSE wants 16-byte vectors (SDL_HasSSE()), and
|
||||
* AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't know that AVX-512 wants
|
||||
* 64. To be clear: if you can't decide to use an instruction set with an
|
||||
* SDL_Has*() function, don't use that instruction set with memory allocated
|
||||
* through here.
|
||||
*
|
||||
* SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't
|
||||
* out of memory.
|
||||
* out of memory, but you are not allowed to dereference it (because you only
|
||||
* own zero bytes of that buffer).
|
||||
*
|
||||
* \param len The length, in bytes, of the block to allocated. The actual
|
||||
* allocated block might be larger due to padding, etc.
|
||||
* \return Pointer to newly-allocated block, NULL if out of memory.
|
||||
* \param len The length, in bytes, of the block to allocate. The actual
|
||||
* allocated block might be larger due to padding, etc.
|
||||
* \returns a pointer to the newly-allocated block, NULL if out of memory.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.10.
|
||||
*
|
||||
* \sa SDL_SIMDAlignment
|
||||
* \sa SDL_SIMDRealloc
|
||||
* \sa SDL_SIMDFree
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
|
||||
|
||||
/**
|
||||
* \brief Deallocate memory obtained from SDL_SIMDAlloc
|
||||
* Reallocate memory obtained from SDL_SIMDAlloc
|
||||
*
|
||||
* It is not valid to use this function on a pointer from anything but
|
||||
* SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc,
|
||||
* SDL_malloc, memalign, new[], etc.
|
||||
* SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc,
|
||||
* SDL_malloc, memalign, new[], etc.
|
||||
*
|
||||
* \param mem The pointer obtained from SDL_SIMDAlloc. This function also
|
||||
* accepts NULL, at which point this function is the same as
|
||||
* calling SDL_SIMDAlloc with a NULL pointer.
|
||||
* \param len The length, in bytes, of the block to allocated. The actual
|
||||
* allocated block might be larger due to padding, etc. Passing 0
|
||||
* will return a non-NULL pointer, assuming the system isn't out of
|
||||
* memory.
|
||||
* \returns a pointer to the newly-reallocated block, NULL if out of memory.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
* \sa SDL_SIMDAlignment
|
||||
* \sa SDL_SIMDAlloc
|
||||
* \sa SDL_SIMDFree
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len);
|
||||
|
||||
/**
|
||||
* Deallocate memory obtained from SDL_SIMDAlloc
|
||||
*
|
||||
* It is not valid to use this function on a pointer from anything but
|
||||
* SDL_SIMDAlloc() or SDL_SIMDRealloc(). It can't be used on pointers from
|
||||
* malloc, realloc, SDL_malloc, memalign, new[], etc.
|
||||
*
|
||||
* However, SDL_SIMDFree(NULL) is a legal no-op.
|
||||
*
|
||||
* The memory pointed to by `ptr` is no longer valid for access upon return,
|
||||
* and may be returned to the system or reused by a future allocation. The
|
||||
* pointer passed to this function is no longer safe to dereference once this
|
||||
* function returns, and should be discarded.
|
||||
*
|
||||
* \param ptr The pointer, returned from SDL_SIMDAlloc or SDL_SIMDRealloc, to
|
||||
* deallocate. NULL is a legal no-op.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.10.
|
||||
*
|
||||
* \sa SDL_SIMDAlloc
|
||||
* \sa SDL_SIMDRealloc
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -30,6 +30,23 @@
|
|||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
|
||||
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
|
||||
#ifdef __clang__
|
||||
#ifndef __PRFCHWINTRIN_H
|
||||
#define __PRFCHWINTRIN_H
|
||||
static __inline__ void __attribute__((__always_inline__, __nodebug__))
|
||||
_m_prefetch(void *__P)
|
||||
{
|
||||
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
|
||||
}
|
||||
#endif /* __PRFCHWINTRIN_H */
|
||||
#endif /* __clang__ */
|
||||
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name The two types of endianness
|
||||
*/
|
||||
|
@ -42,10 +59,16 @@
|
|||
#ifdef __linux__
|
||||
#include <endian.h>
|
||||
#define SDL_BYTEORDER __BYTE_ORDER
|
||||
#else /* __linux__ */
|
||||
#elif defined(__OpenBSD__)
|
||||
#include <endian.h>
|
||||
#define SDL_BYTEORDER BYTE_ORDER
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <sys/endian.h>
|
||||
#define SDL_BYTEORDER BYTE_ORDER
|
||||
#else
|
||||
#if defined(__hppa__) || \
|
||||
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
|
||||
(defined(__MIPS__) && defined(__MISPEB__)) || \
|
||||
(defined(__MIPS__) && defined(__MIPSEB__)) || \
|
||||
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
|
||||
defined(__sparc__)
|
||||
#define SDL_BYTEORDER SDL_BIG_ENDIAN
|
||||
|
@ -65,22 +88,45 @@ extern "C" {
|
|||
/**
|
||||
* \file SDL_endian.h
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__i386__) && \
|
||||
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
|
||||
|
||||
/* various modern compilers may have builtin swap */
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
||||
# define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
# define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
|
||||
/* this one is broken */
|
||||
# define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95)
|
||||
#else
|
||||
# define HAS_BUILTIN_BSWAP16 0
|
||||
# define HAS_BUILTIN_BSWAP32 0
|
||||
# define HAS_BUILTIN_BSWAP64 0
|
||||
# define HAS_BROKEN_BSWAP 0
|
||||
#endif
|
||||
|
||||
#if HAS_BUILTIN_BSWAP16
|
||||
#define SDL_Swap16(x) __builtin_bswap16(x)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#pragma intrinsic(_byteswap_ushort)
|
||||
#define SDL_Swap16(x) _byteswap_ushort(x)
|
||||
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
||||
SDL_FORCE_INLINE Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
#elif defined(__x86_64__)
|
||||
SDL_FORCE_INLINE Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
#elif (defined(__powerpc__) || defined(__ppc__))
|
||||
SDL_FORCE_INLINE Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
|
@ -89,7 +135,7 @@ SDL_Swap16(Uint16 x)
|
|||
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
|
||||
return (Uint16)result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
|
||||
#elif (defined(__m68k__) && !defined(__mcoldfire__))
|
||||
SDL_FORCE_INLINE Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
|
@ -97,7 +143,7 @@ SDL_Swap16(Uint16 x)
|
|||
return x;
|
||||
}
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
extern _inline Uint16 SDL_Swap16(Uint16);
|
||||
extern __inline Uint16 SDL_Swap16(Uint16);
|
||||
#pragma aux SDL_Swap16 = \
|
||||
"xchg al, ah" \
|
||||
parm [ax] \
|
||||
|
@ -110,32 +156,37 @@ SDL_Swap16(Uint16 x)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
#if HAS_BUILTIN_BSWAP32
|
||||
#define SDL_Swap32(x) __builtin_bswap32(x)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#pragma intrinsic(_byteswap_ulong)
|
||||
#define SDL_Swap32(x) _byteswap_ulong(x)
|
||||
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
||||
SDL_FORCE_INLINE Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswap %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
#elif defined(__x86_64__)
|
||||
SDL_FORCE_INLINE Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswapl %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
#elif (defined(__powerpc__) || defined(__ppc__))
|
||||
SDL_FORCE_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));
|
||||
__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__)
|
||||
#elif (defined(__m68k__) && !defined(__mcoldfire__))
|
||||
SDL_FORCE_INLINE Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
|
@ -143,20 +194,11 @@ SDL_Swap32(Uint32 x)
|
|||
return x;
|
||||
}
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
extern _inline Uint32 SDL_Swap32(Uint32);
|
||||
#ifndef __SW_3 /* 486+ */
|
||||
extern __inline Uint32 SDL_Swap32(Uint32);
|
||||
#pragma aux SDL_Swap32 = \
|
||||
"bswap eax" \
|
||||
parm [eax] \
|
||||
modify [eax];
|
||||
#else /* 386-only */
|
||||
#pragma aux SDL_Swap32 = \
|
||||
"xchg al, ah" \
|
||||
"ror eax, 16" \
|
||||
"xchg al, ah" \
|
||||
parm [eax] \
|
||||
modify [eax];
|
||||
#endif
|
||||
#else
|
||||
SDL_FORCE_INLINE Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
|
@ -166,31 +208,42 @@ SDL_Swap32(Uint32 x)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
#if HAS_BUILTIN_BSWAP64
|
||||
#define SDL_Swap64(x) __builtin_bswap64(x)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#pragma intrinsic(_byteswap_uint64)
|
||||
#define SDL_Swap64(x) _byteswap_uint64(x)
|
||||
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
||||
SDL_FORCE_INLINE Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
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));
|
||||
__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__)
|
||||
#elif defined(__x86_64__)
|
||||
SDL_FORCE_INLINE Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
__asm__("bswapq %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
extern __inline Uint64 SDL_Swap64(Uint64);
|
||||
#pragma aux SDL_Swap64 = \
|
||||
"bswap eax" \
|
||||
"bswap edx" \
|
||||
"xchg eax,edx" \
|
||||
parm [eax edx] \
|
||||
modify [eax edx];
|
||||
#else
|
||||
SDL_FORCE_INLINE Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
|
@ -212,8 +265,7 @@ SDL_Swap64(Uint64 x)
|
|||
SDL_FORCE_INLINE float
|
||||
SDL_SwapFloat(float x)
|
||||
{
|
||||
union
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
Uint32 ui32;
|
||||
} swapper;
|
||||
|
@ -222,6 +274,11 @@ SDL_SwapFloat(float x)
|
|||
return swapper.f;
|
||||
}
|
||||
|
||||
/* remove extra macros */
|
||||
#undef HAS_BROKEN_BSWAP
|
||||
#undef HAS_BUILTIN_BSWAP16
|
||||
#undef HAS_BUILTIN_BSWAP32
|
||||
#undef HAS_BUILTIN_BSWAP64
|
||||
|
||||
/**
|
||||
* \name Swap to native
|
||||
|
@ -229,22 +286,22 @@ SDL_SwapFloat(float x)
|
|||
*/
|
||||
/* @{ */
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define SDL_SwapLE16(X) (X)
|
||||
#define SDL_SwapLE32(X) (X)
|
||||
#define SDL_SwapLE64(X) (X)
|
||||
#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_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_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_SwapBE16(X) (X)
|
||||
#define SDL_SwapBE32(X) (X)
|
||||
#define SDL_SwapBE64(X) (X)
|
||||
#define SDL_SwapFloatBE(X) (X)
|
||||
#endif
|
||||
/* @} *//* Swap to native */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -37,9 +37,96 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Public functions */
|
||||
/* SDL_SetError() unconditionally returns -1. */
|
||||
|
||||
|
||||
/**
|
||||
* Set the SDL error message for the current thread.
|
||||
*
|
||||
* Calling this function will replace any previous error message that was set.
|
||||
*
|
||||
* This function always returns -1, since SDL frequently uses -1 to signify an
|
||||
* failing result, leading to this idiom:
|
||||
*
|
||||
* ```c
|
||||
* if (error_code) {
|
||||
* return SDL_SetError("This operation has failed: %d", error_code);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* \param fmt a printf()-style message format string
|
||||
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||
* any
|
||||
* \returns always -1.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_ClearError
|
||||
* \sa SDL_GetError
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||
|
||||
/**
|
||||
* Retrieve a message about the last error that occurred on the current
|
||||
* thread.
|
||||
*
|
||||
* It is possible for multiple errors to occur before calling SDL_GetError().
|
||||
* Only the last error is returned.
|
||||
*
|
||||
* The message is only applicable when an SDL function has signaled an error.
|
||||
* You must check the return values of SDL function calls to determine when to
|
||||
* appropriately call SDL_GetError(). You should *not* use the results of
|
||||
* SDL_GetError() to decide if an error has occurred! Sometimes SDL will set
|
||||
* an error string even when reporting success.
|
||||
*
|
||||
* SDL will *not* clear the error string for successful API calls. You *must*
|
||||
* check return values for failure cases before you can assume the error
|
||||
* string applies.
|
||||
*
|
||||
* Error strings are set per-thread, so an error set in a different thread
|
||||
* will not interfere with the current thread's operation.
|
||||
*
|
||||
* The returned string is internally allocated and must not be freed by the
|
||||
* application.
|
||||
*
|
||||
* \returns a message with information about the specific error that occurred,
|
||||
* or an empty string if there hasn't been an error message set since
|
||||
* the last call to SDL_ClearError(). The message is only applicable
|
||||
* when an SDL function has signaled an error. You must check the
|
||||
* return values of SDL function calls to determine when to
|
||||
* appropriately call SDL_GetError().
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_ClearError
|
||||
* \sa SDL_SetError
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetError(void);
|
||||
|
||||
/**
|
||||
* Get the last error message that was set for the current thread.
|
||||
*
|
||||
* This allows the caller to copy the error string into a provided buffer, but
|
||||
* otherwise operates exactly the same as SDL_GetError().
|
||||
*
|
||||
* \param errstr A buffer to fill with the last error message that was set for
|
||||
* the current thread
|
||||
* \param maxlen The size of the buffer pointed to by the errstr parameter
|
||||
* \returns the pointer passed in as the `errstr` parameter.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
* \sa SDL_GetError
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen);
|
||||
|
||||
/**
|
||||
* Clear any previous error message for this thread.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetError
|
||||
* \sa SDL_SetError
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
|||
#define SDL_PRESSED 1
|
||||
|
||||
/**
|
||||
* \brief The types of events that can be delivered.
|
||||
* The types of events that can be delivered.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -85,6 +85,8 @@ typedef enum
|
|||
Called on Android in onResume()
|
||||
*/
|
||||
|
||||
SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
|
||||
|
||||
/* Display events */
|
||||
SDL_DISPLAYEVENT = 0x150, /**< Display state change */
|
||||
|
||||
|
@ -123,6 +125,10 @@ typedef enum
|
|||
SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
|
||||
SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
|
||||
SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
|
||||
SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
|
||||
SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
|
||||
SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
|
||||
SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
|
||||
|
||||
/* Touch events */
|
||||
SDL_FINGERDOWN = 0x700,
|
||||
|
@ -154,6 +160,9 @@ typedef enum
|
|||
SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
|
||||
SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
|
||||
|
||||
/* Internal events */
|
||||
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
|
||||
|
||||
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
||||
* and should be allocated with SDL_RegisterEvents()
|
||||
*/
|
||||
|
@ -292,6 +301,8 @@ typedef struct SDL_MouseWheelEvent
|
|||
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
|
||||
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
|
||||
Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
|
||||
float preciseX; /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
|
||||
float preciseY; /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
|
||||
} SDL_MouseWheelEvent;
|
||||
|
||||
/**
|
||||
|
@ -413,6 +424,33 @@ typedef struct SDL_ControllerDeviceEvent
|
|||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
|
||||
} SDL_ControllerDeviceEvent;
|
||||
|
||||
/**
|
||||
* \brief Game controller touchpad event structure (event.ctouchpad.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerTouchpadEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Sint32 touchpad; /**< The index of the touchpad */
|
||||
Sint32 finger; /**< The index of the finger on the touchpad */
|
||||
float x; /**< Normalized in the range 0...1 with 0 being on the left */
|
||||
float y; /**< Normalized in the range 0...1 with 0 being at the top */
|
||||
float pressure; /**< Normalized in the range 0...1 */
|
||||
} SDL_ControllerTouchpadEvent;
|
||||
|
||||
/**
|
||||
* \brief Game controller sensor event structure (event.csensor.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerSensorEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
|
||||
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
|
||||
} SDL_ControllerSensorEvent;
|
||||
|
||||
/**
|
||||
* \brief Audio device event structure (event.adevice.*)
|
||||
*/
|
||||
|
@ -442,6 +480,7 @@ typedef struct SDL_TouchFingerEvent
|
|||
float dx; /**< Normalized in the range -1...1 */
|
||||
float dy; /**< Normalized in the range -1...1 */
|
||||
float pressure; /**< Normalized in the range 0...1 */
|
||||
Uint32 windowID; /**< The window underneath the finger, if any */
|
||||
} SDL_TouchFingerEvent;
|
||||
|
||||
|
||||
|
@ -556,56 +595,79 @@ typedef struct SDL_SysWMEvent
|
|||
*/
|
||||
typedef union SDL_Event
|
||||
{
|
||||
Uint32 type; /**< Event type, shared with all events */
|
||||
SDL_CommonEvent common; /**< Common event data */
|
||||
SDL_DisplayEvent display; /**< Window event data */
|
||||
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_JoyDeviceEvent jdevice; /**< Joystick device change event data */
|
||||
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
|
||||
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
|
||||
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
|
||||
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
|
||||
SDL_SensorEvent sensor; /**< Sensor 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_MultiGestureEvent mgesture; /**< Gesture event data */
|
||||
SDL_DollarGestureEvent dgesture; /**< Gesture event data */
|
||||
SDL_DropEvent drop; /**< Drag and drop event data */
|
||||
Uint32 type; /**< Event type, shared with all events */
|
||||
SDL_CommonEvent common; /**< Common event data */
|
||||
SDL_DisplayEvent display; /**< Display event data */
|
||||
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_JoyDeviceEvent jdevice; /**< Joystick device change event data */
|
||||
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
|
||||
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
|
||||
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
|
||||
SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
|
||||
SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
|
||||
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
|
||||
SDL_SensorEvent sensor; /**< Sensor 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_MultiGestureEvent mgesture; /**< Gesture event data */
|
||||
SDL_DollarGestureEvent dgesture; /**< Gesture event data */
|
||||
SDL_DropEvent drop; /**< Drag and drop event data */
|
||||
|
||||
/* This is necessary for ABI compatibility between Visual C++ and GCC
|
||||
Visual C++ will respect the push pack pragma and use 52 bytes for
|
||||
this structure, and GCC will use the alignment of the largest datatype
|
||||
within the union, which is 8 bytes.
|
||||
/* This is necessary for ABI compatibility between Visual C++ and GCC.
|
||||
Visual C++ will respect the push pack pragma and use 52 bytes (size of
|
||||
SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
|
||||
architectures) for this union, and GCC will use the alignment of the
|
||||
largest datatype within the union, which is 8 bytes on 64-bit
|
||||
architectures.
|
||||
|
||||
So... we'll add padding to force the size to be 56 bytes for both.
|
||||
|
||||
On architectures where pointers are 16 bytes, this needs rounding up to
|
||||
the next multiple of 16, 64, and on architectures where pointers are
|
||||
even larger the size of SDL_UserEvent will dominate as being 3 pointers.
|
||||
*/
|
||||
Uint8 padding[56];
|
||||
Uint8 padding[sizeof(void *) <= 8 ? 56 : sizeof(void *) == 16 ? 64 : 3 * sizeof(void *)];
|
||||
} SDL_Event;
|
||||
|
||||
/* Make sure we haven't broken binary compatibility */
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* Pumps the event loop, gathering events from the input devices.
|
||||
* Pump the event loop, gathering events from the input devices.
|
||||
*
|
||||
* This function updates the event queue and internal input device state.
|
||||
* This function updates the event queue and internal input device state.
|
||||
*
|
||||
* This should only be run in the thread that sets the video mode.
|
||||
* **WARNING**: This should only be run in the thread that initialized the
|
||||
* video subsystem, and for extra safety, you should consider only doing those
|
||||
* things on the main thread in any case.
|
||||
*
|
||||
* SDL_PumpEvents() gathers all the pending input information from devices and
|
||||
* places it in the event queue. Without calls to SDL_PumpEvents() no events
|
||||
* would ever be placed on the queue. Often the need for calls to
|
||||
* SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
|
||||
* SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
|
||||
* polling or waiting for events (e.g. you are filtering them), then you must
|
||||
* call SDL_PumpEvents() to force an event queue update.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PollEvent
|
||||
* \sa SDL_WaitEvent
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
|
||||
|
||||
|
@ -618,22 +680,42 @@ typedef enum
|
|||
} SDL_eventaction;
|
||||
|
||||
/**
|
||||
* Checks the event queue for messages and optionally returns them.
|
||||
* Check the event queue for messages and optionally return them.
|
||||
*
|
||||
* If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
|
||||
* the back of the event queue.
|
||||
* `action` may be any of the following:
|
||||
*
|
||||
* 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.
|
||||
* - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the
|
||||
* event queue.
|
||||
* - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
|
||||
* within the specified minimum and maximum type, will be returned to the
|
||||
* caller and will _not_ be removed from the queue.
|
||||
* - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
|
||||
* within the specified minimum and maximum type, will be returned to the
|
||||
* caller and will 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.
|
||||
* You may have to call SDL_PumpEvents() before calling this function.
|
||||
* Otherwise, the events may not be ready to be filtered when you call
|
||||
* SDL_PeepEvents().
|
||||
*
|
||||
* \return The number of events actually stored, or -1 if there was an error.
|
||||
* This function is thread-safe.
|
||||
*
|
||||
* This function is thread-safe.
|
||||
* \param events destination buffer for the retrieved events
|
||||
* \param numevents if action is SDL_ADDEVENT, the number of events to add
|
||||
* back to the event queue; if action is SDL_PEEKEVENT or
|
||||
* SDL_GETEVENT, the maximum number of events to retrieve
|
||||
* \param action action to take; see [[#action|Remarks]] for details
|
||||
* \param minType minimum value of the event type to be considered;
|
||||
* SDL_FIRSTEVENT is a safe choice
|
||||
* \param maxType maximum value of the event type to be considered;
|
||||
* SDL_LASTEVENT is a safe choice
|
||||
* \returns the number of events actually stored or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PollEvent
|
||||
* \sa SDL_PumpEvents
|
||||
* \sa SDL_PushEvent
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
|
||||
SDL_eventaction action,
|
||||
|
@ -641,113 +723,354 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
|
|||
/* @} */
|
||||
|
||||
/**
|
||||
* Checks to see if certain event types are in the event queue.
|
||||
* Check for the existence of a certain event type in the event queue.
|
||||
*
|
||||
* If you need to check for a range of event types, use SDL_HasEvents()
|
||||
* instead.
|
||||
*
|
||||
* \param type the type of event to be queried; see SDL_EventType for details
|
||||
* \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
|
||||
* events matching `type` are not present.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HasEvents
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
|
||||
|
||||
|
||||
/**
|
||||
* Check for the existence of certain event types in the event queue.
|
||||
*
|
||||
* If you need to check for a single event type, use SDL_HasEvent() instead.
|
||||
*
|
||||
* \param minType the low end of event type to be queried, inclusive; see
|
||||
* SDL_EventType for details
|
||||
* \param maxType the high end of event type to be queried, inclusive; see
|
||||
* SDL_EventType for details
|
||||
* \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
|
||||
* present, or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HasEvents
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
|
||||
|
||||
/**
|
||||
* This function clears events from the event queue
|
||||
* This function only affects currently queued events. If you want to make
|
||||
* sure that all pending OS events are flushed, you can call SDL_PumpEvents()
|
||||
* on the main thread immediately before the flush call.
|
||||
* Clear events of a specific type from the event queue.
|
||||
*
|
||||
* This will unconditionally remove any events from the queue that match
|
||||
* `type`. If you need to remove a range of event types, use SDL_FlushEvents()
|
||||
* instead.
|
||||
*
|
||||
* It's also normal to just ignore events you don't care about in your event
|
||||
* loop without calling this function.
|
||||
*
|
||||
* This function only affects currently queued events. If you want to make
|
||||
* sure that all pending OS events are flushed, you can call SDL_PumpEvents()
|
||||
* on the main thread immediately before the flush call.
|
||||
*
|
||||
* \param type the type of event to be cleared; see SDL_EventType for details
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_FlushEvents
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
|
||||
|
||||
/**
|
||||
* Clear events of a range of types from the event queue.
|
||||
*
|
||||
* This will unconditionally remove any events from the queue that are in the
|
||||
* range of `minType` to `maxType`, inclusive. If you need to remove a single
|
||||
* event type, use SDL_FlushEvent() instead.
|
||||
*
|
||||
* It's also normal to just ignore events you don't care about in your event
|
||||
* loop without calling this function.
|
||||
*
|
||||
* This function only affects currently queued events. If you want to make
|
||||
* sure that all pending OS events are flushed, you can call SDL_PumpEvents()
|
||||
* on the main thread immediately before the flush call.
|
||||
*
|
||||
* \param minType the low end of event type to be cleared, inclusive; see
|
||||
* SDL_EventType for details
|
||||
* \param maxType the high end of event type to be cleared, inclusive; see
|
||||
* SDL_EventType for details
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_FlushEvent
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
|
||||
|
||||
/**
|
||||
* \brief Polls for currently pending events.
|
||||
* Poll for currently pending events.
|
||||
*
|
||||
* \return 1 if there are any pending events, or 0 if there are none available.
|
||||
* If `event` is not NULL, the next event is removed from the queue and stored
|
||||
* in the SDL_Event structure pointed to by `event`. The 1 returned refers to
|
||||
* this event, immediately stored in the SDL Event structure -- not an event
|
||||
* to follow.
|
||||
*
|
||||
* \param event If not NULL, the next event is removed from the queue and
|
||||
* stored in that area.
|
||||
* If `event` is NULL, it simply returns 1 if there is an event in the queue,
|
||||
* but will not remove it from the queue.
|
||||
*
|
||||
* As this function may implicitly call SDL_PumpEvents(), you can only call
|
||||
* this function in the thread that set the video mode.
|
||||
*
|
||||
* SDL_PollEvent() is the favored way of receiving system events since it can
|
||||
* be done from the main loop and does not suspend the main loop while waiting
|
||||
* on an event to be posted.
|
||||
*
|
||||
* The common practice is to fully process the event queue once every frame,
|
||||
* usually as a first step before updating the game's state:
|
||||
*
|
||||
* ```c
|
||||
* while (game_is_still_running) {
|
||||
* SDL_Event event;
|
||||
* while (SDL_PollEvent(&event)) { // poll until all events are handled!
|
||||
* // decide what to do with this event.
|
||||
* }
|
||||
*
|
||||
* // update game state, draw the current frame
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* \param event the SDL_Event structure to be filled with the next event from
|
||||
* the queue, or NULL
|
||||
* \returns 1 if there is a pending event or 0 if there are none available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetEventFilter
|
||||
* \sa SDL_PeepEvents
|
||||
* \sa SDL_PushEvent
|
||||
* \sa SDL_SetEventFilter
|
||||
* \sa SDL_WaitEvent
|
||||
* \sa SDL_WaitEventTimeout
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
|
||||
|
||||
/**
|
||||
* \brief Waits indefinitely for the next available event.
|
||||
* Wait indefinitely for the next available event.
|
||||
*
|
||||
* \return 1, or 0 if there was an error while waiting for events.
|
||||
* If `event` is not NULL, the next event is removed from the queue and stored
|
||||
* in the SDL_Event structure pointed to by `event`.
|
||||
*
|
||||
* \param event If not NULL, the next event is removed from the queue and
|
||||
* stored in that area.
|
||||
* As this function may implicitly call SDL_PumpEvents(), you can only call
|
||||
* this function in the thread that initialized the video subsystem.
|
||||
*
|
||||
* \param event the SDL_Event structure to be filled in with the next event
|
||||
* from the queue, or NULL
|
||||
* \returns 1 on success or 0 if there was an error while waiting for events;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PollEvent
|
||||
* \sa SDL_PumpEvents
|
||||
* \sa SDL_WaitEventTimeout
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
|
||||
|
||||
/**
|
||||
* \brief Waits until the specified timeout (in milliseconds) for the next
|
||||
* available event.
|
||||
* Wait until the specified timeout (in milliseconds) for the next available
|
||||
* event.
|
||||
*
|
||||
* \return 1, or 0 if there was an error while waiting for events.
|
||||
* If `event` is not NULL, the next event is removed from the queue and stored
|
||||
* in the SDL_Event structure pointed to by `event`.
|
||||
*
|
||||
* \param event If not NULL, the next event is removed from the queue and
|
||||
* stored in that area.
|
||||
* \param timeout The timeout (in milliseconds) to wait for next event.
|
||||
* As this function may implicitly call SDL_PumpEvents(), you can only call
|
||||
* this function in the thread that initialized the video subsystem.
|
||||
*
|
||||
* \param event the SDL_Event structure to be filled in with the next event
|
||||
* from the queue, or NULL
|
||||
* \param timeout the maximum number of milliseconds to wait for the next
|
||||
* available event
|
||||
* \returns 1 on success or 0 if there was an error while waiting for events;
|
||||
* call SDL_GetError() for more information. This also returns 0 if
|
||||
* the timeout elapsed without an event arriving.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PollEvent
|
||||
* \sa SDL_PumpEvents
|
||||
* \sa SDL_WaitEvent
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
|
||||
int timeout);
|
||||
|
||||
/**
|
||||
* \brief Add an event to the event queue.
|
||||
* 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.
|
||||
* The event queue can actually be used as a two way communication channel.
|
||||
* Not only can events be read from the queue, but the user can also push
|
||||
* their own events onto it. `event` is a pointer to the event structure you
|
||||
* wish to push onto the queue. The event is copied into the queue, and the
|
||||
* caller may dispose of the memory pointed to after SDL_PushEvent() returns.
|
||||
*
|
||||
* Note: Pushing device input events onto the queue doesn't modify the state
|
||||
* of the device within SDL.
|
||||
*
|
||||
* This function is thread-safe, and can be called from other threads safely.
|
||||
*
|
||||
* Note: Events pushed onto the queue with SDL_PushEvent() get passed through
|
||||
* the event filter but events added with SDL_PeepEvents() do not.
|
||||
*
|
||||
* For pushing application-specific events, please use SDL_RegisterEvents() to
|
||||
* get an event type that does not conflict with other code that also wants
|
||||
* its own custom event types.
|
||||
*
|
||||
* \param event the SDL_Event to be added to the queue
|
||||
* \returns 1 on success, 0 if the event was filtered, or a negative error
|
||||
* code on failure; call SDL_GetError() for more information. A
|
||||
* common reason for error is the event queue being full.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PeepEvents
|
||||
* \sa SDL_PollEvent
|
||||
* \sa SDL_RegisterEvents
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
|
||||
|
||||
/**
|
||||
* A function pointer used for callbacks that watch the event queue.
|
||||
*
|
||||
* \param userdata what was passed as `userdata` to SDL_SetEventFilter()
|
||||
* or SDL_AddEventWatch, etc
|
||||
* \param event the event that triggered the callback
|
||||
* \returns 1 to permit event to be added to the queue, and 0 to disallow
|
||||
* it. When used with SDL_AddEventWatch, the return value is ignored.
|
||||
*
|
||||
* \sa SDL_SetEventFilter
|
||||
* \sa SDL_AddEventWatch
|
||||
*/
|
||||
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.
|
||||
* Set up a filter to process all events before they change internal state and
|
||||
* are posted to the internal event queue.
|
||||
*
|
||||
* The filter is prototyped as:
|
||||
* \code
|
||||
* int SDL_EventFilter(void *userdata, SDL_Event * event);
|
||||
* \endcode
|
||||
* If the filter function returns 1 when called, 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.
|
||||
*
|
||||
* 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!
|
||||
*
|
||||
* \warning Be very careful of what you do in the event filter function, as
|
||||
* it may run in a different thread!
|
||||
* On platforms that support it, if the quit event is generated by an
|
||||
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
|
||||
* application at the next event poll.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
* Note: Disabled events never make it to the event filter function; see
|
||||
* SDL_EventState().
|
||||
*
|
||||
* Note: If you just want to inspect events without filtering, you should use
|
||||
* SDL_AddEventWatch() instead.
|
||||
*
|
||||
* Note: Events pushed onto the queue with SDL_PushEvent() get passed through
|
||||
* the event filter, but events pushed onto the queue with SDL_PeepEvents() do
|
||||
* not.
|
||||
*
|
||||
* \param filter An SDL_EventFilter function to call when an event happens
|
||||
* \param userdata a pointer that is passed to `filter`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AddEventWatch
|
||||
* \sa SDL_EventState
|
||||
* \sa SDL_GetEventFilter
|
||||
* \sa SDL_PeepEvents
|
||||
* \sa SDL_PushEvent
|
||||
*/
|
||||
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.
|
||||
* Query the current event filter.
|
||||
*
|
||||
* This function can be used to "chain" filters, by saving the existing filter
|
||||
* before replacing it with a function that will call that saved filter.
|
||||
*
|
||||
* \param filter the current callback function will be stored here
|
||||
* \param userdata the pointer that is passed to the current event filter will
|
||||
* be stored here
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_SetEventFilter
|
||||
*/
|
||||
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.
|
||||
* Add a callback to be triggered when an event is added to the event queue.
|
||||
*
|
||||
* `filter` will be called when an event happens, and its return value is
|
||||
* ignored.
|
||||
*
|
||||
* **WARNING**: Be very careful of what you do in the event filter function,
|
||||
* as it may run in a different thread!
|
||||
*
|
||||
* If the quit event is generated by a signal (e.g. SIGINT), it will bypass
|
||||
* the internal queue and be delivered to the watch callback immediately, and
|
||||
* arrive at the next event poll.
|
||||
*
|
||||
* Note: the callback is called for events posted by the user through
|
||||
* SDL_PushEvent(), but not for disabled events, nor for events by a filter
|
||||
* callback set with SDL_SetEventFilter(), nor for events posted by the user
|
||||
* through SDL_PeepEvents().
|
||||
*
|
||||
* \param filter an SDL_EventFilter function to call when an event happens.
|
||||
* \param userdata a pointer that is passed to `filter`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_DelEventWatch
|
||||
* \sa SDL_SetEventFilter
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Remove an event watch function added with SDL_AddEventWatch()
|
||||
* Remove an event watch callback added with SDL_AddEventWatch().
|
||||
*
|
||||
* This function takes the same input as SDL_AddEventWatch() to identify and
|
||||
* delete the corresponding callback.
|
||||
*
|
||||
* \param filter the function originally passed to SDL_AddEventWatch()
|
||||
* \param userdata the pointer originally passed to SDL_AddEventWatch()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa 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.
|
||||
* Run a specific filter function on the current event queue, removing any
|
||||
* events for which the filter returns 0.
|
||||
*
|
||||
* See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
|
||||
* this function does not change the filter permanently, it only uses the
|
||||
* supplied filter until this function returns.
|
||||
*
|
||||
* \param filter the SDL_EventFilter function to call when an event happens
|
||||
* \param userdata a pointer that is passed to `filter`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetEventFilter
|
||||
* \sa SDL_SetEventFilter
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
@ -759,24 +1082,45 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
|
|||
#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 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.
|
||||
* Set the state of processing events by type.
|
||||
*
|
||||
* `state` may be any of the following:
|
||||
*
|
||||
* - `SDL_QUERY`: returns the current processing state of the specified event
|
||||
* - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped
|
||||
* from the event queue and will not be filtered
|
||||
* - `SDL_ENABLE`: the event will be processed normally
|
||||
*
|
||||
* \param type the type of event; see SDL_EventType for details
|
||||
* \param state how to process the event
|
||||
* \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
|
||||
* of the event before this function makes any changes to it.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetEventState
|
||||
*/
|
||||
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.
|
||||
* Allocate a set of user-defined events, and return the beginning event
|
||||
* number for that set of events.
|
||||
*
|
||||
* If there aren't enough user-defined events left, this function
|
||||
* returns (Uint32)-1
|
||||
* Calling this function with `numevents` <= 0 is an error and will return
|
||||
* (Uint32)-1.
|
||||
*
|
||||
* Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
|
||||
* 0xFFFFFFFF), but is clearer to write.
|
||||
*
|
||||
* \param numevents the number of events to be allocated
|
||||
* \returns the beginning event number, or (Uint32)-1 if there are not enough
|
||||
* user-defined events left.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PushEvent
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -38,88 +38,97 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* \brief Get the path where the application resides.
|
||||
* Get the directory where the application was run from.
|
||||
*
|
||||
* Get the "base path". This is the directory where the application was run
|
||||
* from, which is probably the installation directory, and may or may not
|
||||
* be the process's current working directory.
|
||||
* This is not necessarily a fast call, so you should call this once near
|
||||
* startup and save the string if you need it.
|
||||
*
|
||||
* This returns an absolute path in UTF-8 encoding, and is guaranteed to
|
||||
* end with a path separator ('\\' on Windows, '/' most other places).
|
||||
* **Mac OS X and iOS Specific Functionality**: If the application is in a
|
||||
* ".app" bundle, this function returns the Resource directory (e.g.
|
||||
* MyApp.app/Contents/Resources/). This behaviour can be overridden by adding
|
||||
* a property to the Info.plist file. Adding a string key with the name
|
||||
* SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the
|
||||
* behaviour.
|
||||
*
|
||||
* The pointer returned by this function is owned by you. Please call
|
||||
* SDL_free() on the pointer when you are done with it, or it will be a
|
||||
* memory leak. This is not necessarily a fast call, though, so you should
|
||||
* call this once near startup and save the string if you need it.
|
||||
* Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an
|
||||
* application in /Applications/SDLApp/MyApp.app):
|
||||
*
|
||||
* Some platforms can't determine the application's path, and on other
|
||||
* platforms, this might be meaningless. In such cases, this function will
|
||||
* return NULL.
|
||||
* - `resource`: bundle resource directory (the default). For example:
|
||||
* `/Applications/SDLApp/MyApp.app/Contents/Resources`
|
||||
* - `bundle`: the Bundle directory. For example:
|
||||
* `/Applications/SDLApp/MyApp.app/`
|
||||
* - `parent`: the containing directory of the bundle. For example:
|
||||
* `/Applications/SDLApp/`
|
||||
*
|
||||
* \return String of base dir in UTF-8 encoding, or NULL on error.
|
||||
* The returned path is guaranteed to end with a path separator ('\' on
|
||||
* Windows, '/' on most other platforms).
|
||||
*
|
||||
* The pointer returned is owned by the caller. Please call SDL_free() on the
|
||||
* pointer when done with it.
|
||||
*
|
||||
* \returns an absolute path in UTF-8 encoding to the application data
|
||||
* directory. NULL will be returned on error or when the platform
|
||||
* doesn't implement this functionality, call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.1.
|
||||
*
|
||||
* \sa SDL_GetPrefPath
|
||||
*/
|
||||
extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
|
||||
|
||||
/**
|
||||
* \brief Get the user-and-app-specific path where files can be written.
|
||||
* Get the user-and-app-specific path where files can be written.
|
||||
*
|
||||
* Get the "pref dir". This is meant to be where users can write personal
|
||||
* files (preferences and save games, etc) that are specific to your
|
||||
* application. This directory is unique per user, per application.
|
||||
* files (preferences and save games, etc) that are specific to your
|
||||
* application. This directory is unique per user, per application.
|
||||
*
|
||||
* This function will decide the appropriate location in the native filesystem,
|
||||
* create the directory if necessary, and return a string of the absolute
|
||||
* path to the directory in UTF-8 encoding.
|
||||
* This function will decide the appropriate location in the native
|
||||
* filesystem, create the directory if necessary, and return a string of the
|
||||
* absolute path to the directory in UTF-8 encoding.
|
||||
*
|
||||
* On Windows, the string might look like:
|
||||
* "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\"
|
||||
*
|
||||
* On Linux, the string might look like:
|
||||
* "/home/bob/.local/share/My Program Name/"
|
||||
* `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\`
|
||||
*
|
||||
* On Linux, the string might look like"
|
||||
*
|
||||
* `/home/bob/.local/share/My Program Name/`
|
||||
*
|
||||
* On Mac OS X, the string might look like:
|
||||
* "/Users/bob/Library/Application Support/My Program Name/"
|
||||
*
|
||||
* (etc.)
|
||||
* `/Users/bob/Library/Application Support/My Program Name/`
|
||||
*
|
||||
* You specify the name of your organization (if it's not a real organization,
|
||||
* your name or an Internet domain you own might do) and the name of your
|
||||
* application. These should be untranslated proper names.
|
||||
* You should assume the path returned by this function is the only safe place
|
||||
* to write files (and that SDL_GetBasePath(), while it might be writable, or
|
||||
* even the parent of the returned path, isn't where you should be writing
|
||||
* things).
|
||||
*
|
||||
* Both the org and app strings may become part of a directory name, so
|
||||
* please follow these rules:
|
||||
* Both the org and app strings may become part of a directory name, so please
|
||||
* follow these rules:
|
||||
*
|
||||
* - Try to use the same org string (including case-sensitivity) for
|
||||
* all your applications that use this function.
|
||||
* - Always use a unique app string for each one, and make sure it never
|
||||
* changes for an app once you've decided on it.
|
||||
* - Unicode characters are legal, as long as it's UTF-8 encoded, but...
|
||||
* - ...only use letters, numbers, and spaces. Avoid punctuation like
|
||||
* "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
|
||||
* - Try to use the same org string (_including case-sensitivity_) for all
|
||||
* your applications that use this function.
|
||||
* - Always use a unique app string for each one, and make sure it never
|
||||
* changes for an app once you've decided on it.
|
||||
* - Unicode characters are legal, as long as it's UTF-8 encoded, but...
|
||||
* - ...only use letters, numbers, and spaces. Avoid punctuation like "Game
|
||||
* Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
|
||||
*
|
||||
* This returns an absolute path in UTF-8 encoding, and is guaranteed to
|
||||
* end with a path separator ('\\' on Windows, '/' most other places).
|
||||
* The returned path is guaranteed to end with a path separator ('\' on
|
||||
* Windows, '/' on most other platforms).
|
||||
*
|
||||
* The pointer returned by this function is owned by you. Please call
|
||||
* SDL_free() on the pointer when you are done with it, or it will be a
|
||||
* memory leak. This is not necessarily a fast call, though, so you should
|
||||
* call this once near startup and save the string if you need it.
|
||||
* The pointer returned is owned by the caller. Please call SDL_free() on the
|
||||
* pointer when done with it.
|
||||
*
|
||||
* You should assume the path returned by this function is the only safe
|
||||
* place to write files (and that SDL_GetBasePath(), while it might be
|
||||
* writable, or even the parent of the returned path, aren't where you
|
||||
* should be writing things).
|
||||
* \param org the name of your organization
|
||||
* \param app the name of your application
|
||||
* \returns a UTF-8 string of the user directory in platform-dependent
|
||||
* notation. NULL if there's a problem (creating directory failed,
|
||||
* etc.).
|
||||
*
|
||||
* Some platforms can't determine the pref path, and on other
|
||||
* platforms, this might be meaningless. In such cases, this function will
|
||||
* return NULL.
|
||||
*
|
||||
* \param org The name of your organization.
|
||||
* \param app The name of your application.
|
||||
* \return UTF-8 string of user dir in platform-dependent notation. NULL
|
||||
* if there's a problem (creating directory failed, etc).
|
||||
* \since This function is available since SDL 2.0.1.
|
||||
*
|
||||
* \sa SDL_GetBasePath
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -31,6 +31,7 @@
|
|||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_sensor.h"
|
||||
#include "SDL_joystick.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
|
@ -57,6 +58,19 @@ extern "C" {
|
|||
struct _SDL_GameController;
|
||||
typedef struct _SDL_GameController SDL_GameController;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_CONTROLLER_TYPE_UNKNOWN = 0,
|
||||
SDL_CONTROLLER_TYPE_XBOX360,
|
||||
SDL_CONTROLLER_TYPE_XBOXONE,
|
||||
SDL_CONTROLLER_TYPE_PS3,
|
||||
SDL_CONTROLLER_TYPE_PS4,
|
||||
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
|
||||
SDL_CONTROLLER_TYPE_VIRTUAL,
|
||||
SDL_CONTROLLER_TYPE_PS5,
|
||||
SDL_CONTROLLER_TYPE_AMAZON_LUNA,
|
||||
SDL_CONTROLLER_TYPE_GOOGLE_STADIA
|
||||
} SDL_GameControllerType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -87,6 +101,8 @@ typedef struct SDL_GameControllerButtonBind
|
|||
|
||||
/**
|
||||
* To count the number of game controllers in the system for the following:
|
||||
*
|
||||
* ```c
|
||||
* int nJoysticks = SDL_NumJoysticks();
|
||||
* int nGameControllers = 0;
|
||||
* for (int i = 0; i < nJoysticks; i++) {
|
||||
|
@ -94,6 +110,7 @@ typedef struct SDL_GameControllerButtonBind
|
|||
* nGameControllers++;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
|
||||
* guid,name,mappings
|
||||
|
@ -107,17 +124,39 @@ typedef struct SDL_GameControllerButtonBind
|
|||
* Buttons can be used as a controller axis and vice versa.
|
||||
*
|
||||
* This string shows an example of a valid mapping for a controller
|
||||
* "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
|
||||
*
|
||||
* ```c
|
||||
* "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform()
|
||||
* A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
|
||||
* Load a set of Game Controller mappings from a seekable SDL data stream.
|
||||
*
|
||||
* If \c freerw is non-zero, the stream will be closed after being read.
|
||||
*
|
||||
* \return number of mappings added, -1 on error
|
||||
* You can call this function several times, if needed, to load different
|
||||
* database files.
|
||||
*
|
||||
* If a new mapping is loaded for an already known controller GUID, the later
|
||||
* version will overwrite the one currently loaded.
|
||||
*
|
||||
* Mappings not belonging to the current platform or with no platform field
|
||||
* specified will be ignored (i.e. mappings for Linux will be ignored in
|
||||
* Windows, etc).
|
||||
*
|
||||
* This function will load the text database entirely in memory before
|
||||
* processing it, so take this into consideration if you are in a memory
|
||||
* constrained environment.
|
||||
*
|
||||
* \param rw the data stream for the mappings to be added
|
||||
* \param freerw non-zero to close the stream after being read
|
||||
* \returns the number of mappings added or -1 on error; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*
|
||||
* \sa SDL_GameControllerAddMapping
|
||||
* \sa SDL_GameControllerAddMappingsFromFile
|
||||
* \sa SDL_GameControllerMappingForGUID
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
|
||||
|
||||
|
@ -129,133 +168,372 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
|
|||
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
|
||||
|
||||
/**
|
||||
* Add or update an existing mapping configuration
|
||||
* Add support for controllers that SDL is unaware of or to cause an existing
|
||||
* controller to have a different binding.
|
||||
*
|
||||
* \return 1 if mapping is added, 0 if updated, -1 on error
|
||||
* The mapping string has the format "GUID,name,mapping", where GUID is the
|
||||
* string value from SDL_JoystickGetGUIDString(), name is the human readable
|
||||
* string for the device and mappings are controller mappings to joystick
|
||||
* ones. Under Windows there is a reserved GUID of "xinput" that covers all
|
||||
* XInput devices. The mapping format for joystick is: {| |bX |a joystick
|
||||
* button, index X |- |hX.Y |hat X with value Y |- |aX |axis X of the joystick
|
||||
* |} Buttons can be used as a controller axes and vice versa.
|
||||
*
|
||||
* This string shows an example of a valid mapping for a controller:
|
||||
*
|
||||
* ```c
|
||||
* "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
|
||||
* ```
|
||||
*
|
||||
* \param mappingString the mapping string
|
||||
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
|
||||
* -1 on error; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerMapping
|
||||
* \sa SDL_GameControllerMappingForGUID
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
|
||||
|
||||
/**
|
||||
* Get the number of mappings installed
|
||||
* Get the number of mappings installed.
|
||||
*
|
||||
* \return the number of mappings
|
||||
* \returns the number of mappings.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
|
||||
|
||||
/**
|
||||
* Get the mapping at a particular index.
|
||||
* Get the mapping at a particular index.
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range.
|
||||
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
|
||||
* the index is out of range.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
|
||||
|
||||
/**
|
||||
* Get a mapping string for a GUID
|
||||
* Get the game controller mapping string for a given GUID.
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
|
||||
* The returned string must be freed with SDL_free().
|
||||
*
|
||||
* \param guid a structure containing the GUID for which a mapping is desired
|
||||
* \returns a mapping string or NULL on error; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetDeviceGUID
|
||||
* \sa SDL_JoystickGetGUID
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
|
||||
|
||||
/**
|
||||
* Get a mapping string for an open GameController
|
||||
* Get the current mapping of a Game Controller.
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
|
||||
* The returned string must be freed with SDL_free().
|
||||
*
|
||||
* Details about mappings are discussed with SDL_GameControllerAddMapping().
|
||||
*
|
||||
* \param gamecontroller the game controller you want to get the current
|
||||
* mapping for
|
||||
* \returns a string that has the controller's mapping or NULL if no mapping
|
||||
* is available; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerAddMapping
|
||||
* \sa SDL_GameControllerMappingForGUID
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller);
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Is the joystick on this index supported by the game controller interface?
|
||||
* Check if the given joystick is supported by the game controller interface.
|
||||
*
|
||||
* `joystick_index` is the same as the `device_index` passed to
|
||||
* SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick_index the device_index of a device, up to
|
||||
* SDL_NumJoysticks()
|
||||
* \returns SDL_TRUE if the given joystick is supported by the game controller
|
||||
* interface, SDL_FALSE if it isn't or it's an invalid index.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerNameForIndex
|
||||
* \sa SDL_GameControllerOpen
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
|
||||
|
||||
/**
|
||||
* Get the implementation dependent name of a game controller.
|
||||
* This can be called before any controllers are opened.
|
||||
* If no name can be found, this function returns NULL.
|
||||
* Get the implementation dependent name for the game controller.
|
||||
*
|
||||
* This function can be called before any controllers are opened.
|
||||
*
|
||||
* `joystick_index` is the same as the `device_index` passed to
|
||||
* SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the implementation-dependent name for the game controller, or NULL
|
||||
* if there is no name or the index is invalid.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerName
|
||||
* \sa SDL_GameControllerOpen
|
||||
* \sa SDL_IsGameController
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
|
||||
|
||||
/**
|
||||
* Get the mapping of a game controller.
|
||||
* This can be called before any controllers are opened.
|
||||
* Get the type of a game controller.
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
|
||||
* This can be called before any controllers are opened.
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the controller type.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
|
||||
|
||||
/**
|
||||
* Get the mapping of a game controller.
|
||||
*
|
||||
* This can be called before any controllers are opened.
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
|
||||
* no mapping is available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
|
||||
|
||||
/**
|
||||
* Open a game controller for use.
|
||||
* The index passed as an argument refers to the N'th game controller on the system.
|
||||
* This index is not the value which will identify this controller in future
|
||||
* controller events. The joystick's instance id (::SDL_JoystickID) will be
|
||||
* used there instead.
|
||||
* Open a game controller for use.
|
||||
*
|
||||
* \return A controller identifier, or NULL if an error occurred.
|
||||
* `joystick_index` is the same as the `device_index` passed to
|
||||
* SDL_JoystickOpen().
|
||||
*
|
||||
* The index passed as an argument refers to the N'th game controller on the
|
||||
* system. This index is not the value which will identify this controller in
|
||||
* future controller events. The joystick's instance id (SDL_JoystickID) will
|
||||
* be used there instead.
|
||||
*
|
||||
* \param joystick_index the device_index of a device, up to
|
||||
* SDL_NumJoysticks()
|
||||
* \returns a gamecontroller identifier or NULL if an error occurred; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerClose
|
||||
* \sa SDL_GameControllerNameForIndex
|
||||
* \sa SDL_IsGameController
|
||||
*/
|
||||
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
|
||||
|
||||
/**
|
||||
* Return the SDL_GameController associated with an instance id.
|
||||
* Get the SDL_GameController associated with an instance id.
|
||||
*
|
||||
* \param joyid the instance id to get the SDL_GameController for
|
||||
* \returns an SDL_GameController on success or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*/
|
||||
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
|
||||
|
||||
/**
|
||||
* Return the name for this currently opened controller
|
||||
* Get the SDL_GameController associated with a player index.
|
||||
*
|
||||
* Please note that the player index is _not_ the device index, nor is it the
|
||||
* instance id!
|
||||
*
|
||||
* \param player_index the player index, which is not the device index or the
|
||||
* instance id!
|
||||
* \returns the SDL_GameController associated with a player index.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*
|
||||
* \sa SDL_GameControllerGetPlayerIndex
|
||||
* \sa SDL_GameControllerSetPlayerIndex
|
||||
*/
|
||||
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index);
|
||||
|
||||
/**
|
||||
* Get the implementation-dependent name for an opened game controller.
|
||||
*
|
||||
* This is the same name as returned by SDL_GameControllerNameForIndex(), but
|
||||
* it takes a controller identifier instead of the (unstable) device index.
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen()
|
||||
* \returns the implementation dependent name for the game controller, or NULL
|
||||
* if there is no name or the identifier passed is invalid.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerNameForIndex
|
||||
* \sa SDL_GameControllerOpen
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the player index of an opened game controller, or -1 if it's not available
|
||||
* Get the type of this currently opened controller
|
||||
*
|
||||
* For XInput controllers this returns the XInput user index.
|
||||
* This is the same name as returned by SDL_GameControllerTypeForIndex(), but
|
||||
* it takes a controller identifier instead of the (unstable) device index.
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \returns the controller type.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the player index of an opened game controller.
|
||||
*
|
||||
* For XInput controllers this returns the XInput user index.
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \returns the player index for controller, or -1 if it's not available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened controller, if available.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
* Set the player index of an opened game controller.
|
||||
*
|
||||
* \param gamecontroller the game controller object to adjust.
|
||||
* \param player_index Player index to assign to this controller.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller);
|
||||
extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of an opened controller, if available.
|
||||
* If the product ID isn't available this function returns 0.
|
||||
* Get the USB vendor ID of an opened controller, if available.
|
||||
*
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \return the USB vendor ID, or zero if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller);
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the product version of an opened controller, if available.
|
||||
* If the product version isn't available this function returns 0.
|
||||
* Get the USB product ID of an opened controller, if available.
|
||||
*
|
||||
* If the product ID isn't available this function returns 0.
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \return the USB product ID, or zero if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller);
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Returns SDL_TRUE if the controller has been opened and currently connected,
|
||||
* or SDL_FALSE if it has not.
|
||||
* Get the product version of an opened controller, if available.
|
||||
*
|
||||
* If the product version isn't available this function returns 0.
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \return the USB product version, or zero if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the serial number of an opened controller, if available.
|
||||
*
|
||||
* Returns the serial number of the controller, or NULL if it is not
|
||||
* available.
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \return the serial number, or NULL if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Check if a controller has been opened and is currently connected.
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen()
|
||||
* \returns SDL_TRUE if the controller has been opened and is currently
|
||||
* connected, or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerClose
|
||||
* \sa SDL_GameControllerOpen
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the underlying joystick object used by a controller
|
||||
* Get the Joystick ID from a Game Controller.
|
||||
*
|
||||
* This function will give you a SDL_Joystick object, which allows you to use
|
||||
* the SDL_Joystick functions with a SDL_GameController object. This would be
|
||||
* useful for getting a joystick's position at any given time, even if it
|
||||
* hasn't moved (moving it would produce an event, which would have the axis'
|
||||
* value).
|
||||
*
|
||||
* The pointer returned is owned by the SDL_GameController. You should not
|
||||
* call SDL_JoystickClose() on it, for example, since doing so will likely
|
||||
* cause SDL to crash.
|
||||
*
|
||||
* \param gamecontroller the game controller object that you want to get a
|
||||
* joystick from
|
||||
* \returns a SDL_Joystick object; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Enable/disable controller event polling.
|
||||
* Query or change current state of Game Controller events.
|
||||
*
|
||||
* If controller events are disabled, you must call SDL_GameControllerUpdate()
|
||||
* yourself and check the state of the controller when you want controller
|
||||
* information.
|
||||
* If controller events are disabled, you must call SDL_GameControllerUpdate()
|
||||
* yourself and check the state of the controller when you want controller
|
||||
* information.
|
||||
*
|
||||
* The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
|
||||
* Any number can be passed to SDL_GameControllerEventState(), but only -1, 0,
|
||||
* and 1 will have any effect. Other numbers will just be returned.
|
||||
*
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
||||
* \returns the same value passed to the function, with exception to -1
|
||||
* (SDL_QUERY), which will return the current state.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickEventState
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
|
||||
|
||||
/**
|
||||
* Update the current state of the open game controllers.
|
||||
* Manually pump game controller updates if not using the loop.
|
||||
*
|
||||
* This is called automatically by the event loop if any game controller
|
||||
* events are enabled.
|
||||
* This function is called automatically by the event loop if events are
|
||||
* enabled. Under such circumstances, it will not be necessary to call this
|
||||
* function.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
|
||||
|
||||
|
@ -282,33 +560,94 @@ typedef enum
|
|||
} SDL_GameControllerAxis;
|
||||
|
||||
/**
|
||||
* turn this string into a axis mapping
|
||||
* Convert a string into SDL_GameControllerAxis enum.
|
||||
*
|
||||
* This function is called internally to translate SDL_GameController mapping
|
||||
* strings for the underlying joystick device into the consistent
|
||||
* SDL_GameController mapping. You do not normally need to call this function
|
||||
* unless you are parsing SDL_GameController mappings in your own code.
|
||||
*
|
||||
* Note specially that "righttrigger" and "lefttrigger" map to
|
||||
* `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`,
|
||||
* respectively.
|
||||
*
|
||||
* \param str string representing a SDL_GameController axis
|
||||
* \returns the SDL_GameControllerAxis enum corresponding to the input string,
|
||||
* or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetStringForAxis
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
|
||||
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str);
|
||||
|
||||
/**
|
||||
* turn this axis enum into a string mapping
|
||||
* Convert from an SDL_GameControllerAxis enum to a string.
|
||||
*
|
||||
* The caller should not SDL_free() the returned string.
|
||||
*
|
||||
* \param axis an enum value for a given SDL_GameControllerAxis
|
||||
* \returns a string for the given axis, or NULL if an invalid axis is
|
||||
* specified. The string returned is of the format used by
|
||||
* SDL_GameController mapping strings.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetAxisFromString
|
||||
*/
|
||||
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* Get the SDL joystick layer binding for this controller button mapping
|
||||
* Get the SDL joystick layer binding for a controller axis mapping.
|
||||
*
|
||||
* \param gamecontroller a game controller
|
||||
* \param axis an axis enum value (one of the SDL_GameControllerAxis values)
|
||||
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
|
||||
* (like the given Controller axis doesn't exist on the device), its
|
||||
* `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetBindForButton
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
|
||||
SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
|
||||
SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* Get the current state of an axis control on a game controller.
|
||||
* Query whether a game controller has a given axis.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767 (except for the triggers,
|
||||
* which range from 0 to 32767).
|
||||
* This merely reports whether the controller's mapping defined this axis, as
|
||||
* that is all the information SDL has about the physical device.
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
* \param gamecontroller a game controller
|
||||
* \param axis an axis enum value (an SDL_GameControllerAxis value)
|
||||
* \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL
|
||||
SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* Get the current state of an axis control on a game controller.
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767. Triggers, however, range
|
||||
* from 0 to 32767 (they never return a negative value).
|
||||
*
|
||||
* \param gamecontroller a game controller
|
||||
* \param axis an axis index (one of the SDL_GameControllerAxis values)
|
||||
* \returns axis state (including 0) on success or 0 (also) on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetButton
|
||||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL
|
||||
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
|
||||
SDL_GameControllerAxis axis);
|
||||
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* The list of buttons available from a controller
|
||||
|
@ -331,53 +670,325 @@ typedef enum
|
|||
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
|
||||
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
|
||||
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
|
||||
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
|
||||
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
|
||||
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
|
||||
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
|
||||
SDL_CONTROLLER_BUTTON_MAX
|
||||
} SDL_GameControllerButton;
|
||||
|
||||
/**
|
||||
* turn this string into a button mapping
|
||||
* Convert a string into an SDL_GameControllerButton enum.
|
||||
*
|
||||
* This function is called internally to translate SDL_GameController mapping
|
||||
* strings for the underlying joystick device into the consistent
|
||||
* SDL_GameController mapping. You do not normally need to call this function
|
||||
* unless you are parsing SDL_GameController mappings in your own code.
|
||||
*
|
||||
* \param str string representing a SDL_GameController axis
|
||||
* \returns the SDL_GameControllerButton enum corresponding to the input
|
||||
* string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
|
||||
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str);
|
||||
|
||||
/**
|
||||
* turn this button enum into a string mapping
|
||||
* Convert from an SDL_GameControllerButton enum to a string.
|
||||
*
|
||||
* The caller should not SDL_free() the returned string.
|
||||
*
|
||||
* \param button an enum value for a given SDL_GameControllerButton
|
||||
* \returns a string for the given button, or NULL if an invalid axis is
|
||||
* specified. The string returned is of the format used by
|
||||
* SDL_GameController mapping strings.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetButtonFromString
|
||||
*/
|
||||
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Get the SDL joystick layer binding for this controller button mapping
|
||||
* Get the SDL joystick layer binding for a controller button mapping.
|
||||
*
|
||||
* \param gamecontroller a game controller
|
||||
* \param button an button enum value (an SDL_GameControllerButton value)
|
||||
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
|
||||
* (like the given Controller button doesn't exist on the device),
|
||||
* its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetBindForAxis
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
|
||||
SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
|
||||
SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Query whether a game controller has a given button.
|
||||
*
|
||||
* This merely reports whether the controller's mapping defined this button,
|
||||
* as that is all the information SDL has about the physical device.
|
||||
*
|
||||
* \param gamecontroller a game controller
|
||||
* \param button a button enum value (an SDL_GameControllerButton value)
|
||||
* \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
|
||||
SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Get the current state of a button on a game controller.
|
||||
* Get the current state of a button on a game controller.
|
||||
*
|
||||
* The button indices start at index 0.
|
||||
* \param gamecontroller a game controller
|
||||
* \param button a button index (one of the SDL_GameControllerButton values)
|
||||
* \returns 1 for pressed state or 0 for not pressed state or error; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerGetAxis
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
|
||||
SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Trigger a rumble effect
|
||||
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
|
||||
* Get the number of touchpads on a game controller.
|
||||
*
|
||||
* \param gamecontroller The controller to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the number of supported simultaneous fingers on a touchpad on a game
|
||||
* controller.
|
||||
*
|
||||
* \return 0, or -1 if rumble isn't supported on this joystick
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
|
||||
|
||||
/**
|
||||
* Get the current state of a finger on a touchpad on a game controller.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
|
||||
|
||||
/**
|
||||
* Return whether a game controller has a particular sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
|
||||
|
||||
/**
|
||||
* Set whether data reporting for a game controller sensor is enabled.
|
||||
*
|
||||
* \param gamecontroller The controller to update
|
||||
* \param type The type of sensor to enable/disable
|
||||
* \param enabled Whether data reporting should be enabled
|
||||
* \returns 0 or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* Query whether sensor data reporting is enabled for a game controller.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
|
||||
|
||||
/**
|
||||
* Get the data rate (number of events per second) of a game controller
|
||||
* sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \return the data rate, or 0.0f if the data rate is not available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
*/
|
||||
extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type);
|
||||
|
||||
/**
|
||||
* Get the current state of a game controller sensor.
|
||||
*
|
||||
* The number of values and interpretation of the data is sensor dependent.
|
||||
* See SDL_sensor.h for the details for each type of sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \param data A pointer filled with the current sensor state
|
||||
* \param num_values The number of values to write to data
|
||||
* \return 0 or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
|
||||
|
||||
/**
|
||||
* Start a rumble effect on a game controller.
|
||||
*
|
||||
* Each call to this function cancels any previous rumble effect, and calling
|
||||
* it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* \param gamecontroller The controller to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left)
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right)
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if rumble isn't supported on this controller
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*
|
||||
* \sa SDL_GameControllerHasRumble
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Close a controller previously opened with SDL_GameControllerOpen().
|
||||
* Start a rumble effect in the game controller's triggers.
|
||||
*
|
||||
* Each call to this function cancels any previous trigger rumble effect, and
|
||||
* calling it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* Note that this is rumbling of the _triggers_ and not the game controller as
|
||||
* a whole. The first controller to offer this feature was the PlayStation 5's
|
||||
* DualShock 5.
|
||||
*
|
||||
* \param gamecontroller The controller to vibrate
|
||||
* \param left_rumble The intensity of the left trigger rumble motor, from 0
|
||||
* to 0xFFFF
|
||||
* \param right_rumble The intensity of the right trigger rumble motor, from 0
|
||||
* to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if trigger rumble isn't supported on this controller
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
* \sa SDL_GameControllerHasRumbleTriggers
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Query whether a game controller has an LED.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
|
||||
* modifiable LED
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Query whether a game controller has rumble support.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
|
||||
* support
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_GameControllerRumble
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Query whether a game controller has rumble support on triggers.
|
||||
*
|
||||
* \param gamecontroller The controller to query
|
||||
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
|
||||
* rumble support
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_GameControllerRumbleTriggers
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Update a game controller's LED color.
|
||||
*
|
||||
* \param gamecontroller The controller to update
|
||||
* \param red The intensity of the red LED
|
||||
* \param green The intensity of the green LED
|
||||
* \param blue The intensity of the blue LED
|
||||
* \returns 0, or -1 if this controller does not have a modifiable LED
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
/**
|
||||
* Send a controller specific effect packet
|
||||
*
|
||||
* \param gamecontroller The controller to affect
|
||||
* \param data The data to send to the controller
|
||||
* \param size The size of the data to send to the controller
|
||||
* \returns 0, or -1 if this controller or driver doesn't support effect
|
||||
* packets
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size);
|
||||
|
||||
/**
|
||||
* Close a game controller previously opened with SDL_GameControllerOpen().
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerOpen
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Return the sfSymbolsName for a given button on a game controller on Apple
|
||||
* platforms.
|
||||
*
|
||||
* \param gamecontroller the controller to query
|
||||
* \param button a button on the game controller
|
||||
* \returns the sfSymbolsName or NULL if the name can't be found
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_GameControllerGetAppleSFSymbolsNameForAxis
|
||||
*/
|
||||
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Return the sfSymbolsName for a given axis on a game controller on Apple
|
||||
* platforms.
|
||||
*
|
||||
* \param gamecontroller the controller to query
|
||||
* \param axis an axis on the game controller
|
||||
* \returns the sfSymbolsName or NULL if the name can't be found
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_GameControllerGetAppleSFSymbolsNameForButton
|
||||
*/
|
||||
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -46,36 +46,66 @@ typedef Sint64 SDL_GestureID;
|
|||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Begin Recording a gesture on the specified touch, or all touches (-1)
|
||||
* Begin recording a gesture on a specified touch device or all touch devices.
|
||||
*
|
||||
* If the parameter `touchId` is -1 (i.e., all devices), this function will
|
||||
* always return 1, regardless of whether there actually are any devices.
|
||||
*
|
||||
* \param touchId the touch device id, or -1 for all touch devices
|
||||
* \returns 1 on success or 0 if the specified device could not be found.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetTouchDevice
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Save all currently loaded Dollar Gesture templates
|
||||
* Save all currently loaded Dollar Gesture templates.
|
||||
*
|
||||
* \param dst a SDL_RWops to save to
|
||||
* \returns the number of saved templates on success or 0 on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LoadDollarTemplates
|
||||
* \sa SDL_SaveDollarTemplate
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
|
||||
|
||||
/**
|
||||
* \brief Save a currently loaded Dollar Gesture template
|
||||
* Save a currently loaded Dollar Gesture template.
|
||||
*
|
||||
* \param gestureId a gesture id
|
||||
* \param dst a SDL_RWops to save to
|
||||
* \returns 1 on success or 0 on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LoadDollarTemplates
|
||||
* \sa SDL_SaveAllDollarTemplates
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load Dollar Gesture templates from a file
|
||||
* Load Dollar Gesture templates from a file.
|
||||
*
|
||||
* \param touchId a touch id
|
||||
* \param src a SDL_RWops to load from
|
||||
* \returns the number of loaded templates on success or a negative error code
|
||||
* (or 0) on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_SaveAllDollarTemplates
|
||||
* \sa SDL_SaveDollarTemplate
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -76,7 +76,7 @@
|
|||
* }
|
||||
*
|
||||
* // Create the effect
|
||||
* memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
|
||||
* SDL_memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
|
||||
* effect.type = SDL_HAPTIC_SINE;
|
||||
* effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
|
||||
* effect.periodic.direction.dir[0] = 18000; // Force comes from south
|
||||
|
@ -336,6 +336,14 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||
*/
|
||||
#define SDL_HAPTIC_SPHERICAL 2
|
||||
|
||||
/**
|
||||
* \brief Use this value to play an effect on the steering wheel axis. This
|
||||
* provides better compatibility across platforms and devices as SDL will guess
|
||||
* the correct axis.
|
||||
* \sa SDL_HapticDirection
|
||||
*/
|
||||
#define SDL_HAPTIC_STEERING_AXIS 3
|
||||
|
||||
/* @} *//* Direction encodings */
|
||||
|
||||
/* @} *//* Haptic features */
|
||||
|
@ -444,6 +452,7 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||
* \sa SDL_HAPTIC_POLAR
|
||||
* \sa SDL_HAPTIC_CARTESIAN
|
||||
* \sa SDL_HAPTIC_SPHERICAL
|
||||
* \sa SDL_HAPTIC_STEERING_AXIS
|
||||
* \sa SDL_HapticEffect
|
||||
* \sa SDL_HapticNumAxes
|
||||
*/
|
||||
|
@ -811,419 +820,513 @@ typedef union SDL_HapticEffect
|
|||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Count the number of haptic devices attached to the system.
|
||||
* Count the number of haptic devices attached to the system.
|
||||
*
|
||||
* \return Number of haptic devices detected on the system.
|
||||
* \returns the number of haptic devices detected on the system or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticName
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
|
||||
|
||||
/**
|
||||
* \brief Get the implementation dependent name of a haptic device.
|
||||
* Get the implementation dependent name of a haptic device.
|
||||
*
|
||||
* This can be called before any joysticks are opened.
|
||||
* If no name can be found, this function returns NULL.
|
||||
* This can be called before any joysticks are opened. If no name can be
|
||||
* found, this function returns NULL.
|
||||
*
|
||||
* \param device_index Index of the device to get its name.
|
||||
* \return Name of the device or NULL on error.
|
||||
* \param device_index index of the device to query.
|
||||
* \returns the name of the device or NULL on failure; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
* \sa SDL_NumHaptics
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_NumHaptics
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Opens a haptic device for use.
|
||||
* Open a haptic device for use.
|
||||
*
|
||||
* The index passed as an argument refers to the N'th haptic device on this
|
||||
* system.
|
||||
* The index passed as an argument refers to the N'th haptic device on this
|
||||
* system.
|
||||
*
|
||||
* When opening a haptic device, its gain will be set to maximum and
|
||||
* autocenter will be disabled. To modify these values use
|
||||
* SDL_HapticSetGain() and SDL_HapticSetAutocenter().
|
||||
* When opening a haptic device, its gain will be set to maximum and
|
||||
* autocenter will be disabled. To modify these values use SDL_HapticSetGain()
|
||||
* and SDL_HapticSetAutocenter().
|
||||
*
|
||||
* \param device_index Index of the device to open.
|
||||
* \return Device identifier or NULL on error.
|
||||
* \param device_index index of the device to open
|
||||
* \returns the device identifier or NULL on failure; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
* \sa SDL_HapticIndex
|
||||
* \sa SDL_HapticOpenFromMouse
|
||||
* \sa SDL_HapticOpenFromJoystick
|
||||
* \sa SDL_HapticClose
|
||||
* \sa SDL_HapticSetGain
|
||||
* \sa SDL_HapticSetAutocenter
|
||||
* \sa SDL_HapticPause
|
||||
* \sa SDL_HapticStopAll
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticClose
|
||||
* \sa SDL_HapticIndex
|
||||
* \sa SDL_HapticOpenFromJoystick
|
||||
* \sa SDL_HapticOpenFromMouse
|
||||
* \sa SDL_HapticPause
|
||||
* \sa SDL_HapticSetAutocenter
|
||||
* \sa SDL_HapticSetGain
|
||||
* \sa SDL_HapticStopAll
|
||||
*/
|
||||
extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Checks if the haptic device at index has been opened.
|
||||
* Check if the haptic device at the designated index has been opened.
|
||||
*
|
||||
* \param device_index Index to check to see if it has been opened.
|
||||
* \return 1 if it has been opened or 0 if it hasn't.
|
||||
* \param device_index the index of the device to query
|
||||
* \returns 1 if it has been opened, 0 if it hasn't or on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_HapticIndex
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticIndex
|
||||
* \sa SDL_HapticOpen
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Gets the index of a haptic device.
|
||||
* Get the index of a haptic device.
|
||||
*
|
||||
* \param haptic Haptic device to get the index of.
|
||||
* \return The index of the haptic device or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to query
|
||||
* \returns the index of the specified haptic device or a negative error code
|
||||
* on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_HapticOpened
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_HapticOpened
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Gets whether or not the current mouse has haptic capabilities.
|
||||
* Query whether or not the current mouse has haptic capabilities.
|
||||
*
|
||||
* \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't.
|
||||
* \returns SDL_TRUE if the mouse is haptic or SDL_FALSE if it isn't.
|
||||
*
|
||||
* \sa SDL_HapticOpenFromMouse
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticOpenFromMouse
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void);
|
||||
|
||||
/**
|
||||
* \brief Tries to open a haptic device from the current mouse.
|
||||
* Try to open a haptic device from the current mouse.
|
||||
*
|
||||
* \return The haptic device identifier or NULL on error.
|
||||
* \returns the haptic device identifier or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_MouseIsHaptic
|
||||
* \sa SDL_HapticOpen
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_MouseIsHaptic
|
||||
*/
|
||||
extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void);
|
||||
|
||||
/**
|
||||
* \brief Checks to see if a joystick has haptic features.
|
||||
* Query if a joystick has haptic features.
|
||||
*
|
||||
* \param joystick Joystick to test for haptic capabilities.
|
||||
* \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't
|
||||
* or -1 if an error occurred.
|
||||
* \param joystick the SDL_Joystick to test for haptic capabilities
|
||||
* \returns SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't, or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \sa SDL_HapticOpenFromJoystick
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticOpenFromJoystick
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* \brief Opens a haptic device for use from a joystick device.
|
||||
* Open a haptic device for use from a joystick device.
|
||||
*
|
||||
* You must still close the haptic device separately. It will not be closed
|
||||
* with the joystick.
|
||||
* You must still close the haptic device separately. It will not be closed
|
||||
* with the joystick.
|
||||
*
|
||||
* When opening from a joystick you should first close the haptic device before
|
||||
* closing the joystick device. If not, on some implementations the haptic
|
||||
* device will also get unallocated and you'll be unable to use force feedback
|
||||
* on that device.
|
||||
* When opened from a joystick you should first close the haptic device before
|
||||
* closing the joystick device. If not, on some implementations the haptic
|
||||
* device will also get unallocated and you'll be unable to use force feedback
|
||||
* on that device.
|
||||
*
|
||||
* \param joystick Joystick to create a haptic device from.
|
||||
* \return A valid haptic device identifier on success or NULL on error.
|
||||
* \param joystick the SDL_Joystick to create a haptic device from
|
||||
* \returns a valid haptic device identifier on success or NULL on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_HapticClose
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticClose
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_JoystickIsHaptic
|
||||
*/
|
||||
extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *
|
||||
joystick);
|
||||
|
||||
/**
|
||||
* \brief Closes a haptic device previously opened with SDL_HapticOpen().
|
||||
* Close a haptic device previously opened with SDL_HapticOpen().
|
||||
*
|
||||
* \param haptic Haptic device to close.
|
||||
* \param haptic the SDL_Haptic device to close
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Returns the number of effects a haptic device can store.
|
||||
* Get the number of effects a haptic device can store.
|
||||
*
|
||||
* On some platforms this isn't fully supported, and therefore is an
|
||||
* approximation. Always check to see if your created effect was actually
|
||||
* created and do not rely solely on SDL_HapticNumEffects().
|
||||
* On some platforms this isn't fully supported, and therefore is an
|
||||
* approximation. Always check to see if your created effect was actually
|
||||
* created and do not rely solely on SDL_HapticNumEffects().
|
||||
*
|
||||
* \param haptic The haptic device to query effect max.
|
||||
* \return The number of effects the haptic device can store or
|
||||
* -1 on error.
|
||||
* \param haptic the SDL_Haptic device to query
|
||||
* \returns the number of effects the haptic device can store or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticNumEffectsPlaying
|
||||
* \sa SDL_HapticQuery
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticNumEffectsPlaying
|
||||
* \sa SDL_HapticQuery
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Returns the number of effects a haptic device can play at the same
|
||||
* time.
|
||||
* Get the number of effects a haptic device can play at the same time.
|
||||
*
|
||||
* This is not supported on all platforms, but will always return a value.
|
||||
* Added here for the sake of completeness.
|
||||
* This is not supported on all platforms, but will always return a value.
|
||||
*
|
||||
* \param haptic The haptic device to query maximum playing effects.
|
||||
* \return The number of effects the haptic device can play at the same time
|
||||
* or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to query maximum playing effects
|
||||
* \returns the number of effects the haptic device can play at the same time
|
||||
* or a negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \sa SDL_HapticNumEffects
|
||||
* \sa SDL_HapticQuery
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticNumEffects
|
||||
* \sa SDL_HapticQuery
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Gets the haptic device's supported features in bitwise manner.
|
||||
* Get the haptic device's supported features in bitwise manner.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) {
|
||||
* printf("We have constant haptic effect!\n");
|
||||
* }
|
||||
* \endcode
|
||||
* \param haptic the SDL_Haptic device to query
|
||||
* \returns a list of supported haptic features in bitwise manner (OR'd), or 0
|
||||
* on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \param haptic The haptic device to query.
|
||||
* \return Haptic features in bitwise manner (OR'd).
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticNumEffects
|
||||
* \sa SDL_HapticEffectSupported
|
||||
* \sa SDL_HapticEffectSupported
|
||||
* \sa SDL_HapticNumEffects
|
||||
*/
|
||||
extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Gets the number of haptic axes the device has.
|
||||
* Get the number of haptic axes the device has.
|
||||
*
|
||||
* \sa SDL_HapticDirection
|
||||
* The number of haptic axes might be useful if working with the
|
||||
* SDL_HapticDirection effect.
|
||||
*
|
||||
* \param haptic the SDL_Haptic device to query
|
||||
* \returns the number of axes on success or a negative error code on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Checks to see if effect is supported by haptic.
|
||||
* Check to see if an effect is supported by a haptic device.
|
||||
*
|
||||
* \param haptic Haptic device to check on.
|
||||
* \param effect Effect to check to see if it is supported.
|
||||
* \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to query
|
||||
* \param effect the desired effect to query
|
||||
* \returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't, or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \sa SDL_HapticQuery
|
||||
* \sa SDL_HapticNewEffect
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticNewEffect
|
||||
* \sa SDL_HapticQuery
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic,
|
||||
SDL_HapticEffect *
|
||||
effect);
|
||||
|
||||
/**
|
||||
* \brief Creates a new haptic effect on the device.
|
||||
* Create a new haptic effect on a specified device.
|
||||
*
|
||||
* \param haptic Haptic device to create the effect on.
|
||||
* \param effect Properties of the effect to create.
|
||||
* \return The identifier of the effect on success or -1 on error.
|
||||
* \param haptic an SDL_Haptic device to create the effect on
|
||||
* \param effect an SDL_HapticEffect structure containing the properties of
|
||||
* the effect to create
|
||||
* \returns the ID of the effect on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticUpdateEffect
|
||||
* \sa SDL_HapticRunEffect
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \sa SDL_HapticRunEffect
|
||||
* \sa SDL_HapticUpdateEffect
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic,
|
||||
SDL_HapticEffect * effect);
|
||||
|
||||
/**
|
||||
* \brief Updates the properties of an effect.
|
||||
* Update the properties of an effect.
|
||||
*
|
||||
* Can be used dynamically, although behavior when dynamically changing
|
||||
* direction may be strange. Specifically the effect may reupload itself
|
||||
* and start playing from the start. You cannot change the type either when
|
||||
* running SDL_HapticUpdateEffect().
|
||||
* Can be used dynamically, although behavior when dynamically changing
|
||||
* direction may be strange. Specifically the effect may re-upload itself and
|
||||
* start playing from the start. You also cannot change the type either when
|
||||
* running SDL_HapticUpdateEffect().
|
||||
*
|
||||
* \param haptic Haptic device that has the effect.
|
||||
* \param effect Identifier of the effect to update.
|
||||
* \param data New effect properties to use.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device that has the effect
|
||||
* \param effect the identifier of the effect to update
|
||||
* \param data an SDL_HapticEffect structure containing the new effect
|
||||
* properties to use
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticNewEffect
|
||||
* \sa SDL_HapticRunEffect
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \sa SDL_HapticNewEffect
|
||||
* \sa SDL_HapticRunEffect
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic,
|
||||
int effect,
|
||||
SDL_HapticEffect * data);
|
||||
|
||||
/**
|
||||
* \brief Runs the haptic effect on its associated haptic device.
|
||||
* Run the haptic effect on its associated haptic device.
|
||||
*
|
||||
* If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over
|
||||
* repeating the envelope (attack and fade) every time. If you only want the
|
||||
* effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length
|
||||
* parameter.
|
||||
* To repeat the effect over and over indefinitely, set `iterations` to
|
||||
* `SDL_HAPTIC_INFINITY`. (Repeats the envelope - attack and fade.) To make
|
||||
* one instance of the effect last indefinitely (so the effect does not fade),
|
||||
* set the effect's `length` in its structure/union to `SDL_HAPTIC_INFINITY`
|
||||
* instead.
|
||||
*
|
||||
* \param haptic Haptic device to run the effect on.
|
||||
* \param effect Identifier of the haptic effect to run.
|
||||
* \param iterations Number of iterations to run the effect. Use
|
||||
* ::SDL_HAPTIC_INFINITY for infinity.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to run the effect on
|
||||
* \param effect the ID of the haptic effect to run
|
||||
* \param iterations the number of iterations to run the effect; use
|
||||
* `SDL_HAPTIC_INFINITY` to repeat forever
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticStopEffect
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \sa SDL_HapticGetEffectStatus
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \sa SDL_HapticGetEffectStatus
|
||||
* \sa SDL_HapticStopEffect
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic,
|
||||
int effect,
|
||||
Uint32 iterations);
|
||||
|
||||
/**
|
||||
* \brief Stops the haptic effect on its associated haptic device.
|
||||
* Stop the haptic effect on its associated haptic device.
|
||||
*
|
||||
* \param haptic Haptic device to stop the effect on.
|
||||
* \param effect Identifier of the effect to stop.
|
||||
* \return 0 on success or -1 on error.
|
||||
* *
|
||||
*
|
||||
* \sa SDL_HapticRunEffect
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \param haptic the SDL_Haptic device to stop the effect on
|
||||
* \param effect the ID of the haptic effect to stop
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticDestroyEffect
|
||||
* \sa SDL_HapticRunEffect
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic,
|
||||
int effect);
|
||||
|
||||
/**
|
||||
* \brief Destroys a haptic effect on the device.
|
||||
* Destroy a haptic effect on the device.
|
||||
*
|
||||
* This will stop the effect if it's running. Effects are automatically
|
||||
* destroyed when the device is closed.
|
||||
* This will stop the effect if it's running. Effects are automatically
|
||||
* destroyed when the device is closed.
|
||||
*
|
||||
* \param haptic Device to destroy the effect on.
|
||||
* \param effect Identifier of the effect to destroy.
|
||||
* \param haptic the SDL_Haptic device to destroy the effect on
|
||||
* \param effect the ID of the haptic effect to destroy
|
||||
*
|
||||
* \sa SDL_HapticNewEffect
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticNewEffect
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
|
||||
int effect);
|
||||
|
||||
/**
|
||||
* \brief Gets the status of the current effect on the haptic device.
|
||||
* Get the status of the current effect on the specified haptic device.
|
||||
*
|
||||
* Device must support the ::SDL_HAPTIC_STATUS feature.
|
||||
* Device must support the SDL_HAPTIC_STATUS feature.
|
||||
*
|
||||
* \param haptic Haptic device to query the effect status on.
|
||||
* \param effect Identifier of the effect to query its status.
|
||||
* \return 0 if it isn't playing, 1 if it is playing or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to query for the effect status on
|
||||
* \param effect the ID of the haptic effect to query its status
|
||||
* \returns 0 if it isn't playing, 1 if it is playing, or a negative error
|
||||
* code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticRunEffect
|
||||
* \sa SDL_HapticStopEffect
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticRunEffect
|
||||
* \sa SDL_HapticStopEffect
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
int effect);
|
||||
|
||||
/**
|
||||
* \brief Sets the global gain of the device.
|
||||
* Set the global gain of the specified haptic device.
|
||||
*
|
||||
* Device must support the ::SDL_HAPTIC_GAIN feature.
|
||||
* Device must support the SDL_HAPTIC_GAIN feature.
|
||||
*
|
||||
* The user may specify the maximum gain by setting the environment variable
|
||||
* SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to
|
||||
* SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the
|
||||
* maximum.
|
||||
* The user may specify the maximum gain by setting the environment variable
|
||||
* `SDL_HAPTIC_GAIN_MAX` which should be between 0 and 100. All calls to
|
||||
* SDL_HapticSetGain() will scale linearly using `SDL_HAPTIC_GAIN_MAX` as the
|
||||
* maximum.
|
||||
*
|
||||
* \param haptic Haptic device to set the gain on.
|
||||
* \param gain Value to set the gain to, should be between 0 and 100.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to set the gain on
|
||||
* \param gain value to set the gain to, should be between 0 and 100 (0 - 100)
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticQuery
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticQuery
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
|
||||
|
||||
/**
|
||||
* \brief Sets the global autocenter of the device.
|
||||
* Set the global autocenter of the device.
|
||||
*
|
||||
* Autocenter should be between 0 and 100. Setting it to 0 will disable
|
||||
* autocentering.
|
||||
* Autocenter should be between 0 and 100. Setting it to 0 will disable
|
||||
* autocentering.
|
||||
*
|
||||
* Device must support the ::SDL_HAPTIC_AUTOCENTER feature.
|
||||
* Device must support the SDL_HAPTIC_AUTOCENTER feature.
|
||||
*
|
||||
* \param haptic Haptic device to set autocentering on.
|
||||
* \param autocenter Value to set autocenter to, 0 disables autocentering.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to set autocentering on
|
||||
* \param autocenter value to set autocenter to (0-100)
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticQuery
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticQuery
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic,
|
||||
int autocenter);
|
||||
|
||||
/**
|
||||
* \brief Pauses a haptic device.
|
||||
* Pause a haptic device.
|
||||
*
|
||||
* Device must support the ::SDL_HAPTIC_PAUSE feature. Call
|
||||
* SDL_HapticUnpause() to resume playback.
|
||||
* Device must support the `SDL_HAPTIC_PAUSE` feature. Call
|
||||
* SDL_HapticUnpause() to resume playback.
|
||||
*
|
||||
* Do not modify the effects nor add new ones while the device is paused.
|
||||
* That can cause all sorts of weird errors.
|
||||
* Do not modify the effects nor add new ones while the device is paused. That
|
||||
* can cause all sorts of weird errors.
|
||||
*
|
||||
* \param haptic Haptic device to pause.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to pause
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticUnpause
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticUnpause
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Unpauses a haptic device.
|
||||
* Unpause a haptic device.
|
||||
*
|
||||
* Call to unpause after SDL_HapticPause().
|
||||
* Call to unpause after SDL_HapticPause().
|
||||
*
|
||||
* \param haptic Haptic device to unpause.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to unpause
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticPause
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticPause
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Stops all the currently playing effects on a haptic device.
|
||||
* Stop all the currently playing effects on a haptic device.
|
||||
*
|
||||
* \param haptic Haptic device to stop.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the SDL_Haptic device to stop
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Checks to see if rumble is supported on a haptic device.
|
||||
* Check whether rumble is supported on a haptic device.
|
||||
*
|
||||
* \param haptic Haptic device to check to see if it supports rumble.
|
||||
* \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error.
|
||||
* \param haptic haptic device to check for rumble support
|
||||
* \returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't, or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \sa SDL_HapticRumbleInit
|
||||
* \sa SDL_HapticRumblePlay
|
||||
* \sa SDL_HapticRumbleStop
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticRumbleInit
|
||||
* \sa SDL_HapticRumblePlay
|
||||
* \sa SDL_HapticRumbleStop
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Initializes the haptic device for simple rumble playback.
|
||||
* Initialize a haptic device for simple rumble playback.
|
||||
*
|
||||
* \param haptic Haptic device to initialize for simple rumble playback.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the haptic device to initialize for simple rumble playback
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
* \sa SDL_HapticRumblePlay
|
||||
* \sa SDL_HapticRumbleStop
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticOpen
|
||||
* \sa SDL_HapticRumblePlay
|
||||
* \sa SDL_HapticRumbleStop
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic);
|
||||
|
||||
/**
|
||||
* \brief Runs simple rumble on a haptic device
|
||||
* Run a simple rumble effect on a haptic device.
|
||||
*
|
||||
* \param haptic Haptic device to play rumble effect on.
|
||||
* \param strength Strength of the rumble to play as a 0-1 float value.
|
||||
* \param length Length of the rumble to play in milliseconds.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the haptic device to play the rumble effect on
|
||||
* \param strength strength of the rumble to play as a 0-1 float value
|
||||
* \param length length of the rumble to play in milliseconds
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
* \sa SDL_HapticRumbleInit
|
||||
* \sa SDL_HapticRumbleStop
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticRumbleInit
|
||||
* \sa SDL_HapticRumbleStop
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length );
|
||||
|
||||
/**
|
||||
* \brief Stops the simple rumble on a haptic device.
|
||||
* Stop the simple rumble on a haptic device.
|
||||
*
|
||||
* \param haptic Haptic to stop the rumble on.
|
||||
* \return 0 on success or -1 on error.
|
||||
* \param haptic the haptic device to stop the rumble effect on
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
* \sa SDL_HapticRumbleInit
|
||||
* \sa SDL_HapticRumblePlay
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HapticRumbleInit
|
||||
* \sa SDL_HapticRumblePlay
|
||||
* \sa SDL_HapticRumbleSupported
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic);
|
||||
|
||||
|
|
451
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hidapi.h
Normal file
451
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hidapi.h
Normal file
|
@ -0,0 +1,451 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_hidapi.h
|
||||
*
|
||||
* Header file for SDL HIDAPI functions.
|
||||
*
|
||||
* This is an adaptation of the original HIDAPI interface by Alan Ott,
|
||||
* and includes source code licensed under the following BSD license:
|
||||
*
|
||||
Copyright (c) 2010, Alan Ott, Signal 11 Software
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Signal 11 Software nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* If you would like a version of SDL without this code, you can build SDL
|
||||
* with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for example
|
||||
* on iOS or tvOS to avoid a dependency on the CoreBluetooth framework.
|
||||
*/
|
||||
|
||||
#ifndef SDL_hidapi_h_
|
||||
#define SDL_hidapi_h_
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief A handle representing an open HID device
|
||||
*/
|
||||
struct SDL_hid_device_;
|
||||
typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */
|
||||
|
||||
/** hidapi info structure */
|
||||
/**
|
||||
* \brief Information about a connected HID device
|
||||
*/
|
||||
typedef struct SDL_hid_device_info
|
||||
{
|
||||
/** Platform-specific device path */
|
||||
char *path;
|
||||
/** Device Vendor ID */
|
||||
unsigned short vendor_id;
|
||||
/** Device Product ID */
|
||||
unsigned short product_id;
|
||||
/** Serial Number */
|
||||
wchar_t *serial_number;
|
||||
/** Device Release Number in binary-coded decimal,
|
||||
also known as Device Version Number */
|
||||
unsigned short release_number;
|
||||
/** Manufacturer String */
|
||||
wchar_t *manufacturer_string;
|
||||
/** Product string */
|
||||
wchar_t *product_string;
|
||||
/** Usage Page for this Device/Interface
|
||||
(Windows/Mac only). */
|
||||
unsigned short usage_page;
|
||||
/** Usage for this Device/Interface
|
||||
(Windows/Mac only).*/
|
||||
unsigned short usage;
|
||||
/** The USB interface which this logical device
|
||||
represents.
|
||||
|
||||
* Valid on both Linux implementations in all cases.
|
||||
* Valid on the Windows implementation only if the device
|
||||
contains more than one interface. */
|
||||
int interface_number;
|
||||
|
||||
/** Additional information about the USB interface.
|
||||
Valid on libusb and Android implementations. */
|
||||
int interface_class;
|
||||
int interface_subclass;
|
||||
int interface_protocol;
|
||||
|
||||
/** Pointer to the next device */
|
||||
struct SDL_hid_device_info *next;
|
||||
} SDL_hid_device_info;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the HIDAPI library.
|
||||
*
|
||||
* This function initializes the HIDAPI library. Calling it is not strictly
|
||||
* necessary, as it will be called automatically by SDL_hid_enumerate() and
|
||||
* any of the SDL_hid_open_*() functions if it is needed. This function should
|
||||
* be called at the beginning of execution however, if there is a chance of
|
||||
* HIDAPI handles being opened by different threads simultaneously.
|
||||
*
|
||||
* Each call to this function should have a matching call to SDL_hid_exit()
|
||||
*
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_hid_exit
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_init(void);
|
||||
|
||||
/**
|
||||
* Finalize the HIDAPI library.
|
||||
*
|
||||
* This function frees all of the static data associated with HIDAPI. It
|
||||
* should be called at the end of execution to avoid memory leaks.
|
||||
*
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_hid_init
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_exit(void);
|
||||
|
||||
/**
|
||||
* Check to see if devices may have been added or removed.
|
||||
*
|
||||
* Enumerating the HID devices is an expensive operation, so you can call this
|
||||
* to see if there have been any system device changes since the last call to
|
||||
* this function. A change in the counter returned doesn't necessarily mean
|
||||
* that anything has changed, but you can call SDL_hid_enumerate() to get an
|
||||
* updated device list.
|
||||
*
|
||||
* Calling this function for the first time may cause a thread or other system
|
||||
* resource to be allocated to track device change notifications.
|
||||
*
|
||||
* \returns a change counter that is incremented with each potential device
|
||||
* change, or 0 if device change detection isn't available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_hid_enumerate
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_hid_device_change_count(void);
|
||||
|
||||
/**
|
||||
* Enumerate the HID Devices.
|
||||
*
|
||||
* This function returns a linked list of all the HID devices attached to the
|
||||
* system which match vendor_id and product_id. If `vendor_id` is set to 0
|
||||
* then any vendor matches. If `product_id` is set to 0 then any product
|
||||
* matches. If `vendor_id` and `product_id` are both set to 0, then all HID
|
||||
* devices will be returned.
|
||||
*
|
||||
* \param vendor_id The Vendor ID (VID) of the types of device to open.
|
||||
* \param product_id The Product ID (PID) of the types of device to open.
|
||||
* \returns a pointer to a linked list of type SDL_hid_device_info, containing
|
||||
* information about the HID devices attached to the system, or NULL
|
||||
* in the case of failure. Free this linked list by calling
|
||||
* SDL_hid_free_enumeration().
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_hid_device_change_count
|
||||
*/
|
||||
extern DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id);
|
||||
|
||||
/**
|
||||
* Free an enumeration Linked List
|
||||
*
|
||||
* This function frees a linked list created by SDL_hid_enumerate().
|
||||
*
|
||||
* \param devs Pointer to a list of struct_device returned from
|
||||
* SDL_hid_enumerate().
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_hid_free_enumeration(SDL_hid_device_info *devs);
|
||||
|
||||
/**
|
||||
* Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally
|
||||
* a serial number.
|
||||
*
|
||||
* If `serial_number` is NULL, the first device with the specified VID and PID
|
||||
* is opened.
|
||||
*
|
||||
* \param vendor_id The Vendor ID (VID) of the device to open.
|
||||
* \param product_id The Product ID (PID) of the device to open.
|
||||
* \param serial_number The Serial Number of the device to open (Optionally
|
||||
* NULL).
|
||||
* \returns a pointer to a SDL_hid_device object on success or NULL on
|
||||
* failure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number);
|
||||
|
||||
/**
|
||||
* Open a HID device by its path name.
|
||||
*
|
||||
* The path name be determined by calling SDL_hid_enumerate(), or a
|
||||
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
|
||||
*
|
||||
* \param path The path name of the device to open
|
||||
* \returns a pointer to a SDL_hid_device object on success or NULL on
|
||||
* failure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive /* = false */);
|
||||
|
||||
/**
|
||||
* Write an Output report to a HID device.
|
||||
*
|
||||
* The first byte of `data` must contain the Report ID. For devices which only
|
||||
* support a single report, this must be set to 0x0. The remaining bytes
|
||||
* contain the report data. Since the Report ID is mandatory, calls to
|
||||
* SDL_hid_write() will always contain one more byte than the report contains.
|
||||
* For example, if a hid report is 16 bytes long, 17 bytes must be passed to
|
||||
* SDL_hid_write(), the Report ID (or 0x0, for devices with a single report),
|
||||
* followed by the report data (16 bytes). In this example, the length passed
|
||||
* in would be 17.
|
||||
*
|
||||
* SDL_hid_write() will send the data on the first OUT endpoint, if one
|
||||
* exists. If it does not, it will send the data through the Control Endpoint
|
||||
* (Endpoint 0).
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param data The data to send, including the report number as the first
|
||||
* byte.
|
||||
* \param length The length in bytes of the data to send.
|
||||
* \returns the actual number of bytes written and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_write(SDL_hid_device *dev, const unsigned char *data, size_t length);
|
||||
|
||||
/**
|
||||
* Read an Input report from a HID device with timeout.
|
||||
*
|
||||
* Input reports are returned to the host through the INTERRUPT IN endpoint.
|
||||
* The first byte will contain the Report number if the device uses numbered
|
||||
* reports.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param data A buffer to put the read data into.
|
||||
* \param length The number of bytes to read. For devices with multiple
|
||||
* reports, make sure to read an extra byte for the report
|
||||
* number.
|
||||
* \param milliseconds timeout in milliseconds or -1 for blocking wait.
|
||||
* \returns the actual number of bytes read and -1 on error. If no packet was
|
||||
* available to be read within the timeout period, this function
|
||||
* returns 0.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_read_timeout(SDL_hid_device *dev, unsigned char *data, size_t length, int milliseconds);
|
||||
|
||||
/**
|
||||
* Read an Input report from a HID device.
|
||||
*
|
||||
* Input reports are returned to the host through the INTERRUPT IN endpoint.
|
||||
* The first byte will contain the Report number if the device uses numbered
|
||||
* reports.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param data A buffer to put the read data into.
|
||||
* \param length The number of bytes to read. For devices with multiple
|
||||
* reports, make sure to read an extra byte for the report
|
||||
* number.
|
||||
* \returns the actual number of bytes read and -1 on error. If no packet was
|
||||
* available to be read and the handle is in non-blocking mode, this
|
||||
* function returns 0.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_read(SDL_hid_device *dev, unsigned char *data, size_t length);
|
||||
|
||||
/**
|
||||
* Set the device handle to be non-blocking.
|
||||
*
|
||||
* In non-blocking mode calls to SDL_hid_read() will return immediately with a
|
||||
* value of 0 if there is no data to be read. In blocking mode, SDL_hid_read()
|
||||
* will wait (block) until there is data to read before returning.
|
||||
*
|
||||
* Nonblocking can be turned on and off at any time.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param nonblock enable or not the nonblocking reads - 1 to enable
|
||||
* nonblocking - 0 to disable nonblocking.
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_set_nonblocking(SDL_hid_device *dev, int nonblock);
|
||||
|
||||
/**
|
||||
* Send a Feature report to the device.
|
||||
*
|
||||
* Feature reports are sent over the Control endpoint as a Set_Report
|
||||
* transfer. The first byte of `data` must contain the Report ID. For devices
|
||||
* which only support a single report, this must be set to 0x0. The remaining
|
||||
* bytes contain the report data. Since the Report ID is mandatory, calls to
|
||||
* SDL_hid_send_feature_report() will always contain one more byte than the
|
||||
* report contains. For example, if a hid report is 16 bytes long, 17 bytes
|
||||
* must be passed to SDL_hid_send_feature_report(): the Report ID (or 0x0, for
|
||||
* devices which do not use numbered reports), followed by the report data (16
|
||||
* bytes). In this example, the length passed in would be 17.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param data The data to send, including the report number as the first
|
||||
* byte.
|
||||
* \param length The length in bytes of the data to send, including the report
|
||||
* number.
|
||||
* \returns the actual number of bytes written and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_send_feature_report(SDL_hid_device *dev, const unsigned char *data, size_t length);
|
||||
|
||||
/**
|
||||
* Get a feature report from a HID device.
|
||||
*
|
||||
* Set the first byte of `data` to the Report ID of the report to be read.
|
||||
* Make sure to allow space for this extra byte in `data`. Upon return, the
|
||||
* first byte will still contain the Report ID, and the report data will start
|
||||
* in data[1].
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param data A buffer to put the read data into, including the Report ID.
|
||||
* Set the first byte of `data` to the Report ID of the report to
|
||||
* be read, or set it to zero if your device does not use numbered
|
||||
* reports.
|
||||
* \param length The number of bytes to read, including an extra byte for the
|
||||
* report ID. The buffer can be longer than the actual report.
|
||||
* \returns the number of bytes read plus one for the report ID (which is
|
||||
* still in the first byte), or -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_get_feature_report(SDL_hid_device *dev, unsigned char *data, size_t length);
|
||||
|
||||
/**
|
||||
* Close a HID device.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_hid_close(SDL_hid_device *dev);
|
||||
|
||||
/**
|
||||
* Get The Manufacturer String from a HID device.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param string A wide string buffer to put the data into.
|
||||
* \param maxlen The length of the buffer in multiples of wchar_t.
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_get_manufacturer_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen);
|
||||
|
||||
/**
|
||||
* Get The Product String from a HID device.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param string A wide string buffer to put the data into.
|
||||
* \param maxlen The length of the buffer in multiples of wchar_t.
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_get_product_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen);
|
||||
|
||||
/**
|
||||
* Get The Serial Number String from a HID device.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param string A wide string buffer to put the data into.
|
||||
* \param maxlen The length of the buffer in multiples of wchar_t.
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_get_serial_number_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen);
|
||||
|
||||
/**
|
||||
* Get a string from a HID device, based on its string index.
|
||||
*
|
||||
* \param dev A device handle returned from SDL_hid_open().
|
||||
* \param string_index The index of the string to get.
|
||||
* \param string A wide string buffer to put the data into.
|
||||
* \param maxlen The length of the buffer in multiples of wchar_t.
|
||||
* \returns 0 on success and -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_hid_get_indexed_string(SDL_hid_device *dev, int string_index, wchar_t *string, size_t maxlen);
|
||||
|
||||
/**
|
||||
* Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers
|
||||
*
|
||||
* \param active SDL_TRUE to start the scan, SDL_FALSE to stop the scan
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_hid_ble_scan(SDL_bool active);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* SDL_hidapi_h_ */
|
||||
|
||||
/* vi: set sts=4 ts=4 sw=4 expandtab: */
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -30,10 +30,12 @@
|
|||
* The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
|
||||
* then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
|
||||
*
|
||||
* The term "player_index" is the number assigned to a player on a specific
|
||||
* controller. For XInput controllers this returns the XInput user index.
|
||||
* Many joysticks will not be able to supply this information.
|
||||
*
|
||||
* The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
|
||||
* the device (a X360 wired controller for example). This identifier is platform dependent.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SDL_joystick_h_
|
||||
|
@ -105,6 +107,12 @@ typedef enum
|
|||
SDL_JOYSTICK_POWER_MAX
|
||||
} SDL_JoystickPowerLevel;
|
||||
|
||||
/* Set max recognized G-force from accelerometer
|
||||
See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
|
||||
*/
|
||||
#define SDL_IPHONE_MAX_GFORCE 5.0
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
|
@ -116,210 +124,605 @@ typedef enum
|
|||
* In particular, you are guaranteed that the joystick list won't change, so
|
||||
* the API functions that take a joystick index will be valid, and joystick
|
||||
* and game controller events will not be delivered.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
|
||||
|
||||
|
||||
/**
|
||||
* Unlocking for multi-threaded access to the joystick API
|
||||
*
|
||||
* If you are using the joystick API or handling events from multiple threads
|
||||
* you should use these locking functions to protect access to the joysticks.
|
||||
*
|
||||
* In particular, you are guaranteed that the joystick list won't change, so
|
||||
* the API functions that take a joystick index will be valid, and joystick
|
||||
* and game controller events will not be delivered.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void);
|
||||
|
||||
/**
|
||||
* Count the number of joysticks attached to the system right now
|
||||
* Count the number of joysticks attached to the system.
|
||||
*
|
||||
* \returns the number of attached joysticks on success or a negative error
|
||||
* code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickName
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
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.
|
||||
* Get the implementation dependent name of a joystick.
|
||||
*
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system)
|
||||
* \returns the name of the selected joystick. If no name can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickName
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
|
||||
|
||||
/**
|
||||
* Get the player index of a joystick, or -1 if it's not available
|
||||
* This can be called before any joysticks are opened.
|
||||
* Get the player index of a joystick, or -1 if it's not available This can be
|
||||
* called before any joysticks are opened.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
|
||||
|
||||
/**
|
||||
* Return the GUID for the joystick at this index
|
||||
* This can be called before any joysticks are opened.
|
||||
* Get the implementation-dependent GUID for the joystick at a given device
|
||||
* index.
|
||||
*
|
||||
* This function can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system
|
||||
* \returns the GUID of the selected joystick. If called on an invalid index,
|
||||
* this function returns a zero GUID
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetGUID
|
||||
* \sa SDL_JoystickGetGUIDString
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
* Get the USB vendor ID of a joystick, if available.
|
||||
*
|
||||
* This can be called before any joysticks are opened. If the vendor ID isn't
|
||||
* available this function returns 0.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system
|
||||
* \returns the USB vendor ID of the selected joystick. If called on an
|
||||
* invalid index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the product ID isn't available this function returns 0.
|
||||
* Get the USB product ID of a joystick, if available.
|
||||
*
|
||||
* This can be called before any joysticks are opened. If the product ID isn't
|
||||
* available this function returns 0.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system
|
||||
* \returns the USB product ID of the selected joystick. If called on an
|
||||
* invalid index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
|
||||
|
||||
/**
|
||||
* Get the product version of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the product version isn't available this function returns 0.
|
||||
* Get the product version of a joystick, if available.
|
||||
*
|
||||
* This can be called before any joysticks are opened. If the product version
|
||||
* isn't available this function returns 0.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system
|
||||
* \returns the product version of the selected joystick. If called on an
|
||||
* invalid index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index);
|
||||
|
||||
/**
|
||||
* Get the type of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* Get the type of a joystick, if available.
|
||||
*
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system
|
||||
* \returns the SDL_JoystickType of the selected joystick. If called on an
|
||||
* invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index);
|
||||
|
||||
/**
|
||||
* Get the instance ID of a joystick.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the index is out of range, this function will return -1.
|
||||
* Get the instance ID of a joystick.
|
||||
*
|
||||
* This can be called before any joysticks are opened. If the index is out of
|
||||
* range, this function will return -1.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system
|
||||
* \returns the instance id of the selected joystick. If called on an invalid
|
||||
* index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index);
|
||||
|
||||
/**
|
||||
* Open a joystick for use.
|
||||
* The index passed as an argument refers to the N'th joystick on the system.
|
||||
* This index is not the value which will identify this joystick in future
|
||||
* joystick events. The joystick's instance id (::SDL_JoystickID) will be used
|
||||
* there instead.
|
||||
* Open a joystick for use.
|
||||
*
|
||||
* \return A joystick identifier, or NULL if an error occurred.
|
||||
* The `device_index` argument refers to the N'th joystick presently
|
||||
* recognized by SDL on the system. It is **NOT** the same as the instance ID
|
||||
* used to identify the joystick in future events. See
|
||||
* SDL_JoystickInstanceID() for more details about instance IDs.
|
||||
*
|
||||
* The joystick subsystem must be initialized before a joystick can be opened
|
||||
* for use.
|
||||
*
|
||||
* \param device_index the index of the joystick to query
|
||||
* \returns a joystick identifier or NULL if an error occurred; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickClose
|
||||
* \sa SDL_JoystickInstanceID
|
||||
*/
|
||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
|
||||
|
||||
/**
|
||||
* Return the SDL_Joystick associated with an instance id.
|
||||
*/
|
||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID joyid);
|
||||
|
||||
/**
|
||||
* Return the name for this currently opened joystick.
|
||||
* If no name can be found, this function returns NULL.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the player index of an opened joystick, or -1 if it's not available
|
||||
* Get the SDL_Joystick associated with an instance id.
|
||||
*
|
||||
* For XInput controllers this returns the XInput user index.
|
||||
* \param instance_id the instance id to get the SDL_Joystick for
|
||||
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick);
|
||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID instance_id);
|
||||
|
||||
/**
|
||||
* Return the GUID for this opened joystick
|
||||
* Get the SDL_Joystick associated with a player index.
|
||||
*
|
||||
* \param player_index the player index to get the SDL_Joystick for
|
||||
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
|
||||
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened joystick, if available.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
* Attach a new virtual joystick.
|
||||
*
|
||||
* \returns the joystick's device index, or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick * joystick);
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
||||
int naxes,
|
||||
int nbuttons,
|
||||
int nhats);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of an opened joystick, if available.
|
||||
* If the product ID isn't available this function returns 0.
|
||||
* Detach a virtual joystick.
|
||||
*
|
||||
* \param device_index a value previously returned from
|
||||
* SDL_JoystickAttachVirtual()
|
||||
* \returns 0 on success, or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick * joystick);
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);
|
||||
|
||||
/**
|
||||
* Get the product version of an opened joystick, if available.
|
||||
* If the product version isn't available this function returns 0.
|
||||
* Query whether or not the joystick at a given device index is virtual.
|
||||
*
|
||||
* \param device_index a joystick device index.
|
||||
* \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick * joystick);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);
|
||||
|
||||
/**
|
||||
* Get the type of an opened joystick.
|
||||
* Set values on an opened, virtual-joystick's axis.
|
||||
*
|
||||
* Please note that values set here will not be applied until the next call to
|
||||
* SDL_JoystickUpdate, which can either be called directly, or can be called
|
||||
* indirectly through various other SDL APIs, including, but not limited to
|
||||
* the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
|
||||
* SDL_WaitEvent.
|
||||
*
|
||||
* \param joystick the virtual joystick on which to set state.
|
||||
* \param axis the specific axis on the virtual joystick to set.
|
||||
* \param value the new value for the specified axis.
|
||||
* \returns 0 on success, -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick * joystick);
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
|
||||
|
||||
/**
|
||||
* Return a string representation for this guid. pszGUID must point to at least 33 bytes
|
||||
* (32 for the string plus a NULL terminator).
|
||||
* Set values on an opened, virtual-joystick's button.
|
||||
*
|
||||
* Please note that values set here will not be applied until the next call to
|
||||
* SDL_JoystickUpdate, which can either be called directly, or can be called
|
||||
* indirectly through various other SDL APIs, including, but not limited to
|
||||
* the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
|
||||
* SDL_WaitEvent.
|
||||
*
|
||||
* \param joystick the virtual joystick on which to set state.
|
||||
* \param button the specific button on the virtual joystick to set.
|
||||
* \param value the new value for the specified button.
|
||||
* \returns 0 on success, -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
|
||||
|
||||
/**
|
||||
* Set values on an opened, virtual-joystick's hat.
|
||||
*
|
||||
* Please note that values set here will not be applied until the next call to
|
||||
* SDL_JoystickUpdate, which can either be called directly, or can be called
|
||||
* indirectly through various other SDL APIs, including, but not limited to
|
||||
* the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
|
||||
* SDL_WaitEvent.
|
||||
*
|
||||
* \param joystick the virtual joystick on which to set state.
|
||||
* \param hat the specific hat on the virtual joystick to set.
|
||||
* \param value the new value for the specified hat.
|
||||
* \returns 0 on success, -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
|
||||
|
||||
/**
|
||||
* Get the implementation dependent name of a joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the name of the selected joystick. If no name can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickNameForIndex
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the player index of an opened joystick.
|
||||
*
|
||||
* For XInput controllers this returns the XInput user index. Many joysticks
|
||||
* will not be able to supply this information.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the player index, or -1 if it's not available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Set the player index of an opened joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \param player_index the player index to set.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index);
|
||||
|
||||
/**
|
||||
* Get the implementation-dependent GUID for the joystick.
|
||||
*
|
||||
* This function requires an open joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the GUID of the given joystick. If called on an invalid index,
|
||||
* this function returns a zero GUID; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetDeviceGUID
|
||||
* \sa SDL_JoystickGetGUIDString
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened joystick, if available.
|
||||
*
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of an opened joystick, if available.
|
||||
*
|
||||
* If the product ID isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the USB product ID of the selected joystick, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the product version of an opened joystick, if available.
|
||||
*
|
||||
* If the product version isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the product version of the selected joystick, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the serial number of an opened joystick, if available.
|
||||
*
|
||||
* Returns the serial number of the joystick, or NULL if it is not available.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the serial number of the selected joystick, or NULL if
|
||||
* unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the type of an opened joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the SDL_JoystickType of the selected joystick.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get an ASCII string representation for a given SDL_JoystickGUID.
|
||||
*
|
||||
* You should supply at least 33 bytes for pszGUID.
|
||||
*
|
||||
* \param guid the SDL_JoystickGUID you wish to convert to string
|
||||
* \param pszGUID buffer in which to write the ASCII string
|
||||
* \param cbGUID the size of pszGUID
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetDeviceGUID
|
||||
* \sa SDL_JoystickGetGUID
|
||||
* \sa SDL_JoystickGetGUIDFromString
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
|
||||
|
||||
/**
|
||||
* Convert a string into a joystick guid
|
||||
* Convert a GUID string into a SDL_JoystickGUID structure.
|
||||
*
|
||||
* Performs no error checking. If this function is given a string containing
|
||||
* an invalid GUID, the function will silently succeed, but the GUID generated
|
||||
* will not be useful.
|
||||
*
|
||||
* \param pchGUID string containing an ASCII representation of a GUID
|
||||
* \returns a SDL_JoystickGUID structure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetGUIDString
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
|
||||
|
||||
/**
|
||||
* Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the instance ID of an opened joystick or -1 if the joystick is invalid.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(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.
|
||||
* Get the status of a specified 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.
|
||||
* \param joystick the joystick to query
|
||||
* \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* This is called automatically by the event loop if any joystick
|
||||
* events are enabled.
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickClose
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the instance ID of an opened joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the instance ID of the specified joystick on success or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the number of general axis controls on a joystick.
|
||||
*
|
||||
* Often, the directional pad on a game controller will either look like 4
|
||||
* separate buttons or a POV hat, and not axes, but all of this is up to the
|
||||
* device and platform.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of axis controls/number of axes on success or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetAxis
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of trackballs on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetBall
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the number of POV hats on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of POV hats on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetHat
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the number of buttons on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of buttons on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickGetButton
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickEventState
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
|
||||
|
||||
/**
|
||||
* Enable/disable joystick event polling.
|
||||
* 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.
|
||||
* If joystick events are disabled, you must call SDL_JoystickUpdate()
|
||||
* yourself and manually check the state of the joystick when you want
|
||||
* joystick information.
|
||||
*
|
||||
* The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
|
||||
* It is recommended that you leave joystick event handling enabled.
|
||||
*
|
||||
* **WARNING**: Calling this function may delete all events currently in SDL's
|
||||
* event queue.
|
||||
*
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
||||
* \returns 1 if enabled, 0 if disabled, or a negative error code on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* If `state` is `SDL_QUERY` then the current state is returned,
|
||||
* otherwise the new processing state is returned.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GameControllerEventState
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
|
||||
|
||||
#define SDL_JOYSTICK_AXIS_MAX 32767
|
||||
#define SDL_JOYSTICK_AXIS_MIN -32768
|
||||
|
||||
/**
|
||||
* Get the current state of an axis control on a joystick.
|
||||
* Get the current state of an axis control on a joystick.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767.
|
||||
* SDL makes no promises about what part of the joystick any given axis refers
|
||||
* to. Your game should have some sort of configuration UI to let users
|
||||
* specify what each axis should be bound to. Alternately, SDL's higher-level
|
||||
* Game Controller API makes a great effort to apply order to this lower-level
|
||||
* interface, so you know that a specific axis is the "left thumb stick," etc.
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
* The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to
|
||||
* 32767) representing the current position of the axis. It may be necessary
|
||||
* to impose certain tolerances on these values to account for jitter.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param axis the axis to query; the axis indices start at index 0
|
||||
* \returns a 16-bit signed integer representing the current position of the
|
||||
* axis or 0 on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickNumAxes
|
||||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
|
||||
int axis);
|
||||
|
||||
/**
|
||||
* Get the initial state of an axis control on a joystick.
|
||||
* Get the initial state of an axis control on a joystick.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767.
|
||||
* The state is a value ranging from -32768 to 32767.
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
* The axis indices start at index 0.
|
||||
*
|
||||
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param axis the axis to query; the axis indices start at index 0
|
||||
* \param state Upon return, the initial value is supplied here.
|
||||
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick,
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick,
|
||||
int axis, Sint16 *state);
|
||||
|
||||
/**
|
||||
|
@ -338,64 +741,199 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *
|
|||
/* @} */
|
||||
|
||||
/**
|
||||
* Get the current state of a POV hat on a joystick.
|
||||
* Get the current state of a POV hat on a joystick.
|
||||
*
|
||||
* The hat indices start at index 0.
|
||||
* The returned value will be one of the following positions:
|
||||
*
|
||||
* \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
|
||||
* - `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`
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param hat the hat index to get the state from; indices start at index 0
|
||||
* \returns the current hat position.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickNumHats
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
|
||||
int hat);
|
||||
|
||||
/**
|
||||
* Get the ball axis change since the last poll.
|
||||
* Get the ball axis change since the last poll.
|
||||
*
|
||||
* \return 0, or -1 if you passed it invalid parameters.
|
||||
* Trackballs can only return relative motion since the last call to
|
||||
* SDL_JoystickGetBall(), these motion deltas are placed into `dx` and `dy`.
|
||||
*
|
||||
* The ball indices start at index 0.
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick the SDL_Joystick to query
|
||||
* \param ball the ball index to query; ball indices start at index 0
|
||||
* \param dx stores the difference in the x axis position since the last poll
|
||||
* \param dy stores the difference in the y axis position since the last poll
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickNumBalls
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
|
||||
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.
|
||||
* Get the current state of a button on a joystick.
|
||||
*
|
||||
* The button indices start at index 0.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param button the button index to get the state from; indices start at
|
||||
* index 0
|
||||
* \returns 1 if the specified button is pressed, 0 otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickNumButtons
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
|
||||
int button);
|
||||
|
||||
/**
|
||||
* Trigger a rumble effect
|
||||
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
|
||||
* Start a rumble effect.
|
||||
*
|
||||
* \param joystick The joystick to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* Each call to this function cancels any previous rumble effect, and calling
|
||||
* it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* \return 0, or -1 if rumble isn't supported on this joystick
|
||||
* \param joystick The joystick to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left)
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right)
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if rumble isn't supported on this joystick
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*
|
||||
* \sa SDL_JoystickHasRumble
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Close a joystick previously opened with SDL_JoystickOpen().
|
||||
* Start a rumble effect in the joystick's triggers
|
||||
*
|
||||
* Each call to this function cancels any previous trigger rumble effect, and
|
||||
* calling it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* Note that this function is for _trigger_ rumble; the first joystick to
|
||||
* support this was the PlayStation 5's DualShock 5 controller. If you want
|
||||
* the (more common) whole-controller rumble, use SDL_JoystickRumble()
|
||||
* instead.
|
||||
*
|
||||
* \param joystick The joystick to vibrate
|
||||
* \param left_rumble The intensity of the left trigger rumble motor, from 0
|
||||
* to 0xFFFF
|
||||
* \param right_rumble The intensity of the right trigger rumble motor, from 0
|
||||
* to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if trigger rumble isn't supported on this joystick
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
* \sa SDL_JoystickHasRumbleTriggers
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Return the battery level of this joystick
|
||||
* Query whether a joystick has an LED.
|
||||
*
|
||||
* An example of a joystick LED is the light on the back of a PlayStation 4's
|
||||
* DualShock 4 controller.
|
||||
*
|
||||
* \param joystick The joystick to query
|
||||
* \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Query whether a joystick has rumble support.
|
||||
*
|
||||
* \param joystick The joystick to query
|
||||
* \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_JoystickRumble
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Query whether a joystick has rumble support on triggers.
|
||||
*
|
||||
* \param joystick The joystick to query
|
||||
* \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
* \sa SDL_JoystickRumbleTriggers
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Update a joystick's LED color.
|
||||
*
|
||||
* An example of a joystick LED is the light on the back of a PlayStation 4's
|
||||
* DualShock 4 controller.
|
||||
*
|
||||
* \param joystick The joystick to update
|
||||
* \param red The intensity of the red LED
|
||||
* \param green The intensity of the green LED
|
||||
* \param blue The intensity of the blue LED
|
||||
* \returns 0 on success, -1 if this joystick does not have a modifiable LED
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
/**
|
||||
* Send a joystick specific effect packet
|
||||
*
|
||||
* \param joystick The joystick to affect
|
||||
* \param data The data to send to the joystick
|
||||
* \param size The size of the data to send to the joystick
|
||||
* \returns 0, or -1 if this joystick or driver doesn't support effect packets
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size);
|
||||
|
||||
/**
|
||||
* Close a joystick previously opened with SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick The joystick device to close
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_JoystickOpen
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the battery level of a joystick as SDL_JoystickPowerLevel.
|
||||
*
|
||||
* \param joystick the SDL_Joystick to query
|
||||
* \returns the current battery level as SDL_JoystickPowerLevel on success or
|
||||
* `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -55,154 +55,253 @@ typedef struct SDL_Keysym
|
|||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the window which currently has keyboard focus.
|
||||
* Query the window which currently has keyboard focus.
|
||||
*
|
||||
* \returns the window with keyboard focus.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
|
||||
|
||||
/**
|
||||
* \brief Get a snapshot of the current state of the keyboard.
|
||||
* Get a snapshot of the current state of the keyboard.
|
||||
*
|
||||
* \param numkeys if non-NULL, receives the length of the returned array.
|
||||
* The pointer returned is a pointer to an internal SDL array. It will be
|
||||
* valid for the whole lifetime of the application and should not be freed by
|
||||
* the caller.
|
||||
*
|
||||
* \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values.
|
||||
* A array element with a value of 1 means that the key is pressed and a value
|
||||
* of 0 means that it is not. Indexes into this array are obtained by using
|
||||
* SDL_Scancode values.
|
||||
*
|
||||
* \b Example:
|
||||
* \code
|
||||
* const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||
* if ( state[SDL_SCANCODE_RETURN] ) {
|
||||
* printf("<RETURN> is pressed.\n");
|
||||
* }
|
||||
* \endcode
|
||||
* Use SDL_PumpEvents() to update the state array.
|
||||
*
|
||||
* This function gives you the current state after all events have been
|
||||
* processed, so if a key or button has been pressed and released before you
|
||||
* process events, then the pressed state will never show up in the
|
||||
* SDL_GetKeyboardState() calls.
|
||||
*
|
||||
* Note: This function doesn't take into account whether shift has been
|
||||
* pressed or not.
|
||||
*
|
||||
* \param numkeys if non-NULL, receives the length of the returned array
|
||||
* \returns a pointer to an array of key states.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PumpEvents
|
||||
*/
|
||||
extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
|
||||
|
||||
/**
|
||||
* \brief Get the current key modifier state for the keyboard.
|
||||
* Get the current key modifier state for the keyboard.
|
||||
*
|
||||
* \returns an OR'd combination of the modifier keys for the keyboard. See
|
||||
* SDL_Keymod for details.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyboardState
|
||||
* \sa SDL_SetModState
|
||||
*/
|
||||
extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
|
||||
|
||||
/**
|
||||
* \brief Set the current key modifier state for the keyboard.
|
||||
* Set the current key modifier state for the keyboard.
|
||||
*
|
||||
* \note This does not change the keyboard state, only the key modifier flags.
|
||||
* The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose
|
||||
* modifier key states on your application. Simply pass your desired modifier
|
||||
* states into `modstate`. This value may be a bitwise, OR'd combination of
|
||||
* SDL_Keymod values.
|
||||
*
|
||||
* This does not change the keyboard state, only the key modifier flags that
|
||||
* SDL reports.
|
||||
*
|
||||
* \param modstate the desired SDL_Keymod for the keyboard
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetModState
|
||||
*/
|
||||
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.
|
||||
* Get the key code corresponding to the given scancode according to the
|
||||
* current keyboard layout.
|
||||
*
|
||||
* See ::SDL_Keycode for details.
|
||||
* See SDL_Keycode for details.
|
||||
*
|
||||
* \sa SDL_GetKeyName()
|
||||
* \param scancode the desired SDL_Scancode to query
|
||||
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyName
|
||||
* \sa SDL_GetScancodeFromKey
|
||||
*/
|
||||
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.
|
||||
* Get the scancode corresponding to the given key code according to the
|
||||
* current keyboard layout.
|
||||
*
|
||||
* See ::SDL_Scancode for details.
|
||||
* See SDL_Scancode for details.
|
||||
*
|
||||
* \sa SDL_GetScancodeName()
|
||||
* \param key the desired SDL_Keycode to query
|
||||
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyFromScancode
|
||||
* \sa SDL_GetScancodeName
|
||||
*/
|
||||
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
|
||||
|
||||
/**
|
||||
* \brief Get a human-readable name for a scancode.
|
||||
* Get a human-readable name for a scancode.
|
||||
*
|
||||
* \return A pointer to the name for the scancode.
|
||||
* If the scancode doesn't have a name, this function returns
|
||||
* an empty string ("").
|
||||
* See SDL_Scancode for details.
|
||||
*
|
||||
* \sa SDL_Scancode
|
||||
* **Warning**: The returned name is by design not stable across platforms,
|
||||
* e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left
|
||||
* Windows" under Microsoft Windows, and some scancodes like
|
||||
* `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even
|
||||
* scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and
|
||||
* `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore
|
||||
* unsuitable for creating a stable cross-platform two-way mapping between
|
||||
* strings and scancodes.
|
||||
*
|
||||
* \param scancode the desired SDL_Scancode to query
|
||||
* \returns a pointer to the name for the scancode. If the scancode doesn't
|
||||
* have a name this function returns an empty string ("").
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetScancodeFromKey
|
||||
* \sa SDL_GetScancodeFromName
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
|
||||
|
||||
/**
|
||||
* \brief Get a scancode from a human-readable name
|
||||
* Get a scancode from a human-readable name.
|
||||
*
|
||||
* \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized
|
||||
* \param name the human-readable scancode name
|
||||
* \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't
|
||||
* recognized; call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_Scancode
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyFromName
|
||||
* \sa SDL_GetScancodeFromKey
|
||||
* \sa SDL_GetScancodeName
|
||||
*/
|
||||
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
|
||||
|
||||
/**
|
||||
* \brief Get a human-readable name for a key.
|
||||
* 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 ("").
|
||||
* See SDL_Scancode and SDL_Keycode for details.
|
||||
*
|
||||
* \sa SDL_Keycode
|
||||
* \param key the desired SDL_Keycode to query
|
||||
* \returns 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 ("").
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyFromName
|
||||
* \sa SDL_GetKeyFromScancode
|
||||
* \sa SDL_GetScancodeFromKey
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
|
||||
|
||||
/**
|
||||
* \brief Get a key code from a human-readable name
|
||||
* Get a key code from a human-readable name.
|
||||
*
|
||||
* \return key code, or SDLK_UNKNOWN if the name wasn't recognized
|
||||
* \param name the human-readable key name
|
||||
* \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_Keycode
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyFromScancode
|
||||
* \sa SDL_GetKeyName
|
||||
* \sa SDL_GetScancodeFromName
|
||||
*/
|
||||
extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
|
||||
|
||||
/**
|
||||
* \brief Start accepting Unicode text input events.
|
||||
* This function will show the on-screen keyboard if supported.
|
||||
* Start accepting Unicode text input events.
|
||||
*
|
||||
* \sa SDL_StopTextInput()
|
||||
* \sa SDL_SetTextInputRect()
|
||||
* \sa SDL_HasScreenKeyboardSupport()
|
||||
* This function will start accepting Unicode text input events in the focused
|
||||
* SDL window, and start emitting SDL_TextInputEvent (SDL_TEXTINPUT) and
|
||||
* SDL_TextEditingEvent (SDL_TEXTEDITING) events. Please use this function in
|
||||
* pair with SDL_StopTextInput().
|
||||
*
|
||||
* On some platforms using this function activates the screen keyboard.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_SetTextInputRect
|
||||
* \sa SDL_StopTextInput
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
|
||||
|
||||
/**
|
||||
* \brief Return whether or not Unicode text input events are enabled.
|
||||
* Check whether or not Unicode text input events are enabled.
|
||||
*
|
||||
* \sa SDL_StartTextInput()
|
||||
* \sa SDL_StopTextInput()
|
||||
* \returns SDL_TRUE if text input events are enabled else SDL_FALSE.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
|
||||
|
||||
/**
|
||||
* \brief Stop receiving any text input events.
|
||||
* This function will hide the on-screen keyboard if supported.
|
||||
* Stop receiving any text input events.
|
||||
*
|
||||
* \sa SDL_StartTextInput()
|
||||
* \sa SDL_HasScreenKeyboardSupport()
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
|
||||
|
||||
/**
|
||||
* \brief Set the rectangle used to type Unicode text inputs.
|
||||
* This is used as a hint for IME and on-screen keyboard placement.
|
||||
* Set the rectangle used to type Unicode text inputs.
|
||||
*
|
||||
* \sa SDL_StartTextInput()
|
||||
* \param rect the SDL_Rect structure representing the rectangle to receive
|
||||
* text (ignored if NULL)
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* \brief Returns whether the platform has some screen keyboard support.
|
||||
* Check whether the platform has screen keyboard support.
|
||||
*
|
||||
* \return SDL_TRUE if some keyboard support is available else SDL_FALSE.
|
||||
* \returns SDL_TRUE if the platform has some screen keyboard support or
|
||||
* SDL_FALSE if not.
|
||||
*
|
||||
* \note Not all screen keyboard functions are supported on all platforms.
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_IsScreenKeyboardShown()
|
||||
* \sa SDL_StartTextInput
|
||||
* \sa SDL_IsScreenKeyboardShown
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void);
|
||||
|
||||
/**
|
||||
* \brief Returns whether the screen keyboard is shown for given window.
|
||||
* Check whether the screen keyboard is shown for given window.
|
||||
*
|
||||
* \param window The window for which screen keyboard should be queried.
|
||||
* \param window the window for which screen keyboard should be queried
|
||||
* \returns SDL_TRUE if screen keyboard is shown or SDL_FALSE if not.
|
||||
*
|
||||
* \return SDL_TRUE if screen keyboard is shown else SDL_FALSE.
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_HasScreenKeyboardSupport()
|
||||
* \sa SDL_HasScreenKeyboardSupport
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -47,12 +47,12 @@ typedef Sint32 SDL_Keycode;
|
|||
#define SDLK_SCANCODE_MASK (1<<30)
|
||||
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
|
||||
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDLK_UNKNOWN = 0,
|
||||
|
||||
SDLK_RETURN = '\r',
|
||||
SDLK_ESCAPE = '\033',
|
||||
SDLK_ESCAPE = '\x1B',
|
||||
SDLK_BACKSPACE = '\b',
|
||||
SDLK_TAB = '\t',
|
||||
SDLK_SPACE = ' ',
|
||||
|
@ -88,9 +88,11 @@ enum
|
|||
SDLK_GREATER = '>',
|
||||
SDLK_QUESTION = '?',
|
||||
SDLK_AT = '@',
|
||||
|
||||
/*
|
||||
Skip uppercase letters
|
||||
*/
|
||||
|
||||
SDLK_LEFTBRACKET = '[',
|
||||
SDLK_BACKSLASH = '\\',
|
||||
SDLK_RIGHTBRACKET = ']',
|
||||
|
@ -145,7 +147,7 @@ enum
|
|||
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_DELETE = '\x7F',
|
||||
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),
|
||||
|
@ -317,7 +319,7 @@ enum
|
|||
|
||||
SDLK_AUDIOREWIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOREWIND),
|
||||
SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD)
|
||||
};
|
||||
} SDL_KeyCode;
|
||||
|
||||
/**
|
||||
* \brief Enumeration of valid key mods (possibly OR'd together).
|
||||
|
@ -336,13 +338,15 @@ typedef enum
|
|||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000
|
||||
} SDL_Keymod;
|
||||
KMOD_SCROLL = 0x8000,
|
||||
|
||||
#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)
|
||||
KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL,
|
||||
KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT,
|
||||
KMOD_ALT = KMOD_LALT | KMOD_RALT,
|
||||
KMOD_GUI = KMOD_LGUI | KMOD_RGUI,
|
||||
|
||||
KMOD_RESERVED = KMOD_SCROLL /* This is for source-level compatibility with SDL 2.0.0. */
|
||||
} SDL_Keymod;
|
||||
|
||||
#endif /* SDL_keycode_h_ */
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -51,22 +51,56 @@ extern "C" {
|
|||
#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.
|
||||
* Dynamically load a shared object.
|
||||
*
|
||||
* \param sofile a system-dependent name of the object file
|
||||
* \returns an opaque pointer to the object handle or NULL if there was an
|
||||
* error; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LoadFunction
|
||||
* \sa SDL_UnloadObject
|
||||
*/
|
||||
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().
|
||||
* Look up the address of the named function in a shared object.
|
||||
*
|
||||
* This function pointer is no longer valid after calling SDL_UnloadObject().
|
||||
*
|
||||
* This function can only look up C function names. Other languages may have
|
||||
* name mangling and intrinsic language support that varies from compiler to
|
||||
* compiler.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* If the requested function doesn't exist, NULL is returned.
|
||||
*
|
||||
* \param handle a valid shared object handle returned by SDL_LoadObject()
|
||||
* \param name the name of the function to look up
|
||||
* \returns a pointer to the function or NULL if there was an error; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LoadObject
|
||||
* \sa SDL_UnloadObject
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Unload a shared object from memory.
|
||||
* Unload a shared object from memory.
|
||||
*
|
||||
* \param handle a valid shared object handle returned by SDL_LoadObject()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LoadFunction
|
||||
* \sa SDL_LoadObject
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
|
||||
|
||||
|
|
103
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_locale.h
Normal file
103
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_locale.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_locale.h
|
||||
*
|
||||
* Include file for SDL locale services
|
||||
*/
|
||||
|
||||
#ifndef _SDL_locale_h
|
||||
#define _SDL_locale_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
|
||||
|
||||
|
||||
typedef struct SDL_Locale
|
||||
{
|
||||
const char *language; /**< A language name, like "en" for English. */
|
||||
const char *country; /**< A country, like "US" for America. Can be NULL. */
|
||||
} SDL_Locale;
|
||||
|
||||
/**
|
||||
* Report the user's preferred locale.
|
||||
*
|
||||
* This returns an array of SDL_Locale structs, the final item zeroed out.
|
||||
* When the caller is done with this array, it should call SDL_free() on the
|
||||
* returned value; all the memory involved is allocated in a single block, so
|
||||
* a single SDL_free() will suffice.
|
||||
*
|
||||
* Returned language strings are in the format xx, where 'xx' is an ISO-639
|
||||
* language specifier (such as "en" for English, "de" for German, etc).
|
||||
* Country strings are in the format YY, where "YY" is an ISO-3166 country
|
||||
* code (such as "US" for the United States, "CA" for Canada, etc). Country
|
||||
* might be NULL if there's no specific guidance on them (so you might get {
|
||||
* "en", "US" } for American English, but { "en", NULL } means "English
|
||||
* language, generically"). Language strings are never NULL, except to
|
||||
* terminate the array.
|
||||
*
|
||||
* Please note that not all of these strings are 2 characters; some are three
|
||||
* or more.
|
||||
*
|
||||
* The returned list of locales are in the order of the user's preference. For
|
||||
* example, a German citizen that is fluent in US English and knows enough
|
||||
* Japanese to navigate around Tokyo might have a list like: { "de", "en_US",
|
||||
* "jp", NULL }. Someone from England might prefer British English (where
|
||||
* "color" is spelled "colour", etc), but will settle for anything like it: {
|
||||
* "en_GB", "en", NULL }.
|
||||
*
|
||||
* This function returns NULL on error, including when the platform does not
|
||||
* supply this information at all.
|
||||
*
|
||||
* This might be a "slow" call that has to query the operating system. It's
|
||||
* best to ask for this once and save the results. However, this list can
|
||||
* change, usually because the user has changed a system preference outside of
|
||||
* your program; SDL will send an SDL_LOCALECHANGED event in this case, if
|
||||
* possible, and you can call this function again to get an updated copy of
|
||||
* preferred locales.
|
||||
*
|
||||
* \return array of locales, terminated with a locale with a NULL language
|
||||
* field. Will return NULL on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC SDL_Locale * SDLCALL SDL_GetPreferredLocales(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_locale_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -61,7 +61,7 @@ extern "C" {
|
|||
* at the VERBOSE level and all other categories are enabled at the
|
||||
* CRITICAL level.
|
||||
*/
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
SDL_LOG_CATEGORY_ERROR,
|
||||
|
@ -94,7 +94,7 @@ enum
|
|||
};
|
||||
*/
|
||||
SDL_LOG_CATEGORY_CUSTOM
|
||||
};
|
||||
} SDL_LogCategory;
|
||||
|
||||
/**
|
||||
* \brief The predefined log priorities
|
||||
|
@ -112,90 +112,283 @@ typedef enum
|
|||
|
||||
|
||||
/**
|
||||
* \brief Set the priority of all log categories
|
||||
* Set the priority of all log categories.
|
||||
*
|
||||
* \param priority the SDL_LogPriority to assign
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogSetPriority
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
|
||||
|
||||
/**
|
||||
* \brief Set the priority of a particular log category
|
||||
* Set the priority of a particular log category.
|
||||
*
|
||||
* \param category the category to assign a priority to
|
||||
* \param priority the SDL_LogPriority to assign
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogGetPriority
|
||||
* \sa SDL_LogSetAllPriority
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
|
||||
SDL_LogPriority priority);
|
||||
|
||||
/**
|
||||
* \brief Get the priority of a particular log category
|
||||
* Get the priority of a particular log category.
|
||||
*
|
||||
* \param category the category to query
|
||||
* \returns the SDL_LogPriority for the requested category
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogSetPriority
|
||||
*/
|
||||
extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
|
||||
|
||||
/**
|
||||
* \brief Reset all priorities to default.
|
||||
* Reset all priorities to default.
|
||||
*
|
||||
* \note This is called in SDL_Quit().
|
||||
* This is called by SDL_Quit().
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogSetAllPriority
|
||||
* \sa SDL_LogSetPriority
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
|
||||
* Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
|
||||
*
|
||||
* = * \param fmt a printf() style message format string
|
||||
*
|
||||
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||
* any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
|
||||
* Log a message with SDL_LOG_PRIORITY_VERBOSE.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_DEBUG
|
||||
* Log a message with SDL_LOG_PRIORITY_DEBUG.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_INFO
|
||||
* Log a message with SDL_LOG_PRIORITY_INFO.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_WARN
|
||||
* Log a message with SDL_LOG_PRIORITY_WARN.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_ERROR
|
||||
* Log a message with SDL_LOG_PRIORITY_ERROR.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
|
||||
* Log a message with SDL_LOG_PRIORITY_CRITICAL.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* \brief Log a message with the specified category and priority.
|
||||
* Log a message with the specified category and priority.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param priority the priority of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessageV
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
|
||||
SDL_LogPriority priority,
|
||||
SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3);
|
||||
|
||||
/**
|
||||
* \brief Log a message with the specified category and priority.
|
||||
* Log a message with the specified category and priority.
|
||||
*
|
||||
* \param category the category of the message
|
||||
* \param priority the priority of the message
|
||||
* \param fmt a printf() style message format string
|
||||
* \param ap a variable argument list
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
* \sa SDL_LogCritical
|
||||
* \sa SDL_LogDebug
|
||||
* \sa SDL_LogError
|
||||
* \sa SDL_LogInfo
|
||||
* \sa SDL_LogMessage
|
||||
* \sa SDL_LogVerbose
|
||||
* \sa SDL_LogWarn
|
||||
*/
|
||||
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
|
||||
* The prototype for the log output callback function.
|
||||
*
|
||||
* This function is called by SDL when there is new text to be logged.
|
||||
*
|
||||
* \param userdata what was passed as `userdata` to SDL_LogSetOutputFunction()
|
||||
* \param category the category of the message
|
||||
* \param priority the priority of the message
|
||||
* \param message the message being output
|
||||
*/
|
||||
typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
|
||||
|
||||
/**
|
||||
* \brief Get the current log output function.
|
||||
* Get the current log output function.
|
||||
*
|
||||
* \param callback an SDL_LogOutputFunction filled in with the current log
|
||||
* callback
|
||||
* \param userdata a pointer filled in with the pointer that is passed to
|
||||
* `callback`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogSetOutputFunction
|
||||
*/
|
||||
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.
|
||||
* Replace the default log output function with one of your own.
|
||||
*
|
||||
* \param callback an SDL_LogOutputFunction to call instead of the default
|
||||
* \param userdata a pointer that is passed to `callback`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_LogGetOutputFunction
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -83,6 +83,15 @@
|
|||
*/
|
||||
#define SDL_MAIN_NEEDED
|
||||
|
||||
#elif defined(__PSP__)
|
||||
/* On PSP SDL provides a main function that sets the module info,
|
||||
activates the GPU and starts the thread required to be able to exit
|
||||
the software.
|
||||
|
||||
If you provide this yourself, you may define SDL_MAIN_HANDLED
|
||||
*/
|
||||
#define SDL_MAIN_AVAILABLE
|
||||
|
||||
#endif
|
||||
#endif /* SDL_MAIN_HANDLED */
|
||||
|
||||
|
@ -122,20 +131,62 @@ extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
|
|||
|
||||
|
||||
/**
|
||||
* This is called by the real SDL main function to let the rest of the
|
||||
* library know that initialization was done properly.
|
||||
* Circumvent failure of SDL_Init() when not using SDL_main() as an entry
|
||||
* point.
|
||||
*
|
||||
* Calling this yourself without knowing what you're doing can cause
|
||||
* crashes and hard to diagnose problems with your application.
|
||||
* This function is defined in SDL_main.h, along with the preprocessor rule to
|
||||
* redefine main() as SDL_main(). Thus to ensure that your main() function
|
||||
* will not be changed it is necessary to define SDL_MAIN_HANDLED before
|
||||
* including SDL.h.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_Init
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
/**
|
||||
* This can be called to set the application class at startup
|
||||
* Register a win32 window class for SDL's use.
|
||||
*
|
||||
* This can be called to set the application window class at startup. It is
|
||||
* safe to call this multiple times, as long as every call is eventually
|
||||
* paired with a call to SDL_UnregisterApp, but a second registration attempt
|
||||
* while a previous registration is still active will be ignored, other than
|
||||
* to increment a counter.
|
||||
*
|
||||
* Most applications do not need to, and should not, call this directly; SDL
|
||||
* will call it when initializing the video subsystem.
|
||||
*
|
||||
* \param name the window class name, in UTF-8 encoding. If NULL, SDL
|
||||
* currently uses "SDL_app" but this isn't guaranteed.
|
||||
* \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
|
||||
* currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
|
||||
* what is specified here.
|
||||
* \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
|
||||
* will use `GetModuleHandle(NULL)` instead.
|
||||
* \returns 0 on success, -1 on error. SDL_GetError() may have details.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
|
||||
|
||||
/**
|
||||
* Deregister the win32 window class from an SDL_RegisterApp call.
|
||||
*
|
||||
* This can be called to undo the effects of SDL_RegisterApp.
|
||||
*
|
||||
* Most applications do not need to, and should not, call this directly; SDL
|
||||
* will call it when deinitializing the video subsystem.
|
||||
*
|
||||
* It is safe to call this multiple times, as long as every call is eventually
|
||||
* paired with a prior call to SDL_RegisterApp. The window class will only be
|
||||
* deregistered when the registration counter in SDL_RegisterApp decrements to
|
||||
* zero through calls to this function.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
|
||||
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
||||
|
||||
#endif /* __WIN32__ */
|
||||
|
@ -144,12 +195,14 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
|||
#ifdef __WINRT__
|
||||
|
||||
/**
|
||||
* \brief Initializes and launches an SDL/WinRT application.
|
||||
* Initialize and launch an SDL/WinRT application.
|
||||
*
|
||||
* \param mainFunction The SDL app's C-style main().
|
||||
* \param reserved Reserved for future use; should be NULL
|
||||
* \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more
|
||||
* information on the failure.
|
||||
* \param mainFunction the SDL app's C-style main(), an SDL_main_func
|
||||
* \param reserved reserved for future use; should be NULL
|
||||
* \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
|
||||
* more information on the failure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.3.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved);
|
||||
|
||||
|
@ -158,12 +211,14 @@ extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * r
|
|||
#if defined(__IPHONEOS__)
|
||||
|
||||
/**
|
||||
* \brief Initializes and launches an SDL application.
|
||||
* Initializes and launches an SDL application.
|
||||
*
|
||||
* \param argc The argc parameter from the application's main() function
|
||||
* \param argv The argv parameter from the application's main() function
|
||||
* \param mainFunction The SDL app's C-style main().
|
||||
* \return the return value from mainFunction
|
||||
* \param argc The argc parameter from the application's main() function
|
||||
* \param argv The argv parameter from the application's main() function
|
||||
* \param mainFunction The SDL app's C-style main(), an SDL_main_func
|
||||
* \return the return value from mainFunction
|
||||
*
|
||||
* \since This function is available since SDL 2.0.10.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -32,17 +32,19 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* \brief SDL_MessageBox flags. If supported will display warning icon, etc.
|
||||
* SDL_MessageBox flags. If supported will display warning icon, etc.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
|
||||
SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
|
||||
SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */
|
||||
SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
|
||||
SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
|
||||
SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */
|
||||
SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, /**< buttons placed left to right */
|
||||
SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 /**< buttons placed right to left */
|
||||
} SDL_MessageBoxFlags;
|
||||
|
||||
/**
|
||||
* \brief Flags for SDL_MessageBoxButtonData.
|
||||
* Flags for SDL_MessageBoxButtonData.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -51,7 +53,7 @@ typedef enum
|
|||
} SDL_MessageBoxButtonFlags;
|
||||
|
||||
/**
|
||||
* \brief Individual button data.
|
||||
* Individual button data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
@ -61,7 +63,7 @@ typedef struct
|
|||
} SDL_MessageBoxButtonData;
|
||||
|
||||
/**
|
||||
* \brief RGB value used in a message box color scheme
|
||||
* RGB value used in a message box color scheme
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
@ -79,7 +81,7 @@ typedef enum
|
|||
} SDL_MessageBoxColorType;
|
||||
|
||||
/**
|
||||
* \brief A set of colors to use for message box dialogs
|
||||
* A set of colors to use for message box dialogs
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
@ -87,7 +89,7 @@ typedef struct
|
|||
} SDL_MessageBoxColorScheme;
|
||||
|
||||
/**
|
||||
* \brief MessageBox structure containing title, text, window, etc.
|
||||
* MessageBox structure containing title, text, window, etc.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
@ -103,32 +105,79 @@ typedef struct
|
|||
} SDL_MessageBoxData;
|
||||
|
||||
/**
|
||||
* \brief Create a modal message box.
|
||||
* Create a modal message box.
|
||||
*
|
||||
* \param messageboxdata The SDL_MessageBoxData structure with title, text, etc.
|
||||
* \param buttonid The pointer to which user id of hit button should be copied.
|
||||
* If your needs aren't complex, it might be easier to use
|
||||
* SDL_ShowSimpleMessageBox.
|
||||
*
|
||||
* \return -1 on error, otherwise 0 and buttonid contains user id of button
|
||||
* hit or -1 if dialog was closed.
|
||||
* This function should be called on the thread that created the parent
|
||||
* window, or on the main thread if the messagebox has no parent. It will
|
||||
* block execution of that thread until the user clicks a button or closes the
|
||||
* messagebox.
|
||||
*
|
||||
* \note This function should be called on the thread that created the parent
|
||||
* window, or on the main thread if the messagebox has no parent. It will
|
||||
* block execution of that thread until the user clicks a button or
|
||||
* closes the messagebox.
|
||||
* This function may be called at any time, even before SDL_Init(). This makes
|
||||
* it useful for reporting errors like a failure to create a renderer or
|
||||
* OpenGL context.
|
||||
*
|
||||
* On X11, SDL rolls its own dialog box with X11 primitives instead of a
|
||||
* formal toolkit like GTK+ or Qt.
|
||||
*
|
||||
* Note that if SDL_Init() would fail because there isn't any available video
|
||||
* target, this function is likely to fail for the same reasons. If this is a
|
||||
* concern, check the return value from this function and fall back to writing
|
||||
* to stderr if you can.
|
||||
*
|
||||
* \param messageboxdata the SDL_MessageBoxData structure with title, text and
|
||||
* other options
|
||||
* \param buttonid the pointer to which user id of hit button should be copied
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_ShowSimpleMessageBox
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
/**
|
||||
* \brief Create a simple modal message box
|
||||
* Display a simple modal message box.
|
||||
*
|
||||
* \param flags ::SDL_MessageBoxFlags
|
||||
* \param title UTF-8 title text
|
||||
* \param message UTF-8 message text
|
||||
* \param window The parent window, or NULL for no parent
|
||||
* If your needs aren't complex, this function is preferred over
|
||||
* SDL_ShowMessageBox.
|
||||
*
|
||||
* \return 0 on success, -1 on error
|
||||
* `flags` may be any of the following:
|
||||
*
|
||||
* \sa SDL_ShowMessageBox
|
||||
* - `SDL_MESSAGEBOX_ERROR`: error dialog
|
||||
* - `SDL_MESSAGEBOX_WARNING`: warning dialog
|
||||
* - `SDL_MESSAGEBOX_INFORMATION`: informational dialog
|
||||
*
|
||||
* This function should be called on the thread that created the parent
|
||||
* window, or on the main thread if the messagebox has no parent. It will
|
||||
* block execution of that thread until the user clicks a button or closes the
|
||||
* messagebox.
|
||||
*
|
||||
* This function may be called at any time, even before SDL_Init(). This makes
|
||||
* it useful for reporting errors like a failure to create a renderer or
|
||||
* OpenGL context.
|
||||
*
|
||||
* On X11, SDL rolls its own dialog box with X11 primitives instead of a
|
||||
* formal toolkit like GTK+ or Qt.
|
||||
*
|
||||
* Note that if SDL_Init() would fail because there isn't any available video
|
||||
* target, this function is likely to fail for the same reasons. If this is a
|
||||
* concern, check the return value from this function and fall back to writing
|
||||
* to stderr if you can.
|
||||
*
|
||||
* \param flags an SDL_MessageBoxFlags value
|
||||
* \param title UTF-8 title text
|
||||
* \param message UTF-8 message text
|
||||
* \param window the parent window, or NULL for no parent
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_ShowMessageBox
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window);
|
||||
|
||||
|
|
112
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_metal.h
Normal file
112
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_metal.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_metal.h
|
||||
*
|
||||
* Header file for functions to creating Metal layers and views on SDL windows.
|
||||
*/
|
||||
|
||||
#ifndef SDL_metal_h_
|
||||
#define SDL_metal_h_
|
||||
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
|
||||
*
|
||||
* \note This can be cast directly to an NSView or UIView.
|
||||
*/
|
||||
typedef void *SDL_MetalView;
|
||||
|
||||
/**
|
||||
* \name Metal support functions
|
||||
*/
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
* Create a CAMetalLayer-backed NSView/UIView and attach it to the specified
|
||||
* window.
|
||||
*
|
||||
* On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on
|
||||
* its own. It is up to user code to do that.
|
||||
*
|
||||
* The returned handle can be casted directly to a NSView or UIView. To access
|
||||
* the backing CAMetalLayer, call SDL_Metal_GetLayer().
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*
|
||||
* \sa SDL_Metal_DestroyView
|
||||
* \sa SDL_Metal_GetLayer
|
||||
*/
|
||||
extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* Destroy an existing SDL_MetalView object.
|
||||
*
|
||||
* This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
|
||||
* called after SDL_CreateWindow.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
*
|
||||
* \sa SDL_Metal_CreateView
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
|
||||
|
||||
/**
|
||||
* Get a pointer to the backing CAMetalLayer for the given view.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
* \sa SDL_MetalCreateView
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
|
||||
|
||||
/**
|
||||
* Get the size of a window's underlying drawable in pixels (for use with
|
||||
* setting viewport, scissor & etc).
|
||||
*
|
||||
* \param window SDL_Window from which the drawable size should be queried
|
||||
* \param w Pointer to variable for storing the width in pixels, may be NULL
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
* \sa SDL_GetWindowSize
|
||||
* \sa SDL_CreateWindow
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window* window, int *w,
|
||||
int *h);
|
||||
|
||||
/* @} *//* Metal support functions */
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* SDL_metal_h_ */
|
79
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_misc.h
Normal file
79
libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_misc.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_misc.h
|
||||
*
|
||||
* \brief Include file for SDL API functions that don't fit elsewhere.
|
||||
*/
|
||||
|
||||
#ifndef SDL_misc_h_
|
||||
#define SDL_misc_h_
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Open a URL/URI in the browser or other appropriate external application.
|
||||
*
|
||||
* Open a URL in a separate, system-provided application. How this works will
|
||||
* vary wildly depending on the platform. This will likely launch what makes
|
||||
* sense to handle a specific URL's protocol (a web browser for `http://`,
|
||||
* etc), but it might also be able to launch file managers for directories and
|
||||
* other things.
|
||||
*
|
||||
* What happens when you open a URL varies wildly as well: your game window
|
||||
* may lose focus (and may or may not lose focus if your game was fullscreen
|
||||
* or grabbing input at the time). On mobile devices, your app will likely
|
||||
* move to the background or your process might be paused. Any given platform
|
||||
* may or may not handle a given URL.
|
||||
*
|
||||
* If this is unimplemented (or simply unavailable) for a platform, this will
|
||||
* fail with an error. A successful result does not mean the URL loaded, just
|
||||
* that we launched _something_ to handle it (or at least believe we did).
|
||||
*
|
||||
* All this to say: this function can be useful, but you should definitely
|
||||
* test it on every platform you target.
|
||||
*
|
||||
* \param url A valid URL/URI to open. Use `file:///full/path/to/file` for
|
||||
* local files, if supported.
|
||||
* \returns 0 on success, or -1 on error; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* SDL_misc_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -72,150 +72,240 @@ typedef enum
|
|||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the window which currently has mouse focus.
|
||||
* Get the window which currently has mouse focus.
|
||||
*
|
||||
* \returns the window with mouse focus.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the current state of the mouse.
|
||||
* 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.
|
||||
* The current button state is returned as a button bitmask, which can be
|
||||
* tested using the `SDL_BUTTON(X)` macros (where `X` is generally 1 for the
|
||||
* left, 2 for middle, 3 for the right button), and `x` and `y` are set to the
|
||||
* mouse cursor position relative to the focus window. You can pass NULL for
|
||||
* either `x` or `y`.
|
||||
*
|
||||
* \param x the x coordinate of the mouse cursor position relative to the
|
||||
* focus window
|
||||
* \param y the y coordinate of the mouse cursor position relative to the
|
||||
* focus window
|
||||
* \returns a 32-bit button bitmask of the current button state.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetGlobalMouseState
|
||||
* \sa SDL_GetRelativeMouseState
|
||||
* \sa SDL_PumpEvents
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Get the current state of the mouse, in relation to the desktop
|
||||
* Get the current state of the mouse in relation to the desktop.
|
||||
*
|
||||
* This works just like SDL_GetMouseState(), but the coordinates will be
|
||||
* reported relative to the top-left of the desktop. This can be useful if
|
||||
* you need to track the mouse outside of a specific window and
|
||||
* SDL_CaptureMouse() doesn't fit your needs. For example, it could be
|
||||
* useful if you need to track the mouse while dragging a window, where
|
||||
* coordinates relative to a window might not be in sync at all times.
|
||||
* This works similarly to SDL_GetMouseState(), but the coordinates will be
|
||||
* reported relative to the top-left of the desktop. This can be useful if you
|
||||
* need to track the mouse outside of a specific window and SDL_CaptureMouse()
|
||||
* doesn't fit your needs. For example, it could be useful if you need to
|
||||
* track the mouse while dragging a window, where coordinates relative to a
|
||||
* window might not be in sync at all times.
|
||||
*
|
||||
* \note SDL_GetMouseState() returns the mouse position as SDL understands
|
||||
* it from the last pump of the event queue. This function, however,
|
||||
* queries the OS for the current mouse position, and as such, might
|
||||
* be a slightly less efficient function. Unless you know what you're
|
||||
* doing and have a good reason to use this function, you probably want
|
||||
* SDL_GetMouseState() instead.
|
||||
* Note: SDL_GetMouseState() returns the mouse position as SDL understands it
|
||||
* from the last pump of the event queue. This function, however, queries the
|
||||
* OS for the current mouse position, and as such, might be a slightly less
|
||||
* efficient function. Unless you know what you're doing and have a good
|
||||
* reason to use this function, you probably want SDL_GetMouseState() instead.
|
||||
*
|
||||
* \param x Returns the current X coord, relative to the desktop. Can be NULL.
|
||||
* \param y Returns the current Y coord, relative to the desktop. Can be NULL.
|
||||
* \return The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros.
|
||||
* \param x filled in with the current X coord relative to the desktop; can be
|
||||
* NULL
|
||||
* \param y filled in with the current Y coord relative to the desktop; can be
|
||||
* NULL
|
||||
* \returns the current button state as a bitmask which can be tested using
|
||||
* the SDL_BUTTON(X) macros.
|
||||
*
|
||||
* \sa SDL_GetMouseState
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*
|
||||
* \sa SDL_CaptureMouse
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the relative state of the mouse.
|
||||
* 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().
|
||||
* The current button state is returned as a button bitmask, which can be
|
||||
* tested using the `SDL_BUTTON(X)` macros (where `X` is generally 1 for the
|
||||
* left, 2 for middle, 3 for the right button), and `x` and `y` are set to the
|
||||
* mouse deltas since the last call to SDL_GetRelativeMouseState() or since
|
||||
* event initialization. You can pass NULL for either `x` or `y`.
|
||||
*
|
||||
* \param x a pointer filled with the last recorded x coordinate of the mouse
|
||||
* \param y a pointer filled with the last recorded y coordinate of the mouse
|
||||
* \returns a 32-bit button bitmask of the relative button state.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetMouseState
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Moves the mouse to the given position within the window.
|
||||
* Move the mouse cursor 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
|
||||
* This function generates a mouse motion event.
|
||||
*
|
||||
* \note This function generates a mouse motion event
|
||||
* Note that this function will appear to succeed, but not actually move the
|
||||
* mouse when used over Microsoft Remote Desktop.
|
||||
*
|
||||
* \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
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_WarpMouseGlobal
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
|
||||
int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Moves the mouse to the given position in global screen space.
|
||||
* Move the mouse to the given position in global screen space.
|
||||
*
|
||||
* \param x The x coordinate
|
||||
* \param y The y coordinate
|
||||
* \return 0 on success, -1 on error (usually: unsupported by a platform).
|
||||
* This function generates a mouse motion event.
|
||||
*
|
||||
* \note This function generates a mouse motion event
|
||||
* A failure of this function usually means that it is unsupported by a
|
||||
* platform.
|
||||
*
|
||||
* Note that this function will appear to succeed, but not actually move the
|
||||
* mouse when used over Microsoft Remote Desktop.
|
||||
*
|
||||
* \param x the x coordinate
|
||||
* \param y the y coordinate
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*
|
||||
* \sa SDL_WarpMouseInWindow
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Set relative mouse mode.
|
||||
* Set relative mouse mode.
|
||||
*
|
||||
* \param enabled Whether or not to enable relative mode
|
||||
* 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.
|
||||
*
|
||||
* \return 0 on success, or -1 if relative mode is not supported.
|
||||
* Note that this function will not be able to provide continuous relative
|
||||
* motion when used over Microsoft Remote Desktop, instead motion is limited
|
||||
* to the bounds of the screen.
|
||||
*
|
||||
* 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.
|
||||
* This function will flush any pending mouse motion.
|
||||
*
|
||||
* \note This function will flush any pending mouse motion.
|
||||
* \param enabled SDL_TRUE to enable relative mode, SDL_FALSE to disable.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_GetRelativeMouseMode()
|
||||
* If relative mode is not supported, this returns -1.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetRelativeMouseMode
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* \brief Capture the mouse, to track input outside an SDL window.
|
||||
* Capture the mouse and to track input outside an SDL window.
|
||||
*
|
||||
* \param enabled Whether or not to enable capturing
|
||||
* Capturing enables your app to obtain mouse events globally, instead of just
|
||||
* within your window. Not all video targets support this function. When
|
||||
* capturing is enabled, the current window will get all mouse events, but
|
||||
* unlike relative mode, no change is made to the cursor and it is not
|
||||
* restrained to your window.
|
||||
*
|
||||
* Capturing enables your app to obtain mouse events globally, instead of
|
||||
* just within your window. Not all video targets support this function.
|
||||
* When capturing is enabled, the current window will get all mouse events,
|
||||
* but unlike relative mode, no change is made to the cursor and it is
|
||||
* not restrained to your window.
|
||||
* This function may also deny mouse input to other windows--both those in
|
||||
* your application and others on the system--so you should use this function
|
||||
* sparingly, and in small bursts. For example, you might want to track the
|
||||
* mouse while the user is dragging something, until the user releases a mouse
|
||||
* button. It is not recommended that you capture the mouse for long periods
|
||||
* of time, such as the entire time your app is running. For that, you should
|
||||
* probably use SDL_SetRelativeMouseMode() or SDL_SetWindowGrab(), depending
|
||||
* on your goals.
|
||||
*
|
||||
* This function may also deny mouse input to other windows--both those in
|
||||
* your application and others on the system--so you should use this
|
||||
* function sparingly, and in small bursts. For example, you might want to
|
||||
* track the mouse while the user is dragging something, until the user
|
||||
* releases a mouse button. It is not recommended that you capture the mouse
|
||||
* for long periods of time, such as the entire time your app is running.
|
||||
* While captured, mouse events still report coordinates relative to the
|
||||
* current (foreground) window, but those coordinates may be outside the
|
||||
* bounds of the window (including negative values). Capturing is only allowed
|
||||
* for the foreground window. If the window loses focus while capturing, the
|
||||
* capture will be disabled automatically.
|
||||
*
|
||||
* While captured, mouse events still report coordinates relative to the
|
||||
* current (foreground) window, but those coordinates may be outside the
|
||||
* bounds of the window (including negative values). Capturing is only
|
||||
* allowed for the foreground window. If the window loses focus while
|
||||
* capturing, the capture will be disabled automatically.
|
||||
* While capturing is enabled, the current window will have the
|
||||
* `SDL_WINDOW_MOUSE_CAPTURE` flag set.
|
||||
*
|
||||
* While capturing is enabled, the current window will have the
|
||||
* SDL_WINDOW_MOUSE_CAPTURE flag set.
|
||||
* \param enabled SDL_TRUE to enable capturing, SDL_FALSE to disable.
|
||||
* \returns 0 on success or -1 if not supported; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \return 0 on success, or -1 if not supported.
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*
|
||||
* \sa SDL_GetGlobalMouseState
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* \brief Query whether relative mouse mode is enabled.
|
||||
* Query whether relative mouse mode is enabled.
|
||||
*
|
||||
* \sa SDL_SetRelativeMouseMode()
|
||||
* \returns SDL_TRUE if relative mode is enabled or SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \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).
|
||||
* Create a cursor using the specified bitmap data and mask (in MSB format).
|
||||
*
|
||||
* The cursor width must be a multiple of 8 bits.
|
||||
* `mask` has to be in MSB (Most Significant Bit) format.
|
||||
*
|
||||
* 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>
|
||||
* The cursor width (`w`) must be a multiple of 8 bits.
|
||||
*
|
||||
* \sa SDL_FreeCursor()
|
||||
* The cursor is created in black and white according to the following:
|
||||
*
|
||||
* - data=0, mask=1: white
|
||||
* - data=1, mask=1: black
|
||||
* - data=0, mask=0: transparent
|
||||
* - data=1, mask=0: inverted color if possible, black if not.
|
||||
*
|
||||
* Cursors created with this function must be freed with SDL_FreeCursor().
|
||||
*
|
||||
* If you want to have a color cursor, or create your cursor from an
|
||||
* SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can
|
||||
* hide the cursor and draw your own as part of your game's rendering, but it
|
||||
* will be bound to the framerate.
|
||||
*
|
||||
* Also, since SDL 2.0.0, SDL_CreateSystemCursor() is available, which
|
||||
* provides twelve readily available system cursors to pick from.
|
||||
*
|
||||
* \param data the color value for each pixel of the cursor
|
||||
* \param mask the mask value for each pixel of the cursor
|
||||
* \param w the width of the cursor
|
||||
* \param h the height of the cursor
|
||||
* \param hot_x the X-axis location of the upper left corner of the cursor
|
||||
* relative to the actual mouse position
|
||||
* \param hot_y the Y-axis location of the upper left corner of the cursor
|
||||
* relative to the actual mouse position
|
||||
* \returns a new cursor with the specified parameters on success or NULL on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_FreeCursor
|
||||
* \sa SDL_SetCursor
|
||||
* \sa SDL_ShowCursor
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
|
||||
const Uint8 * mask,
|
||||
|
@ -223,60 +313,123 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
|
|||
int hot_y);
|
||||
|
||||
/**
|
||||
* \brief Create a color cursor.
|
||||
* Create a color cursor.
|
||||
*
|
||||
* \sa SDL_FreeCursor()
|
||||
* \param surface an SDL_Surface structure representing the cursor image
|
||||
* \param hot_x the x position of the cursor hot spot
|
||||
* \param hot_y the y position of the cursor hot spot
|
||||
* \returns the new cursor on success or NULL on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateCursor
|
||||
* \sa SDL_FreeCursor
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
|
||||
int hot_x,
|
||||
int hot_y);
|
||||
|
||||
/**
|
||||
* \brief Create a system cursor.
|
||||
* Create a system cursor.
|
||||
*
|
||||
* \sa SDL_FreeCursor()
|
||||
* \param id an SDL_SystemCursor enum value
|
||||
* \returns a cursor on success or NULL on failure; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_FreeCursor
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
|
||||
|
||||
/**
|
||||
* \brief Set the active cursor.
|
||||
* Set the active cursor.
|
||||
*
|
||||
* This function sets the currently active cursor to the specified one. If the
|
||||
* cursor is currently visible, the change will be immediately represented on
|
||||
* the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
|
||||
* this is desired for any reason.
|
||||
*
|
||||
* \param cursor a cursor to make active
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateCursor
|
||||
* \sa SDL_GetCursor
|
||||
* \sa SDL_ShowCursor
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
|
||||
|
||||
/**
|
||||
* \brief Return the active cursor.
|
||||
* Get the active cursor.
|
||||
*
|
||||
* This function returns a pointer to the current cursor which is owned by the
|
||||
* library. It is not necessary to free the cursor with SDL_FreeCursor().
|
||||
*
|
||||
* \returns the active cursor or NULL if there is no mouse.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_SetCursor
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
|
||||
|
||||
/**
|
||||
* \brief Return the default cursor.
|
||||
* Get the default cursor.
|
||||
*
|
||||
* \returns the default cursor on success or NULL on failure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSystemCursor
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
|
||||
|
||||
/**
|
||||
* \brief Frees a cursor created with SDL_CreateCursor() or similar functions.
|
||||
* Free a previously-created cursor.
|
||||
*
|
||||
* \sa SDL_CreateCursor()
|
||||
* \sa SDL_CreateColorCursor()
|
||||
* \sa SDL_CreateSystemCursor()
|
||||
* Use this function to free cursor resources created with SDL_CreateCursor(),
|
||||
* SDL_CreateColorCursor() or SDL_CreateSystemCursor().
|
||||
*
|
||||
* \param cursor the cursor to free
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateColorCursor
|
||||
* \sa SDL_CreateCursor
|
||||
* \sa SDL_CreateSystemCursor
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
|
||||
|
||||
/**
|
||||
* \brief Toggle whether or not the cursor is shown.
|
||||
* 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.
|
||||
* The cursor starts off displayed but can be turned off. Passing `SDL_ENABLE`
|
||||
* displays the cursor and passing `SDL_DISABLE` hides it.
|
||||
*
|
||||
* \return 1 if the cursor is shown, or 0 if the cursor is hidden.
|
||||
* The current state of the mouse cursor can be queried by passing
|
||||
* `SDL_QUERY`; either `SDL_DISABLE` or `SDL_ENABLE` will be returned.
|
||||
*
|
||||
* \param toggle `SDL_ENABLE` to show the cursor, `SDL_DISABLE` to hide it,
|
||||
* `SDL_QUERY` to query the current state without changing it.
|
||||
* \returns `SDL_ENABLE` if the cursor is shown, or `SDL_DISABLE` if the
|
||||
* cursor is hidden, or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateCursor
|
||||
* \sa SDL_SetCursor
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
|
@ -290,7 +443,6 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
|||
#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
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -59,38 +59,105 @@ struct SDL_mutex;
|
|||
typedef struct SDL_mutex SDL_mutex;
|
||||
|
||||
/**
|
||||
* Create a mutex, initialized unlocked.
|
||||
* Create a new mutex.
|
||||
*
|
||||
* All newly-created mutexes begin in the _unlocked_ state.
|
||||
*
|
||||
* Calls to SDL_LockMutex() will not return while the mutex is locked by
|
||||
* another thread. See SDL_TryLockMutex() to attempt to lock without blocking.
|
||||
*
|
||||
* SDL mutexes are reentrant.
|
||||
*
|
||||
* \returns the initialized and unlocked mutex or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_DestroyMutex
|
||||
* \sa SDL_LockMutex
|
||||
* \sa SDL_TryLockMutex
|
||||
* \sa SDL_UnlockMutex
|
||||
*/
|
||||
extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
|
||||
|
||||
/**
|
||||
* Lock the mutex.
|
||||
* Lock the mutex.
|
||||
*
|
||||
* \return 0, or -1 on error.
|
||||
* This will block until the mutex is available, which is to say it is in the
|
||||
* unlocked state and the OS has chosen the caller as the next thread to lock
|
||||
* it. Of all threads waiting to lock the mutex, only one may do so at a time.
|
||||
*
|
||||
* It is legal for the owning thread to lock an already-locked mutex. It must
|
||||
* unlock it the same number of times before it is actually made available for
|
||||
* other threads in the system (this is known as a "recursive mutex").
|
||||
*
|
||||
* \param mutex the mutex to lock
|
||||
* \return 0, or -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
#define SDL_mutexP(m) SDL_LockMutex(m)
|
||||
extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
|
||||
#define SDL_mutexP(m) SDL_LockMutex(m)
|
||||
|
||||
/**
|
||||
* Try to lock the mutex
|
||||
* Try to lock a mutex without blocking.
|
||||
*
|
||||
* \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error
|
||||
* This works just like SDL_LockMutex(), but if the mutex is not available,
|
||||
* this function returns `SDL_MUTEX_TIMEOUT` immediately.
|
||||
*
|
||||
* This technique is useful if you need exclusive access to a resource but
|
||||
* don't want to wait for it, and will return to it to try again later.
|
||||
*
|
||||
* \param mutex the mutex to try to lock
|
||||
* \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateMutex
|
||||
* \sa SDL_DestroyMutex
|
||||
* \sa SDL_LockMutex
|
||||
* \sa SDL_UnlockMutex
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
|
||||
|
||||
/**
|
||||
* Unlock the mutex.
|
||||
* Unlock the mutex.
|
||||
*
|
||||
* \return 0, or -1 on error.
|
||||
* It is legal for the owning thread to lock an already-locked mutex. It must
|
||||
* unlock it the same number of times before it is actually made available for
|
||||
* other threads in the system (this is known as a "recursive mutex").
|
||||
*
|
||||
* \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.
|
||||
* It is an error to unlock a mutex that has not been locked by the current
|
||||
* thread, and doing so results in undefined behavior.
|
||||
*
|
||||
* It is also an error to unlock a mutex that isn't locked at all.
|
||||
*
|
||||
* \param mutex the mutex to unlock.
|
||||
* \returns 0, or -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
#define SDL_mutexV(m) SDL_UnlockMutex(m)
|
||||
extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
|
||||
#define SDL_mutexV(m) SDL_UnlockMutex(m)
|
||||
|
||||
/**
|
||||
* Destroy a mutex.
|
||||
* Destroy a mutex created with SDL_CreateMutex().
|
||||
*
|
||||
* This function must be called on any mutex that is no longer needed. Failure
|
||||
* to destroy a mutex will result in a system memory or resource leak. While
|
||||
* it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt
|
||||
* to destroy a locked mutex, and may result in undefined behavior depending
|
||||
* on the platform.
|
||||
*
|
||||
* \param mutex the mutex to destroy
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateMutex
|
||||
* \sa SDL_LockMutex
|
||||
* \sa SDL_TryLockMutex
|
||||
* \sa SDL_UnlockMutex
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
|
||||
|
||||
|
@ -107,50 +174,151 @@ struct SDL_semaphore;
|
|||
typedef struct SDL_semaphore SDL_sem;
|
||||
|
||||
/**
|
||||
* Create a semaphore, initialized with value, returns NULL on failure.
|
||||
* Create a semaphore.
|
||||
*
|
||||
* This function creates a new semaphore and initializes it with the value
|
||||
* `initial_value`. Each wait operation on the semaphore will atomically
|
||||
* decrement the semaphore value and potentially block if the semaphore value
|
||||
* is 0. Each post operation will atomically increment the semaphore value and
|
||||
* wake waiting threads and allow them to retry the wait operation.
|
||||
*
|
||||
* \param initial_value the starting value of the semaphore
|
||||
* \returns a new semaphore or NULL on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_DestroySemaphore
|
||||
* \sa SDL_SemPost
|
||||
* \sa SDL_SemTryWait
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
* \sa SDL_SemWaitTimeout
|
||||
*/
|
||||
extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
|
||||
|
||||
/**
|
||||
* Destroy a semaphore.
|
||||
* Destroy a semaphore.
|
||||
*
|
||||
* It is not safe to destroy a semaphore if there are threads currently
|
||||
* waiting on it.
|
||||
*
|
||||
* \param sem the semaphore to destroy
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSemaphore
|
||||
* \sa SDL_SemPost
|
||||
* \sa SDL_SemTryWait
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
* \sa SDL_SemWaitTimeout
|
||||
*/
|
||||
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.
|
||||
* Wait until a semaphore has a positive value and then decrements it.
|
||||
*
|
||||
* This function suspends the calling thread until either the semaphore
|
||||
* pointed to by `sem` has a positive value or the call is interrupted by a
|
||||
* signal or error. If the call is successful it will atomically decrement the
|
||||
* semaphore value.
|
||||
*
|
||||
* This function is the equivalent of calling SDL_SemWaitTimeout() with a time
|
||||
* length of `SDL_MUTEX_MAXWAIT`.
|
||||
*
|
||||
* \param sem the semaphore wait on
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSemaphore
|
||||
* \sa SDL_DestroySemaphore
|
||||
* \sa SDL_SemPost
|
||||
* \sa SDL_SemTryWait
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
* \sa SDL_SemWaitTimeout
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* Non-blocking variant of SDL_SemWait().
|
||||
* See if a semaphore has a positive value and decrement it if it does.
|
||||
*
|
||||
* \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would
|
||||
* block, and -1 on error.
|
||||
* This function checks to see if the semaphore pointed to by `sem` has a
|
||||
* positive value and atomically decrements the semaphore value if it does. If
|
||||
* the semaphore doesn't have a positive value, the function immediately
|
||||
* returns SDL_MUTEX_TIMEDOUT.
|
||||
*
|
||||
* \param sem the semaphore to wait on
|
||||
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would
|
||||
* block, or a negative error code on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSemaphore
|
||||
* \sa SDL_DestroySemaphore
|
||||
* \sa SDL_SemPost
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
* \sa SDL_SemWaitTimeout
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* Variant of SDL_SemWait() with a timeout in milliseconds.
|
||||
* Wait until a semaphore has a positive value and then decrements it.
|
||||
*
|
||||
* \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not
|
||||
* succeed in the allotted time, and -1 on error.
|
||||
* This function suspends the calling thread until either the semaphore
|
||||
* pointed to by `sem` has a positive value, the call is interrupted by a
|
||||
* signal or error, or the specified time has elapsed. If the call is
|
||||
* successful it will atomically decrement the semaphore value.
|
||||
*
|
||||
* \warning On some platforms this function is implemented by looping with a
|
||||
* delay of 1 ms, and so should be avoided if possible.
|
||||
* \param sem the semaphore to wait on
|
||||
* \param ms the length of the timeout, in milliseconds
|
||||
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
|
||||
* succeed in the allotted time, or a negative error code on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSemaphore
|
||||
* \sa SDL_DestroySemaphore
|
||||
* \sa SDL_SemPost
|
||||
* \sa SDL_SemTryWait
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
|
||||
|
||||
/**
|
||||
* Atomically increases the semaphore's count (not blocking).
|
||||
* Atomically increment a semaphore's value and wake waiting threads.
|
||||
*
|
||||
* \return 0, or -1 on error.
|
||||
* \param sem the semaphore to increment
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSemaphore
|
||||
* \sa SDL_DestroySemaphore
|
||||
* \sa SDL_SemTryWait
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
* \sa SDL_SemWaitTimeout
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
|
||||
|
||||
/**
|
||||
* Returns the current count of the semaphore.
|
||||
* Get the current value of a semaphore.
|
||||
*
|
||||
* \param sem the semaphore to query
|
||||
* \returns the current value of the semaphore.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateSemaphore
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
|
||||
|
||||
|
@ -167,72 +335,124 @@ struct SDL_cond;
|
|||
typedef struct SDL_cond SDL_cond;
|
||||
|
||||
/**
|
||||
* Create a condition variable.
|
||||
* Create a condition variable.
|
||||
*
|
||||
* Typical use of condition variables:
|
||||
* \returns a new condition variable or NULL on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* Thread A:
|
||||
* SDL_LockMutex(lock);
|
||||
* while ( ! condition ) {
|
||||
* SDL_CondWait(cond, lock);
|
||||
* }
|
||||
* SDL_UnlockMutex(lock);
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* 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.
|
||||
* \sa SDL_CondBroadcast
|
||||
* \sa SDL_CondSignal
|
||||
* \sa SDL_CondWait
|
||||
* \sa SDL_CondWaitTimeout
|
||||
* \sa SDL_DestroyCond
|
||||
*/
|
||||
extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
|
||||
|
||||
/**
|
||||
* Destroy a condition variable.
|
||||
* Destroy a condition variable.
|
||||
*
|
||||
* \param cond the condition variable to destroy
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CondBroadcast
|
||||
* \sa SDL_CondSignal
|
||||
* \sa SDL_CondWait
|
||||
* \sa SDL_CondWaitTimeout
|
||||
* \sa SDL_CreateCond
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
|
||||
|
||||
/**
|
||||
* Restart one of the threads that are waiting on the condition variable.
|
||||
* Restart one of the threads that are waiting on the condition variable.
|
||||
*
|
||||
* \return 0 or -1 on error.
|
||||
* \param cond the condition variable to signal
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CondBroadcast
|
||||
* \sa SDL_CondWait
|
||||
* \sa SDL_CondWaitTimeout
|
||||
* \sa SDL_CreateCond
|
||||
* \sa SDL_DestroyCond
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
|
||||
|
||||
/**
|
||||
* Restart all threads that are waiting on the condition variable.
|
||||
* Restart all threads that are waiting on the condition variable.
|
||||
*
|
||||
* \return 0 or -1 on error.
|
||||
* \param cond the condition variable to signal
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CondSignal
|
||||
* \sa SDL_CondWait
|
||||
* \sa SDL_CondWaitTimeout
|
||||
* \sa SDL_CreateCond
|
||||
* \sa SDL_DestroyCond
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
|
||||
|
||||
/**
|
||||
* Wait on the condition variable, unlocking the provided mutex.
|
||||
* Wait until a condition variable is signaled.
|
||||
*
|
||||
* \warning The mutex must be locked before entering this function!
|
||||
* This function unlocks the specified `mutex` and waits for another thread to
|
||||
* call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
|
||||
* `cond`. Once the condition variable is signaled, the mutex is re-locked and
|
||||
* the function returns.
|
||||
*
|
||||
* The mutex is re-locked once the condition variable is signaled.
|
||||
* The mutex must be locked before calling this function.
|
||||
*
|
||||
* \return 0 when it is signaled, or -1 on error.
|
||||
* This function is the equivalent of calling SDL_CondWaitTimeout() with a
|
||||
* time length of `SDL_MUTEX_MAXWAIT`.
|
||||
*
|
||||
* \param cond the condition variable to wait on
|
||||
* \param mutex the mutex used to coordinate thread access
|
||||
* \returns 0 when it is signaled or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CondBroadcast
|
||||
* \sa SDL_CondSignal
|
||||
* \sa SDL_CondWaitTimeout
|
||||
* \sa SDL_CreateCond
|
||||
* \sa SDL_DestroyCond
|
||||
*/
|
||||
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.
|
||||
* Wait until a condition variable is signaled or a certain time has passed.
|
||||
*
|
||||
* \warning On some platforms this function is implemented by looping with a
|
||||
* delay of 1 ms, and so should be avoided if possible.
|
||||
* This function unlocks the specified `mutex` and waits for another thread to
|
||||
* call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable
|
||||
* `cond`, or for the specified time to elapse. Once the condition variable is
|
||||
* signaled or the time elapsed, the mutex is re-locked and the function
|
||||
* returns.
|
||||
*
|
||||
* The mutex must be locked before calling this function.
|
||||
*
|
||||
* \param cond the condition variable to wait on
|
||||
* \param mutex the mutex used to coordinate thread access
|
||||
* \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT`
|
||||
* to wait indefinitely
|
||||
* \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
|
||||
* the condition is not signaled in the allotted time, or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CondBroadcast
|
||||
* \sa SDL_CondSignal
|
||||
* \sa SDL_CondWait
|
||||
* \sa SDL_CreateCond
|
||||
* \sa SDL_DestroyCond
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
|
||||
SDL_mutex * mutex, Uint32 ms);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
|
|
@ -40,6 +40,9 @@ extern "C" {
|
|||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#ifndef NOMINMAX /* don't define min() and max(). */
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS)
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -48,7 +48,7 @@ extern "C" {
|
|||
/* @} */
|
||||
|
||||
/** Pixel type. */
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_PIXELTYPE_UNKNOWN,
|
||||
SDL_PIXELTYPE_INDEX1,
|
||||
|
@ -62,18 +62,18 @@ enum
|
|||
SDL_PIXELTYPE_ARRAYU32,
|
||||
SDL_PIXELTYPE_ARRAYF16,
|
||||
SDL_PIXELTYPE_ARRAYF32
|
||||
};
|
||||
} SDL_PixelType;
|
||||
|
||||
/** Bitmap pixel order, high bit -> low bit. */
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_BITMAPORDER_NONE,
|
||||
SDL_BITMAPORDER_4321,
|
||||
SDL_BITMAPORDER_1234
|
||||
};
|
||||
} SDL_BitmapOrder;
|
||||
|
||||
/** Packed component order, high bit -> low bit. */
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_PACKEDORDER_NONE,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
|
@ -84,12 +84,12 @@ enum
|
|||
SDL_PACKEDORDER_BGRX,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDORDER_BGRA
|
||||
};
|
||||
} SDL_PackedOrder;
|
||||
|
||||
/** Array component order, low byte -> high byte. */
|
||||
/* !!! FIXME: in 2.1, make these not overlap differently with
|
||||
!!! FIXME: SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_ARRAYORDER_NONE,
|
||||
SDL_ARRAYORDER_RGB,
|
||||
|
@ -98,10 +98,10 @@ enum
|
|||
SDL_ARRAYORDER_BGR,
|
||||
SDL_ARRAYORDER_BGRA,
|
||||
SDL_ARRAYORDER_ABGR
|
||||
};
|
||||
} SDL_ArrayOrder;
|
||||
|
||||
/** Packed component layout. */
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_PACKEDLAYOUT_NONE,
|
||||
SDL_PACKEDLAYOUT_332,
|
||||
|
@ -112,7 +112,7 @@ enum
|
|||
SDL_PACKEDLAYOUT_8888,
|
||||
SDL_PACKEDLAYOUT_2101010,
|
||||
SDL_PACKEDLAYOUT_1010102
|
||||
};
|
||||
} SDL_PackedLayout;
|
||||
|
||||
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
|
||||
|
||||
|
@ -188,15 +188,22 @@ typedef enum
|
|||
SDL_PIXELFORMAT_RGB332 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_332, 8, 1),
|
||||
SDL_PIXELFORMAT_RGB444 =
|
||||
SDL_PIXELFORMAT_XRGB4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_4444, 12, 2),
|
||||
SDL_PIXELFORMAT_RGB555 =
|
||||
SDL_PIXELFORMAT_RGB444 = SDL_PIXELFORMAT_XRGB4444,
|
||||
SDL_PIXELFORMAT_XBGR4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_4444, 12, 2),
|
||||
SDL_PIXELFORMAT_BGR444 = SDL_PIXELFORMAT_XBGR4444,
|
||||
SDL_PIXELFORMAT_XRGB1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_BGR555 =
|
||||
SDL_PIXELFORMAT_RGB555 = SDL_PIXELFORMAT_XRGB1555,
|
||||
SDL_PIXELFORMAT_XBGR1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_BGR555 = SDL_PIXELFORMAT_XBGR1555,
|
||||
SDL_PIXELFORMAT_ARGB4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
|
@ -233,15 +240,17 @@ typedef enum
|
|||
SDL_PIXELFORMAT_BGR24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
|
||||
24, 3),
|
||||
SDL_PIXELFORMAT_RGB888 =
|
||||
SDL_PIXELFORMAT_XRGB8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_RGB888 = SDL_PIXELFORMAT_XRGB8888,
|
||||
SDL_PIXELFORMAT_RGBX8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_BGR888 =
|
||||
SDL_PIXELFORMAT_XBGR8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_BGR888 = SDL_PIXELFORMAT_XBGR8888,
|
||||
SDL_PIXELFORMAT_BGRX8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
|
@ -292,6 +301,11 @@ typedef enum
|
|||
SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
|
||||
} SDL_PixelFormatEnum;
|
||||
|
||||
/**
|
||||
* The bits of this structure can be directly reinterpreted as an integer-packed
|
||||
* color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888
|
||||
* on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
|
||||
*/
|
||||
typedef struct SDL_Color
|
||||
{
|
||||
Uint8 r;
|
||||
|
@ -336,16 +350,31 @@ typedef struct SDL_PixelFormat
|
|||
} SDL_PixelFormat;
|
||||
|
||||
/**
|
||||
* \brief Get the human readable name of a pixel format
|
||||
* Get the human readable name of a pixel format.
|
||||
*
|
||||
* \param format the pixel format to query
|
||||
* \returns the human readable name of the specified pixel format or
|
||||
* `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
|
||||
|
||||
/**
|
||||
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
|
||||
* Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
|
||||
*
|
||||
* \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
|
||||
* \param format one of the SDL_PixelFormatEnum values
|
||||
* \param bpp a bits per pixel value; usually 15, 16, or 32
|
||||
* \param Rmask a pointer filled in with the red mask for the format
|
||||
* \param Gmask a pointer filled in with the green mask for the format
|
||||
* \param Bmask a pointer filled in with the blue mask for the format
|
||||
* \param Amask a pointer filled in with the alpha mask for the format
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
|
||||
* possible; call SDL_GetError() for more information.
|
||||
*
|
||||
* \sa SDL_MasksToPixelFormatEnum()
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_MasksToPixelFormatEnum
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
|
||||
int *bpp,
|
||||
|
@ -355,12 +384,21 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
|
|||
Uint32 * Amask);
|
||||
|
||||
/**
|
||||
* \brief Convert a bpp and RGBA masks to an enumerated pixel format.
|
||||
* Convert a bpp value and RGBA masks to an enumerated pixel format.
|
||||
*
|
||||
* \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion
|
||||
* wasn't possible.
|
||||
* This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
|
||||
* possible.
|
||||
*
|
||||
* \sa SDL_PixelFormatEnumToMasks()
|
||||
* \param bpp a bits per pixel value; usually 15, 16, or 32
|
||||
* \param Rmask the red mask for the format
|
||||
* \param Gmask the green mask for the format
|
||||
* \param Bmask the blue mask for the format
|
||||
* \param Amask the alpha mask for the format
|
||||
* \returns one of the SDL_PixelFormatEnum values
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_PixelFormatEnumToMasks
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
|
||||
Uint32 Rmask,
|
||||
|
@ -369,84 +407,213 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
|
|||
Uint32 Amask);
|
||||
|
||||
/**
|
||||
* \brief Create an SDL_PixelFormat structure from a pixel format enum.
|
||||
* Create an SDL_PixelFormat structure corresponding to a pixel format.
|
||||
*
|
||||
* Returned structure may come from a shared global cache (i.e. not newly
|
||||
* allocated), and hence should not be modified, especially the palette. Weird
|
||||
* errors such as `Blit combination not supported` may occur.
|
||||
*
|
||||
* \param pixel_format one of the SDL_PixelFormatEnum values
|
||||
* \returns the new SDL_PixelFormat structure or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_FreeFormat
|
||||
*/
|
||||
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
|
||||
|
||||
/**
|
||||
* \brief Free an SDL_PixelFormat structure.
|
||||
* Free an SDL_PixelFormat structure allocated by SDL_AllocFormat().
|
||||
*
|
||||
* \param format the SDL_PixelFormat structure to free
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AllocFormat
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
|
||||
|
||||
/**
|
||||
* \brief Create a palette structure with the specified number of color
|
||||
* entries.
|
||||
* Create a palette structure with the specified number of color entries.
|
||||
*
|
||||
* \return A new palette, or NULL if there wasn't enough memory.
|
||||
* The palette entries are initialized to white.
|
||||
*
|
||||
* \note The palette entries are initialized to white.
|
||||
* \param ncolors represents the number of color entries in the color palette
|
||||
* \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
|
||||
* there wasn't enough memory); call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \sa SDL_FreePalette()
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_FreePalette
|
||||
*/
|
||||
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
|
||||
|
||||
/**
|
||||
* \brief Set the palette for a pixel format structure.
|
||||
* Set the palette for a pixel format structure.
|
||||
*
|
||||
* \param format the SDL_PixelFormat structure that will use the palette
|
||||
* \param palette the SDL_Palette structure that will be used
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AllocPalette
|
||||
* \sa SDL_FreePalette
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
|
||||
SDL_Palette *palette);
|
||||
|
||||
/**
|
||||
* \brief Set a range of colors in a palette.
|
||||
* 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.
|
||||
* \param palette the SDL_Palette structure to modify
|
||||
* \param colors an array of SDL_Color structures to copy into the palette
|
||||
* \param firstcolor the index of the first palette entry to modify
|
||||
* \param ncolors the number of entries to modify
|
||||
* \returns 0 on success or a negative error code if not all of the colors
|
||||
* could be set; call SDL_GetError() for more information.
|
||||
*
|
||||
* \return 0 on success, or -1 if not all of the colors could be set.
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_AllocPalette
|
||||
* \sa SDL_CreateRGBSurface
|
||||
*/
|
||||
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().
|
||||
* Free a palette created with SDL_AllocPalette().
|
||||
*
|
||||
* \sa SDL_AllocPalette()
|
||||
* \param palette the SDL_Palette structure to be freed
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \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.
|
||||
* Map an RGB triple to an opaque pixel value for a given pixel format.
|
||||
*
|
||||
* \sa SDL_MapRGBA
|
||||
* This function maps the RGB color value to the specified pixel format and
|
||||
* returns the pixel value best approximating the given RGB color value for
|
||||
* the given pixel format.
|
||||
*
|
||||
* If the format has a palette (8-bit) the index of the closest matching color
|
||||
* in the palette will be returned.
|
||||
*
|
||||
* If the specified pixel format has an alpha component it will be returned as
|
||||
* all 1 bits (fully opaque).
|
||||
*
|
||||
* If the pixel format bpp (color depth) is less than 32-bpp then the unused
|
||||
* upper bits of the return value can safely be ignored (e.g., with a 16-bpp
|
||||
* format the return value can be assigned to a Uint16, and similarly a Uint8
|
||||
* for an 8-bpp format).
|
||||
*
|
||||
* \param format an SDL_PixelFormat structure describing the pixel format
|
||||
* \param r the red component of the pixel in the range 0-255
|
||||
* \param g the green component of the pixel in the range 0-255
|
||||
* \param b the blue component of the pixel in the range 0-255
|
||||
* \returns a pixel value
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
* \sa SDL_GetRGBA
|
||||
* \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.
|
||||
* Map an RGBA quadruple to a pixel value for a given pixel format.
|
||||
*
|
||||
* \sa SDL_MapRGB
|
||||
* This function maps the RGBA color value to the specified pixel format and
|
||||
* returns the pixel value best approximating the given RGBA color value for
|
||||
* the given pixel format.
|
||||
*
|
||||
* If the specified pixel format has no alpha component the alpha value will
|
||||
* be ignored (as it will be in formats with a palette).
|
||||
*
|
||||
* If the format has a palette (8-bit) the index of the closest matching color
|
||||
* in the palette will be returned.
|
||||
*
|
||||
* If the pixel format bpp (color depth) is less than 32-bpp then the unused
|
||||
* upper bits of the return value can safely be ignored (e.g., with a 16-bpp
|
||||
* format the return value can be assigned to a Uint16, and similarly a Uint8
|
||||
* for an 8-bpp format).
|
||||
*
|
||||
* \param format an SDL_PixelFormat structure describing the format of the
|
||||
* pixel
|
||||
* \param r the red component of the pixel in the range 0-255
|
||||
* \param g the green component of the pixel in the range 0-255
|
||||
* \param b the blue component of the pixel in the range 0-255
|
||||
* \param a the alpha component of the pixel in the range 0-255
|
||||
* \returns a pixel value
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
* \sa SDL_GetRGBA
|
||||
* \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.
|
||||
* Get RGB values from a pixel in the specified format.
|
||||
*
|
||||
* \sa SDL_GetRGBA
|
||||
* This function uses the entire 8-bit [0..255] range when converting color
|
||||
* components from pixel formats with less than 8-bits per RGB component
|
||||
* (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
|
||||
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
|
||||
*
|
||||
* \param pixel a pixel value
|
||||
* \param format an SDL_PixelFormat structure describing the format of the
|
||||
* pixel
|
||||
* \param r a pointer filled in with the red component
|
||||
* \param g a pointer filled in with the green component
|
||||
* \param b a pointer filled in with the blue component
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetRGBA
|
||||
* \sa SDL_MapRGB
|
||||
* \sa SDL_MapRGBA
|
||||
*/
|
||||
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.
|
||||
* Get RGBA values from a pixel in the specified format.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
* This function uses the entire 8-bit [0..255] range when converting color
|
||||
* components from pixel formats with less than 8-bits per RGB component
|
||||
* (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
|
||||
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
|
||||
*
|
||||
* If the surface has no alpha component, the alpha will be returned as 0xff
|
||||
* (100% opaque).
|
||||
*
|
||||
* \param pixel a pixel value
|
||||
* \param format an SDL_PixelFormat structure describing the format of the
|
||||
* pixel
|
||||
* \param r a pointer filled in with the red component
|
||||
* \param g a pointer filled in with the green component
|
||||
* \param b a pointer filled in with the blue component
|
||||
* \param a a pointer filled in with the alpha component
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
* \sa SDL_MapRGB
|
||||
* \sa SDL_MapRGBA
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
|
@ -454,7 +621,14 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
|||
Uint8 * a);
|
||||
|
||||
/**
|
||||
* \brief Calculate a 256 entry gamma ramp for a gamma value.
|
||||
* Calculate a 256 entry gamma ramp for a gamma value.
|
||||
*
|
||||
* \param gamma a gamma value where 0.0 is black and 1.0 is identity
|
||||
* \param ramp an array of 256 values filled in with the gamma ramp
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_SetWindowGammaRamp
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -70,6 +70,27 @@
|
|||
/* lets us know what version of Mac OS X we're compiling on */
|
||||
#include "AvailabilityMacros.h"
|
||||
#include "TargetConditionals.h"
|
||||
|
||||
/* Fix building with older SDKs that don't define these
|
||||
See this for more information:
|
||||
https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
|
||||
*/
|
||||
#ifndef TARGET_OS_MACCATALYST
|
||||
#define TARGET_OS_MACCATALYST 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_IOS
|
||||
#define TARGET_OS_IOS 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_IPHONE
|
||||
#define TARGET_OS_IPHONE 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_TV
|
||||
#define TARGET_OS_TV 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_SIMULATOR
|
||||
#define TARGET_OS_SIMULATOR 0
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_TV
|
||||
#undef __TVOS__
|
||||
#define __TVOS__ 1
|
||||
|
@ -175,6 +196,9 @@
|
|||
#define __SDL_NOGETPROCADDR__
|
||||
#endif
|
||||
|
||||
#if defined(__vita__)
|
||||
#define __VITA__ 1
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
|
@ -183,7 +207,20 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* \brief Gets the name of the platform.
|
||||
* Get the name of the platform.
|
||||
*
|
||||
* Here are the names returned for some (but not all) supported platforms:
|
||||
*
|
||||
* - "Windows"
|
||||
* - "Mac OS X"
|
||||
* - "Linux"
|
||||
* - "iOS"
|
||||
* - "Android"
|
||||
*
|
||||
* \returns the name of the platform. If the correct platform name is not
|
||||
* available, returns a string beginning with the text "Unknown".
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* \brief The basic state for the system's power supply.
|
||||
* The basic state for the system's power supply.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -50,17 +50,30 @@ typedef enum
|
|||
|
||||
|
||||
/**
|
||||
* \brief Get the current power supply details.
|
||||
* 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.
|
||||
* You should never take a battery status as absolute truth. Batteries
|
||||
* (especially failing batteries) are delicate hardware, and the values
|
||||
* reported here are best estimates based on what that hardware reports. It's
|
||||
* not uncommon for older batteries to lose stored power much faster than it
|
||||
* reports, or completely drain when reporting it has 20 percent left, etc.
|
||||
*
|
||||
* \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.
|
||||
* Battery status can change at any time; if you are concerned with power
|
||||
* state, you should call this function frequently, and perhaps ignore changes
|
||||
* until they seem to be stable for a few seconds.
|
||||
*
|
||||
* \return The state of the battery (if any).
|
||||
* It's possible a platform can only report battery percentage or time left
|
||||
* but not both.
|
||||
*
|
||||
* \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
|
||||
* \returns an SDL_PowerState enum representing the current battery state.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue