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

HidP_UnsetUsages

関数
HIDレポート内の指定したボタン用途をオフに設定する。
DLLHID.dll呼出規約winapi

シグネチャ

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

NTSTATUS HidP_UnsetUsages(
    HIDP_REPORT_TYPE ReportType,
    WORD UsagePage,
    WORD LinkCollection,   // optional
    WORD* UsageList,
    DWORD* UsageLength,
    PHIDP_PREPARSED_DATA PreparsedData,
    LPSTR Report,
    DWORD ReportLength
);

パラメーター

名前方向
ReportTypeHIDP_REPORT_TYPEin
UsagePageWORDin
LinkCollectionWORDinoptional
UsageListWORD*inout
UsageLengthDWORD*inout
PreparsedDataPHIDP_PREPARSED_DATAin
ReportLPSTRin
ReportLengthDWORDin

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS HidP_UnsetUsages(
    HIDP_REPORT_TYPE ReportType,
    WORD UsagePage,
    WORD LinkCollection,   // optional
    WORD* UsageList,
    DWORD* UsageLength,
    PHIDP_PREPARSED_DATA PreparsedData,
    LPSTR Report,
    DWORD ReportLength
);
[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_UnsetUsages(
    int ReportType,   // HIDP_REPORT_TYPE
    ushort UsagePage,   // WORD
    ushort LinkCollection,   // WORD optional
    ref ushort UsageList,   // WORD* in/out
    ref uint UsageLength,   // DWORD* in/out
    IntPtr PreparsedData,   // PHIDP_PREPARSED_DATA
    [MarshalAs(UnmanagedType.LPStr)] string Report,   // LPSTR
    uint ReportLength   // DWORD
);
<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_UnsetUsages(
    ReportType As Integer,   ' HIDP_REPORT_TYPE
    UsagePage As UShort,   ' WORD
    LinkCollection As UShort,   ' WORD optional
    ByRef UsageList As UShort,   ' WORD* in/out
    ByRef UsageLength As UInteger,   ' DWORD* in/out
    PreparsedData As IntPtr,   ' PHIDP_PREPARSED_DATA
    <MarshalAs(UnmanagedType.LPStr)> Report As String,   ' LPSTR
    ReportLength As UInteger   ' DWORD
) As Integer
End Function
' ReportType : HIDP_REPORT_TYPE
' UsagePage : WORD
' LinkCollection : WORD optional
' UsageList : WORD* in/out
' UsageLength : DWORD* in/out
' PreparsedData : PHIDP_PREPARSED_DATA
' Report : LPSTR
' ReportLength : DWORD
Declare PtrSafe Function HidP_UnsetUsages Lib "hid" ( _
    ByVal ReportType As Long, _
    ByVal UsagePage As Integer, _
    ByVal LinkCollection As Integer, _
    ByRef UsageList As Integer, _
    ByRef UsageLength As Long, _
    ByVal PreparsedData As LongPtr, _
    ByVal Report As String, _
    ByVal ReportLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HidP_UnsetUsages = ctypes.windll.hid.HidP_UnsetUsages
HidP_UnsetUsages.restype = ctypes.c_int
HidP_UnsetUsages.argtypes = [
    ctypes.c_int,  # ReportType : HIDP_REPORT_TYPE
    ctypes.c_ushort,  # UsagePage : WORD
    ctypes.c_ushort,  # LinkCollection : WORD optional
    ctypes.POINTER(ctypes.c_ushort),  # UsageList : WORD* in/out
    ctypes.POINTER(wintypes.DWORD),  # UsageLength : DWORD* in/out
    ctypes.c_ssize_t,  # PreparsedData : PHIDP_PREPARSED_DATA
    wintypes.LPCSTR,  # Report : LPSTR
    wintypes.DWORD,  # ReportLength : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	hid = windows.NewLazySystemDLL("HID.dll")
	procHidP_UnsetUsages = hid.NewProc("HidP_UnsetUsages")
)

// ReportType (HIDP_REPORT_TYPE), UsagePage (WORD), LinkCollection (WORD optional), UsageList (WORD* in/out), UsageLength (DWORD* in/out), PreparsedData (PHIDP_PREPARSED_DATA), Report (LPSTR), ReportLength (DWORD)
r1, _, err := procHidP_UnsetUsages.Call(
	uintptr(ReportType),
	uintptr(UsagePage),
	uintptr(LinkCollection),
	uintptr(UsageList),
	uintptr(UsageLength),
	uintptr(PreparsedData),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Report))),
	uintptr(ReportLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function HidP_UnsetUsages(
  ReportType: Integer;   // HIDP_REPORT_TYPE
  UsagePage: Word;   // WORD
  LinkCollection: Word;   // WORD optional
  UsageList: Pointer;   // WORD* in/out
  UsageLength: Pointer;   // DWORD* in/out
  PreparsedData: NativeInt;   // PHIDP_PREPARSED_DATA
  Report: PAnsiChar;   // LPSTR
  ReportLength: DWORD   // DWORD
): Integer; stdcall;
  external 'HID.dll' name 'HidP_UnsetUsages';
result := DllCall("HID\HidP_UnsetUsages"
    , "Int", ReportType   ; HIDP_REPORT_TYPE
    , "UShort", UsagePage   ; WORD
    , "UShort", LinkCollection   ; WORD optional
    , "Ptr", UsageList   ; WORD* in/out
    , "Ptr", UsageLength   ; DWORD* in/out
    , "Ptr", PreparsedData   ; PHIDP_PREPARSED_DATA
    , "AStr", Report   ; LPSTR
    , "UInt", ReportLength   ; DWORD
    , "Int")   ; return: NTSTATUS
●HidP_UnsetUsages(ReportType, UsagePage, LinkCollection, UsageList, UsageLength, PreparsedData, Report, ReportLength) = DLL("HID.dll", "int HidP_UnsetUsages(int, int, int, void*, void*, int, char*, dword)")
# 呼び出し: HidP_UnsetUsages(ReportType, UsagePage, LinkCollection, UsageList, UsageLength, PreparsedData, Report, ReportLength)
# ReportType : HIDP_REPORT_TYPE -> "int"
# UsagePage : WORD -> "int"
# LinkCollection : WORD optional -> "int"
# UsageList : WORD* in/out -> "void*"
# UsageLength : DWORD* in/out -> "void*"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# Report : LPSTR -> "char*"
# ReportLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。