aboutsummaryrefslogtreecommitdiff
path: root/lib/addons/library.kodi.peripheral/libKODI_peripheral.cpp
blob: 7c6b0c5e922ab63b93c8bdc54ae9ebe9cd53b5eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 *      Copyright (C) 2014-2016 Team Kodi
 *      http://kodi.tv
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this Program; see the file COPYING.  If not, see
 *  <http://www.gnu.org/licenses/>.
 *
 */

//#include "addons/AddonCallbacks.h"
//#include "addons/include/kodi_peripheral_types.h"
#include "addons/binary/interfaces/AddonInterfaces.h"
#include "addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_callbacks.h"

#include <stdio.h>

#ifdef _WIN32
  #include <windows.h>
  #define DLLEXPORT __declspec(dllexport)
#else
  #define DLLEXPORT
#endif

#ifdef __cplusplus
extern "C" {
#endif

DLLEXPORT CB_PeripheralLib* PERIPHERAL_register_me(AddonCB* frontend)
{
  CB_PeripheralLib* cb = NULL;
  if (!frontend)
    fprintf(stderr, "ERROR: PERIPHERAL_register_frontend is called with NULL handle!!!\n");
  else
  {
    cb = frontend->PeripheralLib_RegisterMe(frontend->addonData);
    if (!cb)
      fprintf(stderr, "ERROR: PERIPHERAL_register_frontend can't get callback table from frontend!!!\n");
  }
  return cb;
}

DLLEXPORT void PERIPHERAL_unregister_me(AddonCB* frontend, CB_PeripheralLib* cb)
{
  if (frontend == NULL || cb == NULL)
    return;
  return frontend->PeripheralLib_UnRegisterMe(frontend->addonData, cb);
}

DLLEXPORT void PERIPHERAL_trigger_scan(AddonCB* frontend, CB_PeripheralLib* cb)
{
  if (frontend == NULL || cb == NULL)
    return;
  return cb->TriggerScan(frontend->addonData);
}

DLLEXPORT void PERIPHERAL_refresh_button_maps(AddonCB* frontend, CB_PeripheralLib* cb, const char* deviceName, const char* controllerId)
{
  if (frontend == NULL || cb == NULL)
    return;
  return cb->RefreshButtonMaps(frontend->addonData, deviceName ? deviceName : "", controllerId ? controllerId : "");
}

#ifdef __cplusplus
}
#endif