Win32 API 日本語リファレンス
ホームDevices.HumanInterfaceDevice › HidP_GetSpecificButtonCaps

HidP_GetSpecificButtonCaps

関数
指定した条件に一致するHIDボタンの能力情報を取得する。
DLLHID.dll呼出規約winapi

シグネチャ

// HID.dll
#include <windows.h>

NTSTATUS HidP_GetSpecificButtonCaps(
    HIDP_REPORT_TYPE ReportType,
    WORD UsagePage,   // optional
    WORD LinkCollection,   // optional
    WORD Usage,   // optional
    HIDP_BUTTON_CAPS* ButtonCaps,
    WORD* ButtonCapsLength,
    PHIDP_PREPARSED_DATA PreparsedData
);

パラメーター

名前方向説明
ReportTypeHIDP_REPORT_TYPEin対象のレポート種別をHIDP_REPORT_TYPE(Input/Output/Feature)で指定する。
UsagePageWORDinoptional絞り込み対象のユーセージページを指定する。0で全ページを対象とする。
LinkCollectionWORDinoptional絞り込み対象のリンクコレクションを指定する。0で全コレクションを対象とする。
UsageWORDinoptional絞り込み対象のユーセージを指定する。0で全ユーセージを対象とする。
ButtonCapsHIDP_BUTTON_CAPS*out条件に一致するボタン能力情報配列(HIDP_BUTTON_CAPS)を受け取るバッファへのポインタ。
ButtonCapsLengthWORD*inout入出力で配列の容量を指定し、実際の要素数を受け取るWORDへのポインタを指定する。
PreparsedDataPHIDP_PREPARSED_DATAinHidD_GetPreparsedDataで取得した前解析データへのポインタを指定する。

戻り値の型: NTSTATUS

各言語での呼び出し定義

// HID.dll
#include <windows.h>

