mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 04:42:18 -05:00
Merge remote-tracking branch 'upstream/develop-zhora' into feature/crowd-control
# Conflicts: # libultraship/libultraship/Lib/SDL/lib/x86/SDL2.lib # libultraship/libultraship/Lib/SDL/lib/x86/SDL2main.lib # soh/soh/Enhancements/debugconsole.cpp
This commit is contained in:
commit
b57e44afc9
29
BUILDING.md
29
BUILDING.md
@ -60,7 +60,7 @@ To build you'll need to follow the instructions from the building section.
|
|||||||
|
|
||||||
_Note: If you're using Visual Studio Code, the [cpack plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._
|
_Note: If you're using Visual Studio Code, the [cpack plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._
|
||||||
|
|
||||||
_Experimental: You can also use another build system entirely rathen than MSVC like [Ninja](https://ninja-build.org/) for possibly better performance._
|
_Experimental: You can also use another build system entirely rather than MSVC like [Ninja](https://ninja-build.org/) for possibly better performance._
|
||||||
|
|
||||||
|
|
||||||
### Generating the distributable
|
### Generating the distributable
|
||||||
@ -130,7 +130,11 @@ cmake --build build-cmake --target ExtractAssets
|
|||||||
# Compile the project
|
# Compile the project
|
||||||
cmake --build build-cmake # --config Release (if you're packaging)
|
cmake --build build-cmake # --config Release (if you're packaging)
|
||||||
|
|
||||||
# Now you can run the executable in ./build-cmake/soh/soh-macos
|
# Copy oot.otr into the Application Support directory
|
||||||
|
cp build-cmake/soh/oot.otr ~/Library/Application\ Support/com.shipofharkinian.soh/
|
||||||
|
|
||||||
|
# Now you can run the executable file:
|
||||||
|
./build-cmake/soh/soh-macos
|
||||||
# To develop the project open the repository in VSCode (or your preferred editor)
|
# To develop the project open the repository in VSCode (or your preferred editor)
|
||||||
|
|
||||||
# If you need to clean the project you can run
|
# If you need to clean the project you can run
|
||||||
@ -167,6 +171,27 @@ cmake --build build-switch --target soh_nro
|
|||||||
# To develop the project open the repository in VSCode (or your preferred editor)
|
# To develop the project open the repository in VSCode (or your preferred editor)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Wii U
|
||||||
|
1. Requires that your build machine is setup with the tools necessary for your platform above
|
||||||
|
2. Requires that you have the Wii U build tools installed
|
||||||
|
3. Clone the Ship of Harkinian repository
|
||||||
|
4. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd Shipwright
|
||||||
|
# Setup cmake project for your host machine
|
||||||
|
cmake -H. -Bbuild-cmake -GNinja
|
||||||
|
# Extract assets & generate OTR (run this anytime you need to regenerate OTR)
|
||||||
|
cmake --build build-cmake --target ExtractAssets
|
||||||
|
# Setup cmake project for building for Wii U
|
||||||
|
cmake -H. -Bbuild-wiiu -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/WiiU.cmake # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging)
|
||||||
|
# Build project and generate rpx
|
||||||
|
cmake --build build-wiiu --target soh
|
||||||
|
|
||||||
|
# Now you can run the executable in ./build-wiiu/soh/soh.rpx
|
||||||
|
# To develop the project open the repository in VSCode (or your preferred editor)
|
||||||
|
```
|
||||||
|
|
||||||
# Compatible Roms
|
# Compatible Roms
|
||||||
```
|
```
|
||||||
OOT_PAL_GC checksum 0x09465AC3
|
OOT_PAL_GC checksum 0x09465AC3
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/extract_assets.py filedata)
|
|
||||||
string(REGEX REPLACE "zapd_exe = .*exec_cmd =" "zapd_exe = \"${program}\"\n exec_cmd =" filedata "${filedata}")
|
|
||||||
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake2.py" "${filedata}")
|
|
||||||
file(CHMOD "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake2.py" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
|
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
|
||||||
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
|
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
|
||||||
@ -18,13 +18,13 @@ set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh)
|
|||||||
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
|
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
include(cmake/automate-vcpkg.cmake)
|
include(CMake/automate-vcpkg.cmake)
|
||||||
|
|
||||||
set(VCPKG_TRIPLET x64-windows-static)
|
set(VCPKG_TRIPLET x64-windows-static)
|
||||||
set(VCPKG_TARGET_TRIPLET x64-windows-static)
|
set(VCPKG_TARGET_TRIPLET x64-windows-static)
|
||||||
|
|
||||||
vcpkg_bootstrap()
|
vcpkg_bootstrap()
|
||||||
vcpkg_install_packages(zlib bzip2 libpng)
|
vcpkg_install_packages(zlib bzip2 libpng SDL2 GLEW glfw3)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -122,7 +122,7 @@ add_subdirectory(ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD)
|
|||||||
add_subdirectory(ZAPDTR/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils)
|
add_subdirectory(ZAPDTR/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils)
|
||||||
add_subdirectory(OTRExporter)
|
add_subdirectory(OTRExporter)
|
||||||
add_subdirectory(soh)
|
add_subdirectory(soh)
|
||||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|NintendoSwitch")
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|NintendoSwitch|CafeOS")
|
||||||
add_subdirectory(OTRGui)
|
add_subdirectory(OTRGui)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -131,22 +131,22 @@ set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/scri
|
|||||||
set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon.png")
|
set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon.png")
|
||||||
|
|
||||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
INSTALL(PROGRAMS "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.sh" DESTINATION . COMPONENT appimage)
|
install(PROGRAMS "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.sh" DESTINATION . COMPONENT appimage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Python3 COMPONENTS Interpreter)
|
find_package(Python3 COMPONENTS Interpreter)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
ExtractAssets
|
ExtractAssets
|
||||||
COMMAND ${CMAKE_COMMAND} -Dprogram=$<TARGET_FILE:ZAPD> -P ${CMAKE_SOURCE_DIR}/CMake/genscript.cmake
|
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
|
||||||
COMMAND ${CMAKE_COMMAND} -E rm -f oot.otr
|
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f oot.otr
|
||||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_SOURCE_DIR}
|
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_SOURCE_DIR}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_BINARY_DIR}/soh
|
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_BINARY_DIR}/soh
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
|
||||||
COMMENT "Running asset extraction..."
|
COMMENT "Running asset extraction..."
|
||||||
DEPENDS ZAPD
|
DEPENDS ZAPD
|
||||||
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py
|
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
@ -177,15 +177,38 @@ add_custom_target(CreateOSXIcons
|
|||||||
COMMENT "Creating OSX icons ..."
|
COMMENT "Creating OSX icons ..."
|
||||||
)
|
)
|
||||||
add_dependencies(soh CreateOSXIcons)
|
add_dependencies(soh CreateOSXIcons)
|
||||||
|
|
||||||
|
add_custom_target(Assets ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/OTRGui/assets/extractor" -Ddst_dir="${CMAKE_BINARY_DIR}/assets/extractor" -P "${CMAKE_SOURCE_DIR}/OTRGui/Overwrite.cmake"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/OTRExporter/assets" -Ddst_dir="${CMAKE_BINARY_DIR}/assets/game" -P "${CMAKE_SOURCE_DIR}/OTRGui/Overwrite.cmake"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/soh/assets/xml" -Ddst_dir="${CMAKE_BINARY_DIR}/assets/extractor/xmls" -P "${CMAKE_SOURCE_DIR}/OTRGui/Overwrite.cmake"
|
||||||
|
)
|
||||||
|
add_dependencies(soh Assets)
|
||||||
|
|
||||||
|
install(TARGETS ZAPD DESTINATION ${CMAKE_BINARY_DIR}/assets/extractor)
|
||||||
|
|
||||||
|
set(PROGRAM_PERMISSIONS_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/assets
|
||||||
|
DESTINATION .
|
||||||
|
PATTERN ZAPD.out
|
||||||
|
PERMISSIONS ${PROGRAM_PERMISSIONS_EXECUTE}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(CODE "
|
||||||
|
include(BundleUtilities)
|
||||||
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/soh-macos\" \"\" \"${dirs}\")
|
||||||
|
")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch")
|
if(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
|
||||||
INSTALL(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION . COMPONENT ship RENAME readme.txt )
|
install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION . COMPONENT ship RENAME readme.txt )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
set(CPACK_GENERATOR "External")
|
set(CPACK_GENERATOR "External")
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
|
||||||
set(CPACK_GENERATOR "ZIP")
|
set(CPACK_GENERATOR "ZIP")
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
set(CPACK_GENERATOR "Bundle")
|
set(CPACK_GENERATOR "Bundle")
|
||||||
|
@ -56,12 +56,13 @@ RUN \
|
|||||||
echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \
|
echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \
|
||||||
apt-get update -y && \
|
apt-get update -y && \
|
||||||
apt-get install -y devkitpro-pacman && \
|
apt-get install -y devkitpro-pacman && \
|
||||||
yes | dkp-pacman -Syu switch-dev switch-portlibs --noconfirm
|
yes | dkp-pacman -Syu switch-dev switch-portlibs wiiu-dev wiiu-portlibs --noconfirm
|
||||||
|
|
||||||
ENV DEVKITPRO=/opt/devkitpro
|
ENV DEVKITPRO=/opt/devkitpro
|
||||||
ENV DEVKITARM=/opt/devkitpro/devkitARM
|
ENV DEVKITARM=/opt/devkitpro/devkitARM
|
||||||
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
|
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
|
||||||
ENV PATH=$PATH:/opt/devkitpro/portlibs/switch/bin/
|
ENV PATH=$PATH:/opt/devkitpro/portlibs/switch/bin/:$DEVKITPPC/bin
|
||||||
|
ENV WUT_ROOT=$DEVKITPRO/wut
|
||||||
|
|
||||||
RUN mkdir /soh
|
RUN mkdir /soh
|
||||||
WORKDIR /soh
|
WORKDIR /soh
|
||||||
|
45
Jenkinsfile
vendored
45
Jenkinsfile
vendored
@ -9,13 +9,11 @@ pipeline {
|
|||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Generate Assets') {
|
stage('Generate Assets') {
|
||||||
options {
|
|
||||||
timeout(time: 10)
|
|
||||||
}
|
|
||||||
agent {
|
agent {
|
||||||
label "SoH-Asset-Builders"
|
label "SoH-Asset-Builders"
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
|
timeout(time: 10) {
|
||||||
checkout([
|
checkout([
|
||||||
$class: 'GitSCM',
|
$class: 'GitSCM',
|
||||||
branches: scm.branches,
|
branches: scm.branches,
|
||||||
@ -25,12 +23,12 @@ pipeline {
|
|||||||
])
|
])
|
||||||
sh '''
|
sh '''
|
||||||
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
|
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
|
||||||
|
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
|
||||||
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release
|
|
||||||
cmake --build build-cmake --target ExtractAssets --config Release
|
cmake --build build-cmake --target ExtractAssets --config Release
|
||||||
'''
|
'''
|
||||||
stash includes: 'soh/assets/**/*', name: 'assets'
|
stash includes: 'soh/assets/**/*', name: 'assets'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
post {
|
post {
|
||||||
unsuccessful {
|
unsuccessful {
|
||||||
step([$class: 'WsCleanup']) // Clean workspace
|
step([$class: 'WsCleanup']) // Clean workspace
|
||||||
@ -187,6 +185,43 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage ('Build Wii U') {
|
||||||
|
agent {
|
||||||
|
label "SoH-Linux-Builders"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
checkout([
|
||||||
|
$class: 'GitSCM',
|
||||||
|
branches: scm.branches,
|
||||||
|
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
|
||||||
|
extensions: scm.extensions,
|
||||||
|
userRemoteConfigs: scm.userRemoteConfigs
|
||||||
|
])
|
||||||
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
|
unstash 'assets'
|
||||||
|
sh '''
|
||||||
|
if docker ps -aq --filter "name=sohwiiucont" | grep -q .; then docker rm -f sohwiiucont; fi
|
||||||
|
docker build . -t sohwiiu
|
||||||
|
docker run --name sohwiiucont -dit --rm -v $(pwd):/soh sohwiiu /bin/bash
|
||||||
|
docker exec sohwiiucont scripts/wiiu/build.sh
|
||||||
|
|
||||||
|
mv build-wiiu/soh/*.rpx soh.rpx
|
||||||
|
mv README.md readme.txt
|
||||||
|
|
||||||
|
7z a soh-wiiu.7z soh.rpx readme.txt
|
||||||
|
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
archiveArtifacts artifacts: 'soh-wiiu.7z', followSymlinks: false, onlyIfSuccessful: true
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
sh 'sudo docker container stop sohwiiucont'
|
||||||
|
sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images
|
||||||
|
step([$class: 'WsCleanup']) // Clean workspace
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,3 @@ if (NOT TARGET ZAPDUtils)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(OTRExporter)
|
add_subdirectory(OTRExporter)
|
||||||
|
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/extract_assets.py filedata)
|
|
||||||
string(REGEX REPLACE "../ZAPDTR/ZAPD.out" "${CMAKE_BINARY_DIR}/ZAPD/ZAPD.out" filedata "${filedata}")
|
|
||||||
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake.py" "${filedata}")
|
|
||||||
file(CHMOD "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake.py" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
|
||||||
|
|
||||||
|
@ -6,15 +6,18 @@ from rom_info import Z64Rom
|
|||||||
import rom_chooser
|
import rom_chooser
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
|
||||||
def BuildOTR(xmlPath, rom):
|
def BuildOTR(xmlPath, rom, zapd_exe=None):
|
||||||
shutil.copytree("assets", "Extract/assets")
|
shutil.copytree("assets", "Extract/assets")
|
||||||
|
|
||||||
checksum = int(Z64Rom(rom).checksum.value, 16)
|
checksum = int(Z64Rom(rom).checksum.value, 16)
|
||||||
with open("Extract/version", "wb") as f:
|
with open("Extract/version", "wb") as f:
|
||||||
f.write(struct.pack('<L', checksum))
|
f.write(struct.pack('<L', checksum))
|
||||||
|
|
||||||
|
if not zapd_exe:
|
||||||
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
|
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
|
||||||
|
|
||||||
exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists",
|
exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists",
|
||||||
"-o", "placeholder", "-osf", "placeholder", "-gsf", "1",
|
"-o", "placeholder", "-osf", "placeholder", "-gsf", "1",
|
||||||
"-rconf", "CFG/Config.xml", "-se", "OTR"]
|
"-rconf", "CFG/Config.xml", "-se", "OTR"]
|
||||||
@ -28,13 +31,19 @@ def BuildOTR(xmlPath, rom):
|
|||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
rom_path = rom_chooser.chooseROM()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
|
||||||
|
parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
rom_path = args.rom if args.rom else rom_chooser.chooseROM()
|
||||||
rom = Z64Rom(rom_path)
|
rom = Z64Rom(rom_path)
|
||||||
|
|
||||||
if (os.path.exists("Extract")):
|
if (os.path.exists("Extract")):
|
||||||
shutil.rmtree("Extract")
|
shutil.rmtree("Extract")
|
||||||
|
|
||||||
BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path)
|
BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path, zapd_exe=args.zapd_exe)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -34,7 +34,12 @@
|
|||||||
// Local functions - platform-specific functions
|
// Local functions - platform-specific functions
|
||||||
|
|
||||||
#ifndef STORMLIB_WINDOWS
|
#ifndef STORMLIB_WINDOWS
|
||||||
|
|
||||||
|
#ifndef STORMLIB_WIIU // WIIU doesn't support thread_local
|
||||||
static thread_local DWORD dwLastError = ERROR_SUCCESS;
|
static thread_local DWORD dwLastError = ERROR_SUCCESS;
|
||||||
|
#else
|
||||||
|
static DWORD dwLastError = ERROR_SUCCESS;
|
||||||
|
#endif
|
||||||
|
|
||||||
DWORD GetLastError()
|
DWORD GetLastError()
|
||||||
{
|
{
|
||||||
|
@ -2005,7 +2005,7 @@ void ConvertTMPQHeader(void *header, uint16_t version)
|
|||||||
TMPQHeader * theHeader = (TMPQHeader *)header;
|
TMPQHeader * theHeader = (TMPQHeader *)header;
|
||||||
|
|
||||||
// Swap header part version 1
|
// Swap header part version 1
|
||||||
if(version == MPQ_FORMAT_VERSION_1)
|
if(version >= MPQ_FORMAT_VERSION_1)
|
||||||
{
|
{
|
||||||
theHeader->dwID = SwapUInt32(theHeader->dwID);
|
theHeader->dwID = SwapUInt32(theHeader->dwID);
|
||||||
theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize);
|
theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize);
|
||||||
@ -2018,21 +2018,21 @@ void ConvertTMPQHeader(void *header, uint16_t version)
|
|||||||
theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize);
|
theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version == MPQ_FORMAT_VERSION_2)
|
if(version >= MPQ_FORMAT_VERSION_2)
|
||||||
{
|
{
|
||||||
theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64);
|
theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64);
|
||||||
theHeader->wHashTablePosHi = SwapUInt16(theHeader->wHashTablePosHi);
|
theHeader->wHashTablePosHi = SwapUInt16(theHeader->wHashTablePosHi);
|
||||||
theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi);
|
theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version == MPQ_FORMAT_VERSION_3)
|
if(version >= MPQ_FORMAT_VERSION_3)
|
||||||
{
|
{
|
||||||
theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64);
|
theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64);
|
||||||
theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64);
|
theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64);
|
||||||
theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64);
|
theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version == MPQ_FORMAT_VERSION_4)
|
if(version >= MPQ_FORMAT_VERSION_4)
|
||||||
{
|
{
|
||||||
theHeader->HashTableSize64 = SwapUInt64(theHeader->HashTableSize64);
|
theHeader->HashTableSize64 = SwapUInt64(theHeader->HashTableSize64);
|
||||||
theHeader->BlockTableSize64 = SwapUInt64(theHeader->BlockTableSize64);
|
theHeader->BlockTableSize64 = SwapUInt64(theHeader->BlockTableSize64);
|
||||||
|
@ -180,7 +180,7 @@ static DWORD LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAtt
|
|||||||
if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
|
if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
|
||||||
return ERROR_FILE_CORRUPT;
|
return ERROR_FILE_CORRUPT;
|
||||||
|
|
||||||
BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbCRC32Size);
|
BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbArraySize);
|
||||||
for(i = 0; i < dwAttributesEntries; i++)
|
for(i = 0; i < dwAttributesEntries; i++)
|
||||||
ha->pFileTable[i].dwCrc32 = ArrayCRC32[i];
|
ha->pFileTable[i].dwCrc32 = ArrayCRC32[i];
|
||||||
pbAttrPtr += cbArraySize;
|
pbAttrPtr += cbArraySize;
|
||||||
@ -196,7 +196,7 @@ static DWORD LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAtt
|
|||||||
if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
|
if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
|
||||||
return ERROR_FILE_CORRUPT;
|
return ERROR_FILE_CORRUPT;
|
||||||
|
|
||||||
BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbFileTimeSize);
|
BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbArraySize);
|
||||||
for(i = 0; i < dwAttributesEntries; i++)
|
for(i = 0; i < dwAttributesEntries; i++)
|
||||||
ha->pFileTable[i].FileTime = ArrayFileTime[i];
|
ha->pFileTable[i].FileTime = ArrayFileTime[i];
|
||||||
pbAttrPtr += cbArraySize;
|
pbAttrPtr += cbArraySize;
|
||||||
|
@ -480,7 +480,7 @@ static bool IsMatchingPatchFile(
|
|||||||
{
|
{
|
||||||
// Load the patch header
|
// Load the patch header
|
||||||
SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL);
|
SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL);
|
||||||
BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6);
|
BSWAP_ARRAY32_UNSIGNED(&PatchHeader, sizeof(DWORD) * 6);
|
||||||
|
|
||||||
// If the file contains an incremental patch,
|
// If the file contains an incremental patch,
|
||||||
// compare the "MD5 before patching" with the base file MD5
|
// compare the "MD5 before patching" with the base file MD5
|
||||||
|
@ -631,8 +631,8 @@ typedef struct _TMPQHash
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
BYTE Platform;
|
|
||||||
BYTE Reserved;
|
BYTE Reserved;
|
||||||
|
BYTE Platform;
|
||||||
USHORT lcLocale;
|
USHORT lcLocale;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -254,6 +254,34 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Defines for Wii U platform
|
||||||
|
|
||||||
|
#if !defined(STORMLIB_PLATFORM_DEFINED) && defined(__WIIU__)
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#undef STORMLIB_LITTLE_ENDIAN // Wii U is always big endian
|
||||||
|
|
||||||
|
#define STORMLIB_MAC // Use Mac compatible code
|
||||||
|
#define STORMLIB_WIIU
|
||||||
|
#define STORMLIB_PLATFORM_DEFINED
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Assumption: If the platform is not defined, assume a Linux-like platform
|
// Assumption: If the platform is not defined, assume a Linux-like platform
|
||||||
|
|
||||||
|
@ -465,6 +465,12 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
|
|||||||
PNG::PNG
|
PNG::PNG
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
)
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
set(ADDITIONAL_LIBRARY_DEPENDENCIES
|
||||||
|
"ZAPDUtils;"
|
||||||
|
"libultraship;"
|
||||||
|
PNG::PNG
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
@ -478,7 +484,7 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
|
if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS")
|
||||||
add_library(pathconf OBJECT pathconf.c)
|
add_library(pathconf OBJECT pathconf.c)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}" $<TARGET_OBJECTS:pathconf> )
|
target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}" $<TARGET_OBJECTS:pathconf> )
|
||||||
else()
|
else()
|
||||||
|
@ -130,7 +130,13 @@ float BinaryReader::ReadSingle()
|
|||||||
stream->Read((char*)&result, sizeof(float));
|
stream->Read((char*)&result, sizeof(float));
|
||||||
|
|
||||||
if (endianness != Endianness::Native)
|
if (endianness != Endianness::Native)
|
||||||
result = BitConverter::ToFloatBE((uint8_t*)&result, 0);
|
{
|
||||||
|
float tmp;
|
||||||
|
char* dst = (char*)&tmp;
|
||||||
|
char* src = (char*)&result;
|
||||||
|
dst[3] = src[0]; dst[2] = src[1]; dst[1] = src[2]; dst[0] = src[3];
|
||||||
|
result = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (std::isnan(result))
|
if (std::isnan(result))
|
||||||
throw std::runtime_error("BinaryReader::ReadSingle(): Error reading stream");
|
throw std::runtime_error("BinaryReader::ReadSingle(): Error reading stream");
|
||||||
@ -145,7 +151,14 @@ double BinaryReader::ReadDouble()
|
|||||||
stream->Read((char*)&result, sizeof(double));
|
stream->Read((char*)&result, sizeof(double));
|
||||||
|
|
||||||
if (endianness != Endianness::Native)
|
if (endianness != Endianness::Native)
|
||||||
result = BitConverter::ToDoubleBE((uint8_t*)&result, 0);
|
{
|
||||||
|
double tmp;
|
||||||
|
char* dst = (char*)&tmp;
|
||||||
|
char* src = (char*)&result;
|
||||||
|
dst[7] = src[0]; dst[6] = src[1]; dst[5] = src[2]; dst[4] = src[3];
|
||||||
|
dst[3] = src[4]; dst[2] = src[5]; dst[1] = src[6]; dst[0] = src[7];
|
||||||
|
result = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (std::isnan(result))
|
if (std::isnan(result))
|
||||||
throw std::runtime_error("BinaryReader::ReadDouble(): Error reading stream");
|
throw std::runtime_error("BinaryReader::ReadDouble(): Error reading stream");
|
||||||
|
@ -107,7 +107,13 @@ void BinaryWriter::Write(uint64_t value)
|
|||||||
void BinaryWriter::Write(float value)
|
void BinaryWriter::Write(float value)
|
||||||
{
|
{
|
||||||
if (endianness != Endianness::Native)
|
if (endianness != Endianness::Native)
|
||||||
value = BitConverter::ToFloatBE((uint8_t*)&value, 0);
|
{
|
||||||
|
float tmp;
|
||||||
|
char* dst = (char*)&tmp;
|
||||||
|
char* src = (char*)&value;
|
||||||
|
dst[3] = src[0]; dst[2] = src[1]; dst[1] = src[2]; dst[0] = src[3];
|
||||||
|
value = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
stream->Write((char*)&value, sizeof(float));
|
stream->Write((char*)&value, sizeof(float));
|
||||||
}
|
}
|
||||||
@ -115,7 +121,14 @@ void BinaryWriter::Write(float value)
|
|||||||
void BinaryWriter::Write(double value)
|
void BinaryWriter::Write(double value)
|
||||||
{
|
{
|
||||||
if (endianness != Endianness::Native)
|
if (endianness != Endianness::Native)
|
||||||
value = BitConverter::ToDoubleBE((uint8_t*)&value, 0);
|
{
|
||||||
|
double tmp;
|
||||||
|
char* dst = (char*)&tmp;
|
||||||
|
char* src = (char*)&value;
|
||||||
|
dst[7] = src[0]; dst[6] = src[1]; dst[5] = src[2]; dst[4] = src[3];
|
||||||
|
dst[3] = src[4]; dst[2] = src[5]; dst[1] = src[6]; dst[0] = src[7];
|
||||||
|
value = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
stream->Write((char*)&value, sizeof(double));
|
stream->Write((char*)&value, sizeof(double));
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,11 @@ void StringHelper::ReplaceOriginal(std::string& str, const std::string& from, co
|
|||||||
|
|
||||||
bool StringHelper::StartsWith(const std::string& s, const std::string& input)
|
bool StringHelper::StartsWith(const std::string& s, const std::string& input)
|
||||||
{
|
{
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
return s.starts_with(input.c_str());
|
||||||
|
#else
|
||||||
return s.rfind(input, 0) == 0;
|
return s.rfind(input, 0) == 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StringHelper::Contains(const std::string& s, const std::string& input)
|
bool StringHelper::Contains(const std::string& s, const std::string& input)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
struct Vec3f
|
struct Vec3f
|
||||||
{
|
{
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
#include "OTRArchive.h"
|
|
||||||
|
|
||||||
void SaveTest()
|
|
||||||
{
|
|
||||||
auto archPtr = OtrLib::OTRArchive::CreateArchive("myarch.mpq");
|
|
||||||
auto arch = archPtr.get();
|
|
||||||
|
|
||||||
char data[] = "ABCDEFG!";
|
|
||||||
|
|
||||||
arch->AddFile("test.txt", (uintptr_t)data, sizeof(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadTest()
|
|
||||||
{
|
|
||||||
std::shared_ptr<OtrLib::OTRArchive> archPtr(new OtrLib::OTRArchive("myarch.mpq"));
|
|
||||||
|
|
||||||
archPtr->LoadFile("(crcfile)");
|
|
||||||
|
|
||||||
int bp = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
LoadTest();
|
|
||||||
//SaveTest();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Binary file not shown.
@ -1,152 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<ProjectGuid>{3c4a8151-48d1-4518-be1a-24016a5b800f}</ProjectGuid>
|
|
||||||
<RootNamespace>TestApp</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<IncludePath>$(ProjectDir)..\otrlib;$(ProjectDir)..\..\ZAPD\ZAPDUtils;$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(SolutionDir)x64\Debug;$(LibraryPath)</LibraryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>otrlib.lib;ZAPDUtils.lib;StormLibDUS.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Main.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Main.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -39,7 +39,7 @@ namespace Ship {
|
|||||||
std::copy(archivePath.begin(), archivePath.end(), t_filename);
|
std::copy(archivePath.begin(), archivePath.end(), t_filename);
|
||||||
|
|
||||||
bool success = SFileCreateArchive(t_filename, MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_ARCHIVE_V2, fileCapacity, &archive->mainMPQ);
|
bool success = SFileCreateArchive(t_filename, MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_ARCHIVE_V2, fileCapacity, &archive->mainMPQ);
|
||||||
int error = GetLastError();
|
int32_t error = GetLastError();
|
||||||
|
|
||||||
delete[] t_filename;
|
delete[] t_filename;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SPDLOG_ERROR("({}) We tried to create an archive, but it has fallen and cannot get up.");
|
SPDLOG_ERROR("({}) We tried to create an archive, but it has fallen and cannot get up.", error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,12 +65,6 @@ namespace Ship {
|
|||||||
|
|
||||||
bool attempt = SFileOpenFileEx(mainMPQ, filePath.c_str(), 0, &fileHandle);
|
bool attempt = SFileOpenFileEx(mainMPQ, filePath.c_str(), 0, &fileHandle);
|
||||||
|
|
||||||
//if (!attempt)
|
|
||||||
//{
|
|
||||||
//std::string filePathAlt = StringHelper::Replace(filePath, "/", "\\");
|
|
||||||
//attempt |= SFileOpenFileEx(mainMPQ, filePathAlt.c_str(), 0, &fileHandle);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (!attempt) {
|
if (!attempt) {
|
||||||
SPDLOG_ERROR("({}) Failed to open file {} from mpq archive {}.", GetLastError(), filePath.c_str(), MainPath.c_str());
|
SPDLOG_ERROR("({}) Failed to open file {} from mpq archive {}.", GetLastError(), filePath.c_str(), MainPath.c_str());
|
||||||
std::unique_lock<std::mutex> Lock(FileToLoad->FileLoadMutex);
|
std::unique_lock<std::mutex> Lock(FileToLoad->FileLoadMutex);
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
//#include "Lib/StrHash64.h"
|
|
||||||
#include "StormLib.h"
|
#include "StormLib.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,11 +86,17 @@ set(Source_Files__Controller
|
|||||||
"InputEditor.h"
|
"InputEditor.h"
|
||||||
"KeyboardController.cpp"
|
"KeyboardController.cpp"
|
||||||
"KeyboardController.h"
|
"KeyboardController.h"
|
||||||
|
"UltraController.h"
|
||||||
|
"DummyController.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
list(APPEND Source_Files__Controller
|
||||||
"SDLController.cpp"
|
"SDLController.cpp"
|
||||||
"SDLController.h"
|
"SDLController.h"
|
||||||
"UltraController.h"
|
|
||||||
"VirtualController.h"
|
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
source_group("Source Files\\Controller" FILES ${Source_Files__Controller})
|
source_group("Source Files\\Controller" FILES ${Source_Files__Controller})
|
||||||
|
|
||||||
set(Source_Files__Controller__Attachment
|
set(Source_Files__Controller__Attachment
|
||||||
@ -127,13 +133,9 @@ source_group("Source Files\\CustomImpl\\Utils" FILES ${Source_Files__CustomImpl_
|
|||||||
set(Source_Files__Globals
|
set(Source_Files__Globals
|
||||||
"Cvar.cpp"
|
"Cvar.cpp"
|
||||||
"Cvar.h"
|
"Cvar.h"
|
||||||
"GlobalCtx2.cpp"
|
|
||||||
"GlobalCtx2.h"
|
|
||||||
"LUSMacros.h"
|
"LUSMacros.h"
|
||||||
"Window.cpp"
|
"Window.cpp"
|
||||||
"Window.h"
|
"Window.h"
|
||||||
"WindowShim.cpp"
|
|
||||||
"WindowShim.h"
|
|
||||||
)
|
)
|
||||||
source_group("Source Files\\Globals" FILES ${Source_Files__Globals})
|
source_group("Source Files\\Globals" FILES ${Source_Files__Globals})
|
||||||
|
|
||||||
@ -150,16 +152,21 @@ source_group("Source Files\\Lib" FILES ${Source_Files__Lib})
|
|||||||
set(Source_Files__Lib__Fast3D
|
set(Source_Files__Lib__Fast3D
|
||||||
"Lib/Fast3D/gfx_cc.cpp"
|
"Lib/Fast3D/gfx_cc.cpp"
|
||||||
"Lib/Fast3D/gfx_cc.h"
|
"Lib/Fast3D/gfx_cc.h"
|
||||||
"Lib/Fast3D/gfx_opengl.cpp"
|
|
||||||
"Lib/Fast3D/gfx_opengl.h"
|
|
||||||
"Lib/Fast3D/gfx_pc.cpp"
|
"Lib/Fast3D/gfx_pc.cpp"
|
||||||
"Lib/Fast3D/gfx_pc.h"
|
"Lib/Fast3D/gfx_pc.h"
|
||||||
"Lib/Fast3D/gfx_rendering_api.h"
|
"Lib/Fast3D/gfx_rendering_api.h"
|
||||||
"Lib/Fast3D/gfx_screen_config.h"
|
"Lib/Fast3D/gfx_screen_config.h"
|
||||||
"Lib/Fast3D/gfx_sdl.h"
|
|
||||||
"Lib/Fast3D/gfx_sdl2.cpp"
|
|
||||||
"Lib/Fast3D/gfx_window_manager_api.h"
|
"Lib/Fast3D/gfx_window_manager_api.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
list(APPEND Source_Files__Lib__Fast3D
|
||||||
|
"Lib/Fast3D/gfx_opengl.cpp"
|
||||||
|
"Lib/Fast3D/gfx_opengl.h"
|
||||||
|
"Lib/Fast3D/gfx_sdl.h"
|
||||||
|
"Lib/Fast3D/gfx_sdl2.cpp"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
source_group("Source Files\\Lib\\Fast3D" FILES ${Source_Files__Lib__Fast3D})
|
source_group("Source Files\\Lib\\Fast3D" FILES ${Source_Files__Lib__Fast3D})
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
@ -179,14 +186,19 @@ set(Source_Files__Lib__Fast3D__extra
|
|||||||
"Lib/Fast3D/gfx_glx.cpp"
|
"Lib/Fast3D/gfx_glx.cpp"
|
||||||
"Lib/Fast3D/gfx_glx.h"
|
"Lib/Fast3D/gfx_glx.h"
|
||||||
)
|
)
|
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
set(Source_Files__Lib__Fast3D__extra
|
||||||
|
"Lib/Fast3D/gfx_wiiu.cpp"
|
||||||
|
"Lib/Fast3D/gfx_wiiu.h"
|
||||||
|
"Lib/Fast3D/gfx_gx2.cpp"
|
||||||
|
"Lib/Fast3D/gfx_gx2.h"
|
||||||
|
"Lib/Fast3D/gx2_shader_gen.c"
|
||||||
|
"Lib/Fast3D/gx2_shader_gen.h"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
source_group("Source Files\\Lib\\Fast3D\\extra" FILES ${Source_Files__Lib__Fast3D__extra})
|
source_group("Source Files\\Lib\\Fast3D\\extra" FILES ${Source_Files__Lib__Fast3D__extra})
|
||||||
|
|
||||||
set(Source_Files__Lib__ImGui
|
set(Source_Files__Lib__ImGui
|
||||||
"Lib/ImGui/backends/imgui_impl_opengl3.cpp"
|
|
||||||
"Lib/ImGui/backends/imgui_impl_opengl3.h"
|
|
||||||
"Lib/ImGui/backends/imgui_impl_sdl.cpp"
|
|
||||||
"Lib/ImGui/backends/imgui_impl_sdl.h"
|
|
||||||
"Lib/ImGui/imconfig.h"
|
"Lib/ImGui/imconfig.h"
|
||||||
"Lib/ImGui/imgui.cpp"
|
"Lib/ImGui/imgui.cpp"
|
||||||
"Lib/ImGui/imgui.h"
|
"Lib/ImGui/imgui.h"
|
||||||
@ -199,6 +211,16 @@ set(Source_Files__Lib__ImGui
|
|||||||
"Lib/ImGui/imstb_textedit.h"
|
"Lib/ImGui/imstb_textedit.h"
|
||||||
"Lib/ImGui/imstb_truetype.h"
|
"Lib/ImGui/imstb_truetype.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
list(APPEND Source_Files__Lib__ImGui
|
||||||
|
"Lib/ImGui/backends/imgui_impl_opengl3.cpp"
|
||||||
|
"Lib/ImGui/backends/imgui_impl_opengl3.h"
|
||||||
|
"Lib/ImGui/backends/imgui_impl_sdl.cpp"
|
||||||
|
"Lib/ImGui/backends/imgui_impl_sdl.h"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
set(Source_Files__Lib__ImGui__Windows
|
set(Source_Files__Lib__ImGui__Windows
|
||||||
"Lib/ImGui/backends/imgui_impl_dx11.cpp"
|
"Lib/ImGui/backends/imgui_impl_dx11.cpp"
|
||||||
@ -206,8 +228,19 @@ set(Source_Files__Lib__ImGui__Windows
|
|||||||
"Lib/ImGui/backends/imgui_impl_win32.cpp"
|
"Lib/ImGui/backends/imgui_impl_win32.cpp"
|
||||||
"Lib/ImGui/backends/imgui_impl_win32.h"
|
"Lib/ImGui/backends/imgui_impl_win32.h"
|
||||||
)
|
)
|
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
set(Source_Files__Lib__ImGui__WiiU
|
||||||
|
"Lib/ImGui/backends/wiiu/imgui_impl_wiiu.cpp"
|
||||||
|
"Lib/ImGui/backends/wiiu/imgui_impl_wiiu.h"
|
||||||
|
"Lib/ImGui/backends/wiiu/imgui_impl_gx2.cpp"
|
||||||
|
"Lib/ImGui/backends/wiiu/imgui_impl_gx2.h"
|
||||||
|
)
|
||||||
endif ()
|
endif ()
|
||||||
source_group("Source Files\\Lib\\ImGui" FILES ${Source_Files__Lib__ImGui} ${Source_Files__Lib__ImGui__Windows})
|
source_group("Source Files\\Lib\\ImGui" FILES
|
||||||
|
${Source_Files__Lib__ImGui}
|
||||||
|
${Source_Files__Lib__ImGui__Windows}
|
||||||
|
${Source_Files__Lib__ImGui__WiiU}
|
||||||
|
)
|
||||||
|
|
||||||
set(Source_Files__Lib__Mercury
|
set(Source_Files__Lib__Mercury
|
||||||
"Lib/Mercury/Mercury.cpp"
|
"Lib/Mercury/Mercury.cpp"
|
||||||
@ -316,6 +349,18 @@ set(Source_Files__NintendoSwitch
|
|||||||
source_group("Source Files\\NintendoSwitch" FILES ${Source_Files__NintendoSwitch})
|
source_group("Source Files\\NintendoSwitch" FILES ${Source_Files__NintendoSwitch})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
set(Source_Files__CafeOS
|
||||||
|
"WiiUController.cpp"
|
||||||
|
"WiiUController.h"
|
||||||
|
"WiiUGamepad.cpp"
|
||||||
|
"WiiUGamepad.h"
|
||||||
|
"WiiUImpl.cpp"
|
||||||
|
"WiiUImpl.h"
|
||||||
|
)
|
||||||
|
source_group("Source Files\\CafeOS" FILES ${Source_Files__CafeOS})
|
||||||
|
endif()
|
||||||
|
|
||||||
set(ALL_FILES
|
set(ALL_FILES
|
||||||
${Header_Files__Resources__Factories}
|
${Header_Files__Resources__Factories}
|
||||||
${Header_Files__Resources__Files}
|
${Header_Files__Resources__Files}
|
||||||
@ -332,6 +377,7 @@ set(ALL_FILES
|
|||||||
${Source_Files__Lib__Fast3D__extra}
|
${Source_Files__Lib__Fast3D__extra}
|
||||||
${Source_Files__Lib__ImGui}
|
${Source_Files__Lib__ImGui}
|
||||||
${Source_Files__Lib__ImGui__Windows}
|
${Source_Files__Lib__ImGui__Windows}
|
||||||
|
${Source_Files__Lib__ImGui__WiiU}
|
||||||
${Source_Files__Lib__Mercury}
|
${Source_Files__Lib__Mercury}
|
||||||
${Source_Files__Lib__stb}
|
${Source_Files__Lib__stb}
|
||||||
${Source_Files__Lib__dr_libs}
|
${Source_Files__Lib__dr_libs}
|
||||||
@ -343,6 +389,7 @@ set(ALL_FILES
|
|||||||
${Source_Files__Resources__mpq}
|
${Source_Files__Resources__mpq}
|
||||||
${Source_Files__Darwin}
|
${Source_Files__Darwin}
|
||||||
${Source_Files__NintendoSwitch}
|
${Source_Files__NintendoSwitch}
|
||||||
|
${Source_Files__CafeOS}
|
||||||
)
|
)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -420,7 +467,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||||||
"_CRT_SECURE_NO_WARNINGS;"
|
"_CRT_SECURE_NO_WARNINGS;"
|
||||||
"ENABLE_DX11;"
|
"ENABLE_DX11;"
|
||||||
"ENABLE_OPENGL;"
|
"ENABLE_OPENGL;"
|
||||||
"%(PreprocessorDefinitions)GLEW_STATIC;"
|
|
||||||
"UNICODE;"
|
"UNICODE;"
|
||||||
"_UNICODE"
|
"_UNICODE"
|
||||||
STORMLIB_NO_AUTO_LINK
|
STORMLIB_NO_AUTO_LINK
|
||||||
@ -439,15 +485,26 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||||||
"_CRT_SECURE_NO_WARNINGS;"
|
"_CRT_SECURE_NO_WARNINGS;"
|
||||||
"ENABLE_OPENGL;"
|
"ENABLE_OPENGL;"
|
||||||
"ENABLE_DX11;"
|
"ENABLE_DX11;"
|
||||||
"%(PreprocessorDefinitions)GLEW_STATIC;"
|
|
||||||
"UNICODE;"
|
"UNICODE;"
|
||||||
"_UNICODE"
|
"_UNICODE"
|
||||||
STORMLIB_NO_AUTO_LINK
|
STORMLIB_NO_AUTO_LINK
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
|
"$<$<CONFIG:Debug>:"
|
||||||
|
"_DEBUG"
|
||||||
|
">"
|
||||||
|
"$<$<CONFIG:Release>:"
|
||||||
|
"NDEBUG"
|
||||||
|
">"
|
||||||
|
"SPDLOG_ACTIVE_LEVEL=3;"
|
||||||
|
"SPDLOG_NO_THREAD_ID;"
|
||||||
|
"SPDLOG_NO_TLS;"
|
||||||
|
"STBI_NO_THREAD_LOCALS;"
|
||||||
|
)
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
"$<$<CONFIG:Debug>:"
|
"$<$<CONFIG:Debug>:"
|
||||||
"_DEBUG"
|
"_DEBUG"
|
||||||
@ -462,7 +519,7 @@ endif()
|
|||||||
################################################################################
|
################################################################################
|
||||||
# Compile and link options
|
# Compile and link options
|
||||||
################################################################################
|
################################################################################
|
||||||
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch")
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
find_package(GLEW)
|
find_package(GLEW)
|
||||||
find_package(X11)
|
find_package(X11)
|
||||||
@ -485,11 +542,13 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch")
|
|||||||
set(GLEW-INCLUDE ${GLEW_INCLUDE_DIRS})
|
set(GLEW-INCLUDE ${GLEW_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
set(SDL2-INCLUDE ${SDL2_INCLUDE_DIRS})
|
set(SDL2-INCLUDE ${SDL2_INCLUDE_DIRS})
|
||||||
elseif (CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch")
|
elseif (CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS")
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
else()
|
else()
|
||||||
set(GLEW-INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Lib/GLEW/)
|
find_package(SDL2)
|
||||||
set(SDL2-INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Lib/SDL/)
|
find_package(GLEW)
|
||||||
|
set(GLEW-INCLUDE ${GLEW_INCLUDE_DIRS})
|
||||||
|
set(SDL2-INCLUDE ${SDL2_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
@ -592,13 +651,13 @@ endif()
|
|||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
|
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
"glew32s;"
|
"GLEW::GLEW;"
|
||||||
"opengl32;"
|
"opengl32;"
|
||||||
"storm;"
|
"storm;"
|
||||||
)
|
)
|
||||||
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
|
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
"glew32s;"
|
"GLEW::GLEW;"
|
||||||
"opengl32;"
|
"opengl32;"
|
||||||
"storm;"
|
"storm;"
|
||||||
)
|
)
|
||||||
@ -627,6 +686,15 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
|
|||||||
SDL2::SDL2
|
SDL2::SDL2
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
)
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
storm
|
||||||
|
SDL2::SDL2-static
|
||||||
|
)
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
|
${DEVKITPRO}/portlibs/wiiu/include/
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
SDL2::SDL2
|
SDL2::SDL2
|
||||||
@ -638,19 +706,3 @@ else()
|
|||||||
storm
|
storm
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
|
|
||||||
add_library(glew32s STATIC IMPORTED )
|
|
||||||
set_property(TARGET glew32s PROPERTY
|
|
||||||
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Lib/GLEW/x64/glew32s.lib )
|
|
||||||
set_property(TARGET glew32s PROPERTY
|
|
||||||
IMPORTED_IMPLIB ${CMAKE_CURRENT_SOURCE_DIR}/Lib/GLEW/x64/glew32s.lib)
|
|
||||||
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
|
|
||||||
add_library(glew32s STATIC IMPORTED )
|
|
||||||
set_property(TARGET glew32s PROPERTY
|
|
||||||
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Lib/GLEW/x86/glew32s.lib )
|
|
||||||
set_property(TARGET glew32s PROPERTY
|
|
||||||
IMPORTED_IMPLIB ${CMAKE_CURRENT_SOURCE_DIR}/Lib/GLEW/x86/glew32s.lib)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
|
|
||||||
#include "Cvar.h"
|
#include "Cvar.h"
|
||||||
#include "GlobalCtx2.h"
|
|
||||||
#include "ImGuiImpl.h"
|
#include "ImGuiImpl.h"
|
||||||
#include "Lib/ImGui/imgui.h"
|
#include "Lib/ImGui/imgui.h"
|
||||||
#include "Utils/StringHelper.h"
|
#include "Utils/StringHelper.h"
|
||||||
#include "Lib/ImGui/imgui_internal.h"
|
#include "Lib/ImGui/imgui_internal.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
std::string BuildUsage(const CommandEntry& entry) {
|
std::string BuildUsage(const CommandEntry& entry) {
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "Lib/ImGui/imgui.h"
|
#include "Lib/ImGui/imgui.h"
|
||||||
#define NOGDI
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
|
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "VirtualController.h"
|
#include "DummyController.h"
|
||||||
#include "KeyboardController.h"
|
|
||||||
#include "SDLController.h"
|
|
||||||
#include <Utils/StringHelper.h>
|
#include <Utils/StringHelper.h>
|
||||||
#include "Cvar.h"
|
#include "Cvar.h"
|
||||||
|
|
||||||
|
#ifndef __WIIU__
|
||||||
|
#include "KeyboardController.h"
|
||||||
|
#include "SDLController.h"
|
||||||
|
#else
|
||||||
|
#include "WiiUGamepad.h"
|
||||||
|
#include "WiiUController.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
|
|
||||||
void ControlDeck::Init(uint8_t* bits) {
|
void ControlDeck::Init(uint8_t* bits) {
|
||||||
@ -20,7 +26,8 @@ namespace Ship {
|
|||||||
virtualDevices.clear();
|
virtualDevices.clear();
|
||||||
physicalDevices.clear();
|
physicalDevices.clear();
|
||||||
|
|
||||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
#ifndef __WIIU__
|
||||||
|
for (int32_t i = 0; i < SDL_NumJoysticks(); i++) {
|
||||||
if (SDL_IsGameController(i)) {
|
if (SDL_IsGameController(i)) {
|
||||||
auto sdl = std::make_shared<SDLController>(i);
|
auto sdl = std::make_shared<SDLController>(i);
|
||||||
sdl->Open();
|
sdl->Open();
|
||||||
@ -28,36 +35,45 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
physicalDevices.push_back(std::make_shared<VirtualController>("Auto", "Auto", true));
|
physicalDevices.push_back(std::make_shared<DummyController>("Auto", "Auto", true));
|
||||||
physicalDevices.push_back(std::make_shared<KeyboardController>());
|
physicalDevices.push_back(std::make_shared<KeyboardController>());
|
||||||
physicalDevices.push_back(std::make_shared<VirtualController>("Disconnected", "None", false));
|
#else
|
||||||
|
physicalDevices.push_back(std::make_shared<DummyController>("Auto", "Auto", true));
|
||||||
|
|
||||||
for (const auto& device : physicalDevices) {
|
auto gamepad = std::make_shared<Ship::WiiUGamepad>();
|
||||||
for (int i = 0; i < MAXCONTROLLERS; i++) {
|
gamepad->Open();
|
||||||
|
physicalDevices.push_back(gamepad);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 4; i++) {
|
||||||
|
auto controller = std::make_shared<Ship::WiiUController>((WPADChan) i);
|
||||||
|
controller->Open();
|
||||||
|
physicalDevices.push_back(controller);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
physicalDevices.push_back(std::make_shared<DummyController>("Disconnected", "None", false));
|
||||||
|
|
||||||
|
for (const auto device : physicalDevices) {
|
||||||
|
for (int32_t i = 0; i < MAXCONTROLLERS; i++) {
|
||||||
device->CreateDefaultBinding(i);
|
device->CreateDefaultBinding(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAXCONTROLLERS; i++) {
|
for (int32_t i = 0; i < MAXCONTROLLERS; i++) {
|
||||||
virtualDevices.push_back(i == 0 ? 0 : static_cast<int>(physicalDevices.size()) - 1);
|
virtualDevices.push_back(i == 0 ? 0 : static_cast<int>(physicalDevices.size()) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadControllerSettings();
|
LoadControllerSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlDeck::SetPhysicalDevice(int slot, int deviceSlot) {
|
void ControlDeck::SetPhysicalDevice(int32_t slot, int32_t deviceSlot) {
|
||||||
const std::shared_ptr<Controller> backend = physicalDevices[deviceSlot];
|
const std::shared_ptr<Controller> backend = physicalDevices[deviceSlot];
|
||||||
virtualDevices[slot] = deviceSlot;
|
virtualDevices[slot] = deviceSlot;
|
||||||
*controllerBits |= (backend->Connected()) << slot;
|
*controllerBits |= (backend->Connected()) << slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlDeck::WriteToPad(OSContPad* pad) const {
|
void ControlDeck::WriteToPad(OSContPad* pad) const {
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
|
||||||
bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0);
|
|
||||||
#else
|
|
||||||
bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0);
|
bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (size_t i = 0; i < virtualDevices.size(); i++) {
|
for (size_t i = 0; i < virtualDevices.size(); i++) {
|
||||||
const std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
|
const std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
|
||||||
@ -77,13 +93,13 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), slot, __VA_ARGS__)
|
#define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), virtualSlot, __VA_ARGS__)
|
||||||
|
|
||||||
void ControlDeck::LoadControllerSettings() {
|
void ControlDeck::LoadControllerSettings() {
|
||||||
std::shared_ptr<Mercury> Config = GlobalCtx2::GetInstance()->GetConfig();
|
std::shared_ptr<Mercury> Config = Window::GetInstance()->GetConfig();
|
||||||
|
|
||||||
for (auto const& val : Config->rjson["Controllers"]["Deck"].items()) {
|
for (auto const& val : Config->rjson["Controllers"]["Deck"].items()) {
|
||||||
int slot = std::stoi(val.key().substr(5));
|
int32_t slot = std::stoi(val.key().substr(5));
|
||||||
|
|
||||||
for (size_t dev = 0; dev < physicalDevices.size(); dev++) {
|
for (size_t dev = 0; dev < physicalDevices.size(); dev++) {
|
||||||
std::string guid = physicalDevices[dev]->GetGuid();
|
std::string guid = physicalDevices[dev]->GetGuid();
|
||||||
@ -98,36 +114,75 @@ namespace Ship {
|
|||||||
Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid());
|
Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& device : physicalDevices) {
|
for (const auto device : physicalDevices) {
|
||||||
|
|
||||||
std::string guid = device->GetGuid();
|
std::string guid = device->GetGuid();
|
||||||
|
|
||||||
for (int slot = 0; slot < MAXCONTROLLERS; slot++) {
|
for (int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
|
||||||
|
|
||||||
if (!(Config->rjson["Controllers"].contains(guid) && Config->rjson["Controllers"][guid].contains(StringHelper::Sprintf("Slot_%d", slot)))) continue;
|
if (!(Config->rjson["Controllers"].contains(guid) && Config->rjson["Controllers"][guid].contains(StringHelper::Sprintf("Slot_%d", virtualSlot)))) continue;
|
||||||
|
|
||||||
auto& profile = device->profiles[slot];
|
auto profile = device->getProfile(virtualSlot);
|
||||||
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)];
|
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", virtualSlot)];
|
||||||
|
|
||||||
profile.Mappings.clear();
|
profile->Mappings.clear();
|
||||||
profile.Thresholds.clear();
|
profile->AxisDeadzones.clear();
|
||||||
profile.UseRumble = Config->getBool(NESTED("Rumble.Enabled", ""));
|
profile->AxisDeadzones.clear();
|
||||||
profile.RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", ""));
|
profile->GyroData.clear();
|
||||||
profile.UseGyro = Config->getBool(NESTED("Gyro.Enabled", ""));
|
|
||||||
|
|
||||||
for (auto const& val : rawProfile["Thresholds"].items()) {
|
profile->Version = Config->getInt(NESTED("Version", ""), DEVICE_PROFILE_VERSION_V0);
|
||||||
profile.Thresholds[static_cast<ControllerThresholds>(std::stoi(val.key()))] = val.value();
|
|
||||||
|
switch (profile->Version) {
|
||||||
|
|
||||||
|
case DEVICE_PROFILE_VERSION_V0:
|
||||||
|
|
||||||
|
// Load up defaults for the things we can't load.
|
||||||
|
device->CreateDefaultBinding(virtualSlot);
|
||||||
|
|
||||||
|
profile->UseRumble = Config->getBool(NESTED("Rumble.Enabled", ""));
|
||||||
|
profile->RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", ""));
|
||||||
|
profile->UseGyro = Config->getBool(NESTED("Gyro.Enabled", ""));
|
||||||
|
|
||||||
|
for (auto const& val : rawProfile["Mappings"].items()) {
|
||||||
|
device->SetButtonMapping(virtualSlot, std::stoi(val.key().substr(4)), val.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DEVICE_PROFILE_VERSION_V1:
|
||||||
|
profile->UseRumble = Config->getBool(NESTED("Rumble.Enabled", ""));
|
||||||
|
profile->RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", ""));
|
||||||
|
profile->UseGyro = Config->getBool(NESTED("Gyro.Enabled", ""));
|
||||||
|
|
||||||
|
for (auto const& val : rawProfile["AxisDeadzones"].items()) {
|
||||||
|
profile->AxisDeadzones[std::stoi(val.key())] = val.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const& val : rawProfile["AxisMinimumPress"].items()) {
|
||||||
|
profile->AxisMinimumPress[std::stoi(val.key())] = val.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const& val : rawProfile["GyroData"].items()) {
|
||||||
|
profile->GyroData[std::stoi(val.key())] = val.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& val : rawProfile["Mappings"].items()) {
|
for (auto const& val : rawProfile["Mappings"].items()) {
|
||||||
device->SetButtonMapping(slot, std::stoi(val.key().substr(4)), val.value());
|
device->SetButtonMapping(virtualSlot, std::stoi(val.key().substr(4)), val.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Version is invalid.
|
||||||
|
default:
|
||||||
|
device->CreateDefaultBinding(virtualSlot);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlDeck::SaveControllerSettings() {
|
void ControlDeck::SaveControllerSettings() {
|
||||||
std::shared_ptr<Mercury> Config = GlobalCtx2::GetInstance()->GetConfig();
|
std::shared_ptr<Mercury> Config = Window::GetInstance()->GetConfig();
|
||||||
|
|
||||||
for (size_t i = 0; i < virtualDevices.size(); i++) {
|
for (size_t i = 0; i < virtualDevices.size(); i++) {
|
||||||
std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
|
std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
|
||||||
@ -136,38 +191,48 @@ namespace Ship {
|
|||||||
|
|
||||||
for (const auto& device : physicalDevices) {
|
for (const auto& device : physicalDevices) {
|
||||||
|
|
||||||
int slot = 0;
|
int32_t virtualSlot = 0;
|
||||||
std::string guid = device->GetGuid();
|
std::string guid = device->GetGuid();
|
||||||
|
|
||||||
for (const auto& profile : device->profiles) {
|
for (int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
|
||||||
|
auto profile = device->getProfile(virtualSlot);
|
||||||
|
|
||||||
if (!device->Connected()) continue;
|
if (!device->Connected()) continue;
|
||||||
|
|
||||||
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)];
|
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", virtualSlot)];
|
||||||
Config->setBool(NESTED("Rumble.Enabled", ""), profile.UseRumble);
|
Config->setInt(NESTED("Version", ""), profile->Version);
|
||||||
Config->setFloat(NESTED("Rumble.Strength", ""), profile.RumbleStrength);
|
Config->setBool(NESTED("Rumble.Enabled", ""), profile->UseRumble);
|
||||||
Config->setBool(NESTED("Gyro.Enabled", ""), profile.UseGyro);
|
Config->setFloat(NESTED("Rumble.Strength", ""), profile->RumbleStrength);
|
||||||
|
Config->setBool(NESTED("Gyro.Enabled", ""), profile->UseGyro);
|
||||||
|
|
||||||
for (auto const& val : rawProfile["Mappings"].items()) {
|
for (auto const& val : rawProfile["Mappings"].items()) {
|
||||||
Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1);
|
Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& [key, val] : profile.Thresholds) {
|
for (auto const& [key, val] : profile->AxisDeadzones) {
|
||||||
Config->setFloat(NESTED("Thresholds.%d", key), val);
|
Config->setFloat(NESTED("AxisDeadzones.%d", key), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& [key, val] : profile.Mappings) {
|
for (auto const& [key, val] : profile->AxisMinimumPress) {
|
||||||
|
Config->setFloat(NESTED("AxisMinimumPress.%d", key), val);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const& [key, val] : profile->GyroData) {
|
||||||
|
Config->setFloat(NESTED("GyroData.%d", key), val);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const& [key, val] : profile->Mappings) {
|
||||||
Config->setInt(NESTED("Mappings.BTN_%d", val), key);
|
Config->setInt(NESTED("Mappings.BTN_%d", val), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
virtualSlot++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config->save();
|
Config->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Controller> ControlDeck::GetPhysicalDevice(int deviceSlot) {
|
std::shared_ptr<Controller> ControlDeck::GetPhysicalDevice(int32_t deviceSlot) {
|
||||||
return physicalDevices[deviceSlot];
|
return physicalDevices[deviceSlot];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +240,7 @@ namespace Ship {
|
|||||||
return physicalDevices.size();
|
return physicalDevices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ControlDeck::GetVirtualDevice(int slot) {
|
int32_t ControlDeck::GetVirtualDevice(int32_t slot) {
|
||||||
return virtualDevices[slot];
|
return virtualDevices[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +248,7 @@ namespace Ship {
|
|||||||
return virtualDevices.size();
|
return virtualDevices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Controller> ControlDeck::GetPhysicalDeviceFromVirtualSlot(int slot) {
|
std::shared_ptr<Controller> ControlDeck::GetPhysicalDeviceFromVirtualSlot(int32_t slot) {
|
||||||
return GetPhysicalDevice(GetVirtualDevice(slot));
|
return GetPhysicalDevice(GetVirtualDevice(slot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "Lib/Mercury/Mercury.h"
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
|
|
||||||
@ -12,11 +13,11 @@ namespace Ship {
|
|||||||
void WriteToPad(OSContPad* pad) const;
|
void WriteToPad(OSContPad* pad) const;
|
||||||
void LoadControllerSettings();
|
void LoadControllerSettings();
|
||||||
void SaveControllerSettings();
|
void SaveControllerSettings();
|
||||||
void SetPhysicalDevice(int slot, int deviceSlot);
|
void SetPhysicalDevice(int32_t slot, int32_t deviceSlot);
|
||||||
std::shared_ptr<Ship::Controller> GetPhysicalDevice(int deviceSlot);
|
std::shared_ptr<Controller> GetPhysicalDevice(int32_t deviceSlot);
|
||||||
std::shared_ptr<Ship::Controller> GetPhysicalDeviceFromVirtualSlot(int slot);
|
std::shared_ptr<Controller> GetPhysicalDeviceFromVirtualSlot(int32_t slot);
|
||||||
size_t GetNumPhysicalDevices();
|
size_t GetNumPhysicalDevices();
|
||||||
int GetVirtualDevice(int slot);
|
int32_t GetVirtualDevice(int32_t slot);
|
||||||
size_t GetNumVirtualDevices();
|
size_t GetNumVirtualDevices();
|
||||||
uint8_t* GetControllerBits();
|
uint8_t* GetControllerBits();
|
||||||
private:
|
private:
|
||||||
|
@ -9,72 +9,107 @@
|
|||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
|
|
||||||
Controller::Controller() : isRumbling(false), wStickX(0), wStickY(0), wGyroX(0), wGyroY(0), wCamX(0), wCamY(0), dwPressedButtons(0){
|
Controller::Controller() : isRumbling(false) {
|
||||||
Attachment = nullptr;
|
Attachment = nullptr;
|
||||||
profiles.resize(MAXCONTROLLERS);
|
|
||||||
for(int slot = 0; slot < MAXCONTROLLERS; slot++) {
|
for(int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
|
||||||
dwPressedButtons.push_back(0);
|
profiles[virtualSlot] = std::make_shared<DeviceProfile>();
|
||||||
|
ButtonData[virtualSlot] = std::make_shared<Buttons>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::Read(OSContPad* pad, int32_t slot) {
|
void Controller::Read(OSContPad* pad, int32_t virtualSlot) {
|
||||||
ReadFromSource(slot);
|
ReadFromSource(virtualSlot);
|
||||||
|
|
||||||
|
#ifndef __WIIU__
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Button Inputs
|
// Button Inputs
|
||||||
pad->button |= dwPressedButtons[slot] & 0xFFFF;
|
pad->button |= getPressedButtons(virtualSlot) & 0xFFFF;
|
||||||
|
|
||||||
// Stick Inputs
|
// Stick Inputs
|
||||||
if (wStickX == 0) {
|
if (getLeftStickX(virtualSlot) == 0) {
|
||||||
if (dwPressedButtons[slot] & BTN_STICKLEFT) {
|
if (getPressedButtons(virtualSlot) & BTN_STICKLEFT) {
|
||||||
pad->stick_x = -128;
|
pad->stick_x = -128;
|
||||||
} else if (dwPressedButtons[slot] & BTN_STICKRIGHT) {
|
} else if (getPressedButtons(virtualSlot) & BTN_STICKRIGHT) {
|
||||||
pad->stick_x = 127;
|
pad->stick_x = 127;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pad->stick_x = wStickX;
|
pad->stick_x = getLeftStickX(virtualSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wStickY == 0) {
|
if (getLeftStickY(virtualSlot) == 0) {
|
||||||
if (dwPressedButtons[slot] & BTN_STICKDOWN) {
|
if (getPressedButtons(virtualSlot) & BTN_STICKDOWN) {
|
||||||
pad->stick_y = -128;
|
pad->stick_y = -128;
|
||||||
} else if (dwPressedButtons[slot] & BTN_STICKUP) {
|
} else if (getPressedButtons(virtualSlot) & BTN_STICKUP) {
|
||||||
pad->stick_y = 127;
|
pad->stick_y = 127;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pad->stick_y = wStickY;
|
pad->stick_y = getLeftStickY(virtualSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stick Inputs
|
// Stick Inputs
|
||||||
if (wCamX == 0) {
|
if (getRightStickX(virtualSlot) == 0) {
|
||||||
if (dwPressedButtons[slot] & BTN_VSTICKLEFT) {
|
if (getPressedButtons(virtualSlot) & BTN_VSTICKLEFT) {
|
||||||
pad->cam_x = -128 * 10.0f;
|
pad->right_stick_x = -128;
|
||||||
} else if (dwPressedButtons[slot] & BTN_VSTICKRIGHT) {
|
} else if (getPressedButtons(virtualSlot) & BTN_VSTICKRIGHT) {
|
||||||
pad->cam_x = 127 * 10.0f;
|
pad->right_stick_x = 127;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pad->cam_x = wCamX;
|
pad->right_stick_x = getRightStickX(virtualSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wCamY == 0) {
|
if (getRightStickY(virtualSlot) == 0) {
|
||||||
if (dwPressedButtons[slot] & BTN_VSTICKDOWN) {
|
if (getPressedButtons(virtualSlot) & BTN_VSTICKDOWN) {
|
||||||
pad->cam_y = -128 * 10.0f;
|
pad->right_stick_y = -128;
|
||||||
} else if (dwPressedButtons[slot] & BTN_VSTICKUP) {
|
} else if (getPressedButtons(virtualSlot) & BTN_VSTICKUP) {
|
||||||
pad->cam_y = 127 * 10.0f;
|
pad->right_stick_y = 127;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pad->cam_y = wCamY;
|
pad->right_stick_y = getRightStickY(virtualSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gyro
|
// Gyro
|
||||||
pad->gyro_x = wGyroX;
|
pad->gyro_x = getGyroX(virtualSlot);
|
||||||
pad->gyro_y = wGyroY;
|
pad->gyro_y = getGyroY(virtualSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::SetButtonMapping(int slot, int32_t n64Button, int32_t dwScancode) {
|
void Controller::SetButtonMapping(int32_t virtualSlot, int32_t n64Button, int32_t dwScancode) {
|
||||||
std::map<int32_t, int32_t>& Mappings = profiles[slot].Mappings;
|
std::map<int32_t, int32_t>& Mappings = getProfile(virtualSlot)->Mappings;
|
||||||
std::erase_if(Mappings, [n64Button](const std::pair<int32_t, int32_t>& bin) { return bin.second == n64Button; });
|
std::erase_if(Mappings, [n64Button](const std::pair<int32_t, int32_t>& bin) { return bin.second == n64Button; });
|
||||||
Mappings[dwScancode] = n64Button;
|
Mappings[dwScancode] = n64Button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t& Controller::getLeftStickX(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->leftStickX;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t& Controller::getLeftStickY(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->leftStickY;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t& Controller::getRightStickX(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->rightStickX;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t& Controller::getRightStickY(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->rightStickY;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t& Controller::getPressedButtons(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->pressedButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
float& Controller::getGyroX(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->gyroX;
|
||||||
|
}
|
||||||
|
|
||||||
|
float& Controller::getGyroY(int32_t virtualSlot) {
|
||||||
|
return ButtonData[virtualSlot]->gyroY;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DeviceProfile> Controller::getProfile(int32_t virtualSlot) {
|
||||||
|
return profiles[virtualSlot];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,33 +3,36 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "stdint.h"
|
#include <cstdint>
|
||||||
#include "UltraController.h"
|
#include "UltraController.h"
|
||||||
#include "ControllerAttachment.h"
|
#include "ControllerAttachment.h"
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#define EXTENDED_SCANCODE_BIT (1 << 8)
|
#define EXTENDED_SCANCODE_BIT (1 << 8)
|
||||||
#define AXIS_SCANCODE_BIT (1 << 9)
|
#define AXIS_SCANCODE_BIT (1 << 9)
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
|
enum GyroData {
|
||||||
enum ControllerThresholds {
|
DRIFT_X,
|
||||||
LEFT_STICK = 1,
|
DRIFT_Y,
|
||||||
RIGHT_STICK = 2,
|
GYRO_SENSITIVITY
|
||||||
LEFT_TRIGGER = 3,
|
|
||||||
RIGHT_TRIGGER = 4,
|
|
||||||
DRIFT_X = 5,
|
|
||||||
DRIFT_Y = 6,
|
|
||||||
SENSITIVITY = 7,
|
|
||||||
GYRO_SENSITIVITY = 8
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum DeviceProfileVersion {
|
||||||
|
DEVICE_PROFILE_VERSION_V0 = 0,
|
||||||
|
DEVICE_PROFILE_VERSION_V1 = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DEVICE_PROFILE_CURRENT_VERSION DEVICE_PROFILE_VERSION_V1
|
||||||
|
|
||||||
struct DeviceProfile {
|
struct DeviceProfile {
|
||||||
|
int32_t Version = 0;
|
||||||
bool UseRumble = false;
|
bool UseRumble = false;
|
||||||
bool UseGyro = false;
|
bool UseGyro = false;
|
||||||
float RumbleStrength = 1.0f;
|
float RumbleStrength = 1.0f;
|
||||||
std::unordered_map<ControllerThresholds, float> Thresholds;
|
std::unordered_map<int32_t, float> AxisDeadzones;
|
||||||
|
std::unordered_map<int32_t, float> AxisMinimumPress;
|
||||||
|
std::unordered_map<int32_t, float> GyroData;
|
||||||
std::map<int32_t, int32_t> Mappings;
|
std::map<int32_t, int32_t> Mappings;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,45 +40,49 @@ namespace Ship {
|
|||||||
public:
|
public:
|
||||||
virtual ~Controller() = default;
|
virtual ~Controller() = default;
|
||||||
Controller();
|
Controller();
|
||||||
void Read(OSContPad* pad, int32_t slot);
|
void Read(OSContPad* pad, int32_t virtualSlot);
|
||||||
virtual void ReadFromSource(int32_t slot) = 0;
|
virtual void ReadFromSource(int32_t virtualSlot) = 0;
|
||||||
virtual void WriteToSource(int32_t slot, ControllerCallback* controller) = 0;
|
virtual void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) = 0;
|
||||||
virtual bool Connected() const = 0;
|
virtual bool Connected() const = 0;
|
||||||
virtual bool CanRumble() const = 0;
|
virtual bool CanRumble() const = 0;
|
||||||
virtual bool CanGyro() const = 0;
|
virtual bool CanGyro() const = 0;
|
||||||
virtual void CreateDefaultBinding(int32_t slot) = 0;
|
virtual void CreateDefaultBinding(int32_t virtualSlot) = 0;
|
||||||
bool isRumbling;
|
|
||||||
std::vector<DeviceProfile> profiles;
|
|
||||||
|
|
||||||
virtual void ClearRawPress() = 0;
|
virtual void ClearRawPress() = 0;
|
||||||
virtual int32_t ReadRawPress() = 0;
|
virtual int32_t ReadRawPress() = 0;
|
||||||
void SetButtonMapping(int slot, int32_t n64Button, int32_t dwScancode);
|
void SetButtonMapping(int32_t virtualSlot, int32_t n64Button, int32_t dwScancode);
|
||||||
std::shared_ptr<ControllerAttachment> GetAttachment() { return Attachment; }
|
std::shared_ptr<ControllerAttachment> GetAttachment() { return Attachment; }
|
||||||
|
int8_t& getLeftStickX(int32_t virtualSlot);
|
||||||
|
int8_t& getLeftStickY(int32_t virtualSlot);
|
||||||
|
int8_t& getRightStickX(int32_t virtualSlot);
|
||||||
|
int8_t& getRightStickY(int32_t virtualSlot);
|
||||||
|
int32_t& getPressedButtons(int32_t virtualSlot);
|
||||||
|
float& getGyroX(int32_t virtualSlot);
|
||||||
|
float& getGyroY(int32_t virtualSlot);
|
||||||
|
std::shared_ptr<DeviceProfile> getProfile(int32_t virtualSlot);
|
||||||
|
bool IsRumbling() { return isRumbling; }
|
||||||
std::string GetGuid() { return GUID; }
|
std::string GetGuid() { return GUID; }
|
||||||
virtual const char* GetButtonName(int slot, int n64Button) = 0;
|
virtual const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) = 0;
|
||||||
virtual const char* GetControllerName() = 0;
|
virtual const std::string GetControllerName() = 0;
|
||||||
|
|
||||||
int8_t wStickX;
|
|
||||||
int8_t wStickY;
|
|
||||||
float wGyroX;
|
|
||||||
float wGyroY;
|
|
||||||
float wCamX;
|
|
||||||
float wCamY;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<int32_t> dwPressedButtons;
|
std::shared_ptr<ControllerAttachment> Attachment;
|
||||||
std::string GUID;
|
std::string GUID;
|
||||||
|
bool isRumbling;
|
||||||
|
|
||||||
void LoadBinding();
|
void LoadBinding();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<ControllerAttachment> Attachment;
|
struct Buttons {
|
||||||
|
int32_t pressedButtons = 0;
|
||||||
|
int8_t leftStickX = 0;
|
||||||
|
int8_t leftStickY = 0;
|
||||||
|
int8_t rightStickX = 0;
|
||||||
|
int8_t rightStickY = 0;
|
||||||
|
float gyroX = 0.0f;
|
||||||
|
float gyroY = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ControllerEntry {
|
std::unordered_map<int32_t, std::shared_ptr<DeviceProfile>> profiles;
|
||||||
uint8_t* controllerBits;
|
std::unordered_map<int32_t, std::shared_ptr<Buttons>> ButtonData = {};
|
||||||
Controller* entryIO;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <Utils/File.h>
|
#include <Utils/File.h>
|
||||||
#include "GlobalCtx2.h"
|
#include "Window.h"
|
||||||
|
|
||||||
std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;
|
std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ template <typename Numeric> bool is_number(const std::string& s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CVar_LoadLegacy() {
|
void CVar_LoadLegacy() {
|
||||||
auto cvarsConfig = Ship::GlobalCtx2::GetPathRelativeToAppDirectory("cvars.cfg");
|
auto cvarsConfig = Ship::Window::GetPathRelativeToAppDirectory("cvars.cfg");
|
||||||
if (File::Exists(cvarsConfig)) {
|
if (File::Exists(cvarsConfig)) {
|
||||||
const auto lines = File::ReadAllLines(cvarsConfig);
|
const auto lines = File::ReadAllLines(cvarsConfig);
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ void CVar_LoadLegacy() {
|
|||||||
|
|
||||||
|
|
||||||
extern "C" void CVar_Load() {
|
extern "C" void CVar_Load() {
|
||||||
std::shared_ptr<Mercury> pConf = Ship::GlobalCtx2::GetInstance()->GetConfig();
|
std::shared_ptr<Mercury> pConf = Ship::Window::GetInstance()->GetConfig();
|
||||||
pConf->reload();
|
pConf->reload();
|
||||||
|
|
||||||
for (const auto& item : pConf->rjson["CVars"].items()) {
|
for (const auto& item : pConf->rjson["CVars"].items()) {
|
||||||
@ -235,7 +235,7 @@ extern "C" void CVar_Load() {
|
|||||||
|
|
||||||
extern "C" void CVar_Save()
|
extern "C" void CVar_Save()
|
||||||
{
|
{
|
||||||
std::shared_ptr<Mercury> pConf = Ship::GlobalCtx2::GetInstance()->GetConfig();
|
std::shared_ptr<Mercury> pConf = Ship::Window::GetInstance()->GetConfig();
|
||||||
|
|
||||||
for (const auto& cvar : cvars) {
|
for (const auto& cvar : cvars) {
|
||||||
const std::string key = StringHelper::Sprintf("CVars.%s", cvar.first.c_str());
|
const std::string key = StringHelper::Sprintf("CVars.%s", cvar.first.c_str());
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
class VirtualController final : public Controller {
|
class DummyController final : public Controller {
|
||||||
public:
|
public:
|
||||||
VirtualController(const std::string& CUID, const std::string& KeyName, bool Connected) {
|
DummyController(const std::string& CUID, const std::string& KeyName, bool Connected) {
|
||||||
GUID = CUID;
|
GUID = CUID;
|
||||||
isConnected = Connected;
|
isConnected = Connected;
|
||||||
ButtonName = KeyName;
|
ButtonName = KeyName;
|
||||||
@ -15,8 +15,8 @@ namespace Ship {
|
|||||||
|
|
||||||
std::map<std::vector<std::string>, int32_t> ReadButtonPress();
|
std::map<std::vector<std::string>, int32_t> ReadButtonPress();
|
||||||
void ReadFromSource(int32_t slot) override {}
|
void ReadFromSource(int32_t slot) override {}
|
||||||
const char* GetControllerName() override { return GUID.c_str(); }
|
const std::string GetControllerName() override { return GUID; }
|
||||||
const char* GetButtonName(int slot, int n64Button) override { return ButtonName.c_str(); }
|
const std::string GetButtonName(int slot, int n64Button) override { return ButtonName; }
|
||||||
void WriteToSource(int32_t slot, ControllerCallback* controller) override { }
|
void WriteToSource(int32_t slot, ControllerCallback* controller) override { }
|
||||||
bool Connected() const override { return isConnected; }
|
bool Connected() const override { return isConnected; }
|
||||||
bool CanRumble() const override { return false; }
|
bool CanRumble() const override { return false; }
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "GlobalCtx2.h"
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
class Archive;
|
class Archive;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "Utils/StringHelper.h"
|
#include "Utils/StringHelper.h"
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
bool OverlayCommand(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
bool GameOverlay::OverlayCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args) {
|
||||||
if (args.size() < 3) {
|
if (args.size() < 3) {
|
||||||
return CMD_FAILED;
|
return CMD_FAILED;
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ namespace Ship {
|
|||||||
|
|
||||||
void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) {
|
void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
std::shared_ptr<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive();
|
std::shared_ptr<Archive> base = Window::GetInstance()->GetResourceManager()->GetArchive();
|
||||||
std::shared_ptr<File> font = std::make_shared<File>();
|
std::shared_ptr<File> font = std::make_shared<File>();
|
||||||
base->LoadFile(path, false, font);
|
base->LoadFile(path, false, font);
|
||||||
if (font->bIsLoaded) {
|
if (font->bIsLoaded) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "Console.h"
|
||||||
#include "Lib/ImGui/imgui.h"
|
#include "Lib/ImGui/imgui.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@ -20,9 +22,8 @@ namespace Ship {
|
|||||||
|
|
||||||
class GameOverlay {
|
class GameOverlay {
|
||||||
public:
|
public:
|
||||||
std::unordered_map<std::string, Overlay*> RegisteredOverlays;
|
static bool OverlayCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args);
|
||||||
std::unordered_map<std::string, ImFont*> Fonts;
|
|
||||||
std::string CurrentFont = "Default";
|
|
||||||
void Init();
|
void Init();
|
||||||
void Draw();
|
void Draw();
|
||||||
void DrawSettings();
|
void DrawSettings();
|
||||||
@ -33,7 +34,11 @@ namespace Ship {
|
|||||||
void TextDraw(float x, float y, bool shadow, ImVec4 color, const char* text, ...);
|
void TextDraw(float x, float y, bool shadow, ImVec4 color, const char* text, ...);
|
||||||
void TextDrawNotification(float duration, bool shadow, const char* fmt, ...);
|
void TextDrawNotification(float duration, bool shadow, const char* fmt, ...);
|
||||||
private:
|
private:
|
||||||
|
std::unordered_map<std::string, ImFont*> Fonts;
|
||||||
|
std::unordered_map<std::string, Overlay*> RegisteredOverlays;
|
||||||
|
std::string CurrentFont = "Default";
|
||||||
bool NeedsCleanup = false;
|
bool NeedsCleanup = false;
|
||||||
|
|
||||||
void CleanupNotifications();
|
void CleanupNotifications();
|
||||||
void LoadFont(const std::string& name, const std::string& path, float fontSize);
|
void LoadFont(const std::string& name, const std::string& path, float fontSize);
|
||||||
};
|
};
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
#include "GlobalCtx2.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include "ResourceMgr.h"
|
|
||||||
#include "Window.h"
|
|
||||||
#include "spdlog/async.h"
|
|
||||||
#include "spdlog/sinks/rotating_file_sink.h"
|
|
||||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
||||||
#include "spdlog/sinks/sohconsole_sink.h"
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include "OSXFolderManager.h"
|
|
||||||
#elif defined(__SWITCH__)
|
|
||||||
#include "SwitchImpl.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Ship {
|
|
||||||
std::weak_ptr<GlobalCtx2> GlobalCtx2::Context;
|
|
||||||
std::shared_ptr<GlobalCtx2> GlobalCtx2::GetInstance() {
|
|
||||||
return Context.lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<GlobalCtx2> GlobalCtx2::CreateInstance(const std::string& Name) {
|
|
||||||
if (Context.expired()) {
|
|
||||||
auto Shared = std::make_shared<GlobalCtx2>(Name);
|
|
||||||
Context = Shared;
|
|
||||||
Shared->InitWindow();
|
|
||||||
return Shared;
|
|
||||||
} else {
|
|
||||||
SPDLOG_DEBUG("Trying to create a context when it already exists.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GlobalCtx2::GetAppDirectoryPath() {
|
|
||||||
#ifdef __APPLE__
|
|
||||||
FolderManager folderManager;
|
|
||||||
std::string fpath = std::string(folderManager.pathForDirectory(NSApplicationSupportDirectory, NSUserDomainMask));
|
|
||||||
fpath.append("/com.shipofharkinian.soh");
|
|
||||||
return fpath;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ".";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GlobalCtx2::GetPathRelativeToAppDirectory(const char* path) {
|
|
||||||
return GlobalCtx2::GetAppDirectoryPath() + "/" + path;
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalCtx2::GlobalCtx2(std::string Name) : Name(std::move(Name)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalCtx2::~GlobalCtx2() {
|
|
||||||
SPDLOG_INFO("destruct GlobalCtx2");
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalCtx2::InitWindow() {
|
|
||||||
InitLogging();
|
|
||||||
Config = std::make_shared<Mercury>(GetPathRelativeToAppDirectory("shipofharkinian.json"));
|
|
||||||
Config->reload();
|
|
||||||
|
|
||||||
MainPath = Config->getString("Game.Main Archive", GetPathRelativeToAppDirectory("oot.otr"));
|
|
||||||
PatchesPath = Config->getString("Game.Patches Archive", GetAppDirectoryPath() + "/mods");
|
|
||||||
|
|
||||||
ResMan = std::make_shared<ResourceMgr>(GetInstance(), MainPath, PatchesPath);
|
|
||||||
Win = std::make_shared<Window>(GetInstance());
|
|
||||||
|
|
||||||
if (!ResMan->DidLoadSuccessfully())
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
MessageBox(nullptr, L"Main OTR file not found!", L"Uh oh", MB_OK);
|
|
||||||
#elif defined(__SWITCH__)
|
|
||||||
printf("Main OTR file not found!\n");
|
|
||||||
#else
|
|
||||||
SPDLOG_ERROR("Main OTR file not found!");
|
|
||||||
#endif
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
#ifdef __SWITCH__
|
|
||||||
Ship::Switch::Init(PostInitPhase);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalCtx2::InitLogging() {
|
|
||||||
try {
|
|
||||||
auto logPath = GetPathRelativeToAppDirectory(("logs/" + GetName() + ".log").c_str());
|
|
||||||
|
|
||||||
// Setup Logging
|
|
||||||
spdlog::init_thread_pool(8192, 1);
|
|
||||||
auto SohConsoleSink = std::make_shared<spdlog::sinks::soh_sink_mt>();
|
|
||||||
SohConsoleSink->set_level(spdlog::level::trace);
|
|
||||||
#if defined(__linux__)
|
|
||||||
auto ConsoleSink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
|
||||||
ConsoleSink->set_level(spdlog::level::trace);
|
|
||||||
#endif
|
|
||||||
auto FileSink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(logPath, 1024 * 1024 * 10, 10);
|
|
||||||
FileSink->set_level(spdlog::level::trace);
|
|
||||||
std::vector<spdlog::sink_ptr> Sinks{
|
|
||||||
#if defined(__linux__)
|
|
||||||
ConsoleSink,
|
|
||||||
#endif
|
|
||||||
FileSink,
|
|
||||||
SohConsoleSink
|
|
||||||
};
|
|
||||||
Logger = std::make_shared<spdlog::async_logger>(GetName(), Sinks.begin(), Sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
|
|
||||||
GetLogger()->set_level(spdlog::level::trace);
|
|
||||||
GetLogger()->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%@] [%l] %v");
|
|
||||||
spdlog::register_logger(GetLogger());
|
|
||||||
spdlog::set_default_logger(GetLogger());
|
|
||||||
}
|
|
||||||
catch (const spdlog::spdlog_ex& ex) {
|
|
||||||
std::cout << "Log initialization failed: " << ex.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalCtx2::WriteSaveFile(const std::filesystem::path& savePath, const uintptr_t addr, void* dramAddr, const size_t size) {
|
|
||||||
std::ofstream saveFile = std::ofstream(savePath, std::fstream::in | std::fstream::out | std::fstream::binary);
|
|
||||||
saveFile.seekp(addr);
|
|
||||||
saveFile.write((char*)dramAddr, size);
|
|
||||||
saveFile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalCtx2::ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, void* dramAddr, size_t size) {
|
|
||||||
std::ifstream saveFile = std::ifstream(savePath, std::fstream::in | std::fstream::out | std::fstream::binary);
|
|
||||||
|
|
||||||
// If the file doesn't exist, initialize DRAM
|
|
||||||
if (saveFile.good()) {
|
|
||||||
saveFile.seekg(addr);
|
|
||||||
saveFile.read((char*)dramAddr, size);
|
|
||||||
} else {
|
|
||||||
memset(dramAddr, 0, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveFile.close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
#ifndef GLOBAL_CTX_2
|
|
||||||
#define GLOBAL_CTX_2
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include <filesystem>
|
|
||||||
#include <memory>
|
|
||||||
#include <fstream>
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
#include "Lib/Mercury/Mercury.h"
|
|
||||||
|
|
||||||
namespace Ship {
|
|
||||||
class ResourceMgr;
|
|
||||||
class Window;
|
|
||||||
|
|
||||||
class GlobalCtx2 {
|
|
||||||
public:
|
|
||||||
static std::shared_ptr<GlobalCtx2> GetInstance();
|
|
||||||
static std::shared_ptr<GlobalCtx2> CreateInstance(const std::string& Name);
|
|
||||||
|
|
||||||
std::string GetName() { return Name; }
|
|
||||||
std::shared_ptr<Window> GetWindow() { return Win; }
|
|
||||||
std::shared_ptr<ResourceMgr> GetResourceManager() { return ResMan; }
|
|
||||||
std::shared_ptr<spdlog::logger> GetLogger() { return Logger; }
|
|
||||||
std::shared_ptr<Mercury> GetConfig() { return Config; }
|
|
||||||
|
|
||||||
static std::string GetAppDirectoryPath();
|
|
||||||
static std::string GetPathRelativeToAppDirectory(const char* path);
|
|
||||||
|
|
||||||
void WriteSaveFile(const std::filesystem::path& savePath, uintptr_t addr, void* dramAddr, size_t size);
|
|
||||||
void ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, void* dramAddr, size_t size);
|
|
||||||
|
|
||||||
GlobalCtx2(std::string Name);
|
|
||||||
~GlobalCtx2();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void InitWindow();
|
|
||||||
void InitLogging();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static std::weak_ptr <GlobalCtx2> Context;
|
|
||||||
std::shared_ptr<spdlog::logger> Logger;
|
|
||||||
std::shared_ptr<Window> Win;
|
|
||||||
std::shared_ptr<Mercury> Config; // Config needs to be after the Window because we call the Window during it's destructor.
|
|
||||||
std::shared_ptr<ResourceMgr> ResMan;
|
|
||||||
std::string Name;
|
|
||||||
std::string MainPath;
|
|
||||||
std::string PatchesPath;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -18,7 +18,6 @@
|
|||||||
#include "Hooks.h"
|
#include "Hooks.h"
|
||||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
#include "Lib/ImGui/imgui_internal.h"
|
#include "Lib/ImGui/imgui_internal.h"
|
||||||
#include "GlobalCtx2.h"
|
|
||||||
#include "ResourceMgr.h"
|
#include "ResourceMgr.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Cvar.h"
|
#include "Cvar.h"
|
||||||
@ -30,6 +29,16 @@
|
|||||||
#include "Lib/spdlog/include/spdlog/common.h"
|
#include "Lib/spdlog/include/spdlog/common.h"
|
||||||
#include "UltraController.h"
|
#include "UltraController.h"
|
||||||
|
|
||||||
|
#ifdef __WIIU__
|
||||||
|
#include <gx2/registers.h> // GX2SetViewport / GX2SetScissor
|
||||||
|
|
||||||
|
#include "Lib/ImGui/backends/wiiu/imgui_impl_gx2.h"
|
||||||
|
#include "Lib/ImGui/backends/wiiu/imgui_impl_wiiu.h"
|
||||||
|
|
||||||
|
#include "Lib/Fast3D/gfx_wiiu.h"
|
||||||
|
#include "Lib/Fast3D/gfx_gx2.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
#include <SDL_hints.h>
|
#include <SDL_hints.h>
|
||||||
#else
|
#else
|
||||||
@ -101,7 +110,11 @@ namespace SohImGui {
|
|||||||
bool statsWindowOpen;
|
bool statsWindowOpen;
|
||||||
|
|
||||||
const char* filters[3] = {
|
const char* filters[3] = {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
"",
|
||||||
|
#else
|
||||||
"Three-Point",
|
"Three-Point",
|
||||||
|
#endif
|
||||||
"Linear",
|
"Linear",
|
||||||
"None"
|
"None"
|
||||||
};
|
};
|
||||||
@ -110,7 +123,11 @@ namespace SohImGui {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
{ "dx11", "DirectX" },
|
{ "dx11", "DirectX" },
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __WIIU__
|
||||||
{ "sdl", "OpenGL" }
|
{ "sdl", "OpenGL" }
|
||||||
|
#else
|
||||||
|
{ "wiiu", "GX2" }
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -178,10 +195,16 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ImGuiWMInit() {
|
void ImGuiWMInit() {
|
||||||
switch (impl.backend) {
|
switch (impl.backend) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
case Backend::GX2:
|
||||||
|
ImGui_ImplWiiU_Init();
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case Backend::SDL:
|
case Backend::SDL:
|
||||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1");
|
||||||
ImGui_ImplSDL2_InitForOpenGL(static_cast<SDL_Window*>(impl.sdl.window), impl.sdl.context);
|
ImGui_ImplSDL2_InitForOpenGL(static_cast<SDL_Window*>(impl.sdl.window), impl.sdl.context);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||||
case Backend::DX11:
|
case Backend::DX11:
|
||||||
ImGui_ImplWin32_Init(impl.dx11.window);
|
ImGui_ImplWin32_Init(impl.dx11.window);
|
||||||
@ -195,6 +218,11 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ImGuiBackendInit() {
|
void ImGuiBackendInit() {
|
||||||
switch (impl.backend) {
|
switch (impl.backend) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
case Backend::GX2:
|
||||||
|
ImGui_ImplGX2_Init();
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case Backend::SDL:
|
case Backend::SDL:
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
ImGui_ImplOpenGL3_Init("#version 410 core");
|
ImGui_ImplOpenGL3_Init("#version 410 core");
|
||||||
@ -202,6 +230,7 @@ namespace SohImGui {
|
|||||||
ImGui_ImplOpenGL3_Init("#version 120");
|
ImGui_ImplOpenGL3_Init("#version 120");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||||
case Backend::DX11:
|
case Backend::DX11:
|
||||||
@ -215,9 +244,17 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ImGuiProcessEvent(EventImpl event) {
|
void ImGuiProcessEvent(EventImpl event) {
|
||||||
switch (impl.backend) {
|
switch (impl.backend) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
case Backend::GX2:
|
||||||
|
if (!ImGui_ImplWiiU_ProcessInput((ImGui_ImplWiiU_ControllerInput*)event.gx2.input)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case Backend::SDL:
|
case Backend::SDL:
|
||||||
ImGui_ImplSDL2_ProcessEvent(static_cast<const SDL_Event*>(event.sdl.event));
|
ImGui_ImplSDL2_ProcessEvent(static_cast<const SDL_Event*>(event.sdl.event));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||||
case Backend::DX11:
|
case Backend::DX11:
|
||||||
ImGui_ImplWin32_WndProcHandler(static_cast<HWND>(event.win32.handle), event.win32.msg, event.win32.wparam, event.win32.lparam);
|
ImGui_ImplWin32_WndProcHandler(static_cast<HWND>(event.win32.handle), event.win32.msg, event.win32.wparam, event.win32.lparam);
|
||||||
@ -230,9 +267,14 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ImGuiWMNewFrame() {
|
void ImGuiWMNewFrame() {
|
||||||
switch (impl.backend) {
|
switch (impl.backend) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
case Backend::GX2:
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case Backend::SDL:
|
case Backend::SDL:
|
||||||
ImGui_ImplSDL2_NewFrame(static_cast<SDL_Window*>(impl.sdl.window));
|
ImGui_ImplSDL2_NewFrame(static_cast<SDL_Window*>(impl.sdl.window));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||||
case Backend::DX11:
|
case Backend::DX11:
|
||||||
ImGui_ImplWin32_NewFrame();
|
ImGui_ImplWin32_NewFrame();
|
||||||
@ -245,9 +287,16 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ImGuiBackendNewFrame() {
|
void ImGuiBackendNewFrame() {
|
||||||
switch (impl.backend) {
|
switch (impl.backend) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
case Backend::GX2:
|
||||||
|
io->DeltaTime = (float) frametime / 1000.0f / 1000.0f;
|
||||||
|
ImGui_ImplGX2_NewFrame();
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case Backend::SDL:
|
case Backend::SDL:
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||||
case Backend::DX11:
|
case Backend::DX11:
|
||||||
ImGui_ImplDX11_NewFrame();
|
ImGui_ImplDX11_NewFrame();
|
||||||
@ -260,9 +309,20 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ImGuiRenderDrawData(ImDrawData* data) {
|
void ImGuiRenderDrawData(ImDrawData* data) {
|
||||||
switch (impl.backend) {
|
switch (impl.backend) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
case Backend::GX2:
|
||||||
|
ImGui_ImplGX2_RenderDrawData(data);
|
||||||
|
|
||||||
|
// Reset viewport and scissor for drawing the keyboard
|
||||||
|
GX2SetViewport(0.0f, 0.0f, io->DisplaySize.x, io->DisplaySize.y, 0.0f, 1.0f);
|
||||||
|
GX2SetScissor(0, 0, io->DisplaySize.x, io->DisplaySize.y);
|
||||||
|
ImGui_ImplWiiU_DrawKeyboardOverlay();
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case Backend::SDL:
|
case Backend::SDL:
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(data);
|
ImGui_ImplOpenGL3_RenderDrawData(data);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||||
case Backend::DX11:
|
case Backend::DX11:
|
||||||
ImGui_ImplDX11_RenderDrawData(data);
|
ImGui_ImplDX11_RenderDrawData(data);
|
||||||
@ -284,27 +344,27 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void ShowCursor(bool hide, Dialogues d) {
|
void ShowCursor(bool hide, Dialogues d) {
|
||||||
if (d == Dialogues::dLoadSettings) {
|
if (d == Dialogues::dLoadSettings) {
|
||||||
GlobalCtx2::GetInstance()->GetWindow()->ShowCursor(hide);
|
Window::GetInstance()->ShowCursor(hide);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d == Dialogues::dConsole && CVar_GetS32("gOpenMenuBar", 0)) {
|
if (d == Dialogues::dConsole && CVar_GetS32("gOpenMenuBar", 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!GlobalCtx2::GetInstance()->GetWindow()->IsFullscreen()) {
|
if (!Window::GetInstance()->IsFullscreen()) {
|
||||||
oldCursorState = false;
|
oldCursorState = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldCursorState != hide) {
|
if (oldCursorState != hide) {
|
||||||
oldCursorState = hide;
|
oldCursorState = hide;
|
||||||
GlobalCtx2::GetInstance()->GetWindow()->ShowCursor(hide);
|
Window::GetInstance()->ShowCursor(hide);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadTexture(const std::string& name, const std::string& path) {
|
void LoadTexture(const std::string& name, const std::string& path) {
|
||||||
GfxRenderingAPI* api = gfx_get_current_rendering_api();
|
GfxRenderingAPI* api = gfx_get_current_rendering_api();
|
||||||
const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(path);
|
const auto res = Window::GetInstance()->GetResourceManager()->LoadFile(path);
|
||||||
|
|
||||||
const auto asset = new GameAsset{ api->new_texture() };
|
const auto asset = new GameAsset{ api->new_texture() };
|
||||||
uint8_t* img_data = stbi_load_from_memory(reinterpret_cast<const stbi_uc*>(res->buffer.get()), res->dwBufferSize, &asset->width, &asset->height, nullptr, 4);
|
uint8_t* img_data = stbi_load_from_memory(reinterpret_cast<const stbi_uc*>(res->buffer.get()), res->dwBufferSize, &asset->width, &asset->height, nullptr, 4);
|
||||||
@ -340,7 +400,7 @@ namespace SohImGui {
|
|||||||
|
|
||||||
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint) {
|
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint) {
|
||||||
GfxRenderingAPI* api = gfx_get_current_rendering_api();
|
GfxRenderingAPI* api = gfx_get_current_rendering_api();
|
||||||
const auto res = static_cast<Ship::Texture*>(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(path).get());
|
const auto res = static_cast<Ship::Texture*>(Window::GetInstance()->GetResourceManager()->LoadResource(path).get());
|
||||||
|
|
||||||
std::vector<uint8_t> texBuffer;
|
std::vector<uint8_t> texBuffer;
|
||||||
texBuffer.reserve(res->width * res->height * 4);
|
texBuffer.reserve(res->width * res->height * 4);
|
||||||
@ -395,23 +455,40 @@ namespace SohImGui {
|
|||||||
Ship::Switch::SetupFont(io->Fonts);
|
Ship::Switch::SetupFont(io->Fonts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lastBackendID = GetBackendID(GlobalCtx2::GetInstance()->GetConfig());
|
#ifdef __WIIU__
|
||||||
|
// Scale everything by 2 for the Wii U
|
||||||
|
ImGui::GetStyle().ScaleAllSizes(2.0f);
|
||||||
|
io->FontGlobalScale = 2.0f;
|
||||||
|
|
||||||
|
// Setup display sizes
|
||||||
|
io->DisplaySize.x = window_impl.gx2.width;
|
||||||
|
io->DisplaySize.y = window_impl.gx2.height;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lastBackendID = GetBackendID(Window::GetInstance()->GetConfig());
|
||||||
if (CVar_GetS32("gOpenMenuBar", 0) != 1) {
|
if (CVar_GetS32("gOpenMenuBar", 0) != 1) {
|
||||||
#ifdef __SWITCH__
|
#if defined(__SWITCH__) || defined(__WIIU__)
|
||||||
SohImGui::overlay->TextDrawNotification(30.0f, true, "Press - to access enhancements menu");
|
SohImGui::overlay->TextDrawNotification(30.0f, true, "Press - to access enhancements menu");
|
||||||
#else
|
#else
|
||||||
SohImGui::overlay->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu");
|
SohImGui::overlay->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
auto imguiIniPath = Ship::GlobalCtx2::GetPathRelativeToAppDirectory("imgui.ini");
|
auto imguiIniPath = Ship::Window::GetPathRelativeToAppDirectory("imgui.ini");
|
||||||
auto imguiLogPath = Ship::GlobalCtx2::GetPathRelativeToAppDirectory("imgui_log.txt");
|
auto imguiLogPath = Ship::Window::GetPathRelativeToAppDirectory("imgui_log.txt");
|
||||||
io->IniFilename = strcpy(new char[imguiIniPath.length() + 1], imguiIniPath.c_str());
|
io->IniFilename = strcpy(new char[imguiIniPath.length() + 1], imguiIniPath.c_str());
|
||||||
io->LogFilename = strcpy(new char[imguiLogPath.length() + 1], imguiLogPath.c_str());
|
io->LogFilename = strcpy(new char[imguiLogPath.length() + 1], imguiLogPath.c_str());
|
||||||
|
|
||||||
if (UseViewports()) {
|
if (UseViewports()) {
|
||||||
io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CVar_GetS32("gControlNav", 0) && CVar_GetS32("gOpenMenuBar", 0)) {
|
||||||
|
io->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
|
} else {
|
||||||
|
io->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad;
|
||||||
|
}
|
||||||
|
|
||||||
console->Init();
|
console->Init();
|
||||||
overlay->Init();
|
overlay->Init();
|
||||||
controller->Init();
|
controller->Init();
|
||||||
@ -422,7 +499,7 @@ namespace SohImGui {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ship::RegisterHook<Ship::GfxInit>([] {
|
Ship::RegisterHook<Ship::GfxInit>([] {
|
||||||
if (GlobalCtx2::GetInstance()->GetWindow()->IsFullscreen())
|
if (Window::GetInstance()->IsFullscreen())
|
||||||
ShowCursor(CVar_GetS32("gOpenMenuBar", 0), Dialogues::dLoadSettings);
|
ShowCursor(CVar_GetS32("gOpenMenuBar", 0), Dialogues::dLoadSettings);
|
||||||
|
|
||||||
LoadTexture("Game_Icon", "assets/ship_of_harkinian/icons/gSohIcon.png");
|
LoadTexture("Game_Icon", "assets/ship_of_harkinian/icons/gSohIcon.png");
|
||||||
@ -616,7 +693,11 @@ namespace SohImGui {
|
|||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
||||||
}
|
}
|
||||||
if (PlusMinusButton) {
|
if (PlusMinusButton) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (ImGui::SliderFloat(id, &val, min, max, format))
|
if (ImGui::SliderFloat(id, &val, min, max, format))
|
||||||
{
|
{
|
||||||
@ -801,8 +882,8 @@ namespace SohImGui {
|
|||||||
ImGuiWMNewFrame();
|
ImGuiWMNewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
const std::shared_ptr<Window> wnd = GlobalCtx2::GetInstance()->GetWindow();
|
const std::shared_ptr<Window> wnd = Window::GetInstance();
|
||||||
const std::shared_ptr<Mercury> pConf = GlobalCtx2::GetInstance()->GetConfig();
|
const std::shared_ptr<Mercury> pConf = Window::GetInstance()->GetConfig();
|
||||||
|
|
||||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoBackground |
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoBackground |
|
||||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
|
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
|
||||||
@ -834,24 +915,16 @@ namespace SohImGui {
|
|||||||
|
|
||||||
ImGui::DockSpace(dockId, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_NoDockingInCentralNode);
|
ImGui::DockSpace(dockId, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_NoDockingInCentralNode);
|
||||||
|
|
||||||
if (ImGui::IsKeyPressed(TOGGLE_BTN) || ImGui::IsKeyPressed(TOGGLE_PAD_BTN)) {
|
if (ImGui::IsKeyPressed(TOGGLE_BTN) ||
|
||||||
|
(ImGui::IsKeyPressed(TOGGLE_PAD_BTN) && CVar_GetS32("gControlNav", 0))) {
|
||||||
bool menu_bar = CVar_GetS32("gOpenMenuBar", 0);
|
bool menu_bar = CVar_GetS32("gOpenMenuBar", 0);
|
||||||
CVar_SetS32("gOpenMenuBar", !menu_bar);
|
CVar_SetS32("gOpenMenuBar", !menu_bar);
|
||||||
needs_save = true;
|
needs_save = true;
|
||||||
GlobalCtx2::GetInstance()->GetWindow()->SetMenuBar(menu_bar);
|
Window::GetInstance()->SetMenuBar(menu_bar);
|
||||||
ShowCursor(menu_bar, Dialogues::dMenubar);
|
ShowCursor(menu_bar, Dialogues::dMenubar);
|
||||||
GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->SaveControllerSettings();
|
Window::GetInstance()->GetControlDeck()->SaveControllerSettings();
|
||||||
#ifdef __SWITCH__
|
if (CVar_GetS32("gControlNav", 0) && CVar_GetS32("gOpenMenuBar", 0)) {
|
||||||
bool enableControllerNavigation = true;
|
io->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
#else
|
|
||||||
bool enableControllerNavigation = CVar_GetS32("gControlNav", 0);
|
|
||||||
#endif
|
|
||||||
if (enableControllerNavigation) {
|
|
||||||
if (CVar_GetS32("gOpenMenuBar", 0)) {
|
|
||||||
io->ConfigFlags |=ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard;
|
|
||||||
} else {
|
|
||||||
io->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
io->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad;
|
io->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad;
|
||||||
}
|
}
|
||||||
@ -875,13 +948,18 @@ namespace SohImGui {
|
|||||||
if (DefaultAssets.contains("Game_Icon")) {
|
if (DefaultAssets.contains("Game_Icon")) {
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
|
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
|
||||||
|
float posScale = 1.0f;
|
||||||
|
#elif defined(__WIIU__)
|
||||||
|
ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2);
|
||||||
|
float posScale = 2.0f;
|
||||||
#else
|
#else
|
||||||
ImVec2 iconSize = ImVec2(16.0f, 16.0f);
|
ImVec2 iconSize = ImVec2(16.0f, 16.0f);
|
||||||
|
float posScale = 1.0f;
|
||||||
#endif
|
#endif
|
||||||
ImGui::SetCursorPos(ImVec2(5, 2.5f));
|
ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale);
|
||||||
ImGui::Image(GetTextureByID(DefaultAssets["Game_Icon"]->textureId), iconSize);
|
ImGui::Image(GetTextureByID(DefaultAssets["Game_Icon"]->textureId), iconSize);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPos(ImVec2(25, 0));
|
ImGui::SetCursorPos(ImVec2(25, 0) * posScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ImVec2 windowPadding(8.0f, 8.0f);
|
static ImVec2 windowPadding(8.0f, 8.0f);
|
||||||
@ -957,9 +1035,11 @@ namespace SohImGui {
|
|||||||
Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing");
|
Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing");
|
||||||
gfx_current_dimensions.internal_mul = CVar_GetFloat("gInternalResolution", 1);
|
gfx_current_dimensions.internal_mul = CVar_GetFloat("gInternalResolution", 1);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __WIIU__
|
||||||
PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, false, true, false);
|
PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, false, true, false);
|
||||||
Tooltip("Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel");
|
Tooltip("Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel");
|
||||||
gfx_msaa_level = CVar_GetS32("gMSAAValue", 1);
|
gfx_msaa_level = CVar_GetS32("gMSAAValue", 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (impl.backend == Backend::DX11)
|
if (impl.backend == Backend::DX11)
|
||||||
{
|
{
|
||||||
@ -1065,16 +1145,34 @@ namespace SohImGui {
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f));
|
||||||
if (ImGui::Button("Apply Preset")) {
|
if (ImGui::Button("Apply Preset")) {
|
||||||
applyEnhancementPresets();
|
applyEnhancementPresets();
|
||||||
|
needs_save = true;
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar(1);
|
ImGui::PopStyleVar(1);
|
||||||
|
|
||||||
PaddedSeparator();
|
PaddedSeparator();
|
||||||
|
|
||||||
if (ImGui::BeginMenu("Controls")) {
|
if (ImGui::BeginMenu("Controls")) {
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f));
|
||||||
|
float availableWidth = ImGui::GetContentRegionAvail().x;
|
||||||
|
if (ImGui::Button(
|
||||||
|
GetWindowButtonText("Customize Game Controls", CVar_GetS32("gGameControlEditorEnabled", 0)).c_str(),
|
||||||
|
ImVec2(availableWidth, 0)
|
||||||
|
)) {
|
||||||
|
bool currentValue = CVar_GetS32("gGameControlEditorEnabled", 0);
|
||||||
|
CVar_SetS32("gGameControlEditorEnabled", !currentValue);
|
||||||
|
needs_save = true;
|
||||||
|
customWindows["Game Control Editor"].enabled = CVar_GetS32("gGameControlEditorEnabled", 0);
|
||||||
|
}
|
||||||
|
ImGui::PopStyleVar(3);
|
||||||
|
ImGui::PopStyleColor(1);
|
||||||
|
|
||||||
// TODO mutual exclusions -- There should be some system to prevent conclifting enhancements from being selected
|
// TODO mutual exclusions -- There should be some system to prevent conclifting enhancements from being selected
|
||||||
EnhancementCheckbox("D-pad Support on Pause and File Select", "gDpadPauseName");
|
PaddedEnhancementCheckbox("D-pad Support on Pause and File Select", "gDpadPauseName");
|
||||||
Tooltip("Enables Pause and File Select screen navigation with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate");
|
Tooltip("Enables Pause and File Select screen navigation with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate");
|
||||||
PaddedEnhancementCheckbox("D-pad Support in Ocarina and Text Choice", "gDpadOcarinaText", true, false);
|
PaddedEnhancementCheckbox("D-pad Support in Text Choice", "gDpadText", true, false);
|
||||||
PaddedEnhancementCheckbox("D-pad Support for Browsing Shop Items", "gDpadShop", true, false);
|
PaddedEnhancementCheckbox("D-pad Support for Browsing Shop Items", "gDpadShop", true, false);
|
||||||
PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips", true, false);
|
PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips", true, false);
|
||||||
Tooltip("Allows the D-pad to be used as extra C buttons");
|
Tooltip("Allows the D-pad to be used as extra C buttons");
|
||||||
@ -1097,8 +1195,8 @@ namespace SohImGui {
|
|||||||
PaddedEnhancementSliderInt("King Zora Speed: %dx", "##MWEEPSPEED", "gMweepSpeed", 1, 5, "", 1, false, false, true);
|
PaddedEnhancementSliderInt("King Zora Speed: %dx", "##MWEEPSPEED", "gMweepSpeed", 1, 5, "", 1, false, false, true);
|
||||||
EnhancementSliderInt("Biggoron Forge Time: %d days", "##FORGETIME", "gForgeTime", 0, 3, "", 3);
|
EnhancementSliderInt("Biggoron Forge Time: %d days", "##FORGETIME", "gForgeTime", 0, 3, "", 3);
|
||||||
Tooltip("Allows you to change the number of days it takes for Biggoron to forge the Biggoron Sword");
|
Tooltip("Allows you to change the number of days it takes for Biggoron to forge the Biggoron Sword");
|
||||||
PaddedEnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", "gClimbSpeed", 0, 12, "", 0);
|
PaddedEnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", "gClimbSpeed", 0, 12, "", 0, false, false, true);
|
||||||
EnhancementCheckbox("Faster Block Push", "gFasterBlockPush");
|
PaddedEnhancementSliderInt("Block pushing speed +%d", "##BLOCKSPEED", "gFasterBlockPush", 0, 5, "", 0, false, false, true);
|
||||||
PaddedEnhancementCheckbox("Faster Heavy Block Lift", "gFasterHeavyBlockLift", true, false);
|
PaddedEnhancementCheckbox("Faster Heavy Block Lift", "gFasterHeavyBlockLift", true, false);
|
||||||
Tooltip("Speeds up lifting silver rocks and obelisks");
|
Tooltip("Speeds up lifting silver rocks and obelisks");
|
||||||
PaddedEnhancementCheckbox("No Forced Navi", "gNoForcedNavi", true, false);
|
PaddedEnhancementCheckbox("No Forced Navi", "gNoForcedNavi", true, false);
|
||||||
@ -1403,6 +1501,7 @@ namespace SohImGui {
|
|||||||
Tooltip("Restores N64 Weird Frames allowing weirdshots to behave the same as N64");
|
Tooltip("Restores N64 Weird Frames allowing weirdshots to behave the same as N64");
|
||||||
PaddedEnhancementCheckbox("Bombchus out of bounds", "gBombchusOOB", true, false);
|
PaddedEnhancementCheckbox("Bombchus out of bounds", "gBombchusOOB", true, false);
|
||||||
Tooltip("Allows bombchus to explode out of bounds\nSimilar to GameCube and Wii VC");
|
Tooltip("Allows bombchus to explode out of bounds\nSimilar to GameCube and Wii VC");
|
||||||
|
PaddedEnhancementCheckbox("Restore old Gold Skulltula cutscene", "gGsCutscene", true, false);
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
@ -1434,7 +1533,7 @@ namespace SohImGui {
|
|||||||
|
|
||||||
const char* fps_cvar = "gInterpolationFPS";
|
const char* fps_cvar = "gInterpolationFPS";
|
||||||
{
|
{
|
||||||
#ifdef __SWITCH__
|
#if defined(__SWITCH__) || defined(__WIIU__)
|
||||||
int minFps = 20;
|
int minFps = 20;
|
||||||
int maxFps = 60;
|
int maxFps = 60;
|
||||||
#else
|
#else
|
||||||
@ -1444,6 +1543,12 @@ namespace SohImGui {
|
|||||||
|
|
||||||
int val = CVar_GetS32(fps_cvar, minFps);
|
int val = CVar_GetS32(fps_cvar, minFps);
|
||||||
val = MAX(MIN(val, maxFps), 20);
|
val = MAX(MIN(val, maxFps), 20);
|
||||||
|
|
||||||
|
#ifdef __WIIU__
|
||||||
|
// only support divisors of 60 on the Wii U
|
||||||
|
val = 60 / (60 / val);
|
||||||
|
#endif
|
||||||
|
|
||||||
int fps = val;
|
int fps = val;
|
||||||
|
|
||||||
if (fps == 20)
|
if (fps == 20)
|
||||||
@ -1458,15 +1563,28 @@ namespace SohImGui {
|
|||||||
std::string MinusBTNFPSI = " - ##FPSInterpolation";
|
std::string MinusBTNFPSI = " - ##FPSInterpolation";
|
||||||
std::string PlusBTNFPSI = " + ##FPSInterpolation";
|
std::string PlusBTNFPSI = " + ##FPSInterpolation";
|
||||||
if (ImGui::Button(MinusBTNFPSI.c_str())) {
|
if (ImGui::Button(MinusBTNFPSI.c_str())) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
if (val >= 60) val = 30;
|
||||||
|
else val = 20;
|
||||||
|
#else
|
||||||
val--;
|
val--;
|
||||||
|
#endif
|
||||||
CVar_SetS32(fps_cvar, val);
|
CVar_SetS32(fps_cvar, val);
|
||||||
needs_save = true;
|
needs_save = true;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
||||||
|
#endif
|
||||||
if (ImGui::SliderInt("##FPSInterpolation", &val, minFps, maxFps, "", ImGuiSliderFlags_AlwaysClamp))
|
if (ImGui::SliderInt("##FPSInterpolation", &val, minFps, maxFps, "", ImGuiSliderFlags_AlwaysClamp))
|
||||||
{
|
{
|
||||||
|
#ifdef __WIIU__
|
||||||
|
// only support divisors of 60 on the Wii U
|
||||||
|
val = 60 / (60 / val);
|
||||||
|
#endif
|
||||||
if (val > 360)
|
if (val > 360)
|
||||||
{
|
{
|
||||||
val = 360;
|
val = 360;
|
||||||
@ -1490,7 +1608,12 @@ namespace SohImGui {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
||||||
if (ImGui::Button(PlusBTNFPSI.c_str())) {
|
if (ImGui::Button(PlusBTNFPSI.c_str())) {
|
||||||
|
#ifdef __WIIU__
|
||||||
|
if (val <= 20) val = 30;
|
||||||
|
else val = 60;
|
||||||
|
#else
|
||||||
val++;
|
val++;
|
||||||
|
#endif
|
||||||
CVar_SetS32(fps_cvar, val);
|
CVar_SetS32(fps_cvar, val);
|
||||||
needs_save = true;
|
needs_save = true;
|
||||||
}
|
}
|
||||||
@ -1632,7 +1755,6 @@ namespace SohImGui {
|
|||||||
else {
|
else {
|
||||||
lastBetaQuestWorld = betaQuestWorld = 0xFFEF;
|
lastBetaQuestWorld = betaQuestWorld = 0xFFEF;
|
||||||
CVar_SetS32("gBetaQuestWorld", betaQuestWorld);
|
CVar_SetS32("gBetaQuestWorld", betaQuestWorld);
|
||||||
needs_save = true;
|
|
||||||
}
|
}
|
||||||
if (betaQuestEnabled != lastBetaQuestEnabled || betaQuestWorld != lastBetaQuestWorld)
|
if (betaQuestEnabled != lastBetaQuestEnabled || betaQuestWorld != lastBetaQuestWorld)
|
||||||
{
|
{
|
||||||
@ -1791,14 +1913,18 @@ namespace SohImGui {
|
|||||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
||||||
ImGui::Begin("Debug Stats", &statsWindowOpen, ImGuiWindowFlags_NoFocusOnAppearing);
|
ImGui::Begin("Debug Stats", &statsWindowOpen, ImGuiWindowFlags_NoFocusOnAppearing);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
ImGui::Text("Platform: Windows");
|
ImGui::Text("Platform: Windows");
|
||||||
#elif __APPLE__
|
#elif defined(__APPLE__)
|
||||||
ImGui::Text("Platform: macOS");
|
ImGui::Text("Platform: macOS");
|
||||||
#elif defined(__SWITCH__)
|
#elif defined(__SWITCH__)
|
||||||
ImGui::Text("Platform: Nintendo Switch");
|
ImGui::Text("Platform: Nintendo Switch");
|
||||||
#else
|
#elif defined(__WIIU__)
|
||||||
|
ImGui::Text("Platform: Nintendo Wii U");
|
||||||
|
#elif defined(__linux__)
|
||||||
ImGui::Text("Platform: Linux");
|
ImGui::Text("Platform: Linux");
|
||||||
|
#else
|
||||||
|
ImGui::Text("Platform: Unknown");
|
||||||
#endif
|
#endif
|
||||||
ImGui::Text("Status: %.3f ms/frame (%.1f FPS)", 1000.0f / framerate, framerate);
|
ImGui::Text("Status: %.3f ms/frame (%.1f FPS)", 1000.0f / framerate, framerate);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@ -1950,6 +2076,21 @@ namespace SohImGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void applyEnhancementPresetDefault(void) {
|
void applyEnhancementPresetDefault(void) {
|
||||||
|
// D-pad Support on Pause and File Select
|
||||||
|
CVar_SetS32("gDpadPauseName", 0);
|
||||||
|
// D-pad Support in Ocarina and Text Choice
|
||||||
|
CVar_SetS32("gDpadOcarinaText", 0);
|
||||||
|
// D-pad Support for Browsing Shop Items
|
||||||
|
CVar_SetS32("gDpadShop", 0);
|
||||||
|
// D-pad as Equip Items
|
||||||
|
CVar_SetS32("gDpadEquips", 0);
|
||||||
|
// Allow the cursor to be on any slot
|
||||||
|
CVar_SetS32("gPauseAnyCursor", 0);
|
||||||
|
// Prevent Dropped Ocarina Inputs
|
||||||
|
CVar_SetS32("gDpadNoDropOcarinaInput", 0);
|
||||||
|
// Answer Navi Prompt with L Button
|
||||||
|
CVar_SetS32("gNaviOnL", 0);
|
||||||
|
|
||||||
// Text Speed (1 to 5)
|
// Text Speed (1 to 5)
|
||||||
CVar_SetS32("gTextSpeed", 1);
|
CVar_SetS32("gTextSpeed", 1);
|
||||||
// King Zora Speed (1 to 5)
|
// King Zora Speed (1 to 5)
|
||||||
@ -1958,8 +2099,10 @@ namespace SohImGui {
|
|||||||
CVar_SetS32("gForgeTime", 3);
|
CVar_SetS32("gForgeTime", 3);
|
||||||
// Vine/Ladder Climb speed (+0 to +12)
|
// Vine/Ladder Climb speed (+0 to +12)
|
||||||
CVar_SetS32("gClimbSpeed", 0);
|
CVar_SetS32("gClimbSpeed", 0);
|
||||||
// Faster Block Push
|
// Faster Block Push (+0 to +5)
|
||||||
CVar_SetS32("gFasterBlockPush", 0);
|
CVar_SetS32("gFasterBlockPush", 0);
|
||||||
|
// Faster Heavy Block Lift
|
||||||
|
CVar_SetS32("gFasterHeavyBlockLift", 0);
|
||||||
// No Forced Navi
|
// No Forced Navi
|
||||||
CVar_SetS32("gNoForcedNavi", 0);
|
CVar_SetS32("gNoForcedNavi", 0);
|
||||||
// No Skulltula Freeze
|
// No Skulltula Freeze
|
||||||
@ -1974,12 +2117,14 @@ namespace SohImGui {
|
|||||||
CVar_SetS32("gBetterOwl", 0);
|
CVar_SetS32("gBetterOwl", 0);
|
||||||
// Fast Ocarina Playback
|
// Fast Ocarina Playback
|
||||||
CVar_SetS32("gFastOcarinaPlayback", 0);
|
CVar_SetS32("gFastOcarinaPlayback", 0);
|
||||||
// Prevent Dropped Ocarina Inputs
|
|
||||||
CVar_SetS32("gDpadNoDropOcarinaInput", 0);
|
|
||||||
// Instant Putaway
|
// Instant Putaway
|
||||||
CVar_SetS32("gInstantPutaway", 0);
|
CVar_SetS32("gInstantPutaway", 0);
|
||||||
|
// Instant Boomerang Recall
|
||||||
|
CVar_SetS32("gFastBoomerang", 0);
|
||||||
// Mask Select in Inventory
|
// Mask Select in Inventory
|
||||||
CVar_SetS32("gMaskSelect", 0);
|
CVar_SetS32("gMaskSelect", 0);
|
||||||
|
// Remember Save Location
|
||||||
|
CVar_SetS32("gRememberSaveLocation", 0);
|
||||||
|
|
||||||
// Damage Multiplier (0 to 8)
|
// Damage Multiplier (0 to 8)
|
||||||
CVar_SetS32("gDamageMul", 0);
|
CVar_SetS32("gDamageMul", 0);
|
||||||
@ -2061,14 +2206,14 @@ namespace SohImGui {
|
|||||||
CVar_SetS32("gVisualAgony", 0);
|
CVar_SetS32("gVisualAgony", 0);
|
||||||
// Assignable Tunics and Boots
|
// Assignable Tunics and Boots
|
||||||
CVar_SetS32("gAssignableTunicsAndBoots", 0);
|
CVar_SetS32("gAssignableTunicsAndBoots", 0);
|
||||||
|
// Equipment Toggle
|
||||||
|
CVar_SetS32("gEquipmentCanBeRemoved", 0);
|
||||||
// Link's Cow in Both Time Periods
|
// Link's Cow in Both Time Periods
|
||||||
CVar_SetS32("gCowOfTime", 0);
|
CVar_SetS32("gCowOfTime", 0);
|
||||||
// Enable visible guard vision
|
// Enable visible guard vision
|
||||||
CVar_SetS32("gGuardVision", 0);
|
CVar_SetS32("gGuardVision", 0);
|
||||||
// Enable passage of time on file select
|
// Enable passage of time on file select
|
||||||
CVar_SetS32("gTimeFlowFileSelect", 0);
|
CVar_SetS32("gTimeFlowFileSelect", 0);
|
||||||
// Allow the cursor to be on any slot
|
|
||||||
CVar_SetS32("gPauseAnyCursor", 0);
|
|
||||||
// Count Golden Skulltulas
|
// Count Golden Skulltulas
|
||||||
CVar_SetS32("gInjectSkulltulaCount", 0);
|
CVar_SetS32("gInjectSkulltulaCount", 0);
|
||||||
// Pull grave during the day
|
// Pull grave during the day
|
||||||
@ -2121,19 +2266,30 @@ namespace SohImGui {
|
|||||||
CVar_SetS32("gN64WeirdFrames", 0);
|
CVar_SetS32("gN64WeirdFrames", 0);
|
||||||
// Bombchus out of bounds
|
// Bombchus out of bounds
|
||||||
CVar_SetS32("gBombchusOOB", 0);
|
CVar_SetS32("gBombchusOOB", 0);
|
||||||
|
|
||||||
|
CVar_SetS32("gGsCutscene", 0);
|
||||||
|
// Autosave
|
||||||
|
CVar_SetS32("gAutosave", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyEnhancementPresetVanillaPlus(void) {
|
void applyEnhancementPresetVanillaPlus(void) {
|
||||||
|
// D-pad Support in Ocarina and Text Choice
|
||||||
|
CVar_SetS32("gDpadOcarinaText", 1);
|
||||||
|
// D-pad Support for Browsing Shop Items
|
||||||
|
CVar_SetS32("gDpadShop", 1);
|
||||||
|
// D-pad as Equip Items
|
||||||
|
CVar_SetS32("gDpadEquips", 1);
|
||||||
|
// Prevent Dropped Ocarina Inputs
|
||||||
|
CVar_SetS32("gDpadNoDropOcarinaInput", 1);
|
||||||
|
|
||||||
// Text Speed (1 to 5)
|
// Text Speed (1 to 5)
|
||||||
CVar_SetS32("gTextSpeed", 5);
|
CVar_SetS32("gTextSpeed", 5);
|
||||||
// King Zora Speed (1 to 5)
|
// King Zora Speed (1 to 5)
|
||||||
CVar_SetS32("gMweepSpeed", 2);
|
CVar_SetS32("gMweepSpeed", 2);
|
||||||
// Faster Block Push
|
// Faster Block Push (+0 to +5)
|
||||||
CVar_SetS32("gFasterBlockPush", 1);
|
CVar_SetS32("gFasterBlockPush", 5);
|
||||||
// Better Owl
|
// Better Owl
|
||||||
CVar_SetS32("gBetterOwl", 1);
|
CVar_SetS32("gBetterOwl", 1);
|
||||||
// Prevent Dropped Ocarina Inputs
|
|
||||||
CVar_SetS32("gDpadNoDropOcarinaInput", 1);
|
|
||||||
|
|
||||||
// Assignable Tunics and Boots
|
// Assignable Tunics and Boots
|
||||||
CVar_SetS32("gAssignableTunicsAndBoots", 1);
|
CVar_SetS32("gAssignableTunicsAndBoots", 1);
|
||||||
@ -2178,6 +2334,8 @@ namespace SohImGui {
|
|||||||
CVar_SetS32("gForgeTime", 0);
|
CVar_SetS32("gForgeTime", 0);
|
||||||
// Vine/Ladder Climb speed (+0 to +12)
|
// Vine/Ladder Climb speed (+0 to +12)
|
||||||
CVar_SetS32("gClimbSpeed", 1);
|
CVar_SetS32("gClimbSpeed", 1);
|
||||||
|
// Faster Heavy Block Lift
|
||||||
|
CVar_SetS32("gFasterHeavyBlockLift", 1);
|
||||||
// No Forced Navi
|
// No Forced Navi
|
||||||
CVar_SetS32("gNoForcedNavi", 1);
|
CVar_SetS32("gNoForcedNavi", 1);
|
||||||
// No Skulltula Freeze
|
// No Skulltula Freeze
|
||||||
@ -2192,12 +2350,16 @@ namespace SohImGui {
|
|||||||
CVar_SetS32("gFastOcarinaPlayback", 1);
|
CVar_SetS32("gFastOcarinaPlayback", 1);
|
||||||
// Instant Putaway
|
// Instant Putaway
|
||||||
CVar_SetS32("gInstantPutaway", 1);
|
CVar_SetS32("gInstantPutaway", 1);
|
||||||
|
// Instant Boomerang Recall
|
||||||
|
CVar_SetS32("gFastBoomerang", 1);
|
||||||
// Mask Select in Inventory
|
// Mask Select in Inventory
|
||||||
CVar_SetS32("gMaskSelect", 1);
|
CVar_SetS32("gMaskSelect", 1);
|
||||||
|
|
||||||
// Disable Navi Call Audio
|
// Disable Navi Call Audio
|
||||||
CVar_SetS32("gDisableNaviCallAudio", 1);
|
CVar_SetS32("gDisableNaviCallAudio", 1);
|
||||||
|
|
||||||
|
// Equipment Toggle
|
||||||
|
CVar_SetS32("gEquipmentCanBeRemoved", 1);
|
||||||
// Count Golden Skulltulas
|
// Count Golden Skulltulas
|
||||||
CVar_SetS32("gInjectSkulltulaCount", 1);
|
CVar_SetS32("gInjectSkulltulaCount", 1);
|
||||||
|
|
||||||
@ -2209,6 +2371,9 @@ namespace SohImGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void applyEnhancementPresetRandomizer(void) {
|
void applyEnhancementPresetRandomizer(void) {
|
||||||
|
// Allow the cursor to be on any slot
|
||||||
|
CVar_SetS32("gPauseAnyCursor", 1);
|
||||||
|
|
||||||
// Instant Fishing
|
// Instant Fishing
|
||||||
CVar_SetS32("gInstantFishing", 1);
|
CVar_SetS32("gInstantFishing", 1);
|
||||||
// Guarantee Bite
|
// Guarantee Bite
|
||||||
@ -2220,8 +2385,6 @@ namespace SohImGui {
|
|||||||
|
|
||||||
// Visual Stone of Agony
|
// Visual Stone of Agony
|
||||||
CVar_SetS32("gVisualAgony", 1);
|
CVar_SetS32("gVisualAgony", 1);
|
||||||
// Allow the cursor to be on any slot
|
|
||||||
CVar_SetS32("gPauseAnyCursor", 1);
|
|
||||||
// Pull grave during the day
|
// Pull grave during the day
|
||||||
CVar_SetS32("gDayGravePull", 1);
|
CVar_SetS32("gDayGravePull", 1);
|
||||||
|
|
||||||
@ -2281,6 +2444,13 @@ namespace SohImGui {
|
|||||||
return gfx_d3d11_get_texture_by_id(id);
|
return gfx_d3d11_get_texture_by_id(id);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __WIIU__
|
||||||
|
if (impl.backend == Backend::GX2)
|
||||||
|
{
|
||||||
|
return gfx_gx2_texture_for_imgui(id);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return reinterpret_cast<ImTextureID>(id);
|
return reinterpret_cast<ImTextureID>(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ struct GameAsset {
|
|||||||
namespace SohImGui {
|
namespace SohImGui {
|
||||||
enum class Backend {
|
enum class Backend {
|
||||||
DX11,
|
DX11,
|
||||||
SDL
|
SDL,
|
||||||
|
GX2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Dialogues {
|
enum class Dialogues {
|
||||||
@ -45,6 +46,10 @@ namespace SohImGui {
|
|||||||
void* window;
|
void* window;
|
||||||
void* context;
|
void* context;
|
||||||
} sdl;
|
} sdl;
|
||||||
|
struct {
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
} gx2;
|
||||||
};
|
};
|
||||||
} WindowImpl;
|
} WindowImpl;
|
||||||
|
|
||||||
@ -58,6 +63,9 @@ namespace SohImGui {
|
|||||||
struct {
|
struct {
|
||||||
void* event;
|
void* event;
|
||||||
} sdl;
|
} sdl;
|
||||||
|
struct {
|
||||||
|
void* input;
|
||||||
|
} gx2;
|
||||||
} EventImpl;
|
} EventImpl;
|
||||||
|
|
||||||
extern WindowImpl impl;
|
extern WindowImpl impl;
|
||||||
|
@ -16,7 +16,7 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Controller> GetControllerPerSlot(int slot) {
|
std::shared_ptr<Controller> GetControllerPerSlot(int slot) {
|
||||||
auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck();
|
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck();
|
||||||
return controlDeck->GetPhysicalDeviceFromVirtualSlot(slot);
|
return controlDeck->GetPhysicalDeviceFromVirtualSlot(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,12 +45,15 @@ namespace Ship {
|
|||||||
if(btn != -1) {
|
if(btn != -1) {
|
||||||
backend->SetButtonMapping(CurrentPort, n64Btn, btn);
|
backend->SetButtonMapping(CurrentPort, n64Btn, btn);
|
||||||
BtnReading = -1;
|
BtnReading = -1;
|
||||||
|
|
||||||
|
// avoid immediately triggering another button during gamepad nav
|
||||||
|
ImGui::SetKeyboardFocusHere(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* BtnName = backend->GetButtonName(CurrentPort, n64Btn);
|
const std::string BtnName = backend->GetButtonName(CurrentPort, n64Btn);
|
||||||
|
|
||||||
if (ImGui::Button(StringHelper::Sprintf("%s##HBTNID_%d", readingMode ? "Press a Key..." : BtnName, n64Btn).c_str())) {
|
if (ImGui::Button(StringHelper::Sprintf("%s##HBTNID_%d", readingMode ? "Press a Key..." : BtnName.c_str(), n64Btn).c_str())) {
|
||||||
BtnReading = n64Btn;
|
BtnReading = n64Btn;
|
||||||
backend->ClearRawPress();
|
backend->ClearRawPress();
|
||||||
}
|
}
|
||||||
@ -82,18 +85,17 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InputEditor::DrawControllerSchema() {
|
void InputEditor::DrawControllerSchema() {
|
||||||
auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck();
|
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck();
|
||||||
auto Backend = controlDeck->GetPhysicalDeviceFromVirtualSlot(CurrentPort);
|
auto Backend = controlDeck->GetPhysicalDeviceFromVirtualSlot(CurrentPort);
|
||||||
DeviceProfile& profile = Backend->profiles[CurrentPort];
|
auto profile = Backend->getProfile(CurrentPort);
|
||||||
float sensitivity = profile.Thresholds[SENSITIVITY];
|
|
||||||
bool IsKeyboard = Backend->GetGuid() == "Keyboard" || Backend->GetGuid() == "Auto" || !Backend->Connected();
|
bool IsKeyboard = Backend->GetGuid() == "Keyboard" || Backend->GetGuid() == "Auto" || !Backend->Connected();
|
||||||
const char* ControllerName = Backend->GetControllerName();
|
std::string ControllerName = Backend->GetControllerName();
|
||||||
|
|
||||||
if (ControllerName != nullptr && ImGui::BeginCombo("##ControllerEntries", ControllerName)) {
|
if (ImGui::BeginCombo("##ControllerEntries", ControllerName.c_str())) {
|
||||||
for (uint8_t i = 0; i < controlDeck->GetNumPhysicalDevices(); i++) {
|
for (uint8_t i = 0; i < controlDeck->GetNumPhysicalDevices(); i++) {
|
||||||
std::string DeviceName = controlDeck->GetPhysicalDevice(i)->GetControllerName();
|
std::string DeviceName = controlDeck->GetPhysicalDevice(i)->GetControllerName();
|
||||||
if (DeviceName != "Keyboard" && DeviceName != "Auto") {
|
if (DeviceName != "Keyboard" && DeviceName != "Auto") {
|
||||||
DeviceName+="##"+std::to_string(i);
|
DeviceName += "##"+std::to_string(i);
|
||||||
}
|
}
|
||||||
if (ImGui::Selectable(DeviceName.c_str(), i == controlDeck->GetVirtualDevice(CurrentPort))) {
|
if (ImGui::Selectable(DeviceName.c_str(), i == controlDeck->GetVirtualDevice(CurrentPort))) {
|
||||||
controlDeck->SetPhysicalDevice(CurrentPort, i);
|
controlDeck->SetPhysicalDevice(CurrentPort, i);
|
||||||
@ -142,15 +144,28 @@ namespace Ship {
|
|||||||
|
|
||||||
if (!IsKeyboard) {
|
if (!IsKeyboard) {
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
|
||||||
DrawVirtualStick("##MainVirtualStick", ImVec2(Backend->wStickX, Backend->wStickY));
|
DrawVirtualStick("##MainVirtualStick", ImVec2(Backend->getLeftStickX(CurrentPort), Backend->getLeftStickY(CurrentPort)));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||||
|
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::BeginChild("##MSInput", ImVec2(90 * 2, 50 * 2), false);
|
||||||
|
#else
|
||||||
ImGui::BeginChild("##MSInput", ImVec2(90, 50), false);
|
ImGui::BeginChild("##MSInput", ImVec2(90, 50), false);
|
||||||
|
#endif
|
||||||
ImGui::Text("Deadzone");
|
ImGui::Text("Deadzone");
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(80 * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(80);
|
ImGui::PushItemWidth(80);
|
||||||
ImGui::InputFloat("##MDZone", &profile.Thresholds[LEFT_STICK], 1.0f, 0.0f, "%.0f");
|
#endif
|
||||||
|
// The window has deadzone per stick, so we need to
|
||||||
|
// set the deadzone for both left stick axes here
|
||||||
|
// SDL_CONTROLLER_AXIS_LEFTX: 0
|
||||||
|
// SDL_CONTROLLER_AXIS_LEFTY: 1
|
||||||
|
ImGui::InputFloat("##MDZone", &profile->AxisDeadzones[0], 1.0f, 0.0f, "%.0f");
|
||||||
|
profile->AxisDeadzones[1] = profile->AxisDeadzones[0];
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
} else {
|
} else {
|
||||||
@ -165,25 +180,36 @@ namespace Ship {
|
|||||||
|
|
||||||
if (!IsKeyboard) {
|
if (!IsKeyboard) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
SohImGui::BeginGroupPanel("Camera Stick", ImVec2(150, 20));
|
SohImGui::BeginGroupPanel("Right Stick", ImVec2(150, 20));
|
||||||
DrawButton("Up", BTN_VSTICKUP);
|
DrawButton("Up", BTN_VSTICKUP);
|
||||||
DrawButton("Down", BTN_VSTICKDOWN);
|
DrawButton("Down", BTN_VSTICKDOWN);
|
||||||
DrawButton("Left", BTN_VSTICKLEFT);
|
DrawButton("Left", BTN_VSTICKLEFT);
|
||||||
DrawButton("Right", BTN_VSTICKRIGHT);
|
DrawButton("Right", BTN_VSTICKRIGHT);
|
||||||
|
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
|
||||||
DrawVirtualStick("##CameraVirtualStick", ImVec2(Backend->wCamX / sensitivity, Backend->wCamY / sensitivity));
|
// 2 is the SDL value for right stick X axis
|
||||||
|
// 3 is the SDL value for right stick Y axis.
|
||||||
|
DrawVirtualStick("##RightVirtualStick", ImVec2(Backend->getRightStickX(CurrentPort), Backend->getRightStickY(CurrentPort)));
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::BeginChild("##CSInput", ImVec2(90 * 2, 85 * 2), false);
|
||||||
|
#else
|
||||||
ImGui::BeginChild("##CSInput", ImVec2(90, 85), false);
|
ImGui::BeginChild("##CSInput", ImVec2(90, 85), false);
|
||||||
|
#endif
|
||||||
ImGui::Text("Deadzone");
|
ImGui::Text("Deadzone");
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(80 * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(80);
|
ImGui::PushItemWidth(80);
|
||||||
ImGui::InputFloat("##MDZone", &profile.Thresholds[RIGHT_STICK], 1.0f, 0.0f, "%.0f");
|
#endif
|
||||||
ImGui::PopItemWidth();
|
// The window has deadzone per stick, so we need to
|
||||||
ImGui::Text("Sensitivity");
|
// set the deadzone for both right stick axes here
|
||||||
ImGui::PushItemWidth(80);
|
// SDL_CONTROLLER_AXIS_RIGHTX: 2
|
||||||
ImGui::InputFloat("##MSensitivity", &profile.Thresholds[SENSITIVITY], 1.0f, 0.0f, "%.0f");
|
// SDL_CONTROLLER_AXIS_RIGHTY: 3
|
||||||
|
ImGui::InputFloat("##MDZone", &profile->AxisDeadzones[2], 1.0f, 0.0f, "%.0f");
|
||||||
|
profile->AxisDeadzones[3] = profile->AxisDeadzones[2];
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
@ -194,37 +220,54 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(Backend->CanGyro()) {
|
if(Backend->CanGyro()) {
|
||||||
|
#ifndef __WIIU__
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
#endif
|
||||||
SohImGui::BeginGroupPanel("Gyro Options", ImVec2(175, 20));
|
SohImGui::BeginGroupPanel("Gyro Options", ImVec2(175, 20));
|
||||||
float cursorX = ImGui::GetCursorPosX() + 5;
|
float cursorX = ImGui::GetCursorPosX() + 5;
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
ImGui::Checkbox("Enable Gyro", &profile.UseGyro);
|
ImGui::Checkbox("Enable Gyro", &profile->UseGyro);
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
ImGui::Text("Gyro Sensitivity: %d%%", static_cast<int>(100.0f * profile.Thresholds[GYRO_SENSITIVITY]));
|
ImGui::Text("Gyro Sensitivity: %d%%", static_cast<int>(100.0f * profile->GyroData[GYRO_SENSITIVITY]));
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(135.0f * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(135.0f);
|
ImGui::PushItemWidth(135.0f);
|
||||||
|
#endif
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
ImGui::SliderFloat("##GSensitivity", &profile.Thresholds[GYRO_SENSITIVITY], 0.0f, 1.0f, "");
|
ImGui::SliderFloat("##GSensitivity", &profile->GyroData[GYRO_SENSITIVITY], 0.0f, 1.0f, "");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::Dummy(ImVec2(0, 1));
|
ImGui::Dummy(ImVec2(0, 1));
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
if (ImGui::Button("Recalibrate Gyro##RGyro")) {
|
if (ImGui::Button("Recalibrate Gyro##RGyro")) {
|
||||||
profile.Thresholds[DRIFT_X] = 0.0f;
|
profile->GyroData[DRIFT_X] = 0.0f;
|
||||||
profile.Thresholds[DRIFT_Y] = 0.0f;
|
profile->GyroData[DRIFT_Y] = 0.0f;
|
||||||
}
|
}
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
DrawVirtualStick("##GyroPreview", ImVec2(-10.0f * Backend->wGyroY, 10.0f * Backend->wGyroX));
|
DrawVirtualStick("##GyroPreview", ImVec2(-10.0f * Backend->getGyroY(CurrentPort), 10.0f * Backend->getGyroX(CurrentPort)));
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::BeginChild("##GyInput", ImVec2(90 * 2, 85 * 2), false);
|
||||||
|
#else
|
||||||
ImGui::BeginChild("##GyInput", ImVec2(90, 85), false);
|
ImGui::BeginChild("##GyInput", ImVec2(90, 85), false);
|
||||||
|
#endif
|
||||||
ImGui::Text("Drift X");
|
ImGui::Text("Drift X");
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(80 * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(80);
|
ImGui::PushItemWidth(80);
|
||||||
ImGui::InputFloat("##GDriftX", &profile.Thresholds[DRIFT_X], 1.0f, 0.0f, "%.1f");
|
#endif
|
||||||
|
ImGui::InputFloat("##GDriftX", &profile->GyroData[DRIFT_X], 1.0f, 0.0f, "%.1f");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::Text("Drift Y");
|
ImGui::Text("Drift Y");
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(80 * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(80);
|
ImGui::PushItemWidth(80);
|
||||||
ImGui::InputFloat("##GDriftY", &profile.Thresholds[DRIFT_Y], 1.0f, 0.0f, "%.1f");
|
#endif
|
||||||
|
ImGui::InputFloat("##GDriftY", &profile->GyroData[DRIFT_Y], 1.0f, 0.0f, "%.1f");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
@ -249,19 +292,25 @@ namespace Ship {
|
|||||||
ImGui::SetCursorPosX(cursor.x);
|
ImGui::SetCursorPosX(cursor.x);
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
ImGui::SetCursorPosY(cursor.y + 167);
|
ImGui::SetCursorPosY(cursor.y + 167);
|
||||||
|
#elif defined(__WIIU__)
|
||||||
|
ImGui::SetCursorPosY(cursor.y + 120 * 2);
|
||||||
#else
|
#else
|
||||||
ImGui::SetCursorPosY(cursor.y + 120);
|
ImGui::SetCursorPosY(cursor.y + 120);
|
||||||
#endif
|
#endif
|
||||||
SohImGui::BeginGroupPanel("Options", ImVec2(158, 20));
|
SohImGui::BeginGroupPanel("Options", ImVec2(158, 20));
|
||||||
float cursorX = ImGui::GetCursorPosX() + 5;
|
float cursorX = ImGui::GetCursorPosX() + 5;
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
ImGui::Checkbox("Rumble Enabled", &profile.UseRumble);
|
ImGui::Checkbox("Rumble Enabled", &profile->UseRumble);
|
||||||
if (Backend->CanRumble()) {
|
if (Backend->CanRumble()) {
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
ImGui::Text("Rumble Force: %d%%", static_cast<int>(100.0f * profile.RumbleStrength));
|
ImGui::Text("Rumble Force: %d%%", static_cast<int>(100.0f * profile->RumbleStrength));
|
||||||
ImGui::SetCursorPosX(cursorX);
|
ImGui::SetCursorPosX(cursorX);
|
||||||
|
#ifdef __WIIU__
|
||||||
|
ImGui::PushItemWidth(135.0f * 2);
|
||||||
|
#else
|
||||||
ImGui::PushItemWidth(135.0f);
|
ImGui::PushItemWidth(135.0f);
|
||||||
ImGui::SliderFloat("##RStrength", &profile.RumbleStrength, 0.0f, 1.0f, "");
|
#endif
|
||||||
|
ImGui::SliderFloat("##RStrength", &profile->RumbleStrength, 0.0f, 1.0f, "");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
}
|
}
|
||||||
ImGui::Dummy(ImVec2(0, 5));
|
ImGui::Dummy(ImVec2(0, 5));
|
||||||
@ -278,6 +327,9 @@ namespace Ship {
|
|||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
ImVec2 minSize = ImVec2(641, 250);
|
ImVec2 minSize = ImVec2(641, 250);
|
||||||
ImVec2 maxSize = ImVec2(2200, 505);
|
ImVec2 maxSize = ImVec2(2200, 505);
|
||||||
|
#elif defined(__WIIU__)
|
||||||
|
ImVec2 minSize = ImVec2(641 * 2, 250 * 2);
|
||||||
|
ImVec2 maxSize = ImVec2(1200 * 2, 290 * 2);
|
||||||
#else
|
#else
|
||||||
ImVec2 minSize = ImVec2(641, 250);
|
ImVec2 minSize = ImVec2(641, 250);
|
||||||
ImVec2 maxSize = ImVec2(1200, 290);
|
ImVec2 maxSize = ImVec2(1200, 290);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Hooks.h"
|
#include "Hooks.h"
|
||||||
#include "GlobalCtx2.h"
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
@ -17,13 +17,12 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardController::PressButton(int32_t dwScancode) {
|
bool KeyboardController::PressButton(int32_t dwScancode) {
|
||||||
|
|
||||||
lastKey = dwScancode;
|
lastKey = dwScancode;
|
||||||
|
|
||||||
for (int slot = 0; slot < MAXCONTROLLERS; slot++) {
|
for (int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
|
||||||
|
|
||||||
if (profiles[slot].Mappings.contains(dwScancode)) {
|
if (getProfile(virtualSlot)->Mappings.contains(dwScancode)) {
|
||||||
dwPressedButtons[slot] |= profiles[slot].Mappings[dwScancode];
|
getPressedButtons(virtualSlot) |= getProfile(virtualSlot)->Mappings[dwScancode];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,9 +31,9 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardController::ReleaseButton(int32_t dwScancode) {
|
bool KeyboardController::ReleaseButton(int32_t dwScancode) {
|
||||||
for (int slot = 0; slot < MAXCONTROLLERS; slot++) {
|
for (int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
|
||||||
if (profiles[slot].Mappings.contains(dwScancode)) {
|
if (getProfile(virtualSlot)->Mappings.contains(dwScancode)) {
|
||||||
dwPressedButtons[slot] &= ~profiles[slot].Mappings[dwScancode];
|
getPressedButtons(virtualSlot) &= ~getProfile(virtualSlot)->Mappings[dwScancode];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,16 +42,16 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardController::ReleaseAllButtons() {
|
void KeyboardController::ReleaseAllButtons() {
|
||||||
for(int slot = 0; slot < MAXCONTROLLERS; slot++) {
|
for(int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
|
||||||
dwPressedButtons[slot] = 0;
|
getPressedButtons(virtualSlot) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardController::ReadFromSource(int32_t slot) {
|
void KeyboardController::ReadFromSource(int32_t virtualSlot) {
|
||||||
wStickX = 0;
|
getLeftStickX(virtualSlot) = 0;
|
||||||
wStickY = 0;
|
getLeftStickY(virtualSlot) = 0;
|
||||||
wCamX = 0;
|
getRightStickX(virtualSlot) = 0;
|
||||||
wCamY = 0;
|
getRightStickY(virtualSlot) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t KeyboardController::ReadRawPress() {
|
int32_t KeyboardController::ReadRawPress() {
|
||||||
@ -60,46 +59,45 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KeyboardController::WriteToSource(int32_t slot, ControllerCallback* controller)
|
void KeyboardController::WriteToSource(int32_t virtualSlot, ControllerCallback* controller) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* KeyboardController::GetButtonName(int slot, int n64Button) {
|
const std::string KeyboardController::GetButtonName(int32_t virtualSlot, int32_t n64Button) {
|
||||||
std::map<int32_t, int32_t>& Mappings = profiles[slot].Mappings;
|
std::map<int32_t, int32_t>& Mappings = getProfile(virtualSlot)->Mappings;
|
||||||
const auto find = std::find_if(Mappings.begin(), Mappings.end(), [n64Button](const std::pair<int32_t, int32_t>& pair) {
|
const auto find = std::find_if(Mappings.begin(), Mappings.end(), [n64Button](const std::pair<int32_t, int32_t>& pair) {
|
||||||
return pair.second == n64Button;
|
return pair.second == n64Button;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (find == Mappings.end()) return "Unknown";
|
if (find == Mappings.end()) return "Unknown";
|
||||||
const char* name = GlobalCtx2::GetInstance()->GetWindow()->GetKeyName(find->first);
|
const char* name = Window::GetInstance()->GetKeyName(find->first);
|
||||||
return strlen(name) == 0 ? "Unknown" : name;
|
return strlen(name) == 0 ? "Unknown" : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KeyboardController::CreateDefaultBinding(int32_t slot) {
|
void KeyboardController::CreateDefaultBinding(int32_t virtualSlot) {
|
||||||
DeviceProfile& profile = profiles[slot];
|
auto profile = getProfile(virtualSlot);
|
||||||
profile.Mappings[0x14D] = BTN_CRIGHT;
|
profile->Mappings[0x14D] = BTN_CRIGHT;
|
||||||
profile.Mappings[0x14B] = BTN_CLEFT;
|
profile->Mappings[0x14B] = BTN_CLEFT;
|
||||||
profile.Mappings[0x150] = BTN_CDOWN;
|
profile->Mappings[0x150] = BTN_CDOWN;
|
||||||
profile.Mappings[0x148] = BTN_CUP;
|
profile->Mappings[0x148] = BTN_CUP;
|
||||||
profile.Mappings[0x13] = BTN_R;
|
profile->Mappings[0x13] = BTN_R;
|
||||||
profile.Mappings[0x12] = BTN_L;
|
profile->Mappings[0x12] = BTN_L;
|
||||||
profile.Mappings[0x023] = BTN_DRIGHT;
|
profile->Mappings[0x023] = BTN_DRIGHT;
|
||||||
profile.Mappings[0x021] = BTN_DLEFT;
|
profile->Mappings[0x021] = BTN_DLEFT;
|
||||||
profile.Mappings[0x022] = BTN_DDOWN;
|
profile->Mappings[0x022] = BTN_DDOWN;
|
||||||
profile.Mappings[0x014] = BTN_DUP;
|
profile->Mappings[0x014] = BTN_DUP;
|
||||||
profile.Mappings[0x039] = BTN_START;
|
profile->Mappings[0x039] = BTN_START;
|
||||||
profile.Mappings[0x02C] = BTN_Z;
|
profile->Mappings[0x02C] = BTN_Z;
|
||||||
profile.Mappings[0x02E] = BTN_B;
|
profile->Mappings[0x02E] = BTN_B;
|
||||||
profile.Mappings[0x02D] = BTN_A;
|
profile->Mappings[0x02D] = BTN_A;
|
||||||
profile.Mappings[0x020] = BTN_STICKRIGHT;
|
profile->Mappings[0x020] = BTN_STICKRIGHT;
|
||||||
profile.Mappings[0x01E] = BTN_STICKLEFT;
|
profile->Mappings[0x01E] = BTN_STICKLEFT;
|
||||||
profile.Mappings[0x01F] = BTN_STICKDOWN;
|
profile->Mappings[0x01F] = BTN_STICKDOWN;
|
||||||
profile.Mappings[0x011] = BTN_STICKUP;
|
profile->Mappings[0x011] = BTN_STICKUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* KeyboardController::GetControllerName() {
|
const std::string KeyboardController::GetControllerName() {
|
||||||
return "Keyboard";
|
return "Keyboard";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@ namespace Ship {
|
|||||||
public:
|
public:
|
||||||
KeyboardController();
|
KeyboardController();
|
||||||
|
|
||||||
void ReadFromSource(int32_t slot) override;
|
void ReadFromSource(int32_t virtualSlot) override;
|
||||||
void WriteToSource(int32_t slot, ControllerCallback* controller) override;
|
void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) override;
|
||||||
bool Connected() const override { return true; }
|
bool Connected() const override { return true; }
|
||||||
bool CanRumble() const override { return false; }
|
bool CanRumble() const override { return false; }
|
||||||
bool CanGyro() const override { return false; }
|
bool CanGyro() const override { return false; }
|
||||||
const char* GetControllerName() override;
|
const std::string GetControllerName() override;
|
||||||
const char* GetButtonName(int slot, int n64Button) override;
|
const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) override;
|
||||||
bool PressButton(int32_t dwScancode);
|
bool PressButton(int32_t dwScancode);
|
||||||
bool ReleaseButton(int32_t dwScancode);
|
bool ReleaseButton(int32_t dwScancode);
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ namespace Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t GetLastScancode() { return lastScancode; }
|
int32_t GetLastScancode() { return lastScancode; }
|
||||||
void CreateDefaultBinding(int32_t slot) override;
|
void CreateDefaultBinding(int32_t virtualSlot) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32_t lastScancode;
|
int32_t lastScancode;
|
||||||
|
@ -108,15 +108,15 @@ typedef struct {
|
|||||||
} OSContStatus; // size = 0x04
|
} OSContStatus; // size = 0x04
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u16 button;
|
/* 0x00 */ uint16_t button;
|
||||||
/* 0x02 */ s8 stick_x;
|
/* 0x02 */ int8_t stick_x;
|
||||||
/* 0x03 */ s8 stick_y;
|
/* 0x03 */ int8_t stick_y;
|
||||||
/* 0x04 */ u8 err_no;
|
/* 0x04 */ uint8_t err_no;
|
||||||
/* 0x05 */ f32 gyro_x;
|
/* 0x05 */ float gyro_x;
|
||||||
/* 0x09 */ f32 gyro_y;
|
/* 0x09 */ float gyro_y;
|
||||||
/* 0x1C */ f32 cam_x;
|
/* 0x1C */ int8_t right_stick_x;
|
||||||
/* 0x20 */ f32 cam_y;
|
/* 0x20 */ int8_t right_stick_y;
|
||||||
} OSContPad; // size = 0x24
|
} OSContPad; // size = 0x22
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u8 rumble;
|
/* 0x00 */ u8 rumble;
|
||||||
|
@ -720,9 +720,9 @@ void ThrowIfFailed(HRESULT res, HWND h_wnd, const char *message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* gfx_dxgi_get_key_name(int scancode) {
|
const char* gfx_dxgi_get_key_name(int scancode) {
|
||||||
TCHAR* Text = new TCHAR[64];
|
static char text[64];
|
||||||
GetKeyNameText(scancode << 16, Text, 64);
|
GetKeyNameTextA(scancode << 16, text, 64);
|
||||||
return (char*) Text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" struct GfxWindowManagerAPI gfx_dxgi_api = {
|
extern "C" struct GfxWindowManagerAPI gfx_dxgi_api = {
|
||||||
|
825
libultraship/libultraship/Lib/Fast3D/gfx_gx2.cpp
Normal file
825
libultraship/libultraship/Lib/Fast3D/gfx_gx2.cpp
Normal file
@ -0,0 +1,825 @@
|
|||||||
|
#ifdef __WIIU__
|
||||||
|
|
||||||
|
#include "../../Window.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#ifndef _LANGUAGE_C
|
||||||
|
#define _LANGUAGE_C
|
||||||
|
#endif
|
||||||
|
#include "PR/ultra64/gbi.h"
|
||||||
|
|
||||||
|
#include "gfx_cc.h"
|
||||||
|
#include "gfx_rendering_api.h"
|
||||||
|
#include "gfx_pc.h"
|
||||||
|
#include "gfx_wiiu.h"
|
||||||
|
|
||||||
|
#include <gx2/texture.h>
|
||||||
|
#include <gx2/draw.h>
|
||||||
|
#include <gx2/clear.h>
|
||||||
|
#include <gx2/state.h>
|
||||||
|
#include <gx2/swap.h>
|
||||||
|
#include <gx2/event.h>
|
||||||
|
#include <gx2/utils.h>
|
||||||
|
#include <gx2/mem.h>
|
||||||
|
#include <gx2/registers.h>
|
||||||
|
#include <gx2/display.h>
|
||||||
|
#include "gx2_shader_gen.h"
|
||||||
|
|
||||||
|
#include <proc_ui/procui.h>
|
||||||
|
#include <coreinit/memory.h>
|
||||||
|
|
||||||
|
#include "../ImGui/backends/wiiu/imgui_impl_gx2.h"
|
||||||
|
|
||||||
|
#define ALIGN(x, align) (((x) + ((align) -1)) & ~((align) -1))
|
||||||
|
|
||||||
|
struct ShaderProgram {
|
||||||
|
struct ShaderGroup group;
|
||||||
|
uint8_t num_inputs;
|
||||||
|
bool used_textures[2];
|
||||||
|
bool used_noise;
|
||||||
|
uint32_t window_params_offset;
|
||||||
|
uint32_t samplers_location[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Texture {
|
||||||
|
GX2Texture texture;
|
||||||
|
bool texture_uploaded;
|
||||||
|
|
||||||
|
GX2Sampler sampler;
|
||||||
|
bool sampler_set;
|
||||||
|
|
||||||
|
// For ImGui rendering
|
||||||
|
ImGui_ImplGX2_Texture imtex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Framebuffer {
|
||||||
|
GX2ColorBuffer color_buffer;
|
||||||
|
bool colorBufferMem1;
|
||||||
|
GX2DepthBuffer depth_buffer;
|
||||||
|
bool depthBufferMem1;
|
||||||
|
|
||||||
|
GX2Texture texture;
|
||||||
|
GX2Sampler sampler;
|
||||||
|
|
||||||
|
// For ImGui rendering
|
||||||
|
ImGui_ImplGX2_Texture imtex;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct Framebuffer main_framebuffer;
|
||||||
|
static GX2DepthBuffer depthReadBuffer;
|
||||||
|
static struct Framebuffer *current_framebuffer;
|
||||||
|
|
||||||
|
static std::map<std::pair<uint64_t, uint32_t>, struct ShaderProgram> shader_program_pool;
|
||||||
|
static struct ShaderProgram *current_shader_program;
|
||||||
|
|
||||||
|
static struct Texture *current_texture;
|
||||||
|
static int current_tile;
|
||||||
|
|
||||||
|
// 96 Mb (should be more than enough to draw everything without waiting for the GPU)
|
||||||
|
#define DRAW_BUFFER_SIZE 0x6000000
|
||||||
|
static uint8_t *draw_buffer = nullptr;
|
||||||
|
static uint8_t *draw_ptr = nullptr;
|
||||||
|
|
||||||
|
static uint32_t frame_count;
|
||||||
|
static float current_noise_scale;
|
||||||
|
static FilteringMode current_filter_mode = FILTER_LINEAR;
|
||||||
|
|
||||||
|
static BOOL current_depth_test = TRUE;
|
||||||
|
static BOOL current_depth_write = TRUE;
|
||||||
|
static GX2CompareFunction current_depth_compare_function = GX2_COMPARE_FUNC_LESS;
|
||||||
|
|
||||||
|
static float current_viewport_x = 0.0f;
|
||||||
|
static float current_viewport_y = 0.0f;
|
||||||
|
static float current_viewport_width = WIIU_DEFAULT_FB_WIDTH;
|
||||||
|
static float current_viewport_height = WIIU_DEFAULT_FB_HEIGHT;
|
||||||
|
|
||||||
|
static uint32_t current_scissor_x = 0;
|
||||||
|
static uint32_t current_scissor_y = 0;
|
||||||
|
static uint32_t current_scissor_width = WIIU_DEFAULT_FB_WIDTH;
|
||||||
|
static uint32_t current_scissor_height = WIIU_DEFAULT_FB_HEIGHT;
|
||||||
|
|
||||||
|
static bool current_zmode_decal = false;
|
||||||
|
static bool current_use_alpha = false;
|
||||||
|
|
||||||
|
static inline GX2SamplerVar *GX2GetPixelSamplerVar(const GX2PixelShader *shader, const char *name)
|
||||||
|
{
|
||||||
|
for (uint32_t i = 0; i < shader->samplerVarCount; ++i) {
|
||||||
|
if (strcmp(name, shader->samplerVars[i].name) == 0) {
|
||||||
|
return &shader->samplerVars[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int32_t GX2GetPixelSamplerVarLocation(const GX2PixelShader *shader, const char *name)
|
||||||
|
{
|
||||||
|
GX2SamplerVar *sampler = GX2GetPixelSamplerVar(shader, name);
|
||||||
|
return sampler ? sampler->location : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int32_t GX2GetPixelUniformVarOffset(const GX2PixelShader *shader, const char *name)
|
||||||
|
{
|
||||||
|
GX2UniformVar *uniform = GX2GetPixelUniformVar(shader, name);
|
||||||
|
return uniform ? uniform->offset : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_init_framebuffer(struct Framebuffer *buffer, uint32_t width, uint32_t height) {
|
||||||
|
memset(&buffer->color_buffer, 0, sizeof(GX2ColorBuffer));
|
||||||
|
buffer->color_buffer.surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV;
|
||||||
|
buffer->color_buffer.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||||
|
buffer->color_buffer.surface.width = width;
|
||||||
|
buffer->color_buffer.surface.height = height;
|
||||||
|
buffer->color_buffer.surface.depth = 1;
|
||||||
|
buffer->color_buffer.surface.mipLevels = 1;
|
||||||
|
buffer->color_buffer.surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||||
|
buffer->color_buffer.surface.aa = GX2_AA_MODE1X;
|
||||||
|
buffer->color_buffer.surface.tileMode = GX2_TILE_MODE_DEFAULT;
|
||||||
|
buffer->color_buffer.viewNumSlices = 1;
|
||||||
|
|
||||||
|
memset(&buffer->depth_buffer, 0, sizeof(GX2DepthBuffer));
|
||||||
|
buffer->depth_buffer.surface.use = GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE;
|
||||||
|
buffer->depth_buffer.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||||
|
buffer->depth_buffer.surface.width = width;
|
||||||
|
buffer->depth_buffer.surface.height = height;
|
||||||
|
buffer->depth_buffer.surface.depth = 1;
|
||||||
|
buffer->depth_buffer.surface.mipLevels = 1;
|
||||||
|
buffer->depth_buffer.surface.format = GX2_SURFACE_FORMAT_FLOAT_R32;
|
||||||
|
buffer->depth_buffer.surface.aa = GX2_AA_MODE1X;
|
||||||
|
buffer->depth_buffer.surface.tileMode = GX2_TILE_MODE_DEFAULT;
|
||||||
|
buffer->depth_buffer.viewNumSlices = 1;
|
||||||
|
buffer->depth_buffer.depthClear = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct GfxClipParameters gfx_gx2_get_clip_parameters(void) {
|
||||||
|
return { false, false };
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_uniforms(struct ShaderProgram *prg) {
|
||||||
|
if (prg->used_noise) {
|
||||||
|
float window_params_array[2] = { current_noise_scale, (float) frame_count };
|
||||||
|
|
||||||
|
GX2SetPixelUniformReg(prg->window_params_offset, 2, window_params_array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_unload_shader(struct ShaderProgram *old_prg) {
|
||||||
|
current_shader_program = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_load_shader(struct ShaderProgram *new_prg) {
|
||||||
|
current_shader_program = new_prg;
|
||||||
|
|
||||||
|
GX2SetFetchShader(&new_prg->group.fetchShader);
|
||||||
|
GX2SetVertexShader(&new_prg->group.vertexShader);
|
||||||
|
GX2SetPixelShader(&new_prg->group.pixelShader);
|
||||||
|
|
||||||
|
gfx_gx2_set_uniforms(new_prg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ShaderProgram* gfx_gx2_create_and_load_new_shader(uint64_t shader_id0, uint32_t shader_id1) {
|
||||||
|
struct CCFeatures cc_features;
|
||||||
|
gfx_cc_get_features(shader_id0, shader_id1, &cc_features);
|
||||||
|
|
||||||
|
struct ShaderProgram* prg = &shader_program_pool[std::make_pair(shader_id0, shader_id1)];
|
||||||
|
|
||||||
|
printf("Generating shader: %016llx-%08x\n", shader_id0, shader_id1);
|
||||||
|
if (gx2GenerateShaderGroup(&prg->group, &cc_features) != 0) {
|
||||||
|
printf("Failed to generate shader\n");
|
||||||
|
current_shader_program = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
prg->num_inputs = cc_features.num_inputs;
|
||||||
|
prg->used_textures[0] = cc_features.used_textures[0];
|
||||||
|
prg->used_textures[1] = cc_features.used_textures[1];
|
||||||
|
|
||||||
|
gfx_gx2_load_shader(prg);
|
||||||
|
|
||||||
|
prg->window_params_offset = GX2GetPixelUniformVarOffset(&prg->group.pixelShader, "window_params");
|
||||||
|
prg->samplers_location[0] = GX2GetPixelSamplerVarLocation(&prg->group.pixelShader, "uTex0");
|
||||||
|
prg->samplers_location[1] = GX2GetPixelSamplerVarLocation(&prg->group.pixelShader, "uTex1");
|
||||||
|
|
||||||
|
prg->used_noise = cc_features.opt_alpha && cc_features.opt_noise;
|
||||||
|
|
||||||
|
printf("Generated and loaded shader\n");
|
||||||
|
|
||||||
|
return prg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ShaderProgram *gfx_gx2_lookup_shader(uint64_t shader_id0, uint32_t shader_id1) {
|
||||||
|
auto it = shader_program_pool.find(std::make_pair(shader_id0, shader_id1));
|
||||||
|
return it == shader_program_pool.end() ? nullptr : &it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_shader_get_info(struct ShaderProgram *prg, uint8_t *num_inputs, bool used_textures[2]) {
|
||||||
|
*num_inputs = prg->num_inputs;
|
||||||
|
used_textures[0] = prg->used_textures[0];
|
||||||
|
used_textures[1] = prg->used_textures[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t gfx_gx2_new_texture(void) {
|
||||||
|
// some 32-bit trickery :P
|
||||||
|
struct Texture *tex = (struct Texture *) calloc(1, sizeof(struct Texture));
|
||||||
|
|
||||||
|
tex->imtex.Texture = &tex->texture;
|
||||||
|
tex->imtex.Sampler = &tex->sampler;
|
||||||
|
|
||||||
|
return (uint32_t) tex;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_delete_texture(uint32_t texture_id) {
|
||||||
|
struct Texture *tex = (struct Texture *) texture_id;
|
||||||
|
|
||||||
|
if (tex->texture.surface.image) {
|
||||||
|
free(tex->texture.surface.image);
|
||||||
|
}
|
||||||
|
|
||||||
|
free((void *) tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_select_texture(int tile, uint32_t texture_id) {
|
||||||
|
struct Texture *tex = (struct Texture *) texture_id;
|
||||||
|
current_texture = tex;
|
||||||
|
current_tile = tile;
|
||||||
|
|
||||||
|
if (current_shader_program) {
|
||||||
|
uint32_t sampler_location = current_shader_program->samplers_location[tile];
|
||||||
|
|
||||||
|
if (tex->texture_uploaded) {
|
||||||
|
GX2SetPixelTexture(&tex->texture, sampler_location);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tex->sampler_set) {
|
||||||
|
GX2SetPixelSampler(&tex->sampler, sampler_location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_upload_texture(const uint8_t *rgba32_buf, uint32_t width, uint32_t height) {
|
||||||
|
struct Texture *tex = current_texture;
|
||||||
|
assert(tex);
|
||||||
|
|
||||||
|
if ((tex->texture.surface.width != width) ||
|
||||||
|
(tex->texture.surface.height != height) ||
|
||||||
|
!tex->texture.surface.image) {
|
||||||
|
|
||||||
|
if (tex->texture.surface.image) {
|
||||||
|
free(tex->texture.surface.image);
|
||||||
|
tex->texture.surface.image = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&tex->texture, 0, sizeof(GX2Texture));
|
||||||
|
tex->texture.surface.use = GX2_SURFACE_USE_TEXTURE;
|
||||||
|
tex->texture.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||||
|
tex->texture.surface.width = width;
|
||||||
|
tex->texture.surface.height = height;
|
||||||
|
tex->texture.surface.depth = 1;
|
||||||
|
tex->texture.surface.mipLevels = 1;
|
||||||
|
tex->texture.surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||||
|
tex->texture.surface.aa = GX2_AA_MODE1X;
|
||||||
|
tex->texture.surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
||||||
|
tex->texture.viewFirstMip = 0;
|
||||||
|
tex->texture.viewNumMips = 1;
|
||||||
|
tex->texture.viewFirstSlice = 0;
|
||||||
|
tex->texture.viewNumSlices = 1;
|
||||||
|
tex->texture.compMap = GX2_COMP_MAP(GX2_SQ_SEL_R, GX2_SQ_SEL_G, GX2_SQ_SEL_B, GX2_SQ_SEL_A);
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&tex->texture.surface);
|
||||||
|
GX2InitTextureRegs(&tex->texture);
|
||||||
|
|
||||||
|
tex->texture.surface.image = memalign(tex->texture.surface.alignment, tex->texture.surface.imageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* buf = (uint8_t *) tex->texture.surface.image;
|
||||||
|
assert(buf);
|
||||||
|
|
||||||
|
for (uint32_t y = 0; y < height; ++y) {
|
||||||
|
memcpy(buf + (y * tex->texture.surface.pitch * 4), rgba32_buf + (y * width * 4), width * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, tex->texture.surface.image, tex->texture.surface.imageSize);
|
||||||
|
|
||||||
|
if (current_shader_program) {
|
||||||
|
GX2SetPixelTexture(&tex->texture, current_shader_program->samplers_location[current_tile]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tex->texture_uploaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GX2TexClampMode gfx_cm_to_gx2(uint32_t val) {
|
||||||
|
switch (val) {
|
||||||
|
case G_TX_NOMIRROR | G_TX_CLAMP:
|
||||||
|
return GX2_TEX_CLAMP_MODE_CLAMP;
|
||||||
|
case G_TX_MIRROR | G_TX_WRAP:
|
||||||
|
return GX2_TEX_CLAMP_MODE_MIRROR;
|
||||||
|
case G_TX_MIRROR | G_TX_CLAMP:
|
||||||
|
return GX2_TEX_CLAMP_MODE_MIRROR_ONCE;
|
||||||
|
case G_TX_NOMIRROR | G_TX_WRAP:
|
||||||
|
return GX2_TEX_CLAMP_MODE_WRAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GX2_TEX_CLAMP_MODE_WRAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) {
|
||||||
|
struct Texture *tex = current_texture;
|
||||||
|
assert(tex);
|
||||||
|
|
||||||
|
current_tile = tile;
|
||||||
|
|
||||||
|
GX2InitSampler(&tex->sampler, GX2_TEX_CLAMP_MODE_CLAMP,
|
||||||
|
(linear_filter && current_filter_mode == FILTER_LINEAR) ?
|
||||||
|
GX2_TEX_XY_FILTER_MODE_LINEAR : GX2_TEX_XY_FILTER_MODE_POINT);
|
||||||
|
|
||||||
|
GX2InitSamplerClamping(&tex->sampler, gfx_cm_to_gx2(cms), gfx_cm_to_gx2(cmt), GX2_TEX_CLAMP_MODE_WRAP);
|
||||||
|
|
||||||
|
if (current_shader_program) {
|
||||||
|
GX2SetPixelSampler(&tex->sampler, current_shader_program->samplers_location[tile]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tex->sampler_set = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_depth_test_and_mask(bool depth_test, bool z_upd) {
|
||||||
|
current_depth_test = depth_test || z_upd;
|
||||||
|
current_depth_write = z_upd;
|
||||||
|
current_depth_compare_function = depth_test ? GX2_COMPARE_FUNC_LEQUAL : GX2_COMPARE_FUNC_ALWAYS;
|
||||||
|
|
||||||
|
GX2SetDepthOnlyControl(current_depth_test, current_depth_write, current_depth_compare_function);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_zmode_decal(bool zmode_decal) {
|
||||||
|
current_zmode_decal = zmode_decal;
|
||||||
|
if (zmode_decal) {
|
||||||
|
GX2SetPolygonControl(GX2_FRONT_FACE_CCW, FALSE, FALSE, TRUE,
|
||||||
|
GX2_POLYGON_MODE_TRIANGLE, GX2_POLYGON_MODE_TRIANGLE,
|
||||||
|
TRUE, TRUE, FALSE);
|
||||||
|
GX2SetPolygonOffset(-2.0f, -2.0f, -2.0f, -2.0f, 0.0f);
|
||||||
|
} else {
|
||||||
|
GX2SetPolygonControl(GX2_FRONT_FACE_CCW, FALSE, FALSE, FALSE,
|
||||||
|
GX2_POLYGON_MODE_TRIANGLE, GX2_POLYGON_MODE_TRIANGLE,
|
||||||
|
FALSE, FALSE, FALSE);
|
||||||
|
GX2SetPolygonOffset(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_viewport(int x, int y, int width, int height) {
|
||||||
|
uint32_t buffer_height = current_framebuffer->color_buffer.surface.height;
|
||||||
|
|
||||||
|
current_viewport_x = x;
|
||||||
|
current_viewport_y = buffer_height - y - height;
|
||||||
|
current_viewport_width = width;
|
||||||
|
current_viewport_height = height;
|
||||||
|
|
||||||
|
GX2SetViewport(current_viewport_x, current_viewport_y, current_viewport_width, current_viewport_height, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_scissor(int x, int y, int width, int height) {
|
||||||
|
uint32_t buffer_height = current_framebuffer->color_buffer.surface.height;
|
||||||
|
uint32_t buffer_width = current_framebuffer->color_buffer.surface.width;
|
||||||
|
|
||||||
|
current_scissor_x = std::min((uint32_t) width, (uint32_t) x);
|
||||||
|
current_scissor_y = std::min((uint32_t) height, buffer_height - y - height);
|
||||||
|
current_scissor_width = std::min((uint32_t) width, buffer_width);
|
||||||
|
current_scissor_height = std::min((uint32_t) height, buffer_height);
|
||||||
|
|
||||||
|
GX2SetScissor(current_scissor_x, current_scissor_y, current_scissor_width, current_scissor_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_set_use_alpha(bool use_alpha) {
|
||||||
|
current_use_alpha = use_alpha;
|
||||||
|
GX2SetColorControl(GX2_LOGIC_OP_COPY, use_alpha ? 0xff : 0, FALSE, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) {
|
||||||
|
if (!current_shader_program) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t vbo_len = sizeof(float) * buf_vbo_len;
|
||||||
|
|
||||||
|
if (draw_ptr + vbo_len >= draw_buffer + DRAW_BUFFER_SIZE) {
|
||||||
|
printf("Waiting on GPU!!!\n");
|
||||||
|
GX2DrawDone();
|
||||||
|
draw_ptr = draw_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
float* new_vbo = (float *) draw_ptr;
|
||||||
|
draw_ptr += ALIGN(vbo_len, GX2_VERTEX_BUFFER_ALIGNMENT);
|
||||||
|
|
||||||
|
OSBlockMove(new_vbo, buf_vbo, vbo_len, FALSE);
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, new_vbo, vbo_len);
|
||||||
|
|
||||||
|
GX2SetAttribBuffer(0, vbo_len, current_shader_program->group.stride, new_vbo);
|
||||||
|
GX2DrawEx(GX2_PRIMITIVE_MODE_TRIANGLES, 3 * buf_vbo_num_tris, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_init(void) {
|
||||||
|
// Init the default framebuffer
|
||||||
|
gfx_gx2_init_framebuffer(&main_framebuffer, WIIU_DEFAULT_FB_WIDTH, WIIU_DEFAULT_FB_HEIGHT);
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&main_framebuffer.color_buffer.surface);
|
||||||
|
GX2InitColorBufferRegs(&main_framebuffer.color_buffer);
|
||||||
|
|
||||||
|
main_framebuffer.color_buffer.surface.image = gfx_wiiu_alloc_mem1(main_framebuffer.color_buffer.surface.imageSize, main_framebuffer.color_buffer.surface.alignment);
|
||||||
|
assert(main_framebuffer.color_buffer.surface.image);
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&main_framebuffer.depth_buffer.surface);
|
||||||
|
GX2InitDepthBufferRegs(&main_framebuffer.depth_buffer);
|
||||||
|
|
||||||
|
main_framebuffer.depth_buffer.surface.image = gfx_wiiu_alloc_mem1(main_framebuffer.depth_buffer.surface.imageSize, main_framebuffer.depth_buffer.surface.alignment);
|
||||||
|
assert(main_framebuffer.depth_buffer.surface.image);
|
||||||
|
|
||||||
|
main_framebuffer.imtex.Texture = &main_framebuffer.texture;
|
||||||
|
main_framebuffer.imtex.Sampler = &main_framebuffer.sampler;
|
||||||
|
|
||||||
|
// create a linear aligned copy of the depth buffer to read pixels to
|
||||||
|
memcpy(&depthReadBuffer, &main_framebuffer.depth_buffer, sizeof(GX2DepthBuffer));
|
||||||
|
|
||||||
|
depthReadBuffer.surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
||||||
|
depthReadBuffer.surface.width = 1;
|
||||||
|
depthReadBuffer.surface.height = 1;
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&depthReadBuffer.surface);
|
||||||
|
|
||||||
|
depthReadBuffer.surface.image = gfx_wiiu_alloc_mem1(depthReadBuffer.surface.alignment, depthReadBuffer.surface.imageSize);
|
||||||
|
assert(depthReadBuffer.surface.image);
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_DEPTH_BUFFER, depthReadBuffer.surface.image, depthReadBuffer.surface.imageSize);
|
||||||
|
|
||||||
|
GX2SetColorBuffer(&main_framebuffer.color_buffer, GX2_RENDER_TARGET_0);
|
||||||
|
GX2SetDepthBuffer(&main_framebuffer.depth_buffer);
|
||||||
|
|
||||||
|
current_framebuffer = &main_framebuffer;
|
||||||
|
|
||||||
|
// allocate draw buffer
|
||||||
|
draw_buffer = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, DRAW_BUFFER_SIZE);
|
||||||
|
assert(draw_buffer);
|
||||||
|
draw_ptr = draw_buffer;
|
||||||
|
|
||||||
|
GX2SetRasterizerClipControl(TRUE, FALSE);
|
||||||
|
|
||||||
|
GX2SetBlendControl(GX2_RENDER_TARGET_0,
|
||||||
|
GX2_BLEND_MODE_SRC_ALPHA,
|
||||||
|
GX2_BLEND_MODE_INV_SRC_ALPHA,
|
||||||
|
GX2_BLEND_COMBINE_MODE_ADD,
|
||||||
|
FALSE,
|
||||||
|
GX2_BLEND_MODE_ZERO,
|
||||||
|
GX2_BLEND_MODE_ZERO,
|
||||||
|
GX2_BLEND_COMBINE_MODE_ADD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_gx2_shutdown(void) {
|
||||||
|
if (has_foreground) {
|
||||||
|
GX2DrawDone();
|
||||||
|
|
||||||
|
if (depthReadBuffer.surface.image) {
|
||||||
|
gfx_wiiu_free_mem1(depthReadBuffer.surface.image);
|
||||||
|
depthReadBuffer.surface.image = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (main_framebuffer.color_buffer.surface.image) {
|
||||||
|
gfx_wiiu_free_mem1(main_framebuffer.color_buffer.surface.image);
|
||||||
|
main_framebuffer.color_buffer.surface.image = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (main_framebuffer.depth_buffer.surface.image) {
|
||||||
|
gfx_wiiu_free_mem1(main_framebuffer.depth_buffer.surface.image);
|
||||||
|
main_framebuffer.depth_buffer.surface.image = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (draw_buffer) {
|
||||||
|
free(draw_buffer);
|
||||||
|
draw_buffer = nullptr;
|
||||||
|
draw_ptr = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_on_resize(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_start_frame(void) {
|
||||||
|
// Restore state since ImGui modified it when rendering
|
||||||
|
GX2SetViewport(current_viewport_x, current_viewport_y, current_viewport_width, current_viewport_height, 0.0f, 1.0f);
|
||||||
|
GX2SetScissor(current_scissor_x, current_scissor_y, current_scissor_width, current_scissor_height);
|
||||||
|
|
||||||
|
GX2SetColorControl(GX2_LOGIC_OP_COPY, current_use_alpha ? 0xff : 0, FALSE, TRUE);
|
||||||
|
|
||||||
|
GX2SetBlendControl(GX2_RENDER_TARGET_0,
|
||||||
|
GX2_BLEND_MODE_SRC_ALPHA,
|
||||||
|
GX2_BLEND_MODE_INV_SRC_ALPHA,
|
||||||
|
GX2_BLEND_COMBINE_MODE_ADD,
|
||||||
|
FALSE,
|
||||||
|
GX2_BLEND_MODE_ZERO,
|
||||||
|
GX2_BLEND_MODE_ZERO,
|
||||||
|
GX2_BLEND_COMBINE_MODE_ADD);
|
||||||
|
|
||||||
|
GX2SetDepthOnlyControl(current_depth_test, current_depth_write, current_depth_compare_function);
|
||||||
|
|
||||||
|
if (current_zmode_decal) {
|
||||||
|
GX2SetPolygonControl(GX2_FRONT_FACE_CCW, FALSE, FALSE, TRUE,
|
||||||
|
GX2_POLYGON_MODE_TRIANGLE, GX2_POLYGON_MODE_TRIANGLE,
|
||||||
|
TRUE, TRUE, FALSE);
|
||||||
|
GX2SetPolygonOffset(-2.0f, -2.0f, -2.0f, -2.0f, 0.0f);
|
||||||
|
} else {
|
||||||
|
GX2SetPolygonControl(GX2_FRONT_FACE_CCW, FALSE, FALSE, FALSE,
|
||||||
|
GX2_POLYGON_MODE_TRIANGLE, GX2_POLYGON_MODE_TRIANGLE,
|
||||||
|
FALSE, FALSE, FALSE);
|
||||||
|
GX2SetPolygonOffset(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_end_frame(void) {
|
||||||
|
draw_ptr = draw_buffer;
|
||||||
|
|
||||||
|
GX2CopyColorBufferToScanBuffer(&main_framebuffer.color_buffer, GX2_SCAN_TARGET_TV);
|
||||||
|
GX2CopyColorBufferToScanBuffer(&main_framebuffer.color_buffer, GX2_SCAN_TARGET_DRC);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_finish_render(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gfx_gx2_create_framebuffer(void) {
|
||||||
|
struct Framebuffer *buffer = (struct Framebuffer *) calloc(1, sizeof(struct Framebuffer));
|
||||||
|
assert(buffer);
|
||||||
|
|
||||||
|
GX2InitSampler(&buffer->sampler, GX2_TEX_CLAMP_MODE_WRAP, GX2_TEX_XY_FILTER_MODE_LINEAR);
|
||||||
|
|
||||||
|
buffer->imtex.Texture = &buffer->texture;
|
||||||
|
buffer->imtex.Sampler = &buffer->sampler;
|
||||||
|
|
||||||
|
// some more 32-bit shenanigans :D
|
||||||
|
return (int) buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_gx2_update_framebuffer_parameters(int fb, uint32_t width, uint32_t height, uint32_t msaa_level, bool opengl_invert_y, bool render_target, bool has_depth_buffer, bool can_extract_depth) {
|
||||||
|
struct Framebuffer *buffer = (struct Framebuffer *) fb;
|
||||||
|
|
||||||
|
// we don't support updating the main buffer (fb 0)
|
||||||
|
if (!buffer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer->texture.surface.width == width &&
|
||||||
|
buffer->texture.surface.height == height) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure the GPU no longer writes to the buffer
|
||||||
|
GX2DrawDone();
|
||||||
|
|
||||||
|
if (buffer->texture.surface.image) {
|
||||||
|
if (buffer->colorBufferMem1) {
|
||||||
|
gfx_wiiu_free_mem1(buffer->texture.surface.image);
|
||||||
|
} else {
|
||||||
|
free(buffer->texture.surface.image);
|
||||||
|
}
|
||||||
|
buffer->texture.surface.image = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer->depth_buffer.surface.image) {
|
||||||
|
if (buffer->depthBufferMem1) {
|
||||||
|
gfx_wiiu_free_mem1(buffer->depth_buffer.surface.image);
|
||||||
|
} else {
|
||||||
|
free(buffer->depth_buffer.surface.image);
|
||||||
|
}
|
||||||
|
buffer->depth_buffer.surface.image = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx_gx2_init_framebuffer(buffer, width, height);
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&buffer->depth_buffer.surface);
|
||||||
|
GX2InitDepthBufferRegs(&buffer->depth_buffer);
|
||||||
|
|
||||||
|
buffer->depth_buffer.surface.image = gfx_wiiu_alloc_mem1(buffer->depth_buffer.surface.imageSize, buffer->depth_buffer.surface.alignment);
|
||||||
|
// fall back to mem2
|
||||||
|
if (!buffer->depth_buffer.surface.image) {
|
||||||
|
buffer->depth_buffer.surface.image = memalign(buffer->depth_buffer.surface.alignment, buffer->depth_buffer.surface.imageSize);
|
||||||
|
buffer->depthBufferMem1 = false;
|
||||||
|
} else {
|
||||||
|
buffer->depthBufferMem1 = true;
|
||||||
|
}
|
||||||
|
assert(buffer->depth_buffer.surface.image);
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&buffer->color_buffer.surface);
|
||||||
|
GX2InitColorBufferRegs(&buffer->color_buffer);
|
||||||
|
|
||||||
|
memset(&buffer->texture, 0, sizeof(GX2Texture));
|
||||||
|
buffer->texture.surface.use = GX2_SURFACE_USE_TEXTURE;
|
||||||
|
buffer->texture.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||||
|
buffer->texture.surface.width = width;
|
||||||
|
buffer->texture.surface.height = height;
|
||||||
|
buffer->texture.surface.depth = 1;
|
||||||
|
buffer->texture.surface.mipLevels = 1;
|
||||||
|
buffer->texture.surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||||
|
buffer->texture.surface.aa = GX2_AA_MODE1X;
|
||||||
|
buffer->texture.surface.tileMode = GX2_TILE_MODE_DEFAULT;
|
||||||
|
buffer->texture.viewFirstMip = 0;
|
||||||
|
buffer->texture.viewNumMips = 1;
|
||||||
|
buffer->texture.viewFirstSlice = 0;
|
||||||
|
buffer->texture.viewNumSlices = 1;
|
||||||
|
buffer->texture.compMap = GX2_COMP_MAP(GX2_SQ_SEL_R, GX2_SQ_SEL_G, GX2_SQ_SEL_B, GX2_SQ_SEL_A);
|
||||||
|
|
||||||
|
GX2CalcSurfaceSizeAndAlignment(&buffer->texture.surface);
|
||||||
|
GX2InitTextureRegs(&buffer->texture);
|
||||||
|
|
||||||
|
// the texture and color buffer share a buffer
|
||||||
|
assert(buffer->color_buffer.surface.imageSize == buffer->texture.surface.imageSize);
|
||||||
|
|
||||||
|
buffer->texture.surface.image = gfx_wiiu_alloc_mem1(buffer->texture.surface.imageSize, buffer->texture.surface.alignment);
|
||||||
|
// fall back to mem2
|
||||||
|
if (!buffer->texture.surface.image) {
|
||||||
|
buffer->texture.surface.image = memalign(buffer->texture.surface.alignment, buffer->texture.surface.imageSize);
|
||||||
|
buffer->colorBufferMem1 = false;
|
||||||
|
} else {
|
||||||
|
buffer->colorBufferMem1 = true;
|
||||||
|
}
|
||||||
|
assert(buffer->texture.surface.image);
|
||||||
|
|
||||||
|
buffer->color_buffer.surface.image = buffer->texture.surface.image;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_gx2_start_draw_to_framebuffer(int fb, float noise_scale) {
|
||||||
|
struct Framebuffer *buffer = (struct Framebuffer *) fb;
|
||||||
|
|
||||||
|
// fb 0 = main buffer
|
||||||
|
if (!buffer) {
|
||||||
|
buffer = &main_framebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noise_scale != 0.0f) {
|
||||||
|
current_noise_scale = 1.0f / noise_scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
GX2SetColorBuffer(&buffer->color_buffer, GX2_RENDER_TARGET_0);
|
||||||
|
GX2SetDepthBuffer(&buffer->depth_buffer);
|
||||||
|
|
||||||
|
current_framebuffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_gx2_clear_framebuffer(void) {
|
||||||
|
struct Framebuffer *buffer = current_framebuffer;
|
||||||
|
|
||||||
|
GX2ClearColor(&buffer->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
GX2ClearDepthStencilEx(&buffer->depth_buffer,
|
||||||
|
buffer->depth_buffer.depthClear,
|
||||||
|
buffer->depth_buffer.stencilClear, GX2_CLEAR_FLAGS_BOTH);
|
||||||
|
|
||||||
|
gfx_wiiu_set_context_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_gx2_resolve_msaa_color_buffer(int fb_id_target, int fb_id_source) {
|
||||||
|
struct Framebuffer *src_buffer = (struct Framebuffer *) fb_id_source;
|
||||||
|
struct Framebuffer *target_buffer = (struct Framebuffer *) fb_id_target;
|
||||||
|
|
||||||
|
// fb 0 = main buffer
|
||||||
|
if (!src_buffer) {
|
||||||
|
src_buffer = &main_framebuffer;
|
||||||
|
}
|
||||||
|
if (!target_buffer) {
|
||||||
|
target_buffer = &main_framebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (src_buffer->color_buffer.surface.aa == GX2_AA_MODE1X) {
|
||||||
|
GX2CopySurface(&src_buffer->color_buffer.surface,
|
||||||
|
src_buffer->color_buffer.viewMip,
|
||||||
|
src_buffer->color_buffer.viewFirstSlice,
|
||||||
|
&target_buffer->color_buffer.surface,
|
||||||
|
target_buffer->color_buffer.viewMip,
|
||||||
|
target_buffer->color_buffer.viewFirstSlice);
|
||||||
|
} else {
|
||||||
|
GX2ResolveAAColorBuffer(&src_buffer->color_buffer,
|
||||||
|
&target_buffer->color_buffer.surface,
|
||||||
|
target_buffer->color_buffer.viewMip,
|
||||||
|
target_buffer->color_buffer.viewFirstSlice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *gfx_gx2_get_framebuffer_texture_id(int fb_id) {
|
||||||
|
struct Framebuffer *buffer = (struct Framebuffer *) fb_id;
|
||||||
|
|
||||||
|
// fb 0 = main buffer
|
||||||
|
if (!buffer) {
|
||||||
|
buffer = &main_framebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &buffer->imtex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_gx2_select_texture_fb(int fb) {
|
||||||
|
struct Framebuffer *buffer = (struct Framebuffer *) fb;
|
||||||
|
assert(buffer);
|
||||||
|
|
||||||
|
assert(current_shader_program);
|
||||||
|
uint32_t location = current_shader_program->samplers_location[0];
|
||||||
|
GX2SetPixelTexture(&buffer->texture, location);
|
||||||
|
GX2SetPixelSampler(&buffer->sampler, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::unordered_map<std::pair<float, float>, uint16_t, hash_pair_ff> gfx_gx2_get_pixel_depth(int fb_id, const std::set<std::pair<float, float>>& coordinates) {
|
||||||
|
struct Framebuffer *buffer = (struct Framebuffer *) fb_id;
|
||||||
|
|
||||||
|
// fb 0 = main buffer
|
||||||
|
if (!buffer) {
|
||||||
|
buffer = &main_framebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unordered_map<std::pair<float, float>, uint16_t, hash_pair_ff> res;
|
||||||
|
|
||||||
|
for (const auto& c : coordinates) {
|
||||||
|
// bug? coordinates sometimes read from oob
|
||||||
|
if ((c.first < 0.0f) || (c.first > (float) buffer->depth_buffer.surface.width)
|
||||||
|
|| (c.second < 0.0f) || (c.second > (float) buffer->depth_buffer.surface.height)) {
|
||||||
|
res.emplace(c, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_DEPTH_BUFFER, depthReadBuffer.surface.image, depthReadBuffer.surface.imageSize);
|
||||||
|
|
||||||
|
// copy the pixel to the depthReadBuffer
|
||||||
|
GX2Rect srcRect = {
|
||||||
|
(int32_t) c.first,
|
||||||
|
(int32_t) buffer->depth_buffer.surface.height - (int32_t) c.second,
|
||||||
|
(int32_t) c.first + 1,
|
||||||
|
(int32_t) (buffer->depth_buffer.surface.height - (int32_t) c.second) + 1
|
||||||
|
};
|
||||||
|
GX2Point dstPoint = { 0, 0 };
|
||||||
|
GX2CopySurfaceEx(&buffer->depth_buffer.surface, 0, 0, &depthReadBuffer.surface, 0, 0, 1, &srcRect, &dstPoint);
|
||||||
|
GX2DrawDone();
|
||||||
|
|
||||||
|
gfx_wiiu_set_context_state();
|
||||||
|
|
||||||
|
// read the pixel from the depthReadBuffer
|
||||||
|
uint32_t tmp = __builtin_bswap32(*(uint32_t *)depthReadBuffer.surface.image);
|
||||||
|
float val = *(float *)&tmp;
|
||||||
|
|
||||||
|
res.emplace(c, val * 65532.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_gx2_set_texture_filter(FilteringMode mode) {
|
||||||
|
// three-point is not implemented in the shaders yet
|
||||||
|
if (mode == FILTER_THREE_POINT) {
|
||||||
|
mode = FILTER_LINEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_filter_mode = mode;
|
||||||
|
gfx_texture_cache_clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
FilteringMode gfx_gx2_get_texture_filter(void) {
|
||||||
|
return current_filter_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplGX2_Texture* gfx_gx2_texture_for_imgui(uint32_t texture_id) {
|
||||||
|
struct Texture *tex = (struct Texture *) texture_id;
|
||||||
|
return &tex->imtex;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct GfxRenderingAPI gfx_gx2_api = {
|
||||||
|
gfx_gx2_get_clip_parameters,
|
||||||
|
gfx_gx2_unload_shader,
|
||||||
|
gfx_gx2_load_shader,
|
||||||
|
gfx_gx2_create_and_load_new_shader,
|
||||||
|
gfx_gx2_lookup_shader,
|
||||||
|
gfx_gx2_shader_get_info,
|
||||||
|
gfx_gx2_new_texture,
|
||||||
|
gfx_gx2_select_texture,
|
||||||
|
gfx_gx2_upload_texture,
|
||||||
|
gfx_gx2_set_sampler_parameters,
|
||||||
|
gfx_gx2_set_depth_test_and_mask,
|
||||||
|
gfx_gx2_set_zmode_decal,
|
||||||
|
gfx_gx2_set_viewport,
|
||||||
|
gfx_gx2_set_scissor,
|
||||||
|
gfx_gx2_set_use_alpha,
|
||||||
|
gfx_gx2_draw_triangles,
|
||||||
|
gfx_gx2_init,
|
||||||
|
gfx_gx2_on_resize,
|
||||||
|
gfx_gx2_start_frame,
|
||||||
|
gfx_gx2_end_frame,
|
||||||
|
gfx_gx2_finish_render,
|
||||||
|
gfx_gx2_create_framebuffer,
|
||||||
|
gfx_gx2_update_framebuffer_parameters,
|
||||||
|
gfx_gx2_start_draw_to_framebuffer,
|
||||||
|
gfx_gx2_clear_framebuffer,
|
||||||
|
gfx_gx2_resolve_msaa_color_buffer,
|
||||||
|
gfx_gx2_get_pixel_depth,
|
||||||
|
gfx_gx2_get_framebuffer_texture_id,
|
||||||
|
gfx_gx2_select_texture_fb,
|
||||||
|
gfx_gx2_delete_texture,
|
||||||
|
gfx_gx2_set_texture_filter,
|
||||||
|
gfx_gx2_get_texture_filter
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
12
libultraship/libultraship/Lib/Fast3D/gfx_gx2.h
Normal file
12
libultraship/libultraship/Lib/Fast3D/gfx_gx2.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef GFX_GX2_H
|
||||||
|
#define GFX_GX2_H
|
||||||
|
|
||||||
|
#include "gfx_rendering_api.h"
|
||||||
|
|
||||||
|
void gfx_gx2_shutdown(void);
|
||||||
|
|
||||||
|
struct ImGui_ImplGX2_Texture* gfx_gx2_texture_for_imgui(uint32_t texture_id);
|
||||||
|
|
||||||
|
extern struct GfxRenderingAPI gfx_gx2_api;
|
||||||
|
|
||||||
|
#endif
|
@ -44,7 +44,7 @@
|
|||||||
#include "gfx_cc.h"
|
#include "gfx_cc.h"
|
||||||
#include "gfx_rendering_api.h"
|
#include "gfx_rendering_api.h"
|
||||||
#include "../../ImGuiImpl.h"
|
#include "../../ImGuiImpl.h"
|
||||||
#include "../../GlobalCtx2.h"
|
#include "../../Window.h"
|
||||||
#include "gfx_pc.h"
|
#include "gfx_pc.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#ifndef _LANGUAGE_C
|
#ifndef _LANGUAGE_C
|
||||||
#define _LANGUAGE_C
|
#define _LANGUAGE_C
|
||||||
#endif
|
#endif
|
||||||
|
#include <PR/ultra64/types.h>
|
||||||
#include <PR/ultra64/gbi.h>
|
#include <PR/ultra64/gbi.h>
|
||||||
#include <PR/ultra64/gs2dex.h>
|
#include <PR/ultra64/gs2dex.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -36,6 +37,7 @@
|
|||||||
#include "../../ResourceMgr.h"
|
#include "../../ResourceMgr.h"
|
||||||
#include "../../Utils.h"
|
#include "../../Utils.h"
|
||||||
|
|
||||||
|
|
||||||
// OTRTODO: fix header files for these
|
// OTRTODO: fix header files for these
|
||||||
extern "C" {
|
extern "C" {
|
||||||
const char* ResourceMgr_GetNameByCRC(uint64_t crc);
|
const char* ResourceMgr_GetNameByCRC(uint64_t crc);
|
||||||
@ -1382,12 +1384,25 @@ static void gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t vtx3_idx, bo
|
|||||||
buf_vbo[buf_vbo_len++] = u / tex_width[t];
|
buf_vbo[buf_vbo_len++] = u / tex_width[t];
|
||||||
buf_vbo[buf_vbo_len++] = v / tex_height[t];
|
buf_vbo[buf_vbo_len++] = v / tex_height[t];
|
||||||
|
|
||||||
if (tm & (1 << 2 * t)) {
|
bool clampS = tm & (1 << 2 * t);
|
||||||
|
bool clampT = tm & (1 << 2 * t + 1);
|
||||||
|
|
||||||
|
if (clampS) {
|
||||||
buf_vbo[buf_vbo_len++] = (tex_width2[t] - 0.5f) / tex_width[t];
|
buf_vbo[buf_vbo_len++] = (tex_width2[t] - 0.5f) / tex_width[t];
|
||||||
}
|
}
|
||||||
if (tm & (1 << 2 * t + 1)) {
|
#ifdef __WIIU__
|
||||||
|
else {
|
||||||
|
buf_vbo[buf_vbo_len++] = 0.0f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (clampT) {
|
||||||
buf_vbo[buf_vbo_len++] = (tex_height2[t] - 0.5f) / tex_height[t];
|
buf_vbo[buf_vbo_len++] = (tex_height2[t] - 0.5f) / tex_height[t];
|
||||||
}
|
}
|
||||||
|
#ifdef __WIIU__
|
||||||
|
else {
|
||||||
|
buf_vbo[buf_vbo_len++] = 0.0f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_fog) {
|
if (use_fog) {
|
||||||
@ -1464,6 +1479,12 @@ static void gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t vtx3_idx, bo
|
|||||||
buf_vbo[buf_vbo_len++] = color->r / 255.0f;
|
buf_vbo[buf_vbo_len++] = color->r / 255.0f;
|
||||||
buf_vbo[buf_vbo_len++] = color->g / 255.0f;
|
buf_vbo[buf_vbo_len++] = color->g / 255.0f;
|
||||||
buf_vbo[buf_vbo_len++] = color->b / 255.0f;
|
buf_vbo[buf_vbo_len++] = color->b / 255.0f;
|
||||||
|
#ifdef __WIIU__
|
||||||
|
// padding
|
||||||
|
if (!use_alpha) {
|
||||||
|
buf_vbo[buf_vbo_len++] = 1.0f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (use_fog && color == &v_arr[i]->color) {
|
if (use_fog && color == &v_arr[i]->color) {
|
||||||
@ -2152,7 +2173,7 @@ static void gfx_run_dl(Gfx* cmd) {
|
|||||||
uintptr_t mtxAddr = cmd->words.w1;
|
uintptr_t mtxAddr = cmd->words.w1;
|
||||||
|
|
||||||
// OTRTODO: Temp way of dealing with gMtxClear. Need something more elegant in the future...
|
// OTRTODO: Temp way of dealing with gMtxClear. Need something more elegant in the future...
|
||||||
uint32_t gameVersion = Ship::GlobalCtx2::GetInstance()->GetResourceManager()->GetGameVersion();
|
uint32_t gameVersion = Ship::Window::GetInstance()->GetResourceManager()->GetGameVersion();
|
||||||
if (gameVersion == OOT_PAL_GC) {
|
if (gameVersion == OOT_PAL_GC) {
|
||||||
if (mtxAddr == SEG_ADDR(0, 0x0FBC20)) {
|
if (mtxAddr == SEG_ADDR(0, 0x0FBC20)) {
|
||||||
mtxAddr = clearMtx;
|
mtxAddr = clearMtx;
|
||||||
@ -2658,8 +2679,10 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co
|
|||||||
gfx_current_dimensions.internal_mul = CVar_GetFloat("gInternalResolution", 1);
|
gfx_current_dimensions.internal_mul = CVar_GetFloat("gInternalResolution", 1);
|
||||||
#endif
|
#endif
|
||||||
gfx_msaa_level = CVar_GetS32("gMSAAValue", 1);
|
gfx_msaa_level = CVar_GetS32("gMSAAValue", 1);
|
||||||
|
#ifndef __WIIU__ // Wii U overrides dimentions in gfx_wapi->init to match framebuffer size
|
||||||
gfx_current_dimensions.width = width;
|
gfx_current_dimensions.width = width;
|
||||||
gfx_current_dimensions.height = height;
|
gfx_current_dimensions.height = height;
|
||||||
|
#endif
|
||||||
game_framebuffer = gfx_rapi->create_framebuffer();
|
game_framebuffer = gfx_rapi->create_framebuffer();
|
||||||
game_framebuffer_msaa_resolved = gfx_rapi->create_framebuffer();
|
game_framebuffer_msaa_resolved = gfx_rapi->create_framebuffer();
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include "U64/PR/ultra64/gbi.h"
|
||||||
#include "U64/PR/ultra64/types.h"
|
#include "U64/PR/ultra64/types.h"
|
||||||
|
|
||||||
// TODO figure out why changing these to 640x480 makes the game only render in a quarter of the window
|
// TODO figure out why changing these to 640x480 makes the game only render in a quarter of the window
|
||||||
|
467
libultraship/libultraship/Lib/Fast3D/gfx_wiiu.cpp
Normal file
467
libultraship/libultraship/Lib/Fast3D/gfx_wiiu.cpp
Normal file
@ -0,0 +1,467 @@
|
|||||||
|
#ifdef __WIIU__
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include <coreinit/time.h>
|
||||||
|
#include <coreinit/thread.h>
|
||||||
|
#include <coreinit/foreground.h>
|
||||||
|
#include <coreinit/memory.h>
|
||||||
|
#include <coreinit/memheap.h>
|
||||||
|
#include <coreinit/memdefaultheap.h>
|
||||||
|
#include <coreinit/memexpheap.h>
|
||||||
|
#include <coreinit/memfrmheap.h>
|
||||||
|
|
||||||
|
#include <gx2/state.h>
|
||||||
|
#include <gx2/context.h>
|
||||||
|
#include <gx2/display.h>
|
||||||
|
#include <gx2/event.h>
|
||||||
|
#include <gx2/swap.h>
|
||||||
|
#include <gx2/mem.h>
|
||||||
|
#include <gx2r/mem.h>
|
||||||
|
|
||||||
|
#include <whb/proc.h>
|
||||||
|
#include <proc_ui/procui.h>
|
||||||
|
#include <proc_ui/memory.h>
|
||||||
|
|
||||||
|
#include <vpad/input.h>
|
||||||
|
#include <padscore/kpad.h>
|
||||||
|
|
||||||
|
#ifndef _LANGUAGE_C
|
||||||
|
#define _LANGUAGE_C
|
||||||
|
#endif
|
||||||
|
#include "PR/ultra64/gbi.h"
|
||||||
|
|
||||||
|
#include "gfx_window_manager_api.h"
|
||||||
|
#include "gfx_pc.h"
|
||||||
|
#include "gfx_gx2.h"
|
||||||
|
#include "gfx_wiiu.h"
|
||||||
|
|
||||||
|
#include "Lib/ImGui/backends/wiiu/imgui_impl_wiiu.h"
|
||||||
|
#include "../../WiiUImpl.h"
|
||||||
|
#include "../../ImGuiImpl.h"
|
||||||
|
#include "../../Hooks.h"
|
||||||
|
|
||||||
|
static MEMHeapHandle heap_MEM1 = nullptr;
|
||||||
|
static MEMHeapHandle heap_foreground = nullptr;
|
||||||
|
|
||||||
|
bool has_foreground = false;
|
||||||
|
static void *mem1_storage = nullptr;
|
||||||
|
static void *command_buffer_pool = nullptr;
|
||||||
|
GX2ContextState *context_state = nullptr;
|
||||||
|
|
||||||
|
static GX2TVRenderMode tv_render_mode;
|
||||||
|
static void *tv_scan_buffer = nullptr;
|
||||||
|
static uint32_t tv_scan_buffer_size = 0;
|
||||||
|
static uint32_t tv_width;
|
||||||
|
static uint32_t tv_height;
|
||||||
|
|
||||||
|
static GX2DrcRenderMode drc_render_mode;
|
||||||
|
static void *drc_scan_buffer = nullptr;
|
||||||
|
static uint32_t drc_scan_buffer_size = 0;
|
||||||
|
|
||||||
|
static int frame_divisor = 1;
|
||||||
|
|
||||||
|
// for ImGui DeltaTime
|
||||||
|
// (initialized to 1 to not trigger imguis assert on initial draw)
|
||||||
|
uint32_t frametime = 1;
|
||||||
|
|
||||||
|
bool gfx_wiiu_init_mem1(void) {
|
||||||
|
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
||||||
|
uint32_t size;
|
||||||
|
void *base;
|
||||||
|
|
||||||
|
size = MEMGetAllocatableSizeForFrmHeapEx(heap, 4);
|
||||||
|
if (!size) {
|
||||||
|
printf("%s: MEMGetAllocatableSizeForFrmHeapEx == 0", __FUNCTION__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
base = MEMAllocFromFrmHeapEx(heap, size, 4);
|
||||||
|
if (!base) {
|
||||||
|
printf("%s: MEMAllocFromFrmHeapEx(heap, 0x%X, 4) failed", __FUNCTION__, size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
heap_MEM1 = MEMCreateExpHeapEx(base, size, 0);
|
||||||
|
if (!heap_MEM1) {
|
||||||
|
printf("%s: MEMCreateExpHeapEx(%p, 0x%X, 0) failed", __FUNCTION__, base, size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_wiiu_destroy_mem1(void) {
|
||||||
|
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
||||||
|
|
||||||
|
if (heap_MEM1) {
|
||||||
|
MEMDestroyExpHeap(heap_MEM1);
|
||||||
|
heap_MEM1 = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gfx_wiiu_init_foreground(void) {
|
||||||
|
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_FG);
|
||||||
|
uint32_t size;
|
||||||
|
void *base;
|
||||||
|
|
||||||
|
size = MEMGetAllocatableSizeForFrmHeapEx(heap, 4);
|
||||||
|
if (!size) {
|
||||||
|
printf("%s: MEMAllocFromFrmHeapEx(heap, 0x%X, 4)", __FUNCTION__, size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
base = MEMAllocFromFrmHeapEx(heap, size, 4);
|
||||||
|
if (!base) {
|
||||||
|
printf("%s: MEMGetAllocatableSizeForFrmHeapEx == 0", __FUNCTION__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
heap_foreground = MEMCreateExpHeapEx(base, size, 0);
|
||||||
|
if (!heap_foreground) {
|
||||||
|
printf("%s: MEMCreateExpHeapEx(%p, 0x%X, 0)", __FUNCTION__, base, size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_wiiu_destroy_foreground(void) {
|
||||||
|
MEMHeapHandle foreground = MEMGetBaseHeapHandle(MEM_BASE_HEAP_FG);
|
||||||
|
|
||||||
|
if (heap_foreground) {
|
||||||
|
MEMDestroyExpHeap(heap_foreground);
|
||||||
|
heap_foreground = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEMFreeToFrmHeap(foreground, MEM_FRM_HEAP_FREE_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *gfx_wiiu_alloc_mem1(uint32_t size, uint32_t alignment) {
|
||||||
|
void *block;
|
||||||
|
|
||||||
|
if (!heap_MEM1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alignment < 4) {
|
||||||
|
alignment = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = MEMAllocFromExpHeapEx(heap_MEM1, size, alignment);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_wiiu_free_mem1(void *block) {
|
||||||
|
if (!heap_MEM1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEMFreeToExpHeap(heap_MEM1, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *gfx_wiiu_alloc_foreground(uint32_t size, uint32_t alignment) {
|
||||||
|
void *block;
|
||||||
|
|
||||||
|
if (!heap_foreground) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alignment < 4) {
|
||||||
|
alignment = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = MEMAllocFromExpHeapEx(heap_foreground, size, alignment);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_wiiu_free_foreground(void *block) {
|
||||||
|
if (!heap_foreground) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEMFreeToExpHeap(heap_foreground, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t gfx_wiiu_proc_callback_acquired(void *context) {
|
||||||
|
has_foreground = true;
|
||||||
|
|
||||||
|
bool result = gfx_wiiu_init_foreground();
|
||||||
|
assert(result);
|
||||||
|
|
||||||
|
tv_scan_buffer = gfx_wiiu_alloc_foreground(tv_scan_buffer_size, GX2_SCAN_BUFFER_ALIGNMENT);
|
||||||
|
assert(tv_scan_buffer);
|
||||||
|
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, tv_scan_buffer, tv_scan_buffer_size);
|
||||||
|
GX2SetTVBuffer(tv_scan_buffer, tv_scan_buffer_size, tv_render_mode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE);
|
||||||
|
|
||||||
|
drc_scan_buffer = gfx_wiiu_alloc_foreground(drc_scan_buffer_size, GX2_SCAN_BUFFER_ALIGNMENT);
|
||||||
|
assert(drc_scan_buffer);
|
||||||
|
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drc_scan_buffer, drc_scan_buffer_size);
|
||||||
|
GX2SetDRCBuffer(drc_scan_buffer, drc_scan_buffer_size, drc_render_mode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t gfx_wiiu_proc_callback_released(void* context) {
|
||||||
|
if (tv_scan_buffer) {
|
||||||
|
gfx_wiiu_free_foreground(tv_scan_buffer);
|
||||||
|
tv_scan_buffer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drc_scan_buffer) {
|
||||||
|
gfx_wiiu_free_foreground(drc_scan_buffer);
|
||||||
|
drc_scan_buffer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx_wiiu_destroy_foreground();
|
||||||
|
|
||||||
|
has_foreground = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_init(const char *game_name, bool start_in_fullscreen, uint32_t width, uint32_t height) {
|
||||||
|
WHBProcInit();
|
||||||
|
|
||||||
|
uint32_t mem1_addr, mem1_size;
|
||||||
|
OSGetMemBound(OS_MEM1, &mem1_addr, &mem1_size);
|
||||||
|
mem1_storage = memalign(0x40, mem1_size);
|
||||||
|
assert(mem1_storage);
|
||||||
|
|
||||||
|
ProcUISetMEM1Storage(mem1_storage, mem1_size);
|
||||||
|
|
||||||
|
bool result = gfx_wiiu_init_mem1();
|
||||||
|
assert(result);
|
||||||
|
|
||||||
|
command_buffer_pool = memalign(GX2_COMMAND_BUFFER_ALIGNMENT, 0x400000);
|
||||||
|
assert(command_buffer_pool);
|
||||||
|
|
||||||
|
uint32_t initAttribs[] = {
|
||||||
|
GX2_INIT_CMD_BUF_BASE, (uintptr_t) command_buffer_pool,
|
||||||
|
GX2_INIT_CMD_BUF_POOL_SIZE, 0x400000,
|
||||||
|
GX2_INIT_ARGC, 0,
|
||||||
|
GX2_INIT_ARGV, 0,
|
||||||
|
GX2_INIT_END
|
||||||
|
};
|
||||||
|
GX2Init(initAttribs);
|
||||||
|
|
||||||
|
switch(GX2GetSystemTVScanMode()) {
|
||||||
|
case GX2_TV_SCAN_MODE_480I:
|
||||||
|
case GX2_TV_SCAN_MODE_480P:
|
||||||
|
tv_render_mode = GX2_TV_RENDER_MODE_WIDE_480P;
|
||||||
|
tv_width = 854;
|
||||||
|
tv_height = 480;
|
||||||
|
break;
|
||||||
|
case GX2_TV_SCAN_MODE_1080I:
|
||||||
|
case GX2_TV_SCAN_MODE_1080P:
|
||||||
|
tv_render_mode = GX2_TV_RENDER_MODE_WIDE_1080P;
|
||||||
|
tv_width = 1920;
|
||||||
|
tv_height = 1080;
|
||||||
|
break;
|
||||||
|
case GX2_TV_SCAN_MODE_720P:
|
||||||
|
default:
|
||||||
|
tv_render_mode = GX2_TV_RENDER_MODE_WIDE_720P;
|
||||||
|
tv_width = 1280;
|
||||||
|
tv_height = 720;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
drc_render_mode = GX2GetSystemDRCScanMode();
|
||||||
|
|
||||||
|
uint32_t unk;
|
||||||
|
GX2CalcTVSize(tv_render_mode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &tv_scan_buffer_size, &unk);
|
||||||
|
GX2CalcDRCSize(drc_render_mode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &drc_scan_buffer_size, &unk);
|
||||||
|
|
||||||
|
ProcUIRegisterCallback(PROCUI_CALLBACK_ACQUIRE, gfx_wiiu_proc_callback_acquired, nullptr, 100);
|
||||||
|
ProcUIRegisterCallback(PROCUI_CALLBACK_RELEASE, gfx_wiiu_proc_callback_released, nullptr, 100);
|
||||||
|
|
||||||
|
gfx_wiiu_proc_callback_acquired(nullptr);
|
||||||
|
|
||||||
|
context_state = (GX2ContextState *) memalign(GX2_CONTEXT_STATE_ALIGNMENT, sizeof(GX2ContextState));
|
||||||
|
assert(context_state);
|
||||||
|
|
||||||
|
GX2SetupContextStateEx(context_state, TRUE);
|
||||||
|
GX2SetContextState(context_state);
|
||||||
|
|
||||||
|
GX2SetTVScale(WIIU_DEFAULT_FB_WIDTH, WIIU_DEFAULT_FB_HEIGHT);
|
||||||
|
GX2SetDRCScale(WIIU_DEFAULT_FB_WIDTH, WIIU_DEFAULT_FB_HEIGHT);
|
||||||
|
|
||||||
|
GX2SetSwapInterval(frame_divisor);
|
||||||
|
|
||||||
|
gfx_current_dimensions.width = gfx_current_game_window_viewport.width = WIIU_DEFAULT_FB_WIDTH;
|
||||||
|
gfx_current_dimensions.height = gfx_current_game_window_viewport.height = WIIU_DEFAULT_FB_HEIGHT;
|
||||||
|
|
||||||
|
SohImGui::WindowImpl window_impl;
|
||||||
|
window_impl.backend = SohImGui::Backend::GX2;
|
||||||
|
window_impl.gx2.width = WIIU_DEFAULT_FB_WIDTH;
|
||||||
|
window_impl.gx2.height = WIIU_DEFAULT_FB_HEIGHT;
|
||||||
|
SohImGui::Init(window_impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_shutdown(void) {
|
||||||
|
if (has_foreground) {
|
||||||
|
gfx_wiiu_proc_callback_released(nullptr);
|
||||||
|
gfx_wiiu_destroy_mem1();
|
||||||
|
}
|
||||||
|
|
||||||
|
GX2Shutdown();
|
||||||
|
|
||||||
|
if (context_state) {
|
||||||
|
free(context_state);
|
||||||
|
context_state = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command_buffer_pool) {
|
||||||
|
free(command_buffer_pool);
|
||||||
|
command_buffer_pool = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcUISetMEM1Storage(nullptr, 0);
|
||||||
|
free(mem1_storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_wiiu_set_context_state(void) {
|
||||||
|
GX2SetContextState(context_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_set_fullscreen_changed_callback(void (*on_fullscreen_changed)(bool is_now_fullscreen)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_set_fullscreen(bool enable) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_show_cursor(bool hide) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode), void (*on_all_keys_up)(void)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_main_loop(void (*run_one_game_iter)(void)) {
|
||||||
|
while (WHBProcIsRunning()) {
|
||||||
|
run_one_game_iter();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ship::ExecuteHooks<Ship::ExitGame>();
|
||||||
|
Ship::WiiU::Exit();
|
||||||
|
|
||||||
|
gfx_gx2_shutdown();
|
||||||
|
gfx_wiiu_shutdown();
|
||||||
|
WHBProcShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_get_dimensions(uint32_t *width, uint32_t *height) {
|
||||||
|
*width = WIIU_DEFAULT_FB_WIDTH;
|
||||||
|
*height = WIIU_DEFAULT_FB_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_handle_events(void) {
|
||||||
|
Ship::WiiU::Update();
|
||||||
|
|
||||||
|
ImGui_ImplWiiU_ControllerInput input{};
|
||||||
|
|
||||||
|
VPADReadError vpad_error;
|
||||||
|
input.vpad = Ship::WiiU::GetVPADStatus(&vpad_error);
|
||||||
|
if (vpad_error != VPAD_READ_SUCCESS) {
|
||||||
|
input.vpad = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
KPADError kpad_error;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
input.kpad[i] = Ship::WiiU::GetKPADStatus((WPADChan) i, &kpad_error);
|
||||||
|
if (kpad_error != KPAD_ERROR_OK) {
|
||||||
|
input.kpad[i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SohImGui::EventImpl event_impl;
|
||||||
|
event_impl.gx2.input = &input;
|
||||||
|
SohImGui::Update(event_impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool gfx_wiiu_start_frame(void) {
|
||||||
|
uint32_t swap_count, flip_count;
|
||||||
|
OSTime last_flip, last_vsync;
|
||||||
|
uint32_t wait_count = 0;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
|
||||||
|
|
||||||
|
if (flip_count >= swap_count) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wait_count >= 10) {
|
||||||
|
// GPU timed out, drop frame
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_count++;
|
||||||
|
GX2WaitForVsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_swap_buffers_begin(void) {
|
||||||
|
GX2SwapScanBuffers();
|
||||||
|
GX2Flush();
|
||||||
|
|
||||||
|
gfx_wiiu_set_context_state();
|
||||||
|
|
||||||
|
GX2SetTVEnable(TRUE);
|
||||||
|
GX2SetDRCEnable(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_swap_buffers_end(void) {
|
||||||
|
static OSTick tick = 0;
|
||||||
|
frametime = OSTicksToMicroseconds(OSGetSystemTick() - tick);
|
||||||
|
tick = OSGetSystemTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
static double gfx_wiiu_get_time(void) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_set_target_fps(int fps) {
|
||||||
|
// use the nearest divisor
|
||||||
|
int divisor = 60 / fps;
|
||||||
|
if (divisor < 1) {
|
||||||
|
divisor = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frame_divisor != divisor) {
|
||||||
|
GX2SetSwapInterval(divisor);
|
||||||
|
frame_divisor = divisor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_wiiu_set_maximum_frame_latency(int latency) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static float gfx_wiiu_get_detected_hz(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct GfxWindowManagerAPI gfx_wiiu = {
|
||||||
|
gfx_wiiu_init,
|
||||||
|
gfx_wiiu_set_keyboard_callbacks,
|
||||||
|
gfx_wiiu_set_fullscreen_changed_callback,
|
||||||
|
gfx_wiiu_set_fullscreen,
|
||||||
|
gfx_wiiu_show_cursor,
|
||||||
|
gfx_wiiu_main_loop,
|
||||||
|
gfx_wiiu_get_dimensions,
|
||||||
|
gfx_wiiu_handle_events,
|
||||||
|
gfx_wiiu_start_frame,
|
||||||
|
gfx_wiiu_swap_buffers_begin,
|
||||||
|
gfx_wiiu_swap_buffers_end,
|
||||||
|
gfx_wiiu_get_time,
|
||||||
|
gfx_wiiu_set_target_fps,
|
||||||
|
gfx_wiiu_set_maximum_frame_latency,
|
||||||
|
gfx_wiiu_get_detected_hz,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
38
libultraship/libultraship/Lib/Fast3D/gfx_wiiu.h
Normal file
38
libultraship/libultraship/Lib/Fast3D/gfx_wiiu.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef GFX_WIIU_H
|
||||||
|
#define GFX_WIIU_H
|
||||||
|
#ifdef __WIIU__
|
||||||
|
|
||||||
|
#include <vpad/input.h>
|
||||||
|
#include <padscore/kpad.h>
|
||||||
|
|
||||||
|
#include "gfx_window_manager_api.h"
|
||||||
|
|
||||||
|
// make the default fb always 1080p to not mess with scaling
|
||||||
|
#define WIIU_DEFAULT_FB_WIDTH 1920
|
||||||
|
#define WIIU_DEFAULT_FB_HEIGHT 1080
|
||||||
|
|
||||||
|
extern bool has_foreground;
|
||||||
|
extern uint32_t frametime;
|
||||||
|
|
||||||
|
bool gfx_wiiu_init_mem1(void);
|
||||||
|
|
||||||
|
void gfx_wiiu_destroy_mem1(void);
|
||||||
|
|
||||||
|
bool gfx_wiiu_init_foreground(void);
|
||||||
|
|
||||||
|
void gfx_wiiu_destroy_foreground(void);
|
||||||
|
|
||||||
|
void *gfx_wiiu_alloc_mem1(uint32_t size, uint32_t alignment);
|
||||||
|
|
||||||
|
void gfx_wiiu_free_mem1(void *block);
|
||||||
|
|
||||||
|
void *gfx_wiiu_alloc_foreground(uint32_t size, uint32_t alignment);
|
||||||
|
|
||||||
|
void gfx_wiiu_free_foreground(void *block);
|
||||||
|
|
||||||
|
void gfx_wiiu_set_context_state(void);
|
||||||
|
|
||||||
|
extern struct GfxWindowManagerAPI gfx_wiiu;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
810
libultraship/libultraship/Lib/Fast3D/gx2_shader_gen.c
Normal file
810
libultraship/libultraship/Lib/Fast3D/gx2_shader_gen.c
Normal file
@ -0,0 +1,810 @@
|
|||||||
|
#ifdef __WIIU__
|
||||||
|
|
||||||
|
#include "gx2_shader_gen.h"
|
||||||
|
#include "gx2_shader_inl.h"
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <gx2/mem.h>
|
||||||
|
|
||||||
|
#define ROUNDUP(x, align) (((x) + ((align) -1)) & ~((align) -1))
|
||||||
|
|
||||||
|
#define FRAG_COORD_REG _R0
|
||||||
|
#define TEXEL_REG _R1
|
||||||
|
#define FOG_REG _R3
|
||||||
|
#define GRAYSCALE_REG _R4
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SHADER_TEXINFO0 = SHADER_COMBINED + 1,
|
||||||
|
SHADER_TEXINFO1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t get_reg(struct CCFeatures *cc_features, uint8_t c) {
|
||||||
|
if (c == SHADER_0) {
|
||||||
|
return ALU_SRC_0;
|
||||||
|
}
|
||||||
|
if (c == SHADER_1) {
|
||||||
|
return ALU_SRC_1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == SHADER_COMBINED) {
|
||||||
|
return TEXEL_REG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c >= SHADER_INPUT_1 && c <= SHADER_INPUT_7) {
|
||||||
|
return _R(5 + (c - SHADER_INPUT_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t input_last = (cc_features->num_inputs + 5) - 1;
|
||||||
|
|
||||||
|
if (c == SHADER_TEXEL0 || c == SHADER_TEXEL0A) {
|
||||||
|
// reuse unused regs
|
||||||
|
if (!cc_features->opt_noise) {
|
||||||
|
return FRAG_COORD_REG;
|
||||||
|
} else if (!cc_features->opt_fog) {
|
||||||
|
return FOG_REG;
|
||||||
|
} else if (!cc_features->opt_grayscale) {
|
||||||
|
return GRAYSCALE_REG;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _R(input_last + 1);
|
||||||
|
}
|
||||||
|
if (c == SHADER_TEXEL1 || c == SHADER_TEXEL1A) {
|
||||||
|
// if the shader doesn't use texture 0 we can reuse it for texture 1
|
||||||
|
if (!cc_features->used_textures[0]) {
|
||||||
|
return get_reg(cc_features, SHADER_TEXEL0);
|
||||||
|
}
|
||||||
|
// reuse unused regs which tex 0 doesn't use yet
|
||||||
|
else if (!cc_features->opt_fog && get_reg(cc_features, SHADER_TEXEL0) != FOG_REG) {
|
||||||
|
return FOG_REG;
|
||||||
|
} else if (!cc_features->opt_grayscale && get_reg(cc_features, SHADER_TEXEL0) != GRAYSCALE_REG) {
|
||||||
|
return GRAYSCALE_REG;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _R(input_last + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// reuse the regs above
|
||||||
|
if (c == SHADER_TEXINFO0) {
|
||||||
|
return get_reg(cc_features, SHADER_TEXEL0);
|
||||||
|
}
|
||||||
|
if (c == SHADER_TEXINFO1) {
|
||||||
|
return get_reg(cc_features, SHADER_TEXEL1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t get_num_regs(struct CCFeatures *cc_features) {
|
||||||
|
uint8_t input_count = cc_features->num_inputs + 5;
|
||||||
|
|
||||||
|
uint8_t last_tex_reg;
|
||||||
|
if (cc_features->used_textures[1]) {
|
||||||
|
last_tex_reg = get_reg(cc_features, SHADER_TEXEL1) + 1;
|
||||||
|
} else if (cc_features->used_textures[0]) {
|
||||||
|
last_tex_reg = get_reg(cc_features, SHADER_TEXEL0) + 1;
|
||||||
|
} else {
|
||||||
|
return input_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (last_tex_reg < input_count) ? input_count : last_tex_reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ADD_INSTR(...) \
|
||||||
|
uint64_t tmp[] = {__VA_ARGS__}; \
|
||||||
|
memcpy(*alu_ptr, tmp, sizeof(tmp)); \
|
||||||
|
*alu_ptr += sizeof(tmp) / sizeof(uint64_t)
|
||||||
|
|
||||||
|
static inline void add_tex_clamp_S_T(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t tex) {
|
||||||
|
uint8_t texinfo_reg = get_reg(cc_features, (tex == 0) ? SHADER_TEXINFO0 : SHADER_TEXINFO1);
|
||||||
|
uint8_t texcoord_reg = (tex == 0) ? _R1 : _R2;
|
||||||
|
|
||||||
|
ADD_INSTR(
|
||||||
|
/* R127.xy = (float) texinfo.xy */
|
||||||
|
ALU_INT_TO_FLT(_R127, _x, texinfo_reg, _x) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_INT_TO_FLT(_R127, _y, texinfo_reg, _y) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* R127.xy = 0.5f / texSize */
|
||||||
|
ALU_RECIP_IEEE(__, _x, _R127, _x) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MUL_IEEE(_R127, _x, ALU_SRC_PS, _x, ALU_SRC_0_5, _x),
|
||||||
|
ALU_RECIP_IEEE(__, _y, _R127, _y) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MUL_IEEE(_R127, _y, ALU_SRC_PS, _y, ALU_SRC_0_5, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* texCoord.xy = clamp(texCoord.xy, R127.xy, texClamp.xy) */
|
||||||
|
ALU_MAX(__, _x, texcoord_reg, _x, _R127, _x),
|
||||||
|
ALU_MAX(__, _y, texcoord_reg, _y, _R127, _y)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MIN(texcoord_reg, _x, ALU_SRC_PV, _x, texcoord_reg, _z),
|
||||||
|
ALU_MIN(texcoord_reg, _y, ALU_SRC_PV, _y, texcoord_reg, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void add_tex_clamp_S(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t tex) {
|
||||||
|
uint8_t texinfo_reg = get_reg(cc_features, (tex == 0) ? SHADER_TEXINFO0 : SHADER_TEXINFO1);
|
||||||
|
uint8_t texcoord_reg = (tex == 0) ? _R1 : _R2;
|
||||||
|
|
||||||
|
ADD_INSTR(
|
||||||
|
/* R127.x = (float) texinfo.x */
|
||||||
|
ALU_INT_TO_FLT(_R127, _x, texinfo_reg, _x) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* R127.x = 0.5f / texSize */
|
||||||
|
ALU_RECIP_IEEE(__, _x, _R127, _x) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MUL_IEEE(_R127, _x, ALU_SRC_PS, _x, ALU_SRC_0_5, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* texCoord.xy = clamp(texCoord.xy, R127.xy, texClamp.xy) */
|
||||||
|
ALU_MAX(__, _x, texcoord_reg, _x, _R127, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MIN(texcoord_reg, _x, ALU_SRC_PV, _x, texcoord_reg, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void add_tex_clamp_T(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t tex) {
|
||||||
|
uint8_t texinfo_reg = get_reg(cc_features, (tex == 0) ? SHADER_TEXINFO0 : SHADER_TEXINFO1);
|
||||||
|
uint8_t texcoord_reg = (tex == 0) ? _R1 : _R2;
|
||||||
|
|
||||||
|
ADD_INSTR(
|
||||||
|
/* R127.y = (float) texinfo.y */
|
||||||
|
ALU_INT_TO_FLT(_R127, _y, texinfo_reg, _y) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* R127.y = 0.5f / texSize */
|
||||||
|
ALU_RECIP_IEEE(__, _x, _R127, _y) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MUL_IEEE(_R127, _y, ALU_SRC_PS, _x, ALU_SRC_0_5, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* texCoord.xy = clamp(texCoord.xy, R127.xy, texClamp.xy) */
|
||||||
|
ALU_MAX(__, _y, texcoord_reg, _y, _R127, _y)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MIN(texcoord_reg, _y, ALU_SRC_PV, _y, texcoord_reg, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void add_mov(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t src, bool single) {
|
||||||
|
bool src_alpha = (src == SHADER_TEXEL0A) || (src == SHADER_TEXEL1A);
|
||||||
|
src = get_reg(cc_features, src);
|
||||||
|
|
||||||
|
/* texel = src */
|
||||||
|
if (single) {
|
||||||
|
ADD_INSTR(
|
||||||
|
ALU_MOV(TEXEL_REG, _w, src, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ADD_INSTR(
|
||||||
|
ALU_MOV(TEXEL_REG, _x, src, src_alpha ? _w :_x),
|
||||||
|
ALU_MOV(TEXEL_REG, _y, src, src_alpha ? _w :_y),
|
||||||
|
ALU_MOV(TEXEL_REG, _z, src, src_alpha ? _w :_z)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void add_mul(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t src0, uint8_t src1, bool single) {
|
||||||
|
bool src0_alpha = (src0 == SHADER_TEXEL0A) || (src0 == SHADER_TEXEL1A);
|
||||||
|
bool src1_alpha = (src1 == SHADER_TEXEL0A) || (src1 == SHADER_TEXEL1A);
|
||||||
|
src0 = get_reg(cc_features, src0);
|
||||||
|
src1 = get_reg(cc_features, src1);
|
||||||
|
|
||||||
|
/* texel = src0 * src1 */
|
||||||
|
if (single) {
|
||||||
|
ADD_INSTR(
|
||||||
|
ALU_MUL(TEXEL_REG, _w, src0, _w, src1, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ADD_INSTR(
|
||||||
|
ALU_MUL(TEXEL_REG, _x, src0, src0_alpha ? _w : _x, src1, src1_alpha ? _w : _x),
|
||||||
|
ALU_MUL(TEXEL_REG, _y, src0, src0_alpha ? _w : _y, src1, src1_alpha ? _w : _y),
|
||||||
|
ALU_MUL(TEXEL_REG, _z, src0, src0_alpha ? _w : _z, src1, src1_alpha ? _w : _z)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void add_mix(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t src0, uint8_t src1, uint8_t src2, uint8_t src3, bool single) {
|
||||||
|
bool src0_alpha = (src0 == SHADER_TEXEL0A) || (src0 == SHADER_TEXEL1A);
|
||||||
|
bool src1_alpha = (src1 == SHADER_TEXEL0A) || (src1 == SHADER_TEXEL1A);
|
||||||
|
bool src2_alpha = (src2 == SHADER_TEXEL0A) || (src2 == SHADER_TEXEL1A);
|
||||||
|
bool src3_alpha = (src3 == SHADER_TEXEL0A) || (src3 == SHADER_TEXEL1A);
|
||||||
|
src0 = get_reg(cc_features, src0);
|
||||||
|
src1 = get_reg(cc_features, src1);
|
||||||
|
src2 = get_reg(cc_features, src2);
|
||||||
|
src3 = get_reg(cc_features, src3);
|
||||||
|
|
||||||
|
/* texel = (src0 - src1) * src2 - src3 */
|
||||||
|
if (single) {
|
||||||
|
ADD_INSTR(
|
||||||
|
ALU_ADD(__, _w, src0, _w, src1 _NEG, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MULADD(TEXEL_REG, _w, ALU_SRC_PV, _w, src2, _w, src3, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ADD_INSTR(
|
||||||
|
ALU_ADD(__, _x, src0, src0_alpha ? _w : _x, src1 _NEG, src1_alpha ? _w : _x),
|
||||||
|
ALU_ADD(__, _y, src0, src0_alpha ? _w : _y, src1 _NEG, src1_alpha ? _w : _y),
|
||||||
|
ALU_ADD(__, _z, src0, src0_alpha ? _w : _z, src1 _NEG, src1_alpha ? _w : _z)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MULADD(TEXEL_REG, _x, ALU_SRC_PV, _x, src2, src2_alpha ? _w : _x, src3, src3_alpha ? _w : _x),
|
||||||
|
ALU_MULADD(TEXEL_REG, _y, ALU_SRC_PV, _y, src2, src2_alpha ? _w : _y, src3, src3_alpha ? _w : _y),
|
||||||
|
ALU_MULADD(TEXEL_REG, _z, ALU_SRC_PV, _z, src2, src2_alpha ? _w : _z, src3, src3_alpha ? _w : _z)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#undef ADD_INSTR
|
||||||
|
|
||||||
|
static void append_tex_clamp(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t tex, bool s, bool t) {
|
||||||
|
if (s && t) {
|
||||||
|
add_tex_clamp_S_T(cc_features, alu_ptr, tex);
|
||||||
|
} else if (s) {
|
||||||
|
add_tex_clamp_S(cc_features, alu_ptr, tex);
|
||||||
|
} else {
|
||||||
|
add_tex_clamp_T(cc_features, alu_ptr, tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void append_formula(struct CCFeatures *cc_features, uint64_t **alu_ptr, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool only_alpha) {
|
||||||
|
if (do_single) {
|
||||||
|
add_mov(cc_features, alu_ptr, c[only_alpha][3], only_alpha);
|
||||||
|
} else if (do_multiply) {
|
||||||
|
add_mul(cc_features, alu_ptr, c[only_alpha][0], c[only_alpha][2], only_alpha);
|
||||||
|
} else if (do_mix) {
|
||||||
|
add_mix(cc_features, alu_ptr, c[only_alpha][0], c[only_alpha][1], c[only_alpha][2], c[only_alpha][1], only_alpha);
|
||||||
|
} else {
|
||||||
|
add_mix(cc_features, alu_ptr, c[only_alpha][0], c[only_alpha][1], c[only_alpha][2], c[only_alpha][3], only_alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uint64_t noise_instructions[] = {
|
||||||
|
/* R127 = floor(gl_FragCoord.xy * window_params.x) */
|
||||||
|
ALU_MUL(__, _x, FRAG_COORD_REG, _x, _C(0), _x),
|
||||||
|
ALU_MUL(__, _y, FRAG_COORD_REG, _y, _C(0), _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_FLOOR(_R127, _x, ALU_SRC_PV, _x),
|
||||||
|
ALU_FLOOR(_R127, _y, ALU_SRC_PV, _y)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* R127 = sin(vec3(R127.x, R127.y, window_params.y)) */
|
||||||
|
ALU_MULADD(_R127, _x, _R127, _x, ALU_SRC_LITERAL, _x, ALU_SRC_0_5, _x),
|
||||||
|
ALU_MULADD(_R127, _y, _R127, _y, ALU_SRC_LITERAL, _x, ALU_SRC_0_5, _x),
|
||||||
|
ALU_MULADD(_R127, _z, _C(0), _y, ALU_SRC_LITERAL, _x, ALU_SRC_0_5, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x3E22F983 /* 0.1591549367f (radians -> revolutions) */),
|
||||||
|
|
||||||
|
ALU_FRACT(__, _x, _R127, _x),
|
||||||
|
ALU_FRACT(__, _y, _R127, _y),
|
||||||
|
ALU_FRACT(__, _z, _R127, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MULADD(_R127, _x, ALU_SRC_PV, _x, ALU_SRC_LITERAL, _x, ALU_SRC_LITERAL, _y),
|
||||||
|
ALU_MULADD(_R127, _y, ALU_SRC_PV, _y, ALU_SRC_LITERAL, _x, ALU_SRC_LITERAL, _y),
|
||||||
|
ALU_MULADD(_R127, _z, ALU_SRC_PV, _z, ALU_SRC_LITERAL, _x, ALU_SRC_LITERAL, _y)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL2(0x40C90FDB /* 6.283185482f (tau) */, 0xC0490FDB /* -3.141592741f (-pi) */),
|
||||||
|
|
||||||
|
ALU_MUL(_R127, _x, ALU_SRC_PV, _x, ALU_SRC_LITERAL, _x),
|
||||||
|
ALU_MUL(_R127, _y, ALU_SRC_PV, _y, ALU_SRC_LITERAL, _x),
|
||||||
|
ALU_MUL(_R127, _z, ALU_SRC_PV, _z, ALU_SRC_LITERAL, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x3E22F983 /* 0.1591549367f (radians -> revolutions) */),
|
||||||
|
|
||||||
|
ALU_SIN(_R127, _x, _R127, _x) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_SIN(_R127, _y, _R127, _y) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_SIN(_R127, _z, _R127, _z) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* R127.x = dot(R127.xyz, vec3(12.9898, 78.233, 37.719)); */
|
||||||
|
ALU_DOT4(_R127, _x, _R127, _x, ALU_SRC_LITERAL, _x),
|
||||||
|
ALU_DOT4(__, _y, _R127, _y, ALU_SRC_LITERAL, _y),
|
||||||
|
ALU_DOT4(__, _z, _R127, _z, ALU_SRC_LITERAL, _z),
|
||||||
|
ALU_DOT4(__, _w, ALU_SRC_LITERAL, _w, ALU_SRC_0, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL4(0x414FD639 /* 12.9898f */, 0x429C774C /* 78.233f */, 0x4216E042 /* 37.719f */, 0x80000000 /* -0.0f */),
|
||||||
|
|
||||||
|
/* R127.x = fract(sin(R127.x) * 143758.5453); */
|
||||||
|
ALU_MULADD(_R127, _x, _R127, _x, ALU_SRC_LITERAL, _x, ALU_SRC_0_5, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x3E22F983 /* 0.1591549367f (radians -> revolutions) */),
|
||||||
|
|
||||||
|
ALU_FRACT(__, _x, _R127, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MULADD(_R127, _x, ALU_SRC_PV, _x, ALU_SRC_LITERAL, _x, ALU_SRC_LITERAL, _y)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL2(0x40C90FDB /* 6.283185482f (tau) */, 0xC0490FDB /* -3.141592741f (-pi) */),
|
||||||
|
|
||||||
|
ALU_SIN(_R127, _x, _R127, _x) SCL_210
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MUL(__, _x, _R127, _x, ALU_SRC_LITERAL, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x480C63A3 /* 143758.5453f */),
|
||||||
|
|
||||||
|
ALU_FRACT( _R127, _x, ALU_SRC_PV, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* texel.a *= floor(R127.x + 0.5); */
|
||||||
|
ALU_ADD(__, _x, _R127, _x, ALU_SRC_0_5, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_FLOOR(__, _x, ALU_SRC_PV, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MUL(TEXEL_REG, _w, TEXEL_REG, _w, ALU_SRC_PV, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
};
|
||||||
|
|
||||||
|
static GX2UniformVar uniformVars[] = {
|
||||||
|
{ "window_params", GX2_SHADER_VAR_TYPE_FLOAT2, 1, 0, -1, },
|
||||||
|
};
|
||||||
|
|
||||||
|
static GX2SamplerVar samplerVars[] = {
|
||||||
|
{ "uTex0", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, 0 },
|
||||||
|
{ "uTex1", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, 1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ADD_INSTR(...) \
|
||||||
|
do { \
|
||||||
|
uint64_t tmp[] = {__VA_ARGS__}; \
|
||||||
|
memcpy(cur_buf, tmp, sizeof(tmp)); \
|
||||||
|
cur_buf += sizeof(tmp) / sizeof(uint64_t); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static int generatePixelShader(GX2PixelShader *psh, struct CCFeatures *cc_features) {
|
||||||
|
static const size_t max_program_buf_size = 512 * sizeof(uint64_t);
|
||||||
|
uint64_t *program_buf = memalign(GX2_SHADER_PROGRAM_ALIGNMENT, max_program_buf_size);
|
||||||
|
if (!program_buf) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(program_buf, 0, max_program_buf_size);
|
||||||
|
|
||||||
|
// start placing alus at offset 32
|
||||||
|
static const uint32_t base_alu_offset = 32;
|
||||||
|
uint64_t *cur_buf = NULL;
|
||||||
|
|
||||||
|
// check if we need to clamp
|
||||||
|
bool texclamp[2] = { false, false };
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (cc_features->used_textures[i]) {
|
||||||
|
if (cc_features->clamp[i][0] || cc_features->clamp[i][1]) {
|
||||||
|
texclamp[i] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t texclamp_alu_offset = base_alu_offset;
|
||||||
|
uint32_t texclamp_alu_size = 0;
|
||||||
|
uint32_t texclamp_alu_cnt = 0;
|
||||||
|
|
||||||
|
if (texclamp[0] || texclamp[1]) {
|
||||||
|
// texclamp alu
|
||||||
|
cur_buf = program_buf + texclamp_alu_offset;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (cc_features->used_textures[i] && texclamp[i]) {
|
||||||
|
append_tex_clamp(cc_features, &cur_buf, i, cc_features->clamp[i][0], cc_features->clamp[i][1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
texclamp_alu_size = (uintptr_t) cur_buf - ((uintptr_t) (program_buf + texclamp_alu_offset));
|
||||||
|
texclamp_alu_cnt = texclamp_alu_size / sizeof(uint64_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// main alu0
|
||||||
|
uint32_t main_alu0_offset = texclamp_alu_offset + texclamp_alu_cnt;
|
||||||
|
cur_buf = program_buf + main_alu0_offset;
|
||||||
|
|
||||||
|
for (int c = 0; c < (cc_features->opt_2cyc ? 2 : 1); c++) {
|
||||||
|
append_formula(cc_features, &cur_buf, cc_features->c[c], cc_features->do_single[c][0], cc_features->do_multiply[c][0], cc_features->do_mix[c][0], false);
|
||||||
|
if (cc_features->opt_alpha) {
|
||||||
|
append_formula(cc_features, &cur_buf, cc_features->c[c], cc_features->do_single[c][1], cc_features->do_multiply[c][1], cc_features->do_mix[c][1], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc_features->opt_fog) {
|
||||||
|
ADD_INSTR(
|
||||||
|
/* texel.rgb = mix(texel.rgb, vFog.rgb, vFog.a); */
|
||||||
|
ALU_ADD(__, _x, FOG_REG, _x, _R1 _NEG, _x),
|
||||||
|
ALU_ADD(__, _y, FOG_REG, _y, _R1 _NEG, _y),
|
||||||
|
ALU_ADD(__, _z, FOG_REG, _z, _R1 _NEG, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MULADD(TEXEL_REG, _x, ALU_SRC_PV, _x, FOG_REG, _w, TEXEL_REG, _x),
|
||||||
|
ALU_MULADD(TEXEL_REG, _y, ALU_SRC_PV, _y, FOG_REG, _w, TEXEL_REG, _y),
|
||||||
|
ALU_MULADD(TEXEL_REG, _z, ALU_SRC_PV, _z, FOG_REG, _w, TEXEL_REG, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc_features->opt_texture_edge && cc_features->opt_alpha) {
|
||||||
|
ADD_INSTR(
|
||||||
|
/* if (texel.a > 0.19) texel.a = 1.0; else discard; */
|
||||||
|
ALU_KILLGT(__, _x, ALU_SRC_LITERAL, _x, TEXEL_REG, _w),
|
||||||
|
ALU_MOV(TEXEL_REG, _w, ALU_SRC_1, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x3e428f5c /*0.19f*/),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t main_alu0_size = (uintptr_t) cur_buf - ((uintptr_t) (program_buf + main_alu0_offset));
|
||||||
|
const uint32_t main_alu0_cnt = main_alu0_size / sizeof(uint64_t);
|
||||||
|
|
||||||
|
// main alu1
|
||||||
|
// place the following instructions into a new alu, in case the other alu uses KILL
|
||||||
|
const uint32_t main_alu1_offset = main_alu0_offset + main_alu0_cnt;
|
||||||
|
cur_buf = program_buf + main_alu1_offset;
|
||||||
|
|
||||||
|
if (cc_features->opt_alpha && cc_features->opt_noise) {
|
||||||
|
memcpy(cur_buf, noise_instructions, sizeof(noise_instructions));
|
||||||
|
cur_buf += sizeof(noise_instructions) / sizeof(uint64_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc_features->opt_grayscale) {
|
||||||
|
ADD_INSTR(
|
||||||
|
/* texel.r + texel.g + texel.b */
|
||||||
|
ALU_ADD(__, _x, TEXEL_REG, _x, TEXEL_REG, _y)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_ADD(__, _x, ALU_SRC_PV, _x, TEXEL_REG, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
/* PV.x / 3 */
|
||||||
|
ALU_MUL_IEEE(__, _x, ALU_SRC_PV, _x, ALU_SRC_LITERAL, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x3eaaaaab /*0.3333333433f*/),
|
||||||
|
|
||||||
|
/* texel.rgb = mix(texel.rgb, vGrayscaleColor.rgb * intensity, vGrayscaleColor.a); */
|
||||||
|
ALU_MULADD(_R127, _x, GRAYSCALE_REG, _x, ALU_SRC_PV, _x, _R1 _NEG, _x),
|
||||||
|
ALU_MULADD(_R127, _y, GRAYSCALE_REG, _y, ALU_SRC_PV, _x, _R1 _NEG, _y),
|
||||||
|
ALU_MULADD(_R127, _z, GRAYSCALE_REG, _z, ALU_SRC_PV, _x, _R1 _NEG, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
|
||||||
|
ALU_MULADD(TEXEL_REG, _x, ALU_SRC_PV, _x, GRAYSCALE_REG, _w, TEXEL_REG, _x),
|
||||||
|
ALU_MULADD(TEXEL_REG, _y, ALU_SRC_PV, _y, GRAYSCALE_REG, _w, TEXEL_REG, _y),
|
||||||
|
ALU_MULADD(TEXEL_REG, _z, ALU_SRC_PV, _z, GRAYSCALE_REG, _w, TEXEL_REG, _z)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc_features->opt_alpha) {
|
||||||
|
if (cc_features->opt_alpha_threshold) {
|
||||||
|
ADD_INSTR(
|
||||||
|
/* if (texel.a < 8.0 / 256.0) discard; */
|
||||||
|
ALU_KILLGT(__, _x, ALU_SRC_LITERAL, _x, TEXEL_REG, _w)
|
||||||
|
ALU_LAST,
|
||||||
|
ALU_LITERAL(0x3d000000 /*0.03125f*/),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc_features->opt_invisible) {
|
||||||
|
ADD_INSTR(
|
||||||
|
/* texel.a = 0.0; */
|
||||||
|
ALU_MOV(TEXEL_REG, _w, ALU_SRC_0, _x)
|
||||||
|
ALU_LAST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t main_alu1_size = (uintptr_t) cur_buf - ((uintptr_t) (program_buf + main_alu1_offset));
|
||||||
|
const uint32_t main_alu1_cnt = main_alu1_size / sizeof(uint64_t);
|
||||||
|
|
||||||
|
// tex
|
||||||
|
uint32_t num_textures = cc_features->used_textures[0] + cc_features->used_textures[1];
|
||||||
|
uint32_t num_texinfo = texclamp[0] + texclamp[1];
|
||||||
|
|
||||||
|
uint32_t texinfo_offset = ROUNDUP(main_alu1_offset + main_alu1_cnt, 16);
|
||||||
|
uint32_t cur_tex_offset = texinfo_offset;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (cc_features->used_textures[i] && texclamp[i]) {
|
||||||
|
uint8_t dst_reg = get_reg(cc_features, (i == 0) ? SHADER_TEXINFO0 : SHADER_TEXINFO1);
|
||||||
|
|
||||||
|
uint64_t texinfo_buf[] = {
|
||||||
|
TEX_GET_TEXTURE_INFO(dst_reg, _x, _y, _m, _m, _R1, _0, _0, _0, _0, _t(i), _s(i))
|
||||||
|
};
|
||||||
|
|
||||||
|
memcpy(program_buf + cur_tex_offset, texinfo_buf, sizeof(texinfo_buf));
|
||||||
|
cur_tex_offset += sizeof(texinfo_buf) / sizeof(uint64_t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t texsample_offset = cur_tex_offset;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (cc_features->used_textures[i]) {
|
||||||
|
uint8_t texcoord_reg = (i == 0) ? _R1 : _R2;
|
||||||
|
uint8_t dst_reg = get_reg(cc_features, (i == 0) ? SHADER_TEXEL0 : SHADER_TEXEL1);
|
||||||
|
|
||||||
|
uint64_t tex_buf[] = {
|
||||||
|
TEX_SAMPLE(dst_reg, _x, _y, _z, _w, texcoord_reg, _x, _y, _0, _x, _t(i), _s(i))
|
||||||
|
};
|
||||||
|
|
||||||
|
memcpy(program_buf + cur_tex_offset, tex_buf, sizeof(tex_buf));
|
||||||
|
cur_tex_offset += sizeof(tex_buf) / sizeof(uint64_t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure we didn't overflow the buffer
|
||||||
|
const uint32_t total_program_size = cur_tex_offset * sizeof(uint64_t);
|
||||||
|
assert(total_program_size <= max_program_buf_size);
|
||||||
|
|
||||||
|
// cf
|
||||||
|
uint32_t cur_cf_offset = 0;
|
||||||
|
|
||||||
|
// if we use texclamp place those alus first
|
||||||
|
if (texclamp[0] || texclamp[1]) {
|
||||||
|
program_buf[cur_cf_offset++] = TEX(texinfo_offset, num_texinfo);
|
||||||
|
program_buf[cur_cf_offset++] = ALU(texclamp_alu_offset, texclamp_alu_cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_textures > 0) {
|
||||||
|
program_buf[cur_cf_offset++] = TEX(texsample_offset, num_textures) VALID_PIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
program_buf[cur_cf_offset++] = ALU(main_alu0_offset, main_alu0_cnt);
|
||||||
|
|
||||||
|
if (main_alu1_cnt > 0) {
|
||||||
|
program_buf[cur_cf_offset++] = ALU(main_alu1_offset, main_alu1_cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc_features->opt_alpha) {
|
||||||
|
program_buf[cur_cf_offset++] = EXP_DONE(PIX0, TEXEL_REG, _x, _y, _z, _w) END_OF_PROGRAM;
|
||||||
|
} else {
|
||||||
|
program_buf[cur_cf_offset++] = EXP_DONE(PIX0, TEXEL_REG, _x, _y, _z, _1) END_OF_PROGRAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
// regs
|
||||||
|
const uint32_t num_ps_inputs = 4 + cc_features->num_inputs;
|
||||||
|
|
||||||
|
psh->regs.sq_pgm_resources_ps = get_num_regs(cc_features); // num_gprs
|
||||||
|
psh->regs.sq_pgm_exports_ps = 2; // export_mode
|
||||||
|
psh->regs.spi_ps_in_control_0 = (num_ps_inputs + 1) // num_interp
|
||||||
|
| (1 << 8) // position_ena
|
||||||
|
| (1 << 26) // persp_gradient_ena
|
||||||
|
| (1 << 28); // baryc_sample_cntl
|
||||||
|
|
||||||
|
psh->regs.num_spi_ps_input_cntl = num_ps_inputs + 1;
|
||||||
|
|
||||||
|
// frag pos
|
||||||
|
psh->regs.spi_ps_input_cntls[0] = 0 | (1 << 8);
|
||||||
|
|
||||||
|
// inputs
|
||||||
|
for (int i = 0; i < num_ps_inputs; i++) {
|
||||||
|
psh->regs.spi_ps_input_cntls[i + 1] = i | (1 << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
psh->regs.cb_shader_mask = 0xf; // output0_enable
|
||||||
|
psh->regs.cb_shader_control = 1; // rt0_enable
|
||||||
|
psh->regs.db_shader_control = (1 << 4) // z_order
|
||||||
|
| (1 << 6); // kill_enable
|
||||||
|
|
||||||
|
// program
|
||||||
|
psh->size = total_program_size;
|
||||||
|
psh->program = program_buf;
|
||||||
|
|
||||||
|
psh->mode = GX2_SHADER_MODE_UNIFORM_REGISTER;
|
||||||
|
|
||||||
|
// uniform vars
|
||||||
|
psh->uniformVars = uniformVars;
|
||||||
|
psh->uniformVarCount = sizeof(uniformVars) / sizeof(GX2UniformVar);
|
||||||
|
|
||||||
|
// samplers
|
||||||
|
psh->samplerVars = samplerVars;
|
||||||
|
psh->samplerVarCount = sizeof(samplerVars) / sizeof(GX2SamplerVar);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GX2AttribVar attribVars[] = {
|
||||||
|
{ "aVtxPos", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 0 },
|
||||||
|
{ "aTexCoord0", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 1 },
|
||||||
|
{ "aTexCoord1", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 2 },
|
||||||
|
{ "aFog", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 3 },
|
||||||
|
{ "aGrayscaleColor", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 4 },
|
||||||
|
{ "aInput1", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 5 },
|
||||||
|
{ "aInput2", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 6 },
|
||||||
|
{ "aInput3", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 7 },
|
||||||
|
{ "aInput4", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 8 },
|
||||||
|
{ "aInput5", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 9 },
|
||||||
|
{ "aInput6", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 10 },
|
||||||
|
{ "aInput7", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 11 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int generateVertexShader(GX2VertexShader *vsh, struct CCFeatures *cc_features) {
|
||||||
|
static const size_t max_program_buf_size = 16 * sizeof(uint64_t);
|
||||||
|
uint64_t *program_buf = memalign(GX2_SHADER_PROGRAM_ALIGNMENT, max_program_buf_size);
|
||||||
|
if (!program_buf) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t num_ps_inputs = 4 + cc_features->num_inputs;
|
||||||
|
|
||||||
|
uint64_t *cur_buf = program_buf;
|
||||||
|
|
||||||
|
// aVtxPos
|
||||||
|
ADD_INSTR(
|
||||||
|
CALL_FS NO_BARRIER,
|
||||||
|
EXP_DONE(POS0, _R1, _x, _y, _z, _w),
|
||||||
|
);
|
||||||
|
|
||||||
|
// params
|
||||||
|
for (int i = 0; i < num_ps_inputs - 1; i++) {
|
||||||
|
ADD_INSTR(
|
||||||
|
EXP(PARAM(i), _R(i + 2), _x, _y, _z, _w) NO_BARRIER,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// last param
|
||||||
|
ADD_INSTR(
|
||||||
|
(EXP_DONE(PARAM(num_ps_inputs - 1), _R(num_ps_inputs + 1), _x, _y, _z, _w) NO_BARRIER)
|
||||||
|
END_OF_PROGRAM,
|
||||||
|
);
|
||||||
|
|
||||||
|
const uint32_t program_size = (uintptr_t) cur_buf - ((uintptr_t) program_buf);
|
||||||
|
assert(program_size <= max_program_buf_size);
|
||||||
|
|
||||||
|
// regs
|
||||||
|
vsh->regs.sq_pgm_resources_vs = (num_ps_inputs + 2) // num_gprs
|
||||||
|
| (1 << 8); // stack_size
|
||||||
|
|
||||||
|
// num outputs minus 1
|
||||||
|
vsh->regs.spi_vs_out_config = ((num_ps_inputs - 1) << 1);
|
||||||
|
|
||||||
|
vsh->regs.num_spi_vs_out_id = 3;
|
||||||
|
memset(vsh->regs.spi_vs_out_id, 0xff, sizeof(vsh->regs.spi_vs_out_id));
|
||||||
|
vsh->regs.spi_vs_out_id[0] = (0) | (1 << 8) | (2 << 16) | (3 << 24);
|
||||||
|
vsh->regs.spi_vs_out_id[1] = (4) | (5 << 8) | (6 << 16) | (7 << 24);
|
||||||
|
vsh->regs.spi_vs_out_id[2] = (8) | (9 << 8) | (10 << 16) | (0xff << 24);
|
||||||
|
|
||||||
|
vsh->regs.sq_vtx_semantic_clear = ~((1 << 12) - 1);
|
||||||
|
vsh->regs.num_sq_vtx_semantic = 12;
|
||||||
|
memset(vsh->regs.sq_vtx_semantic, 0xff, sizeof(vsh->regs.sq_vtx_semantic));
|
||||||
|
// aVtxPos
|
||||||
|
vsh->regs.sq_vtx_semantic[0] = 0;
|
||||||
|
// aTexCoord0
|
||||||
|
vsh->regs.sq_vtx_semantic[1] = 1;
|
||||||
|
// aTexCoord1
|
||||||
|
vsh->regs.sq_vtx_semantic[2] = 2;
|
||||||
|
// aFog
|
||||||
|
vsh->regs.sq_vtx_semantic[3] = 3;
|
||||||
|
// aGrayscaleColor
|
||||||
|
vsh->regs.sq_vtx_semantic[4] = 4;
|
||||||
|
// aInput1
|
||||||
|
vsh->regs.sq_vtx_semantic[5] = 5;
|
||||||
|
// aInput2
|
||||||
|
vsh->regs.sq_vtx_semantic[6] = 6;
|
||||||
|
// aInput3
|
||||||
|
vsh->regs.sq_vtx_semantic[7] = 7;
|
||||||
|
// aInput4
|
||||||
|
vsh->regs.sq_vtx_semantic[8] = 8;
|
||||||
|
// aInput5
|
||||||
|
vsh->regs.sq_vtx_semantic[9] = 9;
|
||||||
|
// aInput6
|
||||||
|
vsh->regs.sq_vtx_semantic[10] = 10;
|
||||||
|
// aInput7
|
||||||
|
vsh->regs.sq_vtx_semantic[11] = 11;
|
||||||
|
|
||||||
|
vsh->regs.vgt_vertex_reuse_block_cntl = 14; // vtx_reuse_depth
|
||||||
|
vsh->regs.vgt_hos_reuse_depth = 16; // reuse_depth
|
||||||
|
|
||||||
|
// program
|
||||||
|
vsh->program = program_buf;
|
||||||
|
vsh->size = program_size;
|
||||||
|
|
||||||
|
vsh->mode = GX2_SHADER_MODE_UNIFORM_REGISTER;
|
||||||
|
|
||||||
|
// attribs
|
||||||
|
vsh->attribVarCount = sizeof(attribVars) / sizeof(GX2AttribVar);
|
||||||
|
vsh->attribVars = attribVars;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#undef ADD_INSTR
|
||||||
|
|
||||||
|
int gx2GenerateShaderGroup(struct ShaderGroup *group, struct CCFeatures *cc_features) {
|
||||||
|
memset(group, 0, sizeof(struct ShaderGroup));
|
||||||
|
|
||||||
|
// generate the pixel shader
|
||||||
|
if (generatePixelShader(&group->pixelShader, cc_features) != 0) {
|
||||||
|
gx2FreeShaderGroup(group);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate the vertex shader
|
||||||
|
if (generateVertexShader(&group->vertexShader, cc_features) != 0) {
|
||||||
|
gx2FreeShaderGroup(group);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t attribOffset = 0;
|
||||||
|
|
||||||
|
// aVtxPos
|
||||||
|
group->attributes[group->numAttributes++] =
|
||||||
|
(GX2AttribStream) { 0, 0, attribOffset, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32, GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT };
|
||||||
|
attribOffset += 4 * sizeof(float);
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (cc_features->used_textures[i]) {
|
||||||
|
// aTexCoordX
|
||||||
|
group->attributes[group->numAttributes++] =
|
||||||
|
(GX2AttribStream) { 1 + i, 0, attribOffset, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32, GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT };
|
||||||
|
attribOffset += 4 * sizeof(float);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// aFog
|
||||||
|
if (cc_features->opt_fog) {
|
||||||
|
group->attributes[group->numAttributes++] =
|
||||||
|
(GX2AttribStream) { 3, 0, attribOffset, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32, GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT };
|
||||||
|
attribOffset += 4 * sizeof(float);
|
||||||
|
}
|
||||||
|
|
||||||
|
// aGrayscaleColor
|
||||||
|
if (cc_features->opt_grayscale) {
|
||||||
|
group->attributes[group->numAttributes++] =
|
||||||
|
(GX2AttribStream) { 4, 0, attribOffset, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32, GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT };
|
||||||
|
attribOffset += 4 * sizeof(float);
|
||||||
|
}
|
||||||
|
|
||||||
|
// aInput
|
||||||
|
for (int i = 0; i < cc_features->num_inputs; i++) {
|
||||||
|
group->attributes[group->numAttributes++] =
|
||||||
|
(GX2AttribStream) { 5 + i, 0, attribOffset, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32, GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT };
|
||||||
|
attribOffset += 4 * sizeof(float);
|
||||||
|
}
|
||||||
|
|
||||||
|
group->stride = attribOffset;
|
||||||
|
|
||||||
|
// init the fetch shader
|
||||||
|
group->fetchShader.size = GX2CalcFetchShaderSizeEx(group->numAttributes, GX2_FETCH_SHADER_TESSELLATION_NONE, GX2_TESSELLATION_MODE_DISCRETE);
|
||||||
|
group->fetchShader.program = memalign(GX2_SHADER_PROGRAM_ALIGNMENT, group->fetchShader.size);
|
||||||
|
if (!group->fetchShader.program) {
|
||||||
|
gx2FreeShaderGroup(group);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
GX2InitFetchShaderEx(&group->fetchShader, group->fetchShader.program, group->numAttributes, group->attributes, GX2_FETCH_SHADER_TESSELLATION_NONE, GX2_TESSELLATION_MODE_DISCRETE);
|
||||||
|
|
||||||
|
// invalidate all programs
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, group->vertexShader.program, group->vertexShader.size);
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, group->pixelShader.program, group->pixelShader.size);
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, group->fetchShader.program, group->fetchShader.size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gx2FreeShaderGroup(struct ShaderGroup *group) {
|
||||||
|
free(group->vertexShader.program);
|
||||||
|
free(group->pixelShader.program);
|
||||||
|
free(group->fetchShader.program);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
27
libultraship/libultraship/Lib/Fast3D/gx2_shader_gen.h
Normal file
27
libultraship/libultraship/Lib/Fast3D/gx2_shader_gen.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "gfx_cc.h"
|
||||||
|
#include <gx2/shaders.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct ShaderGroup {
|
||||||
|
GX2VertexShader vertexShader;
|
||||||
|
GX2PixelShader pixelShader;
|
||||||
|
GX2FetchShader fetchShader;
|
||||||
|
|
||||||
|
uint32_t stride;
|
||||||
|
|
||||||
|
uint32_t numAttributes;
|
||||||
|
GX2AttribStream attributes[13];
|
||||||
|
};
|
||||||
|
|
||||||
|
int gx2GenerateShaderGroup(struct ShaderGroup *group, struct CCFeatures *cc_features);
|
||||||
|
|
||||||
|
void gx2FreeShaderGroup(struct ShaderGroup *group);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
624
libultraship/libultraship/Lib/Fast3D/gx2_shader_inl.h
Normal file
624
libultraship/libultraship/Lib/Fast3D/gx2_shader_inl.h
Normal file
@ -0,0 +1,624 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014-2016 - Ali Bouhlel
|
||||||
|
* Copyright (C) 2022 - GaryOderNichts
|
||||||
|
*
|
||||||
|
* Licensed as MIT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GX2_SHADER_INL_H
|
||||||
|
#define GX2_SHADER_INL_H
|
||||||
|
|
||||||
|
#define to_QWORD(w0, w1) (((uint64_t)(w0) << 32ull) | (w1))
|
||||||
|
#define to_LE(x) (__builtin_bswap32(x))
|
||||||
|
|
||||||
|
/* CF */
|
||||||
|
#define CF_DWORD0(addr) to_LE(addr)
|
||||||
|
|
||||||
|
#define CF_DWORD1(popCount, cfConst, cond, count, callCount, inst) \
|
||||||
|
to_LE(popCount | (cfConst << 3) | (cond << 8) | (count << 10) | (callCount << 13) | (inst << 23) | (1 << 31))
|
||||||
|
|
||||||
|
#define CF_ALU_WORD0(addr, kcacheBank0, kcacheBank1, kcacheMode0) \
|
||||||
|
to_LE(addr | (kcacheBank0 << 22) | (kcacheBank1 << 26) | (kcacheMode0 << 30))
|
||||||
|
#define CF_ALU_WORD1(kcacheMode1, kcacheAddr0, kcacheAddr1, count, altConst, inst) \
|
||||||
|
to_LE(kcacheMode1 | (kcacheAddr0 << 2) | (kcacheAddr1 << 10) | (count << 18) | (altConst << 25) | (inst << 26) | (1 << 31))
|
||||||
|
|
||||||
|
#define CF_EXP_WORD0(dstReg_and_type, srcReg, srcRel, indexGpr, elemSize)\
|
||||||
|
to_LE(dstReg_and_type | (srcReg << 15) | (srcRel << 22) | (indexGpr << 23) | (elemSize << 30))
|
||||||
|
|
||||||
|
#define CF_EXP_WORD1(srcSelX, srcSelY, srcSelZ, srcSelW, validPixelMode, inst) \
|
||||||
|
to_LE(srcSelX | (srcSelY << 3) | (srcSelZ << 6) | (srcSelW << 9) | (validPixelMode << 22) | (inst << 23) | (1 << 31))
|
||||||
|
|
||||||
|
#define CF_ALLOC_EXPORT_WORD0(arrayBase, type, dstReg, dstRel, indexGpr, elemSize) \
|
||||||
|
to_LE(arrayBase | (type << 13) | (dstReg << 15) | (dstRel << 22) | (indexGpr << 23) | (elemSize << 30))
|
||||||
|
|
||||||
|
#define CF_ALLOC_EXPORT_WORD1_BUF(arraySize, writeMask, inst) \
|
||||||
|
to_LE(arraySize | (writeMask << 12) | (inst << 23) | (1 << 31))
|
||||||
|
|
||||||
|
#define ALU_SRC_KCACHE0_BASE 0x80
|
||||||
|
#define ALU_SRC_KCACHE1_BASE 0xA0
|
||||||
|
#define CF_KCACHE_BANK_LOCK_1 0x1
|
||||||
|
#define CB1 0x1
|
||||||
|
#define CB2 0x2
|
||||||
|
#define _0_15 CF_KCACHE_BANK_LOCK_1
|
||||||
|
|
||||||
|
#define KC0(x) (x + ALU_SRC_KCACHE0_BASE)
|
||||||
|
#define KC1(x) (x + ALU_SRC_KCACHE1_BASE)
|
||||||
|
|
||||||
|
#define NO_BARRIER & (~to_QWORD(0,to_LE(1 << 31)))
|
||||||
|
#define END_OF_PROGRAM | to_QWORD(0,to_LE(1 << 21))
|
||||||
|
#define VALID_PIX | to_QWORD(0,to_LE(1 << 22))
|
||||||
|
#define WHOLE_QUAD_MODE | to_QWORD(0,to_LE(1 << 30))
|
||||||
|
#define BURSTCNT(x) | to_QWORD(0,to_LE(x << 17))
|
||||||
|
#define WRITE(x) (x >> 2)
|
||||||
|
#define ARRAY_SIZE(x) x
|
||||||
|
#define ELEM_SIZE(x) x
|
||||||
|
#define KCACHE0(bank, mode) | to_QWORD(CF_ALU_WORD0(0, bank, 0, mode), 0)
|
||||||
|
#define KCACHE1(bank, mode) | to_QWORD(CF_ALU_WORD0(0, 0, bank, 0), CF_ALU_WORD1(mode,0, 0, 0, 0, 0))
|
||||||
|
|
||||||
|
#define DEACTIVATE 1
|
||||||
|
#define UPDATE_EXEC_MASK(mode) | to_QWORD(0, to_LE(mode << 2))
|
||||||
|
#define UPDATE_PRED | to_QWORD(0, to_LE(1ull << 3))
|
||||||
|
#define CLAMP | to_QWORD(0, to_LE(1ull << 31))
|
||||||
|
#define ALU_LAST | to_QWORD(to_LE(1ull << 31), 0)
|
||||||
|
|
||||||
|
/* ALU */
|
||||||
|
|
||||||
|
#define ALU_WORD0(src0Sel, src0Rel, src0Chan, src0Neg, src1Sel, src1Rel, src1Chan, src1Neg, indexMode, predSel) \
|
||||||
|
to_LE(src0Sel | ((src0Rel) << 9) | ((src0Chan) << 10) | ((src0Neg) << 12) | ((src1Sel) << 13) | ((src1Rel) << 22) \
|
||||||
|
| ((src1Chan) << 23) | ((src1Neg) << 25) | ((indexMode) << 26) | ((predSel) << 29))
|
||||||
|
|
||||||
|
#define ALU_WORD1_OP2(src0Abs, src1Abs, updateExecuteMask, updatePred, writeMask, omod, inst, encoding, bankSwizzle, dstGpr, dstRel, dstChan, clamp) \
|
||||||
|
to_LE(src0Abs | (src1Abs << 1) | (updateExecuteMask << 2) | (updatePred << 3) | (writeMask << 4) | (omod << 5) | (inst << 7) | \
|
||||||
|
(encoding << 15) | (bankSwizzle << 18) | ((dstGpr&0x7F) << 21) | (dstRel << 28) | ((dstChan&0x3) << 29) | (clamp << 31))
|
||||||
|
|
||||||
|
#define ALU_WORD1_OP3(src2Sel, src2Rel, src2Chan, src2Neg, inst, bankSwizzle, dstGpr, dstRel, dstChan, clamp) \
|
||||||
|
to_LE(src2Sel | (src2Rel << 9) | (src2Chan << 10) | (src2Neg << 12) | (inst << 13) | \
|
||||||
|
(bankSwizzle << 18) | ((dstGpr&0x7F) << 21) | (dstRel << 28) | ((dstChan&0x3) << 29) | (clamp << 31))
|
||||||
|
|
||||||
|
/* TEX */
|
||||||
|
#define TEX_WORD0(inst, bcFracMode, fetchWholeQuad, resourceID, srcReg, srcRel, altConst) \
|
||||||
|
to_LE(inst | (bcFracMode << 5) | (fetchWholeQuad << 7) | (resourceID << 8) | (srcReg << 16) | (srcRel << 23) | (altConst << 24))
|
||||||
|
|
||||||
|
#define TEX_WORD1(dstReg, dstRel, dstSelX, dstSelY, dstSelZ, dstSelW, lodBias, coordTypeX, coordTypeY, coordTypeZ, coordTypeW) \
|
||||||
|
to_LE(dstReg | (dstRel << 7) | (dstSelX << 9) | (dstSelY << 12) | (dstSelZ << 15) | (dstSelW << 18) | \
|
||||||
|
(lodBias << 21) | (coordTypeX << 28) | (coordTypeY << 29) | (coordTypeZ << 30) | (coordTypeW << 31))
|
||||||
|
|
||||||
|
#define TEX_WORD2(offsetX, offsetY, offsetZ, samplerID, srcSelX, srcSelY, srcSelZ, srcSelW) \
|
||||||
|
to_LE(offsetX | (offsetY << 5) | (offsetZ << 10) | (samplerID << 15) | (srcSelX << 20) | (srcSelY << 23) | (srcSelZ << 26) | (srcSelW << 29))
|
||||||
|
|
||||||
|
#define VTX_WORD0(inst, type, buffer_id, srcReg, srcSelX, mega) \
|
||||||
|
to_LE(inst | (type << 5) | (buffer_id << 8) | (srcReg << 16) | (srcSelX << 24) | (mega << 26))
|
||||||
|
|
||||||
|
#define VTX_WORD1(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW) \
|
||||||
|
to_LE(dstReg | (dstSelX << 9) | (dstSelY << 12) | (dstSelZ << 15) | (dstSelW << 18) | (1 << 21))
|
||||||
|
|
||||||
|
#define VTX_WORD2(offset, ismega) \
|
||||||
|
to_LE(offset| (ismega << 19))
|
||||||
|
|
||||||
|
#define _x 0
|
||||||
|
#define _y 1
|
||||||
|
#define _z 2
|
||||||
|
#define _w 3
|
||||||
|
#define _0 4
|
||||||
|
#define _1 5
|
||||||
|
#define _m 7 /*mask*/
|
||||||
|
|
||||||
|
#define _xyzw 0b1111
|
||||||
|
#define _xy__ 0b0011
|
||||||
|
|
||||||
|
#define GX2_COMP_SEL(c0, c1, c2, c3) (((c0) << 24) | ((c1) << 16) | ((c2) << 8) | (c3))
|
||||||
|
|
||||||
|
#define ALU_LITERAL(v) to_QWORD(to_LE(v), 0)
|
||||||
|
#define ALU_LITERAL2(v0,v1) to_QWORD(to_LE(v0), to_LE(v1))
|
||||||
|
#define ALU_LITERAL3(v0,v1,v2) ALU_LITERAL2(v0,v1),ALU_LITERAL(v2)
|
||||||
|
#define ALU_LITERAL4(v0,v1,v2,v3) ALU_LITERAL2(v0,v1),ALU_LITERAL2(v2,v3)
|
||||||
|
#define ALU_LITERAL5(v0,v1,v2,v3,v5) ALU_LITERAL4(v0,v1,v2,v3),ALU_LITERAL(v4)
|
||||||
|
|
||||||
|
/* SRCx_SEL special constants */
|
||||||
|
#define ALU_SRC_1_DBL_L 0xF4
|
||||||
|
#define ALU_SRC_1_DBL_M 0xF5
|
||||||
|
#define ALU_SRC_0_5_DBL_L 0xF6
|
||||||
|
#define ALU_SRC_0_5_DBL_M 0xF7
|
||||||
|
#define ALU_SRC_0 0xF8
|
||||||
|
#define ALU_SRC_1 0xF9
|
||||||
|
#define ALU_SRC_1_INT 0xFA
|
||||||
|
#define ALU_SRC_M_1_INT 0xFB
|
||||||
|
#define ALU_SRC_0_5 0xFC
|
||||||
|
#define ALU_SRC_LITERAL 0xFD
|
||||||
|
#define ALU_SRC_PV 0xFE
|
||||||
|
#define ALU_SRC_PS 0xFF
|
||||||
|
|
||||||
|
#define _NEG | (1 << 12)
|
||||||
|
#define _ABS | (1 << 13)
|
||||||
|
|
||||||
|
#define ALU_OMOD_OFF 0x0
|
||||||
|
#define ALU_OMOD_M2 0x1
|
||||||
|
#define ALU_OMOD_M4 0x2
|
||||||
|
#define ALU_OMOD_D2 0x3
|
||||||
|
|
||||||
|
#define ALU_VEC_012 0x0
|
||||||
|
#define ALU_VEC_021 0x1
|
||||||
|
#define ALU_VEC_120 0x2
|
||||||
|
#define ALU_VEC_102 0x3
|
||||||
|
#define ALU_VEC_201 0x4
|
||||||
|
#define ALU_VEC_210 0x5
|
||||||
|
#define VEC_012 | to_QWORD(0, to_LE(ALU_VEC_012 << 18))
|
||||||
|
#define VEC_021 | to_QWORD(0, to_LE(ALU_VEC_021 << 18))
|
||||||
|
#define VEC_120 | to_QWORD(0, to_LE(ALU_VEC_120 << 18))
|
||||||
|
#define VEC_102 | to_QWORD(0, to_LE(ALU_VEC_102 << 18))
|
||||||
|
#define VEC_201 | to_QWORD(0, to_LE(ALU_VEC_201 << 18))
|
||||||
|
#define VEC_210 | to_QWORD(0, to_LE(ALU_VEC_210 << 18))
|
||||||
|
|
||||||
|
#define VALID_PIX | to_QWORD(0,to_LE(1 << 22))
|
||||||
|
|
||||||
|
#define ALU_SCL_210 0x0
|
||||||
|
#define ALU_SCL_122 0x1
|
||||||
|
#define ALU_SCL_212 0x2
|
||||||
|
#define ALU_SCL_221 0x3
|
||||||
|
|
||||||
|
#define SCL_210 | to_QWORD(0, to_LE(ALU_SCL_210 << 18))
|
||||||
|
#define SCL_122 | to_QWORD(0, to_LE(ALU_SCL_122 << 18))
|
||||||
|
#define SCL_212 | to_QWORD(0, to_LE(ALU_SCL_212 << 18))
|
||||||
|
#define SCL_221 | to_QWORD(0, to_LE(ALU_SCL_221 << 18))
|
||||||
|
|
||||||
|
#define FETCH_TYPE(x) x
|
||||||
|
#define MINI(x) ((x) - 1)
|
||||||
|
#define MEGA(x) (MINI(x) | 0x80000000)
|
||||||
|
#define OFFSET(x) x
|
||||||
|
|
||||||
|
#define VERTEX_DATA 0
|
||||||
|
#define INSTANCE_DATA 1
|
||||||
|
#define NO_INDEX_OFFSET 2
|
||||||
|
|
||||||
|
/* CF defines */
|
||||||
|
#define CF_COND_ACTIVE 0x0
|
||||||
|
#define CF_COND_FALSE 0x1
|
||||||
|
#define CF_COND_BOOL 0x2
|
||||||
|
#define CF_COND_NOT_BOOL 0x3
|
||||||
|
|
||||||
|
/* TEX defines */
|
||||||
|
#define TEX_UNNORMALIZED 0x0
|
||||||
|
#define TEX_NORMALIZED 0x1
|
||||||
|
|
||||||
|
/* instructions */
|
||||||
|
/* CF */
|
||||||
|
#define CF_INST_TEX 0x01
|
||||||
|
#define CF_INST_VTX 0x02
|
||||||
|
#define CF_INST_LOOP_END 0x05
|
||||||
|
#define CF_INST_LOOP_START_DX10 0x06
|
||||||
|
#define CF_INST_JUMP 0x0A
|
||||||
|
#define CF_INST_ELSE 0x0D
|
||||||
|
#define CF_INST_POP 0x0E
|
||||||
|
#define CF_INST_CALL_FS 0x13
|
||||||
|
#define CF_INST_EMIT_VERTEX 0x15
|
||||||
|
#define CF_INST_MEM_RING 0x26
|
||||||
|
|
||||||
|
#define CF_INST_ALU 0x08
|
||||||
|
#define CF_INST_ALU_PUSH_BEFORE 0x09
|
||||||
|
#define CF_INST_ALU_POP_AFTER 0x0A
|
||||||
|
#define CF_INST_ALU_POP2_AFTER 0x0B
|
||||||
|
#define CF_INST_ALU_BREAK 0x0E
|
||||||
|
#define CF_INST_ALU_ELSE_AFTER 0x0F
|
||||||
|
/* ALU */
|
||||||
|
#define OP2_INST_ADD 0x0
|
||||||
|
#define OP2_INST_MUL 0x1
|
||||||
|
#define OP2_INST_MUL_IEEE 0x2
|
||||||
|
#define OP2_INST_MIN 0x04
|
||||||
|
#define OP2_INST_MAX 0x03
|
||||||
|
#define OP2_INST_MAX_DX10 0x05
|
||||||
|
#define OP2_INST_FRACT 0x10
|
||||||
|
#define OP2_INST_SETGT 0x09
|
||||||
|
#define OP2_INST_SETE_DX10 0x0C
|
||||||
|
#define OP2_INST_SETGT_DX10 0x0D
|
||||||
|
#define OP2_INST_SETGE_DX10 0x0E
|
||||||
|
#define OP2_INST_FLOOR 0x14
|
||||||
|
#define OP2_INST_MOVA_INT 0x18
|
||||||
|
#define OP2_INST_MOV 0x19
|
||||||
|
#define OP2_INST_NOP 0x1A
|
||||||
|
#define OP2_INST_PRED_SETGT 0x21
|
||||||
|
#define OP2_INST_KILLGT 0x2D
|
||||||
|
#define OP2_INST_AND_INT 0x30
|
||||||
|
#define OP2_INST_OR_INT 0x31
|
||||||
|
#define OP2_INST_NOT_INT 0x33
|
||||||
|
#define OP2_INST_ADD_INT 0x34
|
||||||
|
#define OP2_INST_SETE_INT 0x3A
|
||||||
|
#define OP2_INST_SETGT_INT 0x3B
|
||||||
|
#define OP2_INST_SETGE_INT 0x3C
|
||||||
|
#define OP2_INST_SETNE_INT 0x3D
|
||||||
|
#define OP2_INST_PRED_SETE_INT 0x42
|
||||||
|
#define OP2_INST_PRED_SETGT_INT 0x43
|
||||||
|
#define OP2_INST_PRED_SETGE_INT 0x44
|
||||||
|
#define OP2_INST_PRED_SETNE_INT 0x45
|
||||||
|
#define OP2_INST_KILLE_INT 0x46
|
||||||
|
#define OP2_INST_KILLGT_INT 0x47
|
||||||
|
#define OP2_INST_KILLGE_INT 0x48
|
||||||
|
#define OP2_INST_KILLNE_INT 0x49
|
||||||
|
#define OP2_INST_DOT4 0x50
|
||||||
|
#define OP2_INST_DOT4_IEEE 0x51
|
||||||
|
#define OP2_INST_EXP_IEEE 0x61
|
||||||
|
#define OP2_INST_LOG_CLAMPED 0x62
|
||||||
|
#define OP2_INST_RECIP_IEEE 0x66
|
||||||
|
#define OP2_INST_RECIPSQRT_IEEE 0x69
|
||||||
|
#define OP2_INST_SQRT_IEEE 0x6A
|
||||||
|
#define OP2_INST_FLT_TO_INT 0x6B
|
||||||
|
#define OP2_INST_INT_TO_FLT 0x6C
|
||||||
|
#define OP2_INST_SIN 0x6E
|
||||||
|
#define OP2_INST_COS 0x6F
|
||||||
|
#define OP2_INST_LSHR_INT 0x71
|
||||||
|
#define OP2_INST_MULLO_INT 0x73
|
||||||
|
#define OP2_INST_LSHL_INT 0x72
|
||||||
|
#define OP2_INST_FLT_TO_UINT 0x79
|
||||||
|
|
||||||
|
#define OP3_INST_MULADD 0x10
|
||||||
|
#define OP3_INST_MULADD_D2 0x13
|
||||||
|
#define OP3_INST_CNDGT 0x19
|
||||||
|
#define OP3_INST_CNDE_INT 0x1C
|
||||||
|
/* EXP */
|
||||||
|
#define CF_INST_EXP 0x27
|
||||||
|
#define CF_INST_EXP_DONE 0x28
|
||||||
|
|
||||||
|
/* TEX */
|
||||||
|
#define TEX_INST_LD 0x3
|
||||||
|
#define TEX_INST_GET_TEXTURE_INFO 0x4
|
||||||
|
#define TEX_INST_GET_GRADIENTS_H 0x07
|
||||||
|
#define TEX_INST_GET_GRADIENTS_V 0x08
|
||||||
|
#define TEX_INST_SAMPLE 0x10
|
||||||
|
/* VTX */
|
||||||
|
#define VTX_INST_FETCH 0x0
|
||||||
|
|
||||||
|
/* EXPORT_TYPE */
|
||||||
|
#define EXPORT_TYPE_PIXEL 0x0
|
||||||
|
#define EXPORT_TYPE_POS 0x1
|
||||||
|
#define EXPORT_TYPE_PARAM 0x2
|
||||||
|
|
||||||
|
#define EXPORT_ARRAY_BASE_POS(id) (0x3C + id) /* [0, 3] */
|
||||||
|
#define EXPORT_ARRAY_BASE_PARAM(id) id /* [0, 31] */
|
||||||
|
#define EXPORT_ARRAY_BASE_PIX(id) id
|
||||||
|
|
||||||
|
/* exports */
|
||||||
|
#define POS(id) EXPORT_ARRAY_BASE_POS(id) | (EXPORT_TYPE_POS << 13)
|
||||||
|
#define PARAM(id) EXPORT_ARRAY_BASE_PARAM(id) | (EXPORT_TYPE_PARAM << 13)
|
||||||
|
#define PIX(id) EXPORT_ARRAY_BASE_PIX(id) | (EXPORT_TYPE_PIXEL << 13)
|
||||||
|
#define POS0 POS(0)
|
||||||
|
#define PARAM0 PARAM(0)
|
||||||
|
#define PARAM1 PARAM(1)
|
||||||
|
#define PARAM2 PARAM(2)
|
||||||
|
#define PARAM3 PARAM(3)
|
||||||
|
#define PARAM4 PARAM(4)
|
||||||
|
#define PARAM5 PARAM(5)
|
||||||
|
#define PARAM6 PARAM(6)
|
||||||
|
#define PARAM7 PARAM(7)
|
||||||
|
#define PARAM8 PARAM(8)
|
||||||
|
#define PARAM9 PARAM(9)
|
||||||
|
#define PARAM10 PARAM(10)
|
||||||
|
#define PARAM11 PARAM(11)
|
||||||
|
#define PIX0 PIX(0)
|
||||||
|
|
||||||
|
/* registers */
|
||||||
|
#define __ (0x80) /* invalid regitser (write mask off) */
|
||||||
|
#define _R(x) x
|
||||||
|
#define _R0 _R(0x0)
|
||||||
|
#define _R1 _R(0x1)
|
||||||
|
#define _R2 _R(0x2)
|
||||||
|
#define _R3 _R(0x3)
|
||||||
|
#define _R4 _R(0x4)
|
||||||
|
#define _R5 _R(0x5)
|
||||||
|
#define _R6 _R(0x6)
|
||||||
|
#define _R7 _R(0x7)
|
||||||
|
#define _R8 _R(0x8)
|
||||||
|
#define _R9 _R(0x9)
|
||||||
|
#define _R10 _R(0xA)
|
||||||
|
#define _R11 _R(0xB)
|
||||||
|
#define _R12 _R(0xC)
|
||||||
|
#define _R13 _R(0xD)
|
||||||
|
#define _R14 _R(0xE)
|
||||||
|
#define _R15 _R(0xF)
|
||||||
|
#define _R16 _R(0x10)
|
||||||
|
#define _R17 _R(0x11)
|
||||||
|
#define _R18 _R(0x12)
|
||||||
|
#define _R19 _R(0x13)
|
||||||
|
#define _R20 _R(0x14)
|
||||||
|
#define _R21 _R(0x15)
|
||||||
|
#define _R22 _R(0x16)
|
||||||
|
#define _R23 _R(0x17)
|
||||||
|
#define _R24 _R(0x18)
|
||||||
|
#define _R25 _R(0x19)
|
||||||
|
#define _R26 _R(0x1A)
|
||||||
|
#define _R27 _R(0x1B)
|
||||||
|
#define _R28 _R(0x1C)
|
||||||
|
#define _R29 _R(0x1D)
|
||||||
|
#define _R30 _R(0x1E)
|
||||||
|
#define _R31 _R(0x1F)
|
||||||
|
|
||||||
|
#define _R120 _R(0x78)
|
||||||
|
#define _R121 _R(0x79)
|
||||||
|
#define _R122 _R(0x7A)
|
||||||
|
#define _R123 _R(0x7B)
|
||||||
|
#define _R124 _R(0x7C)
|
||||||
|
#define _R125 _R(0x7D)
|
||||||
|
#define _R126 _R(0x7E)
|
||||||
|
#define _R127 _R(0x7F)
|
||||||
|
|
||||||
|
/* texture */
|
||||||
|
#define _t(x) x
|
||||||
|
#define _t0 _t(0x0)
|
||||||
|
#define _t1 _t(0x1)
|
||||||
|
|
||||||
|
/* sampler */
|
||||||
|
#define _s(x) x
|
||||||
|
#define _s0 _s(0x0)
|
||||||
|
#define _s1 _s(0x1)
|
||||||
|
|
||||||
|
#define _b(x) x
|
||||||
|
|
||||||
|
/* const files */
|
||||||
|
#define ALU_SRC_CONST_FILE_BASE 0x100
|
||||||
|
#define _C(x) (ALU_SRC_CONST_FILE_BASE + (x))
|
||||||
|
|
||||||
|
#define CALL_FS to_QWORD(CF_DWORD0(0), CF_DWORD1(0,0,0,0,0,CF_INST_CALL_FS))
|
||||||
|
|
||||||
|
#define TEX(addr, cnt) to_QWORD(CF_DWORD0(addr), CF_DWORD1(0x0, 0x0, CF_COND_ACTIVE, (cnt - 1), 0x0, CF_INST_TEX))
|
||||||
|
#define VTX(addr, cnt) to_QWORD(CF_DWORD0(addr), CF_DWORD1(0x0, 0x0, CF_COND_ACTIVE, (cnt - 1), 0x0, CF_INST_VTX))
|
||||||
|
#define LOOP_END(addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(0x0, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_LOOP_END))
|
||||||
|
#define LOOP_START_DX10(addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(0x0, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_LOOP_START_DX10))
|
||||||
|
#define JUMP(popCount, addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(popCount, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_JUMP))
|
||||||
|
#define ELSE(popCount, addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(popCount, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_ELSE))
|
||||||
|
#define POP(popCount, addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(popCount, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_POP))
|
||||||
|
|
||||||
|
#define ALU(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU))
|
||||||
|
#define ALU_PUSH_BEFORE(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_PUSH_BEFORE))
|
||||||
|
#define ALU_POP_AFTER(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_POP_AFTER))
|
||||||
|
#define ALU_POP2_AFTER(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_POP2_AFTER))
|
||||||
|
#define ALU_BREAK(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_BREAK))
|
||||||
|
#define ALU_ELSE_AFTER(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_ELSE_AFTER))
|
||||||
|
|
||||||
|
#define EXP_DONE(dstReg_and_type, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW) to_QWORD(CF_EXP_WORD0(dstReg_and_type, srcReg, 0x0, 0x0, 0x0), \
|
||||||
|
CF_EXP_WORD1(srcSelX, srcSelY, srcSelZ, srcSelW, 0x0, CF_INST_EXP_DONE))
|
||||||
|
|
||||||
|
#define EXP(dstReg_and_type, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW) to_QWORD(CF_EXP_WORD0(dstReg_and_type, srcReg, 0x0, 0x0, 0x0), \
|
||||||
|
CF_EXP_WORD1(srcSelX, srcSelY, srcSelZ, srcSelW, 0x0, CF_INST_EXP))
|
||||||
|
|
||||||
|
#define MEM_RING(arrayBase, dstReg, writeMask, arraySize, elemSize) \
|
||||||
|
to_QWORD(CF_ALLOC_EXPORT_WORD0(arrayBase, 0x00, dstReg, 0x00, 0x00, elemSize), \
|
||||||
|
CF_ALLOC_EXPORT_WORD1_BUF(arraySize, writeMask, CF_INST_MEM_RING))
|
||||||
|
|
||||||
|
#define EMIT_VERTEX to_QWORD(0, CF_DWORD1(0, 0, 0, 0, 0, CF_INST_EMIT_VERTEX))
|
||||||
|
|
||||||
|
#define ALU_OP2(inst, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, omod) \
|
||||||
|
to_QWORD(ALU_WORD0(((src0Sel) & ((1 << 13) - 1)), 0x0, src0Chan, 0x0, ((src1Sel) & ((1 << 13) - 1)), 0x0, src1Chan, 0x0, 0x0, 0x0), \
|
||||||
|
ALU_WORD1_OP2(((src0Sel) >> 13), ((src1Sel) >> 13), 0x0, 0x0, (((dstGpr&__) >> 7) ^ 0x1), omod, inst, 0x0, 0x0, dstGpr, 0x0, dstChan, 0x0))
|
||||||
|
|
||||||
|
#define ALU_OP3(inst, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
|
||||||
|
to_QWORD(ALU_WORD0(src0Sel, 0x0, src0Chan, 0x0, src1Sel, 0x0, src1Chan, 0x0, 0x0, 0x0), \
|
||||||
|
ALU_WORD1_OP3(src2Sel, 0x0, src2Chan, 0x0, inst, 0x0, dstGpr, 0x0, dstChan, 0x0))
|
||||||
|
|
||||||
|
#define ALU_NOP(dstGpr, dstChan) \
|
||||||
|
ALU_OP2(OP2_INST_NOP, dstGpr, dstChan, ALU_SRC_PV, dstChan, ALU_SRC_PV, dstChan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_ADD(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_ADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_ADD_x2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_ADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M2)
|
||||||
|
|
||||||
|
#define ALU_ADD_D2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_ADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_D2)
|
||||||
|
|
||||||
|
#define ALU_MUL(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MUL, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MUL_x2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MUL, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M2)
|
||||||
|
|
||||||
|
#define ALU_MUL_x4(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MUL, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M4)
|
||||||
|
|
||||||
|
#define ALU_MUL_IEEE(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MUL_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MUL_IEEE_x2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MUL_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M2)
|
||||||
|
|
||||||
|
#define ALU_MUL_IEEE_x4(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MUL_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M4)
|
||||||
|
|
||||||
|
#define ALU_FRACT(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_FRACT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_FLOOR(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_FLOOR, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SQRT_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SQRT_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SQRT_IEEE_D2(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SQRT_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_D2)
|
||||||
|
|
||||||
|
#define ALU_MOVA_INT(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MOVA_INT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MOV(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MOV_D2(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_D2)
|
||||||
|
|
||||||
|
#define ALU_MOV_x2(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_M2)
|
||||||
|
|
||||||
|
#define ALU_MOV_x4(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_M4)
|
||||||
|
|
||||||
|
#define ALU_DOT4_IEEE(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_DOT4_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_DOT4(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_DOT4, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_PRED_SETGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_PRED_SETGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_KILLGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_KILLGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETE_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETE_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETGT_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETGT_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETGE_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETGE_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_PRED_SETE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_PRED_SETE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_PRED_SETGT_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_PRED_SETGT_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_PRED_SETGE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_PRED_SETGE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_KILLGE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_KILLGE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETGT_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETGT_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETGE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETGE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_ADD_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_ADD_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_PRED_SETNE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_PRED_SETNE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MIN(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MIN, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MAX(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MAX, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MAX_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MAX_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_LSHR_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_LSHR_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_MULLO_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_MULLO_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_LSHL_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_LSHL_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_AND_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_AND_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_KILLE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_KILLE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_KILLGT_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_KILLGT_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_KILLNE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_KILLNE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SETNE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SETNE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_OR_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
|
||||||
|
ALU_OP2(OP2_INST_OR_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_INT_TO_FLT(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_INT_TO_FLT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_FLT_TO_UINT(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_FLT_TO_UINT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_FLT_TO_INT(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_FLT_TO_INT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_EXP_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_EXP_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_LOG_CLAMPED(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_LOG_CLAMPED, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_RECIP_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_RECIP_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_RECIPSQRT_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_RECIPSQRT_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_SIN(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_SIN, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_COS(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_COS, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
#define ALU_COS_D2(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_COS, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_D2)
|
||||||
|
|
||||||
|
#define ALU_NOT_INT(dstGpr, dstChan, src0Sel, src0Chan) \
|
||||||
|
ALU_OP2(OP2_INST_NOT_INT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
|
||||||
|
|
||||||
|
|
||||||
|
#define ALU_MULADD(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
|
||||||
|
ALU_OP3(OP3_INST_MULADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
|
||||||
|
|
||||||
|
#define ALU_MULADD_D2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
|
||||||
|
ALU_OP3(OP3_INST_MULADD_D2, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
|
||||||
|
|
||||||
|
#define ALU_CNDGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
|
||||||
|
ALU_OP3(OP3_INST_CNDGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
|
||||||
|
|
||||||
|
#define ALU_CNDE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
|
||||||
|
ALU_OP3(OP3_INST_CNDE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
|
||||||
|
|
||||||
|
#define TEX_LD(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
|
||||||
|
to_QWORD(TEX_WORD0(TEX_INST_LD, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
|
||||||
|
TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_UNNORMALIZED, TEX_UNNORMALIZED, TEX_UNNORMALIZED, TEX_UNNORMALIZED)), \
|
||||||
|
to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, srcSelX, srcSelY, srcSelZ, srcSelW), 0x00000000)
|
||||||
|
|
||||||
|
#define TEX_SAMPLE(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
|
||||||
|
to_QWORD(TEX_WORD0(TEX_INST_SAMPLE, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
|
||||||
|
TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
|
||||||
|
to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, _x, _y, _0, _x), 0x00000000)
|
||||||
|
|
||||||
|
#define TEX_GET_GRADIENTS_H(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
|
||||||
|
to_QWORD(TEX_WORD0(TEX_INST_GET_GRADIENTS_H, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
|
||||||
|
TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
|
||||||
|
to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, _x, _y, _z, _x), 0x00000000)
|
||||||
|
|
||||||
|
#define TEX_GET_GRADIENTS_V(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
|
||||||
|
to_QWORD(TEX_WORD0(TEX_INST_GET_GRADIENTS_V, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
|
||||||
|
TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
|
||||||
|
to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, _x, _y, _z, _x), 0x00000000)
|
||||||
|
|
||||||
|
#define TEX_GET_TEXTURE_INFO(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
|
||||||
|
to_QWORD(TEX_WORD0(TEX_INST_GET_TEXTURE_INFO, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
|
||||||
|
TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
|
||||||
|
to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, srcSelX, srcSelY, srcSelZ, srcSelW), 0x00000000)
|
||||||
|
|
||||||
|
|
||||||
|
#define VTX_FETCH(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, buffer_id, type, mega, offset) \
|
||||||
|
to_QWORD(VTX_WORD0(VTX_INST_FETCH, type, buffer_id, srcReg, srcSelX, mega), VTX_WORD1(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW)) , \
|
||||||
|
to_QWORD(VTX_WORD2(offset, (mega >> 31)), 0x00000000)
|
||||||
|
|
||||||
|
#define _x2(v) v, v
|
||||||
|
#define _x4(v) _x2(v), _x2(v)
|
||||||
|
#define _x8(v) _x4(v), _x4(v)
|
||||||
|
#define _x16(v) _x8(v), _x8(v)
|
||||||
|
|
||||||
|
#define _x9(v) _x8(v), v
|
||||||
|
#define _x30(v) _x16(v), _x8(v), _x4(v),_x2(v)
|
||||||
|
#define _x31(v) _x30(v), v
|
||||||
|
|
||||||
|
#endif /* GX2_SHADER_INL_H */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,525 +0,0 @@
|
|||||||
/*************************************************************************
|
|
||||||
* GLFW 3.3 - www.glfw.org
|
|
||||||
* A library for OpenGL, window and input
|
|
||||||
*------------------------------------------------------------------------
|
|
||||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
|
||||||
* Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.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.
|
|
||||||
*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _glfw3_native_h_
|
|
||||||
#define _glfw3_native_h_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* Doxygen documentation
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
/*! @file glfw3native.h
|
|
||||||
* @brief The header of the native access functions.
|
|
||||||
*
|
|
||||||
* This is the header file of the native access functions. See @ref native for
|
|
||||||
* more information.
|
|
||||||
*/
|
|
||||||
/*! @defgroup native Native access
|
|
||||||
* @brief Functions related to accessing native handles.
|
|
||||||
*
|
|
||||||
* **By using the native access functions you assert that you know what you're
|
|
||||||
* doing and how to fix problems caused by using them. If you don't, you
|
|
||||||
* shouldn't be using them.**
|
|
||||||
*
|
|
||||||
* Before the inclusion of @ref glfw3native.h, you may define zero or more
|
|
||||||
* window system API macro and zero or more context creation API macros.
|
|
||||||
*
|
|
||||||
* The chosen backends must match those the library was compiled for. Failure
|
|
||||||
* to do this will cause a link-time error.
|
|
||||||
*
|
|
||||||
* The available window API macros are:
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_WIN32`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_COCOA`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_X11`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
|
|
||||||
*
|
|
||||||
* The available context API macros are:
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_WGL`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_NSGL`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_GLX`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_EGL`
|
|
||||||
* * `GLFW_EXPOSE_NATIVE_OSMESA`
|
|
||||||
*
|
|
||||||
* These macros select which of the native access functions that are declared
|
|
||||||
* and which platform-specific headers to include. It is then up your (by
|
|
||||||
* definition platform-specific) code to handle which of these should be
|
|
||||||
* defined.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* System headers and types
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
|
||||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
|
||||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
|
||||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
|
||||||
#if defined(GLFW_APIENTRY_DEFINED)
|
|
||||||
#undef APIENTRY
|
|
||||||
#undef GLFW_APIENTRY_DEFINED
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
|
|
||||||
#if defined(__OBJC__)
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#else
|
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
|
||||||
typedef void* id;
|
|
||||||
#endif
|
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/extensions/Xrandr.h>
|
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
|
||||||
#include <wayland-client.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
|
||||||
/* WGL is declared by windows.h */
|
|
||||||
#endif
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
|
||||||
/* NSGL is declared by Cocoa.h */
|
|
||||||
#endif
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
|
||||||
#include <GL/glx.h>
|
|
||||||
#endif
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
|
||||||
#include <EGL/egl.h>
|
|
||||||
#endif
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
|
||||||
#include <GL/osmesa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* Functions
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
|
||||||
/*! @brief Returns the adapter device name of the specified monitor.
|
|
||||||
*
|
|
||||||
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
|
|
||||||
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
|
||||||
* occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.1.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
/*! @brief Returns the display device name of the specified monitor.
|
|
||||||
*
|
|
||||||
* @return The UTF-8 encoded display device name (for example
|
|
||||||
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.1.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
/*! @brief Returns the `HWND` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `HWND` of the specified window, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
|
||||||
/*! @brief Returns the `HGLRC` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `HGLRC` of the specified window, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
|
|
||||||
/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
|
|
||||||
*
|
|
||||||
* @return The `CGDirectDisplayID` of the specified monitor, or
|
|
||||||
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.1.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
/*! @brief Returns the `NSWindow` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `NSWindow` of the specified window, or `nil` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
|
||||||
/*! @brief Returns the `NSOpenGLContext` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
|
||||||
/*! @brief Returns the `Display` used by GLFW.
|
|
||||||
*
|
|
||||||
* @return The `Display` used by GLFW, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI Display* glfwGetX11Display(void);
|
|
||||||
|
|
||||||
/*! @brief Returns the `RRCrtc` of the specified monitor.
|
|
||||||
*
|
|
||||||
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.1.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
/*! @brief Returns the `RROutput` of the specified monitor.
|
|
||||||
*
|
|
||||||
* @return The `RROutput` of the specified monitor, or `None` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.1.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
/*! @brief Returns the `Window` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `Window` of the specified window, or `None` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
|
||||||
|
|
||||||
/*! @brief Sets the current primary selection to the specified string.
|
|
||||||
*
|
|
||||||
* @param[in] string A UTF-8 encoded string.
|
|
||||||
*
|
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
|
||||||
* GLFW_PLATFORM_ERROR.
|
|
||||||
*
|
|
||||||
* @pointer_lifetime The specified string is copied before this function
|
|
||||||
* returns.
|
|
||||||
*
|
|
||||||
* @thread_safety This function must only be called from the main thread.
|
|
||||||
*
|
|
||||||
* @sa @ref clipboard
|
|
||||||
* @sa glfwGetX11SelectionString
|
|
||||||
* @sa glfwSetClipboardString
|
|
||||||
*
|
|
||||||
* @since Added in version 3.3.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI void glfwSetX11SelectionString(const char* string);
|
|
||||||
|
|
||||||
/*! @brief Returns the contents of the current primary selection as a string.
|
|
||||||
*
|
|
||||||
* If the selection is empty or if its contents cannot be converted, `NULL`
|
|
||||||
* is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
|
|
||||||
*
|
|
||||||
* @return The contents of the selection as a UTF-8 encoded string, or `NULL`
|
|
||||||
* if an [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
|
||||||
* GLFW_PLATFORM_ERROR.
|
|
||||||
*
|
|
||||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
|
||||||
* should not free it yourself. It is valid until the next call to @ref
|
|
||||||
* glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
|
|
||||||
* library is terminated.
|
|
||||||
*
|
|
||||||
* @thread_safety This function must only be called from the main thread.
|
|
||||||
*
|
|
||||||
* @sa @ref clipboard
|
|
||||||
* @sa glfwSetX11SelectionString
|
|
||||||
* @sa glfwGetClipboardString
|
|
||||||
*
|
|
||||||
* @since Added in version 3.3.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI const char* glfwGetX11SelectionString(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
|
||||||
/*! @brief Returns the `GLXContext` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `GLXContext` of the specified window, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
|
||||||
|
|
||||||
/*! @brief Returns the `GLXWindow` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `GLXWindow` of the specified window, or `None` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.2.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
|
||||||
/*! @brief Returns the `struct wl_display*` used by GLFW.
|
|
||||||
*
|
|
||||||
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.2.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
|
|
||||||
|
|
||||||
/*! @brief Returns the `struct wl_output*` of the specified monitor.
|
|
||||||
*
|
|
||||||
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.2.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
/*! @brief Returns the main `struct wl_surface*` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
|
||||||
* an [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.2.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
|
||||||
/*! @brief Returns the `EGLDisplay` used by GLFW.
|
|
||||||
*
|
|
||||||
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
|
||||||
|
|
||||||
/*! @brief Returns the `EGLContext` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
|
||||||
|
|
||||||
/*! @brief Returns the `EGLSurface` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.0.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
|
||||||
/*! @brief Retrieves the color buffer associated with the specified window.
|
|
||||||
*
|
|
||||||
* @param[in] window The window whose color buffer to retrieve.
|
|
||||||
* @param[out] width Where to store the width of the color buffer, or `NULL`.
|
|
||||||
* @param[out] height Where to store the height of the color buffer, or `NULL`.
|
|
||||||
* @param[out] format Where to store the OSMesa pixel format of the color
|
|
||||||
* buffer, or `NULL`.
|
|
||||||
* @param[out] buffer Where to store the address of the color buffer, or
|
|
||||||
* `NULL`.
|
|
||||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.3.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
|
|
||||||
|
|
||||||
/*! @brief Retrieves the depth buffer associated with the specified window.
|
|
||||||
*
|
|
||||||
* @param[in] window The window whose depth buffer to retrieve.
|
|
||||||
* @param[out] width Where to store the width of the depth buffer, or `NULL`.
|
|
||||||
* @param[out] height Where to store the height of the depth buffer, or `NULL`.
|
|
||||||
* @param[out] bytesPerValue Where to store the number of bytes per depth
|
|
||||||
* buffer element, or `NULL`.
|
|
||||||
* @param[out] buffer Where to store the address of the depth buffer, or
|
|
||||||
* `NULL`.
|
|
||||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.3.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
|
|
||||||
|
|
||||||
/*! @brief Returns the `OSMesaContext` of the specified window.
|
|
||||||
*
|
|
||||||
* @return The `OSMesaContext` of the specified window, or `NULL` if an
|
|
||||||
* [error](@ref error_handling) occurred.
|
|
||||||
*
|
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
|
||||||
* synchronized.
|
|
||||||
*
|
|
||||||
* @since Added in version 3.3.
|
|
||||||
*
|
|
||||||
* @ingroup native
|
|
||||||
*/
|
|
||||||
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _glfw3_native_h_ */
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
|||||||
//========================================================================
|
|
||||||
// GLFW 3.3 - www.glfw.org
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.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.
|
|
||||||
//
|
|
||||||
//========================================================================
|
|
||||||
// As glfw_config.h.in, this file is used by CMake to produce the
|
|
||||||
// glfw_config.h configuration header file. If you are adding a feature
|
|
||||||
// requiring conditional compilation, this is where to add the macro.
|
|
||||||
//========================================================================
|
|
||||||
// As glfw_config.h, this file defines compile-time option macros for a
|
|
||||||
// specific platform and development environment. If you are using the
|
|
||||||
// GLFW CMake files, modify glfw_config.h.in instead of this file. If you
|
|
||||||
// are using your own build system, make this file define the appropriate
|
|
||||||
// macros in whatever way is suitable.
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
// Define this to 1 if building GLFW for X11
|
|
||||||
/* #undef _GLFW_X11 */
|
|
||||||
// Define this to 1 if building GLFW for Win32
|
|
||||||
#define _GLFW_WIN32
|
|
||||||
// Define this to 1 if building GLFW for Cocoa
|
|
||||||
/* #undef _GLFW_COCOA */
|
|
||||||
// Define this to 1 if building GLFW for Wayland
|
|
||||||
/* #undef _GLFW_WAYLAND */
|
|
||||||
// Define this to 1 if building GLFW for OSMesa
|
|
||||||
/* #undef _GLFW_OSMESA */
|
|
||||||
|
|
||||||
// Define this to 1 if building as a shared library / dynamic library / DLL
|
|
||||||
#define _GLFW_BUILD_DLL
|
|
||||||
// Define this to 1 to use Vulkan loader linked statically into application
|
|
||||||
/* #undef _GLFW_VULKAN_STATIC */
|
|
||||||
|
|
||||||
// Define this to 1 to force use of high-performance GPU on hybrid systems
|
|
||||||
/* #undef _GLFW_USE_HYBRID_HPG */
|
|
||||||
|
|
||||||
// Define this to 1 if xkbcommon supports the compose key
|
|
||||||
/* #undef HAVE_XKBCOMMON_COMPOSE_H */
|
|
||||||
// Define this to 1 if the libc supports memfd_create()
|
|
||||||
/* #undef HAVE_MEMFD_CREATE */
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,334 @@
|
|||||||
|
// dear imgui: Renderer Backend for the Nintendo Wii U using GX2
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_gx2.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h> // intptr_t
|
||||||
|
#include <malloc.h> // memalign
|
||||||
|
|
||||||
|
// GX2 includes
|
||||||
|
#include <whb/gfx.h>
|
||||||
|
#include <gx2/registers.h>
|
||||||
|
#include <gx2/draw.h>
|
||||||
|
#include <gx2/utils.h>
|
||||||
|
#include <gx2/mem.h>
|
||||||
|
#include <gx2r/surface.h>
|
||||||
|
|
||||||
|
// Include shader data
|
||||||
|
#include "shaders/shader.h"
|
||||||
|
|
||||||
|
// GX2 Data
|
||||||
|
struct ImGui_ImplGX2_Data
|
||||||
|
{
|
||||||
|
uint32_t VertexBufferSize;
|
||||||
|
void* VertexBuffer;
|
||||||
|
uint32_t IndexBufferSize;
|
||||||
|
void* IndexBuffer;
|
||||||
|
|
||||||
|
ImGui_ImplGX2_Texture* FontTexture;
|
||||||
|
|
||||||
|
WHBGfxShaderGroup* ShaderGroup;
|
||||||
|
|
||||||
|
ImGui_ImplGX2_Data() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Backend data stored in io.BackendRendererUserData
|
||||||
|
static ImGui_ImplGX2_Data* ImGui_ImplGX2_GetBackendData()
|
||||||
|
{
|
||||||
|
return ImGui::GetCurrentContext() ? (ImGui_ImplGX2_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
bool ImGui_ImplGX2_Init()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
ImGui_ImplGX2_Data* bd = IM_NEW(ImGui_ImplGX2_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_gx2";
|
||||||
|
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGX2_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplGX2_DestroyDeviceObjects();
|
||||||
|
io.BackendRendererName = NULL;
|
||||||
|
io.BackendRendererUserData = NULL;
|
||||||
|
IM_DELETE(bd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGX2_NewFrame()
|
||||||
|
{
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplGX2_Init()?");
|
||||||
|
|
||||||
|
if (!bd->ShaderGroup)
|
||||||
|
ImGui_ImplGX2_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGX2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
|
||||||
|
{
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
|
||||||
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing
|
||||||
|
GX2SetColorControl(GX2_LOGIC_OP_COPY, 0xFF, FALSE, TRUE);
|
||||||
|
GX2SetBlendControl(GX2_RENDER_TARGET_0,
|
||||||
|
GX2_BLEND_MODE_SRC_ALPHA,
|
||||||
|
GX2_BLEND_MODE_INV_SRC_ALPHA,
|
||||||
|
GX2_BLEND_COMBINE_MODE_ADD,
|
||||||
|
TRUE,
|
||||||
|
GX2_BLEND_MODE_ONE,
|
||||||
|
GX2_BLEND_MODE_INV_SRC_ALPHA,
|
||||||
|
GX2_BLEND_COMBINE_MODE_ADD);
|
||||||
|
GX2SetCullOnlyControl(GX2_FRONT_FACE_CCW, FALSE, FALSE);
|
||||||
|
GX2SetDepthOnlyControl(FALSE, FALSE, GX2_COMPARE_FUNC_NEVER);
|
||||||
|
|
||||||
|
// Setup viewport, orthographic projection matrix
|
||||||
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||||
|
GX2SetViewport(0, 0, (float)fb_width, (float)fb_height, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
GX2SetFetchShader(&bd->ShaderGroup->fetchShader);
|
||||||
|
GX2SetVertexShader(bd->ShaderGroup->vertexShader);
|
||||||
|
GX2SetPixelShader(bd->ShaderGroup->pixelShader);
|
||||||
|
|
||||||
|
float L = draw_data->DisplayPos.x;
|
||||||
|
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||||
|
float T = draw_data->DisplayPos.y;
|
||||||
|
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||||
|
const float ortho_projection[4][4] =
|
||||||
|
{
|
||||||
|
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
||||||
|
{ (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
|
||||||
|
};
|
||||||
|
|
||||||
|
GX2SetVertexUniformReg(0, sizeof(ortho_projection) / sizeof(float), &ortho_projection[0][0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGX2_RenderDrawData(ImDrawData* draw_data)
|
||||||
|
{
|
||||||
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
|
if (fb_width <= 0 || fb_height <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
|
||||||
|
ImGui_ImplGX2_SetupRenderState(draw_data, fb_width, fb_height);
|
||||||
|
|
||||||
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
|
// Create continuous vertex/index buffers
|
||||||
|
uint32_t vtx_buffer_size = (uint32_t)draw_data->TotalVtxCount * (int)sizeof(ImDrawVert);
|
||||||
|
uint32_t idx_buffer_size = (uint32_t)draw_data->TotalIdxCount * (int)sizeof(ImDrawIdx);
|
||||||
|
|
||||||
|
// Grow buffers if needed
|
||||||
|
if (bd->VertexBufferSize < vtx_buffer_size)
|
||||||
|
{
|
||||||
|
bd->VertexBufferSize = vtx_buffer_size;
|
||||||
|
free(bd->VertexBuffer);
|
||||||
|
bd->VertexBuffer = memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtx_buffer_size);
|
||||||
|
}
|
||||||
|
if (bd->IndexBufferSize < idx_buffer_size)
|
||||||
|
{
|
||||||
|
bd->IndexBufferSize = idx_buffer_size;
|
||||||
|
free(bd->IndexBuffer);
|
||||||
|
bd->IndexBuffer = memalign(GX2_INDEX_BUFFER_ALIGNMENT, idx_buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy data into continuous buffers
|
||||||
|
uint8_t* vtx_dst = (uint8_t*)bd->VertexBuffer;
|
||||||
|
uint8_t* idx_dst = (uint8_t*)bd->IndexBuffer;
|
||||||
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
|
{
|
||||||
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
|
|
||||||
|
memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
|
vtx_dst += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
|
||||||
|
|
||||||
|
memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
|
idx_dst += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush memory
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, bd->VertexBuffer, vtx_buffer_size);
|
||||||
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, bd->IndexBuffer, idx_buffer_size);
|
||||||
|
|
||||||
|
GX2SetAttribBuffer(0, vtx_buffer_size, sizeof(ImDrawVert), bd->VertexBuffer);
|
||||||
|
|
||||||
|
// Render command lists
|
||||||
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
|
int global_vtx_offset = 0;
|
||||||
|
int global_idx_offset = 0;
|
||||||
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
|
{
|
||||||
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
|
|
||||||
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
|
{
|
||||||
|
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||||
|
if (pcmd->UserCallback != NULL)
|
||||||
|
{
|
||||||
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
|
ImGui_ImplGX2_SetupRenderState(draw_data, fb_width, fb_height);
|
||||||
|
else
|
||||||
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||||
|
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||||
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Discard invalid draws to avoid GPU crash
|
||||||
|
if (clip_min.x < 0.0f || clip_min.y < 0.0f || clip_max.x > fb_width || clip_max.y > fb_height || !pcmd->ElemCount)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Apply scissor/clipping rectangle
|
||||||
|
GX2SetScissor((uint32_t)clip_min.x, (uint32_t)clip_min.y, (uint32_t)(clip_max.x - clip_min.x), (uint32_t)(clip_max.y - clip_min.y));
|
||||||
|
|
||||||
|
// Bind texture, Draw
|
||||||
|
ImGui_ImplGX2_Texture* tex = (ImGui_ImplGX2_Texture*) pcmd->GetTexID();
|
||||||
|
IM_ASSERT(tex && "TextureID cannot be NULL");
|
||||||
|
|
||||||
|
GX2SetPixelTexture(tex->Texture, 0);
|
||||||
|
GX2SetPixelSampler(tex->Sampler, 0);
|
||||||
|
|
||||||
|
GX2DrawIndexedEx(GX2_PRIMITIVE_MODE_TRIANGLES, pcmd->ElemCount,
|
||||||
|
sizeof(ImDrawIdx) == 2 ? GX2_INDEX_TYPE_U16 : GX2_INDEX_TYPE_U32,
|
||||||
|
(uint8_t*) bd->IndexBuffer + (pcmd->IdxOffset + global_idx_offset) * sizeof(ImDrawIdx),
|
||||||
|
global_vtx_offset + pcmd->VtxOffset, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
global_idx_offset += cmd_list->IdxBuffer.Size;
|
||||||
|
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplGX2_CreateFontsTexture()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
|
||||||
|
if (bd->FontTexture)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build texture atlas
|
||||||
|
unsigned char* src_pixels;
|
||||||
|
int width, height;
|
||||||
|
io.Fonts->GetTexDataAsRGBA32(&src_pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders.
|
||||||
|
|
||||||
|
bd->FontTexture = IM_NEW(ImGui_ImplGX2_Texture)();
|
||||||
|
|
||||||
|
GX2Texture* tex = IM_NEW(GX2Texture)();
|
||||||
|
memset(tex, 0, sizeof(GX2Texture));
|
||||||
|
bd->FontTexture->Texture = tex;
|
||||||
|
|
||||||
|
tex->surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
||||||
|
tex->surface.use = GX2_SURFACE_USE_TEXTURE;
|
||||||
|
tex->surface.width = width;
|
||||||
|
tex->surface.height = height;
|
||||||
|
tex->surface.depth = 1;
|
||||||
|
tex->surface.mipLevels = 1;
|
||||||
|
tex->surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||||
|
tex->surface.aa = GX2_AA_MODE1X;
|
||||||
|
tex->surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
||||||
|
tex->viewNumSlices = 1;
|
||||||
|
tex->viewNumMips = 1;
|
||||||
|
// swapped for endianness
|
||||||
|
tex->compMap = GX2_COMP_MAP(GX2_SQ_SEL_A, GX2_SQ_SEL_B, GX2_SQ_SEL_G, GX2_SQ_SEL_R);
|
||||||
|
|
||||||
|
GX2RCreateSurface(&tex->surface, GX2R_RESOURCE_BIND_TEXTURE | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ);
|
||||||
|
GX2InitTextureRegs(tex);
|
||||||
|
|
||||||
|
unsigned char* dst_pixels = (unsigned char*) GX2RLockSurfaceEx(&tex->surface, 0, GX2R_RESOURCE_BIND_NONE);
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
memcpy(dst_pixels + (y * tex->surface.pitch * 4), src_pixels + (y * width * 4), width * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
GX2RUnlockSurfaceEx(&tex->surface, 0, GX2R_RESOURCE_BIND_NONE);
|
||||||
|
|
||||||
|
bd->FontTexture->Sampler = IM_NEW(GX2Sampler)();
|
||||||
|
GX2InitSampler(bd->FontTexture->Sampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR);
|
||||||
|
|
||||||
|
// Store our identifier
|
||||||
|
io.Fonts->SetTexID((ImTextureID) bd->FontTexture);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGX2_DestroyFontsTexture()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
if (bd->FontTexture)
|
||||||
|
{
|
||||||
|
GX2RDestroySurfaceEx(&bd->FontTexture->Texture->surface, GX2R_RESOURCE_BIND_NONE);
|
||||||
|
io.Fonts->SetTexID(0);
|
||||||
|
IM_DELETE(bd->FontTexture->Texture);
|
||||||
|
IM_DELETE(bd->FontTexture->Sampler);
|
||||||
|
IM_DELETE(bd->FontTexture);
|
||||||
|
bd->FontTexture = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplGX2_CreateDeviceObjects()
|
||||||
|
{
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
bd->ShaderGroup = IM_NEW(WHBGfxShaderGroup)();
|
||||||
|
|
||||||
|
if (!WHBGfxLoadGFDShaderGroup(bd->ShaderGroup, 0, shader_gsh))
|
||||||
|
{
|
||||||
|
IM_DELETE(bd->ShaderGroup);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WHBGfxInitShaderAttribute(bd->ShaderGroup, "Position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||||
|
WHBGfxInitShaderAttribute(bd->ShaderGroup, "UV", 0, 8, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||||
|
WHBGfxInitShaderAttribute(bd->ShaderGroup, "Color", 0, 16, GX2_ATTRIB_TYPE_8_8_8_8);
|
||||||
|
|
||||||
|
if (!WHBGfxInitFetchShader(bd->ShaderGroup))
|
||||||
|
{
|
||||||
|
IM_DELETE(bd->ShaderGroup);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplGX2_CreateFontsTexture();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplGX2_DestroyDeviceObjects()
|
||||||
|
{
|
||||||
|
ImGui_ImplGX2_Data* bd = ImGui_ImplGX2_GetBackendData();
|
||||||
|
|
||||||
|
free(bd->VertexBuffer);
|
||||||
|
bd->VertexBuffer = NULL;
|
||||||
|
|
||||||
|
free(bd->IndexBuffer);
|
||||||
|
bd->IndexBuffer = NULL;
|
||||||
|
|
||||||
|
WHBGfxFreeShaderGroup(bd->ShaderGroup);
|
||||||
|
IM_DELETE(bd->ShaderGroup);
|
||||||
|
bd->ShaderGroup = NULL;
|
||||||
|
|
||||||
|
ImGui_ImplGX2_DestroyFontsTexture();
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// dear imgui: Renderer Backend for the Nintendo Wii U using GX2
|
||||||
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
|
// GX2 Texture / contains a texture and sampler
|
||||||
|
// Can be used as a ImTextureID with the GX2 backend
|
||||||
|
struct ImGui_ImplGX2_Texture
|
||||||
|
{
|
||||||
|
struct GX2Texture* Texture;
|
||||||
|
struct GX2Sampler* Sampler;
|
||||||
|
|
||||||
|
ImGui_ImplGX2_Texture() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Backend API
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplGX2_Init();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGX2_Shutdown();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGX2_NewFrame();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGX2_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
|
// (Optional) Called by Init/NewFrame/Shutdown
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplGX2_CreateFontsTexture();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGX2_DestroyFontsTexture();
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplGX2_CreateDeviceObjects();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGX2_DestroyDeviceObjects();
|
@ -0,0 +1,294 @@
|
|||||||
|
// dear imgui: Platform Backend for the Wii U
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_wiiu.h"
|
||||||
|
#include <stdlib.h> // malloc/free
|
||||||
|
|
||||||
|
// Software keyboard
|
||||||
|
#include <nn/swkbd.h>
|
||||||
|
|
||||||
|
// Wii U Data
|
||||||
|
struct ImGui_ImplWiiU_Data
|
||||||
|
{
|
||||||
|
nn::swkbd::CreateArg CreateArg;
|
||||||
|
nn::swkbd::AppearArg AppearArg;
|
||||||
|
nn::swkbd::ControllerType LastController;
|
||||||
|
|
||||||
|
bool WantedTextInput;
|
||||||
|
bool WasTouched;
|
||||||
|
|
||||||
|
ImGui_ImplWiiU_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Backend data stored in io.BackendPlatformUserData
|
||||||
|
static ImGui_ImplWiiU_Data* ImGui_ImplWiiU_GetBackendData()
|
||||||
|
{
|
||||||
|
return ImGui::GetCurrentContext() ? (ImGui_ImplWiiU_Data*)ImGui::GetIO().BackendPlatformUserData : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplWiiU_Init()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
|
||||||
|
|
||||||
|
// Setup backend data
|
||||||
|
ImGui_ImplWiiU_Data* bd = IM_NEW(ImGui_ImplWiiU_Data)();
|
||||||
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
|
io.BackendPlatformName = "imgui_impl_wiiu";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
|
// Initialize and create software keyboard
|
||||||
|
nn::swkbd::CreateArg createArg;
|
||||||
|
|
||||||
|
createArg.workMemory = malloc(nn::swkbd::GetWorkMemorySize(0));
|
||||||
|
createArg.fsClient = (FSClient*) malloc(sizeof(FSClient));
|
||||||
|
if (!createArg.workMemory || !createArg.fsClient)
|
||||||
|
{
|
||||||
|
free(createArg.workMemory);
|
||||||
|
free(createArg.fsClient);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSAddClient(createArg.fsClient, FS_ERROR_FLAG_NONE);
|
||||||
|
|
||||||
|
if (!nn::swkbd::Create(createArg))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
nn::swkbd::AppearArg appearArg;
|
||||||
|
bd->CreateArg = createArg;
|
||||||
|
bd->AppearArg = appearArg;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplWiiU_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplWiiU_Data* bd = ImGui_ImplWiiU_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// Destroy software keyboard
|
||||||
|
nn::swkbd::Destroy();
|
||||||
|
free(bd->CreateArg.workMemory);
|
||||||
|
bd->CreateArg.workMemory = NULL;
|
||||||
|
|
||||||
|
if (bd->CreateArg.fsClient)
|
||||||
|
{
|
||||||
|
FSDelClient(bd->CreateArg.fsClient, FS_ERROR_FLAG_NONE);
|
||||||
|
free(bd->CreateArg.fsClient);
|
||||||
|
bd->CreateArg.fsClient = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
io.BackendPlatformName = NULL;
|
||||||
|
io.BackendPlatformUserData = NULL;
|
||||||
|
IM_DELETE(bd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWiiU_UpdateKeyboardInput(ImGui_ImplWiiU_ControllerInput* input)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &input->vpad->tpNormal, &input->vpad->tpNormal);
|
||||||
|
|
||||||
|
nn::swkbd::ControllerInfo controllerInfo;
|
||||||
|
controllerInfo.vpad = input->vpad;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
controllerInfo.kpad[i] = input->kpad[i];
|
||||||
|
|
||||||
|
nn::swkbd::Calc(controllerInfo);
|
||||||
|
|
||||||
|
if (nn::swkbd::IsNeedCalcSubThreadFont())
|
||||||
|
nn::swkbd::CalcSubThreadFont();
|
||||||
|
|
||||||
|
if (nn::swkbd::IsNeedCalcSubThreadPredict())
|
||||||
|
nn::swkbd::CalcSubThreadPredict();
|
||||||
|
|
||||||
|
if (nn::swkbd::IsDecideOkButton(NULL))
|
||||||
|
{
|
||||||
|
// Add entered text
|
||||||
|
const char16_t* string = nn::swkbd::GetInputFormString();
|
||||||
|
for (int i = 0; *string; string++)
|
||||||
|
io.AddInputCharacterUTF16(string[i]);
|
||||||
|
|
||||||
|
// close keyboard
|
||||||
|
nn::swkbd::DisappearInputForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nn::swkbd::IsDecideCancelButton(NULL))
|
||||||
|
nn::swkbd::DisappearInputForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWiiU_UpdateTouchInput(ImGui_ImplWiiU_ControllerInput* input)
|
||||||
|
{
|
||||||
|
if (!input->vpad)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGui_ImplWiiU_Data* bd = ImGui_ImplWiiU_GetBackendData();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
VPADTouchData touch;
|
||||||
|
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &touch, &input->vpad->tpNormal);
|
||||||
|
|
||||||
|
if (touch.touched)
|
||||||
|
{
|
||||||
|
float scale_x = (io.DisplaySize.x / io.DisplayFramebufferScale.x) / 1280.0f;
|
||||||
|
float scale_y = (io.DisplaySize.y / io.DisplayFramebufferScale.y) / 720.0f;
|
||||||
|
io.AddMousePosEvent(touch.x * scale_x, touch.y * scale_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (touch.touched != bd->WasTouched)
|
||||||
|
{
|
||||||
|
io.AddMouseButtonEvent(ImGuiMouseButton_Left, touch.touched);
|
||||||
|
bd->WasTouched = touch.touched;
|
||||||
|
bd->LastController = nn::swkbd::ControllerType::DrcGamepad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define IM_CLAMP(V, MN, MX) ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V))
|
||||||
|
|
||||||
|
static void ImGui_ImplWiiU_UpdateControllerInput(ImGui_ImplWiiU_ControllerInput* input)
|
||||||
|
{
|
||||||
|
ImGui_ImplWiiU_Data* bd = ImGui_ImplWiiU_GetBackendData();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// SoH removal to make opening the menu easier
|
||||||
|
// if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
uint32_t vpad_buttons = input->vpad ? input->vpad->hold : 0;
|
||||||
|
uint32_t wpad_buttons = 0;
|
||||||
|
uint32_t classic_buttons = 0;
|
||||||
|
uint32_t pro_buttons = 0;
|
||||||
|
|
||||||
|
float stick_l_x = input->vpad ? input->vpad->leftStick.x : 0.0f;
|
||||||
|
float stick_l_y = input->vpad ? input->vpad->leftStick.y : 0.0f;
|
||||||
|
float stick_r_x = input->vpad ? input->vpad->rightStick.x : 0.0f;
|
||||||
|
float stick_r_y = input->vpad ? input->vpad->rightStick.y : 0.0f;
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
KPADStatus* kpad = input->kpad[i];
|
||||||
|
if (!kpad)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (kpad->extensionType)
|
||||||
|
{
|
||||||
|
case WPAD_EXT_CORE:
|
||||||
|
case WPAD_EXT_NUNCHUK:
|
||||||
|
case WPAD_EXT_MPLUS:
|
||||||
|
case WPAD_EXT_MPLUS_NUNCHUK:
|
||||||
|
wpad_buttons |= kpad->hold;
|
||||||
|
break;
|
||||||
|
case WPAD_EXT_CLASSIC:
|
||||||
|
case WPAD_EXT_MPLUS_CLASSIC:
|
||||||
|
classic_buttons |= kpad->classic.hold;
|
||||||
|
if (classic_buttons & WPAD_CLASSIC_BUTTON_Y)
|
||||||
|
bd->LastController = (nn::swkbd::ControllerType) i;
|
||||||
|
|
||||||
|
stick_l_x += kpad->classic.leftStick.x;
|
||||||
|
stick_l_y += kpad->classic.leftStick.y;
|
||||||
|
stick_r_x += kpad->classic.rightStick.x;
|
||||||
|
stick_r_y += kpad->classic.rightStick.y;
|
||||||
|
break;
|
||||||
|
case WPAD_EXT_PRO_CONTROLLER:
|
||||||
|
pro_buttons |= kpad->pro.hold;
|
||||||
|
if (pro_buttons & WPAD_PRO_BUTTON_Y)
|
||||||
|
bd->LastController = (nn::swkbd::ControllerType) i;
|
||||||
|
|
||||||
|
stick_l_x += kpad->pro.leftStick.x;
|
||||||
|
stick_l_y += kpad->pro.leftStick.y;
|
||||||
|
stick_r_x += kpad->pro.rightStick.x;
|
||||||
|
stick_r_y += kpad->pro.rightStick.y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vpad_buttons & VPAD_BUTTON_Y)
|
||||||
|
bd->LastController = nn::swkbd::ControllerType::DrcGamepad;
|
||||||
|
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadStart, (vpad_buttons & VPAD_BUTTON_PLUS) || (wpad_buttons & WPAD_BUTTON_PLUS) || (classic_buttons & WPAD_CLASSIC_BUTTON_PLUS) || (pro_buttons & WPAD_PRO_BUTTON_PLUS));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadBack, (vpad_buttons & VPAD_BUTTON_MINUS) || (wpad_buttons & WPAD_BUTTON_MINUS) || (classic_buttons & WPAD_CLASSIC_BUTTON_MINUS) || (pro_buttons & WPAD_PRO_BUTTON_MINUS));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadFaceLeft, (vpad_buttons & VPAD_BUTTON_X) || (classic_buttons & WPAD_CLASSIC_BUTTON_X) || (pro_buttons & WPAD_PRO_BUTTON_X));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadFaceRight, (vpad_buttons & VPAD_BUTTON_B) || (wpad_buttons & WPAD_BUTTON_B) || (classic_buttons & WPAD_CLASSIC_BUTTON_B) || (pro_buttons & WPAD_PRO_BUTTON_B));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadFaceUp, (vpad_buttons & VPAD_BUTTON_Y) || (classic_buttons & WPAD_CLASSIC_BUTTON_Y) || (pro_buttons & WPAD_PRO_BUTTON_Y));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadFaceDown, (vpad_buttons & VPAD_BUTTON_A) || (wpad_buttons & WPAD_BUTTON_A) || (classic_buttons & WPAD_CLASSIC_BUTTON_A) || (pro_buttons & WPAD_PRO_BUTTON_A));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadDpadLeft, (vpad_buttons & VPAD_BUTTON_LEFT) || (wpad_buttons & WPAD_BUTTON_LEFT) || (classic_buttons & WPAD_CLASSIC_BUTTON_LEFT) || (pro_buttons & WPAD_PRO_BUTTON_LEFT));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadDpadRight, (vpad_buttons & VPAD_BUTTON_RIGHT) || (wpad_buttons & WPAD_BUTTON_RIGHT) || (classic_buttons & WPAD_CLASSIC_BUTTON_RIGHT) || (pro_buttons & WPAD_PRO_BUTTON_RIGHT));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadDpadUp, (vpad_buttons & VPAD_BUTTON_UP) || (wpad_buttons & WPAD_BUTTON_UP) || (classic_buttons & WPAD_CLASSIC_BUTTON_UP) || (pro_buttons & WPAD_PRO_BUTTON_UP));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadDpadDown, (vpad_buttons & VPAD_BUTTON_DOWN) || (wpad_buttons & WPAD_BUTTON_DOWN) || (classic_buttons & WPAD_CLASSIC_BUTTON_DOWN) || (pro_buttons & WPAD_PRO_BUTTON_DOWN));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadL1, (vpad_buttons & VPAD_BUTTON_L) || (classic_buttons & WPAD_CLASSIC_BUTTON_L) || (pro_buttons & WPAD_PRO_TRIGGER_L));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadR1, (vpad_buttons & VPAD_BUTTON_R) || (classic_buttons & WPAD_CLASSIC_BUTTON_R) || (pro_buttons & WPAD_PRO_TRIGGER_R));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadL2, (vpad_buttons & VPAD_BUTTON_ZL) || (classic_buttons & WPAD_CLASSIC_BUTTON_ZL) || (pro_buttons & WPAD_PRO_TRIGGER_ZL));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadR2, (vpad_buttons & VPAD_BUTTON_ZR) || (classic_buttons & WPAD_CLASSIC_BUTTON_ZR) || (pro_buttons & WPAD_PRO_TRIGGER_ZR));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadL3, (vpad_buttons & VPAD_BUTTON_STICK_L) || (pro_buttons & WPAD_PRO_BUTTON_STICK_L));
|
||||||
|
io.AddKeyEvent(ImGuiKey_GamepadR3, (vpad_buttons & VPAD_BUTTON_STICK_R) || (pro_buttons & WPAD_PRO_BUTTON_STICK_R));
|
||||||
|
|
||||||
|
stick_l_x = IM_CLAMP(stick_l_x, -1.0f, 1.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadLStickLeft, stick_l_x < -0.1f, (stick_l_x < -0.1f) ? (stick_l_x * -1.0f) : 0.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadLStickRight, stick_l_x > 0.1f, (stick_l_x > 0.1f) ? stick_l_x : 0.0f);
|
||||||
|
|
||||||
|
stick_l_y = IM_CLAMP(stick_l_y, -1.0f, 1.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadLStickUp, stick_l_y > 0.1f, (stick_l_y > 0.1f) ? stick_l_y : 0.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadLStickDown, stick_l_y < -0.1f, (stick_l_y < -0.1f) ? (stick_l_y * -1.0f) : 0.0f);
|
||||||
|
|
||||||
|
stick_r_x = IM_CLAMP(stick_r_x, -1.0f, 1.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadRStickLeft, stick_r_x < -0.1f, (stick_r_x < -0.1f) ? (stick_r_x * -1.0f) : 0.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadRStickRight, stick_r_x > 0.1f, (stick_r_x > 0.1f) ? stick_r_x : 0.0f);
|
||||||
|
|
||||||
|
stick_r_y = IM_CLAMP(stick_r_y, -1.0f, 1.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadRStickUp, stick_r_y > 0.1f, (stick_r_y > 0.1f) ? stick_r_y : 0.0f);
|
||||||
|
io.AddKeyAnalogEvent(ImGuiKey_GamepadRStickDown, stick_r_y < -0.1f, (stick_r_y < -0.1f) ? (stick_r_y * -1.0f) : 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplWiiU_ProcessInput(ImGui_ImplWiiU_ControllerInput* input)
|
||||||
|
{
|
||||||
|
ImGui_ImplWiiU_Data* bd = ImGui_ImplWiiU_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplWiiU_Init()?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// Show keyboard if wanted
|
||||||
|
if (io.WantTextInput && !bd->WantedTextInput)
|
||||||
|
{
|
||||||
|
// Open the keyboard for the controller which requested the text input
|
||||||
|
bd->AppearArg.keyboardArg.configArg.controllerType = bd->LastController;
|
||||||
|
|
||||||
|
if (nn::swkbd::GetStateInputForm() == nn::swkbd::State::Hidden)
|
||||||
|
nn::swkbd::AppearInputForm(bd->AppearArg);
|
||||||
|
}
|
||||||
|
bd->WantedTextInput = io.WantTextInput;
|
||||||
|
|
||||||
|
// Update keyboard input
|
||||||
|
if (nn::swkbd::GetStateInputForm() != nn::swkbd::State::Hidden)
|
||||||
|
{
|
||||||
|
ImGui_ImplWiiU_UpdateKeyboardInput(input);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update touch screen
|
||||||
|
ImGui_ImplWiiU_UpdateTouchInput(input);
|
||||||
|
|
||||||
|
// Update gamepads
|
||||||
|
ImGui_ImplWiiU_UpdateControllerInput(input);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplWiiU_DrawKeyboardOverlay(ImGui_ImplWiiU_KeyboardOverlayType type)
|
||||||
|
{
|
||||||
|
ImGui_ImplWiiU_Data* bd = ImGui_ImplWiiU_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplWiiU_Init()?");
|
||||||
|
|
||||||
|
if (nn::swkbd::GetStateInputForm() != nn::swkbd::State::Hidden)
|
||||||
|
{
|
||||||
|
if (type == ImGui_KeyboardOverlay_Auto)
|
||||||
|
{
|
||||||
|
if (bd->LastController == nn::swkbd::ControllerType::DrcGamepad)
|
||||||
|
nn::swkbd::DrawDRC();
|
||||||
|
else
|
||||||
|
nn::swkbd::DrawTV();
|
||||||
|
}
|
||||||
|
else if (type == ImGui_KeyboardOverlay_DRC)
|
||||||
|
nn::swkbd::DrawDRC();
|
||||||
|
else if (type == ImGui_KeyboardOverlay_TV)
|
||||||
|
nn::swkbd::DrawTV();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
// dear imgui: Platform Backend for the Wii U
|
||||||
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
|
// GamePad Input
|
||||||
|
#include <vpad/input.h>
|
||||||
|
// Controller Input
|
||||||
|
#include <padscore/kpad.h>
|
||||||
|
|
||||||
|
struct ImGui_ImplWiiU_ControllerInput
|
||||||
|
{
|
||||||
|
VPADStatus* vpad = nullptr;
|
||||||
|
KPADStatus* kpad[4] = { nullptr };
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImGui_ImplWiiU_KeyboardOverlayType
|
||||||
|
{
|
||||||
|
//! Draw for the DRC
|
||||||
|
ImGui_KeyboardOverlay_DRC,
|
||||||
|
//! Draw for the TV
|
||||||
|
ImGui_KeyboardOverlay_TV,
|
||||||
|
//! Draw for the controller which requested the keyboard
|
||||||
|
ImGui_KeyboardOverlay_Auto
|
||||||
|
};
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplWiiU_Init();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplWiiU_Shutdown();
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplWiiU_ProcessInput(ImGui_ImplWiiU_ControllerInput* input);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplWiiU_DrawKeyboardOverlay(ImGui_ImplWiiU_KeyboardOverlayType type = ImGui_KeyboardOverlay_Auto);
|
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# to build shaders you need to place a copy of latte-assembler into the current directory
|
||||||
|
# latte-assembler is part of decaf-emu <https://github.com/decaf-emu/decaf-emu>
|
||||||
|
|
||||||
|
# shader
|
||||||
|
./latte-assembler assemble --vsh=shader.vsh --psh=shader.psh shader.gsh
|
||||||
|
xxd -i shader.gsh > shader.h
|
@ -0,0 +1,148 @@
|
|||||||
|
unsigned char shader_gsh[] = {
|
||||||
|
0x47, 0x66, 0x78, 0x32, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x4c, 0x4b, 0x7b,
|
||||||
|
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0xd8, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x01, 0x00,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x03,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x70,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xd0, 0x60, 0x01, 0x34,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x03, 0xd0, 0x60, 0x01, 0x48, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0xca, 0x70, 0x01, 0x78, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xca, 0x70, 0x01, 0x80,
|
||||||
|
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0xca, 0x70, 0x01, 0x8c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0xca, 0x70, 0x01, 0x90, 0x00, 0x00, 0x00, 0x0b,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, 0x72, 0x6f, 0x6a,
|
||||||
|
0x4d, 0x74, 0x78, 0x00, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x55, 0x56, 0x00, 0x00, 0x43, 0x6f, 0x6c, 0x6f,
|
||||||
|
0x72, 0x00, 0x00, 0x00, 0xd0, 0x60, 0x00, 0xe8, 0xd0, 0x60, 0x01, 0x08,
|
||||||
|
0xca, 0x70, 0x01, 0x34, 0xca, 0x70, 0x01, 0x48, 0xca, 0x70, 0x01, 0x58,
|
||||||
|
0xca, 0x70, 0x01, 0x68, 0x7d, 0x42, 0x4c, 0x4b, 0x00, 0x00, 0x00, 0x28,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x98, 0xd0, 0x60, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x20, 0xd0, 0x60, 0x01, 0x78, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x06, 0xd0, 0x60, 0x01, 0x98, 0x42, 0x4c, 0x4b, 0x7b,
|
||||||
|
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x70, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x09,
|
||||||
|
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0xa0, 0x3c, 0xa0, 0x00, 0x00,
|
||||||
|
0x88, 0x06, 0x00, 0x94, 0x00, 0x40, 0x01, 0x00, 0x08, 0x09, 0x80, 0x13,
|
||||||
|
0x01, 0xc0, 0x01, 0x00, 0x88, 0x06, 0x20, 0x14, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x60, 0x20, 0x00,
|
||||||
|
0x80, 0x00, 0x00, 0x00, 0xfd, 0x64, 0xa0, 0x00, 0x80, 0x00, 0x00, 0x20,
|
||||||
|
0xfd, 0x68, 0x20, 0x01, 0x80, 0x00, 0x00, 0x40, 0xfd, 0x6c, 0xa0, 0x81,
|
||||||
|
0x80, 0x00, 0x00, 0x60, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f,
|
||||||
|
0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x24, 0x20, 0x00,
|
||||||
|
0xfe, 0x00, 0xe2, 0x0f, 0x01, 0x24, 0xa0, 0x00, 0xfe, 0x04, 0xe2, 0x2f,
|
||||||
|
0x01, 0x24, 0x20, 0x01, 0xfe, 0x08, 0xe2, 0x4f, 0x01, 0x24, 0xa0, 0x81,
|
||||||
|
0xfe, 0x0c, 0xe2, 0x6f, 0x01, 0x00, 0x20, 0x00, 0xfe, 0x00, 0x22, 0x00,
|
||||||
|
0x01, 0x00, 0xa0, 0x00, 0xfe, 0x04, 0x22, 0x20, 0x01, 0x00, 0x20, 0x01,
|
||||||
|
0xfe, 0x08, 0x22, 0x40, 0x01, 0x00, 0xa0, 0x81, 0xfe, 0x0c, 0x22, 0x60,
|
||||||
|
0x42, 0x4c, 0x4b, 0x7b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x2c,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x14, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0xd0, 0x60, 0x00, 0xe8, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0xca, 0x70, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0xd0, 0x60, 0x00, 0xd4,
|
||||||
|
0xca, 0x70, 0x00, 0xe8, 0x7d, 0x42, 0x4c, 0x4b, 0x00, 0x00, 0x00, 0x28,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xd0, 0x60, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x08, 0xd0, 0x60, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0xd0, 0x60, 0x00, 0xfc, 0x42, 0x4c, 0x4b, 0x7b,
|
||||||
|
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x03,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x80,
|
||||||
|
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x88, 0x06, 0x20, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x80, 0x01,
|
||||||
|
0x90, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0x90, 0x00, 0x00, 0x20,
|
||||||
|
0x00, 0x28, 0x80, 0x00, 0x90, 0x00, 0x00, 0x40, 0x00, 0x2c, 0x00, 0x80,
|
||||||
|
0x90, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0d, 0xf0,
|
||||||
|
0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x42, 0x4c, 0x4b, 0x7b,
|
||||||
|
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
|
||||||
|
0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
unsigned int shader_gsh_len = 1732;
|
@ -0,0 +1,25 @@
|
|||||||
|
; $MODE = "UniformRegister"
|
||||||
|
|
||||||
|
; $NUM_SPI_PS_INPUT_CNTL = 2
|
||||||
|
; Frag_UV R0
|
||||||
|
; $SPI_PS_INPUT_CNTL[0].SEMANTIC = 0
|
||||||
|
; $SPI_PS_INPUT_CNTL[0].DEFAULT_VAL = 1
|
||||||
|
; Frag_Color R1
|
||||||
|
; $SPI_PS_INPUT_CNTL[1].SEMANTIC = 1
|
||||||
|
; $SPI_PS_INPUT_CNTL[1].DEFAULT_VAL = 1
|
||||||
|
|
||||||
|
; $SAMPLER_VARS[0].name = "Texture"
|
||||||
|
; $SAMPLER_VARS[0].type = "SAMPLER2D"
|
||||||
|
; $SAMPLER_VARS[0].location = 0
|
||||||
|
|
||||||
|
; Note: R1 is swapped for endianness
|
||||||
|
|
||||||
|
00 TEX: ADDR(48) CNT(1) VALID_PIX
|
||||||
|
0 SAMPLE R0, R0.xy0x, t0, s0
|
||||||
|
01 ALU: ADDR(32) CNT(4)
|
||||||
|
1 x: MUL R0.x, R0.x, R1.w
|
||||||
|
y: MUL R0.y, R0.y, R1.z
|
||||||
|
z: MUL R0.z, R0.z, R1.y
|
||||||
|
w: MUL R0.w, R0.w, R1.x
|
||||||
|
02 EXP_DONE: PIX0, R0
|
||||||
|
END_OF_PROGRAM
|
@ -0,0 +1,47 @@
|
|||||||
|
; $MODE = "UniformRegister"
|
||||||
|
|
||||||
|
; $SPI_VS_OUT_CONFIG.VS_EXPORT_COUNT = 1
|
||||||
|
; $NUM_SPI_VS_OUT_ID = 1
|
||||||
|
; uv
|
||||||
|
; $SPI_VS_OUT_ID[0].SEMANTIC_0 = 0
|
||||||
|
; color
|
||||||
|
; $SPI_VS_OUT_ID[0].SEMANTIC_1 = 1
|
||||||
|
|
||||||
|
; C0
|
||||||
|
; $UNIFORM_VARS[0].name = "ProjMtx"
|
||||||
|
; $UNIFORM_VARS[0].type = "mat4"
|
||||||
|
; $UNIFORM_VARS[0].count = 1
|
||||||
|
; $UNIFORM_VARS[0].block = -1
|
||||||
|
; $UNIFORM_VARS[0].offset = 0
|
||||||
|
|
||||||
|
; R1
|
||||||
|
; $ATTRIB_VARS[0].name = "Position"
|
||||||
|
; $ATTRIB_VARS[0].type = "vec2"
|
||||||
|
; $ATTRIB_VARS[0].location = 0
|
||||||
|
; R2
|
||||||
|
; $ATTRIB_VARS[1].name = "UV"
|
||||||
|
; $ATTRIB_VARS[1].type = "vec2"
|
||||||
|
; $ATTRIB_VARS[1].location = 1
|
||||||
|
; R3
|
||||||
|
; $ATTRIB_VARS[2].name = "Color"
|
||||||
|
; $ATTRIB_VARS[2].type = "vec4"
|
||||||
|
; $ATTRIB_VARS[2].location = 2
|
||||||
|
|
||||||
|
00 CALL_FS NO_BARRIER
|
||||||
|
01 ALU: ADDR(32) CNT(14)
|
||||||
|
0 x: MUL ____, 1.0f, C3.x
|
||||||
|
y: MUL ____, 1.0f, C3.y
|
||||||
|
z: MUL ____, 1.0f, C3.z
|
||||||
|
w: MUL ____, 1.0f, C3.w
|
||||||
|
1 x: MULADD R127.x, R1.y, C1.x, PV0.x
|
||||||
|
y: MULADD R127.y, R1.y, C1.y, PV0.y
|
||||||
|
z: MULADD R127.z, R1.y, C1.z, PV0.z
|
||||||
|
w: MULADD R127.w, R1.y, C1.w, PV0.w
|
||||||
|
2 x: MULADD R1.x, R1.x, C0.x, PV0.x
|
||||||
|
y: MULADD R1.y, R1.x, C0.y, PV0.y
|
||||||
|
z: MULADD R1.z, R1.x, C0.z, PV0.z
|
||||||
|
w: MULADD R1.w, R1.x, C0.w, PV0.w
|
||||||
|
02 EXP_DONE: POS0, R1
|
||||||
|
03 EXP: PARAM0, R2.xy00 NO_BARRIER
|
||||||
|
04 EXP_DONE: PARAM1, R3 NO_BARRIER
|
||||||
|
END_OF_PROGRAM
|
@ -761,7 +761,12 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
|
|
||||||
// Temporary buffer
|
// Temporary buffer
|
||||||
// The first <points_count> items are normals at each line point, then after that there are either 2 or 4 temp points for each line point
|
// The first <points_count> items are normals at each line point, then after that there are either 2 or 4 temp points for each line point
|
||||||
|
#ifdef __WIIU__
|
||||||
|
// avoid using alloca on the Wii U
|
||||||
|
ImVec2 temp_normals[points_count * ((use_texture || !thick_line) ? 3 : 5) * sizeof(ImVec2)]; //-V630
|
||||||
|
#else
|
||||||
ImVec2* temp_normals = (ImVec2*)alloca(points_count * ((use_texture || !thick_line) ? 3 : 5) * sizeof(ImVec2)); //-V630
|
ImVec2* temp_normals = (ImVec2*)alloca(points_count * ((use_texture || !thick_line) ? 3 : 5) * sizeof(ImVec2)); //-V630
|
||||||
|
#endif
|
||||||
ImVec2* temp_points = temp_normals + points_count;
|
ImVec2* temp_points = temp_normals + points_count;
|
||||||
|
|
||||||
// Calculate normals (tangents) for each line segment
|
// Calculate normals (tangents) for each line segment
|
||||||
@ -1009,7 +1014,12 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute normals
|
// Compute normals
|
||||||
|
#ifdef __WIIU__
|
||||||
|
// Avoid using alloca on the Wii U
|
||||||
|
ImVec2 temp_normals[points_count * sizeof(ImVec2)]; //-V630
|
||||||
|
#else
|
||||||
ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630
|
ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630
|
||||||
|
#endif
|
||||||
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
||||||
{
|
{
|
||||||
const ImVec2& p0 = points[i0];
|
const ImVec2& p0 = points[i0];
|
||||||
|
@ -111,6 +111,12 @@ void Mercury::reload() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::ifstream ifs(this->path_);
|
std::ifstream ifs(this->path_);
|
||||||
|
|
||||||
|
#ifdef __WIIU__
|
||||||
|
alignas(0x40) char buffer[8192];
|
||||||
|
ifs.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||||
|
#endif
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this->rjson = json::parse(ifs);
|
this->rjson = json::parse(ifs);
|
||||||
this->vjson = this->rjson.flatten();
|
this->vjson = this->rjson.flatten();
|
||||||
@ -122,5 +128,11 @@ void Mercury::reload() {
|
|||||||
|
|
||||||
void Mercury::save() const {
|
void Mercury::save() const {
|
||||||
std::ofstream file(this->path_);
|
std::ofstream file(this->path_);
|
||||||
|
|
||||||
|
#ifdef __WIIU__
|
||||||
|
alignas(0x40) char buffer[8192];
|
||||||
|
file.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||||
|
#endif
|
||||||
|
|
||||||
file << this->vjson.unflatten().dump(4);
|
file << this->vjson.unflatten().dump(4);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
Bugs are now managed in the SDL issue tracker, here:
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
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 the issue
|
|
||||||
tracker, as bugs discussed on the mailing list may be forgotten or missed.
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Simple DirectMedia Layer
|
|
||||||
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
|
|
||||||
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.
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
Please distribute this file with the SDL runtime environment:
|
|
||||||
|
|
||||||
The Simple DirectMedia Layer (SDL for short) is a cross-platform library
|
|
||||||
designed to make it easy to write multi-media software, such as games
|
|
||||||
and emulators.
|
|
||||||
|
|
||||||
The Simple DirectMedia Layer library source code is available from:
|
|
||||||
https://www.libsdl.org/
|
|
||||||
|
|
||||||
This library is distributed under the terms of the zlib license:
|
|
||||||
http://www.zlib.net/zlib_license.html
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
Simple DirectMedia Layer
|
|
||||||
|
|
||||||
(SDL)
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
---
|
|
||||||
https://www.libsdl.org/
|
|
||||||
|
|
||||||
Simple DirectMedia Layer is a cross-platform development library designed
|
|
||||||
to provide low level access to audio, keyboard, mouse, joystick, and graphics
|
|
||||||
hardware via OpenGL and Direct3D. It is used by video playback software,
|
|
||||||
emulators, and popular games including Valve's award winning catalog
|
|
||||||
and many Humble Bundle games.
|
|
||||||
|
|
||||||
More extensive documentation is available in the docs directory, starting
|
|
||||||
with README.md
|
|
||||||
|
|
||||||
Enjoy!
|
|
||||||
Sam Lantinga (slouken@libsdl.org)
|
|
@ -1,232 +0,0 @@
|
|||||||
/*
|
|
||||||
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.h
|
|
||||||
*
|
|
||||||
* Main include header for the SDL library
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SDL_h_
|
|
||||||
#define SDL_h_
|
|
||||||
|
|
||||||
#include "SDL_main.h"
|
|
||||||
#include "SDL_stdinc.h"
|
|
||||||
#include "SDL_assert.h"
|
|
||||||
#include "SDL_atomic.h"
|
|
||||||
#include "SDL_audio.h"
|
|
||||||
#include "SDL_clipboard.h"
|
|
||||||
#include "SDL_cpuinfo.h"
|
|
||||||
#include "SDL_endian.h"
|
|
||||||
#include "SDL_error.h"
|
|
||||||
#include "SDL_events.h"
|
|
||||||
#include "SDL_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"
|
|
||||||
#include "SDL_rwops.h"
|
|
||||||
#include "SDL_sensor.h"
|
|
||||||
#include "SDL_shape.h"
|
|
||||||
#include "SDL_system.h"
|
|
||||||
#include "SDL_thread.h"
|
|
||||||
#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++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* As of version 0.5, SDL is loaded dynamically into the application */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \name SDL_INIT_*
|
|
||||||
*
|
|
||||||
* These are the flags which may be passed to SDL_Init(). You should
|
|
||||||
* specify the subsystems which you will be using in your application.
|
|
||||||
*/
|
|
||||||
/* @{ */
|
|
||||||
#define SDL_INIT_TIMER 0x00000001u
|
|
||||||
#define SDL_INIT_AUDIO 0x00000010u
|
|
||||||
#define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
|
|
||||||
#define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
|
|
||||||
#define SDL_INIT_HAPTIC 0x00001000u
|
|
||||||
#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
|
|
||||||
#define SDL_INIT_EVENTS 0x00004000u
|
|
||||||
#define SDL_INIT_SENSOR 0x00008000u
|
|
||||||
#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
|
|
||||||
#define SDL_INIT_EVERYTHING ( \
|
|
||||||
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
|
|
||||||
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \
|
|
||||||
)
|
|
||||||
/* @} */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compatibility function to initialize the SDL library.
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a mask of the specified subsystems which are currently initialized.
|
|
||||||
*
|
|
||||||
* \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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#include "close_code.h"
|
|
||||||
|
|
||||||
#endif /* SDL_h_ */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,324 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_assert_h_
|
|
||||||
#define SDL_assert_h_
|
|
||||||
|
|
||||||
#include "SDL_config.h"
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
|
||||||
/* Set up for C function definitions, even when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SDL_ASSERT_LEVEL
|
|
||||||
#ifdef SDL_DEFAULT_ASSERT_LEVEL
|
|
||||||
#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
|
|
||||||
#elif defined(_DEBUG) || defined(DEBUG) || \
|
|
||||||
(defined(__GNUC__) && !defined(__OPTIMIZE__))
|
|
||||||
#define SDL_ASSERT_LEVEL 2
|
|
||||||
#else
|
|
||||||
#define SDL_ASSERT_LEVEL 1
|
|
||||||
#endif
|
|
||||||
#endif /* SDL_ASSERT_LEVEL */
|
|
||||||
|
|
||||||
/*
|
|
||||||
These are macros and not first class functions so that the debugger breaks
|
|
||||||
on the assertion line and not in some random guts of SDL, and so each
|
|
||||||
assert can have unique static variables associated with it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
/* Don't include intrin.h here because it contains C++ code */
|
|
||||||
extern void __cdecl __debugbreak(void);
|
|
||||||
#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__)
|
|
||||||
#include <signal.h>
|
|
||||||
#define SDL_TriggerBreakpoint() raise(SIGTRAP)
|
|
||||||
#else
|
|
||||||
/* How do we trigger breakpoints on this platform? */
|
|
||||||
#define SDL_TriggerBreakpoint()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
|
|
||||||
# define SDL_FUNCTION __func__
|
|
||||||
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
|
|
||||||
# define SDL_FUNCTION __FUNCTION__
|
|
||||||
#else
|
|
||||||
# define SDL_FUNCTION "???"
|
|
||||||
#endif
|
|
||||||
#define SDL_FILE __FILE__
|
|
||||||
#define SDL_LINE __LINE__
|
|
||||||
|
|
||||||
/*
|
|
||||||
sizeof (x) makes the compiler still parse the expression even without
|
|
||||||
assertions enabled, so the code is always checked at compile time, but
|
|
||||||
doesn't actually generate code for it, so there are no side effects or
|
|
||||||
expensive checks at run time, just the constant size of what x WOULD be,
|
|
||||||
which presumably gets optimized out as unused.
|
|
||||||
This also solves the problem of...
|
|
||||||
|
|
||||||
int somevalue = blah();
|
|
||||||
SDL_assert(somevalue == 1);
|
|
||||||
|
|
||||||
...which would cause compiles to complain that somevalue is unused if we
|
|
||||||
disable assertions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
|
|
||||||
this condition isn't constant. And looks like an owl's face! */
|
|
||||||
#ifdef _MSC_VER /* stupid /W4 warnings. */
|
|
||||||
#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
|
|
||||||
#else
|
|
||||||
#define SDL_NULL_WHILE_LOOP_CONDITION (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SDL_disabled_assert(condition) \
|
|
||||||
do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */
|
|
||||||
SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */
|
|
||||||
SDL_ASSERTION_ABORT, /**< Terminate the program. */
|
|
||||||
SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
|
|
||||||
SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */
|
|
||||||
} SDL_AssertState;
|
|
||||||
|
|
||||||
typedef struct SDL_AssertData
|
|
||||||
{
|
|
||||||
int always_ignore;
|
|
||||||
unsigned int trigger_count;
|
|
||||||
const char *condition;
|
|
||||||
const char *filename;
|
|
||||||
int linenum;
|
|
||||||
const char *function;
|
|
||||||
const struct SDL_AssertData *next;
|
|
||||||
} SDL_AssertData;
|
|
||||||
|
|
||||||
#if (SDL_ASSERT_LEVEL > 0)
|
|
||||||
|
|
||||||
/* Never call this directly. Use the SDL_assert* macros. */
|
|
||||||
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
|
|
||||||
const char *,
|
|
||||||
const char *, int)
|
|
||||||
#if defined(__clang__)
|
|
||||||
#if __has_feature(attribute_analyzer_noreturn)
|
|
||||||
/* this tells Clang's static analysis that we're a custom assert function,
|
|
||||||
and that the analyzer should assume the condition was always true past this
|
|
||||||
SDL_assert test. */
|
|
||||||
__attribute__((analyzer_noreturn))
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
/* the do {} while(0) avoids dangling else problems:
|
|
||||||
if (x) SDL_assert(y); else blah();
|
|
||||||
... without the do/while, the "else" could attach to this macro's "if".
|
|
||||||
We try to handle just the minimum we need here in a macro...the loop,
|
|
||||||
the static vars, and break points. The heavy lifting is handled in
|
|
||||||
SDL_ReportAssertion(), in SDL_assert.c.
|
|
||||||
*/
|
|
||||||
#define SDL_enabled_assert(condition) \
|
|
||||||
do { \
|
|
||||||
while ( !(condition) ) { \
|
|
||||||
static struct SDL_AssertData sdl_assert_data = { \
|
|
||||||
0, 0, #condition, 0, 0, 0, 0 \
|
|
||||||
}; \
|
|
||||||
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
|
|
||||||
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
|
|
||||||
continue; /* go again. */ \
|
|
||||||
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
|
|
||||||
SDL_TriggerBreakpoint(); \
|
|
||||||
} \
|
|
||||||
break; /* not retrying. */ \
|
|
||||||
} \
|
|
||||||
} while (SDL_NULL_WHILE_LOOP_CONDITION)
|
|
||||||
|
|
||||||
#endif /* enabled assertions support code */
|
|
||||||
|
|
||||||
/* Enable various levels of assertions. */
|
|
||||||
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
|
|
||||||
# define SDL_assert(condition) SDL_disabled_assert(condition)
|
|
||||||
# define SDL_assert_release(condition) SDL_disabled_assert(condition)
|
|
||||||
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
|
|
||||||
#elif SDL_ASSERT_LEVEL == 1 /* release settings. */
|
|
||||||
# define SDL_assert(condition) SDL_disabled_assert(condition)
|
|
||||||
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
|
|
||||||
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
|
|
||||||
#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */
|
|
||||||
# define SDL_assert(condition) SDL_enabled_assert(condition)
|
|
||||||
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
|
|
||||||
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
|
|
||||||
#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */
|
|
||||||
# define SDL_assert(condition) SDL_enabled_assert(condition)
|
|
||||||
# define SDL_assert_release(condition) SDL_enabled_assert(condition)
|
|
||||||
# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
|
|
||||||
#else
|
|
||||||
# error Unknown assertion level.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* this assertion is never disabled at any level. */
|
|
||||||
#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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set an application-defined assertion handler.
|
|
||||||
*
|
|
||||||
* 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 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`
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 2.0.0.
|
|
||||||
*
|
|
||||||
* \sa SDL_GetAssertionHandler
|
|
||||||
*/
|
|
||||||
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
|
|
||||||
SDL_AssertionHandler handler,
|
|
||||||
void *userdata);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* \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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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().
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all assertion failures.
|
|
||||||
*
|
|
||||||
* 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:
|
|
||||||
*
|
|
||||||
* ```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;
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* \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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the list of all assertion failures.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 2.0.0.
|
|
||||||
*
|
|
||||||
* \sa SDL_GetAssertionReport
|
|
||||||
*/
|
|
||||||
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
|
|
||||||
|
|
||||||
|
|
||||||
/* these had wrong naming conventions until 2.0.4. Please update your app! */
|
|
||||||
#define SDL_assert_state SDL_AssertState
|
|
||||||
#define SDL_assert_data SDL_AssertData
|
|
||||||
|
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#include "close_code.h"
|
|
||||||
|
|
||||||
#endif /* SDL_assert_h_ */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,395 +0,0 @@
|
|||||||
/*
|
|
||||||
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_atomic.h
|
|
||||||
*
|
|
||||||
* Atomic operations.
|
|
||||||
*
|
|
||||||
* IMPORTANT:
|
|
||||||
* If you are not an expert in concurrent lockless programming, you should
|
|
||||||
* only be using the atomic lock and reference counting functions in this
|
|
||||||
* file. In all other cases you should be protecting your data structures
|
|
||||||
* with full mutexes.
|
|
||||||
*
|
|
||||||
* The list of "safe" functions to use are:
|
|
||||||
* SDL_AtomicLock()
|
|
||||||
* SDL_AtomicUnlock()
|
|
||||||
* SDL_AtomicIncRef()
|
|
||||||
* SDL_AtomicDecRef()
|
|
||||||
*
|
|
||||||
* Seriously, here be dragons!
|
|
||||||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
*
|
|
||||||
* You can find out a little more about lockless programming and the
|
|
||||||
* subtle issues that can arise here:
|
|
||||||
* http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
|
|
||||||
*
|
|
||||||
* There's also lots of good information here:
|
|
||||||
* http://www.1024cores.net/home/lock-free-algorithms
|
|
||||||
* http://preshing.com/
|
|
||||||
*
|
|
||||||
* These operations may or may not actually be implemented using
|
|
||||||
* processor specific atomic operations. When possible they are
|
|
||||||
* implemented as true processor specific atomic operations. When that
|
|
||||||
* is not possible the are implemented using locks that *do* use the
|
|
||||||
* available atomic operations.
|
|
||||||
*
|
|
||||||
* All of the atomic operations that modify memory are full memory barriers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_atomic_h_
|
|
||||||
#define SDL_atomic_h_
|
|
||||||
|
|
||||||
#include "SDL_stdinc.h"
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
|
||||||
|
|
||||||
/* Set up for C function definitions, even when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \name SDL AtomicLock
|
|
||||||
*
|
|
||||||
* The atomic locks are efficient spinlocks using CPU instructions,
|
|
||||||
* but are vulnerable to starvation and can spin forever if a thread
|
|
||||||
* holding a lock has been terminated. For this reason you should
|
|
||||||
* minimize the code executed inside an atomic lock and never do
|
|
||||||
* expensive things like API or system calls while holding them.
|
|
||||||
*
|
|
||||||
* The atomic locks are not safe to lock recursively.
|
|
||||||
*
|
|
||||||
* Porting Note:
|
|
||||||
* The spin lock functions and type are required and can not be
|
|
||||||
* emulated because they are used in the atomic emulation code.
|
|
||||||
*/
|
|
||||||
/* @{ */
|
|
||||||
|
|
||||||
typedef int SDL_SpinLock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to lock a spin lock by setting it to a non-zero value.
|
|
||||||
*
|
|
||||||
* ***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
|
|
||||||
* \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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lock a spin lock by setting it to a non-zero value.
|
|
||||||
*
|
|
||||||
* ***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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unlock a spin lock by setting it to 0.
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/* @} *//* SDL AtomicLock */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The compiler barrier prevents the compiler from reordering
|
|
||||||
* reads and writes to globally visible variables across the call.
|
|
||||||
*/
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
|
|
||||||
void _ReadWriteBarrier(void);
|
|
||||||
#pragma intrinsic(_ReadWriteBarrier)
|
|
||||||
#define SDL_CompilerBarrier() _ReadWriteBarrier()
|
|
||||||
#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
|
|
||||||
/* 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);
|
|
||||||
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
|
|
||||||
#else
|
|
||||||
#define SDL_CompilerBarrier() \
|
|
||||||
{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
|
||||||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory")
|
|
||||||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory")
|
|
||||||
#elif defined(__GNUC__) && defined(__aarch64__)
|
|
||||||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
|
|
||||||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
|
|
||||||
#elif defined(__GNUC__) && defined(__arm__)
|
|
||||||
#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */
|
|
||||||
/* Information from:
|
|
||||||
https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19
|
|
||||||
|
|
||||||
The Linux kernel provides a helper function which provides the right code for a memory barrier,
|
|
||||||
hard-coded at address 0xffff0fa0
|
|
||||||
*/
|
|
||||||
typedef void (*SDL_KernelMemoryBarrierFunc)();
|
|
||||||
#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)()
|
|
||||||
#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)()
|
|
||||||
#elif 0 /* defined(__QNXNTO__) */
|
|
||||||
#include <sys/cpuinline.h>
|
|
||||||
|
|
||||||
#define SDL_MemoryBarrierRelease() __cpu_membarrier()
|
|
||||||
#define SDL_MemoryBarrierAcquire() __cpu_membarrier()
|
|
||||||
#else
|
|
||||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__)
|
|
||||||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
|
|
||||||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
|
|
||||||
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__)
|
|
||||||
#ifdef __thumb__
|
|
||||||
/* The mcr instruction isn't available in thumb mode, use real functions */
|
|
||||||
#define SDL_MEMORY_BARRIER_USES_FUNCTION
|
|
||||||
#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction()
|
|
||||||
#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction()
|
|
||||||
#else
|
|
||||||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
|
|
||||||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
|
|
||||||
#endif /* __thumb__ */
|
|
||||||
#else
|
|
||||||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory")
|
|
||||||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory")
|
|
||||||
#endif /* __LINUX__ || __ANDROID__ */
|
|
||||||
#endif /* __GNUC__ && __arm__ */
|
|
||||||
#else
|
|
||||||
#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
|
|
||||||
/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */
|
|
||||||
#include <mbarrier.h>
|
|
||||||
#define SDL_MemoryBarrierRelease() __machine_rel_barrier()
|
|
||||||
#define SDL_MemoryBarrierAcquire() __machine_acq_barrier()
|
|
||||||
#else
|
|
||||||
/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */
|
|
||||||
#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier()
|
|
||||||
#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief A type representing an atomic integer value. It is a struct
|
|
||||||
* so people don't accidentally use numeric operations on it.
|
|
||||||
*/
|
|
||||||
typedef struct { int value; } SDL_atomic_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set an atomic variable to a new value if it is currently an old value.
|
|
||||||
*
|
|
||||||
* ***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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set an atomic variable to a value.
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add to an 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 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Increment an atomic variable used as a reference count.
|
|
||||||
*/
|
|
||||||
#ifndef SDL_AtomicIncRef
|
|
||||||
#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Decrement an atomic variable used as a reference count.
|
|
||||||
*
|
|
||||||
* \return SDL_TRUE if the variable reached zero after decrementing,
|
|
||||||
* SDL_FALSE otherwise
|
|
||||||
*/
|
|
||||||
#ifndef SDL_AtomicDecRef
|
|
||||||
#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a pointer to a new value if it is currently an old value.
|
|
||||||
*
|
|
||||||
* ***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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a pointer to a value atomically.
|
|
||||||
*
|
|
||||||
* ***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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "close_code.h"
|
|
||||||
|
|
||||||
#endif /* SDL_atomic_h_ */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
File diff suppressed because it is too large
Load Diff
@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
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_bits.h
|
|
||||||
*
|
|
||||||
* Functions for fiddling with bits and bitmasks.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_bits_h_
|
|
||||||
#define SDL_bits_h_
|
|
||||||
|
|
||||||
#include "SDL_stdinc.h"
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
|
||||||
/* Set up for C function definitions, even when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_bits.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the index of the most significant bit. Result is undefined when called
|
|
||||||
* with 0. This operation can also be stated as "count leading zeroes" and
|
|
||||||
* "log base 2".
|
|
||||||
*
|
|
||||||
* \return the index of the most significant bit, or -1 if the value is 0.
|
|
||||||
*/
|
|
||||||
#if defined(__WATCOMC__) && defined(__386__)
|
|
||||||
extern __inline int _SDL_bsr_watcom(Uint32);
|
|
||||||
#pragma aux _SDL_bsr_watcom = \
|
|
||||||
"bsr eax, eax" \
|
|
||||||
parm [eax] nomemory \
|
|
||||||
value [eax] \
|
|
||||||
modify exact [eax] nomemory;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_FORCE_INLINE int
|
|
||||||
SDL_MostSignificantBitIndex32(Uint32 x)
|
|
||||||
{
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
|
||||||
/* Count Leading Zeroes builtin in GCC.
|
|
||||||
* http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
|
|
||||||
*/
|
|
||||||
if (x == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 31 - __builtin_clz(x);
|
|
||||||
#elif defined(__WATCOMC__) && defined(__386__)
|
|
||||||
if (x == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
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.
|
|
||||||
* http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
|
|
||||||
*/
|
|
||||||
const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
|
|
||||||
const int S[] = {1, 2, 4, 8, 16};
|
|
||||||
|
|
||||||
int msbIndex = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (x == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 4; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (x & b[i])
|
|
||||||
{
|
|
||||||
x >>= S[i];
|
|
||||||
msbIndex |= S[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return msbIndex;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_FORCE_INLINE SDL_bool
|
|
||||||
SDL_HasExactlyOneBitSet32(Uint32 x)
|
|
||||||
{
|
|
||||||
if (x && !(x & (x - 1))) {
|
|
||||||
return SDL_TRUE;
|
|
||||||
}
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#include "close_code.h"
|
|
||||||
|
|
||||||
#endif /* SDL_bits_h_ */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,200 +0,0 @@
|
|||||||
/*
|
|
||||||
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_blendmode.h
|
|
||||||
*
|
|
||||||
* Header file declaring the SDL_BlendMode enumeration
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_blendmode_h_
|
|
||||||
#define SDL_blendmode_h_
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
|
||||||
/* Set up for C function definitions, even when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
|
|
||||||
dstRGBA = srcRGBA */
|
|
||||||
SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending
|
|
||||||
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
|
|
||||||
dstA = srcA + (dstA * (1-srcA)) */
|
|
||||||
SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending
|
|
||||||
dstRGB = (srcRGB * srcA) + dstRGB
|
|
||||||
dstA = dstA */
|
|
||||||
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() */
|
|
||||||
|
|
||||||
} SDL_BlendMode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The blend operation used when combining source and destination pixel components
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
|
|
||||||
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
|
|
||||||
SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
|
|
||||||
SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */
|
|
||||||
SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */
|
|
||||||
|
|
||||||
} SDL_BlendOperation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The normalized factor used to multiply pixel components
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */
|
|
||||||
SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */
|
|
||||||
SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */
|
|
||||||
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */
|
|
||||||
SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */
|
|
||||||
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */
|
|
||||||
SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */
|
|
||||||
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
|
|
||||||
SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */
|
|
||||||
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
|
|
||||||
|
|
||||||
} SDL_BlendFactor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compose a custom blend mode for renderers.
|
|
||||||
*
|
|
||||||
* The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept
|
|
||||||
* the SDL_BlendMode returned by this function if the renderer supports it.
|
|
||||||
*
|
|
||||||
* 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,
|
|
||||||
SDL_BlendOperation colorOperation,
|
|
||||||
SDL_BlendFactor srcAlphaFactor,
|
|
||||||
SDL_BlendFactor dstAlphaFactor,
|
|
||||||
SDL_BlendOperation alphaOperation);
|
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#include "close_code.h"
|
|
||||||
|
|
||||||
#endif /* SDL_blendmode_h_ */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
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_clipboard.h
|
|
||||||
*
|
|
||||||
* Include file for SDL clipboard handling
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_clipboard_h_
|
|
||||||
#define SDL_clipboard_h_
|
|
||||||
|
|
||||||
#include "SDL_stdinc.h"
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
|
||||||
/* Set up for C function definitions, even when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Function prototypes */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Put UTF-8 text into the clipboard.
|
|
||||||
*
|
|
||||||
* \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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get UTF-8 text from the clipboard, which must be freed with SDL_free().
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query whether the clipboard exists and contains a non-empty text string.
|
|
||||||
*
|
|
||||||
* \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);
|
|
||||||
|
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#include "close_code.h"
|
|
||||||
|
|
||||||
#endif /* SDL_clipboard_h_ */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_config.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Add any platform that doesn't build using the configure system. */
|
|
||||||
#if defined(__WIN32__)
|
|
||||||
#include "SDL_config_windows.h"
|
|
||||||
#elif defined(__WINRT__)
|
|
||||||
#include "SDL_config_winrt.h"
|
|
||||||
#elif defined(__MACOSX__)
|
|
||||||
#include "SDL_config_macosx.h"
|
|
||||||
#elif defined(__IPHONEOS__)
|
|
||||||
#include "SDL_config_iphoneos.h"
|
|
||||||
#elif defined(__ANDROID__)
|
|
||||||
#include "SDL_config_android.h"
|
|
||||||
#elif defined(__PSP__)
|
|
||||||
#include "SDL_config_psp.h"
|
|
||||||
#elif defined(__OS2__)
|
|
||||||
#include "SDL_config_os2.h"
|
|
||||||
#elif defined(__EMSCRIPTEN__)
|
|
||||||
#include "SDL_config_emscripten.h"
|
|
||||||
#else
|
|
||||||
/* This is a minimal configuration just to get SDL running on new platforms. */
|
|
||||||
#include "SDL_config_minimal.h"
|
|
||||||
#endif /* platform config */
|
|
||||||
|
|
||||||
#ifdef USING_GENERATED_CONFIG_H
|
|
||||||
#error Wrong SDL_config.h, check your include path?
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* SDL_config_h_ */
|
|
@ -1,575 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_config.h.in
|
|
||||||
*
|
|
||||||
* This is a set of defines to configure the SDL features
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* General platform specific identifiers */
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/* C language features */
|
|
||||||
#cmakedefine const @HAVE_CONST@
|
|
||||||
#cmakedefine inline @HAVE_INLINE@
|
|
||||||
#cmakedefine volatile @HAVE_VOLATILE@
|
|
||||||
|
|
||||||
/* C datatypes */
|
|
||||||
/* Define SIZEOF_VOIDP for 64/32 architectures */
|
|
||||||
#if defined(__LP64__) || defined(_LP64) || defined(_WIN64)
|
|
||||||
#define SIZEOF_VOIDP 8
|
|
||||||
#else
|
|
||||||
#define SIZEOF_VOIDP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@
|
|
||||||
#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@
|
|
||||||
|
|
||||||
/* Comment this if you want to build without any C library requirements */
|
|
||||||
#cmakedefine HAVE_LIBC 1
|
|
||||||
#if HAVE_LIBC
|
|
||||||
|
|
||||||
/* Useful headers */
|
|
||||||
#cmakedefine STDC_HEADERS 1
|
|
||||||
#cmakedefine HAVE_ALLOCA_H 1
|
|
||||||
#cmakedefine HAVE_CTYPE_H 1
|
|
||||||
#cmakedefine HAVE_FLOAT_H 1
|
|
||||||
#cmakedefine HAVE_ICONV_H 1
|
|
||||||
#cmakedefine HAVE_INTTYPES_H 1
|
|
||||||
#cmakedefine HAVE_LIMITS_H 1
|
|
||||||
#cmakedefine HAVE_MALLOC_H 1
|
|
||||||
#cmakedefine HAVE_MATH_H 1
|
|
||||||
#cmakedefine HAVE_MEMORY_H 1
|
|
||||||
#cmakedefine HAVE_SIGNAL_H 1
|
|
||||||
#cmakedefine HAVE_STDARG_H 1
|
|
||||||
#cmakedefine HAVE_STDINT_H 1
|
|
||||||
#cmakedefine HAVE_STDIO_H 1
|
|
||||||
#cmakedefine HAVE_STDLIB_H 1
|
|
||||||
#cmakedefine HAVE_STRINGS_H 1
|
|
||||||
#cmakedefine HAVE_STRING_H 1
|
|
||||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
|
||||||
#cmakedefine HAVE_WCHAR_H 1
|
|
||||||
#cmakedefine HAVE_PTHREAD_NP_H 1
|
|
||||||
#cmakedefine HAVE_LIBUNWIND_H 1
|
|
||||||
|
|
||||||
/* C library functions */
|
|
||||||
#cmakedefine HAVE_DLOPEN 1
|
|
||||||
#cmakedefine HAVE_MALLOC 1
|
|
||||||
#cmakedefine HAVE_CALLOC 1
|
|
||||||
#cmakedefine HAVE_REALLOC 1
|
|
||||||
#cmakedefine HAVE_FREE 1
|
|
||||||
#cmakedefine HAVE_ALLOCA 1
|
|
||||||
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
|
|
||||||
#cmakedefine HAVE_GETENV 1
|
|
||||||
#cmakedefine HAVE_SETENV 1
|
|
||||||
#cmakedefine HAVE_PUTENV 1
|
|
||||||
#cmakedefine HAVE_UNSETENV 1
|
|
||||||
#endif
|
|
||||||
#cmakedefine HAVE_QSORT 1
|
|
||||||
#cmakedefine HAVE_ABS 1
|
|
||||||
#cmakedefine HAVE_BCOPY 1
|
|
||||||
#cmakedefine HAVE_MEMSET 1
|
|
||||||
#cmakedefine HAVE_MEMCPY 1
|
|
||||||
#cmakedefine HAVE_MEMMOVE 1
|
|
||||||
#cmakedefine HAVE_MEMCMP 1
|
|
||||||
#cmakedefine HAVE_WCSLEN 1
|
|
||||||
#cmakedefine HAVE_WCSLCPY 1
|
|
||||||
#cmakedefine HAVE_WCSLCAT 1
|
|
||||||
#cmakedefine HAVE__WCSDUP 1
|
|
||||||
#cmakedefine HAVE_WCSDUP 1
|
|
||||||
#cmakedefine HAVE_WCSSTR 1
|
|
||||||
#cmakedefine HAVE_WCSCMP 1
|
|
||||||
#cmakedefine HAVE_WCSNCMP 1
|
|
||||||
#cmakedefine HAVE_WCSCASECMP 1
|
|
||||||
#cmakedefine HAVE__WCSICMP 1
|
|
||||||
#cmakedefine HAVE_WCSNCASECMP 1
|
|
||||||
#cmakedefine HAVE__WCSNICMP 1
|
|
||||||
#cmakedefine HAVE_STRLEN 1
|
|
||||||
#cmakedefine HAVE_STRLCPY 1
|
|
||||||
#cmakedefine HAVE_STRLCAT 1
|
|
||||||
#cmakedefine HAVE__STRREV 1
|
|
||||||
#cmakedefine HAVE__STRUPR 1
|
|
||||||
#cmakedefine HAVE__STRLWR 1
|
|
||||||
#cmakedefine HAVE_INDEX 1
|
|
||||||
#cmakedefine HAVE_RINDEX 1
|
|
||||||
#cmakedefine HAVE_STRCHR 1
|
|
||||||
#cmakedefine HAVE_STRRCHR 1
|
|
||||||
#cmakedefine HAVE_STRSTR 1
|
|
||||||
#cmakedefine HAVE_STRTOK_R 1
|
|
||||||
#cmakedefine HAVE_ITOA 1
|
|
||||||
#cmakedefine HAVE__LTOA 1
|
|
||||||
#cmakedefine HAVE__UITOA 1
|
|
||||||
#cmakedefine HAVE__ULTOA 1
|
|
||||||
#cmakedefine HAVE_STRTOL 1
|
|
||||||
#cmakedefine HAVE_STRTOUL 1
|
|
||||||
#cmakedefine HAVE__I64TOA 1
|
|
||||||
#cmakedefine HAVE__UI64TOA 1
|
|
||||||
#cmakedefine HAVE_STRTOLL 1
|
|
||||||
#cmakedefine HAVE_STRTOULL 1
|
|
||||||
#cmakedefine HAVE_STRTOD 1
|
|
||||||
#cmakedefine HAVE_ATOI 1
|
|
||||||
#cmakedefine HAVE_ATOF 1
|
|
||||||
#cmakedefine HAVE_STRCMP 1
|
|
||||||
#cmakedefine HAVE_STRNCMP 1
|
|
||||||
#cmakedefine HAVE__STRICMP 1
|
|
||||||
#cmakedefine HAVE_STRCASECMP 1
|
|
||||||
#cmakedefine HAVE__STRNICMP 1
|
|
||||||
#cmakedefine HAVE_STRNCASECMP 1
|
|
||||||
#cmakedefine HAVE_SSCANF 1
|
|
||||||
#cmakedefine HAVE_VSSCANF 1
|
|
||||||
#cmakedefine HAVE_VSNPRINTF 1
|
|
||||||
#cmakedefine HAVE_M_PI 1
|
|
||||||
#cmakedefine HAVE_ACOS 1
|
|
||||||
#cmakedefine HAVE_ACOSF 1
|
|
||||||
#cmakedefine HAVE_ASIN 1
|
|
||||||
#cmakedefine HAVE_ASINF 1
|
|
||||||
#cmakedefine HAVE_ATAN 1
|
|
||||||
#cmakedefine HAVE_ATANF 1
|
|
||||||
#cmakedefine HAVE_ATAN2 1
|
|
||||||
#cmakedefine HAVE_ATAN2F 1
|
|
||||||
#cmakedefine HAVE_CEIL 1
|
|
||||||
#cmakedefine HAVE_CEILF 1
|
|
||||||
#cmakedefine HAVE_COPYSIGN 1
|
|
||||||
#cmakedefine HAVE_COPYSIGNF 1
|
|
||||||
#cmakedefine HAVE_COS 1
|
|
||||||
#cmakedefine HAVE_COSF 1
|
|
||||||
#cmakedefine HAVE_EXP 1
|
|
||||||
#cmakedefine HAVE_EXPF 1
|
|
||||||
#cmakedefine HAVE_FABS 1
|
|
||||||
#cmakedefine HAVE_FABSF 1
|
|
||||||
#cmakedefine HAVE_FLOOR 1
|
|
||||||
#cmakedefine HAVE_FLOORF 1
|
|
||||||
#cmakedefine HAVE_FMOD 1
|
|
||||||
#cmakedefine HAVE_FMODF 1
|
|
||||||
#cmakedefine HAVE_LOG 1
|
|
||||||
#cmakedefine HAVE_LOGF 1
|
|
||||||
#cmakedefine HAVE_LOG10 1
|
|
||||||
#cmakedefine HAVE_LOG10F 1
|
|
||||||
#cmakedefine HAVE_LROUND 1
|
|
||||||
#cmakedefine HAVE_LROUNDF 1
|
|
||||||
#cmakedefine HAVE_POW 1
|
|
||||||
#cmakedefine HAVE_POWF 1
|
|
||||||
#cmakedefine HAVE_ROUND 1
|
|
||||||
#cmakedefine HAVE_ROUNDF 1
|
|
||||||
#cmakedefine HAVE_SCALBN 1
|
|
||||||
#cmakedefine HAVE_SCALBNF 1
|
|
||||||
#cmakedefine HAVE_SIN 1
|
|
||||||
#cmakedefine HAVE_SINF 1
|
|
||||||
#cmakedefine HAVE_SQRT 1
|
|
||||||
#cmakedefine HAVE_SQRTF 1
|
|
||||||
#cmakedefine HAVE_TAN 1
|
|
||||||
#cmakedefine HAVE_TANF 1
|
|
||||||
#cmakedefine HAVE_TRUNC 1
|
|
||||||
#cmakedefine HAVE_TRUNCF 1
|
|
||||||
#cmakedefine HAVE_FOPEN64 1
|
|
||||||
#cmakedefine HAVE_FSEEKO 1
|
|
||||||
#cmakedefine HAVE_FSEEKO64 1
|
|
||||||
#cmakedefine HAVE_SIGACTION 1
|
|
||||||
#cmakedefine HAVE_SA_SIGACTION 1
|
|
||||||
#cmakedefine HAVE_SETJMP 1
|
|
||||||
#cmakedefine HAVE_NANOSLEEP 1
|
|
||||||
#cmakedefine HAVE_SYSCONF 1
|
|
||||||
#cmakedefine HAVE_SYSCTLBYNAME 1
|
|
||||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
|
||||||
#cmakedefine HAVE_GETPAGESIZE 1
|
|
||||||
#cmakedefine HAVE_MPROTECT 1
|
|
||||||
#cmakedefine HAVE_ICONV 1
|
|
||||||
#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
|
|
||||||
#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1
|
|
||||||
#cmakedefine HAVE_SEM_TIMEDWAIT 1
|
|
||||||
#cmakedefine HAVE_GETAUXVAL 1
|
|
||||||
#cmakedefine HAVE_ELF_AUX_INFO 1
|
|
||||||
#cmakedefine HAVE_POLL 1
|
|
||||||
#cmakedefine HAVE__EXIT 1
|
|
||||||
|
|
||||||
#elif defined(__WIN32__)
|
|
||||||
#cmakedefine HAVE_STDARG_H 1
|
|
||||||
#cmakedefine HAVE_STDDEF_H 1
|
|
||||||
#cmakedefine HAVE_FLOAT_H 1
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* We may need some replacement for stdarg.h here */
|
|
||||||
#include <stdarg.h>
|
|
||||||
#endif /* HAVE_LIBC */
|
|
||||||
|
|
||||||
#cmakedefine HAVE_ALTIVEC_H 1
|
|
||||||
#cmakedefine HAVE_DBUS_DBUS_H 1
|
|
||||||
#cmakedefine HAVE_FCITX 1
|
|
||||||
#cmakedefine HAVE_IBUS_IBUS_H 1
|
|
||||||
#cmakedefine HAVE_SYS_INOTIFY_H 1
|
|
||||||
#cmakedefine HAVE_INOTIFY_INIT 1
|
|
||||||
#cmakedefine HAVE_INOTIFY_INIT1 1
|
|
||||||
#cmakedefine HAVE_INOTIFY 1
|
|
||||||
#cmakedefine HAVE_O_CLOEXEC 1
|
|
||||||
|
|
||||||
/* Apple platforms might be building universal binaries, where Intel builds
|
|
||||||
can use immintrin.h but other architectures can't. */
|
|
||||||
#ifdef __APPLE__
|
|
||||||
# if defined(__has_include) && (defined(__i386__) || defined(__x86_64))
|
|
||||||
# if __has_include(<immintrin.h>)
|
|
||||||
# define HAVE_IMMINTRIN_H 1
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#else /* non-Apple platforms can use the normal CMake check for this. */
|
|
||||||
#cmakedefine HAVE_IMMINTRIN_H 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#cmakedefine HAVE_LIBUDEV_H 1
|
|
||||||
#cmakedefine HAVE_LIBSAMPLERATE_H 1
|
|
||||||
#cmakedefine HAVE_LIBDECOR_H 1
|
|
||||||
|
|
||||||
#cmakedefine HAVE_D3D_H @HAVE_D3D_H@
|
|
||||||
#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
|
|
||||||
#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@
|
|
||||||
#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@
|
|
||||||
#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@
|
|
||||||
#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@
|
|
||||||
#cmakedefine HAVE_WINDOWS_GAMING_INPUT_H @HAVE_WINDOWS_GAMING_INPUT_H@
|
|
||||||
#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@
|
|
||||||
|
|
||||||
#cmakedefine HAVE_MMDEVICEAPI_H @HAVE_MMDEVICEAPI_H@
|
|
||||||
#cmakedefine HAVE_AUDIOCLIENT_H @HAVE_AUDIOCLIENT_H@
|
|
||||||
#cmakedefine HAVE_TPCSHRD_H @HAVE_TPCSHRD_H@
|
|
||||||
#cmakedefine HAVE_SENSORSAPI_H @HAVE_SENSORSAPI_H@
|
|
||||||
|
|
||||||
#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@
|
|
||||||
#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@
|
|
||||||
|
|
||||||
/* SDL internal assertion support */
|
|
||||||
#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@
|
|
||||||
|
|
||||||
/* Allow disabling of core subsystems */
|
|
||||||
#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@
|
|
||||||
#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
|
|
||||||
#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@
|
|
||||||
#cmakedefine SDL_EVENTS_DISABLED @SDL_EVENTS_DISABLED@
|
|
||||||
#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@
|
|
||||||
#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
|
|
||||||
#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@
|
|
||||||
#cmakedefine SDL_HIDAPI_DISABLED @SDL_HIDAPI_DISABLED@
|
|
||||||
#cmakedefine SDL_SENSOR_DISABLED @SDL_SENSOR_DISABLED@
|
|
||||||
#cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@
|
|
||||||
#cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@
|
|
||||||
#cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@
|
|
||||||
#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@
|
|
||||||
#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
|
|
||||||
#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@
|
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ANDROID @SDL_AUDIO_DRIVER_ANDROID@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_OPENSLES @SDL_AUDIO_DRIVER_OPENSLES@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_AAUDIO @SDL_AUDIO_DRIVER_AAUDIO@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_DSOUND @SDL_AUDIO_DRIVER_DSOUND@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_DUMMY @SDL_AUDIO_DRIVER_DUMMY@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_EMSCRIPTEN @SDL_AUDIO_DRIVER_EMSCRIPTEN@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ESD @SDL_AUDIO_DRIVER_ESD@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_HAIKU @SDL_AUDIO_DRIVER_HAIKU@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_JACK @SDL_AUDIO_DRIVER_JACK@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_JACK_DYNAMIC @SDL_AUDIO_DRIVER_JACK_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_NETBSD @SDL_AUDIO_DRIVER_NETBSD@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_PIPEWIRE @SDL_AUDIO_DRIVER_PIPEWIRE@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC @SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_SNDIO @SDL_AUDIO_DRIVER_SNDIO@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_SNDIO_DYNAMIC @SDL_AUDIO_DRIVER_SNDIO_DYNAMIC@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_WASAPI @SDL_AUDIO_DRIVER_WASAPI@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_OS2 @SDL_AUDIO_DRIVER_OS2@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_VITA @SDL_AUDIO_DRIVER_VITA@
|
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_PSP @SDL_AUDIO_DRIVER_PSP@
|
|
||||||
|
|
||||||
/* Enable various input drivers */
|
|
||||||
#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
|
|
||||||
#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@
|
|
||||||
#cmakedefine SDL_INPUT_FBSDKBIO @SDL_INPUT_FBSDKBIO@
|
|
||||||
#cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@
|
|
||||||
#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
|
|
||||||
#cmakedefine SDL_JOYSTICK_WGI @SDL_JOYSTICK_WGI@
|
|
||||||
#cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@
|
|
||||||
#cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@
|
|
||||||
#cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
|
|
||||||
#cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
|
|
||||||
#cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@
|
|
||||||
#cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
|
|
||||||
#cmakedefine SDL_JOYSTICK_OS2 @SDL_JOYSTICK_OS2@
|
|
||||||
#cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@
|
|
||||||
#cmakedefine SDL_HAVE_MACHINE_JOYSTICK_H @SDL_HAVE_MACHINE_JOYSTICK_H@
|
|
||||||
#cmakedefine SDL_JOYSTICK_HIDAPI @SDL_JOYSTICK_HIDAPI@
|
|
||||||
#cmakedefine SDL_JOYSTICK_RAWINPUT @SDL_JOYSTICK_RAWINPUT@
|
|
||||||
#cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@
|
|
||||||
#cmakedefine SDL_JOYSTICK_VIRTUAL @SDL_JOYSTICK_VIRTUAL@
|
|
||||||
#cmakedefine SDL_JOYSTICK_VITA @SDL_JOYSTICK_VITA@
|
|
||||||
#cmakedefine SDL_JOYSTICK_PSP @SDL_JOYSTICK_PSP@
|
|
||||||
#cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@
|
|
||||||
#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@
|
|
||||||
#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@
|
|
||||||
#cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@
|
|
||||||
#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@
|
|
||||||
#cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@
|
|
||||||
#cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@
|
|
||||||
|
|
||||||
/* Enable various sensor drivers */
|
|
||||||
#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@
|
|
||||||
#cmakedefine SDL_SENSOR_COREMOTION @SDL_SENSOR_COREMOTION@
|
|
||||||
#cmakedefine SDL_SENSOR_WINDOWS @SDL_SENSOR_WINDOWS@
|
|
||||||
#cmakedefine SDL_SENSOR_DUMMY @SDL_SENSOR_DUMMY@
|
|
||||||
#cmakedefine SDL_SENSOR_VITA @SDL_SENSOR_VITA@
|
|
||||||
|
|
||||||
/* Enable various shared object loading systems */
|
|
||||||
#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@
|
|
||||||
#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@
|
|
||||||
#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@
|
|
||||||
#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@
|
|
||||||
#cmakedefine SDL_LOADSO_OS2 @SDL_LOADSO_OS2@
|
|
||||||
|
|
||||||
/* Enable various threading systems */
|
|
||||||
#cmakedefine SDL_THREAD_GENERIC_COND_SUFFIX @SDL_THREAD_GENERIC_COND_SUFFIX@
|
|
||||||
#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@
|
|
||||||
#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@
|
|
||||||
#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@
|
|
||||||
#cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@
|
|
||||||
#cmakedefine SDL_THREAD_OS2 @SDL_THREAD_OS2@
|
|
||||||
#cmakedefine SDL_THREAD_VITA @SDL_THREAD_VITA@
|
|
||||||
#cmakedefine SDL_THREAD_PSP @SDL_THREAD_PSP@
|
|
||||||
|
|
||||||
/* Enable various timer systems */
|
|
||||||
#cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@
|
|
||||||
#cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@
|
|
||||||
#cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@
|
|
||||||
#cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@
|
|
||||||
#cmakedefine SDL_TIMER_OS2 @SDL_TIMER_OS2@
|
|
||||||
#cmakedefine SDL_TIMER_VITA @SDL_TIMER_VITA@
|
|
||||||
#cmakedefine SDL_TIMER_PSP @SDL_TIMER_PSP@
|
|
||||||
|
|
||||||
/* Enable various video drivers */
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_UIKIT @SDL_VIDEO_DRIVER_UIKIT@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_OFFSCREEN @SDL_VIDEO_DRIVER_OFFSCREEN@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WINRT @SDL_VIDEO_DRIVER_WINRT@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_OS2 @SDL_VIDEO_DRIVER_OS2@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_QNX @SDL_VIDEO_DRIVER_QNX@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_RISCOS @SDL_VIDEO_DRIVER_RISCOS@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_PSP @SDL_VIDEO_DRIVER_PSP@
|
|
||||||
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_KMSDRM @SDL_VIDEO_DRIVER_KMSDRM@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM@
|
|
||||||
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR@
|
|
||||||
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES @SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XDBE @SDL_VIDEO_DRIVER_X11_XDBE@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XFIXES @SDL_VIDEO_DRIVER_X11_XFIXES@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XRANDR @SDL_VIDEO_DRIVER_X11_XRANDR@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XSCRNSAVER @SDL_VIDEO_DRIVER_X11_XSCRNSAVER@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@
|
|
||||||
#cmakedefine SDL_VIDEO_DRIVER_VITA @SDL_VIDEO_DRIVER_VITA@
|
|
||||||
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@
|
|
||||||
#cmakedefine SDL_VIDEO_RENDER_PSP @SDL_VIDEO_RENDER_PSP@
|
|
||||||
|
|
||||||
/* Enable OpenGL support */
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_ES2 @SDL_VIDEO_OPENGL_ES2@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@
|
|
||||||
#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@
|
|
||||||
|
|
||||||
/* Enable Vulkan support */
|
|
||||||
#cmakedefine SDL_VIDEO_VULKAN @SDL_VIDEO_VULKAN@
|
|
||||||
|
|
||||||
/* Enable Metal support */
|
|
||||||
#cmakedefine SDL_VIDEO_METAL @SDL_VIDEO_METAL@
|
|
||||||
|
|
||||||
/* Enable system power support */
|
|
||||||
#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@
|
|
||||||
#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
|
|
||||||
#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
|
|
||||||
#cmakedefine SDL_POWER_WINRT @SDL_POWER_WINRT@
|
|
||||||
#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
|
|
||||||
#cmakedefine SDL_POWER_UIKIT @SDL_POWER_UIKIT@
|
|
||||||
#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@
|
|
||||||
#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@
|
|
||||||
#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
|
|
||||||
#cmakedefine SDL_POWER_VITA @SDL_POWER_VITA@
|
|
||||||
#cmakedefine SDL_POWER_PSP @SDL_POWER_PSP@
|
|
||||||
|
|
||||||
/* Enable system filesystem support */
|
|
||||||
#cmakedefine SDL_FILESYSTEM_ANDROID @SDL_FILESYSTEM_ANDROID@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_RISCOS @SDL_FILESYSTEM_RISCOS@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_OS2 @SDL_FILESYSTEM_OS2@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_VITA @SDL_FILESYSTEM_VITA@
|
|
||||||
#cmakedefine SDL_FILESYSTEM_PSP @SDL_FILESYSTEM_PSP@
|
|
||||||
|
|
||||||
/* Enable assembly routines */
|
|
||||||
#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
|
|
||||||
#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
|
|
||||||
#cmakedefine SDL_ARM_SIMD_BLITTERS @SDL_ARM_SIMD_BLITTERS@
|
|
||||||
#cmakedefine SDL_ARM_NEON_BLITTERS @SDL_ARM_NEON_BLITTERS@
|
|
||||||
|
|
||||||
/* Whether SDL_DYNAMIC_API needs dlopen */
|
|
||||||
#cmakedefine DYNAPI_NEEDS_DLOPEN @DYNAPI_NEEDS_DLOPEN@
|
|
||||||
|
|
||||||
/* Enable dynamic libsamplerate support */
|
|
||||||
#cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@
|
|
||||||
|
|
||||||
/* Enable ime support */
|
|
||||||
#cmakedefine SDL_USE_IME @SDL_USE_IME@
|
|
||||||
|
|
||||||
/* Platform specific definitions */
|
|
||||||
#cmakedefine SDL_IPHONE_KEYBOARD @SDL_IPHONE_KEYBOARD@
|
|
||||||
#cmakedefine SDL_IPHONE_LAUNCHSCREEN @SDL_IPHONE_LAUNCHSCREEN@
|
|
||||||
|
|
||||||
#cmakedefine SDL_VIDEO_VITA_PIB @SDL_VIDEO_VITA_PIB@
|
|
||||||
#cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@
|
|
||||||
|
|
||||||
#if !defined(__WIN32__) && !defined(__WINRT__)
|
|
||||||
# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
|
|
||||||
typedef unsigned int size_t;
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef signed int int32_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef signed long long int64_t;
|
|
||||||
typedef unsigned long long uint64_t;
|
|
||||||
typedef unsigned long uintptr_t;
|
|
||||||
# endif /* if (stdint.h isn't available) */
|
|
||||||
#else /* __WIN32__ */
|
|
||||||
# if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
|
|
||||||
# if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__CODEGEARC__)
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
# elif defined(_MSC_VER)
|
|
||||||
typedef signed __int8 int8_t;
|
|
||||||
typedef unsigned __int8 uint8_t;
|
|
||||||
typedef signed __int16 int16_t;
|
|
||||||
typedef unsigned __int16 uint16_t;
|
|
||||||
typedef signed __int32 int32_t;
|
|
||||||
typedef unsigned __int32 uint32_t;
|
|
||||||
typedef signed __int64 int64_t;
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
# ifndef _UINTPTR_T_DEFINED
|
|
||||||
# ifdef _WIN64
|
|
||||||
typedef unsigned __int64 uintptr_t;
|
|
||||||
# else
|
|
||||||
typedef unsigned int uintptr_t;
|
|
||||||
# endif
|
|
||||||
#define _UINTPTR_T_DEFINED
|
|
||||||
# endif
|
|
||||||
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
|
|
||||||
# if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
|
|
||||||
#define DWORD_PTR DWORD
|
|
||||||
# endif
|
|
||||||
# if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
|
|
||||||
#define LONG_PTR LONG
|
|
||||||
# endif
|
|
||||||
# else /* !__GNUC__ && !_MSC_VER */
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef signed int int32_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef signed long long int64_t;
|
|
||||||
typedef unsigned long long uint64_t;
|
|
||||||
# ifndef _SIZE_T_DEFINED_
|
|
||||||
#define _SIZE_T_DEFINED_
|
|
||||||
typedef unsigned int size_t;
|
|
||||||
# endif
|
|
||||||
typedef unsigned int uintptr_t;
|
|
||||||
# endif /* __GNUC__ || _MSC_VER */
|
|
||||||
# endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
|
||||||
#endif /* __WIN32__ */
|
|
||||||
|
|
||||||
#endif /* SDL_config_h_ */
|
|
@ -1,480 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_config.h.in
|
|
||||||
*
|
|
||||||
* This is a set of defines to configure the SDL features
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* General platform specific identifiers */
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/* Make sure that this isn't included by Visual C++ */
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#error You should run git checkout -f include/SDL_config.h
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* C language features */
|
|
||||||
#undef const
|
|
||||||
#undef inline
|
|
||||||
#undef volatile
|
|
||||||
|
|
||||||
/* C datatypes */
|
|
||||||
#if defined(__LP64__) || defined(_LP64) || defined(_WIN64)
|
|
||||||
#define SIZEOF_VOIDP 8
|
|
||||||
#else
|
|
||||||
#define SIZEOF_VOIDP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef HAVE_GCC_ATOMICS
|
|
||||||
#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
|
||||||
|
|
||||||
/* Comment this if you want to build without any C library requirements */
|
|
||||||
#undef HAVE_LIBC
|
|
||||||
#if HAVE_LIBC
|
|
||||||
|
|
||||||
/* Useful headers */
|
|
||||||
#undef STDC_HEADERS
|
|
||||||
#undef HAVE_ALLOCA_H
|
|
||||||
#undef HAVE_CTYPE_H
|
|
||||||
#undef HAVE_FLOAT_H
|
|
||||||
#undef HAVE_ICONV_H
|
|
||||||
#undef HAVE_INTTYPES_H
|
|
||||||
#undef HAVE_LIMITS_H
|
|
||||||
#undef HAVE_MALLOC_H
|
|
||||||
#undef HAVE_MATH_H
|
|
||||||
#undef HAVE_MEMORY_H
|
|
||||||
#undef HAVE_SIGNAL_H
|
|
||||||
#undef HAVE_STDARG_H
|
|
||||||
#undef HAVE_STDINT_H
|
|
||||||
#undef HAVE_STDIO_H
|
|
||||||
#undef HAVE_STDLIB_H
|
|
||||||
#undef HAVE_STRINGS_H
|
|
||||||
#undef HAVE_STRING_H
|
|
||||||
#undef HAVE_SYS_TYPES_H
|
|
||||||
#undef HAVE_WCHAR_H
|
|
||||||
#undef HAVE_PTHREAD_NP_H
|
|
||||||
#undef HAVE_LIBUNWIND_H
|
|
||||||
|
|
||||||
/* C library functions */
|
|
||||||
#undef HAVE_DLOPEN
|
|
||||||
#undef HAVE_MALLOC
|
|
||||||
#undef HAVE_CALLOC
|
|
||||||
#undef HAVE_REALLOC
|
|
||||||
#undef HAVE_FREE
|
|
||||||
#undef HAVE_ALLOCA
|
|
||||||
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
|
|
||||||
#undef HAVE_GETENV
|
|
||||||
#undef HAVE_SETENV
|
|
||||||
#undef HAVE_PUTENV
|
|
||||||
#undef HAVE_UNSETENV
|
|
||||||
#endif
|
|
||||||
#undef HAVE_QSORT
|
|
||||||
#undef HAVE_ABS
|
|
||||||
#undef HAVE_BCOPY
|
|
||||||
#undef HAVE_MEMSET
|
|
||||||
#undef HAVE_MEMCPY
|
|
||||||
#undef HAVE_MEMMOVE
|
|
||||||
#undef HAVE_MEMCMP
|
|
||||||
#undef HAVE_WCSLEN
|
|
||||||
#undef HAVE_WCSLCPY
|
|
||||||
#undef HAVE_WCSLCAT
|
|
||||||
#undef HAVE__WCSDUP
|
|
||||||
#undef HAVE_WCSDUP
|
|
||||||
#undef HAVE_WCSSTR
|
|
||||||
#undef HAVE_WCSCMP
|
|
||||||
#undef HAVE_WCSNCMP
|
|
||||||
#undef HAVE_WCSCASECMP
|
|
||||||
#undef HAVE__WCSICMP
|
|
||||||
#undef HAVE_WCSNCASECMP
|
|
||||||
#undef HAVE__WCSNICMP
|
|
||||||
#undef HAVE_STRLEN
|
|
||||||
#undef HAVE_STRLCPY
|
|
||||||
#undef HAVE_STRLCAT
|
|
||||||
#undef HAVE__STRREV
|
|
||||||
#undef HAVE__STRUPR
|
|
||||||
#undef HAVE__STRLWR
|
|
||||||
#undef HAVE_INDEX
|
|
||||||
#undef HAVE_RINDEX
|
|
||||||
#undef HAVE_STRCHR
|
|
||||||
#undef HAVE_STRRCHR
|
|
||||||
#undef HAVE_STRSTR
|
|
||||||
#undef HAVE_STRTOK_R
|
|
||||||
#undef HAVE_ITOA
|
|
||||||
#undef HAVE__LTOA
|
|
||||||
#undef HAVE__UITOA
|
|
||||||
#undef HAVE__ULTOA
|
|
||||||
#undef HAVE_STRTOL
|
|
||||||
#undef HAVE_STRTOUL
|
|
||||||
#undef HAVE__I64TOA
|
|
||||||
#undef HAVE__UI64TOA
|
|
||||||
#undef HAVE_STRTOLL
|
|
||||||
#undef HAVE_STRTOULL
|
|
||||||
#undef HAVE_STRTOD
|
|
||||||
#undef HAVE_ATOI
|
|
||||||
#undef HAVE_ATOF
|
|
||||||
#undef HAVE_STRCMP
|
|
||||||
#undef HAVE_STRNCMP
|
|
||||||
#undef HAVE__STRICMP
|
|
||||||
#undef HAVE_STRCASECMP
|
|
||||||
#undef HAVE__STRNICMP
|
|
||||||
#undef HAVE_STRNCASECMP
|
|
||||||
#undef HAVE_SSCANF
|
|
||||||
#undef HAVE_VSSCANF
|
|
||||||
#undef HAVE_SNPRINTF
|
|
||||||
#undef HAVE_VSNPRINTF
|
|
||||||
#undef HAVE_M_PI
|
|
||||||
#undef HAVE_ACOS
|
|
||||||
#undef HAVE_ACOSF
|
|
||||||
#undef HAVE_ASIN
|
|
||||||
#undef HAVE_ASINF
|
|
||||||
#undef HAVE_ATAN
|
|
||||||
#undef HAVE_ATANF
|
|
||||||
#undef HAVE_ATAN2
|
|
||||||
#undef HAVE_ATAN2F
|
|
||||||
#undef HAVE_CEIL
|
|
||||||
#undef HAVE_CEILF
|
|
||||||
#undef HAVE_COPYSIGN
|
|
||||||
#undef HAVE_COPYSIGNF
|
|
||||||
#undef HAVE_COS
|
|
||||||
#undef HAVE_COSF
|
|
||||||
#undef HAVE_EXP
|
|
||||||
#undef HAVE_EXPF
|
|
||||||
#undef HAVE_FABS
|
|
||||||
#undef HAVE_FABSF
|
|
||||||
#undef HAVE_FLOOR
|
|
||||||
#undef HAVE_FLOORF
|
|
||||||
#undef HAVE_FMOD
|
|
||||||
#undef HAVE_FMODF
|
|
||||||
#undef HAVE_LOG
|
|
||||||
#undef HAVE_LOGF
|
|
||||||
#undef HAVE_LOG10
|
|
||||||
#undef HAVE_LOG10F
|
|
||||||
#undef HAVE_LROUND
|
|
||||||
#undef HAVE_LROUNDF
|
|
||||||
#undef HAVE_POW
|
|
||||||
#undef HAVE_POWF
|
|
||||||
#undef HAVE_ROUND
|
|
||||||
#undef HAVE_ROUNDF
|
|
||||||
#undef HAVE_SCALBN
|
|
||||||
#undef HAVE_SCALBNF
|
|
||||||
#undef HAVE_SIN
|
|
||||||
#undef HAVE_SINF
|
|
||||||
#undef HAVE_SQRT
|
|
||||||
#undef HAVE_SQRTF
|
|
||||||
#undef HAVE_TAN
|
|
||||||
#undef HAVE_TANF
|
|
||||||
#undef HAVE_TRUNC
|
|
||||||
#undef HAVE_TRUNCF
|
|
||||||
#undef HAVE_FOPEN64
|
|
||||||
#undef HAVE_FSEEKO
|
|
||||||
#undef HAVE_FSEEKO64
|
|
||||||
#undef HAVE_SIGACTION
|
|
||||||
#undef HAVE_SA_SIGACTION
|
|
||||||
#undef HAVE_SETJMP
|
|
||||||
#undef HAVE_NANOSLEEP
|
|
||||||
#undef HAVE_SYSCONF
|
|
||||||
#undef HAVE_SYSCTLBYNAME
|
|
||||||
#undef HAVE_CLOCK_GETTIME
|
|
||||||
#undef HAVE_GETPAGESIZE
|
|
||||||
#undef HAVE_MPROTECT
|
|
||||||
#undef HAVE_ICONV
|
|
||||||
#undef HAVE_PTHREAD_SETNAME_NP
|
|
||||||
#undef HAVE_PTHREAD_SET_NAME_NP
|
|
||||||
#undef HAVE_SEM_TIMEDWAIT
|
|
||||||
#undef HAVE_GETAUXVAL
|
|
||||||
#undef HAVE_ELF_AUX_INFO
|
|
||||||
#undef HAVE_POLL
|
|
||||||
#undef HAVE__EXIT
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define HAVE_STDARG_H 1
|
|
||||||
#define HAVE_STDDEF_H 1
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
#endif /* HAVE_LIBC */
|
|
||||||
|
|
||||||
#undef HAVE_O_CLOEXEC
|
|
||||||
#undef HAVE_ALTIVEC_H
|
|
||||||
#undef HAVE_DBUS_DBUS_H
|
|
||||||
#undef HAVE_FCITX
|
|
||||||
#undef HAVE_SYS_INOTIFY_H
|
|
||||||
#undef HAVE_INOTIFY_INIT
|
|
||||||
#undef HAVE_INOTIFY_INIT1
|
|
||||||
#undef HAVE_INOTIFY
|
|
||||||
#undef HAVE_IBUS_IBUS_H
|
|
||||||
#undef HAVE_IMMINTRIN_H
|
|
||||||
#undef HAVE_LIBUDEV_H
|
|
||||||
#undef HAVE_LIBSAMPLERATE_H
|
|
||||||
#undef HAVE_LIBDECOR_H
|
|
||||||
|
|
||||||
#undef HAVE_DDRAW_H
|
|
||||||
#undef HAVE_DINPUT_H
|
|
||||||
#undef HAVE_DSOUND_H
|
|
||||||
#undef HAVE_DXGI_H
|
|
||||||
#undef HAVE_WINDOWS_GAMING_INPUT_H
|
|
||||||
#undef HAVE_XINPUT_H
|
|
||||||
#undef HAVE_XINPUT_GAMEPAD_EX
|
|
||||||
#undef HAVE_XINPUT_STATE_EX
|
|
||||||
|
|
||||||
#undef HAVE_MMDEVICEAPI_H
|
|
||||||
#undef HAVE_AUDIOCLIENT_H
|
|
||||||
#undef HAVE_TPCSHRD_H
|
|
||||||
#undef HAVE_SENSORSAPI_H
|
|
||||||
|
|
||||||
/* SDL internal assertion support */
|
|
||||||
#undef SDL_DEFAULT_ASSERT_LEVEL
|
|
||||||
|
|
||||||
/* Allow disabling of core subsystems */
|
|
||||||
#undef SDL_ATOMIC_DISABLED
|
|
||||||
#undef SDL_AUDIO_DISABLED
|
|
||||||
#undef SDL_CPUINFO_DISABLED
|
|
||||||
#undef SDL_EVENTS_DISABLED
|
|
||||||
#undef SDL_FILE_DISABLED
|
|
||||||
#undef SDL_JOYSTICK_DISABLED
|
|
||||||
#undef SDL_HAPTIC_DISABLED
|
|
||||||
#undef SDL_HIDAPI_DISABLED
|
|
||||||
#undef SDL_SENSOR_DISABLED
|
|
||||||
#undef SDL_LOADSO_DISABLED
|
|
||||||
#undef SDL_RENDER_DISABLED
|
|
||||||
#undef SDL_THREADS_DISABLED
|
|
||||||
#undef SDL_TIMERS_DISABLED
|
|
||||||
#undef SDL_VIDEO_DISABLED
|
|
||||||
#undef SDL_POWER_DISABLED
|
|
||||||
#undef SDL_FILESYSTEM_DISABLED
|
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
|
||||||
#undef SDL_AUDIO_DRIVER_AAUDIO
|
|
||||||
#undef SDL_AUDIO_DRIVER_ALSA
|
|
||||||
#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_ANDROID
|
|
||||||
#undef SDL_AUDIO_DRIVER_ARTS
|
|
||||||
#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_COREAUDIO
|
|
||||||
#undef SDL_AUDIO_DRIVER_DISK
|
|
||||||
#undef SDL_AUDIO_DRIVER_DSOUND
|
|
||||||
#undef SDL_AUDIO_DRIVER_DUMMY
|
|
||||||
#undef SDL_AUDIO_DRIVER_EMSCRIPTEN
|
|
||||||
#undef SDL_AUDIO_DRIVER_ESD
|
|
||||||
#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_FUSIONSOUND
|
|
||||||
#undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_HAIKU
|
|
||||||
#undef SDL_AUDIO_DRIVER_JACK
|
|
||||||
#undef SDL_AUDIO_DRIVER_JACK_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_NACL
|
|
||||||
#undef SDL_AUDIO_DRIVER_NAS
|
|
||||||
#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_NETBSD
|
|
||||||
#undef SDL_AUDIO_DRIVER_OPENSLES
|
|
||||||
#undef SDL_AUDIO_DRIVER_OSS
|
|
||||||
#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
|
|
||||||
#undef SDL_AUDIO_DRIVER_PAUDIO
|
|
||||||
#undef SDL_AUDIO_DRIVER_PIPEWIRE
|
|
||||||
#undef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_PULSEAUDIO
|
|
||||||
#undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_QSA
|
|
||||||
#undef SDL_AUDIO_DRIVER_SNDIO
|
|
||||||
#undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC
|
|
||||||
#undef SDL_AUDIO_DRIVER_SUNAUDIO
|
|
||||||
#undef SDL_AUDIO_DRIVER_WASAPI
|
|
||||||
#undef SDL_AUDIO_DRIVER_WINMM
|
|
||||||
#undef SDL_AUDIO_DRIVER_OS2
|
|
||||||
|
|
||||||
/* Enable various input drivers */
|
|
||||||
#undef SDL_INPUT_LINUXEV
|
|
||||||
#undef SDL_INPUT_FBSDKBIO
|
|
||||||
#undef SDL_INPUT_LINUXKD
|
|
||||||
#undef SDL_INPUT_WSCONS
|
|
||||||
#undef SDL_JOYSTICK_HAIKU
|
|
||||||
#undef SDL_JOYSTICK_DINPUT
|
|
||||||
#undef SDL_JOYSTICK_WGI
|
|
||||||
#undef SDL_JOYSTICK_XINPUT
|
|
||||||
#undef SDL_JOYSTICK_DUMMY
|
|
||||||
#undef SDL_JOYSTICK_IOKIT
|
|
||||||
#undef SDL_JOYSTICK_MFI
|
|
||||||
#undef SDL_JOYSTICK_LINUX
|
|
||||||
#undef SDL_JOYSTICK_ANDROID
|
|
||||||
#undef SDL_JOYSTICK_OS2
|
|
||||||
#undef SDL_JOYSTICK_USBHID
|
|
||||||
#undef SDL_HAVE_MACHINE_JOYSTICK_H
|
|
||||||
#undef SDL_JOYSTICK_HIDAPI
|
|
||||||
#undef SDL_JOYSTICK_RAWINPUT
|
|
||||||
#undef SDL_JOYSTICK_EMSCRIPTEN
|
|
||||||
#undef SDL_JOYSTICK_VIRTUAL
|
|
||||||
#undef SDL_HAPTIC_DUMMY
|
|
||||||
#undef SDL_HAPTIC_ANDROID
|
|
||||||
#undef SDL_HAPTIC_LINUX
|
|
||||||
#undef SDL_HAPTIC_IOKIT
|
|
||||||
#undef SDL_HAPTIC_DINPUT
|
|
||||||
#undef SDL_HAPTIC_XINPUT
|
|
||||||
|
|
||||||
/* Enable various sensor drivers */
|
|
||||||
#undef SDL_SENSOR_ANDROID
|
|
||||||
#undef SDL_SENSOR_COREMOTION
|
|
||||||
#undef SDL_SENSOR_WINDOWS
|
|
||||||
#undef SDL_SENSOR_DUMMY
|
|
||||||
|
|
||||||
/* Enable various shared object loading systems */
|
|
||||||
#undef SDL_LOADSO_DLOPEN
|
|
||||||
#undef SDL_LOADSO_DUMMY
|
|
||||||
#undef SDL_LOADSO_LDG
|
|
||||||
#undef SDL_LOADSO_WINDOWS
|
|
||||||
#undef SDL_LOADSO_OS2
|
|
||||||
|
|
||||||
/* Enable various threading systems */
|
|
||||||
#undef SDL_THREAD_GENERIC_COND_SUFFIX
|
|
||||||
#undef SDL_THREAD_PTHREAD
|
|
||||||
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
|
|
||||||
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
|
|
||||||
#undef SDL_THREAD_WINDOWS
|
|
||||||
#undef SDL_THREAD_OS2
|
|
||||||
|
|
||||||
/* Enable various timer systems */
|
|
||||||
#undef SDL_TIMER_HAIKU
|
|
||||||
#undef SDL_TIMER_DUMMY
|
|
||||||
#undef SDL_TIMER_UNIX
|
|
||||||
#undef SDL_TIMER_WINDOWS
|
|
||||||
#undef SDL_TIMER_OS2
|
|
||||||
|
|
||||||
/* Enable various video drivers */
|
|
||||||
#undef SDL_VIDEO_DRIVER_HAIKU
|
|
||||||
#undef SDL_VIDEO_DRIVER_COCOA
|
|
||||||
#undef SDL_VIDEO_DRIVER_DIRECTFB
|
|
||||||
#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
|
|
||||||
#undef SDL_VIDEO_DRIVER_DUMMY
|
|
||||||
#undef SDL_VIDEO_DRIVER_WINDOWS
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
|
|
||||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11
|
|
||||||
#undef SDL_VIDEO_DRIVER_RPI
|
|
||||||
#undef SDL_VIDEO_DRIVER_KMSDRM
|
|
||||||
#undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
|
||||||
#undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM
|
|
||||||
#undef SDL_VIDEO_DRIVER_ANDROID
|
|
||||||
#undef SDL_VIDEO_DRIVER_EMSCRIPTEN
|
|
||||||
#undef SDL_VIDEO_DRIVER_OFFSCREEN
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XCURSOR
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XDBE
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XINPUT2
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XFIXES
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XRANDR
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XSHAPE
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_XVIDMODE
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
|
|
||||||
#undef SDL_VIDEO_DRIVER_NACL
|
|
||||||
#undef SDL_VIDEO_DRIVER_VIVANTE
|
|
||||||
#undef SDL_VIDEO_DRIVER_VIVANTE_VDK
|
|
||||||
#undef SDL_VIDEO_DRIVER_OS2
|
|
||||||
#undef SDL_VIDEO_DRIVER_QNX
|
|
||||||
#undef SDL_VIDEO_DRIVER_RISCOS
|
|
||||||
|
|
||||||
#undef SDL_VIDEO_RENDER_D3D
|
|
||||||
#undef SDL_VIDEO_RENDER_D3D11
|
|
||||||
#undef SDL_VIDEO_RENDER_OGL
|
|
||||||
#undef SDL_VIDEO_RENDER_OGL_ES
|
|
||||||
#undef SDL_VIDEO_RENDER_OGL_ES2
|
|
||||||
#undef SDL_VIDEO_RENDER_DIRECTFB
|
|
||||||
#undef SDL_VIDEO_RENDER_METAL
|
|
||||||
|
|
||||||
/* Enable OpenGL support */
|
|
||||||
#undef SDL_VIDEO_OPENGL
|
|
||||||
#undef SDL_VIDEO_OPENGL_ES
|
|
||||||
#undef SDL_VIDEO_OPENGL_ES2
|
|
||||||
#undef SDL_VIDEO_OPENGL_BGL
|
|
||||||
#undef SDL_VIDEO_OPENGL_CGL
|
|
||||||
#undef SDL_VIDEO_OPENGL_EGL
|
|
||||||
#undef SDL_VIDEO_OPENGL_GLX
|
|
||||||
#undef SDL_VIDEO_OPENGL_WGL
|
|
||||||
#undef SDL_VIDEO_OPENGL_OSMESA
|
|
||||||
#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
|
|
||||||
|
|
||||||
/* Enable Vulkan support */
|
|
||||||
#undef SDL_VIDEO_VULKAN
|
|
||||||
|
|
||||||
/* Enable Metal support */
|
|
||||||
#undef SDL_VIDEO_METAL
|
|
||||||
|
|
||||||
/* Enable system power support */
|
|
||||||
#undef SDL_POWER_LINUX
|
|
||||||
#undef SDL_POWER_WINDOWS
|
|
||||||
#undef SDL_POWER_MACOSX
|
|
||||||
#undef SDL_POWER_HAIKU
|
|
||||||
#undef SDL_POWER_ANDROID
|
|
||||||
#undef SDL_POWER_EMSCRIPTEN
|
|
||||||
#undef SDL_POWER_HARDWIRED
|
|
||||||
|
|
||||||
/* Enable system filesystem support */
|
|
||||||
#undef SDL_FILESYSTEM_HAIKU
|
|
||||||
#undef SDL_FILESYSTEM_COCOA
|
|
||||||
#undef SDL_FILESYSTEM_DUMMY
|
|
||||||
#undef SDL_FILESYSTEM_UNIX
|
|
||||||
#undef SDL_FILESYSTEM_WINDOWS
|
|
||||||
#undef SDL_FILESYSTEM_NACL
|
|
||||||
#undef SDL_FILESYSTEM_ANDROID
|
|
||||||
#undef SDL_FILESYSTEM_EMSCRIPTEN
|
|
||||||
#undef SDL_FILESYSTEM_OS2
|
|
||||||
#undef SDL_FILESYSTEM_RISCOS
|
|
||||||
|
|
||||||
/* Enable assembly routines */
|
|
||||||
#undef SDL_ASSEMBLY_ROUTINES
|
|
||||||
#undef SDL_ALTIVEC_BLITTERS
|
|
||||||
#undef SDL_ARM_SIMD_BLITTERS
|
|
||||||
#undef SDL_ARM_NEON_BLITTERS
|
|
||||||
|
|
||||||
/* Whether SDL_DYNAMIC_API needs dlopen() */
|
|
||||||
#undef DYNAPI_NEEDS_DLOPEN
|
|
||||||
|
|
||||||
/* Enable ime support */
|
|
||||||
#undef SDL_USE_IME
|
|
||||||
|
|
||||||
/* Enable dynamic udev support */
|
|
||||||
#undef SDL_UDEV_DYNAMIC
|
|
||||||
|
|
||||||
/* Enable dynamic libusb support */
|
|
||||||
#undef SDL_LIBUSB_DYNAMIC
|
|
||||||
|
|
||||||
/* Enable dynamic libsamplerate support */
|
|
||||||
#undef SDL_LIBSAMPLERATE_DYNAMIC
|
|
||||||
|
|
||||||
#endif /* SDL_config_h_ */
|
|
@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_android_h_
|
|
||||||
#define SDL_config_android_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_config_android.h
|
|
||||||
*
|
|
||||||
* This is a configuration that can be used to build SDL for Android
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#define HAVE_GCC_ATOMICS 1
|
|
||||||
|
|
||||||
#define STDC_HEADERS 1
|
|
||||||
#define HAVE_ALLOCA_H 1
|
|
||||||
#define HAVE_CTYPE_H 1
|
|
||||||
#define HAVE_INTTYPES_H 1
|
|
||||||
#define HAVE_LIMITS_H 1
|
|
||||||
#define HAVE_MATH_H 1
|
|
||||||
#define HAVE_SIGNAL_H 1
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
#define HAVE_STDIO_H 1
|
|
||||||
#define HAVE_STRING_H 1
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
|
||||||
|
|
||||||
/* C library functions */
|
|
||||||
#define HAVE_DLOPEN 1
|
|
||||||
#define HAVE_MALLOC 1
|
|
||||||
#define HAVE_CALLOC 1
|
|
||||||
#define HAVE_REALLOC 1
|
|
||||||
#define HAVE_FREE 1
|
|
||||||
#define HAVE_ALLOCA 1
|
|
||||||
#define HAVE_GETENV 1
|
|
||||||
#define HAVE_SETENV 1
|
|
||||||
#define HAVE_PUTENV 1
|
|
||||||
#define HAVE_SETENV 1
|
|
||||||
#define HAVE_UNSETENV 1
|
|
||||||
#define HAVE_QSORT 1
|
|
||||||
#define HAVE_ABS 1
|
|
||||||
#define HAVE_BCOPY 1
|
|
||||||
#define HAVE_MEMSET 1
|
|
||||||
#define HAVE_MEMCPY 1
|
|
||||||
#define HAVE_MEMMOVE 1
|
|
||||||
#define HAVE_MEMCMP 1
|
|
||||||
#define HAVE_STRLEN 1
|
|
||||||
#define HAVE_STRLCPY 1
|
|
||||||
#define HAVE_STRLCAT 1
|
|
||||||
#define HAVE_STRCHR 1
|
|
||||||
#define HAVE_STRRCHR 1
|
|
||||||
#define HAVE_STRSTR 1
|
|
||||||
#define HAVE_STRTOK_R 1
|
|
||||||
#define HAVE_STRTOL 1
|
|
||||||
#define HAVE_STRTOUL 1
|
|
||||||
#define HAVE_STRTOLL 1
|
|
||||||
#define HAVE_STRTOULL 1
|
|
||||||
#define HAVE_STRTOD 1
|
|
||||||
#define HAVE_ATOI 1
|
|
||||||
#define HAVE_ATOF 1
|
|
||||||
#define HAVE_STRCMP 1
|
|
||||||
#define HAVE_STRNCMP 1
|
|
||||||
#define HAVE_STRCASECMP 1
|
|
||||||
#define HAVE_STRNCASECMP 1
|
|
||||||
#define HAVE_VSSCANF 1
|
|
||||||
#define HAVE_VSNPRINTF 1
|
|
||||||
#define HAVE_ACOS 1
|
|
||||||
#define HAVE_ACOSF 1
|
|
||||||
#define HAVE_ASIN 1
|
|
||||||
#define HAVE_ASINF 1
|
|
||||||
#define HAVE_ATAN 1
|
|
||||||
#define HAVE_ATANF 1
|
|
||||||
#define HAVE_ATAN2 1
|
|
||||||
#define HAVE_ATAN2F 1
|
|
||||||
#define HAVE_CEIL 1
|
|
||||||
#define HAVE_CEILF 1
|
|
||||||
#define HAVE_COPYSIGN 1
|
|
||||||
#define HAVE_COPYSIGNF 1
|
|
||||||
#define HAVE_COS 1
|
|
||||||
#define HAVE_COSF 1
|
|
||||||
#define HAVE_EXP 1
|
|
||||||
#define HAVE_EXPF 1
|
|
||||||
#define HAVE_FABS 1
|
|
||||||
#define HAVE_FABSF 1
|
|
||||||
#define HAVE_FLOOR 1
|
|
||||||
#define HAVE_FLOORF 1
|
|
||||||
#define HAVE_FMOD 1
|
|
||||||
#define HAVE_FMODF 1
|
|
||||||
#define HAVE_LOG 1
|
|
||||||
#define HAVE_LOGF 1
|
|
||||||
#define HAVE_LOG10 1
|
|
||||||
#define HAVE_LOG10F 1
|
|
||||||
#define HAVE_LROUND 1
|
|
||||||
#define HAVE_LROUNDF 1
|
|
||||||
#define HAVE_POW 1
|
|
||||||
#define HAVE_POWF 1
|
|
||||||
#define HAVE_ROUND 1
|
|
||||||
#define HAVE_ROUNDF 1
|
|
||||||
#define HAVE_SCALBN 1
|
|
||||||
#define HAVE_SCALBNF 1
|
|
||||||
#define HAVE_SIN 1
|
|
||||||
#define HAVE_SINF 1
|
|
||||||
#define HAVE_SQRT 1
|
|
||||||
#define HAVE_SQRTF 1
|
|
||||||
#define HAVE_TAN 1
|
|
||||||
#define HAVE_TANF 1
|
|
||||||
#define HAVE_TRUNC 1
|
|
||||||
#define HAVE_TRUNCF 1
|
|
||||||
#define HAVE_SIGACTION 1
|
|
||||||
#define HAVE_SETJMP 1
|
|
||||||
#define HAVE_NANOSLEEP 1
|
|
||||||
#define HAVE_SYSCONF 1
|
|
||||||
#define HAVE_CLOCK_GETTIME 1
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
|
||||||
#define SIZEOF_VOIDP 8
|
|
||||||
#else
|
|
||||||
#define SIZEOF_VOIDP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
|
||||||
#define SDL_AUDIO_DRIVER_ANDROID 1
|
|
||||||
#define SDL_AUDIO_DRIVER_OPENSLES 1
|
|
||||||
#define SDL_AUDIO_DRIVER_AAUDIO 1
|
|
||||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable various input drivers */
|
|
||||||
#define SDL_JOYSTICK_ANDROID 1
|
|
||||||
#define SDL_JOYSTICK_HIDAPI 1
|
|
||||||
#define SDL_JOYSTICK_VIRTUAL 1
|
|
||||||
#define SDL_HAPTIC_ANDROID 1
|
|
||||||
|
|
||||||
/* Enable sensor driver */
|
|
||||||
#define SDL_SENSOR_ANDROID 1
|
|
||||||
|
|
||||||
/* Enable various shared object loading systems */
|
|
||||||
#define SDL_LOADSO_DLOPEN 1
|
|
||||||
|
|
||||||
/* Enable various threading systems */
|
|
||||||
#define SDL_THREAD_PTHREAD 1
|
|
||||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
|
||||||
|
|
||||||
/* Enable various timer systems */
|
|
||||||
#define SDL_TIMER_UNIX 1
|
|
||||||
|
|
||||||
/* Enable various video drivers */
|
|
||||||
#define SDL_VIDEO_DRIVER_ANDROID 1
|
|
||||||
|
|
||||||
/* Enable OpenGL ES */
|
|
||||||
#define SDL_VIDEO_OPENGL_ES 1
|
|
||||||
#define SDL_VIDEO_OPENGL_ES2 1
|
|
||||||
#define SDL_VIDEO_OPENGL_EGL 1
|
|
||||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
|
||||||
#define SDL_VIDEO_RENDER_OGL_ES2 1
|
|
||||||
|
|
||||||
/* Enable Vulkan support */
|
|
||||||
/* Android does not support Vulkan in native code using the "armeabi" ABI. */
|
|
||||||
#if defined(__ARM_ARCH) && __ARM_ARCH < 7
|
|
||||||
#define SDL_VIDEO_VULKAN 0
|
|
||||||
#else
|
|
||||||
#define SDL_VIDEO_VULKAN 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable system power support */
|
|
||||||
#define SDL_POWER_ANDROID 1
|
|
||||||
|
|
||||||
/* Enable the filesystem driver */
|
|
||||||
#define SDL_FILESYSTEM_ANDROID 1
|
|
||||||
|
|
||||||
#endif /* SDL_config_android_h_ */
|
|
@ -1,216 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SDL_config_emscripten_h_
|
|
||||||
#define _SDL_config_emscripten_h_
|
|
||||||
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_config_emscripten.h
|
|
||||||
*
|
|
||||||
* This is a configuration that can be used to build SDL for Emscripten.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
|
||||||
#define SIZEOF_VOIDP 8
|
|
||||||
#else
|
|
||||||
#define SIZEOF_VOIDP 4
|
|
||||||
#endif
|
|
||||||
#define HAVE_GCC_ATOMICS 1
|
|
||||||
|
|
||||||
/* Useful headers */
|
|
||||||
#define STDC_HEADERS 1
|
|
||||||
#define HAVE_ALLOCA_H 1
|
|
||||||
#define HAVE_CTYPE_H 1
|
|
||||||
#define HAVE_ICONV_H 1
|
|
||||||
#define HAVE_INTTYPES_H 1
|
|
||||||
#define HAVE_LIMITS_H 1
|
|
||||||
#define HAVE_MALLOC_H 1
|
|
||||||
#define HAVE_MATH_H 1
|
|
||||||
#define HAVE_MEMORY_H 1
|
|
||||||
#define HAVE_SIGNAL_H 1
|
|
||||||
#define HAVE_STDARG_H 1
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
#define HAVE_STDIO_H 1
|
|
||||||
#define HAVE_STDLIB_H 1
|
|
||||||
#define HAVE_STRINGS_H 1
|
|
||||||
#define HAVE_STRING_H 1
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
|
||||||
#define HAVE_WCHAR_H 1
|
|
||||||
|
|
||||||
/* C library functions */
|
|
||||||
#define HAVE_DLOPEN 1
|
|
||||||
#define HAVE_MALLOC 1
|
|
||||||
#define HAVE_CALLOC 1
|
|
||||||
#define HAVE_REALLOC 1
|
|
||||||
#define HAVE_FREE 1
|
|
||||||
#define HAVE_ALLOCA 1
|
|
||||||
#define HAVE_GETENV 1
|
|
||||||
#define HAVE_SETENV 1
|
|
||||||
#define HAVE_PUTENV 1
|
|
||||||
#define HAVE_UNSETENV 1
|
|
||||||
#define HAVE_QSORT 1
|
|
||||||
#define HAVE_ABS 1
|
|
||||||
#define HAVE_BCOPY 1
|
|
||||||
#define HAVE_MEMSET 1
|
|
||||||
#define HAVE_MEMCPY 1
|
|
||||||
#define HAVE_MEMMOVE 1
|
|
||||||
#define HAVE_MEMCMP 1
|
|
||||||
#define HAVE_WCSLEN 1
|
|
||||||
#define HAVE_WCSDUP 1
|
|
||||||
#define HAVE_WCSSTR 1
|
|
||||||
#define HAVE_WCSCMP 1
|
|
||||||
#define HAVE_WCSNCMP 1
|
|
||||||
#define HAVE_WCSCASECMP 1
|
|
||||||
#define HAVE_WCSNCASECMP 1
|
|
||||||
#define HAVE_STRLEN 1
|
|
||||||
#define HAVE_STRLCPY 1
|
|
||||||
#define HAVE_STRLCAT 1
|
|
||||||
#define HAVE_STRCHR 1
|
|
||||||
#define HAVE_STRRCHR 1
|
|
||||||
#define HAVE_STRSTR 1
|
|
||||||
#define HAVE_STRTOK_R 1
|
|
||||||
#define HAVE_STRTOL 1
|
|
||||||
#define HAVE_STRTOUL 1
|
|
||||||
#define HAVE_STRTOLL 1
|
|
||||||
#define HAVE_STRTOULL 1
|
|
||||||
#define HAVE_STRTOD 1
|
|
||||||
#define HAVE_ATOI 1
|
|
||||||
#define HAVE_ATOF 1
|
|
||||||
#define HAVE_STRCMP 1
|
|
||||||
#define HAVE_STRNCMP 1
|
|
||||||
#define HAVE_STRCASECMP 1
|
|
||||||
#define HAVE_STRNCASECMP 1
|
|
||||||
#define HAVE_SSCANF 1
|
|
||||||
#define HAVE_VSSCANF 1
|
|
||||||
#define HAVE_VSNPRINTF 1
|
|
||||||
#define HAVE_M_PI 1
|
|
||||||
#define HAVE_ACOS 1
|
|
||||||
#define HAVE_ACOSF 1
|
|
||||||
#define HAVE_ASIN 1
|
|
||||||
#define HAVE_ASINF 1
|
|
||||||
#define HAVE_ATAN 1
|
|
||||||
#define HAVE_ATANF 1
|
|
||||||
#define HAVE_ATAN2 1
|
|
||||||
#define HAVE_ATAN2F 1
|
|
||||||
#define HAVE_CEIL 1
|
|
||||||
#define HAVE_CEILF 1
|
|
||||||
#define HAVE_COPYSIGN 1
|
|
||||||
#define HAVE_COPYSIGNF 1
|
|
||||||
#define HAVE_COS 1
|
|
||||||
#define HAVE_COSF 1
|
|
||||||
#define HAVE_EXP 1
|
|
||||||
#define HAVE_EXPF 1
|
|
||||||
#define HAVE_FABS 1
|
|
||||||
#define HAVE_FABSF 1
|
|
||||||
#define HAVE_FLOOR 1
|
|
||||||
#define HAVE_FLOORF 1
|
|
||||||
#define HAVE_FMOD 1
|
|
||||||
#define HAVE_FMODF 1
|
|
||||||
#define HAVE_LOG 1
|
|
||||||
#define HAVE_LOGF 1
|
|
||||||
#define HAVE_LOG10 1
|
|
||||||
#define HAVE_LOG10F 1
|
|
||||||
#define HAVE_LROUND 1
|
|
||||||
#define HAVE_LROUNDF 1
|
|
||||||
#define HAVE_POW 1
|
|
||||||
#define HAVE_POWF 1
|
|
||||||
#define HAVE_ROUND 1
|
|
||||||
#define HAVE_ROUNDF 1
|
|
||||||
#define HAVE_SCALBN 1
|
|
||||||
#define HAVE_SCALBNF 1
|
|
||||||
#define HAVE_SIN 1
|
|
||||||
#define HAVE_SINF 1
|
|
||||||
#define HAVE_SQRT 1
|
|
||||||
#define HAVE_SQRTF 1
|
|
||||||
#define HAVE_TAN 1
|
|
||||||
#define HAVE_TANF 1
|
|
||||||
#define HAVE_TRUNC 1
|
|
||||||
#define HAVE_TRUNCF 1
|
|
||||||
#define HAVE_FSEEKO 1
|
|
||||||
#define HAVE_FSEEKO64 1
|
|
||||||
#define HAVE_SIGACTION 1
|
|
||||||
#define HAVE_SA_SIGACTION 1
|
|
||||||
#define HAVE_SETJMP 1
|
|
||||||
#define HAVE_NANOSLEEP 1
|
|
||||||
#define HAVE_SYSCONF 1
|
|
||||||
#define HAVE_CLOCK_GETTIME 1
|
|
||||||
/* #undef HAVE_GETPAGESIZE */
|
|
||||||
#define HAVE_MPROTECT 1
|
|
||||||
#define HAVE_ICONV 1
|
|
||||||
|
|
||||||
/* SDL internal assertion support */
|
|
||||||
/* #undef SDL_DEFAULT_ASSERT_LEVEL */
|
|
||||||
|
|
||||||
#define SDL_CPUINFO_DISABLED 1
|
|
||||||
#define SDL_HAPTIC_DISABLED 1
|
|
||||||
#define SDL_HIDAPI_DISABLED 1
|
|
||||||
#ifndef __EMSCRIPTEN_PTHREADS__
|
|
||||||
#define SDL_THREADS_DISABLED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
|
||||||
#define SDL_AUDIO_DRIVER_DISK 1
|
|
||||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
|
||||||
#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1
|
|
||||||
|
|
||||||
/* Enable various input drivers */
|
|
||||||
#define SDL_JOYSTICK_EMSCRIPTEN 1
|
|
||||||
|
|
||||||
/* Enable various sensor drivers */
|
|
||||||
#define SDL_SENSOR_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable various shared object loading systems */
|
|
||||||
#define SDL_LOADSO_DLOPEN 1
|
|
||||||
|
|
||||||
/* Enable various threading systems */
|
|
||||||
#ifdef __EMSCRIPTEN_PTHREADS__
|
|
||||||
#define SDL_THREAD_PTHREAD 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable various timer systems */
|
|
||||||
#define SDL_TIMER_UNIX 1
|
|
||||||
|
|
||||||
/* Enable various video drivers */
|
|
||||||
#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1
|
|
||||||
|
|
||||||
#define SDL_VIDEO_RENDER_OGL_ES2 1
|
|
||||||
|
|
||||||
/* Enable OpenGL support */
|
|
||||||
/* #undef SDL_VIDEO_OPENGL */
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_ES */
|
|
||||||
#define SDL_VIDEO_OPENGL_ES2 1
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_BGL */
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_CGL */
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_GLX */
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_WGL */
|
|
||||||
#define SDL_VIDEO_OPENGL_EGL 1
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_OSMESA */
|
|
||||||
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
|
|
||||||
|
|
||||||
/* Enable system power support */
|
|
||||||
#define SDL_POWER_EMSCRIPTEN 1
|
|
||||||
|
|
||||||
/* Enable system filesystem support */
|
|
||||||
#define SDL_FILESYSTEM_EMSCRIPTEN 1
|
|
||||||
|
|
||||||
#endif /* _SDL_config_emscripten_h_ */
|
|
@ -1,215 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_iphoneos_h_
|
|
||||||
#define SDL_config_iphoneos_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
|
||||||
#define SIZEOF_VOIDP 8
|
|
||||||
#else
|
|
||||||
#define SIZEOF_VOIDP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HAVE_GCC_ATOMICS 1
|
|
||||||
|
|
||||||
#define STDC_HEADERS 1
|
|
||||||
#define HAVE_ALLOCA_H 1
|
|
||||||
#define HAVE_CTYPE_H 1
|
|
||||||
#define HAVE_INTTYPES_H 1
|
|
||||||
#define HAVE_LIMITS_H 1
|
|
||||||
#define HAVE_MATH_H 1
|
|
||||||
#define HAVE_SIGNAL_H 1
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
#define HAVE_STDIO_H 1
|
|
||||||
#define HAVE_STRING_H 1
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
|
||||||
/* The libunwind functions are only available on x86 */
|
|
||||||
/* #undef HAVE_LIBUNWIND_H */
|
|
||||||
|
|
||||||
/* C library functions */
|
|
||||||
#define HAVE_DLOPEN 1
|
|
||||||
#define HAVE_MALLOC 1
|
|
||||||
#define HAVE_CALLOC 1
|
|
||||||
#define HAVE_REALLOC 1
|
|
||||||
#define HAVE_FREE 1
|
|
||||||
#define HAVE_ALLOCA 1
|
|
||||||
#define HAVE_GETENV 1
|
|
||||||
#define HAVE_SETENV 1
|
|
||||||
#define HAVE_PUTENV 1
|
|
||||||
#define HAVE_SETENV 1
|
|
||||||
#define HAVE_UNSETENV 1
|
|
||||||
#define HAVE_QSORT 1
|
|
||||||
#define HAVE_ABS 1
|
|
||||||
#define HAVE_BCOPY 1
|
|
||||||
#define HAVE_MEMSET 1
|
|
||||||
#define HAVE_MEMCPY 1
|
|
||||||
#define HAVE_MEMMOVE 1
|
|
||||||
#define HAVE_MEMCMP 1
|
|
||||||
#define HAVE_STRLEN 1
|
|
||||||
#define HAVE_STRLCPY 1
|
|
||||||
#define HAVE_STRLCAT 1
|
|
||||||
#define HAVE_STRCHR 1
|
|
||||||
#define HAVE_STRRCHR 1
|
|
||||||
#define HAVE_STRSTR 1
|
|
||||||
#define HAVE_STRTOK_R 1
|
|
||||||
#define HAVE_STRTOL 1
|
|
||||||
#define HAVE_STRTOUL 1
|
|
||||||
#define HAVE_STRTOLL 1
|
|
||||||
#define HAVE_STRTOULL 1
|
|
||||||
#define HAVE_STRTOD 1
|
|
||||||
#define HAVE_ATOI 1
|
|
||||||
#define HAVE_ATOF 1
|
|
||||||
#define HAVE_STRCMP 1
|
|
||||||
#define HAVE_STRNCMP 1
|
|
||||||
#define HAVE_STRCASECMP 1
|
|
||||||
#define HAVE_STRNCASECMP 1
|
|
||||||
#define HAVE_VSSCANF 1
|
|
||||||
#define HAVE_VSNPRINTF 1
|
|
||||||
#define HAVE_M_PI 1
|
|
||||||
#define HAVE_ACOS 1
|
|
||||||
#define HAVE_ACOSF 1
|
|
||||||
#define HAVE_ASIN 1
|
|
||||||
#define HAVE_ASINF 1
|
|
||||||
#define HAVE_ATAN 1
|
|
||||||
#define HAVE_ATANF 1
|
|
||||||
#define HAVE_ATAN2 1
|
|
||||||
#define HAVE_ATAN2F 1
|
|
||||||
#define HAVE_CEIL 1
|
|
||||||
#define HAVE_CEILF 1
|
|
||||||
#define HAVE_COPYSIGN 1
|
|
||||||
#define HAVE_COPYSIGNF 1
|
|
||||||
#define HAVE_COS 1
|
|
||||||
#define HAVE_COSF 1
|
|
||||||
#define HAVE_EXP 1
|
|
||||||
#define HAVE_EXPF 1
|
|
||||||
#define HAVE_FABS 1
|
|
||||||
#define HAVE_FABSF 1
|
|
||||||
#define HAVE_FLOOR 1
|
|
||||||
#define HAVE_FLOORF 1
|
|
||||||
#define HAVE_FMOD 1
|
|
||||||
#define HAVE_FMODF 1
|
|
||||||
#define HAVE_LOG 1
|
|
||||||
#define HAVE_LOGF 1
|
|
||||||
#define HAVE_LOG10 1
|
|
||||||
#define HAVE_LOG10F 1
|
|
||||||
#define HAVE_LROUND 1
|
|
||||||
#define HAVE_LROUNDF 1
|
|
||||||
#define HAVE_POW 1
|
|
||||||
#define HAVE_POWF 1
|
|
||||||
#define HAVE_ROUND 1
|
|
||||||
#define HAVE_ROUNDF 1
|
|
||||||
#define HAVE_SCALBN 1
|
|
||||||
#define HAVE_SCALBNF 1
|
|
||||||
#define HAVE_SIN 1
|
|
||||||
#define HAVE_SINF 1
|
|
||||||
#define HAVE_SQRT 1
|
|
||||||
#define HAVE_SQRTF 1
|
|
||||||
#define HAVE_TAN 1
|
|
||||||
#define HAVE_TANF 1
|
|
||||||
#define HAVE_TRUNC 1
|
|
||||||
#define HAVE_TRUNCF 1
|
|
||||||
#define HAVE_SIGACTION 1
|
|
||||||
#define HAVE_SETJMP 1
|
|
||||||
#define HAVE_NANOSLEEP 1
|
|
||||||
#define HAVE_SYSCONF 1
|
|
||||||
#define HAVE_SYSCTLBYNAME 1
|
|
||||||
#define HAVE_O_CLOEXEC 1
|
|
||||||
|
|
||||||
/* enable iPhone version of Core Audio driver */
|
|
||||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
|
||||||
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
|
|
||||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
|
|
||||||
#define SDL_HAPTIC_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable joystick support */
|
|
||||||
/* Only enable HIDAPI support if you want to support Steam Controllers on iOS and tvOS */
|
|
||||||
/*#define SDL_JOYSTICK_HIDAPI 1*/
|
|
||||||
#define SDL_JOYSTICK_MFI 1
|
|
||||||
#define SDL_JOYSTICK_VIRTUAL 1
|
|
||||||
|
|
||||||
#ifdef __TVOS__
|
|
||||||
#define SDL_SENSOR_DUMMY 1
|
|
||||||
#else
|
|
||||||
/* Enable the CoreMotion sensor driver */
|
|
||||||
#define SDL_SENSOR_COREMOTION 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable Unix style SO loading */
|
|
||||||
#define SDL_LOADSO_DLOPEN 1
|
|
||||||
|
|
||||||
/* Enable various threading systems */
|
|
||||||
#define SDL_THREAD_PTHREAD 1
|
|
||||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
|
||||||
|
|
||||||
/* Enable various timer systems */
|
|
||||||
#define SDL_TIMER_UNIX 1
|
|
||||||
|
|
||||||
/* Supported video drivers */
|
|
||||||
#define SDL_VIDEO_DRIVER_UIKIT 1
|
|
||||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable OpenGL ES */
|
|
||||||
#if !TARGET_OS_MACCATALYST
|
|
||||||
#define SDL_VIDEO_OPENGL_ES2 1
|
|
||||||
#define SDL_VIDEO_OPENGL_ES 1
|
|
||||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
|
||||||
#define SDL_VIDEO_RENDER_OGL_ES2 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer
|
|
||||||
Also supported in simulator from iOS 13.0 and tvOS 13.0
|
|
||||||
*/
|
|
||||||
#if (TARGET_OS_SIMULATOR && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (__TV_OS_VERSION_MIN_REQUIRED >= 130000))) || (!TARGET_CPU_ARM && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 90000)))
|
|
||||||
#define SDL_PLATFORM_SUPPORTS_METAL 1
|
|
||||||
#else
|
|
||||||
#define SDL_PLATFORM_SUPPORTS_METAL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_PLATFORM_SUPPORTS_METAL
|
|
||||||
#define SDL_VIDEO_RENDER_METAL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_PLATFORM_SUPPORTS_METAL
|
|
||||||
#define SDL_VIDEO_VULKAN 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_PLATFORM_SUPPORTS_METAL
|
|
||||||
#define SDL_VIDEO_METAL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable system power support */
|
|
||||||
#define SDL_POWER_UIKIT 1
|
|
||||||
|
|
||||||
/* enable iPhone keyboard support */
|
|
||||||
#define SDL_IPHONE_KEYBOARD 1
|
|
||||||
|
|
||||||
/* enable iOS extended launch screen */
|
|
||||||
#define SDL_IPHONE_LAUNCHSCREEN 1
|
|
||||||
|
|
||||||
/* enable filesystem support */
|
|
||||||
#define SDL_FILESYSTEM_COCOA 1
|
|
||||||
|
|
||||||
#endif /* SDL_config_iphoneos_h_ */
|
|
@ -1,280 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_macosx_h_
|
|
||||||
#define SDL_config_macosx_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
|
|
||||||
#include <AvailabilityMacros.h>
|
|
||||||
|
|
||||||
/* This is a set of defines to configure the SDL features */
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
|
||||||
#define SIZEOF_VOIDP 8
|
|
||||||
#else
|
|
||||||
#define SIZEOF_VOIDP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Useful headers */
|
|
||||||
#define STDC_HEADERS 1
|
|
||||||
#define HAVE_ALLOCA_H 1
|
|
||||||
#define HAVE_CTYPE_H 1
|
|
||||||
#define HAVE_FLOAT_H 1
|
|
||||||
#define HAVE_INTTYPES_H 1
|
|
||||||
#define HAVE_LIMITS_H 1
|
|
||||||
#define HAVE_MATH_H 1
|
|
||||||
#define HAVE_SIGNAL_H 1
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
#define HAVE_STDIO_H 1
|
|
||||||
#define HAVE_STRING_H 1
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
|
||||||
#define HAVE_LIBUNWIND_H 1
|
|
||||||
|
|
||||||
/* C library functions */
|
|
||||||
#define HAVE_DLOPEN 1
|
|
||||||
#define HAVE_MALLOC 1
|
|
||||||
#define HAVE_CALLOC 1
|
|
||||||
#define HAVE_REALLOC 1
|
|
||||||
#define HAVE_FREE 1
|
|
||||||
#define HAVE_ALLOCA 1
|
|
||||||
#define HAVE_GETENV 1
|
|
||||||
#define HAVE_SETENV 1
|
|
||||||
#define HAVE_PUTENV 1
|
|
||||||
#define HAVE_UNSETENV 1
|
|
||||||
#define HAVE_QSORT 1
|
|
||||||
#define HAVE_ABS 1
|
|
||||||
#define HAVE_BCOPY 1
|
|
||||||
#define HAVE_MEMSET 1
|
|
||||||
#define HAVE_MEMCPY 1
|
|
||||||
#define HAVE_MEMMOVE 1
|
|
||||||
#define HAVE_MEMCMP 1
|
|
||||||
#define HAVE_STRLEN 1
|
|
||||||
#define HAVE_STRLCPY 1
|
|
||||||
#define HAVE_STRLCAT 1
|
|
||||||
#define HAVE_STRCHR 1
|
|
||||||
#define HAVE_STRRCHR 1
|
|
||||||
#define HAVE_STRSTR 1
|
|
||||||
#define HAVE_STRTOK_R 1
|
|
||||||
#define HAVE_STRTOL 1
|
|
||||||
#define HAVE_STRTOUL 1
|
|
||||||
#define HAVE_STRTOLL 1
|
|
||||||
#define HAVE_STRTOULL 1
|
|
||||||
#define HAVE_STRTOD 1
|
|
||||||
#define HAVE_ATOI 1
|
|
||||||
#define HAVE_ATOF 1
|
|
||||||
#define HAVE_STRCMP 1
|
|
||||||
#define HAVE_STRNCMP 1
|
|
||||||
#define HAVE_STRCASECMP 1
|
|
||||||
#define HAVE_STRNCASECMP 1
|
|
||||||
#define HAVE_VSSCANF 1
|
|
||||||
#define HAVE_VSNPRINTF 1
|
|
||||||
#define HAVE_M_PI 1
|
|
||||||
#define HAVE_ACOS 1
|
|
||||||
#define HAVE_ACOSF 1
|
|
||||||
#define HAVE_ASIN 1
|
|
||||||
#define HAVE_ASINF 1
|
|
||||||
#define HAVE_ATAN 1
|
|
||||||
#define HAVE_ATANF 1
|
|
||||||
#define HAVE_ATAN2 1
|
|
||||||
#define HAVE_ATAN2F 1
|
|
||||||
#define HAVE_CEIL 1
|
|
||||||
#define HAVE_CEILF 1
|
|
||||||
#define HAVE_COPYSIGN 1
|
|
||||||
#define HAVE_COPYSIGNF 1
|
|
||||||
#define HAVE_COS 1
|
|
||||||
#define HAVE_COSF 1
|
|
||||||
#define HAVE_EXP 1
|
|
||||||
#define HAVE_EXPF 1
|
|
||||||
#define HAVE_FABS 1
|
|
||||||
#define HAVE_FABSF 1
|
|
||||||
#define HAVE_FLOOR 1
|
|
||||||
#define HAVE_FLOORF 1
|
|
||||||
#define HAVE_FMOD 1
|
|
||||||
#define HAVE_FMODF 1
|
|
||||||
#define HAVE_LOG 1
|
|
||||||
#define HAVE_LOGF 1
|
|
||||||
#define HAVE_LOG10 1
|
|
||||||
#define HAVE_LOG10F 1
|
|
||||||
#define HAVE_LROUND 1
|
|
||||||
#define HAVE_LROUNDF 1
|
|
||||||
#define HAVE_POW 1
|
|
||||||
#define HAVE_POWF 1
|
|
||||||
#define HAVE_ROUND 1
|
|
||||||
#define HAVE_ROUNDF 1
|
|
||||||
#define HAVE_SCALBN 1
|
|
||||||
#define HAVE_SCALBNF 1
|
|
||||||
#define HAVE_SIN 1
|
|
||||||
#define HAVE_SINF 1
|
|
||||||
#define HAVE_SQRT 1
|
|
||||||
#define HAVE_SQRTF 1
|
|
||||||
#define HAVE_TAN 1
|
|
||||||
#define HAVE_TANF 1
|
|
||||||
#define HAVE_TRUNC 1
|
|
||||||
#define HAVE_TRUNCF 1
|
|
||||||
#define HAVE_SIGACTION 1
|
|
||||||
#define HAVE_SETJMP 1
|
|
||||||
#define HAVE_NANOSLEEP 1
|
|
||||||
#define HAVE_SYSCONF 1
|
|
||||||
#define HAVE_SYSCTLBYNAME 1
|
|
||||||
|
|
||||||
#if defined(__has_include) && (defined(__i386__) || defined(__x86_64))
|
|
||||||
# if __has_include(<immintrin.h>)
|
|
||||||
# define HAVE_IMMINTRIN_H 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
||||||
#define HAVE_O_CLOEXEC 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HAVE_GCC_ATOMICS 1
|
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
|
||||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
|
||||||
#define SDL_AUDIO_DRIVER_DISK 1
|
|
||||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable various input drivers */
|
|
||||||
#define SDL_JOYSTICK_HIDAPI 1
|
|
||||||
#define SDL_JOYSTICK_IOKIT 1
|
|
||||||
#define SDL_JOYSTICK_VIRTUAL 1
|
|
||||||
#define SDL_HAPTIC_IOKIT 1
|
|
||||||
|
|
||||||
/* The MFI controller support requires ARC Objective C runtime */
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 && !defined(__i386__)
|
|
||||||
#define SDL_JOYSTICK_MFI 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable the dummy sensor driver */
|
|
||||||
#define SDL_SENSOR_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable various shared object loading systems */
|
|
||||||
#define SDL_LOADSO_DLOPEN 1
|
|
||||||
|
|
||||||
/* Enable various threading systems */
|
|
||||||
#define SDL_THREAD_PTHREAD 1
|
|
||||||
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
|
|
||||||
|
|
||||||
/* Enable various timer systems */
|
|
||||||
#define SDL_TIMER_UNIX 1
|
|
||||||
|
|
||||||
/* Enable various video drivers */
|
|
||||||
#define SDL_VIDEO_DRIVER_COCOA 1
|
|
||||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
|
||||||
#undef SDL_VIDEO_DRIVER_X11
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/opt/X11/lib/libX11.6.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/opt/X11/lib/libXext.6.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/opt/X11/lib/libXinerama.1.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/opt/X11/lib/libXi.6.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/opt/X11/lib/libXrandr.2.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/opt/X11/lib/libXss.1.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/opt/X11/lib/libXxf86vm.1.dylib"
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XDBE 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XRANDR 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
|
|
||||||
|
|
||||||
#ifdef MAC_OS_X_VERSION_10_8
|
|
||||||
/*
|
|
||||||
* No matter the versions targeted, this is the 10.8 or later SDK, so you have
|
|
||||||
* to use the external Xquartz, which is a more modern Xlib. Previous SDKs
|
|
||||||
* used an older Xlib.
|
|
||||||
*/
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_XINPUT2 1
|
|
||||||
#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SDL_VIDEO_RENDER_OGL
|
|
||||||
#define SDL_VIDEO_RENDER_OGL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SDL_VIDEO_RENDER_OGL_ES2
|
|
||||||
#define SDL_VIDEO_RENDER_OGL_ES2 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Metal only supported on 64-bit architectures with 10.11+ */
|
|
||||||
#if TARGET_RT_64_BIT && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
|
|
||||||
#define SDL_PLATFORM_SUPPORTS_METAL 1
|
|
||||||
#else
|
|
||||||
#define SDL_PLATFORM_SUPPORTS_METAL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SDL_VIDEO_RENDER_METAL
|
|
||||||
#if SDL_PLATFORM_SUPPORTS_METAL
|
|
||||||
#define SDL_VIDEO_RENDER_METAL 1
|
|
||||||
#else
|
|
||||||
#define SDL_VIDEO_RENDER_METAL 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable OpenGL support */
|
|
||||||
#ifndef SDL_VIDEO_OPENGL
|
|
||||||
#define SDL_VIDEO_OPENGL 1
|
|
||||||
#endif
|
|
||||||
#ifndef SDL_VIDEO_OPENGL_ES2
|
|
||||||
#define SDL_VIDEO_OPENGL_ES2 1
|
|
||||||
#endif
|
|
||||||
#ifndef SDL_VIDEO_OPENGL_EGL
|
|
||||||
#define SDL_VIDEO_OPENGL_EGL 1
|
|
||||||
#endif
|
|
||||||
#ifndef SDL_VIDEO_OPENGL_CGL
|
|
||||||
#define SDL_VIDEO_OPENGL_CGL 1
|
|
||||||
#endif
|
|
||||||
#ifndef SDL_VIDEO_OPENGL_GLX
|
|
||||||
#define SDL_VIDEO_OPENGL_GLX 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable Vulkan and Metal support */
|
|
||||||
#ifndef SDL_VIDEO_VULKAN
|
|
||||||
#if SDL_PLATFORM_SUPPORTS_METAL
|
|
||||||
#define SDL_VIDEO_VULKAN 1
|
|
||||||
#else
|
|
||||||
#define SDL_VIDEO_VULKAN 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SDL_VIDEO_METAL
|
|
||||||
#if SDL_PLATFORM_SUPPORTS_METAL
|
|
||||||
#define SDL_VIDEO_METAL 1
|
|
||||||
#else
|
|
||||||
#define SDL_VIDEO_METAL 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable system power support */
|
|
||||||
#define SDL_POWER_MACOSX 1
|
|
||||||
|
|
||||||
/* enable filesystem support */
|
|
||||||
#define SDL_FILESYSTEM_COCOA 1
|
|
||||||
|
|
||||||
/* Enable assembly routines */
|
|
||||||
#define SDL_ASSEMBLY_ROUTINES 1
|
|
||||||
#ifdef __ppc__
|
|
||||||
#define SDL_ALTIVEC_BLITTERS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* SDL_config_macosx_h_ */
|
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDL_config_minimal_h_
|
|
||||||
#define SDL_config_minimal_h_
|
|
||||||
#define SDL_config_h_
|
|
||||||
|
|
||||||
#include "SDL_platform.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file SDL_config_minimal.h
|
|
||||||
*
|
|
||||||
* This is the minimal configuration that can be used to build SDL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define HAVE_STDARG_H 1
|
|
||||||
#define HAVE_STDDEF_H 1
|
|
||||||
|
|
||||||
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
|
||||||
/* Here are some reasonable defaults */
|
|
||||||
typedef unsigned int size_t;
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef signed int int32_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef signed long long int64_t;
|
|
||||||
typedef unsigned long long uint64_t;
|
|
||||||
typedef unsigned long uintptr_t;
|
|
||||||
#else
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
#endif /* Visual Studio 2008 */
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
|
|
||||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
|
|
||||||
#define SDL_JOYSTICK_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
|
|
||||||
#define SDL_HAPTIC_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the stub HIDAPI */
|
|
||||||
#define SDL_HIDAPI_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */
|
|
||||||
#define SDL_SENSOR_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
|
|
||||||
#define SDL_LOADSO_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the stub thread support (src/thread/generic/\*.c) */
|
|
||||||
#define SDL_THREADS_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the stub timer support (src/timer/dummy/\*.c) */
|
|
||||||
#define SDL_TIMERS_DISABLED 1
|
|
||||||
|
|
||||||
/* Enable the dummy video driver (src/video/dummy/\*.c) */
|
|
||||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
|
||||||
|
|
||||||
/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
|
|
||||||
#define SDL_FILESYSTEM_DUMMY 1
|
|
||||||
|
|
||||||
#endif /* SDL_config_minimal_h_ */
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user