public SineWave (double frequency = 1, double amplitude = 1, double offset = 0, double updateFrequency = DefaultUpdateFrequency) : base (updateFrequency) { FrequencyInput = AddInput ("FrequencyInput", Units.Frequency, frequency); AmplitudeInput = AddInput ("AmplitudeInput", Units.Scalar, amplitude); OffsetInput = AddInput ("OffsetInput", Units.Scalar, offset); }
private InputPort CreatePort(AbstractReceivePipeline pipeline, string channel, string uri, string concurrency, string frequency, string scheduled) { InputPort port = null; var value = 0; if (!string.IsNullOrEmpty(scheduled)) { if (Int32.TryParse(scheduled, out value)) port = new InputPort(pipeline, channel, uri, value); } else { var parsedConcurrency = 1; var parsedFrequency = 1; if (!string.IsNullOrEmpty(concurrency)) if (Int32.TryParse(concurrency, out parsedConcurrency)) ; if (!string.IsNullOrEmpty(frequency)) if (Int32.TryParse(frequency, out parsedFrequency)) ; port = new InputPort(pipeline, channel, uri, parsedConcurrency, parsedFrequency); } return port; }
internal async Task <byte[]> GetTypeModeAsyncInternal(InputPort port) { Command c = new Command(CommandType.DirectReply, 2, 0); c.GetTypeMode(port, 0, 1); await SendCommandAsyncInternal(c); return(c.Response.Data); }
internal async Task <int> ReadyRawAsyncInternal(InputPort port, int mode) { Command c = new Command(CommandType.DirectReply, 4, 0); c.ReadyRaw(port, mode, 0); await SendCommandAsyncInternal(c); return(BitConverter.ToInt32(c.Response.Data, 0)); }
public static void Main() { #region debug debugLed = new OutputPort(device.DebugLed, false); debugBtn = new InputPort(device.Socket6.Pin3, false, Port.ResistorMode.Disabled); ifDebug = false; currentDebugBtnValue = false; oldDebugBtnValue = false; #endregion // Initialisation des entrées capteurFrontal = new AnalogInput(device.Socket9.AnalogInput3); capteurGauche = new AnalogInput(device.Socket9.AnalogInput4); capteurDroite = new AnalogInput(device.Socket9.AnalogInput5); // Initialisation des sorties roueDroite = new PWM(device.Socket11.Pwm7, 2500, (int)VITESSE_MAX_D, PWM.ScaleFactor.Microseconds, false); roueGauche = new PWM(device.Socket11.Pwm8, 2500, (int)VITESSE_MAX_G, PWM.ScaleFactor.Microseconds, false); // Démarrage des roues roueGauche.Start(); roueDroite.Start(); while (true) { #region debug /* * currentDebugBtnValue = debugBtn.Read(); * if (currentDebugBtnValue == false && oldDebugBtnValue == true) * { * roueGauche.Duration++; * } * * oldDebugBtnValue = currentDebugBtnValue; */ #endregion // Calcul de la vitesse en fonction des données des capteurs //double vitesseG = -((((capteurFrontal.Read() - 0.5) * 2.0) -0.5)- (capteurGauche.Read() - capteurDroite.Read())) / 2 * VMAX; //double vitesseD = ((((capteurFrontal.Read() - 0.5) * 2.0) -0.5)+ (capteurGauche.Read() - capteurDroite.Read())) / 2 * VMAX; double vitesseG = -(((capteurFrontal.Read() - 0.5) * 2.0) - 0.5) * VMAX; double vitesseD = (((capteurFrontal.Read() - 0.5) * 2.0) - 0.5) * VMAX; // Régulation des vitesses des roues roueGauche.Duration = (uint)(VITESSE_MAX_G + vitesseG); roueDroite.Duration = (uint)(VITESSE_MAX_D + vitesseD); #region debug (affichage des données) //Debug.Print("Capteurs : " + capteurDroite.Read() + " || " + capteurFrontal.Read() + " || " + capteurGauche.Read()); Debug.Print("Moteurs : " + roueDroite.Duration.ToString() + " || " + roueGauche.Duration.ToString()); #endregion } }
private void wMain_Closed(object sender, EventArgs e) { if (ip != null) { ip.Stop(); ip.Close(); ip = null; } }
public static void Main() { var axisX = new AnalogInput(Pins.GPIO_PIN_A0); var axisY = new AnalogInput(Pins.GPIO_PIN_A1); var axisZ = new AnalogInput(Pins.GPIO_PIN_A2); var IrFloorSensor = new AnalogInput(Pins.GPIO_PIN_A3); var out1 = new OutputPort(Pins.GPIO_PIN_D1, false); var out2 = new OutputPort(Pins.GPIO_PIN_D12, false); var in1 = new InputPort(Pins.GPIO_PIN_D2, false, Port.ResistorMode.Disabled); var in2 = new InputPort(Pins.GPIO_PIN_D4, false, Port.ResistorMode.PullUp); var servo1 = new PWM(Pins.GPIO_PIN_D9); servo1.SetDutyCycle(0); var servo2 = new PWM(Pins.GPIO_PIN_D10); servo2.SetDutyCycle(0); var stopWatch = Stopwatch.StartNew(); stopWatch.Start(); int i = 0; bool digState = false; while (i < 5000) { axisX.Read(); axisY.Read(); axisZ.Read(); IrFloorSensor.Read(); in1.Read(); in2.Read(); digState = !digState; out1.Write(digState); out2.Write(digState); servo1.SetPulse(20000, 1500); servo2.SetPulse(20000, 1500); i++; } stopWatch.Stop(); Debug.Print("Elapsed: " + stopWatch.ElapsedMilliseconds.ToString()); }
public PushButton() { DigitalInput = AddInput("DigitalInput", Units.Digital); DebounceDuration = TimeSpan.FromTicks(500 * 10000); clickTime = DateTime.UtcNow; DigitalInput.ValueChanged += HandleValueChanged; }
/// <summary> /// Log input to the transcript file, followed by newline. /// Do this only if the transcript is on, and the port is the current input port. /// </summary> /// <param name="str">The input to log.</param> /// <param name="port">The port that it came from.</param> internal void LogInputLine(string str, InputPort port) { if (this.transcriptWriter == null || port != this.interp.CurrentInputPort) { return; } this.transcriptWriter.WriteLine(str); }
public TemplateOptionPortItem( TemplateMultiPassMasterNode owner, TemplateOptionsItem options ) { m_options = options: InputPort port = owner.InputPorts.Find( x => x.Name.Equals( options.Name ) ): if( port != null ) { m_portId = port.PortId: } }
internal async Task <int> ReadyPercentAsyncInternal(InputPort port, int mode) { Command c = new Command(CommandType.DirectReply, 1, 0); c.ReadyRaw(port, mode, 0); await SendCommandAsyncInternal(c); return(c.Response.Data[0]); }
public PushButton() { DigitalInput = AddInput ("DigitalInput", Units.Digital); DebounceDuration = TimeSpan.FromTicks (500 * 10000); clickTime = DateTime.UtcNow; DigitalInput.ValueChanged += HandleValueChanged; }
internal async Task <int> ReadyRawAsyncInternal(InputPort port, int mode) { Command c = _brick.NewCommand(CommandType.Direct, 4, 0); c.ReadyRaw(port, mode, 0); var response = await _brick.SendCommandAsyncInternal(c); return(BitConverter.ToInt32(response.Data, 0)); }
internal async Task <int> ReadyPercentAsyncInternal(InputPort port, int mode) { Command c = _brick.NewCommand(CommandType.Direct, 1, 0); c.ReadyRaw(port, mode, 0); var response = await _brick.SendCommandAsyncInternal(c); return(response.Data[0]); }
internal async Task <byte[]> GetTypeModeAsyncInternal(InputPort port) { Command c = _brick.NewCommand(CommandType.Direct, 2, 0); c.GetTypeMode(port, 0, 1); var response = await _brick.SendCommandAsyncInternal(c); return(response.Data); }
internal async Task <float> ReadySIAsyncInternal(InputPort port, int mode) { Command c = new Command(CommandType.DirectReply, 4, 0); c.ReadySI(port, mode, 0); await _brick.SendCommandAsyncInternal(c); return(BitConverter.ToSingle(c.Response.Data, 0)); }
/// <summary> /// Sets the IR receiver input port. /// </summary> /// <param name="port">The input port.</param> private void SetInputPort(InputPort port) { byte[] inputPortPacket = new byte[SetInputPortPacket.Length]; SetInputPortPacket.CopyTo(inputPortPacket, 0); inputPortPacket[2] = (byte)(port + 1); WriteSync(inputPortPacket); }
public InputGraphConnector(InputPort port, EC.Node pParent) : base(pParent, port.Name, GetDataType(port.DataType)) { Port = port; Port.ConnectionChanged += Port_ConnectionChanged; InstanceId = Guid.NewGuid(); }
private void Connect(OutputPort output, InputPort input) { if (output.Connection != null) { GraphEditor.RemoveConnection(output.Connection); } Connection.AttemptToConnect(CreateConnection(), input, output); //output.Connection = CreateConnection(); //DraggedOutput.Connect(input); }
public DigitalOutputPin(Cpu.Pin pin, double initialValue = 0) { Input = AddInput("Input", Units.Digital, initialValue); port = new HWOutputPort(pin, initialValue >= HighMinValue); Input.ValueChanged += (s, e) => { port.Write(Input.Value >= HighMinValue); }; }
public MetricMultiplyValue(Graph graph) : base("Multiply", graph, InputPort.CreateMany(InputPort.Create("in", PortDataType.Array), InputPort.Create("f", PortDataType.Value)), OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array))) { _portInp = (DataInputPort)InputPorts[0]; _inputValue = (ValueInputPort)InputPorts[1]; _portOut = (DataOutputPort)OutputPorts[0]; }
public Switch(params Connection[][] connectionGroups) { groups = connectionGroups; Input = AddInput("Input", Units.Scalar); Input.ValueChanged += (s, e) => SetSelection(); SetSelection(); }
public IActionResult OnPostSetInputPort(int deviceIndex, InputPort inputPort) { Debug.Assert(deviceIndex < _numHdmiSwitches); if (deviceIndex < _numHdmiSwitches) { _devices[deviceIndex].SetInputPort(inputPort); DeviceInfoCaches[deviceIndex].State = _devices[deviceIndex].GetState(); } return(RedirectToPage()); }
public static void Main() { Debug.Print(Resources.GetString(Resources.StringResources.String1)); InputPort microswitch = new InputPort(FEZSpider.Socket4.Pin3, false, Port.ResistorMode.PullDown); while (true) { Debug.Print(microswitch.Read().ToString()); } }
public SoftwareShiftRegister(ushort size, Cpu.Pin clock, Cpu.Pin reset, Cpu.Pin data, Cpu.Pin commit, ShiftRegisterCallback callback) { Size = size; _bits = new bool[size]; _clockPin = new InputPort(clock, true, Port.ResistorMode.Disabled); _resetPin = new InputPort(reset, true, Port.ResistorMode.Disabled); _dataPin = new InputPort(data, true, Port.ResistorMode.Disabled); _commitPin = new InputPort(commit, true, Port.ResistorMode.Disabled); _callback = callback; }
public NativeDigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Cpu.Pin cpuPin) { if (cpuPin == Cpu.Pin.GPIO_NONE) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalInput"); } _port = new InputPort(cpuPin, glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode); }
public MetricFFTBandEnergy(Graph graph) : base("Band Energy", graph, InputPort.CreateMany( InputPort.Create("in", PortDataType.FFT)), OutputPort.CreateMany( OutputPort.Create("out", PortDataType.Value))) { _portInp = (FFTInputPort)InputPorts[0]; _portOut = (ValueOutputPort)OutputPorts[0]; }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <param name="socket">The socket for the digital input interface.</param> /// <param name="pin">The pin used by the digital input interface.</param> /// <param name="glitchFilterMode"> /// A value from the <see cref="GlitchFilterMode"/> enumeration that specifies /// whether to enable the glitch filter on this digital input interface. /// </param> /// <param name="resistorMode"> /// A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself. /// </param> /// <param name="module">The module using this interface, which can be null if unspecified.</param> public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module) { this.port = new InputPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode); if (this.port == null) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Digital Input functionality. Please try a different socket."); } }
public Program() { _trigger = new InputPort(Pins.GPIO_PIN_D4, true, ResistorModes.PullUp); _nrf = new Nrf8001(Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, SPI_Devices.SPI1); _nrf.AciEventReceived += OnAciEventReceived; _nrf.DataReceived += OnDataReceived; _nrf.Setup(SetupData); }
public Switch (params Connection[][] connectionGroups) { groups = connectionGroups; Input = AddInput ("Input", Units.Scalar); Input.ValueChanged += (s, e) => SetSelection (); SetSelection (); }
protected override void InputSamplerateChanged(InputPort e) { _inputBuffer = new TimeLocatedBuffer(GlobalSettings.Instance.BufferSize(_portInp.Samplerate), _portInp.Samplerate); _outputBuffer = new TimeLocatedBuffer(GlobalSettings.Instance.BufferSize(_portInp.Samplerate), _portInp.Samplerate); ((DataInputPort)InputPorts[0]).InitBuffer(); _portOut.Samplerate = _portInp.Samplerate; _bpf.Fc = Fc / _portInp.Samplerate; }
// Creates a new instance of the NEC IR Receiver class internal NECReceiver(Cpu.Pin receiverPin) { _newPress = false; _lastTick = DateTime.Now.Ticks; _irPort = new InterruptPort(receiverPin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); _irPort.OnInterrupt += IrPortOnInterrupt; _irPort.EnableInterrupt(); }
private void toolStripButton_NewInPort_Click(object sender, EventArgs e) { InputPort input = new InputPort(); input.Location = new Point(200, 100 + count_input * 60); panel2.Controls.Add(input); input.label.Text = "port" + count.ToString(); count_input++; count++; input.Refresh(); }
public MetricFilter(Graph graph) : base("Filter", graph, InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)), OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array))) { _portInp = (DataInputPort)InputPorts[0]; _portOut = (DataOutputPort)OutputPorts[0]; Fc = 100000; }
public static void Test() { // Create new Thread that runs the ExampleThreadFunction Thread ExampleThread = new Thread(new ThreadStart(ExampleThreadFunction)); // SD stuff is in PersistentStorage sdPS = new PersistentStorage("SD"); // Led stuff is in OutputPort LED; LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true); // Button stuff in InputPort Button; Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false, Port.ResistorMode.PullUp); while (true) { //Led status at the beginning is off LED.Write(false); if (Button.Read()) { while (Button.Read()) { ; // wait while busy } //Led is on LED.Write(true); // Mount sdPS.MountFileSystem(); // Start our new Thread ExampleThread.Start(); while (Button.Read()) { ; // wait while busy } //Led is off LED.Write(true); // Abort our new Thread ExampleThread.Abort(); // Unmount sdPS.UnmountFileSystem(); } } }
public void Show(InputPort port, DeviceType deviceType, MotorMovementTypes movementType, int degreeMovement, int powerRatingMovement, int timeToMoveInSeconds) { PortName.Text = port.ToString(); ObjectName.Text = deviceType.ToString(); MovementStyle.SelectedIndex = (int) movementType; DegreeSlider.Value = degreeMovement; PowerTimerSlider.Value = timeToMoveInSeconds; PowerSlider.Value = powerRatingMovement; Visibility = Visibility.Visible; }
public override void Build(IConfiguration configuration) { var channel = configuration.Attributes["channel"]; var uri = configuration.Attributes["uri"]; var concurrency = configuration.Attributes["concurrency"]; var frequency = configuration.Attributes["frequency"]; var scheduled = configuration.Attributes["scheduled"]; // build the pipeline for the receive port: var pipelineBuilder = new PipelineBuilder(this.Kernel, configuration); var pipeline = pipelineBuilder.BuildReceivePipeline(); Port = this.CreatePort(pipeline, channel, uri, concurrency, frequency, scheduled); }
public void Show(InputPort port, DeviceType deviceType, byte sensorMode) { _sensorType = GetTypeFromSensorType(deviceType); BindData(_sensorType); if (_sensorType != null) SensorStyle.SelectedItem = Enum.ToObject(_sensorType, sensorMode); PortName.Text = port.ToString(); ObjectName.Text = deviceType.ToString(); Visibility = Visibility.Visible; }
public TwoWheeledRobot (IDCMotor leftMotor, IDCMotor rightMotor) { this.leftMotor = leftMotor; this.rightMotor = rightMotor; DirectionInput = AddInput ("DirectionInput", Units.Scalar); SpeedInput = AddInput ("SpeedInput", Units.Ratio); SpinInput = AddInput ("SpinInput", Units.Scalar); Update (); SpeedInput.ValueChanged += (s, e) => Update (); DirectionInput.ValueChanged += (s, e) => Update (); SpinInput.ValueChanged += (s, e) => Update (); }
public SoftPwm () { Output = AddOutput ("Output", Units.Digital); DutyCycleInput = AddInput ("DutyCycleInput", Units.Ratio, 0.5); FrequencyInput = AddInput ("FrequencyInput", Units.Frequency, 1); th = new Thread ((ThreadStart)delegate { for (;;) { Output.Value = 1; Thread.Sleep (OnTimeMillis); Output.Value = 0; Thread.Sleep (OffTimeMillis); } }); th.Start (); }
// From http://www.sharpsma.com/webfm_send/1203 public SharpGP2D12 () { AnalogInput = new InputPort (this, "AnalogInput", Units.Ratio); DistanceOutput = new OutputPort (this, "DistanceOutput", Units.Distance, 0); lookup = new LookupTable { { 0.0912, 0.7904 }, { 0.1086, 0.6472 }, { 0.1476, 0.4352 }, { 0.2094, 0.2912 }, { 0.2976, 0.196 }, { 0.3876, 0.1456 }, { 0.528, 0.0976 }, }; lookup.Input.ConnectTo (AnalogInput); lookup.Output.ConnectTo (DistanceOutput); }
/// <summary> /// Append the Get Mode Name command to an existing Command object /// </summary> /// <param name="port">The port to query</param> /// <param name="mode">The mode of the name to get</param> /// <param name="bufferSize">Size of the buffer to hold the returned data</param> /// <param name="index">Index to the position of the returned data in the global buffer</param> public void GetModeName(InputPort port, int mode, int bufferSize, int index) { if(index > 1024) throw new ArgumentException("Index cannot be greater than 1024", "index"); AddOpcode(Opcode.InputDevice_GetModeName); AddParameter(0x00); AddParameter((byte)port); AddParameter((byte)mode); AddParameter((byte)bufferSize); AddGlobalIndex((byte)index); }
/// <summary> /// Append the Ready Percent command to an existing Command object /// </summary> /// <param name="port">The port to query</param> /// <param name="mode">The mode to query the value as</param> /// <param name="index">The index in the global buffer to hold the return value</param> public void ReadyPercent(InputPort port, int mode, int index) { if(index > 1024) throw new ArgumentException("Index cannot be greater than 1024", "index"); AddOpcode(Opcode.InputDevice_ReadyPct); AddParameter(0x00); // layer AddParameter((byte)port); // port AddParameter(0x00); // type AddParameter((byte)mode); // mode AddParameter(0x01); // # values AddGlobalIndex((byte)index); // index for return data }
/// <summary> /// Append the Get Type/Mode command to an existing Command object /// </summary> /// <param name="port">The port to query</param> /// <param name="typeIndex">The index to hold the Type value in the global buffer</param> /// <param name="modeIndex">The index to hold the Mode value in the global buffer</param> public void GetTypeMode(InputPort port, uint typeIndex, uint modeIndex) { if(typeIndex > 1024) throw new ArgumentException("Index for Type cannot be greater than 1024", "typeIndex"); if(modeIndex > 1024) throw new ArgumentException("Index for Mode cannot be greater than 1024", "modeIndex"); AddOpcode(Opcode.InputDevice_GetTypeMode); AddParameter(0x00); // layer AddParameter((byte)port); // port AddGlobalIndex((byte)typeIndex); // index for type AddGlobalIndex((byte)modeIndex); // index for mode }
/// <summary> /// Append the Clear Changes command to an existing Command object /// </summary> public void ClearChanges(InputPort port) { AddOpcode(Opcode.InputDevice_ClearChanges); AddParameter(0x00); // layer AddParameter((byte)port); // port }
static uint IP_GET_SENSITIVITY(InputPort[] ports, int index) { return (ports[index + 1].type >> 8) & 0xff; }
ushort IP_GET_MAX(InputPort[] ports, int index) { return (ports[index + 1].default_value); }
void input_port_free(InputPort[] dst) { dst = null; }
static int input_port_read(object f, ref InputPort _in) { uint i = 0; ushort w = 0; if (readint(f, ref i) != 0) return -1; _in.type = i; if (readword(f, ref w) != 0) return -1; _in.mask = w; if (readword(f, ref w) != 0) return -1; _in.default_value = w; if (seq_read_ver(f, ref _in.seq) != 0) return -1; return 0; }
/// <summary> /// Read a single expression from the input port. /// </summary> /// <param name="inp">The input port to read from.</param> /// <returns>The object that was read.</returns> private static SchemeObject UnsafeRead(InputPort inp) { return inp.Read(); }
public GenericAmbientLightSensor () { AnalogInput = AddInput ("AnalogInput", Units.Ratio); }
/// <summary> /// Read from the input port and evaluate whatever is there. /// Done for the side effect, not the result. /// Since the result is never tested, asynchronous suspensions do not prevent the rest /// of the file from being loaded. /// </summary> /// <param name="inp">The input port.</param> /// <param name="outp">If not null, input and results are written here.</param> /// <returns>Undefined instance.</returns> internal SchemeObject Load(InputPort inp, OutputPort outp) { while (true) { SchemeObject input; if ((input = inp.Read()) is Eof) { inp.Close(); return Undefined.Instance; } if (outp != null) { outp.WriteLine("> " + input); } var res = this.Eval(input); if (outp != null) { outp.WriteLine(res.ToString()); } } }
/// <summary> /// Read from the given port and evaluate the expression, and return the result /// as a string. /// </summary> /// <param name="inp">The input port to read from.</param> /// <returns>The result of the evaluation.</returns> public string ReadEvalPrint(InputPort inp) { try { return this.UnsafeEval(UnsafeRead(inp)).ToString(true); } catch (Exception ex) { ErrorHandlers.PrintException(ex); return string.Empty; } }
/// <summary> /// Read from the given port and evaluate the expression. /// </summary> /// <param name="inp">The input port to read from.</param> /// <returns>The result of the evaluation.</returns> public SchemeObject ReadEval(InputPort inp) { try { return this.UnsafeEval(UnsafeRead(inp)); } catch (Exception ex) { ErrorHandlers.PrintException(ex); return Undefined.Instance; } }
uint IP_GET_DELTA(InputPort[] ports, int index) { return (ports[index + 1].type >> 16) & 0xff; }
string input_port_name(InputPort[] inputports, int _in) { int i; uint type; if (inputports[_in].name != ports.IP_NAME_DEFAULT) return inputports[_in].name; i = 0; if ((inputports[_in].type & ~ports.IPF_MASK) == (int)ports.inptports.IPT_EXTENSION) type = inputports[_in - 1].type & (~ports.IPF_MASK | ports.IPF_PLAYERMASK); else type = inputports[_in].type & (~ports.IPF_MASK | ports.IPF_PLAYERMASK); while (inputport_defaults[i].type != (int)ports.inptports.IPT_END && inputport_defaults[i].type != type) i++; if ((inputports[_in].type & ~ports.IPF_MASK) == (int)ports.inptports.IPT_EXTENSION) return inputport_defaults[i + 1].name; else return inputport_defaults[i].name; }
InputPort[] input_port_allocate(InputPortTiny[] src) { int dst; int sidx = 0; InputPort[] _base; uint total; total = input_port_count(src); _base = new InputPort[total]; dst = 0; while (src[sidx].type != (int)ports.inptports.IPT_END) { int type = (int)(src[sidx].type & ~ports.IPF_MASK); int ext; int src_end; InputCode seq_default; if (type > (int)ports.inptports.IPT_ANALOG_START && type < (int)ports.inptports.IPT_ANALOG_END) src_end = sidx + 2; else src_end = sidx + 1; switch (type) { case (int)ports.inptports.IPT_END: case (int)ports.inptports.IPT_PORT: case (int)ports.inptports.IPT_DIPSWITCH_NAME: case (int)ports.inptports.IPT_DIPSWITCH_SETTING: seq_default = (int)InputCodes.CODE_NONE; break; default: seq_default = (int)InputCodes.CODE_DEFAULT; break; } ext = src_end; while (sidx < src_end) { _base[dst] = new InputPort(); _base[dst].type = src[sidx].type; _base[dst].mask = src[sidx].mask; _base[dst].default_value = src[sidx].default_value; _base[dst].name = src[sidx].name; if (src[ext].type == (int)ports.inptports.IPT_EXTENSION) { InputCode or1 = IP_GET_CODE_OR1(src[ext]); InputCode or2 = IP_GET_CODE_OR2(src[ext]); if (or1 < (int)InputCodes.__code_max) { if (or2 < (int)InputCodes.__code_max) seq_set_3(_base[dst].seq, or1, (int)InputCodes.CODE_OR, or2); else seq_set_1(_base[dst].seq, or1); } else { if (or1 == (int)InputCodes.CODE_NONE) seq_set_1(_base[dst].seq, or2); else seq_set_1(_base[dst].seq, or1); } ++ext; } else { seq_set_1(_base[dst].seq, seq_default); } ++sidx; ++dst; } sidx = ext; } _base[dst] = new InputPort(); _base[dst].type = (int)ports.inptports.IPT_END; return _base; }
int load_input_port_settings() { object f; load_default_keys(); if ((f = osd_fopen(Machine.gamedrv.name, null, OSD_FILETYPE_CONFIG, 0)) != null) { uint total, savedtotal=0; byte[] buf = new byte[8]; int i; int version; int _in = 0; /* calculate the size of the array */ total = 0; while (Machine.input_ports_default[_in].type != (uint)ports.inptports.IPT_END) { total++; _in++; } /* read header */ if (osd_fread(f, buf, 8) != 8) goto getout; if (memcmp(buf, Encoding.Default.GetBytes(MAMECFGSTRING_V8), 8) == 0) version = 8; else goto getout; /* header invalid */ /* read array size */ if (readint(f, ref savedtotal) != 0) goto getout; if (total != savedtotal) goto getout; /* different size */ /* read the original settings and compare them with the ones defined in the driver */ _in = 0; while (Machine.input_ports_default[_in].type != (uint)ports.inptports.IPT_END) { InputPort saved = new InputPort(); if (input_port_read(f, ref saved) != 0) goto getout; if (Machine.input_ports_default[_in].mask != saved.mask || Machine.input_ports_default[_in].default_value != saved.default_value || Machine.input_ports_default[_in].type != saved.type || seq_cmp(Machine.input_ports_default[_in].seq, saved.seq) != 0) goto getout; /* the default values are different */ _in++; } /* read the current settings */ _in = 0; while (Machine.input_ports[_in].type != (uint)ports.inptports.IPT_END) { if (input_port_read(f, ref Machine.input_ports[_in]) != 0) goto getout; _in++; } /* Clear the coin & ticket counters/flags - LBO 042898 */ for (i = 0; i < COIN_COUNTERS; i++) coins[i] = lastcoin[i] = coinlockedout[i] = 0; dispensed_tickets = 0; /* read in the coin/ticket counters */ for (i = 0; i < COIN_COUNTERS; i++) { if (readint(f, ref coins[i]) != 0) goto getout; } if (readint(f, ref dispensed_tickets) != 0) goto getout; mixer_read_config(f); getout: osd_fclose(f); } /* All analog ports need initialization */ { int i; for (i = 0; i < MAX_INPUT_PORTS; i++) input_analog_init[i] = 1; } update_input_ports(); /* if we didn't find a saved config, return 0 so the main core knows that it */ /* is the first time the game is run and it should diplay the disclaimer. */ if (f != null) return 1; else return 0; }
ushort IP_GET_MIN(InputPort[] ports, int index) { return ports[index + 1].mask; }
uint[] input_port_seq(InputPort[] input_ports, int _in) { int i, type; while (seq_get_1(input_ports[_in].seq) == (int)InputCodes.CODE_PREVIOUS) _in--; if ((input_ports[_in].type & ~ports.IPF_MASK) == (InputCode)ports.inptports.IPT_EXTENSION) { type = (int)(input_ports[_in - 1].type & (~ports.IPF_MASK | ports.IPF_PLAYERMASK)); /* if port is disabled, or cheat with cheats disabled, return no key */ if ((input_ports[_in - 1].type & ports.IPF_UNUSED) != 0 || (!options.cheat && (input_ports[_in - 1].type & ports.IPF_CHEAT) != 0)) return ip_none; } else { type = (int)(input_ports[_in].type & (~ports.IPF_MASK | ports.IPF_PLAYERMASK)); /* if port is disabled, or cheat with cheats disabled, return no key */ if ((input_ports[_in].type & ports.IPF_UNUSED) != 0 || (!options.cheat && (input_ports[_in].type & ports.IPF_CHEAT) != 0)) return ip_none; } if (seq_get_1(input_ports[_in].seq) != (int)InputCodes.CODE_DEFAULT) return input_ports[_in].seq; i = 0; while (inputport_defaults[i].type != (InputCode)ports.inptports.IPT_END && inputport_defaults[i].type != type) i++; if ((input_ports[_in].type & ~ports.IPF_MASK) == (InputCode)ports.inptports.IPT_EXTENSION) return inputport_defaults[i + 1].seq; else return inputport_defaults[i].seq; }