Win32 API 日本語リファレンス
ホームDevices.HumanInterfaceDevice › HIDP_BUTTON_ARRAY_DATA

HIDP_BUTTON_ARRAY_DATA

構造体
サイズx64: 4 バイト / x86: 4 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
ArrayIndexWORD2+0+0ボタン配列内のインデックス値。
OnBOOLEAN1+2+2対応するボタンが押下状態かを示す真偽値。

各言語での定義

#include <windows.h>

// HIDP_BUTTON_ARRAY_DATA  (x64 4 / x86 4 バイト)
typedef struct HIDP_BUTTON_ARRAY_DATA {
    WORD ArrayIndex;
    BOOLEAN On;
} HIDP_BUTTON_ARRAY_DATA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HIDP_BUTTON_ARRAY_DATA
{
    public ushort ArrayIndex;
    [MarshalAs(UnmanagedType.U1)] public bool On;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure HIDP_BUTTON_ARRAY_DATA
    Public ArrayIndex As UShort
    <MarshalAs(UnmanagedType.U1)> Public On As Boolean
End Structure
import ctypes
from ctypes import wintypes

class HIDP_BUTTON_ARRAY_DATA(ctypes.Structure):
    _fields_ = [
        ("ArrayIndex", ctypes.c_ushort),
        ("On", ctypes.c_byte),
    ]
#[repr(C)]
pub struct HIDP_BUTTON_ARRAY_DATA {
    pub ArrayIndex: u16,
    pub On: u8,
}
import "golang.org/x/sys/windows"

type HIDP_BUTTON_ARRAY_DATA struct {
	ArrayIndex uint16
	On byte
}
type
  HIDP_BUTTON_ARRAY_DATA = record
    ArrayIndex: Word;
    On: ByteBool;
  end;
const HIDP_BUTTON_ARRAY_DATA = extern struct {
    ArrayIndex: u16,
    On: u8,
};
type
  HIDP_BUTTON_ARRAY_DATA {.bycopy.} = object
    ArrayIndex: uint16
    On: uint8
struct HIDP_BUTTON_ARRAY_DATA
{
    ushort ArrayIndex;
    ubyte On;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HIDP_BUTTON_ARRAY_DATA サイズ: 4 バイト(x64)
dim st, 1    ; 4byte整数×1(構造体サイズ 4 / 4 切り上げ)
; ArrayIndex : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; On : BOOLEAN (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global HIDP_BUTTON_ARRAY_DATA
    #field short ArrayIndex
    #field bool1 On
#endstruct

stdim st, HIDP_BUTTON_ARRAY_DATA        ; NSTRUCT 変数を確保
st->ArrayIndex = 100
mes "ArrayIndex=" + st->ArrayIndex