NTSTATUS HidP_GetSpecificButtonCaps(
    HIDP_REPORT_TYPE ReportType,
    WORD UsagePage,   // optional
    WORD LinkCollection,   // optional
    WORD Usage,   // optional
    HIDP_BUTTON_CAPS* ButtonCaps,
    WORD* ButtonCapsLength,
    PHIDP_PREPARSED_DATA PreparsedData
);
[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_GetSpecificButtonCaps(
    int ReportType,   // HIDP_REPORT_TYPE
    ushort UsagePage,   // WORD optional
    ushort LinkCollection,   // WORD optional
    ushort Usage,   // WORD optional
    IntPtr ButtonCaps,   // HIDP_BUTTON_CAPS* out
    ref ushort ButtonCapsLength,   // WORD* in/out
    IntPtr PreparsedData   // PHIDP_PREPARSED_DATA
);
<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_GetSpecificButtonCaps(
    ReportType As Integer,   ' HIDP_REPORT_TYPE
    UsagePage As UShort,   ' WORD optional
    LinkCollection As UShort,   ' WORD optional
    Usage As UShort,   ' WORD optional
    ButtonCaps As IntPtr,   ' HIDP_BUTTON_CAPS* out
    ByRef ButtonCapsLength As UShort,   ' WORD* in/out
    PreparsedData As IntPtr   ' PHIDP_PREPARSED_DATA
) As Integer
End Function
' ReportType : HIDP_REPORT_TYPE
' UsagePage : WORD optional
' LinkCollection : WORD optional
' Usage : WORD optional
' ButtonCaps : HIDP_BUTTON_CAPS* out
' ButtonCapsLength : WORD* in/out
' PreparsedData : PHIDP_PREPARSED_DATA
Declare PtrSafe Function HidP_GetSpecificButtonCaps Lib "hid" ( _
    ByVal ReportType As Long, _
    ByVal UsagePage As Integer, _
    ByVal LinkCollection As Integer, _
    ByVal Usage As Integer, _
    ByVal ButtonCaps As LongPtr, _
    ByRef ButtonCapsLength As Integer, _
    ByVal PreparsedData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HidP_GetSpecificButtonCaps = ctypes.windll.hid.HidP_GetSpecificButtonCaps
HidP_GetSpecificButtonCaps.restype = ctypes.c_int
HidP_GetSpecificButtonCaps.argtypes = [
    ctypes.c_int,  # ReportType : HIDP_REPORT_TYPE
    ctypes.c_ushort,  # UsagePage : WORD optional
    ctypes.c_ushort,  # LinkCollection : WORD optional
    ctypes.c_ushort,  # Usage : WORD optional
    ctypes.c_void_p,  # ButtonCaps : HIDP_BUTTON_CAPS* out
    ctypes.POINTER(ctypes.c_ushort),  # ButtonCapsLength : WORD* in/out
    ctypes.c_ssize_t,  # PreparsedData : PHIDP_PREPARSED_DATA
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HID.dll')
HidP_GetSpecificButtonCaps = Fiddle::Function.new(
  lib['HidP_GetSpecificButtonCaps'],
  [
    Fiddle::TYPE_INT,  # ReportType : HIDP_REPORT_TYPE
    -Fiddle::TYPE_SHORT,  # UsagePage : WORD optional
    -Fiddle::TYPE_SHORT,  # LinkCollection : WORD optional
    -Fiddle::TYPE_SHORT,  # Usage : WORD optional
    Fiddle::TYPE_VOIDP,  # ButtonCaps : HIDP_BUTTON_CAPS* out
    Fiddle::TYPE_VOIDP,  # ButtonCapsLength : WORD* in/out
    Fiddle::TYPE_INTPTR_T,  # PreparsedData : PHIDP_PREPARSED_DATA
  ],
  Fiddle::TYPE_INT)
#[link(name = "hid")]
extern "system" {
    fn HidP_GetSpecificButtonCaps(
        ReportType: i32,  // HIDP_REPORT_TYPE
        UsagePage: u16,  // WORD optional
        LinkCollection: u16,  // WORD optional
        Usage: u16,  // WORD optional
        ButtonCaps: *mut HIDP_BUTTON_CAPS,  // HIDP_BUTTON_CAPS* out
        ButtonCapsLength: *mut u16,  // WORD* in/out
        PreparsedData: isize  // PHIDP_PREPARSED_DATA
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HID.dll")]
public static extern int HidP_GetSpecificButtonCaps(int ReportType, ushort UsagePage, ushort LinkCollection, ushort Usage, IntPtr ButtonCaps, ref ushort ButtonCapsLength, IntPtr PreparsedData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_GetSpecificButtonCaps' -Namespace Win32 -PassThru
# $api::HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
#uselib "HID.dll"
#func global HidP_GetSpecificButtonCaps "HidP_GetSpecificButtonCaps" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; HidP_GetSpecificButtonCaps ReportType, UsagePage, LinkCollection, Usage, varptr(ButtonCaps), varptr(ButtonCapsLength), PreparsedData   ; 戻り値は stat
; ReportType : HIDP_REPORT_TYPE -> "sptr"
; UsagePage : WORD optional -> "sptr"
; LinkCollection : WORD optional -> "sptr"
; Usage : WORD optional -> "sptr"
; ButtonCaps : HIDP_BUTTON_CAPS* out -> "sptr"
; ButtonCapsLength : WORD* in/out -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "HID.dll"
#cfunc global HidP_GetSpecificButtonCaps "HidP_GetSpecificButtonCaps" int, int, int, int, var, var, sptr
; res = HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
; ReportType : HIDP_REPORT_TYPE -> "int"
; UsagePage : WORD optional -> "int"
; LinkCollection : WORD optional -> "int"
; Usage : WORD optional -> "int"
; ButtonCaps : HIDP_BUTTON_CAPS* out -> "var"
; ButtonCapsLength : WORD* in/out -> "var"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; NTSTATUS HidP_GetSpecificButtonCaps(HIDP_REPORT_TYPE ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, HIDP_BUTTON_CAPS* ButtonCaps, WORD* ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData)
#uselib "HID.dll"
#cfunc global HidP_GetSpecificButtonCaps "HidP_GetSpecificButtonCaps" int, int, int, int, var, var, intptr
; res = HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
; ReportType : HIDP_REPORT_TYPE -> "int"
; UsagePage : WORD optional -> "int"
; LinkCollection : WORD optional -> "int"
; Usage : WORD optional -> "int"
; ButtonCaps : HIDP_BUTTON_CAPS* out -> "var"
; ButtonCapsLength : WORD* in/out -> "var"
; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	hid = windows.NewLazySystemDLL("HID.dll")
	procHidP_GetSpecificButtonCaps = hid.NewProc("HidP_GetSpecificButtonCaps")
)

// ReportType (HIDP_REPORT_TYPE), UsagePage (WORD optional), LinkCollection (WORD optional), Usage (WORD optional), ButtonCaps (HIDP_BUTTON_CAPS* out), ButtonCapsLength (WORD* in/out), PreparsedData (PHIDP_PREPARSED_DATA)
r1, _, err := procHidP_GetSpecificButtonCaps.Call(
	uintptr(ReportType),
	uintptr(UsagePage),
	uintptr(LinkCollection),
	uintptr(Usage),
	uintptr(ButtonCaps),
	uintptr(ButtonCapsLength),
	uintptr(PreparsedData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function HidP_GetSpecificButtonCaps(
  ReportType: Integer;   // HIDP_REPORT_TYPE
  UsagePage: Word;   // WORD optional
  LinkCollection: Word;   // WORD optional
  Usage: Word;   // WORD optional
  ButtonCaps: Pointer;   // HIDP_BUTTON_CAPS* out
  ButtonCapsLength: Pointer;   // WORD* in/out
  PreparsedData: NativeInt   // PHIDP_PREPARSED_DATA
): Integer; stdcall;
  external 'HID.dll' name 'HidP_GetSpecificButtonCaps';
result := DllCall("HID\HidP_GetSpecificButtonCaps"
    , "Int", ReportType   ; HIDP_REPORT_TYPE
    , "UShort", UsagePage   ; WORD optional
    , "UShort", LinkCollection   ; WORD optional
    , "UShort", Usage   ; WORD optional
    , "Ptr", ButtonCaps   ; HIDP_BUTTON_CAPS* out
    , "Ptr", ButtonCapsLength   ; WORD* in/out
    , "Ptr", PreparsedData   ; PHIDP_PREPARSED_DATA
    , "Int")   ; return: NTSTATUS
●HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData) = DLL("HID.dll", "int HidP_GetSpecificButtonCaps(int, int, int, int, void*, void*, int)")
# 呼び出し: HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
# ReportType : HIDP_REPORT_TYPE -> "int"
# UsagePage : WORD optional -> "int"
# LinkCollection : WORD optional -> "int"
# Usage : WORD optional -> "int"
# ButtonCaps : HIDP_BUTTON_CAPS* out -> "void*"
# ButtonCapsLength : WORD* in/out -> "void*"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "hid" fn HidP_GetSpecificButtonCaps(
    ReportType: i32, // HIDP_REPORT_TYPE
    UsagePage: u16, // WORD optional
    LinkCollection: u16, // WORD optional
    Usage: u16, // WORD optional
    ButtonCaps: [*c]HIDP_BUTTON_CAPS, // HIDP_BUTTON_CAPS* out
    ButtonCapsLength: [*c]u16, // WORD* in/out
    PreparsedData: isize // PHIDP_PREPARSED_DATA
) callconv(std.os.windows.WINAPI) i32;
proc HidP_GetSpecificButtonCaps(
    ReportType: int32,  # HIDP_REPORT_TYPE
    UsagePage: uint16,  # WORD optional
    LinkCollection: uint16,  # WORD optional
    Usage: uint16,  # WORD optional
    ButtonCaps: ptr HIDP_BUTTON_CAPS,  # HIDP_BUTTON_CAPS* out
    ButtonCapsLength: ptr uint16,  # WORD* in/out
    PreparsedData: int  # PHIDP_PREPARSED_DATA
): int32 {.importc: "HidP_GetSpecificButtonCaps", stdcall, dynlib: "HID.dll".}
pragma(lib, "hid");
extern(Windows)
int HidP_GetSpecificButtonCaps(
    int ReportType,   // HIDP_REPORT_TYPE
    ushort UsagePage,   // WORD optional
    ushort LinkCollection,   // WORD optional
    ushort Usage,   // WORD optional
    HIDP_BUTTON_CAPS* ButtonCaps,   // HIDP_BUTTON_CAPS* out
    ushort* ButtonCapsLength,   // WORD* in/out
    ptrdiff_t PreparsedData   // PHIDP_PREPARSED_DATA
);
ccall((:HidP_GetSpecificButtonCaps, "HID.dll"), stdcall, Int32,
      (Int32, UInt16, UInt16, UInt16, Ptr{HIDP_BUTTON_CAPS}, Ptr{UInt16}, Int),
      ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
# ReportType : HIDP_REPORT_TYPE -> Int32
# UsagePage : WORD optional -> UInt16
# LinkCollection : WORD optional -> UInt16
# Usage : WORD optional -> UInt16
# ButtonCaps : HIDP_BUTTON_CAPS* out -> Ptr{HIDP_BUTTON_CAPS}
# ButtonCapsLength : WORD* in/out -> Ptr{UInt16}
# PreparsedData : PHIDP_PREPARSED_DATA -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t HidP_GetSpecificButtonCaps(
    int32_t ReportType,
    uint16_t UsagePage,
    uint16_t LinkCollection,
    uint16_t Usage,
    void* ButtonCaps,
    uint16_t* ButtonCapsLength,
    intptr_t PreparsedData);
]]
local hid = ffi.load("hid")
-- hid.HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
-- ReportType : HIDP_REPORT_TYPE
-- UsagePage : WORD optional
-- LinkCollection : WORD optional
-- Usage : WORD optional
-- ButtonCaps : HIDP_BUTTON_CAPS* out
-- ButtonCapsLength : WORD* in/out
-- PreparsedData : PHIDP_PREPARSED_DATA
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('HID.dll');
const HidP_GetSpecificButtonCaps = lib.func('__stdcall', 'HidP_GetSpecificButtonCaps', 'int32_t', ['int32_t', 'uint16_t', 'uint16_t', 'uint16_t', 'void *', 'uint16_t *', 'intptr_t']);
// HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
// ReportType : HIDP_REPORT_TYPE -> 'int32_t'
// UsagePage : WORD optional -> 'uint16_t'
// LinkCollection : WORD optional -> 'uint16_t'
// Usage : WORD optional -> 'uint16_t'
// ButtonCaps : HIDP_BUTTON_CAPS* out -> 'void *'
// ButtonCapsLength : WORD* in/out -> 'uint16_t *'
// PreparsedData : PHIDP_PREPARSED_DATA -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("HID.dll", {
  HidP_GetSpecificButtonCaps: { parameters: ["i32", "u16", "u16", "u16", "pointer", "pointer", "isize"], result: "i32" },
});
// lib.symbols.HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData)
// ReportType : HIDP_REPORT_TYPE -> "i32"
// UsagePage : WORD optional -> "u16"
// LinkCollection : WORD optional -> "u16"
// Usage : WORD optional -> "u16"
// ButtonCaps : HIDP_BUTTON_CAPS* out -> "pointer"
// ButtonCapsLength : WORD* in/out -> "pointer"
// PreparsedData : PHIDP_PREPARSED_DATA -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t HidP_GetSpecificButtonCaps(
    int32_t ReportType,
    uint16_t UsagePage,
    uint16_t LinkCollection,
    uint16_t Usage,
    void* ButtonCaps,
    uint16_t* ButtonCapsLength,
    intptr_t PreparsedData);
