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

GameInputKeyState

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

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

フィールド

フィールドサイズx64x86説明
scanCodeDWORD4+0+0物理キーのスキャンコードである。
codePointDWORD4+4+4キーに対応するUnicodeコードポイントである。
virtualKeyBYTE1+8+8仮想キーコード(VK値)である。
isDeadKeyBYTE1+9+9デッドキーであるかを示す真偽値である。

各言語での定義

#include <windows.h>

// GameInputKeyState  (x64 12 / x86 12 バイト)
typedef struct GameInputKeyState {
    DWORD scanCode;
    DWORD codePoint;
    BYTE virtualKey;
    BYTE isDeadKey;
} GameInputKeyState;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GameInputKeyState
{
    public uint scanCode;
    public uint codePoint;
    public byte virtualKey;
    public byte isDeadKey;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GameInputKeyState
    Public scanCode As UInteger
    Public codePoint As UInteger
    Public virtualKey As Byte
    Public isDeadKey As Byte
End Structure
import ctypes
from ctypes import wintypes

class GameInputKeyState(ctypes.Structure):
    _fields_ = [
        ("scanCode", wintypes.DWORD),
        ("codePoint", wintypes.DWORD),
        ("virtualKey", ctypes.c_ubyte),
        ("isDeadKey", ctypes.c_ubyte),
    ]
#[repr(C)]
pub struct GameInputKeyState {
    pub scanCode: u32,
    pub codePoint: u32,
    pub virtualKey: u8,
    pub isDeadKey: u8,
}
import "golang.org/x/sys/windows"

type GameInputKeyState struct {
	scanCode uint32
	codePoint uint32
	virtualKey byte
	isDeadKey byte
}
type
  GameInputKeyState = record
    scanCode: DWORD;
    codePoint: DWORD;
    virtualKey: Byte;
    isDeadKey: Byte;
  end;
const GameInputKeyState = extern struct {
    scanCode: u32,
    codePoint: u32,
    virtualKey: u8,
    isDeadKey: u8,
};
type
  GameInputKeyState {.bycopy.} = object
    scanCode: uint32
    codePoint: uint32
    virtualKey: uint8
    isDeadKey: uint8
struct GameInputKeyState
{
    uint scanCode;
    uint codePoint;
    ubyte virtualKey;
    ubyte isDeadKey;
}

HSP用 定義

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

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

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