Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Scancode implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Jun 29, 2023
1 parent dac7bc2 commit d9dcfe7
Show file tree
Hide file tree
Showing 8 changed files with 1,881 additions and 6,451 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ VectorAudio uses two different ways to detect a connection to vatsim: the slurpe

If you see a red "No VATSIM data", this most likely means that VATSIM servers are temporarily down.

### One of my PTT keys does not work (F16, F17, ...)

VectorAudio is limited by the underlying SFML library which is used for keydown detection. So far, the library only support F keys up to F15, and some other keys might have limited support. This is likely to improve in the future.

See also [#46](https://github.com/pierr3/VectorAudio/issues/46)

### Does VectorAudio support HF Simulation?

No.
Expand Down
3 changes: 3 additions & 0 deletions include/modals/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <string>
#include "style.h"
#include <imgui_stdlib.h>
#include <SFML/System/String.hpp>
#include <SFML/Window/Keyboard.hpp>


namespace vector_audio::modals {
class Settings {
Expand Down
2 changes: 1 addition & 1 deletion include/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ inline int headsetOutputChannel = 0;

inline bool capture_ptt_flag = false;

inline sf::Keyboard::Key ptt = sf::Keyboard::Unknown;
inline sf::Keyboard::Scancode ptt = sf::Keyboard::Scan::Unknown;
inline int joyStickId = -1;
inline int joyStickPtt = -1;
inline bool isPttOpen = false;
Expand Down
2 changes: 1 addition & 1 deletion include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inline void AddUnderLine(ImColor col_)
ImVec2 min = ImGui::GetItemRectMin();
ImVec2 max = ImGui::GetItemRectMax();
min.y = max.y;
ImGui::GetWindowDrawList()->AddLine(min, max, col_, 1.0f);
ImGui::GetWindowDrawList()->AddLine(min, max, col_, 1.0F);
}

// From Imgui demo
Expand Down
8,291 changes: 1,861 additions & 6,430 deletions resources/LICENSE.txt

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
namespace vector_audio::application {
using util::TextURL;

static void defaultLogger(const char* subsystem, const char* /*file*/, int /*line*/, const char* lineOut)
{
spdlog::info("[afv_native] {} {}", subsystem, lineOut);
}
namespace afv_logger {
void defaultLogger(const char* subsystem, const char* /*file*/, int /*line*/, const char* lineOut)
{
spdlog::info("[afv_native] {} {}", subsystem, lineOut);
}

static afv_native::log_fn gLogger = defaultLogger;
afv_native::log_fn g_logger = defaultLogger;
}

App::App()
{
try {
afv_native::api::atcClient::setLogger(gLogger);
afv_native::api::atcClient::setLogger(afv_logger::g_logger);

mClient_ = new afv_native::api::atcClient(
shared::kClientName,
Expand All @@ -45,8 +47,8 @@ App::App()
vector_audio::shared::vatsim_password = toml::find_or<std::string>(
cfg::config, "user", "vatsim_password", std::string("password"));

vector_audio::shared::ptt = static_cast<sf::Keyboard::Key>(
toml::find_or<int>(cfg::config, "user", "ptt", -1));
vector_audio::shared::ptt = static_cast<sf::Keyboard::Scancode>(
toml::find_or<int>(cfg::config, "user", "ptt", static_cast<int>(sf::Keyboard::Scan::Unknown)));

vector_audio::shared::joyStickId = static_cast<int>(
toml::find_or<int>(cfg::config, "user", "joyStickId", -1));
Expand Down Expand Up @@ -283,7 +285,7 @@ void App::render_frame()
vector_audio::shared::mVu = mClient_->GetInputVu();

// Set the Ptt if required, input based on event
if (mClient_->IsVoiceConnected() && (shared::ptt != sf::Keyboard::Unknown || shared::joyStickId != -1)) {
if (mClient_->IsVoiceConnected() && (shared::ptt != sf::Keyboard::Scan::Unknown || shared::joyStickId != -1)) {
if (shared::isPttOpen) {
if (shared::joyStickId != -1) {
if (!sf::Joystick::isButtonPressed(shared::joyStickId, shared::joyStickPtt)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int main(int, char**)
} else if (event.type == sf::Event::KeyPressed) {
// Capture the new Ptt key
if (vector_audio::shared::capture_ptt_flag) {
vector_audio::shared::ptt = event.key.code;
vector_audio::shared::ptt = event.key.scancode;

vector_audio::shared::joyStickId = -1; vector_audio::shared::joyStickPtt = -1;
vector_audio::configuration::config["user"]["joyStickId"] = vector_audio::shared::joyStickId;
Expand All @@ -126,7 +126,7 @@ int main(int, char**)
} else if (event.type == sf::Event::JoystickButtonPressed) {

if (vector_audio::shared::capture_ptt_flag) {
vector_audio::shared::ptt = sf::Keyboard::Unknown;
vector_audio::shared::ptt = sf::Keyboard::Scan::Unknown;

vector_audio::shared::joyStickId = event.joystickButton.joystickId;
vector_audio::shared::joyStickPtt = event.joystickButton.button;
Expand Down
4 changes: 2 additions & 2 deletions src/modals/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ void vector_audio::modals::Settings::render(afv_native::api::atcClient* mClient)

ImGui::TextUnformatted("Push to talk key: ");
std::string ptt_key_name;
if (shared::ptt == sf::Keyboard::Unknown && shared::joyStickId == -1) {
if (shared::ptt == sf::Keyboard::Scan::Unknown && shared::joyStickId == -1) {
ptt_key_name = "Not set";
} else if (shared::ptt != -1) {
ptt_key_name = "Key: " + vector_audio::util::getKeyName(shared::ptt);
ptt_key_name = "Key: " + sf::Keyboard::getDescription(shared::ptt);
} else if (shared::joyStickId != -1) {
ptt_key_name = fmt::format("Joystick {} Button {}", shared::joyStickId, shared::joyStickPtt);
}
Expand Down

0 comments on commit d9dcfe7

Please sign in to comment.