Quote:Please post the samples of the changes you made. I'm sure it'll help others.
I've opened the sln file in VS2010. Then I did this...
ScpControl_2010/UsbHub.cs
Code:
public partial class UsbHub : ScpHub
{
public static UsbDevice[] GlobalDevice = null;
protected UsbDevice[] Device = new UsbDevice[4];
public UsbHub()
{
InitializeComponent();
if (GlobalDevice == null)
GlobalDevice = Device;
}
Explanation: added a static variable that will hold reference to all 4 usb devices. I do that because otherwise I can't reach that array where I need it.
ScpControl_2010/ScpUtil.cs
Code:
public class Ds3InputHelper
{
public static byte GetAxisValue(byte[] Input, Ds3Axis Axis)
{
return Input[(UInt32)Axis];
}
public static void SetAxisValue(byte[] Input, Ds3Axis Axis, byte Value)
{
Input[(UInt32)Axis] = Value;
}
public static Ds3Button GetButtons(byte[] Input)
{
return (Ds3Button)((Input[10] << 0) | (Input[11] << 8) | (Input[12] << 16) | (Input[13] << 24));
}
public static void SetButtons(byte[] Input, Ds3Button Buttons)
{
Input[10] = (byte)(Buttons);
Input[11] = (byte)((int)Buttons >> 8);
Input[12] = (byte)((int)Buttons >> 16);
Input[13] = (byte)((int)Buttons >> 24);
}
}
Explanation: Added a helper class so that I can easily modify button/trigger states.
ScpControl_2010/UsbDevice.cs
Code:
protected virtual void Publish()
{
m_ReportArgs.Report[0] = m_ControllerId;
m_ReportArgs.Report[1] = (Byte) m_State;
Ds3Button Buttons = Ds3InputHelper.GetButtons(m_ReportArgs.Report);
byte R2Value = Ds3InputHelper.GetAxisValue(m_ReportArgs.Report, Ds3Axis.R2);
Ds3InputHelper.SetButtons(m_ReportArgs.Report, Buttons & ~Ds3Button.R2);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.R2, 0);
if (Report != null) Report(this, m_ReportArgs);
foreach (UsbDevice device in UsbHub.GlobalDevice)
{
if (device.State == DsState.Reserved)
{
m_ReportArgs.Report[0] = device.m_ControllerId;
m_ReportArgs.Report[1] = (Byte)m_State;
Ds3InputHelper.SetButtons(m_ReportArgs.Report, Buttons & Ds3Button.R2);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.L2, 0);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.R2, R2Value);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.LX, 0);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.LY, 0);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.RX, 0);
Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.RY, 0);
if (Report != null) Report(this, m_ReportArgs);
break;
}
}
}
Explanation: Modified Publish() method so that when R2 is pressed, it's value and button state are set to zero for real joystick and then the actual value is used for the second joystick. Note that I also zero all irrelevant axis values for the second joystick.
Oh and by the way in order to have two XBOX gamepads in Control Panel -> Game Controllers I needed to unplug my DS3 controller and plug it in again. When it is unplugged, the xbox gamepad icon remains, but when I plug the controller back in, the second icon appears. Once you stop/restart the ScpService service, you need to repeat this procedure again (plug DS3, unplug, plug)
Just in case - I'm using Windows XP SP3.
EDIT: Fixed some bugs in my third code sample.
EDIT: Fixed another bug in third code sample. Things look stable now.
I've attached the binary and source files of this mod. The package also contains some explanations on how to use.