Commit 38a34e1d7aa1ac64c2615952ee732da47eee9f14
1 parent
fe71e81a
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
Showing
2 changed files
with
37 additions
and
6 deletions
hw/omap.c
... | ... | @@ -2841,12 +2841,11 @@ static void omap_mpuio_kbd_update(struct omap_mpuio_s *s) |
2841 | 2841 | int i; |
2842 | 2842 | uint8_t *row, rows = 0, cols = ~s->cols; |
2843 | 2843 | |
2844 | - for (row = s->buttons + 4, i = 1 << 5; i; row --, i >>= 1) | |
2844 | + for (row = s->buttons + 4, i = 1 << 4; i; row --, i >>= 1) | |
2845 | 2845 | if (*row & cols) |
2846 | - s->row_latch |= i; | |
2846 | + rows |= i; | |
2847 | 2847 | |
2848 | - if (rows && ~s->kbd_mask && s->clk) | |
2849 | - qemu_irq_raise(s->kbd_irq); | |
2848 | + qemu_set_irq(s->kbd_irq, rows && ~s->kbd_mask && s->clk); | |
2850 | 2849 | s->row_latch = rows ^ 0x1f; |
2851 | 2850 | } |
2852 | 2851 | |
... | ... | @@ -3002,6 +3001,7 @@ void omap_mpuio_reset(struct omap_mpuio_s *s) |
3002 | 3001 | s->latch = 0; |
3003 | 3002 | s->ints = 0; |
3004 | 3003 | s->row_latch = 0x1f; |
3004 | + s->clk = 1; | |
3005 | 3005 | } |
3006 | 3006 | |
3007 | 3007 | 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) |
3056 | 3056 | __FUNCTION__, col, row); |
3057 | 3057 | |
3058 | 3058 | if (down) |
3059 | - s->buttons[row] = 1 << col; | |
3059 | + s->buttons[row] |= 1 << col; | |
3060 | 3060 | else |
3061 | - s->buttons[row] = ~(1 << col); | |
3061 | + s->buttons[row] &= ~(1 << col); | |
3062 | 3062 | |
3063 | 3063 | omap_mpuio_kbd_update(s); |
3064 | 3064 | } | ... | ... |
hw/palm.c
... | ... | @@ -61,6 +61,35 @@ static void palmte_microwire_setup(struct omap_mpu_state_s *cpu) |
61 | 61 | { |
62 | 62 | } |
63 | 63 | |
64 | +static struct { | |
65 | + int row; | |
66 | + int column; | |
67 | +} palmte_keymap[0x80] = { | |
68 | + [0 ... 0x7f] = { -1, -1 }, | |
69 | + [0x3b] = { 0, 0 }, /* F1 -> Calendar */ | |
70 | + [0x3c] = { 1, 0 }, /* F2 -> Contacts */ | |
71 | + [0x3d] = { 2, 0 }, /* F3 -> Tasks List */ | |
72 | + [0x3e] = { 3, 0 }, /* F4 -> Note Pad */ | |
73 | + [0x01] = { 4, 0 }, /* Esc -> Power */ | |
74 | + [0x4b] = { 0, 1 }, /* Left */ | |
75 | + [0x50] = { 1, 1 }, /* Down */ | |
76 | + [0x48] = { 2, 1 }, /* Up */ | |
77 | + [0x4d] = { 3, 1 }, /* Right */ | |
78 | + [0x4c] = { 4, 1 }, /* Centre */ | |
79 | + [0x39] = { 4, 1 }, /* Spc -> Centre */ | |
80 | +}; | |
81 | + | |
82 | +static void palmte_button_event(void *opaque, int keycode) | |
83 | +{ | |
84 | + struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque; | |
85 | + | |
86 | + if (palmte_keymap[keycode & 0x7f].row != -1) | |
87 | + omap_mpuio_key(cpu->mpuio, | |
88 | + palmte_keymap[keycode & 0x7f].row, | |
89 | + palmte_keymap[keycode & 0x7f].column, | |
90 | + !(keycode & 0x80)); | |
91 | +} | |
92 | + | |
64 | 93 | static void palmte_init(int ram_size, int vga_ram_size, int boot_device, |
65 | 94 | DisplayState *ds, const char **fd_filename, int snapshot, |
66 | 95 | 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, |
101 | 130 | |
102 | 131 | palmte_microwire_setup(cpu); |
103 | 132 | |
133 | + qemu_add_kbd_event_handler(palmte_button_event, cpu); | |
134 | + | |
104 | 135 | /* Setup initial (reset) machine state */ |
105 | 136 | if (nb_option_roms) { |
106 | 137 | rom_size = get_image_size(option_rom[0]); | ... | ... |