Note: I have done some testing, but there are probably more bugs

lurking. If you run into anything odd, please let me know.

Added new module uiinput.c which manages input for the user interface.
The OSD is responsible for pushing mouse events and character events
to this interface in order to support mouse movement and text-based
input (currently only used for the select game menu). Added support
for navigating through the menus using the mouse. 
[Nathan Woods, Aaron Giles]

Redesigned the UI menus so that they can maintain a richer state. Now
the menus can be generated once and reused, rather than requiring them
to be regenerated on each frame. All menus also share a comment eventing
system and navigation through them is managed centrally. Rewrote all the 
menus to use the new system, apart from the cheat menus, which are now 
disabled. Reorganized the video menu to make it easier to understand.
[Aaron Giles]
This commit is contained in:
Aaron Giles 2008-07-12 20:18:25 +00:00
parent 465010dc11
commit d8715ab4ac
28 changed files with 3358 additions and 2084 deletions

2
.gitattributes vendored
View File

@ -926,6 +926,8 @@ src/emu/ui.c svneol=native#text/plain
src/emu/ui.h svneol=native#text/plain
src/emu/uigfx.c svneol=native#text/plain
src/emu/uigfx.h svneol=native#text/plain
src/emu/uiinput.c svneol=native#text/plain
src/emu/uiinput.h svneol=native#text/plain
src/emu/uimenu.c svneol=native#text/plain
src/emu/uimenu.h svneol=native#text/plain
src/emu/uismall.png -text svneol=unset#image/png

View File

