Compare commits

..

13 Commits

Author SHA1 Message Date
tTh
494f9ebf01 cosmetic 2024-03-31 21:46:50 +02:00
tTh
e19f6b311b cosmetic again 2024-03-31 21:35:08 +02:00
tTh
593eeeddc9 cosmetic 2024-03-31 21:25:19 +02:00
tTh
7879c84020 add z & w joystick values to sender 2024-03-31 21:12:40 +02:00
tTh
16917ad551 add mandary dependencies 2024-03-31 21:08:13 +02:00
tTh
31087627ac better err msg 2024-03-30 14:42:05 +01:00
tTh
00920841d2 commit before morning nap 2023-03-17 10:33:53 +01:00
tTh
f804d2c7ab some tuning... 2023-01-13 15:36:31 +01:00
tTh
655a528192 bla 2022-10-30 22:42:30 +01:00
tth
b55f9f3575 oups... 2022-01-08 03:52:48 +01:00
tth
85c1846a0b 2020+2 a new hope ? 2022-01-08 03:34:05 +01:00
tth
95046aa71d more debug msg 2021-07-23 23:30:52 +02:00
tth
6a1fc34031 fine tuning 2021-07-23 20:41:39 +02:00
25 changed files with 336 additions and 87 deletions

View File

@@ -2,10 +2,11 @@
# umpf... # umpf...
OPTS = -Wall -g -DDEBUG_LEVEL=1 OPTS = -Wall -g -DDEBUG_LEVEL=0
DEPS = Makefile DEPS = Makefile functions/senders.h functions/joyutils.h \
functions/ncursefuncs.h
all: osc-joy osc2cursor text2osc all: osc-joy osc2cursor text2osc showbuttons
# -------------------------------------------------------------- # --------------------------------------------------------------

View File

@@ -1,6 +1,10 @@
# Gadgets autour du protocole OSC # Gadgets autour du protocole OSC
Oui, je sais, tout ça n'est pas vraiment clair. Oui, je sais, tout ça n'est pas vraiment clair. Mais je me soigne.
Première étape : consulter le
[site d'OSC](https://opensoundcontrol.stanford.edu/) pour comprendre comment
ça fonctionne.
## prérequis ## prérequis
@@ -10,6 +14,7 @@ bibliothèques de support :
``` ```
apt install liblo-tools liblo-dev apt install liblo-tools liblo-dev
apt install libasound2-dev apt install libasound2-dev
apt install ncurses-dev
``` ```
Plus le module Perl `Net::OpenSoundControl` à chercher dans le CPAN. Plus le module Perl `Net::OpenSoundControl` à chercher dans le CPAN.
@@ -21,14 +26,15 @@ cd functions
make make
``` ```
Et ensuite `make` dans le répertoire de base... Et ensuite `make` dans le répertoire de base, je pense que c'est
assez simple, et parfois ça marche...
# Les programmes # Les programmes
## osc-joy ## osc-joy
Lecture d'une manette de jeu USB et envoi des x/y et des boutons Lecture d'une manette de jeu USB et envoi des coordonnées x/y/z/w
vers un écouteur OSC. et des boutons vers un écouteur OSC.
L'option `-o NN` rajoute NN au numéro de bouton. L'option `-o NN` rajoute NN au numéro de bouton.
Voir les [générateurs](generators/) pour les détails. Voir les [générateurs](generators/) pour les détails.
@@ -41,15 +47,10 @@ Une appli ncurses trop choupie :)
Pour faire __beep__ vers Chuck... Pour faire __beep__ vers Chuck...
# Le reste ## showbuttons
Presque fini depuis quelques mois/années.
## Loth Project
Voir README.md
## Teamlaser
Voir asyncburp.c

View File

@@ -6,6 +6,8 @@ pour lancer Chuck sans connexion audio.
## dessiner.ck ## dessiner.ck
Faire des courbes de Lissajous...
## pouet.ck ## pouet.ck
## midi2osc.ck ## midi2osc.ck

View File

