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

GameInputFlightStickState

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

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

フィールド

フィールドサイズx64x86説明
buttonsGameInputFlightStickButtons4+0+0フライトスティックの押下ボタンを示すフラグである。
hatSwitchGameInputSwitchPosition4+4+4ハットスイッチの方向位置を示す値である。
rollFLOAT4+8+8ロール軸の入力値を-1〜1で示す。
pitchFLOAT4+12+12ピッチ軸の入力値を-1〜1で示す。
yawFLOAT4+16+16ヨー軸の入力値を-1〜1で示す。
throttleFLOAT4+20+20スロットルの入力値を0〜1で示す。

各言語での定義

#include <windows.h>

// GameInputFlightStickState  (x64 24 / x86 24 バイト)
typedef struct GameInputFlightStickState {
    GameInputFlightStickButtons buttons;
    GameInputSwitchPosition hatSwitch;
    FLOAT roll;
    FLOAT pitch;
    FLOAT yaw;
    FLOAT throttle;
} GameInputFlightStickState;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GameInputFlightStickState
{
    public int buttons;
    public int hatSwitch;
    public float roll;
    public float pitch;
    public float yaw;
    public float throttle;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GameInputFlightStickState
    Public buttons As Integer
    Public hatSwitch As Integer
    Public roll As Single
    Public pitch As Single
    Public yaw As Single
    Public throttle As Single
End Structure
import ctypes
from ctypes import wintypes

class GameInputFlightStickState(ctypes.Structure):
    _fields_ = [
        ("buttons", ctypes.c_int),
        ("hatSwitch", ctypes.c_int),
        ("roll", ctypes.c_float),
        ("pitch", ctypes.c_float),
        ("yaw", ctypes.c_float),
        ("throttle", ctypes.c_float),
    ]
#[repr(C)]
pub struct GameInputFlightStickState {
    pub buttons: i32,
    pub hatSwitch: i32,
    pub roll: f32,
    pub pitch: f32,
    pub yaw: f32,
    pub throttle: f32,
}
import "golang.org/x/sys/windows"

type GameInputFlightStickState struct {
	buttons int32
	hatSwitch int32
	roll float32
	pitch float32
	yaw float32
	throttle float32
}
type
  GameInputFlightStickState = record
    buttons: Integer;
    hatSwitch: Integer;
    roll: Single;
    pitch: Single;
    yaw: Single;
    throttle: Single;
  end;
const GameInputFlightStickState = extern struct {
    buttons: i32,
    hatSwitch: i32,
    roll: f32,
    pitch: f32,
    yaw: f32,
    throttle: f32,
};
type
  GameInputFlightStickState {.bycopy.} = object
    buttons: int32
    hatSwitch: int32
    roll: float32
    pitch: float32
    yaw: float32
    throttle: float32
struct GameInputFlightStickState
{
    int buttons;
    int hatSwitch;
    float roll;
    float pitch;
    float yaw;
    float throttle;
}

HSP用 定義

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

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

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