Add MouseReports to HIDState for testing

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1120/head
Michael Richters 3 years ago
parent e8c84a0e47
commit e87306144e
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -51,6 +51,14 @@ const KeyboardReport& HIDState::Keyboard(size_t i) const {
return keyboard_reports_.at(i);
}
const std::vector<MouseReport>& HIDState::Mouse() const {
return mouse_reports_;
}
const MouseReport& HIDState::Mouse(size_t i) const {
return mouse_reports_.at(i);
}
const std::vector<SystemControlReport>& HIDState::SystemControl() const {
return system_control_reports_;
}
@ -65,10 +73,6 @@ namespace internal {
void HIDStateBuilder::ProcessHidReport(
uint8_t id, const void* data, int len, int result) {
switch (id) {
case HID_REPORTID_MOUSE: {
LOG(ERROR) << "Dropped MouseReport: unimplemented";
break;
}
case HID_REPORTID_KEYBOARD: {
LOG(ERROR) << "Dropped BootKeyboardReport: unimplemented";
break;
@ -85,6 +89,10 @@ void HIDStateBuilder::ProcessHidReport(
ProcessSystemControlReport(SystemControlReport{data});
break;
}
case HID_REPORTID_MOUSE: {
ProcessMouseReport(MouseReport{data});
break;
}
case HID_REPORTID_MOUSE_ABSOLUTE: {
ProcessAbsoluteMouseReport(AbsoluteMouseReport{data});
break;
@ -107,6 +115,7 @@ std::unique_ptr<HIDState> HIDStateBuilder::Snapshot() {
hid_state->absolute_mouse_reports_ = std::move(absolute_mouse_reports_);
hid_state->consumer_control_reports_ = std::move(consumer_control_reports_);
hid_state->keyboard_reports_ = std::move(keyboard_reports_);
hid_state->mouse_reports_ = std::move(mouse_reports_);
hid_state->system_control_reports_ = std::move(system_control_reports_);
Clear(); // Clear global state.
@ -118,6 +127,7 @@ void HIDStateBuilder::Clear() {
absolute_mouse_reports_.clear();
consumer_control_reports_.clear();
keyboard_reports_.clear();
mouse_reports_.clear();
system_control_reports_.clear();
}
@ -136,6 +146,11 @@ void HIDStateBuilder::ProcessKeyboardReport(const KeyboardReport& report) {
keyboard_reports_.push_back(report);
}
// static
void HIDStateBuilder::ProcessMouseReport(const MouseReport& report) {
mouse_reports_.push_back(report);
}
// static
void HIDStateBuilder::ProcessSystemControlReport(const SystemControlReport& report) {
system_control_reports_.push_back(report);
@ -148,6 +163,8 @@ std::vector<ConsumerControlReport> HIDStateBuilder::consumer_control_reports_;
// static
std::vector<KeyboardReport> HIDStateBuilder::keyboard_reports_;
// static
std::vector<MouseReport> HIDStateBuilder::mouse_reports_;
// static
std::vector<SystemControlReport> HIDStateBuilder::system_control_reports_;
} // namesapce internal

@ -19,6 +19,7 @@
#include "testing/AbsoluteMouseReport.h"
#include "testing/ConsumerControlReport.h"
#include "testing/KeyboardReport.h"
#include "testing/MouseReport.h"
#include "testing/SystemControlReport.h"
// Out of order due to macro conflicts.
@ -42,6 +43,9 @@ class HIDState {
const std::vector<KeyboardReport>& Keyboard() const;
const KeyboardReport& Keyboard(size_t i) const;
const std::vector<MouseReport>& Mouse() const;
const MouseReport& Mouse(size_t i) const;
const std::vector<SystemControlReport>& SystemControl() const;
const SystemControlReport& SystemControl(size_t i) const;
@ -51,6 +55,7 @@ class HIDState {
std::vector<AbsoluteMouseReport> absolute_mouse_reports_;
std::vector<ConsumerControlReport> consumer_control_reports_;
std::vector<KeyboardReport> keyboard_reports_;
std::vector<MouseReport> mouse_reports_;
std::vector<SystemControlReport> system_control_reports_;
};
@ -68,11 +73,13 @@ class HIDStateBuilder {
static void ProcessAbsoluteMouseReport(const AbsoluteMouseReport& report);
static void ProcessConsumerControlReport(const ConsumerControlReport& report);
static void ProcessKeyboardReport(const KeyboardReport& report);
static void ProcessMouseReport(const MouseReport& report);
static void ProcessSystemControlReport(const SystemControlReport& report);
static std::vector<AbsoluteMouseReport> absolute_mouse_reports_;
static std::vector<ConsumerControlReport> consumer_control_reports_;
static std::vector<KeyboardReport> keyboard_reports_;
static std::vector<MouseReport> mouse_reports_;
static std::vector<SystemControlReport> system_control_reports_;
};

Loading…
Cancel
Save