Compare commits

102 Commits

Author SHA1 Message Date
Rémi Verschelde
4e7751913d SCons: Remove obsolete DEBUG_MEMORY_ENABLED define
As done in https://github.com/godotengine/godot/pull/40623.
2020-07-23 09:45:11 +02:00
Rémi Verschelde
a5ae9d9b6b Add README and Godot license text 2020-06-20 17:55:28 +02:00
Fabio Alessandrelli
c0dd6e76b7 Move mix_rate, ouput_latency to AudioDriverManager
Each driver used to define the (same) project settings values
`audio/mix_rate` and `audio/output_latency`, but the setting names are
not driver specific.
Overriding is still possible via platform tags.
2020-05-18 13:02:06 +02:00
Rémi Verschelde
828e1880a6 Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde
bae63f2ae2 Port member initialization from constructor to declaration (C++11)
Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
2020-05-14 10:01:56 +02:00
Rémi Verschelde
d11cd02300 Rename InputFilter back to Input
It changed name as part of the DisplayServer and input refactoring
in #37317, with the rationale that input no longer goes through the
main loop, so the previous Input singleton now only does filtering.

But the gains in consistency are quite limited in the renaming, and
it breaks compatibility for all scripts and tutorials that access
the Input singleton via the scripting language. A temporary option
was suggested to keep the scripting singleton named `Input` even if
its type is `InputFilter`, but that adds inconsistency and breaks C#.

Fixes godotengine/godot-proposals#639.
Fixes #37319.
Fixes #37690.
2020-04-28 15:19:49 +02:00
lupoDharkael
a5c4985328 Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rémi Verschelde
2283ef2994 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.
2020-03-30 09:05:53 +02:00
Juan Linietsky
c88ff48e36 Renaming of servers for coherency.
VisualServer -> RenderingServer
PhysicsServer -> PhysicsServer3D
Physics2DServer -> PhysicsServer2D
NavigationServer -> NavigationServer3D
Navigation2DServer -> NavigationServer2D

Also renamed corresponding files.
2020-03-27 15:21:27 -03:00
Juan Linietsky
cfd5f8f93e Refactored input, goes all via windows now.
Also renamed Input to InputFilter because all it does is filter events.
2020-03-26 15:49:39 +01:00
Juan Linietsky
51607cbb93 Refactored Input, create DisplayServer and DisplayServerX11 2020-03-26 15:49:32 +01:00
Rémi Verschelde
46ef18cfff Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodes
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
2020-03-01 23:00:42 +01:00
Pedro J. Estébanez
6c8d166b84 Reimplement Mutex with C++'s <mutex>
Main:
- It's now implemented thanks to `<mutex>`. No more platform-specific implementations.
- `BinaryMutex` (non-recursive) is added, as an alternative for special cases.
- Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes.
- Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts.
- A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this.
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- Thread-safe utilities are therefore simpler now.

Misc.:
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
- Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock).
- `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-26 20:40:10 +01:00
bruvzg
372cff5481 Rename scancode to keycode.
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap.
Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
2020-02-25 12:30:33 +02:00
Rémi Verschelde
1aa04a5ce2 Remove incomplete battery status/power API
It was initially implemented in #5871 for Godot 3.0, but never really
completed or thoroughly tested for most platforms. It then stayed in
limbo and nobody seems really keen to finish it, so it's better to
remove it in 4.0, and re-add eventually (possibly with a different API)
if there's demand and an implementation confirmed working on all
platforms.

Closes #8770.
2020-02-14 13:43:32 +01:00
Rémi Verschelde
72061c8ec9 Remove obsolete GLES3 backend
Due to the port to Vulkan and complete redesign of the rendering backend,
the `drivers/gles3` code is no longer usable in this state and is not
planned to be ported to the new architecture.

The GLES2 backend is kept (while still disabled and non-working) as it
will eventually be ported to serve as the low-end renderer for Godot 4.0.

Some GLES3 features might be selectively ported to the updated GLES2
backend if there's a need for them, and extensions we can use for that.

So long, OpenGL driver bugs!
2020-02-13 10:36:44 +01:00
Rémi Verschelde
df6fd145a4 Image: Include S3TC compression via Squish in non-tools build
We already build Squish in templates build for S3TC decompression,
so we can as well expose the compression feature.

Fixes #25640.
2020-01-13 15:58:49 +01:00
Rémi Verschelde
2e98068c7d Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
bruvzg
68ea8aaa10 iOS modular build and export implementation. 2019-12-01 21:57:18 +02:00
Fabio Alessandrelli
4f8866df84 Remove libwebsocket. No longer used, yay! 2019-07-04 15:03:04 +02:00
Rémi Verschelde
289fa4347e SCons: Use CPPDEFINES instead of CPPFLAGS for pre-processor defines
It's the recommended way to set those, and is more portable
(automatically prepends -D for GCC/Clang and /D for MSVC).

We still use CPPFLAGS for some pre-processor flags which are not
defines.
2019-07-03 09:59:04 +02:00
Ibrahn Sahir
7ec9c75f82 Png driver reworked to use libpng 1.6 simplified API
Wrapped libpng usage in a pair of functions under PNGDriverCommon,
which convert between Godot Image and png data.
Switched to libpng 1.6 simplified API for ease of maintenance.
Implemented ImageLoaderPNG and ResourceSaverPNG in terms of
PNGDriverCommon functions.
Travis, switched to builtin libpng (thus builtin freetype and zlib also)
so we can build on Xenial.
2019-06-19 11:05:58 +01:00
BastiaanOlij
2511f40e25 Adding a new Camera Server implementation to Godot.
This is a new singleton where camera sources such as webcams or cameras on a mobile phone can register themselves with the Server.
Other parts of Godot can interact with this to obtain images from the camera as textures.
This work includes additions to the Visual Server to use this functionality to present the camera image in the background. This is specifically targetted at AR applications.
2019-06-15 21:30:32 +10:00
hbina085
d53c20c5f4 added a const keyword for a methods that return constant literal... 2019-05-21 02:16:30 -04:00
Rémi Verschelde
02705ef2cb SCons: Always use env.Prepend for CPPPATH
Include paths are processed from left to right, so we use Prepend to
ensure that paths to bundled thirdparty files will have precedence over
system paths (e.g. `/usr/include` should have lowest priority).
2019-04-30 13:12:06 +02:00
Rémi Verschelde
fc6c5bd709 SCons: Review uses of CCFLAGS, CXXFLAGS and CPPFLAGS
Many contributors (me included) did not fully understand what CCFLAGS,
CXXFLAGS and CPPFLAGS refer to exactly, and were thus not using them
in the way they are intended to be.

As per the SCons manual: https://www.scons.org/doc/HTML/scons-user/apa.html

- CCFLAGS: General options that are passed to the C and C++ compilers.
- CFLAGS: General options that are passed to the C compiler (C only;
  not C++).
- CXXFLAGS: General options that are passed to the C++ compiler. By
  default, this includes the value of $CCFLAGS, so that setting
  $CCFLAGS affects both C and C++ compilation.
- CPPFLAGS: User-specified C preprocessor options. These will be
  included in any command that uses the C preprocessor, including not
  just compilation of C and C++ source files [...], but also [...]
  Fortran [...] and [...] assembly language source file[s].

TL;DR: Compiler options go to CCFLAGS, unless they must be restricted
to either C (CFLAGS) or C++ (CXXFLAGS). Preprocessor defines go to
CPPFLAGS.
2019-04-24 16:57:58 +02:00
Guilherme Felipe
3b0d863ac7 Add Input::get_current_cursor_shape
[Clean up] Removed unused/unnecessary methods.
2019-04-15 15:22:09 -03:00
Sebastian Hartte
7dd7757708 Remove ContextGL since as an abstraction it's unused. 2019-04-06 17:52:52 +02:00
Rémi Verschelde
4e32ea9f05 Use mix rate and output latency constants in audio drivers
Fix default mix rate in Xaudio2 and potential shadowing issue in JAndroid.
2019-04-06 12:37:25 +02:00
Juan Linietsky
da2523458e -Remove harcoded opengl extension testing from OS, ask rasterizer instead.
-Fixed a bug where etc textures were imported broken
2019-02-26 11:58:47 -03:00
Hein-Pieter van Braam
c89b26f883 Don't use -ffast-math or other unsafe math optimizations
Godot supports many different compilers and for production releases we
have to support 3 currently: GCC8, Clang6, and MSVC2017. These compilers
all do slightly different things with -ffast-math and it is causing
issues now. See #24841, #24540, #10758, #10070. And probably other
complaints about physics differences between release and release_debug
builds.

I've done some performance comparisons on Linux x86_64. All tests are
ran 20 times.

Bunnymark: (higher is better)
(bunnies)    min    max  stdev average
fast-math   7332   7597    71     7432
this pr     7379   7779   108     7621 (102%)

FPBench (gdscript port http://fpbench.org/) (lower is better)
(ms)
fast-math  15441  16127   192    15764
this pr    15671  16855   326    16001  (99%)

Float_add (adding floats in a tight loop) (lower is better)
(sec)
fast-math   5.49   5.78  0.07     5.65
this pr     5.65   5.90  0.06     5.76  (98%)

Float_div (dividing floats in a tight loop) (lower is better)
(sec)
fast-math  11.70  12.36  0.18    11.99
this pr    11.92  12.32  0.12    12.12  (99%)

Float_mul (multiplying floats in a tight loop) (lower is better)
(sec)
fast-math  11.72  12.17  0.12    11.93
this pr    12.01  12.62  0.17    12.26  (97%)

I have also looked at FPS numbers for tps-demo, 3d platformer, 2d
platformer, and sponza and could not find any measurable difference.

I believe that given the issues and oft-reported (physics) glitches on
release builds I believe that the couple of percent of tight-loop
floating point performance regression is well worth it.

This fixes #24540 and fixes #24841
2019-01-09 02:06:13 +01:00
Rémi Verschelde
390903b16d Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Rémi Verschelde
84bf66df19 Fix init of VisualServerRaster
Contrarily to what #23434 assumed, this is not a memory leak,
the VisualServerRaster instance is passed as a parameter to
VisualServerWrapMT's constructor.

Fixes #23437.
2018-11-01 19:23:12 +01:00
George Marques
a8bf18945d Fix initialization of visual server in all platforms
Avoid leaking an extra instance when using threads. Also fix threaded
loading issues on Android and iOS.
2018-11-01 10:27:04 -03:00
Aaron Franke
0cbdd5a965 Remove redundant "== true" code
If it can be compared to a boolean, it can be evaluated as one in-place.
2018-10-06 16:12:36 -04:00
Rémi Verschelde
ba121dfdcc Fix warnings on virtual methods [-Woverloaded-virtual] [-Wdelete-non-virtual-dtor]
Fixes the following Clang 7 warnings:
```
editor/editor_help.h:123:7: warning: 'EditorHelpIndex::popup' hides overloaded virtual function [-Woverloaded-virtual]
editor/editor_help.h:95:7: warning: 'EditorHelpSearch::popup' hides overloaded virtual function [-Woverloaded-virtual]
editor/editor_help.h:96:7: warning: 'EditorHelpSearch::popup' hides overloaded virtual function [-Woverloaded-virtual]
editor/plugins/curve_editor_plugin.h:141:15: warning: 'CurvePreviewGenerator::generate' hides overloaded virtual function [-Woverloaded-virtual]
editor/plugins/script_editor_plugin.h:70:7: warning: 'ScriptEditorQuickOpen::popup' hides overloaded virtual function [-Woverloaded-virtual]
editor/quick_open.h:69:7: warning: 'EditorQuickOpen::popup' hides overloaded virtual function [-Woverloaded-virtual]
main/tests/test_io.cpp:53:15: warning: 'TestIO::TestMainLoop::input_event' hides overloaded virtual function [-Woverloaded-virtual]
servers/audio/effects/audio_effect_record.h:69:15: warning: 'AudioEffectRecordInstance::process_silence' hides overloaded virtual function [-Woverloaded-virtual]