@@ -7,8 +7,8 @@
* *
*/ */
7777 => int OSCPort; 9000 => int OSCPort;
31000.0 => float Amplitude; 32760.0 => float Amplitude;
OscOut xmit; OscOut xmit;
float dx, dy; float dx, dy;
@@ -20,17 +20,19 @@ clear_the_screen();
for (0 => int foo; foo<25800; foo++) { for (0 => int foo; foo<25800; foo++) {
<<< foo >>>; <<< foo >>>;
Amplitude * Math.sin(foo * 0.30001) => dx; Amplitude * Math.sin(foo * 0.3001) => dx;
Amplitude * Math.cos(foo * 0.50001) => dy; Amplitude * Math.cos(foo * 0.4999) => dy;
xmit.start("/joystick/xy"); xmit.start("/joystick/xy");
Std.ftoi(dx) => xmit.add; Std.ftoi(dx) => xmit.add;
Std.ftoi(dy) => xmit.add; Std.ftoi(dy) => xmit.add;
xmit.send(); xmit.send();
0.02::second => now; 0.025::second => now;
} }
// ----------------------------------------------------
fun void clear_the_screen() fun void clear_the_screen()
{ {
xmit.start("/joystick/b"); xmit.start("/joystick/b");
@@ -40,3 +42,5 @@ xmit.start("/joystick/b");
50 => xmit.add; 0 => xmit.add; 50 => xmit.add; 0 => xmit.add;
xmit.send(); xmit.send();
} }
// ----------------------------------------------------

View File

@@ -7,8 +7,10 @@
MidiIn input; MidiIn input;
MidiMsg msg; MidiMsg msg;
OscOut xmit;
1 => int port; // please explain 1 => int port; // please explain
9000 => int OSCPort;
if (!input.open(port)) { if (!input.open(port)) {
<<< "erreur open" >>>; <<< "erreur open" >>>;
@@ -18,12 +20,20 @@ if (!input.open(port)) {
// print out device that was opened // print out device that was opened
<<< "MIDI device:", input.num(), " -> ", input.name() >>>; <<< "MIDI device:", input.num(), " -> ", input.name() >>>;
xmit.dest("localhost", OSCPort);
// infinite loop // infinite loop
while (1) { while (1) {
input => now; input => now;
while ( input.recv(msg) ) { while ( input.recv(msg) ) {
<<< msg.data1, msg.data2, msg.data3 >>>; <<< msg.data1, msg.data2, msg.data3 >>>;
xmit.start("/joystick/b");
} }

View File

@@ -1,4 +1,5 @@
/* faire pouet avec chuck osc et un joystick /*
faire pouet avec chuck osc et un joystick
----------------------------------------- -----------------------------------------
reception des boutons reception des boutons
*/ */
@@ -9,7 +10,7 @@ SqrOsc sl => Envelope envl => dac.left;
SawOsc sr => Envelope envr => dac.right; SawOsc sr => Envelope envr => dac.right;
0.5 => sl.gain => sr.gain; 0.5 => sl.gain => sr.gain;
0.01 => envl.time; 0.06 => envr.time; 0.22 => envl.time; 0.22 => envr.time;
OscIn oscin; OscMsg msg; OscIn oscin; OscMsg msg;
@@ -33,7 +34,7 @@ while( true ) {
else { else {
1 => envl.keyOff => envr.keyOff; 1 => envl.keyOff => envr.keyOff;
} }
0.2::second => now; 0.1::second => now;
} }
} }

View File

@@ -4,7 +4,7 @@
*/ */
7777 => int InPort; 7777 => int InPort;
15.55 => float divisor;
SqrOsc sl => dac.left; SqrOsc sl => dac.left;
SawOsc sr => dac.right; SawOsc sr => dac.right;
0.0 => sl.gain => sr.gain; 0.0 => sl.gain => sr.gain;
@@ -27,8 +27,8 @@ while( true ) {
msg.getInt(0) => x; msg.getInt(0) => x;
msg.getInt(1) => y; msg.getInt(1) => y;
<<< "got (via ", InPort,") ", x, y >>>; <<< "got (via ", InPort,") ", x, y >>>;
x => sl.freq; x/12.0 => sl.freq;
y => sr.freq; y/12.0 => sr.freq;
} }
} }

