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 );
38 #define TAG_SELECT(i) (6+(i))
40 struct lxdream_config_group hotkeys_group = {
41 "hotkeys", input_keygroup_changed, hotkey_key_callback, NULL, {
42 {"resume", N_("Resume emulation"), CONFIG_TYPE_KEY, NULL, TAG_RESUME },
43 {"stop", N_("Stop emulation"), CONFIG_TYPE_KEY, NULL, TAG_STOP },
44 {"reset", N_("Reset emulator"), CONFIG_TYPE_KEY, NULL, TAG_RESET },
45 {"exit", N_("Exit emulator"), CONFIG_TYPE_KEY, NULL, TAG_EXIT },
46 {"save", N_("Save current quick save"), CONFIG_TYPE_KEY, NULL, TAG_SAVE },
47 {"load", N_("Load current quick save"), CONFIG_TYPE_KEY, NULL, TAG_LOAD },
48 {"state0", N_("Select quick save state 0"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(0) },
49 {"state1", N_("Select quick save state 1"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(1) },
50 {"state2", N_("Select quick save state 2"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(2) },
51 {"state3", N_("Select quick save state 3"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(3) },
52 {"state4", N_("Select quick save state 4"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(4) },
53 {"state5", N_("Select quick save state 5"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(5) },
54 {"state6", N_("Select quick save state 6"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(6) },
55 {"state7", N_("Select quick save state 7"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(7) },
56 {"state8", N_("Select quick save state 8"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(8) },
57 {"state9", N_("Select quick save state 9"), CONFIG_TYPE_KEY, NULL, TAG_SELECT(9) },
58 {NULL, CONFIG_TYPE_NONE}} };
62 hotkeys_register_keys();
65 void hotkeys_register_keys()
67 input_register_keygroup( &hotkeys_group );
70 void hotkeys_unregister_keys()
72 input_unregister_keygroup( &hotkeys_group );
75 lxdream_config_group_t hotkeys_get_config()
77 return &hotkeys_group;
80 static void hotkey_key_callback( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown )
85 if( !dreamcast_is_running() )
86 gui_do_later(dreamcast_run);
89 if( dreamcast_is_running() )
90 gui_do_later(dreamcast_stop);
100 dreamcast_quick_save();
103 dreamcast_quick_load();
106 dreamcast_set_quick_state(value- TAG_SELECT(0) );
.