Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #911 - Set VCCS PTT and audio device via LogonDetails.exe #912

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Changes from release 2024/11 to 2024/12
1. Enhancement - Update LogonDetails.exe to set up VCCS PTT & Audio - thanks to @AdriTheDev, @AliceFord and @BenWalker01 (Callum, Alice and Ben)

# Changes from release 2024/10 to 2024/11
1. Enhancement - Add various aliases to Heathrow (EGLL) profile - thanks to @kristiankunc (Kristián Kunc)
2. Enhancement - Added ground speed to ATM tags - thanks to @frazerxyz (Frazer Scully)
Expand Down
74 changes: 71 additions & 3 deletions UK/LogonDetails.py
AdriTheDev marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import os
import time
import keyboard
import sounddevice as sd

def has_matching_brackets(s):
stack = []
for char in s:
if char == '(':
stack.append(char)
elif char == ')':
if not stack:
return False
stack.pop()
return not stack

# User Inputs
# Name
Expand Down Expand Up @@ -44,6 +57,58 @@
CPDLC = input("Enter Hoppie's Code: ")
os.system('cls')

# VCCS PTT Key

print("Push a key you want to use for VCCS. (Note: Keyboard only)")
PTT = str(int(hex(keyboard.read_event().scan_code), 16) << 16)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keybind prompt character may be transferred to the next prompt as input.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea not too sure on how to fix, all the methods I've tried still result in the input being transferred to the next prompt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've resolved this somehow somewhere else. I'll get back to you on it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be the result of holding the key down for too long? You should make sure to check for the key-up event when reading keyboard input

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I knew there was an easy solution - keyboard.read_event(suppress=True)
This will suppress the key that's pressed from the console.

AdriTheDev marked this conversation as resolved.
Show resolved Hide resolved
os.system('cls')

# VCCS Input and Output Device Selection

VCCSInput = input("Would you like to use your default audio settings for VCCS? (y/n): ").lower()
os.system('cls')

if 'n' in VCCSInput:
devices = sd.query_devices()
unique_input_devices = set()
unique_output_devices = set()

input_device = ''
output_device = ''

input_device_msg = "Please select the input device: \n"
output_device_msg = "Please select the output device: \n"

for i, device in enumerate(devices):
if device['max_input_channels'] > 0 and "mapper" not in device['name'].lower() and not "driver" in device['name'].lower() and has_matching_brackets(device['name']):
if device['name'] not in unique_input_devices:
unique_input_devices.add(device['name'])

for index, item in enumerate(unique_input_devices):
input_device_msg += f'{index}) {item}\n'

while input_device not in map(str, range(0, len(unique_input_devices))):
input_device = input(input_device_msg)
VCCSInput = list(unique_input_devices)[int(input_device)]
os.system('cls')

for i, device in enumerate(devices):
if device['max_output_channels'] > 0 and "mapper" not in device['name'].lower() and not "driver" in device['name'].lower() and has_matching_brackets(device['name']):
if device['name'] not in unique_output_devices:
unique_output_devices.add(device['name'])

for index, item in enumerate(unique_output_devices):
output_device_msg += f'{index}) {item}\n'

while output_device not in map(str, range(0, len(unique_output_devices))):
output_device = input(output_device_msg)
VCCSOutput = list(unique_output_devices)[int(output_device)]
os.system('cls')
else:
VCCSInput = sd.query_devices(sd.default.device[0])['name']
VCCSOutput = sd.query_devices(sd.default.device[1])['name']
Comment on lines +108 to +109
Copy link
Contributor

@PLM1995 PLM1995 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't provide any protection against 'abridged' names being the default device, e.g. in my case, my default device is Headset Microphone (2- Corsair rather than the full Headset Earphone (2- Corsair HS70 Wireless Gaming Headset) as saved in ES .prf files. Do we need a warning/prohibition of this? I wonder if it might make more sense to force people to choose their device from a valid list??



# Write CPDLC to TopSky (all instances)

f = open("Data/Plugin/TopSky_iTEC/TopSkyCPDLChoppieCode.txt", "w")
Expand All @@ -60,9 +125,12 @@

f.close

# Add CID as Nickname to VCCS profiles
# Set VCCS Settings

PrfVCCS=("TeamSpeakVccs Ts3NickName "+CID)
PrfVCCSNick=("TeamSpeakVccs Ts3NickName "+CID)
PrfVCCSPTT=("TeamSpeakVccs Ts3G2GPtt "+PTT)
PrfVCCSInput=("TeamSpeakVccs CaptureDevice "+VCCSInput)
PrfVCCSOutput=("TeamSpeakVccs PlaybackDevice "+VCCSOutput)
Comment on lines +130 to +133
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be considering setting the TeamSpeakVccs CaptureMode as well for completeness or does it not matter/default to something sensible?


#Set intials as object

Expand All @@ -83,7 +151,7 @@
if file.endswith(".prf"):
file_path = os.path.join(root, file)
with open(file_path, 'a') as f:
f.write(f"\n{PrfVCCS}\n{PrfName}\n{PrfCID}\n{PrfOBSCallsign}\n{Prfrating}\n{PrfPassword}\n")
f.write(f"\n{PrfVCCSNick}\n{PrfVCCSPTT}\n{PrfVCCSInput}\n{PrfVCCSOutput}\n{PrfName}\n{PrfCID}\n{PrfOBSCallsign}\n{Prfrating}\n{PrfPassword}\n")

# Adds CPDLC code to Plugins.txt files for vSMR use

Expand Down
Loading