static InputReplay Build(ASIPOptions asipOptions) { Console.Write("Creating touchpad... "); var touchpad = new ConfigurableTouchpad(asipOptions.TouchpadConfig, asipOptions.SmTpadConfig.TargetTouchpadOptions, EDevicePurpose.Target); Console.WriteLine("OK"); Console.Write("Calculating notes coordinates... "); var noteCoords = new NoteCoordinates(asipOptions.InstrumentConfig); noteCoords.Calculate(); Console.WriteLine("OK"); ISongReplayBuilder parser = asipOptions.TrackerType switch { ETrackerType.SkyStudio => new Parsers.SkyStudio.SongReplayBuilder(noteCoords, touchpad), ETrackerType.COTL => new Parsers.COTLTracker.SongReplayBuilder(noteCoords, touchpad), _ => throw new NotImplementedException() }; Console.Write("Parsing... "); parser.Parse(asipOptions.InFilePath); parser.NormalizeOctaves(); Console.WriteLine("OK"); Console.Write("Building replay... "); parser.BuildTouchpad(0); var replayBuilder = new InputReplayBuilder(parser.TickRate) { Name = asipOptions.SongName ?? parser.GetName(), Author = asipOptions.SongAuthor ?? parser.GetAuthor(), About = asipOptions.SongAbout ?? parser.GetAbout() + " " + "https://asip.arkprojects.space" }; replayBuilder.AddDevice(touchpad); foreach (var devicesOptions in asipOptions.SmTpadConfig.TriggerDevicesOptions) { replayBuilder.AddDevice(new GenericTriggerDevice(devicesOptions)); } var replay = replayBuilder.Build(); Console.WriteLine("OK"); return(replay); } }
static void ConfigurableTouchpadSample() { //create target and trigger devices var touchpadOptions = new TouchpadOptions() { Multitouch = 14, MaxXPos = 1279, MaxYPos = 719, DefaultClickPressure = 4, DefaultClickTicks = 2, Path = "/dev/input/event6" }; var touchpadConfiguration = GetMemuTpadConfig(); var touchpad = new ConfigurableTouchpad(touchpadConfiguration, touchpadOptions, EDevicePurpose.Target); var trigger = new GenericTriggerDevice(new DeviceOptions("/dev/input/event2")); //add events touchpad.Tap(1000, 350, 1, 10); touchpad.Swipe(new AbsolutePosition(40, 10), new AbsolutePosition(40, 300), 1, 10); touchpad.Swipe(new AbsolutePosition(40, 800), new AbsolutePosition(40, 310), 1, 10); //create replay builder var replayBuilder = new InputReplayBuilder(20); //add devices replayBuilder.AddDevice(touchpad); replayBuilder.AddDevice(trigger); //build var replay = replayBuilder.Build(); //serialize to json var jsonStr = replay.ToJson(Formatting.Indented); Console.WriteLine(jsonStr); File.WriteAllText("./configurable.json", jsonStr); }