I've encountered a problem where various keypress events to show information, start the engine, engage autopilots, are not reliably executed. I may have to hit a key repeatedly over several seconds before the command actually registers. I've pasted my complete consumebufferedkey function below.
It seems that Orbiter is taking other internal keypress events like switching VCs, changing camera angles, etc. without problem.
It also seems that keypress events in clbk_consumedirectkey() are also being taken without problem. It seems to be an intermittent problem with events in clbk_consumebufferedkey.
Others have tested this same code and have not had this problem, so I am suspicious of a hardware issue as I am on an old laptop running Orbiter under Wine on Linux. This seemed to become a problem when I switched to using Orbiter_NG.exe instead of Orbiter.exe last week. My laptop is certainly working a lot harder under Orbiter_NG.exe even with all the visual effects unchecked. I seem to get random crashes on startup as well.
Any thoughts? Anything I can check?
It seems that Orbiter is taking other internal keypress events like switching VCs, changing camera angles, etc. without problem.
It also seems that keypress events in clbk_consumedirectkey() are also being taken without problem. It seems to be an intermittent problem with events in clbk_consumebufferedkey.
Others have tested this same code and have not had this problem, so I am suspicious of a hardware issue as I am on an old laptop running Orbiter under Wine on Linux. This seemed to become a problem when I switched to using Orbiter_NG.exe instead of Orbiter.exe last week. My laptop is certainly working a lot harder under Orbiter_NG.exe even with all the visual effects unchecked. I seem to get random crashes on startup as well.
Any thoughts? Anything I can check?
Code:
function clbk_consumebufferedkey(key, down, kstate)
if not down then -- only process keydown events
return false
end
if oapi.keydown(kstate, OAPI_KEY.A) then
if altitude_hold == false then
altitude_hold = true
altitude_target = vi:get_altitude(ALTMODE.MEANRAD)
elseif altitude_hold == true then
altitude_hold = false
end
return true
end
if oapi.keydown(kstate, OAPI_KEY.LCONTROL) or oapi.keydown(kstate, OAPI_KEY.RCONTROL) then
if oapi.keydown(kstate, OAPI_KEY.B) then
if brake_hold == false then
brake_hold = true
elseif brake_hold == true then
brake_hold = false
end
return true
end
end
if oapi.keydown(kstate, OAPI_KEY.E) then
if engine_on == nil or engine_on == false then
engine_on = true
elseif engine_on == true then
engine_on = false
vi:set_thrustergrouplevel(THGROUP.MAIN, 0)
end
return true
end
if oapi.keydown(kstate, OAPI_KEY.I) then
if show_help == false then
show_help = true
elseif show_help == true then
show_help = false
end
return true
end
if oapi.keydown(kstate, OAPI_KEY.LCONTROL) or oapi.keydown(kstate, OAPI_KEY.RCONTROL) then
if oapi.keydown(kstate, OAPI_KEY.L) then
if lights_on == false then
lights_on = true
elseif lights_on == true then
lights_on = false
end
lights_switched = true
return true
end
end
if oapi.keydown(kstate, OAPI_KEY.LSHIFT) or oapi.keydown(kstate, OAPI_KEY.RSHIFT) then
if oapi.keydown(kstate, OAPI_KEY.EQUALS) then
instrument_light_level = math.min(instrument_light_level + 0.1, 1)
elseif oapi.keydown(kstate, OAPI_KEY.MINUS) then
instrument_light_level = math.max(instrument_light_level - 0.1, 0)
end
light_level_switched = true
return true
end
if oapi.keydown(kstate, OAPI_KEY.LCONTROL) or oapi.keydown(kstate, OAPI_KEY.RCONTROL) then
if oapi.keydown(kstate, OAPI_KEY.EQUALS) then
cabin_light_level = math.min(cabin_light_level + 0.1, 1)
elseif oapi.keydown(kstate, OAPI_KEY.MINUS) then
cabin_light_level = math.max(cabin_light_level - 0.1, 0)
end
light_level_switched = true
return true
end
if oapi.keydown(kstate, OAPI_KEY.NUMPAD5) then
roll = 0
pitch = 0
return true
end
end
Last edited: