/*! \file eventhandler.hcc * * \section generic This modules coordinates all events. Thus for example * when the mousehandler registers a 'click' we coordinate * the actions that follow that click. * * \section project Project information. * Project Graphic Equalizer\n * \author O.M. Schinagl * \date 20041110 * \version 0.1 * * \section copyright Copyright * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved * * \section history Change history * 20041110: O.M. Schinagl\n Initial version * ********************************************************************/ /******** System Includes *************/ #include #include "pal_master.hch" /******** Application Includes ********/ #include "configuration.hch" #include "mouse_shared.hch" #include "display_shared.hch" #include "eventhandler_shared.hch" #include "eventhandler.hch" #if HAVE_DEBUG #include "debug.hch" #endif extern chan unsigned 1 maskupdate_notification; /*! \fn void eventhandler_main(equalizer_levels_t *equalizer_levels, events_t *events, mousedata_t *mousedata); * \brief * * \param events_t *events pointer to struct with all events. * \param mousedata_t *mousedata pointer to struct with mouse data. * * \return Never Returns. * \retval void */ macro proc eventhandler_main(equalizer_levels, events, mousedata) { unsigned 5 volume_left; unsigned 1 newmaskupdate; for (;;) { maskupdate_notification ? newmaskupdate; print_string("Mask: ");print_hex_value(0 @ events.mask);print_eol(); print_string("state: ");print_hex_value(0 @ mousedata.state);print_eol(); /* * First we determine what mousestate we currently have. Then * we check where we are to decide what to do. */ switch (mousedata.state) { case MOUSE_STATE_ON_PRESS: /* * If the current mask equals the help button * we flip the help bit. */ if (BUTTON_HELP == events.mask) { events.help = !events.help; } else { delay; } break; case MOUSE_STATE_DOWN: /* * If we are in the volume area we update the * volume level for both channels. */ if (AREA_VOLUME_YAXIS == events.mask) { /* * Copy the current Y cursor position * to the events struct. This we then * later use for drawing purposes. */ events.volume_position = 0 @ mousedata.y; /* * Look the relative y-coordinate up in * the volumecontrol lookup table. */ volume_left = volumecontrol_table[((mousedata.y) -65) <- 6]; /* * We feel that volume gets softer the * closer it gets to the 0, and louder * as it approaches 0x1f. The SetVolume * RC200 call does this in an unnatural * reverse way. Therefor we reverse it. */ RC200AudioOutSetVolume(!volume_left, 0x1f -volume_left, 0x1f -volume_left); } else { delay; } if ((AREA_EQUALIZER_MIN <= events.mask) && (events.mask <= AREA_EQUALIZER_MAX)) { print_string("Ypos for eq: ");print_hex_value(0 @ mousedata.y);print_eol(); /* * Copy the current Y position into a * store for the current equalizer bar. */ events.equalizer_position[(events.mask -0x80) <- 7] = mousedata.y; /* * We look our current possition up in * the lookup table. We determin our * position via the current Y position * (minus an offset of course). We * store the result in the array of * equalizer levels. The index we get * from the current mask. * * TODO: lock equalizer store with a * semaphore! */ equalizer_levels.write[0 @ (events.mask -0x80) <- 7] = equalizer_table[((mousedata.y) -382) <- 7]; } else { delay; } break; } } } /* --- eventhandler_main() --- */ /* * Volume Control lookuptable. * TODO: This table is now hardcoded. To ensure full skinability this table * should be dynamically loaded. */ rom unsigned 5 volumecontrol_table[46] = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0}; /* * Equalizer lookuptabe. * TODO: This table is now hardcoded. To ensure full skinability this table * should be dynamically loaded. */ rom unsigned 4 equalizer_table[66] = {15, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0};