summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src/eventhandler.hcc
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-11-15 16:04:27 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-11-15 16:04:27 (GMT)
commitaee5707fed8541410816c0a1ce1f0aa17108b462 (patch)
treef2546786adb04fac0b9d9f3999bc27378fcd751d /Graphic_Equalizer/src/eventhandler.hcc
parent1db17be5a3ba68ffb5b9b23af6ac52a1b29e89ed (diff)
downloadTASS-aee5707fed8541410816c0a1ce1f0aa17108b462.zip
TASS-aee5707fed8541410816c0a1ce1f0aa17108b462.tar.gz
TASS-aee5707fed8541410816c0a1ce1f0aa17108b462.tar.bz2
Added display of active buttons.
Added equalizer preset storage.
Diffstat (limited to 'Graphic_Equalizer/src/eventhandler.hcc')
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc69
1 files changed, 50 insertions, 19 deletions
diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc
index f0583aa..1ec8468 100644
--- a/Graphic_Equalizer/src/eventhandler.hcc
+++ b/Graphic_Equalizer/src/eventhandler.hcc
@@ -25,6 +25,7 @@
/******** Application Includes ********/
#include "configuration.hch"
+#include "audio.hch"
#include "mouse_shared.hch"
#include "display_shared.hch"
#include "eventhandler_shared.hch"
@@ -36,7 +37,7 @@
extern chan unsigned 1 maskupdate_notification;
-/*! \fn void eventhandler_main(equalizer_levels_t *equalizer_levels, events_t *events, mousedata_t *mousedata);
+/*! \fn void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata);
* \brief
*
* \param events_t *events pointer to struct with all events.
@@ -45,66 +46,93 @@ extern chan unsigned 1 maskupdate_notification;
* \return Never Returns.
* \retval void
*/
-macro proc eventhandler_main(equalizer_levels, events, mousedata) {
+void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata) {
+ unsigned 8 equalizer_bands;
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) {
+ 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;
+ if (BUTTON_HELP == events->mask) {
+ events->help = !events->help;
} else {
delay;
}
+
+ if ((BUTTON_PRESET_1 <= events->mask) && (events->mask <= BUTTON_PRESET_6)) {
+ audiodata->active_preset = 0 @ (events->mask -BUTTON_PRESET_1);
+ for (equalizer_bands = 0; equalizer_bands != 128; equalizer_bands++) {
+ events->equalizer_position[equalizer_bands <- 7] = equalizer_table_inv[audiodata->equalizer_levels.write[(0 @ equalizer_bands) +(audiodata->active_preset << 7)]];
+ }
+ } else {
+ delay;
+ }
+
+ if ((BUTTON_1 <= events->mask) && (events->mask <= BUTTON_5)) {
+ events->equalizer_mode = (events->mask -BUTTON_1) <- 3;
+ } else {
+ delay;
+ }
+
+ if (BUTTON_LOG == events->mask) {
+ audiodata->log = !audiodata->log;
+ } 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) {
+ 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;
+ events->volume_position = 0 @ mousedata->y;
/*
* Look the relative y-coordinate up in
- * the volumecontrol lookup table.
+ * the volumecontrol lookup table. We
+ * make a local copy here because the
+ * RC200 call doesn't behave nicely
+ * when passing anything else.
*/
- volume_left = volumecontrol_table[((mousedata.y) -65) <- 6];
+ 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.
+ * reverse way. Therefor we fix 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();
+
+ if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) {
/*
* Copy the current Y position into a
* store for the current equalizer bar.
+ * The index is determined by the mask
+ * minus the maskoffset.
*/
- events.equalizer_position[(events.mask -0x80) <- 7] = mousedata.y;
+ events->equalizer_position[(events->mask -AREA_EQUALIZER_MIN) <- 7] = mousedata->y;
/*
* We look our current possition up in
* the lookup table. We determin our
@@ -112,12 +140,14 @@ macro proc eventhandler_main(equalizer_levels, events, mousedata) {
* (minus an offset of course). We
* store the result in the array of
* equalizer levels. The index we get
- * from the current mask.
+ * from the current mask. We add the
+ * size of our equalizer bands times
+ * the active preset.
*
* TODO: lock equalizer store with a
* semaphore!
*/
- equalizer_levels.write[0 @ (events.mask -0x80) <- 7] = equalizer_table[((mousedata.y) -382) <- 7];
+ audiodata->equalizer_levels.write[(( 0 @ events->mask -AREA_EQUALIZER_MIN) +(audiodata->active_preset << 7))] = equalizer_table[((mousedata->y) -382) <- 7];
} else {
delay;
}
@@ -136,8 +166,9 @@ macro proc eventhandler_main(equalizer_levels, events, mousedata) {
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.
+ * Equalizer lookuptabes.
* 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}; \ No newline at end of file
+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};
+rom unsigned 9 equalizer_table_inv[16] = {448, 444, 440, 436, 432, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 382}; \ No newline at end of file