From d2f4b5839e76dc1dc26faca879f22f643a8d6c0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sun, 18 Jun 2017 10:23:41 +0200
Subject: Config file location


diff --git a/configure.ac b/configure.ac
index a723222..01a2382 100644
--- a/configure.ac
+++ b/configure.ac
@@ -516,6 +516,10 @@ case "$host" in
        AC_DEFINE(LINUX, 1, [Compiling on GNU/Linux])
        AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).])
        ;;
+    *-*-haiku*)
+       AC_DEFINE(HAIKU, 1, [Compiling on Haiku])
+       AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).])
+       ;;
     *-*-freebsd* | *-*-dragonfly* | *-*-netbsd* | *-*-openbsd*)
        dnl Disabled directserial for now. It doesn't do anything without
        dnl specifying an extra ifdef in directserial_posix.*
diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp
index a7710dd..f72a74d 100644
--- a/src/gui/sdlmain.cpp
+++ b/src/gui/sdlmain.cpp
@@ -113,6 +113,8 @@ struct private_hwdata {
 #define DEFAULT_CONFIG_FILE "/dosbox.conf"
 #elif defined(MACOSX)
 #define DEFAULT_CONFIG_FILE "/Library/Preferences/DOSBox Preferences"
+#elif defined(HAIKU)
+#define DEFAULT_CONFIG_FILE "~/config/settings/dosbox/dosbox.conf"
 #else /*linux freebsd*/
 #define DEFAULT_CONFIG_FILE "/.dosboxrc"
 #endif
diff --git a/src/hardware/serialport/libserial.cpp b/src/hardware/serialport/libserial.cpp
index eb5be94..3eb6828 100644
--- a/src/hardware/serialport/libserial.cpp
+++ b/src/hardware/serialport/libserial.cpp
@@ -254,7 +254,7 @@ bool SERIAL_setCommParameters(COMPORT port,
 }
 #endif
 
-#if defined (LINUX) || defined (MACOSX) || defined (BSD)
+#if defined (LINUX) || defined (MACOSX) || defined (BSD) || defined (HAIKU)
 
 #include <string.h> // strlen
 #include <stdlib.h>
diff --git a/src/misc/cross.cpp b/src/misc/cross.cpp
index bc4557e..8f430de 100644
--- a/src/misc/cross.cpp
+++ b/src/misc/cross.cpp
@@ -62,6 +62,9 @@ void Cross::GetPlatformConfigDir(std::string& in) {
 #elif defined(MACOSX)
 	in = "~/Library/Preferences";
 	ResolveHomedir(in);
+#elif defined(HAIKU)
+	in = "~/config/settings/dosbox";
+	ResolveHomedir(in);
 #else
 	in = "~/.dosbox";
 	ResolveHomedir(in);
@@ -89,6 +92,10 @@ void Cross::CreatePlatformConfigDir(std::string& in) {
 	in = "~/Library/Preferences/";
 	ResolveHomedir(in);
 	//Don't create it. Assume it exists
+#elif defined(HAIKU)
+	in = "~/config/settings/dosbox";
+	ResolveHomedir(in);
+	mkdir(in.c_str(),0700);
 #else
 	in = "~/.dosbox";
 	ResolveHomedir(in);
-- 
2.19.1


From e599901a8a86279be532b91da79036ec9afb8ffc Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Wed, 21 Mar 2018 16:02:17 +0300
Subject: Disable usescancodes on Haiku

* DOSBox uses "raw" key codes from SDL, and doesn't handle the fact
that these keycodes are different from one platform to another.

diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp
index 5d32c4b..411751c 100644
--- a/src/gui/sdl_mapper.cpp
+++ b/src/gui/sdl_mapper.cpp
@@ -2400,6 +2400,8 @@ void MAPPER_StartUp(Section * sec) {
 		/* Note: table has to be tested/updated for various OSs */
 #if defined (MACOSX)
 		/* nothing */
+#elif defined(HAIKU)
+		usescancodes = false;
 #elif defined(OS2)
 		sdlkey_map[0x61]=SDLK_UP;
 		sdlkey_map[0x66]=SDLK_DOWN;
-- 
2.19.1

