mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-09-07 04:42:45 +02:00
3rdParty: remove mupen64plus-input-gca
This commit is contained in:
@@ -12,7 +12,6 @@ option(VRU "Enables VRU support in RMG-Input" ON)
|
||||
option(USE_CCACHE "Enables usage of ccache when ccache has been found" ON)
|
||||
option(USE_LTO "Enables building with LTO/IPO when compiler supports it" ON)
|
||||
option(NO_ASM "Disables the usage of assembly in the mupen64plus-core" OFF)
|
||||
option(NO_RUST "Disables the building of rust subprojects" OFF)
|
||||
option(USE_LIBFMT "Enables usage of libfmt instead of detecting whether std::format is supported" OFF)
|
||||
option(USE_ANGRYLION "Enables building angrylion-rdp-plus which uses a non-GPL compliant license" OFF)
|
||||
|
||||
@@ -202,10 +201,6 @@ install(FILES ${MUPEN64PLUS_PLUGIN_INPUT_RAPHNET}
|
||||
DESTINATION ${PLUGIN_INSTALL_PATH}/Input
|
||||
PERMISSIONS ${LIB_PERMISSIONS}
|
||||
)
|
||||
install(FILES ${MUPEN64PLUS_PLUGIN_INPUT_GCA}
|
||||
DESTINATION ${PLUGIN_INSTALL_PATH}/Input
|
||||
PERMISSIONS ${LIB_PERMISSIONS}
|
||||
)
|
||||
if (USE_ANGRYLION)
|
||||
install(FILES ${MUPEN64PLUS_PLUGIN_GFX_ANGRYLION}
|
||||
DESTINATION ${PLUGIN_INSTALL_PATH}/GFX
|
||||
|
||||
Vendored
-30
@@ -5,16 +5,6 @@ include(ExternalProject)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
find_program(RUST_CARGO cargo)
|
||||
if(NO_RUST)
|
||||
set(BUILD_INPUT_GCA OFF)
|
||||
elseif(${RUST_CARGO} STREQUAL "RUST_CARGO-NOTFOUND")
|
||||
message(WARNING "mupen64plus-input-gca will not be built due to not having cargo installed")
|
||||
set(BUILD_INPUT_GCA OFF)
|
||||
else()
|
||||
set(BUILD_INPUT_GCA ON)
|
||||
endif()
|
||||
|
||||
set(M64P_CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/mupen64plus-core)
|
||||
if(WIN32)
|
||||
set(SO_EXT "dll")
|
||||
@@ -172,21 +162,6 @@ ExternalProject_Add(mupen64plus-input-raphnetraw
|
||||
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/mupen64plus-input-raphnetraw/mupen64plus-input-raphnetraw.${SO_EXT}
|
||||
)
|
||||
|
||||
if (BUILD_INPUT_GCA)
|
||||
ExternalProject_Add(mupen64plus-input-gca
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/mupen64plus-input-gca/
|
||||
|
||||
CONFIGURE_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
|
||||
BUILD_COMMAND cargo build --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/mupen64plus-input-gca/Cargo.toml --release --features "m64p_compat" --target-dir=${CMAKE_CURRENT_BINARY_DIR}/mupen64plus-input-gca/target
|
||||
BUILD_IN_SOURCE False
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/mupen64plus-input-gca/target/release
|
||||
|
||||
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/mupen64plus-input-gca/target/release/${GCA_LIB}
|
||||
)
|
||||
endif(BUILD_INPUT_GCA)
|
||||
|
||||
set(GLIDEN64_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mupen64plus-video-GLideN64")
|
||||
set(GLIDEN64_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/mupen64plus-video-GLideN64")
|
||||
set(GLIDEN64_CUSTOM_INI "${GLIDEN64_DIR}/ini/GLideN64.custom.ini")
|
||||
@@ -294,11 +269,6 @@ set(MUPEN64PLUS_PLUGIN_RSP_PARALLEL ${BUILD_BYPRODUCTS} PARENT_SCOPE)
|
||||
ExternalProject_Get_property(mupen64plus-input-raphnetraw BUILD_BYPRODUCTS)
|
||||
set(MUPEN64PLUS_PLUGIN_INPUT_RAPHNET ${BUILD_BYPRODUCTS} PARENT_SCOPE)
|
||||
|
||||
if (BUILD_INPUT_GCA)
|
||||
ExternalProject_Get_property(mupen64plus-input-gca BUILD_BYPRODUCTS)
|
||||
set(MUPEN64PLUS_PLUGIN_INPUT_GCA ${BUILD_BYPRODUCTS} PARENT_SCOPE)
|
||||
endif(BUILD_INPUT_GCA)
|
||||
|
||||
if (USE_ANGRYLION)
|
||||
ExternalProject_Get_property(mupen64plus-video-angrylion-plus BUILD_BYPRODUCTS)
|
||||
set(MUPEN64PLUS_PLUGIN_GFX_ANGRYLION ${BUILD_BYPRODUCTS} PARENT_SCOPE)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# Statically link the C runtime on Windows MSVC
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
||||
@@ -1,136 +0,0 @@
|
||||
# Inspired by: https://github.com/BurntSushi/ripgrep/blob/df83b8b44426b3f2179abe632eb183e8c8270524/.github/workflows/release.yml
|
||||
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
# Enable when testing release infrastructure on a branch.
|
||||
# branches:
|
||||
# - test-ci
|
||||
tags:
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
jobs:
|
||||
create-release:
|
||||
name: create-release
|
||||
runs-on: ubuntu-latest
|
||||
# env:
|
||||
# Set to force version number, e.g., when no tag exists.
|
||||
# PLUGIN_VERSION: TEST-0.0.0
|
||||
outputs:
|
||||
upload_url: ${{ steps.release.outputs.upload_url }}
|
||||
plugin_version: ${{ env.PLUGIN_VERSION }}
|
||||
steps:
|
||||
- name: Get the release version from the tag
|
||||
shell: bash
|
||||
if: env.PLUGIN_VERSION == ''
|
||||
run: |
|
||||
# Apparently, this is the right way to get a tag name. Really?
|
||||
#
|
||||
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
|
||||
echo "PLUGIN_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
echo "version is: ${{ env.PLUGIN_VERSION }}"
|
||||
- name: Create GitHub release
|
||||
id: release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ env.PLUGIN_VERSION }}
|
||||
release_name: ${{ env.PLUGIN_VERSION }}
|
||||
draft: true
|
||||
|
||||
build-release:
|
||||
name: build-release
|
||||
needs: ['create-release']
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
FEATURES_FLAG: ""
|
||||
# Emit backtraces on panics.
|
||||
RUST_BACKTRACE: 1
|
||||
strategy:
|
||||
matrix:
|
||||
# TODO: Remove compat builds when not needed anymore
|
||||
build: [linux, linux-m64p-compat, macos, macos-m64p-compat, windows, windows-m64p-compat]
|
||||
include:
|
||||
- build: linux
|
||||
os: ubuntu-18.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
features: ""
|
||||
file_ext: so
|
||||
- build: linux-m64p-compat
|
||||
os: ubuntu-18.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
features: m64p_compat
|
||||
file_ext: so
|
||||
- build: macos
|
||||
os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
features: ""
|
||||
file_ext: dylib
|
||||
- build: macos-m64p-compat
|
||||
os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
features: m64p_compat
|
||||
file_ext: dylib
|
||||
- build: windows
|
||||
os: windows-2019
|
||||
target: x86_64-pc-windows-msvc
|
||||
features: ""
|
||||
file_ext: dll
|
||||
- build: windows-m64p-compat
|
||||
os: windows-2019
|
||||
target: x86_64-pc-windows-msvc
|
||||
features: m64p_compat
|
||||
file_ext: dll
|
||||
|
||||
steps:
|
||||
- name: Set features flag
|
||||
if: matrix.features != ''
|
||||
shell: bash
|
||||
run: |
|
||||
echo "FEATURES_FLAG=--features ${{ matrix.features }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
profile: minimal
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --verbose --release ${{ env.FEATURES_FLAG }} --target ${{ matrix.target }}
|
||||
|
||||
- name: Strip release binary (linux and macos)
|
||||
if: matrix.os != 'windows-2019'
|
||||
run: strip -x "target/${{ matrix.target }}/release/libmupen64plus_input_gca.${{ matrix.file_ext }}"
|
||||
|
||||
- name: Build archive
|
||||
shell: bash
|
||||
run: |
|
||||
filename="mupen64plus-input-gca.${{ matrix.file_ext }}"
|
||||
archive="mupen64plus-input-gca-${{ needs.create-release.outputs.plugin_version }}-x86_64-${{ matrix.build }}"
|
||||
|
||||
if [ "${{ matrix.os }}" = "windows-2019" ]; then
|
||||
cp "target/${{ matrix.target }}/release/mupen64plus_input_gca.dll" "$filename"
|
||||
7z a "$archive.zip" "$filename"
|
||||
else
|
||||
cp "target/${{ matrix.target }}/release/libmupen64plus_input_gca.${{ matrix.file_ext }}" "$filename"
|
||||
zip "$archive.zip" "$filename"
|
||||
fi
|
||||
|
||||
echo "ASSET=$archive.zip" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload release archive
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ${{ env.ASSET }}
|
||||
asset_name: ${{ env.ASSET }}
|
||||
asset_content_type: application/octet-stream
|
||||
@@ -1,2 +0,0 @@
|
||||
/target
|
||||
Cargo.lock
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
; DO NOT EDIT (unless you know what you are doing)
|
||||
;
|
||||
; This subdirectory is a git "subrepo", and this file is maintained by the
|
||||
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
|
||||
;
|
||||
[subrepo]
|
||||
remote = git@github.com:/amatho/mupen64plus-input-gca.git
|
||||
branch = 21639fb13dfa797a7c0949ffd9bbda9a3456fc69
|
||||
commit = 21639fb13dfa797a7c0949ffd9bbda9a3456fc69
|
||||
parent = 6d1da7514cee26f3ce4b0f3132cf8abb62389c38
|
||||
method = merge
|
||||
cmdver = 0.4.6
|
||||
@@ -1,23 +0,0 @@
|
||||
[package]
|
||||
name = "mupen64plus-input-gca"
|
||||
version = "0.6.0"
|
||||
authors = ["Amandus Søve Thorsrud <ama.thorsrud@gmail.com>"]
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
libloading = "0.7.0"
|
||||
rusb = "0.9.0"
|
||||
once_cell = "1.9"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
toml = "0.5"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
m64p_compat = []
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Amandus Søve Thorsrud
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
# mupen64plus-input-gca
|
||||
|
||||
An input plugin for Mupen64Plus using the GameCube controller adapter for Wii U and Switch.
|
||||
|
||||
## Installing
|
||||
|
||||
**Note:** There are currently only builds for 64-bit Mupen64Plus.
|
||||
|
||||
1. Follow the first section of [this Dolphin guide](https://dolphin-emu.org/docs/guides/how-use-official-gc-controller-adapter-wii-u#Installation) to set up your adapter (use Zadig if you are on Windows).
|
||||
|
||||
1. Download the plugin ZIP from [the latest release](../../releases/latest).
|
||||
|
||||
1. Extract the plugin into your Mupen64Plus folder.
|
||||
|
||||
## Usage
|
||||
|
||||
Select the plugin in your Mupen64Plus frontend and connect your adapter, and you are good to go!
|
||||
|
||||
## Configuration
|
||||
|
||||
After the plugin has been used at least once, a file will be generated in your Mupen64Plus user configuration folder named
|
||||
`mupen64plus-input-gca.toml`. The default location of the Mupen64Plus user configuration folder is
|
||||
|
||||
* `C:\Users\<username>\AppData\Roaming\Mupen64Plus\`, on Windows
|
||||
* `$XDG_CONFIG_HOME/mupen64plus/` or `$HOME/.config/mupen64plus/`, on Linux
|
||||
* `$HOME/Library/Application Support/Mupen64Plus/`, on macOS.
|
||||
|
||||
This file contains the configuration for the plugin. Changes in the configuration will be
|
||||
loaded the next time you start your frontend.
|
||||
|
||||
You can configure the following:
|
||||
|
||||
* Deadzones for the control stick and C-stick.
|
||||
* Control stick sensitivity.
|
||||
* Note that the default sensitivity setting is based on the controllers I had available when testing. All GameCube
|
||||
controllers are different, so you might need to change this to something that works for you. Having the sensitivity
|
||||
too low will prevent you from reaching the maximum input with the stick, and having it too high will make it
|
||||
difficult to control.
|
||||
* Threshold for the trigger buttons (L and R).
|
||||
* This controls how far the triggers need to be pressed before an input is registered.
|
||||
* The controller mapping between the GameCube controller and the N64 buttons.
|
||||
|
||||
The default controller mapping is what you would expect, except for:
|
||||
|
||||
* Y is C-button left
|
||||
* X is C-button right
|
||||
* L and Z are swapped (GC L is N64 Z and GC Z is N64 L)
|
||||
|
||||
## Building
|
||||
|
||||
Build requirements:
|
||||
|
||||
* Cargo
|
||||
|
||||
To build the project:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/amatho/mupen64plus-input-gca
|
||||
$ cd mupen64plus-input-gca
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
The compiled plugin will be at `target/release/mupen64plus_input_gca.(dll|dylib|so)`.
|
||||
|
||||
**Note:** The compiled dynamic library will have underscores in it's name, but m64p (linked above) will only look for plugins with hyphens. Just rename the file and m64p will find it.
|
||||
|
||||
`bindgen` is used to generate the Rust bindings for the Mupen64Plus API found in `src/ffi/`. See [the `bindgen` User Guide](https://rust-lang.github.io/rust-bindgen/command-line-usage.html)
|
||||
for installation instructions, and [this section of the guide](https://rust-lang.github.io/rust-bindgen/requirements.html) for requirements for running `bindgen`.
|
||||
|
||||
## Contributing
|
||||
|
||||
Feel free to open issues or pull requests.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the MIT license, see [LICENSE](LICENSE). For external code in `extern` (headers from the Mupen64Plus-Core API), see [LICENSES](extern/LICENSES).
|
||||
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -1,34 +0,0 @@
|
||||
Mupen64Plus-Core LICENSES
|
||||
-------------------------
|
||||
|
||||
Mupen64Plus-Core is licensed under the GNU General Public License version 2. Please see the
|
||||
included ./LICENSE file for the terms and conditions of the GNU General Public License.
|
||||
The authors of Mupen64Plus-Core are:
|
||||
* Richard Goedeken (Richard42)
|
||||
* Sven Eckelmann (ecsv)
|
||||
* John Chadwick (NMN)
|
||||
* James Hood (Ebenblues)
|
||||
* Scott Gorman (okaygo)
|
||||
* Scott Knauert (Tillin9)
|
||||
* Jesse Dean (DarkJezter)
|
||||
* Louai Al-Khanji (slougi)
|
||||
* Bob Forder (orbitaldecay)
|
||||
* Jason Espinosa (hasone)
|
||||
* Bobby Smiles (bsmiles32)
|
||||
* Dorian Fevrier (Narann)
|
||||
* Richard Hender (ricrpi)
|
||||
* Will Nayes (wnayes)
|
||||
* Conchur Navid
|
||||
* Gillou68310
|
||||
* HyperHacker
|
||||
* littleguy77
|
||||
* Nebuleon
|
||||
* and others.
|
||||
|
||||
Mupen64Plus is based on GPL-licensed source code from Mupen64 v0.5, originally written by:
|
||||
* Hacktarux
|
||||
* Dave2001
|
||||
* Zilmar
|
||||
* Gregor Anich (Blight)
|
||||
* Juha Luotio (JttL)
|
||||
* and others.
|
||||
@@ -1,287 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Mupen64plus-core - m64p_plugin.h *
|
||||
* Mupen64Plus homepage: https://mupen64plus.org/ *
|
||||
* Copyright (C) 2002 Hacktarux *
|
||||
* Copyright (C) 2009 Richard Goedeken *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#if !defined(M64P_PLUGIN_H)
|
||||
#define M64P_PLUGIN_H
|
||||
|
||||
#include "m64p_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*** Controller plugin's ****/
|
||||
#define PLUGIN_NONE 1
|
||||
#define PLUGIN_MEMPAK 2
|
||||
#define PLUGIN_RUMBLE_PAK 3 /* not implemented for non raw data */
|
||||
#define PLUGIN_TRANSFER_PAK 4 /* not implemented for non raw data */
|
||||
#define PLUGIN_RAW 5 /* the controller plugin is passed in raw data */
|
||||
#define PLUGIN_BIO_PAK 6
|
||||
|
||||
/***** Structures *****/
|
||||
typedef struct {
|
||||
unsigned char * RDRAM;
|
||||
unsigned char * DMEM;
|
||||
unsigned char * IMEM;
|
||||
|
||||
unsigned int * MI_INTR_REG;
|
||||
|
||||
unsigned int * SP_MEM_ADDR_REG;
|
||||
unsigned int * SP_DRAM_ADDR_REG;
|
||||
unsigned int * SP_RD_LEN_REG;
|
||||
unsigned int * SP_WR_LEN_REG;
|
||||
unsigned int * SP_STATUS_REG;
|
||||
unsigned int * SP_DMA_FULL_REG;
|
||||
unsigned int * SP_DMA_BUSY_REG;
|
||||
unsigned int * SP_PC_REG;
|
||||
unsigned int * SP_SEMAPHORE_REG;
|
||||
|
||||
unsigned int * DPC_START_REG;
|
||||
unsigned int * DPC_END_REG;
|
||||
unsigned int * DPC_CURRENT_REG;
|
||||
unsigned int * DPC_STATUS_REG;
|
||||
unsigned int * DPC_CLOCK_REG;
|
||||
unsigned int * DPC_BUFBUSY_REG;
|
||||
unsigned int * DPC_PIPEBUSY_REG;
|
||||
unsigned int * DPC_TMEM_REG;
|
||||
|
||||
void (*CheckInterrupts)(void);
|
||||
void (*ProcessDlistList)(void);
|
||||
void (*ProcessAlistList)(void);
|
||||
void (*ProcessRdpList)(void);
|
||||
void (*ShowCFB)(void);
|
||||
} RSP_INFO;
|
||||
|
||||
typedef struct {
|
||||
unsigned char * HEADER; /* This is the rom header (first 40h bytes of the rom) */
|
||||
unsigned char * RDRAM;
|
||||
unsigned char * DMEM;
|
||||
unsigned char * IMEM;
|
||||
|
||||
unsigned int * MI_INTR_REG;
|
||||
|
||||
unsigned int * DPC_START_REG;
|
||||
unsigned int * DPC_END_REG;
|
||||
unsigned int * DPC_CURRENT_REG;
|
||||
unsigned int * DPC_STATUS_REG;
|
||||
unsigned int * DPC_CLOCK_REG;
|
||||
unsigned int * DPC_BUFBUSY_REG;
|
||||
unsigned int * DPC_PIPEBUSY_REG;
|
||||
unsigned int * DPC_TMEM_REG;
|
||||
|
||||
unsigned int * VI_STATUS_REG;
|
||||
unsigned int * VI_ORIGIN_REG;
|
||||
unsigned int * VI_WIDTH_REG;
|
||||
unsigned int * VI_INTR_REG;
|
||||
unsigned int * VI_V_CURRENT_LINE_REG;
|
||||
unsigned int * VI_TIMING_REG;
|
||||
unsigned int * VI_V_SYNC_REG;
|
||||
unsigned int * VI_H_SYNC_REG;
|
||||
unsigned int * VI_LEAP_REG;
|
||||
unsigned int * VI_H_START_REG;
|
||||
unsigned int * VI_V_START_REG;
|
||||
unsigned int * VI_V_BURST_REG;
|
||||
unsigned int * VI_X_SCALE_REG;
|
||||
unsigned int * VI_Y_SCALE_REG;
|
||||
|
||||
void (*CheckInterrupts)(void);
|
||||
|
||||
/* The GFX_INFO.version parameter was added in version 2.5.1 of the core.
|
||||
Plugins should ensure the core is at least this version before
|
||||
attempting to read GFX_INFO.version. */
|
||||
unsigned int version;
|
||||
/* SP_STATUS_REG and RDRAM_SIZE were added in version 2 of GFX_INFO.version.
|
||||
Plugins should only attempt to read these values if GFX_INFO.version is at least 2. */
|
||||
|
||||
/* The RSP plugin should set (HALT | BROKE | TASKDONE) *before* calling ProcessDList.
|
||||
It should not modify SP_STATUS_REG after ProcessDList has returned.
|
||||
This will allow the GFX plugin to unset these bits if it needs. */
|
||||
unsigned int * SP_STATUS_REG;
|
||||
const unsigned int * RDRAM_SIZE;
|
||||
} GFX_INFO;
|
||||
|
||||
typedef struct {
|
||||
unsigned char * RDRAM;
|
||||
unsigned char * DMEM;
|
||||
unsigned char * IMEM;
|
||||
|
||||
unsigned int * MI_INTR_REG;
|
||||
|
||||
unsigned int * AI_DRAM_ADDR_REG;
|
||||
unsigned int * AI_LEN_REG;
|
||||
unsigned int * AI_CONTROL_REG;
|
||||
unsigned int * AI_STATUS_REG;
|
||||
unsigned int * AI_DACRATE_REG;
|
||||
unsigned int * AI_BITRATE_REG;
|
||||
|
||||
void (*CheckInterrupts)(void);
|
||||
} AUDIO_INFO;
|
||||
|
||||
typedef struct {
|
||||
int Present;
|
||||
int RawData;
|
||||
int Plugin;
|
||||
} CONTROL;
|
||||
|
||||
typedef union {
|
||||
unsigned int Value;
|
||||
struct {
|
||||
unsigned R_DPAD : 1;
|
||||
unsigned L_DPAD : 1;
|
||||
unsigned D_DPAD : 1;
|
||||
unsigned U_DPAD : 1;
|
||||
unsigned START_BUTTON : 1;
|
||||
unsigned Z_TRIG : 1;
|
||||
unsigned B_BUTTON : 1;
|
||||
unsigned A_BUTTON : 1;
|
||||
|
||||
unsigned R_CBUTTON : 1;
|
||||
unsigned L_CBUTTON : 1;
|
||||
unsigned D_CBUTTON : 1;
|
||||
unsigned U_CBUTTON : 1;
|
||||
unsigned R_TRIG : 1;
|
||||
unsigned L_TRIG : 1;
|
||||
unsigned Reserved1 : 1;
|
||||
unsigned Reserved2 : 1;
|
||||
|
||||
signed X_AXIS : 8;
|
||||
signed Y_AXIS : 8;
|
||||
};
|
||||
} BUTTONS;
|
||||
|
||||
typedef struct {
|
||||
CONTROL *Controls; /* A pointer to an array of 4 controllers .. eg:
|
||||
CONTROL Controls[4]; */
|
||||
} CONTROL_INFO;
|
||||
|
||||
/* common plugin function pointer types */
|
||||
typedef void (*ptr_RomClosed)(void);
|
||||
typedef int (*ptr_RomOpen)(void);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES)
|
||||
EXPORT int CALL RomOpen(void);
|
||||
EXPORT void CALL RomClosed(void);
|
||||
#endif
|
||||
|
||||
/* video plugin function pointer types */
|
||||
typedef void (*ptr_ChangeWindow)(void);
|
||||
typedef int (*ptr_InitiateGFX)(GFX_INFO Gfx_Info);
|
||||
typedef void (*ptr_MoveScreen)(int x, int y);
|
||||
typedef void (*ptr_ProcessDList)(void);
|
||||
typedef void (*ptr_ProcessRDPList)(void);
|
||||
typedef void (*ptr_ShowCFB)(void);
|
||||
typedef void (*ptr_UpdateScreen)(void);
|
||||
typedef void (*ptr_ViStatusChanged)(void);
|
||||
typedef void (*ptr_ViWidthChanged)(void);
|
||||
typedef void (*ptr_ReadScreen2)(void *dest, int *width, int *height, int front);
|
||||
typedef void (*ptr_SetRenderingCallback)(void (*callback)(int));
|
||||
typedef void (*ptr_ResizeVideoOutput)(int width, int height);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES)
|
||||
EXPORT void CALL ChangeWindow(void);
|
||||
EXPORT int CALL InitiateGFX(GFX_INFO Gfx_Info);
|
||||
EXPORT void CALL MoveScreen(int x, int y);
|
||||
EXPORT void CALL ProcessDList(void);
|
||||
EXPORT void CALL ProcessRDPList(void);
|
||||
EXPORT void CALL ShowCFB(void);
|
||||
EXPORT void CALL UpdateScreen(void);
|
||||
EXPORT void CALL ViStatusChanged(void);
|
||||
EXPORT void CALL ViWidthChanged(void);
|
||||
EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front);
|
||||
EXPORT void CALL SetRenderingCallback(void (*callback)(int));
|
||||
EXPORT void CALL ResizeVideoOutput(int width, int height);
|
||||
#endif
|
||||
|
||||
/* frame buffer plugin spec extension */
|
||||
typedef struct
|
||||
{
|
||||
unsigned int addr;
|
||||
unsigned int size;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
} FrameBufferInfo;
|
||||
typedef void (*ptr_FBRead)(unsigned int addr);
|
||||
typedef void (*ptr_FBWrite)(unsigned int addr, unsigned int size);
|
||||
typedef void (*ptr_FBGetFrameBufferInfo)(void *p);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES)
|
||||
EXPORT void CALL FBRead(unsigned int addr);
|
||||
EXPORT void CALL FBWrite(unsigned int addr, unsigned int size);
|
||||
EXPORT void CALL FBGetFrameBufferInfo(void *p);
|
||||
#endif
|
||||
|
||||
/* audio plugin function pointers */
|
||||
typedef void (*ptr_AiDacrateChanged)(int SystemType);
|
||||
typedef void (*ptr_AiLenChanged)(void);
|
||||
typedef int (*ptr_InitiateAudio)(AUDIO_INFO Audio_Info);
|
||||
typedef void (*ptr_ProcessAList)(void);
|
||||
typedef void (*ptr_SetSpeedFactor)(int percent);
|
||||
typedef void (*ptr_VolumeUp)(void);
|
||||
typedef void (*ptr_VolumeDown)(void);
|
||||
typedef int (*ptr_VolumeGetLevel)(void);
|
||||
typedef void (*ptr_VolumeSetLevel)(int level);
|
||||
typedef void (*ptr_VolumeMute)(void);
|
||||
typedef const char * (*ptr_VolumeGetString)(void);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES)
|
||||
EXPORT void CALL AiDacrateChanged(int SystemType);
|
||||
EXPORT void CALL AiLenChanged(void);
|
||||
EXPORT int CALL InitiateAudio(AUDIO_INFO Audio_Info);
|
||||
EXPORT void CALL ProcessAList(void);
|
||||
EXPORT void CALL SetSpeedFactor(int percent);
|
||||
EXPORT void CALL VolumeUp(void);
|
||||
EXPORT void CALL VolumeDown(void);
|
||||
EXPORT int CALL VolumeGetLevel(void);
|
||||
EXPORT void CALL VolumeSetLevel(int level);
|
||||
EXPORT void CALL VolumeMute(void);
|
||||
EXPORT const char * CALL VolumeGetString(void);
|
||||
#endif
|
||||
|
||||
/* input plugin function pointers */
|
||||
typedef void (*ptr_ControllerCommand)(int Control, unsigned char *Command);
|
||||
typedef void (*ptr_GetKeys)(int Control, BUTTONS *Keys);
|
||||
typedef void (*ptr_InitiateControllers)(CONTROL_INFO ControlInfo);
|
||||
typedef void (*ptr_ReadController)(int Control, unsigned char *Command);
|
||||
typedef void (*ptr_SDL_KeyDown)(int keymod, int keysym);
|
||||
typedef void (*ptr_SDL_KeyUp)(int keymod, int keysym);
|
||||
typedef void (*ptr_RenderCallback)(void);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES)
|
||||
EXPORT void CALL ControllerCommand(int Control, unsigned char *Command);
|
||||
EXPORT void CALL GetKeys(int Control, BUTTONS *Keys);
|
||||
EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo);
|
||||
EXPORT void CALL ReadController(int Control, unsigned char *Command);
|
||||
EXPORT void CALL SDL_KeyDown(int keymod, int keysym);
|
||||
EXPORT void CALL SDL_KeyUp(int keymod, int keysym);
|
||||
EXPORT void CALL RenderCallback(void);
|
||||
#endif
|
||||
|
||||
/* RSP plugin function pointers */
|
||||
typedef unsigned int (*ptr_DoRspCycles)(unsigned int Cycles);
|
||||
typedef void (*ptr_InitiateRSP)(RSP_INFO Rsp_Info, unsigned int *CycleCount);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES)
|
||||
EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles);
|
||||
EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, unsigned int *CycleCount);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* M64P_PLUGIN_H */
|
||||
|
||||
|
||||
@@ -1,415 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Mupen64plus-core - m64p_types.h *
|
||||
* Mupen64Plus homepage: https://mupen64plus.org/ *
|
||||
* Copyright (C) 2012 CasualJames *
|
||||
* Copyright (C) 2009 Richard Goedeken *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#if !defined(M64P_TYPES_H)
|
||||
#define M64P_TYPES_H
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Platform-specific stuff */
|
||||
/* ----------------------------------------- */
|
||||
|
||||
/* necessary headers */
|
||||
#include <stdint.h>
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* DLL handles and function declaration specifiers */
|
||||
#if defined(WIN32)
|
||||
#define IMPORT extern "C" __declspec(dllimport)
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#define CALL __cdecl
|
||||
typedef HMODULE m64p_dynlib_handle;
|
||||
#else
|
||||
#define IMPORT extern "C"
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
#define CALL
|
||||
typedef void * m64p_dynlib_handle;
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Structures and Types for Core library API */
|
||||
/* ----------------------------------------- */
|
||||
|
||||
typedef void * m64p_handle;
|
||||
|
||||
/* Generic function pointer returned from osal_dynlib_getproc (and the like)
|
||||
* Don't use it directly, cast to proper type before using it.
|
||||
*/
|
||||
typedef void (*m64p_function)(void);
|
||||
|
||||
typedef void (*m64p_frame_callback)(unsigned int FrameIndex);
|
||||
typedef void (*m64p_input_callback)(void);
|
||||
typedef void (*m64p_audio_callback)(void);
|
||||
typedef void (*m64p_vi_callback)(void);
|
||||
|
||||
typedef enum {
|
||||
M64TYPE_INT = 1,
|
||||
M64TYPE_FLOAT,
|
||||
M64TYPE_BOOL,
|
||||
M64TYPE_STRING
|
||||
} m64p_type;
|
||||
|
||||
typedef enum {
|
||||
M64MSG_ERROR = 1,
|
||||
M64MSG_WARNING,
|
||||
M64MSG_INFO,
|
||||
M64MSG_STATUS,
|
||||
M64MSG_VERBOSE
|
||||
} m64p_msg_level;
|
||||
|
||||
typedef enum {
|
||||
M64ERR_SUCCESS = 0,
|
||||
M64ERR_NOT_INIT, /* Function is disallowed before InitMupen64Plus() is called */
|
||||
M64ERR_ALREADY_INIT, /* InitMupen64Plus() was called twice */
|
||||
M64ERR_INCOMPATIBLE, /* API versions between components are incompatible */
|
||||
M64ERR_INPUT_ASSERT, /* Invalid parameters for function call, such as ParamValue=NULL for GetCoreParameter() */
|
||||
M64ERR_INPUT_INVALID, /* Invalid input data, such as ParamValue="maybe" for SetCoreParameter() to set a BOOL-type value */
|
||||
M64ERR_INPUT_NOT_FOUND, /* The input parameter(s) specified a particular item which was not found */
|
||||
M64ERR_NO_MEMORY, /* Memory allocation failed */
|
||||
M64ERR_FILES, /* Error opening, creating, reading, or writing to a file */
|
||||
M64ERR_INTERNAL, /* Internal error (bug) */
|
||||
M64ERR_INVALID_STATE, /* Current program state does not allow operation */
|
||||
M64ERR_PLUGIN_FAIL, /* A plugin function returned a fatal error */
|
||||
M64ERR_SYSTEM_FAIL, /* A system function call, such as an SDL or file operation, failed */
|
||||
M64ERR_UNSUPPORTED, /* Function call is not supported (ie, core not built with debugger) */
|
||||
M64ERR_WRONG_TYPE /* A given input type parameter cannot be used for desired operation */
|
||||
} m64p_error;
|
||||
|
||||
typedef enum {
|
||||
M64CAPS_DYNAREC = 1,
|
||||
M64CAPS_DEBUGGER = 2,
|
||||
M64CAPS_CORE_COMPARE = 4
|
||||
} m64p_core_caps;
|
||||
|
||||
typedef enum {
|
||||
M64PLUGIN_NULL = 0,
|
||||
M64PLUGIN_RSP = 1,
|
||||
M64PLUGIN_GFX,
|
||||
M64PLUGIN_AUDIO,
|
||||
M64PLUGIN_INPUT,
|
||||
M64PLUGIN_CORE
|
||||
} m64p_plugin_type;
|
||||
|
||||
typedef enum {
|
||||
M64EMU_STOPPED = 1,
|
||||
M64EMU_RUNNING,
|
||||
M64EMU_PAUSED
|
||||
} m64p_emu_state;
|
||||
|
||||
typedef enum {
|
||||
M64VIDEO_NONE = 1,
|
||||
M64VIDEO_WINDOWED,
|
||||
M64VIDEO_FULLSCREEN
|
||||
} m64p_video_mode;
|
||||
|
||||
typedef enum {
|
||||
M64VIDEOFLAG_SUPPORT_RESIZING = 1
|
||||
} m64p_video_flags;
|
||||
|
||||
typedef enum {
|
||||
M64CORE_EMU_STATE = 1,
|
||||
M64CORE_VIDEO_MODE,
|
||||
M64CORE_SAVESTATE_SLOT,
|
||||
M64CORE_SPEED_FACTOR,
|
||||
M64CORE_SPEED_LIMITER,
|
||||
M64CORE_VIDEO_SIZE,
|
||||
M64CORE_AUDIO_VOLUME,
|
||||
M64CORE_AUDIO_MUTE,
|
||||
M64CORE_INPUT_GAMESHARK,
|
||||
M64CORE_STATE_LOADCOMPLETE,
|
||||
M64CORE_STATE_SAVECOMPLETE
|
||||
} m64p_core_param;
|
||||
|
||||
typedef enum {
|
||||
M64CMD_NOP = 0,
|
||||
M64CMD_ROM_OPEN,
|
||||
M64CMD_ROM_CLOSE,
|
||||
M64CMD_ROM_GET_HEADER,
|
||||
M64CMD_ROM_GET_SETTINGS,
|
||||
M64CMD_EXECUTE,
|
||||
M64CMD_STOP,
|
||||
M64CMD_PAUSE,
|
||||
M64CMD_RESUME,
|
||||
M64CMD_CORE_STATE_QUERY,
|
||||
M64CMD_STATE_LOAD,
|
||||
M64CMD_STATE_SAVE,
|
||||
M64CMD_STATE_SET_SLOT,
|
||||
M64CMD_SEND_SDL_KEYDOWN,
|
||||
M64CMD_SEND_SDL_KEYUP,
|
||||
M64CMD_SET_FRAME_CALLBACK,
|
||||
M64CMD_TAKE_NEXT_SCREENSHOT,
|
||||
M64CMD_CORE_STATE_SET,
|
||||
M64CMD_READ_SCREEN,
|
||||
M64CMD_RESET,
|
||||
M64CMD_ADVANCE_FRAME,
|
||||
M64CMD_SET_MEDIA_LOADER,
|
||||
M64CMD_NETPLAY_INIT,
|
||||
M64CMD_NETPLAY_CONTROL_PLAYER,
|
||||
M64CMD_NETPLAY_GET_VERSION,
|
||||
M64CMD_NETPLAY_CLOSE
|
||||
} m64p_command;
|
||||
|
||||
typedef struct {
|
||||
uint32_t address;
|
||||
int value;
|
||||
} m64p_cheat_code;
|
||||
|
||||
typedef struct {
|
||||
/* Frontend-defined callback data. */
|
||||
void* cb_data;
|
||||
|
||||
/* Allow the frontend to specify the GB cart ROM file to load
|
||||
* cb_data: points to frontend-defined callback data.
|
||||
* controller_num: (0-3) tell the frontend which controller is about to load a GB cart
|
||||
* Returns a NULL-terminated string owned by the core specifying the GB cart ROM filename to load.
|
||||
* Empty or NULL string results in no GB cart being loaded (eg. empty transferpak).
|
||||
*/
|
||||
char* (*get_gb_cart_rom)(void* cb_data, int controller_num);
|
||||
|
||||
/* Allow the frontend to specify the GB cart RAM file to load
|
||||
* cb_data: points to frontend-defined callback data.
|
||||
* controller_num: (0-3) tell the frontend which controller is about to load a GB cart
|
||||
* Returns a NULL-terminated string owned by the core specifying the GB cart RAM filename to load
|
||||
* Empty or NULL string results in the core generating a default save file with empty content.
|
||||
*/
|
||||
char* (*get_gb_cart_ram)(void* cb_data, int controller_num);
|
||||
|
||||
/* Allow the frontend to specify the DD IPL ROM file to load
|
||||
* cb_data: points to frontend-defined callback data.
|
||||
* Returns a NULL-terminated string owned by the core specifying the DD IPL ROM filename to load
|
||||
* Empty or NULL string results in disabled 64DD.
|
||||
*/
|
||||
char* (*get_dd_rom)(void* cb_data);
|
||||
|
||||
/* Allow the frontend to specify the DD disk file to load
|
||||
* cb_data: points to frontend-defined callback data.
|
||||
* Returns a NULL-terminated string owned by the core specifying the DD disk filename to load
|
||||
* Empty or NULL string results in no DD disk being loaded (eg. empty disk drive).
|
||||
*/
|
||||
char* (*get_dd_disk)(void* cb_data);
|
||||
} m64p_media_loader;
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Structures to hold ROM image information */
|
||||
/* ----------------------------------------- */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SYSTEM_NTSC = 0,
|
||||
SYSTEM_PAL,
|
||||
SYSTEM_MPAL
|
||||
} m64p_system_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t init_PI_BSB_DOM1_LAT_REG; /* 0x00 */
|
||||
uint8_t init_PI_BSB_DOM1_PGS_REG; /* 0x01 */
|
||||
uint8_t init_PI_BSB_DOM1_PWD_REG; /* 0x02 */
|
||||
uint8_t init_PI_BSB_DOM1_PGS_REG2; /* 0x03 */
|
||||
uint32_t ClockRate; /* 0x04 */
|
||||
uint32_t PC; /* 0x08 */
|
||||
uint32_t Release; /* 0x0C */
|
||||
uint32_t CRC1; /* 0x10 */
|
||||
uint32_t CRC2; /* 0x14 */
|
||||
uint32_t Unknown[2]; /* 0x18 */
|
||||
uint8_t Name[20]; /* 0x20 */
|
||||
uint32_t unknown; /* 0x34 */
|
||||
uint32_t Manufacturer_ID; /* 0x38 */
|
||||
uint16_t Cartridge_ID; /* 0x3C - Game serial number */
|
||||
uint16_t Country_code; /* 0x3E */
|
||||
} m64p_rom_header;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char goodname[256];
|
||||
char MD5[33];
|
||||
unsigned char savetype;
|
||||
unsigned char status; /* Rom status on a scale from 0-5. */
|
||||
unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */
|
||||
unsigned char rumble; /* 0 - No, 1 - Yes boolean for rumble support. */
|
||||
unsigned char transferpak; /* 0 - No, 1 - Yes boolean for transfer pak support. */
|
||||
unsigned char mempak; /* 0 - No, 1 - Yes boolean for memory pak support. */
|
||||
unsigned char biopak; /* 0 - No, 1 - Yes boolean for bio pak support. */
|
||||
} m64p_rom_settings;
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Structures and Types for the Debugger */
|
||||
/* ----------------------------------------- */
|
||||
|
||||
typedef enum {
|
||||
M64P_DBG_RUN_STATE = 1,
|
||||
M64P_DBG_PREVIOUS_PC,
|
||||
M64P_DBG_NUM_BREAKPOINTS,
|
||||
M64P_DBG_CPU_DYNACORE,
|
||||
M64P_DBG_CPU_NEXT_INTERRUPT
|
||||
} m64p_dbg_state;
|
||||
|
||||
typedef enum {
|
||||
M64P_DBG_RUNSTATE_PAUSED = 0,
|
||||
M64P_DBG_RUNSTATE_STEPPING,
|
||||
M64P_DBG_RUNSTATE_RUNNING
|
||||
} m64p_dbg_runstate;
|
||||
|
||||
typedef enum {
|
||||
M64P_DBG_MEM_TYPE = 1,
|
||||
M64P_DBG_MEM_FLAGS,
|
||||
M64P_DBG_MEM_HAS_RECOMPILED,
|
||||
M64P_DBG_MEM_NUM_RECOMPILED,
|
||||
M64P_DBG_RECOMP_OPCODE = 16,
|
||||
M64P_DBG_RECOMP_ARGS,
|
||||
M64P_DBG_RECOMP_ADDR
|
||||
} m64p_dbg_mem_info;
|
||||
|
||||
typedef enum {
|
||||
M64P_MEM_NOMEM = 0,
|
||||
M64P_MEM_NOTHING,
|
||||
M64P_MEM_RDRAM,
|
||||
M64P_MEM_RDRAMREG,
|
||||
M64P_MEM_RSPMEM,
|
||||
M64P_MEM_RSPREG,
|
||||
M64P_MEM_RSP,
|
||||
M64P_MEM_DP,
|
||||
M64P_MEM_DPS,
|
||||
M64P_MEM_VI,
|
||||
M64P_MEM_AI,
|
||||
M64P_MEM_PI,
|
||||
M64P_MEM_RI,
|
||||
M64P_MEM_SI,
|
||||
M64P_MEM_FLASHRAMSTAT,
|
||||
M64P_MEM_ROM,
|
||||
M64P_MEM_PIF,
|
||||
M64P_MEM_MI,
|
||||
M64P_MEM_BREAKPOINT
|
||||
} m64p_dbg_mem_type;
|
||||
|
||||
typedef enum {
|
||||
M64P_MEM_FLAG_READABLE = 0x01,
|
||||
M64P_MEM_FLAG_WRITABLE = 0x02,
|
||||
M64P_MEM_FLAG_READABLE_EMUONLY = 0x04, /* the EMUONLY flags signify that emulated code can read/write here, but debugger cannot */
|
||||
M64P_MEM_FLAG_WRITABLE_EMUONLY = 0x08
|
||||
} m64p_dbg_mem_flags;
|
||||
|
||||
typedef enum {
|
||||
M64P_DBG_PTR_RDRAM = 1,
|
||||
M64P_DBG_PTR_PI_REG,
|
||||
M64P_DBG_PTR_SI_REG,
|
||||
M64P_DBG_PTR_VI_REG,
|
||||
M64P_DBG_PTR_RI_REG,
|
||||
M64P_DBG_PTR_AI_REG
|
||||
} m64p_dbg_memptr_type;
|
||||
|
||||
typedef enum {
|
||||
M64P_CPU_PC = 1,
|
||||
M64P_CPU_REG_REG,
|
||||
M64P_CPU_REG_HI,
|
||||
M64P_CPU_REG_LO,
|
||||
M64P_CPU_REG_COP0,
|
||||
M64P_CPU_REG_COP1_DOUBLE_PTR,
|
||||
M64P_CPU_REG_COP1_SIMPLE_PTR,
|
||||
M64P_CPU_REG_COP1_FGR_64,
|
||||
M64P_CPU_TLB
|
||||
} m64p_dbg_cpu_data;
|
||||
|
||||
typedef enum {
|
||||
M64P_BKP_CMD_ADD_ADDR = 1,
|
||||
M64P_BKP_CMD_ADD_STRUCT,
|
||||
M64P_BKP_CMD_REPLACE,
|
||||
M64P_BKP_CMD_REMOVE_ADDR,
|
||||
M64P_BKP_CMD_REMOVE_IDX,
|
||||
M64P_BKP_CMD_ENABLE,
|
||||
M64P_BKP_CMD_DISABLE,
|
||||
M64P_BKP_CMD_CHECK
|
||||
} m64p_dbg_bkp_command;
|
||||
|
||||
#define M64P_MEM_INVALID 0xFFFFFFFF /* invalid memory read will return this */
|
||||
|
||||
#define BREAKPOINTS_MAX_NUMBER 128
|
||||
|
||||
typedef enum {
|
||||
M64P_BKP_FLAG_ENABLED = 0x01,
|
||||
M64P_BKP_FLAG_READ = 0x02,
|
||||
M64P_BKP_FLAG_WRITE = 0x04,
|
||||
M64P_BKP_FLAG_EXEC = 0x08,
|
||||
M64P_BKP_FLAG_LOG = 0x10 /* Log to the console when this breakpoint hits */
|
||||
} m64p_dbg_bkp_flags;
|
||||
|
||||
#define BPT_CHECK_FLAG(a, b) ((a.flags & b) == b)
|
||||
#define BPT_SET_FLAG(a, b) a.flags = (a.flags | b);
|
||||
#define BPT_CLEAR_FLAG(a, b) a.flags = (a.flags & (~b));
|
||||
#define BPT_TOGGLE_FLAG(a, b) a.flags = (a.flags ^ b);
|
||||
|
||||
typedef struct {
|
||||
uint32_t address;
|
||||
uint32_t endaddr;
|
||||
unsigned int flags;
|
||||
} m64p_breakpoint;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* Structures and Types for Core Video Extension API */
|
||||
/* ------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
unsigned int uiWidth;
|
||||
unsigned int uiHeight;
|
||||
} m64p_2d_size;
|
||||
|
||||
typedef enum {
|
||||
M64P_GL_DOUBLEBUFFER = 1,
|
||||
M64P_GL_BUFFER_SIZE,
|
||||
M64P_GL_DEPTH_SIZE,
|
||||
M64P_GL_RED_SIZE,
|
||||
M64P_GL_GREEN_SIZE,
|
||||
M64P_GL_BLUE_SIZE,
|
||||
M64P_GL_ALPHA_SIZE,
|
||||
M64P_GL_SWAP_CONTROL,
|
||||
M64P_GL_MULTISAMPLEBUFFERS,
|
||||
M64P_GL_MULTISAMPLESAMPLES,
|
||||
M64P_GL_CONTEXT_MAJOR_VERSION,
|
||||
M64P_GL_CONTEXT_MINOR_VERSION,
|
||||
M64P_GL_CONTEXT_PROFILE_MASK
|
||||
} m64p_GLattr;
|
||||
|
||||
typedef enum {
|
||||
M64P_GL_CONTEXT_PROFILE_CORE,
|
||||
M64P_GL_CONTEXT_PROFILE_COMPATIBILITY,
|
||||
M64P_GL_CONTEXT_PROFILE_ES
|
||||
} m64p_GLContextType;
|
||||
|
||||
typedef struct {
|
||||
unsigned int Functions;
|
||||
m64p_error (*VidExtFuncInit)(void);
|
||||
m64p_error (*VidExtFuncQuit)(void);
|
||||
m64p_error (*VidExtFuncListModes)(m64p_2d_size *, int *);
|
||||
m64p_error (*VidExtFuncSetMode)(int, int, int, int, int);
|
||||
m64p_function (*VidExtFuncGLGetProc)(const char*);
|
||||
m64p_error (*VidExtFuncGLSetAttr)(m64p_GLattr, int);
|
||||
m64p_error (*VidExtFuncGLGetAttr)(m64p_GLattr, int *);
|
||||
m64p_error (*VidExtFuncGLSwapBuf)(void);
|
||||
m64p_error (*VidExtFuncSetCaption)(const char *);
|
||||
m64p_error (*VidExtFuncToggleFS)(void);
|
||||
m64p_error (*VidExtFuncResizeWindow)(int, int);
|
||||
uint32_t (*VidExtFuncGLGetDefaultFramebuffer)(void);
|
||||
} m64p_video_extension_functions;
|
||||
|
||||
#endif /* define M64P_TYPES_H */
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "m64p_plugin.h"
|
||||
@@ -1,47 +0,0 @@
|
||||
# Configuration for mupen64plus-input-gca.
|
||||
#
|
||||
# To revert to defaults simply delete this file.
|
||||
# The default configuration includes all supported controller mappings.
|
||||
# It is currently not possible to change the mapping of the control stick.
|
||||
#
|
||||
# In the controller mappings below, the left side is the GameCube controller button,
|
||||
# and the right side is the N64 controller button.
|
||||
#
|
||||
# Be aware that the values are case sensitive, and an invalid configuration file will
|
||||
# be overwritten with the defaults.
|
||||
|
||||
# Deadzone for the control stick.
|
||||
# Valid values are from 0 to 255.
|
||||
control_stick_deadzone = 20
|
||||
|
||||
# Sensitivity for the control stick.
|
||||
# This controls how far you have to move the stick in order to reach max input.
|
||||
# Valid values are from 0 to 255.
|
||||
control_stick_sensitivity = 180
|
||||
|
||||
# Deadzone for the C-stick.
|
||||
# Valid values are from 0 to 255.
|
||||
c_stick_deadzone = 40
|
||||
|
||||
# Threshold for the trigger buttons (L and R).
|
||||
# Set to max to only detect input when fully pressed.
|
||||
# Valid values are from 0 to 255.
|
||||
trigger_threshold = 168
|
||||
|
||||
[controller_mapping]
|
||||
a = 'A'
|
||||
b = 'B'
|
||||
x = 'CRight'
|
||||
y = 'CLeft'
|
||||
start = 'Start'
|
||||
z = 'L'
|
||||
l = 'Z'
|
||||
r = 'R'
|
||||
d_pad_left = 'DPadLeft'
|
||||
d_pad_right = 'DPadRight'
|
||||
d_pad_down = 'DPadDown'
|
||||
d_pad_up = 'DPadUp'
|
||||
c_stick_left = 'CLeft'
|
||||
c_stick_right = 'CRight'
|
||||
c_stick_down = 'CDown'
|
||||
c_stick_up = 'CUp'
|
||||
@@ -1,323 +0,0 @@
|
||||
use crate::{M64Message, IS_INIT};
|
||||
use rusb::{DeviceHandle, GlobalContext};
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt::Debug,
|
||||
sync::{atomic::Ordering, Mutex},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
const ENDPOINT_IN: u8 = 0x81;
|
||||
const ENDPOINT_OUT: u8 = 0x02;
|
||||
const READ_LEN: usize = 37;
|
||||
|
||||
pub static ADAPTER_STATE: AdapterState = AdapterState::new();
|
||||
|
||||
pub fn start_read_thread() {
|
||||
thread::spawn(move || {
|
||||
debug_print!(M64Message::Info, "Adapter thread started");
|
||||
debug_print!(M64Message::Info, "Trying to connect to GameCube adapter...");
|
||||
|
||||
let mut gc_adapter = GcAdapter::blocking_connect();
|
||||
|
||||
debug_print!(M64Message::Info, "Found a GameCube adapter");
|
||||
|
||||
while IS_INIT.load(Ordering::Acquire) {
|
||||
match gc_adapter.read() {
|
||||
Ok(buf) => *ADAPTER_STATE.buf.lock().unwrap() = buf,
|
||||
Err(rusb::Error::NoDevice) => {
|
||||
debug_print!(
|
||||
M64Message::Info,
|
||||
"Adapter disconnected, trying to reconnect..."
|
||||
);
|
||||
gc_adapter = GcAdapter::blocking_connect();
|
||||
debug_print!(M64Message::Info, "Adapter reconnected");
|
||||
}
|
||||
Err(e) => panic!("error while reading from adapter: {:?}", e),
|
||||
}
|
||||
|
||||
// Gives a polling rate of approx. 1000 Hz
|
||||
thread::park_timeout(Duration::from_millis(1));
|
||||
}
|
||||
|
||||
debug_print!(M64Message::Info, "Adapter thread stopped");
|
||||
});
|
||||
}
|
||||
|
||||
pub struct GcAdapter {
|
||||
handle: DeviceHandle<GlobalContext>,
|
||||
}
|
||||
|
||||
impl Debug for GcAdapter {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"GCAdapter with product string: {}",
|
||||
self.handle
|
||||
.read_product_string_ascii(&self.handle.device().device_descriptor().unwrap())
|
||||
.unwrap()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl GcAdapter {
|
||||
pub fn new() -> Result<Self, rusb::Error> {
|
||||
let device = rusb::devices()?
|
||||
.iter()
|
||||
.find(|dev| {
|
||||
let dev_desc = dev.device_descriptor().unwrap();
|
||||
dev_desc.vendor_id() == 0x057E && dev_desc.product_id() == 0x0337
|
||||
})
|
||||
.ok_or(rusb::Error::NoDevice)?;
|
||||
|
||||
let handle = device.open()?;
|
||||
|
||||
if handle.kernel_driver_active(0).unwrap_or(false) {
|
||||
handle.detach_kernel_driver(0)?;
|
||||
}
|
||||
|
||||
// From Dolphin emulator source:
|
||||
// "This call makes Nyko-brand (and perhaps other) adapters work.
|
||||
// However it returns LIBUSB_ERROR_PIPE with Mayflash adapters."
|
||||
let res = handle.write_control(0x21, 11, 0x0001, 0, &[], Duration::from_millis(1000));
|
||||
if let Err(e) = res {
|
||||
debug_print!(
|
||||
M64Message::Warning,
|
||||
"Control transfer failed with error: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
handle.claim_interface(0)?;
|
||||
handle.write_interrupt(ENDPOINT_OUT, &[0x13], Duration::from_millis(16))?;
|
||||
|
||||
Ok(GcAdapter { handle })
|
||||
}
|
||||
|
||||
/// Continuously try to connect to the adapter
|
||||
pub fn blocking_connect() -> Self {
|
||||
loop {
|
||||
if let Ok(gc) = GcAdapter::new() {
|
||||
break gc;
|
||||
}
|
||||
|
||||
thread::park_timeout(Duration::from_secs(1));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read(&self) -> rusb::Result<[u8; READ_LEN]> {
|
||||
let mut buf = [0; READ_LEN];
|
||||
|
||||
match self
|
||||
.handle
|
||||
.read_interrupt(ENDPOINT_IN, &mut buf, Duration::from_millis(16))
|
||||
{
|
||||
Ok(_) | Err(rusb::Error::Timeout) => Ok(buf),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AdapterState {
|
||||
buf: Mutex<[u8; 37]>,
|
||||
}
|
||||
|
||||
impl AdapterState {
|
||||
pub const fn new() -> Self {
|
||||
AdapterState {
|
||||
buf: Mutex::new([0; READ_LEN]),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the `ControllerState` for the given channel
|
||||
pub fn controller_state<T>(&self, channel: T) -> ControllerState
|
||||
where
|
||||
T: TryInto<Channel>,
|
||||
<T as TryInto<Channel>>::Error: Debug,
|
||||
{
|
||||
let channel = channel.try_into().unwrap() as usize;
|
||||
let buf = *self.buf.lock().unwrap();
|
||||
|
||||
if let [status, b1, b2, stick_x, stick_y, substick_x, substick_y, trigger_left, trigger_right, ..] =
|
||||
buf[(9 * channel) + 1..]
|
||||
{
|
||||
ControllerState {
|
||||
connected: is_controller_connected(status),
|
||||
|
||||
a: b1 & (1 << 0) > 0,
|
||||
b: b1 & (1 << 1) > 0,
|
||||
x: b1 & (1 << 2) > 0,
|
||||
y: b1 & (1 << 3) > 0,
|
||||
|
||||
left: b1 & (1 << 4) > 0,
|
||||
right: b1 & (1 << 5) > 0,
|
||||
down: b1 & (1 << 6) > 0,
|
||||
up: b1 & (1 << 7) > 0,
|
||||
|
||||
start: b2 & (1 << 0) > 0,
|
||||
z: b2 & (1 << 1) > 0,
|
||||
r: b2 & (1 << 2) > 0,
|
||||
l: b2 & (1 << 3) > 0,
|
||||
|
||||
stick_x,
|
||||
stick_y,
|
||||
substick_x,
|
||||
substick_y,
|
||||
trigger_left,
|
||||
trigger_right,
|
||||
}
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a controller is connected to the given channel.
|
||||
pub fn is_connected<T>(&self, channel: T) -> bool
|
||||
where
|
||||
T: TryInto<Channel>,
|
||||
<T as TryInto<Channel>>::Error: Debug,
|
||||
{
|
||||
let buf = *self.buf.lock().unwrap();
|
||||
let channel = channel.try_into().unwrap();
|
||||
|
||||
let status = buf[1 + (9 * channel as usize)] >> 4;
|
||||
is_controller_connected(status)
|
||||
}
|
||||
|
||||
pub fn any_connected(&self) -> bool {
|
||||
(0..4)
|
||||
.map(|i| self.is_connected(i))
|
||||
.any(std::convert::identity)
|
||||
}
|
||||
|
||||
pub fn set_buf(&mut self, buf: [u8; 37]) {
|
||||
*self.buf.get_mut().unwrap() = buf;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AdapterState {
|
||||
fn default() -> Self {
|
||||
AdapterState::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct ControllerState {
|
||||
pub connected: bool,
|
||||
|
||||
pub a: bool,
|
||||
pub b: bool,
|
||||
pub x: bool,
|
||||
pub y: bool,
|
||||
|
||||
pub left: bool,
|
||||
pub right: bool,
|
||||
pub down: bool,
|
||||
pub up: bool,
|
||||
|
||||
pub start: bool,
|
||||
pub z: bool,
|
||||
pub r: bool,
|
||||
pub l: bool,
|
||||
|
||||
pub stick_x: u8,
|
||||
pub stick_y: u8,
|
||||
pub substick_x: u8,
|
||||
pub substick_y: u8,
|
||||
pub trigger_left: u8,
|
||||
pub trigger_right: u8,
|
||||
}
|
||||
|
||||
impl ControllerState {
|
||||
pub fn stick_with_deadzone(&self, deadzone: u8, sensitivity: u8) -> (i8, i8) {
|
||||
const STICK_MAX: i32 = i8::MAX as i32;
|
||||
|
||||
let x = self.stick_x.wrapping_add(128) as i8;
|
||||
let y = self.stick_y.wrapping_add(128) as i8;
|
||||
|
||||
// Convert cartesian coordinates to polar coordinates (radius)
|
||||
let radius = ((x as f32).powi(2) + (y as f32).powi(2)).sqrt();
|
||||
|
||||
if radius <= deadzone as f32 {
|
||||
return (0, 0);
|
||||
}
|
||||
|
||||
// Convert cartesian coordinates to polar coordinates (angle)
|
||||
let angle = (y as f32).atan2(x as f32);
|
||||
|
||||
let deadzone = deadzone as i32;
|
||||
// User-facing sensitivity is inverted (so that higher values give higher radius)
|
||||
let sensitivity = u8::MAX as i32 - sensitivity as i32;
|
||||
|
||||
// Scale radius to counteract the deadzone, and fit the radius to the range [-80, 80] (N64
|
||||
// stick range).
|
||||
// This formula is a simplified version of the following:
|
||||
//
|
||||
// let radius = (radius - deadzone as f32) * (STICK_MAX as f32 / (STICK_MAX - deadzone) as f32);
|
||||
// let radius = radius * 80.0 / (STICK_MAX as f32 * (sensitivity as f32 / 100.0)) as f32;
|
||||
let radius =
|
||||
8000.0 * (radius - deadzone as f32) / (sensitivity * (STICK_MAX - deadzone)) as f32;
|
||||
|
||||
// Convert back to cartesian coordinates
|
||||
let x = (radius * angle.cos()).round() as i8;
|
||||
let y = (radius * angle.sin()).round() as i8;
|
||||
|
||||
(x, y)
|
||||
}
|
||||
|
||||
pub fn substick_with_deadzone(&self, deadzone: u8) -> (i8, i8) {
|
||||
let x = self.substick_x.wrapping_add(128) as i8;
|
||||
let y = self.substick_y.wrapping_add(128) as i8;
|
||||
|
||||
let x = if x.unsigned_abs() < deadzone { 0 } else { x };
|
||||
|
||||
let y = if y.unsigned_abs() < deadzone { 0 } else { y };
|
||||
|
||||
(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_controller_connected(status: u8) -> bool {
|
||||
// 0x10 = Normal
|
||||
// 0x20 = Wavebird
|
||||
let controller_type = status & (0x10 | 0x20);
|
||||
controller_type == 0x10 || controller_type == 0x20
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Channel {
|
||||
One = 0,
|
||||
Two = 1,
|
||||
Three = 2,
|
||||
Four = 3,
|
||||
}
|
||||
|
||||
impl TryFrom<usize> for Channel {
|
||||
type Error = usize;
|
||||
|
||||
fn try_from(val: usize) -> Result<Self, Self::Error> {
|
||||
match val {
|
||||
0 => Ok(Channel::One),
|
||||
1 => Ok(Channel::Two),
|
||||
2 => Ok(Channel::Three),
|
||||
3 => Ok(Channel::Four),
|
||||
x => Err(x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<i32> for Channel {
|
||||
type Error = i32;
|
||||
|
||||
fn try_from(val: i32) -> Result<Self, Self::Error> {
|
||||
match val {
|
||||
0 => Ok(Channel::One),
|
||||
1 => Ok(Channel::Two),
|
||||
2 => Ok(Channel::Three),
|
||||
3 => Ok(Channel::Four),
|
||||
x => Err(x),
|
||||
}
|
||||
}
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, Read, Write},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
pub control_stick_deadzone: u8,
|
||||
pub control_stick_sensitivity: u8,
|
||||
pub c_stick_deadzone: u8,
|
||||
pub trigger_threshold: u8,
|
||||
pub controller_mapping: ControllerMapping,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct ControllerMapping {
|
||||
pub a: N64Button,
|
||||
pub b: N64Button,
|
||||
pub x: N64Button,
|
||||
pub y: N64Button,
|
||||
pub start: N64Button,
|
||||
pub z: N64Button,
|
||||
pub l: N64Button,
|
||||
pub r: N64Button,
|
||||
pub d_pad_left: N64Button,
|
||||
pub d_pad_right: N64Button,
|
||||
pub d_pad_down: N64Button,
|
||||
pub d_pad_up: N64Button,
|
||||
pub c_stick_left: N64Button,
|
||||
pub c_stick_right: N64Button,
|
||||
pub c_stick_down: N64Button,
|
||||
pub c_stick_up: N64Button,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn read_from_file<P: AsRef<Path>>(path: P) -> io::Result<Self> {
|
||||
let path = path.as_ref();
|
||||
let mut file = File::open(path)?;
|
||||
let mut string = String::new();
|
||||
file.read_to_string(&mut string)?;
|
||||
let cfg = toml::from_str(&string).map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||
|
||||
Ok(cfg)
|
||||
}
|
||||
|
||||
pub fn create<P: AsRef<Path>>(path: P) -> Result<Self, Self> {
|
||||
let contents = include_str!("../mupen64plus-input-gca.toml");
|
||||
let cfg = toml::from_str(contents).unwrap();
|
||||
|
||||
let path = path.as_ref();
|
||||
let mut file = match File::create(path) {
|
||||
Ok(f) => f,
|
||||
Err(_) => return Err(cfg),
|
||||
};
|
||||
|
||||
match file.write_all(contents.as_bytes()) {
|
||||
Ok(_) => Ok(cfg),
|
||||
Err(_) => Err(cfg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum N64Button {
|
||||
A,
|
||||
B,
|
||||
Start,
|
||||
Z,
|
||||
L,
|
||||
R,
|
||||
DPadLeft,
|
||||
DPadRight,
|
||||
DPadDown,
|
||||
DPadUp,
|
||||
CLeft,
|
||||
CRight,
|
||||
CDown,
|
||||
CUp,
|
||||
None,
|
||||
}
|
||||
|
||||
impl N64Button {
|
||||
pub fn bit_pattern(&self) -> u32 {
|
||||
match self {
|
||||
N64Button::A => 0x0080,
|
||||
N64Button::B => 0x0040,
|
||||
N64Button::DPadLeft => 0x0002,
|
||||
N64Button::DPadRight => 0x0001,
|
||||
N64Button::DPadDown => 0x0004,
|
||||
N64Button::DPadUp => 0x0008,
|
||||
N64Button::Start => 0x0010,
|
||||
N64Button::Z => 0x0020,
|
||||
N64Button::R => 0x1000,
|
||||
N64Button::L => 0x2000,
|
||||
N64Button::CLeft => 0x0200,
|
||||
N64Button::CRight => 0x0100,
|
||||
N64Button::CDown => 0x0400,
|
||||
N64Button::CUp => 0x0800,
|
||||
N64Button::None => 0x0000,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
use std::{
|
||||
ffi::{c_void, CString},
|
||||
os::raw::{c_char, c_int},
|
||||
sync::{
|
||||
atomic::{AtomicPtr, Ordering},
|
||||
Mutex,
|
||||
},
|
||||
};
|
||||
|
||||
pub type DebugCallback = extern "C" fn(*mut c_void, c_int, *const c_char);
|
||||
|
||||
pub fn init(debug_callback: DebugCallback, context_ptr: *mut c_void) {
|
||||
*DEBUG_INFO.lock().unwrap() = Some(DebugInfo::new(debug_callback, context_ptr));
|
||||
}
|
||||
|
||||
pub static DEBUG_INFO: Mutex<Option<DebugInfo>> = Mutex::new(None);
|
||||
|
||||
macro_rules! debug_print {
|
||||
($level:expr, $s:expr) => {
|
||||
debug_print!($level, $s,)
|
||||
};
|
||||
($level:expr, $s:expr, $($arg:expr),*) => {{
|
||||
if cfg!(debug_assertions) || $level <= $crate::debug::M64Message::Warning {
|
||||
$crate::debug::__print_debug_message($level, format!($s $(, $arg)*));
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(crate) fn __print_debug_message(level: M64Message, message: String) {
|
||||
match *DEBUG_INFO.lock().unwrap() {
|
||||
Some(ref di) => {
|
||||
let message = CString::new(message).unwrap();
|
||||
let context = di.context_ptr.load(Ordering::Acquire);
|
||||
|
||||
(di.callback)(context, level as c_int, message.as_ptr());
|
||||
}
|
||||
None => {
|
||||
println!("{:?}: {}", level, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, PartialOrd, PartialEq, Eq)]
|
||||
pub enum M64Message {
|
||||
Error = 1,
|
||||
Warning,
|
||||
Info,
|
||||
Status,
|
||||
Verbose,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DebugInfo {
|
||||
callback: DebugCallback,
|
||||
context_ptr: AtomicPtr<c_void>,
|
||||
}
|
||||
|
||||
impl DebugInfo {
|
||||
fn new(debug_callback: DebugCallback, context: *mut c_void) -> Self {
|
||||
Self {
|
||||
callback: debug_callback,
|
||||
context_ptr: AtomicPtr::new(context),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#[cfg(unix)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_snake_case)]
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::all)]
|
||||
pub mod unix;
|
||||
#[cfg(unix)]
|
||||
pub use unix::*;
|
||||
|
||||
#[cfg(windows)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_snake_case)]
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::all)]
|
||||
pub mod windows;
|
||||
#[cfg(windows)]
|
||||
pub use windows::*;
|
||||
|
||||
#[cfg(feature = "m64p_compat")]
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[allow(non_snake_case)]
|
||||
pub struct CONTROL_M64P {
|
||||
pub Present: std::os::raw::c_int,
|
||||
pub RawData: std::os::raw::c_int,
|
||||
pub Plugin: std::os::raw::c_int,
|
||||
pub Type: std::os::raw::c_int,
|
||||
}
|
||||
@@ -1,525 +0,0 @@
|
||||
/* automatically generated by rust-bindgen 0.59.1 */
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct __BindgenBitfieldUnit<Storage> {
|
||||
storage: Storage,
|
||||
}
|
||||
impl<Storage> __BindgenBitfieldUnit<Storage> {
|
||||
#[inline]
|
||||
pub const fn new(storage: Storage) -> Self {
|
||||
Self { storage }
|
||||
}
|
||||
}
|
||||
impl<Storage> __BindgenBitfieldUnit<Storage>
|
||||
where
|
||||
Storage: AsRef<[u8]> + AsMut<[u8]>,
|
||||
{
|
||||
#[inline]
|
||||
pub fn get_bit(&self, index: usize) -> bool {
|
||||
debug_assert!(index / 8 < self.storage.as_ref().len());
|
||||
let byte_index = index / 8;
|
||||
let byte = self.storage.as_ref()[byte_index];
|
||||
let bit_index = if cfg!(target_endian = "big") {
|
||||
7 - (index % 8)
|
||||
} else {
|
||||
index % 8
|
||||
};
|
||||
let mask = 1 << bit_index;
|
||||
byte & mask == mask
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_bit(&mut self, index: usize, val: bool) {
|
||||
debug_assert!(index / 8 < self.storage.as_ref().len());
|
||||
let byte_index = index / 8;
|
||||
let byte = &mut self.storage.as_mut()[byte_index];
|
||||
let bit_index = if cfg!(target_endian = "big") {
|
||||
7 - (index % 8)
|
||||
} else {
|
||||
index % 8
|
||||
};
|
||||
let mask = 1 << bit_index;
|
||||
if val {
|
||||
*byte |= mask;
|
||||
} else {
|
||||
*byte &= !mask;
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
|
||||
debug_assert!(bit_width <= 64);
|
||||
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
|
||||
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
|
||||
let mut val = 0;
|
||||
for i in 0..(bit_width as usize) {
|
||||
if self.get_bit(i + bit_offset) {
|
||||
let index = if cfg!(target_endian = "big") {
|
||||
bit_width as usize - 1 - i
|
||||
} else {
|
||||
i
|
||||
};
|
||||
val |= 1 << index;
|
||||
}
|
||||
}
|
||||
val
|
||||
}
|
||||
#[inline]
|
||||
pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
|
||||
debug_assert!(bit_width <= 64);
|
||||
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
|
||||
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
|
||||
for i in 0..(bit_width as usize) {
|
||||
let mask = 1 << i;
|
||||
let val_bit_is_set = val & mask == mask;
|
||||
let index = if cfg!(target_endian = "big") {
|
||||
bit_width as usize - 1 - i
|
||||
} else {
|
||||
i
|
||||
};
|
||||
self.set_bit(index + bit_offset, val_bit_is_set);
|
||||
}
|
||||
}
|
||||
}
|
||||
pub type m64p_dynlib_handle = *mut ::std::os::raw::c_void;
|
||||
pub const m64p_error_M64ERR_SUCCESS: m64p_error = 0;
|
||||
pub const m64p_error_M64ERR_NOT_INIT: m64p_error = 1;
|
||||
pub const m64p_error_M64ERR_ALREADY_INIT: m64p_error = 2;
|
||||
pub const m64p_error_M64ERR_INCOMPATIBLE: m64p_error = 3;
|
||||
pub const m64p_error_M64ERR_INPUT_ASSERT: m64p_error = 4;
|
||||
pub const m64p_error_M64ERR_INPUT_INVALID: m64p_error = 5;
|
||||
pub const m64p_error_M64ERR_INPUT_NOT_FOUND: m64p_error = 6;
|
||||
pub const m64p_error_M64ERR_NO_MEMORY: m64p_error = 7;
|
||||
pub const m64p_error_M64ERR_FILES: m64p_error = 8;
|
||||
pub const m64p_error_M64ERR_INTERNAL: m64p_error = 9;
|
||||
pub const m64p_error_M64ERR_INVALID_STATE: m64p_error = 10;
|
||||
pub const m64p_error_M64ERR_PLUGIN_FAIL: m64p_error = 11;
|
||||
pub const m64p_error_M64ERR_SYSTEM_FAIL: m64p_error = 12;
|
||||
pub const m64p_error_M64ERR_UNSUPPORTED: m64p_error = 13;
|
||||
pub const m64p_error_M64ERR_WRONG_TYPE: m64p_error = 14;
|
||||
pub type m64p_error = ::std::os::raw::c_uint;
|
||||
pub const m64p_plugin_type_M64PLUGIN_NULL: m64p_plugin_type = 0;
|
||||
pub const m64p_plugin_type_M64PLUGIN_RSP: m64p_plugin_type = 1;
|
||||
pub const m64p_plugin_type_M64PLUGIN_GFX: m64p_plugin_type = 2;
|
||||
pub const m64p_plugin_type_M64PLUGIN_AUDIO: m64p_plugin_type = 3;
|
||||
pub const m64p_plugin_type_M64PLUGIN_INPUT: m64p_plugin_type = 4;
|
||||
pub const m64p_plugin_type_M64PLUGIN_CORE: m64p_plugin_type = 5;
|
||||
pub type m64p_plugin_type = ::std::os::raw::c_uint;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct CONTROL {
|
||||
pub Present: ::std::os::raw::c_int,
|
||||
pub RawData: ::std::os::raw::c_int,
|
||||
pub Plugin: ::std::os::raw::c_int,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_CONTROL() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<CONTROL>(),
|
||||
12usize,
|
||||
concat!("Size of: ", stringify!(CONTROL))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<CONTROL>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(CONTROL))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL>())).Present as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL),
|
||||
"::",
|
||||
stringify!(Present)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL>())).RawData as *const _ as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL),
|
||||
"::",
|
||||
stringify!(RawData)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL>())).Plugin as *const _ as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL),
|
||||
"::",
|
||||
stringify!(Plugin)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub union BUTTONS {
|
||||
pub Value: ::std::os::raw::c_uint,
|
||||
pub __bindgen_anon_1: BUTTONS__bindgen_ty_1,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[repr(align(4))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct BUTTONS__bindgen_ty_1 {
|
||||
pub _bitfield_align_1: [u8; 0],
|
||||
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_BUTTONS__bindgen_ty_1() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<BUTTONS__bindgen_ty_1>(),
|
||||
4usize,
|
||||
concat!("Size of: ", stringify!(BUTTONS__bindgen_ty_1))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<BUTTONS__bindgen_ty_1>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(BUTTONS__bindgen_ty_1))
|
||||
);
|
||||
}
|
||||
impl BUTTONS__bindgen_ty_1 {
|
||||
#[inline]
|
||||
pub fn R_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_R_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(0usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn L_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_L_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(1usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn D_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_D_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(2usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn U_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_U_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(3usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn START_BUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_START_BUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(4usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn Z_TRIG(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Z_TRIG(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(5usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn B_BUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_B_BUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(6usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn A_BUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_A_BUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(7usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn R_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_R_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(8usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn L_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_L_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(9usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn D_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_D_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(10usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn U_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_U_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(11usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn R_TRIG(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_R_TRIG(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(12usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn L_TRIG(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_L_TRIG(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(13usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn Reserved1(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Reserved1(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(14usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn Reserved2(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Reserved2(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(15usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn X_AXIS(&self) -> ::std::os::raw::c_int {
|
||||
u32::cast_signed(self._bitfield_1.get(16usize, 8u8) as u32)
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_X_AXIS(&mut self, val: ::std::os::raw::c_int) {
|
||||
let val: u32 = i32::cast_unsigned(val);
|
||||
self._bitfield_1.set(16usize, 8u8, val as u64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn Y_AXIS(&self) -> ::std::os::raw::c_int {
|
||||
u32::cast_signed(self._bitfield_1.get(24usize, 8u8) as u32)
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Y_AXIS(&mut self, val: ::std::os::raw::c_int) {
|
||||
let val: u32 = i32::cast_unsigned(val);
|
||||
self._bitfield_1.set(24usize, 8u8, val as u64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn new_bitfield_1(
|
||||
R_DPAD: ::std::os::raw::c_uint,
|
||||
L_DPAD: ::std::os::raw::c_uint,
|
||||
D_DPAD: ::std::os::raw::c_uint,
|
||||
U_DPAD: ::std::os::raw::c_uint,
|
||||
START_BUTTON: ::std::os::raw::c_uint,
|
||||
Z_TRIG: ::std::os::raw::c_uint,
|
||||
B_BUTTON: ::std::os::raw::c_uint,
|
||||
A_BUTTON: ::std::os::raw::c_uint,
|
||||
R_CBUTTON: ::std::os::raw::c_uint,
|
||||
L_CBUTTON: ::std::os::raw::c_uint,
|
||||
D_CBUTTON: ::std::os::raw::c_uint,
|
||||
U_CBUTTON: ::std::os::raw::c_uint,
|
||||
R_TRIG: ::std::os::raw::c_uint,
|
||||
L_TRIG: ::std::os::raw::c_uint,
|
||||
Reserved1: ::std::os::raw::c_uint,
|
||||
Reserved2: ::std::os::raw::c_uint,
|
||||
X_AXIS: ::std::os::raw::c_int,
|
||||
Y_AXIS: ::std::os::raw::c_int,
|
||||
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
|
||||
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
|
||||
__bindgen_bitfield_unit.set(0usize, 1u8, {
|
||||
let R_DPAD: u32 = unsafe { ::std::mem::transmute(R_DPAD) };
|
||||
R_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(1usize, 1u8, {
|
||||
let L_DPAD: u32 = unsafe { ::std::mem::transmute(L_DPAD) };
|
||||
L_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(2usize, 1u8, {
|
||||
let D_DPAD: u32 = unsafe { ::std::mem::transmute(D_DPAD) };
|
||||
D_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(3usize, 1u8, {
|
||||
let U_DPAD: u32 = unsafe { ::std::mem::transmute(U_DPAD) };
|
||||
U_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(4usize, 1u8, {
|
||||
let START_BUTTON: u32 = unsafe { ::std::mem::transmute(START_BUTTON) };
|
||||
START_BUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(5usize, 1u8, {
|
||||
let Z_TRIG: u32 = unsafe { ::std::mem::transmute(Z_TRIG) };
|
||||
Z_TRIG as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(6usize, 1u8, {
|
||||
let B_BUTTON: u32 = unsafe { ::std::mem::transmute(B_BUTTON) };
|
||||
B_BUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(7usize, 1u8, {
|
||||
let A_BUTTON: u32 = unsafe { ::std::mem::transmute(A_BUTTON) };
|
||||
A_BUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(8usize, 1u8, {
|
||||
let R_CBUTTON: u32 = unsafe { ::std::mem::transmute(R_CBUTTON) };
|
||||
R_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(9usize, 1u8, {
|
||||
let L_CBUTTON: u32 = unsafe { ::std::mem::transmute(L_CBUTTON) };
|
||||
L_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(10usize, 1u8, {
|
||||
let D_CBUTTON: u32 = unsafe { ::std::mem::transmute(D_CBUTTON) };
|
||||
D_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(11usize, 1u8, {
|
||||
let U_CBUTTON: u32 = unsafe { ::std::mem::transmute(U_CBUTTON) };
|
||||
U_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(12usize, 1u8, {
|
||||
let R_TRIG: u32 = unsafe { ::std::mem::transmute(R_TRIG) };
|
||||
R_TRIG as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(13usize, 1u8, {
|
||||
let L_TRIG: u32 = unsafe { ::std::mem::transmute(L_TRIG) };
|
||||
L_TRIG as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(14usize, 1u8, {
|
||||
let Reserved1: u32 = unsafe { ::std::mem::transmute(Reserved1) };
|
||||
Reserved1 as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(15usize, 1u8, {
|
||||
let Reserved2: u32 = unsafe { ::std::mem::transmute(Reserved2) };
|
||||
Reserved2 as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(16usize, 8u8, {
|
||||
let X_AXIS: u32 = i32::cast_unsigned(X_AXIS);
|
||||
X_AXIS as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(24usize, 8u8, {
|
||||
let Y_AXIS: u32 = i32::cast_unsigned(Y_AXIS);
|
||||
Y_AXIS as u64
|
||||
});
|
||||
__bindgen_bitfield_unit
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_BUTTONS() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<BUTTONS>(),
|
||||
4usize,
|
||||
concat!("Size of: ", stringify!(BUTTONS))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<BUTTONS>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(BUTTONS))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<BUTTONS>())).Value as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(BUTTONS),
|
||||
"::",
|
||||
stringify!(Value)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct CONTROL_INFO {
|
||||
pub Controls: *mut CONTROL,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_CONTROL_INFO() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<CONTROL_INFO>(),
|
||||
8usize,
|
||||
concat!("Size of: ", stringify!(CONTROL_INFO))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<CONTROL_INFO>(),
|
||||
8usize,
|
||||
concat!("Alignment of ", stringify!(CONTROL_INFO))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL_INFO>())).Controls as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL_INFO),
|
||||
"::",
|
||||
stringify!(Controls)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,525 +0,0 @@
|
||||
/* automatically generated by rust-bindgen 0.59.1 */
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct __BindgenBitfieldUnit<Storage> {
|
||||
storage: Storage,
|
||||
}
|
||||
impl<Storage> __BindgenBitfieldUnit<Storage> {
|
||||
#[inline]
|
||||
pub const fn new(storage: Storage) -> Self {
|
||||
Self { storage }
|
||||
}
|
||||
}
|
||||
impl<Storage> __BindgenBitfieldUnit<Storage>
|
||||
where
|
||||
Storage: AsRef<[u8]> + AsMut<[u8]>,
|
||||
{
|
||||
#[inline]
|
||||
pub fn get_bit(&self, index: usize) -> bool {
|
||||
debug_assert!(index / 8 < self.storage.as_ref().len());
|
||||
let byte_index = index / 8;
|
||||
let byte = self.storage.as_ref()[byte_index];
|
||||
let bit_index = if cfg!(target_endian = "big") {
|
||||
7 - (index % 8)
|
||||
} else {
|
||||
index % 8
|
||||
};
|
||||
let mask = 1 << bit_index;
|
||||
byte & mask == mask
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_bit(&mut self, index: usize, val: bool) {
|
||||
debug_assert!(index / 8 < self.storage.as_ref().len());
|
||||
let byte_index = index / 8;
|
||||
let byte = &mut self.storage.as_mut()[byte_index];
|
||||
let bit_index = if cfg!(target_endian = "big") {
|
||||
7 - (index % 8)
|
||||
} else {
|
||||
index % 8
|
||||
};
|
||||
let mask = 1 << bit_index;
|
||||
if val {
|
||||
*byte |= mask;
|
||||
} else {
|
||||
*byte &= !mask;
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
|
||||
debug_assert!(bit_width <= 64);
|
||||
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
|
||||
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
|
||||
let mut val = 0;
|
||||
for i in 0..(bit_width as usize) {
|
||||
if self.get_bit(i + bit_offset) {
|
||||
let index = if cfg!(target_endian = "big") {
|
||||
bit_width as usize - 1 - i
|
||||
} else {
|
||||
i
|
||||
};
|
||||
val |= 1 << index;
|
||||
}
|
||||
}
|
||||
val
|
||||
}
|
||||
#[inline]
|
||||
pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
|
||||
debug_assert!(bit_width <= 64);
|
||||
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
|
||||
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
|
||||
for i in 0..(bit_width as usize) {
|
||||
let mask = 1 << i;
|
||||
let val_bit_is_set = val & mask == mask;
|
||||
let index = if cfg!(target_endian = "big") {
|
||||
bit_width as usize - 1 - i
|
||||
} else {
|
||||
i
|
||||
};
|
||||
self.set_bit(index + bit_offset, val_bit_is_set);
|
||||
}
|
||||
}
|
||||
}
|
||||
pub type m64p_dynlib_handle = *mut ::std::os::raw::c_void;
|
||||
pub const m64p_error_M64ERR_SUCCESS: m64p_error = 0;
|
||||
pub const m64p_error_M64ERR_NOT_INIT: m64p_error = 1;
|
||||
pub const m64p_error_M64ERR_ALREADY_INIT: m64p_error = 2;
|
||||
pub const m64p_error_M64ERR_INCOMPATIBLE: m64p_error = 3;
|
||||
pub const m64p_error_M64ERR_INPUT_ASSERT: m64p_error = 4;
|
||||
pub const m64p_error_M64ERR_INPUT_INVALID: m64p_error = 5;
|
||||
pub const m64p_error_M64ERR_INPUT_NOT_FOUND: m64p_error = 6;
|
||||
pub const m64p_error_M64ERR_NO_MEMORY: m64p_error = 7;
|
||||
pub const m64p_error_M64ERR_FILES: m64p_error = 8;
|
||||
pub const m64p_error_M64ERR_INTERNAL: m64p_error = 9;
|
||||
pub const m64p_error_M64ERR_INVALID_STATE: m64p_error = 10;
|
||||
pub const m64p_error_M64ERR_PLUGIN_FAIL: m64p_error = 11;
|
||||
pub const m64p_error_M64ERR_SYSTEM_FAIL: m64p_error = 12;
|
||||
pub const m64p_error_M64ERR_UNSUPPORTED: m64p_error = 13;
|
||||
pub const m64p_error_M64ERR_WRONG_TYPE: m64p_error = 14;
|
||||
pub type m64p_error = ::std::os::raw::c_int;
|
||||
pub const m64p_plugin_type_M64PLUGIN_NULL: m64p_plugin_type = 0;
|
||||
pub const m64p_plugin_type_M64PLUGIN_RSP: m64p_plugin_type = 1;
|
||||
pub const m64p_plugin_type_M64PLUGIN_GFX: m64p_plugin_type = 2;
|
||||
pub const m64p_plugin_type_M64PLUGIN_AUDIO: m64p_plugin_type = 3;
|
||||
pub const m64p_plugin_type_M64PLUGIN_INPUT: m64p_plugin_type = 4;
|
||||
pub const m64p_plugin_type_M64PLUGIN_CORE: m64p_plugin_type = 5;
|
||||
pub type m64p_plugin_type = ::std::os::raw::c_int;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct CONTROL {
|
||||
pub Present: ::std::os::raw::c_int,
|
||||
pub RawData: ::std::os::raw::c_int,
|
||||
pub Plugin: ::std::os::raw::c_int,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_CONTROL() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<CONTROL>(),
|
||||
12usize,
|
||||
concat!("Size of: ", stringify!(CONTROL))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<CONTROL>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(CONTROL))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL>())).Present as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL),
|
||||
"::",
|
||||
stringify!(Present)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL>())).RawData as *const _ as usize },
|
||||
4usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL),
|
||||
"::",
|
||||
stringify!(RawData)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL>())).Plugin as *const _ as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL),
|
||||
"::",
|
||||
stringify!(Plugin)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub union BUTTONS {
|
||||
pub Value: ::std::os::raw::c_uint,
|
||||
pub __bindgen_anon_1: BUTTONS__bindgen_ty_1,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[repr(align(4))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct BUTTONS__bindgen_ty_1 {
|
||||
pub _bitfield_align_1: [u8; 0],
|
||||
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_BUTTONS__bindgen_ty_1() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<BUTTONS__bindgen_ty_1>(),
|
||||
4usize,
|
||||
concat!("Size of: ", stringify!(BUTTONS__bindgen_ty_1))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<BUTTONS__bindgen_ty_1>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(BUTTONS__bindgen_ty_1))
|
||||
);
|
||||
}
|
||||
impl BUTTONS__bindgen_ty_1 {
|
||||
#[inline]
|
||||
pub fn R_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_R_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(0usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn L_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_L_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(1usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn D_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_D_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(2usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn U_DPAD(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_U_DPAD(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(3usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn START_BUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_START_BUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(4usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn Z_TRIG(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Z_TRIG(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(5usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn B_BUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_B_BUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(6usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn A_BUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_A_BUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(7usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn R_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_R_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(8usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn L_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_L_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(9usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn D_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_D_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(10usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn U_CBUTTON(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_U_CBUTTON(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(11usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn R_TRIG(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_R_TRIG(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(12usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn L_TRIG(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_L_TRIG(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(13usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn Reserved1(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Reserved1(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(14usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn Reserved2(&self) -> ::std::os::raw::c_uint {
|
||||
unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u32) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Reserved2(&mut self, val: ::std::os::raw::c_uint) {
|
||||
unsafe {
|
||||
let val: u32 = ::std::mem::transmute(val);
|
||||
self._bitfield_1.set(15usize, 1u8, val as u64)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn X_AXIS(&self) -> ::std::os::raw::c_int {
|
||||
u32::cast_signed(self._bitfield_1.get(16usize, 8u8) as u32)
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_X_AXIS(&mut self, val: ::std::os::raw::c_int) {
|
||||
let val: u32 = i32::cast_unsigned(val);
|
||||
self._bitfield_1.set(16usize, 8u8, val as u64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn Y_AXIS(&self) -> ::std::os::raw::c_int {
|
||||
u32::cast_signed(self._bitfield_1.get(24usize, 8u8) as u32)
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_Y_AXIS(&mut self, val: ::std::os::raw::c_int) {
|
||||
let val: u32 = i32::cast_unsigned(val);
|
||||
self._bitfield_1.set(24usize, 8u8, val as u64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn new_bitfield_1(
|
||||
R_DPAD: ::std::os::raw::c_uint,
|
||||
L_DPAD: ::std::os::raw::c_uint,
|
||||
D_DPAD: ::std::os::raw::c_uint,
|
||||
U_DPAD: ::std::os::raw::c_uint,
|
||||
START_BUTTON: ::std::os::raw::c_uint,
|
||||
Z_TRIG: ::std::os::raw::c_uint,
|
||||
B_BUTTON: ::std::os::raw::c_uint,
|
||||
A_BUTTON: ::std::os::raw::c_uint,
|
||||
R_CBUTTON: ::std::os::raw::c_uint,
|
||||
L_CBUTTON: ::std::os::raw::c_uint,
|
||||
D_CBUTTON: ::std::os::raw::c_uint,
|
||||
U_CBUTTON: ::std::os::raw::c_uint,
|
||||
R_TRIG: ::std::os::raw::c_uint,
|
||||
L_TRIG: ::std::os::raw::c_uint,
|
||||
Reserved1: ::std::os::raw::c_uint,
|
||||
Reserved2: ::std::os::raw::c_uint,
|
||||
X_AXIS: ::std::os::raw::c_int,
|
||||
Y_AXIS: ::std::os::raw::c_int,
|
||||
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
|
||||
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
|
||||
__bindgen_bitfield_unit.set(0usize, 1u8, {
|
||||
let R_DPAD: u32 = unsafe { ::std::mem::transmute(R_DPAD) };
|
||||
R_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(1usize, 1u8, {
|
||||
let L_DPAD: u32 = unsafe { ::std::mem::transmute(L_DPAD) };
|
||||
L_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(2usize, 1u8, {
|
||||
let D_DPAD: u32 = unsafe { ::std::mem::transmute(D_DPAD) };
|
||||
D_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(3usize, 1u8, {
|
||||
let U_DPAD: u32 = unsafe { ::std::mem::transmute(U_DPAD) };
|
||||
U_DPAD as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(4usize, 1u8, {
|
||||
let START_BUTTON: u32 = unsafe { ::std::mem::transmute(START_BUTTON) };
|
||||
START_BUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(5usize, 1u8, {
|
||||
let Z_TRIG: u32 = unsafe { ::std::mem::transmute(Z_TRIG) };
|
||||
Z_TRIG as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(6usize, 1u8, {
|
||||
let B_BUTTON: u32 = unsafe { ::std::mem::transmute(B_BUTTON) };
|
||||
B_BUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(7usize, 1u8, {
|
||||
let A_BUTTON: u32 = unsafe { ::std::mem::transmute(A_BUTTON) };
|
||||
A_BUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(8usize, 1u8, {
|
||||
let R_CBUTTON: u32 = unsafe { ::std::mem::transmute(R_CBUTTON) };
|
||||
R_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(9usize, 1u8, {
|
||||
let L_CBUTTON: u32 = unsafe { ::std::mem::transmute(L_CBUTTON) };
|
||||
L_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(10usize, 1u8, {
|
||||
let D_CBUTTON: u32 = unsafe { ::std::mem::transmute(D_CBUTTON) };
|
||||
D_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(11usize, 1u8, {
|
||||
let U_CBUTTON: u32 = unsafe { ::std::mem::transmute(U_CBUTTON) };
|
||||
U_CBUTTON as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(12usize, 1u8, {
|
||||
let R_TRIG: u32 = unsafe { ::std::mem::transmute(R_TRIG) };
|
||||
R_TRIG as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(13usize, 1u8, {
|
||||
let L_TRIG: u32 = unsafe { ::std::mem::transmute(L_TRIG) };
|
||||
L_TRIG as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(14usize, 1u8, {
|
||||
let Reserved1: u32 = unsafe { ::std::mem::transmute(Reserved1) };
|
||||
Reserved1 as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(15usize, 1u8, {
|
||||
let Reserved2: u32 = unsafe { ::std::mem::transmute(Reserved2) };
|
||||
Reserved2 as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(16usize, 8u8, {
|
||||
let X_AXIS: u32 = i32::cast_unsigned(X_AXIS);
|
||||
X_AXIS as u64
|
||||
});
|
||||
__bindgen_bitfield_unit.set(24usize, 8u8, {
|
||||
let Y_AXIS: u32 = i32::cast_unsigned(Y_AXIS);
|
||||
Y_AXIS as u64
|
||||
});
|
||||
__bindgen_bitfield_unit
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_BUTTONS() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<BUTTONS>(),
|
||||
4usize,
|
||||
concat!("Size of: ", stringify!(BUTTONS))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<BUTTONS>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(BUTTONS))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<BUTTONS>())).Value as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(BUTTONS),
|
||||
"::",
|
||||
stringify!(Value)
|
||||
)
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct CONTROL_INFO {
|
||||
pub Controls: *mut CONTROL,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_CONTROL_INFO() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<CONTROL_INFO>(),
|
||||
8usize,
|
||||
concat!("Size of: ", stringify!(CONTROL_INFO))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<CONTROL_INFO>(),
|
||||
8usize,
|
||||
concat!("Alignment of ", stringify!(CONTROL_INFO))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<CONTROL_INFO>())).Controls as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(CONTROL_INFO),
|
||||
"::",
|
||||
stringify!(Controls)
|
||||
)
|
||||
);
|
||||
}
|
||||
-331
@@ -1,331 +0,0 @@
|
||||
#[macro_use]
|
||||
mod debug;
|
||||
pub mod adapter;
|
||||
pub mod config;
|
||||
mod ffi;
|
||||
#[macro_use]
|
||||
mod static_cstr;
|
||||
|
||||
use adapter::ADAPTER_STATE;
|
||||
use config::Config;
|
||||
use debug::M64Message;
|
||||
use ffi::*;
|
||||
use once_cell::sync::OnceCell;
|
||||
use static_cstr::StaticCStr;
|
||||
use std::{
|
||||
ffi::{c_void, CStr},
|
||||
mem::ManuallyDrop,
|
||||
os::raw::{c_char, c_int, c_uchar},
|
||||
path::Path,
|
||||
ptr,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
use libloading::os::unix::Library;
|
||||
#[cfg(windows)]
|
||||
use libloading::os::windows::Library;
|
||||
|
||||
struct PluginInfo {
|
||||
name: StaticCStr,
|
||||
version: c_int,
|
||||
target_api_version: c_int,
|
||||
}
|
||||
|
||||
static PLUGIN_INFO: PluginInfo = PluginInfo {
|
||||
name: static_cstr!("GC Adapter (for Wii U or Switch) Input Plugin"),
|
||||
version: 0x000600, // v0.6.0
|
||||
target_api_version: 0x020100, // v2.1.0
|
||||
};
|
||||
|
||||
static IS_INIT: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
static CONFIG: OnceCell<Config> = OnceCell::new();
|
||||
|
||||
/// Start up the plugin.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `core_lib_handle` cannot be null and must be a pointer to the mupen64plus-core dynamic library.
|
||||
/// `debug_callback` cannot be null and must be a valid C function pointer with the correct type signature.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn PluginStartup(
|
||||
core_lib_handle: m64p_dynlib_handle,
|
||||
context: *mut c_void,
|
||||
debug_callback: debug::DebugCallback,
|
||||
) -> m64p_error {
|
||||
if IS_INIT.load(Ordering::Acquire) {
|
||||
debug_print!(M64Message::Error, "Plugin was already initialized");
|
||||
return m64p_error_M64ERR_ALREADY_INIT;
|
||||
}
|
||||
|
||||
IS_INIT.store(true, Ordering::Release);
|
||||
|
||||
// Register a custom panic hook in order to stop the adapter thread
|
||||
let default_panic = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |p| {
|
||||
debug_print!(M64Message::Error, "panic occurred");
|
||||
IS_INIT.store(false, Ordering::Release);
|
||||
default_panic(p);
|
||||
}));
|
||||
|
||||
debug::init(debug_callback, context);
|
||||
debug_print!(M64Message::Info, "PluginStartup called");
|
||||
|
||||
// Make sure to NOT free the library associated with the handle
|
||||
let lib = ManuallyDrop::new(Library::from_raw(core_lib_handle.cast()));
|
||||
|
||||
let core_api_version_fn = if let Ok(sym) =
|
||||
lib.get::<extern "C" fn(*mut c_int, *mut c_int, *mut c_int, *mut c_int)>(
|
||||
b"CoreGetAPIVersions\0",
|
||||
) {
|
||||
sym
|
||||
} else {
|
||||
debug_print!(
|
||||
M64Message::Error,
|
||||
"Could not find function for getting core API versions"
|
||||
);
|
||||
return m64p_error_M64ERR_INPUT_INVALID;
|
||||
};
|
||||
|
||||
let mut core_ver = 0;
|
||||
core_api_version_fn(
|
||||
&mut core_ver as *mut _,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
);
|
||||
|
||||
debug_print!(
|
||||
M64Message::Info,
|
||||
"Core API reported version {:#08X}",
|
||||
core_ver
|
||||
);
|
||||
|
||||
if core_ver < PLUGIN_INFO.target_api_version
|
||||
|| core_ver & 0xfff0000 != PLUGIN_INFO.target_api_version & 0xfff0000
|
||||
{
|
||||
debug_print!(
|
||||
M64Message::Error,
|
||||
"Plugin is incompatible with core API version"
|
||||
);
|
||||
return m64p_error_M64ERR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
adapter::start_read_thread();
|
||||
|
||||
let cfg_file_name = "mupen64plus-input-gca.toml";
|
||||
let cfg_path = if let Ok(sym) =
|
||||
lib.get::<extern "C" fn() -> *const c_char>(b"ConfigGetUserConfigPath\0")
|
||||
{
|
||||
let usr_cfg_dir = CStr::from_ptr(sym()).to_string_lossy();
|
||||
Path::new(usr_cfg_dir.as_ref()).join(cfg_file_name)
|
||||
} else {
|
||||
debug_print!(
|
||||
M64Message::Error,
|
||||
"Could not find function for getting user config path"
|
||||
);
|
||||
|
||||
Path::new(cfg_file_name)
|
||||
.canonicalize()
|
||||
.expect("could not canonicalize relative path")
|
||||
};
|
||||
|
||||
debug_print!(
|
||||
M64Message::Info,
|
||||
"Using user configuration path: {}",
|
||||
cfg_path.display()
|
||||
);
|
||||
|
||||
// Ignore error if the cell was alredy initialized
|
||||
let _ = CONFIG.set(Config::read_from_file(&cfg_path).unwrap_or_else(|e| {
|
||||
debug_print!(M64Message::Error, "Config error: {:?}", e);
|
||||
Config::create(&cfg_path).unwrap_or_else(|e| e)
|
||||
}));
|
||||
|
||||
m64p_error_M64ERR_SUCCESS
|
||||
}
|
||||
|
||||
/// Shut down the plugin.
|
||||
///
|
||||
/// This function is not unsafe, but if this is not called then the adapter thread will continue running.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn PluginShutdown() -> m64p_error {
|
||||
debug_print!(M64Message::Info, "PluginShutdown called");
|
||||
|
||||
IS_INIT.store(false, Ordering::Release);
|
||||
|
||||
m64p_error_M64ERR_SUCCESS
|
||||
}
|
||||
|
||||
/// Get the plugin type, version, target API version, name, and capabilities.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller has to make sure the given pointers are valid.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn PluginGetVersion(
|
||||
plugin_type: *mut m64p_plugin_type,
|
||||
plugin_version: *mut c_int,
|
||||
api_version: *mut c_int,
|
||||
plugin_name_ptr: *mut *const c_char,
|
||||
capabilities: *mut c_int,
|
||||
) -> m64p_error {
|
||||
debug_print!(M64Message::Info, "PluginGetVersion called");
|
||||
|
||||
if !plugin_type.is_null() {
|
||||
*plugin_type = m64p_plugin_type_M64PLUGIN_INPUT;
|
||||
}
|
||||
if !plugin_version.is_null() {
|
||||
*plugin_version = PLUGIN_INFO.version;
|
||||
}
|
||||
if !api_version.is_null() {
|
||||
*api_version = PLUGIN_INFO.target_api_version;
|
||||
}
|
||||
if !plugin_name_ptr.is_null() {
|
||||
*plugin_name_ptr = PLUGIN_INFO.name.as_ptr();
|
||||
}
|
||||
if !capabilities.is_null() {
|
||||
*capabilities = 0;
|
||||
}
|
||||
|
||||
m64p_error_M64ERR_SUCCESS
|
||||
}
|
||||
|
||||
/// Initiate controllers by filling the given `CONTROL_INFO` struct.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `control_info` must point to an initialized `CONTROL_INFO` struct, and the `Controls` field must point to an array
|
||||
/// of length 4 with initialized `CONTROL` structs.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn InitiateControllers(control_info: CONTROL_INFO) {
|
||||
debug_print!(M64Message::Info, "InitiateControllers called");
|
||||
|
||||
let controls = control_info.Controls;
|
||||
#[cfg(feature = "m64p_compat")]
|
||||
let controls = controls as *mut CONTROL_M64P;
|
||||
|
||||
for i in 0..4 {
|
||||
(*controls.add(i)).RawData = 0;
|
||||
(*controls.add(i)).Present = 1;
|
||||
}
|
||||
|
||||
if !adapter::ADAPTER_STATE.any_connected() {
|
||||
debug_print!(
|
||||
M64Message::Warning,
|
||||
"No controllers connected, but hotplugging is supported"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the state of the buttons by reading from the adapter.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `keys` must point to an intialized `BUTTONS` union.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn GetKeys(control: c_int, keys: *mut BUTTONS) {
|
||||
let s = ADAPTER_STATE.controller_state(control);
|
||||
if !s.connected {
|
||||
return;
|
||||
}
|
||||
|
||||
let keys = &mut *keys;
|
||||
keys.Value = 0;
|
||||
|
||||
let cfg = CONFIG.get().unwrap();
|
||||
let (stick_x, stick_y) =
|
||||
s.stick_with_deadzone(cfg.control_stick_deadzone, cfg.control_stick_sensitivity);
|
||||
let (substick_x, substick_y) = s.substick_with_deadzone(cfg.c_stick_deadzone);
|
||||
|
||||
if s.right {
|
||||
keys.Value |= cfg.controller_mapping.d_pad_right.bit_pattern();
|
||||
}
|
||||
if s.left {
|
||||
keys.Value |= cfg.controller_mapping.d_pad_left.bit_pattern();
|
||||
}
|
||||
if s.down {
|
||||
keys.Value |= cfg.controller_mapping.d_pad_down.bit_pattern();
|
||||
}
|
||||
if s.up {
|
||||
keys.Value |= cfg.controller_mapping.d_pad_up.bit_pattern();
|
||||
}
|
||||
if s.start {
|
||||
keys.Value |= cfg.controller_mapping.start.bit_pattern();
|
||||
}
|
||||
if s.a {
|
||||
keys.Value |= cfg.controller_mapping.a.bit_pattern();
|
||||
}
|
||||
if s.b {
|
||||
keys.Value |= cfg.controller_mapping.b.bit_pattern();
|
||||
}
|
||||
if s.x {
|
||||
keys.Value |= cfg.controller_mapping.x.bit_pattern();
|
||||
}
|
||||
if s.y {
|
||||
keys.Value |= cfg.controller_mapping.y.bit_pattern();
|
||||
}
|
||||
if substick_x < 0 {
|
||||
keys.Value |= cfg.controller_mapping.c_stick_left.bit_pattern();
|
||||
}
|
||||
if substick_x > 0 {
|
||||
keys.Value |= cfg.controller_mapping.c_stick_right.bit_pattern();
|
||||
}
|
||||
if substick_y < 0 {
|
||||
keys.Value |= cfg.controller_mapping.c_stick_down.bit_pattern();
|
||||
}
|
||||
if substick_y > 0 {
|
||||
keys.Value |= cfg.controller_mapping.c_stick_up.bit_pattern();
|
||||
}
|
||||
if s.l || s.trigger_left > cfg.trigger_threshold {
|
||||
keys.Value |= cfg.controller_mapping.l.bit_pattern();
|
||||
}
|
||||
if s.r || s.trigger_right > cfg.trigger_threshold {
|
||||
keys.Value |= cfg.controller_mapping.r.bit_pattern();
|
||||
}
|
||||
if s.z {
|
||||
keys.Value |= cfg.controller_mapping.z.bit_pattern();
|
||||
}
|
||||
|
||||
keys.__bindgen_anon_1.set_X_AXIS(stick_x as i32);
|
||||
keys.__bindgen_anon_1.set_Y_AXIS(stick_y as i32);
|
||||
}
|
||||
|
||||
/// Process the command and possibly read the controller. Currently unused, since raw data is disabled.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `command` must be a valid u8 array with length dependent of the given command.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ReadController(_control: c_int, _command: *mut u8) {}
|
||||
|
||||
/// Currently unused, only needed to be a valid input plugin.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ControllerCommand(_control: c_int, _command: *mut c_uchar) {}
|
||||
|
||||
/// Currently unused, only needed to be a valid input plugin.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn RomOpen() -> c_int {
|
||||
debug_print!(M64Message::Info, "RomOpen called");
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
/// Currently unused, only needed to be a valid input plugin.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn RomClosed() {
|
||||
debug_print!(M64Message::Info, "RomClosed called");
|
||||
}
|
||||
|
||||
/// Currently unused, only needed to be a valid input plugin.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn SDL_KeyDown(_keymod: c_int, _keysym: c_int) {
|
||||
debug_print!(M64Message::Info, "SDL_KeyDown called");
|
||||
}
|
||||
|
||||
/// Currently unused, only needed to be a valid input plugin.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn SDL_KeyUp(_keymod: c_int, _keysym: c_int) {
|
||||
debug_print!(M64Message::Info, "SDL_KeyUp called");
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
use std::os::raw::c_char;
|
||||
|
||||
macro_rules! static_cstr {
|
||||
($s:expr) => {
|
||||
StaticCStr(concat!($s, "\0").as_bytes())
|
||||
};
|
||||
}
|
||||
|
||||
pub struct StaticCStr(pub &'static [u8]);
|
||||
|
||||
impl StaticCStr {
|
||||
pub fn as_ptr(&self) -> *const c_char {
|
||||
self.0.as_ptr() as *const _
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
use mupen64plus_input_gca::adapter::{AdapterState, ControllerState, GcAdapter};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
fn all_controller_states<'a>(
|
||||
state: &'a AdapterState,
|
||||
) -> impl Iterator<Item = ControllerState> + 'a {
|
||||
(0..4).map(move |i| state.controller_state(i))
|
||||
}
|
||||
|
||||
fn any(state: ControllerState) -> bool {
|
||||
const CONTROL_DEADZONE: u8 = 15;
|
||||
const CONTROL_SENSITIVITY: u8 = 100;
|
||||
const C_DEADZONE: u8 = 15;
|
||||
const TRIGGER_THRESHOLD: u8 = 168;
|
||||
let (stick_x, stick_y) = state.stick_with_deadzone(CONTROL_DEADZONE, CONTROL_SENSITIVITY);
|
||||
let (substick_x, substick_y) = state.substick_with_deadzone(C_DEADZONE);
|
||||
state.connected
|
||||
&& (state.a
|
||||
|| state.b
|
||||
|| state.x
|
||||
|| state.y
|
||||
|| state.start
|
||||
|| state.left
|
||||
|| state.right
|
||||
|| state.down
|
||||
|| state.up
|
||||
|| state.l
|
||||
|| state.trigger_left > TRIGGER_THRESHOLD
|
||||
|| state.r
|
||||
|| state.trigger_right > TRIGGER_THRESHOLD
|
||||
|| state.z
|
||||
|| stick_x != 0
|
||||
|| stick_y != 0
|
||||
|| substick_x != 0
|
||||
|| substick_y != 0)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn receives_input() {
|
||||
const ERR: &str = "make sure the adapter is connected, and press the input(s) you want to test";
|
||||
|
||||
let adapter = GcAdapter::new().expect(ERR);
|
||||
let started = Instant::now();
|
||||
|
||||
let mut state = AdapterState::new();
|
||||
state.set_buf(adapter.read().unwrap());
|
||||
|
||||
if !(0..4).map(|i| state.is_connected(i)).any(|b| b) {
|
||||
eprintln!("no controllers detected, but might be a false negative");
|
||||
}
|
||||
|
||||
let mut any_input = false;
|
||||
loop {
|
||||
if started.elapsed() > Duration::from_secs(10) {
|
||||
break;
|
||||
}
|
||||
|
||||
state.set_buf(adapter.read().unwrap());
|
||||
if let Some((i, _)) = (0..4)
|
||||
.map(|i| (i, any(state.controller_state(i))))
|
||||
.find(|(_, a)| *a)
|
||||
{
|
||||
any_input = true;
|
||||
println!("Channel {}: {:?}", i, state.controller_state(i));
|
||||
}
|
||||
}
|
||||
|
||||
assert!(any_input);
|
||||
}
|
||||
Reference in New Issue
Block a user