mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
- rcsim: formatting code using astyle
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
45
src/rcsim.c
45
src/rcsim.c
@@ -75,7 +75,8 @@ enum initiators
|
||||
|
||||
#include "rcsim.h"
|
||||
|
||||
void usage(char *n){
|
||||
void usage(char *n)
|
||||
{
|
||||
unsigned int keynum = sizeof(keyname) / sizeof(struct key);
|
||||
unsigned int i;
|
||||
#if defined (EVENTDEV)
|
||||
@@ -96,7 +97,8 @@ void usage(char *n){
|
||||
printf("rcsim v1.2\nUsage: %s <keyname>\n\n"
|
||||
" Keys:", n);
|
||||
#endif
|
||||
for (i=0;i<keynum;){
|
||||
for (i = 0; i < keynum;)
|
||||
{
|
||||
if ((i % 4) == 0)
|
||||
printf("\n %-20s", keyname[i++].name);
|
||||
else
|
||||
@@ -180,7 +182,8 @@ int push(int ev, unsigned int code, unsigned int value)
|
||||
}
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv){
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int evd;
|
||||
unsigned long sendcode = KEY_0;
|
||||
unsigned int keys = sizeof(keyname) / sizeof(struct key);
|
||||
@@ -188,40 +191,48 @@ int main (int argc, char **argv){
|
||||
unsigned long reptime = 500;
|
||||
unsigned int offset;
|
||||
|
||||
if (argc<2||argc>4){
|
||||
if (argc < 2 || argc > 4)
|
||||
{
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
if (!strncmp(argv[1],"--help",6)||!strncmp(argv[1],"-h",2)){
|
||||
if (!strncmp(argv[1], "--help", 6) || !strncmp(argv[1], "-h", 2))
|
||||
{
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (offset=0;offset<keys;offset++){
|
||||
if (!strcmp(argv[1],keyname[offset].name)){
|
||||
for (offset = 0; offset < keys; offset++)
|
||||
{
|
||||
if (!strcmp(argv[1], keyname[offset].name))
|
||||
{
|
||||
sendcode = keyname[offset].code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset==keys){
|
||||
if (offset == keys)
|
||||
{
|
||||
printf("keyname '%s' not found in list\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc==4){
|
||||
if (argc == 4)
|
||||
{
|
||||
reptime = atol(argv[3]);
|
||||
}
|
||||
|
||||
if (argc>=3){
|
||||
if (argc >= 3)
|
||||
{
|
||||
rctime = (atol(argv[2]) * 1000) / reptime;
|
||||
}
|
||||
|
||||
#if defined (EVENTDEV)
|
||||
evd = open(EVENTDEV, O_RDWR);
|
||||
if (evd<0){
|
||||
if (evd < 0)
|
||||
{
|
||||
perror("opening " EVENTDEV " failed");
|
||||
return 1;
|
||||
}
|
||||
@@ -229,20 +240,24 @@ int main (int argc, char **argv){
|
||||
evd = -1; // close(-1) does not harm... ;)
|
||||
#endif
|
||||
printf("sending key %s for %ld seconds\n", keyname[offset].name, (reptime * rctime) / 1000);
|
||||
if (push (evd,sendcode,KEY_PRESSED)<0){
|
||||
if (push(evd, sendcode, KEY_PRESSED) < 0)
|
||||
{
|
||||
perror("writing 'key_pressed' event failed");
|
||||
close(evd);
|
||||
return 1;
|
||||
}
|
||||
while (rctime--){
|
||||
while (rctime--)
|
||||
{
|
||||
usleep(reptime * 1000);
|
||||
if (push (evd,sendcode,KEY_AUTOREPEAT)<0){
|
||||
if (push(evd, sendcode, KEY_AUTOREPEAT) < 0)
|
||||
{
|
||||
perror("writing 'key_autorepeat' event failed");
|
||||
close(evd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (push (evd,sendcode,KEY_RELEASED)<0){
|
||||
if (push(evd, sendcode, KEY_RELEASED) < 0)
|
||||
{
|
||||
perror("writing 'key_released' event failed");
|
||||
close(evd);
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user