Compare commits
190 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 625a0ec5ec | |||
| 6b79ead016 | |||
| f2504649e9 | |||
| b4326d972d | |||
| 2f23974f81 | |||
| 26c4be927a | |||
| 87baa3cc79 | |||
| 189354b8e9 | |||
| 345c1c0d27 | |||
| c98ee8dbef | |||
| 6b2ab31824 | |||
| 31ad94a1ee | |||
| 33f71fa042 | |||
| 8e35b4dd35 | |||
| 47de02a172 | |||
| 256f1a99de | |||
| 1361276e1a | |||
| 54a996a989 | |||
| d13493e7fe | |||
| d1f3bd9938 | |||
| cb164a8236 | |||
| 88a9b6ce7b | |||
| 97b6d7e4cf | |||
| cf3250e11b | |||
| d1cf4fcf61 | |||
| afd99f6ec0 | |||
| fcfe75b906 | |||
| 17d955042f | |||
| 1a72165a2c | |||
| 834754b3a3 | |||
| 160bd243a6 | |||
| ba6c7353d9 | |||
| 90c1b7b5c1 | |||
| b83267d257 | |||
| c9915d2b0b | |||
| bb38735679 | |||
| 1f2ba5df16 | |||
| 04850d017f | |||
| ac04d717af | |||
| ddbb41e71a | |||
| 856e285427 | |||
| 3d0816a284 | |||
| c1d8ec0cd2 | |||
| dc817bf2b9 | |||
| 9452acb749 | |||
| c850ae3aea | |||
| 7e43f1bfbf | |||
| d0f8c7c6a9 | |||
| 1e3420aa8f | |||
| 62185ef48b | |||
| e851085b9b | |||
| 748a5ed5b5 | |||
| 4b62a06af9 | |||
| f191347e05 | |||
| a195028061 | |||
| 72ccb94cba | |||
| 53541e8e38 | |||
| 40d1691b40 | |||
| d38c685772 | |||
| b56181e59f | |||
| 8496a93690 | |||
| 3984f0197f | |||
| 73827b40c8 | |||
| 42e34087fc | |||
| 7292ac7b92 | |||
| 931236ec82 | |||
| d25a043958 | |||
| 8c2f5c109a | |||
| f2834c0079 | |||
| 487a686c9a | |||
| 5f8eb8d704 | |||
| 8ee5a039d9 | |||
| 6f62316525 | |||
| e86adb7b4a | |||
| bc139be5ac | |||
| 89606d54f1 | |||
| afaeab92a6 | |||
| e2a81e3626 | |||
| 80c519df6b | |||
| 85b70b1bef | |||
| 10c7b24130 | |||
| 725700952e | |||
| 386d664d2f | |||
| d17b905747 | |||
| f6d198b4fb | |||
| 5e81da6827 | |||
| 8c6b82564a | |||
| dd72f62e06 | |||
| 90dd579372 | |||
| c3c77d79ed | |||
| 128d69039e | |||
| 668ca4d4d5 | |||
| 33e7dc1b04 | |||
| 856b06a9d7 | |||
| 6a95b78584 | |||
| b5631470ad | |||
| 757e29b223 | |||
| 6e17b80cd2 | |||
| d9e8b3bb17 | |||
| 3889ef8d11 | |||
| 9d16ab056b | |||
| 339b665712 | |||
| 71c2f0acf9 | |||
| 6c79e7fb41 | |||
| 98220d224f | |||
| c57923f1a9 | |||
| 13beb3e0f4 | |||
| c5e612a48b | |||
| 14cd8db985 | |||
| 194c87c271 | |||
| d5478c5d26 | |||
| ffd16169a8 | |||
| 69321de26f | |||
| 2608758799 | |||
| 1d2f7bff6b | |||
| b7eb63e481 | |||
| c9efd9e07d | |||
| 2fbb555d1f | |||
| d05bb314c6 | |||
| a8202034ed | |||
| a072ef1ac8 | |||
| c779eaa368 | |||
| e252913a04 | |||
| a7a4b27974 | |||
| db309cab30 | |||
| 44eb59a505 | |||
| dedf57fac0 | |||
| e398f9bafd | |||
| 979b06b3d7 | |||
| 764717a692 | |||
| 955ddf5a68 | |||
| c11694c8f5 | |||
| 71c137cb7b | |||
| 236a8eaf2b | |||
| 11584605aa | |||
| 7ba6ddd36c | |||
| 1919ec2d1f | |||
| 4e0431a322 | |||
| 32dfe1835c | |||
| 39c70d5215 | |||
| 53f46d6cbc | |||
| cac6b77701 | |||
| 10a53e345e | |||
| 858cb2c70c | |||
| 55917f29ee | |||
| 8e298bf3c8 | |||
| 2cd7f3b231 | |||
| df8b9c496b | |||
| 26ed97b25e | |||
| 89b144fe69 | |||
| 7a090660f0 | |||
| 1b864a9a90 | |||
| f302db99fd | |||
| aa71c25eee | |||
| 8ddb42e3b7 | |||
| 3d3b660f35 | |||
| b648d80e52 | |||
| aa744bfc9d | |||
| 157c2f3ebc | |||
| 0277830d44 | |||
| 4478b07e9c | |||
| 9fbd2684e8 | |||
| ad69d1bbbe | |||
| c83d72ee59 | |||
| 079f0e3cbc | |||
| 6d26f077ca | |||
| 884582f056 | |||
| dc01a8cb0b | |||
| 843e548735 | |||
| 3f8605b480 | |||
| fb5597ecc2 | |||
| c0f9e865bd | |||
| c406d589a4 | |||
| 2ca266e1f2 | |||
| 0ed563b102 | |||
| 114c25454b | |||
| eedabd57c2 | |||
| 07b6f36115 | |||
| f87bf17412 | |||
| 877552c3a4 | |||
| 07fcf7d196 | |||
| dff69f7269 | |||
| 9654131119 | |||
| ff4619146e | |||
| 0e366475a3 | |||
| b420f16e3c | |||
| 2d50f82c1b | |||
| 7e99570f41 | |||
| 51f537e2fc | |||
| 6e566bb0dd |
@@ -1,26 +0,0 @@
|
||||
version: '{branch}.{build}'
|
||||
os: Windows
|
||||
clone_folder: C:\Projects\Cataclysm-DDA
|
||||
shallow_clone: true
|
||||
pull_requests:
|
||||
do_not_increment_build_number: false
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
PROJECT: /msvc-full-features/Cataclysm-vcpkg-static.sln
|
||||
COMPILER: msvc2017
|
||||
TOOLCHAIN: msvc15
|
||||
PLATFORM: x64
|
||||
CONFIGURATION: Release
|
||||
APPVEYOR_SAVE_CACHE_ON_ERROR: true
|
||||
matrix:
|
||||
fast_finish: false
|
||||
cache:
|
||||
- 'c:\tools\vcpkg\installed'
|
||||
install:
|
||||
# Install dependency packages
|
||||
- cmd: vcpkg --triplet %PLATFORM%-windows-static install sdl2 sdl2-image sdl2-mixer sdl2-ttf gettext
|
||||
build:
|
||||
parallel: true
|
||||
project: /msvc-full-features/Cataclysm-vcpkg-static.sln
|
||||
verbosity: minimal
|
||||
@@ -1,51 +0,0 @@
|
||||
# These options are mirrored in .astylerc and doc/CODE_STYLE.txt
|
||||
|
||||
# "One True Brace Style"
|
||||
--style=1tbs
|
||||
|
||||
# Attach brackets to class and struct inline function definitions.
|
||||
--attach-inlines
|
||||
|
||||
# 4 spaces per indentation level and per tab stop
|
||||
--indent=spaces=4
|
||||
|
||||
# 'char *foo' instead of 'char* foo'
|
||||
--align-pointer=name
|
||||
|
||||
# maximum length for a single unbroken line
|
||||
--max-code-length=100
|
||||
|
||||
# 'foo ||\nbar' instead of 'foo\n|| bar'
|
||||
--break-after-logical
|
||||
|
||||
# indent 'public:' 'protected:' 'private:' deeper than 'class' or 'struct'
|
||||
--indent-classes
|
||||
|
||||
# indent 'case' lines deeper than 'switch'
|
||||
--indent-switches
|
||||
|
||||
# indent later lines of multi-line preprocessor directives
|
||||
# to be deprecated by --indent-preproc-define
|
||||
--indent-preprocessor
|
||||
|
||||
# indent comments on column 1 to match the code block they are in
|
||||
--indent-col1-comments
|
||||
|
||||
# indent multi-line control block headers like 'if (foo\nbar)'
|
||||
--min-conditional-indent=0
|
||||
|
||||
# add space around operators with two operands
|
||||
--pad-oper
|
||||
|
||||
# add brackets to unbracketed one line conditional statements
|
||||
--add-brackets
|
||||
|
||||
# replaces tabs with spaces in non-indent sections, except in strings
|
||||
--convert-tabs
|
||||
|
||||
# remove extra space padding around parentheses
|
||||
--unpad-paren
|
||||
|
||||
# insert space padding around parentheses on the inside only
|
||||
--pad-paren-in
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Enable some categories of checks and then disable individual ones.
|
||||
# The disabled checks that appear as part of the initial alphabetical section
|
||||
# enabling categories (e.g. cert-err58-cpp) are ones that do not make sense for
|
||||
# this codebase and we do not intend to fix. The disabled checks appearing
|
||||
# thereafter in a separate alphabetical list have yet to be triaged. We may
|
||||
# fix their errors or recategorise them as checks we don't care about.
|
||||
Checks: "\
|
||||
bugprone-*,\
|
||||
cata-*,\
|
||||
cert-*,\
|
||||
-cert-dcl21-cpp,\
|
||||
-cert-env33-c,\
|
||||
-cert-err58-cpp,\
|
||||
clang-diagnostic-*,\
|
||||
cppcoreguidelines-slicing,\
|
||||
llvm-namespace-comment,\
|
||||
misc-*,\
|
||||
modernize-*,\
|
||||
-modernize-use-auto,\
|
||||
-modernize-use-trailing-return-type,\
|
||||
performance-*,\
|
||||
readability-*,\
|
||||
-bugprone-misplaced-widening-cast,\
|
||||
-bugprone-narrowing-conversions,\
|
||||
-bugprone-unused-return-value,\
|
||||
-cert-err34-c,\
|
||||
-cert-flp30-c,\
|
||||
-cert-msc30-c,\
|
||||
-cert-msc32-c,\
|
||||
-cert-msc50-cpp,\
|
||||
-cert-msc51-cpp,\
|
||||
-misc-non-private-member-variables-in-classes,\
|
||||
-modernize-avoid-c-arrays,\
|
||||
-modernize-pass-by-value,\
|
||||
-modernize-return-braced-init-list,\
|
||||
-modernize-use-default-member-init,\
|
||||
-modernize-use-emplace,\
|
||||
-modernize-use-transparent-functors,\
|
||||
-performance-for-range-copy,\
|
||||
-performance-inefficient-vector-operation,\
|
||||
-performance-noexcept-move-constructor,\
|
||||
-performance-implicit-conversion-in-loop,\
|
||||
-performance-inefficient-algorithm,\
|
||||
-performance-inefficient-string-concatenation,\
|
||||
-performance-type-promotion-in-math-fn,\
|
||||
-performance-unnecessary-value-param,\
|
||||
-readability-braces-around-statements,\
|
||||
-readability-else-after-return,\
|
||||
-readability-function-size,\
|
||||
-readability-implicit-bool-conversion,\
|
||||
-readability-isolate-declaration,\
|
||||
-readability-magic-numbers,\
|
||||
-readability-named-parameter,\
|
||||
-readability-redundant-control-flow,\
|
||||
-readability-redundant-declaration,\
|
||||
-readability-redundant-preprocessor,\
|
||||
"
|
||||
WarningsAsErrors: '*'
|
||||
HeaderFilterRegex: '(src|test).*'
|
||||
FormatStyle: none
|
||||
CheckOptions:
|
||||
- key: readability-uppercase-literal-suffix.NewSuffixes
|
||||
value: 'L;UL;LL;ULL'
|
||||
- key: cata-text-style.EscapeUnicode
|
||||
value: 0
|
||||
|
||||
# vim:tw=0
|
||||
@@ -1,17 +0,0 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.json]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -1,39 +0,0 @@
|
||||
# Automatically normalise line endings for all files
|
||||
# detected as text (Convert CRLF => LF).
|
||||
* text=auto
|
||||
|
||||
# Explicitly normalise files with these extensions in
|
||||
# case Git doesn't detect them as text for some reason.
|
||||
*.c text
|
||||
*.cbp text
|
||||
*.cpp text
|
||||
*.h text
|
||||
*.json text
|
||||
*.md text
|
||||
*.py text
|
||||
*.rc text
|
||||
*.sh text
|
||||
*.txt text
|
||||
*.yml text
|
||||
|
||||
# Visual Studio project files, leave them alone.
|
||||
*.cmd -text
|
||||
*.filters -text
|
||||
*.sln -text
|
||||
*.user -text
|
||||
*.vcxproj -text
|
||||
|
||||
# Generated translation text, don't mess with them.
|
||||
*.mo -text
|
||||
*.po -text
|
||||
*.pot -text
|
||||
|
||||
# Treat images, archives, and font files as binary.
|
||||
# (binary is a macro for -text -diff)
|
||||
*.db binary
|
||||
*.fon binary
|
||||
*.gz binary
|
||||
*.ico binary
|
||||
*.png binary
|
||||
*.ttf binary
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#Note that despite github calling these "owners", a better term would be "alerts"
|
||||
#Everything in the cataclysm repository remains under a creative commons license, nobody owns the mods.
|
||||
#In fact, the code "owners" designation is meant to encourage third party
|
||||
#individuals to contribute to the mod, with the maintainers notified for reviews.
|
||||
|
||||
/data/mods/Aftershock/ @Malecypse @John-Candlebury
|
||||
/data/mods/DinoMod/ @damien @ethankaminski @LyleSY
|
||||
/data/mods/Graphical_Overmap/ @Kilvoctu @Larwck
|
||||
/data/mods/MMA/ @Hymore246
|
||||
/data/mods/No_Fungi/ @I-am-Erk
|
||||
/data/mods/blazemod/ @SouP
|
||||
/data/mods/classic_zombies/ @I-am-Erk
|
||||
/data/mods/crt_expansion/ @Soupster89
|
||||
/data/mods/desertpack/ @davidpwbrown
|
||||
/data/mods/generic_guns/ @tenmillimaster
|
||||
/data/mods/magiclysm/ @KorGgenT
|
||||
/data/mods/my_sweet_cataclysm/ @Fris0uman
|
||||
/data/mods/ruralbiome/ @I-am-Erk
|
||||
/data/mods/speedydex/ @KorGgenT
|
||||
/data/mods/stats_through_kills/ @KorGgenT
|
||||
|
||||
magic*.cpp @KorGgenT
|
||||
magic*.h @KorGgenT
|
||||
/data/json/itemgroups/SUS/ @I-am-Erk
|
||||
/data/json/npcs/refugee_center/ @I-am-Erk
|
||||
/data/json/npcs/Backgrounds/ @I-am-Erk
|
||||
/data/json/snippets/ @I-am-Erk
|
||||
/gfx/ @I-am-Erk
|
||||
@@ -1,294 +0,0 @@
|
||||
# Contribute
|
||||
|
||||
**Opening new issue?** Please read [ISSUES.md](../ISSUES.md) first.
|
||||
|
||||
Contributing to Cataclysm: Dark Days Ahead is easy — simply fork the repository here on GitHub, make your changes, and then send us a pull request.
|
||||
|
||||
Cataclysm:Dark Days Ahead is released under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
|
||||
This means any contribution you make to the project will also be covered by the same license, and this license is irrevocable.
|
||||
|
||||
## Guidelines
|
||||
|
||||
There are a couple of guidelines we suggest sticking to:
|
||||
|
||||
* Add this repository as an `upstream` remote.
|
||||
* Keep your `master` branch clean. This means you can easily pull changes made to this repository into yours.
|
||||
* Create a new branch for each new feature or set of related bug fixes.
|
||||
* Never merge from your local branches into your `master` branch. Only update that by pulling from `upstream/master`.
|
||||
|
||||
## Code Style
|
||||
|
||||
Code style is enforced across the codebase by `astyle`.
|
||||
See [CODE_STYLE](../doc/CODE_STYLE.md) for details.
|
||||
|
||||
## Translations
|
||||
|
||||
The translation of Cataclysm: DDA is done using Transifex.
|
||||
Look at the [translation project](https://www.transifex.com/cataclysm-dda-translators/cataclysm-dda/) for an up-to-date list of supported languages.
|
||||
|
||||
See [TRANSLATING](../doc/TRANSLATING.md) for more information:
|
||||
|
||||
* [For translators](../doc/TRANSLATING.md#translators)
|
||||
* [For developers](../doc/TRANSLATING.md#developers)
|
||||
* [For maintainers](../doc/TRANSLATING.md#maintainers)
|
||||
|
||||
## Doxygen Comments
|
||||
|
||||
Extensive documentation of classes and class members will make the code more readable to new contributors. New doxygen comments for existing classes are a welcomed contribution.
|
||||
|
||||
Use the following template for commenting classes:
|
||||
```c++
|
||||
/**
|
||||
* Brief description
|
||||
*
|
||||
* Lengthy description with many words. (optional)
|
||||
*/
|
||||
class foo {
|
||||
```
|
||||
|
||||
Use the following template for commenting functions:
|
||||
```c++
|
||||
/**
|
||||
* Brief description
|
||||
*
|
||||
* Lengthy description with many words. (optional)
|
||||
* @param param1 Description of param1 (optional)
|
||||
* @return Description of return (optional)
|
||||
*/
|
||||
int foo(int param1);
|
||||
```
|
||||
|
||||
Use the following template for commenting member variables:
|
||||
```c++
|
||||
/** Brief description **/
|
||||
int foo;
|
||||
```
|
||||
|
||||
Helpful pages:
|
||||
http://www.stack.nl/~dimitri/doxygen/manual/commands.html
|
||||
http://www.stack.nl/~dimitri/doxygen/manual/markdown.html#markdown_std
|
||||
http://www.stack.nl/~dimitri/doxygen/manual/faq.html
|
||||
|
||||
### Guidelines for adding documentation
|
||||
* Doxygen comments should describe behavior towards the outside, not implementation, but since many classes in Cataclysm are intertwined, it's often necessary to describe implementation.
|
||||
* Describe things that aren't obvious to newcomers just from the name.
|
||||
* Don't describe redundantly: `/** Map **/; map* map;` is not a helpful comment.
|
||||
* When documenting X, describe how X interacts with other components, not just what X itself does.
|
||||
|
||||
### Building the documentation for viewing it locally
|
||||
* Install doxygen
|
||||
* `doxygen doxygen_doc/doxygen_conf.txt `
|
||||
* `firefox doxygen_doc/html/index.html` (replace firefox with your browser of choice)
|
||||
|
||||
## Example Workflow
|
||||
|
||||
#### Setup your environment
|
||||
|
||||
*(This only needs to be done once.)*
|
||||
|
||||
1. Fork this repository here on GitHub.
|
||||
|
||||
2. Clone your fork locally.
|
||||
|
||||
$ git clone https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
|
||||
# Clones your fork of the repository into the current directory in terminal
|
||||
|
||||
3. Set commit message template.
|
||||
|
||||
$ git config --local commit.template .gitmessage
|
||||
|
||||
4. Add this repository as a remote.
|
||||
|
||||
$ cd Cataclysm-DDA
|
||||
# Changes the active directory in the prompt to the newly cloned "Cataclysm-DDA" directory
|
||||
$ git remote add -f upstream https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
# Assigns the original repository to a remote called "upstream"
|
||||
|
||||
For further details about commit message guidelines please visit:
|
||||
- [codeinthehole.com](https://codeinthehole.com/tips/a-useful-template-for-commit-messages/)
|
||||
- [chris.beams.io](https://chris.beams.io/posts/git-commit/)
|
||||
- [help.github.com](https://help.github.com/articles/closing-issues-using-keywords/)
|
||||
|
||||
#### Update your `master` branch
|
||||
|
||||
1. Make sure you have your `master` branch checked out.
|
||||
|
||||
$ git checkout master
|
||||
|
||||
2. Pull the changes from the `upstream/master` branch.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
# gets changes from "master" branch on the "upstream" remote
|
||||
|
||||
* Note: If this gives you an error, it means you have committed directly to your local `master` branch. [Click here for instructions on how to fix this issue](#why-does-git-pull---ff-only-result-in-an-error).
|
||||
|
||||
#### Make your changes
|
||||
|
||||
0. Update your `master` branch, if you haven't already.
|
||||
|
||||
1. For each new feature or bug fix, create a new branch.
|
||||
|
||||
$ git branch new_feature
|
||||
# Creates a new branch called "new_feature"
|
||||
$ git checkout new_feature
|
||||
# Makes "new_feature" the active branch
|
||||
|
||||
2. Once you've committed some changes locally, you need to push them to your fork here on GitHub.
|
||||
|
||||
$ git push origin new_feature
|
||||
# origin was automatically set to point to your fork when you cloned it
|
||||
|
||||
|
||||
3. Once you're finished working on your branch, and have committed and pushed all your changes, submit a pull request from your `new_feature` branch to this repository's `master` branch.
|
||||
|
||||
* Note: any new commits to the `new_feature` branch on GitHub will automatically be included in the pull request, so make sure to only commit related changes to the same branch.
|
||||
|
||||
## Pull Request Notes
|
||||
If you file a PR but you're still working on it, please add a [WIP] before the title text. This will tell the reviewers that you still intend to add more to the PR and we don't need to review it yet. When it's ready to be reviewed by a merger just edit the title text to remove the [WIP].
|
||||
|
||||
If you are also looking for suggestions then mark it with [CR] — "comments requested". You can use both [WIP] and [CR] to indicated that you need opinion/code review/suggestions to continue working (e.g. "[WIP] [CR] Super awesome big feature"). Feel free to remove [CR] when you feel you got enough information to proceed.
|
||||
|
||||
This can help speed up our review process by allowing us to only review the things that are ready for it, and will prevent anything that isn't completely ready from being merged in.
|
||||
|
||||
It is not required to solve or reference an open issue to file a PR, however, if you do so, you need to explain the problem your PR is solving in full detail.
|
||||
|
||||
### All PRs should have a "Summary" line
|
||||
Summary is a one-line description of your change that will be extracted and added to the project changelog at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt
|
||||
|
||||
The format is: ```SUMMARY: Category "description"```
|
||||
|
||||
The categories to choose from are: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N.
|
||||
|
||||
Example: ```SUMMARY: Content "Adds new mutation category 'Mouse'"```
|
||||
Or, if you want it treated as a minor tweak that doesn't appear in the changelog:
|
||||
```SUMMARY: None```
|
||||
|
||||
See the Changelog Guidelines at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md for explanations of the categories.
|
||||
|
||||
### Closing issues using keywords
|
||||
|
||||
One more thing: when marking your PR as closing, fixing, or resolving issues, please include "XXXX #???" somewhere in the description, where XXX is on this list:
|
||||
* close
|
||||
* closes
|
||||
* closed
|
||||
* fix
|
||||
* fixes
|
||||
* fixed
|
||||
* resolve
|
||||
* resolves
|
||||
* resolved
|
||||
|
||||
The "???" is the issue number. This automatically closes the issue when the PR is pulled in, and allows merges to work slightly faster. To close multiple issues format it as "XXXX #???, XXXX#???".
|
||||
|
||||
See https://help.github.com/articles/closing-issues-using-keywords/ for more.
|
||||
|
||||
## Tooling support
|
||||
|
||||
Various tools are available to help you keep your contributions conforming to the appropriate style. See [the relevant docs](../doc/DEVELOPER_TOOLING.md) for more details.
|
||||
|
||||
## Advanced Techniques
|
||||
|
||||
These guidelines aren't essential, but they can make keeping things in order much easier.
|
||||
|
||||
#### Using remote tracking branches
|
||||
|
||||
Remote tracking branches allow you to easily stay in touch with this repository's `master` branch, as they automatically know which remote branch to get changes from.
|
||||
|
||||
$ git branch -vv
|
||||
* master xxxx [origin/master] ....
|
||||
new_feature xxxx ....
|
||||
|
||||
Here you can see we have two branches; `master` which is tracking `origin/master`, and `new_feature` which isn't tracking any branch. In practice, what this means is that git won't know where to get changes from.
|
||||
|
||||
$ git checkout new_feature
|
||||
Switched to branch 'new_feature'
|
||||
$ git pull
|
||||
There is no tracking information for the current branch.
|
||||
Please specify which branch you want to merge with.
|
||||
|
||||
In order to easily pull changes from `upstream/master` into the `new_feature` branch, we can tell git which branch it should track. (You can even do this for your local master branch.)
|
||||
|
||||
$ git branch -u upstream/master new_feature
|
||||
Branch new_feature set up to track remote branch master from upstream.
|
||||
$ git pull
|
||||
Updating xxxx..xxxx
|
||||
....
|
||||
|
||||
You can also set the tracking information at the same time as creating the branch.
|
||||
|
||||
$ git branch new_feature_2 --track upstream/master
|
||||
Branch new_feature_2 set up to track remote branch master from upstream.
|
||||
|
||||
* Note: Although this makes it easier to pull from `upstream/master`, it doesn't change anything with regards to pushing. `git push` fails because you don't have permission to push to `upstream/master`.
|
||||
|
||||
$ git push
|
||||
error: The requested URL returned error: 403 while accessing https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
fatal: HTTP request failed
|
||||
$ git push origin
|
||||
....
|
||||
To https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
|
||||
xxxx..xxxx new_feature -> new_feature
|
||||
|
||||
## Unit tests
|
||||
|
||||
There is a suite of tests built into the source tree at tests/
|
||||
You should run the test suite after ANY change to the game source.
|
||||
An ordinary invocation of ``make`` will build the test executable at tests/cata_test, and it can be invoked like any ordinary executable, or via `make check`.
|
||||
With no arguments it will run the entire test suite.
|
||||
With ``--help`` it will print a number of invocation options you can use to adjust its operation.
|
||||
|
||||
$ make
|
||||
... compilation details ...
|
||||
$ tests/cata_test
|
||||
Starting the actual test at Fri Nov 9 04:37:03 2018
|
||||
===============================================================================
|
||||
All tests passed (1324684 assertions in 94 test cases)
|
||||
Ended test at Fri Nov 9 04:37:45 2018
|
||||
The test took 41.772 seconds
|
||||
|
||||
I recommend habitually invoking make like ``make YOUR BUILD OPTIONS && make check``.
|
||||
|
||||
## In-game testing, test environment and the debug menu
|
||||
|
||||
Whether you are implementing a new feature or whether you are fixing a bug, it is always a good practice to test your changes in-game. It can be a hard task to create the exact conditions by playing a normal game to be able to test your changes, which is why there is a debug menu. There is no default key to bring up the menu so you will need to assign one first.
|
||||
|
||||
Bring up the keybindings menu (press `Escape` then `1`), scroll down almost to the bottom and press `+` to add a new key binding. Press the letter that corresponds to the *Debug menu* item, then press the key you want to use to bring up the debug menu. To test your changes, create a new world with a new character. Once you are in that world, press the key you just assigned for the debug menu and you should see something like this:
|
||||
|
||||
```
|
||||
┌───────────────────────────────────────────────────────────────────────────┐
|
||||
│ Debug Functions - Using these will cheat not only the game, but yourself. │
|
||||
├───────────────────────────────────────────────────────────────────────────┤
|
||||
│ i Info │
|
||||
│ Q Quit to main menu │
|
||||
│ s Spawning… │
|
||||
│ p Player… │
|
||||
│ t Teleport… │
|
||||
│ m Map… │
|
||||
└───────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
With these commands, you should be able to recreate the proper conditions to test your changes. You can find some more information about the debug menu on [the official wiki](http://cddawiki.chezzo.com/cdda_wiki/index.php).
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
#### Why does `git pull --ff-only` result in an error?
|
||||
|
||||
If `git pull --ff-only` shows an error, it means that you've committed directly to your local `master` branch. To fix this, we create a new branch with these commits, find the point at which we diverged from `upstream/master`, and then reset `master` to that point.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
From https://github.com/CleverRaven/Cataclysm-DDA
|
||||
* branch master -> FETCH_HEAD
|
||||
fatal: Not possible to fast-forward, aborting.
|
||||
$ git branch new_branch master # mark the current commit with a tmp branch
|
||||
$ git merge-base master upstream/master
|
||||
cc31d0... # the last commit before we committed directly to master
|
||||
$ git reset --hard cc31d0....
|
||||
HEAD is now at cc31d0... ...
|
||||
|
||||
Now that `master` has been cleaned up, we can easily pull from `upstream/master`, and then continue working on `new_branch`.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
# gets changes from the "upstream" remote for the matching branch, in this case "master"
|
||||
$ git checkout new_branch
|
||||
|
||||
For more frequently asked questions, see the [developer FAQ](../doc/DEVELOPER_FAQ.md).
|
||||
@@ -1,13 +0,0 @@
|
||||
Game version:
|
||||
|
||||
Operating system:
|
||||
|
||||
Tiles or curses:
|
||||
|
||||
Mods active:
|
||||
|
||||
### Expected behavior
|
||||
|
||||
### Actual behavior
|
||||
|
||||
### Steps to reproduce the behavior
|
||||
@@ -1,59 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
<!-- Please follow the template below -->
|
||||
|
||||
# Describe the bug
|
||||
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
|
||||
# Steps To Reproduce
|
||||
|
||||
<!-- Steps to reproduce the behavior:
|
||||
1. Make a player with a gun, magazine, and some ammo.
|
||||
2. Try to aim at a wall.
|
||||
3. There's no way to increase aim level. -->
|
||||
|
||||
|
||||
# Expected behavior
|
||||
|
||||
<!-- A clear and concise description of what you expected to happen.
|
||||
Ideally also describe *why* you expect it to happen. -->
|
||||
|
||||
|
||||
# Screenshots
|
||||
|
||||
<!-- **If applicable**, add screenshots to help explain your problem.
|
||||
|
||||
Do not take a screenshot of the crashing window. Please provide the crash logs in the "Additional context" -->
|
||||
|
||||
# Versions and configuration
|
||||
|
||||
<!-- Please complete the following information; you can now go to:
|
||||
- "Main menu (ESC) > Debug Menu > Info > Generate game report" to generate this report.
|
||||
- Please update your OS version with a more precise version.
|
||||
|
||||
- OS: [e.g. iOS 8 or Windows 10 or Ubuntu 18.04]
|
||||
- Game Version: [from the main menu, e.g. 0.C-29938-g90f5268437]
|
||||
- Graphics version: [Tiles or Terminal]
|
||||
- Ingame language: [Arabic or Bulgarian or Chinese (Simplified) or Chinese (Traditional) or Dutch or Esperanto or French or German or Italian (Italy) or Japanese or Korean or Polish or Portuguese (Brazil) or Russian or Serbian or Spanish (Argentina) or Spanish (Spain) or Turkish]
|
||||
- Mods loaded: [e.g.dda, boats, hacktheplanet, StatsThroughSkills]
|
||||
-->
|
||||
|
||||
# Additional context
|
||||
|
||||
<!-- Add any other context about the problem here.
|
||||
|
||||
Crash: if your problem refers to a crash, please add the following files to the "Additional Context" paragraph:
|
||||
- From the /config folder (you can zip them both together):
|
||||
- crash.log file.
|
||||
- debug.log file.
|
||||
- Your save file (zipped)
|
||||
|
||||
- note #1: you can drag and drop files in this issue post!
|
||||
- note #2: it is very important for us that you provide a save file in case of a crash. It really helps the developers
|
||||
to reproduce the bug and fix it. If possible, try to provide a save file that occurs in the right conditions, just
|
||||
before the crash happens. -->
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
# Is your feature request related to a problem? Please describe.
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
# Describe the solution you'd like
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
# Describe alternatives you've considered
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
# Additional context
|
||||
Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature request here.
|
||||
@@ -1,62 +0,0 @@
|
||||
<!--
|
||||
### How to use
|
||||
Leave the headings unless they don't apply to your PR, replace commented out text (surrounded with <!–– and ––>) with text describing your PR.
|
||||
NOTE: Please grant permission for repository maintainers to edit your PR.
|
||||
It is EXTREMELY common for PRs to be held up due to trivial changes being requested and the author being unavailable to make them.
|
||||
-->
|
||||
|
||||
#### Summary
|
||||
<!--
|
||||
A one-line description of your change that will be extracted and added to the [project changelog](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt).
|
||||
|
||||
The format is (ignore the square brackets): ```SUMMARY: [Category] "[description]"```
|
||||
|
||||
The categories to choose from are:
|
||||
|
||||
* Features
|
||||
* Content
|
||||
* Interface
|
||||
* Mods
|
||||
* Balance
|
||||
* Bugfixes
|
||||
* Performance
|
||||
* Infrastructure
|
||||
* Build
|
||||
* I18N
|
||||
|
||||
Example: ```SUMMARY: Content "Adds new mutation category 'Mouse'"```
|
||||
|
||||
See the [Changelog Guidelines](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md) for explanations of the categories.
|
||||
-->
|
||||
|
||||
#### Purpose of change
|
||||
<!--
|
||||
If there's an existing issue describing the problem this PR addresses or the feature it adds, please link it like: ```#1234```
|
||||
If it *fully* resolves an issue, link it like: Fixes #1234
|
||||
Even if the issue describes the problem, please provide a few-sentence summary here.
|
||||
Example: Fixes #1234 - XL mutants cannot wear arm/leg splints due to missing OVERSIZE flag.
|
||||
If there is no related issue, please describe the issue you are addressing, including how to trigger a bug if this is a bugfix.
|
||||
Don't put the backticks around the `#` and issue or pull request number to allow the GitHub automatically reference to it.
|
||||
-->
|
||||
|
||||
#### Describe the solution
|
||||
<!--
|
||||
How does the feature work, or how does this fix a bug?
|
||||
The easier you make your solution to understand, the faster it can get merged.
|
||||
-->
|
||||
|
||||
#### Describe alternatives you've considered
|
||||
<!--
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
-->
|
||||
|
||||
#### Testing
|
||||
<!--
|
||||
Describe what steps you took to test that this PR resolved the bug or added the feature, and what tests you performed to make sure it didn't cause any regressions.
|
||||
Also include testing suggestions for reviewers and maintainers.
|
||||
-->
|
||||
|
||||
#### Additional context
|
||||
<!--
|
||||
Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature or bugfix here.
|
||||
-->
|
||||
@@ -1,74 +0,0 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 30
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 30
|
||||
|
||||
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
||||
onlyLabels: []
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- <Bug>
|
||||
- <Bugfix>
|
||||
- "<Crash / Freeze>"
|
||||
- "Organization: Bounty"
|
||||
- "(P1 - Critical)"
|
||||
- "(P2 - High)"
|
||||
- "(P3 - Medium)"
|
||||
- "(P4 - Low)"
|
||||
- "(P5 - Long-term)"
|
||||
- "(S2 - Confirmed)"
|
||||
- "0.E Feature Freeze"
|
||||
- "0.E Content Freeze"
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: true
|
||||
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: true
|
||||
|
||||
# Set to true to ignore issues with an assignee (defaults to false)
|
||||
exemptAssignees: true
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions. Please do not \'bump\' or comment on this issue
|
||||
unless you are actively working on it. Stale issues, and stale issues that
|
||||
are closed are still considered.
|
||||
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
closeComment: >
|
||||
This issue has been automatically closed due to lack of activity. This does
|
||||
not mean that we do not value the issue. Feel free to request that it be
|
||||
re-opened if you are going to actively work on it
|
||||
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 2
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
# only: issues
|
||||
|
||||
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
|
||||
# pulls:
|
||||
# daysUntilStale: 30
|
||||
# markComment: >
|
||||
# This pull request has been automatically marked as stale because it has not had
|
||||
# recent activity. It will be closed if no further activity occurs. Thank you
|
||||
# for your contributions.
|
||||
|
||||
# issues:
|
||||
# exemptLabels:
|
||||
# - confirmed
|
||||
@@ -1,32 +0,0 @@
|
||||
name: C/C++ CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 10
|
||||
- name: install dependencies
|
||||
run: sudo apt-get install libncursesw5-dev
|
||||
- name: make
|
||||
run: make
|
||||
- name: run tests
|
||||
run: make check
|
||||
- name: upload artifacts if failed
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: cata_test
|
||||
path: tests/cata_test
|
||||
@@ -1,20 +0,0 @@
|
||||
name: JSON Validation
|
||||
|
||||
on:
|
||||
pull_request
|
||||
|
||||
jobs:
|
||||
style-json:
|
||||
name: JSON style check
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 10
|
||||
- name: JSON style check
|
||||
run: make style-json
|
||||
- name: Display Corrections
|
||||
if: failure()
|
||||
run: git diff
|
||||
@@ -1,16 +0,0 @@
|
||||
name: PR Validator
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
types: [opened, edited, synchronize]
|
||||
jobs:
|
||||
validate:
|
||||
name: Validate PR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Validate SUMMARY"
|
||||
uses: CleverRaven/pr-validator@master
|
||||
with:
|
||||
description-regex: '(\n|^)\s*`{0,3}SUMMARY: +(None|((Features|Content|Interface|Mods|Balance|Bugfixes|Performance|Infrastructure|Build|I18N) +".*"))`{0,3}\s*(\n|$)'
|
||||
description-regex-flags: 'i'
|
||||
@@ -7,6 +7,7 @@
|
||||
*.o
|
||||
*.tmp
|
||||
*.zip
|
||||
*.apk
|
||||
/WinDepend/
|
||||
/bindist/
|
||||
/build/
|
||||
@@ -41,9 +42,11 @@ cataclysmdda-*
|
||||
chkjson*
|
||||
debug.log
|
||||
logg.txt
|
||||
json_formatter
|
||||
|
||||
# Visual Studio files
|
||||
*.code-workspace
|
||||
*.exp
|
||||
*.ilk
|
||||
*.opensdf
|
||||
*.pdb
|
||||
@@ -69,6 +72,10 @@ Cataclysm.exe.lastcodeanalysissucceeded
|
||||
#Visual Studio 2017
|
||||
/msvc-full-features/PredictedInputCache_Debug_x64.dat
|
||||
|
||||
#vcpkg
|
||||
/msvc-full-features/vcpkg_installed
|
||||
/msvc-object_creator/vcpkg_installed
|
||||
|
||||
# PVS Studio
|
||||
/msvc-full-features/*PVS-Studio*
|
||||
|
||||
@@ -88,6 +95,7 @@ cscope.*
|
||||
tags
|
||||
|
||||
# Generated translation source
|
||||
/lang/po/cataclysm-dda.pot
|
||||
/lang/po/en.po
|
||||
|
||||
# Compiled binary translations
|
||||
@@ -120,18 +128,21 @@ nbproject/
|
||||
|
||||
# OSX
|
||||
Cataclysm.app
|
||||
data/osx/AppIcon.icns
|
||||
build-data/osx/AppIcon.icns
|
||||
Cataclysm.dmg
|
||||
|
||||
# Jetbrains CLion
|
||||
.idea/
|
||||
|
||||
# test executables and generated data
|
||||
/tests/obj
|
||||
/tests/cata_test
|
||||
/tests/line_test
|
||||
/tests/map_iterator_test
|
||||
/tests/shadowcasting_test
|
||||
/tests/data/jsionized_overmap.sav
|
||||
/test_user_dir
|
||||
monfactions.txt
|
||||
|
||||
# temporary files generated by tools/reduce_tests.sh
|
||||
/list_of_tests
|
||||
@@ -154,6 +165,7 @@ cataclysm.a
|
||||
|
||||
# clang tooling
|
||||
compile_commands.json
|
||||
.clangd
|
||||
|
||||
# IDA database
|
||||
Cataclysm.i64
|
||||
@@ -161,9 +173,6 @@ Cataclysm.id*
|
||||
Cataclysm.til
|
||||
Cataclysm.nam
|
||||
|
||||
# Transifex Client
|
||||
.tx/
|
||||
|
||||
# Snapcraft build directories
|
||||
prime
|
||||
snap
|
||||
@@ -186,3 +195,22 @@ Xcode/
|
||||
/.flatpak-builder/
|
||||
/repo/
|
||||
/build-dir/
|
||||
|
||||
# precompiled headers
|
||||
/pch/pch.hpp.pch
|
||||
/pch/main-pch.hpp.gch
|
||||
/pch/main-pch.hpp.pch
|
||||
/tests/pch/pch.hpp.pch
|
||||
/tests/pch/tests-pch.hpp.gch
|
||||
/tests/pch/tests-pch.hpp.pch
|
||||
/tests/catch/catch.hpp.gch
|
||||
/tests/catch/catch.hpp.pch
|
||||
weather.output
|
||||
|
||||
# bundler local directories and files for jekyll site
|
||||
/.bundle/
|
||||
/_site/
|
||||
/vendor/
|
||||
.sass-cache
|
||||
.jekyll-metadata
|
||||
Gemfile.lock
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# If this commit is applied, it will ....
|
||||
# |<-- Using around 50, Maximum 72 Characters -->|
|
||||
|
||||
# Explain why this change is being made
|
||||
# |<---- Limit Each Line to a Maximum Of 72 Characters ---->|
|
||||
|
||||
# Provide links or keys to any relevant tickets, articles or other resources
|
||||
# Example: fixes #1234, closes #2345, resolves #3456, references #4567
|
||||
@@ -1,223 +0,0 @@
|
||||
# this file is HEAVILY influenced by https://github.com/boostorg/hana/blob/master/.travis.yml
|
||||
|
||||
dist: xenial
|
||||
language: c++
|
||||
|
||||
cache: ccache
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
irc: "irc.freenode.org#Cataclysm-DDA"
|
||||
use_notice: true
|
||||
skip_join: true
|
||||
|
||||
git:
|
||||
depth: 5
|
||||
|
||||
addons:
|
||||
# these apt sources will be referenced later (by using *name)
|
||||
apt:
|
||||
sources: &apt_sources
|
||||
- ubuntu-toolchain-r-test
|
||||
config:
|
||||
retries: true
|
||||
|
||||
compiler: gcc
|
||||
os: linux
|
||||
|
||||
# We have branch builds disabled globally to prevent double-builds of PRs.
|
||||
# This re-enables just the master branch.
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- development
|
||||
|
||||
# Overall strategy for what sorts of builds to include:
|
||||
# We want a build for each compiler and each platform.
|
||||
# For PRs, we lessen the "each compiler" requirement to just covering the newest
|
||||
# and oldest relevant version of each compiler.
|
||||
# We also want to ensure that each of the following tweaks are covered in at
|
||||
# least one PR build:
|
||||
# - TILES=1
|
||||
# - SOUND=1
|
||||
# - RELEASE=1
|
||||
# - CMAKE=1
|
||||
# - SANITIZE=address
|
||||
# - LOCALIZE=0
|
||||
# - A clang-tidy run
|
||||
# - Tests with important mods enabled (Magiclysm, RL_Classes)
|
||||
# We try to minimize the number of builds subject to those constraints.
|
||||
|
||||
# To see what toolchains are available, consult the following:
|
||||
# https://github.com/travis-ci/apt-source-safelist/blob/master/ubuntu.json
|
||||
# https://launchpad.net/%7Eubuntu-toolchain-r/+archive/ubuntu/test/+index
|
||||
|
||||
jobs:
|
||||
include:
|
||||
# Initial test stage, if this fails everything else is cancelled.
|
||||
- stage: Test
|
||||
# Clang is consistently the fastest to build, so use it for the initial test.
|
||||
env: CLANG=clang++-3.8 MODS=--mods=RL_Classes TEST_STAGE=1 CXXFLAGS="-Wno-error=unused-command-line-argument -D__extern_always_inline='extern __always_inline'"
|
||||
name: "Clang 3.8 Make build with curses, style check and RL_Classes test"
|
||||
compiler: clang
|
||||
addons: &clang38
|
||||
apt:
|
||||
packages: ["clang-3.8", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: [*apt_sources]
|
||||
|
||||
# Then build different configurations and targets in parallel.
|
||||
- stage: "Main Compilers"
|
||||
env: COMPILER=g++ MODS=--mods=magiclysm LOCALIZE=0
|
||||
name: "GCC 5.3 Make build with curses, Magiclysm, and no Localization"
|
||||
compiler: gcc
|
||||
addons: &gcc53
|
||||
apt:
|
||||
packages: ["g++-5=5.3.1-14ubuntu2", "libstdc++-5-dev=5.3.1-14ubuntu2", "gcc-5=5.3.1-14ubuntu2", "gcc-5-base=5.3.1-14ubuntu2", "cpp-5=5.3.1-14ubuntu2", "libgcc-5-dev=5.3.1-14ubuntu2", "libasan2=5.3.1-14ubuntu2", "libmpx0=5.3.1-14ubuntu2"]
|
||||
sources: [*apt_sources]
|
||||
|
||||
- env: COMPILER=g++-8 CXXFLAGS="-Wno-implicit-fallthrough" TILES=1 SOUND=1 SANITIZE=address EXTRA_TEST_OPTS="~[.] ~vehicle_efficiency"
|
||||
name: "GCC 8 Make build with Tiles, Sound, astyle and address sanitization"
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
addons: &gcc8
|
||||
apt:
|
||||
packages: ["g++-8", "g++-8-multilib", "libc6-dbg", "libc6-dbg:i386", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev", "astyle"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: CLANG=clang++-8 SANITIZE=address,undefined EXTRA_TEST_OPTS="~[.] ~vehicle_efficiency ~vehicle_drag ~starting_items ~[starve] ~grenade_lethality"
|
||||
name: "Clang 8 Make build with sanitizers enabled, but long-running tests disabled"
|
||||
compiler: clang
|
||||
addons: &clang8
|
||||
apt:
|
||||
packages: ["clang-8", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-8]
|
||||
|
||||
- stage: "Platforms and Tidy"
|
||||
# MXE variant using alternate repository http://mirror.mxe.cc/repos/apt
|
||||
env: COMPILER=g++ LDFLAGS="-static-libgcc -static-libstdc++" MXE_TARGET="i686-w64-mingw32.static" WINE="wine" TILES=1 SOUND=1
|
||||
name: "Mingw-w64 Make cross-compile to Windows with Tiles and Sound"
|
||||
compiler: gcc
|
||||
addons: &gcc
|
||||
apt:
|
||||
packages: ["wine"]
|
||||
|
||||
- env: NATIVE=android COMPILER=gcc
|
||||
name: "Android build"
|
||||
language: android
|
||||
android:
|
||||
components:
|
||||
- build-tools-28.0.1
|
||||
- android-28
|
||||
cache:
|
||||
# The ccache feature in Travis doesn't work for language: android, so
|
||||
# do it ourselves.
|
||||
directories:
|
||||
- $HOME/.ccache
|
||||
|
||||
- env: CLANG=clang++ NATIVE=osx OSX_MIN=10.13 TILES=1 SOUND=1
|
||||
name: "Xcode 10.1 Make build with Tiles and sound (macOS)"
|
||||
os: osx
|
||||
osx_image: xcode10.1
|
||||
compiler: clang
|
||||
|
||||
- env: CLANG=clang++-8 TILES=1 SOUND=1 CXXFLAGS=-Wno-unused-command-line-argument CMAKE=1 CATA_CLANG_TIDY=plugin
|
||||
name: "Clang-tidy CMake build with Tiles and Sound"
|
||||
compiler: clang
|
||||
addons: &clang8
|
||||
apt:
|
||||
packages: ["clang-8", "libclang-8-dev", "llvm-8-dev", "llvm-8-tools", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev", "libpulse-dev", "libpulse0=1:8.0-0ubuntu3.10", "libpulse-mainloop-glib0=1:8.0-0ubuntu3.10"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-8]
|
||||
|
||||
# Finally check the compiler variants
|
||||
- stage: compilers
|
||||
# GCC 5.4 is default on Xenial
|
||||
env: COMPILER=g++
|
||||
name: "GCC 5.4 Make build with Curses"
|
||||
if: type != pull_request
|
||||
|
||||
- env: COMPILER=g++-6 CODE_COVERAGE=true
|
||||
name: "GCC 6 Make build with Curses and Code Coverage"
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
addons: &gcc6
|
||||
apt:
|
||||
packages: ["g++-6", "g++-6-multilib", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: COMPILER=g++-7 CXXFLAGS='-Wno-implicit-fallthrough -D_GLIBCXX_DEBUG'
|
||||
name: "GCC 7 Make build with Curses and GLIBCXX_DEBUG"
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
addons: &gcc7
|
||||
apt:
|
||||
packages: ["g++-7", "g++-7-multilib", "libc6-dbg", "libc6-dbg:i386", "lcov"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: COMPILER='g++' LDFLAGS='-static-libgcc -static-libstdc++' MXE_TARGET='i686-w64-mingw32.static' WINE='wine'
|
||||
name: "Mingw-w64 Make build with Curses"
|
||||
if: type != pull_request
|
||||
addons: &gcc
|
||||
apt:
|
||||
packages: ["wine"]
|
||||
|
||||
- env: CLANG=clang++-3.9 CXXFLAGS='-Wno-error=unused-command-line-argument -D__extern_always_inline="extern __always_inline"'
|
||||
name: "Clang 3.9 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang39
|
||||
apt:
|
||||
packages: ["clang-3.9", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: CLANG=clang++-4.0 CXXFLAGS=-Wno-error=unused-command-line-argument
|
||||
name: "Clang 4 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang40
|
||||
apt:
|
||||
packages: ["clang-4.0", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
# Luckily the Trusty install Just Works on Xenial
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-4.0]
|
||||
|
||||
# Clang 5.0 (still on Trusty, because I could find no readily available
|
||||
# source on Xenial at time of writing)
|
||||
- env: CLANG=clang++-5.0 CXXFLAGS=-Wno-error=unused-command-line-argument
|
||||
name: "Clang 5 Make build with Curses"
|
||||
if: type != pull_request
|
||||
dist: trusty
|
||||
compiler: clang
|
||||
addons: &clang50
|
||||
apt:
|
||||
packages: ["clang-5.0", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-5.0]
|
||||
|
||||
- env: CLANG=clang++-6.0 TILES=1 SOUND=1 CXXFLAGS=-Wno-error=unused-command-line-argument CMAKE=1 RELEASE=1
|
||||
name: "Clang 6 CMake build with tiles and sound"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang60
|
||||
apt:
|
||||
packages: ["clang-6.0", "g++-multilib", "libc6-dbg", "g++-6", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev", "libpulse-dev", "libpulse0=1:8.0-0ubuntu3.10", "libpulse-mainloop-glib0=1:8.0-0ubuntu3.10"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-6.0]
|
||||
|
||||
- env: CLANG=clang++-7
|
||||
name: "Clang 7 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang7
|
||||
apt:
|
||||
packages: ["clang-7", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-7]
|
||||
|
||||
before_script:
|
||||
- if [ -n "${CLANG}" ]; then COMPILER="$CLANG"; fi
|
||||
- ${COMPILER} --version
|
||||
- CXX="$COMPILER"
|
||||
- source build-scripts/requirements.sh
|
||||
|
||||
script:
|
||||
- build-scripts/build.sh
|
||||
|
||||
after_success:
|
||||
- if [ -n "${CODE_COVERAGE}" ]; then coveralls -b . -i src -e tests --gcov /usr/bin/gcov-6; fi
|
||||
- if [ -n "${CODE_COVERAGE}" ]; then bash <(curl -s https://codecov.io/bash); fi
|
||||
@@ -0,0 +1 @@
|
||||
1e7d902c-02b7-4619-bf01-fe4b9c0ba8ca
|
||||
@@ -1,396 +0,0 @@
|
||||
# Main project build script
|
||||
cmake_minimum_required(VERSION 3.1.4)
|
||||
|
||||
PROJECT(CataclysmDDA)
|
||||
|
||||
SET(CMAKE_MODULE_PATH
|
||||
${CMAKE_MODULE_PATH}
|
||||
${CMAKE_SOURCE_DIR}/CMakeModules
|
||||
)
|
||||
|
||||
SET(CMAKE_TLS_VERIFY ON)
|
||||
|
||||
# Build options
|
||||
option(TILES "Build graphical tileset version." "OFF")
|
||||
option(CURSES "Build curses version." "ON")
|
||||
option(SOUND "Support for in-game sounds & music." "OFF")
|
||||
option(BACKTRACE "Support for printing stack backtraces on crash" "ON")
|
||||
option(LIBBACKTRACE "Print backtrace with libbacktrace." "OFF")
|
||||
option(USE_HOME_DIR "Use user's home directory for save files." "ON")
|
||||
option(LOCALIZE "Support for language localizations. Also enable UTF support." "ON")
|
||||
option(LANGUAGES "Compile localization files for specified languages." "")
|
||||
option(DYNAMIC_LINKING "Use dynamic linking. Or use static to remove MinGW dependency instead." "ON")
|
||||
option(JSON_FORMAT "Build JSON formatter" "OFF")
|
||||
option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF")
|
||||
set(CATA_CLANG_TIDY_INCLUDE_DIR "" CACHE STRING "Path to internal clang-tidy headers required for plugin (e.g. ClangTidy.h)")
|
||||
set(CATA_CHECK_CLANG_TIDY "" CACHE STRING "Path to check_clang_tidy.py for plugin tests")
|
||||
set(GIT_BINARY "" CACHE STRING "Git binary name or path.")
|
||||
set(PREFIX "" CACHE STRING "Location of Data & GFX directories")
|
||||
|
||||
include(CTest)
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
git_describe(GIT_VERSION)
|
||||
|
||||
MESSAGE("\n * Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world.")
|
||||
MESSAGE(" _________ __ .__ ")
|
||||
MESSAGE(" \\_ ___ \\ _____ _/ |_ _____ ____ | | ___.__ ______ _____ ")
|
||||
MESSAGE(" / \\ \\/ \\__ \\ \\ __\\\\__ \\ _/ ___\\ | | < | | / ___/ / \\ ")
|
||||
MESSAGE(" \\ \\____ / __ \\_ | | / __ \\_\\ \\___ | |__ \\___ | \\___ \\ | Y Y \\ ")
|
||||
MESSAGE(" \\______ /\(____ / |__| \(____ / \\___ >|____/ / ____|/____ >|__|_| / ")
|
||||
MESSAGE(" \\/ \\/ \\/ \\/ \\/ \\/ \\/ ")
|
||||
MESSAGE(" --= Dark Days Ahead =--")
|
||||
MESSAGE("\n * https://cataclysmdda.org/\n")
|
||||
|
||||
MESSAGE(STATUS "${PROJECT} build environment -- \n")
|
||||
|
||||
MESSAGE(STATUS "Build realm is : ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
if (NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
|
||||
string(REPLACE "-NOTFOUND" "" GIT_VERSION ${GIT_VERSION})
|
||||
FILE(WRITE ${CMAKE_SOURCE_DIR}/src/version.h "\#define VERSION \"${GIT_VERSION}\"\n")
|
||||
MESSAGE(STATUS "${PROJECT_NAME} build version is : ${GIT_VERSION}\n")
|
||||
ADD_DEFINITIONS(-DGIT_VERSION)
|
||||
ELSE (NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
|
||||
MESSAGE("")
|
||||
ENDIF(NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
|
||||
|
||||
#OS Check Placeholders. Will be used for BINDIST
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
SET(_OS_LINUX_ 1)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
SET(_OS_FREEBSD_ 1)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||
SET(_OS_DARWIN_ 1)
|
||||
SET(LOCALIZE OFF)
|
||||
MESSAGE(STATUS "Disable internationalization on Darwin as it is not supported")
|
||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
#FIXME: Add dest build choice: m32 for 32 bit or m64 for 64 bit version
|
||||
#add_definitions("-m32")
|
||||
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
#SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m32")
|
||||
#SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32")
|
||||
|
||||
IF (NOT DYNAMIC_LINKING)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a")
|
||||
SET(BUILD_SHARED_LIBRARIES OFF)
|
||||
check_cxx_compiler_flag (-static HAVE_STATIC_FLAG)
|
||||
IF(HAVE_STATIC_FLAG)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
||||
ENDIF(HAVE_STATIC_FLAG)
|
||||
# Workaround for cmake link library guesser
|
||||
SET(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
|
||||
SET(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
|
||||
SET(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
|
||||
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
|
||||
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
|
||||
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
|
||||
ELSE (NOT DYNAMIC_LINKING)
|
||||
IF(MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# Avoid depending on MinGW runtime DLLs
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
||||
ENDIF(MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
ENDIF (NOT DYNAMIC_LINKING)
|
||||
|
||||
# System specific actions
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
IF(NOT DATA_PREFIX)
|
||||
SET( DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-dda)
|
||||
ENDIF(NOT DATA_PREFIX)
|
||||
IF(NOT LOCALE_DIR)
|
||||
SET( LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale)
|
||||
ENDIF(NOT LOCALE_DIR)
|
||||
IF(NOT BIN_PREFIX)
|
||||
SET( BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
ENDIF(NOT BIN_PREFIX)
|
||||
IF(NOT DESKTOP_ENTRY_PATH)
|
||||
SET( DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||
ENDIF(NOT DESKTOP_ENTRY_PATH)
|
||||
IF(NOT PIXMAPS_ENTRY_PATH)
|
||||
SET( PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
|
||||
ENDIF(NOT PIXMAPS_ENTRY_PATH)
|
||||
IF(NOT PIXMAPS_UNITY_ENTRY_PATH)
|
||||
SET( PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark)
|
||||
ENDIF(NOT PIXMAPS_UNITY_ENTRY_PATH)
|
||||
IF(NOT MANPAGE_ENTRY_PATH)
|
||||
SET( MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man)
|
||||
ENDIF(NOT MANPAGE_ENTRY_PATH)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
IF(NOT DATA_PREFIX)
|
||||
SET(DATA_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF(NOT DATA_PREFIX)
|
||||
IF(NOT LOCALE_DIR)
|
||||
SET(LOCALE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF(NOT LOCALE_DIR)
|
||||
IF(NOT BIN_PREFIX)
|
||||
SET(BIN_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF(NOT BIN_PREFIX)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
|
||||
|
||||
MESSAGE(STATUS "${PROJECT_NAME} build options --\n")
|
||||
|
||||
# Preset variables
|
||||
IF(NOT LANGUAGES)
|
||||
# English is included to workaround a libintl bug that affects performance
|
||||
# on MinGW targets. See lang/CMakeList.txt for more information.
|
||||
SET (LANGUAGES en de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW)
|
||||
ENDIF(NOT LANGUAGES)
|
||||
|
||||
IF (GIT_BINARY)
|
||||
SET(GIT_EXECUTABLE ${GIT_BINARY})
|
||||
ELSE (GIT_BINARY)
|
||||
FIND_PACKAGE(Git)
|
||||
IF (NOT GIT_FOUND)
|
||||
MESSAGE(WARNING "Git binary not found. Build version will be set to NULL. Install Git package or use -DGIT_BINARY to set path to git binary.")
|
||||
ENDIF (NOT GIT_FOUND)
|
||||
ENDIF (GIT_BINARY)
|
||||
|
||||
IF (PREFIX)
|
||||
ADD_DEFINITIONS(-DPREFIX=${PREFIX})
|
||||
ENDIF (PREFIX)
|
||||
|
||||
# Can't compile curses and tiles build's at same time
|
||||
IF(TILES)
|
||||
SET(CURSES OFF)
|
||||
ENDIF(TILES)
|
||||
|
||||
# Set build types and display info
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE("\n")
|
||||
MESSAGE(STATUS "Build ${PROJECT} in development mode --\n")
|
||||
MESSAGE(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
|
||||
SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
# Since CataclysmDDA does not respect PREFIX for development builds
|
||||
# and has funny path handlers, we should create resulting Binaries
|
||||
# in the source directory
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}
|
||||
CACHE PATH "Single Directory for all Executables."
|
||||
)
|
||||
SET(BIN_PREFIX ${CMAKE_SOURCE_DIR})
|
||||
ELSE (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
|
||||
MESSAGE(STATUS "BIN_PREFIX : ${BIN_PREFIX}")
|
||||
MESSAGE(STATUS "DATA_PREFIX : ${DATA_PREFIX}")
|
||||
IF(LOCALIZE)
|
||||
MESSAGE(STATUS "LOCALE_PATH : ${LOCALE_DIR}")
|
||||
ENDIF(LOCALIZE)
|
||||
MESSAGE(STATUS "DESKTOP_ENTRY_PATH : ${DESKTOP_ENTRY_PATH}")
|
||||
MESSAGE(STATUS "PIXMAPS_ENTRY_PATH : ${PIXMAPS_ENTRY_PATH}")
|
||||
MESSAGE(STATUS "PIXMAPS_UNITY_ENTRY_PATH : ${PIXMAPS_UNITY_ENTRY_PATH}")
|
||||
MESSAGE(STATUS "MANPAGE_ENTRY_PATH : ${MANPAGE_ENTRY_PATH}\n")
|
||||
ADD_DEFINITIONS(-DRELEASE)
|
||||
# Use PREFIX as storage of data,gfx, etc.. Useful only on *nix OS.
|
||||
IF (PREFIX AND NOT WIN32)
|
||||
ADD_DEFINITIONS(-DDATA_DIR_PREFIX)
|
||||
ENDIF (PREFIX AND NOT WIN32)
|
||||
ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
MESSAGE(STATUS "GIT_BINARY : ${GIT_EXECUTABLE}")
|
||||
MESSAGE(STATUS "DYNAMIC_LINKING : ${DYNAMIC_LINKING}")
|
||||
MESSAGE(STATUS "TILES : ${TILES}")
|
||||
MESSAGE(STATUS "CURSES : ${CURSES}")
|
||||
MESSAGE(STATUS "SOUND : ${SOUND}")
|
||||
MESSAGE(STATUS "BACKTRACE : ${BACKTRACE}")
|
||||
MESSAGE(STATUS "LOCALIZE : ${LOCALIZE}")
|
||||
MESSAGE(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}\n")
|
||||
|
||||
MESSAGE(STATUS "LANGUAGES : ${LANGUAGES}\n")
|
||||
|
||||
MESSAGE(STATUS "See INSTALL file for details and more info --\n")
|
||||
|
||||
IF(MSVC)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-D_AMD64_)
|
||||
else()
|
||||
add_definitions(-D_X86_)
|
||||
endif()
|
||||
ELSE()
|
||||
SET(CATA_WARNINGS
|
||||
"-Werror -Wall -Wextra \
|
||||
-Wformat-signedness \
|
||||
-Wlogical-op \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-noreturn \
|
||||
-Wnon-virtual-dtor \
|
||||
-Wold-style-cast \
|
||||
-Woverloaded-virtual \
|
||||
-Wpedantic \
|
||||
-Wsuggest-override \
|
||||
-Wunused-macros \
|
||||
-Wzero-as-null-pointer-constant \
|
||||
-Wno-unknown-warning-option")
|
||||
IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
SET(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls")
|
||||
ENDIF()
|
||||
# Compact the whitespace in the warning string
|
||||
string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# Force out-of-source build
|
||||
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This project requires an out of source build. Remove the file 'CMakeCache.txt' found in this directory before continuing, create a separate build
|
||||
directory and run 'cmake [options] <srcs>' from there.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
|
||||
#SET(THREADS_USE_PTHREADS_WIN32 True)
|
||||
SET(CMAKE_THREAD_PREFER_PTHREAD True)
|
||||
FIND_PACKAGE(Threads REQUIRED)
|
||||
|
||||
# Check for build types and libraries
|
||||
IF(TILES)
|
||||
# Find SDL, SDL_ttf & SDL_image for graphical install
|
||||
MESSAGE(STATUS "Searching for SDL2 library --")
|
||||
FIND_PACKAGE(SDL2)
|
||||
IF(NOT SDL2_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This project requires SDL2 to be installed to be compiled in graphical mode. Please install the SDL2 development libraries, or try compiling
|
||||
without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_FOUND)
|
||||
|
||||
IF (NOT DYNAMIC_LINKING)
|
||||
# SDL, SDL_Image, SDL_ttf deps are required for static build
|
||||
MESSAGE(STATUS "Searching for SDL deps libraries --")
|
||||
FIND_PACKAGE(Freetype REQUIRED)
|
||||
FIND_PACKAGE(PNG REQUIRED)
|
||||
FIND_PACKAGE(JPEG REQUIRED)
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
FIND_PACKAGE(BZip2 REQUIRED)
|
||||
ENDIF (NOT DYNAMIC_LINKING)
|
||||
|
||||
MESSAGE(STATUS "Searching for SDL2_TTF library --")
|
||||
FIND_PACKAGE(SDL2_ttf)
|
||||
IF(NOT SDL2_TTF_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This project requires SDL2_ttf to be installed to be compiled in graphical mode. Please install the SDL2_ttf development libraries, or try
|
||||
compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and moreinfo\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_TTF_FOUND)
|
||||
|
||||
MESSAGE(STATUS "Searching for SDL2_image library --\n")
|
||||
FIND_PACKAGE(SDL2_image)
|
||||
IF(NOT SDL2_IMAGE_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This project requires SDL2_image to be installed to be compiled in graphical mode. Please install the SDL2_image development libraries, or try
|
||||
compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_IMAGE_FOUND)
|
||||
ADD_DEFINITIONS(-DTILES)
|
||||
ENDIF(TILES)
|
||||
|
||||
IF(CURSES)
|
||||
# Find the ncurses library for a text based compile
|
||||
MESSAGE(STATUS "Searching for Curses library --\n")
|
||||
SET(CURSES_NEED_NCURSES TRUE)
|
||||
SET(CURSES_NEED_WIDE TRUE)
|
||||
FIND_PACKAGE(Curses)
|
||||
IF(NOT CURSES_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This project requires ncurses to be installed to be compiled in text only mode. Please install the ncurses development libraries, or try compiling
|
||||
with the -DTILES=1 for a graphical compilation.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT CURSES_FOUND)
|
||||
ENDIF(CURSES)
|
||||
|
||||
IF(SOUND)
|
||||
# You need TILES to be able to use SOUND
|
||||
IF(NOT TILES)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"You must enable graphical support with -DTILES=1 to be able to enable sound support.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT TILES)
|
||||
|
||||
# Sound requires SDL_mixer library
|
||||
MESSAGE(STATUS "Searching for SDL2_mixer library --\n")
|
||||
FIND_PACKAGE(SDL2_mixer)
|
||||
IF(NOT SDL2_MIXER_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"You need the SDL2_mixer development library to be able to compile with sound enabled.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_MIXER_FOUND)
|
||||
ENDIF(SOUND)
|
||||
|
||||
IF(BACKTRACE)
|
||||
ADD_DEFINITIONS(-DBACKTRACE)
|
||||
IF(LIBBACKTRACE)
|
||||
ADD_DEFINITIONS(-DLIBBACKTRACE)
|
||||
ENDIF(LIBBACKTRACE)
|
||||
ENDIF(BACKTRACE)
|
||||
|
||||
# Ok. Now create build and install recipes
|
||||
IF(LOCALIZE)
|
||||
IF(WIN32)
|
||||
FIND_PACKAGE(Libintl)
|
||||
IF(NOT LIBINTL_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"You need the libintl development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT LIBINTL_FOUND)
|
||||
FIND_PACKAGE(Iconv)
|
||||
IF(NOT ICONV_FOUND)
|
||||
MESSAGE(FATAL_ERROr
|
||||
"You need the iconv development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT ICONV_FOUND)
|
||||
ENDIF(WIN32)
|
||||
add_subdirectory(lang)
|
||||
ADD_DEFINITIONS(-DLOCALIZE)
|
||||
ENDIF(LOCALIZE)
|
||||
|
||||
IF(USE_HOME_DIR)
|
||||
ADD_DEFINITIONS(-DUSE_HOME_DIR)
|
||||
ENDIF(USE_HOME_DIR)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(data)
|
||||
if (NOT MSVC)
|
||||
add_subdirectory(src/chkjson)
|
||||
endif()
|
||||
add_subdirectory(tests)
|
||||
if (JSON_FORMAT)
|
||||
add_subdirectory(tools/format)
|
||||
endif()
|
||||
if (CATA_CLANG_TIDY_PLUGIN)
|
||||
add_subdirectory(tools/clang-tidy-plugin)
|
||||
endif()
|
||||
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(uninstall
|
||||
"${CMAKE_COMMAND}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
)
|
||||
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND)
|
||||
|
||||
# vim:noet
|
||||
@@ -1,160 +0,0 @@
|
||||
#.rst:
|
||||
# CMakeParseArguments
|
||||
# -------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords>
|
||||
# <multi_value_keywords> args...)
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions
|
||||
# for parsing the arguments given to that macro or function. It
|
||||
# processes the arguments and defines a set of variables which hold the
|
||||
# values of the respective options.
|
||||
#
|
||||
# The <options> argument contains all options for the respective macro,
|
||||
# i.e. keywords which can be used when calling the macro without any
|
||||
# value following, like e.g. the OPTIONAL keyword of the install()
|
||||
# command.
|
||||
#
|
||||
# The <one_value_keywords> argument contains all keywords for this macro
|
||||
# which are followed by one value, like e.g. DESTINATION keyword of the
|
||||
# install() command.
|
||||
#
|
||||
# The <multi_value_keywords> argument contains all keywords for this
|
||||
# macro which can be followed by more than one value, like e.g. the
|
||||
# TARGETS or FILES keywords of the install() command.
|
||||
#
|
||||
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
|
||||
# keywords listed in <options>, <one_value_keywords> and
|
||||
# <multi_value_keywords> a variable composed of the given <prefix>
|
||||
# followed by "_" and the name of the respective keyword. These
|
||||
# variables will then hold the respective value from the argument list.
|
||||
# For the <options> keywords this will be TRUE or FALSE.
|
||||
#
|
||||
# All remaining arguments are collected in a variable
|
||||
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see
|
||||
# whether your macro was called with unrecognized parameters.
|
||||
#
|
||||
# As an example here a my_install() macro, which takes similar arguments
|
||||
# as the real install() command:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# function(MY_INSTALL)
|
||||
# set(options OPTIONAL FAST)
|
||||
# set(oneValueArgs DESTINATION RENAME)
|
||||
# set(multiValueArgs TARGETS CONFIGURATIONS)
|
||||
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
# ...
|
||||
#
|
||||
#
|
||||
#
|
||||
# Assume my_install() has been called like this:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
|
||||
#
|
||||
#
|
||||
#
|
||||
# After the cmake_parse_arguments() call the macro will have set the
|
||||
# following variables:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# MY_INSTALL_OPTIONAL = TRUE
|
||||
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
|
||||
# MY_INSTALL_DESTINATION = "bin"
|
||||
# MY_INSTALL_RENAME = "" (was not used)
|
||||
# MY_INSTALL_TARGETS = "foo;bar"
|
||||
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
|
||||
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
|
||||
#
|
||||
#
|
||||
#
|
||||
# You can then continue and process these variables.
|
||||
#
|
||||
# Keywords terminate lists of values, e.g. if directly after a
|
||||
# one_value_keyword another recognized keyword follows, this is
|
||||
# interpreted as the beginning of the new option. E.g.
|
||||
# my_install(TARGETS foo DESTINATION OPTIONAL) would result in
|
||||
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION
|
||||
# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
|
||||
|
||||
|
||||
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
|
||||
# first set all result variables to empty/FALSE
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach()
|
||||
|
||||
foreach(option ${_optionNames})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach()
|
||||
|
||||
set(${prefix}_UNPARSED_ARGUMENTS)
|
||||
|
||||
set(insideValues FALSE)
|
||||
set(currentArgName)
|
||||
|
||||
# now iterate over all arguments and fill the result variables
|
||||
foreach(currentArg ${ARGN})
|
||||
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
|
||||
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
|
||||
if(insideValues)
|
||||
if("${insideValues}" STREQUAL "SINGLE")
|
||||
set(${prefix}_${currentArgName} ${currentArg})
|
||||
set(insideValues FALSE)
|
||||
elseif("${insideValues}" STREQUAL "MULTI")
|
||||
list(APPEND ${prefix}_${currentArgName} ${currentArg})
|
||||
endif()
|
||||
else()
|
||||
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
|
||||
endif()
|
||||
else()
|
||||
if(NOT ${optionIndex} EQUAL -1)
|
||||
set(${prefix}_${currentArg} TRUE)
|
||||
set(insideValues FALSE)
|
||||
elseif(NOT ${singleArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "SINGLE")
|
||||
elseif(NOT ${multiArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "MULTI")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
# propagate the result variables to the caller:
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
|
||||
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
|
||||
endforeach()
|
||||
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
@@ -1,78 +0,0 @@
|
||||
#.rst:
|
||||
# CheckLibraryExists
|
||||
# ------------------
|
||||
#
|
||||
# Check if the function exists.
|
||||
#
|
||||
# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# LIBRARY - the name of the library you are looking for
|
||||
# FUNCTION - the name of the function
|
||||
# LOCATION - location where the library should be found
|
||||
# VARIABLE - variable to store the result
|
||||
#
|
||||
#
|
||||
#
|
||||
# The following variables may be set before calling this macro to modify
|
||||
# the way the check is run:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2002-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
|
||||
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
||||
if(${VARIABLE} MATCHES "^${VARIABLE}$")
|
||||
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
||||
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
|
||||
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
|
||||
if(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_LIBRARY_EXISTS_LIBRARIES
|
||||
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
endif()
|
||||
try_compile(${VARIABLE}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
|
||||
CMAKE_FLAGS
|
||||
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
|
||||
-DLINK_DIRECTORIES:STRING=${LOCATION}
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
if(${VARIABLE})
|
||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
|
||||
set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
|
||||
"passed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
else()
|
||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
|
||||
set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
|
||||
"failed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -1,198 +0,0 @@
|
||||
#.rst:
|
||||
# FindCurses
|
||||
# ----------
|
||||
#
|
||||
# Find the curses include file and library
|
||||
#
|
||||
#
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# CURSES_FOUND - system has Curses
|
||||
# CURSES_INCLUDE_DIR - the Curses include directory
|
||||
# CURSES_LIBRARIES - The libraries needed to use Curses
|
||||
# CURSES_HAVE_CURSES_H - true if curses.h is available
|
||||
# CURSES_HAVE_NCURSES_H - true if ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available
|
||||
# CURSES_LIBRARY - set for backwards compatibility with 2.4 CMake
|
||||
#
|
||||
#
|
||||
#
|
||||
# Set CURSES_NEED_NCURSES to TRUE before the find_package() command if
|
||||
# NCurses functionality is required.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
||||
|
||||
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
|
||||
set(CURSES_USE_NCURSES FALSE)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
|
||||
# cygwin ncurses stopped providing curses.h symlinks see above
|
||||
# message. Cygwin is an ncurses package, so force ncurses on
|
||||
# cygwin if the curses.h is missing
|
||||
if(CYGWIN)
|
||||
if(NOT EXISTS /usr/include/curses.h)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Not sure the logic is correct here.
|
||||
# If NCurses is required, use the function wsyncup() to check if the library
|
||||
# has NCurses functionality (at least this is where it breaks on NetBSD).
|
||||
# If wsyncup is in curses, use this one.
|
||||
# If not, try to find ncurses and check if this has the symbol.
|
||||
# Once the ncurses library is found, search the ncurses.h header first, but
|
||||
# some web pages also say that even with ncurses there is not always a ncurses.h:
|
||||
# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html
|
||||
# So at first try ncurses.h, if not found, try to find curses.h under the same
|
||||
# prefix as the library was found, if still not found, try curses.h with the
|
||||
# default search paths.
|
||||
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_NCURSES_HAS_WSYNCUP)
|
||||
if( CURSES_NCURSES_HAS_WSYNCUP)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CURSES_USE_NCURSES)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h )
|
||||
find_path(CURSES_CURSES_H_PATH curses.h )
|
||||
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache wqith these variables set
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}"
|
||||
CACHE FILEPATH "The curses include path")
|
||||
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library")
|
||||
else()
|
||||
# we need to find ncurses
|
||||
get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
find_file(CURSES_HAVE_NCURSES_H ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h
|
||||
ncurses/curses.h)
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload
|
||||
# however if the value of the variable has NOTFOUND in it, then
|
||||
# it is OK to force, and we need to force in order to have it work.
|
||||
# a cache wqith these variables set
|
||||
# only put ncurses include and library into
|
||||
# variables if they are found
|
||||
if(NOT CURSES_NCURSES_INCLUDE_PATH AND CURSES_HAVE_NCURSES_NCURSES_H)
|
||||
get_filename_component(CURSES_NCURSES_INCLUDE_PATH
|
||||
"${CURSES_HAVE_NCURSES_NCURSES_H}" PATH)
|
||||
endif()
|
||||
if(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY)
|
||||
set( FORCE_IT )
|
||||
if(CURSES_INCLUDE_PATH MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}"
|
||||
CACHE FILEPATH "The curses include path" ${FORCE_IT})
|
||||
set( FORCE_IT)
|
||||
if(CURSES_LIBRARY MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library" ${FORCE_IT})
|
||||
endif()
|
||||
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
||||
cbreak "" CURSES_NCURSES_HAS_CBREAK)
|
||||
if(NOT CURSES_NCURSES_HAS_CBREAK)
|
||||
find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_EXTRA_LIBRARY tinfo )
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_EXTRA_LIBRARY}"
|
||||
cbreak "" CURSES_TINFO_HAS_CBREAK)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT CURSES_TINFO_HAS_CBREAK)
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr )
|
||||
endif()
|
||||
|
||||
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_FORM_LIBRARY form )
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache
|
||||
# qith these variables set
|
||||
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}"
|
||||
CACHE FILEPATH "The curses form library")
|
||||
|
||||
# Need to provide the *_LIBRARIES
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
||||
|
||||
if(CURSES_EXTRA_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(CURSES_FORM_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Proper name is *_INCLUDE_DIR
|
||||
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH})
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
|
||||
CURSES_LIBRARY CURSES_INCLUDE_PATH)
|
||||
|
||||
mark_as_advanced(
|
||||
CURSES_INCLUDE_PATH
|
||||
CURSES_LIBRARY
|
||||
CURSES_CURSES_INCLUDE_PATH
|
||||
CURSES_CURSES_LIBRARY
|
||||
CURSES_NCURSES_INCLUDE_PATH
|
||||
CURSES_NCURSES_LIBRARY
|
||||
CURSES_EXTRA_LIBRARY
|
||||
FORM_LIBRARY
|
||||
CURSES_LIBRARIES
|
||||
CURSES_INCLUDE_DIR
|
||||
CURSES_CURSES_HAS_WSYNCUP
|
||||
CURSES_NCURSES_HAS_WSYNCUP
|
||||
CURSES_NCURSES_HAS_CBREAK
|
||||
CURSES_TINFO_HAS_CBREAK
|
||||
)
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# - Try to find Iconv
|
||||
# Once done this will define
|
||||
#
|
||||
# ICONV_FOUND - system has Iconv
|
||||
# ICONV_INCLUDE_DIR - the Iconv include directory
|
||||
# ICONV_LIBRARIES - Link these to use Iconv
|
||||
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
|
||||
#
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(ICONV_FIND_QUIETLY TRUE)
|
||||
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
|
||||
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
|
||||
|
||||
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
|
||||
|
||||
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
SET(ICONV_FOUND TRUE)
|
||||
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
||||
IF(ICONV_FOUND)
|
||||
check_cxx_source_compiles("
|
||||
#include <iconv.h>
|
||||
int main(){
|
||||
iconv_t conv = 0;
|
||||
const char* in = 0;
|
||||
size_t ilen = 0;
|
||||
char* out = 0;
|
||||
size_t olen = 0;
|
||||
iconv(conv, &in, &ilen, &out, &olen);
|
||||
return 0;
|
||||
}
|
||||
" ICONV_SECOND_ARGUMENT_IS_CONST )
|
||||
ENDIF(ICONV_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Iconv DEFAULT_MSG
|
||||
ICONV_LIBRARIES ICONV_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
ICONV_INCLUDE_DIR
|
||||
ICONV_LIBRARIES
|
||||
ICONV_SECOND_ARGUMENT_IS_CONST
|
||||
)
|
||||
@@ -1,45 +0,0 @@
|
||||
# Try to find Libintl functionality
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBINTL_FOUND - system has Libintl
|
||||
# LIBINTL_INCLUDE_DIR - Libintl include directory
|
||||
# LIBINTL_LIBRARIES - Libraries needed to use Libintl
|
||||
#
|
||||
# TODO: This will enable translations only if Gettext functionality is
|
||||
# present in libc. Must have more robust system for release, where Gettext
|
||||
# functionality can also reside in standalone Gettext library, or the one
|
||||
# embedded within kdelibs (cf. gettext.m4 from Gettext source).
|
||||
|
||||
# Copyright (c) 2006, Chusslove Illich, <caslav.ilic@gmx.net>
|
||||
# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
|
||||
set(Libintl_FIND_QUIETLY TRUE)
|
||||
endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
|
||||
|
||||
find_path(LIBINTL_INCLUDE_DIR libintl.h)
|
||||
|
||||
set(LIBINTL_LIB_FOUND FALSE)
|
||||
|
||||
if(LIBINTL_INCLUDE_DIR)
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
|
||||
if (LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
set(LIBINTL_LIBRARIES)
|
||||
set(LIBINTL_LIB_FOUND TRUE)
|
||||
else (LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
find_library(LIBINTL_LIBRARIES intl libintl libintl-8)
|
||||
if(LIBINTL_LIBRARIES)
|
||||
set(LIBINTL_LIB_FOUND TRUE)
|
||||
endif(LIBINTL_LIBRARIES)
|
||||
endif (LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
endif(LIBINTL_INCLUDE_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_LIBRARIES LIBINTL_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND)
|
||||
@@ -1,351 +0,0 @@
|
||||
#.rst:
|
||||
# FindPackageHandleStandardArgs
|
||||
# -----------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
|
||||
#
|
||||
# This function is intended to be used in FindXXX.cmake modules files.
|
||||
# It handles the REQUIRED, QUIET and version-related arguments to
|
||||
# find_package(). It also sets the <packagename>_FOUND variable. The
|
||||
# package is considered found if all variables <var1>... listed contain
|
||||
# valid results, e.g. valid filepaths.
|
||||
#
|
||||
# There are two modes of this function. The first argument in both
|
||||
# modes is the name of the Find-module where it is called (in original
|
||||
# casing).
|
||||
#
|
||||
# The first simple mode looks like this:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
|
||||
#
|
||||
# If the variables <var1> to <varN> are all valid, then
|
||||
# <UPPERCASED_NAME>_FOUND will be set to TRUE. If DEFAULT_MSG is given
|
||||
# as second argument, then the function will generate itself useful
|
||||
# success and error messages. You can also supply a custom error
|
||||
# message for the failure case. This is not recommended.
|
||||
#
|
||||
# The second mode is more powerful and also supports version checking:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [FOUND_VAR <resultVar>]
|
||||
# [REQUIRED_VARS <var1>...<varN>]
|
||||
# [VERSION_VAR <versionvar>]
|
||||
# [HANDLE_COMPONENTS]
|
||||
# [CONFIG_MODE]
|
||||
# [FAIL_MESSAGE "Custom failure message"] )
|
||||
#
|
||||
#
|
||||
#
|
||||
# In this mode, the name of the result-variable can be set either to
|
||||
# either <UPPERCASED_NAME>_FOUND or <OriginalCase_Name>_FOUND using the
|
||||
# FOUND_VAR option. Other names for the result-variable are not
|
||||
# allowed. So for a Find-module named FindFooBar.cmake, the two
|
||||
# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended
|
||||
# to use the original case version. If the FOUND_VAR option is not
|
||||
# used, the default is <UPPERCASED_NAME>_FOUND.
|
||||
#
|
||||
# As in the simple mode, if <var1> through <varN> are all valid,
|
||||
# <packagename>_FOUND will be set to TRUE. After REQUIRED_VARS the
|
||||
# variables which are required for this package are listed. Following
|
||||
# VERSION_VAR the name of the variable can be specified which holds the
|
||||
# version of the package which has been found. If this is done, this
|
||||
# version will be checked against the (potentially) specified required
|
||||
# version used in the find_package() call. The EXACT keyword is also
|
||||
# handled. The default messages include information about the required
|
||||
# version and the version which has been actually found, both if the
|
||||
# version is ok or not. If the package supports components, use the
|
||||
# HANDLE_COMPONENTS option to enable handling them. In this case,
|
||||
# find_package_handle_standard_args() will report which components have
|
||||
# been found and which are missing, and the <packagename>_FOUND variable
|
||||
# will be set to FALSE if any of the required components (i.e. not the
|
||||
# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option
|
||||
# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a
|
||||
# find_package(... NO_MODULE) call. In this case VERSION_VAR will be
|
||||
# set to <NAME>_VERSION and the macro will automatically check whether
|
||||
# the Config module was found. Via FAIL_MESSAGE a custom failure
|
||||
# message can be specified, if this is not used, the default message
|
||||
# will be displayed.
|
||||
#
|
||||
# Example for mode 1:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
|
||||
#
|
||||
#
|
||||
#
|
||||
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
|
||||
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to
|
||||
# TRUE. If it is not found and REQUIRED was used, it fails with
|
||||
# FATAL_ERROR, independent whether QUIET was used or not. If it is
|
||||
# found, success will be reported, including the content of <var1>. On
|
||||
# repeated Cmake runs, the same message won't be printed again.
|
||||
#
|
||||
# Example for mode 2:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# find_package_handle_standard_args(LibXslt FOUND_VAR LibXslt_FOUND
|
||||
# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS
|
||||
# VERSION_VAR LibXslt_VERSION_STRING)
|
||||
#
|
||||
# In this case, LibXslt is considered to be found if the variable(s)
|
||||
# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and
|
||||
# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in
|
||||
# LibXslt_FOUND . Also the version of LibXslt will be checked by using
|
||||
# the version contained in LibXslt_VERSION_STRING. Since no
|
||||
# FAIL_MESSAGE is given, the default messages will be printed.
|
||||
#
|
||||
# Another example for mode 2:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
|
||||
# find_package_handle_standard_args(Automoc4 CONFIG_MODE)
|
||||
#
|
||||
# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4
|
||||
# NO_MODULE) and adds an additional search directory for automoc4. Here
|
||||
# the result will be stored in AUTOMOC4_FOUND. The following
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
|
||||
# success/error message.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
|
||||
|
||||
# internal helper macro
|
||||
macro(_FPHSA_FAILURE_MESSAGE _msg)
|
||||
if (${_NAME}_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "${_msg}")
|
||||
else ()
|
||||
if (NOT ${_NAME}_FIND_QUIETLY)
|
||||
message(STATUS "${_msg}")
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
|
||||
# internal helper macro to generate the failure message when used in CONFIG_MODE:
|
||||
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
|
||||
# <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
|
||||
if(${_NAME}_CONFIG)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
|
||||
else()
|
||||
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
|
||||
# List them all in the error message:
|
||||
if(${_NAME}_CONSIDERED_CONFIGS)
|
||||
set(configsText "")
|
||||
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
|
||||
math(EXPR configsCount "${configsCount} - 1")
|
||||
foreach(currentConfigIndex RANGE ${configsCount})
|
||||
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
|
||||
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
|
||||
set(configsText "${configsText} ${filename} (version ${version})\n")
|
||||
endforeach()
|
||||
if (${_NAME}_NOT_FOUND_MESSAGE)
|
||||
set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
|
||||
endif()
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
|
||||
|
||||
else()
|
||||
# Simple case: No Config-file was found at all:
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
||||
|
||||
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
|
||||
# new extended or in the "old" mode:
|
||||
set(options CONFIG_MODE HANDLE_COMPONENTS)
|
||||
set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
|
||||
set(multiValueArgs REQUIRED_VARS)
|
||||
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
|
||||
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
|
||||
|
||||
if(${INDEX} EQUAL -1)
|
||||
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
|
||||
set(FPHSA_REQUIRED_VARS ${ARGN})
|
||||
set(FPHSA_VERSION_VAR)
|
||||
else()
|
||||
|
||||
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
|
||||
|
||||
if(FPHSA_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
|
||||
endif()
|
||||
|
||||
if(NOT FPHSA_FAIL_MESSAGE)
|
||||
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# now that we collected all arguments, process them
|
||||
|
||||
if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
|
||||
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
|
||||
endif()
|
||||
|
||||
# In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
|
||||
# when it successfully found the config-file, including version checking:
|
||||
if(FPHSA_CONFIG_MODE)
|
||||
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
|
||||
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
|
||||
set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
|
||||
endif()
|
||||
|
||||
if(NOT FPHSA_REQUIRED_VARS)
|
||||
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
|
||||
endif()
|
||||
|
||||
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
|
||||
|
||||
string(TOUPPER ${_NAME} _NAME_UPPER)
|
||||
string(TOLOWER ${_NAME} _NAME_LOWER)
|
||||
|
||||
if(FPHSA_FOUND_VAR)
|
||||
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
|
||||
set(_FOUND_VAR ${FPHSA_FOUND_VAR})
|
||||
else()
|
||||
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
|
||||
endif()
|
||||
else()
|
||||
set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
|
||||
endif()
|
||||
|
||||
# collect all variables which were not found, so they can be printed, so the
|
||||
# user knows better what went wrong (#6375)
|
||||
set(MISSING_VARS "")
|
||||
set(DETAILS "")
|
||||
# check if all passed variables are valid
|
||||
unset(${_FOUND_VAR})
|
||||
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
|
||||
if(NOT ${_CURRENT_VAR})
|
||||
set(${_FOUND_VAR} FALSE)
|
||||
set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
|
||||
else()
|
||||
set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE")
|
||||
set(${_FOUND_VAR} TRUE)
|
||||
endif()
|
||||
|
||||
# component handling
|
||||
unset(FOUND_COMPONENTS_MSG)
|
||||
unset(MISSING_COMPONENTS_MSG)
|
||||
|
||||
if(FPHSA_HANDLE_COMPONENTS)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(${_NAME}_${comp}_FOUND)
|
||||
|
||||
if(NOT DEFINED FOUND_COMPONENTS_MSG)
|
||||
set(FOUND_COMPONENTS_MSG "found components: ")
|
||||
endif()
|
||||
set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
|
||||
|
||||
else()
|
||||
|
||||
if(NOT DEFINED MISSING_COMPONENTS_MSG)
|
||||
set(MISSING_COMPONENTS_MSG "missing components: ")
|
||||
endif()
|
||||
set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
|
||||
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_FOUND_VAR} FALSE)
|
||||
set(MISSING_VARS "${MISSING_VARS} ${comp}")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endforeach()
|
||||
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
|
||||
set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
|
||||
endif()
|
||||
|
||||
# version handling:
|
||||
set(VERSION_MSG "")
|
||||
set(VERSION_OK TRUE)
|
||||
set(VERSION ${${FPHSA_VERSION_VAR}} )
|
||||
if (${_NAME}_FIND_VERSION)
|
||||
|
||||
if(VERSION)
|
||||
|
||||
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
|
||||
if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
|
||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||
set(VERSION_OK FALSE)
|
||||
else ()
|
||||
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
|
||||
endif ()
|
||||
|
||||
else() # minimum version specified:
|
||||
if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
|
||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
|
||||
set(VERSION_OK FALSE)
|
||||
else ()
|
||||
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
# if the package was not found, but a version was given, add that to the output:
|
||||
if(${_NAME}_FIND_VERSION_EXACT)
|
||||
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
|
||||
else()
|
||||
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
else ()
|
||||
if(VERSION)
|
||||
set(VERSION_MSG "(found version \"${VERSION}\")")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(VERSION_OK)
|
||||
set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
|
||||
else()
|
||||
set(${_FOUND_VAR} FALSE)
|
||||
endif()
|
||||
|
||||
|
||||
# print the result:
|
||||
if (${_FOUND_VAR})
|
||||
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
|
||||
else ()
|
||||
|
||||
if(FPHSA_CONFIG_MODE)
|
||||
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
|
||||
else()
|
||||
if(NOT VERSION_OK)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
|
||||
else()
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif ()
|
||||
|
||||
set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
@@ -1,57 +0,0 @@
|
||||
#.rst:
|
||||
# FindPackageMessage
|
||||
# ------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
|
||||
#
|
||||
# This macro is intended to be used in FindXXX.cmake modules files. It
|
||||
# will print a message once for each unique find result. This is useful
|
||||
# for telling the user where a package was found. The first argument
|
||||
# specifies the name (XXX) of the package. The second argument
|
||||
# specifies the message to display. The third argument lists details
|
||||
# about the find result so that if they change the message will be
|
||||
# displayed again. The macro also obeys the QUIET argument to the
|
||||
# find_package command.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# if(X11_FOUND)
|
||||
# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
|
||||
# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
|
||||
# else()
|
||||
# ...
|
||||
# endif()
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2008-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
function(FIND_PACKAGE_MESSAGE pkg msg details)
|
||||
# Avoid printing a message repeatedly for the same find result.
|
||||
if(NOT ${pkg}_FIND_QUIETLY)
|
||||
string(REGEX REPLACE "[\n]" "" details "${details}")
|
||||
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
|
||||
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
|
||||
# The message has not yet been printed.
|
||||
message(STATUS "${msg}")
|
||||
|
||||
# Save the find details in the cache to avoid printing the same
|
||||
# message again.
|
||||
set("${DETAILS_VAR}" "${details}"
|
||||
CACHE INTERNAL "Details about finding ${pkg}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -1,186 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2
|
||||
# -------
|
||||
#
|
||||
# Locate SDL2 library
|
||||
#
|
||||
# This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_LIBRARY, the name of the library to link against
|
||||
# SDL2_FOUND, if false, do not try to link to SDL
|
||||
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||
# SDL2_VERSION_STRING, human-readable string containing the version of SDL
|
||||
#
|
||||
#
|
||||
#
|
||||
# This module responds to the flag:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_BUILDING_LIBRARY
|
||||
# If this is defined, then no SDL2_main will be linked in because
|
||||
# only applications need main().
|
||||
# Otherwise, it is assumed you are building an application and this
|
||||
# module will attempt to locate and set the proper link flags
|
||||
# as part of the returned SDL2_LIBRARY variable.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||
# OS X framework based version. (Other versions link to -lSDLmain which
|
||||
# this module will try to find on your behalf.) Also for OS X, this
|
||||
# module will automatically add the -framework Cocoa on your behalf.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your
|
||||
# configuration and no SDL2_LIBRARY, it means CMake did not find your SDL
|
||||
# library (SDL.dll, libsdl.so, SDL.framework, etc). Set
|
||||
# SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
|
||||
# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
|
||||
# value as appropriate. These values are used to generate the final
|
||||
# SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY
|
||||
# does not get created.
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDLDIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
|
||||
#
|
||||
# Modified by Eric Wing. Added code to assist with automated building
|
||||
# by using environmental variables and providing a more
|
||||
# controlled/consistent search behavior. Added new modifications to
|
||||
# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
# Also corrected the header search path to follow "proper" SDL
|
||||
# guidelines. Added a search for SDLmain which is needed by some
|
||||
# platforms. Added a search for threads which is needed by some
|
||||
# platforms. Added needed compile switches for MinGW.
|
||||
#
|
||||
# On OSX, this will prefer the Framework version (if found) over others.
|
||||
# People will have to manually change the cache values of SDL2_LIBRARY to
|
||||
# override this selection or set the CMake environment
|
||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
#
|
||||
# Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
# This needed to change because "proper" SDL convention is #include
|
||||
# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
||||
# because not all systems place things in SDL/ (see FreeBSD).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2003-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_path(SDL2_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDLDIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
find_library(SDL2_LIBRARY_TEMP
|
||||
NAMES SDL2
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
if(NOT SDL2_BUILDING_LIBRARY)
|
||||
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDLmain for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
find_library(SDL2MAIN_LIBRARY
|
||||
NAMES SDL2main
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
if(NOT APPLE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional library, mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
|
||||
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||
if(MINGW)
|
||||
set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||
endif()
|
||||
|
||||
if(SDL2_LIBRARY_TEMP)
|
||||
# For SDLmain
|
||||
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
|
||||
list(FIND SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
||||
if(_SDL2_MAIN_INDEX EQUAL -1)
|
||||
set(SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
|
||||
endif()
|
||||
unset(_SDL2_MAIN_INDEX)
|
||||
endif()
|
||||
|
||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
if(APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# In fact, there seems to be a problem if I used the Threads package
|
||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||
if(NOT APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# For MinGW library
|
||||
if(MINGW)
|
||||
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||
endif()
|
||||
|
||||
# Set the final string here so the GUI reflects the final state.
|
||||
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||
set(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
@@ -1,97 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2_image
|
||||
# -------------
|
||||
#
|
||||
# Locate SDL2_image library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_IMAGE_LIBRARIES, the name of the library to link against
|
||||
# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_IMAGE_FOUND, if false, do not try to link against
|
||||
# SDL2_IMAGE_VERSION_STRING - human-readable string containing the
|
||||
# version of SDL2_image
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatiblity the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2IMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
|
||||
# SDL2IMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
|
||||
# SDL2IMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(NOT SDL2_IMAGE_INCLUDE_DIR AND SDL2IMAGE_INCLUDE_DIR)
|
||||
set(SDL2_IMAGE_INCLUDE_DIR ${SDL2IMAGE_INCLUDE_DIR} CACHE PATH "directory cache
|
||||
entry initialized from old variable name")
|
||||
endif()
|
||||
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
|
||||
HINTS
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_IMAGE_LIBRARY AND SDL2IMAGE_LIBRARY)
|
||||
set(SDL2_IMAGE_LIBRARY ${SDL2IMAGE_LIBRARY} CACHE FILEPATH "file cache entry
|
||||
initialized from old variable name")
|
||||
endif()
|
||||
find_library(SDL2_IMAGE_LIBRARY
|
||||
NAMES SDL2_image
|
||||
HINTS
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
|
||||
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
|
||||
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
|
||||
|
||||
# for backward compatiblity
|
||||
set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
|
||||
set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
|
||||
set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
|
||||
|
||||
mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
|
||||
@@ -1,97 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2_mixer
|
||||
# -------------
|
||||
#
|
||||
# Locate SDL2_mixer library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_MIXER_LIBRARIES, the name of the library to link against
|
||||
# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_MIXER_FOUND, if false, do not try to link against
|
||||
# SDL2_MIXER_VERSION_STRING - human-readable string containing the
|
||||
# version of SDL2_mixer
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatiblity the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
|
||||
# SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
|
||||
# SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
|
||||
set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
|
||||
entry initialized from old variable name")
|
||||
endif()
|
||||
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
|
||||
HINTS
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
|
||||
set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
|
||||
initialized from old variable name")
|
||||
endif()
|
||||
find_library(SDL2_MIXER_LIBRARY
|
||||
NAMES SDL2_mixer
|
||||
HINTS
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
|
||||
set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
|
||||
REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_MIXER_VERSION_STRING)
|
||||
|
||||
# for backward compatiblity
|
||||
set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
|
||||
set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
|
||||
set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
|
||||
|
||||
mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
|
||||
@@ -1,96 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2_ttf
|
||||
# -----------
|
||||
#
|
||||
# Locate SDL2_ttf library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_TTF_LIBRARIES, the name of the library to link against
|
||||
# SDL2_TTF_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_TTF_FOUND, if false, do not try to link against
|
||||
# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatiblity the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2TTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
|
||||
# SDL2TTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
|
||||
# SDL2TTF_FOUND (same value as SDL2_TTF_FOUND)
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
|
||||
set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
|
||||
entry initialized from old variable name")
|
||||
endif()
|
||||
find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
|
||||
HINTS
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_TTF_LIBRARY AND SDL2TTF_LIBRARY)
|
||||
set(SDL2_TTF_LIBRARY ${SDL2TTF_LIBRARY} CACHE FILEPATH "file cache entry
|
||||
initialized from old variable name")
|
||||
endif()
|
||||
find_library(SDL2_TTF_LIBRARY
|
||||
NAMES SDL2_ttf
|
||||
HINTS
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
|
||||
set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
|
||||
REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_TTF_VERSION_STRING)
|
||||
|
||||
# for backward compatiblity
|
||||
set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
|
||||
set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
|
||||
set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
|
||||
|
||||
mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
|
||||
@@ -1,130 +0,0 @@
|
||||
# - Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can
|
||||
# trust the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
endwhile()
|
||||
# check if this is a submodule
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake"
|
||||
@ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${hash}
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,41 +0,0 @@
|
||||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set(HEAD_HASH)
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
else()
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH)
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
||||
@@ -1,25 +0,0 @@
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
1. Assume other participants are posting in good faith, even if you disagree with what they say.
|
||||
2. Make an effort to treat other participants with respect.
|
||||
1. Do not take a harsh tone towards other participants, and especially don't make personal attacks against them.
|
||||
2. Recognize that criticism of your statements is not a personal attack on you.
|
||||
3. Avoid statements about the presumed typical desires, capabilities or actions of some demographic group.
|
||||
3. Be especially kind to other contributors when saying they made a mistake.
|
||||
4. Don't argue unceasingly for your preferred course of action when a decision for some other course has already been made.
|
||||
5. If other participants complain about the way you express your ideas, please make an effort to cater to them.
|
||||
6. Don't raise unrelated political issues.
|
||||
7. If you feel these standards are being violated, please alert the project lead Kevin Granade at kevin.granade@gmail.com
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][CoC homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][CoC version] and the [GNU Kind Communications Guidelines][GKCG homepage].
|
||||
|
||||
|
||||
[CoC homepage]: http://contributor-covenant.org
|
||||
[CoC version]: http://contributor-covenant.org/version/1/4/
|
||||
[GKCG homepage]: https://www.gnu.org/philosophy/kind-communication.html
|
||||
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"build_systems":
|
||||
[
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"RELEASE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make RELEASE",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"TILES=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make TILES",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"TILES=1",
|
||||
"RELEASE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make RELEASE TILES",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
}
|
||||
],
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"folder_exclude_patterns":
|
||||
[
|
||||
"Cataclysm.app"
|
||||
],
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "~/.cataclysm-dda"
|
||||
},
|
||||
{
|
||||
"path": "~/Library/Application Support/Cataclysm"
|
||||
}
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"AStyleFormatter":
|
||||
{
|
||||
"options_c++":
|
||||
{
|
||||
"additional_options_file": ".astylerc",
|
||||
"use_only_additional_options": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,297 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Cataclysm" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Release">
|
||||
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release (Localized)">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalized/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Localized)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalizedSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Loc, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalizedSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg -g" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (Localized)">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalized/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add directory="WinDepend/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL)">
|
||||
<Option output="CataclysmWin-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Localized)">
|
||||
<Option output="CataclysmWin-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalizedSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DTILES" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Loc, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalizedSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-std=c++14" />
|
||||
<Add option="-DCB_BUILD" />
|
||||
<Add option="-D_WINDOWS -D_MINGW -D_WIN32 -DWIN32 -D__MINGW__" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-Wl,-stack,12000000,-subsystem,windows" />
|
||||
<Add option="-static" />
|
||||
<Add library="gdi32" />
|
||||
<Add library="winmm" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add before="cmd /c git --version || echo 'git' command not found!" />
|
||||
<Add before="cmd /c git describe --tags --always --dirty > version.tmp || echo no-git> version.tmp" />
|
||||
<Add before='cmd /c for /F "tokens=*" %%i in (version.tmp) do echo #define VERSION "%%i" > src/version.h' />
|
||||
<Add before="cmd /c del version.tmp" />
|
||||
<Mode after="always" />
|
||||
</ExtraCommands>
|
||||
<UnitsGlob directory="src" recursive="0" />
|
||||
<Unit filename="src/resource.rc">
|
||||
<Option compilerVar="WINDRES" />
|
||||
</Unit>
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<debugger />
|
||||
<envvars />
|
||||
<DoxyBlocks>
|
||||
<comment_style block="0" line="0" />
|
||||
<doxyfile_project />
|
||||
<doxyfile_build />
|
||||
<doxyfile_warnings />
|
||||
<doxyfile_output />
|
||||
<doxyfile_dot />
|
||||
<general />
|
||||
</DoxyBlocks>
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
@@ -0,0 +1,28 @@
|
||||
source "https://rubygems.org"
|
||||
ruby RUBY_VERSION
|
||||
|
||||
# Hello! This is where you manage which Jekyll version is used to run.
|
||||
# When you want to use a different version, change it below, save the
|
||||
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
||||
#
|
||||
# bundle exec jekyll serve
|
||||
#
|
||||
# This will help ensure the proper Jekyll version is running.
|
||||
# Happy Jekylling!
|
||||
# gem "jekyll", "3.4.2"
|
||||
|
||||
# This is the default theme for new Jekyll sites. You may change this to anything you like.
|
||||
gem "minima", "~> 2.0"
|
||||
|
||||
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
||||
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
||||
gem "github-pages", group: :jekyll_plugins
|
||||
|
||||
# If you have any plugins, put them here!
|
||||
group :jekyll_plugins do
|
||||
gem "jekyll-feed", "~> 0.6"
|
||||
end
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# Issues
|
||||
|
||||
## How to create new issues properly
|
||||
|
||||
GitHub issues are used for everything from bug reporting to suggesting long-term ideas. You can make everything run much smoother by following some simple rules.
|
||||
|
||||
### Rule zero
|
||||
|
||||
Always give your issue a meaningful title as this is the first thing anyone will see.
|
||||
|
||||
Note: `[CR]` and `[WIP]` "tags" are meaningful only for PRs. All open issues by definition are request for comments and work in progress.
|
||||
|
||||
### Bug reports
|
||||
|
||||
Before you submit a bug always search the current list of issues to see if it has been reported already.
|
||||
|
||||
Your bug report has to include:
|
||||
|
||||
- On what OS did you experience the problem (Windows, Linux, OS X etc.)
|
||||
- What version were you playing:
|
||||
- Tiles or Curses (text-based)
|
||||
- Version string (preferably full version e.g. "0.C-4547-g3f1c109", or Jenkins build number e.g. 3245)
|
||||
- Description of the problem written in a way that enables anyone to try and recreate it
|
||||
|
||||
Your bug report may include:
|
||||
|
||||
- Screenshot(s) as some things are best explained visually
|
||||
- Save file (e.g. link to a dropbox upload)
|
||||
|
||||
Bonus points for:
|
||||
|
||||
- Checking if the bug exists under latest experimental build
|
||||
- Checking if it is OS specific
|
||||
|
||||
The OS and CDDA version are very important - with the pace of changes here it is possible the bug you have encountered has already been fixed. After that reproducibility is the key, so write your report with all the necessary details.
|
||||
|
||||
### Enhancements and addition ideas
|
||||
|
||||
We have hundreds of issues open - most of them are ideas and suggestions. If you have a general idea or anything that can't be easily described in terms of *current* code changes you'd be better off suggesting it in the appropriate section of [the forum](https://discourse.cataclysmdda.org/). You'll also get much broader exposure for your idea there. After developing a polished idea on the forum, it should be easy to make a GitHub issue for it.
|
||||
|
||||
Please first search if something like what you have on mind has been already proposed. If so, feel free to join the discussion! If your idea is related but sufficiently different, open a new issue and refer to the older discussion (use GitHub's `#issue_number` reference system).
|
||||
|
||||
Remember to take part in the discussion of your suggestions.
|
||||
|
||||
### Questions
|
||||
|
||||
You should direct your questions to the forum or ask on IRC. You should also read the included documentation and additional text files, e.g. [COMPILING.md](doc/COMPILING/COMPILING.md) if you have problems building.
|
||||
|
||||
## Bounties
|
||||
|
||||
Placing a bounty *does not* necessarily mean that change will be incorporated into the main game. Please coordinate in the issue you intend to place a bounty on to determine if it is a change the project will accept, and keep in mind that placing a bounty will not confer special status on the issue. A good way of thinking about bounties is as encouragement for contributors to work on a particular issue, and certainly not as "paying for features".
|
||||
|
||||
## Issue resolution
|
||||
|
||||
We do not assign people to issues. If you plan to work on a bug fix or a validated idea feel free to just comment about that. Actual PRs are of much greater value than any assignments. In general the first correct PR about something will be the PR that will get merged, but remember: we are using Git - you can collaborate with someone else easily by sending them patches or PRs against their PR branch.
|
||||
@@ -1,94 +0,0 @@
|
||||
Copyright (c) 2019 Dimitar Toshkov Zhekov,
|
||||
with Reserved Font Name "Terminus Font".
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -1,45 +0,0 @@
|
||||
Cataclysm is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
|
||||
|
||||
The Square font (data/font/square.ttf) is copyright Wouter van Oortmerssen, licensed under Creative Commons Attribution 3.0 Unported License. See http://strlen.com/square for more information.
|
||||
|
||||
GNU Unifont (data/font/unitfont.ttf) is licensed under GNU General Public License v2+ with the GNU font embedding exception. Visit http://unifoundry.com/LICENSE.txt for details.
|
||||
|
||||
Terminus Font (data/font/terminus.ttf) is licensed under the SIL Open Font License (see LICENSE-OFL-Terminus-Font.txt).
|
||||
|
||||
CATCH unit-test framework (tests/catch/catch.hpp) is licensed under the Boost Software License. Visit https://github.com/philsquared/Catch/blob/master/LICENSE.txt to read the license.
|
||||
|
||||
PLF List and PLF Colony (src/list.h, src/colony.h) are licensed under the zLib license (https://www.zlib.net/zlib_license.html).
|
||||
|
||||
getpost (tools/json_tools/format/getpost.h) is licensed under the MIT license, see file for text of license.
|
||||
|
||||
libbacktrace is licensed under a BSD license (https://github.com/ianlancetaylor/libbacktrace/blob/master/LICENSE). The full license text is as follows:
|
||||
|
||||
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
|
||||
# (1) Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# (2) Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
|
||||
# (3) The name of the author may not be used to
|
||||
# endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,101 +0,0 @@
|
||||
# Catalcysm: Dark Days Ahead
|
||||
|
||||
Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world. While some have described it as a "zombie game", there is far more to Cataclysm than that. Struggle to survive in a harsh, persistent, procedurally generated world. Scavenge the remnants of a dead civilization for food, equipment, or, if you are lucky, a vehicle with a full tank of gas to get you the hell out of Dodge. Fight to defeat or escape from a wide variety of powerful monstrosities, from zombies to giant insects to killer robots and things far stranger and deadlier, and against the others like yourself, who want what you have...
|
||||
|
||||
<a href="https://repology.org/project/cataclysm-dda/versions">
|
||||
<img src="https://repology.org/badge/vertical-allrepos/cataclysm-dda.svg" alt="Packaging Status" align="right">
|
||||
</a>
|
||||
|
||||
[](https://travis-ci.org/CleverRaven/Cataclysm-DDA)
|
||||
[](https://coveralls.io/github/CleverRaven/Cataclysm-DDA?branch=master)
|
||||
[](https://www.codetriage.com/cleverraven/cataclysm-dda)
|
||||
[](https://github.com/CleverRaven/Cataclysm-DDA/graphs/contributors)
|
||||
[](https://github.com/XAMPPRocky/tokei)
|
||||
|
||||
## Downloads
|
||||
|
||||
**Releases** - [Stable](https://cataclysmdda.org/releases/) | [Experimental](https://cataclysmdda.org/experimental/)
|
||||
|
||||
**Source** - The source can be downloaded as a [.zip archive](https://github.com/CleverRaven/Cataclysm-DDA/archive/master.zip), or cloned from our [GitHub repo](https://github.com/CleverRaven/Cataclysm-DDA/).
|
||||
|
||||
### Packaging status
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
Ncurses and tiles version available in [community repo](https://www.archlinux.org/packages/?q=cataclysm-dda).
|
||||
|
||||
`sudo pacman -S cataclysm-dda`
|
||||
|
||||
#### Fedora
|
||||
|
||||
Ncurses and tiles version available in [official repos](https://src.fedoraproject.org/rpms/cataclysm-dda).
|
||||
|
||||
`sudo dnf install cataclysm-dda`
|
||||
|
||||
#### Debian / Ubuntu
|
||||
|
||||
Ncurses and tiles version available in [official repos](https://tracker.debian.org/pkg/cataclysm-dda).
|
||||
|
||||
`sudo apt install cataclysm-dda-curses cataclysm-dda-sdl`
|
||||
|
||||
## Compile
|
||||
|
||||
Please read [COMPILING.md](doc/COMPILING/COMPILING.md) - it covers general information and more specific recipes for Linux, OS X, Windows and BSD. See [COMPILER_SUPPORT.md](doc/COMPILING/COMPILER_SUPPORT.md) for details on which compilers we support. And you can always dig for more information in [doc/](https://github.com/CleverRaven/Cataclysm-DDA/tree/master/doc).
|
||||
|
||||
We also have the following build guides:
|
||||
* Building on Windows with `MSYS2` at [COMPILING-MSYS.md](doc/COMPILING/COMPILING-MSYS.md)
|
||||
* Building on Windows with `vcpkg` at [COMPILING-VS-VCPKG.md](doc/COMPILING/COMPILING-VS-VCPKG.md)
|
||||
* Building with `cmake` at [COMPILING-CMAKE.md](doc/COMPILING/COMPILING-CMAKE.md) (*unofficial guide*)
|
||||
|
||||
## Contribute
|
||||
|
||||
Cataclysm: Dark Days Ahead is the result of contributions from over 1000 volunteers under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
|
||||
Some code distributed with the project is not part of the project and is released under different software licenses, the files covered by different software licenses have their own license notices.
|
||||
|
||||
[<img src="https://www.bountysource.com/badge/tracker?tracker_id=146201" alt="Bountysource" align="right">](https://www.bountysource.com/trackers/146201-clever-raven-cataclysm-dda?utm_source=146201&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
||||
|
||||
Please see [CONTRIBUTING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/.github/CONTRIBUTING.md) for details.
|
||||
|
||||
## Community
|
||||
|
||||
Forums:
|
||||
https://discourse.cataclysmdda.org
|
||||
|
||||
Wiki:
|
||||
http://cddawiki.chezzo.com/cdda_wiki/index.php
|
||||
|
||||
GitHub repo:
|
||||
https://github.com/CleverRaven/Cataclysm-DDA
|
||||
|
||||
IRC:
|
||||
`irc.freenode.net` ; `#CataclysmDDA`
|
||||
http://webchat.freenode.net/?channels=#CataclysmDDA
|
||||
|
||||
Official Discord:
|
||||
https://discord.gg/jFEc7Yp
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
#### Is there a tutorial?
|
||||
|
||||
Yes, you can find the tutorial in the **Special** menu at the main menu (be aware that due to many code changes the tutorial may not function). You can also access documentation in-game via the `?` key.
|
||||
|
||||
#### How can I change the key bindings?
|
||||
|
||||
Press the `?` key, followed by the `1` key to see the full list of key commands. Press the `+` key to add a key binding, select which action with the corresponding letter key `a-w`, and then the key you wish to assign to that action.
|
||||
|
||||
#### How can I start a new world?
|
||||
|
||||
**World** on the main menu will generate a fresh world for you. Select **Create World**.
|
||||
|
||||
#### I've found a bug. What should I do?
|
||||
|
||||
Please submit an issue on [our GitHub page](https://github.com/CleverRaven/Cataclysm-DDA/issues/) using [bug report template](https://github.com/CleverRaven/Cataclysm-DDA/issues/new?template=bug_report.md). If you're not able to, send an email to `kevin.granade@gmail.com`.
|
||||
|
||||
#### I would like to make a suggestion. What should I do?
|
||||
|
||||
Please submit an issue on [our GitHub page](https://github.com/CleverRaven/Cataclysm-DDA/issues/) using [feature request template](https://github.com/CleverRaven/Cataclysm-DDA/issues/new?template=feature_request.md).
|
||||
|
||||
You can also submit your suggestions or vote for existing suggestions on [our FeatHub page](https://feathub.com/CleverRaven/Cataclysm-DDA). Most voted suggestions are:
|
||||
|
||||
[](https://feathub.com/CleverRaven/Cataclysm-DDA)
|
||||
@@ -1,65 +0,0 @@
|
||||
The undersigned release all their contributions to the Cataclysm project under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
|
||||
Kevin Granade <kevin.granade@gmail.com>
|
||||
Matthew Moffatt <TheDarklingWolf@gmail.com>
|
||||
origamiwolf <origamiwolf@gmail.com>
|
||||
Frank Huard <veryinky@gmail.com>
|
||||
daftfad <daftfjord@gmail.com>
|
||||
ZwodahS <ericnjf@gmail.com>
|
||||
Williham "Wito" Totland <williham.totland@gmail.com>
|
||||
Zach Morgan <zpmorgan@gmail.com>
|
||||
Livingstone <minexal@gmail.com>
|
||||
Ethan "Soron" Kaminski <ethan.kaminski@gmail.com>
|
||||
Soyweiser <soyweiser@gmail.com>
|
||||
Jason Gilbert <0jason.gilbert@gmail.com>
|
||||
Charlie Nolan (FunnyMan3595) <funnyman3595@gmail.com>
|
||||
uzername (some_name) <ivanpost777@gmail.com>
|
||||
Christian Buskirk (i2amroy) <i2amroy@gmail.com>
|
||||
Kevin McKayven (GlyphGryph) <glyphgryph@gmail.com>
|
||||
Ozone <satori.jj@gmail.com>
|
||||
Herbert Jones <jones.herbert@gmail.com>
|
||||
Justin "MacrosBlackD" Drury <macrosblackd@gmail.com>
|
||||
AtomicDryad <fnord@fnord> / <atomicdryad@gmail.com>
|
||||
Izicata
|
||||
Voker57 <voker57@gmail.com>
|
||||
Tommy <yobbobanana@gmx.com>
|
||||
teh-sam
|
||||
Alex Casey (Tamunshin) <tamunshin@hotmail.com>
|
||||
Stevensonz <money3030@yahoo.com.>
|
||||
David Holmes <dholmes@dholmes.us>
|
||||
Sean McLaughlin <galenevil@hotmail.com> / <galenevil.eve@gmail.com>
|
||||
Robert Sørlie (1942rob) <1942rob@gmail.com>
|
||||
Angela Graves <Rivet.the.Zombie@gmail.com>
|
||||
Ian Strachan <ian_e_strachan@hotmail.com>
|
||||
Greg McNew <gmcnew@gmail.com>
|
||||
NaturesWitness <natureswitness@gmail.com>
|
||||
CodeHero <codehero@nerdpol.ch>
|
||||
tasetase "Tase" <tase on irc.freenode.net>
|
||||
Barry Peddycord III <ishara@isharacomix.org>
|
||||
Vidar Engh Skaugen <vidarsk@gmail.com>
|
||||
Brandon Bergren (Bdragon) <bdragon@rtk0.net> / <git@bdragon.rtk0.net>
|
||||
Henrik "Tivec" Bergvin <henrik@bergvin.com>
|
||||
FryCarson <frycarson@gmail.com>
|
||||
TranquilMarmot (Nate Moore) <nate272@gmail.com>
|
||||
Stéphane Travostino <stephane.travostino@gmail.com>
|
||||
Jeremy Osborne <jeremywosborne@gmail.com>
|
||||
David "Davek" Keaton <keaton.david@gmail.com>
|
||||
Piotr S. Staszewski (drbig) <p.staszewski@gmail.com>
|
||||
Donnie "Desrik" McNabb <koderkore@gmail.com>
|
||||
Christian R. Byrne <christianbyrne2012@gmail.com>
|
||||
Dmitry "illi-kun" Serov <D.E.Serov@gmail.com>
|
||||
Karl Parakenings (karlnp) <karl.parakenings@gmail.com>
|
||||
Rob Palkowski <dopeghoti@gmail.com>
|
||||
Zaweri Runewright <mrampuja@gmail.com>
|
||||
Cliffs Dover <cliffs@dancingbottle.com>
|
||||
Sven-Hendrik "svenstaro" Haase <svenstaro@gmail.com>
|
||||
Nick Owens <mischief@offblast.org>
|
||||
Brett Dong <brett.browning.dong@gmail.com>
|
||||
Barry Gackle <bdgackle@gmail.com>
|
||||
BorkBorkGoesTheCode <imreallytoolazy@protonmail.com>
|
||||
Patrik Stridvall <patrik@stridvall.se>
|
||||
Ryan Schneider (RadHazard) <rslego@gmail.com>
|
||||
Paul Bransford (draeath) <draeath@gmail.com>
|
||||
Mark Langsdorf (mlangsdorf) <mark.langsdorf@gmail.com> / <mlangsdo@redhat.com>
|
||||
Ratul Saha (sahaRatul) <ratul.saha@arrakis.in> / <50.ratulsaha@gmail.com>
|
||||
Davis Bray (Kaltag1925) <pdavisbray@gmail.com>
|
||||
@@ -0,0 +1,35 @@
|
||||
# Welcome to Jekyll!
|
||||
#
|
||||
# This config file is meant for settings that affect your whole blog, values
|
||||
# which you are expected to set up once and rarely edit after that. If you find
|
||||
# yourself editing this file very often, consider using Jekyll's data files
|
||||
# feature for the data you need to update frequently.
|
||||
#
|
||||
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
||||
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
|
||||
|
||||
# Site settings
|
||||
# These are used to personalize your new site. If you look in the HTML files,
|
||||
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
|
||||
# You can create any custom variable you would like, and they will be accessible
|
||||
# in the templates via {{ site.myvariable }}.
|
||||
title: "Cataclysm: Dark Days Ahead"
|
||||
email: kevin.granade@gmail.com
|
||||
description: > # this means to ignore newlines until "baseurl:"
|
||||
Official homepage of Cataclysm: Dark Days Ahead open source turn-based survival RPG development project.
|
||||
Hosts downloads of game and links to community sites and resources.
|
||||
baseurl: "" # the subpath of your site, e.g. /blog
|
||||
url: "https://cataclysmdda.org" # the base hostname & protocol for your site, e.g. http://example.com
|
||||
repository: CleverRaven/Cataclysm-DDA
|
||||
|
||||
# Build settings
|
||||
markdown: kramdown
|
||||
theme: minima
|
||||
plugins:
|
||||
- jekyll-feed
|
||||
exclude:
|
||||
- Gemfile
|
||||
- Gemfile.lock
|
||||
- vendor
|
||||
include:
|
||||
- .well-known
|
||||
@@ -0,0 +1,18 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
|
||||
<meta name="description" content="{{ page.excerpt | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">
|
||||
|
||||
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
|
||||
<link rel="canonical" href="{{ page.url | replace:'index.html','' | absolute_url }}">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.title | escape }}" href="{{ "/feed.xml" | relative_url }}">
|
||||
<link rel="me" href="https://mastodon.gamedev.place/@kevingranade">
|
||||
<link rel="me" href="https://social.treehouse.systems/@itsmaya">
|
||||
|
||||
{% if jekyll.environment == 'production' and site.google_analytics %}
|
||||
{% include google-analytics.html %}
|
||||
{% endif %}
|
||||
</head>
|
||||
@@ -0,0 +1,31 @@
|
||||
<header class="site-header">
|
||||
|
||||
<div class="wrapper">
|
||||
{%- assign default_paths = site.pages | map: "path" -%}
|
||||
{%- assign page_paths = site.header_pages | default: default_paths -%}
|
||||
{%- assign titles_size = site.pages | map: 'title' | join: '' | size -%}
|
||||
<a class="site-title" rel="author" href="{{ "/" | relative_url }}">{{ site.title | escape }}</a>
|
||||
|
||||
{%- if titles_size > 0 -%}
|
||||
<nav class="site-nav">
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger">
|
||||
<span class="menu-icon">
|
||||
<svg viewBox="0 0 18 15" width="18px" height="15px">
|
||||
<path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<div class="trigger">
|
||||
<a class="page-link" href="/">Home</a>
|
||||
<a class="page-link" href="/releases/">Releases</a>
|
||||
<!--<a class="page-link" href="/changes/">Changes</a>-->
|
||||
<a class="page-link" href="/contributions/">Contribution Guidelines</a>
|
||||
<a class="page-link" href="/donations/">Donations</a>
|
||||
<a class="page-link" href="https://github.com/CleverRaven/Cataclysm-DDA/">GitHub</a>
|
||||
</div>
|
||||
</nav>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
</header>
|
||||
@@ -1,20 +0,0 @@
|
||||
!config/
|
||||
!deps*.zip
|
||||
*.iml
|
||||
.cxx
|
||||
.DS_Store
|
||||
.externalNativeBuild
|
||||
.gradle
|
||||
/.idea/libraries
|
||||
/.idea/workspace.xml
|
||||
/app/jni/SDL2
|
||||
/app/jni/SDL2_image
|
||||
/app/jni/SDL2_mixer
|
||||
/app/jni/SDL2_ttf
|
||||
/app/jni/libintl-lite
|
||||
/app/jni/lua
|
||||
/app/jni/mpg-123
|
||||
/app/build
|
||||
/build
|
||||
/captures
|
||||
/local.properties
|
||||
@@ -1,358 +0,0 @@
|
||||
import org.gradle.internal.os.OperatingSystem;
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
//options.compilerArgs << "-Xlint:deprecation"
|
||||
}
|
||||
|
||||
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
|
||||
def buildAsApplication = !buildAsLibrary
|
||||
if (buildAsApplication) {
|
||||
apply plugin: 'com.android.application'
|
||||
} else {
|
||||
apply plugin: 'com.android.library'
|
||||
}
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def keystorePropertiesFilename = 'keystore.properties'
|
||||
if (localProperties.getProperty('keystorePropertiesFilename') != null) {
|
||||
keystorePropertiesFilename = localProperties.getProperty("keystorePropertiesFilename")
|
||||
}
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
def keystorePropertiesFile = rootProject.file(keystorePropertiesFilename)
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystorePropertiesFile.withReader('UTF-8') { reader ->
|
||||
keystoreProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def njobs = getProperty("j")
|
||||
if (localProperties.getProperty('j') != null) {
|
||||
njobs = localProperties.getProperty("j")
|
||||
}
|
||||
|
||||
def localize = getProperty("localize").toBoolean()
|
||||
if (localProperties.getProperty('localize') != null) {
|
||||
localize = localProperties.getProperty("localize").toBoolean()
|
||||
}
|
||||
|
||||
def abi_arm_32 = getProperty("abi_arm_32").toBoolean()
|
||||
if (localProperties.getProperty('abi_arm_32') != null) {
|
||||
abi_arm_32 = localProperties.getProperty("abi_arm_32").toBoolean()
|
||||
}
|
||||
|
||||
def abi_arm_64 = getProperty("abi_arm_64").toBoolean()
|
||||
if (localProperties.getProperty('abi_arm_64') != null) {
|
||||
abi_arm_64 = localProperties.getProperty("abi_arm_64").toBoolean()
|
||||
}
|
||||
|
||||
def abi_x86_32 = getProperty("abi_x86_32").toBoolean()
|
||||
if (localProperties.getProperty('abi_x86_32') != null) {
|
||||
abi_x86_32 = localProperties.getProperty("abi_x86_32").toBoolean()
|
||||
}
|
||||
|
||||
def abi_x86_64 = getProperty("abi_x86_64").toBoolean()
|
||||
if (localProperties.getProperty('abi_x86_64') != null) {
|
||||
abi_x86_64 = localProperties.getProperty("abi_x86_64").toBoolean()
|
||||
}
|
||||
|
||||
def deps = getProperty("deps")
|
||||
if (localProperties.getProperty('deps') != null) {
|
||||
deps = localProperties.getProperty("deps")
|
||||
}
|
||||
|
||||
def override_version = getProperty("override_version")
|
||||
if (localProperties.getProperty('override_version') != null) {
|
||||
override_version = localProperties.getProperty("override_version")
|
||||
}
|
||||
|
||||
def version_header_path = getProperty("version_header_path")
|
||||
if (localProperties.getProperty('version_header_path') != null) {
|
||||
version_header_path = localProperties.getProperty("version_header_path")
|
||||
}
|
||||
|
||||
def override_compileSdkVersion = getProperty("override_compileSdkVersion").toInteger()
|
||||
if (localProperties.getProperty('override_compileSdkVersion') != null) {
|
||||
override_compileSdkVersion = localProperties.getProperty("override_compileSdkVersion").toInteger()
|
||||
}
|
||||
|
||||
def override_minSdkVersion = getProperty("override_minSdkVersion").toInteger()
|
||||
if (localProperties.getProperty('override_minSdkVersion') != null) {
|
||||
override_minSdkVersion = localProperties.getProperty("override_minSdkVersion").toInteger()
|
||||
}
|
||||
|
||||
def override_targetSdkVersion = getProperty("override_targetSdkVersion").toInteger()
|
||||
if (localProperties.getProperty('override_targetSdkVersion') != null) {
|
||||
override_targetSdkVersion = localProperties.getProperty("override_targetSdkVersion").toInteger()
|
||||
}
|
||||
|
||||
def override_ndkBuildAppPlatform = getProperty("override_ndkBuildAppPlatform")
|
||||
if (localProperties.getProperty('override_ndkBuildAppPlatform') != null) {
|
||||
override_ndkBuildAppPlatform = localProperties.getProperty("override_ndkBuildAppPlatform")
|
||||
}
|
||||
|
||||
println("Using [ njobs]: $njobs")
|
||||
println("Using [ localize]: $localize")
|
||||
println("Using [ deps]: $deps")
|
||||
println("Using [ override_version]: $override_version")
|
||||
println("Using [version_header_path]: $version_header_path")
|
||||
println("Using [ compileSdkVersion]: $override_compileSdkVersion")
|
||||
println("Using [ minSdkVersion]: $override_minSdkVersion")
|
||||
println("Using [ targetSdkVersion]: $override_targetSdkVersion")
|
||||
println("Using [ndkBuildAppPlatform]: $override_ndkBuildAppPlatform")
|
||||
println("Using [ abi_arm_32]: $abi_arm_32")
|
||||
println("Using [ abi_arm_64]: $abi_arm_64")
|
||||
println("Using [ abi_x86_32]: $abi_x86_32")
|
||||
println("Using [ abi_x86_64]: $abi_x86_64")
|
||||
|
||||
if (!abi_arm_32 && !abi_arm_64 && !abi_x86_32 && !abi_x86_64) {
|
||||
throw new GradleException("All supported ABI properties are set to false!")
|
||||
}
|
||||
if (!file(deps).exists()) {
|
||||
throw new GradleException("Dependencies file does not exist:" + deps)
|
||||
}
|
||||
|
||||
if (!override_version.isEmpty()) {
|
||||
if (version_header_path.isEmpty()) {
|
||||
throw new GradleException("`version_header_path` cannot be empty when `override_version` is not empty")
|
||||
} else {
|
||||
println("Overriding version number to $override_version using path $version_header_path")
|
||||
}
|
||||
}
|
||||
|
||||
task unzipDeps(type: Copy) {
|
||||
println("Using dependencies file: $deps")
|
||||
def zipFile = new File("$deps")
|
||||
def outputDir = new File('.')
|
||||
from zipTree(zipFile)
|
||||
into outputDir
|
||||
}
|
||||
|
||||
task makeLocalization(type: Exec) {
|
||||
if (localize) {
|
||||
println("Building with localization'")
|
||||
switch (OperatingSystem.current()) {
|
||||
case OperatingSystem.LINUX:
|
||||
workingDir './../..'
|
||||
commandLine 'make', 'localization', 'LANGUAGES=all'
|
||||
break
|
||||
case OperatingSystem.WINDOWS:
|
||||
workingDir './../..'
|
||||
commandLine 'sh.exe', 'android/app/makelocalizations.sh'
|
||||
break
|
||||
default:
|
||||
workingDir './../..'
|
||||
commandLine 'echo', 'Building without localization'
|
||||
break
|
||||
}
|
||||
} else {
|
||||
workingDir './../..'
|
||||
commandLine 'echo', 'Building without localization'
|
||||
}
|
||||
}
|
||||
|
||||
makeLocalization
|
||||
unzipDeps.dependsOn makeLocalization
|
||||
preBuild.dependsOn unzipDeps
|
||||
|
||||
android {
|
||||
compileSdkVersion override_compileSdkVersion
|
||||
|
||||
if (override_version.isEmpty()) {
|
||||
println("Generating version number to $version_header_path")
|
||||
switch (OperatingSystem.current()) {
|
||||
case OperatingSystem.LINUX:
|
||||
exec {
|
||||
workingDir './../..'
|
||||
commandLine 'make', 'version'
|
||||
}
|
||||
break
|
||||
case OperatingSystem.WINDOWS:
|
||||
exec {
|
||||
workingDir './../..'
|
||||
commandLine 'sh.exe', '-c', 'make version'
|
||||
}
|
||||
break
|
||||
default:
|
||||
exec {
|
||||
workingDir './../..'
|
||||
commandLine 'make', 'version'
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
println("Overriding version number to $override_version")
|
||||
exec {
|
||||
workingDir './../..'
|
||||
commandLine 'echo', '#define VERSION $override_version', '>', '$version_header_path'
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion override_minSdkVersion
|
||||
targetSdkVersion override_targetSdkVersion
|
||||
versionCode Integer.valueOf(System.env.UPSTREAM_BUILD_NUMBER ?: 1)
|
||||
versionName new File("$version_header_path").text.split('\"')[1]
|
||||
if (buildAsApplication) {
|
||||
applicationId "com.cleverraven.cataclysmdda"
|
||||
setProperty("archivesBaseName", "cataclysmdda-" + versionName)
|
||||
}
|
||||
resValue "string", "app_name", "Cataclysm DDA"
|
||||
|
||||
splits {
|
||||
// Configures multiple APKs based on ABI.
|
||||
abi {
|
||||
// Enables building multiple APKs per ABI.
|
||||
enable true
|
||||
// Resets the list of ABIs that Gradle should create APKs for to none.
|
||||
reset()
|
||||
// Specifies a list of ABIs that Gradle should create APKs for.
|
||||
if (abi_arm_32) {
|
||||
include "armeabi-v7a"
|
||||
}
|
||||
if (abi_arm_64) {
|
||||
include "arm64-v8a"
|
||||
}
|
||||
if (abi_x86_32) {
|
||||
include "x86"
|
||||
}
|
||||
if (abi_x86_64) {
|
||||
include "x86_64"
|
||||
}
|
||||
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
|
||||
universalApk false
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=$override_ndkBuildAppPlatform", "-j$njobs"
|
||||
}
|
||||
}
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
flavorDimensions "version"
|
||||
|
||||
productFlavors {
|
||||
stable {
|
||||
dimension "version"
|
||||
resValue "string", "app_name", "Cataclysm DDA"
|
||||
}
|
||||
experimental {
|
||||
dimension "version"
|
||||
applicationIdSuffix ".experimental"
|
||||
resValue "string", "app_name", "Cataclysm DDA (experimental)"
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (keystoreProperties.getProperty('storeFile') != null) {
|
||||
if (file(keystoreProperties.getProperty('storeFile')).exists()) {
|
||||
release {
|
||||
storeFile file(keystoreProperties.getProperty("storeFile"))
|
||||
storePassword keystoreProperties.getProperty("storePassword")
|
||||
keyAlias keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword keystoreProperties.getProperty("keyPassword")
|
||||
}
|
||||
} else {
|
||||
throw new GradleException("Keystore file " + keystoreProperties.getProperty("storeFile") + " was not found.\n")
|
||||
}
|
||||
}
|
||||
if (keystoreProperties.getProperty('debug_storeFile') != null) {
|
||||
if (file(keystoreProperties.getProperty('debug_storeFile')).exists()) {
|
||||
debug {
|
||||
storeFile file(keystoreProperties.getProperty("debug_storeFile"))
|
||||
storePassword keystoreProperties.getProperty("debug_storePassword")
|
||||
keyAlias keystoreProperties.getProperty("debug_seyAlias")
|
||||
keyPassword keystoreProperties.getProperty("debug_keyPassword")
|
||||
}
|
||||
} else {
|
||||
throw new GradleException("Keystore file " + keystoreProperties.getProperty("debug_storeFile") + " was not found.\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (signingConfigs.hasProperty("release")) {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
cFlags "-DNDEBUG", "-DRELEASE", "-Os"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (signingConfigs.hasProperty("debug")) {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
|
||||
sourceSets.main {
|
||||
jniLibs.srcDir 'libs'
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
path 'jni/Android.mk'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
if (buildAsLibrary) {
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith(".aar")) {
|
||||
def fileName = "$applicationId.aar";
|
||||
output.outputFile = new File(outputFile.parent, fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/main/java']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/main/res']
|
||||
}
|
||||
}
|
||||
stable {
|
||||
}
|
||||
experimental {
|
||||
resources {
|
||||
srcDirs = ['src/experimental/res']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(include: ['*.jar'], dir: 'libs')
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Reference: https://developer.android.com/ndk/guides/android_mk.html
|
||||
|
||||
include $(call all-subdir-makefiles)
|
||||
@@ -1,17 +0,0 @@
|
||||
# Reference: https://developer.android.com/ndk/guides/application_mk.html
|
||||
|
||||
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
|
||||
APP_STL := c++_shared
|
||||
APP_CPPFLAGS += -std=c++14
|
||||
ifneq ($(OS),Windows_NT)
|
||||
APP_LDFLAGS += -fuse-ld=gold
|
||||
endif
|
||||
|
||||
# Do not specify APP_OPTIM here, it is done through ndk-build NDK_DEBUG=0/1 setting instead
|
||||
# See https://developer.android.com/ndk/guides/ndk-build.html#dvr
|
||||
#APP_OPTIM := debug
|
||||
#APP_OPTIM := release
|
||||
|
||||
# Min SDK level
|
||||
APP_PLATFORM=android-16
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../src
|
||||
@@ -1,17 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in [sdk]/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:drawable="@color/black"/>
|
||||
|
||||
<item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:src="@drawable/splash"/>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 92 KiB |
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#000000</color>
|
||||
<color name="accent_material_dark">#990026</color>
|
||||
<color name="primary_material_dark">#212121</color>
|
||||
<color name="background_material_dark">#212121</color>
|
||||
</resources>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installing">Installing game data...</string>
|
||||
<string name="upgrading">Upgrading game data...</string>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
|
||||
<item name="android:windowBackground">@drawable/background_splash</item>
|
||||
<item name="android:colorAccent">@color/accent_material_dark</item>
|
||||
<item name="android:colorPrimary">@color/primary_material_dark</item>
|
||||
<item name="android:colorBackground">@color/background_material_dark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Replace com.test.game with the identifier of your game below, e.g.
|
||||
com.gamemaker.game
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cleverraven.cataclysmdda"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
|
||||
An example Java class can be found in README-android.md
|
||||
-->
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:hardwareAccelerated="true"
|
||||
android:isGame="true" >
|
||||
|
||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
||||
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
|
||||
-->
|
||||
|
||||
<activity android:name="SplashScreen"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleInstance"
|
||||
android:keepScreenOn="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="CataclysmDDA"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleInstance"
|
||||
android:keepScreenOn="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
|
||||
>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
Before Width: | Height: | Size: 8.5 KiB |
@@ -1 +0,0 @@
|
||||
../../../../../data
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../gfx
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../lang/mo
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.cleverraven.cataclysmdda;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.content.Context;
|
||||
import android.os.Vibrator;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
public class CataclysmDDA extends SDLActivity {
|
||||
private static final String TAG = "CDDA";
|
||||
|
||||
public void vibrate(int duration) {
|
||||
try {
|
||||
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
|
||||
v.vibrate(duration);
|
||||
} catch(Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void toast(final String message) {
|
||||
try {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} catch(Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHardwareKeyboardAvailable() {
|
||||
return getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
|
||||
}
|
||||
|
||||
private float getDisplayDensity() {
|
||||
return getResources().getDisplayMetrics().density;
|
||||
}
|
||||
|
||||
public void show_sdl_surface() {
|
||||
try {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} catch(Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getDefaultSetting(final String settingsName, boolean defaultValue) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(settingsName, defaultValue);
|
||||
}
|
||||
}
|
||||
@@ -1,340 +0,0 @@
|
||||
package com.cleverraven.cataclysmdda;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.*;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class SplashScreen extends Activity {
|
||||
private static final String TAG = "Splash";
|
||||
private static final int INSTALL_DIALOG_ID = 0;
|
||||
private ProgressDialog installDialog;
|
||||
|
||||
public CharSequence[] mSettingsNames = { "Software rendering", "Force fullscreen", "Trap Back button" };
|
||||
public boolean[] mSettingsValues = { false, false, true };
|
||||
|
||||
private String getVersionName() {
|
||||
try {
|
||||
Context context = getApplicationContext();
|
||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
return pInfo.versionName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.e(TAG, "onCreate()");
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Start the game if already installed, otherwise start installing...
|
||||
if (getVersionName().equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("installed", ""))) {
|
||||
startGameActivity(false);
|
||||
}
|
||||
else {
|
||||
new InstallProgramTask().execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
case INSTALL_DIALOG_ID:
|
||||
installDialog = new ProgressDialog(this);
|
||||
installDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
boolean clean_install = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("installed", "").isEmpty();
|
||||
installDialog.setTitle(getString(clean_install ? R.string.installTitle : R.string.upgradeTitle));
|
||||
installDialog.setIndeterminate(true);
|
||||
installDialog.setCancelable(false);
|
||||
return installDialog;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void startGameActivity(boolean delay) {
|
||||
if (!delay) {
|
||||
runOnUiThread(new StartGameRunnable());
|
||||
}
|
||||
else {
|
||||
// Wait 1.5 seconds, then start game
|
||||
Timer timer = new Timer();
|
||||
TimerTask gameStartTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new StartGameRunnable());
|
||||
}
|
||||
};
|
||||
timer.schedule(gameStartTask, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
private final class StartGameRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(SplashScreen.this, CataclysmDDA.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private class InstallProgramTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
private final List<String> PRESERVE_SUBFOLDERS = Arrays.asList("sound", "mods", "gfx"); // don't delete custom subfolders under these folders
|
||||
private final List<String> PRESERVE_FOLDERS = Arrays.asList("font"); // don't delete this folder
|
||||
private final List<String> PRESERVE_FILES = Arrays.asList("user-default-mods.json"); // don't delete this file
|
||||
|
||||
private int totalFiles = 0;
|
||||
private int installedFiles = 0;
|
||||
|
||||
private AlertDialog installationAlert;
|
||||
private AlertDialog settingsAlert;
|
||||
private AlertDialog helpAlert;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
installationAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle("Installation Failed")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
SplashScreen.this.finish();
|
||||
return;
|
||||
}
|
||||
}).create();
|
||||
AssetManager assetManager = getAssets();
|
||||
try {
|
||||
totalFiles = countTotalAssets(assetManager, "data") +
|
||||
countTotalAssets(assetManager, "gfx") +
|
||||
countTotalAssets(assetManager, "lang");
|
||||
showDialog(INSTALL_DIALOG_ID);
|
||||
} catch(Exception e) {
|
||||
installationAlert.setMessage(e.getMessage());
|
||||
installationAlert.show();
|
||||
}
|
||||
|
||||
helpAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle(getString(R.string.helpTitle))
|
||||
.setCancelable(false)
|
||||
.setMessage(getString(R.string.helpMessage))
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
settingsAlert.show();
|
||||
return;
|
||||
}
|
||||
}).create();
|
||||
|
||||
settingsAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle("Settings")
|
||||
.setMultiChoiceItems(SplashScreen.this.mSettingsNames, SplashScreen.this.mSettingsValues, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
SplashScreen.this.mSettingsValues[which] = isChecked;
|
||||
}})
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Start game", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
for (int i = 0; i < mSettingsNames.length; ++i)
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean(SplashScreen.this.mSettingsNames[i].toString(), SplashScreen.this.mSettingsValues[i]).commit();
|
||||
SplashScreen.this.startGameActivity(false);
|
||||
return;
|
||||
}
|
||||
})
|
||||
.setNeutralButton("Show help", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
helpAlert.show();
|
||||
return;
|
||||
}
|
||||
}).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
if (installDialog != null) {
|
||||
installDialog.setIndeterminate(false);
|
||||
installDialog.setMax(totalFiles);
|
||||
}
|
||||
publishProgress(installedFiles);
|
||||
|
||||
AssetManager assetManager = getAssets();
|
||||
String externalFilesDir = getExternalFilesDir(null).getPath();
|
||||
|
||||
try {
|
||||
// Clear out the old data if it exists (but preserve custom folders + files)
|
||||
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/data"));
|
||||
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/gfx"));
|
||||
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/lang"));
|
||||
|
||||
// Install the new data over the top
|
||||
copyAssetFolder(assetManager, "data", externalFilesDir + "/data");
|
||||
copyAssetFolder(assetManager, "gfx", externalFilesDir + "/gfx");
|
||||
copyAssetFolder(assetManager, "lang", externalFilesDir + "/lang");
|
||||
} catch(Exception e) {
|
||||
installationAlert.setMessage(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember which version the installed data is
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("installed", getVersionName()).commit();
|
||||
|
||||
publishProgress(++installedFiles);
|
||||
Log.d(TAG, "Total number of files copied: " + installedFiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
void deleteRecursive(AssetManager assetManager, String externalFilesDir, File fileOrDirectory) {
|
||||
String parentFolder = fileOrDirectory.getParentFile().getName().toLowerCase();
|
||||
String fileOrDirectoryName = fileOrDirectory.getName().toLowerCase();
|
||||
if (fileOrDirectory.isDirectory()) {
|
||||
// Don't delete the folder if it is in the preserve folders list
|
||||
if (PRESERVE_FOLDERS.contains(fileOrDirectoryName))
|
||||
return;
|
||||
|
||||
// Don't delete the folder if its parent is in the preserve subfolders list, and it doesn't exist in the APK assets (so must be custom data)
|
||||
if (PRESERVE_SUBFOLDERS.contains(parentFolder) && !assetExists(assetManager, fileOrDirectory.getPath().substring(externalFilesDir.length()+1)))
|
||||
return;
|
||||
|
||||
for (File child : fileOrDirectory.listFiles())
|
||||
deleteRecursive(assetManager, externalFilesDir, child);
|
||||
}
|
||||
else {
|
||||
// Don't delete the file if it's in the preserve files list
|
||||
if (PRESERVE_FILES.contains(fileOrDirectoryName))
|
||||
return;
|
||||
}
|
||||
|
||||
fileOrDirectory.delete();
|
||||
}
|
||||
|
||||
// Returns true if an asset exists in the APK (either a directory or a file)
|
||||
// eg. assetExists("data/sound") or assetExists("data/font", "unifont.ttf") would both return true
|
||||
private boolean assetExists(AssetManager assetManager, String assetPath) {
|
||||
return assetExists(assetManager, assetPath, "");
|
||||
}
|
||||
|
||||
private boolean assetExists(AssetManager assetManager, String assetPath, String assetName) {
|
||||
try {
|
||||
String[] files = assetManager.list(assetPath);
|
||||
if (assetName.isEmpty())
|
||||
return files.length > 0; // folder exists
|
||||
for (String file : files) {
|
||||
if (file.equalsIgnoreCase(assetName))
|
||||
return true; // file exists
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int countTotalAssets(AssetManager assetManager, String assetPath) throws Exception {
|
||||
try {
|
||||
String[] files = assetManager.list(assetPath);
|
||||
int count = 0;
|
||||
for (String file : files)
|
||||
{
|
||||
String filePath = assetPath + "/" + file;
|
||||
String subdir_files[] = assetManager.list(filePath);
|
||||
if (subdir_files.length == 0) // file
|
||||
count++;
|
||||
else // folder
|
||||
count += countTotalAssets(assetManager, filePath);
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Pinched from http://stackoverflow.com/questions/16983989/copy-directory-from-assets-to-data-folder
|
||||
private boolean copyAssetFolder(AssetManager assetManager, String fromAssetPath, String toPath) throws Exception {
|
||||
try {
|
||||
String[] files = assetManager.list(fromAssetPath);
|
||||
new File(toPath).mkdirs();
|
||||
boolean res = true;
|
||||
for (String file : files)
|
||||
{
|
||||
String subdir_files[] = assetManager.list(fromAssetPath + "/" + file);
|
||||
if (subdir_files.length == 0) // file
|
||||
res &= copyAsset(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
|
||||
else // folder
|
||||
res &= copyAssetFolder(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
|
||||
}
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath) throws Exception {
|
||||
publishProgress(++installedFiles, totalFiles);
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
in = assetManager.open(fromAssetPath);
|
||||
new File(toPath).createNewFile();
|
||||
out = new FileOutputStream(toPath);
|
||||
copyFile(in, out);
|
||||
in.close();
|
||||
in = null;
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void copyFile(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
int read;
|
||||
while((read = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Integer... values) {
|
||||
if (installDialog == null) {
|
||||
return;
|
||||
}
|
||||
installDialog.setProgress(values[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
removeDialog(INSTALL_DIALOG_ID);
|
||||
if(result) {
|
||||
settingsAlert.show();
|
||||
} else {
|
||||
installationAlert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
interface HIDDevice
|
||||
{
|
||||
public int getId();
|
||||
public int getVendorId();
|
||||
public int getProductId();
|
||||
public String getSerialNumber();
|
||||
public int getVersion();
|
||||
public String getManufacturerName();
|
||||
public String getProductName();
|
||||
public boolean open();
|
||||
public int sendFeatureReport(byte[] report);
|
||||
public int sendOutputReport(byte[] report);
|
||||
public boolean getFeatureReport(byte[] report);
|
||||
public void setFrozen(boolean frozen);
|
||||
public void close();
|
||||
public void shutdown();
|
||||
}
|
||||
@@ -1,644 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCallback;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattDescriptor;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.os.*;
|
||||
|
||||
//import com.android.internal.util.HexDump;
|
||||
|
||||
import java.lang.Runnable;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDevice {
|
||||
|
||||
private static final String TAG = "hidapi";
|
||||
private HIDDeviceManager mManager;
|
||||
private BluetoothDevice mDevice;
|
||||
private int mDeviceId;
|
||||
private BluetoothGatt mGatt;
|
||||
private boolean mIsRegistered = false;
|
||||
private boolean mIsConnected = false;
|
||||
private boolean mIsChromebook = false;
|
||||
private boolean mIsReconnecting = false;
|
||||
private boolean mFrozen = false;
|
||||
private LinkedList<GattOperation> mOperations;
|
||||
GattOperation mCurrentOperation = null;
|
||||
private Handler mHandler;
|
||||
|
||||
private static final int TRANSPORT_AUTO = 0;
|
||||
private static final int TRANSPORT_BREDR = 1;
|
||||
private static final int TRANSPORT_LE = 2;
|
||||
|
||||
private static final int CHROMEBOOK_CONNECTION_CHECK_INTERVAL = 10000;
|
||||
|
||||
static public final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3");
|
||||
static public final UUID inputCharacteristic = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3");
|
||||
static public final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3");
|
||||
static private final byte[] enterValveMode = new byte[] { (byte)0xC0, (byte)0x87, 0x03, 0x08, 0x07, 0x00 };
|
||||
|
||||
static class GattOperation {
|
||||
private enum Operation {
|
||||
CHR_READ,
|
||||
CHR_WRITE,
|
||||
ENABLE_NOTIFICATION
|
||||
}
|
||||
|
||||
Operation mOp;
|
||||
UUID mUuid;
|
||||
byte[] mValue;
|
||||
BluetoothGatt mGatt;
|
||||
boolean mResult = true;
|
||||
|
||||
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid) {
|
||||
mGatt = gatt;
|
||||
mOp = operation;
|
||||
mUuid = uuid;
|
||||
}
|
||||
|
||||
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value) {
|
||||
mGatt = gatt;
|
||||
mOp = operation;
|
||||
mUuid = uuid;
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// This is executed in main thread
|
||||
BluetoothGattCharacteristic chr;
|
||||
|
||||
switch (mOp) {
|
||||
case CHR_READ:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Reading characteristic " + chr.getUuid());
|
||||
if (!mGatt.readCharacteristic(chr)) {
|
||||
Log.e(TAG, "Unable to read characteristic " + mUuid.toString());
|
||||
mResult = false;
|
||||
break;
|
||||
}
|
||||
mResult = true;
|
||||
break;
|
||||
case CHR_WRITE:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Writing characteristic " + chr.getUuid() + " value=" + HexDump.toHexString(value));
|
||||
chr.setValue(mValue);
|
||||
if (!mGatt.writeCharacteristic(chr)) {
|
||||
Log.e(TAG, "Unable to write characteristic " + mUuid.toString());
|
||||
mResult = false;
|
||||
break;
|
||||
}
|
||||
mResult = true;
|
||||
break;
|
||||
case ENABLE_NOTIFICATION:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Writing descriptor of " + chr.getUuid());
|
||||
if (chr != null) {
|
||||
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
|
||||
if (cccd != null) {
|
||||
int properties = chr.getProperties();
|
||||
byte[] value;
|
||||
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) {
|
||||
value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE;
|
||||
} else if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) {
|
||||
value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE;
|
||||
} else {
|
||||
Log.e(TAG, "Unable to start notifications on input characteristic");
|
||||
mResult = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mGatt.setCharacteristicNotification(chr, true);
|
||||
cccd.setValue(value);
|
||||
if (!mGatt.writeDescriptor(cccd)) {
|
||||
Log.e(TAG, "Unable to write descriptor " + mUuid.toString());
|
||||
mResult = false;
|
||||
return;
|
||||
}
|
||||
mResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean finish() {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
|
||||
BluetoothGattService valveService = mGatt.getService(steamControllerService);
|
||||
if (valveService == null)
|
||||
return null;
|
||||
return valveService.getCharacteristic(uuid);
|
||||
}
|
||||
|
||||
static public GattOperation readCharacteristic(BluetoothGatt gatt, UUID uuid) {
|
||||
return new GattOperation(gatt, Operation.CHR_READ, uuid);
|
||||
}
|
||||
|
||||
static public GattOperation writeCharacteristic(BluetoothGatt gatt, UUID uuid, byte[] value) {
|
||||
return new GattOperation(gatt, Operation.CHR_WRITE, uuid, value);
|
||||
}
|
||||
|
||||
static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid) {
|
||||
return new GattOperation(gatt, Operation.ENABLE_NOTIFICATION, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) {
|
||||
mManager = manager;
|
||||
mDevice = device;
|
||||
mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
|
||||
mIsRegistered = false;
|
||||
mIsChromebook = mManager.getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
|
||||
mOperations = new LinkedList<GattOperation>();
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mGatt = connectGatt();
|
||||
final HIDDeviceBLESteamController finalThis = this;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalThis.checkConnectionForChromebookIssue();
|
||||
}
|
||||
}, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return String.format("SteamController.%s", mDevice.getAddress());
|
||||
}
|
||||
|
||||
public BluetoothGatt getGatt() {
|
||||
return mGatt;
|
||||
}
|
||||
|
||||
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
|
||||
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
|
||||
private BluetoothGatt connectGatt(boolean managed) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
try {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
|
||||
} catch (Exception e) {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this);
|
||||
}
|
||||
} else {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this);
|
||||
}
|
||||
}
|
||||
|
||||
private BluetoothGatt connectGatt() {
|
||||
return connectGatt(false);
|
||||
}
|
||||
|
||||
protected int getConnectionState() {
|
||||
|
||||
Context context = mManager.getContext();
|
||||
if (context == null) {
|
||||
// We are lacking any context to get our Bluetooth information. We'll just assume disconnected.
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
BluetoothManager btManager = (BluetoothManager)context.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
if (btManager == null) {
|
||||
// This device doesn't support Bluetooth. We should never be here, because how did
|
||||
// we instantiate a device to start with?
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
return btManager.getConnectionState(mDevice, BluetoothProfile.GATT);
|
||||
}
|
||||
|
||||
public void reconnect() {
|
||||
|
||||
if (getConnectionState() != BluetoothProfile.STATE_CONNECTED) {
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void checkConnectionForChromebookIssue() {
|
||||
if (!mIsChromebook) {
|
||||
// We only do this on Chromebooks, because otherwise it's really annoying to just attempt
|
||||
// over and over.
|
||||
return;
|
||||
}
|
||||
|
||||
int connectionState = getConnectionState();
|
||||
|
||||
switch (connectionState) {
|
||||
case BluetoothProfile.STATE_CONNECTED:
|
||||
if (!mIsConnected) {
|
||||
// We are in the Bad Chromebook Place. We can force a disconnect
|
||||
// to try to recover.
|
||||
Log.v(TAG, "Chromebook: We are in a very bad state; the controller shows as connected in the underlying Bluetooth layer, but we never received a callback. Forcing a reconnect.");
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
}
|
||||
else if (!isRegistered()) {
|
||||
if (mGatt.getServices().size() > 0) {
|
||||
Log.v(TAG, "Chromebook: We are connected to a controller, but never got our registration. Trying to recover.");
|
||||
probeService(this);
|
||||
}
|
||||
else {
|
||||
Log.v(TAG, "Chromebook: We are connected to a controller, but never discovered services. Trying to recover.");
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.v(TAG, "Chromebook: We are connected, and registered. Everything's good!");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case BluetoothProfile.STATE_DISCONNECTED:
|
||||
Log.v(TAG, "Chromebook: We have either been disconnected, or the Chromebook BtGatt.ContextMap bug has bitten us. Attempting a disconnect/reconnect, but we may not be able to recover.");
|
||||
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
|
||||
case BluetoothProfile.STATE_CONNECTING:
|
||||
Log.v(TAG, "Chromebook: We're still trying to connect. Waiting a bit longer.");
|
||||
break;
|
||||
}
|
||||
|
||||
final HIDDeviceBLESteamController finalThis = this;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalThis.checkConnectionForChromebookIssue();
|
||||
}
|
||||
}, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
private boolean isRegistered() {
|
||||
return mIsRegistered;
|
||||
}
|
||||
|
||||
private void setRegistered() {
|
||||
mIsRegistered = true;
|
||||
}
|
||||
|
||||
private boolean probeService(HIDDeviceBLESteamController controller) {
|
||||
|
||||
if (isRegistered()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mIsConnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.v(TAG, "probeService controller=" + controller);
|
||||
|
||||
for (BluetoothGattService service : mGatt.getServices()) {
|
||||
if (service.getUuid().equals(steamControllerService)) {
|
||||
Log.v(TAG, "Found Valve steam controller service " + service.getUuid());
|
||||
|
||||
for (BluetoothGattCharacteristic chr : service.getCharacteristics()) {
|
||||
if (chr.getUuid().equals(inputCharacteristic)) {
|
||||
Log.v(TAG, "Found input characteristic");
|
||||
// Start notifications
|
||||
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
|
||||
if (cccd != null) {
|
||||
enableNotification(chr.getUuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mGatt.getServices().size() == 0) && mIsChromebook && !mIsReconnecting) {
|
||||
Log.e(TAG, "Chromebook: Discovered services were empty; this almost certainly means the BtGatt.ContextMap bug has bitten us.");
|
||||
mIsConnected = false;
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void finishCurrentGattOperation() {
|
||||
GattOperation op = null;
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation != null) {
|
||||
op = mCurrentOperation;
|
||||
mCurrentOperation = null;
|
||||
}
|
||||
}
|
||||
if (op != null) {
|
||||
boolean result = op.finish(); // TODO: Maybe in main thread as well?
|
||||
|
||||
// Our operation failed, let's add it back to the beginning of our queue.
|
||||
if (!result) {
|
||||
mOperations.addFirst(op);
|
||||
}
|
||||
}
|
||||
executeNextGattOperation();
|
||||
}
|
||||
|
||||
private void executeNextGattOperation() {
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation != null)
|
||||
return;
|
||||
|
||||
if (mOperations.isEmpty())
|
||||
return;
|
||||
|
||||
mCurrentOperation = mOperations.removeFirst();
|
||||
}
|
||||
|
||||
// Run in main thread
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation == null) {
|
||||
Log.e(TAG, "Current operation null in executor?");
|
||||
return;
|
||||
}
|
||||
|
||||
mCurrentOperation.run();
|
||||
// now wait for the GATT callback and when it comes, finish this operation
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void queueGattOperation(GattOperation op) {
|
||||
synchronized (mOperations) {
|
||||
mOperations.add(op);
|
||||
}
|
||||
executeNextGattOperation();
|
||||
}
|
||||
|
||||
private void enableNotification(UUID chrUuid) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.enableNotification(mGatt, chrUuid);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
public void writeCharacteristic(UUID uuid, byte[] value) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.writeCharacteristic(mGatt, uuid, value);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
public void readCharacteristic(UUID uuid) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.readCharacteristic(mGatt, uuid);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////// BluetoothGattCallback overridden methods
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onConnectionStateChange(BluetoothGatt g, int status, int newState) {
|
||||
//Log.v(TAG, "onConnectionStateChange status=" + status + " newState=" + newState);
|
||||
mIsReconnecting = false;
|
||||
if (newState == 2) {
|
||||
mIsConnected = true;
|
||||
// Run directly, without GattOperation
|
||||
if (!isRegistered()) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGatt.discoverServices();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (newState == 0) {
|
||||
mIsConnected = false;
|
||||
}
|
||||
|
||||
// Disconnection is handled in SteamLink using the ACTION_ACL_DISCONNECTED Intent.
|
||||
}
|
||||
|
||||
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
|
||||
//Log.v(TAG, "onServicesDiscovered status=" + status);
|
||||
if (status == 0) {
|
||||
if (gatt.getServices().size() == 0) {
|
||||
Log.v(TAG, "onServicesDiscovered returned zero services; something has gone horribly wrong down in Android's Bluetooth stack.");
|
||||
mIsReconnecting = true;
|
||||
mIsConnected = false;
|
||||
gatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
}
|
||||
else {
|
||||
probeService(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
//Log.v(TAG, "onCharacteristicRead status=" + status + " uuid=" + characteristic.getUuid());
|
||||
|
||||
if (characteristic.getUuid().equals(reportCharacteristic) && !mFrozen) {
|
||||
mManager.HIDDeviceFeatureReport(getId(), characteristic.getValue());
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
//Log.v(TAG, "onCharacteristicWrite status=" + status + " uuid=" + characteristic.getUuid());
|
||||
|
||||
if (characteristic.getUuid().equals(reportCharacteristic)) {
|
||||
// Only register controller with the native side once it has been fully configured
|
||||
if (!isRegistered()) {
|
||||
Log.v(TAG, "Registering Steam Controller with ID: " + getId());
|
||||
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0);
|
||||
setRegistered();
|
||||
}
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||
// Enable this for verbose logging of controller input reports
|
||||
//Log.v(TAG, "onCharacteristicChanged uuid=" + characteristic.getUuid() + " data=" + HexDump.dumpHexString(characteristic.getValue()));
|
||||
|
||||
if (characteristic.getUuid().equals(inputCharacteristic) && !mFrozen) {
|
||||
mManager.HIDDeviceInputReport(getId(), characteristic.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
|
||||
//Log.v(TAG, "onDescriptorRead status=" + status);
|
||||
}
|
||||
|
||||
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
|
||||
BluetoothGattCharacteristic chr = descriptor.getCharacteristic();
|
||||
//Log.v(TAG, "onDescriptorWrite status=" + status + " uuid=" + chr.getUuid() + " descriptor=" + descriptor.getUuid());
|
||||
|
||||
if (chr.getUuid().equals(inputCharacteristic)) {
|
||||
boolean hasWrittenInputDescriptor = true;
|
||||
BluetoothGattCharacteristic reportChr = chr.getService().getCharacteristic(reportCharacteristic);
|
||||
if (reportChr != null) {
|
||||
Log.v(TAG, "Writing report characteristic to enter valve mode");
|
||||
reportChr.setValue(enterValveMode);
|
||||
gatt.writeCharacteristic(reportChr);
|
||||
}
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
|
||||
//Log.v(TAG, "onReliableWriteCompleted status=" + status);
|
||||
}
|
||||
|
||||
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
|
||||
//Log.v(TAG, "onReadRemoteRssi status=" + status);
|
||||
}
|
||||
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
//Log.v(TAG, "onMtuChanged status=" + status);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////// Public API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return mDeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId() {
|
||||
// Valve Corporation
|
||||
final int VALVE_USB_VID = 0x28DE;
|
||||
return VALVE_USB_VID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProductId() {
|
||||
// We don't have an easy way to query from the Bluetooth device, but we know what it is
|
||||
final int D0G_BLE2_PID = 0x1106;
|
||||
return D0G_BLE2_PID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerialNumber() {
|
||||
// This will be read later via feature report by Steam
|
||||
return "12345";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturerName() {
|
||||
return "Valve Corporation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductName() {
|
||||
return "Steam Controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendFeatureReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted sendFeatureReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We need to skip the first byte, as that doesn't go over the air
|
||||
byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1);
|
||||
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(actual_report));
|
||||
writeCharacteristic(reportCharacteristic, actual_report);
|
||||
return report.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendOutputReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted sendOutputReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(report));
|
||||
writeCharacteristic(reportCharacteristic, report);
|
||||
return report.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeatureReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted getFeatureReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.v(TAG, "getFeatureReport");
|
||||
readCharacteristic(reportCharacteristic);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrozen(boolean frozen) {
|
||||
mFrozen = frozen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
close();
|
||||
|
||||
BluetoothGatt g = mGatt;
|
||||
if (g != null) {
|
||||
g.disconnect();
|
||||
g.close();
|
||||
mGatt = null;
|
||||
}
|
||||
mManager = null;
|
||||
mIsRegistered = false;
|
||||
mIsConnected = false;
|
||||
mOperations.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,682 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.util.Log;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.usb.*;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HIDDeviceManager {
|
||||
private static final String TAG = "hidapi";
|
||||
private static final String ACTION_USB_PERMISSION = "org.libsdl.app.USB_PERMISSION";
|
||||
|
||||
private static HIDDeviceManager sManager;
|
||||
private static int sManagerRefCount = 0;
|
||||
|
||||
public static HIDDeviceManager acquire(Context context) {
|
||||
if (sManagerRefCount == 0) {
|
||||
sManager = new HIDDeviceManager(context);
|
||||
}
|
||||
++sManagerRefCount;
|
||||
return sManager;
|
||||
}
|
||||
|
||||
public static void release(HIDDeviceManager manager) {
|
||||
if (manager == sManager) {
|
||||
--sManagerRefCount;
|
||||
if (sManagerRefCount == 0) {
|
||||
sManager.close();
|
||||
sManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private HashMap<Integer, HIDDevice> mDevicesById = new HashMap<Integer, HIDDevice>();
|
||||
private HashMap<UsbDevice, HIDDeviceUSB> mUSBDevices = new HashMap<UsbDevice, HIDDeviceUSB>();
|
||||
private HashMap<BluetoothDevice, HIDDeviceBLESteamController> mBluetoothDevices = new HashMap<BluetoothDevice, HIDDeviceBLESteamController>();
|
||||
private int mNextDeviceId = 0;
|
||||
private SharedPreferences mSharedPreferences = null;
|
||||
private boolean mIsChromebook = false;
|
||||
private UsbManager mUsbManager;
|
||||
private Handler mHandler;
|
||||
private BluetoothManager mBluetoothManager;
|
||||
private List<BluetoothDevice> mLastBluetoothDevices;
|
||||
|
||||
private final BroadcastReceiver mUsbBroadcast = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
|
||||
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||
handleUsbDeviceAttached(usbDevice);
|
||||
} else if (action.equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) {
|
||||
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||
handleUsbDeviceDetached(usbDevice);
|
||||
} else if (action.equals(HIDDeviceManager.ACTION_USB_PERMISSION)) {
|
||||
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||
handleUsbDevicePermission(usbDevice, intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver mBluetoothBroadcast = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
// Bluetooth device was connected. If it was a Steam Controller, handle it
|
||||
if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
Log.d(TAG, "Bluetooth device connected: " + device);
|
||||
|
||||
if (isSteamController(device)) {
|
||||
connectBluetoothDevice(device);
|
||||
}
|
||||
}
|
||||
|
||||
// Bluetooth device was disconnected, remove from controller manager (if any)
|
||||
if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
Log.d(TAG, "Bluetooth device disconnected: " + device);
|
||||
|
||||
disconnectBluetoothDevice(device);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private HIDDeviceManager(final Context context) {
|
||||
mContext = context;
|
||||
|
||||
// Make sure we have the HIDAPI library loaded with the native functions
|
||||
try {
|
||||
SDL.loadLibrary("hidapi");
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, "Couldn't load hidapi: " + e.toString());
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setCancelable(false);
|
||||
builder.setTitle("SDL HIDAPI Error");
|
||||
builder.setMessage("Please report the following error to the SDL maintainers: " + e.getMessage());
|
||||
builder.setNegativeButton("Quit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
// If our context is an activity, exit rather than crashing when we can't
|
||||
// call our native functions.
|
||||
Activity activity = (Activity)context;
|
||||
|
||||
activity.finish();
|
||||
}
|
||||
catch (ClassCastException cce) {
|
||||
// Context wasn't an activity, there's nothing we can do. Give up and return.
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HIDDeviceRegisterCallback();
|
||||
|
||||
mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
|
||||
mIsChromebook = mContext.getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
|
||||
|
||||
// if (shouldClear) {
|
||||
// SharedPreferences.Editor spedit = mSharedPreferences.edit();
|
||||
// spedit.clear();
|
||||
// spedit.commit();
|
||||
// }
|
||||
// else
|
||||
{
|
||||
mNextDeviceId = mSharedPreferences.getInt("next_device_id", 0);
|
||||
}
|
||||
|
||||
initializeUSB();
|
||||
initializeBluetooth();
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public int getDeviceIDForIdentifier(String identifier) {
|
||||
SharedPreferences.Editor spedit = mSharedPreferences.edit();
|
||||
|
||||
int result = mSharedPreferences.getInt(identifier, 0);
|
||||
if (result == 0) {
|
||||
result = mNextDeviceId++;
|
||||
spedit.putInt("next_device_id", mNextDeviceId);
|
||||
}
|
||||
|
||||
spedit.putInt(identifier, result);
|
||||
spedit.commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void initializeUSB() {
|
||||
mUsbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
|
||||
|
||||
/*
|
||||
// Logging
|
||||
for (UsbDevice device : mUsbManager.getDeviceList().values()) {
|
||||
Log.i(TAG,"Path: " + device.getDeviceName());
|
||||
Log.i(TAG,"Manufacturer: " + device.getManufacturerName());
|
||||
Log.i(TAG,"Product: " + device.getProductName());
|
||||
Log.i(TAG,"ID: " + device.getDeviceId());
|
||||
Log.i(TAG,"Class: " + device.getDeviceClass());
|
||||
Log.i(TAG,"Protocol: " + device.getDeviceProtocol());
|
||||
Log.i(TAG,"Vendor ID " + device.getVendorId());
|
||||
Log.i(TAG,"Product ID: " + device.getProductId());
|
||||
Log.i(TAG,"Interface count: " + device.getInterfaceCount());
|
||||
Log.i(TAG,"---------------------------------------");
|
||||
|
||||
// Get interface details
|
||||
for (int index = 0; index < device.getInterfaceCount(); index++) {
|
||||
UsbInterface mUsbInterface = device.getInterface(index);
|
||||
Log.i(TAG," ***** *****");
|
||||
Log.i(TAG," Interface index: " + index);
|
||||
Log.i(TAG," Interface ID: " + mUsbInterface.getId());
|
||||
Log.i(TAG," Interface class: " + mUsbInterface.getInterfaceClass());
|
||||
Log.i(TAG," Interface subclass: " + mUsbInterface.getInterfaceSubclass());
|
||||
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
|
||||
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
|
||||
|
||||
// Get endpoint details
|
||||
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
|
||||
{
|
||||
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
|
||||
Log.i(TAG," ++++ ++++ ++++");
|
||||
Log.i(TAG," Endpoint index: " + epi);
|
||||
Log.i(TAG," Attributes: " + mEndpoint.getAttributes());
|
||||
Log.i(TAG," Direction: " + mEndpoint.getDirection());
|
||||
Log.i(TAG," Number: " + mEndpoint.getEndpointNumber());
|
||||
Log.i(TAG," Interval: " + mEndpoint.getInterval());
|
||||
Log.i(TAG," Packet size: " + mEndpoint.getMaxPacketSize());
|
||||
Log.i(TAG," Type: " + mEndpoint.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.i(TAG," No more devices connected.");
|
||||
*/
|
||||
|
||||
// Register for USB broadcasts and permission completions
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
|
||||
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
|
||||
filter.addAction(HIDDeviceManager.ACTION_USB_PERMISSION);
|
||||
mContext.registerReceiver(mUsbBroadcast, filter);
|
||||
|
||||
for (UsbDevice usbDevice : mUsbManager.getDeviceList().values()) {
|
||||
handleUsbDeviceAttached(usbDevice);
|
||||
}
|
||||
}
|
||||
|
||||
UsbManager getUSBManager() {
|
||||
return mUsbManager;
|
||||
}
|
||||
|
||||
private void shutdownUSB() {
|
||||
try {
|
||||
mContext.unregisterReceiver(mUsbBroadcast);
|
||||
} catch (Exception e) {
|
||||
// We may not have registered, that's okay
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHIDDeviceUSB(UsbDevice usbDevice) {
|
||||
for (int interface_number = 0; interface_number < usbDevice.getInterfaceCount(); ++interface_number) {
|
||||
if (isHIDDeviceInterface(usbDevice, interface_number)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isHIDDeviceInterface(UsbDevice usbDevice, int interface_number) {
|
||||
UsbInterface usbInterface = usbDevice.getInterface(interface_number);
|
||||
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_HID) {
|
||||
return true;
|
||||
}
|
||||
if (interface_number == 0) {
|
||||
if (isXbox360Controller(usbDevice, usbInterface) || isXboxOneController(usbDevice, usbInterface)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) {
|
||||
final int XB360_IFACE_SUBCLASS = 93;
|
||||
final int XB360_IFACE_PROTOCOL = 1; // Wired only
|
||||
final int[] SUPPORTED_VENDORS = {
|
||||
0x0079, // GPD Win 2
|
||||
0x044f, // Thrustmaster
|
||||
0x045e, // Microsoft
|
||||
0x046d, // Logitech
|
||||
0x056e, // Elecom
|
||||
0x06a3, // Saitek
|
||||
0x0738, // Mad Catz
|
||||
0x07ff, // Mad Catz
|
||||
0x0e6f, // Unknown
|
||||
0x0f0d, // Hori
|
||||
0x11c9, // Nacon
|
||||
0x12ab, // Unknown
|
||||
0x1430, // RedOctane
|
||||
0x146b, // BigBen
|
||||
0x1532, // Razer Sabertooth
|
||||
0x15e4, // Numark
|
||||
0x162e, // Joytech
|
||||
0x1689, // Razer Onza
|
||||
0x1bad, // Harmonix
|
||||
0x24c6, // PowerA
|
||||
};
|
||||
|
||||
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
|
||||
usbInterface.getInterfaceSubclass() == XB360_IFACE_SUBCLASS &&
|
||||
usbInterface.getInterfaceProtocol() == XB360_IFACE_PROTOCOL) {
|
||||
int vendor_id = usbDevice.getVendorId();
|
||||
for (int supportedVid : SUPPORTED_VENDORS) {
|
||||
if (vendor_id == supportedVid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterface) {
|
||||
final int XB1_IFACE_SUBCLASS = 71;
|
||||
final int XB1_IFACE_PROTOCOL = 208;
|
||||
final int[] SUPPORTED_VENDORS = {
|
||||
0x045e, // Microsoft
|
||||
0x0738, // Mad Catz
|
||||
0x0e6f, // Unknown
|
||||
0x0f0d, // Hori
|
||||
0x1532, // Razer Wildcat
|
||||
0x24c6, // PowerA
|
||||
};
|
||||
|
||||
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
|
||||
usbInterface.getInterfaceSubclass() == XB1_IFACE_SUBCLASS &&
|
||||
usbInterface.getInterfaceProtocol() == XB1_IFACE_PROTOCOL) {
|
||||
int vendor_id = usbDevice.getVendorId();
|
||||
for (int supportedVid : SUPPORTED_VENDORS) {
|
||||
if (vendor_id == supportedVid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleUsbDeviceAttached(UsbDevice usbDevice) {
|
||||
if (isHIDDeviceUSB(usbDevice)) {
|
||||
connectHIDDeviceUSB(usbDevice);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUsbDeviceDetached(UsbDevice usbDevice) {
|
||||
HIDDeviceUSB device = mUSBDevices.get(usbDevice);
|
||||
if (device == null)
|
||||
return;
|
||||
|
||||
int id = device.getId();
|
||||
mUSBDevices.remove(usbDevice);
|
||||
mDevicesById.remove(id);
|
||||
device.shutdown();
|
||||
HIDDeviceDisconnected(id);
|
||||
}
|
||||
|
||||
private void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) {
|
||||
HIDDeviceUSB device = mUSBDevices.get(usbDevice);
|
||||
if (device == null)
|
||||
return;
|
||||
|
||||
boolean opened = false;
|
||||
if (permission_granted) {
|
||||
opened = device.open();
|
||||
}
|
||||
HIDDeviceOpenResult(device.getId(), opened);
|
||||
}
|
||||
|
||||
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
|
||||
synchronized (this) {
|
||||
for (int interface_number = 0; interface_number < usbDevice.getInterfaceCount(); interface_number++) {
|
||||
if (isHIDDeviceInterface(usbDevice, interface_number)) {
|
||||
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_number);
|
||||
int id = device.getId();
|
||||
mUSBDevices.put(usbDevice, device);
|
||||
mDevicesById.put(id, device);
|
||||
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), interface_number);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeBluetooth() {
|
||||
Log.d(TAG, "Initializing Bluetooth");
|
||||
|
||||
if (mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
||||
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
|
||||
return;
|
||||
}
|
||||
|
||||
// Find bonded bluetooth controllers and create SteamControllers for them
|
||||
mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
if (mBluetoothManager == null) {
|
||||
// This device doesn't support Bluetooth.
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothAdapter btAdapter = mBluetoothManager.getAdapter();
|
||||
if (btAdapter == null) {
|
||||
// This device has Bluetooth support in the codebase, but has no available adapters.
|
||||
return;
|
||||
}
|
||||
|
||||
// Get our bonded devices.
|
||||
for (BluetoothDevice device : btAdapter.getBondedDevices()) {
|
||||
|
||||
Log.d(TAG, "Bluetooth device available: " + device);
|
||||
if (isSteamController(device)) {
|
||||
connectBluetoothDevice(device);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// NOTE: These don't work on Chromebooks, to my undying dismay.
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||
mContext.registerReceiver(mBluetoothBroadcast, filter);
|
||||
|
||||
if (mIsChromebook) {
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
mLastBluetoothDevices = new ArrayList<BluetoothDevice>();
|
||||
|
||||
// final HIDDeviceManager finalThis = this;
|
||||
// mHandler.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// finalThis.chromebookConnectionHandler();
|
||||
// }
|
||||
// }, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
private void shutdownBluetooth() {
|
||||
try {
|
||||
mContext.unregisterReceiver(mBluetoothBroadcast);
|
||||
} catch (Exception e) {
|
||||
// We may not have registered, that's okay
|
||||
}
|
||||
}
|
||||
|
||||
// Chromebooks do not pass along ACTION_ACL_CONNECTED / ACTION_ACL_DISCONNECTED properly.
|
||||
// This function provides a sort of dummy version of that, watching for changes in the
|
||||
// connected devices and attempting to add controllers as things change.
|
||||
public void chromebookConnectionHandler() {
|
||||
if (!mIsChromebook) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<BluetoothDevice> disconnected = new ArrayList<BluetoothDevice>();
|
||||
ArrayList<BluetoothDevice> connected = new ArrayList<BluetoothDevice>();
|
||||
|
||||
List<BluetoothDevice> currentConnected = mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT);
|
||||
|
||||
for (BluetoothDevice bluetoothDevice : currentConnected) {
|
||||
if (!mLastBluetoothDevices.contains(bluetoothDevice)) {
|
||||
connected.add(bluetoothDevice);
|
||||
}
|
||||
}
|
||||
for (BluetoothDevice bluetoothDevice : mLastBluetoothDevices) {
|
||||
if (!currentConnected.contains(bluetoothDevice)) {
|
||||
disconnected.add(bluetoothDevice);
|
||||
}
|
||||
}
|
||||
|
||||
mLastBluetoothDevices = currentConnected;
|
||||
|
||||
for (BluetoothDevice bluetoothDevice : disconnected) {
|
||||
disconnectBluetoothDevice(bluetoothDevice);
|
||||
}
|
||||
for (BluetoothDevice bluetoothDevice : connected) {
|
||||
connectBluetoothDevice(bluetoothDevice);
|
||||
}
|
||||
|
||||
final HIDDeviceManager finalThis = this;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalThis.chromebookConnectionHandler();
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
public boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) {
|
||||
Log.v(TAG, "connectBluetoothDevice device=" + bluetoothDevice);
|
||||
synchronized (this) {
|
||||
if (mBluetoothDevices.containsKey(bluetoothDevice)) {
|
||||
Log.v(TAG, "Steam controller with address " + bluetoothDevice + " already exists, attempting reconnect");
|
||||
|
||||
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
|
||||
device.reconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
HIDDeviceBLESteamController device = new HIDDeviceBLESteamController(this, bluetoothDevice);
|
||||
int id = device.getId();
|
||||
mBluetoothDevices.put(bluetoothDevice, device);
|
||||
mDevicesById.put(id, device);
|
||||
|
||||
// The Steam Controller will mark itself connected once initialization is complete
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) {
|
||||
synchronized (this) {
|
||||
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
|
||||
if (device == null)
|
||||
return;
|
||||
|
||||
int id = device.getId();
|
||||
mBluetoothDevices.remove(bluetoothDevice);
|
||||
mDevicesById.remove(id);
|
||||
device.shutdown();
|
||||
HIDDeviceDisconnected(id);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSteamController(BluetoothDevice bluetoothDevice) {
|
||||
// Sanity check. If you pass in a null device, by definition it is never a Steam Controller.
|
||||
if (bluetoothDevice == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the device has no local name, we really don't want to try an equality check against it.
|
||||
if (bluetoothDevice.getName() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return bluetoothDevice.getName().equals("SteamController") && ((bluetoothDevice.getType() & BluetoothDevice.DEVICE_TYPE_LE) != 0);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
shutdownUSB();
|
||||
shutdownBluetooth();
|
||||
synchronized (this) {
|
||||
for (HIDDevice device : mDevicesById.values()) {
|
||||
device.shutdown();
|
||||
}
|
||||
mDevicesById.clear();
|
||||
mBluetoothDevices.clear();
|
||||
HIDDeviceReleaseCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFrozen(boolean frozen) {
|
||||
synchronized (this) {
|
||||
for (HIDDevice device : mDevicesById.values()) {
|
||||
device.setFrozen(frozen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private HIDDevice getDevice(int id) {
|
||||
synchronized (this) {
|
||||
HIDDevice result = mDevicesById.get(id);
|
||||
if (result == null) {
|
||||
Log.v(TAG, "No device for id: " + id);
|
||||
Log.v(TAG, "Available devices: " + mDevicesById.keySet());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////// JNI interface functions
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public boolean openDevice(int deviceID) {
|
||||
// Look to see if this is a USB device and we have permission to access it
|
||||
for (HIDDeviceUSB device : mUSBDevices.values()) {
|
||||
if (deviceID == device.getId()) {
|
||||
UsbDevice usbDevice = device.getDevice();
|
||||
if (!mUsbManager.hasPermission(usbDevice)) {
|
||||
HIDDeviceOpenPending(deviceID);
|
||||
try {
|
||||
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), 0));
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
|
||||
HIDDeviceOpenResult(deviceID, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Log.v(TAG, "openDevice deviceID=" + deviceID);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device.open();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int sendOutputReport(int deviceID, byte[] report) {
|
||||
try {
|
||||
Log.v(TAG, "sendOutputReport deviceID=" + deviceID + " length=" + report.length);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return device.sendOutputReport(report);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int sendFeatureReport(int deviceID, byte[] report) {
|
||||
try {
|
||||
Log.v(TAG, "sendFeatureReport deviceID=" + deviceID + " length=" + report.length);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return device.sendFeatureReport(report);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean getFeatureReport(int deviceID, byte[] report) {
|
||||
try {
|
||||
Log.v(TAG, "getFeatureReport deviceID=" + deviceID);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device.getFeatureReport(report);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void closeDevice(int deviceID) {
|
||||
try {
|
||||
Log.v(TAG, "closeDevice deviceID=" + deviceID);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return;
|
||||
}
|
||||
|
||||
device.close();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////// Native methods
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private native void HIDDeviceRegisterCallback();
|
||||
private native void HIDDeviceReleaseCallback();
|
||||
|
||||
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number);
|
||||
native void HIDDeviceOpenPending(int deviceID);
|
||||
native void HIDDeviceOpenResult(int deviceID, boolean opened);
|
||||
native void HIDDeviceDisconnected(int deviceID);
|
||||
|
||||
native void HIDDeviceInputReport(int deviceID, byte[] report);
|
||||
native void HIDDeviceFeatureReport(int deviceID, byte[] report);
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.hardware.usb.*;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import java.util.Arrays;
|
||||
|
||||
class HIDDeviceUSB implements HIDDevice {
|
||||
|
||||
private static final String TAG = "hidapi";
|
||||
|
||||
protected HIDDeviceManager mManager;
|
||||
protected UsbDevice mDevice;
|
||||
protected int mInterface;
|
||||
protected int mDeviceId;
|
||||
protected UsbDeviceConnection mConnection;
|
||||
protected UsbEndpoint mInputEndpoint;
|
||||
protected UsbEndpoint mOutputEndpoint;
|
||||
protected InputThread mInputThread;
|
||||
protected boolean mRunning;
|
||||
protected boolean mFrozen;
|
||||
|
||||
public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_number) {
|
||||
mManager = manager;
|
||||
mDevice = usbDevice;
|
||||
mInterface = interface_number;
|
||||
mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier());
|
||||
mRunning = false;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return String.format("%s/%x/%x", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return mDeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId() {
|
||||
return mDevice.getVendorId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProductId() {
|
||||
return mDevice.getProductId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerialNumber() {
|
||||
String result = null;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
result = mDevice.getSerialNumber();
|
||||
}
|
||||
if (result == null) {
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturerName() {
|
||||
String result = null;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
result = mDevice.getManufacturerName();
|
||||
}
|
||||
if (result == null) {
|
||||
result = String.format("%x", getVendorId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductName() {
|
||||
String result = null;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
result = mDevice.getProductName();
|
||||
}
|
||||
if (result == null) {
|
||||
result = String.format("%x", getProductId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public UsbDevice getDevice() {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return getManufacturerName() + " " + getProductName() + "(0x" + String.format("%x", getVendorId()) + "/0x" + String.format("%x", getProductId()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open() {
|
||||
mConnection = mManager.getUSBManager().openDevice(mDevice);
|
||||
if (mConnection == null) {
|
||||
Log.w(TAG, "Unable to open USB device " + getDeviceName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force claim all interfaces
|
||||
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
|
||||
UsbInterface iface = mDevice.getInterface(i);
|
||||
|
||||
if (!mConnection.claimInterface(iface, true)) {
|
||||
Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the endpoints
|
||||
UsbInterface iface = mDevice.getInterface(mInterface);
|
||||
for (int j = 0; j < iface.getEndpointCount(); j++) {
|
||||
UsbEndpoint endpt = iface.getEndpoint(j);
|
||||
switch (endpt.getDirection()) {
|
||||
case UsbConstants.USB_DIR_IN:
|
||||
if (mInputEndpoint == null) {
|
||||
mInputEndpoint = endpt;
|
||||
}
|
||||
break;
|
||||
case UsbConstants.USB_DIR_OUT:
|
||||
if (mOutputEndpoint == null) {
|
||||
mOutputEndpoint = endpt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the required endpoints were present
|
||||
if (mInputEndpoint == null || mOutputEndpoint == null) {
|
||||
Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName());
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start listening for input
|
||||
mRunning = true;
|
||||
mInputThread = new InputThread();
|
||||
mInputThread.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendFeatureReport(byte[] report) {
|
||||
int res = -1;
|
||||
int offset = 0;
|
||||
int length = report.length;
|
||||
boolean skipped_report_id = false;
|
||||
byte report_number = report[0];
|
||||
|
||||
if (report_number == 0x0) {
|
||||
++offset;
|
||||
--length;
|
||||
skipped_report_id = true;
|
||||
}
|
||||
|
||||
res = mConnection.controlTransfer(
|
||||
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT,
|
||||
0x09/*HID set_report*/,
|
||||
(3/*HID feature*/ << 8) | report_number,
|
||||
0,
|
||||
report, offset, length,
|
||||
1000/*timeout millis*/);
|
||||
|
||||
if (res < 0) {
|
||||
Log.w(TAG, "sendFeatureReport() returned " + res + " on device " + getDeviceName());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (skipped_report_id) {
|
||||
++length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendOutputReport(byte[] report) {
|
||||
int r = mConnection.bulkTransfer(mOutputEndpoint, report, report.length, 1000);
|
||||
if (r != report.length) {
|
||||
Log.w(TAG, "sendOutputReport() returned " + r + " on device " + getDeviceName());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeatureReport(byte[] report) {
|
||||
int res = -1;
|
||||
int offset = 0;
|
||||
int length = report.length;
|
||||
boolean skipped_report_id = false;
|
||||
byte report_number = report[0];
|
||||
|
||||
if (report_number == 0x0) {
|
||||
/* Offset the return buffer by 1, so that the report ID
|
||||
will remain in byte 0. */
|
||||
++offset;
|
||||
--length;
|
||||
skipped_report_id = true;
|
||||
}
|
||||
|
||||
res = mConnection.controlTransfer(
|
||||
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN,
|
||||
0x01/*HID get_report*/,
|
||||
(3/*HID feature*/ << 8) | report_number,
|
||||
0,
|
||||
report, offset, length,
|
||||
1000/*timeout millis*/);
|
||||
|
||||
if (res < 0) {
|
||||
Log.w(TAG, "getFeatureReport() returned " + res + " on device " + getDeviceName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (skipped_report_id) {
|
||||
++res;
|
||||
++length;
|
||||
}
|
||||
|
||||
byte[] data;
|
||||
if (res == length) {
|
||||
data = report;
|
||||
} else {
|
||||
data = Arrays.copyOfRange(report, 0, res);
|
||||
}
|
||||
mManager.HIDDeviceFeatureReport(mDeviceId, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
mRunning = false;
|
||||
if (mInputThread != null) {
|
||||
while (mInputThread.isAlive()) {
|
||||
mInputThread.interrupt();
|
||||
try {
|
||||
mInputThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
// Keep trying until we're done
|
||||
}
|
||||
}
|
||||
mInputThread = null;
|
||||
}
|
||||
if (mConnection != null) {
|
||||
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
|
||||
UsbInterface iface = mDevice.getInterface(i);
|
||||
mConnection.releaseInterface(iface);
|
||||
}
|
||||
mConnection.close();
|
||||
mConnection = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
close();
|
||||
mManager = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrozen(boolean frozen) {
|
||||
mFrozen = frozen;
|
||||
}
|
||||
|
||||
protected class InputThread extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
int packetSize = mInputEndpoint.getMaxPacketSize();
|
||||
byte[] packet = new byte[packetSize];
|
||||
while (mRunning) {
|
||||
int r;
|
||||
try
|
||||
{
|
||||
r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.v(TAG, "Exception in UsbDeviceConnection bulktransfer: " + e);
|
||||
break;
|
||||
}
|
||||
if (r < 0) {
|
||||
// Could be a timeout or an I/O error
|
||||
}
|
||||
if (r > 0) {
|
||||
byte[] data;
|
||||
if (r == packetSize) {
|
||||
data = packet;
|
||||
} else {
|
||||
data = Arrays.copyOfRange(packet, 0, r);
|
||||
}
|
||||
|
||||
if (!mFrozen) {
|
||||
mManager.HIDDeviceInputReport(mDeviceId, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/**
|
||||
SDL library initialization
|
||||
*/
|
||||
public class SDL {
|
||||
|
||||
// This function should be called first and sets up the native code
|
||||
// so it can call into the Java classes
|
||||
public static void setupJNI() {
|
||||
SDLActivity.nativeSetupJNI();
|
||||
SDLAudioManager.nativeSetupJNI();
|
||||
SDLControllerManager.nativeSetupJNI();
|
||||
}
|
||||
|
||||
// This function should be called each time the activity is started
|
||||
public static void initialize() {
|
||||
setContext(null);
|
||||
|
||||
SDLActivity.initialize();
|
||||
SDLAudioManager.initialize();
|
||||
SDLControllerManager.initialize();
|
||||
}
|
||||
|
||||
// This function stores the current activity (SDL or not)
|
||||
public static void setContext(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
|
||||
|
||||
if (libraryName == null) {
|
||||
throw new NullPointerException("No library name provided.");
|
||||
}
|
||||
|
||||
try {
|
||||
// Let's see if we have ReLinker available in the project. This is necessary for
|
||||
// some projects that have huge numbers of local libraries bundled, and thus may
|
||||
// trip a bug in Android's native library loader which ReLinker works around. (If
|
||||
// loadLibrary works properly, ReLinker will simply use the normal Android method
|
||||
// internally.)
|
||||
//
|
||||
// To use ReLinker, just add it as a dependency. For more information, see
|
||||
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
||||
//
|
||||
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
|
||||
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
|
||||
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
|
||||
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
|
||||
|
||||
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
||||
// they've changed during updates.
|
||||
Method forceMethod = relinkClass.getDeclaredMethod("force");
|
||||
Object relinkInstance = forceMethod.invoke(null);
|
||||
Class relinkInstanceClass = relinkInstance.getClass();
|
||||
|
||||
// Actually load the library!
|
||||
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
|
||||
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
|
||||
}
|
||||
catch (final Throwable e) {
|
||||
// Fall back
|
||||
try {
|
||||
System.loadLibrary(libraryName);
|
||||
}
|
||||
catch (final UnsatisfiedLinkError ule) {
|
||||
throw ule;
|
||||
}
|
||||
catch (final SecurityException se) {
|
||||
throw se;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static Context mContext;
|
||||
}
|
||||
@@ -1,387 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.media.*;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
public class SDLAudioManager
|
||||
{
|
||||
protected static final String TAG = "SDLAudio";
|
||||
|
||||
protected static AudioTrack mAudioTrack;
|
||||
protected static AudioRecord mAudioRecord;
|
||||
|
||||
public static void initialize() {
|
||||
mAudioTrack = null;
|
||||
mAudioRecord = null;
|
||||
}
|
||||
|
||||
// Audio
|
||||
|
||||
protected static String getAudioFormatString(int audioFormat) {
|
||||
switch (audioFormat) {
|
||||
case AudioFormat.ENCODING_PCM_8BIT:
|
||||
return "8-bit";
|
||||
case AudioFormat.ENCODING_PCM_16BIT:
|
||||
return "16-bit";
|
||||
case AudioFormat.ENCODING_PCM_FLOAT:
|
||||
return "float";
|
||||
default:
|
||||
return Integer.toString(audioFormat);
|
||||
}
|
||||
}
|
||||
|
||||
protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||
int channelConfig;
|
||||
int sampleSize;
|
||||
int frameSize;
|
||||
|
||||
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
|
||||
|
||||
/* On older devices let's use known good settings */
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
if (desiredChannels > 2) {
|
||||
desiredChannels = 2;
|
||||
}
|
||||
if (sampleRate < 8000) {
|
||||
sampleRate = 8000;
|
||||
} else if (sampleRate > 48000) {
|
||||
sampleRate = 48000;
|
||||
}
|
||||
}
|
||||
|
||||
if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
|
||||
int minSDKVersion = (isCapture ? 23 : 21);
|
||||
if (Build.VERSION.SDK_INT < minSDKVersion) {
|
||||
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
}
|
||||
}
|
||||
switch (audioFormat)
|
||||
{
|
||||
case AudioFormat.ENCODING_PCM_8BIT:
|
||||
sampleSize = 1;
|
||||
break;
|
||||
case AudioFormat.ENCODING_PCM_16BIT:
|
||||
sampleSize = 2;
|
||||
break;
|
||||
case AudioFormat.ENCODING_PCM_FLOAT:
|
||||
sampleSize = 4;
|
||||
break;
|
||||
default:
|
||||
Log.v(TAG, "Requested format " + audioFormat + ", getting ENCODING_PCM_16BIT");
|
||||
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
sampleSize = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isCapture) {
|
||||
switch (desiredChannels) {
|
||||
case 1:
|
||||
channelConfig = AudioFormat.CHANNEL_IN_MONO;
|
||||
break;
|
||||
case 2:
|
||||
channelConfig = AudioFormat.CHANNEL_IN_STEREO;
|
||||
break;
|
||||
default:
|
||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
|
||||
desiredChannels = 2;
|
||||
channelConfig = AudioFormat.CHANNEL_IN_STEREO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (desiredChannels) {
|
||||
case 1:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_MONO;
|
||||
break;
|
||||
case 2:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
|
||||
break;
|
||||
case 3:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
|
||||
break;
|
||||
case 4:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_QUAD;
|
||||
break;
|
||||
case 5:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
|
||||
break;
|
||||
case 6:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
|
||||
break;
|
||||
case 7:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
|
||||
break;
|
||||
case 8:
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
|
||||
} else {
|
||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
|
||||
desiredChannels = 6;
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
|
||||
desiredChannels = 2;
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
Log.v(TAG, "Speaker configuration (and order of channels):");
|
||||
|
||||
if ((channelConfig & 0x00000004) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_LEFT");
|
||||
}
|
||||
if ((channelConfig & 0x00000008) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_RIGHT");
|
||||
}
|
||||
if ((channelConfig & 0x00000010) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000020) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_LOW_FREQUENCY");
|
||||
}
|
||||
if ((channelConfig & 0x00000040) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_BACK_LEFT");
|
||||
}
|
||||
if ((channelConfig & 0x00000080) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_BACK_RIGHT");
|
||||
}
|
||||
if ((channelConfig & 0x00000100) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_LEFT_OF_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000200) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_RIGHT_OF_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000400) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_BACK_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000800) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_SIDE_LEFT");
|
||||
}
|
||||
if ((channelConfig & 0x00001000) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_SIDE_RIGHT");
|
||||
}
|
||||
*/
|
||||
}
|
||||
frameSize = (sampleSize * desiredChannels);
|
||||
|
||||
// Let the user pick a larger buffer if they really want -- but ye
|
||||
// gods they probably shouldn't, the minimums are horrifyingly high
|
||||
// latency already
|
||||
int minBufferSize;
|
||||
if (isCapture) {
|
||||
minBufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
|
||||
} else {
|
||||
minBufferSize = AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat);
|
||||
}
|
||||
desiredFrames = Math.max(desiredFrames, (minBufferSize + frameSize - 1) / frameSize);
|
||||
|
||||
int[] results = new int[4];
|
||||
|
||||
if (isCapture) {
|
||||
if (mAudioRecord == null) {
|
||||
mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
|
||||
channelConfig, audioFormat, desiredFrames * frameSize);
|
||||
|
||||
// see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
|
||||
if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
|
||||
Log.e(TAG, "Failed during initialization of AudioRecord");
|
||||
mAudioRecord.release();
|
||||
mAudioRecord = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
mAudioRecord.startRecording();
|
||||
}
|
||||
|
||||
results[0] = mAudioRecord.getSampleRate();
|
||||
results[1] = mAudioRecord.getAudioFormat();
|
||||
results[2] = mAudioRecord.getChannelCount();
|
||||
results[3] = desiredFrames;
|
||||
|
||||
} else {
|
||||
if (mAudioTrack == null) {
|
||||
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
|
||||
|
||||
// Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
|
||||
// Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
|
||||
// Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
|
||||
if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
|
||||
/* Try again, with safer values */
|
||||
|
||||
Log.e(TAG, "Failed during initialization of Audio Track");
|
||||
mAudioTrack.release();
|
||||
mAudioTrack = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
mAudioTrack.play();
|
||||
}
|
||||
|
||||
results[0] = mAudioTrack.getSampleRate();
|
||||
results[1] = mAudioTrack.getAudioFormat();
|
||||
results[2] = mAudioTrack.getChannelCount();
|
||||
results[3] = desiredFrames;
|
||||
}
|
||||
|
||||
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", got " + results[3] + " frames of " + results[2] + " channel " + getAudioFormatString(results[1]) + " audio at " + results[0] + " Hz");
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void audioWriteFloatBuffer(float[] buffer) {
|
||||
if (mAudioTrack == null) {
|
||||
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length;) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
} else if (result == 0) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch(InterruptedException e) {
|
||||
// Nom nom
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "SDL audio: error return from write(float)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void audioWriteShortBuffer(short[] buffer) {
|
||||
if (mAudioTrack == null) {
|
||||
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length;) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
} else if (result == 0) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch(InterruptedException e) {
|
||||
// Nom nom
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "SDL audio: error return from write(short)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void audioWriteByteBuffer(byte[] buffer) {
|
||||
if (mAudioTrack == null) {
|
||||
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length; ) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
} else if (result == 0) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch(InterruptedException e) {
|
||||
// Nom nom
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "SDL audio: error return from write(byte)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||
return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames);
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||
} else {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||
} else {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void audioClose() {
|
||||
if (mAudioTrack != null) {
|
||||
mAudioTrack.stop();
|
||||
mAudioTrack.release();
|
||||
mAudioTrack = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void captureClose() {
|
||||
if (mAudioRecord != null) {
|
||||
mAudioRecord.stop();
|
||||
mAudioRecord.release();
|
||||
mAudioRecord = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void audioSetThreadPriority(boolean iscapture, int device_id) {
|
||||
try {
|
||||
|
||||
/* Set thread name */
|
||||
if (iscapture) {
|
||||
Thread.currentThread().setName("SDLAudioC" + device_id);
|
||||
} else {
|
||||
Thread.currentThread().setName("SDLAudioP" + device_id);
|
||||
}
|
||||
|
||||
/* Set thread priority */
|
||||
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "modify thread properties failed " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static native int nativeSetupJNI();
|
||||
}
|
||||
@@ -1,788 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.*;
|
||||
import android.view.*;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class SDLControllerManager
|
||||
{
|
||||
|
||||
public static native int nativeSetupJNI();
|
||||
|
||||
public static native int nativeAddJoystick(int device_id, String name, String desc,
|
||||
int vendor_id, int product_id,
|
||||
boolean is_accelerometer, int button_mask,
|
||||
int naxes, int nhats, int nballs);
|
||||
public static native int nativeRemoveJoystick(int device_id);
|
||||
public static native int nativeAddHaptic(int device_id, String name);
|
||||
public static native int nativeRemoveHaptic(int device_id);
|
||||
public static native int onNativePadDown(int device_id, int keycode);
|
||||
public static native int onNativePadUp(int device_id, int keycode);
|
||||
public static native void onNativeJoy(int device_id, int axis,
|
||||
float value);
|
||||
public static native void onNativeHat(int device_id, int hat_id,
|
||||
int x, int y);
|
||||
|
||||
protected static SDLJoystickHandler mJoystickHandler;
|
||||
protected static SDLHapticHandler mHapticHandler;
|
||||
|
||||
private static final String TAG = "SDLControllerManager";
|
||||
|
||||
public static void initialize() {
|
||||
if (mJoystickHandler == null) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
mJoystickHandler = new SDLJoystickHandler_API19();
|
||||
} else {
|
||||
mJoystickHandler = new SDLJoystickHandler_API16();
|
||||
}
|
||||
}
|
||||
|
||||
if (mHapticHandler == null) {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
mHapticHandler = new SDLHapticHandler_API26();
|
||||
} else {
|
||||
mHapticHandler = new SDLHapticHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
|
||||
public static boolean handleJoystickMotionEvent(MotionEvent event) {
|
||||
return mJoystickHandler.handleMotionEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void pollInputDevices() {
|
||||
mJoystickHandler.pollInputDevices();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void pollHapticDevices() {
|
||||
mHapticHandler.pollHapticDevices();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void hapticRun(int device_id, float intensity, int length) {
|
||||
mHapticHandler.run(device_id, intensity, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void hapticStop(int device_id)
|
||||
{
|
||||
mHapticHandler.stop(device_id);
|
||||
}
|
||||
|
||||
// Check if a given device is considered a possible SDL joystick
|
||||
public static boolean isDeviceSDLJoystick(int deviceId) {
|
||||
InputDevice device = InputDevice.getDevice(deviceId);
|
||||
// We cannot use InputDevice.isVirtual before API 16, so let's accept
|
||||
// only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
|
||||
if ((device == null) || (deviceId < 0)) {
|
||||
return false;
|
||||
}
|
||||
int sources = device.getSources();
|
||||
|
||||
/* This is called for every button press, so let's not spam the logs */
|
||||
/**
|
||||
if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " has class joystick.");
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " is a dpad.");
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " is a gamepad.");
|
||||
}
|
||||
**/
|
||||
|
||||
return ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ||
|
||||
((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
|
||||
((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SDLJoystickHandler {
|
||||
|
||||
/**
|
||||
* Handles given MotionEvent.
|
||||
* @param event the event to be handled.
|
||||
* @return if given event was processed.
|
||||
*/
|
||||
public boolean handleMotionEvent(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles adding and removing of input devices.
|
||||
*/
|
||||
public void pollInputDevices() {
|
||||
}
|
||||
}
|
||||
|
||||
/* Actual joystick functionality available for API >= 12 devices */
|
||||
class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
|
||||
static class SDLJoystick {
|
||||
public int device_id;
|
||||
public String name;
|
||||
public String desc;
|
||||
public ArrayList<InputDevice.MotionRange> axes;
|
||||
public ArrayList<InputDevice.MotionRange> hats;
|
||||
}
|
||||
static class RangeComparator implements Comparator<InputDevice.MotionRange> {
|
||||
@Override
|
||||
public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {
|
||||
// Some controllers, like the Moga Pro 2, return AXIS_GAS (22) for right trigger and AXIS_BRAKE (23) for left trigger - swap them so they're sorted in the right order for SDL
|
||||
int arg0Axis = arg0.getAxis();
|
||||
int arg1Axis = arg1.getAxis();
|
||||
if (arg0Axis == MotionEvent.AXIS_GAS) {
|
||||
arg0Axis = MotionEvent.AXIS_BRAKE;
|
||||
} else if (arg0Axis == MotionEvent.AXIS_BRAKE) {
|
||||
arg0Axis = MotionEvent.AXIS_GAS;
|
||||
}
|
||||
if (arg1Axis == MotionEvent.AXIS_GAS) {
|
||||
arg1Axis = MotionEvent.AXIS_BRAKE;
|
||||
} else if (arg1Axis == MotionEvent.AXIS_BRAKE) {
|
||||
arg1Axis = MotionEvent.AXIS_GAS;
|
||||
}
|
||||
|
||||
return arg0Axis - arg1Axis;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<SDLJoystick> mJoysticks;
|
||||
|
||||
public SDLJoystickHandler_API16() {
|
||||
|
||||
mJoysticks = new ArrayList<SDLJoystick>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pollInputDevices() {
|
||||
int[] deviceIds = InputDevice.getDeviceIds();
|
||||
for(int i=0; i < deviceIds.length; ++i) {
|
||||
SDLJoystick joystick = getJoystick(deviceIds[i]);
|
||||
if (joystick == null) {
|
||||
joystick = new SDLJoystick();
|
||||
InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
|
||||
if (SDLControllerManager.isDeviceSDLJoystick(deviceIds[i])) {
|
||||
joystick.device_id = deviceIds[i];
|
||||
joystick.name = joystickDevice.getName();
|
||||
joystick.desc = getJoystickDescriptor(joystickDevice);
|
||||
joystick.axes = new ArrayList<InputDevice.MotionRange>();
|
||||
joystick.hats = new ArrayList<InputDevice.MotionRange>();
|
||||
|
||||
List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
|
||||
Collections.sort(ranges, new RangeComparator());
|
||||
for (InputDevice.MotionRange range : ranges ) {
|
||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
if (range.getAxis() == MotionEvent.AXIS_HAT_X ||
|
||||
range.getAxis() == MotionEvent.AXIS_HAT_Y) {
|
||||
joystick.hats.add(range);
|
||||
}
|
||||
else {
|
||||
joystick.axes.add(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mJoysticks.add(joystick);
|
||||
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, getVendorId(joystickDevice), getProductId(joystickDevice), false, getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check removed devices */
|
||||
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
|
||||
for(int i=0; i < mJoysticks.size(); i++) {
|
||||
int device_id = mJoysticks.get(i).device_id;
|
||||
int j;
|
||||
for (j=0; j < deviceIds.length; j++) {
|
||||
if (device_id == deviceIds[j]) break;
|
||||
}
|
||||
if (j == deviceIds.length) {
|
||||
removedDevices.add(Integer.valueOf(device_id));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i < removedDevices.size(); i++) {
|
||||
int device_id = removedDevices.get(i).intValue();
|
||||
SDLControllerManager.nativeRemoveJoystick(device_id);
|
||||
for (int j=0; j < mJoysticks.size(); j++) {
|
||||
if (mJoysticks.get(j).device_id == device_id) {
|
||||
mJoysticks.remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SDLJoystick getJoystick(int device_id) {
|
||||
for(int i=0; i < mJoysticks.size(); i++) {
|
||||
if (mJoysticks.get(i).device_id == device_id) {
|
||||
return mJoysticks.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMotionEvent(MotionEvent event) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
|
||||
int actionPointerIndex = event.getActionIndex();
|
||||
int action = event.getActionMasked();
|
||||
switch(action) {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
SDLJoystick joystick = getJoystick(event.getDeviceId());
|
||||
if ( joystick != null ) {
|
||||
for (int i = 0; i < joystick.axes.size(); i++) {
|
||||
InputDevice.MotionRange range = joystick.axes.get(i);
|
||||
/* Normalize the value to -1...1 */
|
||||
float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
|
||||
SDLControllerManager.onNativeJoy(joystick.device_id, i, value );
|
||||
}
|
||||
for (int i = 0; i < joystick.hats.size(); i+=2) {
|
||||
int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
|
||||
int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
|
||||
SDLControllerManager.onNativeHat(joystick.device_id, i/2, hatX, hatY );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getJoystickDescriptor(InputDevice joystickDevice) {
|
||||
String desc = joystickDevice.getDescriptor();
|
||||
|
||||
if (desc != null && !desc.isEmpty()) {
|
||||
return desc;
|
||||
}
|
||||
|
||||
return joystickDevice.getName();
|
||||
}
|
||||
public int getProductId(InputDevice joystickDevice) {
|
||||
return 0;
|
||||
}
|
||||
public int getVendorId(InputDevice joystickDevice) {
|
||||
return 0;
|
||||
}
|
||||
public int getButtonMask(InputDevice joystickDevice) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
|
||||
|
||||
@Override
|
||||
public int getProductId(InputDevice joystickDevice) {
|
||||
return joystickDevice.getProductId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId(InputDevice joystickDevice) {
|
||||
return joystickDevice.getVendorId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonMask(InputDevice joystickDevice) {
|
||||
int button_mask = 0;
|
||||
int[] keys = new int[] {
|
||||
KeyEvent.KEYCODE_BUTTON_A,
|
||||
KeyEvent.KEYCODE_BUTTON_B,
|
||||
KeyEvent.KEYCODE_BUTTON_X,
|
||||
KeyEvent.KEYCODE_BUTTON_Y,
|
||||
KeyEvent.KEYCODE_BACK,
|
||||
KeyEvent.KEYCODE_BUTTON_MODE,
|
||||
KeyEvent.KEYCODE_BUTTON_START,
|
||||
KeyEvent.KEYCODE_BUTTON_THUMBL,
|
||||
KeyEvent.KEYCODE_BUTTON_THUMBR,
|
||||
KeyEvent.KEYCODE_BUTTON_L1,
|
||||
KeyEvent.KEYCODE_BUTTON_R1,
|
||||
KeyEvent.KEYCODE_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||
KeyEvent.KEYCODE_BUTTON_SELECT,
|
||||
KeyEvent.KEYCODE_DPAD_CENTER,
|
||||
|
||||
// These don't map into any SDL controller buttons directly
|
||||
KeyEvent.KEYCODE_BUTTON_L2,
|
||||
KeyEvent.KEYCODE_BUTTON_R2,
|
||||
KeyEvent.KEYCODE_BUTTON_C,
|
||||
KeyEvent.KEYCODE_BUTTON_Z,
|
||||
KeyEvent.KEYCODE_BUTTON_1,
|
||||
KeyEvent.KEYCODE_BUTTON_2,
|
||||
KeyEvent.KEYCODE_BUTTON_3,
|
||||
KeyEvent.KEYCODE_BUTTON_4,
|
||||
KeyEvent.KEYCODE_BUTTON_5,
|
||||
KeyEvent.KEYCODE_BUTTON_6,
|
||||
KeyEvent.KEYCODE_BUTTON_7,
|
||||
KeyEvent.KEYCODE_BUTTON_8,
|
||||
KeyEvent.KEYCODE_BUTTON_9,
|
||||
KeyEvent.KEYCODE_BUTTON_10,
|
||||
KeyEvent.KEYCODE_BUTTON_11,
|
||||
KeyEvent.KEYCODE_BUTTON_12,
|
||||
KeyEvent.KEYCODE_BUTTON_13,
|
||||
KeyEvent.KEYCODE_BUTTON_14,
|
||||
KeyEvent.KEYCODE_BUTTON_15,
|
||||
KeyEvent.KEYCODE_BUTTON_16,
|
||||
};
|
||||
int[] masks = new int[] {
|
||||
(1 << 0), // A -> A
|
||||
(1 << 1), // B -> B
|
||||
(1 << 2), // X -> X
|
||||
(1 << 3), // Y -> Y
|
||||
(1 << 4), // BACK -> BACK
|
||||
(1 << 5), // MODE -> GUIDE
|
||||
(1 << 6), // START -> START
|
||||
(1 << 7), // THUMBL -> LEFTSTICK
|
||||
(1 << 8), // THUMBR -> RIGHTSTICK
|
||||
(1 << 9), // L1 -> LEFTSHOULDER
|
||||
(1 << 10), // R1 -> RIGHTSHOULDER
|
||||
(1 << 11), // DPAD_UP -> DPAD_UP
|
||||
(1 << 12), // DPAD_DOWN -> DPAD_DOWN
|
||||
(1 << 13), // DPAD_LEFT -> DPAD_LEFT
|
||||
(1 << 14), // DPAD_RIGHT -> DPAD_RIGHT
|
||||
(1 << 4), // SELECT -> BACK
|
||||
(1 << 0), // DPAD_CENTER -> A
|
||||
(1 << 15), // L2 -> ??
|
||||
(1 << 16), // R2 -> ??
|
||||
(1 << 17), // C -> ??
|
||||
(1 << 18), // Z -> ??
|
||||
(1 << 20), // 1 -> ??
|
||||
(1 << 21), // 2 -> ??
|
||||
(1 << 22), // 3 -> ??
|
||||
(1 << 23), // 4 -> ??
|
||||
(1 << 24), // 5 -> ??
|
||||
(1 << 25), // 6 -> ??
|
||||
(1 << 26), // 7 -> ??
|
||||
(1 << 27), // 8 -> ??
|
||||
(1 << 28), // 9 -> ??
|
||||
(1 << 29), // 10 -> ??
|
||||
(1 << 30), // 11 -> ??
|
||||
(1 << 31), // 12 -> ??
|
||||
// We're out of room...
|
||||
0xFFFFFFFF, // 13 -> ??
|
||||
0xFFFFFFFF, // 14 -> ??
|
||||
0xFFFFFFFF, // 15 -> ??
|
||||
0xFFFFFFFF, // 16 -> ??
|
||||
};
|
||||
boolean[] has_keys = joystickDevice.hasKeys(keys);
|
||||
for (int i = 0; i < keys.length; ++i) {
|
||||
if (has_keys[i]) {
|
||||
button_mask |= masks[i];
|
||||
}
|
||||
}
|
||||
return button_mask;
|
||||
}
|
||||
}
|
||||
|
||||
class SDLHapticHandler_API26 extends SDLHapticHandler {
|
||||
@Override
|
||||
public void run(int device_id, float intensity, int length) {
|
||||
SDLHaptic haptic = getHaptic(device_id);
|
||||
if (haptic != null) {
|
||||
Log.d("SDL", "Rtest: Vibe with intensity " + intensity + " for " + length);
|
||||
if (intensity == 0.0f) {
|
||||
stop(device_id);
|
||||
return;
|
||||
}
|
||||
|
||||
int vibeValue = Math.round(intensity * 255);
|
||||
|
||||
if (vibeValue > 255) {
|
||||
vibeValue = 255;
|
||||
}
|
||||
if (vibeValue < 1) {
|
||||
stop(device_id);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
haptic.vib.vibrate(VibrationEffect.createOneShot(length, vibeValue));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Fall back to the generic method, which uses DEFAULT_AMPLITUDE, but works even if
|
||||
// something went horribly wrong with the Android 8.0 APIs.
|
||||
haptic.vib.vibrate(length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SDLHapticHandler {
|
||||
|
||||
class SDLHaptic {
|
||||
public int device_id;
|
||||
public String name;
|
||||
public Vibrator vib;
|
||||
}
|
||||
|
||||
private ArrayList<SDLHaptic> mHaptics;
|
||||
|
||||
public SDLHapticHandler() {
|
||||
mHaptics = new ArrayList<SDLHaptic>();
|
||||
}
|
||||
|
||||
public void run(int device_id, float intensity, int length) {
|
||||
SDLHaptic haptic = getHaptic(device_id);
|
||||
if (haptic != null) {
|
||||
haptic.vib.vibrate(length);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(int device_id) {
|
||||
SDLHaptic haptic = getHaptic(device_id);
|
||||
if (haptic != null) {
|
||||
haptic.vib.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public void pollHapticDevices() {
|
||||
|
||||
final int deviceId_VIBRATOR_SERVICE = 999999;
|
||||
boolean hasVibratorService = false;
|
||||
|
||||
int[] deviceIds = InputDevice.getDeviceIds();
|
||||
// It helps processing the device ids in reverse order
|
||||
// For example, in the case of the XBox 360 wireless dongle,
|
||||
// so the first controller seen by SDL matches what the receiver
|
||||
// considers to be the first controller
|
||||
|
||||
for (int i = deviceIds.length - 1; i > -1; i--) {
|
||||
SDLHaptic haptic = getHaptic(deviceIds[i]);
|
||||
if (haptic == null) {
|
||||
InputDevice device = InputDevice.getDevice(deviceIds[i]);
|
||||
Vibrator vib = device.getVibrator();
|
||||
if (vib.hasVibrator()) {
|
||||
haptic = new SDLHaptic();
|
||||
haptic.device_id = deviceIds[i];
|
||||
haptic.name = device.getName();
|
||||
haptic.vib = vib;
|
||||
mHaptics.add(haptic);
|
||||
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check VIBRATOR_SERVICE */
|
||||
Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (vib != null) {
|
||||
hasVibratorService = vib.hasVibrator();
|
||||
|
||||
if (hasVibratorService) {
|
||||
SDLHaptic haptic = getHaptic(deviceId_VIBRATOR_SERVICE);
|
||||
if (haptic == null) {
|
||||
haptic = new SDLHaptic();
|
||||
haptic.device_id = deviceId_VIBRATOR_SERVICE;
|
||||
haptic.name = "VIBRATOR_SERVICE";
|
||||
haptic.vib = vib;
|
||||
mHaptics.add(haptic);
|
||||
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check removed devices */
|
||||
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
|
||||
for(int i=0; i < mHaptics.size(); i++) {
|
||||
int device_id = mHaptics.get(i).device_id;
|
||||
int j;
|
||||
for (j=0; j < deviceIds.length; j++) {
|
||||
if (device_id == deviceIds[j]) break;
|
||||
}
|
||||
|
||||
if (device_id == deviceId_VIBRATOR_SERVICE && hasVibratorService) {
|
||||
// don't remove the vibrator if it is still present
|
||||
} else if (j == deviceIds.length) {
|
||||
removedDevices.add(device_id);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i < removedDevices.size(); i++) {
|
||||
int device_id = removedDevices.get(i);
|
||||
SDLControllerManager.nativeRemoveHaptic(device_id);
|
||||
for (int j=0; j < mHaptics.size(); j++) {
|
||||
if (mHaptics.get(j).device_id == device_id) {
|
||||
mHaptics.remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SDLHaptic getHaptic(int device_id) {
|
||||
for(int i=0; i < mHaptics.size(); i++) {
|
||||
if (mHaptics.get(i).device_id == device_id) {
|
||||
return mHaptics.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
float x, y;
|
||||
int action;
|
||||
|
||||
switch ( event.getSource() ) {
|
||||
case InputDevice.SOURCE_JOYSTICK:
|
||||
case InputDevice.SOURCE_GAMEPAD:
|
||||
case InputDevice.SOURCE_DPAD:
|
||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||
|
||||
case InputDevice.SOURCE_MOUSE:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Event was not managed
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsRelativeMouse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean inRelativeMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void reclaimRelativeMouseModeIfNeeded()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public float getEventX(MotionEvent event) {
|
||||
return event.getX(0);
|
||||
}
|
||||
|
||||
public float getEventY(MotionEvent event) {
|
||||
return event.getY(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
|
||||
private boolean mRelativeModeEnabled;
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
|
||||
// Handle relative mouse mode
|
||||
if (mRelativeModeEnabled) {
|
||||
if (event.getSource() == InputDevice.SOURCE_MOUSE) {
|
||||
int action = event.getActionMasked();
|
||||
if (action == MotionEvent.ACTION_HOVER_MOVE) {
|
||||
float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
|
||||
float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Event was not managed, call SDLGenericMotionListener_API12 method
|
||||
return super.onGenericMotion(v, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRelativeMouse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRelativeMode() {
|
||||
return mRelativeModeEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||
mRelativeModeEnabled = enabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventX(MotionEvent event) {
|
||||
if (mRelativeModeEnabled) {
|
||||
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
|
||||
}
|
||||
else {
|
||||
return event.getX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventY(MotionEvent event) {
|
||||
if (mRelativeModeEnabled) {
|
||||
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
|
||||
}
|
||||
else {
|
||||
return event.getY(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
private boolean mRelativeModeEnabled;
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
float x, y;
|
||||
int action;
|
||||
|
||||
switch ( event.getSource() ) {
|
||||
case InputDevice.SOURCE_JOYSTICK:
|
||||
case InputDevice.SOURCE_GAMEPAD:
|
||||
case InputDevice.SOURCE_DPAD:
|
||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||
|
||||
case InputDevice.SOURCE_MOUSE:
|
||||
// DeX desktop mouse cursor is a separate non-standard input type.
|
||||
case InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case InputDevice.SOURCE_MOUSE_RELATIVE:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Event was not managed
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRelativeMouse() {
|
||||
return (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRelativeMode() {
|
||||
return mRelativeModeEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||
if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) {
|
||||
if (enabled) {
|
||||
SDLActivity.getContentView().requestPointerCapture();
|
||||
}
|
||||
else {
|
||||
SDLActivity.getContentView().releasePointerCapture();
|
||||
}
|
||||
mRelativeModeEnabled = enabled;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reclaimRelativeMouseModeIfNeeded()
|
||||
{
|
||||
if (mRelativeModeEnabled && !SDLActivity.isDeXMode()) {
|
||||
SDLActivity.getContentView().requestPointerCapture();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventX(MotionEvent event) {
|
||||
// Relative mouse in capture mode will only have relative for X/Y
|
||||
return event.getX(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventY(MotionEvent event) {
|
||||
// Relative mouse in capture mode will only have relative for X/Y
|
||||
return event.getY(0);
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 24 KiB |
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:drawable="@color/black"/>
|
||||
|
||||
<item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:src="@drawable/splash"/>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 86 KiB |
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#000000</color>
|
||||
<color name="accent_material_dark">#009926</color>
|
||||
<color name="primary_material_dark">#212121</color>
|
||||
<color name="background_material_dark">#212121</color>
|
||||
</resources>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">Installing game data...</string>
|
||||
<string name="upgradeTitle">Upgrading game data...</string>
|
||||
<string name="helpTitle">Help & Controls</string>
|
||||
<string name="helpMessage">"Swipe" for directional movement (hold for virtual joystick). "Tap" to confirm selection in menu or Pause one turn in-game (hold to Pause several turns in-game). "Double tap" to cancel or go back in menus (works like Escape key). "Pinch" to zoom in/out (in-game). Use hardware "Back" button to toggle virtual keyboard (hold to toggle keyboard shortcuts).</string>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
|
||||
<item name="android:windowBackground">@drawable/background_splash</item>
|
||||
<item name="android:colorAccent">@color/accent_material_dark</item>
|
||||
<item name="android:colorPrimary">@color/primary_material_dark</item>
|
||||
<item name="android:colorBackground">@color/background_material_dark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -1,25 +0,0 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
# This property controls the number of jobs sent by -j switch to ndk-build
|
||||
# You can override this from the command line by passing "-Pj=#"
|
||||
j=2
|
||||
|
||||
# This property controls whether build should be run with localization
|
||||
# You can override this from the command line by passing "-Plocalize=#"
|
||||
localize=true
|
||||
|
||||
# This property controls whether to build arm 32 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_arm_32=#"
|
||||
abi_arm_32=true
|
||||
|
||||
# This property controls whether to build arm 64 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_arm_64=#"
|
||||
abi_arm_64=true
|
||||
|
||||
# This property controls whether to build x86 32 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_x86_32=#"
|
||||
abi_x86_32=false
|
||||
|
||||
# This property controls whether to build x86 64 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_x86_64=#"
|
||||
abi_x86_64=false
|
||||
|
||||
# This property controls which dependencies file to use
|
||||
# You can override this from the command line by passing "-Pdeps=#"
|
||||
deps=./deps.zip
|
||||
|
||||
# This property controls which override version number to use
|
||||
# You can override this from the command line by passing "-Poverride_version=#"
|
||||
override_version=
|
||||
|
||||
# This property controls path where overriden version number header should be generated
|
||||
# You can override this from the command line by passing "-Pversion_header_path=#"
|
||||
version_header_path=app/jni/src/version.h
|
||||
|
||||
# This property controls which compileSdkVersion should be used
|
||||
# You can override this from the command line by passing "-Poverride_compileSdkVersion=#"
|
||||
override_compileSdkVersion=28
|
||||
|
||||
# This property controls which minSdkVersion should be used
|
||||
# You can override this from the command line by passing "-Poverride_minSdkVersion=#"
|
||||
override_minSdkVersion=14
|
||||
|
||||
# This property controls which targetSdkVersion should be used
|
||||
# You can override this from the command line by passing "-Poverride_targetSdkVersion=#"
|
||||
override_targetSdkVersion=28
|
||||
|
||||
# This property controls which ndkBuildAppPlatform should be used
|
||||
# You can override this from the command line by passing "-Poverride_ndkBuildAppPlatform=#"
|
||||
override_ndkBuildAppPlatform=android-16
|
||||
@@ -1,6 +0,0 @@
|
||||
#Tue Aug 27 13:00:00 UTC 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
|
||||
@@ -1,160 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
@@ -1,90 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1 +0,0 @@
|
||||
include ':app'
|
||||
|
After Width: | Height: | Size: 1.7 MiB |
@@ -1,99 +0,0 @@
|
||||
#HOWTO:
|
||||
# run this from the root of the cdda repo using `docker build -f build-scripts/Dockerfile.debian-build . -t cdda`
|
||||
# (note: the -t cdda is optional but convenient. It tags the resulting image with `cdda`)
|
||||
# (note: the `.` is required and orients Docker to the file/dir struture you want to bring into the image with COPY once the setup is done)
|
||||
|
||||
# basing the build on debian testing is an easy way to bring in clang-6.0. Debian testing is quite stable.
|
||||
# (We want clang for faster builds, and clang 6 is latest)
|
||||
FROM debian:testing
|
||||
|
||||
# read latest package index on repos
|
||||
RUN apt-get -qq update
|
||||
|
||||
# we want apt-fast because it makes apt installs way faster by downloading many packages at once, and these packages are used for a fast/easy install of apt-fast
|
||||
RUN apt-get -qq install curl openssl ca-certificates sudo wget --no-install-recommends
|
||||
# we strip 'sudo' calls out of the script so we don't have to bother with sudo even though it's installed, and we avoid the recommended packages from the apt install in the script as they tend to be bloat on a server-like setup like this build image
|
||||
RUN curl -sL https://git.io/vokNn | sed s/'sudo '//g | sed s/'apt-get install'/'apt-get install --no-install-recommends'/g | bash && echo "DOWNLOADBEFORE=true" >> /etc/apt-fast.conf
|
||||
|
||||
# ensure we know about the latest packages
|
||||
RUN apt-fast -qq update
|
||||
|
||||
# random convenience packages
|
||||
RUN apt-fast -qq install --no-install-recommends aptitude man software-properties-common gpg
|
||||
|
||||
# CDDA: for building
|
||||
RUN apt-fast -qq install --no-install-recommends build-essential clang-6.0 cmake ccache
|
||||
# we probably don't want gcc/g++ so we don't accidentally build with them; note, we may find that we might actually want them
|
||||
RUN apt-get -qq remove gcc g++ && apt-get -qq autoremove
|
||||
|
||||
# CDDA: general stuff; gettext is required for localization
|
||||
RUN apt-fast -qq install --no-install-recommends gettext
|
||||
|
||||
# CDDA: libraries for curses-based terminal cdda
|
||||
RUN apt-fast -qq install --no-install-recommends libncurses5-dev libncursesw5-dev
|
||||
|
||||
# CDDA: libraries for tiles build
|
||||
RUN apt-fast -qq install --no-install-recommends libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev
|
||||
|
||||
# general packages for a much nicer time inside the container (we install psmisc for `killall`)
|
||||
RUN apt-fast -qq install --no-install-recommends tree watch tmux fish colormake vim emacs git silversearcher-ag lsof psmisc dstat
|
||||
|
||||
# install opensssh-server and prepare for running it
|
||||
#TODO: find a nice way of getting ssh keys into the image - by grabbing .pub keys from somewhere?
|
||||
RUN apt-fast -qq install --no-install-recommends openssh-server && mkdir -p /run/sshd
|
||||
|
||||
|
||||
# experimental: trying to get X11 forwarding or x2go to run; xauth seems to be required
|
||||
RUN apt-fast install -qq --no-install-recommends xauth
|
||||
|
||||
# install lldb, the llvm debugger (lldb is quite good, and the clang compiler is based on llvm so it's kinda connected)
|
||||
# NOTE: we have to add `--privileged` to `docker run` to be able to debug inside the container, or else we get a pretty cryptic error once we `run` inside the debugger
|
||||
# NOTE: we can probably run an external debugger and attach it to the process inside the container somehow, to be able to debug inside the container using a full IDE on the host
|
||||
RUN apt-fast -qq install --no-install-recommends lldb-6.0
|
||||
|
||||
|
||||
# we prefer to build as a regular user (cdda) rather than root
|
||||
RUN mkdir /cdda
|
||||
# --disabled-password is a way to rush through the user generation (it's inelegant though), and then we set the password 'lol'
|
||||
#TODO: bring the password in as an ARG with an option
|
||||
RUN adduser cdda --disabled-password && echo cdda:lol | chpasswd
|
||||
USER cdda
|
||||
WORKDIR /home/cdda
|
||||
|
||||
# copy everything from the source directory on the host (the `.` in docker build) - except the contents of .dockerignore
|
||||
COPY --chown=cdda:cdda . .
|
||||
|
||||
# we build in build dirs rather than at the repo root
|
||||
# TODO: move build dirs to a directory ABOVE the source so we can Docker mount in the source dir for 'live' builds of code you're hacking on on the host
|
||||
RUN mkdir cmake-build-debug cmake-build-debug-tiles
|
||||
|
||||
WORKDIR /home/cdda/cmake-build-debug
|
||||
|
||||
|
||||
WORKDIR /home/cdda/cmake-build-debug
|
||||
|
||||
RUN env CC=clang-6.0 CXX=clang++-6.0 cmake ..
|
||||
|
||||
RUN echo `pwd` configured for build; to actually build, run "make -j`nproc --all`" here
|
||||
|
||||
WORKDIR /home/cdda/cmake-build-debug-tiles
|
||||
|
||||
RUN env CC=clang-6.0 CXX=clang++-6.0 cmake -DTILES=ON ..
|
||||
|
||||
RUN echo `pwd` configured for build; to actually build, run "make -j`nproc --all`" here
|
||||
|
||||
|
||||
## ssh server stuff (experimental and not needed except for testing ssh stuff with CDDA! you don't need ssh to get a shell inside the container!)
|
||||
## uncomment this to get ssh
|
||||
##
|
||||
## tell Docker to expose port 22 by default on `docker run` (the result is that it's mapped to a random port on the host so you can ssh in with ssh cdda@localhost:{RANDOMPORT}. Running `docker ps` will reveal the external port.
|
||||
## Note that you DO NOT need SSH to get a shell inside the container. This is for testing only.
|
||||
## Crash course: The usual way into the container is `docker {run or exec} -it {container/image name} bash` (or better yet, tmux or fish rather than bash). Docker run is to start a running container from an image, docker exec is to execute a process inside an already-started container.
|
||||
## TODO: expose 22 to fixed port by default, perhaps with an ARG?
|
||||
#EXPOSE 22
|
||||
##
|
||||
## the CMD entry tells Docker to run that command by default when you `docker run` the image as a container
|
||||
## NOTE: disabled as it's probably not a good default for the container. However, when enabled, `docker run` gives you a somewhat persistent container that accepts SSH connections, and then for a regular shell inside the container you do `docker exec -it {containername} bash` (or ssh if you wish)
|
||||
#USER root
|
||||
#WORKDIR /run/sshd
|
||||
#CMD ["/usr/sbin/sshd", "-De", "-f", "/etc/ssh/sshd_config"]
|
||||
@@ -1,180 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build script intended for use in Travis CI
|
||||
|
||||
set -exo pipefail
|
||||
|
||||
num_jobs=3
|
||||
|
||||
function run_tests
|
||||
{
|
||||
# The grep supresses lines that begin with "0.0## s:", which are timing lines for tests with a very short duration.
|
||||
$WINE "$@" -d yes --use-colour yes --rng-seed time $EXTRA_TEST_OPTS | grep -Ev "^0\.0[0-9]{2} s:"
|
||||
}
|
||||
|
||||
date +%s > build-start-time
|
||||
|
||||
if [ -n "$TEST_STAGE" ]
|
||||
then
|
||||
build-scripts/lint-json.sh
|
||||
make -j "$num_jobs" style-json
|
||||
|
||||
tools/dialogue_validator.py data/json/npcs/* data/json/npcs/*/* data/json/npcs/*/*/*
|
||||
# Also build chkjson (even though we're not using it), to catch any
|
||||
# compile errors there
|
||||
make -j "$num_jobs" chkjson
|
||||
elif [ -n "$JUST_JSON" ]
|
||||
then
|
||||
echo "Early exit on just-json change"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ccache --zero-stats
|
||||
# Increase cache size because debug builds generate large object files
|
||||
ccache -M 2G
|
||||
ccache --show-stats
|
||||
|
||||
if [ -n "$CMAKE" ]
|
||||
then
|
||||
bin_path="./"
|
||||
if [ "$RELEASE" = "1" ]
|
||||
then
|
||||
build_type=MinSizeRel
|
||||
bin_path="build/tests/"
|
||||
else
|
||||
build_type=Debug
|
||||
fi
|
||||
|
||||
cmake_extra_opts=
|
||||
|
||||
if [ "$CATA_CLANG_TIDY" = "plugin" ]
|
||||
then
|
||||
cmake_extra_opts="$cmake_extra_opts -DCATA_CLANG_TIDY_PLUGIN=ON"
|
||||
# Need to specify the particular LLVM / Clang versions to use, lest it
|
||||
# use the llvm-7 that comes by default on the Travis Xenial image.
|
||||
cmake_extra_opts="$cmake_extra_opts -DLLVM_DIR=/usr/lib/llvm-8/lib/cmake/llvm"
|
||||
cmake_extra_opts="$cmake_extra_opts -DClang_DIR=/usr/lib/llvm-8/lib/cmake/clang"
|
||||
fi
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake \
|
||||
-DBACKTRACE=ON \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DCMAKE_BUILD_TYPE="$build_type" \
|
||||
-DTILES=${TILES:-0} \
|
||||
-DSOUND=${SOUND:-0} \
|
||||
$cmake_extra_opts \
|
||||
..
|
||||
if [ -n "$CATA_CLANG_TIDY" ]
|
||||
then
|
||||
if [ "$CATA_CLANG_TIDY" = "plugin" ]
|
||||
then
|
||||
make -j$num_jobs CataAnalyzerPlugin
|
||||
export PATH=$PWD/tools/clang-tidy-plugin/clang-tidy-plugin-support/bin:$PATH
|
||||
if ! which FileCheck
|
||||
then
|
||||
ls -l tools/clang-tidy-plugin/clang-tidy-plugin-support/bin
|
||||
ls -l /usr/bin
|
||||
echo "Missing FileCheck"
|
||||
exit 1
|
||||
fi
|
||||
CATA_CLANG_TIDY=clang-tidy
|
||||
lit -v tools/clang-tidy-plugin/test
|
||||
fi
|
||||
|
||||
"$CATA_CLANG_TIDY" --version
|
||||
|
||||
# Run clang-tidy analysis instead of regular build & test
|
||||
# We could use CMake to create compile_commands.json, but that's super
|
||||
# slow, so use compiledb <https://github.com/nickdiego/compiledb>
|
||||
# instead.
|
||||
compiledb -n make
|
||||
|
||||
cd ..
|
||||
ln -s build/compile_commands.json
|
||||
|
||||
# We want to first analyze all files that changed in this PR, then as
|
||||
# many others as possible, in a random order.
|
||||
all_cpp_files="$( \
|
||||
grep '"file": "' build/compile_commands.json | \
|
||||
sed "s+.*$PWD/++;s+\"$++")"
|
||||
changed_cpp_files="$( \
|
||||
./build-scripts/files_changed | grep -F "$all_cpp_files" || true )"
|
||||
if [ -n "$changed_cpp_files" ]
|
||||
then
|
||||
remaining_cpp_files="$( \
|
||||
echo "$all_cpp_files" | grep -v -F "$changed_cpp_files" || true )"
|
||||
else
|
||||
remaining_cpp_files="$all_cpp_files"
|
||||
fi
|
||||
|
||||
function analyze_files_in_random_order
|
||||
{
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
echo "$1" | shuf | \
|
||||
xargs -P "$num_jobs" -n 1 ./build-scripts/clang-tidy-wrapper.sh -quiet
|
||||
else
|
||||
echo "No files to analyze"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Analyzing changed files"
|
||||
analyze_files_in_random_order "$changed_cpp_files"
|
||||
|
||||
echo "Analyzing remaining files"
|
||||
analyze_files_in_random_order "$remaining_cpp_files"
|
||||
else
|
||||
# Regular build
|
||||
make -j$num_jobs
|
||||
cd ..
|
||||
# Run regular tests
|
||||
[ -f "${bin_path}cata_test" ] && run_tests "${bin_path}cata_test"
|
||||
[ -f "${bin_path}cata_test-tiles" ] && run_tests "${bin_path}cata_test-tiles"
|
||||
fi
|
||||
elif [ "$NATIVE" == "android" ]
|
||||
then
|
||||
export USE_CCACHE=1
|
||||
export NDK_CCACHE="$(which ccache)"
|
||||
|
||||
# Tweak the ccache compiler analysis. We're using the compiler from the
|
||||
# Android NDK which has an unpredictable mtime, so we need to hash the
|
||||
# content rather than the size+mtime (which is ccache's default behaviour).
|
||||
export CCACHE_COMPILERCHECK=content
|
||||
|
||||
cd android
|
||||
# Specify dumb terminal to suppress gradle's constatnt output of time spent building, which
|
||||
# fills the log with nonsense.
|
||||
TERM=dumb ./gradlew assembleRelease -Pj=$num_jobs -Plocalize=false -Pabi_arm_32=false -Pabi_arm_64=true -Pdeps=/home/travis/build/CleverRaven/Cataclysm-DDA/android/app/deps.zip
|
||||
else
|
||||
make -j "$num_jobs" RELEASE=1 CCACHE=1 BACKTRACE=1 CROSS="$CROSS_COMPILATION" LINTJSON=0
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]
|
||||
then
|
||||
run_tests ./tests/cata_test
|
||||
else
|
||||
run_tests ./tests/cata_test &
|
||||
if [ -n "$MODS" ]
|
||||
then
|
||||
run_tests ./tests/cata_test --user-dir=modded $MODS &
|
||||
wait -n
|
||||
fi
|
||||
wait -n
|
||||
fi
|
||||
|
||||
if [ -n "$TEST_STAGE" ]
|
||||
then
|
||||
# Run the tests one more time, without actually running any tests, just to verify that all
|
||||
# the mod data can be successfully loaded
|
||||
|
||||
# Use a blacklist of mods that currently fail to load cleanly. Hopefully this list will
|
||||
# shrink over time.
|
||||
blacklist=build-scripts/mod_test_blacklist
|
||||
mods="$(./build-scripts/get_all_mods.py $blacklist)"
|
||||
run_tests ./tests/cata_test --user-dir=all_modded --mods="$mods" '~*'
|
||||
fi
|
||||
fi
|
||||
ccache --show-stats
|
||||
|
||||
# vim:tw=0
|
||||