aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-02-06 15:57:19 -0800
committerAndroid Code Review <code-review@android.com>2011-02-06 15:57:19 -0800
commit7e539645fe3aa7eb5f9f8e5659b324510ebed25e (patch)
treef3649dbb212fde1dfd3c7fee992d90489c0be025
parentc2e619f0887c0caeb64abaf4dce05edf5a5e5364 (diff)
parent799c6c0ecab548cf4716d14d1f077819cdde8e10 (diff)
downloadexternal_qemu-7e539645fe3aa7eb5f9f8e5659b324510ebed25e.zip
external_qemu-7e539645fe3aa7eb5f9f8e5659b324510ebed25e.tar.gz
external_qemu-7e539645fe3aa7eb5f9f8e5659b324510ebed25e.tar.bz2
Merge "events: Fix no-Dpad emulation when hw.keyboard=yes"
-rw-r--r--hw/goldfish_events_device.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/hw/goldfish_events_device.c b/hw/goldfish_events_device.c
index afc1724..f9775bf 100644
--- a/hw/goldfish_events_device.c
+++ b/hw/goldfish_events_device.c
@@ -328,6 +328,17 @@ events_set_bit(events_state* s, int type, int bit)
events_set_bits(s, type, bit, bit);
}
+static void
+events_clr_bit(events_state* s, int type, int bit)
+{
+ int ii = bit / 8;
+ if (ii < s->ev_bits[type].len) {
+ uint8_t* bits = s->ev_bits[type].bits;
+ uint8_t mask = 0x01U << (bit & 7);
+ bits[ii] &= ~mask;
+ }
+}
+
void events_dev_init(uint32_t base, qemu_irq irq)
{
events_state *s;
@@ -409,6 +420,18 @@ void events_dev_init(uint32_t base, qemu_irq irq)
*/
events_set_bits(s, EV_KEY, 1, 0xff);
events_set_bits(s, EV_KEY, 0x160, 0x1ff);
+
+ /* If there is a keyboard, but no DPad, we need to clear the
+ * corresponding bits. Doing this is simpler than trying to exclude
+ * the DPad values from the ranges above.
+ */
+ if (!config->hw_dPad) {
+ events_clr_bit(s, EV_KEY, KEY_DOWN);
+ events_clr_bit(s, EV_KEY, KEY_UP);
+ events_clr_bit(s, EV_KEY, KEY_LEFT);
+ events_clr_bit(s, EV_KEY, KEY_RIGHT);
+ events_clr_bit(s, EV_KEY, KEY_CENTER);
+ }
}
/* configure EV_REL array