diff options
author | js <js@pkgsrc.org> | 2020-11-01 20:18:30 +0000 |
---|---|---|
committer | js <js@pkgsrc.org> | 2020-11-01 20:18:30 +0000 |
commit | 9136f6ad589cef6dbbd5f58aac67a3863215b201 (patch) | |
tree | aee0d1548483962729f4dbaff7d061aa7d5d77b7 /emulators | |
parent | e7abd2958b74f03b77277a61e01af98b27a0d984 (diff) | |
download | pkgsrc-9136f6ad589cef6dbbd5f58aac67a3863215b201.tar.gz |
emulators/rpcemu: Update to a newer patchset for macOS support
Diffstat (limited to 'emulators')
-rw-r--r-- | emulators/rpcemu/Makefile | 8 | ||||
-rw-r--r-- | emulators/rpcemu/files/Info.plist | 26 | ||||
-rw-r--r-- | emulators/rpcemu/files/rpcemu-0.9.3-mac-patch-v1.patch (renamed from emulators/rpcemu/files/rpcemu-0.9.1-mac-v1.patch) | 1068 |
3 files changed, 797 insertions, 305 deletions
diff --git a/emulators/rpcemu/Makefile b/emulators/rpcemu/Makefile index 41e374d5f07..073dd051e3d 100644 --- a/emulators/rpcemu/Makefile +++ b/emulators/rpcemu/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.2 2020/10/24 16:53:41 js Exp $ +# $NetBSD: Makefile,v 1.3 2020/11/01 20:18:30 js Exp $ DISTNAME= rpcemu-0.9.3 -PKGREVISION= 1 +PKGREVISION= 2 CATEGORIES= emulators MASTER_SITES= http://www.marutan.net/rpcemu/cgi/download.php?sFName=${PKGVERSION_NOREV}/ @@ -18,7 +18,9 @@ INSTALLATION_DIRS+= bin post-patch: ${RUN} cd ${WRKSRC}/src && \ - ${PATCH} -p0 <${FILESDIR}/rpcemu-0.9.1-mac-v1.patch + ${PATCH} -p1 <${FILESDIR}/rpcemu-0.9.3-mac-patch-v1.patch + ${RUN} ${MKDIR} ${WRKSRC}/src/macosx + ${RUN} cp ${FILESDIR}/Info.plist ${WRKSRC}/src/macosx/Info.plist do-configure: cd ${WRKSRC} && ${QTDIR}/bin/qmake src/qt5/rpcemu.pro diff --git a/emulators/rpcemu/files/Info.plist b/emulators/rpcemu/files/Info.plist new file mode 100644 index 00000000000..37e3d987889 --- /dev/null +++ b/emulators/rpcemu/files/Info.plist @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleGetInfoString</key> + <string>Created by Qt/QMake</string> + <key>CFBundleIconFile</key> + <string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string> + <key>CFBundleIdentifier</key> + <string>org.marutan.rpcemu</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>${QMAKE_PKGINFO_TYPEINFO}</string> + <key>LSMinimumSystemVersion</key> + <string>${MACOSX_DEPLOYMENT_TARGET}</string> + <key>NOTE</key> + <string>This file was generated by Qt/QMake.</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> diff --git a/emulators/rpcemu/files/rpcemu-0.9.1-mac-v1.patch b/emulators/rpcemu/files/rpcemu-0.9.3-mac-patch-v1.patch index f3147726518..35c4aa02b63 100644 --- a/emulators/rpcemu/files/rpcemu-0.9.1-mac-v1.patch +++ b/emulators/rpcemu/files/rpcemu-0.9.3-mac-patch-v1.patch @@ -1,37 +1,50 @@ -Patchset from http://www.riscos.info/pipermail/rpcemu/2018-November/002703.html -to add macOS support. +From http://www.riscos.info/pipermail/rpcemu/2020-May/002887.html ---- /dev/null 2018-11-18 20:18:48.000000000 +0000 -+++ macosx/Info.plist 2018-11-18 20:18:14.000000000 +0000 -@@ -0,0 +1,26 @@ -+<?xml version="1.0" encoding="UTF-8"?> -+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -+<plist version="1.0"> -+<dict> -+ <key>CFBundleExecutable</key> -+ <string>${EXECUTABLE_NAME}</string> -+ <key>CFBundleGetInfoString</key> -+ <string>Created by Qt/QMake</string> -+ <key>CFBundleIconFile</key> -+ <string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string> -+ <key>CFBundleIdentifier</key> -+ <string>org.marutan.rpcemu</string> -+ <key>CFBundlePackageType</key> -+ <string>APPL</string> -+ <key>CFBundleSignature</key> -+ <string>${QMAKE_PKGINFO_TYPEINFO}</string> -+ <key>LSMinimumSystemVersion</key> -+ <string>${MACOSX_DEPLOYMENT_TARGET}</string> -+ <key>NOTE</key> -+ <string>This file was generated by Qt/QMake.</string> -+ <key>NSPrincipalClass</key> -+ <string>NSApplication</string> -+ <key>NSSupportsAutomaticGraphicsSwitching</key> -+ <true/> -+</dict> -+</plist> ---- /dev/null 2018-11-18 19:57:31.000000000 +0000 -+++ qt5/choose_dialog.cpp 2018-11-04 16:40:30.000000000 +0000 +--- original/ArmDynarec.c 2020-05-06 20:19:23.000000000 +0100 ++++ src/ArmDynarec.c 2020-05-07 21:14:11.000000000 +0100 +@@ -580,12 +580,39 @@ + { + const long page_size = sysconf(_SC_PAGESIZE); + const long page_mask = ~(page_size - 1); +- void *start; ++ void *start, *addr; + long end; ++ int mmap_flags = 0; + + start = (void *) ((long) ptr & page_mask); + end = ((long) ptr + len + page_size - 1) & page_mask; + len = (size_t) (end - (long) start); ++ ++#if __APPLE__ ++ // More up-to-date versions of OS X require "mmap" to be called prior to "mprotect". ++ // Certain versions also require the MAP_JIT flag as well. ++ // Try without first, and if that fails, add the flag in. ++ mmap_flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED; ++ ++ addr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); ++ if (addr == MAP_FAILED) ++ { ++ mmap_flags |= MAP_JIT; ++ } ++ else ++ { ++ munmap(addr, page_size); ++ } ++ ++ addr = mmap(start, len, PROT_READ | PROT_WRITE | PROT_EXEC, mmap_flags, -1, 0); ++ ++ if (addr == MAP_FAILED) ++ { ++ perror("mmap"); ++ exit(1); ++ } ++ ++#endif + + if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) { + perror("mprotect"); +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/qt5/choose_dialog.cpp 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,107 @@ +/* + RPCEmu - An Acorn system emulator @@ -140,8 +153,8 @@ to add macOS support. +{ +} + ---- /dev/null 2018-11-18 19:57:31.000000000 +0000 -+++ qt5/choose_dialog.h 2018-11-04 16:34:31.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/qt5/choose_dialog.h 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,64 @@ +/* + RPCEmu - An Acorn system emulator @@ -207,8 +220,8 @@ to add macOS support. +}; + +#endif ---- /dev/null 2018-11-18 19:56:31.000000000 +0000 -+++ macosx/events-macosx.h 2018-11-02 19:57:29.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/events-macosx.h 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,45 @@ +/* + RPCEmu - An Acorn system emulator @@ -255,8 +268,8 @@ to add macOS support. +#endif + +#endif // __EVENTS_MACOSX_H__ ---- /dev/null 2018-11-18 19:56:31.000000000 +0000 -+++ macosx/events-macosx.m 2018-11-02 19:57:31.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/events-macosx.m 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,56 @@ +/* + RPCEmu - An Acorn system emulator @@ -314,8 +327,8 @@ to add macOS support. + // Return zero if the event is not handled here. + return result; +} ---- /dev/null 2018-11-18 19:56:31.000000000 +0000 -+++ macosx/hid-macosx.h 2018-11-02 19:57:37.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/hid-macosx.h 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,34 @@ +///* +// RPCEmu - An Acorn system emulator @@ -351,8 +364,8 @@ to add macOS support. +#endif + +#endif // __HID_MACOSX_H__ ---- /dev/null 2018-11-18 19:56:31.000000000 +0000 -+++ macosx/hid-macosx.m 2018-11-02 19:57:40.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/hid-macosx.m 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,165 @@ +///* +// RPCEmu - An Acorn system emulator @@ -519,8 +532,8 @@ to add macOS support. +} + + ---- /dev/null 2018-11-18 19:49:33.000000000 +0000 -+++ hostfs-macosx.c 2018-11-04 16:50:44.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/hostfs-macosx.c 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,121 @@ +#include <assert.h> +#include <errno.h> @@ -643,8 +656,8 @@ to add macOS support. + utime(host_path, &t); + /* TODO handle error in utime() */ +} ---- hostfs.c.orig 2018-11-02 19:15:19.000000000 +0000 -+++ hostfs.c 2018-11-18 19:52:41.000000000 +0000 +--- original/hostfs.c 2020-05-06 20:19:23.000000000 +0100 ++++ src/hostfs.c 2020-05-07 21:05:20.000000000 +0100 @@ -273,6 +273,9 @@ case '>': *host_path++ = '^'; @@ -673,8 +686,39 @@ to add macOS support. if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { continue; } ---- keyboard.c.orig 2018-11-02 19:15:19.000000000 +0000 -+++ keyboard.c 2018-11-02 20:02:26.000000000 +0000 +--- original/iomd.c 2020-05-06 20:19:23.000000000 +0100 ++++ src/iomd.c 2020-05-07 21:05:20.000000000 +0100 +@@ -840,19 +840,28 @@ + } + /* Middle */ + if (mouse_buttons & 4) { ++ ++#ifdef __APPLE__ ++ temp |= 0x20; ++#else + if (config.mousetwobutton) { + temp |= 0x10; // bit 4 + } else { + temp |= 0x20; // bit 5 + } ++#endif + } + /* Right */ + if (mouse_buttons & 2) { ++#ifdef __APPLE__ ++ temp |= 0x10; ++#else + if (config.mousetwobutton) { + temp |= 0x20; // bit 5 + } else { + temp |= 0x10; // bit 4 + } ++#endif + } + + /* bit 0 contains the monitor id bit, 0 for VGA, 1 for TV type monitors. +--- original/keyboard.c 2020-05-06 20:19:23.000000000 +0100 ++++ src/keyboard.c 2020-05-07 21:05:20.000000000 +0100 @@ -44,6 +44,10 @@ #include "arm.h" #include "i8042.h" @@ -686,7 +730,7 @@ to add macOS support. /* Keyboard Commands */ #define KBD_CMD_ENABLE 0xf4 #define KBD_CMD_RESET 0xff -@@ -254,6 +258,11 @@ +@@ -254,6 +258,10 @@ /* Mousehack reset */ mouse_hack.pointer = 0; mouse_hack.cursor_linked = 1; @@ -694,13 +738,60 @@ to add macOS support. +#ifdef __APPLE__ + keyboard_reset_modifiers(0); +#endif -+ } static uint8_t ---- /dev/null 2018-11-18 19:58:10.000000000 +0000 -+++ qt5/keyboard_macosx.c 2018-11-02 20:44:35.000000000 +0000 -@@ -0,0 +1,326 @@ +@@ -731,6 +739,7 @@ + { + uint8_t tmp; + ++#ifndef __APPLE__ + if (config.mousetwobutton) { + /* To help people with only two buttons on their mouse, + swap the behaviour of middle and right buttons */ +@@ -740,6 +749,7 @@ + + mouseb = mousel | (mousem << 1) | (mouser << 2); + } ++#endif + + tmp = (mouseb & 7) | 8; + +@@ -1192,6 +1202,15 @@ + if (mouse.buttons & 1) { + buttons |= 4; /* Left button */ + } ++ ++#ifdef __APPLE__ ++ if (mouse.buttons & 2) { ++ buttons |= 1; /* Right button */ ++ } ++ if (mouse.buttons & 4) { ++ buttons |= 2; /* Middle button */ ++ } ++#else + if (config.mousetwobutton) { + /* To help people with only two buttons on their mouse, swap + the behaviour of middle and right buttons */ +@@ -1209,6 +1228,8 @@ + buttons |= 2; /* Middle button */ + } + } ++#endif ++ + arm.reg[2] = buttons; + + arm.reg[3] = 0; /* R3 = time of button change */ +@@ -1258,4 +1279,4 @@ + mouse_osunits_to_host(osx, osy, &x, &y); + + rpcemu_move_host_mouse(x, y); +-} +\ No newline at end of file ++} +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/qt5/keyboard_macosx.c 2020-05-07 21:05:20.000000000 +0100 +@@ -0,0 +1,351 @@ +/* + RPCEmu - An Acorn system emulator + @@ -726,6 +817,8 @@ to add macOS support. + +#include <Carbon/Carbon.h> + ++#define UNUSED(x) (void)(x) ++ +const int MAX_KEYBOARD_LAYOUTS = 20; + +typedef enum @@ -899,6 +992,7 @@ to add macOS support. + uint maskRight; + uint8_t set_2_left[8]; + uint8_t set_2_right[8]; ++ int simulateMenuButton; +} ModifierMapInfo; + +// The following are from the "NSEventModifierFlagOption" enumeration. @@ -911,11 +1005,11 @@ to add macOS support. +} NativeModifierFlag; + +static const ModifierMapInfo modifier_map[] = { -+ {nativeModifierFlagShift, modifierKeyStateShift, 0x102, 0x104, {0x12}, {0x59} }, // Shift. -+ {nativeModifierFlagControl, modifierKeyStateControl, 0x101, 0x2100, {0x14}, {0xe0, 0x14} }, // Control. -+ {nativeModifierFlagOption, modifierKeyStateAlt, 0x120, 0x140, {0x11}, {0xe0, 0x11}}, // Alt. -+ {nativeModifierFlagCommand, modifierKeyStateCommand, 0x100108, 0x100110, {0xe0, 0x1f}, {0xe0, 0x27}}, // Command. -+ {0x1<<31, 0, 0, 0, {0}, {0} }, ++ {nativeModifierFlagShift, modifierKeyStateShift, 0x102, 0x104, {0x12}, {0x59}, 0 }, // Shift. ++ {nativeModifierFlagControl, modifierKeyStateControl, 0x101, 0x2100, {0x14}, {0xe0, 0x14}, 0}, // Control. ++ {nativeModifierFlagOption, modifierKeyStateAlt, 0x120, 0x140, {0x11}, {0xe0, 0x11}, 0}, // Alt. ++ {nativeModifierFlagCommand, modifierKeyStateCommand, 0x100108, 0x100110, {0xe0, 0x1f}, {0xe0, 0x27}, 1}, // Command. ++ {0x1<<31, 0, 0, 0, {0}, {0}, 0 }, +}; + +int get_virtual_key_index(size_t k) @@ -955,31 +1049,48 @@ to add macOS support. + { + int state = modifierState.keyState[modifier_map[k].checkMask]; + uint modifierMask = modifier_map[k].modifierMask; -+ ++ + if ((mask & modifierMask) != 0) + { -+ if (modifier_map[k].maskLeft != 0xFFFFFFFF && (mask & modifier_map[k].maskLeft) == modifier_map[k].maskLeft && (state & 1) == 0) ++ if (modifier_map[k].simulateMenuButton && config.mousetwobutton && state == 0) + { -+ state |= 1; -+ keyboard_key_press(modifier_map[k].set_2_left); ++ state = 3; ++ mouse_mouse_press(4); + } -+ if (modifier_map[k].maskRight != 0xFFFFFFFF && (mask & modifier_map[k].maskRight) == modifier_map[k].maskRight && (state & 2) == 0) ++ else + { -+ state |= 2; -+ keyboard_key_press(modifier_map[k].set_2_right); ++ if ((mask & modifier_map[k].maskLeft) == modifier_map[k].maskLeft && (state & 1) == 0) ++ { ++ state |= 1; ++ keyboard_key_press(modifier_map[k].set_2_left); ++ } ++ ++ if ((mask & modifier_map[k].maskRight) == modifier_map[k].maskRight && (state & 2) == 0) ++ { ++ state |= 2; ++ keyboard_key_press(modifier_map[k].set_2_right); ++ } + } + } -+ else if ((mask & modifierMask) ==0 && state != 0) ++ else if ((mask & modifierMask) == 0 && state != 0) + { -+ if (state & 1) ++ if (config.mousetwobutton && modifier_map[k].simulateMenuButton) + { -+ state &= ~1; -+ keyboard_key_release(modifier_map[k].set_2_left); ++ state = 0; ++ mouse_mouse_release(4); + } -+ if (state & 2) ++ else + { -+ state &= ~2; -+ keyboard_key_release(modifier_map[k].set_2_right); ++ if (state & 1) ++ { ++ state &= ~1; ++ keyboard_key_release(modifier_map[k].set_2_left); ++ } ++ if (state & 2) ++ { ++ state &= ~2; ++ keyboard_key_release(modifier_map[k].set_2_right); ++ } + } + } + @@ -1024,12 +1135,17 @@ to add macOS support. + } + else + { -+ fprintf(stderr, "Using keyboard layout '%s' (%d).\n", layoutName, keyboardType); ++ fprintf(stderr, "Using keyboard layout '%s' (%d).\n", layoutName, keyboardType); + } +} ---- /dev/null 2018-11-18 19:58:10.000000000 +0000 -+++ qt5/keyboard_macosx.h 2018-11-02 20:44:36.000000000 +0000 -@@ -0,0 +1,39 @@ ++ ++int keyboard_check_special_keys() ++{ ++ return (modifierState.keyState[modifierKeyStateControl] != 0 && modifierState.keyState[modifierKeyStateCommand] != 0); ++} +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/qt5/keyboard_macosx.h 2020-05-07 21:05:20.000000000 +0100 +@@ -0,0 +1,40 @@ +/* + RPCEmu - An Acorn system emulator + @@ -1062,6 +1178,7 @@ to add macOS support. +extern void keyboard_handle_modifier_keys(uint32_t mask); +extern void keyboard_reset_modifiers(int sendReleaseEvent); +extern void keyboard_configure_layout(const char *layoutName); ++extern int keyboard_check_special_keys(); + +#ifdef __cplusplus +} @@ -1069,9 +1186,9 @@ to add macOS support. + +#endif + ---- qt5/main_window.cpp.orig 2018-11-02 19:15:19.000000000 +0000 -+++ qt5/main_window.cpp 2018-11-02 21:25:14.000000000 +0000 -@@ -31,7 +31,11 @@ +--- original/qt5/main_window.cpp 2020-05-06 20:19:23.000000000 +0100 ++++ src/qt5/main_window.cpp 2020-05-07 21:14:11.000000000 +0100 +@@ -31,7 +31,12 @@ #if defined(Q_OS_WIN32) #include "Windows.h" @@ -1080,187 +1197,328 @@ to add macOS support. + +#if defined(Q_OS_MACOS) +#include "macosx/events-macosx.h" ++#include "keyboard_macosx.h" +#endif /* Q_OS_MACOS */ #include "rpcemu.h" #include "keyboard.h" -@@ -423,6 +427,11 @@ +@@ -66,6 +71,9 @@ + void + MainDisplay::mouseMoveEvent(QMouseEvent *event) + { ++ // Ignore mouse events if the application is terminating. ++ if (quited) return; ++ + if((!pconfig_copy->mousehackon && mouse_captured) || full_screen) { + QPoint middle; + +@@ -90,6 +98,9 @@ + void + MainDisplay::mousePressEvent(QMouseEvent *event) + { ++ // Ignore mouse events if the application is terminating. ++ if (quited) return; ++ + // Handle turning on mouse capture in capture mouse mode + if(!pconfig_copy->mousehackon) { + if(!mouse_captured) { +@@ -110,6 +121,9 @@ + void + MainDisplay::mouseReleaseEvent(QMouseEvent *event) + { ++ // Ignore mouse events if the application is terminating. ++ if (quited) return; ++ + if (event->button() & 7) { + emit this->emulator.mouse_release_signal(event->button() & 7); + } +@@ -443,6 +457,11 @@ // Clear the list of keys considered to be held in the host held_keys.clear(); -+ ++ +#if defined(Q_OS_MACOS) -+ emit this->emulator.modifier_keys_reset_signal(); ++ emit this->emulator.modifier_keys_reset_signal(); +#endif /* Q_OS_MACOS */ -+ ++ } /** -@@ -531,7 +540,13 @@ +@@ -505,53 +524,18 @@ + } + + // Special case, check for Ctrl-End, our multi purpose do clever things key +- if((Qt::Key_End == event->key()) && (event->modifiers() & Qt::ControlModifier)) { +- if(full_screen) { +- // Change Full Screen -> Windowed +- +- display->set_full_screen(false); +- +- int host_xsize, host_ysize; +- display->get_host_size(host_xsize, host_ysize); +- display->setFixedSize(host_xsize, host_ysize); +- +- menuBar()->setVisible(true); +- this->showNormal(); +- this->setFixedSize(this->sizeHint()); +- +- full_screen = false; +- +- // Request redraw of display +- display->update(); +- +- // If we were in mousehack mode before entering fullscreen +- // return to it now +- if(reenable_mousehack) { +- emit this->emulator.mouse_hack_signal(); +- } +- reenable_mousehack = false; +- +- // If we were in mouse capture mode before entering fullscreen +- // and we hadn't captured the mouse, display the host cursor now +- if(!config_copy.mousehackon && !mouse_captured) { +- this->display->setCursor(Qt::ArrowCursor); +- } +- +- return; +- } else if(!pconfig_copy->mousehackon && mouse_captured) { +- // Turn off mouse capture +- mouse_captured = 0; +- +- // show pointer in mouse capture mode when it's not been captured +- this->display->setCursor(Qt::ArrowCursor); +- +- return; +- } ++ if((Qt::Key_End == event->key()) && (event->modifiers() & Qt::ControlModifier)) ++ { ++ processMagicKeys(); + } // Regular case pass key press onto the emulator if (!event->isAutoRepeat()) { - native_keypress_event(event->nativeScanCode()); -+ -+#if defined(Q_OS_MACOS) -+ native_keypress_event(event->nativeVirtualKey(), event->nativeModifiers()); -+#else -+ native_keypress_event(event->nativeScanCode(), event->nativeModifiers()); -+#endif /* Q_OS_MACOS */ -+ ++ #if defined(Q_OS_MACOS) ++ native_keypress_event(event->nativeVirtualKey(), event->nativeModifiers()); ++ #else ++ native_keypress_event(event->nativeScanCode(), event->nativeModifiers()); ++ #endif /* Q_OS_MACOS */ } } -@@ -551,7 +566,13 @@ +@@ -571,7 +555,11 @@ // Regular case pass key release onto the emulator if (!event->isAutoRepeat()) { - native_keyrelease_event(event->nativeScanCode()); -+ +#if defined(Q_OS_MACOS) -+ native_keyrelease_event(event->nativeVirtualKey(), event->nativeModifiers()); ++ native_keyrelease_event(event->nativeVirtualKey(), event->nativeModifiers()); +#else -+ native_release_event(event->nativeScanCode(), event->nativeModifiers()); -+#endif /* Q_OS_MACOS */ -+ ++ native_keyrelease_event(event->nativeScanCode(), event->nativeModifiers()); ++#endif /* Q_OS_MACOS */ } } -@@ -559,10 +580,28 @@ - * Called by us with native scan-code to forward key-press to the emulator - * +@@ -581,8 +569,25 @@ * @param scan_code Native scan code of key -+ * @param modifiers Native modifiers */ void -MainWindow::native_keypress_event(unsigned scan_code) +MainWindow::native_keypress_event(unsigned scan_code, unsigned modifiers) { -+ +#if defined(Q_OS_MACOS) -+ if (!(scan_code == 0 && modifiers == 0)) -+ { -+ // Check the key isn't already marked as held down (else ignore) -+ // (to deal with potentially inconsistent host messages) -+ bool found = (std::find(held_keys.begin(), held_keys.end(), scan_code) != held_keys.end()); -+ -+ if (!found) { -+ // Add the key to the list of held_keys, that will be released -+ // when the window loses the focus -+ held_keys.insert(held_keys.end(), scan_code); -+ -+ emit this->emulator.key_press_signal(scan_code); -+ } -+ } ++ if (!(scan_code == 0 && modifiers == 0)) ++ { ++ // Check the key isn't already marked as held down (else ignore) ++ // (to deal with potentially inconsistent host messages) ++ bool found = (std::find(held_keys.begin(), held_keys.end(), scan_code) != held_keys.end()); ++ ++ if (!found) { ++ // Add the key to the list of held_keys, that will be released ++ // when the window loses the focus ++ held_keys.insert(held_keys.end(), scan_code); ++ ++ emit this->emulator.key_press_signal(scan_code); ++ } ++ } +#else ++ // Check the key isn't already marked as held down (else ignore) // (to deal with potentially inconsistent host messages) bool found = (std::find(held_keys.begin(), held_keys.end(), scan_code) != held_keys.end()); -@@ -574,16 +613,39 @@ +@@ -592,8 +597,9 @@ + // when the window loses the focus + held_keys.insert(held_keys.end(), scan_code); - emit this->emulator.key_press_signal(scan_code); - } +- emit this->emulator.key_press_signal(scan_code); + -+#endif /* Q_OS_MACOS */ + } ++#endif } /** - * Called by us with native scan-code to forward key-release to the emulator - * +@@ -602,8 +608,26 @@ * @param scan_code Native scan code of key -+ * @param modifiers Native modifiers */ void -MainWindow::native_keyrelease_event(unsigned scan_code) +MainWindow::native_keyrelease_event(unsigned scan_code, unsigned modifiers) { -+ +#if defined(Q_OS_MACOS) -+ -+ if (!(scan_code == 0 && modifiers == 0)) -+ { -+ // Check the key is marked as held down (else ignore) -+ // (to deal with potentially inconsistent host messages) -+ bool found = (std::find(held_keys.begin(), held_keys.end(), scan_code) != held_keys.end()); -+ -+ if (found) { -+ // Remove the key from the list of held_keys, that will be released -+ // when the window loses the focus -+ held_keys.remove(scan_code); -+ -+ emit this->emulator.key_release_signal(scan_code); -+ } -+ } ++ ++ if (!(scan_code == 0 && modifiers == 0)) ++ { ++ // Check the key is marked as held down (else ignore) ++ // (to deal with potentially inconsistent host messages) ++ bool found = (std::find(held_keys.begin(), held_keys.end(), scan_code) != held_keys.end()); ++ ++ if (found) { ++ // Remove the key from the list of held_keys, that will be released ++ // when the window loses the focus ++ held_keys.remove(scan_code); ++ ++ emit this->emulator.key_release_signal(scan_code); ++ } ++ } + +#else -+ // Check the key is marked as held down (else ignore) // (to deal with potentially inconsistent host messages) bool found = (std::find(held_keys.begin(), held_keys.end(), scan_code) != held_keys.end()); -@@ -595,6 +657,9 @@ +@@ -615,6 +639,7 @@ emit this->emulator.key_release_signal(scan_code); } -+ -+#endif /* Q_OS_MACOS */ -+ ++#endif } void -@@ -1480,3 +1545,38 @@ +@@ -1312,7 +1337,13 @@ + + if(!pconfig_copy->mousehackon) { + if(mouse_captured) { ++ ++#if defined(Q_OS_MACOS) ++ capture_text = " Press CTRL-COMMAND to release mouse"; ++#else + capture_text = " Press CTRL-END to release mouse"; ++#endif ++ + } else { + capture_text = " Click to capture mouse"; + } +@@ -1415,6 +1446,52 @@ + } + } + ++void ++MainWindow::processMagicKeys() ++{ ++ if(full_screen) { ++ // Change Full Screen -> Windowed ++ ++ display->set_full_screen(false); ++ ++ int host_xsize, host_ysize; ++ display->get_host_size(host_xsize, host_ysize); ++ display->setFixedSize(host_xsize, host_ysize); ++ ++ menuBar()->setVisible(true); ++ this->showNormal(); ++ this->setFixedSize(this->sizeHint()); ++ ++ full_screen = false; ++ ++ // Request redraw of display ++ display->update(); ++ ++ // If we were in mousehack mode before entering fullscreen ++ // return to it now ++ if(reenable_mousehack) { ++ emit this->emulator.mouse_hack_signal(); ++ } ++ reenable_mousehack = false; ++ ++ // If we were in mouse capture mode before entering fullscreen ++ // and we hadn't captured the mouse, display the host cursor now ++ if(!config_copy.mousehackon && !mouse_captured) { ++ this->display->setCursor(Qt::ArrowCursor); ++ } ++ ++ return; ++ } else if(!pconfig_copy->mousehackon && mouse_captured) { ++ // Turn off mouse capture ++ mouse_captured = 0; ++ ++ // show pointer in mouse capture mode when it's not been captured ++ this->display->setCursor(Qt::ArrowCursor); ++ ++ return; ++ } ++} ++ + #if defined(Q_OS_WIN32) + /** + * windows pre event handler used by us to modify some default behaviour +@@ -1473,3 +1550,46 @@ return false; } #endif // Q_OS_WIN32 + +#if defined(Q_OS_MACOS) +/** -+ * On OS X, handle additional events for modifier keys. The normal key press/release ++ * On OS X, handle additional events for modifier keys. The normal key press/release + * events do not differentiate between left and right. + * + * @param eventType unused + * @param message window event NSEvent data + * @param result unused -+ * @return bool of whether we've handled the event (true) or OS X/QT should deal with it (false) ++ * @return bool of whether we've handled the event (true) or OS X/QT should deal with it (false) + */ +bool +MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +{ -+ Q_UNUSED(eventType); -+ Q_UNUSED(result); -+ -+ NativeEvent *event = handle_native_event(message); -+ if (!event->processed) -+ { -+ free(event); -+ return false; -+ } -+ -+ if (event->eventType == nativeEventTypeModifiersChanged) -+ { -+ // Modifier key state has changed. -+ emit this->emulator.modifier_keys_changed_signal(event->modifierMask); -+ free(event); -+ } -+ -+ return true; ++ Q_UNUSED(eventType); ++ Q_UNUSED(result); ++ ++ NativeEvent *event = handle_native_event(message); ++ if (!event->processed) ++ { ++ free(event); ++ return false; ++ } ++ ++ if (event->eventType == nativeEventTypeModifiersChanged) ++ { ++ // Modifier key state has changed. ++ emit this->emulator.modifier_keys_changed_signal(event->modifierMask); ++ ++ if (keyboard_check_special_keys()) ++ { ++ // Magic key combination to release mouse capture. ++ processMagicKeys(); ++ } ++ ++ free(event); ++ } ++ ++ return true; +} + +#endif /* Q_OS_MACOS */ ---- qt5/main_window.h.orig 2018-11-02 19:15:19.000000000 +0000 -+++ qt5/main_window.h 2018-11-02 20:59:06.000000000 +0000 -@@ -107,9 +107,9 @@ ++ +--- original/qt5/main_window.h 2020-05-06 20:19:23.000000000 +0100 ++++ src/qt5/main_window.h 2020-05-07 21:14:11.000000000 +0100 +@@ -109,7 +109,7 @@ void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; -#if defined(Q_OS_WIN32) +#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS) bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; --#endif /* Q_OS_WIN32 */ -+#endif /* Q_OS_WIN32 or Q_OS_MACOS */ + #endif /* Q_OS_WIN32 */ - private slots: - void menu_screenshot(); -@@ -163,8 +163,8 @@ +@@ -165,9 +165,11 @@ void cdrom_menu_selection_update(const QAction *cdrom_action); @@ -1269,10 +1527,140 @@ to add macOS support. + void native_keypress_event(unsigned scan_code, unsigned modifiers); + void native_keyrelease_event(unsigned scan_code, unsigned modifiers); void release_held_keys(); ++ ++ void processMagicKeys(); bool full_screen; ---- /dev/null 2018-11-18 19:56:31.000000000 +0000 -+++ macosx/preferences-macosx.h 2018-11-04 16:43:54.000000000 +0000 + bool reenable_mousehack; ///< Did we disable mousehack entering fullscreen and have to reenable it on leaving fullscreen? +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/network-macosx.c 2020-05-07 21:05:20.000000000 +0100 +@@ -0,0 +1,97 @@ ++/* ++ RPCEmu - An Acorn system emulator ++ ++ Copyright (C) 2005-2010 Sarah Walker ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++/* RPCemu networking */ ++ ++#include <assert.h> ++#include <ctype.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <sys/time.h> ++#include <sys/types.h> ++#include <sys/ioctl.h> ++#include <errno.h> ++#include <string.h> ++#include <sys/socket.h> ++#include <net/if.h> ++#include <netinet/in.h> ++#include <arpa/inet.h> ++#include <pwd.h> ++#include <grp.h> ++#include <signal.h> ++ ++#include "rpcemu.h" ++#include "mem.h" ++#include "podules.h" ++#include "network.h" ++ ++int ++network_plt_init(void) ++{ ++ // Do nothing on a Mac, as TUN/TAP is not supported. ++ return 0; ++} ++ ++/** ++ * Shutdown any running network components. ++ * ++ * Called on program shutdown and program reset after ++ * configuration has changed. ++ */ ++void ++network_plt_reset(void) ++{ ++ // Do nothing on a Mac, as TUN/TAP is not supported. ++} ++ ++uint32_t ++network_plt_rx(uint32_t errbuf, uint32_t mbuf, uint32_t rxhdr, uint32_t *dataavail) ++{ ++ NOT_USED(errbuf); ++ NOT_USED(mbuf); ++ NOT_USED(rxhdr); ++ NOT_USED(dataavail); ++ ++ // Do nothing on a Mac, as TUN/TAP is not supported. ++ return 0; ++} ++ ++uint32_t ++network_plt_tx(uint32_t errbuf, uint32_t mbufs, uint32_t dest, uint32_t src, uint32_t frametype) ++{ ++ NOT_USED(errbuf); ++ NOT_USED(mbufs); ++ NOT_USED(dest); ++ NOT_USED(src); ++ NOT_USED(frametype); ++ ++ // Do nothing on a Mac, as TUN/TAP is not supported. ++ return 0; ++} ++ ++void ++network_plt_setirqstatus(uint32_t address) ++{ ++ NOT_USED(address); ++ ++ // Do nothing on a Mac, as TUN/TAP is not supported. ++} +--- original/network.c 2020-05-06 20:19:23.000000000 +0100 ++++ src/network.c 2020-05-07 21:14:11.000000000 +0100 +@@ -80,8 +80,13 @@ + filebase = chunkbase + (8 * 2) + 4; // required size for two entries + poduleromsize = filebase + ((sizeof(description) + 3) & ~3u); // Word align description string + +- // Add on size for driver module if it can be opened successfully +- f = fopen("netroms/EtherRPCEm,ffa", "rb"); ++ char filename[512]; ++ snprintf(filename,sizeof(filename), "%snetroms/EtherRPCEm,ffa", rpcemu_get_datadir()); ++ ++ rpclog("network_rom_init: Attempting to load Ethernet ROM from '%s'\n", filename); ++ ++ // Add on size for driver module if it can be opened successfully ++ f = fopen(filename, "rb"); + if (f != NULL) { + long len; + +@@ -124,6 +129,8 @@ + if (len == module_file_size) { // Load was OK + len = (len + 3) & ~3u; + makechunk(0x81, filebase, (uint32_t) len); // 0x81 = RISC OS, ROM ++ ++ rpclog("network_rom_init: Successfuly loaded 'EtherRPCEm,ffa' into podulerom\n"); + } + } + } +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/preferences-macosx.h 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,38 @@ +///* +// RPCEmu - An Acorn system emulator @@ -1312,8 +1700,8 @@ to add macOS support. +#endif + +#endif // __PREFERENCES_MACOSX_H__ ---- /dev/null 2018-11-18 19:57:31.000000000 +0000 -+++ macosx/preferences-macosx.m 2018-11-04 16:47:58.000000000 +0000 +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/preferences-macosx.m 2020-05-07 21:05:20.000000000 +0100 @@ -0,0 +1,86 @@ +/* + RPCEmu - An Acorn system emulator @@ -1401,19 +1789,9 @@ to add macOS support. + + return [path UTF8String]; +} ---- rpc-machdep.c.orig 2018-11-02 19:15:19.000000000 +0000 -+++ rpc-machdep.c 2018-11-18 19:54:52.000000000 +0000 -@@ -19,6 +19,9 @@ - */ - - #include <string.h> -+#include <unistd.h> -+#include <stdlib.h> -+#include <pwd.h> - - #include "rpcemu.h" - -@@ -26,7 +29,39 @@ +--- original/rpc-machdep.c 2020-05-06 20:19:23.000000000 +0100 ++++ src/rpc-machdep.c 2020-05-07 21:05:20.000000000 +0100 +@@ -26,7 +26,39 @@ be, but currently this version is used by Linux, all the other autoconf based builds and Windows. Only Mac OS X GUI version needs to override */ @@ -1453,9 +1831,9 @@ to add macOS support. static char logpath[1024] = ""; /** ---- /dev/null 2018-11-18 19:54:25.000000000 +0000 -+++ rpc-macosx.c 2018-11-02 20:04:55.000000000 +0000 -@@ -0,0 +1,89 @@ +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/rpc-macosx.c 2020-05-07 21:05:20.000000000 +0100 +@@ -0,0 +1,87 @@ +/* + RPCEmu - An Acorn system emulator + @@ -1505,20 +1883,20 @@ to add macOS support. +int +path_disk_info(const char *path, disk_info *d) +{ -+ struct statvfs s; -+ int ret; ++ struct statvfs s; ++ int ret; + -+ assert(path != NULL); -+ assert(d != NULL); ++ assert(path != NULL); ++ assert(d != NULL); + -+ if ((ret = statvfs(path, &s)) != 0) { -+ return 0; -+ } ++ if ((ret = statvfs(path, &s)) != 0) { ++ return 0; ++ } + -+ d->size = (uint64_t) s.f_blocks * (uint64_t) s.f_frsize; -+ d->free = (uint64_t) s.f_bavail * (uint64_t) s.f_frsize; ++ d->size = (uint64_t) s.f_blocks * (uint64_t) s.f_frsize; ++ d->free = (uint64_t) s.f_bavail * (uint64_t) s.f_frsize; + -+ return 1; ++ return 1; +} + +/** @@ -1531,25 +1909,23 @@ to add macOS support. +void +rpcemu_log_os(void) +{ -+ struct utsname u; ++ struct utsname u; + -+ if (uname(&u) == -1) { -+ rpclog("OS: Could not determine: %s\n", strerror(errno)); -+ return; -+ } ++ if (uname(&u) == -1) { ++ rpclog("OS: Could not determine: %s\n", strerror(errno)); ++ return; ++ } + -+ rpclog("OS: SysName = %s\n", u.sysname); -+ rpclog("OS: Release = %s\n", u.release); -+ rpclog("OS: Version = %s\n", u.version); -+ rpclog("OS: Machine = %s\n", u.machine); ++ rpclog("OS: SysName = %s\n", u.sysname); ++ rpclog("OS: Release = %s\n", u.release); ++ rpclog("OS: Version = %s\n", u.version); ++ rpclog("OS: Machine = %s\n", u.machine); +} -+ -+ ---- qt5/rpc-qt5.cpp.orig 2018-11-02 19:15:19.000000000 +0000 -+++ qt5/rpc-qt5.cpp 2018-11-04 16:45:30.000000000 +0000 -@@ -45,6 +45,15 @@ - #include "ide.h" - #include "cdrom-iso.h" +--- original/qt5/rpc-qt5.cpp 2020-05-06 20:19:23.000000000 +0100 ++++ src/qt5/rpc-qt5.cpp 2020-05-08 14:36:13.000000000 +0100 +@@ -47,6 +47,15 @@ + #include "network.h" + #include "network-nat.h" +#if defined(Q_OS_MACOS) +#include "choose_dialog.h" @@ -1563,7 +1939,7 @@ to add macOS support. #if defined(Q_OS_WIN32) #include "cdrom-ioctl.h" -@@ -396,6 +405,23 @@ +@@ -398,6 +407,23 @@ } // extern "C" @@ -1575,10 +1951,10 @@ to add macOS support. + if (dialog.exec() == QDialog::Accepted) + { + const char *path = preferences_get_data_directory(); -+ ++ + return rpcemu_set_datadir(path); + } -+ ++ + return 0; +} + @@ -1587,72 +1963,67 @@ to add macOS support. /** * Program entry point * -@@ -415,6 +441,22 @@ +@@ -416,6 +442,20 @@ + // Add a program icon QApplication::setWindowIcon(QIcon(":/rpcemu_icon.png")); - ++ +#if defined(Q_OS_MACOS) -+ -+ init_preferences(); -+ -+ // If there is not a data directory in the application preferences, prompt for one. -+ // This will also prompt if the "Command" key is held down while the application loads. -+ if (promptForDataDirectory || (QApplication::queryKeyboardModifiers() & Qt::ControlModifier) != 0) -+ { -+ if (!rpcemu_choose_datadirectory()) ++ init_preferences(); ++ ++ // If there is not a data directory in the application preferences, prompt for one. ++ // This will also prompt if the "Command" key is held down while the application loads. ++ if (promptForDataDirectory || (QApplication::queryKeyboardModifiers() & Qt::ShiftModifier) != 0) + { -+ return(0); ++ if (!rpcemu_choose_datadirectory()) ++ { ++ return 0; ++ } + } -+ } -+ +#endif -+ + // start enough of the emulator system to allow // the GUI to initialise (e.g. load the config to init - // the configure window) -@@ -435,7 +477,12 @@ +@@ -438,6 +478,11 @@ QThread::connect(emulator, &Emulator::finished, emu_thread, &QThread::quit); QThread::connect(emulator, &Emulator::finished, emulator, &Emulator::deleteLater); QThread::connect(emu_thread, &QThread::finished, emu_thread, &QThread::deleteLater); -- -+ ++ +#if defined(Q_OS_MACOS) -+ // Initialise HID manager for Caps Lock key events. -+ init_hid_manager(); -+#endif /* Q_OS_MACOS */ -+ ++ // Initialise the HID manager for CAPS LOCK key events. ++ init_hid_manager(); ++#endif + // Create Main Window MainWindow main_window(*emulator); - pMainWin = &main_window; -@@ -470,6 +517,15 @@ +@@ -473,6 +518,14 @@ connect(this, &Emulator::key_release_signal, this, &Emulator::key_release); -+ ++ +#if defined(Q_OS_MACOS) -+ -+ // Modifier keys on a Mac must be handled separately, as there is no way of telling -+ // left or right from the key press and key release events due to a lack of scan codes. -+ connect(this, &Emulator::modifier_keys_changed_signal, this, &Emulator::modifier_keys_changed); -+ connect(this, &Emulator::modifier_keys_reset_signal, this, &Emulator::modifier_keys_reset); -+ ++ // Modifier keys on a Mac must be handled separately, as there is no way of telling ++ // left or right from the key press and key release events due to a lack of scan codes. ++ ++ connect(this, &Emulator::modifier_keys_changed_signal, this, &Emulator::modifier_keys_changed); ++ connect(this, &Emulator::modifier_keys_reset_signal, this, &Emulator::modifier_keys_reset); +#endif /* Q_OS_MACOS */ connect(this, &Emulator::mouse_move_signal, this, &Emulator::mouse_move); connect(this, &Emulator::mouse_move_relative_signal, this, &Emulator::mouse_move_relative); -@@ -615,6 +671,27 @@ +@@ -630,6 +683,27 @@ keyboard_key_release(scan_codes); } +#if defined(Q_OS_MACOS) -+ ++ +/** + * Modifier keys changed + * @param mask The modifier key mask from the original NSEvent + */ +void Emulator::modifier_keys_changed(unsigned mask) +{ -+ keyboard_handle_modifier_keys(mask); ++ keyboard_handle_modifier_keys(mask); +} + +/** @@ -1660,69 +2031,85 @@ to add macOS support. + */ +void Emulator::modifier_keys_reset() +{ -+ keyboard_reset_modifiers(true); ++ keyboard_reset_modifiers(true); +} -+ ++ +#endif /* Q_OS_MACOS */ + /** * Mouse has moved in absolute position (mousehack mode) * ---- qt5/rpc-qt5.h.orig 2018-11-02 19:15:19.000000000 +0000 -+++ qt5/rpc-qt5.h 2018-11-02 21:03:37.000000000 +0000 -@@ -49,7 +49,12 @@ +--- original/qt5/rpc-qt5.h 2020-05-06 20:19:23.000000000 +0100 ++++ src/qt5/rpc-qt5.h 2020-05-07 21:14:11.000000000 +0100 +@@ -49,6 +49,11 @@ void key_press_signal(unsigned scan_code); void key_release_signal(unsigned scan_code); -- -+ ++ +#if defined(Q_OS_MACOS) -+ void modifier_keys_changed_signal(unsigned mask); -+ void modifier_keys_reset_signal(); ++ void modifier_keys_changed_signal(unsigned mask); ++ void modifier_keys_reset_signal(); +#endif /* Q_OS_MACOS */ -+ + void mouse_move_signal(int x, int y); void mouse_move_relative_signal(int dx, int dy); - void mouse_press_signal(int buttons); -@@ -76,6 +81,11 @@ +@@ -78,6 +83,11 @@ void key_press(unsigned scan_code); void key_release(unsigned scan_code); -+ ++ +#if defined(Q_OS_MACOS) -+ void modifier_keys_changed(unsigned mask); -+ void modifier_keys_reset(); ++ void modifier_keys_changed(unsigned mask); ++ void modifier_keys_reset(); +#endif /* Q_OS_MACOS */ void mouse_move(int x, int y); void mouse_move_relative(int dx, int dy); ---- rpcemu.h.orig 2018-11-02 19:15:19.000000000 +0000 -+++ rpcemu.h 2018-11-04 16:46:58.000000000 +0000 -@@ -170,6 +170,11 @@ +--- original/rpcemu.h 2020-05-06 20:19:23.000000000 +0100 ++++ src/rpcemu.h 2020-05-07 21:14:11.000000000 +0100 +@@ -72,7 +72,7 @@ + /* Note that networking is currently supported on Mac OS X with the Cocoa GUI + version but not with the Allegro GUI. */ + #if defined __linux || defined __linux__ || defined WIN32 || defined _WIN32 || \ +- defined RPCEMU_COCOA_GUI ++ defined RPCEMU_COCOA_GUI || __APPLE__ + #define RPCEMU_NETWORKING + #endif + +@@ -169,6 +169,10 @@ + extern uint32_t inscount; + extern int cyccount; - /* These functions can optionally be overridden by a platform. If not - needed to be overridden, there is a generic version in rpc-machdep.c */ -+ +#ifdef __APPLE__ +extern int rpcemu_set_datadir(const char *path); +#endif + + /* These functions can optionally be overridden by a platform. If not + needed to be overridden, there is a generic version in rpc-machdep.c */ extern const char *rpcemu_get_datadir(void); - extern const char *rpcemu_get_log_path(void); - ---- ../../original/src/qt5/rpcemu.pro 2018-11-02 19:15:19.000000000 +0000 -+++ qt5/rpcemu.pro 2018-11-18 20:15:49.000000000 +0000 -@@ -6,6 +6,9 @@ +--- original/qt5/rpcemu.pro 2020-05-06 20:19:23.000000000 +0100 ++++ src/qt5/rpcemu.pro 2020-05-14 17:33:58.000000000 +0100 +@@ -6,6 +6,10 @@ QT += core widgets gui multimedia INCLUDEPATH += ../ +macx { -+ INCLUDEPATH += ../macosx ++ INCLUDEPATH += ../macosx +} ++ + # This ensures that using switch with enum requires every value to be handled + QMAKE_CFLAGS += -Werror=switch + QMAKE_CXXFLAGS += -Werror=switch +@@ -61,7 +65,7 @@ + plt_sound.cpp + + # NAT Networking +-linux | win32 { ++linux | win32 | macx { + HEADERS += ../network-nat.h + SOURCES += ../network-nat.c - HEADERS = ../superio.h \ - ../cdrom-iso.h \ -@@ -85,10 +88,31 @@ +@@ -141,10 +145,38 @@ network_dialog.h } @@ -1738,27 +2125,34 @@ to add macOS support. + } +} + -+macx -+{ -+ SOURCES += keyboard_macosx.c \ ++macx { ++ SOURCES += ../network.c \ ++ network_dialog.cpp \ ++ keyboard_macosx.c \ + ../hostfs-macosx.c \ + ../rpc-macosx.c \ + ../macosx/hid-macosx.m \ + ../macosx/events-macosx.m \ + ../macosx/preferences-macosx.m \ ++ ../macosx/network-macosx.c \ ++ ../macosx/system-macosx.m \ + choose_dialog.cpp + -+ HEADERS += keyboard_macosx.h \ ++ HEADERS += ../network.h \ ++ network_dialog.h \ ++ keyboard_macosx.h \ + ../macosx/hid-macosx.h \ + ../macosx/events-macosx.h \ + ../macosx/preferences-macosx.h \ ++ ../macosx/system-macosx.h \ + choose_dialog.h + + ICON = ../macosx/rpcemu.icns ++ } # Place exes in top level directory -@@ -133,4 +157,12 @@ +@@ -189,4 +221,13 @@ TARGET = $$join(TARGET, , , -debug) } @@ -1772,29 +2166,99 @@ to add macOS support. + + QMAKE_INFO_PLIST = ../macosx/Info.plist +} ---- qt5/settings.cpp.orig 2018-11-02 19:15:19.000000000 +0000 -+++ qt5/settings.cpp 2018-11-02 20:42:30.000000000 +0000 -@@ -41,8 +41,10 @@ - QByteArray ba; ++ +--- original/qt5/settings.cpp 2020-05-06 20:19:23.000000000 +0100 ++++ src/qt5/settings.cpp 2020-05-07 21:14:11.000000000 +0100 +@@ -42,7 +42,7 @@ snprintf(filename, sizeof(filename), "%srpc.cfg", rpcemu_get_datadir()); -+ -+ rpclog("Loading configuration from '%s'.\n", filename); - QSettings settings("rpc.cfg", QSettings::IniFormat); + QSettings settings(filename, QSettings::IniFormat); /* Copy the contents of the configfile to the log */ QStringList keys = settings.childKeys(); -@@ -188,8 +190,10 @@ - QString sText; +@@ -199,7 +199,7 @@ snprintf(filename, sizeof(filename), "%srpc.cfg", rpcemu_get_datadir()); -+ -+ rpclog("Saving configuration to '%s'.\n", filename); - QSettings settings("rpc.cfg", QSettings::IniFormat); + QSettings settings(filename, QSettings::IniFormat); char s[256]; +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/system-macosx.h 2020-05-07 21:05:20.000000000 +0100 +@@ -0,0 +1,34 @@ ++/* ++RPCEmu - An Acorn system emulator ++ ++Copyright (C) 2017 Peter Howkins ++ ++This program is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++ ++This program is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with this program; if not, write to the Free Software ++Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++*/ ++ ++#ifndef __SYSTEM_MACOSX_H__ ++#define __SYSTEM_MACOSX_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++extern unsigned int get_macosx_version(void); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +--- /dev/null 2020-05-14 17:35:51.000000000 +0100 ++++ src/macosx/system-macosx.m 2020-05-07 21:05:20.000000000 +0100 +@@ -0,0 +1,35 @@ ++/* ++RPCEmu - An Acorn system emulator ++ ++Copyright (C) 2017 Matthew Howkins ++ ++This program is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++ ++This program is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with this program; if not, write to the Free Software ++Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++*/ ++ ++#include <stddef.h> ++#include <stdint.h> ++ ++#include <Cocoa/Cocoa.h> ++#include <Carbon/Carbon.h> ++ ++unsigned int get_macosx_version(void) ++{ ++ NSOperatingSystemVersion version; ++ ++ version = [[NSProcessInfo processInfo] operatingSystemVersion]; ++ ++ return (version.majorVersion << 16) | (version.minorVersion << 8) | (version.patchVersion); ++} ++ |