ホーム › UI.Input.XboxController › XInputSetState
XInputSetState
関数Xboxコントローラーの振動モーター状態を設定する。
シグネチャ
// xinput1_4.dll
#include <windows.h>
DWORD XInputSetState(
DWORD dwUserIndex,
XINPUT_VIBRATION* pVibration
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwUserIndex | DWORD | in |
| pVibration | XINPUT_VIBRATION* | in |
戻り値の型: DWORD
各言語での呼び出し定義
// xinput1_4.dll
#include <windows.h>
DWORD XInputSetState(
DWORD dwUserIndex,
XINPUT_VIBRATION* pVibration
);[DllImport("xinput1_4.dll", ExactSpelling = true)]
static extern uint XInputSetState(
uint dwUserIndex, // DWORD
IntPtr pVibration // XINPUT_VIBRATION*
);<DllImport("xinput1_4.dll", ExactSpelling:=True)>
Public Shared Function XInputSetState(
dwUserIndex As UInteger, ' DWORD
pVibration As IntPtr ' XINPUT_VIBRATION*
) As UInteger
End Function' dwUserIndex : DWORD
' pVibration : XINPUT_VIBRATION*
Declare PtrSafe Function XInputSetState Lib "xinput1_4" ( _
ByVal dwUserIndex As Long, _
ByVal pVibration As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
XInputSetState = ctypes.windll.xinput1_4.XInputSetState
XInputSetState.restype = wintypes.DWORD
XInputSetState.argtypes = [
wintypes.DWORD, # dwUserIndex : DWORD
ctypes.c_void_p, # pVibration : XINPUT_VIBRATION*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('xinput1_4.dll')
XInputSetState = Fiddle::Function.new(
lib['XInputSetState'],
[
-Fiddle::TYPE_INT, # dwUserIndex : DWORD
Fiddle::TYPE_VOIDP, # pVibration : XINPUT_VIBRATION*
],
-Fiddle::TYPE_INT)#[link(name = "xinput1_4")]
extern "system" {
fn XInputSetState(
dwUserIndex: u32, // DWORD
pVibration: *mut XINPUT_VIBRATION // XINPUT_VIBRATION*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("xinput1_4.dll")]
public static extern uint XInputSetState(uint dwUserIndex, IntPtr pVibration);
"@
$api = Add-Type -MemberDefinition $sig -Name 'xinput1_4_XInputSetState' -Namespace Win32 -PassThru
# $api::XInputSetState(dwUserIndex, pVibration)#uselib "xinput1_4.dll"
#func global XInputSetState "XInputSetState" sptr, sptr
; XInputSetState dwUserIndex, varptr(pVibration) ; 戻り値は stat
; dwUserIndex : DWORD -> "sptr"
; pVibration : XINPUT_VIBRATION* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "xinput1_4.dll" #cfunc global XInputSetState "XInputSetState" int, var ; res = XInputSetState(dwUserIndex, pVibration) ; dwUserIndex : DWORD -> "int" ; pVibration : XINPUT_VIBRATION* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "xinput1_4.dll" #cfunc global XInputSetState "XInputSetState" int, sptr ; res = XInputSetState(dwUserIndex, varptr(pVibration)) ; dwUserIndex : DWORD -> "int" ; pVibration : XINPUT_VIBRATION* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD XInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) #uselib "xinput1_4.dll" #cfunc global XInputSetState "XInputSetState" int, var ; res = XInputSetState(dwUserIndex, pVibration) ; dwUserIndex : DWORD -> "int" ; pVibration : XINPUT_VIBRATION* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD XInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) #uselib "xinput1_4.dll" #cfunc global XInputSetState "XInputSetState" int, intptr ; res = XInputSetState(dwUserIndex, varptr(pVibration)) ; dwUserIndex : DWORD -> "int" ; pVibration : XINPUT_VIBRATION* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
xinput1_4 = windows.NewLazySystemDLL("xinput1_4.dll")
procXInputSetState = xinput1_4.NewProc("XInputSetState")
)
// dwUserIndex (DWORD), pVibration (XINPUT_VIBRATION*)
r1, _, err := procXInputSetState.Call(
uintptr(dwUserIndex),
uintptr(pVibration),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction XInputSetState(
dwUserIndex: DWORD; // DWORD
pVibration: Pointer // XINPUT_VIBRATION*
): DWORD; stdcall;
external 'xinput1_4.dll' name 'XInputSetState';result := DllCall("xinput1_4\XInputSetState"
, "UInt", dwUserIndex ; DWORD
, "Ptr", pVibration ; XINPUT_VIBRATION*
, "UInt") ; return: DWORD●XInputSetState(dwUserIndex, pVibration) = DLL("xinput1_4.dll", "dword XInputSetState(dword, void*)")
# 呼び出し: XInputSetState(dwUserIndex, pVibration)
# dwUserIndex : DWORD -> "dword"
# pVibration : XINPUT_VIBRATION* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。