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

📄 joystick.inc

📁 著名的游戏开发库Allegro4.2.0 for DELPHI
💻 INC
字号:
{*         ______   ___    ___
 *        /\  _  \ /\_ \  /\_ \
 *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
 *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
 *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
 *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
 *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
 *                                           /\____/
 *                                           \_/__/
 *
 *      Joystick routines.
 *
 *      By Shawn Hargreaves.
 *
 *      See readme.txt for copyright information.
 *}
{$IFDEF ALLEGRO_INTERFACE}
const
  JOY_TYPE_AUTODETECT     = -1;
  JOY_TYPE_NONE           = 0;

  MAX_JOYSTICKS           = 8;
  MAX_JOYSTICK_AXIS       = 3;
  MAX_JOYSTICK_STICKS     = 5;
  MAX_JOYSTICK_BUTTONS    = 32;

type
// information about a single joystick axis
  P_JOYSTICK_AXIS_INFO = ^JOYSTICK_AXIS_INFO;
  JOYSTICK_AXIS_INFO = record
    pos              : sint32;
    d1, d2           : sint32;
    name             : PChar;
  end;

// information about one or more axis (a slider or directional control)
  P_JOYSTICK_STICK_INFO = ^JOYSTICK_STICK_INFO;
  JOYSTICK_STICK_INFO = record
    flags             : sint32;
    num_axis          : sint32;
    axis              : array[0..MAX_JOYSTICK_AXIS - 1] of JOYSTICK_AXIS_INFO;
    name              : PChar;
  end;

  // information about a joystick button
  P_JOYSTICK_BUTTON_INFO = ^JOYSTICK_BUTTON_INFO;
  JOYSTICK_BUTTON_INFO = record
    b                  : sint32;
    name               : PChar;
  end;

  // information about an entire joystick
  P_JOYSTICK_INFO = ^JOYSTICK_INFOS;
  JOYSTICK_INFO = record
    flags       : sint32;
    num_sticks  : sint32;
    num_buttons : sint32;
    stick       : array[0..MAX_JOYSTICK_STICKS - 1] of JOYSTICK_STICK_INFO;
    button      : array[0..MAX_JOYSTICK_BUTTONS - 1] of JOYSTICK_BUTTON_INFO;
  end;
  JOYSTICK_INFOS = array[0..1023] of JOYSTICK_INFO;

const
  // joystick status flags 
  JOYFLAG_DIGITAL            = 1;
  JOYFLAG_ANALOGUE           = 2;
  JOYFLAG_CALIB_DIGITAL      = 4;
  JOYFLAG_CALIB_ANALOGUE     = 8;
  JOYFLAG_CALIBRATE          = 16;
  JOYFLAG_SIGNED             = 32;
  JOYFLAG_UNSIGNED           = 64;


  // alternative spellings
  JOYFLAG_ANALOG             = JOYFLAG_ANALOGUE;
  JOYFLAG_CALIB_ANALOG       = JOYFLAG_CALIB_ANALOGUE;


var
  // global joystick information
  joy                         : P_JOYSTICK_INFO;
  num_joysticks               : p_sint32;

type
  P_JOYSTICK_DRIVER = ^JOYSTICK_DRIVER;
  JOYSTICK_DRIVER   = record // driver for reading joystick input
    id              : sint32;
    name            : PChar;
    desc            : PChar;
    ascii_name      : PChar;
    init            : function: sint32; cdecl;
    exit            : procedure; cdecl;
    poll            : function: sint32; cdecl;
    save_data       : function: sint32; cdecl;
    load_data       : function: sint32; cdecl;
    calibrate_name  : function(n: sint32): PChar; cdecl;
    calibrate       : function(n: sint32): sint32; cdecl;
  end;

var
  joystick_none           : ^P_JOYSTICK_DRIVER;
  the_joystick_driver     : ^P_JOYSTICK_DRIVER;
  _joystick_driver_list   : P_DRIVER_INFO;

  install_joystick        : function(types: sint32): sint32; cdecl;
  remove_joystick         : procedure; cdecl;

  poll_joystick           : function: sint32; cdecl;

  save_joystick_data      : function(const filename: PChar): sint32; cdecl;
  load_joystick_data      : function(const filename: PChar): sint32; cdecl;

  calibrate_joystick_name : function(n: sint32): PChar; cdecl;
  calibrate_joystick      : function(n: sint32): sint32; cdecl;
{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
  joy                     := LoadDLL('joy');
  num_joysticks           := LoadDLL('num_joysticks');

  joystick_none           := LoadDLL('joystick_none');
  the_joystick_driver     := LoadDLL('joystick_driver');
  _joystick_driver_list   := LoadDLL('_joystick_driver_list');

  install_joystick        := LoadDLL('install_joystick');
  remove_joystick         := LoadDLL('remove_joystick');

  poll_joystick           := LoadDLL('poll_joystick');

  save_joystick_data      := LoadDLL('save_joystick_data');
  load_joystick_data      := LoadDLL('load_joystick_data');

  calibrate_joystick_name := LoadDLL('calibrate_joystick_name');
  calibrate_joystick      := LoadDLL('calibrate_joystick');
{$ENDIF ALLEGRO_LOADVARIABLE}

⌨️ 快捷键说明

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