Справочник по консольным командам Toybox для Android 12


  Ver.0.8.4     Ver.0.8.9     Pending  

Путь: Toys/Android, команды версии: Ver.4     Ver.9


sendevent

Комментарии в файле sendevent.c :

usage: sendevent DEVICE TYPE CODE VALUE

Отправляет событие ввода Linux.


usage: sendevent DEVICE TYPE CODE VALUE

Sends a Linux input event.


Исходный текст в файле sendevent.c

#define FOR_sendevent
#include "toys.h"

#include <linux/input.h>

void sendevent_main(void)
{
  int fd = xopen(*toys.optargs, O_RDWR);
  int version;
  struct input_event ev;

  if (ioctl(fd, EVIOCGVERSION, &version))
    perror_exit("EVIOCGVERSION failed for %s", *toys.optargs);
  
  memset(&ev, 0, sizeof(ev));
  // TODO: error checking and support for named constants.
  ev.type = atoi(toys.optargs[1]);
  ev.code = atoi(toys.optargs[2]);
  ev.value = atoi(toys.optargs[3]);
  xwrite(fd, &ev, sizeof(ev));
}