InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio.

This commit is contained in:
Jordan Woyak 2020-01-24 00:06:39 -06:00
parent 42c03c4dad
commit b92f6480a0
9 changed files with 59 additions and 21 deletions

View file

@ -10,6 +10,7 @@
#include <memory>
#include <mutex>
#include "Common/Matrix.h"
#include "Common/WindowSystemInfo.h"
#include "InputCommon/ControllerInterface/Device.h"
@ -52,6 +53,14 @@ public:
bool IsInit() const { return m_is_init; }
void UpdateInput();
// Set adjustment from the full render window aspect-ratio to the drawn aspect-ratio.
// Used to fit mouse cursor inputs to the relevant region of the render window.
void SetAspectRatioAdjustment(float);
// Calculated from the aspect-ratio adjustment.
// Inputs based on window coordinates should be multiplied by this.
Common::Vec2 GetWindowInputScale() const;
HotplugCallbackHandle RegisterDevicesChangedCallback(std::function<void(void)> callback);
void UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle);
void InvokeDevicesChangedCallbacks() const;
@ -62,6 +71,7 @@ private:
std::atomic<bool> m_is_init;
std::atomic<bool> m_is_populating_devices{false};
WindowSystemInfo m_wsi;
std::atomic<float> m_aspect_ratio_adjustment = 1;
};
extern ControllerInterface g_controller_interface;