public DiPovDirectionProcessor(InputDescriptor inputDescriptor, EventHandler observerListEmptyEventHandler, EventHandler <InputReportEventArgs> bindModeHandler) { _observerListEmptyEventHandler = observerListEmptyEventHandler; _inputDescriptor = inputDescriptor; _thisAngle = _inputDescriptor.BindingDescriptor.SubIndex * 9000; OnBindMode += bindModeHandler; }
public DiPovProcessor(InputDescriptor inputDescriptor, EventHandler observerListEmptyEventHandler, EventHandler <InputReportEventArgs> bindModeHandler) { _observerListEmptyEventHandler = observerListEmptyEventHandler; for (var i = 0; i < 4; i++) { var descriptor = new InputDescriptor(inputDescriptor.DeviceDescriptor, new BindingDescriptor(BindingType.POV, inputDescriptor.BindingDescriptor.Index, i)); _directionProcessors.Add(new DiPovDirectionProcessor(descriptor, observerListEmptyEventHandler, bindModeHandler)); } }
public IDisposable SubscribeInput(InputDescriptor subReq, IObserver <InputReport> observer) { //if (!DiWrapper.Instance.ConnectedDevices.ContainsKey(subReq.DeviceDescriptor.DeviceHandle)) //{ // throw new Exception("Device not found"); //} CreateDevice(subReq.DeviceDescriptor); return(_devices[subReq.DeviceDescriptor].SubscribeInput(subReq, observer)); }
public XiButtonProcessor(InputDescriptor inputDescriptor, EventHandler observerListEmptyEventHandler, EventHandler <InputReportEventArgs> bindModeHandler) { _observerListEmptyEventHandler = observerListEmptyEventHandler; OnBindMode += bindModeHandler; _inputDescriptor = inputDescriptor; var index = inputDescriptor.BindingDescriptor.Type == BindingType.Button ? inputDescriptor.BindingDescriptor.Index : inputDescriptor.BindingDescriptor.SubIndex + 10; _gamepadButtonFlag = _buttonFlags[index]; }
public Input(InputDescriptor inputDescriptor) { Port = (int)inputDescriptor.Port; Device = (Device)inputDescriptor.Device; RawInputID = (int)inputDescriptor.ID; CoreDescription = inputDescriptor.Description; switch (Device) { case Device.Joypad: JoypadInputID = (JoypadInputID)inputDescriptor.ID; break; } }
public IDisposable Subscribe(InputDescriptor subReq, IObserver <InputReport> observer) { return(Subscribe(observer)); }
public IDisposable SubscribeInput(InputDescriptor subReq, IObserver <InputReport> observer) { CreateDevice(subReq.DeviceDescriptor); return(_devices[subReq.DeviceDescriptor].SubscribeInput(subReq, observer)); }
// build a way for the user of core to passthrough their choice of commands to handle private bool environmentCallback(uint command, IntPtr data) { switch ((EnvironmentCommand)command) { case EnvironmentCommand.GetOverscan: Marshal.WriteByte(data, 0, Convert.ToByte(true)); return(true); case EnvironmentCommand.GetCanDupe: Marshal.WriteByte(data, 0, Convert.ToByte(true)); return(true); case EnvironmentCommand.SetPerformanceLevel: uint temp = (uint)Marshal.ReadInt32(data); // this isn't being stored anywhere return(true); case EnvironmentCommand.GetSystemDirectory: Marshal.WriteIntPtr(data, Marshal.StringToHGlobalAnsi(_systemDirectoryPath)); return(true); case EnvironmentCommand.SetPixelFormat: PixelFormat = (PixelFormat)Marshal.ReadInt32(data); return(true); case EnvironmentCommand.SetInputDescriptors: IntPtr inputDescriptorAddress = data; while (true) { InputDescriptor inputDescriptor = (InputDescriptor)Marshal.PtrToStructure(inputDescriptorAddress, typeof(InputDescriptor)); if (inputDescriptor.Description == null) { break; } Inputs.Add(new Input(inputDescriptor)); inputDescriptorAddress = (IntPtr)((long)inputDescriptorAddress + Marshal.SizeOf(inputDescriptor)); } return(true); case EnvironmentCommand.GetVariable: Variable variable = (Variable)Marshal.PtrToStructure(data, typeof(Variable)); IEnumerable <string> matchedVariables = Variables.Where(v => v.Key == variable.Key).Select(v => v.Value); if (matchedVariables.Any()) { string firstValue = Variables.Where(v => v.Key == variable.Key).Select(v => v.Value).First(); firstValue = firstValue.Substring(firstValue.IndexOf(';') + 2); if (firstValue.Contains("|")) { firstValue = firstValue.Substring(0, firstValue.IndexOf('|')); } variable.Value = firstValue; Marshal.StructureToPtr(variable, data, false); } return(true); case EnvironmentCommand.SetVariables: IntPtr variableAddress = data; while (true) { variable = (Variable)Marshal.PtrToStructure(variableAddress, typeof(Variable)); if (variable.Key == null) { break; } Variables.Add(variable); variableAddress = (IntPtr)((long)variableAddress + Marshal.SizeOf(variable)); } return(true); case EnvironmentCommand.GetVariableUpdate: Marshal.WriteByte(data, 0, Convert.ToByte(_variablesDirty)); _variablesDirty = false; return(true); case EnvironmentCommand.GetLogInterface: _logCallback = new LogCallback(); if (LogPassthroughHandler == null) { _logCallback.Log = logCallback; } else { _logCallback.Log = LogPassthroughHandler; } Marshal.StructureToPtr(_logCallback, data, false); return(true); case EnvironmentCommand.GetSaveDirectory: Marshal.WriteIntPtr(data, Marshal.StringToHGlobalAnsi(Directory.GetCurrentDirectory())); return(true); case EnvironmentCommand.SetMemoryMaps: // not saved anywhere return(true); case EnvironmentCommand.SetGeometry: GameGeometry gameGeometry = (GameGeometry)Marshal.PtrToStructure(data, typeof(GameGeometry)); return(true); case EnvironmentCommand.GetCurrentSoftwareFrameBuffer: // not implemented return(false); default: Debug.WriteLine("Unhandled Environment Command: " + command); return(false); } }
public DiButtonProcessor(InputDescriptor inputDescriptor, EventHandler observerListEmptyEventHandler, EventHandler <InputReportEventArgs> bindModeHandler) { _observerListEmptyEventHandler = observerListEmptyEventHandler; _inputDescriptor = inputDescriptor; OnBindMode += bindModeHandler; }
public IDisposable Subscribe(InputDescriptor subReq, IObserver <InputReport> observer) { return(_directionProcessors[subReq.BindingDescriptor.SubIndex].Subscribe(subReq, observer)); }
public static IObservable <object> ReadInputAsObservable(this DataIO io, InputDescriptor input, object settings = null) { return(io.ReadInputAsObservable(input.Reader, input.Format, input.DataType, settings)); }
public static IEnumerable <T> ReadInput <T>(this DataIO io, InputDescriptor input, object settings = null) { return(io.ReadInput <T>(input.Reader, input.Format, input.DataType, settings)); }