Replace deprecated macOS APIs with modern equivalents
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
/* http://www.cocoadev.com/index.pl?MacintoshModels */
|
||||
{
|
||||
"ADP2,1" = "Developer Transition Kit";
|
||||
"iMac,1" = iMac;
|
||||
"iMac4,1" = "iMac (Core Duo)";
|
||||
"iMac5,1" = "iMac (Core 2 Duo)";
|
||||
"iMac6,1" = "iMac (24-inch Core 2 Duo)";
|
||||
"iMac7,1" = "iMac (Aluminum Core 2 Duo)";
|
||||
"iMac8,1" = "iMac (Aluminum Core 2 Duo)";
|
||||
"M43ADP1,1" = "Development Mac Pro";
|
||||
"MacBook1,1" = "MacBook (Core Duo)";
|
||||
"MacBook2,1" = "MacBook (Core 2 Duo)";
|
||||
"MacBook3,1" = "MacBook (Core 2 Duo)";
|
||||
"MacBook4,1" = "MacBook (Early 2008)";
|
||||
"MacBookAir1,1" = "MacBook Air";
|
||||
"MacBookPro1,1" = "MacBook Pro (15-inch Core Duo)";
|
||||
"MacBookPro1,2" = "MacBook Pro (17-inch Core Duo)";
|
||||
"MacBookPro2,1" = "MacBook Pro (17-inch Core 2 Duo)";
|
||||
"MacBookPro2,2" = "MacBook Pro (15-inch Core 2 Duo)";
|
||||
"MacBookPro3,1" = "MacBook Pro (15-inch or 17-inch LED, Core 2 Duo)";
|
||||
"MacBookPro4,1" = "MacBook Pro (15-inch or 17-inch LED, Early 2008)";
|
||||
"MacBookPro5,1" = "MacBook Pro (15-inch LED Unibody, Late 2008)";
|
||||
"Macmini1,1" = "Mac mini (Core Duo/Solo)";
|
||||
"MacPro1,1" = "Mac Pro (Quad Xeon)";
|
||||
"MacPro2,1" = "Mac Pro (Octal Xeon)";
|
||||
"MacPro3,1" = "Mac Pro (Early 2008)";
|
||||
"PowerBook1,1" = "PowerBook G3";
|
||||
"PowerBook2,1" = iBook;
|
||||
"PowerBook2,2" = "iBook (FireWire)";
|
||||
"PowerBook3,1" = "PowerBook G3 (FireWire)";
|
||||
"PowerBook3,2" = "PowerBook G4";
|
||||
"PowerBook3,3" = "PowerBook G4 (Gigabit Ethernet)";
|
||||
"PowerBook3,4" = "PowerBook G4 (DVI)";
|
||||
"PowerBook3,5" = "PowerBook G4 (867, 1 GHz)";
|
||||
"PowerBook4,1" = "iBook G3";
|
||||
"PowerBook4,2" = "iBook G3";
|
||||
"PowerBook4,3" = "iBook G3";
|
||||
"PowerBook5,1" = "PowerBook G4 (17-inch)";
|
||||
"PowerBook5,2" = "PowerBook G4 (15-inch FW800)";
|
||||
"PowerBook5,3" = "PowerBook G4 (17-inch 1.33 GHz)";
|
||||
"PowerBook5,4" = "PowerBook G4 (15-inch 1.5/1.33 GHz)";
|
||||
"PowerBook5,5" = "PowerBook G4 (17-inch 1.5 GHz)";
|
||||
"PowerBook5,6" = "PowerBook G4 (15-inch 1.67/1.5 GHz)";
|
||||
"PowerBook5,7" = "PowerBook G4 (17-inch 1.67 GHz)";
|
||||
"PowerBook5,8" = "PowerBook G4 (Double-Layer SD, 15-inch)";
|
||||
"PowerBook5,9" = "PowerBook G4 (Double-Layer SD, 17-inch)";
|
||||
"PowerBook6,1" = "PowerBook G4 (12-inch)";
|
||||
"PowerBook6,2" = "PowerBook G4 (12-inch DVI)";
|
||||
"PowerBook6,3" = "iBook G4";
|
||||
"PowerBook6,4" = "PowerBook G4 (12-inch 1.33 GHz)";
|
||||
"PowerBook6,5" = "iBook G4";
|
||||
"PowerBook6,7" = "iBook G4";
|
||||
"PowerBook6,8" = "PowerBook G4 (12-inch 1.5 GHz)";
|
||||
"PowerMac1,1" = "Power Macintosh G3 (B&W)";
|
||||
"PowerMac1,2" = "Power Macintosh G4 (PCI-Graphics)";
|
||||
"PowerMac10,1" = "Mac mini";
|
||||
"PowerMac10,2" = "Mac mini";
|
||||
"PowerMac11,2" = "Power Macintosh G5 (PCIe)";
|
||||
"PowerMac12,1" = "iMac G5 (iSight)";
|
||||
"PowerMac2,1" = "iMac (Slot-Loading)";
|
||||
"PowerMac2,2" = "iMac (2000)";
|
||||
"PowerMac3,1" = "Power Macintosh G4 (AGP-Graphics)";
|
||||
"PowerMac3,2" = "Power Macintosh G4 (AGP-Graphics)";
|
||||
"PowerMac3,3" = "Power Macintosh G4 (Gigabit Ethernet)";
|
||||
"PowerMac3,4" = "Power Macintosh G4 (Digital Audio)";
|
||||
"PowerMac3,5" = "Power Macintosh G4 (Quick Silver)";
|
||||
"PowerMac3,6" = "Power Macintosh G4 (Mirrored Drive Doors)";
|
||||
"PowerMac4,1" = "iMac (2001)";
|
||||
"PowerMac4,2" = "iMac (Flat Panel)";
|
||||
"PowerMac4,4" = "eMac G3";
|
||||
"PowerMac4,5" = "iMac (17-inch Flat Panel)";
|
||||
"PowerMac5,1" = "Power Macintosh G4 Cube";
|
||||
"PowerMac6,1" = "iMac (USB 2.0)";
|
||||
"PowerMac6,3" = "iMac (20-inch Flat Panel)";
|
||||
"PowerMac6,4" = "eMac (USB 2.0)";
|
||||
"PowerMac7,2" = "Power Macintosh G5";
|
||||
"PowerMac7,3" = "Power Macintosh G5";
|
||||
"PowerMac8,1" = "iMac G5";
|
||||
"PowerMac8,2" = "iMac G5 (Ambient Light Sensor)";
|
||||
"PowerMac9,1" = "Power Macintosh G5 (Late 2004)";
|
||||
"RackMac1,1" = "Xserve G4";
|
||||
"RackMac1,2" = "Xserve G4 (Slot-Loading)";
|
||||
"RackMac3,1" = "Xserve G5";
|
||||
"Xserve1,1" = "Xserve Xeon";
|
||||
"Xserve2,1" = "Xserve Xeon";
|
||||
}
|
||||
Binary file not shown.
@@ -44,7 +44,7 @@ if(WIN32)
|
||||
"arch/Sound/RageSoundDriver_WaveOut.h"
|
||||
"arch/Sound/RageSoundDriver_WDMKS.h")
|
||||
elseif(APPLE)
|
||||
list(APPEND SMDATA_ARCH_SOUND_SRC "arch/Sound/RageSoundDriver_AU.cpp")
|
||||
list(APPEND SMDATA_ARCH_SOUND_SRC "arch/Sound/RageSoundDriver_AU.mm")
|
||||
list(APPEND SMDATA_ARCH_SOUND_HPP "arch/Sound/RageSoundDriver_AU.h")
|
||||
else() # Unix
|
||||
if(HAS_PULSE)
|
||||
@@ -273,7 +273,7 @@ if(WIN32)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
list(APPEND SMDATA_ARCH_INPUT_SRC
|
||||
"arch/InputHandler/InputHandler_MacOSX_HID.cpp")
|
||||
"arch/InputHandler/InputHandler_MacOSX_HID.mm")
|
||||
list(APPEND SMDATA_ARCH_INPUT_HPP
|
||||
"arch/InputHandler/InputHandler_MacOSX_HID.h")
|
||||
else() # Unix/Linux
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
if(APPLE)
|
||||
list(APPEND SMDATA_OS_DARWIN_SRC
|
||||
"archutils/Darwin/Crash.cpp"
|
||||
"archutils/Darwin/Crash.mm"
|
||||
"archutils/Darwin/DarwinThreadHelpers.cpp"
|
||||
"archutils/Darwin/HIDDevice.cpp"
|
||||
"archutils/Darwin/JoystickDevice.cpp"
|
||||
@@ -8,7 +8,7 @@ if(APPLE)
|
||||
"archutils/Darwin/MouseDevice.cpp"
|
||||
"archutils/Darwin/PumpDevice.cpp"
|
||||
"archutils/Darwin/SMMain.mm"
|
||||
"archutils/Darwin/SpecialDirs.cpp"
|
||||
"archutils/Darwin/SpecialDirs.mm"
|
||||
"archutils/Darwin/VectorHelper.cpp")
|
||||
list(APPEND SMDATA_OS_DARWIN_HPP
|
||||
"archutils/Darwin/arch_setup.h"
|
||||
|
||||
@@ -230,9 +230,6 @@ elseif(APPLE)
|
||||
"$<TARGET_FILE_DIR:ITGmania>/../Resources"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${SM_XCODE_DIR}/logo.icns"
|
||||
"$<TARGET_FILE_DIR:ITGmania>/../Resources/"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${SM_XCODE_DIR}/Hardware.plist"
|
||||
"$<TARGET_FILE_DIR:ITGmania>/../Resources/")
|
||||
else() # Linux
|
||||
set_target_properties("${SM_EXE_NAME}"
|
||||
|
||||
@@ -20,6 +20,7 @@ extern "C" {
|
||||
#include <IOKit/network/IONetworkInterface.h>
|
||||
#include <IOKit/network/IOEthernetController.h>
|
||||
|
||||
#import <AppKit/NSScreen.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static bool IsFatalSignal( int signal )
|
||||
@@ -146,7 +147,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
{
|
||||
// http://stackoverflow.com/a/891336
|
||||
NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
|
||||
NSString *productVersion = [version objectForKey:@"ProductVersion"];
|
||||
NSString *productVersion = version[@"ProductVersion"];
|
||||
SystemVersion = ssprintf("macOS %s", [productVersion cStringUsingEncoding:[NSString defaultCStringEncoding]]);
|
||||
}
|
||||
|
||||
@@ -158,16 +159,9 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
{
|
||||
uint64_t iRam = 0;
|
||||
GET_PARAM( "hw.memsize", iRam );
|
||||
if( iRam >= 1073741824 )
|
||||
{
|
||||
fRam = float( double(iRam) / 1073741824.0 );
|
||||
ramPower = 'G';
|
||||
}
|
||||
else
|
||||
{
|
||||
fRam = float( double(iRam) / 1048576.0 );
|
||||
ramPower = 'M';
|
||||
}
|
||||
|
||||
fRam = float( double(iRam) / 1073741824.0 );
|
||||
ramPower = 'G';
|
||||
}
|
||||
|
||||
// Get processor information
|
||||
@@ -175,7 +169,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
int iCPUs = 0;
|
||||
float fFreq;
|
||||
char freqPower;
|
||||
RString sModel;
|
||||
RString sModel("Unknown");
|
||||
do {
|
||||
char szModel[128];
|
||||
uint64_t iFreq;
|
||||
@@ -184,49 +178,23 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
GET_PARAM( "hw.logicalcpu", iCPUs );
|
||||
GET_PARAM( "hw.cpufrequency", iFreq );
|
||||
|
||||
if( iFreq >= 1000000000 )
|
||||
{
|
||||
fFreq = float( double(iFreq) / 1000000000.0 );
|
||||
freqPower = 'G';
|
||||
}
|
||||
else
|
||||
{
|
||||
fFreq = float( double(iFreq) / 1000000.0 );
|
||||
freqPower = 'M';
|
||||
}
|
||||
fFreq = float( double(iFreq) / 1000000000.0 );
|
||||
freqPower = 'G';
|
||||
|
||||
if( GET_PARAM("hw.model", szModel) )
|
||||
{
|
||||
sModel = "Unknown";
|
||||
if( GET_PARAM("hw.model", szModel) != 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
sModel = szModel;
|
||||
CFURLRef urlRef = CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR("Hardware.plist"), nil, nil);
|
||||
|
||||
if( urlRef == nil)
|
||||
NSURL* url = [NSURL fileURLWithPath:@"//System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/en.lproj/SIMachineAttributes.plist"];
|
||||
NSDictionary* machineAttributes = [NSDictionary dictionaryWithContentsOfURL:url];
|
||||
if (machineAttributes == nil)
|
||||
break;
|
||||
CFDataRef dataRef = nil;
|
||||
SInt32 error;
|
||||
CFURLCreateDataAndPropertiesFromResource( nil, urlRef, &dataRef, nil, nil, &error );
|
||||
CFRelease( urlRef );
|
||||
if( dataRef == nil)
|
||||
break;
|
||||
// This also works with binary property lists for some reason.
|
||||
CFPropertyListRef plRef = CFPropertyListCreateFromXMLData( nil, dataRef, kCFPropertyListImmutable, nil);
|
||||
CFRelease( dataRef );
|
||||
if( plRef == nil)
|
||||
break;
|
||||
if( CFGetTypeID(plRef) != CFDictionaryGetTypeID() )
|
||||
{
|
||||
CFRelease( plRef );
|
||||
break;
|
||||
}
|
||||
CFStringRef keyRef = CFStringCreateWithCStringNoCopy( nil, szModel, kCFStringEncodingMacRoman, kCFAllocatorNull );
|
||||
CFStringRef modelRef = (CFStringRef)CFDictionaryGetValue( (CFDictionaryRef)plRef, keyRef );
|
||||
if( modelRef )
|
||||
sModel = CFStringGetCStringPtr( modelRef, kCFStringEncodingMacRoman );
|
||||
CFRelease( keyRef );
|
||||
CFRelease( plRef );
|
||||
|
||||
NSString* key = [NSString stringWithUTF8String:szModel];
|
||||
NSString* val = machineAttributes[key][@"_LOCALIZABLE_"][@"marketingModel"];
|
||||
if (val != nil)
|
||||
sModel = [val UTF8String];
|
||||
} while( false );
|
||||
#undef GET_PARAM
|
||||
|
||||
@@ -303,16 +271,6 @@ int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
|
||||
#include "RageFileManager.h"
|
||||
|
||||
static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
|
||||
{
|
||||
FSRef fs;
|
||||
|
||||
if( FSFindFolder(kUserDomain, folderType, kDontCreateFolder, &fs) )
|
||||
FAIL_M( ssprintf("FSFindFolder(%lu) failed.", folderType) );
|
||||
if( FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
|
||||
FAIL_M( "FSRefMakePath() failed." );
|
||||
}
|
||||
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
FILEMAN->Mount("dirro", sDirOfExecutable, "/");
|
||||
@@ -374,41 +332,48 @@ void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
}
|
||||
}
|
||||
|
||||
static std::string PathForDirectory( NSSearchPathDirectory directory )
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSURL *url = [fileManager URLForDirectory:directory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
if (url == nil)
|
||||
FAIL_M( "URLForDirectory() failed." );
|
||||
|
||||
return [url fileSystemRepresentation];
|
||||
}
|
||||
|
||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
char dir[PATH_MAX];
|
||||
|
||||
// /Save -> ~/Library/Preferences/PRODUCT_ID
|
||||
PathForFolderType( dir, kPreferencesFolderType );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID, dir), "/Save" );
|
||||
std::string libraryDir = PathForDirectory(NSLibraryDirectory);
|
||||
FILEMAN->Mount( "dir", libraryDir + "/Preferences/" PRODUCT_ID, "/Save" );
|
||||
|
||||
// Other stuff -> ~/Library/Application Support/PRODUCT_ID/*
|
||||
PathForFolderType( dir, kApplicationSupportFolderType );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Announcers", dir), "/Announcers" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/BGAnimations", dir), "/BGAnimations" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/BackgroundEffects", dir), "/BackgroundEffects" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/BackgroundTransitions", dir), "/BackgroundTransitions" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/CDTitles", dir), "/CDTitles" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Characters", dir), "/Characters" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Courses", dir), "/Courses" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Downloads", dir), "/Downloads" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/NoteSkins", dir), "/NoteSkins" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Packages", dir), "/Packages" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Songs", dir), "/Songs" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/RandomMovies", dir), "/RandomMovies" );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID "/Themes", dir), "/Themes" );
|
||||
std::string appSupportDir = PathForDirectory(NSApplicationSupportDirectory);
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Announcers", "/Announcers" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/BGAnimations", "/BGAnimations" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/BackgroundEffects", "/BackgroundEffects" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/BackgroundTransitions", "/BackgroundTransitions" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/CDTitles", "/CDTitles" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Characters", "/Characters" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Courses", "/Courses" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Downloads", "/Downloads" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/NoteSkins", "/NoteSkins" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Packages", "/Packages" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Songs", "/Songs" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/RandomMovies", "/RandomMovies" );
|
||||
FILEMAN->Mount( "dir", appSupportDir + "/" PRODUCT_ID "/Themes", "/Themes" );
|
||||
|
||||
// /Screenshots -> ~/Pictures/PRODUCT_ID Screenshots
|
||||
PathForFolderType( dir, kPictureDocumentsFolderType );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID " Screenshots", dir), "/Screenshots" );
|
||||
std::string picturesDir = PathForDirectory(NSCachesDirectory);
|
||||
FILEMAN->Mount( "dir", picturesDir + "/" PRODUCT_ID " Screenshots", "/Screenshots" );
|
||||
|
||||
// /Cache -> ~/Library/Caches/PRODUCT_ID
|
||||
PathForFolderType( dir, kCachedDataFolderType );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/" PRODUCT_ID, dir), "/Cache" );
|
||||
std::string cachesDir = PathForDirectory(NSCachesDirectory);
|
||||
FILEMAN->Mount( "dir", cachesDir + "/" PRODUCT_ID, "/Cache" );
|
||||
|
||||
// /Logs -> ~/Library/Logs/PRODUCT_ID
|
||||
PathForFolderType( dir, kDomainLibraryFolderType );
|
||||
FILEMAN->Mount( "dir", ssprintf("%s/Logs/" PRODUCT_ID, dir), "/Logs" );
|
||||
FILEMAN->Mount( "dir", libraryDir + "/Logs/" PRODUCT_ID, "/Logs" );
|
||||
}
|
||||
|
||||
static inline int GetIntValue( CFTypeRef r )
|
||||
@@ -423,16 +388,8 @@ static inline int GetIntValue( CFTypeRef r )
|
||||
|
||||
float ArchHooks_MacOSX::GetDisplayAspectRatio()
|
||||
{
|
||||
io_connect_t displayPort = CGDisplayIOServicePort( CGMainDisplayID() );
|
||||
CFDictionaryRef dict = IODisplayCreateInfoDictionary( displayPort, 0 );
|
||||
int width = GetIntValue( CFDictionaryGetValue(dict, CFSTR(kDisplayHorizontalImageSize)) );
|
||||
int height = GetIntValue( CFDictionaryGetValue(dict, CFSTR(kDisplayVerticalImageSize)) );
|
||||
|
||||
CFRelease( dict );
|
||||
|
||||
if( width && height )
|
||||
return float(width)/height;
|
||||
return 4/3.f;
|
||||
NSScreen *screen = [NSScreen mainScreen];
|
||||
return screen.frame.size.width / screen.frame.size.height;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+6
-7
@@ -17,14 +17,13 @@ REGISTER_INPUT_HANDLER_CLASS2( HID, MacOSX_HID );
|
||||
void InputHandler_MacOSX_HID::QueueCallback( void *target, int result, void *refcon, void *sender )
|
||||
{
|
||||
// The result seems useless as you can't actually return anything...
|
||||
// refcon is the Device number
|
||||
|
||||
RageTimer now;
|
||||
InputHandler_MacOSX_HID *This = (InputHandler_MacOSX_HID *)target;
|
||||
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)sender;
|
||||
IOHIDEventStruct event;
|
||||
AbsoluteTime zeroTime = { 0, 0 };
|
||||
HIDDevice *dev = This->m_vDevices[size_t( refcon )];
|
||||
HIDDevice *dev = static_cast<HIDDevice*>(refcon);
|
||||
vector<DeviceInput> vPresses;
|
||||
|
||||
while( (result = CALL(queue, getNextEvent, &event, zeroTime, 0)) == kIOReturnSuccess )
|
||||
@@ -116,11 +115,9 @@ void InputHandler_MacOSX_HID::DeviceChanged( void *refCon, io_service_t service,
|
||||
// m_LoopRef needs to be set before this is called
|
||||
void InputHandler_MacOSX_HID::StartDevices()
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
ASSERT( m_LoopRef );
|
||||
for (HIDDevice *i : m_vDevices)
|
||||
i->StartQueue( m_LoopRef, InputHandler_MacOSX_HID::QueueCallback, this, n++ );
|
||||
i->StartQueue( m_LoopRef, InputHandler_MacOSX_HID::QueueCallback, this );
|
||||
|
||||
CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource( m_NotifyPort );
|
||||
|
||||
@@ -397,8 +394,10 @@ static wchar_t KeyCodeToChar(CGKeyCode keyCode, unsigned int modifierFlags)
|
||||
|
||||
if( status != noErr )
|
||||
{
|
||||
fprintf(stderr, "There was an %s error translating from the '%d' key code to a human readable string: %s\n",
|
||||
GetMacOSStatusErrorString(status), (int)status, GetMacOSStatusCommentString(status));
|
||||
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||
const char* errorDescription = [error.localizedDescription UTF8String];
|
||||
fprintf(stderr, "There was an error translating from the '%d' key code to a human readable string: %s\n",
|
||||
keyCode, errorDescription);
|
||||
}
|
||||
else if( actualStringLength == 0 )
|
||||
{
|
||||
@@ -52,7 +52,7 @@
|
||||
[m_Text setSelectable:NO];
|
||||
[m_Text setDrawsBackground:NO];
|
||||
[m_Text setBackgroundColor:[NSColor lightGrayColor]];
|
||||
[m_Text setAlignment:NSCenterTextAlignment];
|
||||
[m_Text setAlignment:NSTextAlignmentCenter];
|
||||
[m_Text setHorizontallyResizable:NO];
|
||||
[m_Text setVerticallyResizable:NO];
|
||||
[m_Text setString:@"Initializing Hardware..."];
|
||||
@@ -64,17 +64,15 @@
|
||||
|
||||
windowRect = NSMakeRect( 0, 0, size.width, size.height + height + progressHeight + padding);
|
||||
m_Window = [[NSWindow alloc] initWithContentRect:windowRect
|
||||
styleMask:NSTitledWindowMask
|
||||
styleMask:NSWindowStyleMaskTitled
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
|
||||
NSView *view = [m_Window contentView];
|
||||
|
||||
// Set some properties.
|
||||
[m_Window setOneShot:YES];
|
||||
[m_Window setReleasedWhenClosed:YES];
|
||||
[m_Window setExcludedFromWindowsMenu:YES];
|
||||
[m_Window useOptimizedDrawing:YES];
|
||||
[m_Window setTitle:@PRODUCT_FAMILY];
|
||||
[m_Window center];
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ extern "C" {
|
||||
}
|
||||
|
||||
|
||||
static const unsigned int g_iStyleMask = NSTitledWindowMask | NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask | NSResizableWindowMask;
|
||||
static const unsigned int g_iStyleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
||||
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
|
||||
static bool g_bResized;
|
||||
static int g_iWidth;
|
||||
static int g_iHeight;
|
||||
@@ -94,7 +94,6 @@ public:
|
||||
defer:YES];
|
||||
|
||||
[m_Window setExcludedFromWindowsMenu:YES];
|
||||
[m_Window useOptimizedDrawing:YES];
|
||||
[m_Window setReleasedWhenClosed:NO];
|
||||
[m_Window setDelegate:static_cast<id<NSWindowDelegate> >(self)];
|
||||
}
|
||||
|
||||
@@ -16,28 +16,10 @@ static const UInt32 kBytesPerPacket = kChannelsPerFrame * kBitsPerChannel / 8;
|
||||
static const UInt32 kBytesPerFrame = kBytesPerPacket;
|
||||
static const UInt32 kFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsFloat;
|
||||
|
||||
#define WERROR(str, num, extra...) str ": '%s' (%lu).", ## extra, FourCCToString(num).c_str(), (num)
|
||||
#define ERROR(str, num, extra...) (ssprintf(WERROR(str, (num), ## extra)))
|
||||
|
||||
static inline RString FourCCToString( uint32_t num )
|
||||
static const char *FormatOSError(OSStatus status)
|
||||
{
|
||||
RString s( 4, '?' );
|
||||
char c;
|
||||
|
||||
c = (num >> 24) & 0xFF;
|
||||
if( c >='\x20' && c <= '\x7e' )
|
||||
s[0] = c;
|
||||
c = (num >> 16) & 0xFF;
|
||||
if( c >='\x20' && c <= '\x7e' )
|
||||
s[1] = c;
|
||||
c = (num >> 8) & 0xFF;
|
||||
if( c >='\x20' && c <= '\x7e' )
|
||||
s[2] = c;
|
||||
c = num & 0xFF;
|
||||
if( c >= '\x20' && c <= '\x7e' )
|
||||
s[3] = c;
|
||||
|
||||
return s;
|
||||
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||
return [error.localizedDescription UTF8String];
|
||||
}
|
||||
|
||||
RageSoundDriver_AU::RageSoundDriver_AU() : m_OutputUnit(nullptr), m_iSampleRate(0), m_bDone(false), m_bStarted(false),
|
||||
@@ -54,7 +36,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
if( (error = AudioUnitGetProperty(au, kAudioOutputUnitProperty_CurrentDevice,
|
||||
kAudioUnitScope_Global, 0, &OutputDevice, &size)) )
|
||||
{
|
||||
LOG->Warn( WERROR("No output device", error) );
|
||||
LOG->Warn("No output device: %s", FormatOSError(error));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,7 +50,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
size = sizeof( Float64 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &RateAddr, 0, NULL, &size, &rate)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't get the device's sample rate", error) );
|
||||
LOG->Warn("Couldn't get the device's sample rate: %s", FormatOSError(error));
|
||||
return;
|
||||
}
|
||||
if( rate == desiredRate )
|
||||
@@ -82,7 +64,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &AvailableRatesAddr, 0, nullptr, &size, nullptr)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't get available nominal sample rates info", error) );
|
||||
LOG->Warn("Couldn't get available nominal sample rates info: %s", FormatOSError(error));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,7 +73,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &AvailableRatesAddr, 0, NULL, &size, ranges)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't get available nominal sample rates", error) );
|
||||
LOG->Warn("Couldn't get available nominal sample rates: %s", FormatOSError(error));
|
||||
delete[] ranges;
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +97,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
|
||||
if( (error = AudioObjectSetPropertyData(OutputDevice, &RateAddr, 0, nullptr, sizeof(Float64), &bestRate)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't set the device's sample rate", error) );
|
||||
LOG->Warn("Couldn't set the device's sample rate: %s", FormatOSError(error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +120,7 @@ RString RageSoundDriver_AU::Init()
|
||||
OSStatus error = AudioComponentInstanceNew( comp, &m_OutputUnit );
|
||||
|
||||
if( error != noErr || m_OutputUnit == nullptr )
|
||||
return ERROR( "Could not open the default output unit", error );
|
||||
return ssprintf("Could not open the default output unit: %s", FormatOSError(error));
|
||||
|
||||
// Set up a callback function to generate output to the output unit
|
||||
AURenderCallbackStruct input;
|
||||
@@ -152,7 +134,7 @@ RString RageSoundDriver_AU::Init()
|
||||
&input,
|
||||
sizeof(input) );
|
||||
if( error != noErr )
|
||||
return ERROR( "Failed to set render callback", error );
|
||||
return ssprintf("Failed to set render callback: %s", FormatOSError(error));
|
||||
|
||||
AudioStreamBasicDescription streamFormat;
|
||||
|
||||
@@ -181,7 +163,7 @@ RString RageSoundDriver_AU::Init()
|
||||
&streamFormat,
|
||||
sizeof(AudioStreamBasicDescription) );
|
||||
if( error != noErr )
|
||||
return ERROR( "Failed to set AU stream format", error );
|
||||
return ssprintf("Failed to set AU stream format: %s", FormatOSError(error));
|
||||
UInt32 renderQuality = kRenderQuality_Max;
|
||||
|
||||
error = AudioUnitSetProperty( m_OutputUnit,
|
||||
@@ -191,16 +173,16 @@ RString RageSoundDriver_AU::Init()
|
||||
&renderQuality,
|
||||
sizeof(renderQuality) );
|
||||
if( error != noErr )
|
||||
LOG->Warn( WERROR("Failed to set the maximum render quality", error) );
|
||||
LOG->Warn("Failed to set the maximum render quality: %s", FormatOSError(error));
|
||||
|
||||
// Initialize the AU.
|
||||
if( (error = AudioUnitInitialize(m_OutputUnit)) )
|
||||
return ERROR( "Could not initialize the AudioUnit", error );
|
||||
return ssprintf("Could not initialize the AudioUnit: %s", FormatOSError(error));
|
||||
|
||||
StartDecodeThread();
|
||||
|
||||
if( (error = AudioOutputUnitStart(m_OutputUnit)) )
|
||||
return ERROR( "Could not start the AudioUnit", error );
|
||||
return ssprintf("Could not start the AudioUnit: %s", FormatOSError(error));
|
||||
m_bStarted = true;
|
||||
return RString();
|
||||
}
|
||||
@@ -215,7 +197,7 @@ RageSoundDriver_AU::~RageSoundDriver_AU()
|
||||
m_Semaphore.Wait();
|
||||
}
|
||||
AudioUnitUninitialize( m_OutputUnit );
|
||||
CloseComponent( m_OutputUnit );
|
||||
AudioComponentInstanceDispose( m_OutputUnit );
|
||||
delete m_pIOThread;
|
||||
delete m_pNotificationThread;
|
||||
}
|
||||
@@ -245,7 +227,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
if( (error = AudioUnitGetProperty(m_OutputUnit, kAudioOutputUnitProperty_CurrentDevice,
|
||||
kAudioUnitScope_Global, 0, &OutputDevice, &size)) )
|
||||
{
|
||||
LOG->Warn( WERROR("No output device", error) );
|
||||
LOG->Warn("No output device: %s", FormatOSError(error));
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -258,7 +240,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
size = sizeof( Float64 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &RateAddr, 0, nullptr, &size, &sampleRate)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't get the device sample rate", error) );
|
||||
LOG->Warn("Couldn't get the device sample rate: %s", FormatOSError(error));
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -271,7 +253,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
size = sizeof( UInt32 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &BufferAddr, 0, nullptr, &size, &bufferSize)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't determine buffer size", error) );
|
||||
LOG->Warn("Couldn't determine buffer size: %s", FormatOSError(error));
|
||||
bufferSize = 0;
|
||||
}
|
||||
|
||||
@@ -286,7 +268,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
size = sizeof( UInt32 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &LatencyAddr, 0, nullptr, &size, &frames)) )
|
||||
{
|
||||
LOG->Warn( WERROR( "Couldn't get device latency", error) );
|
||||
LOG->Warn("Couldn't get device latency: %s", FormatOSError(error));
|
||||
frames = 0;
|
||||
}
|
||||
|
||||
@@ -300,7 +282,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
size = sizeof( UInt32 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &SafetyAddr, 0, nullptr, &size, &frames)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't get device safety offset", error) );
|
||||
LOG->Warn("Couldn't get device safety offset: %s", FormatOSError(error));
|
||||
frames = 0;
|
||||
}
|
||||
bufferSize += frames;
|
||||
@@ -315,7 +297,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &StreamsAddr, 0, nullptr, &size, nullptr)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Device has no streams", error) );
|
||||
LOG->Warn("Device has no streams: %s", FormatOSError(error));
|
||||
break;
|
||||
}
|
||||
int num = size / sizeof( AudioStreamID );
|
||||
@@ -328,7 +310,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &StreamsAddr, 0, nullptr, &size, streams)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Cannot get device's streams", error) );
|
||||
LOG->Warn("Cannot get device's streams: %s", FormatOSError(error));
|
||||
delete[] streams;
|
||||
break;
|
||||
}
|
||||
@@ -341,7 +323,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(streams[0], &LatencyAddr, 0, nullptr, &size, &frames)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Stream does not report latency", error) );
|
||||
LOG->Warn("Stream does not report latency: %s", FormatOSError(error));
|
||||
frames = 0;
|
||||
}
|
||||
delete[] streams;
|
||||
@@ -10,17 +10,16 @@
|
||||
#endif
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
RString CrashHandler::GetLogsDirectory()
|
||||
{
|
||||
FSRef fs;
|
||||
char dir[PATH_MAX];
|
||||
|
||||
if( FSFindFolder(kUserDomain, kDomainLibraryFolderType, kDontCreateFolder, &fs) ||
|
||||
FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSURL *url = [fileManager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
if (url == nil)
|
||||
return "/tmp";
|
||||
}
|
||||
return RString( dir ) + "/Logs/" PRODUCT_ID;
|
||||
|
||||
return RString([url fileSystemRepresentation]) + "/Logs/" PRODUCT_ID;
|
||||
}
|
||||
|
||||
// XXX Can we use LocalizedString here instead?
|
||||
@@ -144,7 +144,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
return true;
|
||||
}
|
||||
|
||||
void HIDDevice::StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback, void *target, int refCon )
|
||||
void HIDDevice::StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback, void *target )
|
||||
{
|
||||
CFRunLoopSourceRef runLoopSource;
|
||||
// This creates a run loop source. It is released in the dtor.
|
||||
@@ -159,7 +159,7 @@ void HIDDevice::StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback
|
||||
if( !CFRunLoopContainsSource(loopRef, runLoopSource, kCFRunLoopDefaultMode) )
|
||||
CFRunLoopAddSource( loopRef, runLoopSource, kCFRunLoopDefaultMode );
|
||||
|
||||
ret = CALL( m_Queue, setEventCallout, callback, target, (void *)refCon );
|
||||
ret = CALL( m_Queue, setEventCallout, callback, target, this );
|
||||
|
||||
if( ret != kIOReturnSuccess )
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ protected:
|
||||
{
|
||||
IOReturn ret = CALL( m_Queue, addElement, cookie, 0 );
|
||||
if( ret != KERN_SUCCESS )
|
||||
LOG->Warn( "Failed to add HID element with cookie %p to queue: %u", cookie, ret );
|
||||
LOG->Warn( "Failed to add HID element with cookie %u to queue: %u", cookie, ret );
|
||||
}
|
||||
|
||||
// Perform a synchronous set report on the HID interface.
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
virtual ~HIDDevice();
|
||||
|
||||
bool Open( io_object_t device );
|
||||
void StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback, void *target, int refCon );
|
||||
void StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback, void *target );
|
||||
inline const RString& GetDescription() const { return m_sDescription; }
|
||||
|
||||
/* Add button presses (or releases) to vPresses for the given cookie. More
|
||||
|
||||
@@ -2,7 +2,7 @@ char *GetPreferredLanguage()
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *languages = [def objectForKey:@"AppleLanguages"];
|
||||
NSArray *languages = def[@"AppleLanguages"];
|
||||
const char *lang = [[languages objectAtIndex:0] UTF8String];
|
||||
char *ret = (char *)malloc( strlen(lang) + 1 );
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event
|
||||
{
|
||||
if( [event type] == NSKeyDown )
|
||||
if( [event type] == NSEventTypeKeyDown )
|
||||
[[self mainMenu] performKeyEquivalent:event];
|
||||
else
|
||||
[super sendEvent:event];
|
||||
@@ -172,7 +172,7 @@ static void SetupMenus( void )
|
||||
NSMenu *windowMenu = [[[NSMenu alloc] initWithTitle:sWindow] autorelease];
|
||||
NSMenuItem *hideOthers = MenuItem( sHideOthers, @selector(hideOtherApplications:), @"h" );
|
||||
|
||||
[hideOthers setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask ];
|
||||
[hideOthers setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand ];
|
||||
|
||||
[appMenu addItem:MenuItem( sAbout, @selector(orderFrontStandardAboutPanel:), @"" )];
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
@@ -188,7 +188,7 @@ static void SetupMenus( void )
|
||||
// Add a Full Screen item.
|
||||
NSMenuItem *item = MenuItem( sEnterFullScreen, @selector(fullscreen:), @"\n" );
|
||||
|
||||
[item setKeyEquivalentModifierMask:NSAlternateKeyMask]; // opt-enter
|
||||
[item setKeyEquivalentModifierMask:NSEventModifierFlagOption]; // opt-enter
|
||||
[windowMenu addItem:item];
|
||||
|
||||
[[mainMenu addItemWithTitle:[appMenu title] action:nil keyEquivalent:@""] setSubmenu:appMenu];
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
#include "global.h"
|
||||
#include "SpecialDirs.h"
|
||||
#include "ProductInfo.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include "RageUtil.h"
|
||||
|
||||
static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
|
||||
{
|
||||
FSRef fs;
|
||||
|
||||
if( FSFindFolder(kUserDomain, folderType, kDontCreateFolder, &fs) )
|
||||
FAIL_M( ssprintf("FSFindFolder(%lu) failed.", folderType) );
|
||||
if( FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
|
||||
FAIL_M( "FSRefMakePath() failed." );
|
||||
}
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
RString SpecialDirs::GetDesktopDir()
|
||||
{
|
||||
char dir[PATH_MAX];
|
||||
PathForFolderType( dir, kDesktopFolderType );
|
||||
return RString( ssprintf("%s/" PRODUCT_ID, dir) );
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSURL *url = [fileManager URLForDirectory:NSDesktopDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
if (url == nil)
|
||||
return "/tmp";
|
||||
|
||||
return RString([url fileSystemRepresentation]) + "/" PRODUCT_ID;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user