core/os/memory.h:119:2: warning: destructor called on non-final 'ContextGL_X11' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
core/os/memory.h:119:2: warning: destructor called on non-final 'EditorScriptCodeCompletionCache' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
core/os/memory.h:119:2: warning: destructor called on non-final 'Engine' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
core/os/memory.h:119:2: warning: destructor called on non-final 'PhysicalBone::JointData' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
core/os/memory.h:119:2: warning: destructor called on non-final 'VisualServerScene' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
core/os/memory.h:119:2: warning: destructor called on non-final 'VisualServerViewport' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
```
2018-10-02 13:40:17 +02:00
Rémi Verschelde
b52e4fd2c7 SCons: Remove avoidable defines from main env's CPPPATH
Also finally move freetype to its own env and disable warnings for it.
Still needs some work to fix the awkward situation of the freetype and
svg modules used in scene/ and editor/ respectively.
2018-10-01 11:59:22 +02:00
Rémi Verschelde
4ba037a9c2 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Adrien Destugues
6624b186ba Rebase patches for fixing haiku build. 2018-08-11 17:20:51 +02:00
Rémi Verschelde
748ff3d520 Fix some more build issues after c69de2ba4
Fixes #20301.
2018-07-20 11:56:18 +02:00
Juan Linietsky
e0d6362e5c -Project/Editor settings now use new inspector
-Project/Editor settings now show tooltips properly
-Settings thar require restart now will show a restart warning
-Video driver is now visible all the time, can be changed easily
-Added function to request current video driver
2018-07-19 19:02:04 -03:00
Hugo Locurcio
a221c85800 Optimize images losslessly using oxipng -o6 --strip all --zopfli 2018-06-28 19:17:41 +02:00
Hugo Locurcio
6aa5d63ca7 Tweak some help texts in the build system
This also removes `unix_global_settings_path` from SConstruct
since it is no longer used.
2018-06-07 21:40:54 +02:00
Rémi Verschelde
63cbf6d2f0 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Duy-Nguyen TA
2d8ccae545 Fix macOS and other builds after #15299
Commit ammended by @akien-mga to fix more platforms.
2018-01-04 19:48:05 +01:00
Emmanuel Leblond
52f44a96ba Change OS::initialize signature to return Error (fix segfault on x11) 2018-01-04 15:15:55 +01:00
Rémi Verschelde
ac7319b508 Merge pull request #12814 from guilhermefelipecgs/add_hardware_custom_cursor
Custom hardware-accelerated mouse cursor
2018-01-03 08:35:59 +01:00
Rémi Verschelde
55e60cf44a Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
Guilherme Silva
254c8a3142 Add implementation for custom hardware cursor 2017-12-17 13:40:29 -02:00
Stefano Bonicatti
d5bffbe3cb Fixes vsync setting ignored when using a separate thread for rendering
Setting the vsync in the main thread, after the rendering thread starts
and takes the OpenGL context fails, so we need to do that before.
Also, for some reason, the main thread cannot make current the context
anymore.

Fixes #13447
2017-12-09 01:43:23 +01:00
Rémi Verschelde
98ed70d40e Style: Apply new clang-format 5.0 style to all files 2017-12-07 08:02:00 +01:00
Rémi Verschelde
b65c6801b2 Style: Apply clang-format again on all files
Fixes issues introduced by newer clang-format versions or commits
pushed directly without using the clang-format pre-commit hook.
2017-12-07 08:02:00 +01:00
Rhody Lugo
b3ca68fa6d disable caching for targets using helper functions 2017-11-28 23:24:12 -04:00
Rémi Verschelde
f1a088314f Merge pull request #12988 from akien-mga/xdg-home-paths
Add support for XDG Base Directory spec
2017-11-20 00:42:51 +01:00
Rémi Verschelde
63bab816a6 Add initial support for the XDG Base Directory spec
Spec version 0.7 from https://standards.freedesktop.org/basedir-spec/basedir-spec-0.7.html
(latest as of this commit).

Three virtual methods are added to OS for the various XDG paths we will use:
- OS::get_data_path gives XDG_DATA_HOME, or if missing:
  ~/.local/share on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_config_path gives XDG_CONFIG_HOME, or if missing:
  ~/.config on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_cache_path gives XDG_CACHE_HOME, or if missing:
  ~/.cache on X11, ~/Library/Caches on macOS and %APPDATA% on Windows

So for Windows there are no changes, for Linux we follow the full split spec
and for macOS stuff will move from ~/.godot to ~/Library/Application Support/Godot.

Support for system-wide installation of templates on Unix was removed for now,
as it's a bit hackish and I don't think anyone uses it.

user:// will still be OS::get_data_path() + "/godot/app_userdata/$name" by
default, but when using the application/config/use_shared_user_dir option
it will now use XDG_DATA_HOME/$name, e.g. ~/.local/share/MyGame.

For now everything still goes in EditorSettings::get_settings_dir(), but
this will be changed in a later commit to make use of the new splitting
where relevant.

Part of #3513.
2017-11-19 20:54:24 +01:00
Rémi Verschelde
013a355eef Cleanup old references to GLES2 renderer
There are still some left in the Android Java code, even stuff to swap between
GLES1 and GLES2 support from early Godot days... would be good to see some cleanup
there too one day.

The "graphics/api" option for Android exports is removed, as only GLES 3.0 is supported.
It can be readded when GLES 2.0 support comes back. Fixes #13004.
2017-11-19 17:52:18 +01:00
Juan Linietsky
d22c0d4025 Make video mode initialization more intuitive, fixes #12022 2017-11-09 13:02:26 -03:00
AndreaCatania
256f1096b5 Implemented physics plug
Moved init_physics

Implemented physics 2D plug

Fix clang

Fix clang

Fix static check

Fix clang

Fix static check

Moved physics server initialization

Moved physics server settings initialization
2017-11-04 03:25:51 +01:00
Rémi Verschelde
218fd3070c Drop unusued LEGACYGL_ENABLED check
[ci skip]
2017-10-13 00:18:04 +02:00
Elliott Sales de Andrade
c285f10f2e Use EnumVariable for choice-based build options. 2017-09-25 14:36:01 -04:00
Rémi Verschelde
a37d7598b0 Merge pull request #11243 from hpvb/add-debug-info-on-release
Create separate debug info files by default
2017-09-21 10:30:17 +02:00
letheed
f0b665f387 Rename pos to position in user facing methods and variables
Rename user facing methods and variables as well as the corresponding
C++ methods according to the folloming changes:

* pos -> position
* rot -> rotation
* loc -> location

C++ variables are left as is.
2017-09-20 13:11:10 +02:00
Rémi Verschelde
e83891b599 Merge pull request #11252 from marcelofg55/fix_noaudio_crash
Fix crash when no audio driver is available
2017-09-17 22:48:22 +02:00
Hein-Pieter van Braam
380b249aee Create separate debug info files by default
Now that we have a built-in stacktrace on a segfault it would be useful
to have debug information on debug_release builds so that bugreports can
include this information. Without this debug info we will still get
function names in the backtrace but not file location.

This commit will by default build all targets with minimal debug info
and then strip the information into separate files. On MacOS this is a
.dSYM file, on Linux/MingW this is a .debug file. MacOSX will
automatically load a dSYM file if it exists in its debugger. On
Linux/MingW we create a 'gnu debuglink' meaning that gdb and friends
will automatically find the debug symbols if they exist.

Existing workflow for developers does not change at all, except that we
now create two instead of one build artifact by default.

This commit also adds a 'debug_symbols' option to X11, MacOS, and MingW
targets. The default is 'yes' which corresponds to -g1. The alternatives
are 'no' (don't generate debug infos at all) or 'full' which runs with
-g2. A target=debug build will now build with -g3.
2017-09-16 12:00:46 +02:00
Marcelo Fernandez
e89ab74585 Fix crash when no audio driver is available 2017-09-13 20:54:55 -03:00
Maxim Sheronov
b1f8f3b3c2 Fix enums bindings
Add missed bindings for enums
Move some enums to class to have correct output of api.json
2017-09-13 20:57:07 +03:00
Rémi Verschelde
35d66b703b Dead code tells no tales 2017-08-27 22:13:45 +02:00
Rémi Verschelde
79fdaf5cbd Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
Marcelo Fernandez
06ad740677 p_screen param from get_screen_* funcs now default to the current screen 2017-08-21 18:28:29 -03:00
Marcelo Fernandez
e350dcf2fd Add closest_power_of_2 func and implement mix_rate/latency on OS X 2017-08-17 19:51:13 -03:00
Bojidar Marinov
0a405bcc93 Rename KEY_RETURN to KEY_ENTER and KEY_ENTER to KEY_KP_ENTER
Closes #7695
2017-08-06 16:26:07 +03:00
Juan Linietsky
3b8757f444 -Renamed GlobalConfig to ProjectSettings, makes more sense.
-Added system for feature overrides, it's pretty cool :)
2017-07-19 17:06:03 -03:00
Rémi Verschelde
a5e32eb15a Buildsystem: Improve detect.py readability and fix issues
Tried to organize the configure(env) calls in sections, using the same order
for all platforms whenever possible.

Apart from cosmetic changes, the following issues were fixed:
- Android: cleanup linkage, remove GLESv1_CM and GLESv2
- iPhone: Remove obsolete "ios_gles22_override" option
- OSX:
  * Fix bits detection (default to 64) and remove obsolete "force_64_bits" option
    (closes #9449)
  * Make "fat" bits argument explicit
- Server: sync with X11
- Windows: clean up old DirectX 9 stuff
- X11:
  * Do not require system OpenSSL for building (closes #9443)
  * Fix typo'ed use_leak_sanitizer option
  * Fix .llvm suffix overriding custom extra_suffix
2017-07-01 08:20:51 +02:00
Juan Linietsky
7c32f3fd7d Removal of InputEvent as built-in Variant type..
this might cause bugs I haven't found yet..
2017-05-20 17:05:38 -03:00
Sergey Pusnei
fe4fba9e7f Rename [gs]et_pos to [gs]et_position for Controls
Control set_pos -> set_position
Control set_global_pos -> set_global_position
[gs]et_mouse_pos -> [gs]et_mouse_position
[gs]et_global_mouse_pos -> [gs]et_global_mouse_position
fixes #8005
2017-04-10 08:27:34 +02:00
Rémi Verschelde
65f26a9703 Add "Godot Engine contributors" copyright line 2017-04-08 00:11:42 +02:00
Rémi Verschelde
afce5944ff Merge pull request #8159 from Hinsbart/last_id
Input: Remove usage of platform dependent event IDs.
2017-03-27 08:52:58 +02:00
Rémi Verschelde
c3ac9f1816 SCons: Add option to toggle warnings (on by default)
All the warnings are factored out of the platform-specific files and moved to
SConstruct. Will have to check that it does not introduce regressions on some
platforms/compilers.

(cherry picked from commit 31107daa1a41fe9ab3c7c1868479e78e16848333)
2017-03-26 21:58:37 +02:00
Andreas Haas
b3a496acb0 Input: Remove usage of platform dependent event IDs.
The ID property for InputEvents is set by `SceneTree` when sending the event down the tree.
So there's no need for the platform specific code to set this value when it will later be overriden anyway...
2017-03-26 15:59:32 +02:00
Rémi Verschelde
78354332c6 Fix typos in source code using codespell
From https://github.com/lucasdemarchi/codespell
2017-03-24 21:45:31 +01:00
Rémi Verschelde
9b443edfd9 A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?

I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon

A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format

A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
2017-03-05 16:44:50 +01:00
Rémi Verschelde
4d865b764a Add a bunch of missing Godot headers in own files 2017-03-05 15:47:28 +01:00
Julian Murgia
1d08349ce9 Add API to access battery power state
Done:
- X11, server (tested)
- Windows (developed, would be nice to retest)
- OSX (not tested)
Prepared (not developed):
- Android (code is here, but may not compile)
- iphone
- winrt
- bb10
- haiku
- javascript
2017-03-04 18:04:29 +01:00
Bojidar Marinov
e6272fe76e Complete the globals.h -> global_config.h conversion 2017-02-23 17:47:25 +02:00
Rémi Verschelde
e8eba252b7 Adapt platforms to AudioServer refactoring
Fixes compilation on Windows and likely other platforms (at least
as far as AudioServer changes were concerned), though they were
not tested.
2017-01-16 19:19:45 +01:00
Juan Linietsky
24596acf47 Oops! Audio engine has vanished :D 2017-01-15 16:07:51 -03:00
Rémi Verschelde
15c3dfeff2 Style: Fix whole-line commented code
They do not play well with clang-format which aligns the `//` part
with the rest of the code block, thus producing badly indented commented code.
2017-01-14 14:52:23 +01:00
Juan Linietsky
6afb936cb6 rename Input.get_mouse_speed() to Input.get_last_mouse_speed() 2017-01-13 19:24:28 -03:00
Rémi Verschelde
1c76c18b91 Remove bundled glew, obsoleted by glad
Also make Haiku load the glad header for GLES3 too,
though I haven't test it.
2017-01-06 22:56:51 +01:00
Rémi Verschelde
2848f31173 Welcome in 2017, dear changelog reader!
That year should bring the long-awaited OpenGL ES 3.0 compatible renderer
with state-of-the-art rendering techniques tuned to work as low as middle
end handheld devices - without compromising with the possibilities given
for higher end desktop games of course. Great times ahead for the Godot
community and the gamers that will play our games!
2017-01-01 22:03:33 +01:00
Rémi Verschelde
3c8293e224 style: Fix PEP8 blank lines issues in Python files
Done with `autopep8 --select=E3,W3`, fixes:

