public void RumbleEventCallback(GameEvent e) { RumbleEvent ev = (RumbleEvent)e; ShakeEvent[] evArr = RumbleEvents.ToArray(); int idxToInsert = 0; for (int i = 0; i < evArr.Length; i++) { ShakeEvent evI = evArr[i]; if (evI.intensity < ev.Intensity) { idxToInsert = i - 1; } } if (idxToInsert < 0) { idxToInsert = 0; } int id = GetShakeId(); RumbleEvents.Insert(idxToInsert, new ShakeEvent(id, ev.Intensity)); eventCtrl.BroadcastEvent(typeof(StartTimerEvent), new StartTimerEvent("rumbleEvent_" + id, ev.Duration, () => { eventCtrl.BroadcastEvent(typeof(RumbleOverEvent), new RumbleOverEvent(id)); })); }
public bool Disconnect() { if (PluggedIn) { PluggedIn = !busRef.Unplug(ID); RumbleEvent?.Invoke(0, 0); } return(PluggedIn == false); }
public void Update() { //if (!Started) return; // reset temps tempLX = -10; tempLY = -10; tempRX = -10; tempRY = -10; byte[] rumble = new byte[8]; byte[] output = new byte[28]; // Fill the output to be sent output[0] = 0x1C; output[4] = (byte)ID; output[9] = 0x14; // buttons int buttonFlags = 0x00; output[10] |= (byte)(inputs.Up ? 1 << 0 : 0); output[10] |= (byte)(inputs.Down ? 1 << 1 : 0); output[10] |= (byte)(inputs.Left ? 1 << 2 : 0); output[10] |= (byte)(inputs.Right ? 1 << 3 : 0); output[10] |= (byte)(inputs.Start ? 1 << 4 : 0); output[10] |= (byte)(inputs.Back ? 1 << 5 : 0); output[10] |= (byte)(inputs.LS ? 1 << 6 : 0); output[10] |= (byte)(inputs.RS ? 1 << 7 : 0); output[11] |= (byte)(inputs.LB ? 1 << 0 : 0); output[11] |= (byte)(inputs.RB ? 1 << 1 : 0); output[11] |= (byte)(inputs.Guide ? 1 << 2 : 0); output[11] |= (byte)(inputs.A ? 1 << 4 : 0); output[11] |= (byte)(inputs.B ? 1 << 5 : 0); output[11] |= (byte)(inputs.X ? 1 << 6 : 0); output[11] |= (byte)(inputs.Y ? 1 << 7 : 0); // triggers output[(uint)X360Axis.LT] = GetRawTrigger(inputs.LT); output[(uint)X360Axis.RT] = GetRawTrigger(inputs.RT); // Left Joystick int rawLX = GetRawAxis(inputs.LX); int rawLY = GetRawAxis(inputs.LY); output[(uint)X360Axis.LX_Lo] = (byte)((rawLX >> 0) & 0xFF); output[(uint)X360Axis.LX_Hi] = (byte)((rawLX >> 8) & 0xFF); output[(uint)X360Axis.LY_Lo] = (byte)((rawLY >> 0) & 0xFF); output[(uint)X360Axis.LY_Hi] = (byte)((rawLY >> 8) & 0xFF); // Right Joystick int rawRX = GetRawAxis(inputs.RX); int rawRY = GetRawAxis(inputs.RY); output[(uint)X360Axis.RX_Lo] = (byte)((rawRX >> 0) & 0xFF); output[(uint)X360Axis.RX_Hi] = (byte)((rawRX >> 8) & 0xFF); output[(uint)X360Axis.RY_Lo] = (byte)((rawRY >> 0) & 0xFF); output[(uint)X360Axis.RY_Hi] = (byte)((rawRY >> 8) & 0xFF); if (busRef.Report(output, rumble)) { // True on rumble state change if (rumble[1] == 0x08) { RumbleEvent?.Invoke(rumble[3], rumble[4]); } } //inputs.Reset(); }