View File

@@ -24,7 +24,10 @@
\section{Open Sound Control} \section{Open Sound Control}
De quoi parle-t-on exactement ? De quoi parle-t-on exactement ?
\vspace{1em} \vspace{5em}
OSC est un protocole réseau basé sur UDP\index{UDP}.
% ------------------------------------------------------------------- % -------------------------------------------------------------------
\section{Example} \section{Example}

4
functions/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
mkbigchars
t

BIN
functions/8x8thin Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
all: libpocosc.a all: libpocosc.a
OPTS = -Wall -g -DDEBUG_LEVEL=1 OPTS = -Wall -g -DDEBUG_LEVEL=0
senders.o: senders.c senders.h Makefile senders.o: senders.c senders.h Makefile
gcc ${OPTS} -c $< gcc ${OPTS} -c $<
@@ -23,6 +23,26 @@ joyutils.o: joyutils.c joyutils.h Makefile
ncursefuncs.o: ncursefuncs.c ncursefuncs.h Makefile ncursefuncs.o: ncursefuncs.c ncursefuncs.h Makefile
gcc ${OPTS} -c $< gcc ${OPTS} -c $<
#
libpocosc.a: senders.o alsaseq.o serial.o ncursefuncs.o \ libpocosc.a: senders.o alsaseq.o serial.o ncursefuncs.o \
joyutils.o joyutils.o bigchars.o
ar r $@ $? ar r $@ $?
#
mkbigchars: mkbigchars.c Makefile
gcc ${OPTS} $< -o $@
chars8x8.def: mkbigchars Makefile
./mkbigchars 8x8thin $@
bigchars.o: bigchars.c chars8x8.def ncursefuncs.h Makefile
gcc ${OPTS} -c $<
# programmes de test
t: t.c Makefile libpocosc.a ncursefuncs.h
gcc $(OPTS) $< libpocosc.a -o $@

44
functions/bigchars.c Normal file
View File

@@ -0,0 +1,44 @@
/*
! ncurses widgets for poc-osc
!
! nnnnn n nnnn
! n n n n n
! nnnnn n n
! n n n n nnn
! n n n n n
! nnnnn n nnnn
!
!
! nnnn n n nn nnnnn nnnn
! n n n n n n n n n
! n nnnnnn n n n n nnnn
! n n n nnnnnn nnnnn n
! n n n n n n n n n n
! nnnn n n n n n n nnnn
!
*/
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <signal.h>
#include <locale.h>
#include "ncursefuncs.h"
/* XXX */
#include "chars8x8.def"
extern int verbosity; /* to be declared public near main() */
/* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */
int essai_bigchars(char *texte, int stand)
{
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, texte, stand);
return -1;
}
/* ----------------------------------------------------------------- */

View File

@@ -28,6 +28,7 @@ else {
} }
return "???"; return "???";
} }
/* ----------------------------------------------------------------- */
void dump_my_joystick(char *joy_device) void dump_my_joystick(char *joy_device)
{ {
int joy_fd, foo; int joy_fd, foo;
@@ -47,23 +48,19 @@ fprintf(stderr, "Name: \"%s\"\n", joy_name);
for (;;) { for (;;) {
foo = read(joy_fd, &js, sizeof(struct js_event)); foo = read(joy_fd, &js, sizeof(struct js_event));
if ( ! flag ) {
debut = js.time;
flag = 1;
}
if (8 != foo) { if (8 != foo) {
fprintf(stderr, "%s: err reading joy\n", __func__); fprintf(stderr, "%s: err reading joy\n", __func__);
exit(1); exit(1);
} }
if ( ! flag ) {
printf("%8lu %4d / %-8s %2d %7d\n", debut = js.time;
flag = 1;
}
printf("%8lu %4d %-8s %3d %7d\n",
js.time-debut, js.time-debut,
js.type, type2txt(js.type), js.type, type2txt(js.type),
js.number, js.value); js.number, js.value);
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */

77
functions/mkbigchars.c Normal file
View File

@@ -0,0 +1,77 @@
/*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
/* ----------------------------------------------------------------- */
int make_bigfont_def(char *input, char *deffile)
{
FILE *fp;
int fd, idx, foo;
unsigned char buffer[2048];
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, input, deffile);
/*
* load the binary font datas
*/
fd = open(input, O_RDONLY, 0);
if (-1 == fd) {
perror(input);
exit(1);
}
foo = read(fd, buffer, 2048);
if (2048 != foo) {
fprintf(stderr, "%s: read %d bytes, 2048 expected\n", __func__, foo);
close(fd);
return 1;
}
close(fd);
/*
* write the definition file as a .h c-file
*/
fp = fopen(deffile, "w");
if (NULL == fp) {
perror(deffile);
exit(1);
}
fprintf(fp, "/*\n * ! ! ! GENERATED FILE ! ! !\n*/\n");
for (idx=0; idx-256; idx++) {
fprintf(fp, "/*\n *\t***\t%3d 0x%02x\n */\n", idx, idx);
fprintf(fp, "\n");
}
fprintf(fp, "/* yolo? */\n");
fclose(fp);
return 0;
}
/* ----------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
if (3 != argc) {
fprintf(stderr, "ERR: %s need two filenames\n", argv[0]);
exit(1);
}
foo = make_bigfont_def(argv[1], argv[2]);
if (foo) {
fprintf(stderr, "got %d from font converter.\n", foo);
exit(1);
}
return 0;
}
/* ----------------------------------------------------------------- */

View File

@@ -49,7 +49,7 @@ char ligne[81];
int foo; int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "--> %s ( '%s' %d )\n", __func__, title, unused); fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, title, unused);
#endif #endif
if (verbosity) { if (verbosity) {
@@ -68,10 +68,10 @@ return 0; /* this is not a magic number */
int blast_error_message(char *txt, int violence, int unused) int blast_error_message(char *txt, int violence, int unused)
{ {
int line, foo; int line, foo;
char buff[60]; char buff[80];
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "--> %s ( '%s' %d %d )\n", __func__, fprintf(stderr, ">>> %s ( '%s' %d %d )\n", __func__,
txt, violence, unused); txt, violence, unused);
#endif #endif
@@ -82,26 +82,42 @@ if (verbosity > 3) {
} }
standout(); standout();
// setup our part of screen
// clear our part of screen
for (foo=0; foo<COLS; foo++) { for (foo=0; foo<COLS; foo++) {
mvaddch(line, foo, '_'); mvaddch(line, foo, '|');
} }
mvaddstr(line, 0, "SYS$MSG_| ");
mvaddstr(line, 0, "SYS$MSG_ "); mvaddstr(line, 10, txt);
mvaddstr(line, 9, txt);
standend(); standend();
refresh();
return 0; return 0;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
int erase_error_message(int ascii)
{
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%c' )\n", __func__, ascii);
#endif
standout();
// clear our part of screen
for (foo=0; foo<COLS; foo++) {
mvaddch(LINES-1, foo, ascii);
}
standend(); refresh();
return 0;
}
/* ----------------------------------------------------------------- */
/* warning: only use the bit 0 of the 'state' arg */ /* warning: only use the bit 0 of the 'state' arg */
int draw_a_button(WINDOW *w, int lig, int col, char *txt, int state) int draw_a_button(WINDOW *w, int lig, int col, char *txt, int state)
{ {
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "--> %s ( %3d %3d '%s' %d )\n", __func__, fprintf(stderr, ">>> %s ( %3d %3d '%s' %d )\n", __func__,
lig, col, txt, state); lig, col, txt, state);
#endif #endif

View File

@@ -9,6 +9,13 @@ void endcurses(int p);
int draw_main_screen(char *title, int unused); int draw_main_screen(char *title, int unused);
int blast_error_message(char *txt, int violence, int unused); int blast_error_message(char *txt, int violence, int unused);
int erase_error_message(int ascii);
/* warning: only use the bit 0 of the 'state' arg */ /* warning: only use the bit 0 of the 'state' arg */
int draw_a_button(WINDOW *w, int lig, int col, char *txt, int state); int draw_a_button(WINDOW *w, int lig, int col, char *txt, int state);
/*
* bigchars.c
*/
int essai_bigchars(char *texte, int stand);

View File

@@ -22,6 +22,19 @@ if (verbosity > 2) {
return foo; return foo;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/* function added Sun Mar 31 18:51:46 UTC 2024 */
int send_data_zw(lo_address dst, int w, int z)
{
int foo;
if (verbosity) fprintf(stderr, "sending w z %7d %7d\n", w, z);
foo = lo_send(dst, "/joystick/wz", "ii", w, z);
if (verbosity > 2) {
fprintf(stderr, "lo_send -> %d\n", foo);
}
return foo;
}
/* ----------------------------------------------------------------- */
int send_data_button(lo_address dst, int n, int v) int send_data_button(lo_address dst, int n, int v)
{ {
int foo; int foo;

View File

@@ -5,6 +5,7 @@
/* ------------------------------------------------------- */ /* ------------------------------------------------------- */
int send_data_xy(lo_address dst, int x, int y); int send_data_xy(lo_address dst, int x, int y);
int send_data_zw(lo_address dst, int w, int z);
int send_data_button(lo_address dst, int n, int v); int send_data_button(lo_address dst, int n, int v);
int send_data_id(lo_address dst, char *s); int send_data_id(lo_address dst, char *s);

21
functions/t.c Normal file
View File

@@ -0,0 +1,21 @@
/*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "ncursefuncs.h"
/* ----------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
foo = essai_bigchars("foo", 0);
fprintf(stderr, " essai bigchars -> %d\n", foo);
return 0;
}
/* ----------------------------------------------------------------- */

View File

@@ -21,7 +21,7 @@ cpan[3]> install Net::OpenSoundControl
Et voilà... Et voilà...
## moresinus.pl ## moresinus.pl
Options : `-d host:port` et `-v` Options : `-d host:port` et `-v`

View File

@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
{ {
int foo, joy_fd; int foo, joy_fd;
struct js_event js; struct js_event js;
int x_pos, y_pos, flag; int x_pos, y_pos, z_pos, w_pos, what;
char joy_name[128]; char joy_name[128];
int opt; int opt;
char *remote_host = REMOTE_HOST; char *remote_host = REMOTE_HOST;
@@ -84,34 +84,36 @@ if (do_dump) {
} }
if (verbosity) { if (verbosity) {
fprintf(stderr, "%s is sending to %s:%s\n", argv[0], fprintf(stderr, " %s is sending to %s:%s\n", argv[0],
remote_host, remote_port); remote_host, remote_port);
fprintf(stderr, " the stick '%s' is on %s\n", my_id, joy_device); fprintf(stderr, " the stick '%s' is on %s\n", my_id, joy_device);
} }
lo_address t = lo_address_new(remote_host, remote_port); lo_address t = lo_address_new(remote_host, remote_port);
/*
* XXX no error check ? wtf ?
*/
if( ( joy_fd = open(joy_device , O_RDONLY)) == -1 ) { if( ( joy_fd = open(joy_device , O_RDONLY)) == -1 ) {
fprintf(stderr, "Couldn't open %s\n", joy_device); fprintf(stderr, "%s: Couldn't open %s\n", argv[0], joy_device);
exit(1); exit(1);
} }
if (verbosity) { if (verbosity) {
if (ioctl(joy_fd, JSIOCGNAME(sizeof(joy_name)), joy_name) < 0) if (ioctl(joy_fd, JSIOCGNAME(sizeof(joy_name)), joy_name) < 0)
strncpy(joy_name, "Unknown", sizeof(joy_name)); strncpy(joy_name, "Unknown", sizeof(joy_name));
fprintf(stderr, "Name: %s\n", joy_name); fprintf(stderr, " Name: %s\n", joy_name);
} }
send_data_id(t, my_id); send_data_id(t, my_id);
x_pos = y_pos = 0; x_pos = y_pos = z_pos = w_pos = 0;
for (;;) { for (;;) {
foo = read(joy_fd, &js, sizeof(struct js_event)); foo = read(joy_fd, &js, sizeof(struct js_event));
if (8 != foo) { if (8 != foo) {
fprintf(stderr, "err reading joy\n"); fprintf(stderr, "err reading joy\n");
exit(1); exit(1);
} }
/* calibration datas ignored */ /* calibration datas ignored */
if (js.type > 128) continue; if (js.type > 128) continue;
@@ -119,24 +121,37 @@ for (;;) {
fprintf(stderr, "%10u %2d %2d %7d\n", fprintf(stderr, "%10u %2d %2d %7d\n",
js.time, js.type, js.number, js.value); js.time, js.type, js.number, js.value);
} }
if (2==js.type) { /* oscillating stick */ if (2==js.type) { /* oscillating stick */
flag = 0; what = 0;
switch (js.number) switch (js.number) {
{
case 0: case 0:
x_pos = js.value; x_pos = js.value;
flag = 1; what = 1;
break; break;
case 1: case 1:
y_pos = js.value; y_pos = js.value;
flag = 1; what = 1;
break;
case 2:
z_pos = js.value;
what = 2;
break;
case 3:
w_pos = js.value;
what = 2;
break; break;
} }
/* now, send the datas */
if (flag) { // fprintf(stderr, "\t\twhat = %d\n", what);
switch (what) {
case 1:
foo = send_data_xy(t, x_pos, y_pos); foo = send_data_xy(t, x_pos, y_pos);
flag = 0; what = 0;
break;
case 2:
foo = send_data_zw(t, z_pos, w_pos);
what = 0;
break;
} }
} }
@@ -144,7 +159,6 @@ for (;;) {
foo = send_data_button(t, js.number+button_offset, foo = send_data_button(t, js.number+button_offset,
js.value); js.value);
} }
} }
return 0; return 0;

View File

@@ -46,6 +46,8 @@ printf(stderr, "%s : %s %s %d\n", __func__, path, types, argc);
if (verbosity) { if (verbosity) {
sprintf(ligne, "%s %s %s %d\n", __func__, path, types, argc); sprintf(ligne, "%s %s %s %d\n", __func__, path, types, argc);
mvaddstr(2, 2, ligne); mvaddstr(2, 2, ligne);
sprintf(ligne, "button : %6d %6d", argv[0]->i, argv[1]->i);
mvaddstr(3, 2, ligne);
refresh(); refresh();
} }
@@ -54,6 +56,8 @@ if (-1 == erase_button) return 0;
if ( (argv[0]->i == erase_button) && if ( (argv[0]->i == erase_button) &&
(argv[1]->i == 0) ) { (argv[1]->i == 0) ) {
must_erase = 1; must_erase = 1;
mvaddstr(3, 2, "KILL ! KILL !");
refresh();
} }
return 0; return 0;
@@ -116,7 +120,7 @@ if (verbosity) {
} }
/* erase the old spot */ /* erase the old spot */
if (old_l) mvaddch(old_l, old_c, current_char); if (old_l || old_c) mvaddch(old_l, old_c, current_char);
standout(); standout();
mvaddch(cur_l, cur_c, '#'); mvaddch(cur_l, cur_c, '#');
@@ -169,9 +173,9 @@ fprintf(stderr, "erase %d\n", erase_button);
st = lo_server_thread_new(local_port, error); st = lo_server_thread_new(local_port, error);
foo = initcurses(); foo = initcurses();
sprintf(ligne, ":%s ", local_port); sprintf(ligne, ":%s e=%d ", local_port, erase_button);
foo = draw_main_screen(ligne, 0); foo = draw_main_screen(ligne, 0);
if (verbosity) fprintf(stderr, "dms %d\n", foo); // if (verbosity) fprintf(stderr, "dms %d\n", foo);
lo_server_thread_add_method(st, "/joystick/xy", "ii", xy_handler, NULL); lo_server_thread_add_method(st, "/joystick/xy", "ii", xy_handler, NULL);
lo_server_thread_add_method(st, "/joystick/b", "ii", button_handler, NULL); lo_server_thread_add_method(st, "/joystick/b", "ii", button_handler, NULL);

View File

@@ -67,13 +67,15 @@ int display_a_value(int lig, short value, char letter)
char buffer[80], symbol; char buffer[80], symbol;
int width, seuil, foo; int width, seuil, foo;
width = 60;
sprintf(buffer, "%6d [", value); sprintf(buffer, "%6d [", value);
mvaddstr(lig, 4, buffer); mvaddstr(lig, 4, buffer);
mvaddch(lig, width+12, ']');
if (value < 0) symbol = '-'; if (value < 0) symbol = '-';
else symbol = '+'; else symbol = '+';
width = 60;
seuil = (abs((int)value) * width) / 32767; seuil = (abs((int)value) * width) / 32767;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
@@ -141,8 +143,7 @@ int do_animation(int cycles, int speed)
(void)initcurses(); (void)initcurses();
animation(cycles, speed); animation(cycles, speed);
sleep(2); sleep(2); exit(0);
exit(0);
return 0; return 0;
} }
@@ -230,8 +231,8 @@ return 0;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
static void help(int k) static void help(int k)
{ {
puts("\t * showbuttons " __DATE__ " *"); puts("\t*** showbuttons " __DATE__ " ***");
puts("\t-a\tshow animation"); puts("\t-a\tshow animation and exit");
puts("\t-p\tlocal udp port ("LOCAL_PORT")"); puts("\t-p\tlocal udp port ("LOCAL_PORT")");
puts("\t-v\tenhance my verbosity"); puts("\t-v\tenhance my verbosity");
exit(0); exit(0);
@@ -273,7 +274,7 @@ if (foo) {
/* set up the pretty screen user interface */ /* set up the pretty screen user interface */
foo = initcurses(); foo = initcurses();
sprintf(ligne, ":%s ", local_port); sprintf(ligne, "showbuttons port=%s ", local_port);
foo = draw_main_screen(ligne, 0); foo = draw_main_screen(ligne, 0);
if (foo) { if (foo) {
endwin(); endwin();
@@ -294,9 +295,14 @@ lo_server_thread_add_method(st, "/joystick/xy", "ii",
xy_handler, NULL); xy_handler, NULL);
lo_server_thread_start(st); lo_server_thread_start(st);
sprintf(ligne, "process %d on board, captain", getpid()); #if DEBUG_LEVEL
fprintf(stderr, "pid %d: osc server thread started\n", getpid());
#endif
sprintf(ligne, "process %d on board, captain ", getpid());
blast_error_message(ligne, 0, 0); blast_error_message(ligne, 0, 0);
sleep(1); sleep(3);
erase_error_message(' ');
for (;;) { for (;;) {
/* wait for un event from liblo threads */ /* wait for un event from liblo threads */

View File

@@ -17,7 +17,7 @@
int verbosity = 0; int verbosity = 0;
char *my_id = MY_TEXT_ID; char *my_id = MY_TEXT_ID;
int wait_time = 100; /* in milliseconds */ int wait_time = 80; /* in milliseconds */
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
int megaloop(FILE *fp, lo_address loa) int megaloop(FILE *fp, lo_address loa)
@@ -38,7 +38,7 @@ while (EOF != (caractere=getc(fp))) {
char_count++; char_count++;
if (verbosity) fprintf(stderr, "car = %4d %c\n", if (verbosity) fprintf(stderr, "char = %4d %c\n",
caractere, caractere); caractere, caractere);
if (isalpha(caractere)) { if (isalpha(caractere)) {

View File

@@ -79,12 +79,15 @@ do {
if (verbosity) { if (verbosity) {
gettimeofday(&tp, NULL); gettimeofday(&tp, NULL);
curtime = tp.tv_sec + tp.tv_usec / 1e6; curtime = tp.tv_sec + tp.tv_usec / 1e6;
printf("----+ %4ld %5d b ts: %.3f\n", printf("----+ frame %4ld %5d bytes t= %.3f sec.\n",
serial, foo, curtime - starttime); serial, foo, curtime - starttime);
/*
* MUST display ip:port of the sender !
*/
} }
for (bar=0; bar<=foo; bar+=16) { for (bar=0; bar<=foo; bar+=16) {
printf("%3ld | ", bar); printf("%3d | ", bar);
dumpln(buffer+bar); dumpln(buffer+bar);
} }
serial++; serial++;