@ -11,6 +11,7 @@
#include "driver.h"
#include "ui.h"
#include "uiinput.h"
#include "uimenu.h"
#include "machine/eeprom.h"
#include "cheat.h"
@ -1663,7 +1664,7 @@ static int ui_pressed_repeat_throttle(running_machine *machine, int code, int ba
last_code = -1;
}
return input_ui_pressed_repeat(machine, code, last_speed);
return ui_input_pressed_repeat(machine, code, last_speed);
}
/*-----------------------------------
@ -1784,7 +1785,7 @@ static UINT32 do_edit_hex_field(running_machine *machine, UINT32 data)
data >>= 4;
return data;
}
else if(input_ui_pressed(machine, IPT_UI_CLEAR))
else if(ui_input_pressed(machine, IPT_UI_CLEAR))
{
/* data clear */
data = 0;
@ -2660,7 +2661,7 @@ static int user_select_value_menu(running_machine *machine, cheat_menu_stack *me
display_value = decimal_to_bcd(bcd_to_decimal(display_value));
}
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
int i;
@ -2716,12 +2717,12 @@ static int user_select_value_menu(running_machine *machine, cheat_menu_stack *me
menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_EDIT_CHEAT))
{
edit_active ^= 1;
edit_cursor = 0;
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
if(edit_active) edit_active = 0;
else menu->sel = -1;
@ -2825,7 +2826,7 @@ static int user_select_label_menu(running_machine *machine, cheat_menu_stack *me
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(menu->sel != total - 1)
{
@ -2844,7 +2845,7 @@ static int user_select_label_menu(running_machine *machine, cheat_menu_stack *me
else
menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
menu->sel = -1;
return menu->sel + 1;
@ -2872,7 +2873,7 @@ static int comment_menu(running_machine *machine, cheat_menu_stack *menu)
ui_draw_message_window(buf);
/********** KEY HANDLING **********/
if(input_ui_pressed(machine, IPT_UI_SELECT) || input_ui_pressed(machine, IPT_UI_CANCEL))
if(ui_input_pressed(machine, IPT_UI_SELECT) || ui_input_pressed(machine, IPT_UI_CANCEL))
menu->sel = -1;
return menu->sel + 1;
@ -2942,7 +2943,7 @@ static int extend_comment_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT) || input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_SELECT) || ui_input_pressed(machine, IPT_UI_CANCEL))
menu->sel = -1;
return menu->sel + 1;
@ -3033,7 +3034,7 @@ static int cheat_main_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
switch(menu->sel)
{
@ -3074,7 +3075,7 @@ static int cheat_main_menu(running_machine *machine, cheat_menu_stack *menu)
menu->sel = -1;
}
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
if(shift_key_pressed())
reset_cheat_options();
@ -3083,7 +3084,7 @@ static int cheat_main_menu(running_machine *machine, cheat_menu_stack *menu)
else
reload_cheat_database(machine);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -3358,7 +3359,7 @@ static int enable_disable_cheat_menu(running_machine *machine, cheat_menu_stack
{
do_select = 1;
}
if(input_ui_pressed(machine, IPT_UI_SELECT))
if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(entry == NULL)
{
@ -3382,7 +3383,7 @@ static int enable_disable_cheat_menu(running_machine *machine, cheat_menu_stack
do_select = 1;
}
}
else if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_SAVE_CHEAT))
{
if(shift_key_pressed())
{
@ -3403,28 +3404,28 @@ static int enable_disable_cheat_menu(running_machine *machine, cheat_menu_stack
save_pre_enable(machine, entry, info->sub_cheat);
}
}
else if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
{
add_cheat_before(info->sub_cheat);
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
if(entry) delete_cheat_at(info->sub_cheat);
else SET_MESSAGE(CHEAT_MESSAGE_FAILED_TO_DELETE);
}
else if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_EDIT_CHEAT))
{
if(entry) cheat_menu_stack_push(command_add_edit_menu, menu->handler, info->sub_cheat);
}
else if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE))
else if(ui_input_pressed(machine, IPT_UI_WATCH_VALUE))
{
watch_cheat_entry(entry, 0);
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
reload_cheat_database(machine);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
/* NOTE : cancel button return cheat main menu directly */
menu->sel = -1;
@ -3540,7 +3541,7 @@ static int add_edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(entry)
{
@ -3554,11 +3555,11 @@ static int add_edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
else
menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
reload_cheat_database(machine);
}
else if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_EDIT_CHEAT))
{
if(entry)
{
@ -3570,15 +3571,15 @@ static int add_edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
cheat_menu_stack_push(command_add_edit_menu, menu->handler, menu->sel);
}
}
else if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
{
add_cheat_before(menu->sel);
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
delete_cheat_at(menu->sel);
}
else if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_SAVE_CHEAT))
{
if(shift_key_pressed())
{
@ -3604,11 +3605,11 @@ static int add_edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
save_cheat_code(machine, entry);
}
}
else if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE))
else if(ui_input_pressed(machine, IPT_UI_WATCH_VALUE))
{
watch_cheat_entry(entry, 0);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -3696,7 +3697,7 @@ static int command_add_edit_menu(running_machine *machine, cheat_menu_stack *men
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
switch(menu->sel)
{
@ -3778,11 +3779,11 @@ static int command_add_edit_menu(running_machine *machine, cheat_menu_stack *men
break;
}
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
reload_cheat_database(machine);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL) || input_ui_pressed(machine, IPT_UI_LEFT) || input_ui_pressed(machine, IPT_UI_RIGHT))
else if(ui_input_pressed(machine, IPT_UI_CANCEL) || ui_input_pressed(machine, IPT_UI_LEFT) || ui_input_pressed(machine, IPT_UI_RIGHT))
{
menu->sel = -1;
}
@ -4160,7 +4161,7 @@ static int edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
{
do_select = -1;
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(edit_active)
edit_active = 0;
@ -4179,7 +4180,7 @@ static int edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
}
}
}
else if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
{
add_action_before(entry, info->sub_cheat);
@ -4194,15 +4195,15 @@ static int edit_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
else SET_MASK_FIELD(action->type, LinkEnable);
}
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
delete_action_at(entry, info->sub_cheat);
}
else if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE))
else if(ui_input_pressed(machine, IPT_UI_WATCH_VALUE))
{
watch_cheat_entry(entry, 0);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
if(edit_active) edit_active = 0;
else menu->sel = -1;
@ -4734,7 +4735,7 @@ static int view_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
if(edit_active == 0)
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(edit_active)
edit_active = 0;
@ -4754,15 +4755,15 @@ static int view_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
}
}
}
else if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_SAVE_CHEAT))
{
save_cheat_code(machine, entry);
}
else if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE))
else if(ui_input_pressed(machine, IPT_UI_WATCH_VALUE))
{
watch_cheat_entry(entry, 0);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
if(edit_active) edit_active = 0;
else menu->sel = -1;
@ -4940,18 +4941,18 @@ static int analyse_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_EDIT_CHEAT))
{
is_edit = 1;
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(menu->sel == total - 2)
is_edit = 1;
else
menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -5378,7 +5379,7 @@ static int search_main_menu(running_machine *machine, cheat_menu_stack *menu)
else
do_increment = 1;
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(edit_active)
{
@ -5440,7 +5441,7 @@ static int search_main_menu(running_machine *machine, cheat_menu_stack *menu)
}
}
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
if(edit_active) edit_active = 0;
else menu->sel = -1;
@ -5725,7 +5726,7 @@ static int select_search_region_menu(running_machine *machine, cheat_menu_stack
do_reallocate = 1;
}
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
if(shift_key_pressed() && region && search)
{
@ -5733,14 +5734,14 @@ static int select_search_region_menu(running_machine *machine, cheat_menu_stack
invalidate_entire_region(search, region);
}
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
if(search->search_speed == SEARCH_SPEED_USER_DEFINED)
/* reload user region */
do_rebuild = 1;
do_reallocate = 1;
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(region)
{
@ -5755,7 +5756,7 @@ static int select_search_region_menu(running_machine *machine, cheat_menu_stack
else if(menu->sel == total - 1)
menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
menu->sel = -1;
/********** REBUILD SEARCH REGION **********/
@ -6049,12 +6050,12 @@ static int view_search_result_menu(running_machine *machine, cheat_menu_stack *m
menu->sel = kMenu_FirstResult;
}
else if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
{
if(selectedAddressGood)
add_cheat_from_result(machine, search, region, selectedAddress);
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
if(shift_key_pressed())
{
@ -6072,12 +6073,12 @@ static int view_search_result_menu(running_machine *machine, cheat_menu_stack *m
SET_MESSAGE(CHEAT_MESSAGE_SUCCEEDED_TO_DELETE);
}
}
else if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE))
else if(ui_input_pressed(machine, IPT_UI_WATCH_VALUE))
{
if(selectedAddressGood)
add_watch_from_result(search, region, selectedAddress);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT) || input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_SELECT) || ui_input_pressed(machine, IPT_UI_CANCEL))
menu->sel = -1;
switch(pageSwitch)
@ -6321,7 +6322,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
edit_cursor = info->address_chars_needed + 1;
}
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(edit_active)
edit_active = 0;
@ -6333,7 +6334,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
menu->sel = -1;
}
}
else if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
{
if(!edit_active && watch)
{
@ -6356,7 +6357,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
add_watch_before(menu->sel);
}
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
if(!edit_active && watch)
{
@ -6392,7 +6393,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
}
}
}
else if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_SAVE_CHEAT))
{
if(!edit_active && watch)
{
@ -6405,7 +6406,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
dispose_cheat(&entry);
}
}
else if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_EDIT_CHEAT))
{
if(watch)
{
@ -6413,7 +6414,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
edit_active ^= 1;
}
}
else if(input_ui_pressed(machine, IPT_UI_CLEAR))
else if(ui_input_pressed(machine, IPT_UI_CLEAR))
{
if(!edit_active)
{
@ -6434,7 +6435,7 @@ static int choose_watch_menu(running_machine *machine, cheat_menu_stack *menu)
watch->element_bytes = 0;
}
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
if(edit_active)
edit_active = 0;
@ -6515,7 +6516,7 @@ static int command_watch_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
switch(menu->sel)
{
@ -6580,11 +6581,11 @@ static int command_watch_menu(running_machine *machine, cheat_menu_stack *menu)
menu->sel = -1;
}
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
reload_cheat_database(machine);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL) || input_ui_pressed(machine, IPT_UI_LEFT) || input_ui_pressed(machine, IPT_UI_RIGHT))
else if(ui_input_pressed(machine, IPT_UI_CANCEL) || ui_input_pressed(machine, IPT_UI_LEFT) || ui_input_pressed(machine, IPT_UI_RIGHT))
{
menu->sel = -1;
}
@ -6964,7 +6965,7 @@ static int edit_watch_menu(running_machine *machine, cheat_menu_stack *menu)
}
}
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(edit_active)
edit_active = 0;
@ -6991,11 +6992,11 @@ static int edit_watch_menu(running_machine *machine, cheat_menu_stack *menu)
}
}
}
else if(input_ui_pressed(machine, IPT_UI_CLEAR))
else if(ui_input_pressed(machine, IPT_UI_CLEAR))
{
reset_watch(entry);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
if(edit_active)
edit_active = 0;
@ -7055,13 +7056,13 @@ static int edit_watch_menu(running_machine *machine, cheat_menu_stack *menu)
}
else
{
if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
add_cheat_from_watch(machine, entry);
if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
entry->num_elements = 0;
if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT))
if(ui_input_pressed(machine, IPT_UI_SAVE_CHEAT))
{
cheat_entry temp_entry;
@ -7230,7 +7231,7 @@ static int select_option_menu(running_machine *machine, cheat_menu_stack *menu)
{
do_select = 1;
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
switch(menu->sel)
{
@ -7258,18 +7259,18 @@ static int select_option_menu(running_machine *machine, cheat_menu_stack *menu)
break;
}
}
else if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_SAVE_CHEAT))
{
save_cheat_options();
}
else if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_RELOAD_CHEAT))
{
if(shift_key_pressed())
reset_cheat_options();
else
load_cheat_database(machine, LOAD_CHEAT_OPTIONS);
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -7387,22 +7388,22 @@ static int select_search_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_ADD_CHEAT))
{
add_search_before(menu->sel);
build_search_regions(machine, &search_list[menu->sel]);
allocate_search_regions(&search_list[menu->sel]);
}
else if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT))
else if(ui_input_pressed(machine, IPT_UI_DELETE_CHEAT))
{
delete_search_at(menu->sel);
}
if(input_ui_pressed(machine, IPT_UI_SELECT))
if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(menu->sel < total - 1) current_search_idx = menu->sel;
else menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -7489,7 +7490,7 @@ static int command_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
{
toggle = 1;
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
switch(menu->sel)
{
@ -7515,7 +7516,7 @@ static int command_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
break;
}
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -7568,7 +7569,7 @@ static int check_activation_key_code_menu(running_machine *machine, cheat_menu_s
ui_draw_message_window(stringsBuf);
/* NOTE : shift + cancel is only key to return because normal cancel prevents from diplaying this key */
if(shift_key_pressed() && input_ui_pressed(machine, IPT_UI_CANCEL))
if(shift_key_pressed() && ui_input_pressed(machine, IPT_UI_CANCEL))
{
index = INPUT_CODE_INVALID;
menu->sel = -1;
@ -7742,12 +7743,12 @@ static int view_cpu_region_info_list_menu(running_machine *machine, cheat_menu_s
i--;
}
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
if(menu->sel == kMenu_Return)
menu->sel = -1;
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -7875,7 +7876,7 @@ static int debug_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
{
CURSOR_PAGE_DOWN(menu->sel, total);
}
else if(input_ui_pressed(machine, IPT_UI_SELECT))
else if(ui_input_pressed(machine, IPT_UI_SELECT))
{
switch(menu->sel)
{
@ -7892,7 +7893,7 @@ static int debug_cheat_menu(running_machine *machine, cheat_menu_stack *menu)
break;
}
}
else if(input_ui_pressed(machine, IPT_UI_CANCEL))
else if(ui_input_pressed(machine, IPT_UI_CANCEL))
{
menu->sel = -1;
}
@ -7910,7 +7911,7 @@ static TIMER_CALLBACK( cheat_periodic )
{
int i;
if(input_ui_pressed(machine, IPT_UI_TOGGLE_CHEAT))
if(ui_input_pressed(machine, IPT_UI_TOGGLE_CHEAT))
{
if(shift_key_pressed())
{

View File

@ -25,6 +25,7 @@
#include "debugvw.h"
#include "debugger.h"
#include "deprecat.h"
#include "uiinput.h"
#include <ctype.h>
@ -408,7 +409,7 @@ void debug_cpu_start_hook(running_machine *machine, int cpunum, attotime endtime
}
/* check for debug keypresses */
else if (input_ui_pressed(machine, IPT_UI_DEBUG_BREAK))
else if (ui_input_pressed(machine, IPT_UI_DEBUG_BREAK))
{
global.execution_state = EXECUTION_STATE_STOPPED;
debug_console_printf("User-initiated break\n");

View File

@ -38,7 +38,6 @@ OBJDIRS += \
EMUOBJS = \
$(EMUOBJ)/attotime.o \
$(EMUOBJ)/audit.o \
$(EMUOBJ)/cheat.o \
$(EMUOBJ)/clifront.o \
$(EMUOBJ)/config.o \
$(EMUOBJ)/cpuexec.o \
@ -76,6 +75,7 @@ EMUOBJS = \
$(EMUOBJ)/timer.o \
$(EMUOBJ)/ui.o \
$(EMUOBJ)/uigfx.o \
$(EMUOBJ)/uiinput.o \
$(EMUOBJ)/uimenu.o \
$(EMUOBJ)/validity.o \
$(EMUOBJ)/video.o \

View File

@ -248,7 +248,6 @@ struct _input_port_private
/* specific special global input states */
digital_joystick_state joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; /* joystick states */
osd_ticks_t ui_memory[__ipt_max];/* keypress timing for UI */
/* frame time tracking */
attotime last_frame_time; /* time of the last frame callback */
@ -905,6 +904,49 @@ void input_field_set_user_settings(const input_field_config *field, const input_
}
/*-------------------------------------------------
input_field_setting_name - return the expanded
setting name for a field
-------------------------------------------------*/
const char *input_field_setting_name(const input_field_config *field)
{
const input_setting_config *setting;
/* only makes sense if we have settings */
assert(field->settinglist != NULL);
/* scan the list of settings looking for a match on the current value */
for (setting = field->settinglist; setting != NULL; setting = setting->next)
if (input_condition_true(field->port->machine, &setting->condition))
if (setting->value == field->state->value)
return setting->name;
return "INVALID";
}
/*-------------------------------------------------
input_field_has_previous_setting - return TRUE
if the given field has a "previous" setting
-------------------------------------------------*/
int input_field_has_previous_setting(const input_field_config *field)
{
const input_setting_config *setting;
/* only makes sense if we have settings */
assert(field->settinglist != NULL);
/* scan the list of settings looking for a match on the current value */
for (setting = field->settinglist; setting != NULL; setting = setting->next)
if (input_condition_true(field->port->machine, &setting->condition))
return (setting->value != field->state->value);
return FALSE;
}
/*-------------------------------------------------
input_field_select_previous_setting - select
the previous item for a DIP switch or
@ -947,6 +989,33 @@ void input_field_select_previous_setting(const input_field_config *field)
}
/*-------------------------------------------------
input_field_has_next_setting - return TRUE
if the given field has a "next" setting
-------------------------------------------------*/
int input_field_has_next_setting(const input_field_config *field)
{
const input_setting_config *setting;
int found = FALSE;
/* only makes sense if we have settings */
assert(field->settinglist != NULL);
/* scan the list of settings looking for a match on the current value */
for (setting = field->settinglist; setting != NULL; setting = setting->next)
if (input_condition_true(field->port->machine, &setting->condition))
{
if (found)
return TRUE;
if (setting->value == field->state->value)
found = TRUE;
}
return FALSE;
}
/*-------------------------------------------------
input_field_select_next_setting - select the
next item for a DIP switch or
@ -1131,69 +1200,6 @@ const input_type_desc *input_type_list(running_machine *machine)
/***************************************************************************
USER INTERFACE SEQUENCE READING
***************************************************************************/
/*-------------------------------------------------
input_ui_pressed - return TRUE if a key down
for the given user interface sequence is
detected
-------------------------------------------------*/
int input_ui_pressed(running_machine *machine, int code)
{
return input_ui_pressed_repeat(machine, code, 0);
}
/*-------------------------------------------------
input_ui_pressed_r - return TRUE if a key down
for the given user interface sequence is
detected, or if autorepeat at the given speed
is triggered
-------------------------------------------------*/
int input_ui_pressed_repeat(running_machine *machine, int code, int speed)
{
input_port_private *portdata = machine->input_port_data;
int pressed;
profiler_mark(PROFILER_INPUT);
/* get the status of this key (assumed to be only in the defaults) */
assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16);
pressed = input_seq_pressed(input_type_seq(machine, code, 0, SEQ_TYPE_STANDARD));
/* if down, handle it specially */
if (pressed)
{
osd_ticks_t tps = osd_ticks_per_second();
/* if this is the first press, set a 3x delay and leave pressed = 1 */
if (portdata->ui_memory[code] == 0)
portdata->ui_memory[code] = osd_ticks() + 3 * speed * tps / 60;
/* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */
else if (speed > 0 && (osd_ticks() + tps - portdata->ui_memory[code]) >= tps)
portdata->ui_memory[code] += 1 * speed * tps / 60;
/* otherwise, reset pressed = 0 */
else
pressed = 0;
}
/* if we're not pressed, reset the memory field */
else
portdata->ui_memory[code] = 0;
profiler_mark(PROFILER_END);
return pressed;
}
/***************************************************************************
PORT READING
***************************************************************************/
@ -1988,7 +1994,7 @@ profiler_mark(PROFILER_INPUT);
/* track the duration of the previous frame */
portdata->last_delta_nsec = attotime_to_attoseconds(attotime_sub(curtime, portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND;
portdata->last_frame_time = curtime;
/* update the digital joysticks */
frame_update_digital_joysticks(machine);

View File

@ -988,23 +988,22 @@ void input_field_get_user_settings(const input_field_config *field, input_field_
/* modify the current settings for the given input field */
void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings);
/* return the expanded setting name for a field */
const char *input_field_setting_name(const input_field_config *field);
/* return TRUE if the given field has a "previous" setting */
int input_field_has_previous_setting(const input_field_config *field);
/* select the previous item for a DIP switch or configuration field */
void input_field_select_previous_setting(const input_field_config *field);
/* return TRUE if the given field has a "next" setting */
int input_field_has_next_setting(const input_field_config *field);
/* select the next item for a DIP switch or configuration field */
void input_field_select_next_setting(const input_field_config *field);
/* ----- user interface sequence reading ----- */
/* return TRUE if a key down for the given user interface sequence is detected */
int input_ui_pressed(running_machine *machine, int code);
/* return TRUE if a key down for the given user interface sequence is detected, or if
autorepeat at the given speed is triggered */
int input_ui_pressed_repeat(running_machine *machine, int code, int speed);
/* ----- port reading ----- */

View File

@ -936,6 +936,33 @@ int input_code_pressed_once(input_code code)
}
/*-------------------------------------------------
input_code_from_input_item_id - translates
an input_item_id to an input_code
-------------------------------------------------*/
input_code input_code_from_input_item_id(input_item_id itemid)
{
input_device_class devclass;
/* iterate over device classes and devices */
for (devclass = DEVICE_CLASS_INVALID + 1; devclass < DEVICE_CLASS_MAXIMUM; devclass++)
{
input_device_list *devlist = &device_list[devclass];
int devnum;
/* iterate over devices within each class */
for (devnum = 0; devnum < devlist->count; devnum++)
{
input_device *device = &devlist->list[devnum];
if (device->item[itemid] != NULL)
return device_item_to_code(device, itemid);
}
}
return 0;
}
/*-------------------------------------------------
input_code_poll_switches - poll for any input
-------------------------------------------------*/

View File

@ -609,6 +609,9 @@ INT32 input_code_pressed(input_code code);
/* same as above, but returns TRUE only on the first call after an off->on transition */
INT32 input_code_pressed_once(input_code code);
/* translates an input_item_id to an input_code */
input_code input_code_from_input_item_id(input_item_id itemid);
/* poll for any switch input, optionally resetting internal memory */
input_code input_code_poll_switches(int reset);

View File

@ -88,6 +88,7 @@
#include "render.h"
#include "ui.h"
#include "uimenu.h"
#include "uiinput.h"
#include "deprecat.h"
#include "debug/debugcon.h"
@ -1558,6 +1559,9 @@ static void init_machine(running_machine *machine)
if (newbase != 0)
mame->base_time = newbase;
/* intialize UI input */
ui_input_init(machine);
/* first load ROMs, then populate memory, and finally initialize CPUs */
/* these operations must proceed in this order */
rom_init(machine, machine->gamedrv->rom);
@ -1612,8 +1616,8 @@ static void init_machine(running_machine *machine)
/* initialize miscellaneous systems */
saveload_init(machine);
if (options_get_bool(mame_options(), OPTION_CHEAT))
cheat_init(machine);
// if (options_get_bool(mame_options(), OPTION_CHEAT))
// cheat_init(machine);
}

View File

@ -185,6 +185,7 @@ typedef struct _palette_private palette_private;
typedef struct _streams_private streams_private;
typedef struct _devices_private devices_private;
typedef struct _input_port_private input_port_private;
typedef struct _ui_input_private ui_input_private;
/* description of the currently-running machine */
@ -221,6 +222,7 @@ struct _running_machine
streams_private * streams_data; /* internal data from streams.c */
devices_private * devices_data; /* internal data from devices.c */
input_port_private * input_port_data; /* internal data from inptport.c */
ui_input_private * ui_input_data; /* internal data from uiinput.c */
#ifdef MESS
images_private * images_data; /* internal data from image.c */
#endif /* MESS */

View File

@ -244,6 +244,10 @@ static const render_quad_texuv oriented_texcoords[8] =
{ { 1,1 }, { 1,0 }, { 0,1 }, { 0,0 } } /* ORIENTATION_SWAP_XY | ORIENTATION_FLIP_X | ORIENTATION_FLIP_Y */
};
/* layer orders */
static const int layer_order_standard[] = { ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BACKDROP, ITEM_LAYER_BEZEL };
static const int layer_order_alternate[] = { ITEM_LAYER_BACKDROP, ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BEZEL };
/***************************************************************************
@ -460,6 +464,45 @@ INLINE void free_render_ref(render_ref *ref)
}
/*-------------------------------------------------
get_layer_and_blendmode - return the
appropriate layer index and blendmode
-------------------------------------------------*/
INLINE int get_layer_and_blendmode(const layout_view *view, int index, int *blendmode)
{
const int *layer_order = layer_order_standard;
int layer;
/*
if we have multiple backdrop pieces and no overlays, render:
backdrop (add) + screens (add) + bezels (alpha)
else render:
screens (add) + overlays (RGB multiply) + backdrop (add) + bezels (alpha)
*/
if (view->itemlist[ITEM_LAYER_BACKDROP] != NULL && view->itemlist[ITEM_LAYER_BACKDROP]->next != NULL && view->itemlist[ITEM_LAYER_OVERLAY] == NULL)
layer_order = layer_order_alternate;
/* select the layer */
layer = layer_order[index];
/* if we want the blendmode as well, compute it */
if (blendmode != NULL)
{
/* pick a blendmode */
if (layer == ITEM_LAYER_SCREEN && layer_order == layer_order_standard)
*blendmode = -1;
else if (layer == ITEM_LAYER_SCREEN || (layer == ITEM_LAYER_BACKDROP && layer_order == layer_order_standard))
*blendmode = BLENDMODE_ADD;
else if (layer == ITEM_LAYER_OVERLAY)
*blendmode = BLENDMODE_RGB_MULTIPLY;
else
*blendmode = BLENDMODE_ALPHA;
}
return layer;
}
/*-------------------------------------------------
get_screen_container_by_index - get the
screen container for this screen index
@ -1479,11 +1522,8 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3
const render_primitive_list *render_target_get_primitives(render_target *target)
{
static const int standard_order[] = { ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BACKDROP, ITEM_LAYER_BEZEL };
static const int alternate_order[] = { ITEM_LAYER_BACKDROP, ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BEZEL };
object_transform root_xform, ui_xform;
int itemcount[ITEM_LAYER_MAX];
const int *layer_order;
INT32 viswidth, visheight;
int layernum, listnum;
@ -1510,36 +1550,17 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
root_xform.color.r = root_xform.color.g = root_xform.color.b = root_xform.color.a = 1.0f;
root_xform.orientation = target->orientation;
/*
if we have multiple backdrop pieces and no overlays, render:
backdrop (add) + screens (add) + bezels (alpha)
else render:
screens (add) + overlays (RGB multiply) + backdrop (add) + bezels (alpha)
*/
layer_order = standard_order;
if (target->curview->itemlist[ITEM_LAYER_BACKDROP] != NULL &&
target->curview->itemlist[ITEM_LAYER_BACKDROP]->next != NULL &&
target->curview->itemlist[ITEM_LAYER_OVERLAY] == NULL)
layer_order = alternate_order;
/* iterate over layers back-to-front, but only if we're running */
if (mame_get_phase(Machine) >= MAME_PHASE_RESET)
for (layernum = 0; layernum < ITEM_LAYER_MAX; layernum++)
{
int layer = layer_order[layernum];
int blendmode;
int layer = get_layer_and_blendmode(target->curview, layernum, &blendmode);
if (target->curview->layenabled[layer])
{
int blendmode = BLENDMODE_ALPHA;
view_item *item;
/* pick a blendmode */
if (layer == ITEM_LAYER_SCREEN && layer_order == standard_order)
blendmode = -1;
else if (layer == ITEM_LAYER_SCREEN || (layer == ITEM_LAYER_BACKDROP && layer_order == standard_order))
blendmode = BLENDMODE_ADD;
else if (layer == ITEM_LAYER_OVERLAY)
blendmode = BLENDMODE_RGB_MULTIPLY;
/* iterate over items in the layer */
itemcount[layer] = 0;
for (item = target->curview->itemlist[layer]; item != NULL; item = item->next)
@ -1566,7 +1587,10 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
/* if there is no associated element, it must be a screen element */
if (item->element != NULL)
{
int state = (item->name[0] == 0) ? 0 : output_get_value(item->name);
int state = 0;
if (item->name[0] != '\0')
state = output_get_value(item->name);
add_element_primitives(target, &target->primlist[listnum], &item_xform, item->element, state, blendmode);
}
else
@ -1626,6 +1650,94 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
}
/*-------------------------------------------------
render_target_map_point_internal - internal
logic for mapping points
-------------------------------------------------*/
static int render_target_map_point_internal(render_target *target, INT32 target_x, INT32 target_y,
render_container *container, const char *input_tag, UINT32 input_mask, float *mapped_x, float *mapped_y)
{
int layernum;
view_item *item;
float target_fx, target_fy;
float dummy;
int hit;
/* sanity check */
if (mapped_x == NULL)
mapped_x = &dummy;
if (mapped_y == NULL)
mapped_y = &dummy;
/* convert target coordinates to float */
target_fx = (float)target_x / target->width;
target_fy = (float)target_y / target->height;
if (container != NULL && container == ui_container)
{
/* this hit test went against the UI container */
if (target_fx >= 0.0 && target_fx < 1.0 && target_fy >= 0.0 && target_fy < 1.0)
{
/* this point was successfully mapped */
*mapped_x = target_fx;
*mapped_y = target_fy;
return TRUE;
}
}
else
{
/* loop through each layer */
for (layernum = 0; layernum < ITEM_LAYER_MAX; layernum++)
{
int layer = get_layer_and_blendmode(target->curview, layernum, NULL);
if (target->curview->layenabled[layer])
{
/* iterate over items in the layer */
for (item = target->curview->itemlist[layer]; item != NULL; item = item->next)
{
/* perform the hit test */
if (item->element == NULL && container != NULL)
hit = (container == get_screen_container_by_index(item->index));
else
hit = FALSE;
/* is this item the container in which we are interested? */
if (hit)
{
/* this target contains the specified container; now check the point */
if (target_fx >= item->bounds.x0 && target_fx < item->bounds.x1 && target_fy >= item->bounds.y0 && target_fy < item->bounds.y1)
{
/* point successfully mapped */
*mapped_x = (target_fx - item->bounds.x0) / (item->bounds.x1 - item->bounds.x0);
*mapped_y = (target_fy - item->bounds.y0) / (item->bounds.y1 - item->bounds.y0);
return TRUE;
}
}
}
}
}
}
/* point not mapped */
*mapped_x = -1.0;
*mapped_y = -1.0;
return FALSE;
}
/*-------------------------------------------------
render_target_map_point_container - attempts to
map a point on the specified render_target to
the specified container, if possible
-------------------------------------------------*/
int render_target_map_point_container(render_target *target, INT32 target_x, INT32 target_y, render_container *container, float *container_x, float *container_y)
{
return render_target_map_point_internal(target, target_x, target_y, container, NULL, 0, container_x, container_y);
}
/*-------------------------------------------------
load_layout_files - load layout files for a
given render target

View File

@ -322,6 +322,9 @@ render_target *render_get_ui_target(void);
/* return the aspect ratio for UI fonts */
float render_get_ui_aspect(void);
/* performs an input hit test */
int render_input_hit_test(render_target *target, INT32 target_x, INT32 target_y, const char *input_tag, UINT32 input_mask);
/* ----- render target management ----- */
@ -384,6 +387,9 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3
/* return a list of primitives for a given render target */
const render_primitive_list *render_target_get_primitives(render_target *target);
/* attempts to map a point on the specified render_target to the specified container, if possible */
int render_target_map_point_container(render_target *target, INT32 target_x, INT32 target_y, render_container *container, float *container_x, float *container_y);
/* ----- render texture management ----- */
@ -480,4 +486,5 @@ void render_container_add_quad(render_container *container, float x0, float y0,
void render_container_add_char(render_container *container, float x0, float y0, float height, float aspect, rgb_t argb, render_font *font, UINT16 ch);
#endif /* __RENDER_H__ */

View File

@ -17,6 +17,7 @@
#include "render.h"
#include "rendfont.h"
#include "ui.h"
#include "uiinput.h"
#include "uimenu.h"
#include "uigfx.h"
@ -348,8 +349,16 @@ int ui_display_startup_screens(running_machine *machine, int first_time, int sho
break;
case 2:
if (show_gameinfo && sprintf_game_info(machine, messagebox_text))
ui_set_handler(handler_messagebox_anykey, 0);
if (show_gameinfo)
{
astring *tempstring = game_info_astring(machine, astring_alloc());
if (astring_len(tempstring) > 0)
{
strcpy(messagebox_text, astring_c(tempstring));
ui_set_handler(handler_messagebox_anykey, 0);
}
astring_free(tempstring);
}
break;
#ifdef MESS
case 3:
@ -564,10 +573,11 @@ void ui_draw_text(const char *buf, float x, float y)
and full size computation
-------------------------------------------------*/
void ui_draw_text_full(const char *origs, float x, float y, float wrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight)
void ui_draw_text_full(const char *origs, float x, float y, float origwrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight)
{
float lineheight = ui_get_line_height();
const char *ends = origs + strlen(origs);
float wrapwidth = origwrapwidth;
const char *s = origs;
const char *linestart;
float cury = y;
@ -690,9 +700,9 @@ void ui_draw_text_full(const char *origs, float x, float y, float wrapwidth, int
/* align according to the justfication */
if (line_justify == JUSTIFY_CENTER)
curx += (wrapwidth - curwidth) * 0.5f;
curx += (origwrapwidth - curwidth) * 0.5f;
else if (line_justify == JUSTIFY_RIGHT)
curx += wrapwidth - curwidth;
curx += origwrapwidth - curwidth;
/* track the maximum width of any given line */
if (curwidth > maxwidth)
@ -1037,19 +1047,18 @@ static int sprintf_warnings(running_machine *machine, char *buffer)
/*-------------------------------------------------
sprintf_game_info - print the game info text
to the given buffer
game_info_astring - populate an allocated
string with the game info text
-------------------------------------------------*/
int sprintf_game_info(running_machine *machine, char *buffer)
astring *game_info_astring(running_machine *machine, astring *string)
{
int scrcount = video_screen_count(machine->config);
char *bufptr = buffer;
int cpunum, sndnum;
int count;
/* print description, manufacturer, and CPU: */
bufptr += sprintf(bufptr, "%s\n%s %s\n\nCPU:\n", machine->gamedrv->description, machine->gamedrv->year, machine->gamedrv->manufacturer);
astring_printf(string, "%s\n%s %s\n\nCPU:\n", machine->gamedrv->description, machine->gamedrv->year, machine->gamedrv->manufacturer);
/* loop over all CPUs */
for (cpunum = 0; cpunum < MAX_CPU && machine->config->cpu[cpunum].type != CPU_DUMMY; cpunum += count)
@ -1065,14 +1074,14 @@ int sprintf_game_info(running_machine *machine, char *buffer)
/* if more than one, prepend a #x in front of the CPU name */
if (count > 1)
bufptr += sprintf(bufptr, "%d" UTF8_MULTIPLY, count);
bufptr += sprintf(bufptr, "%s", cputype_name(type));
astring_catprintf(string, "%d" UTF8_MULTIPLY, count);
astring_catc(string, cputype_name(type));
/* display clock in kHz or MHz */
if (clock >= 1000000)
bufptr += sprintf(bufptr, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
astring_catprintf(string, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
else
bufptr += sprintf(bufptr, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
astring_catprintf(string, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
}
/* loop over all sound chips */
@ -1083,7 +1092,7 @@ int sprintf_game_info(running_machine *machine, char *buffer)
/* append the Sound: string */
if (sndnum == 0)
bufptr += sprintf(bufptr, "\nSound:\n");
astring_catc(string, "\nSound:\n");
/* count how many identical sound chips we have */
for (count = 1; sndnum + count < MAX_SOUND; count++)
@ -1093,22 +1102,22 @@ int sprintf_game_info(running_machine *machine, char *buffer)
/* if more than one, prepend a #x in front of the CPU name */
if (count > 1)
bufptr += sprintf(bufptr, "%d" UTF8_MULTIPLY, count);
bufptr += sprintf(bufptr, "%s", sndnum_name(sndnum));
astring_catprintf(string, "%d" UTF8_MULTIPLY, count);
astring_catc(string, sndnum_name(sndnum));
/* display clock in kHz or MHz */
if (clock >= 1000000)
bufptr += sprintf(bufptr, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
astring_catprintf(string, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
else if (clock != 0)
bufptr += sprintf(bufptr, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
astring_catprintf(string, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
else
*bufptr++ = '\n';
astring_catc(string, "\n");
}
/* display screen information */
bufptr += sprintf(bufptr, "\nVideo:\n");
astring_catc(string, "\nVideo:\n");
if (scrcount == 0)
buffer += sprintf(bufptr, "None\n");
astring_catc(string, "None\n");
else
{
const device_config *screen;
@ -1118,15 +1127,15 @@ int sprintf_game_info(running_machine *machine, char *buffer)
const screen_config *scrconfig = screen->inline_config;
if (scrcount > 1)
bufptr += sprintf(bufptr, "%s: ", slider_get_screen_desc(screen));
astring_catc(string, slider_get_screen_desc(screen));
if (scrconfig->type == SCREEN_TYPE_VECTOR)
bufptr += sprintf(bufptr, "Vector\n");
astring_catc(string, "Vector\n");
else
{
const rectangle *visarea = video_screen_get_visible_area(screen);
bufptr += sprintf(bufptr, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
astring_catprintf(string, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
visarea->max_x - visarea->min_x + 1,
visarea->max_y - visarea->min_y + 1,
(machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H",
@ -1134,8 +1143,8 @@ int sprintf_game_info(running_machine *machine, char *buffer)
}
}
}
return bufptr - buffer;
return string;
}
@ -1167,15 +1176,15 @@ static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state)
ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
/* an 'O' or left joystick kicks us to the next state */
if (state == 0 && (input_code_pressed_once(KEYCODE_O) || input_ui_pressed(machine, IPT_UI_LEFT)))
if (state == 0 && (input_code_pressed_once(KEYCODE_O) || ui_input_pressed(machine, IPT_UI_LEFT)))
state++;
/* a 'K' or right joystick exits the state */
else if (state == 1 && (input_code_pressed_once(KEYCODE_K) || input_ui_pressed(machine, IPT_UI_RIGHT)))
else if (state == 1 && (input_code_pressed_once(KEYCODE_K) || ui_input_pressed(machine, IPT_UI_RIGHT)))
state = UI_HANDLER_CANCEL;
/* if the user cancels, exit out completely */
else if (input_ui_pressed(machine, IPT_UI_CANCEL))
else if (ui_input_pressed(machine, IPT_UI_CANCEL))
{
mame_schedule_exit(machine);
state = UI_HANDLER_CANCEL;
@ -1197,7 +1206,7 @@ static UINT32 handler_messagebox_anykey(running_machine *machine, UINT32 state)
ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
/* if the user cancels, exit out completely */
if (input_ui_pressed(machine, IPT_UI_CANCEL))
if (ui_input_pressed(machine, IPT_UI_CANCEL))
{
mame_schedule_exit(machine);
state = UI_HANDLER_CANCEL;
@ -1234,8 +1243,8 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
ui_draw_text_full(profiler_get_text(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
/* let the cheat engine display its stuff */
if (options_get_bool(mame_options(), OPTION_CHEAT))
cheat_display_watches(machine);
// if (options_get_bool(mame_options(), OPTION_CHEAT))
// cheat_display_watches(machine);
/* display any popup messages */
if (osd_ticks() < popup_text_end)
@ -1256,25 +1265,25 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
#endif /* MESS */
/* if the user pressed ESC, stop the emulation */
if (input_ui_pressed(machine, IPT_UI_CANCEL))
if (ui_input_pressed(machine, IPT_UI_CANCEL))
mame_schedule_exit(machine);
/* turn on menus if requested */
if (input_ui_pressed(machine, IPT_UI_CONFIGURE))
if (ui_input_pressed(machine, IPT_UI_CONFIGURE))
return ui_set_handler(ui_menu_ui_handler, 0);
/* if the on-screen display isn't up and the user has toggled it, turn it on */
if ((machine->debug_flags & DEBUG_FLAG_ENABLED) == 0 && input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY))
if ((machine->debug_flags & DEBUG_FLAG_ENABLED) == 0 && ui_input_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY))
return ui_set_handler(handler_slider, 0);
/* handle a reset request */
if (input_ui_pressed(machine, IPT_UI_RESET_MACHINE))
if (ui_input_pressed(machine, IPT_UI_RESET_MACHINE))
mame_schedule_hard_reset(machine);
if (input_ui_pressed(machine, IPT_UI_SOFT_RESET))
if (ui_input_pressed(machine, IPT_UI_SOFT_RESET))
mame_schedule_soft_reset(machine);
/* handle a request to display graphics/palette */
if (input_ui_pressed(machine, IPT_UI_SHOW_GFX))
if (ui_input_pressed(machine, IPT_UI_SHOW_GFX))
{
if (!is_paused)
mame_pause(machine, TRUE);
@ -1282,25 +1291,25 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
}
/* handle a save state request */
if (input_ui_pressed(machine, IPT_UI_SAVE_STATE))
if (ui_input_pressed(machine, IPT_UI_SAVE_STATE))
{
mame_pause(machine, TRUE);
return ui_set_handler(handler_load_save, LOADSAVE_SAVE);
}
/* handle a load state request */
if (input_ui_pressed(machine, IPT_UI_LOAD_STATE))
if (ui_input_pressed(machine, IPT_UI_LOAD_STATE))
{
mame_pause(machine, TRUE);
return ui_set_handler(handler_load_save, LOADSAVE_LOAD);
}
/* handle a save snapshot request */
if (input_ui_pressed(machine, IPT_UI_SNAPSHOT))
if (ui_input_pressed(machine, IPT_UI_SNAPSHOT))
video_save_active_screen_snapshots(machine);
/* toggle pause */
if (input_ui_pressed(machine, IPT_UI_PAUSE))
if (ui_input_pressed(machine, IPT_UI_PAUSE))
{
/* with a shift key, it is single step */
if (is_paused && (input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT)))
@ -1313,7 +1322,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
}
/* toggle movie recording */
if (input_ui_pressed(machine, IPT_UI_RECORD_MOVIE))
if (ui_input_pressed(machine, IPT_UI_RECORD_MOVIE))
{
if (!video_mng_is_movie_active(machine))
{
@ -1328,19 +1337,19 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
}
/* toggle profiler display */
if (input_ui_pressed(machine, IPT_UI_SHOW_PROFILER))
if (ui_input_pressed(machine, IPT_UI_SHOW_PROFILER))
ui_set_show_profiler(!ui_get_show_profiler());
/* toggle FPS display */
if (input_ui_pressed(machine, IPT_UI_SHOW_FPS))
if (ui_input_pressed(machine, IPT_UI_SHOW_FPS))
ui_set_show_fps(!ui_get_show_fps());
/* toggle crosshair display */
if (input_ui_pressed(machine, IPT_UI_TOGGLE_CROSSHAIR))
if (ui_input_pressed(machine, IPT_UI_TOGGLE_CROSSHAIR))
crosshair_toggle(machine);
/* increment frameskip? */
if (input_ui_pressed(machine, IPT_UI_FRAMESKIP_INC))
if (ui_input_pressed(machine, IPT_UI_FRAMESKIP_INC))
{
/* get the current value and increment it */
int newframeskip = video_get_frameskip() + 1;
@ -1353,7 +1362,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
}
/* decrement frameskip? */
if (input_ui_pressed(machine, IPT_UI_FRAMESKIP_DEC))
if (ui_input_pressed(machine, IPT_UI_FRAMESKIP_DEC))
{
/* get the current value and decrement it */
int newframeskip = video_get_frameskip() - 1;
@ -1366,7 +1375,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
}
/* toggle throttle? */
if (input_ui_pressed(machine, IPT_UI_THROTTLE))
if (ui_input_pressed(machine, IPT_UI_THROTTLE))
video_set_throttle(!video_get_throttle());
/* check for fast forward */
@ -1380,7 +1389,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
#ifdef MESS
/* paste? */
if (input_ui_pressed(machine, IPT_UI_PASTE))
if (ui_input_pressed(machine, IPT_UI_PASTE))
ui_paste(machine);
#endif /* MESS */
@ -1400,9 +1409,9 @@ static UINT32 handler_slider(running_machine *machine, UINT32 state)
char textbuf[256];
/* left/right control the increment */
if (input_ui_pressed_repeat(machine, IPT_UI_LEFT,6))
if (ui_input_pressed_repeat(machine, IPT_UI_LEFT,6))
increment = -cur->incval;
if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT,6))
if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT,6))
increment = cur->incval;
/* alt goes to 1, shift goes 10x smaller, control goes 10x larger */
@ -1420,7 +1429,7 @@ static UINT32 handler_slider(running_machine *machine, UINT32 state)
newval = (*cur->update)(machine, 0, NULL, cur->arg) + increment;
/* select resets to the default value */
if (input_ui_pressed(machine, IPT_UI_SELECT))
if (ui_input_pressed(machine, IPT_UI_SELECT))
newval = cur->defval;
/* clamp within bounds */
@ -1436,17 +1445,17 @@ static UINT32 handler_slider(running_machine *machine, UINT32 state)
slider_display(textbuf, cur->minval, cur->maxval, cur->defval, newval);
/* up/down select which slider to control */
if (input_ui_pressed_repeat(machine, IPT_UI_DOWN,6))
if (ui_input_pressed_repeat(machine, IPT_UI_DOWN,6))
slider_current = (slider_current + 1) % slider_count;
if (input_ui_pressed_repeat(machine, IPT_UI_UP,6))
if (ui_input_pressed_repeat(machine, IPT_UI_UP,6))
slider_current = (slider_current + slider_count - 1) % slider_count;
/* the slider toggle or ESC will cancel out of our display */
if (input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY) || input_ui_pressed(machine, IPT_UI_CANCEL))
if (ui_input_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY) || ui_input_pressed(machine, IPT_UI_CANCEL))
return UI_HANDLER_CANCEL;
/* the menu key will take us directly to the menu */
if (input_ui_pressed(machine, IPT_UI_CONFIGURE))
if (ui_input_pressed(machine, IPT_UI_CONFIGURE))
return ui_set_handler(ui_menu_ui_handler, 0);
return 0;
@ -1475,7 +1484,7 @@ static UINT32 handler_load_save(running_machine *machine, UINT32 state)
ui_draw_message_window("Select position to load from");
/* check for cancel key */
if (input_ui_pressed(machine, IPT_UI_CANCEL))
if (ui_input_pressed(machine, IPT_UI_CANCEL))
{
/* display a popup indicating things were cancelled */
if (state == LOADSAVE_SAVE)

View File

@ -136,6 +136,6 @@ int ui_is_menu_active(void);
int ui_is_slider_active(void);
/* print the game info string into a buffer */
int sprintf_game_info(running_machine *machine, char *buffer);
astring *game_info_astring(running_machine *machine, astring *string);
#endif /* __USRINTRF_H__ */

View File

@ -10,6 +10,7 @@
*********************************************************************/
#include "ui.h"
#include "uiinput.h"
#include "render.h"
#include "rendfont.h"
#include "rendutil.h"
@ -201,16 +202,16 @@ again:
}
/* handle keys */
if (input_ui_pressed(machine, IPT_UI_SELECT))
if (ui_input_pressed(machine, IPT_UI_SELECT))
{
state->mode = (state->mode + 1) % 3;
state->bitmap_dirty = TRUE;
}
if (input_ui_pressed(machine, IPT_UI_PAUSE))
if (ui_input_pressed(machine, IPT_UI_PAUSE))
mame_pause(machine, !mame_is_paused(machine));
if (input_ui_pressed(machine, IPT_UI_CANCEL) || input_ui_pressed(machine, IPT_UI_SHOW_GFX))
if (ui_input_pressed(machine, IPT_UI_CANCEL) || ui_input_pressed(machine, IPT_UI_SHOW_GFX))
goto cancel;
return uistate;
@ -359,9 +360,9 @@ static void palette_handle_keys(running_machine *machine, ui_gfx_state *state)
int total;
/* handle zoom (minus,plus) */
if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT))
if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
state->palette.count /= 2;
if (input_ui_pressed(machine, IPT_UI_ZOOM_IN))
if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
state->palette.count *= 2;
/* clamp within range */
@ -371,9 +372,9 @@ static void palette_handle_keys(running_machine *machine, ui_gfx_state *state)
state->palette.count = 64;
/* handle colormap selection (open bracket,close bracket) */
if (input_ui_pressed(machine, IPT_UI_PREV_GROUP))
if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
state->palette.which--;
if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP))
if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
state->palette.which++;
/* clamp within range */
@ -390,17 +391,17 @@ static void palette_handle_keys(running_machine *machine, ui_gfx_state *state)
screencount = rowcount * rowcount;
/* handle keyboard navigation */
if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
state->palette.offset -= rowcount;
if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
state->palette.offset += rowcount;
if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
state->palette.offset -= screencount;
if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
state->palette.offset += screencount;
if (input_ui_pressed_repeat(machine, IPT_UI_HOME, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_HOME, 4))
state->palette.offset = 0;
if (input_ui_pressed_repeat(machine, IPT_UI_END, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_END, 4))
state->palette.offset = total;
/* clamp within range */
@ -594,7 +595,7 @@ static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, in
int temp, set;
/* handle gfxset selection (open bracket,close bracket) */
if (input_ui_pressed(machine, IPT_UI_PREV_GROUP))
if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
{
for (temp = state->gfxset.set - 1; temp >= 0; temp--)
if (Machine->gfx[temp] != NULL)
@ -602,7 +603,7 @@ static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, in
if (temp >= 0)
state->gfxset.set = temp;
}
if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP))
if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
{
for (temp = state->gfxset.set + 1; temp < MAX_GFX_ELEMENTS; temp++)
if (Machine->gfx[temp] != NULL)
@ -616,9 +617,9 @@ static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, in
gfx = Machine->gfx[set];
/* handle cells per line (minus,plus) */
if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT))
if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
state->gfxset.count[set] = xcells - 1;
if (input_ui_pressed(machine, IPT_UI_ZOOM_IN))
if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
state->gfxset.count[set] = xcells + 1;
/* clamp within range */
@ -628,21 +629,21 @@ static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, in
state->gfxset.count[set] = 32;
/* handle rotation (R) */
if (input_ui_pressed(machine, IPT_UI_ROTATE))
if (ui_input_pressed(machine, IPT_UI_ROTATE))
state->gfxset.rotate[set] = orientation_add(ROT90, state->gfxset.rotate[set]);
/* handle navigation within the cells (up,down,pgup,pgdown) */
if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
state->gfxset.offset[set] -= xcells;
if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
state->gfxset.offset[set] += xcells;
if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
state->gfxset.offset[set] -= xcells * ycells;
if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
state->gfxset.offset[set] += xcells * ycells;
if (input_ui_pressed_repeat(machine, IPT_UI_HOME, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_HOME, 4))
state->gfxset.offset[set] = 0;
if (input_ui_pressed_repeat(machine, IPT_UI_END, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_END, 4))
state->gfxset.offset[set] = gfx->total_elements;
/* clamp within range */
@ -652,9 +653,9 @@ static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, in
state->gfxset.offset[set] = 0;
/* handle color selection (left,right) */
if (input_ui_pressed_repeat(machine, IPT_UI_LEFT, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 4))
state->gfxset.color[set] -= 1;
if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 4))
state->gfxset.color[set] += 1;
/* clamp within range */
@ -955,9 +956,9 @@ static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, i
int step;
/* handle tilemap selection (open bracket,close bracket) */
if (input_ui_pressed(machine, IPT_UI_PREV_GROUP))
if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
state->tilemap.which--;
if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP))
if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
state->tilemap.which++;
/* clamp within range */
@ -970,9 +971,9 @@ static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, i
tilemap_size_by_index(state->tilemap.which, &mapwidth, &mapheight);
/* handle zoom (minus,plus) */
if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT))
if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
state->tilemap.zoom--;
if (input_ui_pressed(machine, IPT_UI_ZOOM_IN))
if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
state->tilemap.zoom++;
/* clamp within range */
@ -989,20 +990,20 @@ static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, i
}
/* handle rotation (R) */
if (input_ui_pressed(machine, IPT_UI_ROTATE))
if (ui_input_pressed(machine, IPT_UI_ROTATE))
state->tilemap.rotate = orientation_add(ROT90, state->tilemap.rotate);
/* handle navigation (up,down,left,right) */
step = 8;
if (input_code_pressed(KEYCODE_LSHIFT)) step = 1;
if (input_code_pressed(KEYCODE_LCONTROL)) step = 64;
if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
state->tilemap.yoffs -= step;
if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4))
if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
state->tilemap.yoffs += step;
if (input_ui_pressed_repeat(machine, IPT_UI_LEFT, 6))
if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 6))
state->tilemap.xoffs -= step;
if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT, 6))
if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 6))
state->tilemap.xoffs += step;
/* clamp within range */

