7c76f397fd
Now that we have converted to qdev, we can use the newer qemu_input_handler_register() API rather than the legacy qemu_add_kbd_event_handler(). Since we only have one user, take the opportunity to convert from scancodes to QCodes, rather than using qemu_input_key_value_to_scancode() (which adds an 0xe0 prefix and encodes up/down indication in the scancode, which our old handler function then had to reverse). That lets us drop the old state field which was tracking whether we were halfway through a two-byte scancode. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20231030114802.3671871-7-peter.maydell@linaro.org
38 lines
937 B
C
38 lines
937 B
C
/*
|
|
* Gamepad style buttons connected to IRQ/GPIO lines
|
|
*
|
|
* Copyright (c) 2007 CodeSourcery.
|
|
* Written by Paul Brook
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#ifndef HW_INPUT_STELLARIS_GAMEPAD_H
|
|
#define HW_INPUT_STELLARIS_GAMEPAD_H
|
|
|
|
#include "hw/sysbus.h"
|
|
#include "qom/object.h"
|
|
|
|
/*
|
|
* QEMU interface:
|
|
* + QOM array property "keycodes": uint32_t QEMU keycodes to handle
|
|
* (these are QCodes, ie the Q_KEY_* values)
|
|
* + unnamed GPIO outputs: one per keycode, in the same order as the
|
|
* "keycodes" array property entries; asserted when key is down
|
|
*/
|
|
|
|
#define TYPE_STELLARIS_GAMEPAD "stellaris-gamepad"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(StellarisGamepad, STELLARIS_GAMEPAD)
|
|
|
|
struct StellarisGamepad {
|
|
SysBusDevice parent_obj;
|
|
|
|
uint32_t num_buttons;
|
|
qemu_irq *irqs;
|
|
uint32_t *keycodes;
|
|
uint8_t *pressed;
|
|
};
|
|
|
|
#endif
|