ホーム › Media.Multimedia › joySetThreshold
joySetThreshold
関数ジョイスティックの移動しきい値を設定する。
シグネチャ
// WINMM.dll
#include <windows.h>
DWORD joySetThreshold(
DWORD uJoyID,
DWORD uThreshold
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| uJoyID | DWORD | in | ジョイスティックの識別子。uJoyID の有効な値は 0 (JOYSTICKID1) から 15 までの範囲です。 |
| uThreshold | DWORD | in | 新しい移動しきい値。 |
戻り値の型: DWORD
公式ドキュメント
joySetThreshold 関数は、ジョイスティックの移動しきい値を設定します。
戻り値
成功した場合は JOYERR_NOERROR を返し、失敗した場合は以下のいずれかのエラー値を返します。
| 戻り値 | 説明 |
|---|---|
| ジョイスティックドライバーが存在しません。 | |
| 指定されたジョイスティックデバイス識別子 uJoyID が無効です。 |
解説(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 joySetThreshold(
DWORD uJoyID,
DWORD uThreshold
);[DllImport("WINMM.dll", ExactSpelling = true)]
static extern uint joySetThreshold(
uint uJoyID, // DWORD
uint uThreshold // DWORD
);<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function joySetThreshold(
uJoyID As UInteger, ' DWORD
uThreshold As UInteger ' DWORD
) As UInteger
End Function' uJoyID : DWORD
' uThreshold : DWORD
Declare PtrSafe Function joySetThreshold Lib "winmm" ( _
ByVal uJoyID As Long, _
ByVal uThreshold As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
joySetThreshold = ctypes.windll.winmm.joySetThreshold
joySetThreshold.restype = wintypes.DWORD
joySetThreshold.argtypes = [
wintypes.DWORD, # uJoyID : DWORD
wintypes.DWORD, # uThreshold : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINMM.dll')
joySetThreshold = Fiddle::Function.new(
lib['joySetThreshold'],
[
-Fiddle::TYPE_INT, # uJoyID : DWORD
-Fiddle::TYPE_INT, # uThreshold : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "winmm")]
extern "system" {
fn joySetThreshold(
uJoyID: u32, // DWORD
uThreshold: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINMM.dll")]
public static extern uint joySetThreshold(uint uJoyID, uint uThreshold);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_joySetThreshold' -Namespace Win32 -PassThru
# $api::joySetThreshold(uJoyID, uThreshold)#uselib "WINMM.dll"
#func global joySetThreshold "joySetThreshold" sptr, sptr
; joySetThreshold uJoyID, uThreshold ; 戻り値は stat
; uJoyID : DWORD -> "sptr"
; uThreshold : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WINMM.dll"
#cfunc global joySetThreshold "joySetThreshold" int, int
; res = joySetThreshold(uJoyID, uThreshold)
; uJoyID : DWORD -> "int"
; uThreshold : DWORD -> "int"; DWORD joySetThreshold(DWORD uJoyID, DWORD uThreshold)
#uselib "WINMM.dll"
#cfunc global joySetThreshold "joySetThreshold" int, int
; res = joySetThreshold(uJoyID, uThreshold)
; uJoyID : DWORD -> "int"
; uThreshold : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winmm = windows.NewLazySystemDLL("WINMM.dll")
procjoySetThreshold = winmm.NewProc("joySetThreshold")
)
// uJoyID (DWORD), uThreshold (DWORD)
r1, _, err := procjoySetThreshold.Call(
uintptr(uJoyID),
uintptr(uThreshold),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction joySetThreshold(
uJoyID: DWORD; // DWORD
uThreshold: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'joySetThreshold';result := DllCall("WINMM\joySetThreshold"
, "UInt", uJoyID ; DWORD
, "UInt", uThreshold ; DWORD
, "UInt") ; return: DWORD●joySetThreshold(uJoyID, uThreshold) = DLL("WINMM.dll", "dword joySetThreshold(dword, dword)")
# 呼び出し: joySetThreshold(uJoyID, uThreshold)
# uJoyID : DWORD -> "dword"
# uThreshold : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winmm" fn joySetThreshold(
uJoyID: u32, // DWORD
uThreshold: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc joySetThreshold(
uJoyID: uint32, # DWORD
uThreshold: uint32 # DWORD
): uint32 {.importc: "joySetThreshold", stdcall, dynlib: "WINMM.dll".}pragma(lib, "winmm");
extern(Windows)
uint joySetThreshold(
uint uJoyID, // DWORD
uint uThreshold // DWORD
);ccall((:joySetThreshold, "WINMM.dll"), stdcall, UInt32,
(UInt32, UInt32),
uJoyID, uThreshold)
# uJoyID : DWORD -> UInt32
# uThreshold : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t joySetThreshold(
uint32_t uJoyID,
uint32_t uThreshold);
]]
local winmm = ffi.load("winmm")
-- winmm.joySetThreshold(uJoyID, uThreshold)
-- uJoyID : DWORD
-- uThreshold : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINMM.dll');
const joySetThreshold = lib.func('__stdcall', 'joySetThreshold', 'uint32_t', ['uint32_t', 'uint32_t']);
// joySetThreshold(uJoyID, uThreshold)
// uJoyID : DWORD -> 'uint32_t'
// uThreshold : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINMM.dll", {
joySetThreshold: { parameters: ["u32", "u32"], result: "u32" },
});
// lib.symbols.joySetThreshold(uJoyID, uThreshold)
// uJoyID : DWORD -> "u32"
// uThreshold : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t joySetThreshold(
uint32_t uJoyID,
uint32_t uThreshold);
C, "WINMM.dll");
// $ffi->joySetThreshold(uJoyID, uThreshold);
// uJoyID : DWORD
// uThreshold : DWORD
// 構造体/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 joySetThreshold(
int uJoyID, // DWORD
int uThreshold // DWORD
);
}@[Link("winmm")]
lib LibWINMM
fun joySetThreshold = joySetThreshold(
uJoyID : UInt32, # DWORD
uThreshold : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef joySetThresholdNative = Uint32 Function(Uint32, Uint32);
typedef joySetThresholdDart = int Function(int, int);
final joySetThreshold = DynamicLibrary.open('WINMM.dll')
.lookupFunction<joySetThresholdNative, joySetThresholdDart>('joySetThreshold');
// uJoyID : DWORD -> Uint32
// uThreshold : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function joySetThreshold(
uJoyID: DWORD; // DWORD
uThreshold: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'joySetThreshold';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "joySetThreshold"
c_joySetThreshold :: Word32 -> Word32 -> IO Word32
-- uJoyID : DWORD -> Word32
-- uThreshold : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let joysetthreshold =
foreign "joySetThreshold"
(uint32_t @-> uint32_t @-> returning uint32_t)
(* uJoyID : DWORD -> uint32_t *)
(* uThreshold : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winmm (t "WINMM.dll"))
(cffi:use-foreign-library winmm)
(cffi:defcfun ("joySetThreshold" joy-set-threshold :convention :stdcall) :uint32
(u-joy-id :uint32) ; DWORD
(u-threshold :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $joySetThreshold = Win32::API::More->new('WINMM',
'DWORD joySetThreshold(DWORD uJoyID, DWORD uThreshold)');
# my $ret = $joySetThreshold->Call($uJoyID, $uThreshold);
# uJoyID : DWORD -> DWORD
# uThreshold : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。