Skip to content
Permalink
Browse files

Merge pull request #3455 from Sonicadvance1/GC_adapter_android

[Android] Add support for the Wii U Gamecube adapter under Android.
  • Loading branch information
Sonicadvance1 committed Jan 6, 2016
2 parents 87e753b + e62503c commit 342496563dc2fd129c6ab3831b181eb0875f46d0
Showing with 940 additions and 216 deletions.
  1. +91 −0 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Java_GCAdapter.java
  2. +2 −2 Source/Core/Core/CMakeLists.txt
  3. +4 −4 Source/Core/Core/ConfigManager.cpp
  4. +2 −2 Source/Core/Core/ConfigManager.h
  5. +4 −6 Source/Core/Core/Core.cpp
  6. +2 −8 Source/Core/Core/Core.vcxproj
  7. +6 −6 Source/Core/Core/Core.vcxproj.filters
  8. +4 −0 Source/Core/Core/HW/SI_Device.cpp
  9. +2 −1 Source/Core/Core/HW/SI_Device.h
  10. +150 −0 Source/Core/Core/HW/SI_DeviceGCAdapter.cpp
  11. +20 −0 Source/Core/Core/HW/SI_DeviceGCAdapter.h
  12. +27 −29 Source/Core/Core/HW/SI_DeviceGCController.cpp
  13. +8 −12 Source/Core/Core/HW/SI_DeviceGCController.h
  14. +1 −0 Source/Core/DolphinWX/CMakeLists.txt
  15. +77 −0 Source/Core/DolphinWX/Config/GCAdapterConfigDiag.cpp
  16. +40 −0 Source/Core/DolphinWX/Config/GCAdapterConfigDiag.h
  17. +32 −82 Source/Core/DolphinWX/ControllerConfigDiag.cpp
  18. +2 −23 Source/Core/DolphinWX/ControllerConfigDiag.h
  19. +3 −1 Source/Core/DolphinWX/DolphinWX.vcxproj
  20. +7 −1 Source/Core/DolphinWX/DolphinWX.vcxproj.filters
  21. +10 −4 Source/Core/InputCommon/CMakeLists.txt
  22. +42 −21 Source/Core/{Core/HW/SI_GCAdapter.cpp → InputCommon/GCAdapter.cpp}
  23. +10 −3 Source/Core/{Core/HW/SI_GCAdapter.h → InputCommon/GCAdapter.h}
  24. +353 −0 Source/Core/InputCommon/GCAdapter_Android.cpp
  25. +23 −0 Source/Core/InputCommon/GCAdapter_Null.cpp
  26. +2 −0 Source/Core/InputCommon/GCPadStatus.h
  27. +9 −1 Source/Core/InputCommon/InputCommon.vcxproj
  28. +3 −1 Source/Core/InputCommon/InputCommon.vcxproj.filters
  29. +4 −9 Source/Core/UICommon/UICommon.cpp
@@ -0,0 +1,91 @@
package org.dolphinemu.dolphinemu.utils;

import android.app.Activity;
import android.hardware.usb.UsbConfiguration;
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;

import java.util.HashMap;
import java.util.Iterator;

public class Java_GCAdapter {
public static UsbManager manager;
public static Activity our_activity;
static byte[] controller_payload = new byte[37];
static byte HasRead;

static UsbDeviceConnection usb_con;
static UsbInterface usb_intf;
static UsbEndpoint usb_in;
static UsbEndpoint usb_out;

public static void Shutdown()
{
usb_con.close();
}
public static int GetFD() { return usb_con.getFileDescriptor(); }

public static boolean QueryAdapter()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
Iterator it = devices.entrySet().iterator();
while (it.hasNext())
{
HashMap.Entry pair = (HashMap.Entry) it.next();
UsbDevice dev = (UsbDevice) pair.getValue();
if (dev.getProductId() == 0x0337 && dev.getVendorId() == 0x057e)
if (manager.hasPermission(dev))
return true;
}
return false;
}

public static void InitAdapter()
{
byte[] init = { 0x13 };
usb_con.bulkTransfer(usb_in, init, init.length, 0);
}

public static int Input() {
int read = usb_con.bulkTransfer(usb_in, controller_payload, controller_payload.length, 16);
return read;
}

public static int Output(byte[] rumble) {
int size = usb_con.bulkTransfer(usb_out, rumble, 5, 16);
return size;
}

