This commit is contained in:
trung09122002
2026-09-22 16:04:42 +07:00
parent d8c96377c6
commit 83e20a64d9
5 changed files with 37 additions and 20 deletions

View File

@@ -304,23 +304,24 @@ TEST(Gamepad, CocLtChiAnKhiBatVaKhongAnLucChuaChamToi) {
GamepadState s = MakePad();
PressEnable(&m, &s, c, 1.0);
// ⚠️ Truoc lan bam dau tien, joydev tra ve 0.0 cho coc chu khong phai +1.0.
// Neu nguong la "khac 1" thi vua cam tay cam vao la xe dung cung.
s.axes[c.axis_lt] = 0.0f;
// ⚠️ DO TREN TAY CAM THAT (vslam_joy_probe, Logitech Gamepad F710):
// coc NGHI o -1.0, bop len +1.0. Lay nguong am thi coc dang nghi da thoa
// dieu kien va robot dung cung vinh vien -- bug that o ban dau.
s.axes[c.axis_lt] = -1.0f;
s.axes[c.axis_linear] = 1.0f;
EXPECT_DOUBLE_EQ(m.Step(s, T(2.0)).linear, c.max_linear_speed);
// Nghi that su la +1.0.
s.axes[c.axis_lt] = 1.0f;
// Truoc mau dau tien, truc co the doc ra 0.0. Van phai la "khong bop".
s.axes[c.axis_lt] = 0.0f;
EXPECT_DOUBLE_EQ(m.Step(s, T(2.1)).linear, c.max_linear_speed);
// Bop coc -> ve am -> dung, du can gat van day het.
s.axes[c.axis_lt] = -1.0f;
// Bop coc -> len duong -> dung, du can gat van day het.
s.axes[c.axis_lt] = 1.0f;
const GamepadCommand stopped = m.Step(s, T(2.2));
EXPECT_TRUE(stopped.publish);
EXPECT_DOUBLE_EQ(stopped.linear, 0.0);
// Nha coc -> chay lai ngay. "Giu de dung", khong chot.
s.axes[c.axis_lt] = 1.0f;
s.axes[c.axis_lt] = -1.0f;
EXPECT_DOUBLE_EQ(m.Step(s, T(2.3)).linear, c.max_linear_speed);
}