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

DIJOYUSERVALUES

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

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

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0この構造体のバイトサイズ。
ruvJOYREGUSERVALUES100+4+4ユーザー定義のレジストリ値(JOYREGUSERVALUES)。
wszGlobalDriverWCHAR512+104+104グローバルドライバー名を示すワイド文字列。
wszGameportEmulatorWCHAR512+616+616ゲームポートエミュレーター名を示すワイド文字列。

各言語での定義

#include <windows.h>

// JOYPOS  (x64 24 / x86 24 バイト)
typedef struct JOYPOS {
    DWORD dwX;
    DWORD dwY;
    DWORD dwZ;
    DWORD dwR;
    DWORD dwU;
    DWORD dwV;
} JOYPOS;

// JOYRANGE  (x64 72 / x86 72 バイト)
typedef struct JOYRANGE {
    JOYPOS jpMin;
    JOYPOS jpMax;
    JOYPOS jpCenter;
} JOYRANGE;

// JOYREGUSERVALUES  (x64 100 / x86 100 バイト)
typedef struct JOYREGUSERVALUES {
    DWORD dwTimeOut;
    JOYRANGE jrvRanges;
    JOYPOS jpDeadZone;
} JOYREGUSERVALUES;

// DIJOYUSERVALUES  (x64 1128 / x86 1128 バイト)
typedef struct DIJOYUSERVALUES {
    DWORD dwSize;
    JOYREGUSERVALUES ruv;
    WCHAR wszGlobalDriver[256];
    WCHAR wszGameportEmulator[256];
} DIJOYUSERVALUES;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct JOYPOS
{
    public uint dwX;
    public uint dwY;
    public uint dwZ;
    public uint dwR;
    public uint dwU;
    public uint dwV;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct JOYRANGE
{
    public JOYPOS jpMin;
    public JOYPOS jpMax;
    public JOYPOS jpCenter;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct JOYREGUSERVALUES
{
    public uint dwTimeOut;
    public JOYRANGE jrvRanges;
    public JOYPOS jpDeadZone;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DIJOYUSERVALUES
{
    public uint dwSize;
    public JOYREGUSERVALUES ruv;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string wszGlobalDriver;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string wszGameportEmulator;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure JOYPOS
    Public dwX As UInteger
    Public dwY As UInteger
    Public dwZ As UInteger
    Public dwR As UInteger
    Public dwU As UInteger
    Public dwV As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure JOYRANGE
    Public jpMin As JOYPOS
    Public jpMax As JOYPOS
    Public jpCenter As JOYPOS
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure JOYREGUSERVALUES
    Public dwTimeOut As UInteger
    Public jrvRanges As JOYRANGE
    Public jpDeadZone As JOYPOS
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DIJOYUSERVALUES
    Public dwSize As UInteger
    Public ruv As JOYREGUSERVALUES
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public wszGlobalDriver As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public wszGameportEmulator As String
End Structure
import ctypes
from ctypes import wintypes

class JOYPOS(ctypes.Structure):
    _fields_ = [
        ("dwX", wintypes.DWORD),
        ("dwY", wintypes.DWORD),
        ("dwZ", wintypes.DWORD),
        ("dwR", wintypes.DWORD),
        ("dwU", wintypes.DWORD),
        ("dwV", wintypes.DWORD),
    ]

class JOYRANGE(ctypes.Structure):
    _fields_ = [
        ("jpMin", JOYPOS),
        ("jpMax", JOYPOS),
        ("jpCenter", JOYPOS),
    ]

class JOYREGUSERVALUES(ctypes.Structure):
    _fields_ = [
        ("dwTimeOut", wintypes.DWORD),
        ("jrvRanges", JOYRANGE),
        ("jpDeadZone", JOYPOS),
    ]

class DIJOYUSERVALUES(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("ruv", JOYREGUSERVALUES),
        ("wszGlobalDriver", ctypes.c_wchar * 256),
        ("wszGameportEmulator", ctypes.c_wchar * 256),
    ]
#[repr(C)]
pub struct JOYPOS {
    pub dwX: u32,
    pub dwY: u32,
    pub dwZ: u32,
    pub dwR: u32,
    pub dwU: u32,
    pub dwV: u32,
}

#[repr(C)]
pub struct JOYRANGE {
    pub jpMin: JOYPOS,
    pub jpMax: JOYPOS,
    pub jpCenter: JOYPOS,
}

#[repr(C)]
pub struct JOYREGUSERVALUES {
    pub dwTimeOut: u32,
    pub jrvRanges: JOYRANGE,
    pub jpDeadZone: JOYPOS,
}

#[repr(C)]
pub struct DIJOYUSERVALUES {
    pub dwSize: u32,
    pub ruv: JOYREGUSERVALUES,
    pub wszGlobalDriver: [u16; 256],
    pub wszGameportEmulator: [u16; 256],
}
import "golang.org/x/sys/windows"

type JOYPOS struct {
	dwX uint32
	dwY uint32
	dwZ uint32
	dwR uint32
	dwU uint32
	dwV uint32
}

type JOYRANGE struct {
	jpMin JOYPOS
	jpMax JOYPOS
	jpCenter JOYPOS
}

type JOYREGUSERVALUES struct {
	dwTimeOut uint32
	jrvRanges JOYRANGE
	jpDeadZone JOYPOS
}

type DIJOYUSERVALUES struct {
	dwSize uint32
	ruv JOYREGUSERVALUES
	wszGlobalDriver [256]uint16
	wszGameportEmulator [256]uint16
}
type
  JOYPOS = record
    dwX: DWORD;
    dwY: DWORD;
    dwZ: DWORD;
    dwR: DWORD;
    dwU: DWORD;
    dwV: DWORD;
  end;

  JOYRANGE = record
    jpMin: JOYPOS;
    jpMax: JOYPOS;
    jpCenter: JOYPOS;
  end;

  JOYREGUSERVALUES = record
    dwTimeOut: DWORD;
    jrvRanges: JOYRANGE;
    jpDeadZone: JOYPOS;
  end;

  DIJOYUSERVALUES = record
    dwSize: DWORD;
    ruv: JOYREGUSERVALUES;
    wszGlobalDriver: array[0..255] of WideChar;
    wszGameportEmulator: array[0..255] of WideChar;
  end;
const JOYPOS = extern struct {
    dwX: u32,
    dwY: u32,
    dwZ: u32,
    dwR: u32,
    dwU: u32,
    dwV: u32,
};

const JOYRANGE = extern struct {
    jpMin: JOYPOS,
    jpMax: JOYPOS,
    jpCenter: JOYPOS,
};

const JOYREGUSERVALUES = extern struct {
    dwTimeOut: u32,
    jrvRanges: JOYRANGE,
    jpDeadZone: JOYPOS,
};

const DIJOYUSERVALUES = extern struct {
    dwSize: u32,
    ruv: JOYREGUSERVALUES,
    wszGlobalDriver: [256]u16,
    wszGameportEmulator: [256]u16,
};
type
  JOYPOS {.bycopy.} = object
    dwX: uint32
    dwY: uint32
    dwZ: uint32
    dwR: uint32
    dwU: uint32
    dwV: uint32

  JOYRANGE {.bycopy.} = object
    jpMin: JOYPOS
    jpMax: JOYPOS
    jpCenter: JOYPOS

  JOYREGUSERVALUES {.bycopy.} = object
    dwTimeOut: uint32
    jrvRanges: JOYRANGE
    jpDeadZone: JOYPOS

  DIJOYUSERVALUES {.bycopy.} = object
    dwSize: uint32
    ruv: JOYREGUSERVALUES
    wszGlobalDriver: array[256, uint16]
    wszGameportEmulator: array[256, uint16]
struct JOYPOS
{
    uint dwX;
    uint dwY;
    uint dwZ;
    uint dwR;
    uint dwU;
    uint dwV;
}

struct JOYRANGE
{
    JOYPOS jpMin;
    JOYPOS jpMax;
    JOYPOS jpCenter;
}

struct JOYREGUSERVALUES
{
    uint dwTimeOut;
    JOYRANGE jrvRanges;
    JOYPOS jpDeadZone;
}

struct DIJOYUSERVALUES
{
    uint dwSize;
    JOYREGUSERVALUES ruv;
    wchar[256] wszGlobalDriver;
    wchar[256] wszGameportEmulator;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DIJOYUSERVALUES サイズ: 1128 バイト(x64)
dim st, 282    ; 4byte整数×282(構造体サイズ 1128 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ruv : JOYREGUSERVALUES (+4, 100byte)  varptr(st)+4 を基点に操作(100byte:入れ子/配列)
; wszGlobalDriver : WCHAR (+104, 512byte)  varptr(st)+104 を基点に操作(512byte:入れ子/配列)
; wszGameportEmulator : WCHAR (+616, 512byte)  varptr(st)+616 を基点に操作(512byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global JOYPOS
    #field int dwX
    #field int dwY
    #field int dwZ
    #field int dwR
    #field int dwU
    #field int dwV
#endstruct

#defstruct global JOYRANGE
    #field JOYPOS jpMin
    #field JOYPOS jpMax
    #field JOYPOS jpCenter
#endstruct

#defstruct global JOYREGUSERVALUES
    #field int dwTimeOut
    #field JOYRANGE jrvRanges
    #field JOYPOS jpDeadZone
#endstruct

#defstruct global DIJOYUSERVALUES
    #field int dwSize
    #field JOYREGUSERVALUES ruv
    #field wchar wszGlobalDriver 256
    #field wchar wszGameportEmulator 256
#endstruct

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