From ba9782dcec447370a37bf0aa7d9c03f270c311a3 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Fri, 4 Jan 2008 17:51:33 +0000 Subject: [PATCH] Added new function input_poll_keyboard_switches to poll for only key events. Expanded the size of the maximum simultaneously pressed switches. Should fix editableui0120u4red and cheat0118red. --- src/emu/cheat.c | 6 +++--- src/emu/input.c | 40 +++++++++++++++++++++++++++++++++++++++- src/emu/input.h | 3 +++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/emu/cheat.c b/src/emu/cheat.c index d4c89b4389e..4c97489f5c0 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -964,14 +964,14 @@ static int ReadKeyAsync(int flush) if(flush) // check key input { - while(input_code_poll_switches(TRUE) != INPUT_CODE_INVALID) ; + while(input_code_poll_keyboard_switches(TRUE) != INPUT_CODE_INVALID) ; return 0; } while(1) // check pressed key { - code = input_code_poll_switches(FALSE); + code = input_code_poll_keyboard_switches(FALSE); if(code == INPUT_CODE_INVALID) { @@ -4470,7 +4470,7 @@ static int EditCheatMenu(CheatEntry * entry, int index, int selection) } else { - int code = input_code_poll_switches(FALSE); + int code = input_code_poll_keyboard_switches(FALSE); if(code == KEYCODE_ESC) { diff --git a/src/emu/input.c b/src/emu/input.c index 2f841fadd9a..e7d750a71b5 100644 --- a/src/emu/input.c +++ b/src/emu/input.c @@ -39,7 +39,7 @@ #define JOYSTICK_MAP_STICKY 0x0f /* the largest number of tracked pressed switches for memory */ -#define MAX_PRESSED_SWITCHES 16 +#define MAX_PRESSED_SWITCHES 64 /* invalid memory value for axis polling */ #define INVALID_AXIS_VALUE 0x7fffffff @@ -955,6 +955,44 @@ input_code input_code_poll_switches(int reset) } +/*------------------------------------------------- + input_code_poll_keyboard_switches - poll for + any keyboard-specific input +-------------------------------------------------*/ + +input_code input_code_poll_keyboard_switches(int reset) +{ + input_device_list *devlist = &device_list[DEVICE_CLASS_KEYBOARD]; + int devnum; + + /* if resetting memory, do it now */ + if (reset) + code_pressed_memory_reset(); + + /* iterate over devices within each class */ + for (devnum = 0; devnum < devlist->count; devnum++) + { + input_device *device = &devlist->list[devnum]; + input_item_id itemid; + + /* iterate over items within each device */ + for (itemid = ITEM_ID_INVALID + 1; itemid <= device->maxitem; itemid++) + { + input_device_item *item = device->item[itemid]; + if (item != NULL && item->itemclass == ITEM_CLASS_SWITCH) + { + input_code code = device_item_to_code(device, itemid); + if (input_code_pressed_once(code)) + return code; + } + } + } + + /* if nothing, return an invalid code */ + return INPUT_CODE_INVALID; +} + + /*------------------------------------------------- input_code_poll_axes - poll for any input -------------------------------------------------*/ diff --git a/src/emu/input.h b/src/emu/input.h index 30fd3fea98f..d7dac1c6ffe 100644 --- a/src/emu/input.h +++ b/src/emu/input.h @@ -535,6 +535,9 @@ INT32 input_code_pressed_once(input_code code); /* poll for any switch input, optionally resetting internal memory */ input_code input_code_poll_switches(int reset); +/* poll for any keyboard switch input, optionally resetting internal memory */ +input_code input_code_poll_keyboard_switches(int reset); + /* poll for any axis input, optionally resetting internal memory */ input_code input_code_poll_axes(int reset);