ホーム › Devices.HumanInterfaceDevice › DIMOUSESTATE2
DIMOUSESTATE2
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| lX | INT | 4 | +0 | +0 | X軸の相対移動量。 |
| lY | INT | 4 | +4 | +4 | Y軸の相対移動量。 |
| lZ | INT | 4 | +8 | +8 | Z軸(ホイール)の相対移動量。 |
| rgbButtons | BYTE | 8 | +12 | +12 | 最大8個のマウスボタン状態を示すバイト配列。最上位ビットで押下を表す。 |
各言語での定義
#include <windows.h>
// DIMOUSESTATE2 (x64 20 / x86 20 バイト)
typedef struct DIMOUSESTATE2 {
INT lX;
INT lY;
INT lZ;
BYTE rgbButtons[8];
} DIMOUSESTATE2;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DIMOUSESTATE2
{
public int lX;
public int lY;
public int lZ;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] rgbButtons;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DIMOUSESTATE2
Public lX As Integer
Public lY As Integer
Public lZ As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public rgbButtons() As Byte
End Structureimport ctypes
from ctypes import wintypes
class DIMOUSESTATE2(ctypes.Structure):
_fields_ = [
("lX", ctypes.c_int),
("lY", ctypes.c_int),
("lZ", ctypes.c_int),
("rgbButtons", ctypes.c_ubyte * 8),
]#[repr(C)]
pub struct DIMOUSESTATE2 {
pub lX: i32,
pub lY: i32,
pub lZ: i32,
pub rgbButtons: [u8; 8],
}import "golang.org/x/sys/windows"
type DIMOUSESTATE2 struct {
lX int32
lY int32
lZ int32
rgbButtons [8]byte
}type
DIMOUSESTATE2 = record
lX: Integer;
lY: Integer;
lZ: Integer;
rgbButtons: array[0..7] of Byte;
end;const DIMOUSESTATE2 = extern struct {
lX: i32,
lY: i32,
lZ: i32,
rgbButtons: [8]u8,
};type
DIMOUSESTATE2 {.bycopy.} = object
lX: int32
lY: int32
lZ: int32
rgbButtons: array[8, uint8]struct DIMOUSESTATE2
{
int lX;
int lY;
int lZ;
ubyte[8] rgbButtons;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DIMOUSESTATE2 サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; lX : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lY : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; lZ : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; rgbButtons : BYTE (+12, 8byte) varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DIMOUSESTATE2
#field int lX
#field int lY
#field int lZ
#field byte rgbButtons 8
#endstruct
stdim st, DIMOUSESTATE2 ; NSTRUCT 変数を確保
st->lX = 100
mes "lX=" + st->lX