2015-05-24 04:32:32 +00:00
// Copyright 2010 Dolphin Emulator Project
2021-07-05 01:22:19 +00:00
// SPDX-License-Identifier: GPL-2.0-or-later
2015-05-24 04:32:32 +00:00
2013-10-19 09:27:57 +00: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 18:54:46 +00:00
# pragma once
2010-04-02 02:48:24 +00:00
2014-02-19 01:17:31 +00:00
# include <windows.h>
2017-01-23 07:08:45 +00:00
# include <XInput.h>
2010-04-02 02:48:24 +00:00
2016-06-12 15:08:04 +00:00
# include "InputCommon/ControllerInterface/ControllerInterface.h"
2014-02-19 01:17:31 +00:00
2013-10-19 09:27:57 +00: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 20:39:24 +00:00
namespace ciface : : XInput
2010-04-02 02:48:24 +00:00
{
2016-06-12 15:08:04 +00:00
void Init ( ) ;
2016-10-16 20:39:05 +00:00
void PopulateDevices ( ) ;
2013-10-19 09:27:57 +00:00
void DeInit ( ) ;
2010-04-02 02:48:24 +00:00
2020-02-08 21:45:01 +00: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 21:45:01 +00:00
std : : string GetName ( ) const override ;
std : : string GetSource ( ) const override ;
std : : optional < int > GetPreferredId ( ) const override ;
2022-03-02 21:40:20 +00:00
int GetSortPriority ( ) const override { return - 2 ; }
2020-02-08 21:45:01 +00:00
void UpdateInput ( ) override ;
2010-04-02 02:48:24 +00:00
2014-11-13 09:10:55 +00:00
void UpdateMotors ( ) ;
2010-04-02 02:48:24 +00:00
private :
2020-02-08 21:02:54 +00:00
XINPUT_STATE m_state_in { } ;
2016-04-21 12:22:48 +00:00
XINPUT_VIBRATION m_state_out { } ;
2020-02-08 21:02:54 +00: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 20:39:24 +00:00
} // namespace ciface::XInput