mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 12:51:47 +00:00
rework pointing driver and update tests
This commit is contained in:
parent
8716256fba
commit
ab0029e2b8
@ -16,23 +16,23 @@ struct SimpleReport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Pointing : public TestFixture {};
|
class Pointing : public TestFixture {};
|
||||||
class PointingInvertXYParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
class PointingInvertXYParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
||||||
|
|
||||||
TEST_P(PointingInvertXYParametrizedTestFixture, PointingMouseKeysViaPointingDriver) {
|
TEST_P(PointingInvertXYParametrized, PointingInvertXY) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
SimpleReport input = GetParam().first;
|
SimpleReport input = GetParam().first;
|
||||||
SimpleReport expectations = GetParam().second;
|
SimpleReport expectations = GetParam().second;
|
||||||
|
|
||||||
set_x(input.x);
|
pd_set_x(input.x);
|
||||||
set_y(input.y);
|
pd_set_y(input.y);
|
||||||
set_h(input.h);
|
pd_set_h(input.h);
|
||||||
set_v(input.v);
|
pd_set_v(input.v);
|
||||||
|
|
||||||
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
EXPECT_NO_MOUSE_REPORT(driver);
|
EXPECT_NO_MOUSE_REPORT(driver);
|
||||||
@ -42,8 +42,8 @@ TEST_P(PointingInvertXYParametrizedTestFixture, PointingMouseKeysViaPointingDriv
|
|||||||
}
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
PointingInvertXYTests,
|
X_Y_XY,
|
||||||
PointingInvertXYParametrizedTestFixture,
|
PointingInvertXYParametrized,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
// Input Expected
|
// Input Expected
|
||||||
std::make_pair(SimpleReport{ 33, 0, 0, 0}, SimpleReport{ -33, 0, 0, 0}),
|
std::make_pair(SimpleReport{ 33, 0, 0, 0}, SimpleReport{ -33, 0, 0, 0}),
|
||||||
|
@ -16,23 +16,23 @@ struct SimpleReport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Pointing : public TestFixture {};
|
class Pointing : public TestFixture {};
|
||||||
class PointingRotateParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
||||||
|
|
||||||
TEST_P(PointingRotateParametrizedTestFixture, PointingRotateXY) {
|
TEST_P(PointingRotateParametrized, PointingRotateXY) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
SimpleReport input = GetParam().first;
|
SimpleReport input = GetParam().first;
|
||||||
SimpleReport expectations = GetParam().second;
|
SimpleReport expectations = GetParam().second;
|
||||||
|
|
||||||
set_x(input.x);
|
pd_set_x(input.x);
|
||||||
set_y(input.y);
|
pd_set_y(input.y);
|
||||||
set_h(input.h);
|
pd_set_h(input.h);
|
||||||
set_v(input.v);
|
pd_set_v(input.v);
|
||||||
|
|
||||||
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
EXPECT_NO_MOUSE_REPORT(driver);
|
EXPECT_NO_MOUSE_REPORT(driver);
|
||||||
@ -42,8 +42,8 @@ TEST_P(PointingRotateParametrizedTestFixture, PointingRotateXY) {
|
|||||||
}
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
Rotate180Tests,
|
Rotate180,
|
||||||
PointingRotateParametrizedTestFixture,
|
PointingRotateParametrized,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
// Input Expected
|
// Input Expected
|
||||||
// Rotate Clockwise
|
// Rotate Clockwise
|
||||||
|
@ -16,23 +16,23 @@ struct SimpleReport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Pointing : public TestFixture {};
|
class Pointing : public TestFixture {};
|
||||||
class PointingRotateParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
||||||
|
|
||||||
TEST_P(PointingRotateParametrizedTestFixture, PointingRotateXY) {
|
TEST_P(PointingRotateParametrized, PointingRotateXY) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
SimpleReport input = GetParam().first;
|
SimpleReport input = GetParam().first;
|
||||||
SimpleReport expectations = GetParam().second;
|
SimpleReport expectations = GetParam().second;
|
||||||
|
|
||||||
set_x(input.x);
|
pd_set_x(input.x);
|
||||||
set_y(input.y);
|
pd_set_y(input.y);
|
||||||
set_h(input.h);
|
pd_set_h(input.h);
|
||||||
set_v(input.v);
|
pd_set_v(input.v);
|
||||||
|
|
||||||
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
EXPECT_NO_MOUSE_REPORT(driver);
|
EXPECT_NO_MOUSE_REPORT(driver);
|
||||||
@ -42,8 +42,8 @@ TEST_P(PointingRotateParametrizedTestFixture, PointingRotateXY) {
|
|||||||
}
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
Rotate270Tests,
|
Rotate270,
|
||||||
PointingRotateParametrizedTestFixture,
|
PointingRotateParametrized,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
// Input Expected
|
// Input Expected
|
||||||
// Actual Result - Rotate Anticlockwise
|
// Actual Result - Rotate Anticlockwise
|
||||||
|
@ -16,23 +16,23 @@ struct SimpleReport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Pointing : public TestFixture {};
|
class Pointing : public TestFixture {};
|
||||||
class PointingRotateParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
|
||||||
|
|
||||||
TEST_P(PointingRotateParametrizedTestFixture, PointingRotateXY) {
|
TEST_P(PointingRotateParametrized, PointingRotateXY) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
SimpleReport input = GetParam().first;
|
SimpleReport input = GetParam().first;
|
||||||
SimpleReport expectations = GetParam().second;
|
SimpleReport expectations = GetParam().second;
|
||||||
|
|
||||||
set_x(input.x);
|
pd_set_x(input.x);
|
||||||
set_y(input.y);
|
pd_set_y(input.y);
|
||||||
set_h(input.h);
|
pd_set_h(input.h);
|
||||||
set_v(input.v);
|
pd_set_v(input.v);
|
||||||
|
|
||||||
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
EXPECT_NO_MOUSE_REPORT(driver);
|
EXPECT_NO_MOUSE_REPORT(driver);
|
||||||
@ -42,8 +42,8 @@ TEST_P(PointingRotateParametrizedTestFixture, PointingRotateXY) {
|
|||||||
}
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
Rotate90Tests,
|
Rotate90,
|
||||||
PointingRotateParametrizedTestFixture,
|
PointingRotateParametrized,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
// Input Expected
|
// Input Expected
|
||||||
// Actual Result - Rotate Anticlockwise
|
// Actual Result - Rotate Anticlockwise
|
||||||
|
@ -9,16 +9,8 @@
|
|||||||
|
|
||||||
using testing::_;
|
using testing::_;
|
||||||
|
|
||||||
struct MouseKeyExpectations {
|
|
||||||
int16_t x;
|
|
||||||
int16_t y;
|
|
||||||
int16_t h;
|
|
||||||
int16_t v;
|
|
||||||
uint16_t button_mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Pointing : public TestFixture {};
|
class Pointing : public TestFixture {};
|
||||||
class PointingKeycodeButtonsParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<KeymapKey, MouseKeyExpectations>>, public Pointing {};
|
class PointingButtonsViaMousekeysParametrized : public ::testing::WithParamInterface<std::pair<KeymapKey, uint8_t>>, public Pointing {};
|
||||||
|
|
||||||
TEST_F(Pointing, SendMouseIsNotCalledWithNoInput) {
|
TEST_F(Pointing, SendMouseIsNotCalledWithNoInput) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
@ -29,12 +21,12 @@ TEST_F(Pointing, SendMouseIsNotCalledWithNoInput) {
|
|||||||
TEST_F(Pointing, Xnegative) {
|
TEST_F(Pointing, Xnegative) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
set_x(-10);
|
pd_set_x(-10);
|
||||||
EXPECT_MOUSE_REPORT(driver, (-10, 0, 0, 0, 0));
|
EXPECT_MOUSE_REPORT(driver, (-10, 0, 0, 0, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver); // This should probably generate an empty report.
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
@ -43,12 +35,12 @@ TEST_F(Pointing, Xnegative) {
|
|||||||
TEST_F(Pointing, Xpositive) {
|
TEST_F(Pointing, Xpositive) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
set_x(10);
|
pd_set_x(10);
|
||||||
EXPECT_MOUSE_REPORT(driver, (10, 0, 0, 0, 0));
|
EXPECT_MOUSE_REPORT(driver, (10, 0, 0, 0, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver); // This should probably generate an empty report.
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
@ -57,12 +49,12 @@ TEST_F(Pointing, Xpositive) {
|
|||||||
TEST_F(Pointing, Ynegative) {
|
TEST_F(Pointing, Ynegative) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
set_y(-20);
|
pd_set_y(-20);
|
||||||
EXPECT_MOUSE_REPORT(driver, (0, -20, 0, 0, 0));
|
EXPECT_MOUSE_REPORT(driver, (0, -20, 0, 0, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver); // This should probably generate an empty report.
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
@ -71,12 +63,12 @@ TEST_F(Pointing, Ynegative) {
|
|||||||
TEST_F(Pointing, Ypositive) {
|
TEST_F(Pointing, Ypositive) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
set_y(20);
|
pd_set_y(20);
|
||||||
EXPECT_MOUSE_REPORT(driver, (0, 20, 0, 0, 0));
|
EXPECT_MOUSE_REPORT(driver, (0, 20, 0, 0, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver); // This should probably generate an empty report.
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
@ -85,13 +77,13 @@ TEST_F(Pointing, Ypositive) {
|
|||||||
TEST_F(Pointing, XandY) {
|
TEST_F(Pointing, XandY) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
set_x(-50);
|
pd_set_x(-50);
|
||||||
set_y(100);
|
pd_set_y(100);
|
||||||
EXPECT_MOUSE_REPORT(driver, (-50, 100, 0, 0, 0));
|
EXPECT_MOUSE_REPORT(driver, (-50, 100, 0, 0, 0));
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
clear_movement();
|
pd_clear_movement();
|
||||||
// EXPECT_EMPTY_MOUSE_REPORT(driver); // This should probably generate an empty report.
|
// EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
@ -101,17 +93,17 @@ TEST_F(Pointing, CorrectButtonIsReportedWhenPressed) {
|
|||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
|
|
||||||
EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1));
|
EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1));
|
||||||
press_button(POINTING_DEVICE_BUTTON1);
|
pd_press_button(POINTING_DEVICE_BUTTON1);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
EXPECT_EMPTY_MOUSE_REPORT(driver);
|
EXPECT_EMPTY_MOUSE_REPORT(driver);
|
||||||
release_button(POINTING_DEVICE_BUTTON1);
|
pd_release_button(POINTING_DEVICE_BUTTON1);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
EXPECT_NO_MOUSE_REPORT(driver);
|
EXPECT_NO_MOUSE_REPORT(driver);
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
clear_all_buttons();
|
pd_clear_all_buttons();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
@ -136,14 +128,14 @@ TEST_F(Pointing, CorrectButtonIsReportedWhenKeyPressed) {
|
|||||||
VERIFY_AND_CLEAR(driver);
|
VERIFY_AND_CLEAR(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(PointingKeycodeButtonsParametrizedTestFixture, PointingMouseKeysViaPointingDriver) {
|
TEST_P(PointingButtonsViaMousekeysParametrized, MouseKeysViaPointingDriver) {
|
||||||
TestDriver driver;
|
TestDriver driver;
|
||||||
KeymapKey mouse_key = GetParam().first;
|
KeymapKey mouse_key = GetParam().first;
|
||||||
MouseKeyExpectations expectations = GetParam().second;
|
uint8_t button_mask = GetParam().second;
|
||||||
|
|
||||||
set_keymap({mouse_key});
|
set_keymap({mouse_key});
|
||||||
|
|
||||||
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, expectations.button_mask));
|
EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, button_mask));
|
||||||
mouse_key.press();
|
mouse_key.press();
|
||||||
run_one_scan_loop();
|
run_one_scan_loop();
|
||||||
|
|
||||||
@ -158,17 +150,17 @@ TEST_P(PointingKeycodeButtonsParametrizedTestFixture, PointingMouseKeysViaPointi
|
|||||||
}
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
PointingMouseKeysTests,
|
ButtonsOneToEight,
|
||||||
PointingKeycodeButtonsParametrizedTestFixture,
|
PointingButtonsViaMousekeysParametrized,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
// Key , X, Y, H, V, Buttons Mask
|
// Key , Buttons Mask
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, MouseKeyExpectations{0, 0, 0, 0, 1}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, 1),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_2}, MouseKeyExpectations{0, 0, 0, 0, 2}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_2}, 2),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_3}, MouseKeyExpectations{0, 0, 0, 0, 4}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_3}, 4),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_4}, MouseKeyExpectations{0, 0, 0, 0, 8}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_4}, 8),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_5}, MouseKeyExpectations{0, 0, 0, 0, 16}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_5}, 16),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_6}, MouseKeyExpectations{0, 0, 0, 0, 32}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_6}, 32),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_7}, MouseKeyExpectations{0, 0, 0, 0, 64}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_7}, 64),
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_8}, MouseKeyExpectations{0, 0, 0, 0, 128})
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_8}, 128)
|
||||||
));
|
));
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -8,86 +8,102 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
bool state;
|
bool state;
|
||||||
bool set;
|
bool set;
|
||||||
} test_buttons_t;
|
} pd_button_state_t;
|
||||||
|
|
||||||
static report_mouse_t test_report = {0};
|
typedef struct {
|
||||||
static uint16_t test_cpi = {0};
|
int16_t x;
|
||||||
static test_buttons_t test_button_events[8] = {0};
|
int16_t y;
|
||||||
|
int16_t h;
|
||||||
|
int16_t v;
|
||||||
|
pd_button_state_t button_state[8];
|
||||||
|
uint16_t cpi;
|
||||||
|
bool initiated;
|
||||||
|
} pd_config_t;
|
||||||
|
|
||||||
void pointing_device_driver_init(void) {}
|
static pd_config_t pd_config = {0};
|
||||||
|
|
||||||
|
void pointing_device_driver_init(void) {
|
||||||
|
pd_set_init(true);
|
||||||
|
}
|
||||||
|
|
||||||
report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
|
report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
|
||||||
test_report.buttons = 0;
|
|
||||||
test_report.buttons = mouse_report.buttons; // buttons must currently be preserved by pointing device driver
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
if (test_button_events[i].set) {
|
if (pd_config.button_state[i].set) {
|
||||||
test_button_events[i].set = false;
|
pd_config.button_state[i].set = false;
|
||||||
if (test_button_events[i].state) {
|
if (pd_config.button_state[i].state) {
|
||||||
test_report.buttons |= 1 << (i);
|
mouse_report.buttons |= 1 << (i);
|
||||||
} else {
|
} else {
|
||||||
test_report.buttons &= ~(1 << (i));
|
mouse_report.buttons &= ~(1 << (i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return test_report;
|
mouse_report.x = pd_config.x;
|
||||||
|
mouse_report.y = pd_config.y;
|
||||||
|
mouse_report.h = pd_config.h;
|
||||||
|
mouse_report.v = pd_config.v;
|
||||||
|
return mouse_report;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
|
__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
|
||||||
return test_cpi;
|
return pd_config.cpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {
|
__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {
|
||||||
test_cpi = cpi;
|
pd_config.cpi = cpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void press_button(uint8_t btn) {
|
void pd_press_button(uint8_t btn) {
|
||||||
test_button_events[btn].set = true;
|
pd_config.button_state[btn].set = true;
|
||||||
test_button_events[btn].state = true;
|
pd_config.button_state[btn].state = true;
|
||||||
}
|
}
|
||||||
void release_button(uint8_t btn) {
|
void pd_release_button(uint8_t btn) {
|
||||||
test_button_events[btn].set = true;
|
pd_config.button_state[btn].set = true;
|
||||||
test_button_events[btn].state = false;
|
pd_config.button_state[btn].state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_all_buttons(void) {
|
void pd_clear_all_buttons(void) {
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
test_button_events[i].set = true;
|
pd_config.button_state[i].set = true;
|
||||||
test_button_events[i].state = false;
|
pd_config.button_state[i].state = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_x(int16_t x) {
|
void pd_set_x(int16_t x) {
|
||||||
test_report.x = x;
|
pd_config.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_x(void) {
|
void pd_clear_x(void) {
|
||||||
set_x(0);
|
pd_set_x(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_y(int16_t y) {
|
void pd_set_y(int16_t y) {
|
||||||
test_report.y = y;
|
pd_config.y = y;
|
||||||
}
|
}
|
||||||
void clear_y(void) {
|
void pd_clear_y(void) {
|
||||||
set_y(0);
|
pd_set_y(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_h(int16_t h) {
|
void pd_set_h(int16_t h) {
|
||||||
test_report.h = h;
|
pd_config.h = h;
|
||||||
}
|
}
|
||||||
void clear_h(void) {
|
void pd_clear_h(void) {
|
||||||
set_h(0);
|
pd_set_h(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_v(int16_t v) {
|
void pd_set_v(int16_t v) {
|
||||||
test_report.v = v;
|
pd_config.v = v;
|
||||||
}
|
}
|
||||||
void clear_v(void) {
|
void pd_clear_v(void) {
|
||||||
set_v(0);
|
pd_set_v(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_movement(void) {
|
void pd_clear_movement(void) {
|
||||||
set_x(0);
|
pd_set_x(0);
|
||||||
set_y(0);
|
pd_set_y(0);
|
||||||
set_h(0);
|
pd_set_h(0);
|
||||||
set_v(0);
|
pd_set_v(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pd_set_init(bool success) {
|
||||||
|
pd_config.initiated = success;
|
||||||
}
|
}
|
||||||
|
@ -7,23 +7,25 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void press_button(uint8_t btn);
|
void pd_press_button(uint8_t btn);
|
||||||
void release_button(uint8_t btn);
|
void pd_release_button(uint8_t btn);
|
||||||
void clear_all_buttons(void);
|
void pd_clear_all_buttons(void);
|
||||||
|
|
||||||
void set_x(int16_t x);
|
void pd_set_x(int16_t x);
|
||||||
void clear_x(void);
|
void clear_x(void);
|
||||||
|
|
||||||
void set_y(int16_t y);
|
void pd_set_y(int16_t y);
|
||||||
void clear_y(void);
|
void pd_clear_y(void);
|
||||||
|
|
||||||
void set_h(int16_t h);
|
void pd_set_h(int16_t h);
|
||||||
void clear_h(void);
|
void pd_clear_h(void);
|
||||||
|
|
||||||
void set_v(int16_t v);
|
void pd_set_v(int16_t v);
|
||||||
void clear_v(void);
|
void pd_clear_v(void);
|
||||||
|
|
||||||
void clear_movement(void);
|
void pd_clear_movement(void);
|
||||||
|
|
||||||
|
void pd_set_init(bool success);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user