Controlling Xcsoar while flying condor

Moderators: Uros, Tom, OXO

AUBUISSON
Posts: 49
Joined: Sat Dec 16, 2017 9:48 pm

Re: Controlling Xcsoar while flying condor

Post by AUBUISSON » Sun Nov 03, 2019 7:11 pm

OK ,mais cela marche t_il en VR
OK, but does it work in VR Oculus Rift s
Image

User avatar
Tailspin
Posts: 48
Joined: Sun Dec 13, 2009 3:27 am
Location: San Diego USA
Contact:

Re: Controlling Xcsoar while flying condor

Post by Tailspin » Fri Nov 08, 2019 10:59 pm

Very useful free app lists controllers, axis and keys.

https://github.com/AntiMicro/antimicro/ ... s/tag/2.23

Used it to remap joystick to keyboard keys so Jeff's scripts work.

Spent several hours trying to make AutoHotKey do it, and five minutes reassigning the buttons to up, down, left , right arrow keys.

Ta-dah! It works!
Image

Jeffchrisope
Posts: 19
Joined: Sun Oct 06, 2019 11:21 pm

Re: Controlling Xcsoar while flying condor

Post by Jeffchrisope » Sat Nov 09, 2019 3:54 am

AUBUISSON wrote:
Sun Nov 03, 2019 7:11 pm
OK ,mais cela marche t_il en VR
OK, but does it work in VR Oculus Rift s
The main challenge is that you want to send keystrokes to XCSoar without actually moving input focus to XCSoar, and that's just a Windows behavior. It *shouldn't* matter which VR rig you're using, though I think most VR setups work best when you take the "mirror" screen and make it full-screen … gives fewer opportunities for inputs to change focus from Condor accidentally.

(Also, I use the Oculus Rift, v1, and it works fine, so I doubt Rift S would differ at all)
Image

Jeffchrisope
Posts: 19
Joined: Sun Oct 06, 2019 11:21 pm

Re: Controlling Xcsoar while flying condor

Post by Jeffchrisope » Sat Nov 09, 2019 4:03 am

Vlovs wrote:
Sun Nov 03, 2019 1:12 pm
how to assign a button to xcsoar?
I *think* that you're asking how do you actually add a UI button to a dialog in XCSoar. If that's the case, my understanding is that once you're looking at a "dialog" (a window, displayed over other stuff) you are no longer in the realm of stuff that can be easily configured with XCI files. I could be wrong though. Pop over to the XCSoar forum (https://forum.xcsoar.org/index.php) to confirm ...
Image

User avatar
Pit_R
Posts: 1348
Joined: Mon Feb 27, 2006 7:16 pm

Re: Controlling Xcsoar while flying condor

Post by Pit_R » Sat Nov 09, 2019 1:31 pm

To all XCSoar/C2 users. :)
Small ahk code to remove XCS titlebar [left win key + left click, use while app is in front]
and bring titlebar back [left win key + right click, use while app is in front]
Hope you'll like the effect. :)

Code: Select all

;-Caption
LWIN & LButton::
WinSet, Style, -0xC40000, A
return
;
;+Caption
LWIN & RButton::
WinSet, Style, +0xC40000, A
return
No matter where you go... There you are...

Image
:::: Please use this envelope
Image
to send me a PM.

h.kreso
Posts: 86
Joined: Sun Sep 21, 2008 11:49 pm
Location: Croatia

Re: Controlling Xcsoar while flying condor

Post by h.kreso » Sat Nov 09, 2019 6:12 pm

For me worked great for now, AHK last alpha v2, and in VR (Oculus last beta), XCSoar is pined as external window

Run, C:\Condor2\AddOn\XCSoar\xcsoar.exe
WinWait, XCSoar
WinMove, 1104, 1081
WinMaximize

SetTitleMatchMode 2
DetectHiddenWindows, on

up::
ControlSend,ahk_parent, {Up}, XCSoar
Return

down::
ControlSend,ahk_parent, {Down}, XCSoar
Return

left::
ControlSend,ahk_parent, {Left}, XCSoar
Return

right::
ControlSend,ahk_parent, {Right}, XCSoar
Return



Question, howe to add autozoom in XSCoar?
Image

User avatar
EDB
Posts: 1575
Joined: Mon Oct 31, 2011 1:17 am
Location: The Netherlands, Europe Continent, Earth Planet, Milky Way Galaxy, Virgo Super Cluster

Re: Controlling Xcsoar while flying condor

Post by EDB » Sat Nov 09, 2019 7:01 pm

Swipe up-down

jorgemarmor
Posts: 12
Joined: Sun Jun 21, 2020 11:57 am

Re: Controlling Xcsoar while flying condor

Post by jorgemarmor » Fri Oct 23, 2020 7:32 pm

