bool input_manager::code_check_axis(input_device_item &item, input_code code) { // if we've already reported this one, don't bother if (item.memory() == INVALID_AXIS_VALUE) return false; // ignore min/max for lightguns // so the selection will not be affected by a gun going out of range int32_t curval = code_value(code); if (code.device_class() == DEVICE_CLASS_LIGHTGUN && (code.item_id() == ITEM_ID_XAXIS || code.item_id() == ITEM_ID_YAXIS) && (curval == INPUT_ABSOLUTE_MAX || curval == INPUT_ABSOLUTE_MIN)) return false; // compute the diff against memory int32_t diff = curval - item.memory(); if (diff < 0) diff = -diff; // for absolute axes, look for 25% of maximum if (item.itemclass() == ITEM_CLASS_ABSOLUTE && diff > (INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN) / 4) { item.set_memory(INVALID_AXIS_VALUE); return true; } // for relative axes, look for ~20 pixels movement if (item.itemclass() == ITEM_CLASS_RELATIVE && diff > 20 * INPUT_RELATIVE_PER_PIXEL) { item.set_memory(INVALID_AXIS_VALUE); return true; } return false; }
int keyboard_trans_table::vkey_for_mame_code(input_code code) const { // only works for keyboard switches if (code.device_class() == DEVICE_CLASS_KEYBOARD && code.item_class() == ITEM_CLASS_SWITCH) { input_item_id id = code.item_id(); int tablenum; // scan the table for a match for (tablenum = 0; tablenum < m_table_size; tablenum++) if (m_table[tablenum].mame_key == id) return m_table[tablenum].virtual_key; } return 0; }