ホーム › Devices.HumanInterfaceDevice › DIDEVICEOBJECTINSTANCEW
DIDEVICEOBJECTINSTANCEW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwSize | DWORD | 4 | +0 | +0 | この構造体のバイトサイズ。 |
| guidType | GUID | 16 | +4 | +4 | オブジェクト種別を示すGUID(X軸/ボタン等)。 |
| dwOfs | DWORD | 4 | +20 | +20 | データ形式内でのこのオブジェクトのバイトオフセット。 |
| dwType | DWORD | 4 | +24 | +24 | オブジェクトの種別とインスタンス番号を符号化した値。 |
| dwFlags | DWORD | 4 | +28 | +28 | オブジェクトの属性を示すフラグ(DIDOI_*)。 |
| tszName | WCHAR | 520 | +32 | +32 | オブジェクトの名前を示すワイド文字列。 |
| dwFFMaxForce | DWORD | 4 | +552 | +552 | このオブジェクトで出力可能な最大フォース。 |
| dwFFForceResolution | DWORD | 4 | +556 | +556 | フォース出力の分解能(ステップ数)。 |
| wCollectionNumber | WORD | 2 | +560 | +560 | HIDコレクション番号。 |
| wDesignatorIndex | WORD | 2 | +562 | +562 | HIDデジグネーター(物理位置)インデックス。 |
| wUsagePage | WORD | 2 | +564 | +564 | HIDのUsage Page値。 |
| wUsage | WORD | 2 | +566 | +566 | HIDのUsage値。 |
| dwDimension | DWORD | 4 | +568 | +568 | 物理量の次元を示す値。 |
| wExponent | WORD | 2 | +572 | +572 | 物理量の指数(スケール)を示す値。 |
| wReportId | WORD | 2 | +574 | +574 | オブジェクトが属するHIDレポートID。 |
各言語での定義
#include <windows.h>
// DIDEVICEOBJECTINSTANCEW (x64 576 / x86 576 バイト)
typedef struct DIDEVICEOBJECTINSTANCEW {
DWORD dwSize;
GUID guidType;
DWORD dwOfs;
DWORD dwType;
DWORD dwFlags;
WCHAR tszName[260];
DWORD dwFFMaxForce;
DWORD dwFFForceResolution;
WORD wCollectionNumber;
WORD wDesignatorIndex;
WORD wUsagePage;
WORD wUsage;
DWORD dwDimension;
WORD wExponent;
WORD wReportId;
} DIDEVICEOBJECTINSTANCEW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DIDEVICEOBJECTINSTANCEW
{
public uint dwSize;
public Guid guidType;
public uint dwOfs;
public uint dwType;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string tszName;
public uint dwFFMaxForce;
public uint dwFFForceResolution;
public ushort wCollectionNumber;
public ushort wDesignatorIndex;
public ushort wUsagePage;
public ushort wUsage;
public uint dwDimension;
public ushort wExponent;
public ushort wReportId;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DIDEVICEOBJECTINSTANCEW
Public dwSize As UInteger
Public guidType As Guid
Public dwOfs As UInteger
Public dwType As UInteger
Public dwFlags As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public tszName As String
Public dwFFMaxForce As UInteger
Public dwFFForceResolution As UInteger
Public wCollectionNumber As UShort
Public wDesignatorIndex As UShort
Public wUsagePage As UShort
Public wUsage As UShort
Public dwDimension As UInteger
Public wExponent As UShort
Public wReportId As UShort
End Structureimport ctypes
from ctypes import wintypes
class DIDEVICEOBJECTINSTANCEW(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),
("guidType", GUID),
("dwOfs", wintypes.DWORD),
("dwType", wintypes.DWORD),
("dwFlags", wintypes.DWORD),
("tszName", ctypes.c_wchar * 260),
("dwFFMaxForce", wintypes.DWORD),
("dwFFForceResolution", wintypes.DWORD),
("wCollectionNumber", ctypes.c_ushort),
("wDesignatorIndex", ctypes.c_ushort),
("wUsagePage", ctypes.c_ushort),
("wUsage", ctypes.c_ushort),
("dwDimension", wintypes.DWORD),
("wExponent", ctypes.c_ushort),
("wReportId", ctypes.c_ushort),
]#[repr(C)]
pub struct DIDEVICEOBJECTINSTANCEW {
pub dwSize: u32,
pub guidType: GUID,
pub dwOfs: u32,
pub dwType: u32,
pub dwFlags: u32,
pub tszName: [u16; 260],
pub dwFFMaxForce: u32,
pub dwFFForceResolution: u32,
pub wCollectionNumber: u16,
pub wDesignatorIndex: u16,
pub wUsagePage: u16,
pub wUsage: u16,
pub dwDimension: u32,
pub wExponent: u16,
pub wReportId: u16,
}import "golang.org/x/sys/windows"
type DIDEVICEOBJECTINSTANCEW struct {
dwSize uint32
guidType windows.GUID
dwOfs uint32
dwType uint32
dwFlags uint32
tszName [260]uint16
dwFFMaxForce uint32
dwFFForceResolution uint32
wCollectionNumber uint16
wDesignatorIndex uint16
wUsagePage uint16
wUsage uint16
dwDimension uint32
wExponent uint16
wReportId uint16
}type
DIDEVICEOBJECTINSTANCEW = record
dwSize: DWORD;
guidType: TGUID;
dwOfs: DWORD;
dwType: DWORD;
dwFlags: DWORD;
tszName: array[0..259] of WideChar;
dwFFMaxForce: DWORD;
dwFFForceResolution: DWORD;
wCollectionNumber: Word;
wDesignatorIndex: Word;
wUsagePage: Word;
wUsage: Word;
dwDimension: DWORD;
wExponent: Word;
wReportId: Word;
end;const DIDEVICEOBJECTINSTANCEW = extern struct {
dwSize: u32,
guidType: GUID,
dwOfs: u32,
dwType: u32,
dwFlags: u32,
tszName: [260]u16,
dwFFMaxForce: u32,
dwFFForceResolution: u32,
wCollectionNumber: u16,
wDesignatorIndex: u16,
wUsagePage: u16,
wUsage: u16,
dwDimension: u32,
wExponent: u16,
wReportId: u16,
};type
DIDEVICEOBJECTINSTANCEW {.bycopy.} = object
dwSize: uint32
guidType: GUID
dwOfs: uint32
dwType: uint32
dwFlags: uint32
tszName: array[260, uint16]
dwFFMaxForce: uint32
dwFFForceResolution: uint32
wCollectionNumber: uint16
wDesignatorIndex: uint16
wUsagePage: uint16
wUsage: uint16
dwDimension: uint32
wExponent: uint16
wReportId: uint16struct DIDEVICEOBJECTINSTANCEW
{
uint dwSize;
GUID guidType;
uint dwOfs;
uint dwType;
uint dwFlags;
wchar[260] tszName;
uint dwFFMaxForce;
uint dwFFForceResolution;
ushort wCollectionNumber;
ushort wDesignatorIndex;
ushort wUsagePage;
ushort wUsage;
uint dwDimension;
ushort wExponent;
ushort wReportId;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DIDEVICEOBJECTINSTANCEW サイズ: 576 バイト(x64)
dim st, 144 ; 4byte整数×144(構造体サイズ 576 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; guidType : GUID (+4, 16byte) varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; dwOfs : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwType : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; dwFlags : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; tszName : WCHAR (+32, 520byte) varptr(st)+32 を基点に操作(520byte:入れ子/配列)
; dwFFMaxForce : DWORD (+552, 4byte) st.138 = 値 / 値 = st.138 (lpoke/lpeek も可)
; dwFFForceResolution : DWORD (+556, 4byte) st.139 = 値 / 値 = st.139 (lpoke/lpeek も可)
; wCollectionNumber : WORD (+560, 2byte) wpoke st,560,値 / 値 = wpeek(st,560)
; wDesignatorIndex : WORD (+562, 2byte) wpoke st,562,値 / 値 = wpeek(st,562)
; wUsagePage : WORD (+564, 2byte) wpoke st,564,値 / 値 = wpeek(st,564)
; wUsage : WORD (+566, 2byte) wpoke st,566,値 / 値 = wpeek(st,566)
; dwDimension : DWORD (+568, 4byte) st.142 = 値 / 値 = st.142 (lpoke/lpeek も可)
; wExponent : WORD (+572, 2byte) wpoke st,572,値 / 値 = wpeek(st,572)
; wReportId : WORD (+574, 2byte) wpoke st,574,値 / 値 = wpeek(st,574)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global DIDEVICEOBJECTINSTANCEW
#field int dwSize
#field GUID guidType
#field int dwOfs
#field int dwType
#field int dwFlags
#field wchar tszName 260
#field int dwFFMaxForce
#field int dwFFForceResolution
#field short wCollectionNumber
#field short wDesignatorIndex
#field short wUsagePage
#field short wUsage
#field int dwDimension
#field short wExponent
#field short wReportId
#endstruct
stdim st, DIDEVICEOBJECTINSTANCEW ; NSTRUCT 変数を確保
st->dwSize = 100
mes "dwSize=" + st->dwSize