⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpw_joystick.h

📁 关于游戏手柄的驱动编程
💻 H
📖 第 1 页 / 共 2 页
字号:
  /*                                                                       */
  /* <Struct>                                                              */
  /*    CpwJoystickList                                                    */
  /*                                                                       */
  /* <Description>                                                         */
  /*    The primary data structure for cpwInitJoysticks.                   */
  /*                                                                       */
  /* <Fields>                                                              */
  /*                                                                       */
  struct _CpwJoystickList
  {
    uint_32                 joysticks;
    CpwJoystickRanges       ranges;
    CpwJoystickCapabilities caps[CPW_MAX_JOYSTICKS];
  };
  typedef struct _CpwJoystickList CpwJoystickList;
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    CpwJoystickInfo                                                    */
  /*                                                                       */
  /* <Description>                                                         */
  /*                                                                       */
  /*    Inputs:                                                            */
  /*                                                                       */
  /*    id          - the id of the joystick to read                       */
  /*                                                                       */
  /*    Outputs:                                                           */
  /*                                                                       */
  /*    axis[]      - returns the value of the axis position.              */
  /*                  default values : -1000/1000                          */
  /*                                                                       */
  /*    rot[]       - returns the value of the axis rotation.              */
  /*                  default values : 0/3590                              */
  /*                                                                       */
  /*    vel[]       - returns the value of the axis velocity of            */
  /*                  motion.                                              */
  /*                  default values : 0/1000                              */
  /*                                                                       */
  /*    accel[]     - returns the value of the axis acceleration           */
  /*                  of motion.                                           */
  /*                  default values : 0/1000                              */
  /*                                                                       */
  /*    pov[]       - returns the value of the pov (point-of-view) hat.    */
  /*                  pov positions can either be discrete, meaning they   */
  /*                  adhere to a set of Cpw directional states, or they   */
  /*                  are variable, meaning they have continuous position  */
  /*                  values like an axis.                                 */
  /*                  variable values : 0/35900, 36000 centered            */
  /*                  discrete values : POV position constants             */
  /*                                                                       */
  struct _CpwJoystickInfo
  {
    uint_32 id;                      /* the joystick id to access */

    int_32 axis[CPW_JOY_AXES];       /* x, y, z, u, v axis */
    int_32 rot[CPW_JOY_AXES];        /* axis rotation */
    int_32 pov[CPW_JOY_POVS];        /* point-of-view hats, variable or discrete */
    int_32 vel[CPW_JOY_AXES];        /* axis velocity */
    int_32 accel[CPW_JOY_AXES];      /* axis acceleration */
    bool   buttons[CPW_JOY_BUTTONS]; /* button states */
  };
  typedef struct _CpwJoystickInfo CpwJoystickInfo;
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Prototypes>                                                          */
  /*    Global joystick event callback                                     */
  /*                                                                       */
  /* <Description>                                                         */
  /*                                                                       */
  typedef void (*CpwJoystickCallback) ( pCpw cpw, CpwJoystickInfo * info ); 
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    cpwInitJoysticks                                                   */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Lists any active, plugged in joystick available. Returns a list of */
  /*    CpwJoystickCapabilities containing information about each          */
  /*    joystick.                                                          */
  /*                                                                       */
  CPW_API bool 
  cpwInitJoysticks( pCpw cpw, 
                    CpwJoystickList * list );
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    cpwJoystickCallback                                                */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Sets a global joystick callback which will be called               */
  /*    every msecs 'delay'.                                               */
  /*                                                                       */
  CPW_API bool 
  cpwJoystickCallback( pCpw cpw, 
                       CpwJoystickCallback joyCallback, 
                       uint_32 joyid, 
                       uint_32 delay );
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    cpwJoystickPing                                                    */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Forces the generation of a callback to cpwJoystickCallback's       */
  /*    callback function.                                                 */
  /*                                                                       */
  CPW_API bool 
  cpwJoystickPing( pCpw cpw, uint_32 joyid ); 
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    cpwJoystickPoll                                                    */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Returns real-time information on the state of a joystick.          */
  /*                                                                       */
  CPW_API bool 
  cpwJoystickPoll( pCpw cpw, 
                   CpwJoystickInfo * info );
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /*   internal functions and definitions                                  */
  /*                                                                       */
  /*************************************************************************/

#ifdef CPW_INTERN

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    CpwJoystickList                                                    */
  /*                                                                       */
  /* <Description>                                                         */
  /*                                                                       */
  struct _CpwJoystickContext 
  {
    CpwJoystickCallback joyCallback[CPW_MAX_JOYSTICKS];
    uint_32             timerid[CPW_MAX_JOYSTICKS];
  }; 
  typedef struct _CpwJoystickContext  CpwJoystickContext;
  typedef struct _CpwJoystickContext* pCpwJoystickContext;
  /*                                                                       */
  /*************************************************************************/

  /* init and exit */

  bool cpw_joystick_init( pCpw cpw );
  void cpw_joystick_exit( pCpw cpw );

  /* cpw_timer callback */

  void cpw_joystick_timout( pCpw cpw, uint_32 id );

#endif /* CPW_INTERN */

CPW_END_HEADER

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -