APP如何控制手柄马达震动

2022-10-20 14:17:21   第一文档网     [ 字体: ] [ 阅读: ] [ 文档下载 ]

#第一文档网# 导语】以下是®第一文档网的小编为您整理的《APP如何控制手柄马达震动》,欢迎阅读!
手柄,马达,震动,控制,如何
使

APP如何控制手柄达震



可以使用以下三种方案的任意一种,都可以使用连接手柄震动。

方案一:

游戏开发者可以通过android vibrator API发送震动指令至游戏手柄。 所有已经链接的游戏手柄都会震动

----------------------------------------------API------------------------------------------- public abstract class Vibrator

abstract void abstract boolean abstract void abstract void

cancel()

Turn the vibrator off. hasVibrator()

Check whether the hardware has a vibrator. vibrate(long[] pattern, int repeat) Vibrate with a given pattern. vibrate(long milliseconds)

Vibrate constantly for the specified period of time.

--------------------------------------------------------------------------------------------

方案二:

游戏开发者可以通过android inputdevice API获取vibrator对象,通过android vibrator API发送震动指令至游戏手柄。 可以实现对连接上手柄进行单独控制震动

------------------------------------------API----------------------------------------------- public final class InputDevice:

1 / 3


使

public Vibrator getVibrator ()

Gets the vibrator service associated with the device, if there is one. Even if the device does not have a vibrator, the result is never null. Use hasVibrator() to determine whether a vibrator is present. Note that the vibrator associated with the device may be different from the system vibrator. To obtain an instance of the system vibrator instead, call getSystemService(String) with VIBRATOR_SERVICE as argument. Returns

· The vibrator service associated with the device, never null.

public abstract class InputEvent public final InputDevice getDevice () Added in API level 9

Gets the device that this event came from. Returns

· The device, or null if unknown.

-----------------------------------------end----------------------------------------------- 方案三

者可以通过蓝HID 接口送指令,控制手柄左/达震达震强度 指令数据格式:

Request

Set_Report Feature

Report Data playload

Repoert ID Motor Left

2 / 3

Motor right


本文来源:https://www.dy1993.cn/UW3x.html

相关推荐