Compare commits
	
		
			No commits in common. "03bdd5ab88a174bf651af8b421a1bc2965c6a0c0" and "a8179661045f4a8f19bf6de7058620c4cb4411db" have entirely different histories.
		
	
	
		
			03bdd5ab88
			...
			a817966104
		
	
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -3,7 +3,6 @@ MANIFEST | |||||||
| tarball | tarball | ||||||
| 
 | 
 | ||||||
| osc2cursor | osc2cursor | ||||||
| osc-joy |  | ||||||
| 
 | 
 | ||||||
| doc/*.toc | doc/*.toc | ||||||
| doc/*.log | doc/*.log | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Makefile
									
									
									
									
									
								
							| @ -9,7 +9,4 @@ OPTS = -Wall -g -DDEBUG_LEVEL=1 | |||||||
| osc2cursor:        osc2cursor.c ${DEPS} functions/libpocosc.a  | osc2cursor:        osc2cursor.c ${DEPS} functions/libpocosc.a  | ||||||
| 	gcc ${OPTS} $< functions/libpocosc.a -llo -lcurses -o $@ | 	gcc ${OPTS} $< functions/libpocosc.a -llo -lcurses -o $@ | ||||||
| 
 | 
 | ||||||
| osc-joy:        osc-joy.c ${DEPS} functions/libpocosc.a  |  | ||||||
| 	gcc ${OPTS} $< functions/libpocosc.a -llo -o $@ |  | ||||||
| 
 |  | ||||||
| # ----------------------------------------------------
 | # ----------------------------------------------------
 | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| 
 | 
 | ||||||
| \makeindex | \makeindex | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| \title{Gadgets for Open Sound Control} | \title{Floating images processing} | ||||||
| \author{tTh} | \author{tTh} | ||||||
| 
 | 
 | ||||||
| \begin{document} | \begin{document} | ||||||
| @ -31,18 +31,6 @@ De quoi parle-t-on exactement ? | |||||||
| 
 | 
 | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| \subsection{osc-joy} |  | ||||||
| 
 |  | ||||||
| \begin{verbatim} |  | ||||||
|          * joystick -> osc       Aug  2 2019 * |  | ||||||
|         -r      remote host (localhost) |  | ||||||
|         -p      remote UDP port (9000) |  | ||||||
|         -j      joystick device (/dev/input/js0) |  | ||||||
|         -v      increase verbosity |  | ||||||
|         -o      offset added to button number |  | ||||||
|         -I      change text id ("suck my stick") |  | ||||||
| \end{verbatim} |  | ||||||
| 
 |  | ||||||
| \pagebreak | \pagebreak | ||||||
| \tableofcontents | \tableofcontents | ||||||
| \printindex | \printindex | ||||||
|  | |||||||
							
								
								
									
										143
									
								
								osc-joy.c
									
									
									
									
									
								
							
							
						
						
									
										143
									
								
								osc-joy.c
									
									
									
									
									
								
							| @ -1,143 +0,0 @@ | |||||||
| /*
 |  | ||||||
|  *   Pour compiler : |  | ||||||
|  *     gcc -Wall osc-joy.c -llo -o osc-joy |  | ||||||
|  * |  | ||||||
|  *   Options : |  | ||||||
|  *        -j joydevice			default /dev/input/js0 |  | ||||||
|  *        -h destination (or IP addr)	default localhost  |  | ||||||
|  *        -p destport			default is 9000 |  | ||||||
|  *        -o nnn			offset for button number |  | ||||||
|  */   |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| #include  <fcntl.h> |  | ||||||
| #include  <stdio.h> |  | ||||||
| #include  <stdlib.h> |  | ||||||
| #include  <unistd.h> |  | ||||||
| #include  <string.h> |  | ||||||
| #include  <sys/ioctl.h> |  | ||||||
| 
 |  | ||||||
| #include <linux/joystick.h> |  | ||||||
| #include <lo/lo.h> |  | ||||||
| 
 |  | ||||||
| #include  "functions/senders.h" |  | ||||||
| 
 |  | ||||||
| /*   default values, can be changed on command line */ |  | ||||||
| 
 |  | ||||||
| #define REMOTE_HOST	"localhost"		/* just loling */ |  | ||||||
| #define REMOTE_PORT	"9000" |  | ||||||
| #define	JOY_DEVICE	"/dev/input/js0" |  | ||||||
| #define MY_TEXT_ID	"suck my stick" |  | ||||||
| 
 |  | ||||||
| /* ----------------------------------------------------------------- */ |  | ||||||
| int		verbosity = 0; |  | ||||||
| int		button_offset = 0; |  | ||||||
| 
 |  | ||||||
| char		*my_id = MY_TEXT_ID; |  | ||||||
| 
 |  | ||||||
