Compare commits

...

15 Commits

Author SHA1 Message Date
Eric Lasota
549e1ec3e6 Merge pull request #17 from WickedSmoke/master
Fix Linux build
2023-05-24 22:43:03 -04:00
Karl Robillard
141b176574 AerofoilX: Print missing files to stderr. 2023-05-24 07:40:51 -04:00
Karl Robillard
18a0d3a42a Fix Linux compile errors. 2023-05-24 07:40:45 -04:00
elasota
af6d18829e Fix compile failure on systems where pthread_t isn't a pointer, and possibly also systems where it isn't pointer-sized either 2023-05-21 21:53:18 -04:00
elasota
4182a1a107 Bump version to 1.1.3 2022-06-22 21:31:46 -04:00
elasota
5643f464cc Discard security exception on getSerialNumber, fixes Android USB gamepad crash. 2022-06-22 21:29:55 -04:00
elasota
a04c5f10df Reject zip archives with non-zero file count but empty central directory 2022-06-22 21:28:28 -04:00
Eric Lasota
3e13877788 Merge pull request #11 from ryandesign/stdlib
Include stdlib.h where its functions are used
2022-03-17 13:10:33 -04:00
Ryan Schmidt
53ff18d337 Include stdlib.h where its functions are used
Fixes build failure on OS X 10.10 and 10.11:

error: use of undeclared identifier 'free'
error: use of undeclared identifier 'malloc'
error: use of undeclared identifier 'qsort'
2022-03-17 02:54:37 -05:00
elasota
e33c01cc40 Change line endings to UNIX 2022-03-17 02:00:06 -04:00
Eric Lasota
0c891d3117 Merge pull request #10 from ryandesign/mac
Improve CMake macOS build
2022-03-17 01:58:13 -04:00
elasota
e4d2d9f9a4 Fix bad null compares 2022-03-17 01:50:19 -04:00
elasota
41c0312921 Add more nullptr_t operators 2022-03-17 01:48:16 -04:00
Ryan Schmidt
e78b01a5f3 Improve CMake macOS build
Now actually builds on macOS.

Closes #9
2022-03-17 00:39:55 -05:00
elasota
d470bb5eeb Add nullptr_t constructor to THandle 2022-03-16 21:24:47 -04:00
12 changed files with 367 additions and 294 deletions

View File

@@ -15,8 +15,8 @@ android {
}
minSdkVersion 16
targetSdkVersion 30
versionCode 16
versionName "1.1.2"
versionCode 17
versionName "1.1.3"
externalNativeBuild {
ndkBuild {
arguments "APP_PLATFORM=android-16"

View File

@@ -1,5 +1,7 @@
#include "GpThreadEvent_Cpp11.h"
#include <stdlib.h>
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11(bool autoReset, bool startSignaled)
: m_flag(startSignaled)
, m_autoReset(autoReset)

View File

@@ -27,7 +27,7 @@
#include "UTF8.h"
#if defined(__CYGWIN__) || defined(__MACOS__)
#if defined(__CYGWIN__) || defined(__MACOS__) || defined(__linux)
typedef off_t off64_t;
#define fstat64 fstat
#define fseek64 fseek
@@ -305,6 +305,8 @@ GpIOStream *GpFileSystem_X::OpenFileNested(PortabilityLayer::VirtualDirectory_t
FILE *f = fopen(resolvedPath.c_str(), mode);
if (!f)
{
fprintf(stderr, "GpFileSystem_X: Cannot open \"%s\"\n",
resolvedPath.c_str());
free(objStorage);
return nullptr;
}

View File

@@ -4,6 +4,7 @@
#include "GpApplicationName.h"
#include "GpIOStream.h"
#include <stdlib.h>
#include <time.h>
#include <cstring>

View File

@@ -20,7 +20,9 @@
#include "IGpVOSEventQueue.h"
#include <string>
#ifdef __MACOS__
#include "MacInit.h"
#endif
GpXGlobals g_gpXGlobals;
@@ -28,7 +30,7 @@ IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProp
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties);
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
#ifdef __MACOS__
#ifndef _WIN32
int main(int argc, char *argv[])
#else
SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[])

View File

@@ -3,16 +3,13 @@
#include "IGpClipboardContents.h"
#include "IGpThreadEvent.h"
#ifdef __MACOS__
#include <SDL.h>
#include <pthread.h>
#else
#include "SDL2/SDL.h"
#endif
#include <time.h>
#include <unistd.h>
#include <string>
#include <string.h>
#include <stdlib.h>
struct GpSystemServices_X_ThreadStartParams
{
@@ -52,13 +49,19 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context)
if (!evt)
return nullptr;
pthread_t *threadPtr = static_cast<pthread_t*>(malloc(sizeof(pthread_t)));
if (!threadPtr)
{
evt->Destroy();
return nullptr;
}
GpSystemServices_X_ThreadStartParams startParams;
startParams.m_threadContext = context;
startParams.m_threadFunc = threadFunc;
startParams.m_threadStartEvent = evt;
pthread_t thread = nullptr;
if (pthread_create(&thread, nullptr, StaticStartThread, &startParams) != 0)
if (pthread_create(threadPtr, nullptr, StaticStartThread, &startParams) != 0)
{
evt->Destroy();
return nullptr;
@@ -67,7 +70,7 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context)
evt->Wait();
evt->Destroy();
return thread;
return static_cast<void*>(threadPtr);
}
bool GpSystemServices_X::Beep() const