281
src/emu/uiinput.c Normal file
View File

@ -0,0 +1,281 @@
/***************************************************************************
uiinput.c
Internal MAME user interface input state.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
***************************************************************************/
#include "uiinput.h"
#include "mame.h"
#include "inptport.h"
#include "profiler.h"
#include "render.h"
#include "deprecat.h"
/***************************************************************************
CONSTANTS
***************************************************************************/
#define EVENT_QUEUE_SIZE 128
enum
{
SEQ_PRESSED_FALSE = 0, /* not pressed */
SEQ_PRESSED_TRUE, /* pressed */
SEQ_PRESSED_RESET /* reset -- converted to FALSE once detected as not pressed */
};
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
/* private input port state */
struct _ui_input_private
{
/* pressed states; retrieved with ui_input_pressed() */
osd_ticks_t next_repeat[__ipt_max];
UINT8 seqpressed[__ipt_max];
/* mouse position/info */
render_target * current_mouse_target;
INT32 current_mouse_x;
INT32 current_mouse_y;
/* popped states; ring buffer of ui_events */
ui_event events[EVENT_QUEUE_SIZE];
int events_start;
int events_end;
};
/***************************************************************************
FUNCTION PROTOYPES
***************************************************************************/
static void ui_input_frame_update(running_machine *machine);
/***************************************************************************
INITIALIZATION
***************************************************************************/
/*-------------------------------------------------
ui_input_init - initializes the UI input
system
-------------------------------------------------*/
void ui_input_init(running_machine *machine)
{
/* create the private data */
machine->ui_input_data = auto_malloc(sizeof(*machine->ui_input_data));
memset(machine->ui_input_data, 0, sizeof(*machine->ui_input_data));
machine->ui_input_data->current_mouse_x = -1;
machine->ui_input_data->current_mouse_y = -1;
/* add a frame callback to poll inputs */
add_frame_callback(machine, ui_input_frame_update);
}
/***************************************************************************
EVENT HANDLING
***************************************************************************/
/*-------------------------------------------------
ui_input_frame_update - looks through pressed
input as per events pushed our way and posts
corresponding IPT_UI_* events
-------------------------------------------------*/
static void ui_input_frame_update(running_machine *machine)
{
ui_input_private *uidata = machine->ui_input_data;
int code;
/* update the state of all the UI keys */
for (code = __ipt_ui_start; code <= __ipt_ui_end; code++)
{
int pressed = input_seq_pressed(input_type_seq(machine, code, 0, SEQ_TYPE_STANDARD));
if (!pressed || uidata->seqpressed[code] != SEQ_PRESSED_RESET)
uidata->seqpressed[code] = pressed;
}
}
/*-------------------------------------------------
ui_input_push_event - pushes a single event
onto the queue
-------------------------------------------------*/
int ui_input_push_event(running_machine *machine, ui_event evt)
{
ui_input_private *uidata = machine->ui_input_data;
/* we may be called before the UI is initialized */
if (uidata == NULL)
return FALSE;
/* some pre-processing (this is an icky place to do this stuff!) */
switch (evt.event_type)
{
case UI_EVENT_MOUSE_MOVE:
uidata->current_mouse_target = evt.target;
uidata->current_mouse_x = evt.mouse_x;
uidata->current_mouse_y = evt.mouse_y;
break;
case UI_EVENT_MOUSE_LEAVE:
if (uidata->current_mouse_target == evt.target)
{
uidata->current_mouse_target = NULL;
uidata->current_mouse_x = -1;
uidata->current_mouse_y = -1;
}
break;
default:
/* do nothing */
break;
}
/* is the queue filled up? */
if ((uidata->events_end + 1) % ARRAY_LENGTH(uidata->events) == uidata->events_start)
return FALSE;
uidata->events[uidata->events_end++] = evt;
uidata->events_end %= ARRAY_LENGTH(uidata->events);
return TRUE;
}
/*-------------------------------------------------
ui_input_pop_event - pops an event off of the queue
-------------------------------------------------*/
int ui_input_pop_event(running_machine *machine, ui_event *evt)
{
ui_input_private *uidata = machine->ui_input_data;
int result;
if (uidata->events_start != uidata->events_end)
{
*evt = uidata->events[uidata->events_start++];
uidata->events_start %= ARRAY_LENGTH(uidata->events);
result = TRUE;
}
else
{
memset(evt, 0, sizeof(*evt));
result = FALSE;
}
return result;
}
/*-------------------------------------------------
ui_input_reset - clears all outstanding events
and resets the sequence states
-------------------------------------------------*/
void ui_input_reset(running_machine *machine)
{
ui_input_private *uidata = machine->ui_input_data;
int code;
uidata->events_start = 0;
uidata->events_end = 0;
for (code = __ipt_ui_start; code <= __ipt_ui_end; code++)
{
uidata->seqpressed[code] = SEQ_PRESSED_RESET;
uidata->next_repeat[code] = 0;
}
}
/*-------------------------------------------------
ui_input_find_mouse - retrieves the current
location of the mouse
-------------------------------------------------*/
render_target *ui_input_find_mouse(running_machine *machine, INT32 *x, INT32 *y)
{
ui_input_private *uidata = machine->ui_input_data;
if (x != NULL)
*x = uidata->current_mouse_x;
if (y != NULL)
*y = uidata->current_mouse_y;
return uidata->current_mouse_target;
}
/***************************************************************************
USER INTERFACE SEQUENCE READING
***************************************************************************/
/*-------------------------------------------------
ui_input_pressed - return TRUE if a key down
for the given user interface sequence is
detected
-------------------------------------------------*/
int ui_input_pressed(running_machine *machine, int code)
{
return ui_input_pressed_repeat(machine, code, 0);
}
/*-------------------------------------------------
ui_input_pressed_repeat - return TRUE if a key
down for the given user interface sequence is
detected, or if autorepeat at the given speed
is triggered
-------------------------------------------------*/
int ui_input_pressed_repeat(running_machine *machine, int code, int speed)
{
ui_input_private *uidata = machine->ui_input_data;
int pressed = FALSE;
profiler_mark(PROFILER_INPUT);
/* get the status of this key (assumed to be only in the defaults) */
assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16);
pressed = (uidata->seqpressed[code] == SEQ_PRESSED_TRUE);
/* if down, handle it specially */
if (pressed)
{
osd_ticks_t tps = osd_ticks_per_second();
/* if this is the first press, set a 3x delay and leave pressed = 1 */
if (uidata->next_repeat[code] == 0)
uidata->next_repeat[code] = osd_ticks() + 3 * speed * tps / 60;
/* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */
else if (speed > 0 && (osd_ticks() + tps - uidata->next_repeat[code]) >= tps)
uidata->next_repeat[code] += 1 * speed * tps / 60;
/* otherwise, reset pressed = 0 */
else
pressed = FALSE;
}
/* if we're not pressed, reset the memory field */
else
uidata->next_repeat[code] = 0;
profiler_mark(PROFILER_END);
return pressed;
}

