summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/audio_driver_opensl.cpp3
-rw-r--r--platform/android/cpu-features.c2
-rw-r--r--platform/android/detect.py91
-rw-r--r--platform/android/java/src/com/android/godot/payments/PaymentsManager.java4
-rw-r--r--platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java6
-rw-r--r--platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java73
-rw-r--r--platform/bb10/audio_driver_bb10.cpp1
-rw-r--r--platform/haiku/SCsub16
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp143
-rw-r--r--platform/haiku/audio_driver_media_kit.h72
-rw-r--r--platform/haiku/context_gl_haiku.cpp43
-rw-r--r--platform/haiku/context_gl_haiku.h29
-rw-r--r--platform/haiku/detect.py61
-rw-r--r--platform/haiku/godot_haiku.cpp19
-rw-r--r--platform/haiku/haiku_application.cpp7
-rw-r--r--platform/haiku/haiku_application.h13
-rw-r--r--platform/haiku/haiku_direct_window.cpp344
-rw-r--r--platform/haiku/haiku_direct_window.h60
-rw-r--r--platform/haiku/haiku_gl_view.cpp18
-rw-r--r--platform/haiku/haiku_gl_view.h15
-rw-r--r--platform/haiku/key_mapping_haiku.cpp193
-rw-r--r--platform/haiku/key_mapping_haiku.h13
-rw-r--r--platform/haiku/logo.pngbin0 -> 1361 bytes
-rw-r--r--platform/haiku/os_haiku.cpp320
-rw-r--r--platform/haiku/os_haiku.h99
-rw-r--r--platform/haiku/platform_config.h6
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm5
-rw-r--r--platform/windows/tcp_server_winsock.cpp7
-rw-r--r--platform/x11/os_x11.cpp12
30 files changed, 1554 insertions, 123 deletions
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index a08bc8943c..761bef27aa 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -236,13 +236,12 @@ void AudioDriverOpenSL::start(){
ERR_FAIL_COND( res !=SL_RESULT_SUCCESS );
/* Initialize arrays required[] and iidArray[] */
- int i;
SLboolean required[MAX_NUMBER_INTERFACES];
SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
#if 0
- for (i=0; i<MAX_NUMBER_INTERFACES; i++)
+ for (int i=0; i<MAX_NUMBER_INTERFACES; i++)
{
required[i] = SL_BOOLEAN_FALSE;
iidArray[i] = SL_IID_NULL;
diff --git a/platform/android/cpu-features.c b/platform/android/cpu-features.c
index 156d464729..9cdadd5407 100644
--- a/platform/android/cpu-features.c
+++ b/platform/android/cpu-features.c
@@ -127,7 +127,7 @@ static __inline__ void x86_cpuid(int func, int values[4])
static int
get_file_size(const char* pathname)
{
- int fd, ret, result = 0;
+ int fd, result = 0;
char buffer[256];
fd = open(pathname, O_RDONLY);
diff --git a/platform/android/detect.py b/platform/android/detect.py
index c36e35484e..9db5d02b48 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -20,15 +20,14 @@ def can_build():
def get_opts():
return [
- ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
- ('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"),
- #android 2.3
- ('ndk_platform', 'compile for platform: (2.2,2.3)',"2.2"),
- ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
- ('android_stl','enable STL support in android port (for modules)','no'),
- ('armv6','compile for older phones running arm v6 (instead of v7+neon+smp)','no'),
- ('x86','Xompile for Android-x86','no')
-
+ ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
+ ('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"),
+ ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
+ ('NDK_TARGET_X86', 'toolchain to use for the NDK x86',"x86-4.8"),
+ ('ndk_platform', 'compile for platform: (android-<api> , example: android-15)',"android-15"),
+ ('android_arch', 'select compiler architecture: (armv7/armv6/x86)',"armv7"),
+ ('android_neon','enable neon (armv7 only)',"yes"),
+ ('android_stl','enable STL support in android port (for modules)',"no")
]
def get_flags():
@@ -92,8 +91,13 @@ def configure(env):
env['SPAWN'] = mySpawn
- if env['x86']=='yes':
- env['NDK_TARGET']='x86-4.8'
+ ndk_platform=env['ndk_platform']
+
+ if env['android_arch'] not in ['armv7','armv6','x86']:
+ env['android_arch']='armv7'
+
+ if env['android_arch']=='x86':
+ env['NDK_TARGET']=env['NDK_TARGET_X86']
if env['PLATFORM'] == 'win32':
import methods
@@ -101,22 +105,28 @@ def configure(env):
#env['SPAWN'] = methods.win32_spawn
env['SHLIBSUFFIX'] = '.so'
-# env.android_source_modules.append("../libs/apk_expansion")
+ #env.android_source_modules.append("../libs/apk_expansion")
env.android_source_modules.append("../libs/google_play_services")
env.android_source_modules.append("../libs/downloader_library")
env.android_source_modules.append("../libs/play_licensing")
-
- ndk_platform=""
-
- ndk_platform="android-15"
- print("Godot Android!!!!!")
+ neon_text=""
+ if env["android_arch"]=="armv7" and env['android_neon']=='yes':
+ neon_text=" (with neon)"
+ print("Godot Android!!!!! ("+env['android_arch']+")"+neon_text)
env.Append(CPPPATH=['#platform/android'])
- if env['x86']=='yes':
- env.extra_suffix=".x86"
-
+ if env['android_arch']=='x86':
+ env.extra_suffix=".x86"+env.extra_suffix
+ elif env['android_arch']=='armv6':
+ env.extra_suffix=".armv6"+env.extra_suffix
+ elif env["android_arch"]=="armv7":
+ if env['android_neon']=='yes':
+ env.extra_suffix=".armv7.neon"+env.extra_suffix
+ else:
+ env.extra_suffix=".armv7"+env.extra_suffix
+
gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/";
import os
@@ -134,7 +144,7 @@ def configure(env):
env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH']
- if env['x86']=='yes':
+ if env['android_arch']=='x86':
env['CC'] = gcc_path+'/i686-linux-android-gcc'
env['CXX'] = gcc_path+'/i686-linux-android-g++'
env['AR'] = gcc_path+"/i686-linux-android-ar"
@@ -147,7 +157,7 @@ def configure(env):
env['RANLIB'] = gcc_path+"/arm-linux-androideabi-ranlib"
env['AS'] = gcc_path+"/arm-linux-androideabi-as"
- if env['x86']=='yes':
+ if env['android_arch']=='x86':
env['ARCH'] = 'arch-x86'
else:
env['ARCH'] = 'arch-arm'
@@ -161,12 +171,18 @@ def configure(env):
env.Append(CPPPATH=[gcc_include])
# env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ')
- if env['x86']=='yes':
+ env['neon_enabled']=False
+ if env['android_arch']=='x86':
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
- elif env["armv6"]!="no":
+ elif env["android_arch"]=="armv6":
env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
- else:
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ elif env["android_arch"]=="armv7":
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__ -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ if env['android_neon']=='yes':
+ env['neon_enabled']=True
+ env.Append(CCFLAGS=['-mfpu=neon','-D__ARM_NEON__'])
+ else:
+ env.Append(CCFLAGS=['-mfpu=vfpv3-d16'])
env.Append(LDPATH=[ld_path])
env.Append(LIBS=['OpenSLES'])
@@ -190,9 +206,6 @@ def configure(env):
env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED'])
env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
- if env["armv6"] == "no" and env['x86'] != 'yes':
- env['neon_enabled']=True
-
env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT'])
# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
@@ -202,9 +215,17 @@ def configure(env):
if (env['android_stl']=='yes'):
#env.Append(CCFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/system/include"])
- env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/include"])
- env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include"])
- env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi"])
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/include"])
+ if env['android_arch']=='x86':
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86"])
+ elif env['android_arch']=='armv6':
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi"])
+ elif env["android_arch"]=="armv7":
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a"])
+
env.Append(LIBS=["gnustl_static","supc++"])
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
@@ -215,10 +236,12 @@ def configure(env):
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/include"])
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
- if env['x86']=='yes':
+ if env['android_arch']=='x86':
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/x86"])
- else:
+ elif env["android_arch"]=="armv6":
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi"])
+ elif env["android_arch"]=="armv7":
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi-v7a"])
env.Append(LIBS=['gabi++_static'])
env.Append(CCFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST'])
diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
index fd1a62738a..5bf86d0b69 100644
--- a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
@@ -47,8 +47,10 @@ public class PaymentsManager {
}
public PaymentsManager initService(){
+ Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
+ intent.setPackage("com.android.vending");
activity.bindService(
- new Intent("com.android.vending.billing.InAppBillingService.BIND"),
+ intent,
mServiceConn,
Context.BIND_AUTO_CREATE);
return this;
diff --git a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java b/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java
deleted file mode 100644
index da9d06e63c..0000000000
--- a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package com.android.vending.expansion.downloader;
-
-public final class BuildConfig {
- public final static boolean DEBUG = false;
-} \ No newline at end of file
diff --git a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java b/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java
deleted file mode 100644
index 330aed1856..0000000000
--- a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package com.android.vending.expansion.downloader;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static int notify_panel_notification_icon_bg=0x7f020000;
- }
- public static final class id {
- public static int appIcon=0x7f060001;
- public static int description=0x7f060007;
- public static int notificationLayout=0x7f060000;
- public static int progress_bar=0x7f060006;
- public static int progress_bar_frame=0x7f060005;
- public static int progress_text=0x7f060002;
- public static int time_remaining=0x7f060004;
- public static int title=0x7f060003;
- }
- public static final class layout {
- public static int status_bar_ongoing_event_progress_bar=0x7f030000;
- }
- public static final class string {
- public static int kilobytes_per_second=0x7f040014;
- /** When a download completes, a notification is displayed, and this
- string is used to indicate that the download successfully completed.
- Note that such a download could have been initiated by a variety of
- applications, including (but not limited to) the browser, an email
- application, a content marketplace.
- */
- public static int notification_download_complete=0x7f040000;
- /** When a download completes, a notification is displayed, and this
- string is used to indicate that the download failed.
- Note that such a download could have been initiated by a variety of
- applications, including (but not limited to) the browser, an email
- application, a content marketplace.
- */
- public static int notification_download_failed=0x7f040001;
- public static int state_completed=0x7f040007;
- public static int state_connecting=0x7f040005;
- public static int state_downloading=0x7f040006;
- public static int state_failed=0x7f040013;
- public static int state_failed_cancelled=0x7f040012;
- public static int state_failed_fetching_url=0x7f040010;
- public static int state_failed_sdcard_full=0x7f040011;
- public static int state_failed_unlicensed=0x7f04000f;
- public static int state_fetching_url=0x7f040004;
- public static int state_idle=0x7f040003;
- public static int state_paused_by_request=0x7f04000a;
- public static int state_paused_network_setup_failure=0x7f040009;
- public static int state_paused_network_unavailable=0x7f040008;
- public static int state_paused_roaming=0x7f04000d;
- public static int state_paused_sdcard_unavailable=0x7f04000e;
- public static int state_paused_wifi_disabled=0x7f04000c;
- public static int state_paused_wifi_unavailable=0x7f04000b;
- public static int state_unknown=0x7f040002;
- public static int time_remaining=0x7f040015;
- public static int time_remaining_notification=0x7f040016;
- }
- public static final class style {
- public static int ButtonBackground=0x7f050003;
- public static int NotificationText=0x7f050000;
- public static int NotificationTextSecondary=0x7f050004;
- public static int NotificationTextShadow=0x7f050001;
- public static int NotificationTitle=0x7f050002;
- }
-}
diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp
index 2f1d5a49b3..f12625d3b8 100644
--- a/platform/bb10/audio_driver_bb10.cpp
+++ b/platform/bb10/audio_driver_bb10.cpp
@@ -53,7 +53,6 @@ Error AudioDriverBB10::init(const char* p_name) {
dev_name = (char *) p_name;
}
printf("******** reconnecting to device %s\n", dev_name);
- int card, dev;
int ret = snd_pcm_open_name(&pcm_handle, dev_name, SND_PCM_OPEN_PLAYBACK);
ERR_FAIL_COND_V(ret < 0, FAILED);
pcm_open = true;
diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub
new file mode 100644
index 0000000000..859095fa5a
--- /dev/null
+++ b/platform/haiku/SCsub
@@ -0,0 +1,16 @@
+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'
+]
+
+env.Program(
+ '#bin/godot',
+ ['godot_haiku.cpp'] + common_haiku
+)
diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp
new file mode 100644
index 0000000000..3fabe4f96f
--- /dev/null
+++ b/platform/haiku/audio_driver_media_kit.cpp
@@ -0,0 +1,143 @@
+/*************************************************************************/
+/* audio_driver_media_kit.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "audio_driver_media_kit.h"
+
+#ifdef MEDIA_KIT_ENABLED
+
+#include "globals.h"
+
+int32_t* AudioDriverMediaKit::samples_in = NULL;
+
+Error AudioDriverMediaKit::init() {
+ active = false;
+
+ mix_rate = 44100;
+ output_format = OUTPUT_STEREO;
+ channels = 2;
+
+ int latency = GLOBAL_DEF("audio/output_latency", 25);
+ buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ samples_in = memnew_arr(int32_t, buffer_size * channels);
+
+ media_raw_audio_format format;
+ format = media_raw_audio_format::wildcard;
+ format.frame_rate = mix_rate;
+ format.channel_count = channels;
+ format.format = media_raw_audio_format::B_AUDIO_INT;
+ format.byte_order = B_MEDIA_LITTLE_ENDIAN;
+ format.buffer_size = buffer_size * sizeof(int32_t) * channels;
+
+ player = new BSoundPlayer(
+ &format,
+ "godot_sound_server",
+ AudioDriverMediaKit::PlayBuffer,
+ NULL,
+ 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);
+ }
+
+ 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;
+
+ if (!ad->active) {
+ for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
+ AudioDriverMediaKit::samples_in[i] = 0;
+ }
+ } else {
+ ad->lock();
+ ad->audio_server_process(ad->buffer_size, AudioDriverMediaKit::samples_in);
+ ad->unlock();
+ }
+
+ for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
+ buf[i] = AudioDriverMediaKit::samples_in[i];
+ }
+}
+
+void AudioDriverMediaKit::start() {
+ active = true;
+}
+
+int AudioDriverMediaKit::get_mix_rate() const {
+ return mix_rate;
+}
+
+AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const {
+ return output_format;
+}
+
+void AudioDriverMediaKit::lock() {
+ if (!mutex)
+ return;
+
+ mutex->lock();
+}
+
+void AudioDriverMediaKit::unlock() {
+ if (!mutex)
+ return;
+
+ mutex->unlock();
+}
+
+void AudioDriverMediaKit::finish() {
+ if (player)
+ delete player;
+
+ if (samples_in) {
+ memdelete_arr(samples_in);
+ };
+
+ if (mutex) {
+ memdelete(mutex);
+ mutex = NULL;
+ }
+}
+
+AudioDriverMediaKit::AudioDriverMediaKit() {
+ mutex = NULL;
+ player = NULL;
+}
+
+AudioDriverMediaKit::~AudioDriverMediaKit() {
+
+}
+
+#endif
diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h
new file mode 100644
index 0000000000..a23ec447f1
--- /dev/null
+++ b/platform/haiku/audio_driver_media_kit.h
@@ -0,0 +1,72 @@
+/*************************************************************************/
+/* audio_driver_media_kit.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "servers/audio/audio_server_sw.h"
+
+#ifdef MEDIA_KIT_ENABLED
+
+#include "core/os/thread.h"
+#include "core/os/mutex.h"
+
+#include <kernel/image.h> // needed for image_id
+#include <SoundPlayer.h>
+
+class AudioDriverMediaKit : public AudioDriverSW {
+ Mutex* mutex;
+
+ BSoundPlayer* player;
+ static int32_t* samples_in;
+
+ static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format);
+
+ unsigned int mix_rate;
+ OutputFormat output_format;
+ unsigned int buffer_size;
+ int channels;
+
+ bool active;
+
+public:
+
+ 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 void lock();
+ virtual void unlock();
+ virtual void finish();
+
+ AudioDriverMediaKit();
+ ~AudioDriverMediaKit();
+};
+
+#endif
diff --git a/platform/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp
new file mode 100644
index 0000000000..21107a52a4
--- /dev/null
+++ b/platform/haiku/context_gl_haiku.cpp
@@ -0,0 +1,43 @@
+#include "context_gl_haiku.h"
+
+#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
+
+ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow* p_window) {
+ window = p_window;
+
+ uint32 type = BGL_RGB | BGL_DOUBLE | BGL_DEPTH;
+ view = new HaikuGLView(window->Bounds(), type);
+}
+
+ContextGL_Haiku::~ContextGL_Haiku() {
+ delete view;
+}
+
+Error ContextGL_Haiku::initialize() {
+ window->AddChild(view);
+ window->SetHaikuGLView(view);
+
+ return OK;
+}
+
+void ContextGL_Haiku::release_current() {
+ view->UnlockGL();
+}
+
+void ContextGL_Haiku::make_current() {
+ view->LockGL();
+}
+
+void ContextGL_Haiku::swap_buffers() {
+ view->SwapBuffers();
+}
+
+int ContextGL_Haiku::get_window_width() {
+ return window->Bounds().IntegerWidth();
+}
+
+int ContextGL_Haiku::get_window_height() {
+ return window->Bounds().IntegerHeight();
+}
+
+#endif
diff --git a/platform/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h
new file mode 100644
index 0000000000..e37fe14970
--- /dev/null
+++ b/platform/haiku/context_gl_haiku.h
@@ -0,0 +1,29 @@
+#ifndef CONTEXT_GL_HAIKU_H
+#define CONTEXT_GL_HAIKU_H
+
+#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
+
+#include "drivers/gl_context/context_gl.h"
+
+#include "haiku_direct_window.h"
+#include "haiku_gl_view.h"
+
+class ContextGL_Haiku : public ContextGL {
+private:
+ HaikuGLView* view;
+ HaikuDirectWindow* window;
+
+public:
+ ContextGL_Haiku(HaikuDirectWindow* p_window);
+ ~ContextGL_Haiku();
+
+ 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();
+};
+
+#endif
+#endif
diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py
new file mode 100644
index 0000000000..b5fd550442
--- /dev/null
+++ b/platform/haiku/detect.py
@@ -0,0 +1,61 @@
+import os
+import sys
+
+def is_active():
+ return True
+
+def get_name():
+ return "Haiku"
+
+def can_build():
+ if (os.name != "posix"):
+ return False
+
+ if (sys.platform == "darwin"):
+ return False
+
+ return True
+
+def get_opts():
+ return [
+ ('debug_release', 'Add debug symbols to release version','no')
+ ]
+
+def get_flags():
+ return [
+ ('builtin_zlib', 'no')
+ ]
+
+def configure(env):
+ is64 = sys.maxsize > 2**32
+
+ if (env["bits"]=="default"):
+ if (is64):
+ env["bits"]="64"
+ else:
+ env["bits"]="32"
+
+ env.Append(CPPPATH = ['#platform/haiku'])
+
+ env["CC"] = "gcc"
+ env["CXX"] = "g++"
+
+ 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'])
+
+ #env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
+ 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'])
+
+ 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')})
diff --git a/platform/haiku/godot_haiku.cpp b/platform/haiku/godot_haiku.cpp
new file mode 100644
index 0000000000..b4e5e50891
--- /dev/null
+++ b/platform/haiku/godot_haiku.cpp
@@ -0,0 +1,19 @@
+#include "main/main.h"
+#include "os_haiku.h"
+
+int main(int argc, char* argv[]) {
+ OS_Haiku os;
+
+ 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();
+}
diff --git a/platform/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp
new file mode 100644
index 0000000000..ea20d73729
--- /dev/null
+++ b/platform/haiku/haiku_application.cpp
@@ -0,0 +1,7 @@
+#include "haiku_application.h"
+
+HaikuApplication::HaikuApplication()
+ : BApplication("application/x-vnd.Godot")
+{
+
+}
diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h
new file mode 100644
index 0000000000..a64b01c94d
--- /dev/null
+++ b/platform/haiku/haiku_application.h
@@ -0,0 +1,13 @@
+#ifndef HAIKU_APPLICATION_H
+#define HAIKU_APPLICATION_H
+
+#include <kernel/image.h> // needed for image_id
+#include <Application.h>
+
+class HaikuApplication : public BApplication
+{
+public:
+ HaikuApplication();
+};
+
+#endif
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
new file mode 100644
index 0000000000..3914ee272a
--- /dev/null
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -0,0 +1,344 @@
+#include <UnicodeChar.h>
+
+#include "main/main.h"
+#include "os/keyboard.h"
+#include "haiku_direct_window.h"
+#include "key_mapping_haiku.h"
+
+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() {
+ if (update_runner) {
+ delete update_runner;
+ }
+}
+
+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 */);
+}
+
+void HaikuDirectWindow::StopMessageRunner() {
+ delete update_runner;
+}
+
+void HaikuDirectWindow::SetInput(InputDefault* p_input) {
+ input = p_input;
+}
+
+void HaikuDirectWindow::SetMainLoop(MainLoop* p_main_loop) {
+ main_loop = p_main_loop;
+}
+
+bool HaikuDirectWindow::QuitRequested() {
+ main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
+ return false;
+}
+
+void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) {
+ view->DirectConnected(info);
+ view->EnableDirectMode(true);
+}
+
+void HaikuDirectWindow::MessageReceived(BMessage* message) {
+ switch (message->what) {
+ case REDRAW_MSG:
+ if (Main::iteration() == true) {
+ view->EnableDirectMode(false);
+ Quit();
+ }
+ break;
+
+ default:
+ BDirectWindow::MessageReceived(message);
+ }
+}
+
+void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) {
+ switch (message->what) {
+ case B_MOUSE_DOWN:
+ case B_MOUSE_UP:
+ HandleMouseButton(message);
+ break;
+
+ case B_MOUSE_MOVED:
+ HandleMouseMoved(message);
+ break;
+
+ case B_MOUSE_WHEEL_CHANGED:
+ HandleMouseWheelChanged(message);
+ break;
+
+ case B_KEY_DOWN:
+ case B_KEY_UP:
+ HandleKeyboardEvent(message);
+ break;
+
+ case B_MODIFIERS_CHANGED:
+ HandleKeyboardModifierEvent(message);
+ break;
+
+ case B_WINDOW_RESIZED:
+ HandleWindowResized(message);
+ break;
+
+ case LOCKGL_MSG:
+ view->LockGL();
+ break;
+
+ case UNLOCKGL_MSG:
+ view->UnlockGL();
+ break;
+
+ default:
+ BDirectWindow::DispatchMessage(message, handler);
+ }
+}
+
+void HaikuDirectWindow::HandleMouseButton(BMessage* message) {
+ BPoint where;
+ if (message->FindPoint("where", &where) != B_OK) {
+ return;
+ }
+
+ uint32 modifiers = message->FindInt32("modifiers");
+ uint32 buttons = message->FindInt32("buttons");
+ uint32 button = buttons ^ last_buttons_state;
+ 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;
+ //}
+
+ InputEvent mouse_event;
+ mouse_event.ID = ++event_id;
+ mouse_event.type = 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.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;
+ break;
+
+ case B_SECONDARY_MOUSE_BUTTON:
+ mouse_event.mouse_button.button_index = 2;
+ break;
+
+ case B_TERTIARY_MOUSE_BUTTON:
+ mouse_event.mouse_button.button_index = 3;
+ break;
+ }
+
+ mouse_event.mouse_button.pressed = (message->what == B_MOUSE_DOWN);
+
+ if (message->what == B_MOUSE_DOWN && mouse_event.mouse_button.button_index == 1) {
+ int32 clicks = message->FindInt32("clicks");
+
+ if (clicks > 1) {
+ mouse_event.mouse_button.doubleclick=true;
+ }
+ }
+
+ input->parse_input_event(mouse_event);
+}
+
+void HaikuDirectWindow::HandleMouseMoved(BMessage* message) {
+ BPoint where;
+ if (message->FindPoint("where", &where) != B_OK) {
+ return;
+ }
+
+ Point2i pos(where.x, where.y);
+ uint32 modifiers = message->FindInt32("modifiers");
+ uint32 buttons = message->FindInt32("buttons");
+
+ if (!last_mouse_pos_valid) {
+ last_mouse_position = pos;
+ last_mouse_pos_valid = true;
+ }
+
+ Point2i rel = pos - last_mouse_position;
+
+ InputEvent motion_event;
+ motion_event.ID = ++event_id;
+ motion_event.type = InputEvent::MOUSE_MOTION;
+ motion_event.device = 0;
+
+ 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.mouse_motion.relative_x = rel.x;
+ motion_event.mouse_motion.relative_y = rel.y;
+
+ last_mouse_position = pos;
+
+ input->parse_input_event(motion_event);
+}
+
+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;
+
+ 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.mouse_button.pressed = true;
+ input->parse_input_event(mouse_event);
+
+ mouse_event.ID = ++event_id;
+ mouse_event.mouse_button.pressed = false;
+ input->parse_input_event(mouse_event);
+}
+
+void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) {
+ int32 raw_char = 0;
+ int32 key = 0;
+ int32 modifiers = 0;
+
+ if (message->FindInt32("raw_char", &raw_char) != B_OK) {
+ return;
+ }
+
+ if (message->FindInt32("key", &key) != B_OK) {
+ return;
+ }
+
+ if (message->FindInt32("modifiers", &modifiers) != B_OK) {
+ 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;
+
+ 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;
+ }
+
+ input->parse_input_event(event);
+}
+
+void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage* message) {
+ int32 old_modifiers = 0;
+ int32 modifiers = 0;
+
+ if (message->FindInt32("be:old_modifiers", &old_modifiers) != B_OK) {
+ return;
+ }
+
+ if (message->FindInt32("modifiers", &modifiers) != B_OK) {
+ return;
+ }
+
+ 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;
+
+ input->parse_input_event(event);
+}
+
+void HaikuDirectWindow::HandleWindowResized(BMessage* message) {
+ int32 width = 0;
+ int32 height = 0;
+
+ if ((message->FindInt32("width", &width) != B_OK) || (message->FindInt32("height", &height) != B_OK)) {
+ return;
+ }
+
+ current_video_mode->width = width;
+ current_video_mode->height = height;
+}
+
+inline InputModifierState HaikuDirectWindow::GetKeyModifierState(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;
+
+ return state;
+}
+
+inline int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) {
+ int state = 0;
+
+ if (p_state & B_PRIMARY_MOUSE_BUTTON) {
+ state |= 1 << 0;
+ }
+
+ if (p_state & B_SECONDARY_MOUSE_BUTTON) {
+ state |= 1 << 1;
+ }
+
+ if (p_state & B_TERTIARY_MOUSE_BUTTON) {
+ state |= 1 << 2;
+ }
+
+ last_button_mask = state;
+
+ return state;
+}
diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h
new file mode 100644
index 0000000000..f0398df505
--- /dev/null
+++ b/platform/haiku/haiku_direct_window.h
@@ -0,0 +1,60 @@
+#ifndef HAIKU_DIRECT_WINDOW_H
+#define HAIKU_DIRECT_WINDOW_H
+
+#include <kernel/image.h> // needed for image_id
+#include <DirectWindow.h>
+
+#include "core/os/os.h"
+#include "main/input_default.h"
+
+#include "haiku_gl_view.h"
+
+#define REDRAW_MSG 'rdrw'
+#define LOCKGL_MSG 'glck'
+#define UNLOCKGL_MSG 'ulck'
+
+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;
+
+ 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);
+ inline int GetMouseButtonState(uint32 p_state);
+
+public:
+ HaikuDirectWindow(BRect p_frame);
+ ~HaikuDirectWindow();
+
+ 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; };
+ virtual bool QuitRequested();
+ 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; };
+};
+
+#endif
diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp
new file mode 100644
index 0000000000..481d6098a7
--- /dev/null
+++ b/platform/haiku/haiku_gl_view.cpp
@@ -0,0 +1,18 @@
+#include "main/main.h"
+#include "haiku_gl_view.h"
+
+HaikuGLView::HaikuGLView(BRect frame, uint32 type)
+ : BGLView(frame, "GodotGLView", B_FOLLOW_ALL_SIDES, 0, type)
+{
+}
+
+void HaikuGLView::AttachedToWindow(void) {
+ LockGL();
+ BGLView::AttachedToWindow();
+ UnlockGL();
+ MakeFocus();
+}
+
+void HaikuGLView::Draw(BRect updateRect) {
+ Main::force_redraw();
+}
diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h
new file mode 100644
index 0000000000..f44b6d4325
--- /dev/null
+++ b/platform/haiku/haiku_gl_view.h
@@ -0,0 +1,15 @@
+#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
+{
+public:
+ HaikuGLView(BRect frame, uint32 type);
+ virtual void AttachedToWindow(void);
+ virtual void Draw(BRect updateRect);
+};
+
+#endif
diff --git a/platform/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp
new file mode 100644
index 0000000000..d7bde9a727
--- /dev/null
+++ b/platform/haiku/key_mapping_haiku.cpp
@@ -0,0 +1,193 @@
+#include <InterfaceDefs.h>
+
+#include "key_mapping_haiku.h"
+#include "os/keyboard.h"
+
+struct _HaikuTranslatePair {
+ unsigned int keysym;
+ int32 keycode;
+};
+
+static _HaikuTranslatePair _mod_to_keycode[] = {
+ { KEY_SHIFT, B_SHIFT_KEY },
+ { KEY_ALT, B_COMMAND_KEY },
+ { KEY_CONTROL, B_CONTROL_KEY },
+ { KEY_CAPSLOCK, B_CAPS_LOCK },
+ { KEY_SCROLLLOCK, B_SCROLL_LOCK },
+ { KEY_NUMLOCK, B_NUM_LOCK },
+ { KEY_SUPER_L, B_OPTION_KEY },
+ { KEY_MENU, B_MENU_KEY },
+ { KEY_SHIFT, B_LEFT_SHIFT_KEY },
+ { KEY_SHIFT, B_RIGHT_SHIFT_KEY },
+ { KEY_ALT, B_LEFT_COMMAND_KEY },
+ { KEY_ALT, B_RIGHT_COMMAND_KEY },
+ { KEY_CONTROL, B_LEFT_CONTROL_KEY },
+ { KEY_CONTROL, B_RIGHT_CONTROL_KEY },
+ { KEY_SUPER_L, B_LEFT_OPTION_KEY },
+ { KEY_SUPER_R, B_RIGHT_OPTION_KEY },
+ { KEY_UNKNOWN, 0 }
+};
+
+static _HaikuTranslatePair _fn_to_keycode[] = {
+ { KEY_F1, B_F1_KEY },
+ { KEY_F2, B_F2_KEY },
+ { KEY_F3, B_F3_KEY },
+ { KEY_F4, B_F4_KEY },
+ { KEY_F5, B_F5_KEY },
+ { KEY_F6, B_F6_KEY },
+ { KEY_F7, B_F7_KEY },
+ { KEY_F8, B_F8_KEY },
+ { KEY_F9, B_F9_KEY },
+ { KEY_F10, B_F10_KEY },
+ { KEY_F11, B_F11_KEY },
+ { KEY_F12, B_F12_KEY },
+ //{ KEY_F13, ? },
+ //{ KEY_F14, ? },
+ //{ KEY_F15, ? },
+ //{ KEY_F16, ? },
+ { KEY_PRINT, B_PRINT_KEY },
+ { KEY_SCROLLLOCK, B_SCROLL_KEY },
+ { KEY_PAUSE, B_PAUSE_KEY },
+ { KEY_UNKNOWN, 0 }
+};
+
+static _HaikuTranslatePair _hb_to_keycode[] = {
+ { KEY_BACKSPACE, B_BACKSPACE },
+ { KEY_TAB, B_TAB },
+ { KEY_RETURN, B_RETURN },
+ { KEY_CAPSLOCK, B_CAPS_LOCK },
+ { KEY_ESCAPE, B_ESCAPE },
+ { KEY_SPACE, B_SPACE },
+ { KEY_PAGEUP, B_PAGE_UP },
+ { KEY_PAGEDOWN, B_PAGE_DOWN },
+ { KEY_END, B_END },
+ { KEY_HOME, B_HOME },
+ { KEY_LEFT, B_LEFT_ARROW },
+ { KEY_UP, B_UP_ARROW },
+ { KEY_RIGHT, B_RIGHT_ARROW },
+ { KEY_DOWN, B_DOWN_ARROW },
+ { KEY_PRINT, B_PRINT_KEY },
+ { KEY_INSERT, B_INSERT },
+ { KEY_DELETE, B_DELETE },
+ // { KEY_HELP, ??? },
+
+ { KEY_0, (0x30) },
+ { KEY_1, (0x31) },
+ { KEY_2, (0x32) },
+ { KEY_3, (0x33) },
+ { KEY_4, (0x34) },
+ { KEY_5, (0x35) },
+ { KEY_6, (0x36) },
+ { KEY_7, (0x37) },
+ { KEY_8, (0x38) },
+ { KEY_9, (0x39) },
+ { KEY_A, (0x61) },
+ { KEY_B, (0x62) },
+ { KEY_C, (0x63) },
+ { KEY_D, (0x64) },
+ { KEY_E, (0x65) },
+ { KEY_F, (0x66) },
+ { KEY_G, (0x67) },
+ { KEY_H, (0x68) },
+ { KEY_I, (0x69) },
+ { KEY_J, (0x6A) },
+ { KEY_K, (0x6B) },
+ { KEY_L, (0x6C) },
+ { KEY_M, (0x6D) },
+ { KEY_N, (0x6E) },
+ { KEY_O, (0x6F) },
+ { KEY_P, (0x70) },
+ { KEY_Q, (0x71) },
+ { KEY_R, (0x72) },
+ { KEY_S, (0x73) },
+ { KEY_T, (0x74) },
+ { KEY_U, (0x75) },
+ { KEY_V, (0x76) },
+ { KEY_W, (0x77) },
+ { KEY_X, (0x78) },
+ { KEY_Y, (0x79) },
+ { KEY_Z, (0x7A) },
+
+/*
+{ KEY_PLAY, VK_PLAY},// (0xFA)
+{ KEY_STANDBY,VK_SLEEP },//(0x5F)
+{ KEY_BACK,VK_BROWSER_BACK},// (0xA6)
+{ KEY_FORWARD,VK_BROWSER_FORWARD},// (0xA7)
+{ KEY_REFRESH,VK_BROWSER_REFRESH},// (0xA8)
+{ KEY_STOP,VK_BROWSER_STOP},// (0xA9)
+{ KEY_SEARCH,VK_BROWSER_SEARCH},// (0xAA)
+{ KEY_FAVORITES, VK_BROWSER_FAVORITES},// (0xAB)
+{ KEY_HOMEPAGE,VK_BROWSER_HOME},// (0xAC)
+{ KEY_VOLUMEMUTE,VK_VOLUME_MUTE},// (0xAD)
+{ KEY_VOLUMEDOWN,VK_VOLUME_DOWN},// (0xAE)
+{ KEY_VOLUMEUP,VK_VOLUME_UP},// (0xAF)
+{ KEY_MEDIANEXT,VK_MEDIA_NEXT_TRACK},// (0xB0)
+{ KEY_MEDIAPREVIOUS,VK_MEDIA_PREV_TRACK},// (0xB1)
+{ KEY_MEDIASTOP,VK_MEDIA_STOP},// (0xB2)
+{ KEY_LAUNCHMAIL, VK_LAUNCH_MAIL},// (0xB4)
+{ KEY_LAUNCHMEDIA,VK_LAUNCH_MEDIA_SELECT},// (0xB5)
+{ KEY_LAUNCH0,VK_LAUNCH_APP1},// (0xB6)
+{ KEY_LAUNCH1,VK_LAUNCH_APP2},// (0xB7)
+*/
+
+ { KEY_SEMICOLON, 0x3B },
+ { KEY_EQUAL, 0x3D },
+ { KEY_COLON, 0x2C },
+ { KEY_MINUS, 0x2D },
+ { KEY_PERIOD, 0x2E },
+ { KEY_SLASH, 0x2F },
+ { KEY_KP_MULTIPLY, 0x2A },
+ { KEY_KP_ADD, 0x2B },
+
+ { KEY_QUOTELEFT, 0x60 },
+ { KEY_BRACKETLEFT, 0x5B },
+ { KEY_BACKSLASH, 0x5C },
+ { KEY_BRACKETRIGHT, 0x5D },
+ { KEY_APOSTROPHE, 0x27 },
+
+ { KEY_UNKNOWN, 0 }
+};
+
+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_SUBSTRACT; }
+ 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++) {
+ if (_fn_to_keycode[i].keycode == key) {
+ return _fn_to_keycode[i].keysym;
+ }
+ }
+
+ return KEY_UNKNOWN;
+ }
+
+ 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;
+ }
+ }
+
+ return KEY_UNKNOWN;
+}
+
+unsigned int KeyMappingHaiku::get_modifier_keysym(int32 key) {
+ 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;
+ }
+ }
+
+ return KEY_UNKNOWN;
+}
diff --git a/platform/haiku/key_mapping_haiku.h b/platform/haiku/key_mapping_haiku.h
new file mode 100644
index 0000000000..e2864678a8
--- /dev/null
+++ b/platform/haiku/key_mapping_haiku.h
@@ -0,0 +1,13 @@
+#ifndef KEY_MAPPING_HAIKU_H
+#define KEY_MAPPING_HAIKU_H
+
+class KeyMappingHaiku
+{
+ KeyMappingHaiku() {};
+
+public:
+ static unsigned int get_keysym(int32 raw_char, int32 key);
+ static unsigned int get_modifier_keysym(int32 key);
+};
+
+#endif
diff --git a/platform/haiku/logo.png b/platform/haiku/logo.png
new file mode 100644
index 0000000000..42d7728da8
--- /dev/null
+++ b/platform/haiku/logo.png
Binary files differ
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
new file mode 100644
index 0000000000..1edb23d504
--- /dev/null
+++ b/platform/haiku/os_haiku.cpp
@@ -0,0 +1,320 @@
+#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"
+
+#include "os_haiku.h"
+
+
+OS_Haiku::OS_Haiku() {
+#ifdef MEDIA_KIT_ENABLED
+ AudioDriverManagerSW::add_driver(&driver_media_kit);
+#endif
+};
+
+void OS_Haiku::run() {
+ if (!main_loop) {
+ return;
+ }
+
+ main_loop->init();
+ context_gl->release_current();
+
+ // TODO: clean up
+ BMessenger* bms = new BMessenger(window);
+ BMessage* msg = new BMessage();
+ bms->SendMessage(LOCKGL_MSG, msg);
+
+ window->StartMessageRunner();
+ app->Run();
+ window->StopMessageRunner();
+
+ delete app;
+
+ delete bms;
+ delete msg;
+ main_loop->finish();
+}
+
+String OS_Haiku::get_name() {
+ return "Haiku";
+}
+
+int OS_Haiku::get_video_driver_count() const {
+ return 1;
+}
+
+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);
+}
+
+void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) {
+ main_loop = NULL;
+ current_video_mode = p_desired;
+
+ app = new HaikuApplication();
+
+ BRect frame;
+ frame.Set(50, 50, 50 + current_video_mode.width - 1, 50 + current_video_mode.height - 1);
+
+ window = new HaikuDirectWindow(frame);
+ window->SetVideoMode(&current_video_mode);
+
+ if (current_video_mode.fullscreen) {
+ window->SetFullScreen(true);
+ }
+
+ if (!current_video_mode.resizable) {
+ uint32 flags = window->Flags();
+ flags |= B_NOT_RESIZABLE;
+ window->SetFlags(flags);
+ }
+
+#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
+ context_gl = memnew(ContextGL_Haiku(window));
+ context_gl->initialize();
+ context_gl->make_current();
+
+ rasterizer = memnew(RasterizerGLES2);
+#endif
+
+ visual_server = memnew(VisualServerRaster(rasterizer));
+
+ ERR_FAIL_COND(!visual_server);
+
+ // 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));
+ //}
+
+ input = memnew(InputDefault);
+ window->SetInput(input);
+
+ 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();
+
+ 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();
+}
+
+void OS_Haiku::finalize() {
+ if (main_loop) {
+ memdelete(main_loop);
+ }
+
+ main_loop = NULL;
+
+ spatial_sound_server->finish();
+ memdelete(spatial_sound_server);
+
+ spatial_sound_2d_server->finish();
+ memdelete(spatial_sound_2d_server);
+
+ audio_server->finish();
+ memdelete(audio_server);
+ memdelete(sample_manager);
+
+ 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)
+ memdelete(context_gl);
+#endif
+}
+
+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 {
+ return main_loop;
+}
+
+void OS_Haiku::delete_main_loop() {
+ if (main_loop) {
+ memdelete(main_loop);
+ }
+
+ main_loop = NULL;
+ window->SetMainLoop(NULL);
+}
+
+void OS_Haiku::release_rendering_thread() {
+ context_gl->release_current();
+}
+
+void OS_Haiku::make_rendering_thread() {
+ context_gl->make_current();
+}
+
+bool OS_Haiku::can_draw() const {
+ // TODO: implement
+ return true;
+}
+
+void OS_Haiku::swap_buffers() {
+ context_gl->swap_buffers();
+}
+
+Point2 OS_Haiku::get_mouse_pos() const {
+ return window->GetLastMousePosition();
+}
+
+int OS_Haiku::get_mouse_button_state() const {
+ return window->GetLastButtonMask();
+}
+
+void OS_Haiku::set_cursor_shape(CursorShape p_shape) {
+ //ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED");
+}
+
+int OS_Haiku::get_screen_count() const {
+ // TODO: implement get_screen_count()
+ return 1;
+}
+
+int OS_Haiku::get_current_screen() const {
+ // TODO: implement get_current_screen()
+ return 0;
+}
+
+void OS_Haiku::set_current_screen(int p_screen) {
+ // TODO: implement set_current_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);
+ BRect frame = screen->Frame();
+ delete screen;
+ return Point2i(frame.left, frame.top);
+}
+
+Size2 OS_Haiku::get_screen_size(int p_screen) const {
+ // TODO: make this work with the p_screen parameter
+ 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) {
+ window->SetTitle(p_title.utf8().get_data());
+}
+
+Size2 OS_Haiku::get_window_size() const {
+ BSize size = window->Size();
+ return Size2i(size.IntegerWidth() + 1, size.IntegerHeight() + 1);
+}
+
+void OS_Haiku::set_window_size(const Size2 p_size) {
+ // TODO: why does it stop redrawing after this is called?
+ window->ResizeTo(p_size.x, p_size.y);
+}
+
+Point2 OS_Haiku::get_window_position() const {
+ BPoint point(0, 0);
+ window->ConvertToScreen(&point);
+ return Point2i(point.x, point.y);
+}
+
+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();
+}
+
+bool OS_Haiku::is_window_fullscreen() const {
+ return current_video_mode.fullscreen;
+}
+
+void OS_Haiku::set_window_resizable(bool p_enabled) {
+ uint32 flags = window->Flags();
+
+ if (p_enabled) {
+ flags &= ~(B_NOT_RESIZABLE);
+ } else {
+ flags |= B_NOT_RESIZABLE;
+ }
+
+ window->SetFlags(flags);
+ current_video_mode.resizable = p_enabled;
+}
+
+bool OS_Haiku::is_window_resizable() const {
+ return current_video_mode.resizable;
+}
+
+void OS_Haiku::set_window_minimized(bool p_enabled) {
+ window->Minimize(p_enabled);
+}
+
+bool OS_Haiku::is_window_minimized() const {
+ return window->IsMinimized();
+}
+
+void OS_Haiku::set_window_maximized(bool p_enabled) {
+ window->Minimize(!p_enabled);
+}
+
+bool OS_Haiku::is_window_maximized() const {
+ return !window->IsMinimized();
+}
+
+void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) {
+ ERR_PRINT("set_video_mode() NOT IMPLEMENTED");
+}
+
+OS::VideoMode OS_Haiku::get_video_mode(int p_screen) const {
+ return current_video_mode;
+}
+
+void OS_Haiku::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
+ ERR_PRINT("get_fullscreen_mode_list() NOT IMPLEMENTED");
+}
+
+String OS_Haiku::get_executable_path() const {
+ return OS::get_executable_path();
+}
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
new file mode 100644
index 0000000000..e1b0b86cf4
--- /dev/null
+++ b/platform/haiku/os_haiku.h
@@ -0,0 +1,99 @@
+#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 "haiku_application.h"
+#include "haiku_direct_window.h"
+
+
+class OS_Haiku : public OS_Unix {
+private:
+ 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;
+
+#ifdef MEDIA_KIT_ENABLED
+ AudioDriverMediaKit driver_media_kit;
+#endif
+
+#if defined(OPENGL_ENABLED) || defined(LEGACYGL_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 void 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);
+
+public:
+ OS_Haiku();
+ void run();
+
+ virtual String get_name();
+
+ 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 int get_mouse_button_state() const;
+ virtual void set_cursor_shape(CursorShape p_shape);
+
+ 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 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_fullscreen(bool p_enabled);
+ virtual bool is_window_fullscreen() const;
+ virtual void set_window_resizable(bool p_enabled);
+ virtual bool is_window_resizable() const;
+ virtual void set_window_minimized(bool p_enabled);
+ virtual bool is_window_minimized() const;
+ 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 String get_executable_path() const;
+};
+
+#endif
diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h
new file mode 100644
index 0000000000..691bdbdb9c
--- /dev/null
+++ b/platform/haiku/platform_config.h
@@ -0,0 +1,6 @@
+#include <alloca.h>
+
+// for ifaddrs.h needed in drivers/unix/ip_unix.cpp
+#define _BSD_SOURCE 1
+
+#define GLES2_INCLUDE_H <GL/glew.h>
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 49fa6c0862..e8277688ac 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -157,6 +157,8 @@ public:
Error shell_open(String p_uri);
void push_input(const InputEvent& p_event);
+ String get_locale() 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;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index b0ce37cecf..4990d04ab6 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1254,6 +1254,11 @@ Error OS_OSX::shell_open(String p_uri) {
return OK;
}
+String OS_OSX::get_locale() const {
+ NSString* preferredLang = [[NSLocale preferredLanguages] objectAtIndex:0];
+ return [preferredLang UTF8String];
+}
+
void OS_OSX::swap_buffers() {
[context flushBuffer];
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
index bf7e85aebb..cc689d9dcf 100644
--- a/platform/windows/tcp_server_winsock.cpp
+++ b/platform/windows/tcp_server_winsock.cpp
@@ -79,6 +79,13 @@ Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_ho
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP TODO: use p_accepted_hosts
memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
+ int reuse=1;
+ if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) < 0) {
+
+ printf("REUSEADDR failed!");
+ }
+
+
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) != SOCKET_ERROR) {
if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) {
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index fe15dd5a08..85928f2815 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -784,8 +784,6 @@ void OS_X11::set_window_size(const Size2 p_size) {
void OS_X11::set_window_fullscreen(bool p_enabled) {
set_wm_fullscreen(p_enabled);
current_videomode.fullscreen = p_enabled;
-
- visual_server->init();
}
bool OS_X11::is_window_fullscreen() const {
@@ -891,8 +889,14 @@ void OS_X11::set_window_maximized(bool p_enabled) {
xev.xclient.data.l[2] = wm_max_vert;
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
-
+/* sorry this does not fix it, fails on multi monitor
+ XWindowAttributes xwa;
+ XGetWindowAttributes(x11_display,DefaultRootWindow(x11_display),&xwa);
+ current_videomode.width = xwa.width;
+ current_videomode.height = xwa.height;
+*/
maximized = p_enabled;
+
}
bool OS_X11::is_window_maximized() const {
@@ -1201,7 +1205,6 @@ void OS_X11::process_xevents() {
#ifdef NEW_WM_API
if(current_videomode.fullscreen) {
set_wm_fullscreen(true);
- visual_server->init();
}
#endif
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
@@ -1218,7 +1221,6 @@ void OS_X11::process_xevents() {
if(current_videomode.fullscreen) {
set_wm_fullscreen(false);
set_window_minimized(true);
- visual_server->init();
}
#endif
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);