📄 xinput.pas
字号:
{******************************************************************************}
{* *}
{* Copyright (C) Microsoft Corporation. All Rights Reserved. *}
{* *}
{* Files: XInput.h *}
{* Content: This module defines XBOX controller APIs *}
{* and constansts for the Windows platform. *}
{* *}
{* DirectX 9.0 Delphi / FreePascal adaptation by Alexey Barkovoy *}
{* E-Mail: directx@clootie.ru *}
{* *}
{* Latest version can be downloaded from: *}
{* http://www.clootie.ru *}
{* http://sourceforge.net/projects/delphi-dx9sdk *}
{* *}
{*----------------------------------------------------------------------------*}
{* $Id: XInput.pas,v 1.3 2006/10/21 21:30:10 clootie Exp $ }
{******************************************************************************}
{ }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ The contents of this file are used with permission, subject to the Mozilla }
{ Public License Version 1.1 (the "License"); you may not use this file except }
{ in compliance with the License. You may obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License. }
{ }
{ Alternatively, the contents of this file may be used under the terms of the }
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
{ provisions of the LGPL License are applicable instead of those above. }
{ If you wish to allow use of your version of this file only under the terms }
{ of the LGPL License and not to allow others to use your version of this file }
{ under the MPL, indicate your decision by deleting the provisions above and }
{ replace them with the notice and other provisions required by the LGPL }
{ License. If you do not delete the provisions above, a recipient may use }
{ your version of this file under either the MPL or the LGPL License. }
{ }
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
{ }
{******************************************************************************}
{$I DirectX.inc}
unit XInput;
interface
(*$HPPEMIT '#include "XInput.h"' *)
uses
Windows;
const
// Current name of the DLL shipped in the same SDK as this header.
// The name reflects the current version
XINPUT_DLL_A = 'xinput1_3.dll';
{$EXTERNALSYM XINPUT_DLL_A}
XINPUT_DLL_W = 'xinput1_3.dll';
{$EXTERNALSYM XINPUT_DLL_W}
{$IFDEF UNICODE}
XINPUT_DLL = XINPUT_DLL_W;
{$ELSE}
XINPUT_DLL = XINPUT_DLL_A;
{$ENDIF}
{$EXTERNALSYM XINPUT_DLL}
//
// Device types available in XINPUT_CAPABILITIES
//
XINPUT_DEVTYPE_GAMEPAD = $01;
{$EXTERNALSYM XINPUT_DEVTYPE_GAMEPAD}
XINPUT_DEVSUBTYPE_WHEEL = $02;
{$EXTERNALSYM XINPUT_DEVSUBTYPE_WHEEL}
XINPUT_DEVSUBTYPE_ARCADE_STICK = $03;
{$EXTERNALSYM XINPUT_DEVSUBTYPE_ARCADE_STICK}
XINPUT_DEVSUBTYPE_FLIGHT_SICK = $04;
{$EXTERNALSYM XINPUT_DEVSUBTYPE_FLIGHT_SICK}
XINPUT_DEVSUBTYPE_DANCE_PAD = $05;
{$EXTERNALSYM XINPUT_DEVSUBTYPE_DANCE_PAD}
//
// Device subtypes available in XINPUT_CAPABILITIES
//
XINPUT_DEVSUBTYPE_GAMEPAD = $01;
{$EXTERNALSYM XINPUT_DEVSUBTYPE_GAMEPAD}
//
// Flags for XINPUT_CAPABILITIES
//
XINPUT_CAPS_VOICE_SUPPORTED = $0004;
{$EXTERNALSYM XINPUT_CAPS_VOICE_SUPPORTED}
//
// Constants for gamepad buttons
//
XINPUT_GAMEPAD_DPAD_UP = $0001;
{$EXTERNALSYM XINPUT_GAMEPAD_DPAD_UP}
XINPUT_GAMEPAD_DPAD_DOWN = $0002;
{$EXTERNALSYM XINPUT_GAMEPAD_DPAD_DOWN}
XINPUT_GAMEPAD_DPAD_LEFT = $0004;
{$EXTERNALSYM XINPUT_GAMEPAD_DPAD_LEFT}
XINPUT_GAMEPAD_DPAD_RIGHT = $0008;
{$EXTERNALSYM XINPUT_GAMEPAD_DPAD_RIGHT}
XINPUT_GAMEPAD_START = $0010;
{$EXTERNALSYM XINPUT_GAMEPAD_START}
XINPUT_GAMEPAD_BACK = $0020;
{$EXTERNALSYM XINPUT_GAMEPAD_BACK}
XINPUT_GAMEPAD_LEFT_THUMB = $0040;
{$EXTERNALSYM XINPUT_GAMEPAD_LEFT_THUMB}
XINPUT_GAMEPAD_RIGHT_THUMB = $0080;
{$EXTERNALSYM XINPUT_GAMEPAD_RIGHT_THUMB}
XINPUT_GAMEPAD_LEFT_SHOULDER = $0100;
{$EXTERNALSYM XINPUT_GAMEPAD_LEFT_SHOULDER}
XINPUT_GAMEPAD_RIGHT_SHOULDER = $0200;
{$EXTERNALSYM XINPUT_GAMEPAD_RIGHT_SHOULDER}
XINPUT_GAMEPAD_A = $1000;
{$EXTERNALSYM XINPUT_GAMEPAD_A}
XINPUT_GAMEPAD_B = $2000;
{$EXTERNALSYM XINPUT_GAMEPAD_B}
XINPUT_GAMEPAD_X = $4000;
{$EXTERNALSYM XINPUT_GAMEPAD_X}
XINPUT_GAMEPAD_Y = $8000;
{$EXTERNALSYM XINPUT_GAMEPAD_Y}
//
// Gamepad thresholds
//
XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE = 7849;
{$EXTERNALSYM XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE}
XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE = 8689;
{$EXTERNALSYM XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE}
XINPUT_GAMEPAD_TRIGGER_THRESHOLD = 30;
{$EXTERNALSYM XINPUT_GAMEPAD_TRIGGER_THRESHOLD}
//
// Flags to pass to XInputGetCapabilities
//
XINPUT_FLAG_GAMEPAD = $00000001;
{$EXTERNALSYM XINPUT_FLAG_GAMEPAD}
//
// Devices that support batteries
//
BATTERY_DEVTYPE_GAMEPAD = $00;
{$EXTERNALSYM BATTERY_DEVTYPE_GAMEPAD}
BATTERY_DEVTYPE_HEADSET = $01;
{$EXTERNALSYM BATTERY_DEVTYPE_HEADSET}
//
// Flags for battery status level
//
BATTERY_TYPE_DISCONNECTED = $00; // This device is not connected
{$EXTERNALSYM BATTERY_TYPE_DISCONNECTED}
BATTERY_TYPE_WIRED = $01; // Wired device, no battery
{$EXTERNALSYM BATTERY_TYPE_WIRED}
BATTERY_TYPE_ALKALINE = $02; // Alkaline battery source
{$EXTERNALSYM BATTERY_TYPE_ALKALINE}
BATTERY_TYPE_NIMH = $03; // Nickel Metal Hydride battery source
{$EXTERNALSYM BATTERY_TYPE_NIMH}
BATTERY_TYPE_UNKNOWN = $FF; // Cannot determine the battery type
{$EXTERNALSYM BATTERY_TYPE_UNKNOWN}
// These are only valid for wireless, connected devices, with known battery types
// The amount of use time remaining depends on the type of device.
BATTERY_LEVEL_EMPTY = $00;
{$EXTERNALSYM BATTERY_LEVEL_EMPTY}
BATTERY_LEVEL_LOW = $01;
{$EXTERNALSYM BATTERY_LEVEL_LOW}
BATTERY_LEVEL_MEDIUM = $02;
{$EXTERNALSYM BATTERY_LEVEL_MEDIUM}
BATTERY_LEVEL_FULL = $03;
{$EXTERNALSYM BATTERY_LEVEL_FULL}
// User index definitions
XUSER_MAX_COUNT = 4;
{$EXTERNALSYM XUSER_MAX_COUNT}
XUSER_INDEX_ANY = $000000FF;
{$EXTERNALSYM XUSER_INDEX_ANY}
//
// Codes returned for the gamepad keystroke
//
VK_PAD_A = $5800;
{$EXTERNALSYM VK_PAD_A}
VK_PAD_B = $5801;
{$EXTERNALSYM VK_PAD_B}
VK_PAD_X = $5802;
{$EXTERNALSYM VK_PAD_X}
VK_PAD_Y = $5803;
{$EXTERNALSYM VK_PAD_Y}
VK_PAD_RSHOULDER = $5804;
{$EXTERNALSYM VK_PAD_RSHOULDER}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -