ホーム › Devices.HumanInterfaceDevice › HidP_MaxUsageListLength
HidP_MaxUsageListLength
関数HIDレポートが返しうる用途リストの最大長を取得する。
シグネチャ
// HID.dll
#include <windows.h>
DWORD HidP_MaxUsageListLength(
HIDP_REPORT_TYPE ReportType,
WORD UsagePage, // optional
PHIDP_PREPARSED_DATA PreparsedData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ReportType | HIDP_REPORT_TYPE | in | 対象のレポート種別をHIDP_REPORT_TYPE(Input/Output/Feature)で指定する。 |
| UsagePage | WORD | inoptional | 対象とするユーセージページを指定する。0で全ページを対象とする。 |
| PreparsedData | PHIDP_PREPARSED_DATA | in | HidD_GetPreparsedDataで取得した前解析データへのポインタを指定する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// HID.dll
#include <windows.h>
DWORD HidP_MaxUsageListLength(
HIDP_REPORT_TYPE ReportType,
WORD UsagePage, // optional
PHIDP_PREPARSED_DATA PreparsedData
);[DllImport("HID.dll", ExactSpelling = true)]
static extern uint HidP_MaxUsageListLength(
int ReportType, // HIDP_REPORT_TYPE
ushort UsagePage, // WORD optional
IntPtr PreparsedData // PHIDP_PREPARSED_DATA
);<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_MaxUsageListLength(
ReportType As Integer, ' HIDP_REPORT_TYPE
UsagePage As UShort, ' WORD optional
PreparsedData As IntPtr ' PHIDP_PREPARSED_DATA
) As UInteger
End Function' ReportType : HIDP_REPORT_TYPE
' UsagePage : WORD optional
' PreparsedData : PHIDP_PREPARSED_DATA
Declare PtrSafe Function HidP_MaxUsageListLength Lib "hid" ( _
ByVal ReportType As Long, _
ByVal UsagePage 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_MaxUsageListLength = ctypes.windll.hid.HidP_MaxUsageListLength
HidP_MaxUsageListLength.restype = wintypes.DWORD
HidP_MaxUsageListLength.argtypes = [
ctypes.c_int, # ReportType : HIDP_REPORT_TYPE
ctypes.c_ushort, # UsagePage : WORD optional
ctypes.c_ssize_t, # PreparsedData : PHIDP_PREPARSED_DATA
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('HID.dll')
HidP_MaxUsageListLength = Fiddle::Function.new(
lib['HidP_MaxUsageListLength'],
[
Fiddle::TYPE_INT, # ReportType : HIDP_REPORT_TYPE
-Fiddle::TYPE_SHORT, # UsagePage : WORD optional
Fiddle::TYPE_INTPTR_T, # PreparsedData : PHIDP_PREPARSED_DATA
],
-Fiddle::TYPE_INT)#[link(name = "hid")]
extern "system" {
fn HidP_MaxUsageListLength(
ReportType: i32, // HIDP_REPORT_TYPE
UsagePage: u16, // WORD optional
PreparsedData: isize // PHIDP_PREPARSED_DATA
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("HID.dll")]
public static extern uint HidP_MaxUsageListLength(int ReportType, ushort UsagePage, IntPtr PreparsedData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_MaxUsageListLength' -Namespace Win32 -PassThru
# $api::HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)#uselib "HID.dll"
#func global HidP_MaxUsageListLength "HidP_MaxUsageListLength" sptr, sptr, sptr
; HidP_MaxUsageListLength ReportType, UsagePage, PreparsedData ; 戻り値は stat
; ReportType : HIDP_REPORT_TYPE -> "sptr"
; UsagePage : WORD optional -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "HID.dll"
#cfunc global HidP_MaxUsageListLength "HidP_MaxUsageListLength" int, int, sptr
; res = HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
; ReportType : HIDP_REPORT_TYPE -> "int"
; UsagePage : WORD optional -> "int"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"; DWORD HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, WORD UsagePage, PHIDP_PREPARSED_DATA PreparsedData)
#uselib "HID.dll"
#cfunc global HidP_MaxUsageListLength "HidP_MaxUsageListLength" int, int, intptr
; res = HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
; ReportType : HIDP_REPORT_TYPE -> "int"
; UsagePage : WORD optional -> "int"
; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
hid = windows.NewLazySystemDLL("HID.dll")
procHidP_MaxUsageListLength = hid.NewProc("HidP_MaxUsageListLength")
)
// ReportType (HIDP_REPORT_TYPE), UsagePage (WORD optional), PreparsedData (PHIDP_PREPARSED_DATA)
r1, _, err := procHidP_MaxUsageListLength.Call(
uintptr(ReportType),
uintptr(UsagePage),
uintptr(PreparsedData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction HidP_MaxUsageListLength(
ReportType: Integer; // HIDP_REPORT_TYPE
UsagePage: Word; // WORD optional
PreparsedData: NativeInt // PHIDP_PREPARSED_DATA
): DWORD; stdcall;
external 'HID.dll' name 'HidP_MaxUsageListLength';result := DllCall("HID\HidP_MaxUsageListLength"
, "Int", ReportType ; HIDP_REPORT_TYPE
, "UShort", UsagePage ; WORD optional
, "Ptr", PreparsedData ; PHIDP_PREPARSED_DATA
, "UInt") ; return: DWORD●HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData) = DLL("HID.dll", "dword HidP_MaxUsageListLength(int, int, int)")
# 呼び出し: HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
# ReportType : HIDP_REPORT_TYPE -> "int"
# UsagePage : WORD optional -> "int"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "hid" fn HidP_MaxUsageListLength(
ReportType: i32, // HIDP_REPORT_TYPE
UsagePage: u16, // WORD optional
PreparsedData: isize // PHIDP_PREPARSED_DATA
) callconv(std.os.windows.WINAPI) u32;proc HidP_MaxUsageListLength(
ReportType: int32, # HIDP_REPORT_TYPE
UsagePage: uint16, # WORD optional
PreparsedData: int # PHIDP_PREPARSED_DATA
): uint32 {.importc: "HidP_MaxUsageListLength", stdcall, dynlib: "HID.dll".}pragma(lib, "hid");
extern(Windows)
uint HidP_MaxUsageListLength(
int ReportType, // HIDP_REPORT_TYPE
ushort UsagePage, // WORD optional
ptrdiff_t PreparsedData // PHIDP_PREPARSED_DATA
);ccall((:HidP_MaxUsageListLength, "HID.dll"), stdcall, UInt32,
(Int32, UInt16, Int),
ReportType, UsagePage, PreparsedData)
# ReportType : HIDP_REPORT_TYPE -> Int32
# UsagePage : WORD optional -> UInt16
# PreparsedData : PHIDP_PREPARSED_DATA -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t HidP_MaxUsageListLength(
int32_t ReportType,
uint16_t UsagePage,
intptr_t PreparsedData);
]]
local hid = ffi.load("hid")
-- hid.HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
-- ReportType : HIDP_REPORT_TYPE
-- UsagePage : WORD optional
-- PreparsedData : PHIDP_PREPARSED_DATA
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('HID.dll');
const HidP_MaxUsageListLength = lib.func('__stdcall', 'HidP_MaxUsageListLength', 'uint32_t', ['int32_t', 'uint16_t', 'intptr_t']);
// HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
// ReportType : HIDP_REPORT_TYPE -> 'int32_t'
// UsagePage : WORD optional -> 'uint16_t'
// PreparsedData : PHIDP_PREPARSED_DATA -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("HID.dll", {
HidP_MaxUsageListLength: { parameters: ["i32", "u16", "isize"], result: "u32" },
});
// lib.symbols.HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
// ReportType : HIDP_REPORT_TYPE -> "i32"
// UsagePage : WORD optional -> "u16"
// PreparsedData : PHIDP_PREPARSED_DATA -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t HidP_MaxUsageListLength(
int32_t ReportType,
uint16_t UsagePage,
intptr_t PreparsedData);
C, "HID.dll");
// $ffi->HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData);
// ReportType : HIDP_REPORT_TYPE
// UsagePage : WORD optional
// 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_MaxUsageListLength(
int ReportType, // HIDP_REPORT_TYPE
short UsagePage, // WORD optional
long PreparsedData // PHIDP_PREPARSED_DATA
);
}@[Link("hid")]
lib LibHID
fun HidP_MaxUsageListLength = HidP_MaxUsageListLength(
ReportType : Int32, # HIDP_REPORT_TYPE
UsagePage : UInt16, # WORD optional
PreparsedData : LibC::SSizeT # PHIDP_PREPARSED_DATA
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HidP_MaxUsageListLengthNative = Uint32 Function(Int32, Uint16, IntPtr);
typedef HidP_MaxUsageListLengthDart = int Function(int, int, int);
final HidP_MaxUsageListLength = DynamicLibrary.open('HID.dll')
.lookupFunction<HidP_MaxUsageListLengthNative, HidP_MaxUsageListLengthDart>('HidP_MaxUsageListLength');
// ReportType : HIDP_REPORT_TYPE -> Int32
// UsagePage : WORD optional -> Uint16
// PreparsedData : PHIDP_PREPARSED_DATA -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HidP_MaxUsageListLength(
ReportType: Integer; // HIDP_REPORT_TYPE
UsagePage: Word; // WORD optional
PreparsedData: NativeInt // PHIDP_PREPARSED_DATA
): DWORD; stdcall;
external 'HID.dll' name 'HidP_MaxUsageListLength';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HidP_MaxUsageListLength"
c_HidP_MaxUsageListLength :: Int32 -> Word16 -> CIntPtr -> IO Word32
-- ReportType : HIDP_REPORT_TYPE -> Int32
-- UsagePage : WORD optional -> Word16
-- PreparsedData : PHIDP_PREPARSED_DATA -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hidp_maxusagelistlength =
foreign "HidP_MaxUsageListLength"
(int32_t @-> uint16_t @-> intptr_t @-> returning uint32_t)
(* ReportType : HIDP_REPORT_TYPE -> int32_t *)
(* UsagePage : WORD optional -> 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_MaxUsageListLength" hid-p-max-usage-list-length :convention :stdcall) :uint32
(report-type :int32) ; HIDP_REPORT_TYPE
(usage-page :uint16) ; WORD optional
(preparsed-data :int64)) ; PHIDP_PREPARSED_DATA
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HidP_MaxUsageListLength = Win32::API::More->new('HID',
'DWORD HidP_MaxUsageListLength(int ReportType, WORD UsagePage, LPARAM PreparsedData)');
# my $ret = $HidP_MaxUsageListLength->Call($ReportType, $UsagePage, $PreparsedData);
# ReportType : HIDP_REPORT_TYPE -> int
# UsagePage : WORD optional -> WORD
# PreparsedData : PHIDP_PREPARSED_DATA -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型