Win32 API 日本語リファレンス
ホームUI.Input.Pointer › GetRawPointerDeviceData

GetRawPointerDeviceData

関数
ポインターデバイスから生の入力データ履歴を取得する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

BOOL GetRawPointerDeviceData(
    DWORD pointerId,
    DWORD historyCount,
    DWORD propertiesCount,
    POINTER_DEVICE_PROPERTY* pProperties,
    INT* pValues
);

パラメーター

名前方向説明
pointerIdDWORDin生データを取得する対象ポインタのIDを指定する。
historyCountDWORDin取得する履歴エントリ数を指定する。
propertiesCountDWORDinpPropertiesに含まれるプロパティ数を指定する。
pPropertiesPOINTER_DEVICE_PROPERTY*in取得対象のHIDプロパティを示すPOINTER_DEVICE_PROPERTY配列へのポインタ。
pValuesINT*out各プロパティの生の値を受け取るINT配列へのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetRawPointerDeviceData(
    DWORD pointerId,
    DWORD historyCount,
    DWORD propertiesCount,
    POINTER_DEVICE_PROPERTY* pProperties,
    INT* pValues
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetRawPointerDeviceData(
    uint pointerId,   // DWORD
    uint historyCount,   // DWORD
    uint propertiesCount,   // DWORD
    IntPtr pProperties,   // POINTER_DEVICE_PROPERTY*
    out int pValues   // INT* out
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetRawPointerDeviceData(
    pointerId As UInteger,   ' DWORD
    historyCount As UInteger,   ' DWORD
    propertiesCount As UInteger,   ' DWORD
    pProperties As IntPtr,   ' POINTER_DEVICE_PROPERTY*
    <Out> ByRef pValues As Integer   ' INT* out
) As Boolean
End Function
' pointerId : DWORD
' historyCount : DWORD
' propertiesCount : DWORD
' pProperties : POINTER_DEVICE_PROPERTY*
' pValues : INT* out
Declare PtrSafe Function GetRawPointerDeviceData Lib "user32" ( _
    ByVal pointerId As Long, _
    ByVal historyCount As Long, _
    ByVal propertiesCount As Long, _
    ByVal pProperties As LongPtr, _
    ByRef pValues As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetRawPointerDeviceData = ctypes.windll.user32.GetRawPointerDeviceData
GetRawPointerDeviceData.restype = wintypes.BOOL
GetRawPointerDeviceData.argtypes = [
    wintypes.DWORD,  # pointerId : DWORD
    wintypes.DWORD,  # historyCount : DWORD
    wintypes.DWORD,  # propertiesCount : DWORD
    ctypes.c_void_p,  # pProperties : POINTER_DEVICE_PROPERTY*
    ctypes.POINTER(ctypes.c_int),  # pValues : INT* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GetRawPointerDeviceData = Fiddle::Function.new(
  lib['GetRawPointerDeviceData'],
  [
    -Fiddle::TYPE_INT,  # pointerId : DWORD
    -Fiddle::TYPE_INT,  # historyCount : DWORD
    -Fiddle::TYPE_INT,  # propertiesCount : DWORD
    Fiddle::TYPE_VOIDP,  # pProperties : POINTER_DEVICE_PROPERTY*
    Fiddle::TYPE_VOIDP,  # pValues : INT* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetRawPointerDeviceData(
        pointerId: u32,  // DWORD
        historyCount: u32,  // DWORD
        propertiesCount: u32,  // DWORD
        pProperties: *mut POINTER_DEVICE_PROPERTY,  // POINTER_DEVICE_PROPERTY*
        pValues: *mut i32  // INT* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool GetRawPointerDeviceData(uint pointerId, uint historyCount, uint propertiesCount, IntPtr pProperties, out int pValues);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetRawPointerDeviceData' -Namespace Win32 -PassThru
# $api::GetRawPointerDeviceData(pointerId, historyCount, propertiesCount, pProperties, pValues)
#uselib "USER32.dll"
#func global GetRawPointerDeviceData "GetRawPointerDeviceData" sptr, sptr, sptr, sptr, sptr
; GetRawPointerDeviceData pointerId, historyCount, propertiesCount, varptr(pProperties), varptr(pValues)   ; 戻り値は stat
; pointerId : DWORD -> "sptr"
; historyCount : DWORD -> "sptr"
; propertiesCount : DWORD -> "sptr"
; pProperties : POINTER_DEVICE_PROPERTY* -> "sptr"
; pValues : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global GetRawPointerDeviceData "GetRawPointerDeviceData" int, int, int, var, var
; res = GetRawPointerDeviceData(pointerId, historyCount, propertiesCount, pProperties, pValues)
; pointerId : DWORD -> "int"
; historyCount : DWORD -> "int"
; propertiesCount : DWORD -> "int"
; pProperties : POINTER_DEVICE_PROPERTY* -> "var"
; pValues : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetRawPointerDeviceData(DWORD pointerId, DWORD historyCount, DWORD propertiesCount, POINTER_DEVICE_PROPERTY* pProperties, INT* pValues)
#uselib "USER32.dll"
#cfunc global GetRawPointerDeviceData "GetRawPointerDeviceData" int, int, int, var, var
; res = GetRawPointerDeviceData(pointerId, historyCount, propertiesCount, pProperties, pValues)
; pointerId : DWORD -> "int"
; historyCount : DWORD -> "int"
; propertiesCount : DWORD -> "int"
; pProperties : POINTER_DEVICE_PROPERTY* -> "var"
; pValues : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetRawPointerDeviceData = user32.NewProc("GetRawPointerDeviceData")
)

// pointerId (DWORD), historyCount (DWORD), propertiesCount (DWORD), pProperties (POINTER_DEVICE_PROPERTY*), pValues (INT* out)
r1, _, err := procGetRawPointerDeviceData.Call(
	uintptr(pointerId),
	uintptr(historyCount),
	uintptr(propertiesCount),
	uintptr(pProperties),
	uintptr(pValues),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetRawPointerDeviceData(
  pointerId: DWORD;   // DWORD
  historyCount: DWORD;   // DWORD
  propertiesCount: DWORD;   // DWORD
  pProperties: Pointer;   // POINTER_DEVICE_PROPERTY*
  pValues: Pointer   // INT* out
): BOOL; stdcall;
  external 'USER32.dll' name 'GetRawPointerDeviceData';
result := DllCall("USER32\GetRawPointerDeviceData"
    , "UInt", pointerId   ; DWORD
    , "UInt", historyCount   ; DWORD
    , "UInt", propertiesCount   ; DWORD
    , "Ptr", pProperties   ; POINTER_DEVICE_PROPERTY*
    , "Ptr", pValues   ; INT* out
    , "Int")   ; return: BOOL
●GetRawPointerDeviceData(pointerId, historyCount, propertiesCount, pProperties, pValues) = DLL("USER32.dll", "bool GetRawPointerDeviceData(dword, dword, dword, void*, void*)")
# 呼び出し: GetRawPointerDeviceData(pointerId, historyCount, propertiesCount, pProperties, pValues)
# pointerId : DWORD -> "dword"
# historyCount : DWORD -> "dword"
# propertiesCount : DWORD -> "dword"
# pProperties : POINTER_DEVICE_PROPERTY* -> "void*"
# pValues : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。