public static void OpenAdapter()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
Iterator it = devices.entrySet().iterator();
while (it.hasNext())
{
HashMap.Entry pair = (HashMap.Entry)it.next();
UsbDevice dev = (UsbDevice)pair.getValue();
if (dev.getProductId() == 0x0337 && dev.getVendorId() == 0x057e) {
if (manager.hasPermission(dev))
{
usb_con = manager.openDevice(dev);
UsbConfiguration conf = dev.getConfiguration(0);
usb_intf = conf.getInterface(0);
usb_con.claimInterface(usb_intf, true);
for (int i = 0; i < usb_intf.getEndpointCount(); ++i)
if (usb_intf.getEndpoint(i).getDirection() == UsbConstants.USB_DIR_IN)
usb_in = usb_intf.getEndpoint(i);
else
usb_out = usb_intf.getEndpoint(i);

InitAdapter();
return;
}
}

}
}
}
@@ -113,6 +113,7 @@ set(SRCS ActionReplay.cpp
HW/SI_Device.cpp
HW/SI_DeviceDanceMat.cpp
HW/SI_DeviceGBA.cpp
HW/SI_DeviceGCAdapter.cpp
HW/SI_DeviceGCController.cpp
HW/SI_DeviceGCSteeringWheel.cpp
HW/SI_DeviceKeyboard.cpp
@@ -239,8 +240,7 @@ set(LIBS
if(LIBUSB_FOUND)
# Using shared LibUSB
set(LIBS ${LIBS} ${LIBUSB_LIBRARIES})
set(SRCS ${SRCS} IPC_HLE/WII_IPC_HLE_Device_hid.cpp
HW/SI_GCAdapter.cpp)
set(SRCS ${SRCS} IPC_HLE/WII_IPC_HLE_Device_hid.cpp)
endif(LIBUSB_FOUND)

set(LIBS ${LIBS} ${MBEDTLS_LIBRARIES})
@@ -254,6 +254,8 @@ void SConfig::SaveCoreSettings(IniFile& ini)
for (int i = 0; i < MAX_SI_CHANNELS; ++i)
{
core->Set(StringFromFormat("SIDevice%i", i), m_SIDevice[i]);
core->Set(StringFromFormat("AdapterRumble%i", i), m_AdapterRumble[i]);
core->Set(StringFromFormat("SimulateKonga%i", i), m_AdapterKonga[i]);
}
core->Set("WiiSDCard", m_WiiSDCard);
core->Set("WiiKeyboard", m_WiiKeyboard);
@@ -267,8 +269,6 @@ void SConfig::SaveCoreSettings(IniFile& ini)
core->Set("OverclockEnable", m_OCEnable);
core->Set("GFXBackend", m_strVideoBackend);
core->Set("GPUDeterminismMode", m_strGPUDeterminismMode);
core->Set("GameCubeAdapter", m_GameCubeAdapter);
core->Set("AdapterRumble", m_AdapterRumble);
core->Set("PerfMapDir", m_perfDir);
}

@@ -509,6 +509,8 @@ void SConfig::LoadCoreSettings(IniFile& ini)
for (int i = 0; i < MAX_SI_CHANNELS; ++i)
{
core->Get(StringFromFormat("SIDevice%i", i), (u32*)&m_SIDevice[i], (i == 0) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE);
core->Get(StringFromFormat("AdapterRumble%i", i), &m_AdapterRumble[i], true);
core->Get(StringFromFormat("SimulateKonga%i", i), &m_AdapterKonga[i], false);
}
core->Get("WiiSDCard", &m_WiiSDCard, false);
core->Get("WiiKeyboard", &m_WiiKeyboard, false);
@@ -532,8 +534,6 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("FrameSkip", &m_FrameSkip, 0);
core->Get("GFXBackend", &m_strVideoBackend, "");
core->Get("GPUDeterminismMode", &m_strGPUDeterminismMode, "auto");
core->Get("GameCubeAdapter", &m_GameCubeAdapter, false);
core->Get("AdapterRumble", &m_AdapterRumble, true);
core->Get("PerfMapDir", &m_perfDir, "");
}

@@ -264,8 +264,8 @@ struct SConfig : NonCopyable

// Input settings
bool m_BackgroundInput;
bool m_GameCubeAdapter;
bool m_AdapterRumble;
bool m_AdapterRumble[4];
bool m_AdapterKonga[4];

SysConf* m_SYSCONF;

@@ -48,9 +48,6 @@
#include "Core/HW/HW.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/ProcessorInterface.h"
#if defined(__LIBUSB__) || defined(_WIN32)
#include "Core/HW/SI_GCAdapter.h"
#endif
#include "Core/HW/SystemTimers.h"
#include "Core/HW/VideoInterface.h"
#include "Core/HW/Wiimote.h"
@@ -65,6 +62,7 @@
#endif

#include "DiscIO/FileMonitor.h"
#include "InputCommon/GCAdapter.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoBackendBase.h"
@@ -285,7 +283,7 @@ void Stop() // - Hammertime!
g_video_backend->Video_ExitLoop();
}
#if defined(__LIBUSB__) || defined(_WIN32)
SI_GCAdapter::ResetRumble();
GCAdapter::ResetRumble();
#endif

#ifdef USE_MEMORYWATCHER
@@ -630,7 +628,7 @@ void SetState(EState _State)
CPU::EnableStepping(true); // Break
Wiimote::Pause();
#if defined(__LIBUSB__) || defined(_WIN32)
SI_GCAdapter::ResetRumble();
GCAdapter::ResetRumble();
#endif
break;
case CORE_RUN:
@@ -741,7 +739,7 @@ bool PauseAndLock(bool doLock, bool unpauseOnUnlock)
g_video_backend->PauseAndLock(doLock, unpauseOnUnlock);

