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) |
m (add gpl) |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
*See the [[Talk:USB_Roll-up_drum_kit_user-space_driver_for_linux|talk page]] for development notes. | *See the [[Talk:USB_Roll-up_drum_kit_user-space_driver_for_linux|talk page]] for development notes. | ||
<pre> | <pre> | ||
+ | /* | ||
+ | * This program is free software; you can redistribute it and/or modify | ||
+ | * it under the terms of the GNU General Public License as published by | ||
+ | * the Free Software Foundation; either version 2 of the License, or | ||
+ | * (at your option) any later version. | ||
+ | * | ||
+ | * This program is distributed in the hope that it will be useful, | ||
+ | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+ | * GNU General Public License for more details. | ||
+ | * | ||
+ | */ | ||
+ | |||
#include <stdio.h> | #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() { | int main() { | ||
Line 15: | Line 31: | ||
FILE *f; | FILE *f; | ||
int i,j; | int i,j; | ||
− | struct | + | struct pad r; |
− | f=fopen("/dev/random","r"); | + | f = fopen("/dev/random","r"); |
− | while(fread(&r,sizeof(struct | + | while( fread(&r,sizeof(struct pad),1,f) != 0 ) |
− | printf("%d\n",r. | + | 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 46: | ||
} | } | ||
+ | |||
</pre> | </pre> |
Latest revision as of 04:00, 21 January 2009
- See the talk page for development notes.
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #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"); }