/* Include Files */
#include "KTag.h"

static void OnFocus(bool IncludeDetails);
static MenuItem_T const * OnSelect();
static void OnIncrement();
static void OnDecrement();
static void ToggleHanded();

const MenuItem_T HandedMenuItem =
{
    .OnFocus = OnFocus,
    .OnSelect = OnSelect,
    .OnIncrement = OnIncrement,
    .OnDecrement = OnDecrement
    
};

static void OnFocus(bool IncludeDetails)
{
    if (NVM_IS_RIGHT_HANDED == true)
    {
        AudioAction_T audio_action = {.ID = AUDIO_PLAY_RIGHT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
        xQueueSend(xQueueAudio, &audio_action, 0);
    }
    else
    {
        AudioAction_T audio_action = {.ID = AUDIO_PLAY_LEFT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
        xQueueSend(xQueueAudio, &audio_action, 0);
    }
}

static MenuItem_T const * OnSelect()
{
    AudioAction_T audio_action = {.ID = AUDIO_PLAY_SELECTION_INDICATOR, .Data = (void *)0x00};
    xQueueSend(xQueueAudio, &audio_action, 0);
    return NULL;
}

static void OnIncrement()
{
    ToggleHanded();
}

static void OnDecrement()
{
    ToggleHanded();
}

static void ToggleHanded()
{
    if (NVM_IS_RIGHT_HANDED == true)
    {
        NVM_IS_RIGHT_HANDED = false;
        AudioAction_T audio_action = {.ID = AUDIO_PLAY_LEFT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
        xQueueSend(xQueueAudio, &audio_action, 0);
    }
    else
    {
        NVM_IS_RIGHT_HANDED = true;
        AudioAction_T audio_action = {.ID = AUDIO_PLAY_RIGHT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
        xQueueSend(xQueueAudio, &audio_action, 0);
    }
}
