Permalink
Browse files

More Button Fixes

  • Loading branch information...
Trevelopment committed Dec 22, 2018
1 parent d8333ef commit 831d74f3685d5d6d3be11a5983a10c1665f6c8ac
Showing with 23 additions and 24 deletions.
  1. +2 −2 mazda/callbacks.cpp
  2. +0 −6 mazda/main.cpp
  3. +20 −15 mazda/outputs.cpp
  4. +1 −1 ubuntu/callbacks.cpp
@@ -95,7 +95,7 @@ void MazdaEventCallbacks::AudioFocusRequest(int chan, const HU::AudioFocusReques
audioMgrClient->audioMgrReleaseAudioFocus();
} else {
if (!inCall) {
if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN_TRANSIENT || request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN_NAVI) {
if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN_TRANSIENT) { // || request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN_NAVI) {
audioMgrClient->audioMgrRequestAudioFocus(AudioManagerClient::FocusType::TRANSIENT); //assume media
} else if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN) {
audioMgrClient->audioMgrRequestAudioFocus(AudioManagerClient::FocusType::PERMANENT); //assume media
@@ -396,7 +396,7 @@ void AudioManagerClient::aaRegisterStream()
}

// Stream is registered add it to the array
streamToSessionIds[aaStreamName] = aaSessionID;
streamToSessionIds[aaStreamName] = aaTransientSessionID;
}


@@ -35,12 +35,6 @@
#include "glib_utils.h"
#include "config.h"

#include "json/json.hpp"
#include "config.h"

using json = nlohmann::json;


#define HMI_BUS_ADDRESS "unix:path=/tmp/dbus_hmi_socket"
#define SERVICE_BUS_ADDRESS "unix:path=/tmp/dbus_service_socket"
// Check the content folder. sd_nav still exists without the card installed
@@ -235,6 +235,7 @@ void VideoOutput::input_thread_func()
uint32_t scanCode = 0;
int32_t scrollAmount = 0;
bool isPressed = (event.value == 1);
bool longPress = false;
AudioManagerClient::FocusType audioFocus = callbacks->audioFocus;
bool hasMediaAudioFocus = audioFocus == AudioManagerClient::FocusType::PERMANENT;
bool hasAudioFocus = audioFocus != AudioManagerClient::FocusType::NONE;
@@ -255,22 +256,22 @@ void VideoOutput::input_thread_func()
printf("KEY_LEFTBRACE (next track with media focus: %i)\n", hasMediaAudioFocus ? 1 : 0);
if(hasMediaAudioFocus)
{
scanCode = HUIB_NEXT;
scanCode = HUIB_NEXT;
}
else
{
pass_key_to_mzd(event.type, event.code, event.value);
pass_key_to_mzd(event.type, event.code, event.value);
}
break;
case KEY_RIGHTBRACE:
printf("KEY_RIGHTBRACE (prev track with media focus: %i)\n", hasMediaAudioFocus ? 1 : 0);
if(hasMediaAudioFocus)
{
scanCode = HUIB_PREV;
scanCode = HUIB_PREV;
}
else
{
pass_key_to_mzd(event.type, event.code, event.value);
pass_key_to_mzd(event.type, event.code, event.value);
}
break;
case KEY_BACKSPACE:
@@ -319,7 +320,7 @@ void VideoOutput::input_thread_func()
break;
case KEY_Z: // CALL ANS
printf("KEY_Z\n");
scanCode = HUIB_TEL;
scanCode = HUIB_PHONE;
break;
case KEY_X: // CALL END
printf("KEY_X\n");
@@ -340,23 +341,27 @@ void VideoOutput::input_thread_func()
}
break;
case KEY_T: // FAV
printf("KEY_T (any audio focus: %i media focus: %i)\n", hasAudioFocus, hasMediaAudioFocus ? 1 : 0);
if (hasMediaAudioFocus)
{ //do it on release to avoid key bounce/repeat
if(!isPressed)
{
printf("KEY_T (any audio focus: %i media focus: %i is pressed: %i)\n", hasAudioFocus, hasMediaAudioFocus ? 1 : 0, isPressed ? 1 : 0);
if(isPressed)
{
if (hasAudioFocus)
{ // avoid key bounce/repeat by only capturing on key press
callbacks->releaseAudioFocus(); //This will also pause audio automatically in AA
}
else
{ // if we don't have audio focus take focus by playing music
scanCode = HUIB_PLAYPAUSE;
}
}
else
{ // if we don't have audio focus take focus by playing music
scanCode = HUIB_PLAYPAUSE;
else if(hasMediaAudioFocus)
{ // This will be the release when audio focus is taken
scanCode = HUIB_PLAYPAUSE;
}
break;
}
if (scanCode != 0 || scrollAmount != 0)
{
g_hu->hu_queue_command([timeStamp, scanCode, scrollAmount, isPressed](IHUConnectionThreadInterface& s)
g_hu->hu_queue_command([timeStamp, scanCode, scrollAmount, isPressed, longPress](IHUConnectionThreadInterface& s)
{
HU::InputEvent inputEvent;
inputEvent.set_timestamp(timeStamp);
@@ -365,7 +370,7 @@ void VideoOutput::input_thread_func()
HU::ButtonInfo* buttonInfo = inputEvent.mutable_button()->add_button();
buttonInfo->set_is_pressed(isPressed);
buttonInfo->set_meta(0);
buttonInfo->set_long_press(false);
buttonInfo->set_long_press(longPress);
buttonInfo->set_scan_code(scanCode);
}
if (scrollAmount != 0)
@@ -206,7 +206,7 @@ void DesktopEventCallbacks::HandleNaviTurn(IHUConnectionThreadInterface& stream,
std::string image = request.image();
printf(event_name);
logv ("AA_CH_NAVI: %s, TurnSide: %d, TurnEvent:%d, TurnNumber: %d, TurnAngle: %d", event_name, request.turn_side(), request.turn_event(), request.turn_number(), request.turn_angle());
hex_dumpv("AA_CH_NAVI", 256, (unsigned char*)image.c_str(), image.length());
hex_dump("AA_CH_NAVI", 256, (unsigned char*)image.c_str(), image.length());
}
void DesktopEventCallbacks::HandleNaviTurnDistance(IHUConnectionThreadInterface& stream, const HU::NAVDistanceMessage &request){
logv ("AA_CH_NAVI: Distance: %d", request.distance());

0 comments on commit 831d74f

Please sign in to comment.