1 /*
2  *  Copyright (C) 2014-2020 Garrett Brown
3  *  Copyright (C) 2014-2020 Team Kodi
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSE.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "api/Joystick.h"
12 
13 #include <windows.h>
14 
15 namespace JOYSTICK
16 {
17   class CJoystickXInput : public CJoystick
18   {
19   public:
20     enum
21     {
22       MOTOR_LEFT = 0,
23       MOTOR_RIGHT = 1,
24       MOTOR_COUNT = 2,
25     };
26 
27     CJoystickXInput(unsigned int controllerID);
~CJoystickXInput(void)28     virtual ~CJoystickXInput(void) { }
29 
30     virtual bool Equals(const CJoystick* rhs) const override;
31 
32     virtual void PowerOff() override;
33 
34   protected:
35     virtual bool ScanEvents(void) override;
36     virtual bool SetMotor(unsigned int motorIndex, float magnitude) override;
37 
38   private:
39     unsigned int m_controllerID;   // XInput port, in the range (0, 3)
40     DWORD        m_dwPacketNumber; // If unchanged, controller state hasn't changed (currently ignored)
41     float        m_motorSpeeds[MOTOR_COUNT];
42   };
43 }
44