//virtual ~input_code_poller(); public virtual void reset() { // iterate over device classes and devices m_axis_memory.clear(); m_switch_memory.clear(); for (input_device_class classno = input_device_class.DEVICE_CLASS_FIRST_VALID; input_device_class.DEVICE_CLASS_LAST_VALID >= classno; ++classno) { input_class devclass = m_manager.device_class(classno); if (devclass.enabled()) { for (int devnum = 0; devclass.maxindex() >= devnum; ++devnum) { // fetch the device; ignore if nullptr input_device device = devclass.device(devnum); if (device != null) { // iterate over items within each device for (input_item_id itemid = input_item_id.ITEM_ID_FIRST_VALID; device.maxitem() >= itemid; ++itemid) { // for any non-switch items, set memory to the current value input_device_item item = device.item(itemid); if (item != null && (item.itemclass() != input_item_class.ITEM_CLASS_SWITCH)) { m_axis_memory.emplace_back(new std.pair <input_device_item, s32>(item, m_manager.code_value(item.code()))); } } } } } } m_axis_memory.Sort(); //std::sort(m_axis_memory.begin(), m_axis_memory.end()); }
// helpers //------------------------------------------------- // apply_steadykey - apply steadykey option //------------------------------------------------- public void apply_steadykey() { // ignore if not enabled if (!steadykey_enabled()) { return; } // update the state of all the keys and see if any changed state bool anything_changed = false; for (input_item_id itemid = input_item_id.ITEM_ID_FIRST_VALID; itemid <= maxitem(); ++itemid) { input_device_item itm = item(itemid); if (itm != null && itm.itemclass() == input_item_class.ITEM_CLASS_SWITCH) { if (((input_device_switch_item)itm).steadykey_changed()) { anything_changed = true; } } } // if the keyboard state is stable, flush the current state if (!anything_changed) { for (input_item_id itemid = input_item_id.ITEM_ID_FIRST_VALID; itemid <= maxitem(); ++itemid) { input_device_item itm = item(itemid); if (itm != null && itm.itemclass() == input_item_class.ITEM_CLASS_SWITCH) { ((input_device_switch_item)itm).steadykey_update_to_current(); } } } }
public override input_code poll() { // iterate over device classes and devices, skipping disabled classes for (input_device_class classno = input_device_class.DEVICE_CLASS_FIRST_VALID; input_device_class.DEVICE_CLASS_LAST_VALID >= classno; ++classno) { input_class devclass = m_manager.device_class(classno); if (!devclass.enabled()) { continue; } for (int devnum = 0; devclass.maxindex() >= devnum; ++devnum) { // fetch the device; ignore if nullptr input_device device = devclass.device(devnum); if (device == null) { continue; } // iterate over items within each device for (input_item_id itemid = input_item_id.ITEM_ID_FIRST_VALID; device.maxitem() >= itemid; ++itemid) { input_device_item item = device.item(itemid); if (item == null) { continue; } input_code code = item.code(); if (item.itemclass() == input_item_class.ITEM_CLASS_SWITCH) { // item is natively a switch, poll it if (code_pressed_once(code, true)) { return(code); } else { continue; } } throw new emu_unimplemented(); #if false var memory = std.lower_bound( m_axis_memory, item, (std.pair <input_device_item, s32> x, input_device_item y) => { return(x.first < y); }); if ((m_axis_memory.end() == memory) || (item != memory.first)) //if ((m_axis_memory.end() == memory) || (item != memory->first)) { continue; } // poll axes digitally bool moved = item.check_axis(code.item_modifier(), memory.second); code.set_item_class(input_item_class.ITEM_CLASS_SWITCH); if ((classno == input_device_class.DEVICE_CLASS_JOYSTICK) && (code.item_id() == input_item_id.ITEM_ID_XAXIS)) { // joystick X axis - check with left/right modifiers code.set_item_modifier(input_item_modifier.ITEM_MODIFIER_LEFT); if (code_pressed_once(code, moved)) { return(code); } code.set_item_modifier(input_item_modifier.ITEM_MODIFIER_RIGHT); if (code_pressed_once(code, moved)) { return(code); } } else if ((classno == input_device_class.DEVICE_CLASS_JOYSTICK) && (code.item_id() == input_item_id.ITEM_ID_YAXIS)) { // if this is a joystick Y axis, check with up/down modifiers code.set_item_modifier(input_item_modifier.ITEM_MODIFIER_UP); if (code_pressed_once(code, moved)) { return(code); } code.set_item_modifier(input_item_modifier.ITEM_MODIFIER_DOWN); if (code_pressed_once(code, moved)) { return(code); } } else { // any other axis, check with pos/neg modifiers code.set_item_modifier(input_item_modifier.ITEM_MODIFIER_POS); if (code_pressed_once(code, moved)) { return(code); } code.set_item_modifier(input_item_modifier.ITEM_MODIFIER_NEG); if (code_pressed_once(code, moved)) { return(code); } } #endif } } } // if nothing, return an invalid code return(input_code.INPUT_CODE_INVALID); }