ホーム › Devices.HumanInterfaceDevice › HidP_GetScaledUsageValue
HidP_GetScaledUsageValue
関数HIDレポートから指定した用途の物理単位の値を取得する。
シグネチャ
// HID.dll
#include <windows.h>
NTSTATUS HidP_GetScaledUsageValue(
HIDP_REPORT_TYPE ReportType,
WORD UsagePage,
WORD LinkCollection, // optional
WORD Usage,
INT* UsageValue,
PHIDP_PREPARSED_DATA PreparsedData,
LPSTR Report,
DWORD ReportLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ReportType | HIDP_REPORT_TYPE | in |
| UsagePage | WORD | in |
| LinkCollection | WORD | inoptional |
| Usage | WORD | in |
| UsageValue | INT* | out |
| PreparsedData | PHIDP_PREPARSED_DATA | in |
| Report | LPSTR | in |
| ReportLength | DWORD | in |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// HID.dll
#include <windows.h>
NTSTATUS HidP_GetScaledUsageValue(
HIDP_REPORT_TYPE ReportType,
WORD UsagePage,
WORD LinkCollection, // optional
WORD Usage,
INT* UsageValue,
PHIDP_PREPARSED_DATA PreparsedData,
LPSTR Report,
DWORD ReportLength
);[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_GetScaledUsageValue(
int ReportType, // HIDP_REPORT_TYPE
ushort UsagePage, // WORD
ushort LinkCollection, // WORD optional
ushort Usage, // WORD
out int UsageValue, // INT* out
IntPtr PreparsedData, // PHIDP_PREPARSED_DATA
[MarshalAs(UnmanagedType.LPStr)] string Report, // LPSTR
uint ReportLength // DWORD
);<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_GetScaledUsageValue(
ReportType As Integer, ' HIDP_REPORT_TYPE
UsagePage As UShort, ' WORD
LinkCollection As UShort, ' WORD optional
Usage As UShort, ' WORD
<Out> ByRef UsageValue As Integer, ' INT* 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 : INT* out
' PreparsedData : PHIDP_PREPARSED_DATA
' Report : LPSTR
' ReportLength : DWORD
Declare PtrSafe Function HidP_GetScaledUsageValue 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_GetScaledUsageValue = ctypes.windll.hid.HidP_GetScaledUsageValue
HidP_GetScaledUsageValue.restype = ctypes.c_int
HidP_GetScaledUsageValue.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(ctypes.c_int), # UsageValue : INT* 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_GetScaledUsageValue = Fiddle::Function.new(
lib['HidP_GetScaledUsageValue'],
[
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 : INT* 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_GetScaledUsageValue(
ReportType: i32, // HIDP_REPORT_TYPE
UsagePage: u16, // WORD
LinkCollection: u16, // WORD optional
Usage: u16, // WORD
UsageValue: *mut i32, // INT* 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_GetScaledUsageValue(int ReportType, ushort UsagePage, ushort LinkCollection, ushort Usage, out int UsageValue, IntPtr PreparsedData, [MarshalAs(UnmanagedType.LPStr)] string Report, uint ReportLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_GetScaledUsageValue' -Namespace Win32 -PassThru
# $api::HidP_GetScaledUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)#uselib "HID.dll"
#func global HidP_GetScaledUsageValue "HidP_GetScaledUsageValue" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; HidP_GetScaledUsageValue 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 : INT* out -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; Report : LPSTR -> "sptr"
; ReportLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "HID.dll" #cfunc global HidP_GetScaledUsageValue "HidP_GetScaledUsageValue" int, int, int, int, var, sptr, str, int ; res = HidP_GetScaledUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD -> "int" ; UsageValue : INT* out -> "var" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "HID.dll" #cfunc global HidP_GetScaledUsageValue "HidP_GetScaledUsageValue" int, int, int, int, sptr, sptr, str, int ; res = HidP_GetScaledUsageValue(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 : INT* out -> "sptr" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, INT* UsageValue, PHIDP_PREPARSED_DATA PreparsedData, LPSTR Report, DWORD ReportLength) #uselib "HID.dll" #cfunc global HidP_GetScaledUsageValue "HidP_GetScaledUsageValue" int, int, int, int, var, intptr, str, int ; res = HidP_GetScaledUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength) ; ReportType : HIDP_REPORT_TYPE -> "int" ; UsagePage : WORD -> "int" ; LinkCollection : WORD optional -> "int" ; Usage : WORD -> "int" ; UsageValue : INT* out -> "var" ; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr" ; Report : LPSTR -> "str" ; ReportLength : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, WORD UsagePage, WORD LinkCollection, WORD Usage, INT* UsageValue, PHIDP_PREPARSED_DATA PreparsedData, LPSTR Report, DWORD ReportLength) #uselib "HID.dll" #cfunc global HidP_GetScaledUsageValue "HidP_GetScaledUsageValue" int, int, int, int, intptr, intptr, str, int ; res = HidP_GetScaledUsageValue(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 : INT* 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_GetScaledUsageValue = hid.NewProc("HidP_GetScaledUsageValue")
)
// ReportType (HIDP_REPORT_TYPE), UsagePage (WORD), LinkCollection (WORD optional), Usage (WORD), UsageValue (INT* out), PreparsedData (PHIDP_PREPARSED_DATA), Report (LPSTR), ReportLength (DWORD)
r1, _, err := procHidP_GetScaledUsageValue.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_GetScaledUsageValue(
ReportType: Integer; // HIDP_REPORT_TYPE
UsagePage: Word; // WORD
LinkCollection: Word; // WORD optional
Usage: Word; // WORD
UsageValue: Pointer; // INT* out
PreparsedData: NativeInt; // PHIDP_PREPARSED_DATA
Report: PAnsiChar; // LPSTR
ReportLength: DWORD // DWORD
): Integer; stdcall;
external 'HID.dll' name 'HidP_GetScaledUsageValue';result := DllCall("HID\HidP_GetScaledUsageValue"
, "Int", ReportType ; HIDP_REPORT_TYPE
, "UShort", UsagePage ; WORD
, "UShort", LinkCollection ; WORD optional
, "UShort", Usage ; WORD
, "Ptr", UsageValue ; INT* out
, "Ptr", PreparsedData ; PHIDP_PREPARSED_DATA
, "AStr", Report ; LPSTR
, "UInt", ReportLength ; DWORD
, "Int") ; return: NTSTATUS●HidP_GetScaledUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength) = DLL("HID.dll", "int HidP_GetScaledUsageValue(int, int, int, int, void*, int, char*, dword)")
# 呼び出し: HidP_GetScaledUsageValue(ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength)
# ReportType : HIDP_REPORT_TYPE -> "int"
# UsagePage : WORD -> "int"
# LinkCollection : WORD optional -> "int"
# Usage : WORD -> "int"
# UsageValue : INT* out -> "void*"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# Report : LPSTR -> "char*"
# ReportLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。