int initialize_samples(int fp, int effect) { struct ff_effect new; new.type = FF_PERIODIC; new.id = -1; new.direction = 0; new.u.periodic.waveform = FF_CUSTOM; new.u.periodic.period = 6; new.u.periodic.magnitude = 0; new.u.periodic.offset = 0; new.u.periodic.phase = 0; new.u.periodic.envelope.attack_length = 0; new.u.periodic.envelope.attack_level = 0; new.u.periodic.envelope.fade_length = 0; new.u.periodic.envelope.fade_level = 0; new.u.periodic.custom_len = 306; new.u.periodic.custom_data = (void *) initstring[effect]; if(ioctl(fp, EVIOCSFF, &new) < 0) { perror("ioctl"); } return ret; }