Merge pull request #4227 from ligfx/clean_objc
Don't force compile everything as Objective-C++ on macOS
This commit is contained in:
commit
8fcc3b04e0
|
@ -984,15 +984,6 @@ add_definitions(-std=c++1y)
|
||||||
# but some dependencies require them (LLVM, libav).
|
# but some dependencies require them (LLVM, libav).
|
||||||
add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
|
add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
|
||||||
|
|
||||||
# Do this at the last minute because try_compile ignores linker flags. Yay...
|
|
||||||
if(APPLE)
|
|
||||||
# Some of our code contains Objective C constructs.
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++")
|
|
||||||
# Avoid mistaking an object file for a source file on the link command line.
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(Source)
|
add_subdirectory(Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ endif()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(SRCS ${SRCS} GL/GLInterface/WGL.cpp)
|
set(SRCS ${SRCS} GL/GLInterface/WGL.cpp)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(SRCS ${SRCS} GL/GLInterface/AGL.cpp)
|
set(SRCS ${SRCS} GL/GLInterface/AGL.mm)
|
||||||
elseif(USE_X11)
|
elseif(USE_X11)
|
||||||
if (NOT USE_EGL)
|
if (NOT USE_EGL)
|
||||||
set(SRCS ${SRCS} GL/GLInterface/GLX.cpp)
|
set(SRCS ${SRCS} GL/GLInterface/GLX.cpp)
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) && defined(__OBJC__)
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
#else
|
||||||
|
struct NSOpenGLContext;
|
||||||
|
struct NSView;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common/GL/GLInterfaceBase.h"
|
#include "Common/GL/GLInterfaceBase.h"
|
||||||
|
|
|
@ -5,76 +5,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Work around an Apple bug: for some reason, IOBluetooth.h errors on
|
|
||||||
// inclusion in Mavericks, but only in Objective-C++ C++11 mode. I filed
|
|
||||||
// this as <rdar://15312520>; in the meantime...
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#undef NS_ENUM_AVAILABLE
|
|
||||||
#define NS_ENUM_AVAILABLE(...)
|
|
||||||
// end hack
|
|
||||||
#import <IOBluetooth/IOBluetooth.h>
|
|
||||||
#include <IOKit/hid/IOHIDManager.h>
|
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
|
||||||
|
|
||||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||||
|
|
||||||
namespace WiimoteReal
|
namespace WiimoteReal
|
||||||
{
|
{
|
||||||
class WiimoteDarwin final : public Wiimote
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WiimoteDarwin(IOBluetoothDevice* device);
|
|
||||||
~WiimoteDarwin() override;
|
|
||||||
|
|
||||||
// These are not protected/private because ConnectBT needs them.
|
|
||||||
void DisconnectInternal() override;
|
|
||||||
IOBluetoothDevice* m_btd;
|
|
||||||
unsigned char* m_input;
|
|
||||||
int m_inputlen;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool ConnectInternal() override;
|
|
||||||
bool IsConnected() const override;
|
|
||||||
void IOWakeup() override;
|
|
||||||
int IORead(u8* buf) override;
|
|
||||||
int IOWrite(u8 const* buf, size_t len) override;
|
|
||||||
void EnablePowerAssertionInternal() override;
|
|
||||||
void DisablePowerAssertionInternal() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
IOBluetoothL2CAPChannel* m_ichan;
|
|
||||||
IOBluetoothL2CAPChannel* m_cchan;
|
|
||||||
bool m_connected;
|
|
||||||
CFRunLoopRef m_wiimote_thread_run_loop;
|
|
||||||
IOPMAssertionID m_pm_assertion;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WiimoteDarwinHid final : public Wiimote
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WiimoteDarwinHid(IOHIDDeviceRef device);
|
|
||||||
~WiimoteDarwinHid() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool ConnectInternal() override;
|
|
||||||
void DisconnectInternal() override;
|
|
||||||
bool IsConnected() const override;
|
|
||||||
void IOWakeup() override;
|
|
||||||
int IORead(u8* buf) override;
|
|
||||||
int IOWrite(u8 const* buf, size_t len) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void ReportCallback(void* context, IOReturn result, void* sender, IOHIDReportType type,
|
|
||||||
u32 reportID, u8* report, CFIndex reportLength);
|
|
||||||
static void RemoveCallback(void* context, IOReturn result, void* sender);
|
|
||||||
void QueueBufferReport(int length);
|
|
||||||
IOHIDDeviceRef m_device;
|
|
||||||
bool m_connected;
|
|
||||||
std::atomic<bool> m_interrupted;
|
|
||||||
Report m_report_buffer;
|
|
||||||
Common::FifoQueue<Report> m_buffered_reports;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WiimoteScannerDarwin final : public WiimoteScannerBackend
|
class WiimoteScannerDarwin final : public WiimoteScannerBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
||||||
|
#include "Core/HW/WiimoteReal/IOdarwin_private.h"
|
||||||
|
|
||||||
@interface SearchBT : NSObject
|
@interface SearchBT : NSObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
// Copyright 2016 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||||
|
|
||||||
|
// Work around an Apple bug: for some reason, IOBluetooth.h errors on
|
||||||
|
// inclusion in Mavericks, but only in Objective-C++ C++11 mode. I filed
|
||||||
|
// this as <rdar://15312520>; in the meantime...
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#undef NS_ENUM_AVAILABLE
|
||||||
|
#define NS_ENUM_AVAILABLE(...)
|
||||||
|
// end hack
|
||||||
|
#include <IOBluetooth/IOBluetooth.h>
|
||||||
|
#include <IOKit/hid/IOHIDManager.h>
|
||||||
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
|
|
||||||
|
namespace WiimoteReal
|
||||||
|
{
|
||||||
|
class WiimoteDarwin final : public Wiimote
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WiimoteDarwin(IOBluetoothDevice* device);
|
||||||
|
~WiimoteDarwin() override;
|
||||||
|
|
||||||
|
// These are not protected/private because ConnectBT needs them.
|
||||||
|
void DisconnectInternal() override;
|
||||||
|
IOBluetoothDevice* m_btd;
|
||||||
|
unsigned char* m_input;
|
||||||
|
int m_inputlen;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool ConnectInternal() override;
|
||||||
|
bool IsConnected() const override;
|
||||||
|
void IOWakeup() override;
|
||||||
|
int IORead(u8* buf) override;
|
||||||
|
int IOWrite(u8 const* buf, size_t len) override;
|
||||||
|
void EnablePowerAssertionInternal() override;
|
||||||
|
void DisablePowerAssertionInternal() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IOBluetoothL2CAPChannel* m_ichan;
|
||||||
|
IOBluetoothL2CAPChannel* m_cchan;
|
||||||
|
bool m_connected;
|
||||||
|
CFRunLoopRef m_wiimote_thread_run_loop;
|
||||||
|
IOPMAssertionID m_pm_assertion;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WiimoteDarwinHid final : public Wiimote
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WiimoteDarwinHid(IOHIDDeviceRef device);
|
||||||
|
~WiimoteDarwinHid() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool ConnectInternal() override;
|
||||||
|
void DisconnectInternal() override;
|
||||||
|
bool IsConnected() const override;
|
||||||
|
void IOWakeup() override;
|
||||||
|
int IORead(u8* buf) override;
|
||||||
|
int IOWrite(u8 const* buf, size_t len) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void ReportCallback(void* context, IOReturn result, void* sender, IOHIDReportType type,
|
||||||
|
u32 reportID, u8* report, CFIndex reportLength);
|
||||||
|
static void RemoveCallback(void* context, IOReturn result, void* sender);
|
||||||
|
void QueueBufferReport(int length);
|
||||||
|
IOHIDDeviceRef m_device;
|
||||||
|
bool m_connected;
|
||||||
|
std::atomic<bool> m_interrupted;
|
||||||
|
Report m_report_buffer;
|
||||||
|
Common::FifoQueue<Report> m_buffered_reports;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace WiimoteReal
|
|
@ -12,10 +12,6 @@
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#import <AppKit/AppKit.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "DolphinWX/AboutDolphin.h"
|
#include "DolphinWX/AboutDolphin.h"
|
||||||
#include "DolphinWX/WxUtils.h"
|
#include "DolphinWX/WxUtils.h"
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <Cocoa/Cocoa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -579,16 +575,6 @@ bool CFrame::RendererIsFullscreen()
|
||||||
fullscreen = m_RenderFrame->IsFullScreen();
|
fullscreen = m_RenderFrame->IsFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
if (m_RenderFrame != nullptr)
|
|
||||||
{
|
|
||||||
NSView* view = (NSView*)m_RenderFrame->GetHandle();
|
|
||||||
NSWindow* window = [view window];
|
|
||||||
|
|
||||||
fullscreen = (([window styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return fullscreen;
|
return fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,15 +1265,6 @@ void CFrame::DoFullscreen(bool enable_fullscreen)
|
||||||
|
|
||||||
ToggleDisplayMode(enable_fullscreen);
|
ToggleDisplayMode(enable_fullscreen);
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
NSView* view = (NSView*)m_RenderFrame->GetHandle();
|
|
||||||
NSWindow* window = [view window];
|
|
||||||
|
|
||||||
if (enable_fullscreen != RendererIsFullscreen())
|
|
||||||
{
|
|
||||||
[window toggleFullScreen:nil];
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (enable_fullscreen)
|
if (enable_fullscreen)
|
||||||
{
|
{
|
||||||
m_RenderFrame->ShowFullScreen(true, wxFULLSCREEN_ALL);
|
m_RenderFrame->ShowFullScreen(true, wxFULLSCREEN_ALL);
|
||||||
|
@ -1298,7 +1275,6 @@ void CFrame::DoFullscreen(bool enable_fullscreen)
|
||||||
// Therefore we don't exit fullscreen from here if we are in exclusive mode.
|
// Therefore we don't exit fullscreen from here if we are in exclusive mode.
|
||||||
m_RenderFrame->ShowFullScreen(false, wxFULLSCREEN_ALL);
|
m_RenderFrame->ShowFullScreen(false, wxFULLSCREEN_ALL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (SConfig::GetInstance().bRenderToMain)
|
if (SConfig::GetInstance().bRenderToMain)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,10 +21,6 @@
|
||||||
#include <wx/toolbar.h>
|
#include <wx/toolbar.h>
|
||||||
#include <wx/toplevel.h>
|
#include <wx/toplevel.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <AppKit/AppKit.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Common/CDUtils.h"
|
#include "Common/CDUtils.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/FileSearch.h"
|
#include "Common/FileSearch.h"
|
||||||
|
@ -1022,10 +1018,7 @@ void CFrame::StartGame(const std::string& filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
NSView* view = (NSView*)m_RenderFrame->GetHandle();
|
m_RenderFrame->EnableFullScreenView(true);
|
||||||
NSWindow* window = [view window];
|
|
||||||
|
|
||||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
@ -1241,10 +1234,7 @@ void CFrame::OnStopped()
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// Disable the full screen button when not in a game.
|
// Disable the full screen button when not in a game.
|
||||||
NSView* view = (NSView*)m_RenderFrame->GetHandle();
|
m_RenderFrame->EnableFullScreenView(false);
|
||||||
NSWindow* window = [view window];
|
|
||||||
|
|
||||||
[window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make sure the window is not longer set to stay on top
|
// Make sure the window is not longer set to stay on top
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -1235,9 +1231,9 @@ bool CISOProperties::SaveGameConfig()
|
||||||
void CISOProperties::LaunchExternalEditor(const std::string& filename, bool wait_until_closed)
|
void CISOProperties::LaunchExternalEditor(const std::string& filename, bool wait_until_closed)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// wxTheMimeTypesManager is not yet implemented for wxCocoa
|
// GetOpenCommand does not work for wxCocoa
|
||||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:filename.c_str()]
|
const char* OpenCommandConst[] = {"open", "-a", "TextEdit", filename.c_str(), NULL};
|
||||||
withApplication:@"TextEdit"];
|
char** OpenCommand = const_cast<char**>(OpenCommandConst);
|
||||||
#else
|
#else
|
||||||
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("ini");
|
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("ini");
|
||||||
if (filetype == nullptr) // From extension failed, trying with MIME type now
|
if (filetype == nullptr) // From extension failed, trying with MIME type now
|
||||||
|
@ -1256,6 +1252,7 @@ void CISOProperties::LaunchExternalEditor(const std::string& filename, bool wait
|
||||||
WxUtils::ShowErrorDialog(_("Couldn't find open command for extension 'ini'!"));
|
WxUtils::ShowErrorDialog(_("Couldn't find open command for extension 'ini'!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
long result;
|
long result;
|
||||||
|
|
||||||
|
@ -1269,7 +1266,6 @@ void CISOProperties::LaunchExternalEditor(const std::string& filename, bool wait
|
||||||
WxUtils::ShowErrorDialog(_("wxExecute returned -1 on application run!"));
|
WxUtils::ShowErrorDialog(_("wxExecute returned -1 on application run!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CISOProperties::GenerateLocalIniModified()
|
void CISOProperties::GenerateLocalIniModified()
|
||||||
|
|
|
@ -70,10 +70,6 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#import <AppKit/AppKit.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class wxFrame;
|
class wxFrame;
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
|
|
|
@ -17,10 +17,6 @@
|
||||||
|
|
||||||
#include "DolphinWX/WxUtils.h"
|
#include "DolphinWX/WxUtils.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#import <AppKit/AppKit.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace WxUtils
|
namespace WxUtils
|
||||||
{
|
{
|
||||||
// Launch a file according to its mime type
|
// Launch a file according to its mime type
|
||||||
|
|
Loading…
Reference in New Issue