| * Gamepad style buttons connected to IRQ/GPIO lines |
| * Copyright (c) 2007 CodeSourcery. |
| * This code is licenced under the GPL. |
| static void stellaris_gamepad_put_key(void * opaque, int keycode) |
| gamepad_state *s = (gamepad_state *)opaque; |
| if (keycode == 0xe0 && !s->extension) { |
| down = (keycode & 0x80) == 0; |
| keycode = (keycode & 0x7f) | s->extension; |
| for (i = 0; i < s->num_buttons; i++) { |
| if (s->buttons[i].keycode == keycode |
| && s->buttons[i].pressed != down) { |
| s->buttons[i].pressed = down; |
| qemu_set_irq(s->buttons[i].irq, down); |
| /* Returns an array 5 ouput slots. */ |
| void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) |
| s = (gamepad_state *)qemu_mallocz(sizeof (gamepad_state)); |
| s->buttons = (gamepad_button *)qemu_mallocz(n * sizeof (gamepad_button)); |
| for (i = 0; i < n; i++) { |
| s->buttons[i].irq = irq[i]; |
| s->buttons[i].keycode = keycode[i]; |
| qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s); |