/src/captureif.h

http://bdremote-ng.googlecode.com/ · C Header · 125 lines · 27 code · 23 blank · 75 comment · 0 complexity · 666c22a039936952ce77a4fea74ba13d MD5 · raw file

  1. /*
  2. * bdremoteng - helper daemon for Sony(R) BD Remote Control
  3. * Based on bdremoted, written by Anton Starikov <antst@mail.ru>.
  4. *
  5. * Copyright (C) 2009 Michael Wojciechowski <wojci@wojci.dk>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. /** @defgroup captureinterface Capture Interface
  24. * This group contains the capture interface used by this
  25. * application. It needs to be implemented in order to capture
  26. * bluetooth data from the PS3 remote.
  27. * @{
  28. */
  29. /*! \file captureif.h
  30. \brief Bluetooth capture interface.
  31. */
  32. #ifndef BD_CAPTUREIF_H
  33. #define BD_CAPTUREIF_H
  34. #include <globaldefs.h>
  35. #include <bdrcfg.h>
  36. /** Struct given to the function which is supposed to capture data from
  37. * a BT interface.
  38. */
  39. typedef struct
  40. {
  41. #if BDREMOTE_DEBUG
  42. /** Magic value used to assert on. */
  43. int magic0;
  44. #endif /* BDREMOTE_DEBUG */
  45. /** Pointer to configuration. */
  46. const configuration* config;
  47. /** Context pointer - pointer to LIRC data, which is used when
  48. calling the callback functions defined in this file. */
  49. void* p;
  50. /** BT Address of the device to open. */
  51. char* bt_dev_address;
  52. /** BT Address of the remote, which is sending keypresses to this
  53. daemon. */
  54. char* dest_address;
  55. /** Timeout in seconds. */
  56. int timeout;
  57. /** Sockets in use. */
  58. int sockets[3];
  59. } captureData;
  60. /** Function used to init the data used by this interface.
  61. * @param _cd Data used for capturing.
  62. * @param _config Configuration to use.
  63. * @param _p Pointer to LIRC data.
  64. */
  65. void InitCaptureData(captureData* _cd,
  66. const configuration* _config,
  67. void* _p);
  68. /** Release any data used by this interface. */
  69. void DestroyCaptureData(captureData* _cd);
  70. /*
  71. * Callbacks.
  72. */
  73. /** A remote was connected. */
  74. void RemoteConnected(void* _p);
  75. /** Remote sent some data.
  76. * p - context pointer.
  77. */
  78. void DataInd(void* p, const char* _data, const int _size);
  79. /** Battery charge change detected.
  80. * p - context pointer.
  81. * _val - charge in percent.
  82. */
  83. void RemoteBatteryCharge(void* _p, int _val);
  84. /** Remote disconnected. */
  85. void RemoteDisconnected(void* _p);
  86. /** Setup the data needed to start capturing.
  87. * Called before captureLoop(..), after which the daemon
  88. * will change UID:GID.
  89. */
  90. int InitcaptureLoop(captureData* _capturedata);
  91. /** Main capture loop.
  92. *
  93. * The idea is to run this as a thread and call the above callback
  94. * functions when a change is detected.
  95. *
  96. * returns: -1 on error.
  97. */
  98. int captureLoop(captureData* _capturedata);
  99. #endif /* BD_CAPTUREIF_H */
  100. /*@}*/