172
src/emu/uiinput.h Normal file
View File

@ -0,0 +1,172 @@
/***************************************************************************
uiinput.h
Internal MAME user interface input state.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
***************************************************************************/
#pragma once
#ifndef __UIINPUT_H__
#define __UIINPUT_H__
#include "mamecore.h"
#include "render.h"
#include "unicode.h"
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
enum _ui_event_type
{
UI_EVENT_NONE,
UI_EVENT_MOUSE_MOVE,
UI_EVENT_MOUSE_LEAVE,
UI_EVENT_MOUSE_CLICK,
UI_EVENT_MOUSE_DOUBLE_CLICK,
UI_EVENT_CHAR
};
typedef enum _ui_event_type ui_event_type;
typedef struct _ui_event ui_event;
struct _ui_event
{
ui_event_type event_type;
render_target * target;
INT32 mouse_x;
INT32 mouse_y;
input_item_id key;
unicode_char ch;
};
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
/* ----- core system management ----- */
/* initialization */
void ui_input_init(running_machine *machine);
/* ----- event handling ----- */
/* pushes a single event onto the queue */
int ui_input_push_event(running_machine *machine, ui_event event);
/* pops an event off of the queue */
int ui_input_pop_event(running_machine *machine, ui_event *event);
/* clears all outstanding events */
void ui_input_reset(running_machine *machine);
/* retrieves the current location of the mouse */
render_target *ui_input_find_mouse(running_machine *machine, INT32 *x, INT32 *y);
/* ----- user interface sequence reading ----- */
/* return TRUE if a key down for the given user interface sequence is detected */
int ui_input_pressed(running_machine *machine, int code);
/* return TRUE if a key down for the given user interface sequence is detected, or if
autorepeat at the given speed is triggered */
int ui_input_pressed_repeat(running_machine *machine, int code, int speed);
/***************************************************************************
INLINE FUNCTIONS
***************************************************************************/
/*-------------------------------------------------
ui_input_push_mouse_move_event - pushes a mouse
move event to the specified render_target
-------------------------------------------------*/
INLINE void ui_input_push_mouse_move_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
{
ui_event event = { UI_EVENT_NONE };
event.event_type = UI_EVENT_MOUSE_MOVE;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
ui_input_push_event(machine, event);
}
/*-------------------------------------------------
ui_input_push_mouse_leave_event - pushes a
mouse leave event to the specified render_target
-------------------------------------------------*/
INLINE void ui_input_push_mouse_leave_event(running_machine *machine, render_target *target)
{
ui_event event = { UI_EVENT_NONE };
event.event_type = UI_EVENT_MOUSE_LEAVE;
event.target = target;
ui_input_push_event(machine, event);
}
/*-------------------------------------------------
ui_input_push_mouse_click_event - pushes a mouse
click event to the specified render_target
-------------------------------------------------*/
INLINE void ui_input_push_mouse_click_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
{
ui_event event = { UI_EVENT_NONE };
event.event_type = UI_EVENT_MOUSE_CLICK;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
ui_input_push_event(machine, event);
}
/*-------------------------------------------------
ui_input_push_mouse_double_click_event - pushes
a mouse double-click event to the specified
render_target
-------------------------------------------------*/
INLINE void ui_input_push_mouse_double_click_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
{
ui_event event = { UI_EVENT_NONE };
event.event_type = UI_EVENT_MOUSE_DOUBLE_CLICK;
event.target = target;
event.mouse_x = x;
event.mouse_y = y;
ui_input_push_event(machine, event);
}
/*-------------------------------------------------
ui_input_push_char_event - pushes a char event
to the specified render_target
-------------------------------------------------*/
INLINE void ui_input_push_char_event(running_machine *machine, render_target *target, unicode_char ch)
{
ui_event event = { UI_EVENT_NONE };
event.event_type = UI_EVENT_CHAR;
event.target = target;
event.ch = ch;
ui_input_push_event(machine, event);
}
#endif /* __UIINPUT_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -22,12 +22,27 @@
***************************************************************************/
/* flags for menu items */
#define MENU_FLAG_LEFT_ARROW (1 << 0)
#define MENU_FLAG_RIGHT_ARROW (1 << 1)
#define MENU_FLAG_INVERT (1 << 2)
#define MENU_FLAG_LEFT_ARROW (1 << 0)
#define MENU_FLAG_RIGHT_ARROW (1 << 1)
#define MENU_FLAG_INVERT (1 << 2)
#define MENU_FLAG_MULTILINE (1 << 3)
#define MENU_FLAG_REDTEXT (1 << 4)
/* special menu item for separators */
#define MENU_SEPARATOR_ITEM "---"
#define MENU_SEPARATOR_ITEM "---"
/* flags to pass to ui_menu_process */
#define UI_MENU_PROCESS_NOKEYS 1
#define UI_MENU_PROCESS_LR_REPEAT 2
/* options for ui_menu_reset */
enum _ui_menu_reset_options
{
UI_MENU_RESET_SELECT_FIRST,
UI_MENU_RESET_REMEMBER_POSITION,
UI_MENU_RESET_REMEMBER_REF
};
typedef enum _ui_menu_reset_options ui_menu_reset_options;
@ -35,25 +50,22 @@
TYPE DEFINITIONS
***************************************************************************/
typedef UINT32 (*ui_menu_handler_func)(running_machine *machine, UINT32 state);
/* forward declarations */
typedef struct _ui_menu ui_menu;
typedef struct _ui_menu_item ui_menu_item;
struct _ui_menu_item
/* menu-related callback functions */
typedef void (*ui_menu_handler_func)(running_machine *machine, ui_menu *menu, void *parameter, void *state);
typedef void (*ui_menu_custom_func)(running_machine *machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
/* menu-related events */
typedef struct _ui_menu_event ui_menu_event;
struct _ui_menu_event
{
const char *text;
const char *subtext;
UINT32 flags;
void *ref;
};
typedef struct _menu_extra menu_extra;
struct _menu_extra
{
float top; /* amount of extra height to add at the top */
float bottom; /* amount of extra height to add at the bottom*/
void (*render)(const menu_extra *extra, float x, float y, float x2, float y2);
void * param; /* parameter to pass through */
void * itemref; /* reference for the selected item */
int iptkey; /* one of the IPT_* values from inptport.h */
unicode_char unichar; /* unicode character if iptkey == IPT_SPECIAL */
};
@ -62,23 +74,66 @@ struct _menu_extra
FUNCTION PROTOTYPES
***************************************************************************/
/* ----- core system management ----- */
/* initialization */
void ui_menu_init(running_machine *machine);
/* draw a menu, returning the number of visible items */
int ui_menu_draw(const ui_menu_item *items, int numitems, int selected, const menu_extra *extra);
/* ----- core menu management ----- */
/* allocate a new menu */
ui_menu *ui_menu_alloc(running_machine *machine, ui_menu_handler_func handler, void *parameter);
/* free a menu */
void ui_menu_free(ui_menu *menu);
/* free all items in the menu, and all memory allocated from the memory pool */
void ui_menu_reset(ui_menu *menu, ui_menu_reset_options options);
/* returns TRUE if the menu has any non-default items in it */
int ui_menu_populated(ui_menu *menu);
/* append a new item to the end of the menu */
void ui_menu_item_append(ui_menu *menu, const char *text, const char *subtext, UINT32 flags, void *ref);
/* process a menu, drawing it and returning any interesting events */
const ui_menu_event *ui_menu_process(ui_menu *menu, UINT32 flags);
/* configure the menu for custom rendering */
void ui_menu_set_custom_render(ui_menu *menu, ui_menu_custom_func custom, float top, float bottom);
/* allocate permanent memory to represent the menu's state */
void *ui_menu_alloc_state(ui_menu *menu, size_t size);
/* allocate temporary memory from the menu's memory pool */
void *ui_menu_pool_alloc(ui_menu *menu, size_t size);
/* make a temporary string copy in the menu's memory pool */
const char *ui_menu_pool_strdup(ui_menu *menu, const char *string);
/* ----- menu stack management ----- */
/* reset the menus, clearing everything */
void ui_menu_stack_reset(running_machine *machine);
/* push a new menu onto the stack */
void ui_menu_stack_push(ui_menu *menu);
/* pop a menu from the stack */
void ui_menu_stack_pop(running_machine *machine);
/* ----- UI system interaction ----- */
/* master handler */
UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state);
/* menu keyboard handling */
int ui_menu_generic_keys(running_machine *machine, UINT32 *selected, int num_items, int visible_items);
/* menu stack management */
void ui_menu_stack_reset(void);
UINT32 ui_menu_stack_push(ui_menu_handler_func new_handler, UINT32 new_state);
UINT32 ui_menu_stack_pop(void);
/* force game select menu */
void ui_menu_force_game_select(void);
int ui_menu_is_force_game_select(void);

