Difference between revisions of "USB Roll-up drum kit user-space driver for linux"

From Organic Design wiki
(just reads from the pipe for now)
(add new version)
Line 3: Line 3:
 
<pre>
 
<pre>
 
#include <stdio.h>
 
#include <stdio.h>
#include <stdlib.h>
 
#include <unistd.h>
 
  
 +
struct pad {
 +
char data[8];
 +
};
 +
 +
// drumkit: pad status data (0 = not pressed, 1 = pressed)
 +
unsigned int pad_data[6] = {0, 0, 0, 0, 0, 0};
  
struct rec {
+
// drumkit: pad note data (0 = do nothing, 1 = play note)
int x,y,z;
+
unsigned int pad_notes[6] = {0, 0, 0, 0, 0, 0};
};
 
  
 
int main() {
 
int main() {
Line 15: Line 18:
 
FILE *f;     
 
FILE *f;     
 
   int i,j;     
 
   int i,j;     
   struct rec r;
+
   struct pad r;
  
   f=fopen("/dev/random","r");     
+
   f = fopen("/dev/random","r");     
  
while(fread(&r,sizeof(struct rec),1,f) != 0)
+
while( fread(&r,sizeof(struct pad),1,f) != 0 )
printf("%d\n",r.x);     
+
printf("%d %d %d %d %d %d %d %d\n",
 +
r.data[0], r.data[1], r.data[2], r.data[3], r.data[4], r.data[5], r.data[6], r.data[7]);     
  
  
Line 29: Line 33:
 
 
 
}
 
}
 +
  
 
</pre>
 
</pre>

Revision as of 03:52, 21 January 2009

#include <stdio.h>

struct pad { 
	char data[8]; 
	};

// drumkit: pad status data (0 = not pressed, 1 = pressed)
unsigned int pad_data[6] = {0, 0, 0, 0, 0, 0};

// drumkit: pad note data (0 = do nothing, 1 = play note)
unsigned int pad_notes[6] = {0, 0, 0, 0, 0, 0};

int main() {

	FILE *f;    
  int i,j;    
  struct pad r;

  f = fopen("/dev/random","r");    

	while( fread(&r,sizeof(struct pad),1,f) != 0 )
		printf("%d %d %d %d %d %d %d %d\n",
			r.data[0], r.data[1], r.data[2], r.data[3], r.data[4], r.data[5], r.data[6], r.data[7]);    


  fclose(f);    

  printf("\n");
	
	
}