ホーム › Media.Multimedia › joyGetThreshold
joyGetThreshold
関数ジョイスティックの移動しきい値を取得する。
シグネチャ
// WINMM.dll
#include <windows.h>
DWORD joyGetThreshold(
DWORD uJoyID,
DWORD* puThreshold
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| uJoyID | DWORD | in | ジョイスティックの識別子。uJoyID に指定できる値は 0 (JOYSTICKID1) から 15 までです。 |
| puThreshold | DWORD* | out | 移動しきい値の値を格納する変数へのポインター。 |
戻り値の型: DWORD
公式ドキュメント
joyGetThreshold 関数は、ジョイスティックに対して現在の移動しきい値を照会します。
戻り値
成功した場合は JOYERR_NOERROR を返します。それ以外の場合は、次のいずれかのエラー値を返します。
| 戻り値 | 説明 |
|---|---|
| ジョイスティックのドライバーが存在しません。 | |
| 無効なパラメーターが渡されました。 |
解説(Remarks)
移動しきい値とは、ジョイスティックの位置変更メッセージ (MM_JOY1MOVE、MM_JOY1ZMOVE、MM_JOY2MOVE、または MM_JOY2ZMOVE) が、デバイスをキャプチャしているウィンドウへ送信されるまでに、ジョイスティックを動かす必要のある距離です。しきい値の初期値は 0 です。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WINMM.dll
#include <windows.h>
DWORD joyGetThreshold(
DWORD uJoyID,
DWORD* puThreshold
);[DllImport("WINMM.dll", ExactSpelling = true)]
static extern uint joyGetThreshold(
uint uJoyID, // DWORD
out uint puThreshold // DWORD* out
);<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function joyGetThreshold(
uJoyID As UInteger, ' DWORD
<Out> ByRef puThreshold As UInteger ' DWORD* out
) As UInteger
End Function' uJoyID : DWORD
' puThreshold : DWORD* out
Declare PtrSafe Function joyGetThreshold Lib "winmm" ( _
ByVal uJoyID As Long, _
ByRef puThreshold As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
joyGetThreshold = ctypes.windll.winmm.joyGetThreshold
joyGetThreshold.restype = wintypes.DWORD
joyGetThreshold.argtypes = [
wintypes.DWORD, # uJoyID : DWORD
ctypes.POINTER(wintypes.DWORD), # puThreshold : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINMM.dll')
joyGetThreshold = Fiddle::Function.new(
lib['joyGetThreshold'],
[
-Fiddle::TYPE_INT, # uJoyID : DWORD
Fiddle::TYPE_VOIDP, # puThreshold : DWORD* out
],
-Fiddle::TYPE_INT)#[link(name = "winmm")]
extern "system" {
fn joyGetThreshold(
uJoyID: u32, // DWORD
puThreshold: *mut u32 // DWORD* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINMM.dll")]
public static extern uint joyGetThreshold(uint uJoyID, out uint puThreshold);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_joyGetThreshold' -Namespace Win32 -PassThru
# $api::joyGetThreshold(uJoyID, puThreshold)#uselib "WINMM.dll"
#func global joyGetThreshold "joyGetThreshold" sptr, sptr
; joyGetThreshold uJoyID, varptr(puThreshold) ; 戻り値は stat
; uJoyID : DWORD -> "sptr"
; puThreshold : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WINMM.dll" #cfunc global joyGetThreshold "joyGetThreshold" int, var ; res = joyGetThreshold(uJoyID, puThreshold) ; uJoyID : DWORD -> "int" ; puThreshold : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WINMM.dll" #cfunc global joyGetThreshold "joyGetThreshold" int, sptr ; res = joyGetThreshold(uJoyID, varptr(puThreshold)) ; uJoyID : DWORD -> "int" ; puThreshold : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD joyGetThreshold(DWORD uJoyID, DWORD* puThreshold) #uselib "WINMM.dll" #cfunc global joyGetThreshold "joyGetThreshold" int, var ; res = joyGetThreshold(uJoyID, puThreshold) ; uJoyID : DWORD -> "int" ; puThreshold : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD joyGetThreshold(DWORD uJoyID, DWORD* puThreshold) #uselib "WINMM.dll" #cfunc global joyGetThreshold "joyGetThreshold" int, intptr ; res = joyGetThreshold(uJoyID, varptr(puThreshold)) ; uJoyID : DWORD -> "int" ; puThreshold : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winmm = windows.NewLazySystemDLL("WINMM.dll")
procjoyGetThreshold = winmm.NewProc("joyGetThreshold")
)
// uJoyID (DWORD), puThreshold (DWORD* out)
r1, _, err := procjoyGetThreshold.Call(
uintptr(uJoyID),
uintptr(puThreshold),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction joyGetThreshold(
uJoyID: DWORD; // DWORD
puThreshold: Pointer // DWORD* out
): DWORD; stdcall;
external 'WINMM.dll' name 'joyGetThreshold';result := DllCall("WINMM\joyGetThreshold"
, "UInt", uJoyID ; DWORD
, "Ptr", puThreshold ; DWORD* out
, "UInt") ; return: DWORD●joyGetThreshold(uJoyID, puThreshold) = DLL("WINMM.dll", "dword joyGetThreshold(dword, void*)")
# 呼び出し: joyGetThreshold(uJoyID, puThreshold)
# uJoyID : DWORD -> "dword"
# puThreshold : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winmm" fn joyGetThreshold(
uJoyID: u32, // DWORD
puThreshold: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) u32;proc joyGetThreshold(
uJoyID: uint32, # DWORD
puThreshold: ptr uint32 # DWORD* out
): uint32 {.importc: "joyGetThreshold", stdcall, dynlib: "WINMM.dll".}pragma(lib, "winmm");
extern(Windows)
uint joyGetThreshold(
uint uJoyID, // DWORD
uint* puThreshold // DWORD* out
);ccall((:joyGetThreshold, "WINMM.dll"), stdcall, UInt32,
(UInt32, Ptr{UInt32}),
uJoyID, puThreshold)
# uJoyID : DWORD -> UInt32
# puThreshold : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t joyGetThreshold(
uint32_t uJoyID,
uint32_t* puThreshold);
]]
local winmm = ffi.load("winmm")
-- winmm.joyGetThreshold(uJoyID, puThreshold)
-- uJoyID : DWORD
-- puThreshold : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINMM.dll');
const joyGetThreshold = lib.func('__stdcall', 'joyGetThreshold', 'uint32_t', ['uint32_t', 'uint32_t *']);
// joyGetThreshold(uJoyID, puThreshold)
// uJoyID : DWORD -> 'uint32_t'
// puThreshold : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINMM.dll", {
joyGetThreshold: { parameters: ["u32", "pointer"], result: "u32" },
});
// lib.symbols.joyGetThreshold(uJoyID, puThreshold)
// uJoyID : DWORD -> "u32"
// puThreshold : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t joyGetThreshold(
uint32_t uJoyID,
uint32_t* puThreshold);
C, "WINMM.dll");
// $ffi->joyGetThreshold(uJoyID, puThreshold);
// uJoyID : DWORD
// puThreshold : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Winmm extends StdCallLibrary {
Winmm INSTANCE = Native.load("winmm", Winmm.class);
int joyGetThreshold(
int uJoyID, // DWORD
IntByReference puThreshold // DWORD* out
);
}@[Link("winmm")]
lib LibWINMM
fun joyGetThreshold = joyGetThreshold(
uJoyID : UInt32, # DWORD
puThreshold : UInt32* # DWORD* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef joyGetThresholdNative = Uint32 Function(Uint32, Pointer<Uint32>);
typedef joyGetThresholdDart = int Function(int, Pointer<Uint32>);
final joyGetThreshold = DynamicLibrary.open('WINMM.dll')
.lookupFunction<joyGetThresholdNative, joyGetThresholdDart>('joyGetThreshold');
// uJoyID : DWORD -> Uint32
// puThreshold : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function joyGetThreshold(
uJoyID: DWORD; // DWORD
puThreshold: Pointer // DWORD* out
): DWORD; stdcall;
external 'WINMM.dll' name 'joyGetThreshold';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "joyGetThreshold"
c_joyGetThreshold :: Word32 -> Ptr Word32 -> IO Word32
-- uJoyID : DWORD -> Word32
-- puThreshold : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let joygetthreshold =
foreign "joyGetThreshold"
(uint32_t @-> (ptr uint32_t) @-> returning uint32_t)
(* uJoyID : DWORD -> uint32_t *)
(* puThreshold : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winmm (t "WINMM.dll"))
(cffi:use-foreign-library winmm)
(cffi:defcfun ("joyGetThreshold" joy-get-threshold :convention :stdcall) :uint32
(u-joy-id :uint32) ; DWORD
(pu-threshold :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $joyGetThreshold = Win32::API::More->new('WINMM',
'DWORD joyGetThreshold(DWORD uJoyID, LPVOID puThreshold)');
# my $ret = $joyGetThreshold->Call($uJoyID, $puThreshold);
# uJoyID : DWORD -> DWORD
# puThreshold : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。