C, "HID.dll");
// $ffi->HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, ButtonCaps, ButtonCapsLength, PreparsedData);
// ReportType : HIDP_REPORT_TYPE
// UsagePage : WORD optional
// LinkCollection : WORD optional
// Usage : WORD optional
// ButtonCaps : HIDP_BUTTON_CAPS* out
// ButtonCapsLength : WORD* in/out
// PreparsedData : PHIDP_PREPARSED_DATA
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Hid extends StdCallLibrary {
    Hid INSTANCE = Native.load("hid", Hid.class);
    int HidP_GetSpecificButtonCaps(
        int ReportType,   // HIDP_REPORT_TYPE
        short UsagePage,   // WORD optional
        short LinkCollection,   // WORD optional
        short Usage,   // WORD optional
        Pointer ButtonCaps,   // HIDP_BUTTON_CAPS* out
        ShortByReference ButtonCapsLength,   // WORD* in/out
        long PreparsedData   // PHIDP_PREPARSED_DATA
    );
}
@[Link("hid")]
lib LibHID
  fun HidP_GetSpecificButtonCaps = HidP_GetSpecificButtonCaps(
    ReportType : Int32,   # HIDP_REPORT_TYPE
    UsagePage : UInt16,   # WORD optional
    LinkCollection : UInt16,   # WORD optional
    Usage : UInt16,   # WORD optional
    ButtonCaps : HIDP_BUTTON_CAPS*,   # HIDP_BUTTON_CAPS* out
    ButtonCapsLength : UInt16*,   # WORD* in/out
    PreparsedData : LibC::SSizeT   # PHIDP_PREPARSED_DATA
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef HidP_GetSpecificButtonCapsNative = Int32 Function(Int32, Uint16, Uint16, Uint16, Pointer<Void>, Pointer<Uint16>, IntPtr);
typedef HidP_GetSpecificButtonCapsDart = int Function(int, int, int, int, Pointer<Void>, Pointer<Uint16>, int);
final HidP_GetSpecificButtonCaps = DynamicLibrary.open('HID.dll')
    .lookupFunction<HidP_GetSpecificButtonCapsNative, HidP_GetSpecificButtonCapsDart>('HidP_GetSpecificButtonCaps');
// ReportType : HIDP_REPORT_TYPE -> Int32
// UsagePage : WORD optional -> Uint16
// LinkCollection : WORD optional -> Uint16
// Usage : WORD optional -> Uint16
// ButtonCaps : HIDP_BUTTON_CAPS* out -> Pointer<Void>
// ButtonCapsLength : WORD* in/out -> Pointer<Uint16>
// PreparsedData : PHIDP_PREPARSED_DATA -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HidP_GetSpecificButtonCaps(
  ReportType: Integer;   // HIDP_REPORT_TYPE
  UsagePage: Word;   // WORD optional
  LinkCollection: Word;   // WORD optional
  Usage: Word;   // WORD optional
  ButtonCaps: Pointer;   // HIDP_BUTTON_CAPS* out
  ButtonCapsLength: Pointer;   // WORD* in/out
  PreparsedData: NativeInt   // PHIDP_PREPARSED_DATA
): Integer; stdcall;
  external 'HID.dll' name 'HidP_GetSpecificButtonCaps';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HidP_GetSpecificButtonCaps"
  c_HidP_GetSpecificButtonCaps :: Int32 -> Word16 -> Word16 -> Word16 -> Ptr () -> Ptr Word16 -> CIntPtr -> IO Int32
