InputSource.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Copyright 2023 Google LLC.
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { Input } from '../../../protocol/protocol.js';
  18. export import SourceType = Input.SourceActionsType;
  19. export declare class NoneSource {
  20. type: Input.SourceActionsType.None;
  21. }
  22. export declare class KeySource {
  23. #private;
  24. type: Input.SourceActionsType.Key;
  25. pressed: Set<string>;
  26. get modifiers(): number;
  27. get alt(): boolean;
  28. set alt(value: boolean);
  29. get ctrl(): boolean;
  30. set ctrl(value: boolean);
  31. get meta(): boolean;
  32. set meta(value: boolean);
  33. get shift(): boolean;
  34. set shift(value: boolean);
  35. }
  36. interface ClickContext {
  37. x: number;
  38. y: number;
  39. timeStamp: number;
  40. }
  41. export declare class PointerSource {
  42. #private;
  43. type: Input.SourceActionsType.Pointer;
  44. subtype: Input.PointerType;
  45. pointerId: number;
  46. pressed: Set<number>;
  47. x: number;
  48. y: number;
  49. constructor(id: number, subtype: Input.PointerType);
  50. get buttons(): number;
  51. setClickCount(context: ClickContext): void;
  52. get clickCount(): number;
  53. }
  54. export declare class WheelSource {
  55. type: Input.SourceActionsType.Wheel;
  56. }
  57. export type InputSource = NoneSource | KeySource | PointerSource | WheelSource;
  58. export type InputSourceFor<Type extends SourceType> = Type extends SourceType.Key ? KeySource : Type extends SourceType.Pointer ? PointerSource : Type extends SourceType.Wheel ? WheelSource : NoneSource;
  59. export {};