| /* ----------------------------------------------------------------- */ |  | ||||||
| static void help(int k) |  | ||||||
| { |  | ||||||
| puts("\t * joystick -> osc       "__DATE__" *"); |  | ||||||
| puts("\t-r\tremote host ("REMOTE_HOST")"); |  | ||||||
| puts("\t-p\tremote UDP port ("REMOTE_PORT")"); |  | ||||||
| puts("\t-j\tjoystick device ("JOY_DEVICE")"); |  | ||||||
| puts("\t-v\tincrease verbosity"); |  | ||||||
| puts("\t-o\toffset added to button number"); |  | ||||||
| puts("\t-I\tchange text id (\""MY_TEXT_ID"\")"); |  | ||||||
| exit(0); |  | ||||||
| } |  | ||||||
| /* ----------------------------------------------------------------- */ |  | ||||||
| int main(int argc, char *argv[]) |  | ||||||
| { |  | ||||||
| int		foo, joy_fd; |  | ||||||
| struct js_event js; |  | ||||||
| int		x_pos, y_pos, flag; |  | ||||||
| char		joy_name[128]; |  | ||||||
| int		opt; |  | ||||||
| char		*remote_host = REMOTE_HOST; |  | ||||||
| char		*remote_port = REMOTE_PORT; |  | ||||||
| char		*joy_device = JOY_DEVICE; |  | ||||||
| 
 |  | ||||||
| /* parsing command line options */ |  | ||||||
| while ((opt = getopt(argc, argv, "hp:r:vj:o:I:")) != -1) { |  | ||||||
| 	switch (opt) { |  | ||||||
| 		case 'h':	help(0);		break; |  | ||||||
| 		case 'r':	remote_host = optarg;	break; |  | ||||||
| 		case 'p':	remote_port = optarg;	break; |  | ||||||
| 		case 'j':	joy_device = optarg;	break; |  | ||||||
| 		case 'v':	verbosity++;		break; |  | ||||||
| 		case 'o':	button_offset = atoi(optarg); |  | ||||||
| 				break; |  | ||||||
| 		case 'I':	my_id = optarg;		break; |  | ||||||
| 		default:	exit(1);		break; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| if (verbosity) { |  | ||||||
| 	fprintf(stderr, "%s is sending to %s:%s\n", argv[0], |  | ||||||
| 			remote_host, remote_port); |  | ||||||
| 	fprintf(stderr, "  the stick '%s'is on %s\n", my_id, joy_device); |  | ||||||
| 	}  |  | ||||||
| 
 |  | ||||||
| lo_address t =  lo_address_new(remote_host, remote_port); |  | ||||||
| 
 |  | ||||||
| if( ( joy_fd = open(joy_device , O_RDONLY)) == -1 ) { |  | ||||||
| 	fprintf(stderr, "Couldn't open %s\n", JOY_DEVICE); |  | ||||||
| 	exit(1); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| if (verbosity) { |  | ||||||
| 	if (ioctl(joy_fd, JSIOCGNAME(sizeof(joy_name)), joy_name) < 0) |  | ||||||
| 		strncpy(joy_name, "Unknown", sizeof(joy_name)); |  | ||||||
| 	fprintf(stderr, "Name: %s\n", joy_name); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| send_data_id(t, my_id); |  | ||||||
| 
 |  | ||||||
| x_pos = y_pos = 0; |  | ||||||
| for (;;) { |  | ||||||
| 	foo = read(joy_fd, &js, sizeof(struct js_event)); |  | ||||||
| 	if (8 != foo) { |  | ||||||
| 		fprintf(stderr, "err reading joy\n"); |  | ||||||
| 		exit(1); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 	/* calibration datas ignored */ |  | ||||||
| 	if (js.type > 128)	continue; |  | ||||||
| 
 |  | ||||||
| 	if (verbosity>1) {	 |  | ||||||
| 		fprintf(stderr, "%10u  %2d  %2d %7d\n", |  | ||||||
| 			js.time, js.type, js.number, js.value); |  | ||||||
| 		} |  | ||||||
| 			 |  | ||||||
| 	if (2==js.type)	{		/* oscillating stick */ |  | ||||||
| 		flag = 0; |  | ||||||
| 		switch (js.number) |  | ||||||
| 			{ |  | ||||||
| 			case 0: |  | ||||||
| 				x_pos = js.value; |  | ||||||
| 				flag = 1; |  | ||||||
| 				break; |  | ||||||
| 			case 1: |  | ||||||
| 				y_pos = js.value; |  | ||||||
| 				flag = 1; |  | ||||||
| 				break; |  | ||||||
| 			} |  | ||||||
| 				 |  | ||||||
| 		if (flag) { |  | ||||||
| 			foo = send_data_xy(t, x_pos, y_pos); |  | ||||||
| 			flag = 0; |  | ||||||
| 			}			 |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 	if (1==js.type)	{		/* it's a button */ |  | ||||||
| 		foo = send_data_button(t, js.number+button_offset, |  | ||||||
| 						 js.value); |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| return 0; |  | ||||||
| } |  | ||||||
| /* ----------------------------------------------------------------- */ |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user