View File

@ -335,6 +335,28 @@ int astring_printf(astring *dst, const char *format, ...)
}
/*-------------------------------------------------
astring_catprintf - formatted printf to
the end of an astring
-------------------------------------------------*/
int astring_catprintf(astring *dst, const char *format, ...)
{
char tempbuf[4096];
va_list args;
int result;
/* sprintf into the temporary buffer */
va_start(args, format);
result = vsprintf(tempbuf, format, args);
va_end(args);
/* append the result */
astring_catc(dst, tempbuf);
return result;
}
/***************************************************************************
ASTRING QUERIES

View File

@ -75,6 +75,9 @@ astring *astring_del(astring *str, int start, int count);
/* formatted printf to an astring */
int astring_printf(astring *dst, const char *format, ...) ATTR_PRINTF(2,3);
/* formatted printf to the end of an astring */
int astring_catprintf(astring *dst, const char *format, ...) ATTR_PRINTF(2,3);
/* ----- astring queries ----- */

View File

@ -38,6 +38,7 @@
/* these are UTF-8 encoded strings for common characters */
#define UTF8_NBSP "\xc2\xa0" /* non-breaking space */
#define UTF8_MULTIPLY "\xc3\x97" /* multiplication symbol */
#define UTF8_DEGREES "\xc2\xb0" /* degrees symbol */

