s32 m_memory; // "memory" value, to remember where we started during polling // construction/destruction //------------------------------------------------- // input_device_item - constructor //------------------------------------------------- protected input_device_item(input_device device, string name, object internalobj, input_item_id itemid, item_get_state_func getstate, input_item_class itemclass) { m_device = device; m_name = name; m_internal = internalobj; m_itemid = itemid; m_itemclass = itemclass; m_getstate = getstate; m_current = 0; m_memory = 0; // use a standard token name for know item IDs string standard_token = manager().standard_token(itemid); if (standard_token != null) { m_token = standard_token; } // otherwise, create a tokenized name else { m_token = name; m_token = m_token.ToUpper(); m_token = m_token.Replace(" ", ""); //strdelchr(m_token, ' '); m_token = m_token.Replace("_", ""); //strdelchr(m_token, '_'); } }
// item management //------------------------------------------------- // add_item - add a new item to an input device //------------------------------------------------- public input_item_id add_item(string name, input_item_id itemid, item_get_state_func getstate, object internal_obj = null) { if (machine().phase() != machine_phase.INIT) { throw new emu_fatalerror("Can only call input_device::add_item at init time!"); } assert(itemid > input_item_id.ITEM_ID_INVALID && itemid < input_item_id.ITEM_ID_MAXIMUM); assert(getstate != null); // if we have a generic ID, pick a new internal one input_item_id originalid = itemid; if (itemid >= input_item_id.ITEM_ID_OTHER_SWITCH && itemid <= input_item_id.ITEM_ID_OTHER_AXIS_RELATIVE) { for (itemid = (input_item_id)(input_item_id.ITEM_ID_MAXIMUM + 1); itemid <= input_item_id.ITEM_ID_ABSOLUTE_MAXIMUM; ++itemid) { if (m_item[(int)itemid] == null) { break; } } } assert(itemid <= input_item_id.ITEM_ID_ABSOLUTE_MAXIMUM); // make sure we don't have any overlap assert(m_item[(int)itemid] == null); // determine the class and create the appropriate item class switch (m_manager.device_class(devclass()).standard_item_class(originalid)) { case input_item_class.ITEM_CLASS_SWITCH: m_item[(int)itemid] = new input_device_switch_item(this, name, internal_obj, itemid, getstate); break; case input_item_class.ITEM_CLASS_RELATIVE: m_item[(int)itemid] = new input_device_relative_item(this, name, internal_obj, itemid, getstate); break; case input_item_class.ITEM_CLASS_ABSOLUTE: m_item[(int)itemid] = new input_device_absolute_item(this, name, internal_obj, itemid, getstate); break; default: m_item[(int)itemid] = null; assert(false); break; } // assign the new slot and update the maximum m_maxitem = (input_item_id)std.max((int)m_maxitem, (int)itemid); return(itemid); }
int m_oldkey; // old live state // construction/destruction //------------------------------------------------- // input_device_switch_item - constructor //------------------------------------------------- public input_device_switch_item(input_device device, string name, object internalobj, input_item_id itemid, item_get_state_func getstate) : base(device, name, internalobj, itemid, getstate, input_item_class.ITEM_CLASS_SWITCH) { m_steadykey = 0; m_oldkey = 0; }
// construction/destruction //------------------------------------------------- // input_device_absolute_item - constructor //------------------------------------------------- public input_device_absolute_item(input_device device, string name, object internalobj, input_item_id itemid, item_get_state_func getstate) : base(device, name, internalobj, itemid, getstate, input_item_class.ITEM_CLASS_ABSOLUTE) { }
// construction/destruction //------------------------------------------------- // input_device_relative_item - constructor //------------------------------------------------- public input_device_relative_item(input_device device, string name, object internalobj, input_item_id itemid, item_get_state_func getstate) : base(device, name, internalobj, itemid, getstate, input_item_class.ITEM_CLASS_RELATIVE) { }