4 * Handles hotkeys for pause/continue, save states, quit, etc
6 * Copyright (c) 2009 wahrhaft
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
24 #include "dreamcast.h"
30 static void hotkey_key_callback( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown );
31 static gboolean hotkey_config_changed( void *data, lxdream_config_group_t group, unsigned key,
32 const gchar *oldval, const gchar *newval );
40 #define TAG_SELECT(i) (6+(i))
42 struct lxdream_config_group hotkeys_group = {
43 "hotkeys", input_keygroup_changed, hotkey_key_callback, NULL, {
44 {"resume", N_("Resume emulation"), CONFIG_TYPE_KEY, NULL, TAG_RESUME },
45 {"stop", N_("Stop emulation"), CONFIG_TYPE_KEY, NULL, TAG_STOP },
46 {"reset", N_("Reset emulator"), CONFIG_TYPE_KEY, NULL, TAG_RESET },
47 {"exit", N_("Exit emulator"), CONFIG_TYPE_KEY, NULL, TAG_EXIT },
48 {"save", N_("Save current quick save"), CONFIG_TYPE_KEY, NULL, TAG_SAVE },
49 {"load", N_("Load current quick save"), CONFIG_TYPE_KEY, NULL, TAG_LOAD },
50 {"state0", N_("Select quick save state 0"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(0) },
51 {"state1", N_("Select quick save state 1"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(1) },
52 {"state2", N_("Select quick save state 2"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(2) },
53 {"state3", N_("Select quick save state 3"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(3) },
54 {"state4", N_("Select quick save state 4"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(4) },
55 {"state5", N_("Select quick save state 5"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(5) },
56 {"state6", N_("Select quick save state 6"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(6) },
57 {"state7", N_("Select quick save state 7"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(7) },
58 {"state8", N_("Select quick save state 8"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(8) },
59 {"state9", N_("Select quick save state 9"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(9) },
60 {NULL, CONFIG_TYPE_NONE}} };
64 hotkeys_register_keys();
67 void hotkeys_register_keys()
69 input_register_keygroup( &hotkeys_group );
72 void hotkeys_unregister_keys()
74 input_unregister_keygroup( &hotkeys_group );
77 lxdream_config_group_t hotkeys_get_config()
79 return &hotkeys_group;
82 static void hotkey_key_callback( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown )
87 if( !dreamcast_is_running() )
88 gui_do_later(dreamcast_run);
91 if( dreamcast_is_running() )
92 gui_do_later(dreamcast_stop);
102 dreamcast_quick_save();
105 dreamcast_quick_load();
108 dreamcast_set_quick_state(value- TAG_SELECT(0) );
.