- E301 - Add missing blank line.
- E302 - Add missing 2 blank lines.
- E303 - Remove extra blank lines.
- E304 - Remove blank line following function decorator.
- E309 - Add missing blank line.
- W391 - Remove trailing blank lines.
2016-11-01 00:35:16 +01:00
Rémi Verschelde
fbaab7f70a style: Fix PEP8 whitespace issues in Python files
Done with `autopep8 --select=E2,W2`, fixes:

- E201 - Remove extraneous whitespace.
- E202 - Remove extraneous whitespace.
- E203 - Remove extraneous whitespace.
- E211 - Remove extraneous whitespace.
- E221 - Fix extraneous whitespace around keywords.
- E222 - Fix extraneous whitespace around keywords.
- E223 - Fix extraneous whitespace around keywords.
- E224 - Remove extraneous whitespace around operator.
- E225 - Fix missing whitespace around operator.
- E226 - Fix missing whitespace around operator.
- E227 - Fix missing whitespace around operator.
- E228 - Fix missing whitespace around operator.
- E231 - Add missing whitespace.
- E231 - Fix various deprecated code (via lib2to3).
- E241 - Fix extraneous whitespace around keywords.
- E242 - Remove extraneous whitespace around operator.
- E251 - Remove whitespace around parameter '=' sign.
- E261 - Fix spacing after comment hash.
- E262 - Fix spacing after comment hash.
- E265 - Format block comments.
- E271 - Fix extraneous whitespace around keywords.
- E272 - Fix extraneous whitespace around keywords.
- E273 - Fix extraneous whitespace around keywords.
- E274 - Fix extraneous whitespace around keywords.
- W291 - Remove trailing whitespace.
- W293 - Remove trailing whitespace.
2016-11-01 00:35:16 +01:00
Rémi Verschelde
92f4413a5e style: Start applying PEP8 to Python files, indentation issues
Done with `autopep8 --select=E1`, fixes:

