类型 函数 库 system.* 返回值 InputDevice 设备数组 修订版 发行版 2024.3703 关键字 getInputDevices 另请参见 InputDevice InputAxis
返回当前连接到系统的一系列 InputDevice 设备,例如触摸屏、键盘、鼠标、操纵杆等。如果未找到任何输入设备,则返回一个空数组。请注意,此函数不会返回曾经连接但后来断开的输入设备。
此函数旨在在应用程序启动和应用程序恢复时调用。在正常运行时,最好改用 inputDeviceStatus 事件 — 当新输入设备连接到系统或现有设备断开连接时,会触发此事件。
system.getInputDevices()
-- Fetch all input devices currently connected to the system local inputDevices = system.getInputDevices() -- Print all of the input devices found if ( #inputDevices > 0 ) then print( "Input devices found:" ) for index = 1,#inputDevices do print( index .. ") " .. inputDevices[index].displayName ) end else print( "No input devices found!" ) end