upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/gameinput_test.cpp
diff options
context:
space:
mode:
authorVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 17:40:39 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 17:40:39 +0100
commit3ffdaed7613907c5aca425d02b6fee88880e32e3 (patch)
tree56075731340bf2ebacec3161c58b5457702f899c /runtime/test/gameinput_test.cpp
parentc7b6136446946bea75530b7322f60386f06c199b (diff)
parent49475796c226c8511b9470bf97a4daf57b8af323 (diff)
chore(shader): merge main for packed 2D mip loads
Keep upstream packed image atomics and allow packed texel and mip addresses on ordinary 2D mip loads.
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index d1923ceaf..f525d1cb9 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -577,6 +577,76 @@ bool found_is(IGameInput* input, IGameInputDevice* dev) {
577} 577}
578 578
579// Pads SDL cannot tell apart: the same name, vendor and product, no serial, no path. Runs with no other pad connected. 579// Pads SDL cannot tell apart: the same name, vendor and product, no serial, no path. Runs with no other pad connected.
580void test_aggregate_device(IGameInput* input) {
581 check(input->CreateAggregateDevice(GameInputKindGamepad, nullptr) == E_POINTER,
582 "CreateAggregateDevice rejects null output pointer");
583 IGameInputDevice* agg = nullptr;
584 check(input->CreateAggregateDevice(GameInputKindUnknown, &agg) == E_INVALIDARG && !agg,
585 "CreateAggregateDevice rejects GameInputKindUnknown");
586 check(input->CreateAggregateDevice(GameInputKindGamepad | GameInputKindKeyboard, &agg) == E_INVALIDARG && !agg,
587 "CreateAggregateDevice rejects multiple combined kind flags");
588 check(input->CreateAggregateDevice(0x80000000, &agg) == E_INVALIDARG && !agg,
589 "CreateAggregateDevice rejects unsupported kind flag");
590
591 check(input->CreateAggregateDevice(GameInputKindGamepad, &agg) == S_OK && agg != nullptr,
592 "CreateAggregateDevice creates an aggregate device for GameInputKindGamepad");
593 if (agg) {
594 const GameInputDeviceInfo* info = agg->GetDeviceInfo();
595 check(info && info->deviceFamily == GameInputFamilyAggregate,
596 "aggregate device reports GameInputFamilyAggregate");
597 check(info && info->supportedInput == GameInputKindGamepad,
598 "aggregate device reports supportedInput == GameInputKindGamepad");
599 check(agg->GetDeviceStatus() == GameInputDeviceConnected,
600 "aggregate device status is GameInputDeviceConnected");
601
602 IGameInputDevice* agg2 = nullptr;
603 check(input->CreateAggregateDevice(GameInputKindGamepad, &agg2) == S_OK && agg2 == agg,
604 "CreateAggregateDevice returns existing aggregate instance for the same kind");
605 if (agg2) agg2->Release();
606
607 // Reading test with no connected pad
608 IGameInputReading* r = nullptr;
609 check(input->GetCurrentReading(GameInputKindGamepad, agg, &r) == GAMEINPUT_E_READING_NOT_FOUND && !r,
610 "aggregate device returns READING_NOT_FOUND when no pads are connected");
611
612 // Attach a virtual pad and verify aggregate device yields readings from it
613 Pad xbox;
614 attach(xbox, "Leonida virtual Xbox pad", 0x045E, 0x0B12, true);
615 rt::gameinput::poll();
616
617 SDL_SetJoystickVirtualButton(xbox.js, SDL_GAMEPAD_BUTTON_SOUTH, true);
618 rt::gameinput::poll();
619
620 check(input->GetCurrentReading(GameInputKindGamepad, agg, &r) == S_OK && r != nullptr,
621 "aggregate device yields reading from connected pad");
622 if (r) {
623 check(buttons_of(r) == GameInputGamepadA, "aggregate device reading reflects pad input state");
624 r->Release();
625 }
626
627 SDL_SetJoystickVirtualButton(xbox.js, SDL_GAMEPAD_BUTTON_SOUTH, false);
628 rt::gameinput::poll();
629 IGameInputReading* r2 = nullptr;
630 check(input->GetCurrentReading(GameInputKindGamepad, agg, &r2) == S_OK && r2 != nullptr,
631 "aggregate device yields updated reading after button release");
632 if (r2) {
633 check(buttons_of(r2) == 0, "aggregate reading shows button released");
634 IGameInputReading* prev = nullptr;
635 check(input->GetPreviousReading(r2, GameInputKindGamepad, agg, &prev) == S_OK && prev != nullptr,
636 "GetPreviousReading with aggregate device filter finds prior reading");
637 if (prev) {
638 check(buttons_of(prev) == GameInputGamepadA, "prior reading has pressed button");
639 prev->Release();
640 }
641 r2->Release();
642 }
643
644 detach(xbox);
645 rt::gameinput::poll();
646 agg->Release();
647 }
648}
649
580void test_twins(IGameInput* input) { 650void test_twins(IGameInput* input) {
581 Pad pads[3]; 651 Pad pads[3];
582 IGameInputDevice* dev[3] = {}; 652 IGameInputDevice* dev[3] = {};
@@ -1099,6 +1169,7 @@ int main() {
1099 test_twins(input); 1169 test_twins(input);
1100 test_keyboard_pad(input); 1170 test_keyboard_pad(input);
1101 test_motion(input); 1171 test_motion(input);
1172 test_aggregate_device(input);
1102 input->Release(); 1173 input->Release();
1103 1174
1104 std::printf("%d checks, %d failures\n", g_checks, g_failures); 1175 std::printf("%d checks, %d failures\n", g_checks, g_failures);