Keyboard asignment

Announcements, questions
Post Reply
J.G.
Posts: 4
Joined: 14 Jul 2015, 15:10

Keyboard asignment

Post by J.G. » 20 Jun 2016, 14:54

Hi.

I have three number pads remapped using LuaMacros. I set the logical names as below:
-- assign logical name to macro keyboard
clear()
lmc_say('Assigning Keyboards');
lmc_device_set_name('Comms_systems', '3166D5A9')
lmc_device_set_name('weapons_systems', '3263C97E')
lmc_device_set_name('Aircraft_systems', '26286BE')
lmc_print_devices()
The first two re-names are constant, they are always present as USB devices on a Flight Sim PC.

However, the third device is one of as set of keyboards that I swap in and out according to the aircraft model in use, having buttons tailored to a specific aircraft.

I don't want to load a different script for each aircraft and I want the keyboard assignment to be done without manual intervention.

My question is: Are the keyboard identifiers always unique to each keyboard, or are they likely to be different if a keyboard is swapped out?

So if I was to to do this:
clear()
lmc_say('Assigning Keyboards');
lmc_device_set_name('Comms_systems', '3166D5A9')
lmc_device_set_name('weapons_systems', '3263C97E')
lmc_device_set_name('Harrier_Aircraft_systems', 'AAAAAAAA')
lmc_device_set_name('Phantom_Aircraft_systems', 'BBBBBBBBB')
lmc_device_set_name('General_Aircraft_systems', 'CCCCCCCC')
lmc_print_devices()
Where only one of the last three assigned keyboards was present at any one run of the macro,

And then logically:

For Harrier_Aircraft_systems do:
XXX

For Phantom_Aircraft_systems do:
XXX

For General_Aircraft_systems do:
XXX
So I could make the assignment above in my macro secure in the knowledge that if any two of the last three keyboards was not present, the one that was would have the correct assignment and therefore the macro would only execute the code for the present keypad.

J.G.
Posts: 4
Joined: 14 Jul 2015, 15:10

Re: Keyboard asignment

Post by J.G. » 22 Jun 2016, 12:32

I am bit disappointed by the number of views and lack of advice with this topic.

However I have found a partial answer to my own question so I will post it here for the benefit of others.

The keyboard device name is driven by the USB port that it connects to.

So, lets say that you have a 4 port hub with ports A, B, C and D.
  • Connect any keyboard to port A and it will be given a device name for keyboard on that port.
    Connect the same keyboard to port B and it will be given a device name for that port that will be different even if it is the same keyboard.
    Connect a second keyboard to Port A and it will be given a keyboard device name the same as the first keyboard when it was connected to that port and so on.
However you cant label your USB ports with a keyboard ID as this seems to change occasionally when a keypad is disconnected or the PC is rebooted. It would be good if there was a way to manage this issue within Lua Macros.

Post Reply