-- ReportType : HIDP_REPORT_TYPE -> Int32
-- UsagePage : WORD optional -> Word16
-- LinkCollection : WORD optional -> Word16
-- Usage : WORD optional -> Word16
-- ButtonCaps : HIDP_BUTTON_CAPS* out -> Ptr ()
-- ButtonCapsLength : WORD* in/out -> Ptr Word16
-- PreparsedData : PHIDP_PREPARSED_DATA -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hidp_getspecificbuttoncaps =
  foreign "HidP_GetSpecificButtonCaps"
    (int32_t @-> uint16_t @-> uint16_t @-> uint16_t @-> (ptr void) @-> (ptr uint16_t) @-> intptr_t @-> returning int32_t)
(* ReportType : HIDP_REPORT_TYPE -> int32_t *)
(* UsagePage : WORD optional -> uint16_t *)
(* LinkCollection : WORD optional -> uint16_t *)
(* Usage : WORD optional -> uint16_t *)
(* ButtonCaps : HIDP_BUTTON_CAPS* out -> (ptr void) *)
(* ButtonCapsLength : WORD* in/out -> (ptr uint16_t) *)
(* PreparsedData : PHIDP_PREPARSED_DATA -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library hid (t "HID.dll"))
(cffi:use-foreign-library hid)

