Compare commits
22 Commits
1fc36d8790
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
494f9ebf01 | ||
|
|
e19f6b311b | ||
|
|
593eeeddc9 | ||
|
|
7879c84020 | ||
|
|
16917ad551 | ||
|
|
31087627ac | ||
|
|
00920841d2 | ||
|
|
f804d2c7ab | ||
|
|
655a528192 | ||
|
|
b55f9f3575 | ||
|
|
85c1846a0b | ||
|
|
95046aa71d | ||
|
|
6a1fc34031 | ||
|
|
7c91072873 | ||
|
|
2e9b344922 | ||
|
|
11cd7dbf5e | ||
|
|
2a8c892e33 | ||
|
|
3301315367 | ||
|
|
030472e7d9 | ||
|
|
47e6f7a690 | ||
|
|
dea4232d8e | ||
|
|
5b6359ce9e |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,6 +22,8 @@ tools/wait-for-joystick
|
|||||||
tools/*.o
|
tools/*.o
|
||||||
|
|
||||||
Gaby/*.[oa]
|
Gaby/*.[oa]
|
||||||
|
Gaby/gabylaser
|
||||||
|
Gaby/DUMP*
|
||||||
|
|
||||||
specific/joy2laser
|
specific/joy2laser
|
||||||
specific/asyncburp
|
specific/asyncburp
|
||||||
|
|||||||
@@ -4,3 +4,27 @@
|
|||||||
# Piloter le laser de Gaby
|
# Piloter le laser de Gaby
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
|
|
||||||
|
DEPS = Makefile transmit.h receive-osc.h
|
||||||
|
|
||||||
|
receive-osc.o: receive-osc.c $(DEPS)
|
||||||
|
gcc -Wall -c $<
|
||||||
|
|
||||||
|
transmit.o: transmit.c $(DEPS)
|
||||||
|
gcc -Wall -c $<
|
||||||
|
|
||||||
|
audiodrive.o: audiodrive.c $(DEPS)
|
||||||
|
gcc -Wall -c $<
|
||||||
|
|
||||||
|
# ------------------------------------------------------
|
||||||
|
|
||||||
|
gabylaser.o: gabylaser.c $(DEPS)
|
||||||
|
gcc -Wall -c $<
|
||||||
|
|
||||||
|
OBJS = receive-osc.o transmit.o
|
||||||
|
|
||||||
|
gabylaser: gabylaser.o $(DEPS) $(OBJS)
|
||||||
|
gcc -Wall $< $(OBJS) -llo -o $@
|
||||||
|
|
||||||
|
# ------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
Gaby/audiodrive.c
Normal file
13
Gaby/audiodrive.c
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* LE LASER DE GABY
|
||||||
|
*
|
||||||
|
* +--------------------------------------------------+
|
||||||
|
* | pilotage du bouzin par la sortie audio (wtf?) |
|
||||||
|
* +--------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**** note de l'auteur : on devrait essayer de faire ça en chuck ***/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
8
Gaby/burps.sh
Executable file
8
Gaby/burps.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
for x in $(seq -32000 133 32000)
|
||||||
|
do
|
||||||
|
echo $x
|
||||||
|
oscsend localhost 9001 /joystick/xy ii $x -9999
|
||||||
|
done
|
||||||
102
Gaby/gabylaser.c
Normal file
102
Gaby/gabylaser.c
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* LE LASER DE GABY
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <lo/lo.h>
|
||||||
|
|
||||||
|
#include "transmit.h"
|
||||||
|
#include "receive-osc.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
static void error(int num, const char *msg, const char *path)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "liblo server error %d in path %s : %s\n", num, path, msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
int init_rx_osc(char *port)
|
||||||
|
{
|
||||||
|
lo_server_thread st;
|
||||||
|
|
||||||
|
st = lo_server_thread_new(port, error);
|
||||||
|
|
||||||
|
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_start(st);
|
||||||
|
|
||||||
|
fprintf(stderr, "%s [done]\n", __func__);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
static void print_lo_version(char *bla)
|
||||||
|
{
|
||||||
|
#define SZ 100
|
||||||
|
char str[SZ];
|
||||||
|
char extra[SZ];
|
||||||
|
|
||||||
|
lo_version(str, SZ, 0, 0, extra, SZ, 0, 0, 0);
|
||||||
|
|
||||||
|
fprintf(stderr, "%s: liblo v%s %s\n", bla, str, extra);
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
int help(int k)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "help = %d\n", k);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *local_port = "9001";
|
||||||
|
int bauds = 0;
|
||||||
|
int foo, opt;
|
||||||
|
|
||||||
|
fprintf(stderr, "GabyLaser - compiled %s %s\n", __DATE__, __TIME__);
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "hp:v")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'h': if (help(0)) exit(1); break;
|
||||||
|
case 'p': local_port = optarg; break;
|
||||||
|
case 'v': verbosity++; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity) print_lo_version(argv[0]);
|
||||||
|
|
||||||
|
foo = init_rx_osc(local_port);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "init rx osc -> %d\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = init_transmit("./DUMP", bauds);
|
||||||
|
if (foo < 0) {
|
||||||
|
fprintf(stderr, "init transmit -> %d\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* infinite loop is infinite
|
||||||
|
*/
|
||||||
|
for (;;) {
|
||||||
|
if (verbosity)
|
||||||
|
fprintf(stderr, "t = %ld\n", time(NULL));
|
||||||
|
sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
56
Gaby/receive-osc.c
Normal file
56
Gaby/receive-osc.c
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* LE LASER DE GABY
|
||||||
|
*
|
||||||
|
* +--------------------------------------------------+
|
||||||
|
* | reception des trames osc depuis le grand monde |
|
||||||
|
* +--------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <lo/lo.h>
|
||||||
|
|
||||||
|
#include "receive-osc.h"
|
||||||
|
#include "transmit.h"
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static int old_x, old_y;
|
||||||
|
|
||||||
|
int xy_handler(const char *path, const char *types, lo_arg ** argv,
|
||||||
|
int argc, void *data, void *user_data)
|
||||||
|
{
|
||||||
|
int val_x, val_y;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
// fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, path, types);
|
||||||
|
|
||||||
|
val_x = argv[0]->i; val_y = argv[1]->i;
|
||||||
|
|
||||||
|
fprintf(stderr, "osc -> %7d %7d\n", val_x, val_y);
|
||||||
|
|
||||||
|
if (old_x != val_x) {
|
||||||
|
foo = send_position('X', val_x);
|
||||||
|
old_x = val_x;
|
||||||
|
}
|
||||||
|
if (old_y != val_y) {
|
||||||
|
foo = send_position('Y', val_y);
|
||||||
|
old_y = val_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
int button_handler(const char *path, const char *types, lo_arg ** argv,
|
||||||
|
int argc, void *data, void *user_data)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, path, types);
|
||||||
|
|
||||||
|
foo = send_button(argv[0]->i, argv[1]->i);
|
||||||
|
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
12
Gaby/receive-osc.h
Normal file
12
Gaby/receive-osc.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int xy_handler(const char *path, const char *types, lo_arg ** argv,
|
||||||
|
int argc, void *data, void *user_data);
|
||||||
|
|
||||||
|
|
||||||
|
int button_handler(const char *path, const char *types, lo_arg ** argv,
|
||||||
|
int argc, void *data, void *user_data);
|
||||||
|
|
||||||
120
Gaby/transmit.c
120
Gaby/transmit.c
@@ -1,6 +1,126 @@
|
|||||||
/*
|
/*
|
||||||
|
* LE LASER DE GABY
|
||||||
|
*
|
||||||
* +---------------------------------------------+
|
* +---------------------------------------------+
|
||||||
* | transmission des commandes vers l'arduino |
|
* | transmission des commandes vers l'arduino |
|
||||||
* +---------------------------------------------+
|
* +---------------------------------------------+
|
||||||
|
|
||||||
|
$ oscsend localhost 9001 /joystick/xy ii 32000 -2210
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
|
#include "../functions/serial.h"
|
||||||
|
#include "transmit.h"
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static int fdtx = -1;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* parametres :
|
||||||
|
* fname: a file for dumping data or a serial device
|
||||||
|
* bauds: speed of serial port, 0 for a file dump
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int init_transmit(char *fname, int bauds)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int baudsymb;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, bauds);
|
||||||
|
|
||||||
|
if (0 == bauds) {
|
||||||
|
/* open as a dump file */
|
||||||
|
fd = open(fname, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror(fname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
/* open as as a serial out to Arduino */
|
||||||
|
|
||||||
|
fprintf(stderr, "bauds are %d, exiting\n", bauds);
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fdtx = fd;
|
||||||
|
fprintf(stderr, "%s: fd is %d\n", __func__, fdtx);
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* ici on présupoose que la valeur est un "short int"
|
||||||
|
* donc 2^16 valeurs -32768 32767
|
||||||
|
*/
|
||||||
|
int send_position(char xy, int value)
|
||||||
|
{
|
||||||
|
char message[100];
|
||||||
|
char val8;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
if (fdtx < 0) {
|
||||||
|
fprintf(stderr, "%s: fdtx not initialized !\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xy != 'X' && xy != 'Y') {
|
||||||
|
fprintf(stderr, "%s: invalid xy tag '%c'\n", __func__, xy);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
val8 = (char)(value / 256); /* -> signed byte */
|
||||||
|
sprintf(message, "%c%02x", xy, (unsigned char)val8);
|
||||||
|
fprintf(stderr, " %c %8d %8d %s\n", xy, value, val8, message);
|
||||||
|
foo = write(fdtx, message, 3);
|
||||||
|
if (3 != foo) {
|
||||||
|
perror("write ?");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* comment gerer le up/down des boutons ?
|
||||||
|
*/
|
||||||
|
|
||||||
|
int send_button(int number, int state)
|
||||||
|
{
|
||||||
|
char message[100];
|
||||||
|
|
||||||
|
if (fdtx < 0) {
|
||||||
|
fprintf(stderr, "%s: fdtx not initialized !\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number<0 || number>16) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(message, "T%01x%1x", number, state);
|
||||||
|
fprintf(stderr, "%s ----> '%s'\n", __func__, message);
|
||||||
|
foo = write(fdtx, message, 3);
|
||||||
|
if (3 != foo) {
|
||||||
|
perror("write ?");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
|||||||
13
Gaby/transmit.h
Normal file
13
Gaby/transmit.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* LE LASER DE GABY
|
||||||
|
*
|
||||||
|
* +---------------------------------------------+
|
||||||
|
* | transmission des commandes vers l'arduino |
|
||||||
|
* +---------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
int init_transmit(char *fname, int k);
|
||||||
|
int send_position(char xy, int value);
|
||||||
|
|
||||||
|
int send_button(int number, int state);
|
||||||
|
|
||||||
7
Makefile
7
Makefile
@@ -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
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
25
README.md
25
README.md
@@ -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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
chuck/README.md
Normal file
16
chuck/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# trucs en ChucK
|
||||||
|
|
||||||
|
Attention, il faut parfois utiliser l'option `--silent`
|
||||||
|
pour lancer Chuck sans connexion audio.
|
||||||
|
|
||||||
|
|
||||||
|
## dessiner.ck
|
||||||
|
|
||||||
|
Faire des courbes de Lissajous...
|
||||||
|
|
||||||
|
## pouet.ck
|
||||||
|
|
||||||
|
## midi2osc.ck
|
||||||
|
|
||||||
|
## zwouik.ck
|
||||||
|
|
||||||
@@ -1,4 +1,46 @@
|
|||||||
|
|
||||||
#
|
/*
|
||||||
# dessiner par OSC avec le laser de Gaby
|
* dessiner par OSC
|
||||||
#
|
* (avec le laser de Gaby ?)
|
||||||
|
*
|
||||||
|
* nouveau Rural Art System 2021 - TerreBlanque
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
9000 => int OSCPort;
|
||||||
|
32760.0 => float Amplitude;
|
||||||
|
|
||||||
|
OscOut xmit;
|
||||||
|
float dx, dy;
|
||||||
|
|
||||||
|
xmit.dest("localhost", OSCPort);
|
||||||
|
|
||||||
|
clear_the_screen();
|
||||||
|
|
||||||
|
for (0 => int foo; foo<25800; foo++) {
|
||||||
|
<<< foo >>>;
|
||||||
|
|
||||||
|
Amplitude * Math.sin(foo * 0.3001) => dx;
|
||||||
|
Amplitude * Math.cos(foo * 0.4999) => dy;
|
||||||
|
|
||||||
|
xmit.start("/joystick/xy");
|
||||||
|
Std.ftoi(dx) => xmit.add;
|
||||||
|
Std.ftoi(dy) => xmit.add;
|
||||||
|
xmit.send();
|
||||||
|
|
||||||
|
0.025::second => now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------
|
||||||
|
|
||||||
|
fun void clear_the_screen()
|
||||||
|
{
|
||||||
|
xmit.start("/joystick/b");
|
||||||
|
50 => xmit.add; 1 => xmit.add;
|
||||||
|
xmit.send();
|
||||||
|
xmit.start("/joystick/b");
|
||||||
|
50 => xmit.add; 0 => xmit.add;
|
||||||
|
xmit.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------
|
||||||
|
|||||||
43
chuck/midi2osc.ck
Normal file
43
chuck/midi2osc.ck
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* recevoir des notes on/off par le MIDI
|
||||||
|
* et envoyer des boutons de joy par OSC
|
||||||
|
*
|
||||||
|
* nouveau Rural Art System 2021 - TerreBlanque
|
||||||
|
*/
|
||||||
|
|
||||||
|
MidiIn input;
|
||||||
|
MidiMsg msg;
|
||||||
|
OscOut xmit;
|
||||||
|
|
||||||
|
1 => int port; // please explain
|
||||||
|
9000 => int OSCPort;
|
||||||
|
|
||||||
|
if (!input.open(port)) {
|
||||||
|
<<< "erreur open" >>>;
|
||||||
|
me.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// print out device that was opened
|
||||||
|
<<< "MIDI device:", input.num(), " -> ", input.name() >>>;
|
||||||
|
|
||||||
|
xmit.dest("localhost", OSCPort);
|
||||||
|
|
||||||
|
|
||||||
|
// infinite loop
|
||||||
|
while (1) {
|
||||||
|
input => now;
|
||||||
|
|
||||||
|
while ( input.recv(msg) ) {
|
||||||
|
<<< msg.data1, msg.data2, msg.data3 >>>;
|
||||||
|
|
||||||
|
xmit.start("/joystick/b");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,20 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
OscIn oscin;
|
OscIn oscin;
|
||||||
OscMsg msg;
|
OscMsg msg;
|
||||||
|
|
||||||
InPort => oscin.port;
|
InPort => oscin.port;
|
||||||
oscin.addAddress( "/joystick/xy, ii" );
|
oscin.addAddress( "/joystick/xy, ii" );
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
55 => int base;
|
55 => int base;
|
||||||
|
|
||||||
|
0.5 => sl.gain => sr.gain;
|
||||||
|
|
||||||
<<< "listening on port", InPort >>>;
|
<<< "listening on port", InPort >>>;
|
||||||
|
|
||||||
while( true ) {
|
while( true ) {
|
||||||
@@ -26,8 +27,16 @@ 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/12.0 => sl.freq;
|
||||||
|
y/12.0 => sr.freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* made in doubledragon2 by tTh */
|
/* made in doubledragon2 by tTh */
|
||||||
|
|
||||||
|
/* --------------------------------------------------------
|
||||||
|
conversion coordonnées vers frequence */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
4
functions/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
mkbigchars
|
||||||
|
t
|
||||||
|
|
||||||
BIN
functions/8x8thin
Normal file
BIN
functions/8x8thin
Normal file
Binary file not shown.
@@ -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
44
functions/bigchars.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
@@ -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
77
functions/mkbigchars.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -41,22 +41,10 @@ return fd;
|
|||||||
this will disconnect the line.
|
this will disconnect the line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int bauds_str_to_B(char *strb, int unused)
|
int bauds_to_B(int bauds)
|
||||||
{
|
{
|
||||||
long value;
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
switch (bauds) {
|
||||||
fprintf(stderr, "--> %s ( '%s' 0x%x )\n", __func__, strb, unused);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (1 != sscanf(strb, "%ld", &value)) {
|
|
||||||
return B0;
|
|
||||||
}
|
|
||||||
#if DEBUG_LEVEL
|
|
||||||
fprintf(stderr, " computed baudrate = %ld\n", value);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (value) {
|
|
||||||
case 50: return B50;
|
case 50: return B50;
|
||||||
case 75: return B75;
|
case 75: return B75;
|
||||||
case 110: return B110;
|
case 110: return B110;
|
||||||
|
|||||||
@@ -4,4 +4,5 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int open_serial(char *dev, int bauds, int unused);
|
int open_serial(char *dev, int bauds, int unused);
|
||||||
int bauds_str_to_B(char *strb, int unused);
|
|
||||||
|
int bauds_to_B(int bauds);
|
||||||
|
|||||||
21
functions/t.c
Normal file
21
functions/t.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
@@ -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`
|
||||||
|
|
||||||
|
|||||||
48
osc-joy.c
48
osc-joy.c
@@ -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;
|
||||||
|
|||||||
10
osc2cursor.c
10
osc2cursor.c
@@ -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);
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -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)) {
|
||||||
|
|||||||
@@ -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++;
|
||||||
|
|||||||
Reference in New Issue
Block a user