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

GameInputMouseState

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

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

フィールド

フィールドサイズx64x86説明
buttonsGameInputMouseButtons4+0+0押下中のマウスボタンを示すフラグである。
positionXLONGLONG8+8+8マウスのX軸累積移動量である。
positionYLONGLONG8+16+16マウスのY軸累積移動量である。
wheelXLONGLONG8+24+24水平ホイールの累積回転量である。
wheelYLONGLONG8+32+32垂直ホイールの累積回転量である。

各言語での定義

#include <windows.h>

// GameInputMouseState  (x64 40 / x86 40 バイト)
typedef struct GameInputMouseState {
    GameInputMouseButtons buttons;
    LONGLONG positionX;
    LONGLONG positionY;
    LONGLONG wheelX;
    LONGLONG wheelY;
} GameInputMouseState;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GameInputMouseState
{
    public int buttons;
    public long positionX;
    public long positionY;
    public long wheelX;
    public long wheelY;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GameInputMouseState
    Public buttons As Integer
    Public positionX As Long
    Public positionY As Long
    Public wheelX As Long
    Public wheelY As Long
End Structure
import ctypes
from ctypes import wintypes

class GameInputMouseState(ctypes.Structure):
    _fields_ = [
        ("buttons", ctypes.c_int),
        ("positionX", ctypes.c_longlong),
        ("positionY", ctypes.c_longlong),
        ("wheelX", ctypes.c_longlong),
        ("wheelY", ctypes.c_longlong),
    ]
#[repr(C)]
pub struct GameInputMouseState {
    pub buttons: i32,
    pub positionX: i64,
    pub positionY: i64,
    pub wheelX: i64,
    pub wheelY: i64,
}
import "golang.org/x/sys/windows"

type GameInputMouseState struct {
	buttons int32
	positionX int64
	positionY int64
	wheelX int64
	wheelY int64
}
type
  GameInputMouseState = record
    buttons: Integer;
    positionX: Int64;
    positionY: Int64;
    wheelX: Int64;
    wheelY: Int64;
  end;
const GameInputMouseState = extern struct {
    buttons: i32,
    positionX: i64,
    positionY: i64,
    wheelX: i64,
    wheelY: i64,
};
type
  GameInputMouseState {.bycopy.} = object
    buttons: int32
    positionX: int64
    positionY: int64
    wheelX: int64
    wheelY: int64
struct GameInputMouseState
{
    int buttons;
    long positionX;
    long positionY;
    long wheelX;
    long wheelY;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; GameInputMouseState サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; buttons : GameInputMouseButtons (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; positionX : LONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; positionY : LONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; wheelX : LONGLONG (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; wheelY : LONGLONG (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global GameInputMouseState
    #field int buttons
    #field int64 positionX
    #field int64 positionY
    #field int64 wheelX
    #field int64 wheelY
#endstruct

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