public IndexToSerial ( byte index ) : int | ||
index | byte | The Pad ID to translate. |
return | int |
protected override void OnHidReportReceived(object sender, ScpHidReport e) { // get current pad ID var serial = (int)e.PadId; if (GlobalConfiguration.Instance.ProfilesEnabled) { // pass current report through user profiles DualShockProfileManager.Instance.PassThroughAllProfiles(e); } if (e.PadState == DsState.Connected) { // translate current report to Xbox format and send it to bus device XOutputWrapper.Instance.SetState((uint)serial, _scpBus.Parse(e)); // set currently assigned XInput slot Pads[serial].XInputSlot = XOutputWrapper.Instance.GetRealIndex((uint)serial); byte largeMotor = 0; byte smallMotor = 0; // forward rumble request to pad if (XOutputWrapper.Instance.GetState((uint)serial, ref largeMotor, ref smallMotor) && (largeMotor != _vibration[serial][0] || smallMotor != _vibration[serial][1])) { _vibration[serial][0] = largeMotor; _vibration[serial][1] = smallMotor; Pads[serial].Rumble(largeMotor, smallMotor); } } else { // reset rumble/vibration to off state _vibration[serial][0] = _vibration[serial][1] = 0; _mNative[serial][0] = _mNative[serial][1] = 0; if (GlobalConfiguration.Instance.AlwaysDisconnectVirtualBusDevice) { _scpBus.Unplug(_scpBus.IndexToSerial((byte)e.PadId)); } } // skip broadcast if native feed is disabled if (GlobalConfiguration.Instance.DisableNative) { return; } // send native controller inputs to subscribed clients foreach ( var channel in _nativeFeedSubscribers.Select(nativeFeedSubscriber => nativeFeedSubscriber.Value)) { try { channel.SendAsync(e.RawBytes); } catch (AggregateException) { /* This might happen if the client disconnects while sending the * response is still in progress. The exception can be ignored. */ } } }
protected override void OnHidReportReceived(object sender, ScpHidReport e) { // get current pad ID var serial = (int)e.PadId; // get cached status data var report = _cache[serial].Report; var rumble = _cache[serial].Rumble; // pass current report through user profiles DualShockProfileManager.Instance.PassThroughAllProfiles(e); // pass current report through user scripts ScpMapperPlugins.Instance.Process(e); // translate current report to Xbox format _scpBus.Parse(e, report); if (_scpBus.Report(report, rumble) && e.PadState == DsState.Connected) { var large = rumble[3]; var small = rumble[4]; if (rumble[1] == 0x08 && (large != _mXInput[serial][0] || small != _mXInput[serial][1])) { _mXInput[serial][0] = large; _mXInput[serial][1] = small; Pads[serial].Rumble(large, small); } } if (e.PadState != DsState.Connected) { // reset rumble/vibration to off state _mXInput[serial][0] = _mXInput[serial][1] = 0; _mNative[serial][0] = _mNative[serial][1] = 0; if (GlobalConfiguration.Instance.AlwaysDisconnectVirtualBusDevice) { _scpBus.Unplug(_scpBus.IndexToSerial((byte)e.PadId)); } } // skip broadcast if native feed is disabled if (GlobalConfiguration.Instance.DisableNative) { return; } // send native controller inputs to subscribed clients foreach ( var channel in _nativeFeedSubscribers.Select(nativeFeedSubscriber => nativeFeedSubscriber.Value)) { try { channel.SendAsync(e.RawBytes); } catch (AggregateException) { /* This might happen if the client disconnects while sending the * response is still in progress. The exception can be ignored. */ } } }