Something I've been looking for a while is to control tasks (move to next task point and previous one) with the joystick. Finally AMS told me how. Basically it is also by setting the options in XCSoar's xci file with the following commands:
mode=default
type=key
data=s
event=AdjustWaypoint nextarm
event=Beep 1
event=TaskTransition next
mode=default
type=key
data=x
event=AdjustWaypoint previousarm
event=Beep 1
Then you have the keys "s" and "k" to control it. Similarly to other functions you should use autohotkey or any other solution to send those keys to XCsoar while flying.
Controlling Xcsoar while flying condor
-
- Posts: 12
- Joined: Sun Jun 21, 2020 11:57 am
-
- Posts: 51
- Joined: Wed Jan 21, 2009 4:47 am
Re: Controlling Xcsoar while flying condor
Not sure if this has been solved elsewhere, but I was able to fix the AHK script provided earlier in this thread so that keys/buttons are passed properly in the background to XCSoar (or LK8000). The quick-menu now works properly, so you can do most everything you need without having to switch focus to XCsoar.
Of course, you will need to change which buttons or keys are used as hotkeys in the script so that it works with your specific control setup. Run out of buttons? Joystick Gremlin is a great tool to create more using long-presses, mode shifts, etc.
Here are the contents of the custom XCI file (eg: condor.XCI) I used in parallel with this.
LK8000 is very similar, but you have to append these "events" into the DEFAULT_MENU.TXT file in SYSTEM folder (this file says to create a custom events file instead, but that didn't work for me) . Here is an example of what I added (not complete yet):
Of course, you will need to change which buttons or keys are used as hotkeys in the script so that it works with your specific control setup. Run out of buttons? Joystick Gremlin is a great tool to create more using long-presses, mode shifts, etc.
Code: Select all
#InstallKeybdHook
#Persistent
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
DetectHiddenWindows, On
;launches XCSoar - change file location as needed
if not WinExist("XCSoar")
{
run %A_MyDocuments%\XCSoar.exe
WinWait XCSoar
}
else
WinActivate XCSoar
#SingleInstance force
; remove the title bar
WinSet, Style, -0xC00000, XCSoar
; Joystick buttons routed to XCSoar. Change these to whatever buttons or keys suit your controls
; the best. Or if you have limited buttons, use a program like Joystick Gremlin to create more (eg.
; long-press buttons, mode shifts, etc.)
3Joy2::SendToXCS("{Enter}")
3Joy1::SendToXCS("{Escape}")
3Joy3::SendToXCS("{F1}")
; Main top-level cursor behaviors
3Joy7::SendToXCS("{Up}")
3Joy6::SendToXCS("{Down}")
3Joy4::SendToXCS("{Left}")
3Joy5::SendToXCS("{Right}")
; Pan On and Zoom as up/down keys pan the map in this mode, instead of zooming
3Joy8::SendToXCS("{o}")
3Joy9::SendToXCS("{i}")
3Joy10::SendToXCS("{p}")
; MacCready controls
3Joy27::SendToXCS("{m}")
3Joy20::SendToXCS("{a}")
3Joy19::SendToXCS("{z}")
; task next and previous arm
3Joy15::SendToXCS("{x}")
3Joy16::SendToXCS("{s}")
; Main-level numeric "APP keys" (1-4) and submenus (6-0)
^!1::SendToXCS("{1}")
^!2::SendToXCS("{2}")
^!3::SendToXCS("{3}")
^!4::SendToXCS("{4}")
^!5::SendToXCS("{5}")
^!6::SendToXCS("{6}")
^!7::SendToXCS("{7}")
^!8::SendToXCS("{8}")
^!9::SendToXCS("{9}")
^!0::SendToXCS("{0}")
WatchJoy:
POV := GetKeyState("5JoyPOV") ; Get position of the POV control.
KeyToHoldDownPrev := KeyToHoldDown ; Prev now holds the key that was down before (if any).
; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if (POV < 0) ; No angle to report
KeyToHoldDown := ""
else if (POV > 31500) ; 315 to 360 degrees: Forward
KeyToHoldDown := "Up"
else if POV between 0 and 4500 ; 0 to 45 degrees: Forward
KeyToHoldDown := "Up"
else if POV between 4501 and 13500 ; 45 to 135 degrees: Right
KeyToHoldDown := "Right"
else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
KeyToHoldDown := "Down"
else ; 225 to 315 degrees: Left
KeyToHoldDown := "Left"
if (KeyToHoldDown = KeyToHoldDownPrev) ; The correct key is already down (or no key is needed).
return ; Do nothing.
; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
SendToXCS("{" . KeyToHoldDownPrev . " up}") ; Release it.
if KeyToHoldDown ; There is a key to press down.
SendToXCS("{" . KeyToHoldDown . " down}") ; Press it down.
return
; Handles piping individual keys to XCSoar
SendToXCS(k)
{
; this fixes the "quirks" with the original script, the ControlGetFocus was the key
WinGet, WinID, ID, XCSoar
ControlGetFocus,CursorPosition, XCSoar
if not CursorPosition
ControlSend, ahk_parent, %k%, ahk_id %WinID%
else
ControlSend, %CursorPosition%, %k%, ahk_id %WinID%
; can use this with LK8000 as well. Will need to update the DEFAULT_MENU.TXT file in LK8000 System directory.
WinGet, WinID, ID, LK8000
ControlGetFocus,CursorPosition, LK8000
if not CursorPosition
ControlSend, ahk_parent, %k%, ahk_id %WinID%
else
ControlSend, %CursorPosition%, %k%, ahk_id %WinID%
return
}
Code: Select all
mode=default
type=key
data=m
event=MacCready auto toggle
mode=default
type=key
data=a
event=MacCready up
mode=default
type=key
data=z
event=MacCready down
mode=default pan
type=key
data=i
event=Zoom in
mode=default pan
type=key
data=o
event=Zoom out
mode=default
type=key
data=p
event=Pan on
mode=default
type=key
data=s
event=AdjustWaypoint nextarm
event=Beep 1
event=TaskTransition next
mode=default
type=key
data=x
event=AdjustWaypoint previousarm
event=Beep 1
event=StatusMessage Previous Turnpoint
Code: Select all
mode=default
type=key
data=p
event=Mode fullscreenpan
event=Pan on
mode=pan fullscreenpan
type=key
data=ESCAPE
event=Pan off
mode=default pan fullscreenpan
type=key
data=i
event=Zoom in
mode=default pan fullscreenpan
type=key
data=o
event=Zoom out
mode=pan fullscreenpan
type=key
data=l
event=Pan off
mode=default
type=key
data=m
event=MacCready auto toggle
mode=default
type=key
data=a
event=MacCready up
mode=default
type=key
data=z
event=MacCready down
mode=default
type=key
data=s
event=AdjustWaypoint next
event=Beep 1
event=StatusMessage Next Turnpoint
mode=default
type=key
data=x
event=AdjustWaypoint previous
event=Beep 1
event=StatusMessage Previous Turnpoint