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

JOYCAPSW

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

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

フィールド

フィールドサイズx64x86説明
wMidWORD2+0+0ジョイスティックのメーカーID(Manufacturer ID)。
wPidWORD2+2+2ジョイスティックの製品ID(Product ID)。
szPnameWCHAR64+4+4製品名のUnicode文字列。デバイスの表示名を示す。
wXminDWORD4+68+68X軸座標の最小値。
wXmaxDWORD4+72+72X軸座標の最大値。
wYminDWORD4+76+76Y軸座標の最小値。
wYmaxDWORD4+80+80Y軸座標の最大値。
wZminDWORD4+84+84Z軸座標の最小値。
wZmaxDWORD4+88+88Z軸座標の最大値。
wNumButtonsDWORD4+92+92ジョイスティックのボタン数。
wPeriodMinDWORD4+96+96joySetCaptureの最小ポーリング間隔。ミリ秒単位で示す。
wPeriodMaxDWORD4+100+100joySetCaptureの最大ポーリング間隔。ミリ秒単位で示す。
wRminDWORD4+104+104R軸(ラダー)座標の最小値。
wRmaxDWORD4+108+108R軸(ラダー)座標の最大値。
wUminDWORD4+112+112U軸(第5軸)座標の最小値。
wUmaxDWORD4+116+116U軸(第5軸)座標の最大値。
wVminDWORD4+120+120V軸(第6軸)座標の最小値。
wVmaxDWORD4+124+124V軸(第6軸)座標の最大値。
wCapsDWORD4+128+128ジョイスティックの機能を示す能力フラグ。POVや各軸の有無を示す。
wMaxAxesDWORD4+132+132デバイスがサポートする最大軸数。
wNumAxesDWORD4+136+136現在使用中の軸数。
wMaxButtonsDWORD4+140+140デバイスがサポートする最大ボタン数。
szRegKeyWCHAR64+144+144ドライバ設定のレジストリキー名のUnicode文字列。
szOEMVxDWCHAR520+208+208OEM VxDドライバ名のUnicode文字列。

各言語での定義

#include <windows.h>

// JOYCAPSW  (x64 728 / x86 728 バイト)
#pragma pack(push, 1)
typedef struct JOYCAPSW {
    WORD wMid;
    WORD wPid;
    WCHAR szPname[32];
    DWORD wXmin;
    DWORD wXmax;
    DWORD wYmin;
    DWORD wYmax;
    DWORD wZmin;
    DWORD wZmax;
    DWORD wNumButtons;
    DWORD wPeriodMin;
    DWORD wPeriodMax;
    DWORD wRmin;
    DWORD wRmax;
    DWORD wUmin;
    DWORD wUmax;
    DWORD wVmin;
    DWORD wVmax;
    DWORD wCaps;
    DWORD wMaxAxes;
    DWORD wNumAxes;
    DWORD wMaxButtons;
    WCHAR szRegKey[32];
    WCHAR szOEMVxD[260];
} JOYCAPSW;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct JOYCAPSW
{
    public ushort wMid;
    public ushort wPid;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string szPname;
    public uint wXmin;
    public uint wXmax;
    public uint wYmin;
    public uint wYmax;
    public uint wZmin;
    public uint wZmax;
    public uint wNumButtons;
    public uint wPeriodMin;
    public uint wPeriodMax;
    public uint wRmin;
    public uint wRmax;
    public uint wUmin;
    public uint wUmax;
    public uint wVmin;
    public uint wVmax;
    public uint wCaps;
    public uint wMaxAxes;
    public uint wNumAxes;
    public uint wMaxButtons;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string szRegKey;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szOEMVxD;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure JOYCAPSW
    Public wMid As UShort
    Public wPid As UShort
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public szPname As String
    Public wXmin As UInteger
    Public wXmax As UInteger
    Public wYmin As UInteger
    Public wYmax As UInteger
    Public wZmin As UInteger
    Public wZmax As UInteger
    Public wNumButtons As UInteger
    Public wPeriodMin As UInteger
    Public wPeriodMax As UInteger
    Public wRmin As UInteger
    Public wRmax As UInteger
    Public wUmin As UInteger
    Public wUmax As UInteger
    Public wVmin As UInteger
    Public wVmax As UInteger
    Public wCaps As UInteger
    Public wMaxAxes As UInteger
    Public wNumAxes As UInteger
    Public wMaxButtons As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public szRegKey As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szOEMVxD As String
End Structure
import ctypes
from ctypes import wintypes

class JOYCAPSW(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("wMid", ctypes.c_ushort),
        ("wPid", ctypes.c_ushort),
        ("szPname", ctypes.c_wchar * 32),
        ("wXmin", wintypes.DWORD),
        ("wXmax", wintypes.DWORD),
        ("wYmin", wintypes.DWORD),
        ("wYmax", wintypes.DWORD),
        ("wZmin", wintypes.DWORD),
        ("wZmax", wintypes.DWORD),
        ("wNumButtons", wintypes.DWORD),
        ("wPeriodMin", wintypes.DWORD),
        ("wPeriodMax", wintypes.DWORD),
        ("wRmin", wintypes.DWORD),
        ("wRmax", wintypes.DWORD),
        ("wUmin", wintypes.DWORD),
        ("wUmax", wintypes.DWORD),
        ("wVmin", wintypes.DWORD),
        ("wVmax", wintypes.DWORD),
        ("wCaps", wintypes.DWORD),
        ("wMaxAxes", wintypes.DWORD),
        ("wNumAxes", wintypes.DWORD),
        ("wMaxButtons", wintypes.DWORD),
        ("szRegKey", ctypes.c_wchar * 32),
        ("szOEMVxD", ctypes.c_wchar * 260),
    ]
#[repr(C, packed(1))]
pub struct JOYCAPSW {
    pub wMid: u16,
    pub wPid: u16,
    pub szPname: [u16; 32],
    pub wXmin: u32,
    pub wXmax: u32,
    pub wYmin: u32,
    pub wYmax: u32,
    pub wZmin: u32,
    pub wZmax: u32,
    pub wNumButtons: u32,
    pub wPeriodMin: u32,
    pub wPeriodMax: u32,
    pub wRmin: u32,
    pub wRmax: u32,
    pub wUmin: u32,
    pub wUmax: u32,
    pub wVmin: u32,
    pub wVmax: u32,
    pub wCaps: u32,
    pub wMaxAxes: u32,
    pub wNumAxes: u32,
    pub wMaxButtons: u32,
    pub szRegKey: [u16; 32],
    pub szOEMVxD: [u16; 260],
}
import "golang.org/x/sys/windows"

type JOYCAPSW struct {
	wMid uint16
	wPid uint16
	szPname [32]uint16
	wXmin uint32
	wXmax uint32
	wYmin uint32
	wYmax uint32
	wZmin uint32
	wZmax uint32
	wNumButtons uint32
	wPeriodMin uint32
	wPeriodMax uint32
	wRmin uint32
	wRmax uint32
	wUmin uint32
	wUmax uint32
	wVmin uint32
	wVmax uint32
	wCaps uint32
	wMaxAxes uint32
	wNumAxes uint32
	wMaxButtons uint32
	szRegKey [32]uint16
	szOEMVxD [260]uint16
}
type
  JOYCAPSW = packed record
    wMid: Word;
    wPid: Word;
    szPname: array[0..31] of WideChar;
    wXmin: DWORD;
    wXmax: DWORD;
    wYmin: DWORD;
    wYmax: DWORD;
    wZmin: DWORD;
    wZmax: DWORD;
    wNumButtons: DWORD;
    wPeriodMin: DWORD;
    wPeriodMax: DWORD;
    wRmin: DWORD;
    wRmax: DWORD;
    wUmin: DWORD;
    wUmax: DWORD;
    wVmin: DWORD;
    wVmax: DWORD;
    wCaps: DWORD;
    wMaxAxes: DWORD;
    wNumAxes: DWORD;
    wMaxButtons: DWORD;
    szRegKey: array[0..31] of WideChar;
    szOEMVxD: array[0..259] of WideChar;
  end;
const JOYCAPSW = extern struct {
    wMid: u16,
    wPid: u16,
    szPname: [32]u16,
    wXmin: u32,
    wXmax: u32,
    wYmin: u32,
    wYmax: u32,
    wZmin: u32,
    wZmax: u32,
    wNumButtons: u32,
    wPeriodMin: u32,
    wPeriodMax: u32,
    wRmin: u32,
    wRmax: u32,
    wUmin: u32,
    wUmax: u32,
    wVmin: u32,
    wVmax: u32,
    wCaps: u32,
    wMaxAxes: u32,
    wNumAxes: u32,
    wMaxButtons: u32,
    szRegKey: [32]u16,
    szOEMVxD: [260]u16,
};
type
  JOYCAPSW {.packed.} = object
    wMid: uint16
    wPid: uint16
    szPname: array[32, uint16]
    wXmin: uint32
    wXmax: uint32
    wYmin: uint32
    wYmax: uint32
    wZmin: uint32
    wZmax: uint32
    wNumButtons: uint32
    wPeriodMin: uint32
    wPeriodMax: uint32
    wRmin: uint32
    wRmax: uint32
    wUmin: uint32
    wUmax: uint32
    wVmin: uint32
    wVmax: uint32
    wCaps: uint32
    wMaxAxes: uint32
    wNumAxes: uint32
    wMaxButtons: uint32
    szRegKey: array[32, uint16]
    szOEMVxD: array[260, uint16]
align(1)
struct JOYCAPSW
{
    ushort wMid;
    ushort wPid;
    wchar[32] szPname;
    uint wXmin;
    uint wXmax;
    uint wYmin;
    uint wYmax;
    uint wZmin;
    uint wZmax;
    uint wNumButtons;
    uint wPeriodMin;
    uint wPeriodMax;
    uint wRmin;
    uint wRmax;
    uint wUmin;
    uint wUmax;
    uint wVmin;
    uint wVmax;
    uint wCaps;
    uint wMaxAxes;
    uint wNumAxes;
    uint wMaxButtons;
    wchar[32] szRegKey;
    wchar[260] szOEMVxD;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; JOYCAPSW サイズ: 728 バイト(x64)
dim st, 182    ; 4byte整数×182(構造体サイズ 728 / 4 切り上げ)
; wMid : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; wPid : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; szPname : WCHAR (+4, 64byte)  varptr(st)+4 を基点に操作(64byte:入れ子/配列)
; wXmin : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; wXmax : DWORD (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; wYmin : DWORD (+76, 4byte)  st.19 = 値  /  値 = st.19   (lpoke/lpeek も可)
; wYmax : DWORD (+80, 4byte)  st.20 = 値  /  値 = st.20   (lpoke/lpeek も可)
; wZmin : DWORD (+84, 4byte)  st.21 = 値  /  値 = st.21   (lpoke/lpeek も可)
; wZmax : DWORD (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; wNumButtons : DWORD (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; wPeriodMin : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; wPeriodMax : DWORD (+100, 4byte)  st.25 = 値  /  値 = st.25   (lpoke/lpeek も可)
; wRmin : DWORD (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; wRmax : DWORD (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; wUmin : DWORD (+112, 4byte)  st.28 = 値  /  値 = st.28   (lpoke/lpeek も可)
; wUmax : DWORD (+116, 4byte)  st.29 = 値  /  値 = st.29   (lpoke/lpeek も可)
; wVmin : DWORD (+120, 4byte)  st.30 = 値  /  値 = st.30   (lpoke/lpeek も可)
; wVmax : DWORD (+124, 4byte)  st.31 = 値  /  値 = st.31   (lpoke/lpeek も可)
; wCaps : DWORD (+128, 4byte)  st.32 = 値  /  値 = st.32   (lpoke/lpeek も可)
; wMaxAxes : DWORD (+132, 4byte)  st.33 = 値  /  値 = st.33   (lpoke/lpeek も可)
; wNumAxes : DWORD (+136, 4byte)  st.34 = 値  /  値 = st.34   (lpoke/lpeek も可)
; wMaxButtons : DWORD (+140, 4byte)  st.35 = 値  /  値 = st.35   (lpoke/lpeek も可)
; szRegKey : WCHAR (+144, 64byte)  varptr(st)+144 を基点に操作(64byte:入れ子/配列)
; szOEMVxD : WCHAR (+208, 520byte)  varptr(st)+208 を基点に操作(520byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global JOYCAPSW, pack=1
    #field short wMid
    #field short wPid
    #field wchar szPname 32
    #field int wXmin
    #field int wXmax
    #field int wYmin
    #field int wYmax
    #field int wZmin
    #field int wZmax
    #field int wNumButtons
    #field int wPeriodMin
    #field int wPeriodMax
    #field int wRmin
    #field int wRmax
    #field int wUmin
    #field int wUmax
    #field int wVmin
    #field int wVmax
    #field int wCaps
    #field int wMaxAxes
    #field int wNumAxes
    #field int wMaxButtons
    #field wchar szRegKey 32
    #field wchar szOEMVxD 260
#endstruct

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