Bug 219076 - joystick cannot be used (libjsw should be added to extras)
joystick cannot be used (libjsw should be added to extras)
Status: CLOSED CANTFIX
Product: Fedora
Classification: Fedora
Component: fuse-emulator (Show other bugs)
6
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ian Chapman
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-12-10 09:24 EST by Paul Osmialowski
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-10-05 14:25:12 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Paul Osmialowski 2006-12-10 09:24:02 EST
Description of problem:
Joystick cannot be used as if applicable option --with-joystick wasn't set
during ./configure step

Version-Release number of selected component (if applicable):
fuse-emulator-0.7.0-6.fc6

How reproducible:
Always

Steps to Reproduce:
1. install fuse-emulator from .rpm
2. download any game that uses Kemspton or Sinclair (Interface II) joystick from
http://worldofspectrum.org (can be Jet Set Willy which has joystick
autodetection, or River Raid which has joystick selection menu or any other 80's
game, most of them should have 'Select Control' menu)
3. setup joystick in Options->Peripherals and Options->Joystick menus
  
Actual results:
Joystick is not available in games, which is annoying and keyboard-killing and
finger-tireding

Expected results:
Joystick should be available in games

Additional info:
Before I've upgraded FC3->FC6 I had Fuse emulator compiled from tarballs and had
no problems with joystick in games. I had to install additional library called
libjsw otherwise I could see:
checking for jsw.h... no
configure: warning: jsw.h not found - joystick support disabled
Comment 1 Paul F. Johnson 2007-02-15 20:42:47 EST
libjsw is very unpleasant and requires a tonne of work to get it to behave.
Comment 2 Paul Osmialowski 2007-07-07 10:06:36 EDT
libjsw-1.5.6 is fine and requires only two changes to be done to compile it with
gcc-4.x: first in libjsw/Makefile (or libjsw/Makefile.linux if you prefer to use
that): CC = cc should be changed to CC = c++
second in libjsw/forcefeedback.c:
###########################################################
--- forcefeedback.c.old 2006-03-31 08:28:00.000000000 +0200
+++ forcefeedback.c     2007-06-29 21:17:29.758672538 +0200
@@ -57,5 +57,6 @@

        /* Deallocate structure itself. */
        free(ff);
-       ff = ptr = NULL;
+       ff = NULL;
+       ptr = NULL;
 }
############################################################
Note that jscalibrator (from libjsw tarball) should be also shipped with libjsw
rpm package, as FUSE won't be able to use joystick without .joystick calibration
file present in user's home directory: jscalibrator is able to create that file.
Fortunately, no need to change anything in jscalibrator Makefile(s). It is a
nice gtk application and it should be available in desktop menu (Games section
would be the right place).

Unfortunately, to have joystick support FUSE must be fixed as well.
Note that I've done these changes to the latest fuse-0.8.0.1.tar.gz compiled
together with the latest libspectrum-0.3.0.1.tar.gz!!!
1. libjsw API has changed slightly, now JSLoadCalibrationUNIX function which
parses .joystick file is less error sensitive and does not set errno variable at
all, other way must be used to detect if it failed to read settings (see patch
below).
2. jscalibrator while finding joystick device looks first for /dev/js0 then for
/dev/input/js0, FUSE should also behave that way to avoid unneeded error message.
2. Missing break; and variable assignment situated in wrong place caused
multi-button logic to be broken.
3. Directions are swapped upside-down, one minus sign must be added.
Proposed patch to ui/uijoystick.c file is:
###########################################################
--- uijoystick.c.old    2007-04-27 23:13:54.000000000 +0200
+++ uijoystick.c        2007-07-07 15:43:42.289591225 +0200
@@ -45,7 +45,6 @@

 #include <stdio.h>
 #include <string.h>
-#include <errno.h>

 #include <jsw.h>

@@ -73,10 +72,9 @@
   switch( JSInit( &jsd[which], device, calibration, JSFlagNonBlocking ) ) {

   case JSSuccess:
-    if( JSLoadCalibrationUNIX( &jsd[which] ) && errno != ENOENT ) {
+    if( JSLoadCalibrationUNIX( &jsd[which] ) ) {
       ui_error( UI_ERROR_ERROR,
-               "failed to read calibration for joystick %i: %s", which + 1,
-               strerror( errno ) );
+               "failed to read calibration for joystick %i", which + 1 );
       break;
     }

@@ -86,6 +84,12 @@
                which + 1, device );
       break;
     }
+
+    if ( jsd[which].axis[0]->nz == JSDefaultNullZone )
+    {
+      ui_error( UI_ERROR_ERROR, "joystick %s is not calibrated", device );
+      break;
+    }
     return 0;

   case JSBadValue:
@@ -128,13 +132,13 @@
      only that */
   if( device && device[0] ) return init_stick( which, device, calibration );

-  /* Otherwise try /dev/input/js<n> and /dev/js<n> */
-  snprintf( path, PATH_MAX, "/dev/input/js%d", which );
-  if( !init_stick( which, path, calibration ) ) return 0;
-
+  /* Otherwise try /dev/js<n> and /dev/input/js<n> */
   snprintf( path, PATH_MAX, "/dev/js%d", which );
   if( !init_stick( which, path, calibration ) ) return 0;

+  snprintf( path, PATH_MAX, "/dev/input/js%d", which );
+  if( !init_stick( which, path, calibration ) ) return 0;
+
   /* Couldn't find this joystick */
   return 1;
 }
@@ -200,7 +204,7 @@
   position = JSGetAxisCoeffNZ( joystick, 0 );
   do_axis( which, position, INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT );

-  position = JSGetAxisCoeffNZ( joystick, 1 );
+  position = -JSGetAxisCoeffNZ( joystick, 1 );
   do_axis( which, position, INPUT_JOYSTICK_UP,   INPUT_JOYSTICK_DOWN  );

   event.types.joystick.which = which;
@@ -211,13 +215,13 @@
   for( i = 0; i < buttons; i++ ) {

     fire = JSGetButtonState( joystick, i );
+    event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + i;
     if( fire == JSButtonStateOn ) {
       event.type = INPUT_EVENT_JOYSTICK_PRESS;
+      break;
     } else {
       event.type = INPUT_EVENT_JOYSTICK_RELEASE;
     }
-
-    event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + i;
   }

   input_event( &event );
##############################################################
Remember to add these options while running configure script!:
--enable-ui-joystick --with-joystick
Hope these changes will be applied to FC6 and F7 some day to help young Linux
users to get the feeling of 80's gaming which would not be fully featured
without joystick support!
Comment 3 Ian Chapman 2007-07-07 14:54:50 EDT
I'm the new maintainer for this package. I'm currently working on getting
0.8.0.1 out of the door but in the process I'm updating several libraries that
have been or will be updated too. libjsw support won't be the initial release
but I'll be looking at it after that.
Comment 4 Ian Chapman 2007-10-02 09:54:49 EDT
libjsw upstream seems to be dead with no ability to download any files from it.
Comment 5 Ian Chapman 2007-10-05 14:25:12 EDT
Closing as CANTFIX for the moment.

Note You need to log in before you can comment on or make changes to this bug.