gadgets-OSC/specific/asyncburp.c

97 lines
2.3 KiB
C
Raw Normal View History

2020-10-31 08:21:20 +11:00
/*
* Joystick to Laser
* async version, with continuous refresh
* post Sonoptic 2020
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <lo/lo.h> /* OSC library */
#include "laserblast.h"
#include "burpmsg.h"
/* ------------------------------------------------------------------- */
#define LOCAL_PORT "9000"
#define REMOTE_HOST "localhost" /* just loling */
#define REMOTE_PORT "9999"
/* ------------------------------------------------------------------- */
int verbosity; /* global variable */
/* ------------------------------------------------------------------- */
static int bloub(void)
{
BurpMsg message;
message.magic = BURP_MAGIC;
display_burp_msg(&message, NULL);
return 0;
}
/* ------------------------------------------------------------------- */
static int help(int krkrkr)
{
puts("HELP ME !");
puts("\t-p NNN\t\tlocal listening port");
puts("\t-R a.b.c.d\tremote host");
puts("\t-P NNN\t\tremote port");
puts("\t-L N\t\tlaser number");
puts("\t-S N\t\tscene number");
puts("\t-v\t\tincrease verbosity");
return 1;
}
/* ------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
char *local_port = LOCAL_PORT;
char *remote_host = REMOTE_HOST;
char *remote_port = REMOTE_PORT;
int lasernumber, scenenumber;
int opt;
fprintf(stderr, "%s compiled %s at %s\n",argv[0], __DATE__, __TIME__);
/* set some default values */
lasernumber = scenenumber = 0;
/* parsing command line options */
while ((opt = getopt(argc, argv, "hp:vL:S:R:P:")) != -1) {
switch (opt) {
case 'h': if (help(0)) exit(1); break;
case 'p': local_port = optarg; break;
case 'R': remote_host = optarg; break;
case 'P': remote_port = optarg; break;
case 'L': lasernumber = atoi(optarg); break;
case 'S': scenenumber = atoi(optarg); break;
case 'v': verbosity++; break;
}
}
if (verbosity) {
fprintf(stderr, "-------------: %s\n", argv[0]);
fprintf(stderr, "pid : %d\n", getpid());
fprintf(stderr, "local port : %s\n", local_port);
fprintf(stderr, "remote : %s %s\n", remote_host, remote_port);
fprintf(stderr, "scn/laser : %d %d\n", scenenumber, lasernumber);
}
bloub();
return 2;
}
/* ------------------------------------------------------------------- */