| 1690 | } |
| 1691 | |
| 1692 | void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) |
| 1693 | { |
| 1694 | SDL_HapticEffect tempEffect; |
| 1695 | SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); |
| 1696 | tempEffect.type = SDL_HAPTIC_SPRING; |
| 1697 | tempEffect.condition.type = SDL_HAPTIC_SPRING; |
| 1698 | tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; |
| 1699 | tempEffect.condition.delay = 0; |
| 1700 | tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength; |
| 1701 | tempEffect.condition.direction.dir[0] = 1; |
| 1702 | tempEffect.constant.direction.dir[1] = 0; //Y Position |
| 1703 | |
| 1704 | SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. |
| 1705 | SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); |
| 1706 | SHORT range = maxForce - minForce; |
| 1707 | SHORT coeff = (SHORT)(strength * range + minForce); |
| 1708 | if (coeff < 0) |
| 1709 | { |
| 1710 | coeff = 32767; |
| 1711 | } |
| 1712 | |
| 1713 | tempEffect.condition.left_coeff[0] = (short)(coeff); |
| 1714 | tempEffect.condition.right_coeff[0] = (short)(coeff); |
| 1715 | tempEffect.condition.left_sat[0] = (short)(coeff * 2.0); //Needed for Logitech G920 wheel |
| 1716 | tempEffect.condition.right_sat[0] = (short)(coeff * 2.0); //Needed for Logitech G920 wheel |
| 1717 | tempEffect.condition.center[0] = 0; |
| 1718 | |
| 1719 | SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect); |
| 1720 | SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1); |
| 1721 | } |
| 1722 | |
| 1723 | void TriggerSpringEffectInfinite(double strength) |
| 1724 | { |
no outgoing calls
no test coverage detected