From 5076d0c35eacb2e7b246e7bd5e6637086ea74a15 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 6 Dec 2015 05:23:04 +0100 Subject: api/joy: nix static, now that we're not a singleton --- opentrack/win32-joystick.cpp | 19 ++++++------------- opentrack/win32-joystick.hpp | 5 ++--- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'opentrack') diff --git a/opentrack/win32-joystick.cpp b/opentrack/win32-joystick.cpp index 89092403..78720c79 100644 --- a/opentrack/win32-joystick.cpp +++ b/opentrack/win32-joystick.cpp @@ -4,20 +4,13 @@ #ifdef _WIN32 -std::unordered_map>& win32_joy_ctx::joys() -{ - static std::unordered_map> js; - - return js; -} - void win32_joy_ctx::poll(fn f) { refresh(false); QMutexLocker l(&mtx); - for (auto& j : joys()) + for (auto& j : joys) { j.second->poll(f); } @@ -29,9 +22,9 @@ bool win32_joy_ctx::poll_axis(const QString &guid, int axes[]) QMutexLocker l(&mtx); - auto iter = joys().find(guid); + auto iter = joys.find(guid); - if (iter == joys().end()) + if (iter == joys.end()) return false; auto& j = iter->second; @@ -89,7 +82,7 @@ std::vector win32_joy_ctx::get_joy_info() std::vector ret; - for (auto& j : joys()) + for (auto& j : joys) ret.push_back(joy_info { j.second->name, j.first }); return ret; @@ -106,7 +99,7 @@ win32_joy_ctx::win32_joy_ctx() void win32_joy_ctx::release() { - joys() = std::unordered_map>(); + joys = std::unordered_map>(); di->Release(); di = nullptr; } @@ -122,7 +115,7 @@ void win32_joy_ctx::refresh(bool first) timer_joylist.start(); } - enum_state st(joys(), mtx, fake_main_window, di); + enum_state st(joys, mtx, fake_main_window, di); } QString win32_joy_ctx::guid_to_string(const GUID guid) diff --git a/opentrack/win32-joystick.hpp b/opentrack/win32-joystick.hpp index f7629c3d..e68ea2c6 100644 --- a/opentrack/win32-joystick.hpp +++ b/opentrack/win32-joystick.hpp @@ -70,9 +70,6 @@ private: void release(); void refresh(bool first); - struct joy; - static std::unordered_map>& joys(); - struct joy { LPDIRECTINPUTDEVICE8 joy_handle; @@ -97,6 +94,8 @@ private: void release(); bool poll(fn f); }; + + std::unordered_map> joys; class enum_state { -- cgit v1.2.3