View File

@ -18,6 +18,7 @@
// MAME headers
#include "driver.h"
#include "uiinput.h"
#include "debug/debugvw.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
@ -426,7 +427,7 @@ void debugwin_update_during_game(void)
{
// see if the interrupt key is pressed and break if it is
temporarily_fake_that_we_are_not_visible = TRUE;
if (input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK))
if (ui_input_pressed(Machine, IPT_UI_DEBUG_BREAK))
{
debugwin_info *info;
HWND focuswnd = GetFocus();
@ -2890,7 +2891,7 @@ static int global_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam)
int ignoreme;
/* ignore any keys that are received while the debug key is down */
ignoreme = input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK);
ignoreme = ui_input_pressed(Machine, IPT_UI_DEBUG_BREAK);
if (ignoreme)
return 1;

View File

@ -593,17 +593,17 @@ int wininput_should_hide_mouse(void)
// wininput_handle_mouse_button
//============================================================
void wininput_handle_mouse_button(int button, int down, int x, int y)
BOOL wininput_handle_mouse_button(int button, int down, int x, int y)
{
device_info *devinfo;
// ignore if not enabled
if (!input_enabled)
return;
return FALSE;
// only need this for shared axis hack
if (!lightgun_shared_axis_mode || button >= 4)
return;
return FALSE;
// choose a device based on the button
devinfo = lightgun_list;
@ -636,6 +636,7 @@ void wininput_handle_mouse_button(int button, int down, int x, int y)
// release the lock
osd_lock_release(input_lock);
return TRUE;
}

