diff --git a/src/tools/evdev-joystick/80-stelladaptor-joystick.rules b/src/tools/evdev-joystick/80-stelladaptor-joystick.rules index 6a547079d..7d8659a24 100644 --- a/src/tools/evdev-joystick/80-stelladaptor-joystick.rules +++ b/src/tools/evdev-joystick/80-stelladaptor-joystick.rules @@ -6,3 +6,21 @@ KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f # 2600-daptor II (Microchip Technology Inc. / 2600-daptor II) KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f947", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" + +# Astro-daptor (Microchip Technology Inc. / Astro-daptor) +KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f809", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" + +# 5200-daptor (Microchip Technology Inc. / 5200-daptor) +KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f6ec", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" + +# 2600-daptor D9 (Microchip Technology Inc. / 2600-daptor D9) +KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f6eb", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" + +# Ultimate 2600-daptor (Microchip Technology Inc. / Ultimate 2600-daptor) +KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="d4e2", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" + +# Ultimate Flashback (Microchip Technology Inc. / Ultimate Flashback) +KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="edec", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" + +# 2600=daptor D9 (Microchip Technology Inc. / 2600=daptor D9) +KERNEL=="event*", NAME="input/%k", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="edd9", ACTION=="add", RUN+="/usr/local/bin/evdev-joystick --e /dev/input/%k --d 0" diff --git a/src/tools/evdev-joystick/Readme.txt b/src/tools/evdev-joystick/Readme.txt index 7a394cdc2..59dce812f 100644 --- a/src/tools/evdev-joystick/Readme.txt +++ b/src/tools/evdev-joystick/Readme.txt @@ -9,9 +9,9 @@ It is developed by Stephen Anthony, and released under the GPL/v2. evdev-joystick is used to set the deadzone for Linux 'evdev' joystick devices. Currently, other than G25manage there is no other standalone program available to perform such calibration. This program was originally developed for Stella -(https://stella-emu.github.io), an Atari 2600 emulator, and as such much of this document -refers to Stella. The program itself can be used to calibrate any joystick -for any application, though, and is not specific to Stella. +(https://stella-emu.github.io), an Atari 2600 emulator, and as such much of +this document refers to Stella. The program itself can be used to calibrate +any joystick for any application, though, and is not specific to Stella. Short Explanation (Stella users with Stelladaptor, 2600-daptor, etc.) diff --git a/src/tools/evdev-joystick/evdev-joystick.c b/src/tools/evdev-joystick/evdev-joystick.c index 9d5c27f09..5f37c75ec 100644 --- a/src/tools/evdev-joystick/evdev-joystick.c +++ b/src/tools/evdev-joystick/evdev-joystick.c @@ -32,11 +32,19 @@ */ #define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) -// The default location for evdev devices in Linux +/* The default location for evdev devices in Linux */ #define EVDEV_DIR "/dev/input/by-id/" +/* Function signatures; see actual functions for documentation */ +void help(void); +void listDevices(void); +void printAxisType(int i); +int showCalibration(const char* const evdev); +int setDeadzoneAndFuzz(const char* const evdev, int axisindex, + __s32 deadzonevalue, __s32 fuzzvalue); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void help() +void help(void) { printf("%s","Usage:\n\n" " --help, --h The message you're now reading\n" @@ -72,7 +80,7 @@ void help() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void listDevices() +void listDevices(void) { DIR* dirp = opendir(EVDEV_DIR); struct dirent* dp; @@ -81,11 +89,11 @@ void listDevices() return; // Loop over dir entries using readdir - int len = strlen("event-joystick"); + size_t len = strlen("event-joystick"); while((dp = readdir(dirp)) != NULL) { // Only select names that end in 'event-joystick' - int devlen = strlen(dp->d_name); + size_t devlen = strlen(dp->d_name); if(devlen >= len) { const char* const start = dp->d_name + devlen - len; @@ -129,11 +137,11 @@ void printAxisType(int i) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int showCalibration(const char* evdev) +int showCalibration(const char* const evdev) { int fd = -1, axisindex; uint8_t abs_bitmask[ABS_MAX/8 + 1]; - float percent_deadzone; + double percent_deadzone; struct input_absinfo abs_features; if((fd = open(evdev, O_RDONLY)) < 0) @@ -159,7 +167,7 @@ int showCalibration(const char* evdev) if(ioctl(fd, EVIOCGABS(axisindex), &abs_features)) perror("evdev EVIOCGABS ioctl"); - percent_deadzone = (float)abs_features.flat * 100 / (float)abs_features.maximum; + percent_deadzone = (double)(abs_features.flat * 100.0 / abs_features.maximum); printf("(min: %d, max: %d, flatness: %d (=%.2f%%), fuzz: %d)\n", abs_features.minimum, abs_features.maximum, abs_features.flat, percent_deadzone, abs_features.fuzz); @@ -171,12 +179,12 @@ int showCalibration(const char* evdev) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int setDeadzoneAndFuzz(const char* evdev, int axisindex, +int setDeadzoneAndFuzz(const char* const evdev, int axisindex, __s32 deadzonevalue, __s32 fuzzvalue) { int fd = -1; uint8_t abs_bitmask[ABS_MAX/8 + 1]; - float percent_deadzone; + double percent_deadzone; struct input_absinfo abs_features; if ((fd = open(evdev, O_RDONLY)) < 0) @@ -248,7 +256,7 @@ int setDeadzoneAndFuzz(const char* evdev, int axisindex, perror("evdev EVIOCGABS ioctl"); return 1; } - percent_deadzone = (float)abs_features.flat * 100 / (float)abs_features.maximum; + percent_deadzone = (double)(abs_features.flat * 100.0 / abs_features.maximum); printf(" (min: %d, max: %d, flatness: %d (=%.2f%%), fuzz: %d)\n", abs_features.minimum, abs_features.maximum, abs_features.flat, percent_deadzone, abs_features.fuzz);