View File

@@ -45,6 +45,7 @@ add_library(PortabilityLayer STATIC
PortabilityLayer/BitmapImage.cpp
PortabilityLayer/ByteSwap.cpp
PortabilityLayer/CFileStream.cpp
PortabilityLayer/CompositeRenderedFont.cpp
PortabilityLayer/DeflateCodec.cpp
PortabilityLayer/DialogManager.cpp
PortabilityLayer/DisplayDeviceManager.cpp
@@ -240,7 +241,8 @@ target_include_directories(GpApp PRIVATE
target_link_libraries(GpApp PortabilityLayer)
if(CMAKE_HOST_UNIX)
add_executable(${EXECNAME}
set(EXEC_SOURCES )
list(APPEND EXEC_SOURCES
AerofoilPortable/GpSystemServices_POSIX.cpp
AerofoilPortable/GpThreadEvent_Cpp11.cpp
AerofoilPortable/GpAllocator_C.cpp
@@ -258,7 +260,15 @@ if(CMAKE_HOST_UNIX)
AerofoilX/GpFileSystem_X.cpp
)
target_include_directories(${EXECNAME} PRIVATE
set(EXEC_LIBS )
list(APPEND EXEC_LIBS
${SDL2_LIBRARIES}
GpApp
GpShell
)
set(EXEC_INC_DIRS )
list(APPEND EXEC_INC_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpCommon>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpShell>
@@ -267,8 +277,22 @@ if(CMAKE_HOST_UNIX)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/PortabilityLayer>
${SDL2_INCLUDE_DIRS}
)
if(PLATFORM STREQUAL "MAC")
list(APPEND EXEC_SOURCES
AerofoilMac/AerofoilMac/AerofoilApplication.mm
AerofoilMac/AerofoilMac/MacInit.mm
)
list(APPEND EXEC_INC_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/AerofoilMac/AerofoilMac>
)
list(APPEND EXEC_LIBS
"-framework Cocoa"
)
endif(PLATFORM STREQUAL "MAC")
target_link_libraries(${EXECNAME} ${SDL2_LIBRARIES} GpApp GpShell)
add_executable(${EXECNAME} ${EXEC_SOURCES})
target_include_directories(${EXECNAME} PRIVATE ${EXEC_INC_DIRS})
target_link_libraries(${EXECNAME} ${EXEC_LIBS})
endif()

View File

@@ -336,7 +336,7 @@ void DisposCursors (void)
void IncrementCursor (void)
{
if (animCursorH == 0)
if (animCursorH == nullptr)
InitAnimatedCursor(nil);
if (animCursorH)
{
@@ -356,7 +356,7 @@ void IncrementCursor (void)
void DecrementCursor (void)
{
if (animCursorH == 0)
if (animCursorH == nullptr)
InitAnimatedCursor(nil);
if (animCursorH)
{

View File

@@ -2,8 +2,8 @@
#define GP_BUILD_VERSION_MAJOR 1
#define GP_BUILD_VERSION_MINOR 1
#define GP_BUILD_VERSION_UPDATE 2
#define GP_BUILD_VERSION_UPDATE 3
#define GP_APPLICATION_VERSION_STRING "1.1.2"
#define GP_APPLICATION_COPYRIGHT_STRING "2019-2021 Gale Force Games LLC"
#define GP_APPLICATION_VERSION_STRING "1.1.3"
#define GP_APPLICATION_COPYRIGHT_STRING "2019-2022 Gale Force Games LLC"
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"

View File

@@ -1,5 +1,7 @@
#pragma once
#include <cstddef>
namespace PortabilityLayer
{
struct MMHandleBlock;
@@ -24,6 +26,7 @@ class THandle final : public THandleBase
{
public:
THandle();
THandle(std::nullptr_t);
THandle(T **hdl);
explicit THandle(PortabilityLayer::MMHandleBlock *hdl);
THandle(const THandle<T> &other);
@@ -46,6 +49,9 @@ public:
bool operator==(T** other) const;
bool operator!=(T** other) const;
bool operator==(std::nullptr_t) const;
bool operator!=(std::nullptr_t) const;
static THandle<T> NullPtr();
};
@@ -74,6 +80,12 @@ inline THandle<T>::THandle()
{
}
template<class T>
inline THandle<T>::THandle(std::nullptr_t)
: THandleBase(nullptr)
{
}
template<class T>
inline THandle<T>::THandle(T **hdl)
: THandleBase(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(hdl))
@@ -107,17 +119,33 @@ inline bool THandle<T>::operator!=(const THandle<T> &other) const
template<class T>
inline bool THandle<T>::operator==(T** other) const
{
if (other == nullptr)
return m_hdl == nullptr;
return static_cast<void*>(&m_hdl->m_contents) == static_cast<void*>(other);
}
template<class T>
inline bool THandle<T>::operator!=(T** other) const
{
if (other == nullptr)
return m_hdl != nullptr;
return static_cast<void*>(&m_hdl->m_contents) != static_cast<void*>(other);
}
template<class T>
THandle<T> THandle<T>::NullPtr()
inline bool THandle<T>::operator==(std::nullptr_t) const
{
return m_hdl == nullptr;
}
template<class T>
inline bool THandle<T>::operator!=(std::nullptr_t) const
{
return m_hdl != nullptr;
}
template<class T>
inline THandle<T> THandle<T>::NullPtr()
{
return THandle<T>(static_cast<PortabilityLayer::MMHandleBlock *>(nullptr));
}

View File

@@ -10,6 +10,7 @@
#include "DeflateCodec.h"
#include <algorithm>
#include <stdlib.h>
namespace
{
@@ -323,6 +324,11 @@ namespace PortabilityLayer
return nullptr;
}
}
else
{
if (numFiles != 0)
return nullptr;
}
bool failed = false;

View File

@@ -53,7 +53,12 @@ class HIDDeviceUSB implements HIDDevice {
public String getSerialNumber() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getSerialNumber();
try {
result = mDevice.getSerialNumber();
}
catch (SecurityException exception) {
//Log.w(TAG, "App permissions mean we cannot get serial number for device " + getDeviceName() + " message: " + exception.getMessage());
}
}
if (result == null) {
result = "";