void menu_options_joysticks_select( int action ) { widget_select_t info; int *setting, error; setting = NULL; switch( action - 1 ) { case 0: setting = &( settings_current.joystick_1_output ); break; case 1: setting = &( settings_current.joystick_2_output ); break; case JOYSTICK_KEYBOARD: setting = &( settings_current.joystick_keyboard_output ); break; } info.title = "Select joystick"; info.options = joystick_name; info.count = JOYSTICK_TYPE_COUNT; info.current = *setting; error = widget_do( WIDGET_TYPE_SELECT, &info ); if( error ) return; if( info.result != -1 ) *setting = info.result; }
scaler_type menu_get_scaler( scaler_available_fn selector ) { size_t count, i; const char *options[ SCALER_NUM ]; widget_select_t info; int error; count = 0; info.current = 0; for( i = 0; i < SCALER_NUM; i++ ) if( selector( i ) ) { if( current_scaler == i ) info.current = count; options[ count++ ] = scaler_name( i ); } info.title = "Select scaler"; info.options = options; info.count = count; error = widget_do( WIDGET_TYPE_SELECT, &info ); if( error ) return SCALER_NUM; if( info.result == -1 ) return SCALER_NUM; for( i = 0; i < SCALER_NUM; i++ ) if( selector( i ) && !info.result-- ) return i; ui_error( UI_ERROR_ERROR, "widget_select_scaler: ran out of scalers" ); fuse_abort(); }
void menu_help_keyboard( int action ) { int error, fd; utils_file file; widget_picture_data info; static const char *filename = "keyboard.scr"; fd = utils_find_auxiliary_file( filename, UTILS_AUXILIARY_LIB ); if( fd == -1 ) { ui_error( UI_ERROR_ERROR, "couldn't find keyboard picture ('%s')", filename ); return; } error = utils_read_fd( fd, filename, &file ); if( error ) return; if( file.length != 6912 ) { ui_error( UI_ERROR_ERROR, "keyboard picture ('%s') is not 6912 bytes long", filename ); utils_close_file( &file ); return; } info.filename = filename; info.screen = file.buffer; info.border = 0; widget_do( WIDGET_TYPE_PICTURE, &info ); if( utils_close_file( &file ) ) return; }
void menu_machine_reset( int action ) { if( widget_do( WIDGET_TYPE_QUERY, "Reset machine?" ) || !widget_query.confirm ) return; widget_end_all( WIDGET_FINISHED_OK ); machine_reset( action ); }
void menu_file_exit( int action ) { if( widget_do( WIDGET_TYPE_QUERY, "Exit Fuse?" ) || !widget_query.confirm ) return; if( menu_check_media_changed() ) return; fuse_exiting = 1; widget_end_all( WIDGET_FINISHED_OK ); }
/* Options/Select ROMs/<type> */ int menu_select_roms_with_title( const char *title, size_t start, size_t count ) { widget_roms_info info; info.title = title; info.start = start; info.count = count; info.initialised = 0; return widget_do( WIDGET_TYPE_ROM, &info ); }
void menu_machine_reset( int action ) { int hard_reset = action; const char *message = "Reset?"; if( hard_reset ) message = "Hard reset?"; if( widget_do( WIDGET_TYPE_QUERY, message ) || !widget_query.confirm ) return; widget_end_all( WIDGET_FINISHED_OK ); machine_reset( hard_reset ); }
void menu_machine_select( int action ) { widget_select_t info; char **options, *buffer; size_t i; int error; libspectrum_machine new_machine; options = malloc( machine_count * sizeof( const char * ) ); if( !options ) { ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); return; } buffer = malloc( 40 * machine_count ); if( !buffer ) { ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); free( options ); return; } for( i = 0; i < machine_count; i++ ) { options[i] = &buffer[ i * 40 ]; snprintf( options[i], 40, "%s", libspectrum_machine_name( machine_types[i]->machine ) ); if( machine_current->machine == machine_types[i]->machine ) info.current = i; } info.title = "Select machine"; info.options = (const char**)options; info.count = machine_count; info.finish_all = 1; error = widget_do( WIDGET_TYPE_SELECT, &info ); free( buffer ); free( options ); if( error ) return; if( info.result == -1 ) return; new_machine = machine_types[ info.result ]->machine; if( machine_current->machine != new_machine ) machine_select( new_machine ); }
void menu_help_keyboard( int action ) { utils_file screen; widget_picture_data info; static const char *filename = "keyboard.scr"; if( utils_read_screen( filename, &screen ) ) { return; } info.filename = filename; info.screen = screen.buffer; info.border = 0; widget_do( WIDGET_TYPE_PICTURE, &info ); utils_close_file( &screen ); }
void menu_machine_debugger( int action ) { debugger_mode = DEBUGGER_MODE_HALTED; widget_do( WIDGET_TYPE_DEBUGGER, NULL ); }
void menu_options_peripherals_general( int action ) { widget_do( WIDGET_TYPE_PERIPHERALS_GENERAL, NULL ); }
void menu_options_movie( int action ) { widget_do( WIDGET_TYPE_MOVIE, NULL ); }
void menu_options_rzx( int action ) { widget_do( WIDGET_TYPE_RZX, NULL ); }
void menu_media_tape_browse( int action ) { widget_do( WIDGET_TYPE_BROWSE, NULL ); }
void menu_options_general( int action ) { widget_do( WIDGET_TYPE_GENERAL, NULL ); }
static int keypress( const input_event_key_t *event ) { int swallow; const keyboard_spectrum_keys_t *ptr; #ifdef USE_WIDGET if( widget_level >= 0 ) { widget_keyhandler( event->native_key ); return 0; } #endif /* #ifdef USE_WIDGET */ /* Escape => ask UI to end mouse grab, return if grab ended */ if( event->native_key == INPUT_KEY_Escape && ui_mouse_grabbed ) { ui_mouse_grabbed = ui_mouse_release( 0 ); if( !ui_mouse_grabbed ) return 0; } swallow = 0; /* Joystick emulation via keyboard keys */ if ( event->spectrum_key == settings_current.joystick_keyboard_up ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_UP , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_down ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_DOWN , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_left ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_LEFT , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_right ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_RIGHT, 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_fire ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_FIRE , 1 ); } if( swallow ) return 0; ptr = keyboard_get_spectrum_keys( event->spectrum_key ); if( ptr ) { keyboard_press( ptr->key1 ); keyboard_press( ptr->key2 ); } #ifdef USE_WIDGET switch( event->native_key ) { case INPUT_KEY_F1: fuse_emulation_pause(); widget_do( WIDGET_TYPE_MENU, &widget_menu ); fuse_emulation_unpause(); break; case INPUT_KEY_F2: fuse_emulation_pause(); menu_file_savesnapshot( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F3: fuse_emulation_pause(); menu_file_open( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F4: fuse_emulation_pause(); menu_options_general( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F5: fuse_emulation_pause(); menu_machine_reset( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F6: fuse_emulation_pause(); menu_media_tape_write( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F7: fuse_emulation_pause(); menu_media_tape_open( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F8: menu_media_tape_play( 0 ); break; case INPUT_KEY_F9: fuse_emulation_pause(); menu_machine_select( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F10: fuse_emulation_pause(); menu_file_exit( 0 ); fuse_emulation_unpause(); break; default: break; /* Remove gcc warning */ } #endif /* #ifdef USE_WIDGET */ return 0; }
void menu_options_diskoptions( int action ) { widget_do( WIDGET_TYPE_DISKOPTIONS, NULL ); }
void widget_menu_keyhandler( input_key key ) { widget_menu_entry *ptr; int new_highlight_line = 0; int cursor_pressed = 0; switch( key ) { #if 0 case INPUT_KEY_Resize: /* Fake keypress used on window resize */ widget_menu_draw( menu ); break; #endif case INPUT_KEY_Escape: case INPUT_JOYSTICK_FIRE_2: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_Return: case INPUT_JOYSTICK_FIRE_1: ptr=&menu[1 + highlight_line]; if(!ptr->inactive) { if( ptr->submenu ) { widget_do( WIDGET_TYPE_MENU, ptr->submenu ); } else { ptr->callback( ptr->action ); } } return; case INPUT_KEY_Up: case INPUT_KEY_7: case INPUT_JOYSTICK_UP: if ( highlight_line ) { new_highlight_line = highlight_line - 1; cursor_pressed = 1; } break; case INPUT_KEY_Down: case INPUT_KEY_6: case INPUT_JOYSTICK_DOWN: if ( highlight_line + 1 < (ptrdiff_t)count ) { new_highlight_line = highlight_line + 1; cursor_pressed = 1; } break; default: /* Keep gcc happy */ break; } if( cursor_pressed ) { highlight_line = new_highlight_line; print_items(); return; } for( ptr=&menu[1]; ptr->text; ptr++ ) { if( !ptr->inactive && key == ptr->key ) { if( ptr->submenu ) { widget_do( WIDGET_TYPE_MENU, ptr->submenu ); } else { ptr->callback( ptr->action ); } break; } } }
void menu_machine_pokememory( int action ) { widget_do( WIDGET_TYPE_POKEMEM, NULL ); }
void menu_machine_pokefinder( int action ) { widget_do( WIDGET_TYPE_POKEFINDER, NULL ); }
void menu_options_peripherals( int action ) { widget_do( WIDGET_TYPE_PERIPHERALS, NULL ); }
void menu_machine_memorybrowser( int action ) { widget_do( WIDGET_TYPE_MEMORYBROWSER, NULL ); }
void menu_options_sound( int action ) { widget_do( WIDGET_TYPE_SOUND, NULL ); }
static int do_joystick( const input_event_joystick_t *joystick_event, int press ) { int which; #ifdef USE_WIDGET if( widget_level >= 0 ) { if( press ) widget_keyhandler( joystick_event->button ); return 0; } switch( joystick_event->button ) { case INPUT_JOYSTICK_FIRE_2: fuse_emulation_pause(); widget_do( WIDGET_TYPE_MENU, &widget_menu ); fuse_emulation_unpause(); break; default: break; /* Remove gcc warning */ } #endif /* #ifdef USE_WIDGET */ which = joystick_event->which; if( joystick_event->button < INPUT_JOYSTICK_FIRE_1 ) { joystick_button button; switch( joystick_event->button ) { case INPUT_JOYSTICK_UP : button = JOYSTICK_BUTTON_UP; break; case INPUT_JOYSTICK_DOWN : button = JOYSTICK_BUTTON_DOWN; break; case INPUT_JOYSTICK_LEFT : button = JOYSTICK_BUTTON_LEFT; break; case INPUT_JOYSTICK_RIGHT: button = JOYSTICK_BUTTON_RIGHT; break; default: ui_error( UI_ERROR_ERROR, "do_joystick: unknown button %d", joystick_event->button ); fuse_abort(); } joystick_press( which, button, press ); } else { keyboard_key_name key; key = get_fire_button_key( which, joystick_event->button ); if( key == KEYBOARD_JOYSTICK_FIRE ) { joystick_press( which, JOYSTICK_BUTTON_FIRE, press ); } else { if( press ) { keyboard_press( key ); } else { keyboard_release( key ); } } } return 0; }
void menu_options_joysticks_select( int action ) { int error = 0; int i; switch( action - 1 ) { #ifdef USE_JOYSTICK case 0: current_settings[ 0 ] = &( settings_current.joystick_1_output ); current_settings[ 1 ] = &( settings_current.joystick_1_fire_1 ); current_settings[ 2 ] = &( settings_current.joystick_1_fire_2 ); current_settings[ 3 ] = &( settings_current.joystick_1_fire_3 ); current_settings[ 4 ] = &( settings_current.joystick_1_fire_4 ); current_settings[ 5 ] = &( settings_current.joystick_1_fire_5 ); current_settings[ 6 ] = &( settings_current.joystick_1_fire_6 ); current_settings[ 7 ] = &( settings_current.joystick_1_fire_7 ); current_settings[ 8 ] = &( settings_current.joystick_1_fire_8 ); current_settings[ 9 ] = &( settings_current.joystick_1_fire_9 ); current_settings[ 10 ] = &( settings_current.joystick_1_fire_10 ); current_settings[ 11 ] = &( settings_current.joystick_1_fire_11 ); current_settings[ 12 ] = &( settings_current.joystick_1_fire_12 ); current_settings[ 13 ] = &( settings_current.joystick_1_fire_13 ); current_settings[ 14 ] = &( settings_current.joystick_1_fire_14 ); current_settings[ 15 ] = &( settings_current.joystick_1_fire_15 ); submenu_type_and_mapping_for_joystick[ 1 ].detail = menu_joystick_1_detail; break; case 1: current_settings[ 0 ] = &( settings_current.joystick_2_output ); current_settings[ 1 ] = &( settings_current.joystick_2_fire_1 ); current_settings[ 2 ] = &( settings_current.joystick_2_fire_2 ); current_settings[ 3 ] = &( settings_current.joystick_2_fire_3 ); current_settings[ 4 ] = &( settings_current.joystick_2_fire_4 ); current_settings[ 5 ] = &( settings_current.joystick_2_fire_5 ); current_settings[ 6 ] = &( settings_current.joystick_2_fire_6 ); current_settings[ 7 ] = &( settings_current.joystick_2_fire_7 ); current_settings[ 8 ] = &( settings_current.joystick_2_fire_8 ); current_settings[ 9 ] = &( settings_current.joystick_2_fire_9 ); current_settings[ 10 ] = &( settings_current.joystick_2_fire_10 ); current_settings[ 11 ] = &( settings_current.joystick_2_fire_11 ); current_settings[ 12 ] = &( settings_current.joystick_2_fire_12 ); current_settings[ 13 ] = &( settings_current.joystick_2_fire_13 ); current_settings[ 14 ] = &( settings_current.joystick_2_fire_14 ); current_settings[ 15 ] = &( settings_current.joystick_2_fire_15 ); submenu_type_and_mapping_for_joystick[ 1 ].detail = menu_joystick_2_detail; break; #endif /* #ifdef USE_JOYSTICK */ case JOYSTICK_KEYBOARD: current_settings[ 0 ] = &( settings_current.joystick_keyboard_output ); current_settings[ 1 ] = &( settings_current.joystick_keyboard_up ); current_settings[ 2 ] = &( settings_current.joystick_keyboard_down ); current_settings[ 3 ] = &( settings_current.joystick_keyboard_left ); current_settings[ 4 ] = &( settings_current.joystick_keyboard_right ); current_settings[ 5 ] = &( settings_current.joystick_keyboard_fire ); submenu_type_and_mapping_for_keyboard[ 1 ].detail = menu_keyboard_joystick_detail; break; } /* Populate joystick names */ if( JOYSTICK_TYPE_COUNT > MAX_JOYSTICK_TYPES ) ui_error( UI_ERROR_ERROR, "Not all joystick types are displayed" ); submenu_types[ 0 ].text = "Select joystick type"; for( i = 0; ( i < JOYSTICK_TYPE_COUNT ) && ( i < MAX_JOYSTICK_TYPES ); i++ ) { char shortcut[ 2 ] = { 'A' + i, '\0' }; snprintf( ( char * ) joystick_names[ i ], 100, "\012%s\011 %s", shortcut, joystick_name[ i ] ); submenu_types[ i + 1 ].text = joystick_names[ i ]; submenu_types[ i + 1 ].key = INPUT_KEY_a + i; submenu_types[ i + 1 ].callback = set_joystick_type; submenu_types[ i + 1 ].action = i; } submenu_types[ i + 1 ].text = NULL; if( action - 1 == JOYSTICK_KEYBOARD ) error = widget_do( WIDGET_TYPE_MENU, submenu_type_and_mapping_for_keyboard ); #ifdef USE_JOYSTICK else error = widget_do( WIDGET_TYPE_MENU, submenu_type_and_mapping_for_joystick ); #endif /* #ifdef USE_JOYSTICK */ if( error ) return; }