Xplane 11 Function and Numpad Keys not working

Announcements, questions
russell458
Posts: 9
Joined: 23 Mar 2018, 04:14

Xplane 11 Function and Numpad Keys not working

Post by russell458 » 23 Mar 2018, 04:35

Hey guys,
I am a noob at this stuff, here is the script I have compiled so far.
All commands are working, however any commands listed as a function key F1 F2 F3 ect as well as any Numpad keys are not working.
I have tried scripting the commands that work with other keys to the numpad or function keys and they dont work.
My overhead works awesome on xplane, I just really wish I could map out my numpad/functions correctly..

Check out my script...



-- assign logical name to macro keyboard
lmc_assign_keyboard('MACROS');
lmc_print_devices()

-- define callback for whole device
lmc_set_handler('MACROS',function(button, direction)
if (direction == 1) then return end -- ignore down
if (button == string.byte('C')) then lmc_xpl_command('laminar/B738/toggle_switch/bleed_air_2')
elseif (button == string.byte('X')) then lmc_xpl_command('laminar/B738/toggle_switch/bleed_air_apu')
elseif (button == string.byte('Z')) then lmc_xpl_command('laminar/B738/toggle_switch/bleed_air_1')
elseif (button == string.byte('^A')) then lmc_xpl_command('laminar/B738/toggle_switch/l_pack_dn')
elseif (button == string.byte('A')) then lmc_xpl_command('laminar/B738/toggle_switch/l_pack_up')
elseif (button == string.byte('D')) then lmc_xpl_command('laminar/B738/toggle_switch/r_pack_up')
elseif (button == string.byte('^D')) then lmc_xpl_command('laminar/B738/toggle_switch/r_pack_dn')
elseif (button == string.byte('S')) then lmc_xpl_command('laminar/B738/toggle_switch/iso_valve_dn')
elseif (button == string.byte('+(S)')) then lmc_xpl_command('laminar/B738/toggle_switch/iso_valve_up')
elseif (button == string.byte('`')) then lmc_xpl_command('sim/lights/taxi_lights_toggle')
elseif (button == string.byte('1')) then lmc_xpl_command('sim/lights/landing_lights_on')
elseif (button == string.byte('2')) then lmc_xpl_command('laminar/B738/switch/rwy_light_left_on')
elseif (button == string.byte('3')) then lmc_xpl_command('laminar/B738/switch/rwy_light_right_on')
elseif (button == string.byte('4')) then lmc_xpl_command('laminar/B738/switch/wing_light_on')
elseif (button == string.byte('5')) then lmc_xpl_command('laminar/B738/switch/logo_light_on')
elseif (button == string.byte('7')) then lmc_xpl_command('laminar/B738/toggle_switch/position_light_up')
elseif (button == string.byte('8')) then lmc_xpl_command('laminar/B738/switch/wheel_light_on')
elseif (button == string.byte('9')) then lmc_xpl_command('laminar/B738/toggle_switch/window_heat_l_side')
elseif (button == string.byte('0')) then lmc_xpl_command('laminar/B738/toggle_switch/window_heat_r_side')
elseif (button == string.byte('-')) then lmc_xpl_command('laminar/B738/toggle_switch/window_heat_l_fwd')
elseif (button == string.byte('=')) then lmc_xpl_command('laminar/B738/toggle_switch/window_heat_r_fwd')
elseif (button == string.byte('=')) then lmc_xpl_command('laminar/B738/toggle_switch/window_heat_r_side')
elseif (button == string.byte('+')) then lmc_xpl_command('laminar/B738/push_button/master_caution1')
elseif (button == string.byte('{f1}')) then lmc_xpl_command('laminar/B738/autopilot/n1_press')
elseif (button == string.byte('{F2}')) then lmc_xpl_command('laminar/B738/autopilot/cmd_a_press')
elseif (button == string.byte('{NUM1}')) then lmc_xpl_command('laminar/B738/autopilot/speed_press')
elseif (button == string.byte('{NUM3}')) then lmc_xpl_command('laminar/B738/autopilot/autothrottle_arm_toggle')
elseif (button == string.byte('{NUM4}')) then lmc_xpl_command('laminar/B738/autopilot/hdg_sel_press')
elseif (button == string.byte('{NUM5}')) then lmc_xpl_command('laminar/B738/autopilot/app_press')
elseif (button == string.byte ('{NUM6}')) then lmc_xpl_command('laminar/B738/autopilot/vorloc_press')
elseif (button == string.byte('{NUM9}')) then lmc_xpl_command('laminar/B738/autopilot/lvl_chg_press')
elseif (button == string.byte('*')) then lmc_xpl_command('laminar/B738/autopilot/vs_press')
elseif (button == string.byte('{numast}')) then lmc_xpl_command('laminar/B738/autopilot/lvl_chg_press')
elseif (button == string.byte('{numminus}')) then lmc_xpl_command('laminar/B738/autopilot/alt_hld_press')
elseif (button == string.byte('{numplus}')) then lmc_xpl_command('laminar/B738/autopilot/vnav_press')
elseif (button == string.byte('{ENT}')) then lmc_xpl_command('laminar/B738/autopilot/lnav_press')
elseif (button == string.byte('{numdecimal}')) then lmc_xpl_command('laminar/B738/autopilot/flight_director_toggle')

end
end)


Please help, Beers to whoever can fix this!
Thanks alot for your time
Rich
Attachments
setup.jpg
setup.jpg (72.38 KiB) Viewed 3126 times

admin
Site Admin
Posts: 620
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Xplane 11 Function and Numpad Keys not working

