コード例 #1
0
        //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());
        }
コード例 #2
0
        // 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);
        }