/src/captureif.h
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 24/** @defgroup captureinterface Capture Interface 25 26 * This group contains the capture interface used by this 27 * application. It needs to be implemented in order to capture 28 * bluetooth data from the PS3 remote. 29 30 * @{ 31 */ 32 33/*! \file captureif.h 34 \brief Bluetooth capture interface. 35*/ 36 37#ifndef BD_CAPTUREIF_H 38#define BD_CAPTUREIF_H 39 40#include <globaldefs.h> 41#include <bdrcfg.h> 42 43/** Struct given to the function which is supposed to capture data from 44 * a BT interface. 45 */ 46typedef struct 47{ 48#if BDREMOTE_DEBUG 49 /** Magic value used to assert on. */ 50 int magic0; 51#endif /* BDREMOTE_DEBUG */ 52 53 /** Pointer to configuration. */ 54 const configuration* config; 55 56 /** Context pointer - pointer to LIRC data, which is used when 57 calling the callback functions defined in this file. */ 58 void* p; 59 60 /** BT Address of the device to open. */ 61 char* bt_dev_address; 62 63 /** BT Address of the remote, which is sending keypresses to this 64 daemon. */ 65 char* dest_address; 66 67 /** Timeout in seconds. */ 68 int timeout; 69 70 /** Sockets in use. */ 71 int sockets[3]; 72} captureData; 73 74/** Function used to init the data used by this interface. 75 * @param _cd Data used for capturing. 76 * @param _config Configuration to use. 77 * @param _p Pointer to LIRC data. 78 */ 79void InitCaptureData(captureData* _cd, 80 const configuration* _config, 81 void* _p); 82 83/** Release any data used by this interface. */ 84void DestroyCaptureData(captureData* _cd); 85 86/* 87 * Callbacks. 88 */ 89 90/** A remote was connected. */ 91void RemoteConnected(void* _p); 92 93/** Remote sent some data. 94 * p - context pointer. 95 */ 96void DataInd(void* p, const char* _data, const int _size); 97 98/** Battery charge change detected. 99 * p - context pointer. 100 * _val - charge in percent. 101 */ 102void RemoteBatteryCharge(void* _p, int _val); 103 104/** Remote disconnected. */ 105void RemoteDisconnected(void* _p); 106 107/** Setup the data needed to start capturing. 108 * Called before captureLoop(..), after which the daemon 109 * will change UID:GID. 110 */ 111int InitcaptureLoop(captureData* _capturedata); 112 113/** Main capture loop. 114 * 115 * The idea is to run this as a thread and call the above callback 116 * functions when a change is detected. 117 * 118 * returns: -1 on error. 119 */ 120int captureLoop(captureData* _capturedata); 121 122#endif /* BD_CAPTUREIF_H */ 123 124/*@}*/ 125