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:
authorSHAURYASANYAL3 <shauryasanya.21jun@gmail.com>2026-11-22 21:29:03 +0530
committerSHAURYASANYAL3 <shauryasanya.21jun@gmail.com>2026-11-22 21:29:03 +0530
commit3ad253147f54f13a030f986858f953ebe3c32b37 (patch)
tree065ea9f4500d704b306459b799ac41f64525b111 /runtime/test/gameinput_test.cpp
parent3b8e4420551a55df58fba8f418e3552a1e55775a (diff)
gameinput_test: add assertions for aggregate kind-mismatch and callback E_NOTIMPL guards
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index f525d1cb9..a0a950d9d 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -608,6 +608,20 @@ void test_aggregate_device(IGameInput* input) {
608 IGameInputReading* r = nullptr; 608 IGameInputReading* r = nullptr;
609 check(input->GetCurrentReading(GameInputKindGamepad, agg, &r) == GAMEINPUT_E_READING_NOT_FOUND && !r, 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"); 610 "aggregate device returns READING_NOT_FOUND when no pads are connected");
611 check(input->GetCurrentReading(GameInputKindKeyboard, agg, &r) == GAMEINPUT_E_READING_NOT_FOUND && !r,
612 "aggregate device returns READING_NOT_FOUND for kind mismatch with no pads");
613
614 // Callback registration guards for aggregate device
615 GameInputCallbackToken reading_tok = 0xbeef;
616 check(input->RegisterReadingCallback(agg, GameInputKindGamepad, 0.0f, nullptr, on_reading, &reading_tok) == E_NOTIMPL &&
617 reading_tok == kInvalidCallbackToken,
618 "RegisterReadingCallback rejects aggregate device with E_NOTIMPL and invalid token");
619
620 GameInputCallbackToken device_tok = 0xbeef;
621 check(input->RegisterDeviceCallback(agg, GameInputKindGamepad, GameInputDeviceConnected,
622 GameInputBlockingEnumeration, nullptr, on_device, &device_tok) == E_NOTIMPL &&
623 device_tok == kInvalidCallbackToken,
624 "RegisterDeviceCallback rejects aggregate device with E_NOTIMPL and invalid token");
611 625
612 // Attach a virtual pad and verify aggregate device yields readings from it 626 // Attach a virtual pad and verify aggregate device yields readings from it
613 Pad xbox; 627 Pad xbox;
@@ -624,6 +638,10 @@ void test_aggregate_device(IGameInput* input) {
624 r->Release(); 638 r->Release();
625 } 639 }
626 640
641 IGameInputReading* r_mismatch = nullptr;
642 check(input->GetCurrentReading(GameInputKindKeyboard, agg, &r_mismatch) == GAMEINPUT_E_READING_NOT_FOUND && !r_mismatch,
643 "aggregate device rejects kind mismatch even when pad is connected");
644
627 SDL_SetJoystickVirtualButton(xbox.js, SDL_GAMEPAD_BUTTON_SOUTH, false); 645 SDL_SetJoystickVirtualButton(xbox.js, SDL_GAMEPAD_BUTTON_SOUTH, false);
628 rt::gameinput::poll(); 646 rt::gameinput::poll();
629 IGameInputReading* r2 = nullptr; 647 IGameInputReading* r2 = nullptr;