2015-04-19 20:16:50 +00:00
|
|
|
#ifndef CDOLPHINSMASHADAPTER_HPP
|
|
|
|
#define CDOLPHINSMASHADAPTER_HPP
|
|
|
|
|
2015-04-24 00:24:15 +00:00
|
|
|
#include <stdint.h>
|
2015-04-21 04:02:43 +00:00
|
|
|
#include "CDeviceBase.hpp"
|
|
|
|
|
2015-04-24 00:24:15 +00:00
|
|
|
struct IDolphinSmashAdapterCallback
|
|
|
|
{
|
|
|
|
enum EDolphinControllerType
|
|
|
|
{
|
|
|
|
DOL_TYPE_NONE = 0,
|
|
|
|
DOL_TYPE_NORMAL = 0x10,
|
|
|
|
DOL_TYPE_WAVEBIRD = 0x20,
|
|
|
|
};
|
|
|
|
enum EDolphinControllerButtons
|
|
|
|
{
|
|
|
|
DOL_START = 1<<0,
|
|
|
|
DOL_Z = 1<<1,
|
|
|
|
DOL_L = 1<<2,
|
|
|
|
DOL_R = 1<<3,
|
|
|
|
DOL_A = 1<<8,
|
|
|
|
DOL_B = 1<<9,
|
|
|
|
DOL_X = 1<<10,
|
|
|
|
DOL_Y = 1<<11,
|
|
|
|
DOL_LEFT = 1<<12,
|
|
|
|
DOL_RIGHT = 1<<13,
|
|
|
|
DOL_DOWN = 1<<14,
|
|
|
|
DOL_UP = 1<<15
|
|
|
|
};
|
|
|
|
struct SDolphinControllerState
|
|
|
|
{
|
|
|
|
uint8_t m_leftStick[2];
|
|
|
|
uint8_t m_rightStick[2];
|
|
|
|
uint8_t m_analogTriggers[2];
|
|
|
|
uint16_t m_btns;
|
|
|
|
};
|
|
|
|
virtual void controllerConnected(unsigned idx, EDolphinControllerType type) {}
|
|
|
|
virtual void controllerDisconnected(unsigned idx, EDolphinControllerType type) {}
|
|
|
|
virtual void controllerUpdate(unsigned idx, EDolphinControllerType type,
|
|
|
|
const SDolphinControllerState& state) {}
|
|
|
|
};
|
|
|
|
|
2015-04-21 04:02:43 +00:00
|
|
|
class CDolphinSmashAdapter final : public CDeviceBase
|
|
|
|
{
|
2015-04-24 00:24:15 +00:00
|
|
|
IDolphinSmashAdapterCallback* m_callback;
|
|
|
|
uint8_t m_knownControllers;
|
|
|
|
uint8_t m_rumbleRequest;
|
|
|
|
uint8_t m_rumbleState;
|
|
|
|
bool m_didHandshake;
|
2015-04-21 04:02:43 +00:00
|
|
|
void deviceDisconnected();
|
2015-04-24 00:24:15 +00:00
|
|
|
void transferCycle();
|
2015-04-26 08:25:44 +00:00
|
|
|
void finalCycle();
|
2015-04-21 04:02:43 +00:00
|
|
|
public:
|
2015-04-24 00:24:15 +00:00
|
|
|
CDolphinSmashAdapter(CDeviceToken* token);
|
2015-04-23 00:46:32 +00:00
|
|
|
~CDolphinSmashAdapter();
|
2015-04-24 00:24:15 +00:00
|
|
|
|
|
|
|
inline void setCallback(IDolphinSmashAdapterCallback* cb)
|
|
|
|
{m_callback = cb; m_knownControllers = 0;}
|
|
|
|
inline void startRumble(unsigned idx) {if (idx >= 4) return; m_rumbleRequest |= 1<<idx;}
|
|
|
|
inline void stopRumble(unsigned idx) {if (idx >= 4) return; m_rumbleRequest &= ~(1<<idx);}
|
2015-04-21 04:02:43 +00:00
|
|
|
};
|
2015-04-19 20:16:50 +00:00
|
|
|
|
|
|
|
#endif // CDOLPHINSMASHADAPTER_HPP
|