github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/bluetoothprivate/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/bluetoothprivate", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "constof_ConnectResultType": (ref: heap.Ref<string>): number => { 8 const idx = [ 9 "alreadyConnected", 10 "authCanceled", 11 "authFailed", 12 "authRejected", 13 "authTimeout", 14 "failed", 15 "inProgress", 16 "success", 17 "unknownError", 18 "unsupportedDevice", 19 "notReady", 20 "alreadyExists", 21 "notConnected", 22 "doesNotExist", 23 "invalidArgs", 24 ].indexOf(A.H.get(ref)); 25 return idx < 0 ? 0 : idx + 1; 26 }, 27 "constof_TransportType": (ref: heap.Ref<string>): number => { 28 const idx = ["le", "bredr", "dual"].indexOf(A.H.get(ref)); 29 return idx < 0 ? 0 : idx + 1; 30 }, 31 32 "store_DiscoveryFilter": (ptr: Pointer, ref: heap.Ref<any>) => { 33 const x = A.H.get<any>(ref); 34 35 if (typeof x === "undefined") { 36 A.store.Bool(ptr + 18, false); 37 A.store.Enum(ptr + 0, -1); 38 A.store.Ref(ptr + 4, undefined); 39 A.store.Bool(ptr + 16, false); 40 A.store.Int32(ptr + 8, 0); 41 A.store.Bool(ptr + 17, false); 42 A.store.Int32(ptr + 12, 0); 43 } else { 44 A.store.Bool(ptr + 18, true); 45 A.store.Enum(ptr + 0, ["le", "bredr", "dual"].indexOf(x["transport"] as string)); 46 A.store.Ref(ptr + 4, x["uuids"]); 47 A.store.Bool(ptr + 16, "rssi" in x ? true : false); 48 A.store.Int32(ptr + 8, x["rssi"] === undefined ? 0 : (x["rssi"] as number)); 49 A.store.Bool(ptr + 17, "pathloss" in x ? true : false); 50 A.store.Int32(ptr + 12, x["pathloss"] === undefined ? 0 : (x["pathloss"] as number)); 51 } 52 }, 53 "load_DiscoveryFilter": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 54 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 55 56 x["transport"] = A.load.Enum(ptr + 0, ["le", "bredr", "dual"]); 57 x["uuids"] = A.load.Ref(ptr + 4, undefined); 58 if (A.load.Bool(ptr + 16)) { 59 x["rssi"] = A.load.Int32(ptr + 8); 60 } else { 61 delete x["rssi"]; 62 } 63 if (A.load.Bool(ptr + 17)) { 64 x["pathloss"] = A.load.Int32(ptr + 12); 65 } else { 66 delete x["pathloss"]; 67 } 68 return create === A.H.TRUE ? A.H.push(x) : ref; 69 }, 70 71 "store_NewAdapterState": (ptr: Pointer, ref: heap.Ref<any>) => { 72 const x = A.H.get<any>(ref); 73 74 if (typeof x === "undefined") { 75 A.store.Bool(ptr + 8, false); 76 A.store.Ref(ptr + 0, undefined); 77 A.store.Bool(ptr + 6, false); 78 A.store.Bool(ptr + 4, false); 79 A.store.Bool(ptr + 7, false); 80 A.store.Bool(ptr + 5, false); 81 } else { 82 A.store.Bool(ptr + 8, true); 83 A.store.Ref(ptr + 0, x["name"]); 84 A.store.Bool(ptr + 6, "powered" in x ? true : false); 85 A.store.Bool(ptr + 4, x["powered"] ? true : false); 86 A.store.Bool(ptr + 7, "discoverable" in x ? true : false); 87 A.store.Bool(ptr + 5, x["discoverable"] ? true : false); 88 } 89 }, 90 "load_NewAdapterState": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 91 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 92 93 x["name"] = A.load.Ref(ptr + 0, undefined); 94 if (A.load.Bool(ptr + 6)) { 95 x["powered"] = A.load.Bool(ptr + 4); 96 } else { 97 delete x["powered"]; 98 } 99 if (A.load.Bool(ptr + 7)) { 100 x["discoverable"] = A.load.Bool(ptr + 5); 101 } else { 102 delete x["discoverable"]; 103 } 104 return create === A.H.TRUE ? A.H.push(x) : ref; 105 }, 106 "constof_PairingEventType": (ref: heap.Ref<string>): number => { 107 const idx = [ 108 "requestPincode", 109 "displayPincode", 110 "requestPasskey", 111 "displayPasskey", 112 "keysEntered", 113 "confirmPasskey", 114 "requestAuthorization", 115 "complete", 116 ].indexOf(A.H.get(ref)); 117 return idx < 0 ? 0 : idx + 1; 118 }, 119 120 "store_PairingEvent": (ptr: Pointer, ref: heap.Ref<any>) => { 121 const x = A.H.get<any>(ref); 122 123 if (typeof x === "undefined") { 124 A.store.Bool(ptr + 86, false); 125 A.store.Enum(ptr + 0, -1); 126 127 A.store.Bool(ptr + 4 + 67, false); 128 A.store.Ref(ptr + 4 + 0, undefined); 129 A.store.Ref(ptr + 4 + 4, undefined); 130 A.store.Bool(ptr + 4 + 56, false); 131 A.store.Int32(ptr + 4 + 8, 0); 132 A.store.Enum(ptr + 4 + 12, -1); 133 A.store.Bool(ptr + 4 + 57, false); 134 A.store.Int32(ptr + 4 + 16, 0); 135 A.store.Bool(ptr + 4 + 58, false); 136 A.store.Int32(ptr + 4 + 20, 0); 137 A.store.Bool(ptr + 4 + 59, false); 138 A.store.Int32(ptr + 4 + 24, 0); 139 A.store.Enum(ptr + 4 + 28, -1); 140 A.store.Bool(ptr + 4 + 60, false); 141 A.store.Bool(ptr + 4 + 32, false); 142 A.store.Bool(ptr + 4 + 61, false); 143 A.store.Bool(ptr + 4 + 33, false); 144 A.store.Bool(ptr + 4 + 62, false); 145 A.store.Bool(ptr + 4 + 34, false); 146 A.store.Bool(ptr + 4 + 63, false); 147 A.store.Bool(ptr + 4 + 35, false); 148 A.store.Ref(ptr + 4 + 36, undefined); 149 A.store.Bool(ptr + 4 + 64, false); 150 A.store.Int32(ptr + 4 + 40, 0); 151 A.store.Bool(ptr + 4 + 65, false); 152 A.store.Int32(ptr + 4 + 44, 0); 153 A.store.Enum(ptr + 4 + 48, -1); 154 A.store.Bool(ptr + 4 + 66, false); 155 A.store.Int32(ptr + 4 + 52, 0); 156 A.store.Ref(ptr + 72, undefined); 157 A.store.Bool(ptr + 84, false); 158 A.store.Int32(ptr + 76, 0); 159 A.store.Bool(ptr + 85, false); 160 A.store.Int32(ptr + 80, 0); 161 } else { 162 A.store.Bool(ptr + 86, true); 163 A.store.Enum( 164 ptr + 0, 165 [ 166 "requestPincode", 167 "displayPincode", 168 "requestPasskey", 169 "displayPasskey", 170 "keysEntered", 171 "confirmPasskey", 172 "requestAuthorization", 173 "complete", 174 ].indexOf(x["pairing"] as string) 175 ); 176 177 if (typeof x["device"] === "undefined") { 178 A.store.Bool(ptr + 4 + 67, false); 179 A.store.Ref(ptr + 4 + 0, undefined); 180 A.store.Ref(ptr + 4 + 4, undefined); 181 A.store.Bool(ptr + 4 + 56, false); 182 A.store.Int32(ptr + 4 + 8, 0); 183 A.store.Enum(ptr + 4 + 12, -1); 184 A.store.Bool(ptr + 4 + 57, false); 185 A.store.Int32(ptr + 4 + 16, 0); 186 A.store.Bool(ptr + 4 + 58, false); 187 A.store.Int32(ptr + 4 + 20, 0); 188 A.store.Bool(ptr + 4 + 59, false); 189 A.store.Int32(ptr + 4 + 24, 0); 190 A.store.Enum(ptr + 4 + 28, -1); 191 A.store.Bool(ptr + 4 + 60, false); 192 A.store.Bool(ptr + 4 + 32, false); 193 A.store.Bool(ptr + 4 + 61, false); 194 A.store.Bool(ptr + 4 + 33, false); 195 A.store.Bool(ptr + 4 + 62, false); 196 A.store.Bool(ptr + 4 + 34, false); 197 A.store.Bool(ptr + 4 + 63, false); 198 A.store.Bool(ptr + 4 + 35, false); 199 A.store.Ref(ptr + 4 + 36, undefined); 200 A.store.Bool(ptr + 4 + 64, false); 201 A.store.Int32(ptr + 4 + 40, 0); 202 A.store.Bool(ptr + 4 + 65, false); 203 A.store.Int32(ptr + 4 + 44, 0); 204 A.store.Enum(ptr + 4 + 48, -1); 205 A.store.Bool(ptr + 4 + 66, false); 206 A.store.Int32(ptr + 4 + 52, 0); 207 } else { 208 A.store.Bool(ptr + 4 + 67, true); 209 A.store.Ref(ptr + 4 + 0, x["device"]["address"]); 210 A.store.Ref(ptr + 4 + 4, x["device"]["name"]); 211 A.store.Bool(ptr + 4 + 56, "deviceClass" in x["device"] ? true : false); 212 A.store.Int32( 213 ptr + 4 + 8, 214 x["device"]["deviceClass"] === undefined ? 0 : (x["device"]["deviceClass"] as number) 215 ); 216 A.store.Enum(ptr + 4 + 12, ["bluetooth", "usb"].indexOf(x["device"]["vendorIdSource"] as string)); 217 A.store.Bool(ptr + 4 + 57, "vendorId" in x["device"] ? true : false); 218 A.store.Int32(ptr + 4 + 16, x["device"]["vendorId"] === undefined ? 0 : (x["device"]["vendorId"] as number)); 219 A.store.Bool(ptr + 4 + 58, "productId" in x["device"] ? true : false); 220 A.store.Int32( 221 ptr + 4 + 20, 222 x["device"]["productId"] === undefined ? 0 : (x["device"]["productId"] as number) 223 ); 224 A.store.Bool(ptr + 4 + 59, "deviceId" in x["device"] ? true : false); 225 A.store.Int32(ptr + 4 + 24, x["device"]["deviceId"] === undefined ? 0 : (x["device"]["deviceId"] as number)); 226 A.store.Enum( 227 ptr + 4 + 28, 228 [ 229 "computer", 230 "phone", 231 "modem", 232 "audio", 233 "carAudio", 234 "video", 235 "peripheral", 236 "joystick", 237 "gamepad", 238 "keyboard", 239 "mouse", 240 "tablet", 241 "keyboardMouseCombo", 242 ].indexOf(x["device"]["type"] as string) 243 ); 244 A.store.Bool(ptr + 4 + 60, "paired" in x["device"] ? true : false); 245 A.store.Bool(ptr + 4 + 32, x["device"]["paired"] ? true : false); 246 A.store.Bool(ptr + 4 + 61, "connected" in x["device"] ? true : false); 247 A.store.Bool(ptr + 4 + 33, x["device"]["connected"] ? true : false); 248 A.store.Bool(ptr + 4 + 62, "connecting" in x["device"] ? true : false); 249 A.store.Bool(ptr + 4 + 34, x["device"]["connecting"] ? true : false); 250 A.store.Bool(ptr + 4 + 63, "connectable" in x["device"] ? true : false); 251 A.store.Bool(ptr + 4 + 35, x["device"]["connectable"] ? true : false); 252 A.store.Ref(ptr + 4 + 36, x["device"]["uuids"]); 253 A.store.Bool(ptr + 4 + 64, "inquiryRssi" in x["device"] ? true : false); 254 A.store.Int32( 255 ptr + 4 + 40, 256 x["device"]["inquiryRssi"] === undefined ? 0 : (x["device"]["inquiryRssi"] as number) 257 ); 258 A.store.Bool(ptr + 4 + 65, "inquiryTxPower" in x["device"] ? true : false); 259 A.store.Int32( 260 ptr + 4 + 44, 261 x["device"]["inquiryTxPower"] === undefined ? 0 : (x["device"]["inquiryTxPower"] as number) 262 ); 263 A.store.Enum(ptr + 4 + 48, ["invalid", "classic", "le", "dual"].indexOf(x["device"]["transport"] as string)); 264 A.store.Bool(ptr + 4 + 66, "batteryPercentage" in x["device"] ? true : false); 265 A.store.Int32( 266 ptr + 4 + 52, 267 x["device"]["batteryPercentage"] === undefined ? 0 : (x["device"]["batteryPercentage"] as number) 268 ); 269 } 270 A.store.Ref(ptr + 72, x["pincode"]); 271 A.store.Bool(ptr + 84, "passkey" in x ? true : false); 272 A.store.Int32(ptr + 76, x["passkey"] === undefined ? 0 : (x["passkey"] as number)); 273 A.store.Bool(ptr + 85, "enteredKey" in x ? true : false); 274 A.store.Int32(ptr + 80, x["enteredKey"] === undefined ? 0 : (x["enteredKey"] as number)); 275 } 276 }, 277 "load_PairingEvent": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 278 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 279 280 x["pairing"] = A.load.Enum(ptr + 0, [ 281 "requestPincode", 282 "displayPincode", 283 "requestPasskey", 284 "displayPasskey", 285 "keysEntered", 286 "confirmPasskey", 287 "requestAuthorization", 288 "complete", 289 ]); 290 if (A.load.Bool(ptr + 4 + 67)) { 291 x["device"] = {}; 292 x["device"]["address"] = A.load.Ref(ptr + 4 + 0, undefined); 293 x["device"]["name"] = A.load.Ref(ptr + 4 + 4, undefined); 294 if (A.load.Bool(ptr + 4 + 56)) { 295 x["device"]["deviceClass"] = A.load.Int32(ptr + 4 + 8); 296 } else { 297 delete x["device"]["deviceClass"]; 298 } 299 x["device"]["vendorIdSource"] = A.load.Enum(ptr + 4 + 12, ["bluetooth", "usb"]); 300 if (A.load.Bool(ptr + 4 + 57)) { 301 x["device"]["vendorId"] = A.load.Int32(ptr + 4 + 16); 302 } else { 303 delete x["device"]["vendorId"]; 304 } 305 if (A.load.Bool(ptr + 4 + 58)) { 306 x["device"]["productId"] = A.load.Int32(ptr + 4 + 20); 307 } else { 308 delete x["device"]["productId"]; 309 } 310 if (A.load.Bool(ptr + 4 + 59)) { 311 x["device"]["deviceId"] = A.load.Int32(ptr + 4 + 24); 312 } else { 313 delete x["device"]["deviceId"]; 314 } 315 x["device"]["type"] = A.load.Enum(ptr + 4 + 28, [ 316 "computer", 317 "phone", 318 "modem", 319 "audio", 320 "carAudio", 321 "video", 322 "peripheral", 323 "joystick", 324 "gamepad", 325 "keyboard", 326 "mouse", 327 "tablet", 328 "keyboardMouseCombo", 329 ]); 330 if (A.load.Bool(ptr + 4 + 60)) { 331 x["device"]["paired"] = A.load.Bool(ptr + 4 + 32); 332 } else { 333 delete x["device"]["paired"]; 334 } 335 if (A.load.Bool(ptr + 4 + 61)) { 336 x["device"]["connected"] = A.load.Bool(ptr + 4 + 33); 337 } else { 338 delete x["device"]["connected"]; 339 } 340 if (A.load.Bool(ptr + 4 + 62)) { 341 x["device"]["connecting"] = A.load.Bool(ptr + 4 + 34); 342 } else { 343 delete x["device"]["connecting"]; 344 } 345 if (A.load.Bool(ptr + 4 + 63)) { 346 x["device"]["connectable"] = A.load.Bool(ptr + 4 + 35); 347 } else { 348 delete x["device"]["connectable"]; 349 } 350 x["device"]["uuids"] = A.load.Ref(ptr + 4 + 36, undefined); 351 if (A.load.Bool(ptr + 4 + 64)) { 352 x["device"]["inquiryRssi"] = A.load.Int32(ptr + 4 + 40); 353 } else { 354 delete x["device"]["inquiryRssi"]; 355 } 356 if (A.load.Bool(ptr + 4 + 65)) { 357 x["device"]["inquiryTxPower"] = A.load.Int32(ptr + 4 + 44); 358 } else { 359 delete x["device"]["inquiryTxPower"]; 360 } 361 x["device"]["transport"] = A.load.Enum(ptr + 4 + 48, ["invalid", "classic", "le", "dual"]); 362 if (A.load.Bool(ptr + 4 + 66)) { 363 x["device"]["batteryPercentage"] = A.load.Int32(ptr + 4 + 52); 364 } else { 365 delete x["device"]["batteryPercentage"]; 366 } 367 } else { 368 delete x["device"]; 369 } 370 x["pincode"] = A.load.Ref(ptr + 72, undefined); 371 if (A.load.Bool(ptr + 84)) { 372 x["passkey"] = A.load.Int32(ptr + 76); 373 } else { 374 delete x["passkey"]; 375 } 376 if (A.load.Bool(ptr + 85)) { 377 x["enteredKey"] = A.load.Int32(ptr + 80); 378 } else { 379 delete x["enteredKey"]; 380 } 381 return create === A.H.TRUE ? A.H.push(x) : ref; 382 }, 383 "constof_PairingResponse": (ref: heap.Ref<string>): number => { 384 const idx = ["confirm", "reject", "cancel"].indexOf(A.H.get(ref)); 385 return idx < 0 ? 0 : idx + 1; 386 }, 387 388 "store_SetPairingResponseOptions": (ptr: Pointer, ref: heap.Ref<any>) => { 389 const x = A.H.get<any>(ref); 390 391 if (typeof x === "undefined") { 392 A.store.Bool(ptr + 81, false); 393 394 A.store.Bool(ptr + 0 + 67, false); 395 A.store.Ref(ptr + 0 + 0, undefined); 396 A.store.Ref(ptr + 0 + 4, undefined); 397 A.store.Bool(ptr + 0 + 56, false); 398 A.store.Int32(ptr + 0 + 8, 0); 399 A.store.Enum(ptr + 0 + 12, -1); 400 A.store.Bool(ptr + 0 + 57, false); 401 A.store.Int32(ptr + 0 + 16, 0); 402 A.store.Bool(ptr + 0 + 58, false); 403 A.store.Int32(ptr + 0 + 20, 0); 404 A.store.Bool(ptr + 0 + 59, false); 405 A.store.Int32(ptr + 0 + 24, 0); 406 A.store.Enum(ptr + 0 + 28, -1); 407 A.store.Bool(ptr + 0 + 60, false); 408 A.store.Bool(ptr + 0 + 32, false); 409 A.store.Bool(ptr + 0 + 61, false); 410 A.store.Bool(ptr + 0 + 33, false); 411 A.store.Bool(ptr + 0 + 62, false); 412 A.store.Bool(ptr + 0 + 34, false); 413 A.store.Bool(ptr + 0 + 63, false); 414 A.store.Bool(ptr + 0 + 35, false); 415 A.store.Ref(ptr + 0 + 36, undefined); 416 A.store.Bool(ptr + 0 + 64, false); 417 A.store.Int32(ptr + 0 + 40, 0); 418 A.store.Bool(ptr + 0 + 65, false); 419 A.store.Int32(ptr + 0 + 44, 0); 420 A.store.Enum(ptr + 0 + 48, -1); 421 A.store.Bool(ptr + 0 + 66, false); 422 A.store.Int32(ptr + 0 + 52, 0); 423 A.store.Enum(ptr + 68, -1); 424 A.store.Ref(ptr + 72, undefined); 425 A.store.Bool(ptr + 80, false); 426 A.store.Int32(ptr + 76, 0); 427 } else { 428 A.store.Bool(ptr + 81, true); 429 430 if (typeof x["device"] === "undefined") { 431 A.store.Bool(ptr + 0 + 67, false); 432 A.store.Ref(ptr + 0 + 0, undefined); 433 A.store.Ref(ptr + 0 + 4, undefined); 434 A.store.Bool(ptr + 0 + 56, false); 435 A.store.Int32(ptr + 0 + 8, 0); 436 A.store.Enum(ptr + 0 + 12, -1); 437 A.store.Bool(ptr + 0 + 57, false); 438 A.store.Int32(ptr + 0 + 16, 0); 439 A.store.Bool(ptr + 0 + 58, false); 440 A.store.Int32(ptr + 0 + 20, 0); 441 A.store.Bool(ptr + 0 + 59, false); 442 A.store.Int32(ptr + 0 + 24, 0); 443 A.store.Enum(ptr + 0 + 28, -1); 444 A.store.Bool(ptr + 0 + 60, false); 445 A.store.Bool(ptr + 0 + 32, false); 446 A.store.Bool(ptr + 0 + 61, false); 447 A.store.Bool(ptr + 0 + 33, false); 448 A.store.Bool(ptr + 0 + 62, false); 449 A.store.Bool(ptr + 0 + 34, false); 450 A.store.Bool(ptr + 0 + 63, false); 451 A.store.Bool(ptr + 0 + 35, false); 452 A.store.Ref(ptr + 0 + 36, undefined); 453 A.store.Bool(ptr + 0 + 64, false); 454 A.store.Int32(ptr + 0 + 40, 0); 455 A.store.Bool(ptr + 0 + 65, false); 456 A.store.Int32(ptr + 0 + 44, 0); 457 A.store.Enum(ptr + 0 + 48, -1); 458 A.store.Bool(ptr + 0 + 66, false); 459 A.store.Int32(ptr + 0 + 52, 0); 460 } else { 461 A.store.Bool(ptr + 0 + 67, true); 462 A.store.Ref(ptr + 0 + 0, x["device"]["address"]); 463 A.store.Ref(ptr + 0 + 4, x["device"]["name"]); 464 A.store.Bool(ptr + 0 + 56, "deviceClass" in x["device"] ? true : false); 465 A.store.Int32( 466 ptr + 0 + 8, 467 x["device"]["deviceClass"] === undefined ? 0 : (x["device"]["deviceClass"] as number) 468 ); 469 A.store.Enum(ptr + 0 + 12, ["bluetooth", "usb"].indexOf(x["device"]["vendorIdSource"] as string)); 470 A.store.Bool(ptr + 0 + 57, "vendorId" in x["device"] ? true : false); 471 A.store.Int32(ptr + 0 + 16, x["device"]["vendorId"] === undefined ? 0 : (x["device"]["vendorId"] as number)); 472 A.store.Bool(ptr + 0 + 58, "productId" in x["device"] ? true : false); 473 A.store.Int32( 474 ptr + 0 + 20, 475 x["device"]["productId"] === undefined ? 0 : (x["device"]["productId"] as number) 476 ); 477 A.store.Bool(ptr + 0 + 59, "deviceId" in x["device"] ? true : false); 478 A.store.Int32(ptr + 0 + 24, x["device"]["deviceId"] === undefined ? 0 : (x["device"]["deviceId"] as number)); 479 A.store.Enum( 480 ptr + 0 + 28, 481 [ 482 "computer", 483 "phone", 484 "modem", 485 "audio", 486 "carAudio", 487 "video", 488 "peripheral", 489 "joystick", 490 "gamepad", 491 "keyboard", 492 "mouse", 493 "tablet", 494 "keyboardMouseCombo", 495 ].indexOf(x["device"]["type"] as string) 496 ); 497 A.store.Bool(ptr + 0 + 60, "paired" in x["device"] ? true : false); 498 A.store.Bool(ptr + 0 + 32, x["device"]["paired"] ? true : false); 499 A.store.Bool(ptr + 0 + 61, "connected" in x["device"] ? true : false); 500 A.store.Bool(ptr + 0 + 33, x["device"]["connected"] ? true : false); 501 A.store.Bool(ptr + 0 + 62, "connecting" in x["device"] ? true : false); 502 A.store.Bool(ptr + 0 + 34, x["device"]["connecting"] ? true : false); 503 A.store.Bool(ptr + 0 + 63, "connectable" in x["device"] ? true : false); 504 A.store.Bool(ptr + 0 + 35, x["device"]["connectable"] ? true : false); 505 A.store.Ref(ptr + 0 + 36, x["device"]["uuids"]); 506 A.store.Bool(ptr + 0 + 64, "inquiryRssi" in x["device"] ? true : false); 507 A.store.Int32( 508 ptr + 0 + 40, 509 x["device"]["inquiryRssi"] === undefined ? 0 : (x["device"]["inquiryRssi"] as number) 510 ); 511 A.store.Bool(ptr + 0 + 65, "inquiryTxPower" in x["device"] ? true : false); 512 A.store.Int32( 513 ptr + 0 + 44, 514 x["device"]["inquiryTxPower"] === undefined ? 0 : (x["device"]["inquiryTxPower"] as number) 515 ); 516 A.store.Enum(ptr + 0 + 48, ["invalid", "classic", "le", "dual"].indexOf(x["device"]["transport"] as string)); 517 A.store.Bool(ptr + 0 + 66, "batteryPercentage" in x["device"] ? true : false); 518 A.store.Int32( 519 ptr + 0 + 52, 520 x["device"]["batteryPercentage"] === undefined ? 0 : (x["device"]["batteryPercentage"] as number) 521 ); 522 } 523 A.store.Enum(ptr + 68, ["confirm", "reject", "cancel"].indexOf(x["response"] as string)); 524 A.store.Ref(ptr + 72, x["pincode"]); 525 A.store.Bool(ptr + 80, "passkey" in x ? true : false); 526 A.store.Int32(ptr + 76, x["passkey"] === undefined ? 0 : (x["passkey"] as number)); 527 } 528 }, 529 "load_SetPairingResponseOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 530 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 531 532 if (A.load.Bool(ptr + 0 + 67)) { 533 x["device"] = {}; 534 x["device"]["address"] = A.load.Ref(ptr + 0 + 0, undefined); 535 x["device"]["name"] = A.load.Ref(ptr + 0 + 4, undefined); 536 if (A.load.Bool(ptr + 0 + 56)) { 537 x["device"]["deviceClass"] = A.load.Int32(ptr + 0 + 8); 538 } else { 539 delete x["device"]["deviceClass"]; 540 } 541 x["device"]["vendorIdSource"] = A.load.Enum(ptr + 0 + 12, ["bluetooth", "usb"]); 542 if (A.load.Bool(ptr + 0 + 57)) { 543 x["device"]["vendorId"] = A.load.Int32(ptr + 0 + 16); 544 } else { 545 delete x["device"]["vendorId"]; 546 } 547 if (A.load.Bool(ptr + 0 + 58)) { 548 x["device"]["productId"] = A.load.Int32(ptr + 0 + 20); 549 } else { 550 delete x["device"]["productId"]; 551 } 552 if (A.load.Bool(ptr + 0 + 59)) { 553 x["device"]["deviceId"] = A.load.Int32(ptr + 0 + 24); 554 } else { 555 delete x["device"]["deviceId"]; 556 } 557 x["device"]["type"] = A.load.Enum(ptr + 0 + 28, [ 558 "computer", 559 "phone", 560 "modem", 561 "audio", 562 "carAudio", 563 "video", 564 "peripheral", 565 "joystick", 566 "gamepad", 567 "keyboard", 568 "mouse", 569 "tablet", 570 "keyboardMouseCombo", 571 ]); 572 if (A.load.Bool(ptr + 0 + 60)) { 573 x["device"]["paired"] = A.load.Bool(ptr + 0 + 32); 574 } else { 575 delete x["device"]["paired"]; 576 } 577 if (A.load.Bool(ptr + 0 + 61)) { 578 x["device"]["connected"] = A.load.Bool(ptr + 0 + 33); 579 } else { 580 delete x["device"]["connected"]; 581 } 582 if (A.load.Bool(ptr + 0 + 62)) { 583 x["device"]["connecting"] = A.load.Bool(ptr + 0 + 34); 584 } else { 585 delete x["device"]["connecting"]; 586 } 587 if (A.load.Bool(ptr + 0 + 63)) { 588 x["device"]["connectable"] = A.load.Bool(ptr + 0 + 35); 589 } else { 590 delete x["device"]["connectable"]; 591 } 592 x["device"]["uuids"] = A.load.Ref(ptr + 0 + 36, undefined); 593 if (A.load.Bool(ptr + 0 + 64)) { 594 x["device"]["inquiryRssi"] = A.load.Int32(ptr + 0 + 40); 595 } else { 596 delete x["device"]["inquiryRssi"]; 597 } 598 if (A.load.Bool(ptr + 0 + 65)) { 599 x["device"]["inquiryTxPower"] = A.load.Int32(ptr + 0 + 44); 600 } else { 601 delete x["device"]["inquiryTxPower"]; 602 } 603 x["device"]["transport"] = A.load.Enum(ptr + 0 + 48, ["invalid", "classic", "le", "dual"]); 604 if (A.load.Bool(ptr + 0 + 66)) { 605 x["device"]["batteryPercentage"] = A.load.Int32(ptr + 0 + 52); 606 } else { 607 delete x["device"]["batteryPercentage"]; 608 } 609 } else { 610 delete x["device"]; 611 } 612 x["response"] = A.load.Enum(ptr + 68, ["confirm", "reject", "cancel"]); 613 x["pincode"] = A.load.Ref(ptr + 72, undefined); 614 if (A.load.Bool(ptr + 80)) { 615 x["passkey"] = A.load.Int32(ptr + 76); 616 } else { 617 delete x["passkey"]; 618 } 619 return create === A.H.TRUE ? A.H.push(x) : ref; 620 }, 621 "has_Connect": (): heap.Ref<boolean> => { 622 if (WEBEXT?.bluetoothPrivate && "connect" in WEBEXT?.bluetoothPrivate) { 623 return A.H.TRUE; 624 } 625 return A.H.FALSE; 626 }, 627 "func_Connect": (fn: Pointer): void => { 628 A.store.Ref(fn, WEBEXT.bluetoothPrivate.connect); 629 }, 630 "call_Connect": (retPtr: Pointer, deviceAddress: heap.Ref<object>): void => { 631 const _ret = WEBEXT.bluetoothPrivate.connect(A.H.get<object>(deviceAddress)); 632 A.store.Ref(retPtr, _ret); 633 }, 634 "try_Connect": (retPtr: Pointer, errPtr: Pointer, deviceAddress: heap.Ref<object>): heap.Ref<boolean> => { 635 try { 636 const _ret = WEBEXT.bluetoothPrivate.connect(A.H.get<object>(deviceAddress)); 637 A.store.Ref(retPtr, _ret); 638 return A.H.TRUE; 639 } catch (err: any) { 640 A.store.Ref(errPtr, err); 641 return A.H.FALSE; 642 } 643 }, 644 "has_DisconnectAll": (): heap.Ref<boolean> => { 645 if (WEBEXT?.bluetoothPrivate && "disconnectAll" in WEBEXT?.bluetoothPrivate) { 646 return A.H.TRUE; 647 } 648 return A.H.FALSE; 649 }, 650 "func_DisconnectAll": (fn: Pointer): void => { 651 A.store.Ref(fn, WEBEXT.bluetoothPrivate.disconnectAll); 652 }, 653 "call_DisconnectAll": (retPtr: Pointer, deviceAddress: heap.Ref<object>): void => { 654 const _ret = WEBEXT.bluetoothPrivate.disconnectAll(A.H.get<object>(deviceAddress)); 655 A.store.Ref(retPtr, _ret); 656 }, 657 "try_DisconnectAll": (retPtr: Pointer, errPtr: Pointer, deviceAddress: heap.Ref<object>): heap.Ref<boolean> => { 658 try { 659 const _ret = WEBEXT.bluetoothPrivate.disconnectAll(A.H.get<object>(deviceAddress)); 660 A.store.Ref(retPtr, _ret); 661 return A.H.TRUE; 662 } catch (err: any) { 663 A.store.Ref(errPtr, err); 664 return A.H.FALSE; 665 } 666 }, 667 "has_ForgetDevice": (): heap.Ref<boolean> => { 668 if (WEBEXT?.bluetoothPrivate && "forgetDevice" in WEBEXT?.bluetoothPrivate) { 669 return A.H.TRUE; 670 } 671 return A.H.FALSE; 672 }, 673 "func_ForgetDevice": (fn: Pointer): void => { 674 A.store.Ref(fn, WEBEXT.bluetoothPrivate.forgetDevice); 675 }, 676 "call_ForgetDevice": (retPtr: Pointer, deviceAddress: heap.Ref<object>): void => { 677 const _ret = WEBEXT.bluetoothPrivate.forgetDevice(A.H.get<object>(deviceAddress)); 678 A.store.Ref(retPtr, _ret); 679 }, 680 "try_ForgetDevice": (retPtr: Pointer, errPtr: Pointer, deviceAddress: heap.Ref<object>): heap.Ref<boolean> => { 681 try { 682 const _ret = WEBEXT.bluetoothPrivate.forgetDevice(A.H.get<object>(deviceAddress)); 683 A.store.Ref(retPtr, _ret); 684 return A.H.TRUE; 685 } catch (err: any) { 686 A.store.Ref(errPtr, err); 687 return A.H.FALSE; 688 } 689 }, 690 "has_OnDeviceAddressChanged": (): heap.Ref<boolean> => { 691 if ( 692 WEBEXT?.bluetoothPrivate?.onDeviceAddressChanged && 693 "addListener" in WEBEXT?.bluetoothPrivate?.onDeviceAddressChanged 694 ) { 695 return A.H.TRUE; 696 } 697 return A.H.FALSE; 698 }, 699 "func_OnDeviceAddressChanged": (fn: Pointer): void => { 700 A.store.Ref(fn, WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener); 701 }, 702 "call_OnDeviceAddressChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 703 const _ret = WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener(A.H.get<object>(callback)); 704 }, 705 "try_OnDeviceAddressChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 706 try { 707 const _ret = WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener(A.H.get<object>(callback)); 708 return A.H.TRUE; 709 } catch (err: any) { 710 A.store.Ref(errPtr, err); 711 return A.H.FALSE; 712 } 713 }, 714 "has_OffDeviceAddressChanged": (): heap.Ref<boolean> => { 715 if ( 716 WEBEXT?.bluetoothPrivate?.onDeviceAddressChanged && 717 "removeListener" in WEBEXT?.bluetoothPrivate?.onDeviceAddressChanged 718 ) { 719 return A.H.TRUE; 720 } 721 return A.H.FALSE; 722 }, 723 "func_OffDeviceAddressChanged": (fn: Pointer): void => { 724 A.store.Ref(fn, WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener); 725 }, 726 "call_OffDeviceAddressChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 727 const _ret = WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener(A.H.get<object>(callback)); 728 }, 729 "try_OffDeviceAddressChanged": ( 730 retPtr: Pointer, 731 errPtr: Pointer, 732 callback: heap.Ref<object> 733 ): heap.Ref<boolean> => { 734 try { 735 const _ret = WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener(A.H.get<object>(callback)); 736 return A.H.TRUE; 737 } catch (err: any) { 738 A.store.Ref(errPtr, err); 739 return A.H.FALSE; 740 } 741 }, 742 "has_HasOnDeviceAddressChanged": (): heap.Ref<boolean> => { 743 if ( 744 WEBEXT?.bluetoothPrivate?.onDeviceAddressChanged && 745 "hasListener" in WEBEXT?.bluetoothPrivate?.onDeviceAddressChanged 746 ) { 747 return A.H.TRUE; 748 } 749 return A.H.FALSE; 750 }, 751 "func_HasOnDeviceAddressChanged": (fn: Pointer): void => { 752 A.store.Ref(fn, WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener); 753 }, 754 "call_HasOnDeviceAddressChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 755 const _ret = WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener(A.H.get<object>(callback)); 756 A.store.Bool(retPtr, _ret); 757 }, 758 "try_HasOnDeviceAddressChanged": ( 759 retPtr: Pointer, 760 errPtr: Pointer, 761 callback: heap.Ref<object> 762 ): heap.Ref<boolean> => { 763 try { 764 const _ret = WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener(A.H.get<object>(callback)); 765 A.store.Bool(retPtr, _ret); 766 return A.H.TRUE; 767 } catch (err: any) { 768 A.store.Ref(errPtr, err); 769 return A.H.FALSE; 770 } 771 }, 772 "has_OnPairing": (): heap.Ref<boolean> => { 773 if (WEBEXT?.bluetoothPrivate?.onPairing && "addListener" in WEBEXT?.bluetoothPrivate?.onPairing) { 774 return A.H.TRUE; 775 } 776 return A.H.FALSE; 777 }, 778 "func_OnPairing": (fn: Pointer): void => { 779 A.store.Ref(fn, WEBEXT.bluetoothPrivate.onPairing.addListener); 780 }, 781 "call_OnPairing": (retPtr: Pointer, callback: heap.Ref<object>): void => { 782 const _ret = WEBEXT.bluetoothPrivate.onPairing.addListener(A.H.get<object>(callback)); 783 }, 784 "try_OnPairing": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 785 try { 786 const _ret = WEBEXT.bluetoothPrivate.onPairing.addListener(A.H.get<object>(callback)); 787 return A.H.TRUE; 788 } catch (err: any) { 789 A.store.Ref(errPtr, err); 790 return A.H.FALSE; 791 } 792 }, 793 "has_OffPairing": (): heap.Ref<boolean> => { 794 if (WEBEXT?.bluetoothPrivate?.onPairing && "removeListener" in WEBEXT?.bluetoothPrivate?.onPairing) { 795 return A.H.TRUE; 796 } 797 return A.H.FALSE; 798 }, 799 "func_OffPairing": (fn: Pointer): void => { 800 A.store.Ref(fn, WEBEXT.bluetoothPrivate.onPairing.removeListener); 801 }, 802 "call_OffPairing": (retPtr: Pointer, callback: heap.Ref<object>): void => { 803 const _ret = WEBEXT.bluetoothPrivate.onPairing.removeListener(A.H.get<object>(callback)); 804 }, 805 "try_OffPairing": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 806 try { 807 const _ret = WEBEXT.bluetoothPrivate.onPairing.removeListener(A.H.get<object>(callback)); 808 return A.H.TRUE; 809 } catch (err: any) { 810 A.store.Ref(errPtr, err); 811 return A.H.FALSE; 812 } 813 }, 814 "has_HasOnPairing": (): heap.Ref<boolean> => { 815 if (WEBEXT?.bluetoothPrivate?.onPairing && "hasListener" in WEBEXT?.bluetoothPrivate?.onPairing) { 816 return A.H.TRUE; 817 } 818 return A.H.FALSE; 819 }, 820 "func_HasOnPairing": (fn: Pointer): void => { 821 A.store.Ref(fn, WEBEXT.bluetoothPrivate.onPairing.hasListener); 822 }, 823 "call_HasOnPairing": (retPtr: Pointer, callback: heap.Ref<object>): void => { 824 const _ret = WEBEXT.bluetoothPrivate.onPairing.hasListener(A.H.get<object>(callback)); 825 A.store.Bool(retPtr, _ret); 826 }, 827 "try_HasOnPairing": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 828 try { 829 const _ret = WEBEXT.bluetoothPrivate.onPairing.hasListener(A.H.get<object>(callback)); 830 A.store.Bool(retPtr, _ret); 831 return A.H.TRUE; 832 } catch (err: any) { 833 A.store.Ref(errPtr, err); 834 return A.H.FALSE; 835 } 836 }, 837 "has_Pair": (): heap.Ref<boolean> => { 838 if (WEBEXT?.bluetoothPrivate && "pair" in WEBEXT?.bluetoothPrivate) { 839 return A.H.TRUE; 840 } 841 return A.H.FALSE; 842 }, 843 "func_Pair": (fn: Pointer): void => { 844 A.store.Ref(fn, WEBEXT.bluetoothPrivate.pair); 845 }, 846 "call_Pair": (retPtr: Pointer, deviceAddress: heap.Ref<object>): void => { 847 const _ret = WEBEXT.bluetoothPrivate.pair(A.H.get<object>(deviceAddress)); 848 A.store.Ref(retPtr, _ret); 849 }, 850 "try_Pair": (retPtr: Pointer, errPtr: Pointer, deviceAddress: heap.Ref<object>): heap.Ref<boolean> => { 851 try { 852 const _ret = WEBEXT.bluetoothPrivate.pair(A.H.get<object>(deviceAddress)); 853 A.store.Ref(retPtr, _ret); 854 return A.H.TRUE; 855 } catch (err: any) { 856 A.store.Ref(errPtr, err); 857 return A.H.FALSE; 858 } 859 }, 860 "has_RecordDeviceSelection": (): heap.Ref<boolean> => { 861 if (WEBEXT?.bluetoothPrivate && "recordDeviceSelection" in WEBEXT?.bluetoothPrivate) { 862 return A.H.TRUE; 863 } 864 return A.H.FALSE; 865 }, 866 "func_RecordDeviceSelection": (fn: Pointer): void => { 867 A.store.Ref(fn, WEBEXT.bluetoothPrivate.recordDeviceSelection); 868 }, 869 "call_RecordDeviceSelection": ( 870 retPtr: Pointer, 871 selectionDurationMs: number, 872 wasPaired: heap.Ref<boolean>, 873 transport: number 874 ): void => { 875 const _ret = WEBEXT.bluetoothPrivate.recordDeviceSelection( 876 selectionDurationMs, 877 wasPaired === A.H.TRUE, 878 transport > 0 && transport <= 4 ? ["invalid", "classic", "le", "dual"][transport - 1] : undefined 879 ); 880 }, 881 "try_RecordDeviceSelection": ( 882 retPtr: Pointer, 883 errPtr: Pointer, 884 selectionDurationMs: number, 885 wasPaired: heap.Ref<boolean>, 886 transport: number 887 ): heap.Ref<boolean> => { 888 try { 889 const _ret = WEBEXT.bluetoothPrivate.recordDeviceSelection( 890 selectionDurationMs, 891 wasPaired === A.H.TRUE, 892 transport > 0 && transport <= 4 ? ["invalid", "classic", "le", "dual"][transport - 1] : undefined 893 ); 894 return A.H.TRUE; 895 } catch (err: any) { 896 A.store.Ref(errPtr, err); 897 return A.H.FALSE; 898 } 899 }, 900 "has_RecordPairing": (): heap.Ref<boolean> => { 901 if (WEBEXT?.bluetoothPrivate && "recordPairing" in WEBEXT?.bluetoothPrivate) { 902 return A.H.TRUE; 903 } 904 return A.H.FALSE; 905 }, 906 "func_RecordPairing": (fn: Pointer): void => { 907 A.store.Ref(fn, WEBEXT.bluetoothPrivate.recordPairing); 908 }, 909 "call_RecordPairing": (retPtr: Pointer, transport: number, pairingDurationMs: number, result: number): void => { 910 const _ret = WEBEXT.bluetoothPrivate.recordPairing( 911 transport > 0 && transport <= 4 ? ["invalid", "classic", "le", "dual"][transport - 1] : undefined, 912 pairingDurationMs, 913 result > 0 && result <= 15 914 ? [ 915 "alreadyConnected", 916 "authCanceled", 917 "authFailed", 918 "authRejected", 919 "authTimeout", 920 "failed", 921 "inProgress", 922 "success", 923 "unknownError", 924 "unsupportedDevice", 925 "notReady", 926 "alreadyExists", 927 "notConnected", 928 "doesNotExist", 929 "invalidArgs", 930 ][result - 1] 931 : undefined 932 ); 933 }, 934 "try_RecordPairing": ( 935 retPtr: Pointer, 936 errPtr: Pointer, 937 transport: number, 938 pairingDurationMs: number, 939 result: number 940 ): heap.Ref<boolean> => { 941 try { 942 const _ret = WEBEXT.bluetoothPrivate.recordPairing( 943 transport > 0 && transport <= 4 ? ["invalid", "classic", "le", "dual"][transport - 1] : undefined, 944 pairingDurationMs, 945 result > 0 && result <= 15 946 ? [ 947 "alreadyConnected", 948 "authCanceled", 949 "authFailed", 950 "authRejected", 951 "authTimeout", 952 "failed", 953 "inProgress", 954 "success", 955 "unknownError", 956 "unsupportedDevice", 957 "notReady", 958 "alreadyExists", 959 "notConnected", 960 "doesNotExist", 961 "invalidArgs", 962 ][result - 1] 963 : undefined 964 ); 965 return A.H.TRUE; 966 } catch (err: any) { 967 A.store.Ref(errPtr, err); 968 return A.H.FALSE; 969 } 970 }, 971 "has_RecordReconnection": (): heap.Ref<boolean> => { 972 if (WEBEXT?.bluetoothPrivate && "recordReconnection" in WEBEXT?.bluetoothPrivate) { 973 return A.H.TRUE; 974 } 975 return A.H.FALSE; 976 }, 977 "func_RecordReconnection": (fn: Pointer): void => { 978 A.store.Ref(fn, WEBEXT.bluetoothPrivate.recordReconnection); 979 }, 980 "call_RecordReconnection": (retPtr: Pointer, result: number): void => { 981 const _ret = WEBEXT.bluetoothPrivate.recordReconnection( 982 result > 0 && result <= 15 983 ? [ 984 "alreadyConnected", 985 "authCanceled", 986 "authFailed", 987 "authRejected", 988 "authTimeout", 989 "failed", 990 "inProgress", 991 "success", 992 "unknownError", 993 "unsupportedDevice", 994 "notReady", 995 "alreadyExists", 996 "notConnected", 997 "doesNotExist", 998 "invalidArgs", 999 ][result - 1] 1000 : undefined 1001 ); 1002 }, 1003 "try_RecordReconnection": (retPtr: Pointer, errPtr: Pointer, result: number): heap.Ref<boolean> => { 1004 try { 1005 const _ret = WEBEXT.bluetoothPrivate.recordReconnection( 1006 result > 0 && result <= 15 1007 ? [ 1008 "alreadyConnected", 1009 "authCanceled", 1010 "authFailed", 1011 "authRejected", 1012 "authTimeout", 1013 "failed", 1014 "inProgress", 1015 "success", 1016 "unknownError", 1017 "unsupportedDevice", 1018 "notReady", 1019 "alreadyExists", 1020 "notConnected", 1021 "doesNotExist", 1022 "invalidArgs", 1023 ][result - 1] 1024 : undefined 1025 ); 1026 return A.H.TRUE; 1027 } catch (err: any) { 1028 A.store.Ref(errPtr, err); 1029 return A.H.FALSE; 1030 } 1031 }, 1032 "has_SetAdapterState": (): heap.Ref<boolean> => { 1033 if (WEBEXT?.bluetoothPrivate && "setAdapterState" in WEBEXT?.bluetoothPrivate) { 1034 return A.H.TRUE; 1035 } 1036 return A.H.FALSE; 1037 }, 1038 "func_SetAdapterState": (fn: Pointer): void => { 1039 A.store.Ref(fn, WEBEXT.bluetoothPrivate.setAdapterState); 1040 }, 1041 "call_SetAdapterState": (retPtr: Pointer, adapterState: Pointer): void => { 1042 const adapterState_ffi = {}; 1043 1044 adapterState_ffi["name"] = A.load.Ref(adapterState + 0, undefined); 1045 if (A.load.Bool(adapterState + 6)) { 1046 adapterState_ffi["powered"] = A.load.Bool(adapterState + 4); 1047 } 1048 if (A.load.Bool(adapterState + 7)) { 1049 adapterState_ffi["discoverable"] = A.load.Bool(adapterState + 5); 1050 } 1051 1052 const _ret = WEBEXT.bluetoothPrivate.setAdapterState(adapterState_ffi); 1053 A.store.Ref(retPtr, _ret); 1054 }, 1055 "try_SetAdapterState": (retPtr: Pointer, errPtr: Pointer, adapterState: Pointer): heap.Ref<boolean> => { 1056 try { 1057 const adapterState_ffi = {}; 1058 1059 adapterState_ffi["name"] = A.load.Ref(adapterState + 0, undefined); 1060 if (A.load.Bool(adapterState + 6)) { 1061 adapterState_ffi["powered"] = A.load.Bool(adapterState + 4); 1062 } 1063 if (A.load.Bool(adapterState + 7)) { 1064 adapterState_ffi["discoverable"] = A.load.Bool(adapterState + 5); 1065 } 1066 1067 const _ret = WEBEXT.bluetoothPrivate.setAdapterState(adapterState_ffi); 1068 A.store.Ref(retPtr, _ret); 1069 return A.H.TRUE; 1070 } catch (err: any) { 1071 A.store.Ref(errPtr, err); 1072 return A.H.FALSE; 1073 } 1074 }, 1075 "has_SetDiscoveryFilter": (): heap.Ref<boolean> => { 1076 if (WEBEXT?.bluetoothPrivate && "setDiscoveryFilter" in WEBEXT?.bluetoothPrivate) { 1077 return A.H.TRUE; 1078 } 1079 return A.H.FALSE; 1080 }, 1081 "func_SetDiscoveryFilter": (fn: Pointer): void => { 1082 A.store.Ref(fn, WEBEXT.bluetoothPrivate.setDiscoveryFilter); 1083 }, 1084 "call_SetDiscoveryFilter": (retPtr: Pointer, discoveryFilter: Pointer): void => { 1085 const discoveryFilter_ffi = {}; 1086 1087 discoveryFilter_ffi["transport"] = A.load.Enum(discoveryFilter + 0, ["le", "bredr", "dual"]); 1088 discoveryFilter_ffi["uuids"] = A.load.Ref(discoveryFilter + 4, undefined); 1089 if (A.load.Bool(discoveryFilter + 16)) { 1090 discoveryFilter_ffi["rssi"] = A.load.Int32(discoveryFilter + 8); 1091 } 1092 if (A.load.Bool(discoveryFilter + 17)) { 1093 discoveryFilter_ffi["pathloss"] = A.load.Int32(discoveryFilter + 12); 1094 } 1095 1096 const _ret = WEBEXT.bluetoothPrivate.setDiscoveryFilter(discoveryFilter_ffi); 1097 A.store.Ref(retPtr, _ret); 1098 }, 1099 "try_SetDiscoveryFilter": (retPtr: Pointer, errPtr: Pointer, discoveryFilter: Pointer): heap.Ref<boolean> => { 1100 try { 1101 const discoveryFilter_ffi = {}; 1102 1103 discoveryFilter_ffi["transport"] = A.load.Enum(discoveryFilter + 0, ["le", "bredr", "dual"]); 1104 discoveryFilter_ffi["uuids"] = A.load.Ref(discoveryFilter + 4, undefined); 1105 if (A.load.Bool(discoveryFilter + 16)) { 1106 discoveryFilter_ffi["rssi"] = A.load.Int32(discoveryFilter + 8); 1107 } 1108 if (A.load.Bool(discoveryFilter + 17)) { 1109 discoveryFilter_ffi["pathloss"] = A.load.Int32(discoveryFilter + 12); 1110 } 1111 1112 const _ret = WEBEXT.bluetoothPrivate.setDiscoveryFilter(discoveryFilter_ffi); 1113 A.store.Ref(retPtr, _ret); 1114 return A.H.TRUE; 1115 } catch (err: any) { 1116 A.store.Ref(errPtr, err); 1117 return A.H.FALSE; 1118 } 1119 }, 1120 "has_SetPairingResponse": (): heap.Ref<boolean> => { 1121 if (WEBEXT?.bluetoothPrivate && "setPairingResponse" in WEBEXT?.bluetoothPrivate) { 1122 return A.H.TRUE; 1123 } 1124 return A.H.FALSE; 1125 }, 1126 "func_SetPairingResponse": (fn: Pointer): void => { 1127 A.store.Ref(fn, WEBEXT.bluetoothPrivate.setPairingResponse); 1128 }, 1129 "call_SetPairingResponse": (retPtr: Pointer, options: Pointer): void => { 1130 const options_ffi = {}; 1131 1132 if (A.load.Bool(options + 0 + 67)) { 1133 options_ffi["device"] = {}; 1134 options_ffi["device"]["address"] = A.load.Ref(options + 0 + 0, undefined); 1135 options_ffi["device"]["name"] = A.load.Ref(options + 0 + 4, undefined); 1136 if (A.load.Bool(options + 0 + 56)) { 1137 options_ffi["device"]["deviceClass"] = A.load.Int32(options + 0 + 8); 1138 } 1139 options_ffi["device"]["vendorIdSource"] = A.load.Enum(options + 0 + 12, ["bluetooth", "usb"]); 1140 if (A.load.Bool(options + 0 + 57)) { 1141 options_ffi["device"]["vendorId"] = A.load.Int32(options + 0 + 16); 1142 } 1143 if (A.load.Bool(options + 0 + 58)) { 1144 options_ffi["device"]["productId"] = A.load.Int32(options + 0 + 20); 1145 } 1146 if (A.load.Bool(options + 0 + 59)) { 1147 options_ffi["device"]["deviceId"] = A.load.Int32(options + 0 + 24); 1148 } 1149 options_ffi["device"]["type"] = A.load.Enum(options + 0 + 28, [ 1150 "computer", 1151 "phone", 1152 "modem", 1153 "audio", 1154 "carAudio", 1155 "video", 1156 "peripheral", 1157 "joystick", 1158 "gamepad", 1159 "keyboard", 1160 "mouse", 1161 "tablet", 1162 "keyboardMouseCombo", 1163 ]); 1164 if (A.load.Bool(options + 0 + 60)) { 1165 options_ffi["device"]["paired"] = A.load.Bool(options + 0 + 32); 1166 } 1167 if (A.load.Bool(options + 0 + 61)) { 1168 options_ffi["device"]["connected"] = A.load.Bool(options + 0 + 33); 1169 } 1170 if (A.load.Bool(options + 0 + 62)) { 1171 options_ffi["device"]["connecting"] = A.load.Bool(options + 0 + 34); 1172 } 1173 if (A.load.Bool(options + 0 + 63)) { 1174 options_ffi["device"]["connectable"] = A.load.Bool(options + 0 + 35); 1175 } 1176 options_ffi["device"]["uuids"] = A.load.Ref(options + 0 + 36, undefined); 1177 if (A.load.Bool(options + 0 + 64)) { 1178 options_ffi["device"]["inquiryRssi"] = A.load.Int32(options + 0 + 40); 1179 } 1180 if (A.load.Bool(options + 0 + 65)) { 1181 options_ffi["device"]["inquiryTxPower"] = A.load.Int32(options + 0 + 44); 1182 } 1183 options_ffi["device"]["transport"] = A.load.Enum(options + 0 + 48, ["invalid", "classic", "le", "dual"]); 1184 if (A.load.Bool(options + 0 + 66)) { 1185 options_ffi["device"]["batteryPercentage"] = A.load.Int32(options + 0 + 52); 1186 } 1187 } 1188 options_ffi["response"] = A.load.Enum(options + 68, ["confirm", "reject", "cancel"]); 1189 options_ffi["pincode"] = A.load.Ref(options + 72, undefined); 1190 if (A.load.Bool(options + 80)) { 1191 options_ffi["passkey"] = A.load.Int32(options + 76); 1192 } 1193 1194 const _ret = WEBEXT.bluetoothPrivate.setPairingResponse(options_ffi); 1195 A.store.Ref(retPtr, _ret); 1196 }, 1197 "try_SetPairingResponse": (retPtr: Pointer, errPtr: Pointer, options: Pointer): heap.Ref<boolean> => { 1198 try { 1199 const options_ffi = {}; 1200 1201 if (A.load.Bool(options + 0 + 67)) { 1202 options_ffi["device"] = {}; 1203 options_ffi["device"]["address"] = A.load.Ref(options + 0 + 0, undefined); 1204 options_ffi["device"]["name"] = A.load.Ref(options + 0 + 4, undefined); 1205 if (A.load.Bool(options + 0 + 56)) { 1206 options_ffi["device"]["deviceClass"] = A.load.Int32(options + 0 + 8); 1207 } 1208 options_ffi["device"]["vendorIdSource"] = A.load.Enum(options + 0 + 12, ["bluetooth", "usb"]); 1209 if (A.load.Bool(options + 0 + 57)) { 1210 options_ffi["device"]["vendorId"] = A.load.Int32(options + 0 + 16); 1211 } 1212 if (A.load.Bool(options + 0 + 58)) { 1213 options_ffi["device"]["productId"] = A.load.Int32(options + 0 + 20); 1214 } 1215 if (A.load.Bool(options + 0 + 59)) { 1216 options_ffi["device"]["deviceId"] = A.load.Int32(options + 0 + 24); 1217 } 1218 options_ffi["device"]["type"] = A.load.Enum(options + 0 + 28, [ 1219 "computer", 1220 "phone", 1221 "modem", 1222 "audio", 1223 "carAudio", 1224 "video", 1225 "peripheral", 1226 "joystick", 1227 "gamepad", 1228 "keyboard", 1229 "mouse", 1230 "tablet", 1231 "keyboardMouseCombo", 1232 ]); 1233 if (A.load.Bool(options + 0 + 60)) { 1234 options_ffi["device"]["paired"] = A.load.Bool(options + 0 + 32); 1235 } 1236 if (A.load.Bool(options + 0 + 61)) { 1237 options_ffi["device"]["connected"] = A.load.Bool(options + 0 + 33); 1238 } 1239 if (A.load.Bool(options + 0 + 62)) { 1240 options_ffi["device"]["connecting"] = A.load.Bool(options + 0 + 34); 1241 } 1242 if (A.load.Bool(options + 0 + 63)) { 1243 options_ffi["device"]["connectable"] = A.load.Bool(options + 0 + 35); 1244 } 1245 options_ffi["device"]["uuids"] = A.load.Ref(options + 0 + 36, undefined); 1246 if (A.load.Bool(options + 0 + 64)) { 1247 options_ffi["device"]["inquiryRssi"] = A.load.Int32(options + 0 + 40); 1248 } 1249 if (A.load.Bool(options + 0 + 65)) { 1250 options_ffi["device"]["inquiryTxPower"] = A.load.Int32(options + 0 + 44); 1251 } 1252 options_ffi["device"]["transport"] = A.load.Enum(options + 0 + 48, ["invalid", "classic", "le", "dual"]); 1253 if (A.load.Bool(options + 0 + 66)) { 1254 options_ffi["device"]["batteryPercentage"] = A.load.Int32(options + 0 + 52); 1255 } 1256 } 1257 options_ffi["response"] = A.load.Enum(options + 68, ["confirm", "reject", "cancel"]); 1258 options_ffi["pincode"] = A.load.Ref(options + 72, undefined); 1259 if (A.load.Bool(options + 80)) { 1260 options_ffi["passkey"] = A.load.Int32(options + 76); 1261 } 1262 1263 const _ret = WEBEXT.bluetoothPrivate.setPairingResponse(options_ffi); 1264 A.store.Ref(retPtr, _ret); 1265 return A.H.TRUE; 1266 } catch (err: any) { 1267 A.store.Ref(errPtr, err); 1268 return A.H.FALSE; 1269 } 1270 }, 1271 }; 1272 });