diff options
author | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-17 18:18:04 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-17 18:18:04 +0000 |
commit | 7c6ce4baedfcd0c39250f313926ef61dcb47d74c (patch) | |
tree | 9e507ec2d12d57fa66c415b832a4cac44ac781ba /hw/musicpal.c | |
parent | 4aa9aca4c25605bcc97a167f8f808a1ec5d34259 (diff) | |
download | qemu-7c6ce4baedfcd0c39250f313926ef61dcb47d74c.zip |
musicpal: Improve button handling (Jan Kiszka).
Looking at the hold-button-on-powerup thing, I came across some
improvable parts in the MusicPal's button handling. This patch allows
for repeated wheel events by keying the arrow keys pressed, corrects
some constant name, and introduces an explicitly maintained GPIO_ISR
state.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4476 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/musicpal.c')
-rw-r--r-- | hw/musicpal.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/hw/musicpal.c b/hw/musicpal.c index a9e576754a..56eb2dc879 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -59,6 +59,7 @@ #define MP_AUDIO_IRQ 30 static uint32_t gpio_in_state = 0xffffffff; +static uint32_t gpio_isr; static uint32_t gpio_out_state; static ram_addr_t sram_off; @@ -1280,11 +1281,10 @@ static uint32_t musicpal_read(void *opaque, target_phys_addr_t offset) (i2c_get_data(mixer_i2c) << MP_GPIO_I2C_DATA_BIT); return gpio_in_state >> 16; - /* This is a simplification of reality */ case MP_GPIO_ISR_LO: - return ~gpio_in_state & 0xFFFF; + return gpio_isr & 0xFFFF; case MP_GPIO_ISR_HI: - return ~gpio_in_state >> 16; + return gpio_isr >> 16; /* Workaround to allow loading the binary-only wlandrv.ko crap * from the original Freecom firmware. */ @@ -1324,7 +1324,7 @@ static void musicpal_write(void *opaque, target_phys_addr_t offset, } /* Keyboard codes & masks */ -#define KEY_PRESSED 0x80 +#define KEY_RELEASED 0x80 #define KEY_CODE 0x7f #define KEYCODE_TAB 0x0f @@ -1367,7 +1367,7 @@ static void musicpal_key_event(void *opaque, int keycode) event = MP_GPIO_WHEEL_VOL; break; } - else + else { switch (keycode & KEY_CODE) { case KEYCODE_F: event = MP_GPIO_BTN_FAVORITS; @@ -1385,12 +1385,19 @@ static void musicpal_key_event(void *opaque, int keycode) event = MP_GPIO_BTN_MENU; break; } + /* Do not repeat already pressed buttons */ + if (!(keycode & KEY_RELEASED) && !(gpio_in_state & event)) + event = 0; + } - if (keycode & KEY_PRESSED) - gpio_in_state |= event; - else if (gpio_in_state & event) { - gpio_in_state &= ~event; - qemu_irq_raise(irq); + if (event) { + if (keycode & KEY_RELEASED) { + gpio_in_state |= event; + } else { + gpio_in_state &= ~event; + gpio_isr = event; + qemu_irq_raise(irq); + } } kbd_extended = 0; |