Post by admin » 23 Mar 2018, 08:57

string.byte is strandard lua function at it has nothing to do with key names used in sendKeys (like {NUM6}).
You need to use virtual key code here - even find such codes for F* keys or put debug print command to your handler that will print current key value (variable button) and then use this value in if (elseif) condition.
Petr Medek
LUAmacros author

russell458
Posts: 9
Joined: 23 Mar 2018, 04:14

Re: Xplane 11 Function and Numpad Keys not working

Post by russell458 » 23 Mar 2018, 12:33

@admin
My apologies, thanks for your knowledgeable reply, I really don't understand what that means though..

admin
Site Admin
Posts: 620
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Xplane 11 Function and Numpad Keys not working

Post by admin » 23 Mar 2018, 13:19

Ok, instead of

Code: Select all

elseif (button == string.byte('{NUM1}')) then lmc_xpl_command('laminar/B738/autopilot/speed_press')
try

Code: Select all

elseif (button == 97) then lmc_xpl_command('laminar/B738/autopilot/speed_press')
and if it works find other numbers here
Petr Medek
LUAmacros author

russell458
Posts: 9
Joined: 23 Mar 2018, 04:14

Re: Xplane 11 Function and Numpad Keys not working

Post by russell458 » 23 Mar 2018, 15:05

Thanks for the reply I will try when I'm off work.
One last request, as you can see towards the top of the script, some buttons mean switch down, and ive tried to use ctrl+the button to make the switch go up. Useful for turning stuff off.
I have tried the command found in hidmacros documentation to no avail.

elseif (button == string.byte('S')) then lmc_xpl_command('laminar/B738/toggle_switch/iso_valve_dn')
elseif (button == string.byte('+(S)')) then lmc_xpl_command('laminar/B738/toggle_switch/iso_valve_up')

How do I properly code this?
Thanks a million, donation on the way of you can help me out. Cheers

admin
Site Admin
Posts: 620
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Xplane 11 Function and Numpad Keys not working

Post by admin » 23 Mar 2018, 15:20

Generally the tool is not intended to react to key combinations. The idea is opposite – you can use multiple keyboards to avoid need of key combinations.
On the other hand I think it’s doable – you need some flag (variable) which you set on ctrl (or shift) down and reset on release. Then you can adapt macro action accordingly when the key ("real" ket, not modifier like shift or ctrl) is pressed. However you need to understand the script and need some basic knowledge of Lua language. As stated – to use luamacros you need at least basics in lua scripting and programming concepts (variables, functions etc).

PS: Again, don’t mix key names you found in HidMacros doc with string.byte – it’s something completely different.
Petr Medek
LUAmacros author

russell458
Posts: 9
Joined: 23 Mar 2018, 04:14

Re: Xplane 11 Function and Numpad Keys not working

Post by russell458 » 23 Mar 2018, 15:57

So I switched from string.byte to the button == commands
The commands in bold work, all else do not.

elseif (button == 112) then lmc_xpl_command('laminar/B738/push_button/master_caution1')
elseif (button == 98) then lmc_xpl_command('laminar/B738/autopilot/n1_press')
elseif (button == 96) then lmc_xpl_command('laminar/B738/autopilot/cmd_a_press')
elseif (button == 97) then lmc_xpl_command('laminar/B738/autopilot/speed_press')
elseif (button == 99) then lmc_xpl_command('laminar/B738/autopilot/autothrottle_arm_toggle') This is numpad 3.
elseif (button == 99) then lmc_xpl_command('laminar/B738/autopilot/hdg_sel_press')
elseif (button == 101) then lmc_xpl_command('laminar/B738/autopilot/app_press')
elseif (button == 102) then lmc_xpl_command('laminar/B738/autopilot/vorloc_press')
elseif (button == 105) then lmc_xpl_command('laminar/B738/autopilot/lvl_chg_press')
elseif (button == 106) then lmc_xpl_command('laminar/B738/autopilot/vs_press') This is numpad *
elseif (button == 120) then lmc_xpl_command('laminar/B738/autopilot/lvl_chg_press') This is numpad 9
elseif (button == 109) then lmc_xpl_command('laminar/B738/autopilot/alt_hld_press') This is numpad -
elseif (button == 107) then lmc_xpl_command('laminar/B738/autopilot/vnav_press')
elseif (button == 13) then lmc_xpl_command('laminar/B738/autopilot/lnav_press')
elseif (button == 110) then lmc_xpl_command('laminar/B738/autopilot/flight_director_toggle') This is numpad decimal

I am lost to why only certain numpad numbers are working??

admin
Site Admin
Posts: 620
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Xplane 11 Function and Numpad Keys not working

Post by admin » 23 Mar 2018, 16:56

After your last elseif line add command

Code: Select all

else print('To use this key add elseif with number ' .. button)
Run it, see output
Petr Medek
LUAmacros author

russell458
Posts: 9
Joined: 23 Mar 2018, 04:14

Re: Xplane 11 Function and Numpad Keys not working

Post by russell458 » 23 Mar 2018, 17:05

It would seem that num lock may be an issue? Some keys do not show a value when pressed, others will but only with num lock on, others only with num lock off?

When I press numlock on my 1st keyboard, the num lock light illuminates on my upper keyboard as well?

russell458
Posts: 9
Joined: 23 Mar 2018, 04:14

Re: Xplane 11 Function and Numpad Keys not working

Post by russell458 » 23 Mar 2018, 18:09

Alright,
I have everything working!

Other than a single button and that is CMD A autopilot as NUMPAD 0.
In fact I cannot even get the print elseif command to populate correct value.

Post Reply