Native iPhone port of Factorio 2.0.77
Run the original macOS ARM64 game code on iOS: - tools/retarget.py: header-only Mach-O retargeting to an iOS dylib - platform/native: UIKit host and macOS API shims (AppKit for SDL's Cocoa backend, CoreGraphics displays, CoreAudio device, Metal device properties, Wuffs PNG decoding, Steam and peripheral stubs) - touch, overlay, iOS keyboard and hardware keyboard input - tools/build_native.py: build, sign, install, data copy, launch - docs: build guide, controls, architecture Also includes the earlier static-translation research (ARM64 -> WASM -> native) under docs/research, runtime/, tests/ and tools/. No game files are included; the build reads them from a local install.
This commit is contained in:
commit
51d085e865
89 files changed
+7999
No files matched your search
@@ -0,0 +1,118 @@
|
||||
// Small macOS-only APIs. Each FX_LIB_* section is compiled into its own shim dylib by
|
||||
// tools/build_native.py, so the original two-level-namespace bindings stay valid.
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include "fx.h"
|
||||
|
||||
#ifdef FX_LIB_COREVIDEO
|
||||
typedef struct { int64_t timeValue; int32_t timeScale; int32_t flags; } fx_cvtime;
|
||||
FX_EXPORT int32_t CVDisplayLinkCreateWithActiveCGDisplays(void **link) { *link = (void *)1; return 0; }
|
||||
FX_EXPORT int32_t CVDisplayLinkCreateWithCGDisplay(uint32_t display, void **link) { *link = (void *)1; return 0; }
|
||||
FX_EXPORT fx_cvtime CVDisplayLinkGetNominalOutputVideoRefreshPeriod(void *link) { return (fx_cvtime){1, 60, 0}; }
|
||||
FX_EXPORT void CVDisplayLinkRelease(void *link) { }
|
||||
FX_EXPORT int32_t CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(void *l, void *c, void *p) { return 0; }
|
||||
FX_EXPORT int32_t CVDisplayLinkSetOutputCallback(void *link, void *callback, void *context) { return 0; }
|
||||
FX_EXPORT int32_t CVDisplayLinkStart(void *link) { fx_log("[fx] CVDisplayLinkStart ignored"); return 0; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_CARBON
|
||||
FX_EXPORT const CFStringRef kTISPropertyUnicodeKeyLayoutData = CFSTR("TISPropertyUnicodeKeyLayoutData");
|
||||
FX_EXPORT void *TISCopyCurrentKeyboardLayoutInputSource(void) { return NULL; }
|
||||
FX_EXPORT void *TISGetInputSourceProperty(void *source, CFStringRef key) { return NULL; }
|
||||
FX_EXPORT uint32_t KBGetLayoutType(int16_t keyboard) { return 0; }
|
||||
FX_EXPORT uint8_t LMGetKbdType(void) { return 0; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_CORESERVICES
|
||||
FX_EXPORT int32_t LSOpenCFURLRef(CFURLRef url, CFURLRef *launched) { fx_log("[fx] LSOpenCFURLRef ignored"); return -10814; }
|
||||
FX_EXPORT int32_t UCKeyTranslate(const void *layout, uint16_t key, uint16_t action, uint32_t mods, uint32_t kbd,
|
||||
uint32_t opts, uint32_t *dead, unsigned long max, unsigned long *len, uint16_t *chars) {
|
||||
if (len) *len = 0;
|
||||
return -1;
|
||||
}
|
||||
FX_EXPORT double nan(const char *tag) { return __builtin_nan(""); }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_OPENCL
|
||||
FX_EXPORT int32_t clGetPlatformIDs(uint32_t n, void **platforms, uint32_t *count) { if (count) *count = 0; return -1001; }
|
||||
FX_EXPORT int32_t clGetDeviceIDs(void *p, uint64_t type, uint32_t n, void **devices, uint32_t *count) { if (count) *count = 0; return -1; }
|
||||
FX_EXPORT int32_t clGetDeviceInfo(void *d, uint32_t name, size_t size, void *value, size_t *ret) { return -33; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_FORCEFEEDBACK
|
||||
#define FF_UNSUPPORTED ((int32_t)0x80040202)
|
||||
FX_EXPORT int32_t FFIsForceFeedback(uint32_t service) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFCreateDevice(uint32_t service, void **device) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFReleaseDevice(void *device) { return 0; }
|
||||
FX_EXPORT int32_t FFDeviceCreateEffect(void *d, CFUUIDRef u, void *e, void **h) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFDeviceReleaseEffect(void *d, void *e) { return 0; }
|
||||
FX_EXPORT int32_t FFDeviceGetForceFeedbackCapabilities(void *d, void *c) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFDeviceGetForceFeedbackProperty(void *d, uint32_t p, void *v, uint32_t s) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFDeviceSetForceFeedbackProperty(void *d, uint32_t p, void *v) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFDeviceSendForceFeedbackCommand(void *d, uint32_t c) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFEffectGetEffectStatus(void *e, uint32_t *s) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFEffectSetParameters(void *e, void *p, uint32_t f) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFEffectStart(void *e, uint32_t i, uint32_t f) { return FF_UNSUPPORTED; }
|
||||
FX_EXPORT int32_t FFEffectStop(void *e) { return FF_UNSUPPORTED; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_LDAP
|
||||
// Only reachable from libcurl's LDAP protocol handler; every entry fails.
|
||||
#define LDAP_FAIL 0x51 /* LDAP_SERVER_DOWN */
|
||||
FX_EXPORT void *ldap_init(const char *host, int port) { return NULL; }
|
||||
FX_EXPORT int ldap_set_option(void *ld, int option, const void *value) { return LDAP_FAIL; }
|
||||
FX_EXPORT int ldap_simple_bind_s(void *ld, const char *who, const char *cred) { return LDAP_FAIL; }
|
||||
FX_EXPORT int ldap_search_s(void *ld, const char *b, int s, const char *f, char **a, int o, void **r) { if (r) *r = NULL; return LDAP_FAIL; }
|
||||
FX_EXPORT int ldap_unbind_s(void *ld) { return 0; }
|
||||
FX_EXPORT char *ldap_err2string(int err) { return "LDAP unsupported on iOS port"; }
|
||||
FX_EXPORT void *ldap_first_entry(void *ld, void *r) { return NULL; }
|
||||
FX_EXPORT void *ldap_next_entry(void *ld, void *e) { return NULL; }
|
||||
FX_EXPORT char *ldap_first_attribute(void *ld, void *e, void **b) { return NULL; }
|
||||
FX_EXPORT char *ldap_next_attribute(void *ld, void *e, void *b) { return NULL; }
|
||||
FX_EXPORT char *ldap_get_dn(void *ld, void *e) { return NULL; }
|
||||
FX_EXPORT void **ldap_get_values_len(void *ld, void *e, const char *a) { return NULL; }
|
||||
FX_EXPORT void ldap_value_free_len(void **v) { }
|
||||
FX_EXPORT void ldap_memfree(void *p) { }
|
||||
FX_EXPORT int ldap_msgfree(void *m) { return 0; }
|
||||
FX_EXPORT int ldap_url_parse(const char *url, void **desc) { return LDAP_FAIL; }
|
||||
FX_EXPORT void ldap_free_urldesc(void *d) { }
|
||||
FX_EXPORT void ber_free(void *b, int f) { }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_APPLICATIONSERVICES
|
||||
FX_EXPORT int UAZoomEnabled(void) { return 0; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_SECURITY
|
||||
#define errSecUnimplemented (-4)
|
||||
FX_EXPORT CFStringRef SecCertificateCopyLongDescription(CFAllocatorRef a, void *cert, CFErrorRef *e) { return NULL; }
|
||||
FX_EXPORT int32_t SecIdentityCreateWithCertificate(CFTypeRef keychain, void *cert, void **identity) { return errSecUnimplemented; }
|
||||
FX_EXPORT int32_t SecItemImport(CFDataRef data, CFStringRef ext, void *fmt, void *type, uint32_t flags,
|
||||
const void *params, void *keychain, CFArrayRef *items) { return errSecUnimplemented; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_IOKIT
|
||||
FX_EXPORT CFDictionaryRef IODisplayCreateInfoDictionary(uint32_t framebuffer, uint32_t options) {
|
||||
return CFDictionaryCreate(NULL, NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_STEAM
|
||||
// Steam is excluded from the target. Init reports failure; the game runs without Steam.
|
||||
FX_EXPORT int SteamAPI_RestartAppIfNecessary(uint32_t app) { fx_log("[fx] SteamAPI_RestartAppIfNecessary(%u) -> false", app); return 0; }
|
||||
FX_EXPORT int SteamAPI_Init(void) { fx_log("[fx] SteamAPI_Init -> false"); return 0; }
|
||||
FX_EXPORT void SteamAPI_Shutdown(void) { }
|
||||
FX_EXPORT void SteamAPI_RunCallbacks(void) { }
|
||||
FX_EXPORT int32_t SteamAPI_GetHSteamUser(void) { return 0; }
|
||||
FX_EXPORT void SteamAPI_RegisterCallback(void *cb, int id) { }
|
||||
FX_EXPORT void SteamAPI_UnregisterCallback(void *cb) { }
|
||||
FX_EXPORT void SteamAPI_RegisterCallResult(void *cb, uint64_t call) { }
|
||||
FX_EXPORT void SteamAPI_UnregisterCallResult(void *cb, uint64_t call) { }
|
||||
FX_EXPORT void *SteamInternal_ContextInit(void *context) { fx_log("[fx] SteamInternal_ContextInit -> NULL"); return NULL; }
|
||||
FX_EXPORT void *SteamInternal_FindOrCreateUserInterface(int32_t user, const char *version) { return NULL; }
|
||||
#endif
|
||||
|
||||
#ifdef FX_LIB_EMPTY
|
||||
FX_EXPORT int fx_empty_shim;
|
||||
#endif
|
||||
Reference in new issue
Block a user