SHARE
TWEET

Untitled

a guest Apr 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <unistd.h>
  4. #include <linux/input.h>
  5. #include <sys/ioctl.h>
  6. #include <limits.h>
  7.  
  8. int main() {
  9.  
  10.   int fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
  11.   if (fd <= 0)
  12.     return -1;
  13.  
  14.   printf("Device opened!\n");
  15.  
  16.   struct ff_effect effect = {0};
  17.   effect.type = FF_RUMBLE;
  18.   effect.id = -1;
  19.   effect.replay.length = USHRT_MAX;
  20.   effect.u.rumble.strong_magnitude = 3000;
  21.   effect.u.rumble.weak_magnitude = 3000;
  22.   if (ioctl(fd, EVIOCSFF, &effect) == -1)
  23.     return -1;
  24.  
  25.   printf("Effect uploaded!\n");
  26.  
  27.   struct input_event event = {0};
  28.   event.type = EV_FF;
  29.   event.code = effect.id;
  30.   write(fd, (const void*) &event, sizeof(event));
  31.  
  32.   printf("Effect written!\n");
  33.  
  34.   sleep(3);
  35.  
  36.   return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top