(cffi:defcfun ("HidP_GetSpecificButtonCaps" hid-p-get-specific-button-caps :convention :stdcall) :int32
  (report-type :int32)   ; HIDP_REPORT_TYPE
  (usage-page :uint16)   ; WORD optional
  (link-collection :uint16)   ; WORD optional
  (usage :uint16)   ; WORD optional
  (button-caps :pointer)   ; HIDP_BUTTON_CAPS* out
  (button-caps-length :pointer)   ; WORD* in/out
  (preparsed-data :int64))   ; PHIDP_PREPARSED_DATA
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HidP_GetSpecificButtonCaps = Win32::API::More->new('HID',
    'int HidP_GetSpecificButtonCaps(int ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, LPVOID ButtonCaps, LPVOID ButtonCapsLength, LPARAM PreparsedData)');
# my $ret = $HidP_GetSpecificButtonCaps->Call($ReportType, $UsagePage, $LinkCollection, $Usage, $ButtonCaps, $ButtonCapsLength, $PreparsedData);
# ReportType : HIDP_REPORT_TYPE -> int
# UsagePage : WORD optional -> WORD
# LinkCollection : WORD optional -> WORD
# Usage : WORD optional -> WORD
# ButtonCaps : HIDP_BUTTON_CAPS* out -> LPVOID
# ButtonCapsLength : WORD* in/out -> LPVOID
# PreparsedData : PHIDP_PREPARSED_DATA -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型