Skip to content

Commit

Permalink
Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.…
Browse files Browse the repository at this point in the history
…phase handled as time instead of angle; + direction clarification

Elias Vanderstuyft

Remove the dependency of the calculation of Linux "phase" on "period",
currently the "phase" parameter is interpreted as a time shift, instead of a phase shift.
The Linux input documentation is not clear about the exact units of the "phase" parameter (see http://lxr.free-electrons.com/source/include/uapi/linux/input.h?v=3.17#L1075 ),
but we're about to standardize the 'phase shift' interpretation into the Linux input documentation,
since this will ease the job of a driver to recalculate the effect's state when the user dynamically updates the "period" parameter.
  • Loading branch information
slouken committed Nov 29, 2014
1 parent a5ce9c1 commit 265b219
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/haptic/linux/SDL_syshaptic.c
Expand Up @@ -729,7 +729,6 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
static int
SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
{
Uint32 tmp;
SDL_HapticConstant *constant;
SDL_HapticPeriodic *periodic;
SDL_HapticCondition *condition;
Expand Down Expand Up @@ -807,9 +806,8 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
dest->u.periodic.period = CLAMP(periodic->period);
dest->u.periodic.magnitude = periodic->magnitude;
dest->u.periodic.offset = periodic->offset;
/* Phase is calculated based of offset from period and then clamped. */
tmp = ((periodic->phase % 36000) * dest->u.periodic.period) / 36000;
dest->u.periodic.phase = CLAMP(tmp);
/* Linux phase is defined in interval "[0x0000, 0x10000[", corresponds with "[0deg, 360deg[" phase shift. */
dest->u.periodic.phase = ((Uint32)periodic->phase * 0x10000U) / 36000;

/* Envelope */
dest->u.periodic.envelope.attack_length =
Expand Down

0 comments on commit 265b219

Please sign in to comment.