diff options
author | 2016-03-27 14:06:51 +0200 | |
---|---|---|
committer | 2016-03-27 17:35:23 +0200 | |
commit | 158c90cf1196f219e6a7c9c3e23ca47129429a7b (patch) | |
tree | 4630c4834544108f1ec74b5b48fe4d437d3efbeb /src | |
parent | 5640305d0ecfdbf6a1a456688f48f6f0fe22adb3 (diff) |
Initial work to make MAME work on Android [Miodrag Milanovic]
Diffstat (limited to 'src')
-rw-r--r-- | src/osd/modules/file/posixfile.cpp | 14 | ||||
-rw-r--r-- | src/osd/modules/file/posixptty.cpp | 7 | ||||
-rw-r--r-- | src/osd/modules/font/font_sdl.cpp | 2 | ||||
-rw-r--r-- | src/osd/modules/render/drawbgfx.cpp | 6 | ||||
-rw-r--r-- | src/osd/sdl/sdldir.cpp | 2 | ||||
-rw-r--r-- | src/osd/sdl/sdlmain.cpp | 6 | ||||
-rw-r--r-- | src/osd/sdl/sdlos_unix.cpp | 8 | ||||
-rw-r--r-- | src/osd/sdl/sdlprefix.h | 4 |
8 files changed, 30 insertions, 19 deletions
diff --git a/src/osd/modules/file/posixfile.cpp b/src/osd/modules/file/posixfile.cpp index a5e3fe6a54e..513a3cbfd70 100644 --- a/src/osd/modules/file/posixfile.cpp +++ b/src/osd/modules/file/posixfile.cpp @@ -88,7 +88,7 @@ public: { ssize_t result; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) || defined(__ANDROID__) result = ::pread(m_fd, buffer, size_t(count), off_t(std::make_unsigned_t<off_t>(offset))); #elif defined(WIN32) || defined(SDLMAME_NO64BITIO) if (lseek(m_fd, off_t(std::make_unsigned_t<off_t>(offset)), SEEK_SET) < 0) @@ -109,7 +109,7 @@ public: { ssize_t result; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) || defined(__ANDROID__) result = ::pwrite(m_fd, buffer, size_t(count), off_t(std::make_unsigned_t<off_t>(offset))); #elif defined(WIN32) || defined(SDLMAME_NO64BITIO) if (lseek(m_fd, off_t(std::make_unsigned_t<off_t>(offset)), SEEK_SET) < 0) @@ -130,7 +130,7 @@ public: { int result; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) || defined(WIN32) || defined(SDLMAME_NO64BITIO) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(EMSCRIPTEN) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) result = ::ftruncate(m_fd, off_t(std::make_unsigned_t<off_t>(offset))); #else result = ::ftruncate64(m_fd, off64_t(offset)); @@ -236,7 +236,7 @@ osd_file::error osd_file::open(std::string const &path, std::uint32_t openflags, // attempt to open the file int fd = -1; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) fd = ::open(dst.c_str(), access, 0666); #else fd = ::open64(dst.c_str(), access, 0666); @@ -256,7 +256,7 @@ osd_file::error osd_file::open(std::string const &path, std::uint32_t openflags, // attempt to reopen the file if (error == osd_file::error::NONE) { -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) fd = ::open(dst.c_str(), access, 0666); #else fd = ::open64(dst.c_str(), access, 0666); @@ -273,7 +273,7 @@ osd_file::error osd_file::open(std::string const &path, std::uint32_t openflags, } // get the file size -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) struct stat st; if (::fstat(fd, &st) < 0) #else @@ -340,7 +340,7 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN osd_directory_entry *osd_stat(const std::string &path) { -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) struct stat st; int const err = ::stat(path.c_str(), &st); #else diff --git a/src/osd/modules/file/posixptty.cpp b/src/osd/modules/file/posixptty.cpp index b84838c0578..f7842574312 100644 --- a/src/osd/modules/file/posixptty.cpp +++ b/src/osd/modules/file/posixptty.cpp @@ -22,7 +22,7 @@ #if defined(__FreeBSD__) || defined(__DragonFly__) #include <termios.h> #include <libutil.h> -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__ANDROID__) #include <termios.h> #include <util.h> #elif defined(__linux__) || defined(EMSCRIPTEN) @@ -141,7 +141,10 @@ osd_file::error posix_open_ptty(std::uint32_t openflags, osd_file::ptr &file, st ::close(masterfd); return errno_to_file_error(err); } -#else +#elif defined(__ANDROID__) + int masterfd = -1, slavefd = -1; + char slavepath[PATH_MAX]; +#else struct termios tios; std::memset(&tios, 0, sizeof(tios)); ::cfmakeraw(&tios); diff --git a/src/osd/modules/font/font_sdl.cpp b/src/osd/modules/font/font_sdl.cpp index c6f45635623..c5a73b0a541 100644 --- a/src/osd/modules/font/font_sdl.cpp +++ b/src/osd/modules/font/font_sdl.cpp @@ -8,7 +8,7 @@ #include "font_module.h" #include "modules/osdmodule.h" -#if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX) && !defined(SDLMAME_SOLARIS) && !defined(SDLMAME_HAIKU) +#if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX) && !defined(SDLMAME_SOLARIS) && !defined(SDLMAME_HAIKU) && !defined(SDLMAME_ANDROID) #include "corestr.h" #include "corealloc.h" diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp index 3ef04cbf5cf..ab1985a6898 100644 --- a/src/osd/modules/render/drawbgfx.cpp +++ b/src/osd/modules/render/drawbgfx.cpp @@ -5,10 +5,6 @@ // drawbgfx.cpp - BGFX renderer // //============================================================ -#define __STDC_LIMIT_MACROS -#define __STDC_FORMAT_MACROS -#define __STDC_CONSTANT_MACROS - #if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS) // standard windows headers #define WIN32_LEAN_AND_MEAN @@ -95,7 +91,7 @@ static void* sdlNativeWindowHandle(SDL_Window* _window) return wmi.info.win.window; # elif BX_PLATFORM_STEAMLINK return wmi.info.vivante.window; -# elif BX_PLATFORM_EMSCRIPTEN +# elif BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_ANDROID return nullptr; # endif // BX_PLATFORM_ } diff --git a/src/osd/sdl/sdldir.cpp b/src/osd/sdl/sdldir.cpp index 439eb0a9792..abf1f126b94 100644 --- a/src/osd/sdl/sdldir.cpp +++ b/src/osd/sdl/sdldir.cpp @@ -50,7 +50,7 @@ #define INVPATHSEPCH '\\' #endif -#if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_HAIKU) || defined(SDLMAME_EMSCRIPTEN) +#if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_HAIKU) || defined(SDLMAME_EMSCRIPTEN) || defined(SDLMAME_ANDROID) typedef struct dirent sdl_dirent; typedef struct stat sdl_stat; #define sdl_readdir readdir diff --git a/src/osd/sdl/sdlmain.cpp b/src/osd/sdl/sdlmain.cpp index ad71a48aa08..ef4c6b7c927 100644 --- a/src/osd/sdl/sdlmain.cpp +++ b/src/osd/sdl/sdlmain.cpp @@ -10,7 +10,7 @@ #ifdef SDLMAME_UNIX -#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_EMSCRIPTEN)) +#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(SDLMAME_ANDROID)) #ifndef SDLMAME_HAIKU #include <fontconfig/fontconfig.h> #endif @@ -202,7 +202,7 @@ int main(int argc, char *argv[]) #ifdef SDLMAME_UNIX sdl_entered_debugger = 0; -#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) +#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(SDLMAME_ANDROID)) FcInit(); #endif #endif @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) } #ifdef SDLMAME_UNIX -#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) +#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(SDLMAME_ANDROID)) if (!sdl_entered_debugger) { FcFini(); diff --git a/src/osd/sdl/sdlos_unix.cpp b/src/osd/sdl/sdlos_unix.cpp index 23080512e91..82e11ebc07c 100644 --- a/src/osd/sdl/sdlos_unix.cpp +++ b/src/osd/sdl/sdlos_unix.cpp @@ -23,6 +23,12 @@ // MAME headers #include "osdcore.h" +#ifdef SDLMAME_ANDROID +char *osd_get_clipboard_text(void) +{ + return nullptr; +} +#else //============================================================ // osd_get_clipboard_text //============================================================ @@ -40,3 +46,5 @@ char *osd_get_clipboard_text(void) } return result; } + +#endif
\ No newline at end of file diff --git a/src/osd/sdl/sdlprefix.h b/src/osd/sdl/sdlprefix.h index 2acc6a9d98e..9ba0001ccc5 100644 --- a/src/osd/sdl/sdlprefix.h +++ b/src/osd/sdl/sdlprefix.h @@ -70,6 +70,10 @@ struct _IO_FILE {}; //_IO_FILE is an opaque type in the emscripten libc which makes clang cranky #endif +#if defined(__ANDROID__) +#define SDLMAME_ANDROID 1 +#endif + // fix for Ubuntu 8.10 #ifdef _FORTIFY_SOURCE #undef _FORTIFY_SOURCE |