AppEvent.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_Light,
  29. kEventType_Install,
  30. };
  31. uint16_t Type;
  32. union
  33. {
  34. struct
  35. {
  36. uint8_t Action;
  37. } ButtonEvent;
  38. struct
  39. {
  40. void * Context;
  41. } TimerEvent;
  42. struct
  43. {
  44. uint8_t Action;
  45. int32_t Actor;
  46. } LightEvent;
  47. };
  48. EventHandler Handler;
  49. };