/* * $id$ * * Tests the force feedback driver * Copyright 2001-2002 Johann Deneux */ /* * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * You can contact the author by email at this address: * Johann Deneux */ #include #include #include #include #include #include #include #include #include #define BITS_PER_LONG (sizeof(long) * 8) #define OFF(x) ((x)%BITS_PER_LONG) #define BIT(x) (1UL<> OFF(bit)) & 1) #define N_EFFECTS 6 char* effect_names[] = { "Sine vibration", "Constant Force", "Spring Condition", "Damping Condition", "Strong Rumble", "Weak Rumble" }; int main(int argc, char** argv) { struct ff_effect effects[N_EFFECTS]; struct input_event play, stop; int fd; char device_file_name[64]; unsigned long features[4]; int n_effects; /* Number of effects the device can play at the same time */ int i; printf("Force feedback test program.\n"); printf("HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES\n\n"); strncpy(device_file_name, "/dev/input/event0", 64); for (i=1; i= 0 && i < N_EFFECTS) { play.type = EV_FF; play.code = effects[i].id; play.value = 1; if (write(fd, (const void*) &play, sizeof(play)) == -1) { perror("Play effect"); exit(1); } printf("Now Playing: %s\n", effect_names[i]); } else if (i == -2) { /* Crash test */ int i = *((int *)0); printf("Crash test: %d\n", i); } else { printf("No such effect\n"); } } while (i>=0); /* Stop the effects */ for (i=0; i