aboutsummaryrefslogtreecommitdiffstats
path: root/libgamepad_construct_force_feedback_effect__.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-25 12:35:05 +0200
committerMattias Andrée <maandree@kth.se>2022-07-25 12:35:05 +0200
commit41ae3f04fd22d22c552742458344591061822884 (patch)
tree00ef785370327ebf578efa49a38c430523c4924a /libgamepad_construct_force_feedback_effect__.c
parentAdd test-visual (diff)
downloadlibgamepad-41ae3f04fd22d22c552742458344591061822884.tar.gz
libgamepad-41ae3f04fd22d22c552742458344591061822884.tar.bz2
libgamepad-41ae3f04fd22d22c552742458344591061822884.tar.xz
m + add force feedback support
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libgamepad_construct_force_feedback_effect__.c')
-rw-r--r--libgamepad_construct_force_feedback_effect__.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libgamepad_construct_force_feedback_effect__.c b/libgamepad_construct_force_feedback_effect__.c
new file mode 100644
index 0000000..f84314d
--- /dev/null
+++ b/libgamepad_construct_force_feedback_effect__.c
@@ -0,0 +1,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 += 0.5;
+ fmod(direction, 1);
+ if (direction < 0)
+ direction = 1 - direction;
+ direction *= 0x10000UL;
+ effectp->direction = (uint16_t)direction;
+ effectp->replay.length = length;
+ effectp->type = effect;
+}