2015-05-24 06:32:32 +02:00
// Copyright 2010 Dolphin Emulator Project
2021-07-05 03:22:19 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
2015-05-24 06:32:32 +02:00
2013-10-19 02:27:57 -07:00
// XInput suffers a similar issue as XAudio2. Since Win8, it is part of the OS.
// However, unlike XAudio2 they have not made the API incompatible - so we just
// compile against the latest version and fall back to dynamically loading the
// old DLL.
2014-02-10 13:54:46 -05:00
# pragma once
2010-04-02 02:48:24 +00:00
2014-02-19 02:17:31 +01:00
# include <windows.h>
2017-01-22 23:08:45 -08:00
# include <XInput.h>
2010-04-02 02:48:24 +00:00
2016-06-12 17:08:04 +02:00
# include "InputCommon/ControllerInterface/ControllerInterface.h"
2014-02-19 02:17:31 +01:00
2013-10-19 02:27:57 -07:00
# ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
# error You are building this module against the wrong version of DirectX. You probably need to remove DXSDK_DIR from your include path and / or _WIN32_WINNT is wrong.
# endif
2019-06-17 16:39:24 -04:00
namespace ciface : : XInput
2010-04-02 02:48:24 +00:00
{
2016-06-12 17:08:04 +02:00
void Init ( ) ;
2016-10-16 13:39:05 -07:00
void PopulateDevices ( ) ;
2013-10-19 02:27:57 -07:00
void DeInit ( ) ;
2010-04-02 02:48:24 +00:00
2020-02-08 15:45:01 -06:00
class Device final : public Core : : Device
2010-04-02 02:48:24 +00:00
{
2011-03-14 01:20:11 +00:00
public :
Device ( const XINPUT_CAPABILITIES & capabilities , u8 index ) ;
2010-04-02 02:48:24 +00:00
2020-02-08 15:45:01 -06:00
std : : string GetName ( ) const override ;
std : : string GetSource ( ) const override ;
std : : optional < int > GetPreferredId ( ) const override ;
void UpdateInput ( ) override ;
2010-04-02 02:48:24 +00:00
2014-11-13 01:10:55 -08:00
void UpdateMotors ( ) ;
2010-04-02 02:48:24 +00:00
private :
2020-02-08 15:02:54 -06:00
XINPUT_STATE m_state_in { } ;
2016-04-21 14:22:48 +02:00
XINPUT_VIBRATION m_state_out { } ;
2020-02-08 15:02:54 -06:00
ControlState m_battery_level { } ;
2011-03-14 01:20:11 +00:00
const BYTE m_subtype ;
const u8 m_index ;
2010-04-02 02:48:24 +00:00
} ;
2019-06-17 16:39:24 -04:00
} // namespace ciface::XInput