- E101 - Reindent all lines.
- E112 - Fix under-indented comments.
- E113 - Fix over-indented comments.
- E115 - Fix under-indented comments.
- E116 - Fix over-indented comments.
- E121 - Fix a badly indented line.
- E122 - Fix a badly indented line.
- E123 - Fix a badly indented line.
- E124 - Fix a badly indented line.
- E125 - Fix indentation undistinguish from the next logical line.
- E126 - Fix a badly indented line.
- E127 - Fix a badly indented line.
- E128 - Fix a badly indented line.
- E129 - Fix a badly indented line.
2016-11-01 00:33:51 +01:00
Rémi Verschelde
a823cee5ce SCsub: Add python shebang as a hint for syntax highlighting
Also switch existing shebangs to "better" /usr/bin/env python.
2016-10-17 20:10:46 +02:00
Rémi Verschelde
472bf523ed zlib: Split thirdparty files, simplify scons option 2016-10-15 12:20:47 +02:00
Rémi Verschelde
e3023c29f6 glew: Split thirdparty files and isolate env
Not fully happy about the way this one interacts with the various
platforms. Maybe the platform_config.h should be generated by the
SCsub instead of passing a define just to know where is the header.
2016-10-15 12:01:28 +02:00
Jamil Halabi
1687b8023a Fixed building for latest Haiku nightlies. 2016-06-29 15:40:25 -04:00
J08nY
d903be77a8 Fixed iCCp chunk in pngs
neccesary for libpng 1.6.27 to work silently
2016-06-22 21:13:29 +02:00
Rémi Verschelde
4e83a47856 Add missing license headers in our source files (#5255)
Also removes a couple wrong Godot headers from third-party source files.
2016-06-18 14:46:12 +02:00
Rémi Verschelde
e1cb00e214 GLEW: Define static + enabled and includes via SCons
This allows us not to have to hack our definitions in the upstream files,
making it easier to upgrade to newer versions in the future.

For the include paths to work, the headers are moved to a GL subfolder to
match their upstream location.
2016-06-08 00:16:27 +02:00
Rémi Verschelde
c147f8a3e4 Haiku: Do not define GLEW_ENABLED to undefine it later
Partial revert of f61eb5fd8e13642c82364f8ee66a0f6c791a4511.
2016-06-08 00:10:30 +02:00
Hubert Jarosz
4c4ac1a8cd remove trailing whitespace 2016-03-09 00:00:52 +01:00
21 changed files with 1016 additions and 406 deletions

20
LICENSE.txt Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
Copyright (c) 2014-2020 Godot Engine contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

53
README.md Normal file
View File

@@ -0,0 +1,53 @@
## Godot Engine platform port for Haiku
This is the platform port of [Godot Engine](https://godotengine.org) for the
[Haiku](https://www.haiku-os.org) operating system.
Haiku is not an officially supported platform in the main tree of Godot, so
this port is kept separate so that it can be contributed to independently of
Godot's main release cycle.
It may imply that this port might not be functional for the latest versions of
Godot. For the time being, neither the `3.2` branch nor the `master` branch are
functional out-of-the-box on Haiku.
We welcome all contributions from Haiku developers to ensure that each branch
and Git tag of this repository work as expected with the matching branches and
tags of the [Godot repository](https://github.com/godotengine/godot/).
## Usage
This code is meant to be copied as `platform/haiku` in the Godot Engine
[source repository](https://github.com/godotengine/godot/) to make builds of
Godot for Haiku.
It can also be cloned as a Git submodule:
```
git clone https://github.com/godotengine/godot
cd godot
git submodule add https://github.com/godotengine/godot-haiku-platform platform/haiku
```
Be sure to use compatible branches for the Godot repository and the Haiku port.
You can then compile Godot for Haiku with:
```
# Editor build, optimized.
scons p=haiku tools=yes target=release_debug
# Export template, debug.
scons p=haiku tools=no target=release_debug
# Export template, release.
scons p=haiku tools=no target=release
```
## License
This port is distributed under the MIT license, with the same copyright as the
main Godot source repository.
See [LICENSE.txt](/LICENSE.txt) for details, and
[AUTHORS.md](https://github.com/godotengine/godot/blob/master/AUTHORS.md) in
the Godot repository for a list of contributors.

32
SCsub
View File

@@ -1,25 +1,25 @@
Import('env')
#!/usr/bin/env python
Import("env")
common_haiku = [
'os_haiku.cpp',
'context_gl_haiku.cpp',
'haiku_application.cpp',
'haiku_direct_window.cpp',
'haiku_gl_view.cpp',
'key_mapping_haiku.cpp',
'audio_driver_media_kit.cpp'
"os_haiku.cpp",
"context_gl_haiku.cpp",
"haiku_application.cpp",
"haiku_direct_window.cpp",
"haiku_gl_view.cpp",
"key_mapping_haiku.cpp",
"audio_driver_media_kit.cpp",
]
target = env.Program(
'#bin/godot',
['godot_haiku.cpp'] + common_haiku
)
target = env.add_program("#bin/godot", ["godot_haiku.cpp"] + common_haiku)
command = env.Command('#bin/godot.rsrc', '#platform/haiku/godot.rdef',
['rc -o $TARGET $SOURCE'])
command = env.Command("#bin/godot.rsrc", "#platform/haiku/godot.rdef", ["rc -o $TARGET $SOURCE"])
def addResourcesAction(target=None, source=None, env=None):
return env.Execute("xres -o " + File(target)[0].path + " bin/godot.rsrc")
def addResourcesAction(target = None, source = None, env = None):
return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc')
env.AddPostAction(target, addResourcesAction)
env.Depends(target, command)

View File

@@ -3,9 +3,10 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,23 +27,24 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_driver_media_kit.h"
#ifdef MEDIA_KIT_ENABLED
#include "globals.h"
#include "core/project_settings.h"
int32_t* AudioDriverMediaKit::samples_in = NULL;
int32_t *AudioDriverMediaKit::samples_in = nullptr;
Error AudioDriverMediaKit::init() {
active = false;
mix_rate = 44100;
output_format = OUTPUT_STEREO;
mix_rate = GLOBAL_GET("audio/mix_rate");
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
int latency = GLOBAL_GET("audio/output_latency");
buffer_size = next_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
media_raw_audio_format format;
@@ -54,27 +56,25 @@ Error AudioDriverMediaKit::init() {
format.buffer_size = buffer_size * sizeof(int32_t) * channels;
player = new BSoundPlayer(
&format,
"godot_sound_server",
AudioDriverMediaKit::PlayBuffer,
NULL,
this
);
&format,
"godot_sound_server",
AudioDriverMediaKit::PlayBuffer,
nullptr,
this);
if (player->InitCheck() != B_OK) {
fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n");
ERR_FAIL_COND_V(player == NULL, ERR_CANT_OPEN);
ERR_FAIL_COND_V(player == nullptr, ERR_CANT_OPEN);
}
mutex = Mutex::create();
player->Start();
return OK;
}
void AudioDriverMediaKit::PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format) {
AudioDriverMediaKit* ad = (AudioDriverMediaKit*) cookie;
int32_t* buf = (int32_t*) buffer;
void AudioDriverMediaKit::PlayBuffer(void *cookie, void *buffer, size_t size, const media_raw_audio_format &format) {
AudioDriverMediaKit *ad = (AudioDriverMediaKit *)cookie;
int32_t *buf = (int32_t *)buffer;
if (!ad->active) {
for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
@@ -99,22 +99,22 @@ int AudioDriverMediaKit::get_mix_rate() const {
return mix_rate;
}
AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const {
return output_format;
AudioDriverMediaKit::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const {
return speaker_mode;
}
void AudioDriverMediaKit::lock() {
if (!mutex)
return;
mutex->lock();
mutex.lock();
}
void AudioDriverMediaKit::unlock() {
if (!mutex)
return;
mutex->unlock();
mutex.unlock();
}
void AudioDriverMediaKit::finish() {
@@ -123,20 +123,13 @@ void AudioDriverMediaKit::finish() {
if (samples_in) {
memdelete_arr(samples_in);
};
if (mutex) {
memdelete(mutex);
mutex = NULL;
}
}
AudioDriverMediaKit::AudioDriverMediaKit() {
mutex = NULL;
player = NULL;
player = nullptr;
}
AudioDriverMediaKit::~AudioDriverMediaKit() {
}
#endif

View File

@@ -3,9 +3,10 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,41 +27,42 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "servers/audio/audio_server_sw.h"
#include "servers/audio_server.h"
#ifdef MEDIA_KIT_ENABLED
#include "core/os/thread.h"
#include "core/os/mutex.h"
#include "core/os/thread.h"
#include <kernel/image.h> // needed for image_id
#include <SoundPlayer.h>
class AudioDriverMediaKit : public AudioDriverSW {
Mutex* mutex;
class AudioDriverMediaKit : public AudioDriver {
Mutex mutex;
BSoundPlayer* player;
static int32_t* samples_in;
BSoundPlayer *player;
static int32_t *samples_in;
static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format);
static void PlayBuffer(void *cookie, void *buffer, size_t size, const media_raw_audio_format &format);
unsigned int mix_rate;
OutputFormat output_format;
SpeakerMode speaker_mode;
unsigned int buffer_size;
int channels;
bool active;
public:
const char* get_name() const {
const char *get_name() const {
return "MediaKit";
};
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
virtual OutputFormat get_output_format() const;
virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();

View File

@@ -1,12 +1,44 @@
/*************************************************************************/
/* context_gl_haiku.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "context_gl_haiku.h"
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
#if defined(OPENGL_ENABLED)
ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow* p_window) {
ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow *p_window) {
window = p_window;
uint32 type = BGL_RGB | BGL_DOUBLE | BGL_DEPTH;
view = new HaikuGLView(window->Bounds(), type);
use_vsync = false;
}
ContextGL_Haiku::~ContextGL_Haiku() {
@@ -29,7 +61,7 @@ void ContextGL_Haiku::make_current() {
}
void ContextGL_Haiku::swap_buffers() {
view->SwapBuffers();
view->SwapBuffers(use_vsync);
}
int ContextGL_Haiku::get_window_width() {
@@ -38,6 +70,14 @@ int ContextGL_Haiku::get_window_width() {
int ContextGL_Haiku::get_window_height() {
return window->Bounds().IntegerHeight();
}
}
void ContextGL_Haiku::set_use_vsync(bool p_use) {
use_vsync = p_use;
}
bool ContextGL_Haiku::is_using_vsync() const {
return use_vsync;
}
#endif

View File

@@ -1,28 +1,61 @@
/*************************************************************************/
/* context_gl_haiku.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef CONTEXT_GL_HAIKU_H
#define CONTEXT_GL_HAIKU_H
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
#include "drivers/gl_context/context_gl.h"
#if defined(OPENGL_ENABLED)
#include "haiku_direct_window.h"
#include "haiku_gl_view.h"
class ContextGL_Haiku : public ContextGL {
class ContextGL_Haiku {
private:
HaikuGLView* view;
HaikuDirectWindow* window;
HaikuGLView *view;
HaikuDirectWindow *window;
bool use_vsync;
public:
ContextGL_Haiku(HaikuDirectWindow* p_window);
~ContextGL_Haiku();
Error initialize();
void release_current();
void make_current();
void swap_buffers();
int get_window_width();
int get_window_height();
virtual Error initialize();
virtual void release_current();
virtual void make_current();
virtual void swap_buffers();
virtual int get_window_width();
virtual int get_window_height();
void set_use_vsync(bool p_use);
bool is_using_vsync() const;
ContextGL_Haiku(HaikuDirectWindow *p_window);
~ContextGL_Haiku();
};
#endif

176
detect.py
View File

@@ -1,62 +1,158 @@
import os
import sys
def is_active():
return True
return True
def get_name():
return "Haiku"
return "Haiku"
def can_build():
if (os.name != "posix"):
return False
if (sys.platform == "darwin"):
return False
if os.name != "posix" or sys.platform == "darwin":
return False
return True
return True
def get_opts():
return [
('debug_release', 'Add debug symbols to release version','no')
]
from SCons.Variables import EnumVariable
return [
EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")),
]
def get_flags():
return [
('builtin_zlib', 'no')
]
return []
def configure(env):
is64 = sys.maxsize > 2**32
if (env["bits"]=="default"):
if (is64):
env["bits"]="64"
else:
env["bits"]="32"
## Build type
env.Append(CPPPATH = ['#platform/haiku'])
if env["target"] == "release":
env.Prepend(CCFLAGS=["-O3"])
if env["debug_symbols"] == "yes":
env.Prepend(CCFLAGS=["-g1"])
if env["debug_symbols"] == "full":
env.Prepend(CCFLAGS=["-g2"])
env["CC"] = "gcc"
env["CXX"] = "g++"
elif env["target"] == "release_debug":
env.Prepend(CCFLAGS=["-O2", "-DDEBUG_ENABLED"])
if env["debug_symbols"] == "yes":
env.Prepend(CCFLAGS=["-g1"])
if env["debug_symbols"] == "full":
env.Prepend(CCFLAGS=["-g2"])
if (env["target"]=="release"):
if (env["debug_release"]=="yes"):
env.Append(CCFLAGS=['-g2'])
else:
env.Append(CCFLAGS=['-O3','-ffast-math'])
elif (env["target"]=="release_debug"):
env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
elif (env["target"]=="debug"):
env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
elif env["target"] == "debug":
env.Prepend(CCFLAGS=["-g3", "-DDEBUG_ENABLED"])
#env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
env.Append(CPPFLAGS = ['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np
env.Append(CPPFLAGS = ['-DGLEW_ENABLED', '-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED'])
env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL', 'GLEW'])
## Architecture
import methods
env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')})
env.Append(BUILDERS = {'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl')})
env.Append(BUILDERS = {'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl')})
is64 = sys.maxsize > 2 ** 32
if env["bits"] == "default":
env["bits"] = "64" if is64 else "32"
## Compiler configuration
env["CC"] = "gcc-x86"
env["CXX"] = "g++-x86"
## Dependencies
if not env["builtin_libwebp"]:
env.ParseConfig("pkg-config libwebp --cflags --libs")
# freetype depends on libpng and zlib, so bundling one of them while keeping others
# as shared libraries leads to weird issues
if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]:
env["builtin_freetype"] = True
env["builtin_libpng"] = True
env["builtin_zlib"] = True
if not env["builtin_freetype"]:
env.ParseConfig("pkg-config freetype2 --cflags --libs")
if not env["builtin_libpng"]:
env.ParseConfig("pkg-config libpng16 --cflags --libs")
if not env["builtin_bullet"]:
# We need at least version 2.88
import subprocess
bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip()
if bullet_version < "2.88":
# Abort as system bullet was requested but too old
print(
"Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(
bullet_version, "2.88"
)
)
sys.exit(255)
env.ParseConfig("pkg-config bullet --cflags --libs")
if not env["builtin_enet"]:
env.ParseConfig("pkg-config libenet --cflags --libs")
if not env["builtin_squish"]:
env.ParseConfig("pkg-config libsquish --cflags --libs")
if not env["builtin_zstd"]:
env.ParseConfig("pkg-config libzstd --cflags --libs")
# Sound and video libraries
# Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
if not env["builtin_libtheora"]:
env["builtin_libogg"] = False # Needed to link against system libtheora
env["builtin_libvorbis"] = False # Needed to link against system libtheora
env.ParseConfig("pkg-config theora theoradec --cflags --libs")
if not env["builtin_libvpx"]:
env.ParseConfig("pkg-config vpx --cflags --libs")
if not env["builtin_libvorbis"]:
env["builtin_libogg"] = False # Needed to link against system libvorbis
env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs")
if not env["builtin_opus"]:
env["builtin_libogg"] = False # Needed to link against system opus
env.ParseConfig("pkg-config opus opusfile --cflags --libs")
if not env["builtin_libogg"]:
env.ParseConfig("pkg-config ogg --cflags --libs")
if env["builtin_libtheora"]:
list_of_x86 = ["x86_64", "x86", "i386", "i586"]
if any(platform.machine() in s for s in list_of_x86):
env["x86_libtheora_opt_gcc"] = True
if not env["builtin_wslay"]:
env.ParseConfig("pkg-config libwslay --cflags --libs")
if not env["builtin_mbedtls"]:
# mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
if not env["builtin_miniupnpc"]:
# No pkgconfig file so far, hardcode default paths.
env.Prepend(CPPPATH=["/system/develop/headers/x86/miniupnpc"])
env.Append(LIBS=["miniupnpc"])
# On Linux wchar_t should be 32-bits
# 16-bit library shouldn't be required due to compiler optimisations
if not env["builtin_pcre2"]:
env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
## Flags
env.Prepend(CPPPATH=["#platform/haiku"])
env.Append(CPPDEFINES=["UNIX_ENABLED", "OPENGL_ENABLED", "GLES_ENABLED"])
env.Append(CPPDEFINES=["MEDIA_KIT_ENABLED"])
env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"]) # TODO: enable when we have pthread_setname_np
env.Append(LIBS=["be", "game", "media", "network", "bnetapi", "z", "GL"])

View File

@@ -1,19 +1,49 @@
/*************************************************************************/
/* godot_haiku.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "main/main.h"
#include "os_haiku.h"
int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
OS_Haiku os;
Error error = Main::setup(argv[0], argc-1, &argv[1]);
Error error = Main::setup(argv[0], argc - 1, &argv[1]);
if (error != OK) {
return 255;
}
if (Main::start()) {
os.run();
}
Main::cleanup();
return os.get_exit_code();
}

View File

@@ -1,7 +1,35 @@
/*************************************************************************/
/* haiku_application.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "haiku_application.h"
HaikuApplication::HaikuApplication()
: BApplication("application/x-vnd.godot")
{
HaikuApplication::HaikuApplication() :
BApplication("application/x-vnd.godot") {
}

View File

@@ -1,13 +1,43 @@
/*************************************************************************/
/* haiku_application.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef HAIKU_APPLICATION_H
#define HAIKU_APPLICATION_H
#include <kernel/image.h> // needed for image_id
#include <Application.h>
class HaikuApplication : public BApplication
{
class HaikuApplication : public BApplication {
public:
HaikuApplication();
HaikuApplication();
};
#endif

View File

@@ -1,59 +1,92 @@
/*************************************************************************/
/* haiku_direct_window.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include <UnicodeChar.h>
#include "main/main.h"
#include "os/keyboard.h"
#include "core/os/keyboard.h"
#include "haiku_direct_window.h"
#include "key_mapping_haiku.h"
#include "main/main.h"
HaikuDirectWindow::HaikuDirectWindow(BRect p_frame)
: BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) :
BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) {
last_mouse_pos_valid = false;
last_buttons_state = 0;
last_button_mask = 0;
last_key_modifier_state = 0;
}
view = nullptr;
update_runner = nullptr;
input = nullptr;
main_loop = nullptr;
}
HaikuDirectWindow::~HaikuDirectWindow() {
delete update_runner;
}
void HaikuDirectWindow::SetHaikuGLView(HaikuGLView* p_view) {
void HaikuDirectWindow::SetHaikuGLView(HaikuGLView *p_view) {
view = p_view;
}
void HaikuDirectWindow::StartMessageRunner() {
update_runner = new BMessageRunner(BMessenger(this),
new BMessage(REDRAW_MSG), 1000000/30 /* 30 fps */);
new BMessage(REDRAW_MSG), 1000000 / 60 /* 60 fps */);
}
void HaikuDirectWindow::StopMessageRunner() {
delete update_runner;
}
void HaikuDirectWindow::SetInput(InputDefault* p_input) {
void HaikuDirectWindow::SetInput(InputDefault *p_input) {
input = p_input;
}
void HaikuDirectWindow::SetMainLoop(MainLoop* p_main_loop) {
void HaikuDirectWindow::SetMainLoop(MainLoop *p_main_loop) {
main_loop = p_main_loop;
}
bool HaikuDirectWindow::QuitRequested() {
main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
StopMessageRunner();
main_loop->notification(NOTIFICATION_WM_CLOSE_REQUEST);
return false;
}
void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) {
void HaikuDirectWindow::DirectConnected(direct_buffer_info *info) {
view->DirectConnected(info);
view->EnableDirectMode(true);
}
void HaikuDirectWindow::MessageReceived(BMessage* message) {
void HaikuDirectWindow::MessageReceived(BMessage *message) {
switch (message->what) {
case REDRAW_MSG:
if (Main::iteration() == true) {
if (Main::iteration()) {
view->EnableDirectMode(false);
Quit();
}
@@ -64,7 +97,7 @@ void HaikuDirectWindow::MessageReceived(BMessage* message) {
}
}
void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) {
void HaikuDirectWindow::DispatchMessage(BMessage *message, BHandler *handler) {
switch (message->what) {
case B_MOUSE_DOWN:
case B_MOUSE_UP:
@@ -105,7 +138,7 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) {
}
}
void HaikuDirectWindow::HandleMouseButton(BMessage* message) {
void HaikuDirectWindow::HandleMouseButton(BMessage *message) {
BPoint where;
if (message->FindPoint("where", &where) != B_OK) {
return;
@@ -117,52 +150,50 @@ void HaikuDirectWindow::HandleMouseButton(BMessage* message) {
last_buttons_state = buttons;
// TODO: implement the mouse_mode checks
//if (mouse_mode == MOUSE_MODE_CAPTURED) {
// event.xbutton.x=last_mouse_pos.x;
// event.xbutton.y=last_mouse_pos.y;
//}
/*
if (mouse_mode == MOUSE_MODE_CAPTURED) {
event.xbutton.x=last_mouse_pos.x;
event.xbutton.y=last_mouse_pos.y;
}
*/
InputEvent mouse_event;
mouse_event.ID = ++event_id;
mouse_event.type = InputEvent::MOUSE_BUTTON;
mouse_event.device = 0;
Ref<InputEventMouseButton> mouse_event;
mouse_event.instance();
mouse_event.mouse_button.mod = GetKeyModifierState(modifiers);
mouse_event.mouse_button.button_mask = GetMouseButtonState(buttons);
mouse_event.mouse_button.x = where.x;
mouse_event.mouse_button.y = where.y;
mouse_event.mouse_button.global_x = where.x;
mouse_event.mouse_button.global_y = where.y;
mouse_event->set_button_mask(GetMouseButtonState(buttons));
mouse_event->set_position({ where.x, where.y });
mouse_event->set_global_position({ where.x, where.y });
GetKeyModifierState(mouse_event, modifiers);
switch (button) {
default:
case B_PRIMARY_MOUSE_BUTTON:
mouse_event.mouse_button.button_index = 1;
mouse_event->set_button_index(1);
break;
case B_SECONDARY_MOUSE_BUTTON:
mouse_event.mouse_button.button_index = 2;
mouse_event->set_button_index(2);
break;
case B_TERTIARY_MOUSE_BUTTON:
mouse_event.mouse_button.button_index = 3;
mouse_event->set_button_index(3);
break;
}
mouse_event.mouse_button.pressed = (message->what == B_MOUSE_DOWN);
mouse_event->set_pressed(message->what == B_MOUSE_DOWN);
if (message->what == B_MOUSE_DOWN && mouse_event.mouse_button.button_index == 1) {
if (message->what == B_MOUSE_DOWN && mouse_event->get_button_index() == 1) {
int32 clicks = message->FindInt32("clicks");
if (clicks > 1) {
mouse_event.mouse_button.doubleclick=true;
mouse_event->set_doubleclick(true);
}
}
input->parse_input_event(mouse_event);
}
void HaikuDirectWindow::HandleMouseMoved(BMessage* message) {
void HaikuDirectWindow::HandleMouseMoved(BMessage *message) {
BPoint where;
if (message->FindPoint("where", &where) != B_OK) {
return;
@@ -179,57 +210,49 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage* message) {
Point2i rel = pos - last_mouse_position;
InputEvent motion_event;
motion_event.ID = ++event_id;
motion_event.type = InputEvent::MOUSE_MOTION;
motion_event.device = 0;
Ref<InputEventMouseMotion> motion_event;
motion_event.instance();
GetKeyModifierState(motion_event, modifiers);
motion_event.mouse_motion.mod = GetKeyModifierState(modifiers);
motion_event.mouse_motion.button_mask = GetMouseButtonState(buttons);
motion_event.mouse_motion.x = pos.x;
motion_event.mouse_motion.y = pos.y;
input->set_mouse_pos(pos);
motion_event.mouse_motion.global_x = pos.x;
motion_event.mouse_motion.global_y = pos.y;
motion_event.mouse_motion.speed_x = input->get_mouse_speed().x;
motion_event.mouse_motion.speed_y = input->get_mouse_speed().y;
motion_event->set_button_mask(GetMouseButtonState(buttons));
motion_event->set_position({ pos.x, pos.y });
input->set_mouse_position(pos);
motion_event->set_global_position({ pos.x, pos.y });
motion_event->set_speed({ input->get_last_mouse_speed().x,
input->get_last_mouse_speed().y });
motion_event.mouse_motion.relative_x = rel.x;
motion_event.mouse_motion.relative_y = rel.y;
motion_event->set_relative({ rel.x, rel.y });
last_mouse_position = pos;
input->parse_input_event(motion_event);
}
void HaikuDirectWindow::HandleMouseWheelChanged(BMessage* message) {
void HaikuDirectWindow::HandleMouseWheelChanged(BMessage *message) {
float wheel_delta_y = 0;
if (message->FindFloat("be:wheel_delta_y", &wheel_delta_y) != B_OK) {
return;
}
InputEvent mouse_event;
mouse_event.ID = ++event_id;
mouse_event.type = InputEvent::MOUSE_BUTTON;
mouse_event.device = 0;
Ref<InputEventMouseButton> mouse_event;
mouse_event.instance();
//GetKeyModifierState(mouse_event, modifiers);
mouse_event.mouse_button.button_index = wheel_delta_y < 0 ? 4 : 5;
mouse_event.mouse_button.mod = GetKeyModifierState(last_key_modifier_state);
mouse_event.mouse_button.button_mask = last_button_mask;
mouse_event.mouse_button.x = last_mouse_position.x;
mouse_event.mouse_button.y = last_mouse_position.y;
mouse_event.mouse_button.global_x = last_mouse_position.x;
mouse_event.mouse_button.global_y = last_mouse_position.y;
mouse_event->set_button_index(wheel_delta_y < 0 ? 4 : 5);
mouse_event->set_button_mask(last_button_mask);
mouse_event->set_position({ last_mouse_position.x,
last_mouse_position.y });
mouse_event->set_global_position({ last_mouse_position.x,
last_mouse_position.y });
mouse_event.mouse_button.pressed = true;
mouse_event->set_pressed(true);
input->parse_input_event(mouse_event);
mouse_event.ID = ++event_id;
mouse_event.mouse_button.pressed = false;
mouse_event->set_pressed(false);
input->parse_input_event(mouse_event);
}
void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) {
void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
int32 raw_char = 0;
int32 key = 0;
int32 modifiers = 0;
@@ -246,31 +269,31 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) {
return;
}
InputEvent event;
event.ID = ++event_id;
event.type = InputEvent::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
event.key.pressed = (message->what == B_KEY_DOWN);
event.key.scancode = KeyMappingHaiku::get_keysym(raw_char, key);
event.key.echo = message->HasInt32("be:key_repeat");
event.key.unicode = 0;
Ref<InputEventKey> event;
event.instance();
GetKeyModifierState(event, modifiers);
event->set_pressed(message->what == B_KEY_DOWN);
event->set_keycode(KeyMappingHaiku::get_keysym(raw_char, key));
event->set_physical_keycode(KeyMappingHaiku::get_keysym(raw_char, key));
event->set_echo(message->HasInt32("be:key_repeat"));
event->set_unicode(0);
const char* bytes = NULL;
const char *bytes = nullptr;
if (message->FindString("bytes", &bytes) == B_OK) {
event.key.unicode = BUnicodeChar::FromUTF8(&bytes);
event->set_unicode(BUnicodeChar::FromUTF8(&bytes));
}
//make it consistent accross platforms.
if (event.key.scancode==KEY_BACKTAB) {
event.key.scancode=KEY_TAB;
event.key.mod.shift=true;
//make it consistent across platforms.
if (event->get_keycode() == KEY_BACKTAB) {
event->set_keycode(KEY_TAB);
event->set_physical_keycode(KEY_TAB);
event->set_shift(true);
}
input->parse_input_event(event);
}
void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage* message) {
void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage *message) {
int32 old_modifiers = 0;
int32 modifiers = 0;
@@ -284,20 +307,19 @@ void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage* message) {
int32 key = old_modifiers ^ modifiers;
InputEvent event;
event.ID = ++event_id;
event.type = InputEvent::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
event.key.pressed = ((modifiers & key) != 0);
event.key.scancode = KeyMappingHaiku::get_modifier_keysym(key);
event.key.echo = false;
event.key.unicode = 0;
Ref<InputEventWithModifiers> event;
event.instance();
GetKeyModifierState(event, modifiers);
event->set_shift(key & B_SHIFT_KEY);
event->set_alt(key & B_OPTION_KEY);
event->set_control(key & B_CONTROL_KEY);
event->set_command(key & B_COMMAND_KEY);
input->parse_input_event(event);
}
void HaikuDirectWindow::HandleWindowResized(BMessage* message) {
void HaikuDirectWindow::HandleWindowResized(BMessage *message) {
int32 width = 0;
int32 height = 0;
@@ -309,14 +331,13 @@ void HaikuDirectWindow::HandleWindowResized(BMessage* message) {
current_video_mode->height = height;
}
inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) {
inline void HaikuDirectWindow::GetKeyModifierState(Ref<InputEventWithModifiers> event, uint32 p_state) {
last_key_modifier_state = p_state;
InputModifierState state;
state.shift = (p_state & B_SHIFT_KEY) != 0;
state.control = (p_state & B_CONTROL_KEY) != 0;
state.alt = (p_state & B_OPTION_KEY) != 0;
state.meta = (p_state & B_COMMAND_KEY) != 0;
event->set_shift(p_state & B_SHIFT_KEY);
event->set_control(p_state & B_CONTROL_KEY);
event->set_alt(p_state & B_OPTION_KEY);
event->set_metakey(p_state & B_COMMAND_KEY);
return state;
}

View File

@@ -1,11 +1,42 @@
/*************************************************************************/
/* haiku_direct_window.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef HAIKU_DIRECT_WINDOW_H
#define HAIKU_DIRECT_WINDOW_H
#include <kernel/image.h> // needed for image_id
#include <DirectWindow.h>
#include "core/input/input.h"
#include "core/os/os.h"
#include "main/input_default.h"
#include "haiku_gl_view.h"
@@ -13,45 +44,43 @@
#define LOCKGL_MSG 'glck'
#define UNLOCKGL_MSG 'ulck'
class HaikuDirectWindow : public BDirectWindow
{
class HaikuDirectWindow : public BDirectWindow {
private:
unsigned int event_id;
Point2i last_mouse_position;
bool last_mouse_pos_valid;
uint32 last_buttons_state;
uint32 last_key_modifier_state;
int last_button_mask;
OS::VideoMode* current_video_mode;
OS::VideoMode *current_video_mode;
MainLoop* main_loop;
InputDefault* input;
HaikuGLView* view;
BMessageRunner* update_runner;
MainLoop *main_loop;
InputDefault *input;
HaikuGLView *view;
BMessageRunner *update_runner;
void HandleMouseButton(BMessage* message);
void HandleMouseMoved(BMessage* message);
void HandleMouseWheelChanged(BMessage* message);
void HandleWindowResized(BMessage* message);
void HandleKeyboardEvent(BMessage* message);
void HandleKeyboardModifierEvent(BMessage* message);
inline InputModifierState GetKeyModifierState(uint32 p_state);
void HandleMouseButton(BMessage *message);
void HandleMouseMoved(BMessage *message);
void HandleMouseWheelChanged(BMessage *message);
void HandleWindowResized(BMessage *message);
void HandleKeyboardEvent(BMessage *message);
void HandleKeyboardModifierEvent(BMessage *message);
inline void GetKeyModifierState(Ref<InputEventWithModifiers> event, uint32 p_state);
inline int GetMouseButtonState(uint32 p_state);
public:
HaikuDirectWindow(BRect p_frame);
~HaikuDirectWindow();
void SetHaikuGLView(HaikuGLView* p_view);
void SetHaikuGLView(HaikuGLView *p_view);
void StartMessageRunner();
void StopMessageRunner();
void SetInput(InputDefault* p_input);
void SetMainLoop(MainLoop* p_main_loop);
inline void SetVideoMode(OS::VideoMode* video_mode) { current_video_mode = video_mode; };
void SetInput(InputDefault *p_input);
void SetMainLoop(MainLoop *p_main_loop);
inline void SetVideoMode(OS::VideoMode *video_mode) { current_video_mode = video_mode; };
virtual bool QuitRequested();
virtual void DirectConnected(direct_buffer_info* info);
virtual void MessageReceived(BMessage* message);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void DirectConnected(direct_buffer_info *info);
virtual void MessageReceived(BMessage *message);
virtual void DispatchMessage(BMessage *message, BHandler *handler);
inline Point2i GetLastMousePosition() { return last_mouse_position; };
inline int GetLastButtonMask() { return last_button_mask; };

View File

@@ -1,9 +1,38 @@
#include "main/main.h"
#include "haiku_gl_view.h"
/*************************************************************************/
/* haiku_gl_view.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
HaikuGLView::HaikuGLView(BRect frame, uint32 type)
: BGLView(frame, "GodotGLView", B_FOLLOW_ALL_SIDES, 0, type)
{
#include "haiku_gl_view.h"
#include "main/main.h"
HaikuGLView::HaikuGLView(BRect frame, uint32 type) :
BGLView(frame, "GodotGLView", B_FOLLOW_ALL_SIDES, 0, type) {
}
void HaikuGLView::AttachedToWindow(void) {

View File

@@ -1,11 +1,41 @@
/*************************************************************************/
/* haiku_gl_view.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef HAIKU_GL_VIEW_H
#define HAIKU_GL_VIEW_H
#include <kernel/image.h> // needed for image_id
#include <GLView.h>
class HaikuGLView : public BGLView
{
class HaikuGLView : public BGLView {
public:
HaikuGLView(BRect frame, uint32 type);
virtual void AttachedToWindow(void);

View File

@@ -1,7 +1,37 @@
/*************************************************************************/
/* key_mapping_haiku.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include <InterfaceDefs.h>
#include "core/os/keyboard.h"
#include "key_mapping_haiku.h"
#include "os/keyboard.h"
struct _HaikuTranslatePair {
unsigned int keysym;
@@ -54,7 +84,7 @@ static _HaikuTranslatePair _fn_to_keycode[] = {
static _HaikuTranslatePair _hb_to_keycode[] = {
{ KEY_BACKSPACE, B_BACKSPACE },
{ KEY_TAB, B_TAB },
{ KEY_RETURN, B_RETURN },
{ KEY_ENTER, B_RETURN },
{ KEY_CAPSLOCK, B_CAPS_LOCK },
{ KEY_ESCAPE, B_ESCAPE },
{ KEY_SPACE, B_SPACE },
@@ -70,7 +100,7 @@ static _HaikuTranslatePair _hb_to_keycode[] = {
{ KEY_INSERT, B_INSERT },
{ KEY_DELETE, B_DELETE },
// { KEY_HELP, ??? },
{ KEY_0, (0x30) },
{ KEY_1, (0x31) },
{ KEY_2, (0x32) },
@@ -108,7 +138,7 @@ static _HaikuTranslatePair _hb_to_keycode[] = {
{ KEY_Y, (0x79) },
{ KEY_Z, (0x7A) },
/*
/*
{ KEY_PLAY, VK_PLAY},// (0xFA)
{ KEY_STANDBY,VK_SLEEP },//(0x5F)
{ KEY_BACK,VK_BROWSER_BACK},// (0xA6)
@@ -149,22 +179,48 @@ static _HaikuTranslatePair _hb_to_keycode[] = {
};
unsigned int KeyMappingHaiku::get_keysym(int32 raw_char, int32 key) {
if (raw_char == B_INSERT && key == 0x64) { return KEY_KP_0; }
if (raw_char == B_END && key == 0x58) { return KEY_KP_1; }
if (raw_char == B_DOWN_ARROW && key == 0x59) { return KEY_KP_2; }
if (raw_char == B_PAGE_DOWN && key == 0x5A) { return KEY_KP_3; }
if (raw_char == B_LEFT_ARROW && key == 0x48) { return KEY_KP_4; }
if (raw_char == 0x35 && key == 0x49) { return KEY_KP_5; }
if (raw_char == B_RIGHT_ARROW && key == 0x4A) { return KEY_KP_6; }
if (raw_char == B_HOME && key == 0x37) { return KEY_KP_7; }
if (raw_char == B_UP_ARROW && key == 0x38) { return KEY_KP_8; }
if (raw_char == B_PAGE_UP && key == 0x39) { return KEY_KP_9; }
if (raw_char == 0x2F && key == 0x23) { return KEY_KP_DIVIDE; }
if (raw_char == 0x2D && key == 0x25) { return KEY_KP_SUBTRACT; }
if (raw_char == B_DELETE && key == 0x65) { return KEY_KP_PERIOD; }
if (raw_char == B_INSERT && key == 0x64) {
return KEY_KP_0;
}
if (raw_char == B_END && key == 0x58) {
return KEY_KP_1;
}
if (raw_char == B_DOWN_ARROW && key == 0x59) {
return KEY_KP_2;
}
if (raw_char == B_PAGE_DOWN && key == 0x5A) {
return KEY_KP_3;
}
if (raw_char == B_LEFT_ARROW && key == 0x48) {
return KEY_KP_4;
}
if (raw_char == 0x35 && key == 0x49) {
return KEY_KP_5;
}
if (raw_char == B_RIGHT_ARROW && key == 0x4A) {
return KEY_KP_6;
}
if (raw_char == B_HOME && key == 0x37) {
return KEY_KP_7;
}
if (raw_char == B_UP_ARROW && key == 0x38) {
return KEY_KP_8;
}
if (raw_char == B_PAGE_UP && key == 0x39) {
return KEY_KP_9;
}
if (raw_char == 0x2F && key == 0x23) {
return KEY_KP_DIVIDE;
}
if (raw_char == 0x2D && key == 0x25) {
return KEY_KP_SUBTRACT;
}
if (raw_char == B_DELETE && key == 0x65) {
return KEY_KP_PERIOD;
}
if (raw_char == 0x10) {
for(int i = 0; _fn_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
for (int i = 0; _fn_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
if (_fn_to_keycode[i].keycode == key) {
return _fn_to_keycode[i].keysym;
}
@@ -173,7 +229,7 @@ unsigned int KeyMappingHaiku::get_keysym(int32 raw_char, int32 key) {
return KEY_UNKNOWN;
}
for(int i = 0; _hb_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
for (int i = 0; _hb_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
if (_hb_to_keycode[i].keycode == raw_char) {
return _hb_to_keycode[i].keysym;
}
@@ -183,7 +239,7 @@ unsigned int KeyMappingHaiku::get_keysym(int32 raw_char, int32 key) {
}
unsigned int KeyMappingHaiku::get_modifier_keysym(int32 key) {
for(int i = 0; _mod_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
for (int i = 0; _mod_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
if ((_mod_to_keycode[i].keycode & key) != 0) {
return _mod_to_keycode[i].keysym;
}

View File

@@ -1,9 +1,38 @@
/*************************************************************************/
/* key_mapping_haiku.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef KEY_MAPPING_HAIKU_H
#define KEY_MAPPING_HAIKU_H
class KeyMappingHaiku
{
KeyMappingHaiku() {};
class KeyMappingHaiku {
KeyMappingHaiku() {}
public:
static unsigned int get_keysym(int32 raw_char, int32 key);

BIN
logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,18 +1,46 @@
#include <Screen.h>
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "drivers/gles2/rasterizer_gles2.h"
#include "servers/physics/physics_server_sw.h"
//#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "main/main.h"
/*************************************************************************/
/* os_haiku.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os_haiku.h"
#include "drivers/gles2/rasterizer_gles2.h"
#include "main/main.h"
#include "servers/physics_3d/physics_server_3d_sw.h"
#include "servers/rendering/rendering_server_raster.h"
#include "servers/rendering/rendering_server_wrap_mt.h"
#include <Screen.h>
OS_Haiku::OS_Haiku() {
#ifdef MEDIA_KIT_ENABLED
AudioDriverManagerSW::add_driver(&driver_media_kit);
AudioDriverManager::add_driver(&driver_media_kit);
#endif
};
@@ -25,8 +53,8 @@ void OS_Haiku::run() {
context_gl->release_current();
// TODO: clean up
BMessenger* bms = new BMessenger(window);
BMessage* msg = new BMessage();
BMessenger *bms = new BMessenger(window);
BMessage *msg = new BMessage();
bms->SendMessage(LOCKGL_MSG, msg);
window->StartMessageRunner();
@@ -40,7 +68,7 @@ void OS_Haiku::run() {
main_loop->finish();
}
String OS_Haiku::get_name() {
String OS_Haiku::get_name() const {
return "Haiku";
}
@@ -48,16 +76,16 @@ int OS_Haiku::get_video_driver_count() const {
return 1;
}
const char* OS_Haiku::get_video_driver_name(int p_driver) const {
const char *OS_Haiku::get_video_driver_name(int p_driver) const {
return "GLES2";
}
OS::VideoMode OS_Haiku::get_default_video_mode() const {
return OS::VideoMode(800, 600, false);
int OS_Haiku::get_current_video_driver() const {
return video_driver_index;
}
void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) {
main_loop = NULL;
Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
main_loop = nullptr;
current_video_mode = p_desired;
app = new HaikuApplication();
@@ -78,50 +106,35 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_
window->SetFlags(flags);
}
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
#if defined(OPENGL_ENABLED)
context_gl = memnew(ContextGL_Haiku(window));
context_gl->initialize();
context_gl->make_current();
rasterizer = memnew(RasterizerGLES2);
context_gl->set_use_vsync(current_video_mode.use_vsync);
// FIXME: That's not how the rasterizer setup should happen.
RasterizerGLES2::register_config();
RasterizerGLES2::make_current();
#endif
visual_server = memnew(VisualServerRaster(rasterizer));
rendering_server = memnew(RenderingServerRaster);
// FIXME: Reimplement threaded rendering
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
}
ERR_FAIL_COND(!visual_server);
ERR_FAIL_COND_V(!rendering_server, ERR_UNAVAILABLE);
// TODO: enable multithreaded VS
//if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
// visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
//}
video_driver_index = p_video_driver;
input = memnew(InputDefault);
window->SetInput(input);
window->Show();
visual_server->init();
rendering_server->init();
physics_server = memnew(PhysicsServerSW);
physics_server->init();
physics_2d_server = memnew(Physics2DServerSW);
// TODO: enable multithreaded PS
//physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
AudioDriverManager::initialize(p_audio_driver);
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) {
ERR_PRINT("Initializing audio failed.");
}
sample_manager = memnew(SampleManagerMallocSW);
audio_server = memnew(AudioServerSW(sample_manager));
audio_server->init();
spatial_sound_server = memnew(SpatialSoundServerSW);
spatial_sound_server->init();
spatial_sound_2d_server = memnew(SpatialSound2DServerSW);
spatial_sound_2d_server->init();
return OK;
}
void OS_Haiku::finalize() {
@@ -129,43 +142,25 @@ void OS_Haiku::finalize() {
memdelete(main_loop);
}
main_loop = NULL;
main_loop = nullptr;
spatial_sound_server->finish();
memdelete(spatial_sound_server);
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);
memdelete(sample_manager);
audio_server->finish();
memdelete(audio_server);
visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
physics_2d_server->finish();
memdelete(physics_2d_server);
rendering_server->finish();
memdelete(rendering_server);
memdelete(input);
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
#if defined(OPENGL_ENABLED)
memdelete(context_gl);
#endif
}
void OS_Haiku::set_main_loop(MainLoop* p_main_loop) {
void OS_Haiku::set_main_loop(MainLoop *p_main_loop) {
main_loop = p_main_loop;
input->set_main_loop(p_main_loop);
window->SetMainLoop(p_main_loop);
}
MainLoop* OS_Haiku::get_main_loop() const {
MainLoop *OS_Haiku::get_main_loop() const {
return main_loop;
}
@@ -174,8 +169,8 @@ void OS_Haiku::delete_main_loop() {
memdelete(main_loop);
}
main_loop = NULL;
window->SetMainLoop(NULL);
main_loop = nullptr;
window->SetMainLoop(nullptr);
}
void OS_Haiku::release_rendering_thread() {
@@ -195,7 +190,7 @@ void OS_Haiku::swap_buffers() {
context_gl->swap_buffers();
}
Point2 OS_Haiku::get_mouse_pos() const {
Point2 OS_Haiku::get_mouse_position() const {
return window->GetLastMousePosition();
}
@@ -207,6 +202,14 @@ void OS_Haiku::set_cursor_shape(CursorShape p_shape) {
//ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED");
}
OS::CursorShape OS_Haiku::get_cursor_shape() const {
// TODO: implement get_cursor_shape
}
void OS_Haiku::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
// TODO
}
int OS_Haiku::get_screen_count() const {
// TODO: implement get_screen_count()
return 1;
@@ -223,7 +226,7 @@ void OS_Haiku::set_current_screen(int p_screen) {
Point2 OS_Haiku::get_screen_position(int p_screen) const {
// TODO: make this work with the p_screen parameter
BScreen* screen = new BScreen(window);
BScreen *screen = new BScreen(window);
BRect frame = screen->Frame();
delete screen;
return Point2i(frame.left, frame.top);
@@ -231,13 +234,13 @@ Point2 OS_Haiku::get_screen_position(int p_screen) const {
Size2 OS_Haiku::get_screen_size(int p_screen) const {
// TODO: make this work with the p_screen parameter
BScreen* screen = new BScreen(window);
BScreen *screen = new BScreen(window);
BRect frame = screen->Frame();
delete screen;
return Size2i(frame.IntegerWidth() + 1, frame.IntegerHeight() + 1);
}
void OS_Haiku::set_window_title(const String& p_title) {
void OS_Haiku::set_window_title(const String &p_title) {
window->SetTitle(p_title.utf8().get_data());
}
@@ -257,14 +260,14 @@ Point2 OS_Haiku::get_window_position() const {
return Point2i(point.x, point.y);
}
void OS_Haiku::set_window_position(const Point2& p_position) {
void OS_Haiku::set_window_position(const Point2 &p_position) {
window->MoveTo(p_position.x, p_position.y);
}
void OS_Haiku::set_window_fullscreen(bool p_enabled) {
window->SetFullScreen(p_enabled);
current_video_mode.fullscreen = p_enabled;
visual_server->init();
rendering_server->init();
}
bool OS_Haiku::is_window_fullscreen() const {
@@ -304,7 +307,7 @@ bool OS_Haiku::is_window_maximized() const {
return !window->IsMinimized();
}
void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) {
void OS_Haiku::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
ERR_PRINT("set_video_mode() NOT IMPLEMENTED");
}
@@ -319,3 +322,37 @@ void OS_Haiku::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) c
String OS_Haiku::get_executable_path() const {
return OS::get_executable_path();
}
bool OS_Haiku::_check_internal_feature_support(const String &p_feature) {
return p_feature == "pc";
}
String OS_Haiku::get_config_path() const {
if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
return get_environment("HOME").plus_file("config/settings");
} else {
return ".";
}
}
String OS_Haiku::get_data_path() const {
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else if (has_environment("HOME")) {
return get_environment("HOME").plus_file("config/data");
} else {
return get_config_path();
}
}
String OS_Haiku::get_cache_path() const {
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
return get_environment("HOME").plus_file("config/cache");
} else {
return get_config_path();
}
}

View File

@@ -1,86 +1,104 @@
/*************************************************************************/
/* os_haiku.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef OS_HAIKU_H
#define OS_HAIKU_H
#include "drivers/unix/os_unix.h"
#include "servers/visual_server.h"
#include "servers/visual/rasterizer.h"
#include "servers/physics_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/audio/audio_server_sw.h"
#include "servers/audio/sample_manager_sw.h"
#include "servers/spatial_sound/spatial_sound_server_sw.h"
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "main/input_default.h"
#include "audio_driver_media_kit.h"
#include "context_gl_haiku.h"
#include "core/input/input.h"
#include "drivers/unix/os_unix.h"
#include "haiku_application.h"
#include "haiku_direct_window.h"
#include "servers/audio_server.h"
#include "servers/rendering_server.h"
class OS_Haiku : public OS_Unix {
private:
HaikuApplication* app;
HaikuDirectWindow* window;
MainLoop* main_loop;
InputDefault* input;
Rasterizer* rasterizer;
VisualServer* visual_server;
HaikuApplication *app;
HaikuDirectWindow *window;
MainLoop *main_loop;
InputDefault *input;
RenderingServer *rendering_server;
VideoMode current_video_mode;
PhysicsServer* physics_server;
Physics2DServer* physics_2d_server;
AudioServerSW* audio_server;
SampleManagerMallocSW* sample_manager;
SpatialSoundServerSW* spatial_sound_server;
SpatialSound2DServerSW* spatial_sound_2d_server;
int video_driver_index;
#ifdef MEDIA_KIT_ENABLED
AudioDriverMediaKit driver_media_kit;
#endif
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
ContextGL_Haiku* context_gl;
#if defined(OPENGL_ENABLED)
ContextGL_Haiku *context_gl;
#endif
virtual void delete_main_loop();
protected:
virtual int get_video_driver_count() const;
virtual const char* get_video_driver_name(int p_driver) const;
virtual VideoMode get_default_video_mode() const;
virtual const char *get_video_driver_name(int p_driver) const;
virtual int get_current_video_driver() const;
virtual void initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver);
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
virtual void finalize();
virtual void set_main_loop(MainLoop* p_main_loop);
virtual void set_main_loop(MainLoop *p_main_loop);
public:
OS_Haiku();
void run();
virtual String get_name();
virtual String get_name() const;
virtual MainLoop* get_main_loop() const;
virtual MainLoop *get_main_loop() const;
virtual bool can_draw() const;
virtual void release_rendering_thread();
virtual void make_rendering_thread();
virtual void swap_buffers();
virtual Point2 get_mouse_pos() const;
virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_cursor_shape(CursorShape p_shape);
virtual CursorShape get_cursor_shape() const;
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
virtual void set_window_title(const String& p_title);
virtual Point2 get_screen_position(int p_screen = -1) const;
virtual Size2 get_screen_size(int p_screen = -1) const;
virtual void set_window_title(const String &p_title);
virtual Size2 get_window_size() const;
virtual void set_window_size(const Size2 p_size);
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual void set_window_position(const Point2 &p_position);
virtual void set_window_fullscreen(bool p_enabled);
virtual bool is_window_fullscreen() const;
virtual void set_window_resizable(bool p_enabled);
@@ -90,10 +108,16 @@ public:
virtual void set_window_maximized(bool p_enabled);
virtual bool is_window_maximized() const;
virtual void set_video_mode(const VideoMode& p_video_mode, int p_screen=0);
virtual VideoMode get_video_mode(int p_screen=0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen=0) const;
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
virtual VideoMode get_video_mode(int p_screen = 0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
virtual String get_executable_path() const;
virtual bool _check_internal_feature_support(const String &p_feature);
virtual String get_config_path() const;
virtual String get_data_path() const;
virtual String get_cache_path() const;
};
#endif

View File

@@ -1,6 +1,36 @@
/*************************************************************************/
/* platform_config.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include <alloca.h>
// for ifaddrs.h needed in drivers/unix/ip_unix.cpp
#define _BSD_SOURCE 1
#define GLES2_INCLUDE_H <GL/glew.h>
#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h"