mirror of https://github.com/xqemu/xqemu.git
vmstate: port stellaris gamepad
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
0c067bbb26
commit
4483c7ac31
|
@ -13,7 +13,7 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
int keycode;
|
int keycode;
|
||||||
int pressed;
|
uint8_t pressed;
|
||||||
} gamepad_button;
|
} gamepad_button;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -47,30 +47,29 @@ static void stellaris_gamepad_put_key(void * opaque, int keycode)
|
||||||
s->extension = 0;
|
s->extension = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stellaris_gamepad_save(QEMUFile *f, void *opaque)
|
static const VMStateDescription vmstate_stellaris_button = {
|
||||||
{
|
.name = "stellaris_button",
|
||||||
gamepad_state *s = (gamepad_state *)opaque;
|
.version_id = 0,
|
||||||
int i;
|
.minimum_version_id = 0,
|
||||||
|
.minimum_version_id_old = 0,
|
||||||
qemu_put_be32(f, s->extension);
|
.fields = (VMStateField[]) {
|
||||||
for (i = 0; i < s->num_buttons; i++)
|
VMSTATE_UINT8(pressed, gamepad_button),
|
||||||
qemu_put_byte(f, s->buttons[i].pressed);
|
VMSTATE_END_OF_LIST()
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static int stellaris_gamepad_load(QEMUFile *f, void *opaque, int version_id)
|
static const VMStateDescription vmstate_stellaris_gamepad = {
|
||||||
{
|
.name = "stellaris_gamepad",
|
||||||
gamepad_state *s = (gamepad_state *)opaque;
|
.version_id = 1,
|
||||||
int i;
|
.minimum_version_id = 1,
|
||||||
|
.minimum_version_id_old = 1,
|
||||||
if (version_id != 1)
|
.fields = (VMStateField[]) {
|
||||||
return -EINVAL;
|
VMSTATE_INT32(extension, gamepad_state),
|
||||||
|
VMSTATE_STRUCT_VARRAY_INT32(buttons, gamepad_state, num_buttons, 0,
|
||||||
s->extension = qemu_get_be32(f);
|
vmstate_stellaris_button, gamepad_button),
|
||||||
for (i = 0; i < s->num_buttons; i++)
|
VMSTATE_END_OF_LIST()
|
||||||
s->buttons[i].pressed = qemu_get_byte(f);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* Returns an array 5 ouput slots. */
|
/* Returns an array 5 ouput slots. */
|
||||||
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
|
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
|
||||||
|
@ -86,6 +85,5 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
|
||||||
}
|
}
|
||||||
s->num_buttons = n;
|
s->num_buttons = n;
|
||||||
qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);
|
qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);
|
||||||
register_savevm(NULL, "stellaris_gamepad", -1, 1,
|
vmstate_register(NULL, -1, &vmstate_stellaris_gamepad, s);
|
||||||
stellaris_gamepad_save, stellaris_gamepad_load, s);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue