diff --git a/include/inputdev/CDolphinSmashAdapter.hpp b/include/inputdev/CDolphinSmashAdapter.hpp index 7786b29..0516135 100644 --- a/include/inputdev/CDolphinSmashAdapter.hpp +++ b/include/inputdev/CDolphinSmashAdapter.hpp @@ -11,7 +11,6 @@ struct IDolphinSmashAdapterCallback DOL_TYPE_NONE = 0, DOL_TYPE_NORMAL = 0x10, DOL_TYPE_WAVEBIRD = 0x20, - DOL_TYPE_RUMBLE = 0xF0 }; enum EDolphinControllerButtons { diff --git a/src/inputdev/CDolphinSmashAdapter.cpp b/src/inputdev/CDolphinSmashAdapter.cpp index 41ac550..acc4778 100644 --- a/src/inputdev/CDolphinSmashAdapter.cpp +++ b/src/inputdev/CDolphinSmashAdapter.cpp @@ -5,26 +5,6 @@ /* Reference: https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c */ -static const bool BUTTON_MASK[] = -{ - true, - true, - true, - true, - false, - false, - false, - false, - true, - true, - true, - true, - true, - true, - true, - true -}; - CDolphinSmashAdapter::CDolphinSmashAdapter(CDeviceToken* token) : CDeviceBase(token), m_callback(NULL), @@ -57,15 +37,13 @@ parseType(unsigned char status) } static inline IDolphinSmashAdapterCallback::EDolphinControllerType -parseState(IDolphinSmashAdapterCallback::SDolphinControllerState* stateOut, uint8_t* payload) +parseState(IDolphinSmashAdapterCallback::SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble) { memset(stateOut, 0, sizeof(IDolphinSmashAdapterCallback::SDolphinControllerState)); unsigned char status = payload[0]; IDolphinSmashAdapterCallback::EDolphinControllerType type = parseType(status); - IDolphinSmashAdapterCallback::EDolphinControllerType extra = - ((status & 0x04) != 0) ? IDolphinSmashAdapterCallback::DOL_TYPE_RUMBLE : - IDolphinSmashAdapterCallback::DOL_TYPE_NONE; + rumble = ((status & 0x04) != 0) ? true : false; stateOut->m_btns = (uint16_t)payload[1] << 8 | (uint16_t)payload[2]; @@ -76,7 +54,7 @@ parseState(IDolphinSmashAdapterCallback::SDolphinControllerState* stateOut, uint stateOut->m_analogTriggers[0] = payload[7]; stateOut->m_analogTriggers[1] = payload[8]; - return static_cast(type|extra); + return type; } void CDolphinSmashAdapter::transferCycle() @@ -101,11 +79,12 @@ void CDolphinSmashAdapter::transferCycle() /* Parse controller states */ uint8_t* controller = &payload[1]; - bool rumbleMask[4] = {false}; + uint8_t rumbleMask = 0; for (int i=0 ; i<4 ; i++, controller += 9) { IDolphinSmashAdapterCallback::SDolphinControllerState state; - IDolphinSmashAdapterCallback::EDolphinControllerType type = parseState(&state, controller); + bool rumble = false; + IDolphinSmashAdapterCallback::EDolphinControllerType type = parseState(&state, controller, rumble); if (type && !(m_knownControllers & 1<controllerDisconnected(i, type); } - m_callback->controllerUpdate(i, type, state); - rumbleMask[i] = type & IDolphinSmashAdapterCallback::DOL_TYPE_RUMBLE; + if (m_knownControllers & 1<controllerUpdate(i, type, state); + rumbleMask |= rumble ? 1<(tok.openAndGetDevice()); smashAdapter->setCallback(&m_cb); + smashAdapter->startRumble(0); } void deviceDisconnected(CDeviceToken&, CDeviceBase* device) {