~ubuntu-branches/debian/experimental/mednafen/experimental

« back to all changes in this revision

Viewing changes to src/drivers/joystick.cpp

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-01-31 07:21:35 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120131072135-es3dj12y00xcnrsk
Tags: 0.9.19-1
* New upstream WIP version.
* Update copyright information.
* Refresh use-system-tremor.patch and remove psx-big-endian-only.patch.
* Add spelling-fixes.patch based on Lintian's recommendations.
* Build-depend on debhelper 9 or later and remove corresponding Lintian
  override.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
 return(0);
96
96
}
97
97
 
 
98
int DTestAnalogButtonJoy(ButtConfig &bc)
 
99
{
 
100
 if(bc.DeviceNum >= MAX_JOYSTICKS)
 
101
  return(0);
 
102
 
 
103
 if(bc.ButtonNum & 0x8000)      /* Axis "button" */
 
104
 {
 
105
        int pos;
 
106
        pos = SDL_JoystickGetAxis(Joysticks[bc.DeviceNum], bc.ButtonNum&16383);
 
107
 
 
108
        if ((bc.ButtonNum & 0x4000) && pos < 0)
 
109
         return(std::min<int>(-pos, 32767));
 
110
        else if (!(bc.ButtonNum & 0x4000) && pos > 0)
 
111
         return(pos);
 
112
  }
 
113
  else if(bc.ButtonNum & 0x2000)        /* Hat "button" */
 
114
  {
 
115
   if( SDL_JoystickGetHat(Joysticks[bc.DeviceNum],(bc.ButtonNum>>8)&0x1F) & (bc.ButtonNum&0xFF))
 
116
    return(32767);
 
117
  }
 
118
  else
 
119
   if(SDL_JoystickGetButton(Joysticks[bc.DeviceNum], bc.ButtonNum)) 
 
120
    return(32767);
 
121
 
 
122
 return(0);
 
123
}
 
124
 
98
125
/* Cleanup opened joysticks. */
99
126
int KillJoysticks (void)
100
127
{