void widget_text_keyhandler( input_key key ) { switch( key ) { case INPUT_KEY_BackSpace: /* Backspace generates DEL which is Caps + 0 */ delete_character(); widget_text_draw_text(); return; case INPUT_KEY_Escape: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: widget_end_widget( WIDGET_FINISHED_OK ); return; default: /* Keep gcc happy */ break; } /* Input validation. * We rely on various INPUT_KEY_* being mapped directly onto ASCII. */ /* FIXME: we *don't* want keypresses filtered through the input layer */ /* First, return if the character isn't printable ASCII. */ if( key < ' ' || key > '~' ) return; /* Return if the key isn't valid. */ switch( allow ) { case WIDGET_INPUT_ASCII: break; case WIDGET_INPUT_DIGIT: if( !isdigit( key ) ) return; break; case WIDGET_INPUT_ALPHA: if( !isalpha( key ) ) return; break; case WIDGET_INPUT_ALNUM: if( !isdigit( key ) && !isalpha( key ) ) return; break; } /* If we've got this far, we have a valid key */ append_character( key ); widget_text_draw_text(); }
void widget_picture_keyhandler( input_key key ) { switch( key ) { #if 0 case INPUT_KEY_Resize: /* Fake keypress used on widget resize */ widget_picture_draw( ptr ); break; #endif case INPUT_KEY_Escape: case INPUT_JOYSTICK_FIRE_2: widget_end_widget( WIDGET_FINISHED_CANCEL ); break; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: case INPUT_JOYSTICK_FIRE_1: widget_end_all( WIDGET_FINISHED_OK ); break; default: /* Keep gcc happy */ break; } }
void widget_memory_keyhandler( input_key key ) { switch ( key ) { case INPUT_KEY_Escape: /* Close widget */ widget_end_widget( WIDGET_FINISHED_CANCEL ); break; case INPUT_KEY_Return: /* Close widget */ case INPUT_KEY_KP_Enter: widget_end_all( WIDGET_FINISHED_OK ); break; /* Address selection */ case INPUT_KEY_Up: memaddr -= 16; widget_memory_draw( NULL ); break; case INPUT_KEY_Down: memaddr += 16; widget_memory_draw( NULL ); break; case INPUT_KEY_Page_Up: memaddr -= 128; widget_memory_draw( NULL ); break; case INPUT_KEY_Page_Down: memaddr += 128; widget_memory_draw( NULL ); break; case INPUT_KEY_Home: memaddr = 0; widget_memory_draw( NULL ); break; case INPUT_KEY_End: memaddr = 0xFF80; widget_memory_draw( NULL ); break; default:; } }
void widget_error_keyhandler( input_key key ) { switch( key ) { case INPUT_KEY_Escape: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: widget_end_widget( WIDGET_FINISHED_OK ); return; default: /* Keep gcc happy */ break; } }
void widget_roms_keyhandler( input_key key ) { switch( key ) { #if 0 case INPUT_KEY_Resize: /* Fake keypress used on window resize */ widget_roms_draw( NULL ); break; #endif case INPUT_KEY_Escape: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: widget_end_all( WIDGET_FINISHED_OK ); return; default: /* Keep gcc happy */ break; } if( key >= INPUT_KEY_a && key <= INPUT_KEY_z && key - INPUT_KEY_a < (ptrdiff_t)rom_count ) { char **setting; char buf[32]; widget_filesel_data data; key -= INPUT_KEY_a; snprintf( buf, sizeof( buf ), "%s - ROM %d", info->title, key ); data.exit_all_widgets = 0; data.title = buf; widget_do_fileselector( &data ); if( !widget_filesel_name ) return; setting = settings_get_rom_setting( widget_settings, key + first_rom, is_peripheral ); settings_set_string( setting, widget_filesel_name ); print_rom( key ); } }
static void widget_query_generic_keyhandler( widget_query_entry *query, int num_entries, input_key key ) { int new_highlight_line = 0; int cursor_pressed = 0; widget_query_entry *ptr; int menu_width = widget_calculate_query_width( title, query, message_lines, num_message_lines ); int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; switch( key ) { #if 0 case INPUT_KEY_Resize: /* Fake keypress used on window resize */ widget_dialog_with_border( 1, 2, 30, 2 + 20 ); widget_general_show_all( &widget_options_settings ); break; #endif case INPUT_KEY_Escape: case INPUT_JOYSTICK_FIRE_2: widget_end_widget( WIDGET_FINISHED_CANCEL ); break; 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 < num_entries - 2 ) { new_highlight_line = highlight_line + 1; cursor_pressed = 1; } break; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: case INPUT_JOYSTICK_FIRE_1: query[highlight_line].click(); widget_end_all( WIDGET_FINISHED_OK ); display_refresh_all(); return; default: /* Keep gcc happy */ break; } if( cursor_pressed ) { int old_highlight_line = highlight_line; highlight_line = new_highlight_line; widget_query_line_draw( menu_left_edge_x, menu_width, query + old_highlight_line, query[old_highlight_line].text ); widget_query_line_draw( menu_left_edge_x, menu_width, query + highlight_line, query[highlight_line].text ); return; } for( ptr=query; ptr->text != NULL; ptr++ ) { if( key == ptr->key ) { int old_highlight_line = highlight_line; ptr->click(); highlight_line = ptr->index; widget_query_line_draw( menu_left_edge_x, menu_width, query + old_highlight_line, query[old_highlight_line].text ); widget_query_line_draw( menu_left_edge_x, menu_width, ptr, query[highlight_line].text ); break; } } }
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 widget_select_keyhandler( input_key key ) { int new_highlight_line = 0; int cursor_pressed = 0; size_t width = widget_calculate_select_width( title ); int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-width/2; switch( key ) { #if 0 case INPUT_KEY_Resize: /* Fake keypress used on window resize */ widget_select_draw( NULL ); break; #endif case INPUT_KEY_Escape: case INPUT_JOYSTICK_FIRE_2: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: case INPUT_JOYSTICK_FIRE_1: widget_end_widget( WIDGET_FINISHED_OK ); 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; case INPUT_KEY_Home: if ( highlight_line ) { new_highlight_line = 0; cursor_pressed = 1; } break; case INPUT_KEY_End: if ( highlight_line + 2 < (ptrdiff_t)count ) { new_highlight_line = (ptrdiff_t)count - 1; cursor_pressed = 1; } break; default: /* Keep gcc happy */ break; } if( cursor_pressed || ( key >= INPUT_KEY_a && key <= INPUT_KEY_z && key - INPUT_KEY_a < (ptrdiff_t)count ) ) { /* Remove the old highlight */ widget_rectangle( menu_left_edge_x * 8 + 1, highlight_line * 8 + 24, width * 8 - 2, 1 * 8, WIDGET_COLOUR_BACKGROUND ); print_item( menu_left_edge_x, width, highlight_line, WIDGET_COLOUR_FOREGROUND ); /* draw the new one */ if( cursor_pressed ) { highlight_line = new_highlight_line; } else { highlight_line = key - INPUT_KEY_a; } widget_rectangle( menu_left_edge_x * 8 + 1, highlight_line * 8 + 24, width * 8 - 2, 1 * 8, WIDGET_COLOUR_HIGHLIGHT ); print_item( menu_left_edge_x, width, highlight_line, WIDGET_COLOUR_FOREGROUND ); widget_display_lines( 2, count + 2 ); } }