Vlovs wrote:
Sun Nov 03, 2019 1:12 pm
how to assign a button to xcsoar?
Actually I just had the same idea of having associated Condor's button for dumping water with XCsoar command and I got to a solution. You can use the following code in the autohotkeys file:

1Joy9::
SendToXCS("{6}")
SendToXCS("{Up}")
SendToXCS("{Up}")
SendToXCS("{Enter}")
SendToXCS("{Escape}")
Return

(Substituting the "9" by the button you have associated to dumping water in the Joystick.
Image

User avatar
jcomm
Posts: 252
Joined: Mon May 16, 2005 12:51 am

Re: Controlling Xcsoar while flying condor

Post by jcomm » Sat Oct 24, 2020 11:25 am

I wonder which is the best choice to run XCSoar, Top-Hat, LK8000, ... with condorsoaring regarding display type in condor ?

If I plan to use two monitors, placing the PNA on the second monitor, how should I preferably set condor ?

- windowed
- full screen emulation
- full screen

to run on the main monitor ?
José Oliveira
Hey you Chicks flying bricks....
Come Fly Gliders ! Be Outsiders!

jorgemarmor
Posts: 12
Joined: Sun Jun 21, 2020 11:57 am

Re: Controlling Xcsoar while flying condor

Post by jorgemarmor » Sun Nov 08, 2020 9:18 am

Jeffchrisope wrote:
Wed Oct 30, 2019 4:51 am
Tailspin wrote:
Mon Oct 28, 2019 4:14 am
Yes indeed. Love to see your AHK script!

Okay, I've attached my current AHK file below, along with the XCI file I use to surface the MacCready change functions. As I noted above, this is using a Koolertron keypad (https://www.amazon.com/gp/product/B076M ... UTF8&psc=1) that works great as one option for surfacing controls for XCSoar. If XCSoar is in portrait, keys 1-4 cause the main menus to appear along the bottom, and the submenu options along the right side. This is very easy to map to keys on the big keypad (along with the u/d/l/r cursor keys, enter, and escape, which all have functions in XCS).

The other control option is to use a joystick, which is also included in the AHK file. I really like using this … but it doesn't work perfectly yet. Here I'm using the POV control on my Sidewinder FFB joystick to serve as the cursor keys, and mapping enter and escape to buttons. I've also mapped a keypad and joystick key/button to 'F1', which pops up the XCS "Quick Menu", which would be REALLY helpful … except there are cursor navigation issues once you're in dialogs. More on that below.

To customize the keypad/keyboard based control part, you obviously have to change what keys/buttons you want mapped to each function. In mine, you'll see lots of ^!1, ^!Up, etc. because I set my Koolertron keypad encodes keystrokes that way (^ is control, ! is alt modifier keys). You can use whatever you want, obviously. https://www.autohotkey.com/docs/Hotkeys.htm has information on all the ways to specify keys in AHK.

Customizing the joystick is picking which joystick number to use, known that joystick buttons in AHK are specified with <joysticknumber>Joy<buttonnumber>, so on my system, 5Joy2 refers to button 2 on joystick 5. Trial and error will help you figure out what number your particular joystick is with your setup.

The XCI file is loaded in the XCS config for Input (specify the file, than reboot XCS to load it). It's a surprisingly powerful system for surfacing commands.

So … other than being a minor pain to get this setup initially, the problem enters when any non-map page is up - including things like the Task manager screen and the Quick Menu. When these are showing, button routing gets all wonky, and I haven't figured out how to fix it yet. If you look at the AHK script, it is already a little hacky in the function that does the routing as it fires each key at a few targets. For any given key, at any given time, only one of those methods seems to work … so more to learn there. At any rate, this is MOSTLY not too painful, EXCEPT it would be REALLY cool if you could use the Quick Menu from the joystick POV hat to do things like enter Pan mode or the like. So … I'll keep poking at it, but the end result might be we just have to add the additional "important" commands in the XCI (like Pan mode, maybe) and target them directly.

Let me know if anyone has any questions on this. And yeah, I know most folks just run this on another monitor, or on a tablet, and don't care about this, but for me I really want it all working seamlessly in VR (with XCS projected right on top of the existing PDA, even), and it's sooooo close … :)


AutoHotKey script:

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

#SingleInstance force

; Sets up joystick POV/button watcher
SetTimer, WatchJoy, 5
return

; Joystick buttons routed to XCSoar
5Joy2::SendToXCS("{Enter}")
5Joy3::SendToXCS("{Escape}")
5Joy4::SendToXCS("{F1}")

; Main top-level cursor behaviors, plus MOST cursor
; movement in submenus
^!Up::SendToXCS("{Up}")
^!Down::SendToXCS("{Down}")
^!Left::SendToXCS("{Left}")
^!Right::SendToXCS("{Right}")

; 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}")

; Pulls up the XCSoar quick menu ... utterly busted at the moment
^!F1::SendToXCS("{F1}")

