mirror of
https://github.com/godotengine/godot-platform-haiku.git
synced 2026-01-02 21:48:21 +03:00
Compare commits
59 Commits
2.0.4-stab
...
3.0.2-stab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63cbf6d2f0 | ||
|
|
2d8ccae545 | ||
|
|
52f44a96ba | ||
|
|
ac7319b508 | ||
|
|
55e60cf44a | ||
|
|
254c8a3142 | ||
|
|
d5bffbe3cb | ||
|
|
98ed70d40e | ||
|
|
b65c6801b2 | ||
|
|
b3ca68fa6d | ||
|
|
f1a088314f | ||
|
|
63bab816a6 | ||
|
|
013a355eef | ||
|
|
d22c0d4025 | ||
|
|
256f1096b5 | ||
|
|
218fd3070c | ||
|
|
c285f10f2e | ||
|
|
a37d7598b0 | ||
|
|
f0b665f387 | ||
|
|
e83891b599 | ||
|
|
380b249aee | ||
|
|
e89ab74585 | ||
|
|
b1f8f3b3c2 | ||
|
|
35d66b703b | ||
|
|
79fdaf5cbd | ||
|
|
06ad740677 | ||
|
|
e350dcf2fd | ||
|
|
0a405bcc93 | ||
|
|
3b8757f444 | ||
|
|
a5e32eb15a | ||
|
|
7c32f3fd7d | ||
|
|
fe4fba9e7f | ||
|
|
65f26a9703 | ||
|
|
afce5944ff | ||
|
|
c3ac9f1816 | ||
|
|
b3a496acb0 | ||
|
|
78354332c6 | ||
|
|
9b443edfd9 | ||
|
|
4d865b764a | ||
|
|
1d08349ce9 | ||
|
|
e6272fe76e | ||
|
|
e8eba252b7 | ||
|
|
24596acf47 | ||
|
|
15c3dfeff2 | ||
|
|
6afb936cb6 | ||
|
|
1c76c18b91 | ||
|
|
2848f31173 | ||
|
|
3c8293e224 | ||
|
|
fbaab7f70a | ||
|
|
92f4413a5e | ||
|
|
a823cee5ce | ||
|
|
472bf523ed | ||
|
|
e3023c29f6 | ||
|
|
1687b8023a | ||
|
|
d903be77a8 | ||
|
|
4e83a47856 | ||
|
|
e1cb00e214 | ||
|
|
c147f8a3e4 | ||
|
|
4c4ac1a8cd |
29
SCsub
29
SCsub
@@ -1,25 +1,28 @@
|
||||
#!/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'])
|
||||
['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)
|
||||
|
||||
@@ -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-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 "project_settings.h"
|
||||
|
||||
int32_t* AudioDriverMediaKit::samples_in = NULL;
|
||||
int32_t *AudioDriverMediaKit::samples_in = NULL;
|
||||
|
||||
Error AudioDriverMediaKit::init() {
|
||||
active = false;
|
||||
|
||||
mix_rate = 44100;
|
||||
output_format = OUTPUT_STEREO;
|
||||
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);
|
||||
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,12 +56,11 @@ 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,
|
||||
NULL,
|
||||
this);
|
||||
|
||||
if (player->InitCheck() != B_OK) {
|
||||
fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n");
|
||||
@@ -72,9 +73,9 @@ Error AudioDriverMediaKit::init() {
|
||||
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,8 +100,8 @@ int AudioDriverMediaKit::get_mix_rate() const {
|
||||
return mix_rate;
|
||||
}
|
||||
|
||||
AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const {
|
||||
return output_format;
|
||||
AudioDriverSW::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const {
|
||||
return speaker_mode;
|
||||
}
|
||||
|
||||
void AudioDriverMediaKit::lock() {
|
||||
@@ -136,7 +137,6 @@ AudioDriverMediaKit::AudioDriverMediaKit() {
|
||||
}
|
||||
|
||||
AudioDriverMediaKit::~AudioDriverMediaKit() {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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,41 @@
|
||||
/* 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>
|
||||
#include <kernel/image.h> // needed for image_id
|
||||
|
||||
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();
|
||||
|
||||
@@ -1,12 +1,44 @@
|
||||
/*************************************************************************/
|
||||
/* context_gl_haiku.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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
|
||||
|
||||
@@ -1,7 +1,37 @@
|
||||
/*************************************************************************/
|
||||
/* context_gl_haiku.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
|
||||
#include "drivers/gl_context/context_gl.h"
|
||||
|
||||
@@ -10,19 +40,24 @@
|
||||
|
||||
class ContextGL_Haiku : public ContextGL {
|
||||
private:
|
||||
HaikuGLView* view;
|
||||
HaikuDirectWindow* window;
|
||||
HaikuGLView *view;
|
||||
HaikuDirectWindow *window;
|
||||
|
||||
bool use_vsync;
|
||||
|
||||
public:
|
||||
ContextGL_Haiku(HaikuDirectWindow* p_window);
|
||||
ContextGL_Haiku(HaikuDirectWindow *p_window);
|
||||
~ContextGL_Haiku();
|
||||
|
||||
virtual Error initialize();
|
||||
virtual void release_current();
|
||||
virtual void make_current();
|
||||
virtual void release_current();
|
||||
virtual void make_current();
|
||||
virtual void swap_buffers();
|
||||
virtual int get_window_width();
|
||||
virtual int get_window_height();
|
||||
|
||||
virtual void set_use_vsync(bool p_use);
|
||||
virtual bool is_using_vsync() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
92
detect.py
92
detect.py
@@ -1,62 +1,74 @@
|
||||
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 debug symbols to release version', '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', '-ffast-math'])
|
||||
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', '-ffast-math', '-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', '-DDEBUG_MEMORY_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"
|
||||
|
||||
## Flags
|
||||
|
||||
env.Append(CPPPATH=['#platform/haiku'])
|
||||
env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES_ENABLED', '-DGLES_OVER_GL'])
|
||||
env.Append(CPPFLAGS=['-DMEDIA_KIT_ENABLED'])
|
||||
# env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
|
||||
env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np
|
||||
env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL'])
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
/*************************************************************************/
|
||||
/* godot_haiku.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,35 @@
|
||||
/*************************************************************************/
|
||||
/* haiku_application.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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") {
|
||||
}
|
||||
|
||||
@@ -1,13 +1,42 @@
|
||||
/*************************************************************************/
|
||||
/* haiku_application.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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>
|
||||
#include <kernel/image.h> // needed for image_id
|
||||
|
||||
class HaikuApplication : public BApplication
|
||||
{
|
||||
class HaikuApplication : public BApplication {
|
||||
public:
|
||||
HaikuApplication();
|
||||
HaikuApplication();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,42 +1,70 @@
|
||||
/*************************************************************************/
|
||||
/* haiku_direct_window.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 "haiku_direct_window.h"
|
||||
#include "key_mapping_haiku.h"
|
||||
#include "main/main.h"
|
||||
#include "os/keyboard.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;
|
||||
}
|
||||
|
||||
|
||||
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 / 30 /* 30 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;
|
||||
}
|
||||
|
||||
@@ -45,12 +73,12 @@ bool HaikuDirectWindow::QuitRequested() {
|
||||
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) {
|
||||
@@ -64,7 +92,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 +133,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 +145,53 @@ 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;
|
||||
Ref<InputEvent> mouse_event;
|
||||
mouse_event.type = Ref<InputEvent>::MOUSE_BUTTON;
|
||||
mouse_event.device = 0;
|
||||
|
||||
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->get_button_mask() = GetMouseButtonState(buttons);
|
||||
mouse_event->get_position().x = where.x;
|
||||
mouse_event->get_position().y = where.y;
|
||||
mouse_event.mouse_button.global_x = where.x;
|
||||
mouse_event.mouse_button.global_y = where.y;
|
||||
|
||||
switch (button) {
|
||||
default:
|
||||
case B_PRIMARY_MOUSE_BUTTON:
|
||||
mouse_event.mouse_button.button_index = 1;
|
||||
mouse_event->get_button_index() = 1;
|
||||
break;
|
||||
|
||||
case B_SECONDARY_MOUSE_BUTTON:
|
||||
mouse_event.mouse_button.button_index = 2;
|
||||
mouse_event->get_button_index() = 2;
|
||||
break;
|
||||
|
||||
case B_TERTIARY_MOUSE_BUTTON:
|
||||
mouse_event.mouse_button.button_index = 3;
|
||||
mouse_event->get_button_index() = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
mouse_event.mouse_button.pressed = (message->what == B_MOUSE_DOWN);
|
||||
mouse_event->is_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.mouse_button.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 +208,54 @@ 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;
|
||||
Ref<InputEvent> motion_event;
|
||||
motion_event.type = Ref<InputEvent>::MOUSE_MOTION;
|
||||
motion_event.device = 0;
|
||||
|
||||
motion_event.mouse_motion.mod = GetKeyModifierState(modifiers);
|
||||
motion_event.mouse_motion.button_mask = GetMouseButtonState(buttons);
|
||||
motion_event->get_button_mask() = GetMouseButtonState(buttons);
|
||||
motion_event.mouse_motion.x = pos.x;
|
||||
motion_event.mouse_motion.y = pos.y;
|
||||
input->set_mouse_pos(pos);
|
||||
input->set_mouse_position(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.mouse_motion.speed_x = input->get_last_mouse_speed().x;
|
||||
motion_event.mouse_motion.speed_y = input->get_last_mouse_speed().y;
|
||||
|
||||
motion_event.mouse_motion.relative_x = rel.x;
|
||||
motion_event.mouse_motion.relative_y = rel.y;
|
||||
motion_event->get_relative().x = rel.x;
|
||||
motion_event->get_relative().y = 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;
|
||||
Ref<InputEvent> mouse_event;
|
||||
mouse_event.type = Ref<InputEvent>::MOUSE_BUTTON;
|
||||
mouse_event.device = 0;
|
||||
|
||||
mouse_event.mouse_button.button_index = wheel_delta_y < 0 ? 4 : 5;
|
||||
mouse_event->get_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->get_button_mask() = last_button_mask;
|
||||
mouse_event->get_position().x = last_mouse_position.x;
|
||||
mouse_event->get_position().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.mouse_button.pressed = true;
|
||||
mouse_event->is_pressed() = true;
|
||||
input->parse_input_event(mouse_event);
|
||||
|
||||
mouse_event.ID = ++event_id;
|
||||
mouse_event.mouse_button.pressed = false;
|
||||
mouse_event->is_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 +272,30 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputEvent event;
|
||||
event.ID = ++event_id;
|
||||
event.type = InputEvent::KEY;
|
||||
Ref<InputEvent> event;
|
||||
event.type = Ref<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->is_pressed() = (message->what == B_KEY_DOWN);
|
||||
event->get_scancode() = KeyMappingHaiku::get_keysym(raw_char, key);
|
||||
event->is_echo() = message->HasInt32("be:key_repeat");
|
||||
event.key.unicode = 0;
|
||||
|
||||
const char* bytes = NULL;
|
||||
const char *bytes = NULL;
|
||||
if (message->FindString("bytes", &bytes) == B_OK) {
|
||||
event.key.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_scancode() == KEY_BACKTAB) {
|
||||
event->get_scancode() = KEY_TAB;
|
||||
event->get_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 +309,19 @@ void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage* message) {
|
||||
|
||||
int32 key = old_modifiers ^ modifiers;
|
||||
|
||||
InputEvent event;
|
||||
event.ID = ++event_id;
|
||||
event.type = InputEvent::KEY;
|
||||
Ref<InputEvent> event;
|
||||
event.type = Ref<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->is_pressed() = ((modifiers & key) != 0);
|
||||
event->get_scancode() = KeyMappingHaiku::get_modifier_keysym(key);
|
||||
event->is_echo() = false;
|
||||
event.key.unicode = 0;
|
||||
|
||||
input->parse_input_event(event);
|
||||
}
|
||||
|
||||
void HaikuDirectWindow::HandleWindowResized(BMessage* message) {
|
||||
void HaikuDirectWindow::HandleWindowResized(BMessage *message) {
|
||||
int32 width = 0;
|
||||
int32 height = 0;
|
||||
|
||||
|
||||
@@ -1,8 +1,38 @@
|
||||
/*************************************************************************/
|
||||
/* haiku_direct_window.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 <kernel/image.h> // needed for image_id
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "main/input_default.h"
|
||||
@@ -13,28 +43,26 @@
|
||||
#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);
|
||||
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);
|
||||
inline int GetMouseButtonState(uint32 p_state);
|
||||
|
||||
@@ -42,16 +70,16 @@ 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; };
|
||||
|
||||
@@ -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-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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) {
|
||||
|
||||
@@ -1,11 +1,40 @@
|
||||
/*************************************************************************/
|
||||
/* haiku_gl_view.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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>
|
||||
#include <kernel/image.h> // needed for image_id
|
||||
|
||||
class HaikuGLView : public BGLView
|
||||
{
|
||||
class HaikuGLView : public BGLView {
|
||||
public:
|
||||
HaikuGLView(BRect frame, uint32 type);
|
||||
virtual void AttachedToWindow(void);
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* key_mapping_haiku.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 "key_mapping_haiku.h"
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
/*************************************************************************/
|
||||
/* key_mapping_haiku.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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
BIN
logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
176
os_haiku.cpp
176
os_haiku.cpp
@@ -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-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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/gles3/rasterizer_gles3.h"
|
||||
#include "main/main.h"
|
||||
#include "servers/physics/physics_server_sw.h"
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#include "servers/visual/visual_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();
|
||||
@@ -48,15 +76,11 @@ int OS_Haiku::get_video_driver_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* OS_Haiku::get_video_driver_name(int p_driver) const {
|
||||
return "GLES2";
|
||||
const char *OS_Haiku::get_video_driver_name(int p_driver) const {
|
||||
return "GLES3";
|
||||
}
|
||||
|
||||
OS::VideoMode OS_Haiku::get_default_video_mode() const {
|
||||
return OS::VideoMode(800, 600, false);
|
||||
}
|
||||
|
||||
void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) {
|
||||
Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
main_loop = NULL;
|
||||
current_video_mode = p_desired;
|
||||
|
||||
@@ -78,22 +102,27 @@ 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();
|
||||
context_gl->set_use_vsync(current_video_mode.use_vsync);
|
||||
|
||||
/* Port to GLES 3 rasterizer */
|
||||
//rasterizer = memnew(RasterizerGLES2);
|
||||
|
||||
rasterizer = memnew(RasterizerGLES2);
|
||||
#endif
|
||||
|
||||
visual_server = memnew(VisualServerRaster(rasterizer));
|
||||
|
||||
ERR_FAIL_COND(!visual_server);
|
||||
ERR_FAIL_COND_V(!visual_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));
|
||||
//}
|
||||
/*
|
||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||
visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
|
||||
}
|
||||
*/
|
||||
|
||||
input = memnew(InputDefault);
|
||||
window->SetInput(input);
|
||||
@@ -101,27 +130,11 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_
|
||||
window->Show();
|
||||
visual_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();
|
||||
power_manager = memnew(PowerHaiku);
|
||||
|
||||
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() {
|
||||
@@ -131,41 +144,24 @@ void OS_Haiku::finalize() {
|
||||
|
||||
main_loop = NULL;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -195,7 +191,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 +203,10 @@ void OS_Haiku::set_cursor_shape(CursorShape p_shape) {
|
||||
//ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
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 +223,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 +231,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,7 +257,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,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 +319,41 @@ 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" || p_feature == "s3tc";
|
||||
}
|
||||
|
||||
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");
|
||||
} 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(".local/share");
|
||||
} 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(".cache");
|
||||
} else {
|
||||
return get_config_path();
|
||||
}
|
||||
}
|
||||
|
||||
107
os_haiku.h
107
os_haiku.h
@@ -1,58 +1,76 @@
|
||||
/*************************************************************************/
|
||||
/* os_haiku.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 "drivers/unix/os_unix.h"
|
||||
#include "haiku_application.h"
|
||||
#include "haiku_direct_window.h"
|
||||
|
||||
#include "main/input_default.h"
|
||||
#include "power_haiku.h"
|
||||
#include "servers/audio_server.h"
|
||||
#include "servers/visual/rasterizer.h"
|
||||
#include "servers/visual_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;
|
||||
Rasterizer *rasterizer;
|
||||
VisualServer *visual_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;
|
||||
PowerHaiku *power_manager;
|
||||
|
||||
#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 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();
|
||||
@@ -60,27 +78,28 @@ public:
|
||||
|
||||
virtual String get_name();
|
||||
|
||||
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 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 +109,20 @@ 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 OS::PowerState get_power_state();
|
||||
virtual int get_power_seconds_left();
|
||||
virtual int get_power_percent_left();
|
||||
|
||||
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
|
||||
|
||||
@@ -1,6 +1,36 @@
|
||||
/*************************************************************************/
|
||||
/* platform_config.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 GLES3_INCLUDE_H "glad/glad.h"
|
||||
|
||||
74
power_haiku.cpp
Normal file
74
power_haiku.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/*************************************************************************/
|
||||
/* power_haiku.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 "core/error_macros.h"
|
||||
|
||||
#include "power_haiku.h"
|
||||
|
||||
bool PowerHaiku::UpdatePowerInfo() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
OS::PowerState PowerHaiku::get_power_state() {
|
||||
if (UpdatePowerInfo()) {
|
||||
return power_state;
|
||||
} else {
|
||||
WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN");
|
||||
return OS::POWERSTATE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
int PowerX11::get_power_seconds_left() {
|
||||
if (UpdatePowerInfo()) {
|
||||
return nsecs_left;
|
||||
} else {
|
||||
WARN_PRINT("Power management is not implemented on this platform, defaulting to -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int PowerX11::get_power_percent_left() {
|
||||
if (UpdatePowerInfo()) {
|
||||
return percent_left;
|
||||
} else {
|
||||
WARN_PRINT("Power management is not implemented on this platform, defaulting to -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PowerHaiku::PowerHaiku() :
|
||||
nsecs_left(-1),
|
||||
percent_left(-1),
|
||||
power_state(OS::POWERSTATE_UNKNOWN) {
|
||||
}
|
||||
|
||||
PowerHaiku::~PowerHaiku() {
|
||||
}
|
||||
53
power_haiku.h
Normal file
53
power_haiku.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*************************************************************************/
|
||||
/* power_haiku.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 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 PLATFORM_HAIKU_POWER_HAIKU_H_
|
||||
#define PLATFORM_HAIKU_POWER_HAIKU_H_
|
||||
|
||||
#include <os/os.h>
|
||||
|
||||
class PowerHaiku {
|
||||
private:
|
||||
int nsecs_left;
|
||||
int percent_left;
|
||||
OS::PowerState power_state;
|
||||
|
||||
bool UpdatePowerInfo();
|
||||
|
||||
public:
|
||||
PowerHaiku();
|
||||
virtual ~PowerHaiku();
|
||||
|
||||
OS::PowerState get_power_state();
|
||||
int get_power_seconds_left();
|
||||
int get_power_percent_left();
|
||||
};
|
||||
|
||||
#endif /* PLATFORM_HAIKU_POWER_HAIKU_H_ */
|
||||
Reference in New Issue
Block a user