View File

@ -18,7 +18,7 @@
void wininput_init(running_machine *machine);
void wininput_poll(running_machine *machine);
void wininput_handle_mouse_button(int button, int down, int x, int y);
BOOL wininput_handle_mouse_button(int button, int down, int x, int y);
BOOL wininput_handle_raw(HANDLE device);
int wininput_should_hide_mouse(void);

View File

@ -27,6 +27,7 @@
#include "render.h"
#include "rendutil.h"
#include "ui.h"
#include "uiinput.h"
// MAMEOS headers
#include "winmain.h"
@ -351,12 +352,12 @@ finishit:
static void check_osd_inputs(running_machine *machine)
{
// check for toggling fullscreen mode
if (input_ui_pressed(machine, IPT_OSD_1))
if (ui_input_pressed(machine, IPT_OSD_1))
winwindow_toggle_full_screen();
#ifdef MESS
// check for toggling menu bar
if (input_ui_pressed(machine, IPT_OSD_2))
if (ui_input_pressed(machine, IPT_OSD_2))
win_toggle_menubar();
#endif
}

View File

@ -27,6 +27,7 @@
#include "osdepend.h"
#include "driver.h"
#include "deprecat.h"
#include "uiinput.h"
// MAMEOS headers
#include "winmain.h"
@ -376,54 +377,41 @@ void winwindow_process_events(running_machine *machine, int ingame)
// ignore keyboard messages
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
#ifndef MESS
case WM_KEYUP:
case WM_KEYDOWN:
case WM_CHAR:
#endif
dispatch = FALSE;
break;
// forward mouse button downs to the input system
case WM_LBUTTONDOWN:
wininput_handle_mouse_button(0, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(0, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_RBUTTONDOWN:
wininput_handle_mouse_button(1, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(1, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_MBUTTONDOWN:
wininput_handle_mouse_button(2, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(2, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_XBUTTONDOWN:
wininput_handle_mouse_button(3, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(3, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
// forward mouse button ups to the input system
case WM_LBUTTONUP:
wininput_handle_mouse_button(0, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(0, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_RBUTTONUP:
wininput_handle_mouse_button(1, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(1, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_MBUTTONUP:
wininput_handle_mouse_button(2, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(2, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_XBUTTONUP:
wininput_handle_mouse_button(3, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(3, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
}
}
@ -1025,54 +1013,41 @@ static unsigned __stdcall thread_entry(void *param)
// ignore input messages here
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
#ifndef MESS
case WM_KEYUP:
case WM_KEYDOWN:
case WM_CHAR:
#endif // MESS
dispatch = FALSE;
break;
// forward mouse button downs to the input system
case WM_LBUTTONDOWN:
wininput_handle_mouse_button(0, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(0, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_RBUTTONDOWN:
wininput_handle_mouse_button(1, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(1, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_MBUTTONDOWN:
wininput_handle_mouse_button(2, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(2, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_XBUTTONDOWN:
wininput_handle_mouse_button(3, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(3, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
// forward mouse button ups to the input system
case WM_LBUTTONUP:
wininput_handle_mouse_button(0, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(0, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_RBUTTONUP:
wininput_handle_mouse_button(1, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(1, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_MBUTTONUP:
wininput_handle_mouse_button(2, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(2, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
case WM_XBUTTONUP:
wininput_handle_mouse_button(3, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = FALSE;
dispatch = !wininput_handle_mouse_button(3, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
break;
// a terminate message to the thread posts a quit
@ -1231,6 +1206,41 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar
case WM_SYSKEYDOWN:
break;
// input events
case WM_MOUSEMOVE:
ui_input_push_mouse_move_event(Machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_MOUSELEAVE:
ui_input_push_mouse_leave_event(Machine, window->target);
break;
case WM_LBUTTONDOWN:
{
DWORD ticks = GetTickCount();
ui_input_push_mouse_click_event(Machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
// check for a double-click
if (ticks - window->lastclicktime < GetDoubleClickTime() &&
GET_X_LPARAM(lparam) >= window->lastclickx - 4 && GET_X_LPARAM(lparam) <= window->lastclickx + 4 &&
GET_Y_LPARAM(lparam) >= window->lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->lastclicky + 4)
{
window->lastclicktime = 0;
ui_input_push_mouse_double_click_event(Machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
}
else
{
window->lastclicktime = ticks;
window->lastclickx = GET_X_LPARAM(lparam);
window->lastclicky = GET_Y_LPARAM(lparam);
}
break;
}
case WM_CHAR:
ui_input_push_char_event(Machine, window->target, (unicode_char) wparam);
break;
// pause the system when we start a menu or resize
case WM_ENTERSIZEMOVE:
window->resize_state = RESIZE_STATE_RESIZING;

View File

@ -70,6 +70,11 @@ struct _win_window_info
int targetorient;
int targetlayerconfig;
const render_primitive_list *primlist;
// input info
DWORD lastclicktime;
int lastclickx;
int lastclicky;
// drawing data
void * drawdata;