/// <summary> /// Reimplements the original function which calculates/sets how much each button has been repeatedly pressed/tapped. /// </summary> /// <param name="skyPad"></param> /// <returns></returns> private static SkyPad *MakeRepeatCountImpl(SkyPad *skyPad) { // This function has been chosen because it sits between the function // that actually applies the current SkyPad inputs to the game // and the original SkyPad inputs have been assigned. // Do not mix trigger buttons and triggers. switch ((int)skyPad) { // 1P, 2P, 3P, 4P cases. case 0x00A23A68: playerOneController.SetTriggerRotations(skyPad); break; case 0x00A23AB4: playerTwoController.SetTriggerRotations(skyPad); break; case 0x00A23B00: playerThreeController.SetTriggerRotations(skyPad); break; case 0x00A23B4C: playerFourController.SetTriggerRotations(skyPad); break; } return(periMakeRepeatFunction(skyPad)); }
/// <summary> /// Re-implements the original function which calculates/sets how much each button has been repeatedly pressed/tapped. /// This is the last function executed before the game uses our inputs to perform our actions. /// We add trigger pressure support here. /// </summary> private SkyPad *MakeRepeatCountImpl(SkyPad *skyPad) { int port = -1; // Find port using address. for (int x = 0; x < InputFunctions.FinalInputs.Count; x++) { if (&InputFunctions.FinalInputs.Pointer[x] != skyPad) { continue; } port = x; break; } if (port != -1) { _controllers[port].SetTriggers(skyPad); } return(_periMakeRepeatCountHook.OriginalFunction(skyPad)); }
/// <summary> /// Sets the individual left and right trigger pressures to a Heroes peri controller "SkyPad" instance. /// </summary> /// <param name="skypad"></param> public void SetTriggerRotations(SkyPad *skypad) { if (_heroesControllerHelper.ControllerMapping.TriggerOptions.EnableTriggerRotation) { // Get trigger pressures scaled to Heroes' 255 max. var triggerPressures = GetTriggerPressures(255F); short leftTriggerPressure = (short)Math.Round(triggerPressures.leftPressure); short rightTriggerPressure = (short)Math.Round(triggerPressures.rightPressure); // Override bumper buttons if the triggers are pressed if (leftTriggerPressure > 0 || rightTriggerPressure > 0) { // Get pressures to set. if (_heroesControllerHelper.ControllerMapping.TriggerOptions.SwapTriggers) { Swap(ref leftTriggerPressure, ref rightTriggerPressure); } // Apply trigger pressures. (*skypad).TriggerPressureL = leftTriggerPressure; (*skypad).TriggerPressureR = rightTriggerPressure; } } }