From 48fe00b0b87d5972f59bb2028c908e620d9336a2 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Wed, 20 Jul 2022 14:43:39 -0700 Subject: [PATCH] in-progress adding start and end times to events for sleep calculations --- .github/FUNDING.yml | 12 ++++++++++++ capture.go | 48 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9992e9d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: taigrr # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/capture.go b/capture.go index d85e6ef..26e41ac 100644 --- a/capture.go +++ b/capture.go @@ -30,9 +30,18 @@ func (s SequenceSleep) Length() time.Duration { return s.Duration } +func (s SequenceSleep) StartTime() time.Time{ + return time.Time{} +} + +func (s SequenceSwipe) StartTime() time.Time{ + return s.Start +} type SequenceTap struct { - X int - Y int + X int + Y int + Start time.Time + End time.Time } func (s SequenceTap) Play(d Device, ctx context.Context) error { @@ -43,18 +52,27 @@ func (s SequenceTap) Length() time.Duration { return 0 } +func (s SequenceSwipe) StartTime() time.Time{ + return s.Start +} type SequenceSwipe struct { X1 int Y1 int X2 int Y2 int Duration time.Duration + Start time.Time + End time.Time } func (s SequenceSwipe) Play(d Device, ctx context.Context) error { return d.Swipe(ctx, s.X1, s.Y1, s.X2, s.Y2, s.Duration) } +func (s SequenceSwipe) StartTime() time.Time{ + return s.Start +} + func (s SequenceSwipe) Length() time.Duration { return s.Duration } @@ -62,6 +80,8 @@ func (s SequenceSwipe) Length() time.Duration { type Input interface { Play(d Device, ctx context.Context) error Length() time.Duration + StartTime() time.Time + EndTime() time.Time } type TapSequence struct { @@ -173,12 +193,27 @@ func parseGetEvent(input string) (events []Input) { return } -func touchesToInputs([][]event) []Input { - return []Input{} +func touchesToInputs(events []eventSet) []Input { + inputs := []Input{} + for _, eventSet := range events { + i, err := eventSet.ToInput() + if err != nil { + inputs = append(inputs, i) + } + } + return inputs } -func getEventSlices(events []event) [][]event { - eventSets := [][]event{{}} +type eventSet []event + +func (e eventSet) ToInput() (Input, error) { + var i Input + // i = + return i, nil +} + +func getEventSlices(events []event) []eventSet { + eventSets := []eventSet{{}} current := 0 foundDown := false for _, e := range events { @@ -197,7 +232,6 @@ func getEventSlices(events []event) [][]event { } } eventSets = eventSets[:len(eventSets)-1] - // fmt.Println(eventSets[len(eventSets)-1]) return eventSets }