; Enter and Escape - usually works, if you can just get the right thing selected
^!e::SendToXCS("{Enter}")

; Escape:  works well in that it gets me out of broken dialogs that otherwise don't work
^!k::SendToXCS("{Escape}")

; MacCready controls ...
^!m::SendToXCS("{m}")
^!a::SendToXCS("{a}")
^!z::SendToXCS("{z}")

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)
{	
	; Yes, this is pretty much belt AND suspenders ... and it's still not 
	; quite enough for all scenarios, due to some quirks in either AHK, XCS, or both
	WinGet, WinID, ID, XCSoar
	ControlSend, ahk_parent, %k%, ahk_id %WinID%
	ControlGet, WinHwnd, Hwnd,,, XCSoar
	ControlSend,ahk_parent, %k%,ahk_id %WinHwnd%
	return
}
XCI file for the easy MacCready controls:

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
Hi Jeff, first of all thanks for this. It is amazing and working great.

The only thing I couldn't manage to make to work is using the quick menu (F1). I can invoke it, and move around, but when sending the key "Enter", instead of doing it, it sends me to the task menu.

Actually it is strange because when using keyboard keys directly in XCSoar, Enter works just fine, but not when sending it with AutoHotKey.

Anyone had the same problem?
Image

User avatar
Snapcase
Posts: 42
Joined: Tue May 11, 2010 4:51 pm
Location: Cracow, POLAND
Contact:

Re: Controlling Xcsoar while flying condor

Post by Snapcase » Wed Jan 06, 2021 3:24 pm

Yes, same problem here.

I tried:

3Joy2::
SendToXCS("{F1}")
SendToXCS("{Left}")
SendToXCS("{Left}")
SendToXCS("{UP}")
SendToXCS("{Enter}")

Then after pushing button "2" i should go to PAN map.. But when I'm in F1 menu - hitting "Enter" button takes me to the Task menu :/
Wojciech Sołtysik - SOL - Poland

jorgemarmor
Posts: 12
Joined: Sun Jun 21, 2020 11:57 am

Re: Controlling Xcsoar while flying condor

Post by jorgemarmor » Wed Jan 06, 2021 4:09 pm

For pan mode there is a shortcut that works. You can create an input file for XCSoar (.xci) with a command for that. For instance, I have the following in my xci file:

mode=default
type=key
data=p
event=Pan on

Then in the AutoHotKey script I send "p" to XCSoar and it works.

I hope this is useful.
Image

User avatar
Snapcase
Posts: 42
Joined: Tue May 11, 2010 4:51 pm
Location: Cracow, POLAND
Contact:

Re: Controlling Xcsoar while flying condor

Post by Snapcase » Wed Jan 06, 2021 6:58 pm

THANK YOU!

Works great!
Wojciech Sołtysik - SOL - Poland

User avatar
Snapcase
Posts: 42
Joined: Tue May 11, 2010 4:51 pm
Location: Cracow, POLAND
Contact:

Re: Controlling Xcsoar while flying condor

Post by Snapcase » Fri Feb 12, 2021 6:02 pm

jorgemarmor wrote:
Wed Jan 06, 2021 4:09 pm
For pan mode there is a shortcut that works. You can create an input file for XCSoar (.xci) with a command for that. For instance, I have the following in my xci file:

mode=default
type=key
data=p
event=Pan on

Then in the AutoHotKey script I send "p" to XCSoar and it works.

I hope this is useful.

Ok i got maped "p" key with joystick button but... when im in "windows" it works, when im in condor - it doesn't. When i hit alt+tab during the flight to "activate" xcsoar (opened on second monitor) it works again.

What could be a problem? What do you mean with "send" "p" to XCsoar witj AHK??
Wojciech Sołtysik - SOL - Poland

jorgemarmor
Posts: 12
Joined: Sun Jun 21, 2020 11:57 am

Re: Controlling Xcsoar while flying condor

Post by jorgemarmor » Sat Mar 06, 2021 1:04 pm

Snapcase wrote:
Fri Feb 12, 2021 6:02 pm
jorgemarmor wrote:
Wed Jan 06, 2021 4:09 pm
For pan mode there is a shortcut that works. You can create an input file for XCSoar (.xci) with a command for that. For instance, I have the following in my xci file:

mode=default
type=key
data=p
event=Pan on

Then in the AutoHotKey script I send "p" to XCSoar and it works.

I hope this is useful.

Ok i got maped "p" key with joystick button but... when im in "windows" it works, when im in condor - it doesn't. When i hit alt+tab during the flight to "activate" xcsoar (opened on second monitor) it works again.

What could be a problem? What do you mean with "send" "p" to XCsoar witj AHK??

AHK is autohotkey. See the rest of the post since page 1 where it is explained how to send sends to XCSoar with autohotkey.
Image

Post Reply