ホーム › Devices.HumanInterfaceDevice › HidP_GetSpecificButtonCaps
HidP_GetSpecificButtonCaps
関数指定した条件に一致するHIDボタンの能力情報を取得する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ReportType | HIDP_REPORT_TYPE | in |
| UsagePage | WORD | inoptional |
| LinkCollection | WORD | inoptional |
| Usage | WORD | inoptional |
| ButtonCaps | HIDP_BUTTON_CAPS* | out |
| ButtonCapsLength | WORD* | inout |
| PreparsedData | PHIDP_PREPARSED_DATA | in |
戻り値の型: 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 方式にも切替可。#uselib "HID.dll" #cfunc global HidP_GetSpecificButtonCaps "HidP_GetSpecificButtonCaps" int, int, int, int, sptr, sptr, sptr ; res = HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, varptr(ButtonCaps), varptr(ButtonCapsLength), PreparsedData) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD optional -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD optional -> "int" ; ButtonCaps : HIDP_BUTTON_CAPS* out -> "sptr" ; ButtonCapsLength : WORD* in/out -> "sptr" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, intptr, intptr ; res = HidP_GetSpecificButtonCaps(ReportType, UsagePage, LinkCollection, Usage, varptr(ButtonCaps), varptr(ButtonCapsLength), PreparsedData) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD optional -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD optional -> "int" ; ButtonCaps : HIDP_BUTTON_CAPS* out -> "intptr" ; ButtonCapsLength : WORD* in/out -> "intptr" ; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // NTSTATUSfunction 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)。