Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>pull/1120/head
parent
72c2e0fe27
commit
e8c84a0e47
@ -0,0 +1,65 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testing/ExpectedMouseReport.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
|
ExpectedMouseReport::ExpectedMouseReport(uint32_t timestamp,
|
||||||
|
uint8_t buttons,
|
||||||
|
int8_t x, int8_t y,
|
||||||
|
int8_t v, int8_t h,
|
||||||
|
std::string message) {
|
||||||
|
timestamp_ = timestamp;
|
||||||
|
report_data_.buttons = buttons;
|
||||||
|
report_data_.xAxis = x;
|
||||||
|
report_data_.yAxis = y;
|
||||||
|
report_data_.vWheel = v;
|
||||||
|
report_data_.hWheel = h;
|
||||||
|
failure_message_ = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ExpectedMouseReport::Timestamp() const {
|
||||||
|
return timestamp_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string & ExpectedMouseReport::Message() const {
|
||||||
|
return failure_message_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ExpectedMouseReport::Buttons() const {
|
||||||
|
return report_data_.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t ExpectedMouseReport::XAxis() const {
|
||||||
|
return report_data_.xAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t ExpectedMouseReport::YAxis() const {
|
||||||
|
return report_data_.yAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t ExpectedMouseReport::VWheel() const {
|
||||||
|
return report_data_.vWheel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t ExpectedMouseReport::HWheel() const {
|
||||||
|
return report_data_.hWheel;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
} // namespace kaleidoscope
|
@ -0,0 +1,52 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "MouseReport.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
|
class ExpectedMouseReport {
|
||||||
|
public:
|
||||||
|
ExpectedMouseReport(uint32_t timestamp,
|
||||||
|
uint8_t buttons, int8_t x, int8_t y, int8_t v, int8_t h,
|
||||||
|
std::string message = "");
|
||||||
|
|
||||||
|
uint8_t Buttons() const;
|
||||||
|
int8_t XAxis() const;
|
||||||
|
int8_t YAxis() const;
|
||||||
|
int8_t VWheel() const;
|
||||||
|
int8_t HWheel() const;
|
||||||
|
|
||||||
|
uint32_t Timestamp() const;
|
||||||
|
|
||||||
|
const std::string & Message() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t timestamp_;
|
||||||
|
MouseReport::ReportData report_data_;
|
||||||
|
std::string failure_message_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
} // namespace kaleidoscope
|
@ -0,0 +1,61 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testing/MouseReport.h"
|
||||||
|
|
||||||
|
#include "Kaleidoscope.h"
|
||||||
|
#include "testing/fix-macros.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "MouseButtons.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
|
MouseReport::MouseReport(const void* data) {
|
||||||
|
const ReportData& report_data =
|
||||||
|
*static_cast<const ReportData*>(data);
|
||||||
|
memcpy(&report_data_, &report_data, sizeof(report_data_));
|
||||||
|
timestamp_ = Runtime.millisAtCycleStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t MouseReport::Timestamp() const {
|
||||||
|
return timestamp_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t MouseReport::Buttons() const {
|
||||||
|
return report_data_.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t MouseReport::XAxis() const {
|
||||||
|
return report_data_.xAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t MouseReport::YAxis() const {
|
||||||
|
return report_data_.yAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t MouseReport::VWheel() const {
|
||||||
|
return report_data_.vWheel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t MouseReport::HWheel() const {
|
||||||
|
return report_data_.hWheel;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
} // namespace kaleidoscope
|
@ -0,0 +1,56 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "HID-Settings.h"
|
||||||
|
#include "MultiReport/Mouse.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
|
class MouseReport {
|
||||||
|
public:
|
||||||
|
typedef HID_MouseReport_Data_t ReportData;
|
||||||
|
|
||||||
|
static constexpr uint8_t kHidReportType = HID_REPORTID_MOUSE;
|
||||||
|
|
||||||
|
MouseReport(const void* data);
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr uint8_t kButtonLeft = MOUSE_LEFT;
|
||||||
|
static constexpr uint8_t kButtonRight = MOUSE_RIGHT;
|
||||||
|
static constexpr uint8_t kButtonMiddle = MOUSE_MIDDLE;
|
||||||
|
static constexpr uint8_t kButtonPrev = MOUSE_PREV;
|
||||||
|
static constexpr uint8_t kButtonNext = MOUSE_NEXT;
|
||||||
|
|
||||||
|
uint32_t Timestamp() const;
|
||||||
|
uint8_t Buttons() const;
|
||||||
|
int8_t XAxis() const;
|
||||||
|
int8_t YAxis() const;
|
||||||
|
int8_t VWheel() const;
|
||||||
|
int8_t HWheel() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t timestamp_;
|
||||||
|
ReportData report_data_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
} // namespce kaleidoscope
|
Loading…
Reference in new issue