ホーム › Devices.HumanInterfaceDevice › HidP_GetUsageValue
HidP_GetUsageValue
関数HIDレポートから指定した用途の値を取得する。
シグネチャ
// HID.dll
#include <windows.h>
NTSTATUS HidP_GetUsageValue(
HIDP_REPORT_TYPE ReportType,
WORD UsagePage,
WORD LinkCollection, // optional
WORD Usage,
DWORD* UsageValue,
PHIDP_PREPARSED_DATA PreparsedData,
LPSTR Report,
DWORD ReportLength
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ReportType | HIDP_REPORT_TYPE | in | 対象のレポート種別をHIDP_REPORT_TYPE(Input/Output/Feature)で指定する。 |
| UsagePage | WORD | in | 取得する値コントロールのユーセージページを指定する。 |
| LinkCollection | WORD | inoptional | 対象のリンクコレクションを指定する。0で限定しない。 |
| Usage | WORD | in | 値を取得する対象のユーセージを指定する。 |
| UsageValue | DWORD* | out | 取得した論理値を受け取るDWORDへのポインタを指定する。出力専用。 |
| PreparsedData | PHIDP_PREPARSED_DATA | in | HidD_GetPreparsedDataで取得した前解析データへのポインタを指定する。 |
| Report | LPSTR | in | 読み取り元のレポートバッファへのポインタを指定する。 |
| ReportLength | DWORD | in | Reportバッファのバイト長を指定する。 |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// HID.dll
#include <windows.h>
NTSTATUS HidP_GetUsageValue(
HIDP_REPORT_TYPE ReportType,
WORD UsagePage,
WORD LinkCollection, // optional
WORD Usage,
DWORD* UsageValue,
PHIDP_PREPARSED_DATA PreparsedData,
LPSTR Report,
DWORD ReportLength
);[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_GetUsageValue(
int ReportType, // HIDP_REPORT_TYPE
ushort UsagePage, // WORD
ushort LinkCollection, // WORD optional
ushort Usage, // WORD
out uint UsageValue, // DWORD* out
IntPtr PreparsedData, // PHIDP_PREPARSED_DATA
[MarshalAs(UnmanagedType.LPStr)] string Report, // LPSTR
uint ReportLength // DWORD
);<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_GetUsageValue(
ReportType As Integer, ' HIDP_REPORT_TYPE
UsagePage As UShort, ' WORD
LinkCollection As UShort, ' WORD optional
Usage As UShort, ' WORD
<Out> ByRef UsageValue As UInteger, ' DWORD* 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
' Usage : WORD
' UsageValue : DWORD* out
' PreparsedData : PHIDP_PREPARSED_DATA
' Report : LPSTR
' ReportLength : DWORD
Declare PtrSafe Function HidP_GetUsageValue Lib "hid" ( _
ByVal ReportType As Long, _
ByVal UsagePage As Integer, _
ByVal LinkCollection As Integer, _
ByVal Usage As Integer, _
ByRef UsageValue 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_GetUsageValue = ctypes.windll.hid.HidP_GetUsageValue
HidP_GetUsageValue.restype = ctypes.c_int
HidP_GetUsageValue.argtypes = [
ctypes.c_int, # ReportType : HIDP_REPORT_TYPE
ctypes.c_ushort, # UsagePage : WORD
ctypes.c_ushort, # LinkCollection : WORD optional
ctypes.c_ushort, # Usage : WORD
ctypes.POINTER(wintypes.DWORD), # UsageValue : DWORD* 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_GetUsageValue = Fiddle::Function.new(
lib['HidP_GetUsageValue'],
[
Fiddle::TYPE_INT, # ReportType : HIDP_REPORT_TYPE
-Fiddle::TYPE_SHORT, # UsagePage : WORD
-Fiddle::TYPE_SHORT, # LinkCollection : WORD optional
-Fiddle::TYPE_SHORT, # Usage : WORD
Fiddle::TYPE_VOIDP, # UsageValue : DWORD* 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_GetUsageValue(
ReportType: i32, // HIDP_REPORT_TYPE
UsagePage: u16, // WORD
LinkCollection: u16, // WORD optional
Usage: u16, // WORD
UsageValue: *mut u32, // DWORD* 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_GetUsageValue(int ReportType, ushort UsagePage, ushort LinkCollection, ushort Usage, out uint UsageValue, IntPtr PreparsedData, [MarshalAs(UnmanagedType.LPStr)] string Report, uint ReportLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_GetUsageValue' -Namespace Win32 -PassThru
# $api::HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)#uselib "HID.dll"
#func global HidP_GetUsageValue "HidP_GetUsageValue" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; HidP_GetUsageValue ReportType, UsagePage, LinkCollection, Usage, varptr(UsageValue), PreparsedData, Report, ReportLength ; 戻り値は stat
; ReportType : HIDP_REPORT_TYPE -> "sptr"
; UsagePage : WORD -> "sptr"
; LinkCollection : WORD optional -> "sptr"
; Usage : WORD -> "sptr"
; UsageValue : DWORD* out -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; Report : LPSTR -> "sptr"
; ReportLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "HID.dll" #cfunc global HidP_GetUsageValue "HidP_GetUsageValue" int, int, int, int, var, sptr, str, int ; res = HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD -> "int" ; UsageValue : DWORD* out -> "var" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "HID.dll" #cfunc global HidP_GetUsageValue "HidP_GetUsageValue" int, int, int, int, sptr, sptr, str, int ; res = HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, varptr(UsageValue), PreparsedData, Report, ReportLength) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD -> "int" ; UsageValue : DWORD* out -> "sptr" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, DWORD* UsageValue, PHIDP_PREPARSED_DATA PreparsedData, LPSTR Report, DWORD ReportLength) #uselib "HID.dll" #cfunc global HidP_GetUsageValue "HidP_GetUsageValue" int, int, int, int, var, intptr, str, int ; res = HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD -> "int" ; UsageValue : DWORD* out -> "var" ; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, DWORD* UsageValue, PHIDP_PREPARSED_DATA PreparsedData, LPSTR Report, DWORD ReportLength) #uselib "HID.dll" #cfunc global HidP_GetUsageValue "HidP_GetUsageValue" int, int, int, int, intptr, intptr, str, int ; res = HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, varptr(UsageValue), PreparsedData, Report, ReportLength) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD -> "int" ; UsageValue : DWORD* out -> "intptr" ; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
hid = windows.NewLazySystemDLL("HID.dll")
procHidP_GetUsageValue = hid.NewProc("HidP_GetUsageValue")
)
// ReportType (HIDP_REPORT_TYPE), UsagePage (WORD), LinkCollection (WORD optional), Usage (WORD), UsageValue (DWORD* out), PreparsedData (PHIDP_PREPARSED_DATA), Report (LPSTR), ReportLength (DWORD)
r1, _, err := procHidP_GetUsageValue.Call(
uintptr(ReportType),
uintptr(UsagePage),
uintptr(LinkCollection),
uintptr(Usage),
uintptr(UsageValue),
uintptr(PreparsedData),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Report))),
uintptr(ReportLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction HidP_GetUsageValue(
ReportType: Integer; // HIDP_REPORT_TYPE
UsagePage: Word; // WORD
LinkCollection: Word; // WORD optional
Usage: Word; // WORD
UsageValue: Pointer; // DWORD* out
PreparsedData: NativeInt; // PHIDP_PREPARSED_DATA
Report: PAnsiChar; // LPSTR
ReportLength: DWORD // DWORD
): Integer; stdcall;
external 'HID.dll' name 'HidP_GetUsageValue';result := DllCall("HID\HidP_GetUsageValue"
, "Int", ReportType ; HIDP_REPORT_TYPE
, "UShort", UsagePage ; WORD
, "UShort", LinkCollection ; WORD optional
, "UShort", Usage ; WORD
, "Ptr", UsageValue ; DWORD* out
, "Ptr", PreparsedData ; PHIDP_PREPARSED_DATA
, "AStr", Report ; LPSTR
, "UInt", ReportLength ; DWORD
, "Int") ; return: NTSTATUS●HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength) = DLL("HID.dll", "int HidP_GetUsageValue(int, int, int, int, void*, int, char*, dword)")
# 呼び出し: HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)
# ReportType : HIDP_REPORT_TYPE -> "int"
# UsagePage : WORD -> "int"
# LinkCollection : WORD optional -> "int"
# Usage : WORD -> "int"
# UsageValue : DWORD* out -> "void*"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# Report : LPSTR -> "char*"
# ReportLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "hid" fn HidP_GetUsageValue(
ReportType: i32, // HIDP_REPORT_TYPE
UsagePage: u16, // WORD
LinkCollection: u16, // WORD optional
Usage: u16, // WORD
UsageValue: [*c]u32, // DWORD* out
PreparsedData: isize, // PHIDP_PREPARSED_DATA
Report: [*c]const u8, // LPSTR
ReportLength: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc HidP_GetUsageValue(
ReportType: int32, # HIDP_REPORT_TYPE
UsagePage: uint16, # WORD
LinkCollection: uint16, # WORD optional
Usage: uint16, # WORD
UsageValue: ptr uint32, # DWORD* out
PreparsedData: int, # PHIDP_PREPARSED_DATA
Report: cstring, # LPSTR
ReportLength: uint32 # DWORD
): int32 {.importc: "HidP_GetUsageValue", stdcall, dynlib: "HID.dll".}pragma(lib, "hid");
extern(Windows)
int HidP_GetUsageValue(
int ReportType, // HIDP_REPORT_TYPE
ushort UsagePage, // WORD
ushort LinkCollection, // WORD optional
ushort Usage, // WORD
uint* UsageValue, // DWORD* out
ptrdiff_t PreparsedData, // PHIDP_PREPARSED_DATA
const(char)* Report, // LPSTR
uint ReportLength // DWORD
);ccall((:HidP_GetUsageValue, "HID.dll"), stdcall, Int32,
(Int32, UInt16, UInt16, UInt16, Ptr{UInt32}, Int, Cstring, UInt32),
ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)
# ReportType : HIDP_REPORT_TYPE -> Int32
# UsagePage : WORD -> UInt16
# LinkCollection : WORD optional -> UInt16
# Usage : WORD -> UInt16
# UsageValue : DWORD* out -> Ptr{UInt32}
# PreparsedData : PHIDP_PREPARSED_DATA -> Int
# Report : LPSTR -> Cstring
# ReportLength : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HidP_GetUsageValue(
int32_t ReportType,
uint16_t UsagePage,
uint16_t LinkCollection,
uint16_t Usage,
uint32_t* UsageValue,
intptr_t PreparsedData,
const char* Report,
uint32_t ReportLength);
]]
local hid = ffi.load("hid")
-- hid.HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)
-- ReportType : HIDP_REPORT_TYPE
-- UsagePage : WORD
-- LinkCollection : WORD optional
-- Usage : WORD
-- UsageValue : DWORD* out
-- PreparsedData : PHIDP_PREPARSED_DATA
-- Report : LPSTR
-- ReportLength : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('HID.dll');
const HidP_GetUsageValue = lib.func('__stdcall', 'HidP_GetUsageValue', 'int32_t', ['int32_t', 'uint16_t', 'uint16_t', 'uint16_t', 'uint32_t *', 'intptr_t', 'str', 'uint32_t']);
// HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)
// ReportType : HIDP_REPORT_TYPE -> 'int32_t'
// UsagePage : WORD -> 'uint16_t'
// LinkCollection : WORD optional -> 'uint16_t'
// Usage : WORD -> 'uint16_t'
// UsageValue : DWORD* out -> 'uint32_t *'
// PreparsedData : PHIDP_PREPARSED_DATA -> 'intptr_t'
// Report : LPSTR -> 'str'
// ReportLength : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("HID.dll", {
HidP_GetUsageValue: { parameters: ["i32", "u16", "u16", "u16", "pointer", "isize", "buffer", "u32"], result: "i32" },
});
// lib.symbols.HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)
// ReportType : HIDP_REPORT_TYPE -> "i32"
// UsagePage : WORD -> "u16"
// LinkCollection : WORD optional -> "u16"
// Usage : WORD -> "u16"
// UsageValue : DWORD* out -> "pointer"
// PreparsedData : PHIDP_PREPARSED_DATA -> "isize"
// Report : LPSTR -> "buffer"
// ReportLength : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HidP_GetUsageValue(
int32_t ReportType,
uint16_t UsagePage,
uint16_t LinkCollection,
uint16_t Usage,
uint32_t* UsageValue,
intptr_t PreparsedData,
const char* Report,
uint32_t ReportLength);
C, "HID.dll");
// $ffi->HidP_GetUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength);
// ReportType : HIDP_REPORT_TYPE
// UsagePage : WORD
// LinkCollection : WORD optional
// Usage : WORD
// UsageValue : DWORD* out
// PreparsedData : PHIDP_PREPARSED_DATA
// Report : LPSTR
// ReportLength : DWORD
// 構造体/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_GetUsageValue(
int ReportType, // HIDP_REPORT_TYPE
short UsagePage, // WORD
short LinkCollection, // WORD optional
short Usage, // WORD
IntByReference UsageValue, // DWORD* out
long PreparsedData, // PHIDP_PREPARSED_DATA
String Report, // LPSTR
int ReportLength // DWORD
);
}@[Link("hid")]
lib LibHID
fun HidP_GetUsageValue = HidP_GetUsageValue(
ReportType : Int32, # HIDP_REPORT_TYPE
UsagePage : UInt16, # WORD
LinkCollection : UInt16, # WORD optional
Usage : UInt16, # WORD
UsageValue : UInt32*, # DWORD* out
PreparsedData : LibC::SSizeT, # PHIDP_PREPARSED_DATA
Report : UInt8*, # LPSTR
ReportLength : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HidP_GetUsageValueNative = Int32 Function(Int32, Uint16, Uint16, Uint16, Pointer<Uint32>, IntPtr, Pointer<Utf8>, Uint32);
typedef HidP_GetUsageValueDart = int Function(int, int, int, int, Pointer<Uint32>, int, Pointer<Utf8>, int);
final HidP_GetUsageValue = DynamicLibrary.open('HID.dll')
.lookupFunction<HidP_GetUsageValueNative, HidP_GetUsageValueDart>('HidP_GetUsageValue');
// ReportType : HIDP_REPORT_TYPE -> Int32
// UsagePage : WORD -> Uint16
// LinkCollection : WORD optional -> Uint16
// Usage : WORD -> Uint16
// UsageValue : DWORD* out -> Pointer<Uint32>
// PreparsedData : PHIDP_PREPARSED_DATA -> IntPtr
// Report : LPSTR -> Pointer<Utf8>
// ReportLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HidP_GetUsageValue(
ReportType: Integer; // HIDP_REPORT_TYPE
UsagePage: Word; // WORD
LinkCollection: Word; // WORD optional
Usage: Word; // WORD
UsageValue: Pointer; // DWORD* out
PreparsedData: NativeInt; // PHIDP_PREPARSED_DATA
Report: PAnsiChar; // LPSTR
ReportLength: DWORD // DWORD
): Integer; stdcall;
external 'HID.dll' name 'HidP_GetUsageValue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HidP_GetUsageValue"
c_HidP_GetUsageValue :: Int32 -> Word16 -> Word16 -> Word16 -> Ptr Word32 -> CIntPtr -> CString -> Word32 -> IO Int32
-- ReportType : HIDP_REPORT_TYPE -> Int32
-- UsagePage : WORD -> Word16
-- LinkCollection : WORD optional -> Word16
-- Usage : WORD -> Word16
-- UsageValue : DWORD* out -> Ptr Word32
-- PreparsedData : PHIDP_PREPARSED_DATA -> CIntPtr
-- Report : LPSTR -> CString
-- ReportLength : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hidp_getusagevalue =
foreign "HidP_GetUsageValue"
(int32_t @-> uint16_t @-> uint16_t @-> uint16_t @-> (ptr uint32_t) @-> intptr_t @-> string @-> uint32_t @-> returning int32_t)
(* ReportType : HIDP_REPORT_TYPE -> int32_t *)
(* UsagePage : WORD -> uint16_t *)
(* LinkCollection : WORD optional -> uint16_t *)
(* Usage : WORD -> uint16_t *)
(* UsageValue : DWORD* out -> (ptr uint32_t) *)
(* PreparsedData : PHIDP_PREPARSED_DATA -> intptr_t *)
(* Report : LPSTR -> string *)
(* ReportLength : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library hid (t "HID.dll"))
(cffi:use-foreign-library hid)
(cffi:defcfun ("HidP_GetUsageValue" hid-p-get-usage-value :convention :stdcall) :int32
(report-type :int32) ; HIDP_REPORT_TYPE
(usage-page :uint16) ; WORD
(link-collection :uint16) ; WORD optional
(usage :uint16) ; WORD
(usage-value :pointer) ; DWORD* out
(preparsed-data :int64) ; PHIDP_PREPARSED_DATA
(report :string) ; LPSTR
(report-length :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HidP_GetUsageValue = Win32::API::More->new('HID',
'int HidP_GetUsageValue(int ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, LPVOID UsageValue, LPARAM PreparsedData, LPCSTR Report, DWORD ReportLength)');
# my $ret = $HidP_GetUsageValue->Call($ReportType, $UsagePage, $LinkCollection, $Usage, $UsageValue, $PreparsedData, $Report, $ReportLength);
# ReportType : HIDP_REPORT_TYPE -> int
# UsagePage : WORD -> WORD
# LinkCollection : WORD optional -> WORD
# Usage : WORD -> WORD
# UsageValue : DWORD* out -> LPVOID
# PreparsedData : PHIDP_PREPARSED_DATA -> LPARAM
# Report : LPSTR -> LPCSTR
# ReportLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型