-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
30 lines (27 loc) · 806 Bytes
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local gc = require "game_controller"
local num_devices = gc.getDeviceCount()
local ffi = require( "ffi" )
function lovr.load()
print( "Number of devices: " .. num_devices )
for i = 1, num_devices do
local name = "-N/A-"
if gc.isDeviceGamepad( i ) then
name = gc.getGamepadName( i )
end
print( "Index: " .. i .. ", GUID: " .. gc.getDeviceGUID( i ) .. ", Name: " .. gc.getDeviceName( i ) .. ", Gamepad name: " .. name )
end
end
function lovr.update( dt )
local result, type, device = gc.configurationChanged()
if result then
print( "Device: " .. device .. " was " .. type )
end
if gc.isDevicePresent( 1 ) then
local btn_count = gc.getButtonCount( 1 )
for i = 1, btn_count do
if gc.getButtonState( 1, i ) == 1 then
print( "Button " .. i .. " is down" )
end
end
end
end