summaryrefslogtreecommitdiffhomepage
path: root/opentrack-dinput/win32-joystick.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-12 18:00:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-12 18:00:49 +0200
commit9040b187a1c4fa380f8a12207b9dd6d04b3a10ac (patch)
tree115e1351571d690c1261a9d512e6d44e717f3051 /opentrack-dinput/win32-joystick.hpp
parent13a18b149764509a3f460be86590250cdcf690fb (diff)
all: rename modules s#^opentrack-##. and opentrack -> api
Adjust usages.
Diffstat (limited to 'opentrack-dinput/win32-joystick.hpp')
-rw-r--r--opentrack-dinput/win32-joystick.hpp101
1 files changed, 0 insertions, 101 deletions
diff --git a/opentrack-dinput/win32-joystick.hpp b/opentrack-dinput/win32-joystick.hpp
deleted file mode 100644
index ef8f59b0..00000000
--- a/opentrack-dinput/win32-joystick.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright (c) 2015-2016, Stanislaw Halik <sthalik@misaki.pl>
-
- * Permission to use, copy, modify, and/or distribute this
- * software for any purpose with or without fee is hereby granted,
- * provided that the above copyright notice and this permission
- * notice appear in all copies.
- */
-#pragma once
-
-#ifdef _WIN32
-
-#include "dinput.hpp"
-#include "opentrack-compat/timer.hpp"
-#include "export.hpp"
-#include <cstring>
-#include <memory>
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <unordered_map>
-#include <QString>
-#include <QDebug>
-#include <QMutex>
-#include <QMutexLocker>
-#include <QWidget>
-
-namespace std {
-template<>
-struct hash<QString>
-{
- inline std::size_t operator()(const QString& value) const
- {
- return qHash(value);
- }
-};
-}
-
-struct OPENTRACK_DINPUT_EXPORT win32_joy_ctx
-{
- using fn = std::function<void(const QString& guid, int btn, bool held)>;
-
- struct joy
- {
- LPDIRECTINPUTDEVICE8 joy_handle;
- QString guid, name;
- bool pressed[128 + 4 * 4];
- Timer first_timer;
-
- joy(LPDIRECTINPUTDEVICE8 handle, const QString& guid, const QString& name);
- ~joy();
-
- void release();
- bool poll(fn f);
- };
-
- using joys_t = std::unordered_map<QString, std::shared_ptr<joy>>;
-
- static constexpr int joy_axis_size = 65535;
-
- struct joy_info
- {
- QString name, guid;
- };
-
- void poll(fn f);
- bool poll_axis(const QString& guid, int* axes);
- std::vector<joy_info> get_joy_info();
-
- win32_joy_ctx(const win32_joy_ctx&) = delete;
- win32_joy_ctx& operator=(const win32_joy_ctx&) = delete;
-
- win32_joy_ctx();
- void refresh();
-
- using di_t = dinput_handle::di_t;
-
-private:
- static QString guid_to_string(const GUID& guid);
-
- class OPENTRACK_DINPUT_EXPORT enum_state final
- {
- std::vector<QString> all;
- joys_t joys;
- dinput_handle::di_t di;
-
- static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext);
- static BOOL CALLBACK EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* ctx);
-
- public:
- static QMutex mtx;
-
- enum_state();
- ~enum_state();
- void refresh();
- const joys_t& get_joys() const;
- };
-
- static enum_state enumerator;
-};
-
-#endif