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

GameInputTouchState

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

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

フィールド

フィールドサイズx64x86説明
touchIdULONGLONG8+0+0このタッチ接触点を一意に識別するIDである。
sensorIndexDWORD4+8+8接触を検知したタッチセンサーのインデックスである。
positionXFLOAT4+12+12接触点のX座標を0〜1の正規化値で示す。
positionYFLOAT4+16+16接触点のY座標を0〜1の正規化値で示す。
pressureFLOAT4+20+20接触の圧力を0〜1の正規化値で示す。
proximityFLOAT4+24+24指などの近接度を0〜1の正規化値で示す。
contactRectTopFLOAT4+28+28接触領域矩形の上辺を正規化値で示す。
contactRectLeftFLOAT4+32+32接触領域矩形の左辺を正規化値で示す。
contactRectRightFLOAT4+36+36接触領域矩形の右辺を正規化値で示す。
contactRectBottomFLOAT4+40+40接触領域矩形の下辺を正規化値で示す。

各言語での定義

#include <windows.h>

// GameInputTouchState  (x64 48 / x86 48 バイト)
typedef struct GameInputTouchState {
    ULONGLONG touchId;
    DWORD sensorIndex;
    FLOAT positionX;
    FLOAT positionY;
    FLOAT pressure;
    FLOAT proximity;
    FLOAT contactRectTop;
    FLOAT contactRectLeft;
    FLOAT contactRectRight;
    FLOAT contactRectBottom;
} GameInputTouchState;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GameInputTouchState
{
    public ulong touchId;
    public uint sensorIndex;
    public float positionX;
    public float positionY;
    public float pressure;
    public float proximity;
    public float contactRectTop;
    public float contactRectLeft;
    public float contactRectRight;
    public float contactRectBottom;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GameInputTouchState
    Public touchId As ULong
    Public sensorIndex As UInteger
    Public positionX As Single
    Public positionY As Single
    Public pressure As Single
    Public proximity As Single
    Public contactRectTop As Single
    Public contactRectLeft As Single
    Public contactRectRight As Single
    Public contactRectBottom As Single
End Structure
import ctypes
from ctypes import wintypes

class GameInputTouchState(ctypes.Structure):
    _fields_ = [
        ("touchId", ctypes.c_ulonglong),
        ("sensorIndex", wintypes.DWORD),
        ("positionX", ctypes.c_float),
        ("positionY", ctypes.c_float),
        ("pressure", ctypes.c_float),
        ("proximity", ctypes.c_float),
        ("contactRectTop", ctypes.c_float),
        ("contactRectLeft", ctypes.c_float),
        ("contactRectRight", ctypes.c_float),
        ("contactRectBottom", ctypes.c_float),
    ]
#[repr(C)]
pub struct GameInputTouchState {
    pub touchId: u64,
    pub sensorIndex: u32,
    pub positionX: f32,
    pub positionY: f32,
    pub pressure: f32,
    pub proximity: f32,
    pub contactRectTop: f32,
    pub contactRectLeft: f32,
    pub contactRectRight: f32,
    pub contactRectBottom: f32,
}
import "golang.org/x/sys/windows"

type GameInputTouchState struct {
	touchId uint64
	sensorIndex uint32
	positionX float32
	positionY float32
	pressure float32
	proximity float32
	contactRectTop float32
	contactRectLeft float32
	contactRectRight float32
	contactRectBottom float32
}
type
  GameInputTouchState = record
    touchId: UInt64;
    sensorIndex: DWORD;
    positionX: Single;
    positionY: Single;
    pressure: Single;
    proximity: Single;
    contactRectTop: Single;
    contactRectLeft: Single;
    contactRectRight: Single;
    contactRectBottom: Single;
  end;
const GameInputTouchState = extern struct {
    touchId: u64,
    sensorIndex: u32,
    positionX: f32,
    positionY: f32,
    pressure: f32,
    proximity: f32,
    contactRectTop: f32,
    contactRectLeft: f32,
    contactRectRight: f32,
    contactRectBottom: f32,
};
type
  GameInputTouchState {.bycopy.} = object
    touchId: uint64
    sensorIndex: uint32
    positionX: float32
    positionY: float32
    pressure: float32
    proximity: float32
    contactRectTop: float32
    contactRectLeft: float32
    contactRectRight: float32
    contactRectBottom: float32
struct GameInputTouchState
{
    ulong touchId;
    uint sensorIndex;
    float positionX;
    float positionY;
    float pressure;
    float proximity;
    float contactRectTop;
    float contactRectLeft;
    float contactRectRight;
    float contactRectBottom;
}

HSP用 定義

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

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

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