/*
 * joystick driver
 */

typedef struct _WINE_JOYSTICK_DRV WINE_JOYSTICK_DRV;

typedef struct _WINE_JOYSTICK {
  WINE_JOYSTICK_DRV *drv;
  char devname[32];
  int joyIntf;
  int devIntf;
  int detected, in_use;
  JOYCAPSA caps;
  DIDEVCAPS dicaps;
  DIDEVICEINSTANCEA diinfo;
  void *internal, *minternal;
} WINE_JOYSTICK;

struct _WINE_JOYSTICK_DRV {
  void (*DevName)(WINE_JOYSTICK *joy);
  LONG (*GetDevCaps)(WINE_JOYSTICK *joy);
  LONG (*GetPosEx)(WINE_JOYSTICK *joy, LPJOYINFOEX lpInfo);
  HRESULT (*GetDIInfo)(WINE_JOYSTICK *joy, DWORD dwVersion, LPDIDEVCAPS lpCaps, LPDIDEVICEINSTANCEA lpInfo);
  HRESULT (*OpenDIDev)(WINE_JOYSTICK *joy, DWORD dwVersion);
  HRESULT (*CloseDIDev)(WINE_JOYSTICK *joy);
  HRESULT (*GetDIDataFormat)(WINE_JOYSTICK *joy, LPDIDATAFORMAT *pdf);
  HRESULT (*GetDIData)(WINE_JOYSTICK *joy, BOOL req, DWORD *dwObj, DWORD *dwData, DWORD *dwTimeStamp);

  /* Force Feedback */
  HRESULT (*GetEffectInfo)(WINE_JOYSTICK *joy, DWORD *dwNumEffs, LPDIEFFECTINFOA *pEffInfo);
  HRESULT (*GetEffectStatus)(WINE_JOYSTICK *joy, DWORD dwEffID, DWORD *pdwFlags);
  HRESULT (*SetAutoCenter)(WINE_JOYSTICK *joy, DWORD dwValue);
  HRESULT (*SetGain)(WINE_JOYSTICK *joy, DWORD dwValue);
  HRESULT (*UnloadEffect)(WINE_JOYSTICK *joy, DWORD dwEffID);
  HRESULT (*LoadEffect)(WINE_JOYSTICK *joy, DWORD *pdwEffID, DWORD dwFlags, DIEFFECT *pEff, DIEFFECTINFOA *pEffInfo);
  HRESULT (*StopEffect)(WINE_JOYSTICK *joy, DWORD dwEffID);
  HRESULT (*StartEffect)(WINE_JOYSTICK *joy, DWORD dwEffID, DWORD dwCount);
};

typedef enum {
  JMAP_END,
  JMAP_DISABLE,
  JMAP_X,
  JMAP_Y,
  JMAP_Z,
  JMAP_RX,
  JMAP_RY,
  JMAP_RZ,
  JMAP_SLIDER,
  JMAP_HAT,
  JMAP_BALL
} JMAP;

JMAP* JSTCK_get_joy_map(char *name);
#define JSTCK_free_joy_map(map) HeapFree(GetProcessHeap(), 0, map)
REFGUID JSTCK_get_map_guid(JMAP map);
DWORD JSTCK_calc_pov4(int x, int y);
DWORD JSTCK_calc_povcts(int x, int y);