#if defined(__LIBUSB__) || defined(_WIN32)
SI_GCAdapter::ResetRumble();
GCAdapter::ResetRumble();
#endif
return wasUnpaused;
}
@@ -145,16 +145,10 @@
<ClCompile Include="HW\SI_DeviceAMBaseboard.cpp" />
<ClCompile Include="HW\SI_DeviceDanceMat.cpp" />
<ClCompile Include="HW\SI_DeviceGBA.cpp" />
<ClCompile Include="HW\SI_DeviceGCAdapter.cpp" />
<ClCompile Include="HW\SI_DeviceGCController.cpp" />
<ClCompile Include="HW\SI_DeviceGCSteeringWheel.cpp" />
<ClCompile Include="HW\SI_DeviceKeyboard.cpp" />
<ClCompile Include="HW\SI_GCAdapter.cpp">
<!--
Disable "nonstandard extension used : zero-sized array in struct/union" warning,
which is hit in libusb.h.
-->
<DisableSpecificWarnings>4200;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ClCompile Include="HW\Sram.cpp" />
<ClCompile Include="HW\StreamADPCM.cpp" />
<ClCompile Include="HW\SystemTimers.cpp" />
@@ -357,10 +351,10 @@
<ClInclude Include="HW\SI_DeviceAMBaseboard.h" />
<ClInclude Include="HW\SI_DeviceDanceMat.h" />
<ClInclude Include="HW\SI_DeviceGBA.h" />
<ClInclude Include="HW\SI_DeviceGCAdapter.h" />
<ClInclude Include="HW\SI_DeviceGCController.h" />
<ClInclude Include="HW\SI_DeviceGCSteeringWheel.h" />
<ClInclude Include="HW\SI_DeviceKeyboard.h" />
<ClInclude Include="HW\SI_GCAdapter.h" />
<ClInclude Include="HW\Sram.h" />
<ClInclude Include="HW\StreamADPCM.h" />
<ClInclude Include="HW\SystemTimers.h" />
@@ -447,6 +447,9 @@
<ClCompile Include="HW\SI_DeviceGBA.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
<ClCompile Include="HW\SI_DeviceGCAdapter.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
<ClCompile Include="HW\SI_DeviceGCController.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
@@ -720,9 +723,6 @@
<ClCompile Include="PowerPC\MMU.cpp">
<Filter>PowerPC</Filter>
</ClCompile>
<ClCompile Include="HW\SI_GCAdapter.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
<ClCompile Include="PowerPC\JitCommon\JitBackpatch.cpp">
<Filter>PowerPC\JitCommon</Filter>
</ClCompile>
@@ -991,6 +991,9 @@
<ClInclude Include="HW\SI_DeviceGBA.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
<ClInclude Include="HW\SI_DeviceGCAdapter.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
<ClInclude Include="HW\SI_DeviceGCController.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
@@ -1241,9 +1244,6 @@
<ClInclude Include="HW\GCKeyboard.h">
<Filter>HW %28Flipper/Hollywood%29\GCKeyboard</Filter>
</ClInclude>
<ClInclude Include="HW\SI_GCAdapter.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
<ClInclude Include="PowerPC\Jit64Common\Jit64AsmCommon.h">
<Filter>PowerPC\Jit64Common</Filter>
</ClInclude>
@@ -11,6 +11,7 @@
#include "Core/HW/SI_DeviceAMBaseboard.h"
#include "Core/HW/SI_DeviceDanceMat.h"
#include "Core/HW/SI_DeviceGBA.h"
#include "Core/HW/SI_DeviceGCAdapter.h"
#include "Core/HW/SI_DeviceGCController.h"
#include "Core/HW/SI_DeviceGCSteeringWheel.h"
#include "Core/HW/SI_DeviceKeyboard.h"
@@ -73,6 +74,9 @@ std::unique_ptr<ISIDevice> SIDevice_Create(const SIDevices device, const int por
case SIDEVICE_GC_CONTROLLER:
return std::make_unique<CSIDevice_GCController>(device, port_number);

case SIDEVICE_WIIU_ADAPTER:
return std::make_unique<CSIDevice_GCAdapter>(device, port_number);

case SIDEVICE_DANCEMAT:
return std::make_unique<CSIDevice_DanceMat>(device, port_number);

@@ -61,7 +61,8 @@ enum SIDevices : int
SIDEVICE_GC_STEERING,
SIDEVICE_DANCEMAT,
SIDEVICE_GC_TARUKONGA,
SIDEVICE_AM_BASEBOARD
SIDEVICE_AM_BASEBOARD,
SIDEVICE_WIIU_ADAPTER,
};


0 comments on commit 3424965

Please sign in to comment.
You can’t perform that action at this time.