aboutsummaryrefslogtreecommitdiff
path: root/hw/stellaris_input.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-07-02 16:48:32 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-07-02 16:48:32 +0000
commit23e39294034e13d29a0707483542bab850d601b4 (patch)
treebf8c1fa3e39234083a06bd7b579476f870853b06 /hw/stellaris_input.c
parentab19b0ecfddf94ae2053b973cea5a58c8dac0363 (diff)
Save/restore for stellaris boards.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4824 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/stellaris_input.c')
-rw-r--r--hw/stellaris_input.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/hw/stellaris_input.c b/hw/stellaris_input.c
index 461868b2ee..aef4ce0c63 100644
--- a/hw/stellaris_input.c
+++ b/hw/stellaris_input.c
@@ -47,6 +47,31 @@ static void stellaris_gamepad_put_key(void * opaque, int keycode)
s->extension = 0;
}
+static void stellaris_gamepad_save(QEMUFile *f, void *opaque)
+{
+ gamepad_state *s = (gamepad_state *)opaque;
+ int i;
+
+ qemu_put_be32(f, s->extension);
+ for (i = 0; i < s->num_buttons; i++)
+ qemu_put_byte(f, s->buttons[i].pressed);
+}
+
+static int stellaris_gamepad_load(QEMUFile *f, void *opaque, int version_id)
+{
+ gamepad_state *s = (gamepad_state *)opaque;
+ int i;
+
+ if (version_id != 1)
+ return -EINVAL;
+
+ s->extension = qemu_get_be32(f);
+ for (i = 0; i < s->num_buttons; i++)
+ s->buttons[i].pressed = qemu_get_byte(f);
+
+ return 0;
+}
+
/* Returns an array 5 ouput slots. */
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
{
@@ -61,6 +86,8 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
}
s->num_buttons = n;
qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);
+ register_savevm("stellaris_gamepad", -1, 1,
+ stellaris_gamepad_save, stellaris_gamepad_load, s);
}