Win32 API 日本語リファレンス
ホームMedia.Multimedia › JOYINFO

JOYINFO

構造体
サイズx64: 16 バイト / x86: 16 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
wXposDWORD4+0+0X軸の現在位置。
wYposDWORD4+4+4Y軸の現在位置。
wZposDWORD4+8+8Z軸の現在位置。
wButtonsDWORD4+12+12押下中のボタンを示すビットフラグ。JOY_BUTTON1〜4の組み合わせ。

各言語での定義

#include <windows.h>

// JOYINFO  (x64 16 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct JOYINFO {
    DWORD wXpos;
    DWORD wYpos;
    DWORD wZpos;
    DWORD wButtons;
} JOYINFO;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct JOYINFO
{
    public uint wXpos;
    public uint wYpos;
    public uint wZpos;
    public uint wButtons;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure JOYINFO
    Public wXpos As UInteger
    Public wYpos As UInteger
    Public wZpos As UInteger
    Public wButtons As UInteger
End Structure
import ctypes
from ctypes import wintypes

class JOYINFO(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("wXpos", wintypes.DWORD),
        ("wYpos", wintypes.DWORD),
        ("wZpos", wintypes.DWORD),
        ("wButtons", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct JOYINFO {
    pub wXpos: u32,
    pub wYpos: u32,
    pub wZpos: u32,
    pub wButtons: u32,
}
import "golang.org/x/sys/windows"

type JOYINFO struct {
	wXpos uint32
	wYpos uint32
	wZpos uint32
	wButtons uint32
}
type
  JOYINFO = packed record
    wXpos: DWORD;
    wYpos: DWORD;
    wZpos: DWORD;
    wButtons: DWORD;
  end;
const JOYINFO = extern struct {
    wXpos: u32,
    wYpos: u32,
    wZpos: u32,
    wButtons: u32,
};
type
  JOYINFO {.packed.} = object
    wXpos: uint32
    wYpos: uint32
    wZpos: uint32
    wButtons: uint32
align(1)
struct JOYINFO
{
    uint wXpos;
    uint wYpos;
    uint wZpos;
    uint wButtons;
}

HSP用 定義

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

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

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