diff options
Diffstat (limited to 'platform')
41 files changed, 99 insertions, 2523 deletions
diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle index 80c6be0fae..821a4dc584 100644 --- a/platform/android/java/build.gradle +++ b/platform/android/java/build.gradle @@ -97,13 +97,6 @@ task copyReleaseAARToAppModule(type: Copy) { include('godot-lib.release.aar') } -task copyGodotPaymentPluginToAppModule(type: Copy) { - dependsOn ':plugins:godotpayment:assembleRelease' - from('plugins/godotpayment/build/outputs/aar') - into('app/libs/plugins') - include('GodotPayment.release.aar') -} - /** * Copy the Godot android library archive release file into the root bin directory. * Depends on the library build task to ensure the AAR file is generated prior to copying. @@ -161,7 +154,6 @@ task generateGodotTemplates(type: GradleBuild) { } } - dependsOn 'copyGodotPaymentPluginToAppModule' finalizedBy 'zipCustomBuild' } diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 8ba9b0400f..fcbbc86100 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -262,7 +262,7 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe // Include the returned non-null views in the Godot view hierarchy. for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) { - View pluginView = plugin.onMainCreateView(this); + View pluginView = plugin.onMainCreate(this); if (pluginView != null) { layout.addView(pluginView); } diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java index 431bd4f5f9..ce85880fa3 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java @@ -35,6 +35,7 @@ import org.godotengine.godot.Godot; import android.app.Activity; import android.content.Intent; +import android.os.Bundle; import android.util.Log; import android.view.Surface; import android.view.View; @@ -93,6 +94,14 @@ public abstract class GodotPlugin { } /** + * Provides access to the underlying {@link Activity}. + */ + @Nullable + protected Activity getActivity() { + return godot; + } + + /** * Register the plugin with Godot native code. * * This method is invoked on the render thread. @@ -145,13 +154,14 @@ public abstract class GodotPlugin { * Invoked once during the Godot Android initialization process after creation of the * {@link org.godotengine.godot.GodotView} view. * <p> - * This method should be overridden by descendants of this class that would like to add - * their view/layout to the Godot view hierarchy. + * The plugin can return a non-null {@link View} layout in order to add it to the Godot view + * hierarchy. * - * @return the view to be included; null if no views should be included. + * @see Activity#onCreate(Bundle) + * @return the plugin's view to be included; null if no views should be included. */ @Nullable - public View onMainCreateView(Activity activity) { + public View onMainCreate(Activity activity) { return null; } diff --git a/platform/android/java/plugins/godotpayment/build.gradle b/platform/android/java/plugins/godotpayment/build.gradle deleted file mode 100644 index fb3aa8bba2..0000000000 --- a/platform/android/java/plugins/godotpayment/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion versions.compileSdk - buildToolsVersion versions.buildTools - - defaultConfig { - minSdkVersion versions.minSdk - targetSdkVersion versions.targetSdk - } - - libraryVariants.all { variant -> - variant.outputs.all { output -> - output.outputFileName = "GodotPayment.${variant.name}.aar" - } - } - -} - -dependencies { - implementation libraries.supportCoreUtils - implementation libraries.v4Support - implementation 'com.android.billingclient:billing:2.2.1' - - if (rootProject.findProject(":lib")) { - compileOnly project(":lib") - } else if (rootProject.findProject(":godot:lib")) { - compileOnly project(":godot:lib") - } else { - compileOnly fileTree(dir: 'libs', include: ['godot-lib*.aar']) - } -} diff --git a/platform/android/java/plugins/godotpayment/src/main/AndroidManifest.xml b/platform/android/java/plugins/godotpayment/src/main/AndroidManifest.xml deleted file mode 100644 index 61afa03799..0000000000 --- a/platform/android/java/plugins/godotpayment/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.godotengine.godot.plugin.payment"> - - <application> - - <meta-data - android:name="org.godotengine.plugin.v1.GodotPayment" - android:value="org.godotengine.godot.plugin.payment.GodotPayment" /> - - </application> -</manifest> diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java deleted file mode 100644 index 6447a9ec3f..0000000000 --- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java +++ /dev/null @@ -1,239 +0,0 @@ -/*************************************************************************/ -/* GodotPayment.java */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -package org.godotengine.godot.plugin.payment; - -import org.godotengine.godot.Dictionary; -import org.godotengine.godot.Godot; -import org.godotengine.godot.plugin.GodotPlugin; -import org.godotengine.godot.plugin.SignalInfo; -import org.godotengine.godot.plugin.payment.utils.GodotPaymentUtils; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.collection.ArraySet; - -import com.android.billingclient.api.AcknowledgePurchaseParams; -import com.android.billingclient.api.AcknowledgePurchaseResponseListener; -import com.android.billingclient.api.BillingClient; -import com.android.billingclient.api.BillingClientStateListener; -import com.android.billingclient.api.BillingFlowParams; -import com.android.billingclient.api.BillingResult; -import com.android.billingclient.api.ConsumeParams; -import com.android.billingclient.api.ConsumeResponseListener; -import com.android.billingclient.api.Purchase; -import com.android.billingclient.api.PurchasesUpdatedListener; -import com.android.billingclient.api.SkuDetails; -import com.android.billingclient.api.SkuDetailsParams; -import com.android.billingclient.api.SkuDetailsResponseListener; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -public class GodotPayment extends GodotPlugin implements PurchasesUpdatedListener, BillingClientStateListener { - private final BillingClient billingClient; - private final HashMap<String, SkuDetails> skuDetailsCache = new HashMap<>(); // sku → SkuDetails - - public GodotPayment(Godot godot) { - super(godot); - - billingClient = BillingClient - .newBuilder(getGodot()) - .enablePendingPurchases() - .setListener(this) - .build(); - } - - public void startConnection() { - billingClient.startConnection(this); - } - - public void endConnection() { - billingClient.endConnection(); - } - - public boolean isReady() { - return this.billingClient.isReady(); - } - - public Dictionary queryPurchases(String type) { - Purchase.PurchasesResult result = billingClient.queryPurchases(type); - - Dictionary returnValue = new Dictionary(); - if (result.getBillingResult().getResponseCode() == BillingClient.BillingResponseCode.OK) { - returnValue.put("status", 0); // OK = 0 - returnValue.put("purchases", GodotPaymentUtils.convertPurchaseListToDictionaryObjectArray(result.getPurchasesList())); - } else { - returnValue.put("status", 1); // FAILED = 1 - returnValue.put("response_code", result.getBillingResult().getResponseCode()); - returnValue.put("debug_message", result.getBillingResult().getDebugMessage()); - } - - return returnValue; - } - - public void querySkuDetails(final String[] list, String type) { - List<String> skuList = Arrays.asList(list); - - SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder() - .setSkusList(skuList) - .setType(type); - - billingClient.querySkuDetailsAsync(params.build(), new SkuDetailsResponseListener() { - @Override - public void onSkuDetailsResponse(BillingResult billingResult, - List<SkuDetails> skuDetailsList) { - if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { - for (SkuDetails skuDetails : skuDetailsList) { - skuDetailsCache.put(skuDetails.getSku(), skuDetails); - } - emitSignal("sku_details_query_completed", (Object)GodotPaymentUtils.convertSkuDetailsListToDictionaryObjectArray(skuDetailsList)); - } else { - emitSignal("sku_details_query_error", billingResult.getResponseCode(), billingResult.getDebugMessage(), list); - } - } - }); - } - - public void acknowledgePurchase(final String purchaseToken) { - AcknowledgePurchaseParams acknowledgePurchaseParams = - AcknowledgePurchaseParams.newBuilder() - .setPurchaseToken(purchaseToken) - .build(); - billingClient.acknowledgePurchase(acknowledgePurchaseParams, new AcknowledgePurchaseResponseListener() { - @Override - public void onAcknowledgePurchaseResponse(BillingResult billingResult) { - if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { - emitSignal("purchase_acknowledged", purchaseToken); - } else { - emitSignal("purchase_acknowledgement_error", billingResult.getResponseCode(), billingResult.getDebugMessage(), purchaseToken); - } - } - }); - } - - public void consumePurchase(String purchaseToken) { - ConsumeParams consumeParams = ConsumeParams.newBuilder() - .setPurchaseToken(purchaseToken) - .build(); - - billingClient.consumeAsync(consumeParams, new ConsumeResponseListener() { - @Override - public void onConsumeResponse(BillingResult billingResult, String purchaseToken) { - if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { - emitSignal("purchase_consumed", purchaseToken); - } else { - emitSignal("purchase_consumption_error", billingResult.getResponseCode(), billingResult.getDebugMessage(), purchaseToken); - } - } - }); - } - - @Override - public void onBillingSetupFinished(BillingResult billingResult) { - if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { - emitSignal("connected"); - } else { - emitSignal("connect_error", billingResult.getResponseCode(), billingResult.getDebugMessage()); - } - } - - @Override - public void onBillingServiceDisconnected() { - emitSignal("disconnected"); - } - - public Dictionary purchase(String sku) { - if (!skuDetailsCache.containsKey(sku)) { - emitSignal("purchase_error", null, "You must query the sku details and wait for the result before purchasing!"); - } - - SkuDetails skuDetails = skuDetailsCache.get(sku); - BillingFlowParams purchaseParams = BillingFlowParams.newBuilder() - .setSkuDetails(skuDetails) - .build(); - - BillingResult result = billingClient.launchBillingFlow(getGodot(), purchaseParams); - - Dictionary returnValue = new Dictionary(); - if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) { - returnValue.put("status", 0); // OK = 0 - } else { - returnValue.put("status", 1); // FAILED = 1 - returnValue.put("response_code", result.getResponseCode()); - returnValue.put("debug_message", result.getDebugMessage()); - } - - return returnValue; - } - - @Override - public void onPurchasesUpdated(final BillingResult billingResult, @Nullable final List<Purchase> list) { - if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null) { - emitSignal("purchases_updated", (Object)GodotPaymentUtils.convertPurchaseListToDictionaryObjectArray(list)); - } else { - emitSignal("purchase_error", billingResult.getResponseCode(), billingResult.getDebugMessage()); - } - } - - @NonNull - @Override - public String getPluginName() { - return "GodotPayment"; - } - - @NonNull - @Override - public List<String> getPluginMethods() { - return Arrays.asList("startConnection", "endConnection", "purchase", "querySkuDetails", "isReady", "queryPurchases", "acknowledgePurchase", "consumePurchase"); - } - - @NonNull - @Override - public Set<SignalInfo> getPluginSignals() { - Set<SignalInfo> signals = new ArraySet<>(); - - signals.add(new SignalInfo("connected")); - signals.add(new SignalInfo("disconnected")); - signals.add(new SignalInfo("connect_error", Integer.class, String.class)); - signals.add(new SignalInfo("purchases_updated", Object[].class)); - signals.add(new SignalInfo("purchase_error", Integer.class, String.class)); - signals.add(new SignalInfo("sku_details_query_completed", Object[].class)); - signals.add(new SignalInfo("sku_details_query_error", Integer.class, String.class, String[].class)); - signals.add(new SignalInfo("purchase_acknowledged", String.class)); - signals.add(new SignalInfo("purchase_acknowledgement_error", Integer.class, String.class, String.class)); - signals.add(new SignalInfo("purchase_consumed", String.class)); - signals.add(new SignalInfo("purchase_consumption_error", Integer.class, String.class, String.class)); - - return signals; - } -} diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java deleted file mode 100644 index f569c1b8bf..0000000000 --- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.godotengine.godot.plugin.payment.utils; - -import org.godotengine.godot.Dictionary; - -import com.android.billingclient.api.Purchase; -import com.android.billingclient.api.SkuDetails; - -import java.util.List; - -public class GodotPaymentUtils { - public static Dictionary convertPurchaseToDictionary(Purchase purchase) { - Dictionary dictionary = new Dictionary(); - dictionary.put("order_id", purchase.getOrderId()); - dictionary.put("package_name", purchase.getPackageName()); - dictionary.put("purchase_state", Integer.valueOf(purchase.getPurchaseState())); - dictionary.put("purchase_time", Long.valueOf(purchase.getPurchaseTime())); - dictionary.put("purchase_token", purchase.getPurchaseToken()); - dictionary.put("signature", purchase.getSignature()); - dictionary.put("sku", purchase.getSku()); - dictionary.put("is_acknowledged", Boolean.valueOf(purchase.isAcknowledged())); - dictionary.put("is_auto_renewing", Boolean.valueOf(purchase.isAutoRenewing())); - return dictionary; - } - - public static Dictionary convertSkuDetailsToDictionary(SkuDetails details) { - Dictionary dictionary = new Dictionary(); - dictionary.put("sku", details.getSku()); - dictionary.put("title", details.getTitle()); - dictionary.put("description", details.getDescription()); - dictionary.put("price", details.getPrice()); - dictionary.put("price_currency_code", details.getPriceCurrencyCode()); - dictionary.put("price_amount_micros", Long.valueOf(details.getPriceAmountMicros())); - dictionary.put("free_trial_period", details.getFreeTrialPeriod()); - dictionary.put("icon_url", details.getIconUrl()); - dictionary.put("introductory_price", details.getIntroductoryPrice()); - dictionary.put("introductory_price_amount_micros", Long.valueOf(details.getIntroductoryPriceAmountMicros())); - dictionary.put("introductory_price_cycles", details.getIntroductoryPriceCycles()); - dictionary.put("introductory_price_period", details.getIntroductoryPricePeriod()); - dictionary.put("original_price", details.getOriginalPrice()); - dictionary.put("original_price_amount_micros", Long.valueOf(details.getOriginalPriceAmountMicros())); - dictionary.put("subscription_period", details.getSubscriptionPeriod()); - dictionary.put("type", details.getType()); - dictionary.put("is_rewarded", Boolean.valueOf(details.isRewarded())); - return dictionary; - } - - public static Object[] convertPurchaseListToDictionaryObjectArray(List<Purchase> purchases) { - Object[] purchaseDictionaries = new Object[purchases.size()]; - - for (int i = 0; i < purchases.size(); i++) { - purchaseDictionaries[i] = GodotPaymentUtils.convertPurchaseToDictionary(purchases.get(i)); - } - - return purchaseDictionaries; - } - - public static Object[] convertSkuDetailsListToDictionaryObjectArray(List<SkuDetails> skuDetails) { - Object[] skuDetailsDictionaries = new Object[skuDetails.size()]; - - for (int i = 0; i < skuDetails.size(); i++) { - skuDetailsDictionaries[i] = GodotPaymentUtils.convertSkuDetailsToDictionary(skuDetails.get(i)); - } - - return skuDetailsDictionaries; - } -} diff --git a/platform/android/java/settings.gradle b/platform/android/java/settings.gradle index 9536d3de6d..f6921c70aa 100644 --- a/platform/android/java/settings.gradle +++ b/platform/android/java/settings.gradle @@ -3,4 +3,3 @@ rootProject.name = "Godot" include ':app' include ':lib' -include ':plugins:godotpayment' diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 1f61c4a805..8667727b1d 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -435,6 +435,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env->DeleteLocalRef(obj); }; + static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4]); // something env->PopLocalFrame(nullptr); diff --git a/platform/android/plugin/godot_plugin_config.h b/platform/android/plugin/godot_plugin_config.h index 5bc0fc3a58..ea3c7b4f55 100644 --- a/platform/android/plugin/godot_plugin_config.h +++ b/platform/android/plugin/godot_plugin_config.h @@ -86,17 +86,18 @@ struct PluginConfig { /* * Set of prebuilt plugins. + * Currently unused, this is just for future reference: */ -static const PluginConfig GODOT_PAYMENT = { - /*.valid_config =*/true, - /*.last_updated =*/0, - /*.name =*/"GodotPayment", - /*.binary_type =*/"local", - /*.binary =*/"res://android/build/libs/plugins/GodotPayment.release.aar", - /*.local_dependencies =*/{}, - /*.remote_dependencies =*/String("com.android.billingclient:billing:2.2.1").split("|"), - /*.custom_maven_repos =*/{} -}; +// static const PluginConfig MY_PREBUILT_PLUGIN = { +// /*.valid_config =*/true, +// /*.last_updated =*/0, +// /*.name =*/"GodotPayment", +// /*.binary_type =*/"local", +// /*.binary =*/"res://android/build/libs/plugins/GodotPayment.release.aar", +// /*.local_dependencies =*/{}, +// /*.remote_dependencies =*/String("com.android.billingclient:billing:2.2.1").split("|"), +// /*.custom_maven_repos =*/{} +// }; static inline String resolve_local_dependency_path(String plugin_config_dir, String dependency_path) { String absolute_path; @@ -125,7 +126,7 @@ static inline PluginConfig resolve_prebuilt_plugin(PluginConfig prebuilt_plugin, static inline Vector<PluginConfig> get_prebuilt_plugins(String plugins_base_dir) { Vector<PluginConfig> prebuilt_plugins; - prebuilt_plugins.push_back(resolve_prebuilt_plugin(GODOT_PAYMENT, plugins_base_dir)); + // prebuilt_plugins.push_back(resolve_prebuilt_plugin(MY_PREBUILT_PLUGIN, plugins_base_dir)); return prebuilt_plugins; } diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub deleted file mode 100644 index dbff6c5ae9..0000000000 --- a/platform/haiku/SCsub +++ /dev/null @@ -1,25 +0,0 @@ -#!/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", -] - -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"]) - - -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) diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp deleted file mode 100644 index 2fbbeeb176..0000000000 --- a/platform/haiku/audio_driver_media_kit.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************/ -/* audio_driver_media_kit.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "audio_driver_media_kit.h" - -#ifdef MEDIA_KIT_ENABLED - -#include "core/project_settings.h" - -int32_t *AudioDriverMediaKit::samples_in = nullptr; - -Error AudioDriverMediaKit::init() { - active = false; - - mix_rate = GLOBAL_GET("audio/mix_rate"); - speaker_mode = SPEAKER_MODE_STEREO; - channels = 2; - - int latency = GLOBAL_GET("audio/output_latency"); - buffer_size = next_power_of_2(latency * mix_rate / 1000); - samples_in = memnew_arr(int32_t, buffer_size * channels); - - media_raw_audio_format format; - 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, - nullptr, - this); - - if (player->InitCheck() != B_OK) { - fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n"); - ERR_FAIL_COND_V(player == nullptr, ERR_CANT_OPEN); - } - - 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; -} - -AudioDriverMediaKit::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const { - return speaker_mode; -} - -void AudioDriverMediaKit::lock() { - if (!mutex) - return; - - mutex.lock(); -} - -void AudioDriverMediaKit::unlock() { - if (!mutex) - return; - - mutex.unlock(); -} - -void AudioDriverMediaKit::finish() { - delete player; - - if (samples_in) { - memdelete_arr(samples_in); - }; -} - -AudioDriverMediaKit::AudioDriverMediaKit() { - player = nullptr; -} - -AudioDriverMediaKit::~AudioDriverMediaKit() { -} - -#endif diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h deleted file mode 100644 index 8272780fa7..0000000000 --- a/platform/haiku/audio_driver_media_kit.h +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************/ -/* audio_driver_media_kit.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "servers/audio_server.h" - -#ifdef MEDIA_KIT_ENABLED - -#include "core/os/mutex.h" -#include "core/os/thread.h" - -#include <kernel/image.h> // needed for image_id - -#include <SoundPlayer.h> - -class AudioDriverMediaKit : public AudioDriver { - 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; - SpeakerMode speaker_mode; - 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 SpeakerMode get_speaker_mode() 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 deleted file mode 100644 index 3c4d43ff71..0000000000 --- a/platform/haiku/context_gl_haiku.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************/ -/* context_gl_haiku.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "context_gl_haiku.h" - -#if defined(OPENGL_ENABLED) - -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() { - 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(use_vsync); -} - -int ContextGL_Haiku::get_window_width() { - return window->Bounds().IntegerWidth(); -} - -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 diff --git a/platform/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h deleted file mode 100644 index c5d258915d..0000000000 --- a/platform/haiku/context_gl_haiku.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* context_gl_haiku.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef CONTEXT_GL_HAIKU_H -#define CONTEXT_GL_HAIKU_H - -#if defined(OPENGL_ENABLED) - -#include "haiku_direct_window.h" -#include "haiku_gl_view.h" - -class ContextGL_Haiku { -private: - HaikuGLView *view; - HaikuDirectWindow *window; - - bool use_vsync; - -public: - Error initialize(); - void release_current(); - void make_current(); - void swap_buffers(); - int get_window_width(); - int get_window_height(); - - void set_use_vsync(bool p_use); - bool is_using_vsync() const; - - ContextGL_Haiku(HaikuDirectWindow *p_window); - ~ContextGL_Haiku(); -}; - -#endif -#endif diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py deleted file mode 100644 index 0b84df8f9b..0000000000 --- a/platform/haiku/detect.py +++ /dev/null @@ -1,158 +0,0 @@ -import os -import sys - - -def is_active(): - return True - - -def get_name(): - return "Haiku" - - -def can_build(): - - if os.name != "posix" or sys.platform == "darwin": - return False - - return True - - -def get_opts(): - from SCons.Variables import EnumVariable - - return [ - EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")), - ] - - -def get_flags(): - - return [] - - -def configure(env): - - ## Build type - - if env["target"] == "release": - env.Prepend(CCFLAGS=["-O3"]) - if env["debug_symbols"] == "yes": - env.Prepend(CCFLAGS=["-g1"]) - if env["debug_symbols"] == "full": - env.Prepend(CCFLAGS=["-g2"]) - - elif env["target"] == "release_debug": - env.Prepend(CCFLAGS=["-O2", "-DDEBUG_ENABLED"]) - if env["debug_symbols"] == "yes": - env.Prepend(CCFLAGS=["-g1"]) - if env["debug_symbols"] == "full": - env.Prepend(CCFLAGS=["-g2"]) - - elif env["target"] == "debug": - env.Prepend(CCFLAGS=["-g3", "-DDEBUG_ENABLED", "-DDEBUG_MEMORY_ENABLED"]) - - ## Architecture - - is64 = sys.maxsize > 2 ** 32 - if env["bits"] == "default": - env["bits"] = "64" if is64 else "32" - - ## Compiler configuration - - env["CC"] = "gcc-x86" - env["CXX"] = "g++-x86" - - ## Dependencies - - if not env["builtin_libwebp"]: - env.ParseConfig("pkg-config libwebp --cflags --libs") - - # freetype depends on libpng and zlib, so bundling one of them while keeping others - # as shared libraries leads to weird issues - if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]: - env["builtin_freetype"] = True - env["builtin_libpng"] = True - env["builtin_zlib"] = True - - if not env["builtin_freetype"]: - env.ParseConfig("pkg-config freetype2 --cflags --libs") - - if not env["builtin_libpng"]: - env.ParseConfig("pkg-config libpng16 --cflags --libs") - - if not env["builtin_bullet"]: - # We need at least version 2.88 - import subprocess - - bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip() - if bullet_version < "2.88": - # Abort as system bullet was requested but too old - print( - "Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format( - bullet_version, "2.88" - ) - ) - sys.exit(255) - env.ParseConfig("pkg-config bullet --cflags --libs") - - if not env["builtin_enet"]: - env.ParseConfig("pkg-config libenet --cflags --libs") - - if not env["builtin_squish"]: - env.ParseConfig("pkg-config libsquish --cflags --libs") - - if not env["builtin_zstd"]: - env.ParseConfig("pkg-config libzstd --cflags --libs") - - # Sound and video libraries - # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - - if not env["builtin_libtheora"]: - env["builtin_libogg"] = False # Needed to link against system libtheora - env["builtin_libvorbis"] = False # Needed to link against system libtheora - env.ParseConfig("pkg-config theora theoradec --cflags --libs") - - if not env["builtin_libvpx"]: - env.ParseConfig("pkg-config vpx --cflags --libs") - - if not env["builtin_libvorbis"]: - env["builtin_libogg"] = False # Needed to link against system libvorbis - env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs") - - if not env["builtin_opus"]: - env["builtin_libogg"] = False # Needed to link against system opus - env.ParseConfig("pkg-config opus opusfile --cflags --libs") - - if not env["builtin_libogg"]: - env.ParseConfig("pkg-config ogg --cflags --libs") - - if env["builtin_libtheora"]: - list_of_x86 = ["x86_64", "x86", "i386", "i586"] - if any(platform.machine() in s for s in list_of_x86): - env["x86_libtheora_opt_gcc"] = True - - if not env["builtin_wslay"]: - env.ParseConfig("pkg-config libwslay --cflags --libs") - - if not env["builtin_mbedtls"]: - # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228 - env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) - - if not env["builtin_miniupnpc"]: - # No pkgconfig file so far, hardcode default paths. - env.Prepend(CPPPATH=["/system/develop/headers/x86/miniupnpc"]) - env.Append(LIBS=["miniupnpc"]) - - # On Linux wchar_t should be 32-bits - # 16-bit library shouldn't be required due to compiler optimisations - if not env["builtin_pcre2"]: - env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") - - ## Flags - - env.Prepend(CPPPATH=["#platform/haiku"]) - env.Append(CPPDEFINES=["UNIX_ENABLED", "OPENGL_ENABLED", "GLES_ENABLED"]) - env.Append(CPPDEFINES=["MEDIA_KIT_ENABLED"]) - env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"]) # TODO: enable when we have pthread_setname_np - env.Append(LIBS=["be", "game", "media", "network", "bnetapi", "z", "GL"]) diff --git a/platform/haiku/godot.rdef b/platform/haiku/godot.rdef deleted file mode 100644 index a55cddbf0d..0000000000 --- a/platform/haiku/godot.rdef +++ /dev/null @@ -1,60 +0,0 @@ -resource app_version { - major = 2, - middle = 0, - minor = 0, - - variety = B_APPV_FINAL, - internal = 0, - - short_info = "Godot Game Engine", - long_info = "An advanced, feature packed, multi-platform 2D and 3D game engine." -}; - -resource app_signature "application/x-vnd.godot"; - -resource vector_icon { - $"6E6369660403A39F9F05FF03478CBF03414042090A04B37FB379CC26B379CC26" - $"CC20B37FCC200A09B5E9C41B2AC240B8E1BDFBBFA1BDA4C6A7BDFFCA1AC45CC9" - $"7AC607C01CC75BB6F4C65A062AFE9FFF9F69FE7FFEDFCF0FC95FC3D7C95FC51E" - $"C95FC51EC95FC53EC92BC565C94AC55BC92BC565C728C60BC728C60BC712C612" - $"C6E6C600C6F9C60EC6D3C5F2C6C7C5C4C6C7C5DCC6C7C5C4C460C4E5C4BCC4E5" - $"C626C4E5C626C4E5C64BC4A5C670C4CAC66BC4A5C670C1EDC6CFC1EDC6CFC1E9" - $"C6CFC1E2C6D0C1E6C6D0C1D1C6D0C1B2C6BEC1BFC6C9C1A2C6AFC19851C198C6" - $"9BC19851C505C031C507C507C016C507BFFCC507C507BE94C505BE9451BE9451" - $"BE94C69BBE7BC6BEBE8BC6AFBE6DC6C9BE4AC6D0BE5CC6D0BE47C6D0BE40C6CF" - $"BE44C6CFBE40C6CFBB87C670BB87C670BB63C66BBB47C626BB47C64BBB47C626" - $"C4BCB965C460B965C5C4B965C5C4B965C5DCB947C600B95AC5F2B934C60EB904" - $"C60BB91BC612B904C60BB701C565B701C565B6E3C55BB6CEC51EB6CEC53EB6CE" - $"C51EC3D7B590C36CB590C36CB581C3B0B578C43AB578C3F5B578C78FBFF8CA27" - $"BA2ACA22BFF8CA27BFFABFFCCA27BFFCCA27C5CACA22CA7CC43ACA7CC78FCA7C" - $"C3FBCA67C37ECA754ACA67C37E0639F6F97FFEF8E7FFF9F6FFFFFFFFFF03B67D" - $"BDEEC31FB730C35CB730C35CB74EC3662BC3A22BC3822BC3A2C4E8B8D1C55EB8" - $"D1C406B8D1C406B8D1C3F0B8ECC3CDB8DBC3DBB8FDC3BFB929C3BDB913C3B9B9" - $"29C3BDBB9FC436BB9FC436BBC2C43CBBDCC47EBBDCC45BBBDCC47EC5E6BE00C6" - $"31BE00C4BBBE00C4BBBE00C4A7BE16C486BE08C494BE24C479BE4AC471BE37C4" - $"71BE4AC471BE4BC016C473C1E2C471C1E2C471C1F6C471C217C486C209C479C2" - $"25C494C22DC4BBC22DC4A7C22DC4BBC631C451C5E6C451C47EC451C47EC451C4" - $"5BC48DC436C46AC43CC48DC436C704C3BDC704C3BDC719C3B9C741C3CDC730C3" - $"BF53C3DBC75CC406C75CC3F0C75CC406C55EC8CAC4E8C8CAC3A2C8CAC3A2C8CA" - $"C382C8FDC35CC8DFC366C8FDC35CC977C333BDEEC97ABDEEC97ABDEEC9F1BD56" - $"CAC9BC0BCA60BCB6CA3DBB1CC8D9B981C991BA47C82FB9D7C6EDBAA0C789BA38" - $"C69FBA52C5F0B9D0C647BA12C59BB98BC4E0B91FC53BB959C4FBB855C50EB6C0" - $"C509B78FC424B64AC22DB5C4C32AB5FCC1C8B66DC11BB7D9C16BB725C0BCB7C9" - $"BFFCB7C2C05CB7C3BFFCB7C2BFFCB7C2BFFCB7C2BFFBB7C2BFFAB7C2BFFAB7C2" - $"BFF9B7C2BFF8B7C2BFF9B7C2BFF8B7C2BFF8B7C2BFF8B7C2BF98B7C3BED9B7D9" - $"BF38B7C9BE88B725BDC7B5C4BE2CB66DBCCAB5FCBAE6B6C0BBD0B64ABAEBB78F" - $"BB13B91F34B855BAB8B959BA04B9D0BA59B98BB9ADBA12B907BAA0B955BA52B8" - $"6ABA38B71AB981B7C5B9D7B663BA47B52BBC0BB5B7BB1CB594BCB6B679BDEEB6" - $"02BD56B679BDEE0005BD3EC06CBD3EC06CBD3EC197BB2147BC4C47B9F647B904" - $"C06CB904C197B904BF41BB21BE4FB9F6BE4FBC4CBE4FBD3EC06CBD3EBF41BD3E" - $"C06C0005BCBC42BCBC42BCBCC153BB55C1F3BC1BC1F3BA8EC1F3B9ED42B9EDC1" - $"53B9EDBFC6BB55BF25BA8EBF25BC1BBF25BCBC42BCBCBFC6BCBC420007C01BC2" - $"BBC01BC2BBBFBAC2BBBF6CC21CBF6CC274BF6CC21CBF6CC02ABF6CC02ABF6CBF" - $"D3C01BBF8CBFBABF8CC07BBF8CC0C9C02AC0C9BFD3C0C9C02AC0C9C21CC0C9C2" - $"1CC0C9C274C01BC2BBC07BC2BBC01BC2BB0005C2F7C06CC2F7C06CC2F7C197C5" - $"1547C3E947C64047C732C06CC732C197C732BF41C515BE4FC640BE4FC3E9BE4F" - $"C2F7C06CC2F7BF41C2F7C06C0005C37942C37942C379C153C4E1C1F3C41AC1F3" - $"C5A7C1F3C64842C648C153C648BFC6C4E1BF25C5A7BF25C41ABF25C37942C379" - $"BFC6C37942090A0000000A010101000A020102000A020103000A010104000A03" - $"0105000A010106000A010107000A03010800" -}; diff --git a/platform/haiku/godot_haiku.cpp b/platform/haiku/godot_haiku.cpp deleted file mode 100644 index 0657f4c052..0000000000 --- a/platform/haiku/godot_haiku.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************/ -/* godot_haiku.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "main/main.h" -#include "os_haiku.h" - -int main(int argc, char *argv[]) { - 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 deleted file mode 100644 index 82d9c093e1..0000000000 --- a/platform/haiku/haiku_application.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************/ -/* haiku_application.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "haiku_application.h" - -HaikuApplication::HaikuApplication() : - BApplication("application/x-vnd.godot") { -} diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h deleted file mode 100644 index 2e04d921bf..0000000000 --- a/platform/haiku/haiku_application.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************/ -/* haiku_application.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef HAIKU_APPLICATION_H -#define HAIKU_APPLICATION_H - -#include <kernel/image.h> // needed for image_id - -#include <Application.h> - -class HaikuApplication : public BApplication { -public: - HaikuApplication(); -}; - -#endif diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp deleted file mode 100644 index 0a40f847f4..0000000000 --- a/platform/haiku/haiku_direct_window.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/*************************************************************************/ -/* haiku_direct_window.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include <UnicodeChar.h> - -#include "core/os/keyboard.h" -#include "haiku_direct_window.h" -#include "key_mapping_haiku.h" -#include "main/main.h" - -HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) : - BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) { - last_mouse_pos_valid = false; - last_buttons_state = 0; - last_button_mask = 0; - last_key_modifier_state = 0; - - view = nullptr; - update_runner = nullptr; - input = nullptr; - main_loop = nullptr; -} - -HaikuDirectWindow::~HaikuDirectWindow() { -} - -void HaikuDirectWindow::SetHaikuGLView(HaikuGLView *p_view) { - view = p_view; -} - -void HaikuDirectWindow::StartMessageRunner() { - update_runner = new BMessageRunner(BMessenger(this), - new BMessage(REDRAW_MSG), 1000000 / 60 /* 60 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() { - StopMessageRunner(); - main_loop->notification(NOTIFICATION_WM_CLOSE_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()) { - 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; - } - */ - - Ref<InputEventMouseButton> mouse_event; - mouse_event.instance(); - - mouse_event->set_button_mask(GetMouseButtonState(buttons)); - mouse_event->set_position({ where.x, where.y }); - mouse_event->set_global_position({ where.x, where.y }); - GetKeyModifierState(mouse_event, modifiers); - - switch (button) { - default: - case B_PRIMARY_MOUSE_BUTTON: - mouse_event->set_button_index(1); - break; - - case B_SECONDARY_MOUSE_BUTTON: - mouse_event->set_button_index(2); - break; - - case B_TERTIARY_MOUSE_BUTTON: - mouse_event->set_button_index(3); - break; - } - - mouse_event->set_pressed(message->what == B_MOUSE_DOWN); - - if (message->what == B_MOUSE_DOWN && mouse_event->get_button_index() == 1) { - int32 clicks = message->FindInt32("clicks"); - - if (clicks > 1) { - mouse_event->set_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; - - Ref<InputEventMouseMotion> motion_event; - motion_event.instance(); - GetKeyModifierState(motion_event, modifiers); - - motion_event->set_button_mask(GetMouseButtonState(buttons)); - motion_event->set_position({ pos.x, pos.y }); - input->set_mouse_position(pos); - motion_event->set_global_position({ pos.x, pos.y }); - motion_event->set_speed({ input->get_last_mouse_speed().x, - input->get_last_mouse_speed().y }); - - motion_event->set_relative({ rel.x, 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; - } - - Ref<InputEventMouseButton> mouse_event; - mouse_event.instance(); - //GetKeyModifierState(mouse_event, modifiers); - - mouse_event->set_button_index(wheel_delta_y < 0 ? 4 : 5); - mouse_event->set_button_mask(last_button_mask); - mouse_event->set_position({ last_mouse_position.x, - last_mouse_position.y }); - mouse_event->set_global_position({ last_mouse_position.x, - last_mouse_position.y }); - - mouse_event->set_pressed(true); - input->parse_input_event(mouse_event); - - mouse_event->set_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; - } - - Ref<InputEventKey> event; - event.instance(); - GetKeyModifierState(event, modifiers); - event->set_pressed(message->what == B_KEY_DOWN); - event->set_keycode(KeyMappingHaiku::get_keysym(raw_char, key)); - event->set_physical_keycode(KeyMappingHaiku::get_keysym(raw_char, key)); - event->set_echo(message->HasInt32("be:key_repeat")); - event->set_unicode(0); - - const char *bytes = nullptr; - if (message->FindString("bytes", &bytes) == B_OK) { - event->set_unicode(BUnicodeChar::FromUTF8(&bytes)); - } - - //make it consistent across platforms. - if (event->get_keycode() == KEY_BACKTAB) { - event->set_keycode(KEY_TAB); - event->set_physical_keycode(KEY_TAB); - event->set_shift(true); - } - - input->parse_input_event(event); -} - -void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage *message) { - 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; - - Ref<InputEventWithModifiers> event; - event.instance(); - GetKeyModifierState(event, modifiers); - - event->set_shift(key & B_SHIFT_KEY); - event->set_alt(key & B_OPTION_KEY); - event->set_control(key & B_CONTROL_KEY); - event->set_command(key & B_COMMAND_KEY); - - input->parse_input_event(event); -} - -void HaikuDirectWindow::HandleWindowResized(BMessage *message) { - 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 void HaikuDirectWindow::GetKeyModifierState(Ref<InputEventWithModifiers> event, uint32 p_state) { - last_key_modifier_state = p_state; - - event->set_shift(p_state & B_SHIFT_KEY); - event->set_control(p_state & B_CONTROL_KEY); - event->set_alt(p_state & B_OPTION_KEY); - event->set_metakey(p_state & B_COMMAND_KEY); - - return state; -} - -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 deleted file mode 100644 index 4817abbb7a..0000000000 --- a/platform/haiku/haiku_direct_window.h +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************/ -/* haiku_direct_window.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef HAIKU_DIRECT_WINDOW_H -#define HAIKU_DIRECT_WINDOW_H - -#include <kernel/image.h> // needed for image_id - -#include <DirectWindow.h> - -#include "core/input/input.h" -#include "core/os/os.h" - -#include "haiku_gl_view.h" - -#define REDRAW_MSG 'rdrw' -#define LOCKGL_MSG 'glck' -#define UNLOCKGL_MSG 'ulck' - -class HaikuDirectWindow : public BDirectWindow { -private: - 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 void GetKeyModifierState(Ref<InputEventWithModifiers> event, uint32 p_state); - inline int GetMouseButtonState(uint32 p_state); - -public: - HaikuDirectWindow(BRect p_frame); - ~HaikuDirectWindow(); - - void SetHaikuGLView(HaikuGLView *p_view); - void 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 deleted file mode 100644 index 970a1276fd..0000000000 --- a/platform/haiku/haiku_gl_view.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************/ -/* haiku_gl_view.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#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) { - 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 deleted file mode 100644 index 59e02d2367..0000000000 --- a/platform/haiku/haiku_gl_view.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************/ -/* haiku_gl_view.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef HAIKU_GL_VIEW_H -#define HAIKU_GL_VIEW_H - -#include <kernel/image.h> // needed for image_id - -#include <GLView.h> - -class HaikuGLView : public BGLView { -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 deleted file mode 100644 index 692a1e5a78..0000000000 --- a/platform/haiku/key_mapping_haiku.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/*************************************************************************/ -/* key_mapping_haiku.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include <InterfaceDefs.h> - -#include "core/os/keyboard.h" -#include "key_mapping_haiku.h" - -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_ENTER, 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_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++) { - 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 deleted file mode 100644 index e735108e44..0000000000 --- a/platform/haiku/key_mapping_haiku.h +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************/ -/* key_mapping_haiku.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef KEY_MAPPING_HAIKU_H -#define KEY_MAPPING_HAIKU_H - -class KeyMappingHaiku { - KeyMappingHaiku() {} - -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 Binary files differdeleted file mode 100644 index a2d8e242a6..0000000000 --- a/platform/haiku/logo.png +++ /dev/null diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp deleted file mode 100644 index 7a2591784f..0000000000 --- a/platform/haiku/os_haiku.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/*************************************************************************/ -/* os_haiku.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "os_haiku.h" - -#include "drivers/gles2/rasterizer_gles2.h" -#include "main/main.h" -#include "servers/physics_3d/physics_server_3d_sw.h" -#include "servers/rendering/rendering_server_raster.h" -#include "servers/rendering/rendering_server_wrap_mt.h" - -#include <Screen.h> - -OS_Haiku::OS_Haiku() { -#ifdef MEDIA_KIT_ENABLED - AudioDriverManager::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() const { - 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"; -} - -int OS_Haiku::get_current_video_driver() const { - return video_driver_index; -} - -Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { - main_loop = nullptr; - current_video_mode = p_desired; - - app = new HaikuApplication(); - - BRect frame; - frame.Set(50, 50, 50 + current_video_mode.width - 1, 50 + current_video_mode.height - 1); - - window = new HaikuDirectWindow(frame); - window->SetVideoMode(¤t_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) - context_gl = memnew(ContextGL_Haiku(window)); - context_gl->initialize(); - context_gl->make_current(); - context_gl->set_use_vsync(current_video_mode.use_vsync); - // FIXME: That's not how the rasterizer setup should happen. - RasterizerGLES2::register_config(); - RasterizerGLES2::make_current(); -#endif - - rendering_server = memnew(RenderingServerRaster); - // FIXME: Reimplement threaded rendering - if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - rendering_server = memnew(RenderingServerWrapMT(rendering_server, false)); - } - - ERR_FAIL_COND_V(!rendering_server, ERR_UNAVAILABLE); - - video_driver_index = p_video_driver; - - input = memnew(InputDefault); - window->SetInput(input); - - window->Show(); - rendering_server->init(); - - AudioDriverManager::initialize(p_audio_driver); - - return OK; -} - -void OS_Haiku::finalize() { - if (main_loop) { - memdelete(main_loop); - } - - main_loop = nullptr; - - rendering_server->finish(); - memdelete(rendering_server); - - memdelete(input); - -#if defined(OPENGL_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 = nullptr; - window->SetMainLoop(nullptr); -} - -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_position() 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"); -} - -OS::CursorShape OS_Haiku::get_cursor_shape() const { - // TODO: implement get_cursor_shape -} - -void OS_Haiku::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { - // TODO -} - -int OS_Haiku::get_screen_count() const { - // TODO: implement get_screen_count() - return 1; -} - -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; - rendering_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(); -} - -bool OS_Haiku::_check_internal_feature_support(const String &p_feature) { - return p_feature == "pc"; -} - -String OS_Haiku::get_config_path() const { - if (has_environment("XDG_CONFIG_HOME")) { - return get_environment("XDG_CONFIG_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file("config/settings"); - } else { - return "."; - } -} - -String OS_Haiku::get_data_path() const { - if (has_environment("XDG_DATA_HOME")) { - return get_environment("XDG_DATA_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file("config/data"); - } else { - return get_config_path(); - } -} - -String OS_Haiku::get_cache_path() const { - if (has_environment("XDG_CACHE_HOME")) { - return get_environment("XDG_CACHE_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file("config/cache"); - } else { - return get_config_path(); - } -} diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h deleted file mode 100644 index d3ef9400d4..0000000000 --- a/platform/haiku/os_haiku.h +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************/ -/* os_haiku.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef OS_HAIKU_H -#define OS_HAIKU_H - -#include "audio_driver_media_kit.h" -#include "context_gl_haiku.h" -#include "core/input/input.h" -#include "drivers/unix/os_unix.h" -#include "haiku_application.h" -#include "haiku_direct_window.h" -#include "servers/audio_server.h" -#include "servers/rendering_server.h" - -class OS_Haiku : public OS_Unix { -private: - HaikuApplication *app; - HaikuDirectWindow *window; - MainLoop *main_loop; - InputDefault *input; - RenderingServer *rendering_server; - VideoMode current_video_mode; - int video_driver_index; - -#ifdef MEDIA_KIT_ENABLED - AudioDriverMediaKit driver_media_kit; -#endif - -#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 int get_current_video_driver() const; - - 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); - -public: - OS_Haiku(); - void run(); - - virtual String get_name() 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_position() const; - virtual int get_mouse_button_state() const; - virtual void set_cursor_shape(CursorShape p_shape); - virtual CursorShape get_cursor_shape() const; - virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); - - virtual int get_screen_count() const; - virtual int get_current_screen() const; - virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = -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_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; - - 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 diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h deleted file mode 100644 index f2d5418adf..0000000000 --- a/platform/haiku/platform_config.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************/ -/* platform_config.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include <alloca.h> - -// for ifaddrs.h needed in drivers/unix/ip_unix.cpp -#define _BSD_SOURCE 1 - -#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h" diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub index a48629f720..b72d29149c 100644 --- a/platform/iphone/SCsub +++ b/platform/iphone/SCsub @@ -20,6 +20,9 @@ iphone_lib = [ env_ios = env.Clone() ios_lib = env_ios.add_library("iphone", iphone_lib) +# (iOS) Enable module support +env_ios.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) + def combine_libs(target=None, source=None, env=None): lib_path = target[0].srcnode().abspath diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 63c3cb8c23..194e71c9de 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -217,7 +217,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0")); @@ -293,8 +293,8 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_ strnew += lines[i].replace("$name", p_config.pkg_name) + "\n"; } else if (lines[i].find("$info") != -1) { strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n"; - } else if (lines[i].find("$identifier") != -1) { - strnew += lines[i].replace("$identifier", p_preset->get("application/identifier")) + "\n"; + } else if (lines[i].find("$bundle_identifier") != -1) { + strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n"; } else if (lines[i].find("$short_version") != -1) { strnew += lines[i].replace("$short_version", p_preset->get("application/short_version")) + "\n"; } else if (lines[i].find("$version") != -1) { @@ -343,6 +343,9 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_ } else if (lines[i].find("$push_notifications") != -1) { bool is_on = p_preset->get("capabilities/push_notifications"); strnew += lines[i].replace("$push_notifications", is_on ? "1" : "0") + "\n"; + } else if (lines[i].find("$entitlements_push_notifications") != -1) { + bool is_on = p_preset->get("capabilities/push_notifications"); + strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "<key>aps-environment</key><string>development</string>" : "") + "\n"; } else if (lines[i].find("$required_device_capabilities") != -1) { String capabilities; @@ -1066,6 +1069,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p files_to_parse.insert("godot_ios/dummy.cpp"); files_to_parse.insert("godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata"); files_to_parse.insert("godot_ios.xcodeproj/xcshareddata/xcschemes/godot_ios.xcscheme"); + files_to_parse.insert("godot_ios/godot_ios.entitlements"); IOSConfigData config_data = { pkg_name, @@ -1346,7 +1350,7 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset valid = false; } - String identifier = p_preset->get("application/identifier"); + String identifier = p_preset->get("application/bundle_identifier"); String pn_err; if (!is_package_name_valid(identifier, &pn_err)) { err += TTR("Invalid Identifier:") + " " + pn_err + "\n"; diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index a2efd6691b..548dcc549d 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -207,7 +207,7 @@ Error InAppStore::restore_purchases() { NSString *receipt_to_send = nil; if (receipt != nil) { - receipt_to_send = [receipt description]; + receipt_to_send = [receipt base64EncodedStringWithOptions:0]; } Dictionary receipt_ret; receipt_ret["receipt"] = String::utf8(receipt_to_send != nil ? [receipt_to_send UTF8String] : ""); diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 4a94e09c1c..920fd24c4a 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -1937,10 +1937,14 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { // Apple Docs state that the display parameter is not used. // "This parameter is not used. By default, you may pass kCGDirectMainDisplay." // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html - CGDisplayHideCursor(kCGDirectMainDisplay); + if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { + CGDisplayHideCursor(kCGDirectMainDisplay); + } CGAssociateMouseAndMouseCursorPosition(false); } else if (p_mode == MOUSE_MODE_HIDDEN) { - CGDisplayHideCursor(kCGDirectMainDisplay); + if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { + CGDisplayHideCursor(kCGDirectMainDisplay); + } CGAssociateMouseAndMouseCursorPosition(true); } else { CGDisplayShowCursor(kCGDirectMainDisplay); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index c9b01ebbb4..9af7c02351 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -145,7 +145,7 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.png,*.icns"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0")); @@ -354,8 +354,8 @@ void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset strnew += lines[i].replace("$name", p_binary) + "\n"; } else if (lines[i].find("$info") != -1) { strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n"; - } else if (lines[i].find("$identifier") != -1) { - strnew += lines[i].replace("$identifier", p_preset->get("application/identifier")) + "\n"; + } else if (lines[i].find("$bundle_identifier") != -1) { + strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n"; } else if (lines[i].find("$short_version") != -1) { strnew += lines[i].replace("$short_version", p_preset->get("application/short_version")) + "\n"; } else if (lines[i].find("$version") != -1) { @@ -399,7 +399,7 @@ Error EditorExportPlatformOSX::_notarize(const Ref<EditorExportPreset> &p_preset args.push_back("--notarize-app"); args.push_back("--primary-bundle-id"); - args.push_back(p_preset->get("application/identifier")); + args.push_back(p_preset->get("application/bundle_identifier")); args.push_back("--username"); args.push_back(p_preset->get("notarization/apple_id_name")); @@ -829,7 +829,10 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String zipfi.tmz_date.tm_sec = time.sec; zipfi.tmz_date.tm_year = date.year; zipfi.dosDate = 0; - zipfi.external_fa = (is_executable ? 0755 : 0644) << 16L; + // 0100000: regular file type + // 0000755: permissions rwxr-xr-x + // 0000644: permissions rw-r--r-- + zipfi.external_fa = (is_executable ? 0100755 : 0100644) << 16L; zipfi.internal_fa = 0; zipOpenNewFileInZip4(p_zip, @@ -885,7 +888,7 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset valid = dvalid || rvalid; r_missing_templates = !valid; - String identifier = p_preset->get("application/identifier"); + String identifier = p_preset->get("application/bundle_identifier"); String pn_err; if (!is_package_name_valid(identifier, &pn_err)) { err += TTR("Invalid bundle identifier:") + " " + pn_err + "\n"; diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index cb4716bd65..0fd017f96e 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -970,7 +970,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { public: virtual String get_name() const { - return "Windows Universal"; + return "UWP"; } virtual String get_os_name() const { return "UWP"; @@ -1180,7 +1180,7 @@ public: virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) { String src_appx; - EditorProgress ep("export", "Exporting for Windows Universal", 7, true); + EditorProgress ep("export", "Exporting for UWP", 7, true); if (p_debug) { src_appx = p_preset->get("custom_template/debug"); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 0b7130db74..f47afcc4e5 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -103,7 +103,11 @@ void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { } if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) { - hCursor = SetCursor(nullptr); + if (hCursor == nullptr) { + hCursor = SetCursor(nullptr); + } else { + SetCursor(nullptr); + } } else { CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; @@ -117,9 +121,9 @@ void DisplayServerWindows::mouse_set_mode(MouseMode p_mode) { if (mouse_mode == p_mode) return; - _set_mouse_mode_impl(p_mode); - mouse_mode = p_mode; + + _set_mouse_mode_impl(p_mode); } DisplayServer::MouseMode DisplayServerWindows::mouse_get_mode() const { @@ -2565,9 +2569,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case WM_KEYUP: case WM_KEYDOWN: { if (wParam == VK_SHIFT) - shift_mem = uMsg == WM_KEYDOWN; + shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); if (wParam == VK_CONTROL) - control_mem = uMsg == WM_KEYDOWN; + control_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); if (wParam == VK_MENU) { alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); if (lParam & (1 << 24)) @@ -2654,10 +2658,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (LOWORD(lParam) == HTCLIENT) { if (windows[window_id].window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) { //Hide the cursor - if (hCursor == nullptr) + if (hCursor == nullptr) { hCursor = SetCursor(nullptr); - else + } else { SetCursor(nullptr); + } } else { if (hCursor != nullptr) { CursorShape c = cursor_shape; diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 271a4e41bc..65caee3035 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -172,6 +172,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { sprintf_s(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", type, 0, vendor, 0, product, 0, version, 0); id_to_change = joypad_count; + slider_count = 0; joy->di_joy->SetDataFormat(&c_dfDIJoystick2); joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND); @@ -206,9 +207,14 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ ofs = DIJOFS_RY; else if (ob->guidType == GUID_RzAxis) ofs = DIJOFS_RZ; - else if (ob->guidType == GUID_Slider) - ofs = DIJOFS_SLIDER(0); - else + else if (ob->guidType == GUID_Slider) { + if (slider_count < 2) { + ofs = DIJOFS_SLIDER(slider_count); + slider_count++; + } else { + return; + } + } else return; prop_range.diph.dwSize = sizeof(DIPROPRANGE); prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); @@ -388,9 +394,9 @@ void JoypadWindows::process_joypads() { } // on mingw, these constants are not constants - int count = 6; - unsigned int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ }; - int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz }; + int count = 8; + unsigned int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ, DIJOFS_SLIDER(0), DIJOFS_SLIDER(1) }; + int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz, js.rglSlider[0], js.rglSlider[1] }; for (int j = 0; j < joy->joy_axis.size(); j++) { for (int k = 0; k < count; k++) { diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h index 6c06b3f6f0..c961abf0a5 100644 --- a/platform/windows/joypad_windows.h +++ b/platform/windows/joypad_windows.h @@ -118,6 +118,7 @@ private: Input *input; int id_to_change; + int slider_count; int joypad_count; bool attached_joypads[JOYPADS_MAX]; dinput_gamepad d_joypads[JOYPADS_MAX]; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 29eabfdde8..5b15896b0c 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -208,6 +208,13 @@ void OS_Windows::initialize() { process_map = memnew((Map<ProcessID, ProcessInfo>)); + // Add current Godot PID to the list of known PIDs + ProcessInfo current_pi = {}; + PROCESS_INFORMATION current_pi_pi = {}; + current_pi.pi = current_pi_pi; + current_pi.pi.hProcess = GetCurrentProcess(); + process_map->insert(GetCurrentProcessId(), current_pi); + IP_Unix::make_default(); main_loop = nullptr; } @@ -343,55 +350,21 @@ OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { return ret; } -uint64_t OS_Windows::get_unix_time() const { - FILETIME ft; - SYSTEMTIME st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, &ft); - - SYSTEMTIME ep; - ep.wYear = 1970; - ep.wMonth = 1; - ep.wDayOfWeek = 4; - ep.wDay = 1; - ep.wHour = 0; - ep.wMinute = 0; - ep.wSecond = 0; - ep.wMilliseconds = 0; - FILETIME fep; - SystemTimeToFileTime(&ep, &fep); - - // Type punning through unions (rather than pointer cast) as per: - // https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime#remarks - ULARGE_INTEGER ft_punning; - ft_punning.LowPart = ft.dwLowDateTime; - ft_punning.HighPart = ft.dwHighDateTime; - - ULARGE_INTEGER fep_punning; - fep_punning.LowPart = fep.dwLowDateTime; - fep_punning.HighPart = fep.dwHighDateTime; - - return (ft_punning.QuadPart - fep_punning.QuadPart) / 10000000; -}; - -uint64_t OS_Windows::get_system_time_secs() const { - return get_system_time_msecs() / 1000; -} - -uint64_t OS_Windows::get_system_time_msecs() const { - const uint64_t WINDOWS_TICK = 10000; - const uint64_t MSEC_TO_UNIX_EPOCH = 11644473600000LL; +double OS_Windows::get_unix_time() const { + // 1 Windows tick is 100ns + const uint64_t WINDOWS_TICKS_PER_SECOND = 10000000; + const uint64_t TICKS_TO_UNIX_EPOCH = 116444736000000000LL; SYSTEMTIME st; GetSystemTime(&st); FILETIME ft; SystemTimeToFileTime(&st, &ft); - uint64_t ret; - ret = ft.dwHighDateTime; - ret <<= 32; - ret |= ft.dwLowDateTime; + uint64_t ticks_time; + ticks_time = ft.dwHighDateTime; + ticks_time <<= 32; + ticks_time |= ft.dwLowDateTime; - return (uint64_t)(ret / WINDOWS_TICK - MSEC_TO_UNIX_EPOCH); + return (double)(ticks_time - TICKS_TO_UNIX_EPOCH) / WINDOWS_TICKS_PER_SECOND; } void OS_Windows::delay_usec(uint32_t p_usec) const { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 11e3533bfd..910a83539a 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -129,9 +129,7 @@ public: virtual Date get_date(bool utc) const; virtual Time get_time(bool utc) const; virtual TimeZoneInfo get_time_zone_info() const; - virtual uint64_t get_unix_time() const; - virtual uint64_t get_system_time_secs() const; - virtual uint64_t get_system_time_msecs() const; + virtual double get_unix_time() const; virtual Error set_cwd(const String &p_cwd); |