/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id: $
 *
 * Copyright (C) 2002 Philipp Pertermann
 *
 * All files in this archive are subject to the GNU General Public License.
 * See the file COPYING in the source tree root for full license agreement.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied. 
 *
 ****************************************************************************/

#include <string.h>
#include "key_scheme.h"
#include "commands.h"

struct key_command key_command_table[KEY_COMMAND_TABLE_SIZE];

/* this file should be generated during the build process 
 * similar to the lang.c file 
 * In the source a file for that all available commands must be registered.
 * From the description of the command an automatic reference manual could
 * be generated. The source file could have the following format:
 *
 * id: SPLIT_X
 * desc: Specifies the position of the cursor in 
 *       the split editor. The values are screen coordinates
 *       and range from 0 <= value < LCD_WIDTH.
 * action: NULL
 * set_value: set_split_x
 * get_value: get_split_x
 * get_text: NULL
 * set_text: NULL
 *
 */

/* I fear that these extern declarations must be genearated, too */
/* start of generated section */
extern void set_split_x(int value);
extern int  get_split_x(void);
extern void split_zoom_in(void);
extern void split_zoom_out(void);
extern void set_loop_mode(int value);
extern int  get_loop_mode(void);
extern void mpeg_pause(void);
extern void mpeg_resume(void);
extern void mpeg_set_pitch(int percent);
extern void split_quit(void);
/* end of generated section */

/**
 * All available commands must be registered here. It should be done in
 */
void init_commands(void) {
    int i;

    /* blank the table */
    for (i = 0; i < KEY_COMMAND_TABLE_SIZE; i++) {
        key_command_table[i].action = NULL;
        key_command_table[i].get_value = NULL;
        key_command_table[i].set_value = NULL;
        key_command_table[i].get_text = NULL;
        key_command_table[i].set_text = NULL;
    }

    /* start of another generated section */

    key_command_table[SPLIT_X].action = NULL;
    key_command_table[SPLIT_X].get_value = get_split_x;
    key_command_table[SPLIT_X].set_value = set_split_x;
    key_command_table[SPLIT_X].get_text = NULL;
    key_command_table[SPLIT_X].set_text = NULL;

    key_command_table[SPLIT_ZOOM_IN].action = split_zoom_in;
    key_command_table[SPLIT_ZOOM_IN].get_value = NULL;
    key_command_table[SPLIT_ZOOM_IN].set_value = NULL;
    key_command_table[SPLIT_ZOOM_IN].get_text = NULL;
    key_command_table[SPLIT_ZOOM_IN].set_text = NULL;

    key_command_table[SPLIT_ZOOM_OUT].action = split_zoom_out;
    key_command_table[SPLIT_ZOOM_OUT].get_value = NULL;
    key_command_table[SPLIT_ZOOM_OUT].set_value = NULL;
    key_command_table[SPLIT_ZOOM_OUT].get_text = NULL;
    key_command_table[SPLIT_ZOOM_OUT].set_text = NULL;

    key_command_table[SPLIT_LOOP_MODE].action = NULL;
    key_command_table[SPLIT_LOOP_MODE].get_value = get_loop_mode;
    key_command_table[SPLIT_LOOP_MODE].set_value = set_loop_mode;
    key_command_table[SPLIT_LOOP_MODE].get_text = NULL;
    key_command_table[SPLIT_LOOP_MODE].set_text = NULL;

    key_command_table[MPEG_PAUSE].action = mpeg_pause;
    key_command_table[MPEG_PAUSE].get_value = NULL;
    key_command_table[MPEG_PAUSE].set_value = NULL;
    key_command_table[MPEG_PAUSE].get_text = NULL;
    key_command_table[MPEG_PAUSE].set_text = NULL;

    key_command_table[MPEG_RESUME].action = mpeg_resume;
    key_command_table[MPEG_RESUME].get_value = NULL;
    key_command_table[MPEG_RESUME].set_value = NULL;
    key_command_table[MPEG_RESUME].get_text = NULL;
    key_command_table[MPEG_RESUME].set_text = NULL;

    key_command_table[MPEG_SET_PITCH].action = NULL;
    key_command_table[MPEG_SET_PITCH].get_value = NULL;
    key_command_table[MPEG_SET_PITCH].set_value = mpeg_set_pitch;
    key_command_table[MPEG_SET_PITCH].get_text = NULL;
    key_command_table[MPEG_SET_PITCH].set_text = NULL;

    key_command_table[SPLIT_QUIT].action = split_quit;
    key_command_table[SPLIT_QUIT].get_value = NULL;
    key_command_table[SPLIT_QUIT].set_value = NULL;
    key_command_table[SPLIT_QUIT].get_text = NULL;
    key_command_table[SPLIT_QUIT].set_text = NULL;
    
    /* end of the other generated section */

}

