From: Johann D. <jo...@Do...> - 2002-01-21 09:39:35
|
On Sun, 20 Jan 2002, Rodrigo Damazio wrote: > Btw, how do custom effects work?? They are not supported by the current API. We need to add it. The problem would be how to pass the variable length data describing the shape of the force ? One way would be to append it to the ff_effect: ff_effect* custom; s8* shape; custom = (ff_effect*)malloc(sizeof(ff_effect) + len_shape); shape = ((s8*)custom) + sizeof(ff_effect); /* Init custom */ ... /* Init shape */ for (i=0; i<len_shape; ++i) { shape(i) = ...; } /* Upload effect to device */ ioctl(fd, EVIOCS_FF, custom, sizeof(ff_effect)+len_shape); If we can use ISO C instead of ANSI C, I think there is a feature in the new specs allowing for variable-size arrays to be placed at the end of a structure, which eliminates the initialization of the shape pointer. Another solution, which looks much better to me, would be to separate the downloading of parameters and the creation of the effect with two different ioctls. We would move the union out of ff_effect to ff_constant_param, ff_interactive_param... First the parameters would be downloaded, then the effect itself. In ff_struct, we would add a "pointer" to the parameter block to use. Opinions ? -- Johann Deneux |