InputCommon:QuarzKB&M: Use KVO to watch window position

CGWindowListCreateDescriptionFromArray would block for up to ~1ms, which isn't a great thing to do on the main emulation thread
This commit is contained in:
TellowKrinkle
2022-08-12 03:02:47 -05:00
parent b96bc4267e
commit 798b241832
2 changed files with 82 additions and 29 deletions

View File

@ -8,6 +8,12 @@
#include "Common/Matrix.h"
#include "InputCommon/ControllerInterface/CoreDevice.h"
#ifdef __OBJC__
@class DolWindowPositionObserver;
#else
class DolWindowPositionObserver;
#endif
namespace ciface::Quartz
{
std::string KeycodeToName(const CGKeyCode keycode);
@ -59,13 +65,16 @@ public:
void UpdateInput() override;
explicit KeyboardAndMouse(void* view);
~KeyboardAndMouse() override;
std::string GetName() const override;
std::string GetSource() const override;
private:
void MainThreadInitialization(void* view);
Common::Vec2 m_cursor;
uint32_t m_windowid;
DolWindowPositionObserver* m_window_pos_observer;
};
} // namespace ciface::Quartz