Actions which are executed by device event are pieces of Lua code. Those pieces needs to be bound to specific device and (optionally, in some cases) specific button. When you start LuaMacros it detects physical devices connected to your computer. Those devices usually have some name defined by manufacturer (default names for game devices) or some ugly very long string - kind of system identifier - for devices.
To make LuaMacros script nice for reading and easy for transfer between different computers every device that should act as action trigger needs to have some (nice) logical name assigned first.
Let's have an example. These are devices what LuaMacros can detect
Code: Select all
<unassigned> : Saitek X52 Flight Control System [0] : game
<unassigned> : Saitek Pro Flight Rudder Pedals [0] : game
<unassigned> : BU0836A Interface [0] : game
<unassigned> : \\?\HID#VID_1C4F&PID_0002&MI_00#9&826BD90&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [327833] : keyboard
<unassigned> : \\?\HID#VID_04FC&PID_05D8&MI_00#7&1BDC3055&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65605] : keyboard
<unassigned> : \\?\HID#VID_046D&PID_C52E&MI_00#9&12234230&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [720963] : keyboard
Total number of devices: 6
To assign logical name to some device there are several functions available. The most common is lmc_device_set_name. It has 2 arguments:
- logical name - to be assigned
- regular expression to match system id of the device. On multiple match first device is used.
Code: Select all
lmc_device_set_name('LB', 'BU0836A')
lmc_device_set_name('KBD1', '826BD90')
lmc_device_set_name('KBD2', '1BDC3055')
Code: Select all
<unassigned> : Saitek X52 Flight Control System [0] : game
<unassigned> : Saitek Pro Flight Rudder Pedals [0] : game
LB : BU0836A Interface [0] : game
KBD1 : \\?\HID#VID_1C4F&PID_0002&MI_00#9&826BD90&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [327833] : keyboard
KBD2 : \\?\HID#VID_04FC&PID_05D8&MI_00#7&1BDC3055&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65605] : keyboard
<unassigned> : \\?\HID#VID_046D&PID_C52E&MI_00#9&12234230&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [720963] : keyboard
Total number of devices: 6
Having logical names assigned you can write Lua functions as event handlers (callbacks). See another how-to for instructions and examples (to be written - Apr 2015).
In the future (written in Apr 2015) there might be functions for multiple regexp assignment (working with string map) and also for storing/loading these maps from/to file (kind of properties file). However you can easily do the same with proper lmc_device_set_name functions so I'm not that motivated.