diff options
| author | SHAURYASANYAL3 <shauryasanya.21jun@gmail.com> | 2026-11-22 21:09:21 +0530 |
|---|---|---|
| committer | SHAURYASANYAL3 <shauryasanya.21jun@gmail.com> | 2026-11-22 21:09:21 +0530 |
| commit | 3b8e4420551a55df58fba8f418e3552a1e55775a (patch) | |
| tree | 824594ad00c2a913637735c8452491ebae6a4862 /runtime/shims/gameinput.cpp | |
| parent | 3ba52051804690feb1f75269e672060edb159255 (diff) | |
gameinput: refine aggregate device reading kind filter and callback guards
Diffstat (limited to 'runtime/shims/gameinput.cpp')
| -rw-r--r-- | runtime/shims/gameinput.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp index 35eac4c4e..d9c62fec5 100644 --- a/runtime/shims/gameinput.cpp +++ b/runtime/shims/gameinput.cpp | |||
| @@ -1190,10 +1190,12 @@ HRESULT find_reading(IGameInputReading* ref, uint32_t kind, IGameInputDevice* de | |||
| 1190 | if (device) { | 1190 | if (device) { |
| 1191 | Device* dev = as_device(device); | 1191 | Device* dev = as_device(device); |
| 1192 | if (dev->info.deviceFamily == GameInputFamilyAggregate) { | 1192 | if (dev->info.deviceFamily == GameInputFamilyAggregate) { |
| 1193 | const uint32_t effective_kind = (kind != GameInputKindUnknown) ? kind : dev->info.supportedInput; | 1193 | if (kind != GameInputKindUnknown && !(kind & dev->info.supportedInput)) |
| 1194 | return GAMEINPUT_E_READING_NOT_FOUND; | ||
| 1195 | const uint32_t effective_kind = (kind != GameInputKindUnknown) ? (kind & dev->info.supportedInput) : dev->info.supportedInput; | ||
| 1194 | scope.clear(); | 1196 | scope.clear(); |
| 1195 | for (Device* cd : s.connected) { | 1197 | for (Device* cd : s.connected) { |
| 1196 | if (effective_kind == GameInputKindUnknown || (effective_kind & cd->info.supportedInput)) { | 1198 | if (effective_kind & cd->info.supportedInput) { |
| 1197 | scope.push_back(cd); | 1199 | scope.push_back(cd); |
| 1198 | } | 1200 | } |
| 1199 | } | 1201 | } |
| @@ -1246,9 +1248,11 @@ public: | |||
| 1246 | if (device) { | 1248 | if (device) { |
| 1247 | Device* d = as_device(device); | 1249 | Device* d = as_device(device); |
| 1248 | if (d->info.deviceFamily == GameInputFamilyAggregate) { | 1250 | if (d->info.deviceFamily == GameInputFamilyAggregate) { |
| 1249 | const uint32_t effective_kind = (kind != GameInputKindUnknown) ? kind : d->info.supportedInput; | 1251 | if (kind != GameInputKindUnknown && !(kind & d->info.supportedInput)) |
| 1252 | return GAMEINPUT_E_READING_NOT_FOUND; | ||
| 1253 | const uint32_t effective_kind = (kind != GameInputKindUnknown) ? (kind & d->info.supportedInput) : d->info.supportedInput; | ||
| 1250 | for (Device* cd : g().connected) { | 1254 | for (Device* cd : g().connected) { |
| 1251 | if (effective_kind != GameInputKindUnknown && !(effective_kind & cd->info.supportedInput)) continue; | 1255 | if (!(effective_kind & cd->info.supportedInput)) continue; |
| 1252 | if (Reading* r = cd->latest(); r && (!best || r->GetTimestamp() >= best->GetTimestamp())) best = r; | 1256 | if (Reading* r = cd->latest(); r && (!best || r->GetTimestamp() >= best->GetTimestamp())) best = r; |
| 1253 | } | 1257 | } |
| 1254 | } else { | 1258 | } else { |
| @@ -1283,6 +1287,9 @@ public: | |||
| 1283 | 1287 | ||
| 1284 | HRESULT STDMETHODCALLTYPE RegisterReadingCallback(IGameInputDevice* device, uint32_t kind, float, void* context, | 1288 | HRESULT STDMETHODCALLTYPE RegisterReadingCallback(IGameInputDevice* device, uint32_t kind, float, void* context, |
| 1285 | GameInputReadingCallback fn, GameInputCallbackToken* token) override { | 1289 | GameInputReadingCallback fn, GameInputCallbackToken* token) override { |
| 1290 | if (token) *token = kInvalidCallbackToken; | ||
| 1291 | if (!fn) return E_INVALIDARG; | ||
| 1292 | if (device && as_device(device)->info.deviceFamily == GameInputFamilyAggregate) return E_NOTIMPL; | ||
| 1286 | return add({0, CbType::Reading, as_device(device), kind, 0, context, reinterpret_cast<void*>(fn), true}, token); | 1293 | return add({0, CbType::Reading, as_device(device), kind, 0, context, reinterpret_cast<void*>(fn), true}, token); |
| 1287 | } | 1294 | } |
| 1288 | 1295 | ||
| @@ -1291,6 +1298,7 @@ public: | |||
| 1291 | GameInputDeviceCallback fn, GameInputCallbackToken* token) override { | 1298 | GameInputDeviceCallback fn, GameInputCallbackToken* token) override { |
| 1292 | if (token) *token = kInvalidCallbackToken; | 1299 | if (token) *token = kInvalidCallbackToken; |
| 1293 | if (!fn) return E_INVALIDARG; | 1300 | if (!fn) return E_INVALIDARG; |
| 1301 | if (device && as_device(device)->info.deviceFamily == GameInputFamilyAggregate) return E_NOTIMPL; | ||
| 1294 | State& s = g(); | 1302 | State& s = g(); |
| 1295 | GameInputCallbackToken t; | 1303 | GameInputCallbackToken t; |
| 1296 | std::vector<Event> now; | 1304 | std::vector<Event> now; |