2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 11:54:46 -07:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
#include <algorithm>
|
2017-02-19 01:00:00 -07:00
|
|
|
#include <functional>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <map>
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
// enable disable sources
|
|
|
|
#ifdef _WIN32
|
2016-06-24 02:43:46 -06:00
|
|
|
#define CIFACE_USE_XINPUT
|
|
|
|
#define CIFACE_USE_DINPUT
|
2010-07-16 13:17:35 -06:00
|
|
|
#endif
|
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
2016-06-24 02:43:46 -06:00
|
|
|
#define CIFACE_USE_XLIB
|
2010-07-16 13:17:35 -06:00
|
|
|
#endif
|
2010-04-02 03:41:43 -06:00
|
|
|
#if defined(__APPLE__)
|
2016-06-24 02:43:46 -06:00
|
|
|
#define CIFACE_USE_OSX
|
2010-04-02 03:41:43 -06:00
|
|
|
#endif
|
2014-05-04 18:41:02 -06:00
|
|
|
#if defined(HAVE_SDL) && HAVE_SDL
|
2016-06-24 02:43:46 -06:00
|
|
|
#define CIFACE_USE_SDL
|
2014-05-04 18:41:02 -06:00
|
|
|
#endif
|
2015-06-28 18:17:35 -06:00
|
|
|
#if defined(HAVE_LIBEVDEV) && defined(HAVE_LIBUDEV)
|
2016-06-24 02:43:46 -06:00
|
|
|
#define CIFACE_USE_EVDEV
|
2015-06-28 18:17:35 -06:00
|
|
|
#endif
|
2015-10-24 21:20:03 -06:00
|
|
|
#if defined(USE_PIPES)
|
2016-06-24 02:43:46 -06:00
|
|
|
#define CIFACE_USE_PIPES
|
2015-10-24 21:20:03 -06:00
|
|
|
#endif
|
2013-06-16 18:07:10 -06:00
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
//
|
2014-01-30 17:51:21 -07:00
|
|
|
// ControllerInterface
|
2010-04-01 20:48:24 -06:00
|
|
|
//
|
2014-01-30 17:51:21 -07:00
|
|
|
// Some crazy shit I made to control different device inputs and outputs
|
|
|
|
// from lots of different sources, hopefully more easily.
|
2010-04-01 20:48:24 -06:00
|
|
|
//
|
2014-09-04 18:41:42 -06:00
|
|
|
class ControllerInterface : public ciface::Core::DeviceContainer
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
ControllerInterface() : m_is_init(false), m_hwnd(nullptr) {}
|
|
|
|
void Initialize(void* const hwnd);
|
2016-10-16 14:39:05 -06:00
|
|
|
void RefreshDevices();
|
2016-06-24 02:43:46 -06:00
|
|
|
void Shutdown();
|
2016-06-25 13:46:39 -06:00
|
|
|
void AddDevice(std::shared_ptr<ciface::Core::Device> device);
|
2016-07-14 09:45:59 -06:00
|
|
|
void RemoveDevice(std::function<bool(const ciface::Core::Device*)> callback);
|
2016-06-24 02:43:46 -06:00
|
|
|
bool IsInit() const { return m_is_init; }
|
|
|
|
void UpdateInput();
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-06-13 03:11:47 -06:00
|
|
|
void RegisterHotplugCallback(std::function<void(void)> callback);
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
private:
|
2017-11-09 13:14:21 -07:00
|
|
|
void InvokeHotplugCallbacks() const;
|
|
|
|
|
2016-06-13 03:11:47 -06:00
|
|
|
std::vector<std::function<void()>> m_hotplug_callbacks;
|
2016-06-24 02:43:46 -06:00
|
|
|
bool m_is_init;
|
|
|
|
void* m_hwnd;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2010-10-12 13:42:29 -06:00
|
|
|
extern ControllerInterface g_controller_interface;
|