Switch from deprecated Carbon idle tickling to Cocoa power assertions.
Also, this avoids keeping the system awake if a game is not being played. Frankly, I don't know what the point of precisely tracking these things is, but that's how the API works. Feel free to add analogous functionality on other platforms.
This commit is contained in:
parent
aae234c5d7
commit
e631f68c1b
|
@ -64,4 +64,9 @@ int Wiimote::IOWrite(const u8* buf, size_t len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Wiimote::EnablePowerAssertionInternal()
|
||||
{}
|
||||
void Wiimote::DisablePowerAssertionInternal()
|
||||
{}
|
||||
|
||||
};
|
||||
|
|
|
@ -255,4 +255,9 @@ int Wiimote::IOWrite(u8 const* buf, size_t len)
|
|||
return write(int_sock, buf, (int)len);
|
||||
}
|
||||
|
||||
void Wiimote::EnablePowerAssertionInternal()
|
||||
{}
|
||||
void Wiimote::DisablePowerAssertionInternal()
|
||||
{}
|
||||
|
||||
}; // WiimoteReal
|
||||
|
|
|
@ -783,6 +783,11 @@ int Wiimote::IOWrite(const u8* buf, size_t len)
|
|||
return _IOWrite(dev_handle, hid_overlap_write, stack, buf, len, nullptr);
|
||||
}
|
||||
|
||||
void Wiimote::EnablePowerAssertionInternal()
|
||||
{}
|
||||
void Wiimote::DisablePowerAssertionInternal()
|
||||
{}
|
||||
|
||||
// invokes callback for each found wiimote bluetooth device
|
||||
template <typename T>
|
||||
void ProcessWiimotes(bool new_scan, T& callback)
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
memcpy(wm->input, data, length);
|
||||
wm->inputlen = length;
|
||||
|
||||
(void)UpdateSystemActivity(UsrActivity);
|
||||
CFRunLoopStop(CFRunLoopGetCurrent());
|
||||
}
|
||||
|
||||
|
@ -195,6 +194,7 @@ void Wiimote::InitInternal()
|
|||
m_connected = false;
|
||||
m_wiimote_thread_run_loop = nullptr;
|
||||
btd = nil;
|
||||
m_pm_assertion = kIOPMNullAssertionID;
|
||||
}
|
||||
|
||||
void Wiimote::TeardownInternal()
|
||||
|
@ -328,4 +328,22 @@ int Wiimote::IOWrite(const unsigned char *buf, size_t len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Wiimote::EnablePowerAssertionInternal()
|
||||
{
|
||||
if (m_pm_assertion == kIOPMNullAssertionID)
|
||||
{
|
||||
if (IOReturn ret = IOPMAssertionCreateWithName(kIOPMAssertPreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, CFSTR("Dolphin Wiimote activity"), &m_pm_assertion))
|
||||
ERROR_LOG(WIIMOTE, "Could not create power management assertion: %08x", ret);
|
||||
}
|
||||
}
|
||||
|
||||
void Wiimote::DisablePowerAssertionInternal()
|
||||
{
|
||||
if (m_pm_assertion != kIOPMNullAssertionID)
|
||||
{
|
||||
if (IOReturn ret = IOPMAssertionRelease(m_pm_assertion))
|
||||
ERROR_LOG(WIIMOTE, "Could not release power management assertion: %08x", ret);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ Wiimote::Wiimote()
|
|||
|
||||
Wiimote::~Wiimote()
|
||||
{
|
||||
DisablePowerAssertionInternal();
|
||||
StopThread();
|
||||
ClearReadQueue();
|
||||
m_write_reports.Clear();
|
||||
|
@ -334,6 +335,7 @@ bool Wiimote::PrepareOnThread()
|
|||
void Wiimote::EmuStart()
|
||||
{
|
||||
DisableDataReporting();
|
||||
EnablePowerAssertionInternal();
|
||||
}
|
||||
|
||||
void Wiimote::EmuStop()
|
||||
|
@ -343,6 +345,8 @@ void Wiimote::EmuStop()
|
|||
DisableDataReporting();
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "Stopping Wiimote data reporting.");
|
||||
|
||||
DisablePowerAssertionInternal();
|
||||
}
|
||||
|
||||
void Wiimote::EmuResume()
|
||||
|
@ -358,6 +362,8 @@ void Wiimote::EmuResume()
|
|||
QueueReport(WM_REPORT_MODE, &rpt, sizeof(rpt));
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "Resuming Wiimote data reporting.");
|
||||
|
||||
EnablePowerAssertionInternal();
|
||||
}
|
||||
|
||||
void Wiimote::EmuPause()
|
||||
|
@ -371,6 +377,8 @@ void Wiimote::EmuPause()
|
|||
QueueReport(WM_REPORT_MODE, &rpt, sizeof(rpt));
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "Pausing Wiimote data reporting.");
|
||||
|
||||
DisablePowerAssertionInternal();
|
||||
}
|
||||
|
||||
static unsigned int CalculateConnectedWiimotes()
|
||||
|
|
|
@ -47,6 +47,9 @@ public:
|
|||
void EmuResume();
|
||||
void EmuPause();
|
||||
|
||||
void EnablePowerAssertionInternal();
|
||||
void DisablePowerAssertionInternal();
|
||||
|
||||
// connecting and disconnecting from physical devices
|
||||
// (using address inserted by FindWiimotes)
|
||||
// these are called from the wiimote's thread.
|
||||
|
@ -80,6 +83,7 @@ public:
|
|||
int inputlen;
|
||||
bool m_connected;
|
||||
CFRunLoopRef m_wiimote_thread_run_loop;
|
||||
IOPMAssertionID m_pm_assertion;
|
||||
#elif defined(__linux__) && HAVE_BLUEZ
|
||||
bdaddr_t bdaddr; // Bluetooth address
|
||||
int cmd_sock; // Command socket
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define NS_ENUM_AVAILABLE(...)
|
||||
// end hack
|
||||
#import <IOBluetooth/IOBluetooth.h>
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#elif defined(__linux__) && HAVE_BLUEZ
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue