Search
lxdream.org :: lxdream/src/hotkeys.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/hotkeys.c
changeset 1038:f220d18c0615
prev1024:c67f2d61ab97
next1072:d82e04e6d497
author nkeynes
date Thu Jun 25 01:15:25 2009 +0000 (10 years ago)
permissions -rw-r--r--
last change Move configuration to .lxdream/lxdreamrc on *nix, Library/Application Support/Lxdream on OS X
Create standard directories on first run
Add current quick state to config file
Refactor quick-state handling into dreamcast.c, and use the save directory
file annotate diff log raw
1.1 --- a/src/hotkeys.c Sat Jun 13 00:50:48 2009 +0000
1.2 +++ b/src/hotkeys.c Thu Jun 25 01:15:25 2009 +0000
1.3 @@ -35,9 +35,6 @@
1.4 static void hotkey_state_save_callback( void *mdev, uint32_t value, uint32_t pressure, gboolean isKeyDown );
1.5 static void hotkey_state_load_callback( void *mdev, uint32_t value, uint32_t pressure, gboolean isKeyDown );
1.6
1.7 -static char *set_current_state_filename(int filenum);
1.8 -
1.9 -static char *current_save_state;
1.10
1.11 struct lxdream_config_entry hotkeys_config[] = {
1.12 {"resume", N_("Resume emulation"), CONFIG_TYPE_KEY},
1.13 @@ -46,6 +43,7 @@
1.14 {"exit", N_("Exit emulator"), CONFIG_TYPE_KEY},
1.15 {"save", N_("Save current quick save"), CONFIG_TYPE_KEY},
1.16 {"load", N_("Load current quick save"), CONFIG_TYPE_KEY},
1.17 + {"state0", N_("Select quick save state 0"), CONFIG_TYPE_KEY},
1.18 {"state1", N_("Select quick save state 1"), CONFIG_TYPE_KEY},
1.19 {"state2", N_("Select quick save state 2"), CONFIG_TYPE_KEY},
1.20 {"state3", N_("Select quick save state 3"), CONFIG_TYPE_KEY},
1.21 @@ -58,15 +56,8 @@
1.22 {NULL, CONFIG_TYPE_NONE}
1.23 };
1.24
1.25 -void hotkeys_init() {
1.26 -
1.27 - char *home = getenv("HOME");
1.28 - char *save_path = g_strdup_printf("%s/.lxdream", home);
1.29 - mkdir(save_path, S_IRWXU);
1.30 - g_free(save_path);
1.31 -
1.32 - set_current_state_filename(1);
1.33 -
1.34 +void hotkeys_init()
1.35 +{
1.36 hotkeys_register_keys();
1.37 }
1.38
1.39 @@ -78,7 +69,7 @@
1.40 input_register_key(hotkeys_config[3].value, &hotkey_exit_callback, NULL, 0);
1.41 input_register_key(hotkeys_config[4].value, &hotkey_state_save_callback, NULL, 0);
1.42 input_register_key(hotkeys_config[5].value, &hotkey_state_load_callback, NULL, 0);
1.43 - for (int i = 0; i < 9; i++)
1.44 + for (int i = 0; i < 10; i++)
1.45 {
1.46 input_register_key(hotkeys_config[6 + i].value, &hotkey_state_select_callback, NULL, i);
1.47 }
1.48 @@ -92,7 +83,7 @@
1.49 input_unregister_key(hotkeys_config[3].value, &hotkey_exit_callback, NULL, 0);
1.50 input_unregister_key(hotkeys_config[4].value, &hotkey_state_save_callback, NULL, 0);
1.51 input_unregister_key(hotkeys_config[5].value, &hotkey_state_load_callback, NULL, 0);
1.52 - for (int i = 0; i < 9; i++)
1.53 + for (int i = 0; i < 10; i++)
1.54 {
1.55 input_unregister_key(hotkeys_config[6 + i].value, &hotkey_state_select_callback, NULL, i);
1.56 }
1.57 @@ -136,33 +127,22 @@
1.58 static void hotkey_state_select_callback( void *mdev, uint32_t value, uint32_t pressure, gboolean isKeyDown )
1.59 {
1.60 if (isKeyDown) {
1.61 - INFO("state select callback called (%d)", value);
1.62 - assert(value > 0 && value <= 9);
1.63 - set_current_state_filename(value);
1.64 + dreamcast_set_quick_state(value);
1.65 }
1.66 }
1.67
1.68 static void hotkey_state_save_callback( void *mdev, uint32_t value, uint32_t pressure, gboolean isKeyDown )
1.69 {
1.70 if (isKeyDown) {
1.71 - if (current_save_state != NULL)
1.72 - dreamcast_save_state(current_save_state);
1.73 + dreamcast_quick_save();
1.74 }
1.75 }
1.76
1.77 static void hotkey_state_load_callback( void *mdev, uint32_t value, uint32_t pressure, gboolean isKeyDown )
1.78 {
1.79 if (isKeyDown) {
1.80 - if (current_save_state != NULL)
1.81 - dreamcast_load_state(current_save_state);
1.82 + dreamcast_quick_load();
1.83 }
1.84 }
1.85
1.86 -static char *set_current_state_filename(int filenum)
1.87 -{
1.88 - char *home = getenv("HOME");
1.89 - if (current_save_state != NULL)
1.90 - g_free(current_save_state);
1.91 - current_save_state = g_strdup_printf("%s/.lxdream/quicksave%d.dst", home, filenum);
1.92 -}
1.93
.