blob: 5c99a135647e5ca3db3aaecc9dad66b8e58c1934 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
void
libgamepad_construct_force_feedback_effect__(struct ff_effect *effectp, const struct ff_effect *from,
double direction, uint16_t length, uint16_t effect)
{
if (from) {
if (effectp != from)
memcpy(effectp, from, sizeof(*effectp));
} else {
memset(effectp, 0, sizeof(*effectp));
effectp->id = -1;
}
direction += (double)1 / 2;
fmod(direction, 1);
if (direction < 0)
direction = 1 - direction;
direction *= 0x10000UL;
effectp->direction = (uint16_t)direction;
effectp->replay.length = length;
effectp->type = effect;
}
|