Fix macOS builds
This commit is contained in:
@@ -17,7 +17,7 @@ add_library(ui STATIC
|
||||
qt_mainwindow.ui
|
||||
qt_machinestatus.cpp
|
||||
qt_machinestatus.hpp
|
||||
qt_machinestatus.ui
|
||||
#qt_machinestatus.ui
|
||||
qt_gleswidget.cpp
|
||||
qt_gleswidget.hpp
|
||||
|
||||
|
@@ -7,4 +7,4 @@ public:
|
||||
CocoaEventFilter() {};
|
||||
~CocoaEventFilter();
|
||||
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
|
||||
};
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <SDL.h>
|
||||
#include "86box/plat.h"
|
||||
//#include "86box/plat.h"
|
||||
#include "cocoa_mouse.hpp"
|
||||
#import <AppKit/AppKit.h>
|
||||
extern "C"
|
||||
@@ -15,6 +15,7 @@ extern "C"
|
||||
#include <86box/ui.h>
|
||||
#include <86box/video.h>
|
||||
extern int mouse_capture;
|
||||
extern void plat_mouse_capture(int);
|
||||
}
|
||||
|
||||
typedef struct mouseinputdata
|
||||
@@ -23,8 +24,7 @@ typedef struct mouseinputdata
|
||||
int mousebuttons;
|
||||
} mouseinputdata;
|
||||
|
||||
extern SDL_mutex* mousemutex;
|
||||
extern mouseinputdata mousedata;
|
||||
static mouseinputdata mousedata;
|
||||
|
||||
CocoaEventFilter::~CocoaEventFilter()
|
||||
{
|
||||
@@ -40,17 +40,13 @@ bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
NSEvent* event = (NSEvent*)message;
|
||||
if ([event type] == NSEventTypeMouseMoved)
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.deltax += [event deltaX];
|
||||
mousedata.deltay += [event deltaY];
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
return true;
|
||||
}
|
||||
if ([event type] == NSEventTypeScrollWheel)
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.deltaz += [event deltaY];
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
return true;
|
||||
}
|
||||
switch ([event type])
|
||||
@@ -58,45 +54,33 @@ bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
default: return false;
|
||||
case NSEventTypeLeftMouseDown:
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.mousebuttons |= 1;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeLeftMouseUp:
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.mousebuttons &= ~1;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeRightMouseDown:
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.mousebuttons |= 2;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeRightMouseUp:
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.mousebuttons &= ~2;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeOtherMouseDown:
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.mousebuttons |= 4;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeOtherMouseUp:
|
||||
{
|
||||
if (mouse_get_buttons() < 3) { plat_mouse_capture(0); return true; }
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.mousebuttons &= ~4;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -105,3 +89,12 @@ bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" void macos_poll_mouse()
|
||||
{
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ extern "C"
|
||||
#include <86box/video.h>
|
||||
}
|
||||
|
||||
|
||||
extern "C" void macos_poll_mouse();
|
||||
void
|
||||
qt_mouse_capture(int on)
|
||||
{
|
||||
@@ -34,11 +34,15 @@ qt_mouse_capture(int on)
|
||||
|
||||
void GLESWidget::qt_mouse_poll()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return macos_poll_mouse();
|
||||
#else
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLESWidget::resizeGL(int w, int h)
|
||||
|
@@ -29,6 +29,8 @@ extern uint64_t tsc;
|
||||
#include <QTimer>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace {
|
||||
struct PixmapSetActive {
|
||||
QPixmap normal;
|
||||
|
@@ -283,10 +283,10 @@ plat_mmap(size_t size, uint8_t executable)
|
||||
void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE | (executable ? MAP_JIT : 0), 0, 0);
|
||||
#else
|
||||
void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE, 0, 0);
|
||||
#endif
|
||||
auto retval = *reinterpret_cast<int*>(ret);
|
||||
return (retval < 0) ? nullptr : ret;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user