summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2007-10-28 18:29:04 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2007-10-28 18:29:04 +0000
commit38a34e1d7aa1ac64c2615952ee732da47eee9f14 (patch)
treebb5721fe771542ee76e038cc2caa640173bdc72e
parentfe71e81aba0f0cc10cd807a1b3f7a2978db255ce (diff)
downloadfocaccia-qemu-38a34e1d7aa1ac64c2615952ee732da47eee9f14.tar.gz
focaccia-qemu-38a34e1d7aa1ac64c2615952ee732da47eee9f14.zip
Add PalmT|E matrix keypad connected to OMAP GPIOs.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3470 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/omap.c12
-rw-r--r--hw/palm.c31
2 files changed, 37 insertions, 6 deletions
diff --git a/hw/omap.c b/hw/omap.c
index a1e8598bb7..9c0e570aea 100644
--- a/hw/omap.c
+++ b/hw/omap.c
@@ -2841,12 +2841,11 @@ static void omap_mpuio_kbd_update(struct omap_mpuio_s *s)
     int i;
     uint8_t *row, rows = 0, cols = ~s->cols;
 
-    for (row = s->buttons + 4, i = 1 << 5; i; row --, i >>= 1)
+    for (row = s->buttons + 4, i = 1 << 4; i; row --, i >>= 1)
         if (*row & cols)
-            s->row_latch |= i;
+            rows |= i;
 
-    if (rows && ~s->kbd_mask && s->clk)
-        qemu_irq_raise(s->kbd_irq);
+    qemu_set_irq(s->kbd_irq, rows && ~s->kbd_mask && s->clk);
     s->row_latch = rows ^ 0x1f;
 }
 
@@ -3002,6 +3001,7 @@ void omap_mpuio_reset(struct omap_mpuio_s *s)
     s->latch = 0;
     s->ints = 0;
     s->row_latch = 0x1f;
+    s->clk = 1;
 }
 
 static void omap_mpuio_onoff(void *opaque, int line, int on)
@@ -3056,9 +3056,9 @@ void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down)
                         __FUNCTION__, col, row);
 
     if (down)
-        s->buttons[row] = 1 << col;
+        s->buttons[row] |= 1 << col;
     else
-        s->buttons[row] = ~(1 << col);
+        s->buttons[row] &= ~(1 << col);
 
     omap_mpuio_kbd_update(s);
 }
diff --git a/hw/palm.c b/hw/palm.c
index 623fcd6482..ead9cfd453 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -61,6 +61,35 @@ static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
 {
 }
 
+static struct {
+    int row;
+    int column;
+} palmte_keymap[0x80] = {
+    [0 ... 0x7f] = { -1, -1 },
+    [0x3b] = { 0, 0 },	/* F1	-> Calendar */
+    [0x3c] = { 1, 0 },	/* F2	-> Contacts */
+    [0x3d] = { 2, 0 },	/* F3	-> Tasks List */
+    [0x3e] = { 3, 0 },	/* F4	-> Note Pad */
+    [0x01] = { 4, 0 },	/* Esc	-> Power */
+    [0x4b] = { 0, 1 },	/* 	   Left */
+    [0x50] = { 1, 1 },	/* 	   Down */
+    [0x48] = { 2, 1 },	/*	   Up */
+    [0x4d] = { 3, 1 },	/*	   Right */
+    [0x4c] = { 4, 1 },	/* 	   Centre */
+    [0x39] = { 4, 1 },	/* Spc	-> Centre */
+};
+
+static void palmte_button_event(void *opaque, int keycode)
+{
+    struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque;
+
+    if (palmte_keymap[keycode & 0x7f].row != -1)
+        omap_mpuio_key(cpu->mpuio,
+                        palmte_keymap[keycode & 0x7f].row,
+                        palmte_keymap[keycode & 0x7f].column,
+                        !(keycode & 0x80));
+}
+
 static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
                 DisplayState *ds, const char **fd_filename, int snapshot,
                 const char *kernel_filename, const char *kernel_cmdline,
@@ -101,6 +130,8 @@ static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
 
     palmte_microwire_setup(cpu);
 
+    qemu_add_kbd_event_handler(palmte_button_event, cpu);
+
     /* Setup initial (reset) machine state */
     if (nb_option_roms) {
         rom_size = get_image_size(option_rom[0]);