From 4864dfaa4b455905fece5cd93502b80890d1b2d2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 6 Dec 2015 20:13:56 +0100 Subject: api/joy: move from header --- opentrack/win32-joystick.cpp | 15 +++++++++++++++ opentrack/win32-joystick.hpp | 17 +++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'opentrack') diff --git a/opentrack/win32-joystick.cpp b/opentrack/win32-joystick.cpp index 73e27f80..728e2f68 100644 --- a/opentrack/win32-joystick.cpp +++ b/opentrack/win32-joystick.cpp @@ -292,4 +292,19 @@ win32_joy_ctx::enum_state::EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE *pdi return DIENUM_CONTINUE; } +win32_joy_ctx::joy::joy(LPDIRECTINPUTDEVICE8 handle, const QString &guid, const QString &name) + : joy_handle(handle), guid(guid), name(name) +{ + qDebug() << "got joy" << guid; + for (int i = 0; i < 128; i++) + pressed[i] = false; + memset(&js_old, 0, sizeof(js_old)); +} + +win32_joy_ctx::joy::~joy() +{ + qDebug() << "nix joy" << guid; + release(); +} + #endif diff --git a/opentrack/win32-joystick.hpp b/opentrack/win32-joystick.hpp index df00aee7..6d5e1074 100644 --- a/opentrack/win32-joystick.hpp +++ b/opentrack/win32-joystick.hpp @@ -24,7 +24,7 @@ namespace std { template<> struct hash { - std::size_t operator()(const QString& value) const + inline std::size_t operator()(const QString& value) const { return qHash(value); } @@ -78,19 +78,8 @@ private: Timer first_timer; DIJOYSTATE2 js_old; - joy(LPDIRECTINPUTDEVICE8 handle, const QString& guid, const QString& name) - : joy_handle(handle), guid(guid), name(name) - { - qDebug() << "got joy" << guid; - for (int i = 0; i < 128; i++) - pressed[i] = false; - } - - ~joy() - { - qDebug() << "nix joy" << guid; - release(); - } + joy(LPDIRECTINPUTDEVICE8 handle, const QString& guid, const QString& name); + ~joy(); void release(); bool poll(fn f); -- cgit v1.2.3