AppEvent.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. *
  3. * Copyright (c) 2020 Project CHIP Authors
  4. * Copyright (c) 2018 Nest Labs, Inc.
  5. * All rights reserved.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. #pragma once
  20. struct AppEvent;
  21. typedef void (*EventHandler)(AppEvent *);
  22. struct AppEvent
  23. {
  24. enum AppEventTypes
  25. {
  26. kEventType_Button = 0,
  27. kEventType_Timer,
  28. kEventType_PumpTimer,
  29. kEventType_Install,
  30. kEventType_None,
  31. };
  32. uint16_t Type;
  33. union
  34. {
  35. struct
  36. {
  37. uint8_t Action;
  38. } ButtonEvent;
  39. struct
  40. {
  41. void * Context;
  42. } TimerEvent;
  43. struct
  44. {
  45. uint8_t Action;
  46. int32_t Actor;
  47. void * Context;
  48. } PumpEvent;
  49. };
  50. EventHandler Handler;
  51. };