summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h709
1 files changed, 709 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h
new file mode 100644
index 0000000..393f34a
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h
@@ -0,0 +1,709 @@
1/*
2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PERIPHERAL_H
12#define C_API_ADDONINSTANCE_PERIPHERAL_H
13
14#include "../addon_base.h"
15
16/* indicates a joystick has no preference for port number */
17#define NO_PORT_REQUESTED (-1)
18
19/* joystick's driver button/hat/axis index is unknown */
20#define DRIVER_INDEX_UNKNOWN (-1)
21
22#ifdef __cplusplus
23extern "C"
24{
25#endif /* __cplusplus */
26
27 //============================================================================
28 /// @defgroup cpp_kodi_addon_peripheral_Defs_General_PERIPHERAL_ERROR enum PERIPHERAL_ERROR
29 /// @ingroup cpp_kodi_addon_peripheral_Defs_General
30 /// @brief **Peripheral add-on error codes**\n
31 /// Used as return values on most peripheral related functions.
32 ///
33 /// In this way, a peripheral instance signals errors in its processing and,
34 /// under certain conditions, allows Kodi to make corrections.
35 ///
36 ///@{
37 typedef enum PERIPHERAL_ERROR
38 {
39 /// @brief __0__ : No error occurred
40 PERIPHERAL_NO_ERROR = 0,
41
42 /// @brief __-1__ : An unknown error occurred
43 PERIPHERAL_ERROR_UNKNOWN = -1,
44
45 /// @brief __-2__ : The command failed
46 PERIPHERAL_ERROR_FAILED = -2,
47
48 /// @brief __-3__ : The parameters of the method are invalid for this operation
49 PERIPHERAL_ERROR_INVALID_PARAMETERS = -3,
50
51 /// @brief __-4__ : The method that the frontend called is not implemented
52 PERIPHERAL_ERROR_NOT_IMPLEMENTED = -4,
53
54 /// @brief __-5__ : No peripherals are connected
55 PERIPHERAL_ERROR_NOT_CONNECTED = -5,
56
57 /// @brief __-6__ : Peripherals are connected, but command was interrupted
58 PERIPHERAL_ERROR_CONNECTION_FAILED = -6,
59 } PERIPHERAL_ERROR;
60 ///@}
61 //----------------------------------------------------------------------------
62
63 // @name Peripheral types
64 //{
65
66 //============================================================================
67 /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PERIPHERAL_TYPE enum PERIPHERAL_TYPE
68 /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral
69 /// @brief **Peripheral types**\n
70 /// Types used to identify wanted peripheral.
71 ///@{
72 typedef enum PERIPHERAL_TYPE
73 {
74 /// @brief Type declared as unknown.
75 PERIPHERAL_TYPE_UNKNOWN,
76
77 /// @brief Type declared as joystick.
78 PERIPHERAL_TYPE_JOYSTICK,
79
80 /// @brief Type declared as keyboard.
81 PERIPHERAL_TYPE_KEYBOARD,
82 } PERIPHERAL_TYPE;
83 ///@}
84 //----------------------------------------------------------------------------
85
86 /*!
87 * @brief Information shared between peripherals
88 */
89 typedef struct PERIPHERAL_INFO
90 {
91 PERIPHERAL_TYPE type; /*!< type of peripheral */
92 char* name; /*!< name of peripheral */
93 uint16_t vendor_id; /*!< vendor ID of peripheral, 0x0000 if unknown */
94 uint16_t product_id; /*!< product ID of peripheral, 0x0000 if unknown */
95 unsigned int index; /*!< the order in which the add-on identified this peripheral */
96 } ATTRIBUTE_PACKED PERIPHERAL_INFO;
97
98 /*!
99 * @brief Peripheral add-on capabilities.
100 */
101 typedef struct PERIPHERAL_CAPABILITIES
102 {
103 bool provides_joysticks; /*!< true if the add-on provides joysticks */
104 bool provides_joystick_rumble;
105 bool provides_joystick_power_off;
106 bool provides_buttonmaps; /*!< true if the add-on provides button maps */
107 } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES;
108
109 //}
110
111 // @name Event types
112 //{
113
114 //============================================================================
115 /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_PERIPHERAL_EVENT_TYPE enum PERIPHERAL_EVENT_TYPE
116 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
117 /// @brief **Event types**\n
118 /// Types of events that can be sent and received.
119 ///@{
120 typedef enum PERIPHERAL_EVENT_TYPE
121 {
122 /// @brief unknown event
123 PERIPHERAL_EVENT_TYPE_NONE,
124
125 /// @brief state changed for joystick driver button
126 PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON,
127
128 /// @brief state changed for joystick driver hat
129 PERIPHERAL_EVENT_TYPE_DRIVER_HAT,
130
131 /// @brief state changed for joystick driver axis
132 PERIPHERAL_EVENT_TYPE_DRIVER_AXIS,
133
134 /// @brief set the state for joystick rumble motor
135 PERIPHERAL_EVENT_TYPE_SET_MOTOR,
136 } PERIPHERAL_EVENT_TYPE;
137 ///@}
138 //----------------------------------------------------------------------------
139
140 //============================================================================
141 /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_JOYSTICK_STATE_BUTTON enum JOYSTICK_STATE_BUTTON
142 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
143 /// @brief **State button**\n
144 /// States a button can have
145 ///@{
146 typedef enum JOYSTICK_STATE_BUTTON
147 {
148 /// @brief button is released
149 JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0,
150
151 /// @brief button is pressed
152 JOYSTICK_STATE_BUTTON_PRESSED = 0x1,
153 } JOYSTICK_STATE_BUTTON;
154 ///@}
155 //----------------------------------------------------------------------------
156
157 //============================================================================
158 /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_JOYSTICK_STATE_HAT enum JOYSTICK_STATE_HAT
159 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
160 /// @brief **State hat**\n
161 /// States a D-pad (also called a hat) can have
162 ///@{
163 typedef enum JOYSTICK_STATE_HAT
164 {
165 /// @brief no directions are pressed
166 JOYSTICK_STATE_HAT_UNPRESSED = 0x0,
167
168 /// @brief only left is pressed
169 JOYSTICK_STATE_HAT_LEFT = 0x1,
170
171 /// @brief only right is pressed
172 JOYSTICK_STATE_HAT_RIGHT = 0x2,
173
174 /// @brief only up is pressed
175 JOYSTICK_STATE_HAT_UP = 0x4,
176
177 /// @brief only down is pressed
178 JOYSTICK_STATE_HAT_DOWN = 0x8,
179
180 /// @brief left and up is pressed
181 JOYSTICK_STATE_HAT_LEFT_UP = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_UP,
182
183 /// @brief left and down is pressed
184 JOYSTICK_STATE_HAT_LEFT_DOWN = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_DOWN,
185
186 /// @brief right and up is pressed
187 JOYSTICK_STATE_HAT_RIGHT_UP = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_UP,
188
189 /// @brief right and down is pressed
190 JOYSTICK_STATE_HAT_RIGHT_DOWN = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_DOWN,
191 } JOYSTICK_STATE_HAT;
192 ///@}
193 //----------------------------------------------------------------------------
194
195 //============================================================================
196 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
197 /// @brief Axis value in the closed interval [-1.0, 1.0]
198 ///
199 /// The axis state uses the XInput coordinate system:
200 /// - Negative values signify down or to the left
201 /// - Positive values signify up or to the right
202 ///
203 typedef float JOYSTICK_STATE_AXIS;
204 //----------------------------------------------------------------------------
205
206 //============================================================================
207 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
208 /// @brief Motor value in the closed interval [0.0, 1.0]
209 typedef float JOYSTICK_STATE_MOTOR;
210 //----------------------------------------------------------------------------
211
212 /*!
213 * @brief Event information
214 */
215 typedef struct PERIPHERAL_EVENT
216 {
217 /*! @brief Index of the peripheral handling/receiving the event */
218 unsigned int peripheral_index;
219
220 /*! @brief Type of the event used to determine which enum field to access below */
221 PERIPHERAL_EVENT_TYPE type;
222
223 /*! @brief The index of the event source */
224 unsigned int driver_index;
225
226 JOYSTICK_STATE_BUTTON driver_button_state;
227 JOYSTICK_STATE_HAT driver_hat_state;
228 JOYSTICK_STATE_AXIS driver_axis_state;
229 JOYSTICK_STATE_MOTOR motor_state;
230 } ATTRIBUTE_PACKED PERIPHERAL_EVENT;
231
232 //}
233
234 // @name Joystick types
235 //{
236
237 /*!
238 * @brief Info specific to joystick peripherals
239 */
240 typedef struct JOYSTICK_INFO
241 {
242 PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */
243 char* provider; /*!< @brief name of the driver or interface providing the joystick */
244 int requested_port; /*!< @brief requested port number (such as for 360 controllers), or NO_PORT_REQUESTED */
245 unsigned int button_count; /*!< @brief number of buttons reported by the driver */
246 unsigned int hat_count; /*!< @brief number of hats reported by the driver */
247 unsigned int axis_count; /*!< @brief number of axes reported by the driver */
248 unsigned int motor_count; /*!< @brief number of motors reported by the driver */
249 bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */
250 } ATTRIBUTE_PACKED JOYSTICK_INFO;
251
252 //============================================================================
253 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_PRIMITIVE_TYPE enum JOYSTICK_DRIVER_PRIMITIVE_TYPE
254 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
255 /// @brief **Driver primitive type**\n
256 /// Driver input primitives
257 ///
258 /// Mapping lower-level driver values to higher-level controller features is
259 /// non-injective; two triggers can share a single axis.
260 ///
261 /// To handle this, driver values are subdivided into "primitives" that map
262 /// injectively to higher-level features.
263 ///
264 ///@{
265 typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE
266 {
267 /// @brief Driver input primitive type unknown
268 JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN,
269
270 /// @brief Driver input primitive type button
271 JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON,
272
273 /// @brief Driver input primitive type hat direction
274 JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION,
275
276 /// @brief Driver input primitive type semiaxis
277 JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS,
278
279 /// @brief Driver input primitive type motor
280 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR,
281
282 /// @brief Driver input primitive type key
283 JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY,
284
285 /// @brief Driver input primitive type mouse button
286 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON,
287
288 /// @brief Driver input primitive type relative pointer direction
289 JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION,
290 } JOYSTICK_DRIVER_PRIMITIVE_TYPE;
291 ///@}
292 //----------------------------------------------------------------------------
293
294 /*!
295 * @brief Button primitive
296 */
297 typedef struct JOYSTICK_DRIVER_BUTTON
298 {
299 int index;
300 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON;
301
302 //============================================================================
303 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_HAT_DIRECTION enum JOYSTICK_DRIVER_HAT_DIRECTION
304 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
305 /// @brief **Driver direction**\n
306 /// Hat direction.
307 ///@{
308 typedef enum JOYSTICK_DRIVER_HAT_DIRECTION
309 {
310 /// @brief Driver hat unknown
311 JOYSTICK_DRIVER_HAT_UNKNOWN,
312
313 /// @brief Driver hat left
314 JOYSTICK_DRIVER_HAT_LEFT,
315
316 /// @brief Driver hat right
317 JOYSTICK_DRIVER_HAT_RIGHT,
318
319 /// @brief Driver hat up
320 JOYSTICK_DRIVER_HAT_UP,
321
322 /// @brief Driver hat down
323 JOYSTICK_DRIVER_HAT_DOWN,
324 } JOYSTICK_DRIVER_HAT_DIRECTION;
325 ///@}
326 //----------------------------------------------------------------------------
327
328 /*!
329 * @brief Hat direction primitive
330 */
331 typedef struct JOYSTICK_DRIVER_HAT
332 {
333 int index;
334 JOYSTICK_DRIVER_HAT_DIRECTION direction;
335 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT;
336
337 //============================================================================
338 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_SEMIAXIS_DIRECTION enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION
339 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
340 /// @brief **Driver direction**\n
341 /// Semiaxis direction.
342 ///@{
343 typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION
344 {
345 /// @brief negative half of the axis
346 JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1,
347
348 /// @brief unknown direction
349 JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN = 0,
350
351 /// @brief positive half of the axis
352 JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1,
353 } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION;
354 ///@}
355 //----------------------------------------------------------------------------
356
357 /*!
358 * @brief Semiaxis primitive
359 */
360 typedef struct JOYSTICK_DRIVER_SEMIAXIS
361 {
362 int index;
363 int center;
364 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction;
365 unsigned int range;
366 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS;
367
368 /*!
369 * @brief Motor primitive
370 */
371 typedef struct JOYSTICK_DRIVER_MOTOR
372 {
373 int index;
374 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR;
375
376 /*!
377 * @brief Keyboard key primitive
378 */
379 typedef struct JOYSTICK_DRIVER_KEY
380 {
381 char keycode[16];
382 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY;
383
384 //============================================================================
385 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_MOUSE_INDEX enum JOYSTICK_DRIVER_MOUSE_INDEX
386 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
387 /// @brief **Buttons**\n
388 /// Mouse buttons.
389 ///@{
390 typedef enum JOYSTICK_DRIVER_MOUSE_INDEX
391 {
392 /// @brief Mouse index unknown
393 JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN,
394
395 /// @brief Mouse index left
396 JOYSTICK_DRIVER_MOUSE_INDEX_LEFT,
397
398 /// @brief Mouse index right
399 JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT,
400
401 /// @brief Mouse index middle
402 JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE,
403
404 /// @brief Mouse index button 4
405 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4,
406
407 /// @brief Mouse index button 5
408 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5,
409
410 /// @brief Mouse index wheel up
411 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP,
412
413 /// @brief Mouse index wheel down
414 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN,
415
416 /// @brief Mouse index horizontal wheel left
417 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT,
418
419 /// @brief Mouse index horizontal wheel right
420 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT,
421 } JOYSTICK_DRIVER_MOUSE_INDEX;
422 ///@}
423 //----------------------------------------------------------------------------
424
425 /*!
426 * @brief Mouse button primitive
427 */
428 typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON
429 {
430 JOYSTICK_DRIVER_MOUSE_INDEX button;
431 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON;
432
433 //============================================================================
434 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_RELPOINTER_DIRECTION enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION
435 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
436 /// @brief **Pointer direction**\n
437 /// Relative pointer direction
438 ///@{
439 typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION
440 {
441 /// @brief Relative pointer direction unknown
442 JOYSTICK_DRIVER_RELPOINTER_UNKNOWN,
443
444 /// @brief Relative pointer direction left
445 JOYSTICK_DRIVER_RELPOINTER_LEFT,
446
447 /// @brief Relative pointer direction right
448 JOYSTICK_DRIVER_RELPOINTER_RIGHT,
449
450 /// @brief Relative pointer direction up
451 JOYSTICK_DRIVER_RELPOINTER_UP,
452
453 /// @brief Relative pointer direction down
454 JOYSTICK_DRIVER_RELPOINTER_DOWN,
455 } JOYSTICK_DRIVER_RELPOINTER_DIRECTION;
456 ///@}
457 //----------------------------------------------------------------------------
458
459 /*!
460 * @brief Relative pointer direction primitive
461 */
462 typedef struct JOYSTICK_DRIVER_RELPOINTER
463 {
464 JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction;
465 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER;
466
467 /*!
468 * @brief Driver primitive struct
469 */
470 typedef struct JOYSTICK_DRIVER_PRIMITIVE
471 {
472 JOYSTICK_DRIVER_PRIMITIVE_TYPE type;
473 union
474 {
475 struct JOYSTICK_DRIVER_BUTTON button;
476 struct JOYSTICK_DRIVER_HAT hat;
477 struct JOYSTICK_DRIVER_SEMIAXIS semiaxis;
478 struct JOYSTICK_DRIVER_MOTOR motor;
479 struct JOYSTICK_DRIVER_KEY key;
480 struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse;
481 struct JOYSTICK_DRIVER_RELPOINTER relpointer;
482 };
483 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE;
484
485 //============================================================================
486 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_FEATURE_TYPE enum JOYSTICK_FEATURE_TYPE
487 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
488 /// @brief **Feature type**\n
489 /// Controller feature.
490 ///
491 /// Controller features are an abstraction over driver values. Each feature
492 /// maps to one or more driver primitives.
493 ///
494 ///@{
495 typedef enum JOYSTICK_FEATURE_TYPE
496 {
497 /// @brief Unknown type
498 JOYSTICK_FEATURE_TYPE_UNKNOWN,
499
500 /// @brief Type scalar
501 JOYSTICK_FEATURE_TYPE_SCALAR,
502
503 /// @brief Type analog stick
504 JOYSTICK_FEATURE_TYPE_ANALOG_STICK,
505
506 /// @brief Type accelerometer
507 JOYSTICK_FEATURE_TYPE_ACCELEROMETER,
508
509 /// @brief Type motor
510 JOYSTICK_FEATURE_TYPE_MOTOR,
511
512 /// @brief Type relative pointer
513 JOYSTICK_FEATURE_TYPE_RELPOINTER,
514
515 /// @brief Type absolut pointer
516 JOYSTICK_FEATURE_TYPE_ABSPOINTER,
517
518 /// @brief Type wheel
519 JOYSTICK_FEATURE_TYPE_WHEEL,
520
521 /// @brief Type throttle
522 JOYSTICK_FEATURE_TYPE_THROTTLE,
523
524 /// @brief Type key
525 JOYSTICK_FEATURE_TYPE_KEY,
526 } JOYSTICK_FEATURE_TYPE;
527 ///@}
528 //----------------------------------------------------------------------------
529
530 //============================================================================
531 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_FEATURE_PRIMITIVE enum JOYSTICK_FEATURE_PRIMITIVE
532 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
533 /// @brief **Feature primitives**\n
534 /// Indices used to access a feature's driver primitives.
535 ///
536 ///@{
537 typedef enum JOYSTICK_FEATURE_PRIMITIVE
538 {
539 /// @brief Scalar feature (a button, hat direction or semiaxis)
540 JOYSTICK_SCALAR_PRIMITIVE = 0,
541
542 /// @brief Analog stick up
543 JOYSTICK_ANALOG_STICK_UP = 0,
544 /// @brief Analog stick down
545 JOYSTICK_ANALOG_STICK_DOWN = 1,
546 /// @brief Analog stick right
547 JOYSTICK_ANALOG_STICK_RIGHT = 2,
548 /// @brief Analog stick left
549 JOYSTICK_ANALOG_STICK_LEFT = 3,
550
551 /// @brief Accelerometer X
552 JOYSTICK_ACCELEROMETER_POSITIVE_X = 0,
553 /// @brief Accelerometer Y
554 JOYSTICK_ACCELEROMETER_POSITIVE_Y = 1,
555 /// @brief Accelerometer Z
556 JOYSTICK_ACCELEROMETER_POSITIVE_Z = 2,
557
558 /// @brief Motor
559 JOYSTICK_MOTOR_PRIMITIVE = 0,
560
561 /// @brief Wheel left
562 JOYSTICK_WHEEL_LEFT = 0,
563 /// @brief Wheel right
564 JOYSTICK_WHEEL_RIGHT = 1,
565
566 /// @brief Throttle up
567 JOYSTICK_THROTTLE_UP = 0,
568 /// @brief Throttle down
569 JOYSTICK_THROTTLE_DOWN = 1,
570
571 /// @brief Key
572 JOYSTICK_KEY_PRIMITIVE = 0,
573
574 /// @brief Mouse button
575 JOYSTICK_MOUSE_BUTTON = 0,
576
577 /// @brief Relative pointer direction up
578 JOYSTICK_RELPOINTER_UP = 0,
579 /// @brief Relative pointer direction down
580 JOYSTICK_RELPOINTER_DOWN = 1,
581 /// @brief Relative pointer direction right
582 JOYSTICK_RELPOINTER_RIGHT = 2,
583 /// @brief Relative pointer direction left
584 JOYSTICK_RELPOINTER_LEFT = 3,
585
586 /// @brief Maximum number of primitives
587 JOYSTICK_PRIMITIVE_MAX = 4,
588 } JOYSTICK_FEATURE_PRIMITIVE;
589 ///@}
590 //----------------------------------------------------------------------------
591
592 /*!
593 * @brief Mapping between higher-level controller feature and its driver primitives
594 */
595 typedef struct JOYSTICK_FEATURE
596 {
597 char* name;
598 JOYSTICK_FEATURE_TYPE type;
599 struct JOYSTICK_DRIVER_PRIMITIVE primitives[JOYSTICK_PRIMITIVE_MAX];
600 } ATTRIBUTE_PACKED JOYSTICK_FEATURE;
601 //}
602
603 typedef struct AddonProps_Peripheral
604 {
605 const char* user_path; /*!< @brief path to the user profile */
606 const char* addon_path; /*!< @brief path to this add-on */
607 } ATTRIBUTE_PACKED AddonProps_Peripheral;
608
609 struct AddonInstance_Peripheral;
610
611 typedef struct AddonToKodiFuncTable_Peripheral
612 {
613 KODI_HANDLE kodiInstance;
614 void (*trigger_scan)(void* kodiInstance);
615 void (*refresh_button_maps)(void* kodiInstance,
616 const char* device_name,
617 const char* controller_id);
618 unsigned int (*feature_count)(void* kodiInstance,
619 const char* controller_id,
620 JOYSTICK_FEATURE_TYPE type);
621 JOYSTICK_FEATURE_TYPE(*feature_type)
622 (void* kodiInstance, const char* controller_id, const char* feature_name);
623 } AddonToKodiFuncTable_Peripheral;
624
625 //! @todo Mouse, light gun, multitouch
626
627 typedef struct KodiToAddonFuncTable_Peripheral
628 {
629 KODI_HANDLE addonInstance;
630
631 void(__cdecl* get_capabilities)(const struct AddonInstance_Peripheral* addonInstance,
632 struct PERIPHERAL_CAPABILITIES* capabilities);
633 PERIPHERAL_ERROR(__cdecl* perform_device_scan)
634 (const struct AddonInstance_Peripheral* addonInstance,
635 unsigned int* peripheral_count,
636 struct PERIPHERAL_INFO** scan_results);
637 void(__cdecl* free_scan_results)(const struct AddonInstance_Peripheral* addonInstance,
638 unsigned int peripheral_count,
639 struct PERIPHERAL_INFO* scan_results);
640 PERIPHERAL_ERROR(__cdecl* get_events)
641 (const struct AddonInstance_Peripheral* addonInstance,
642 unsigned int* event_count,
643 struct PERIPHERAL_EVENT** events);
644 void(__cdecl* free_events)(const struct AddonInstance_Peripheral* addonInstance,
645 unsigned int event_count,
646 struct PERIPHERAL_EVENT* events);
647 bool(__cdecl* send_event)(const struct AddonInstance_Peripheral* addonInstance,
648 const struct PERIPHERAL_EVENT* event);
649
650 /// @name Joystick operations
651 ///{
652 PERIPHERAL_ERROR(__cdecl* get_joystick_info)
653 (const struct AddonInstance_Peripheral* addonInstance,
654 unsigned int index,
655 struct JOYSTICK_INFO* info);
656 void(__cdecl* free_joystick_info)(const struct AddonInstance_Peripheral* addonInstance,
657 struct JOYSTICK_INFO* info);
658 PERIPHERAL_ERROR(__cdecl* get_features)
659 (const struct AddonInstance_Peripheral* addonInstance,
660 const struct JOYSTICK_INFO* joystick,
661 const char* controller_id,
662 unsigned int* feature_count,
663 struct JOYSTICK_FEATURE** features);
664 void(__cdecl* free_features)(const struct AddonInstance_Peripheral* addonInstance,
665 unsigned int feature_count,
666 struct JOYSTICK_FEATURE* features);
667 PERIPHERAL_ERROR(__cdecl* map_features)
668 (const struct AddonInstance_Peripheral* addonInstance,
669 const struct JOYSTICK_INFO* joystick,
670 const char* controller_id,
671 unsigned int feature_count,
672 const struct JOYSTICK_FEATURE* features);
673 PERIPHERAL_ERROR(__cdecl* get_ignored_primitives)
674 (const struct AddonInstance_Peripheral* addonInstance,
675 const struct JOYSTICK_INFO* joystick,
676 unsigned int* feature_count,
677 struct JOYSTICK_DRIVER_PRIMITIVE** primitives);
678 void(__cdecl* free_primitives)(const struct AddonInstance_Peripheral* addonInstance,
679 unsigned int,
680 struct JOYSTICK_DRIVER_PRIMITIVE* primitives);
681 PERIPHERAL_ERROR(__cdecl* set_ignored_primitives)
682 (const struct AddonInstance_Peripheral* addonInstance,
683 const struct JOYSTICK_INFO* joystick,
684 unsigned int primitive_count,
685 const struct JOYSTICK_DRIVER_PRIMITIVE* primitives);
686 void(__cdecl* save_button_map)(const struct AddonInstance_Peripheral* addonInstance,
687 const struct JOYSTICK_INFO* joystick);
688 void(__cdecl* revert_button_map)(const struct AddonInstance_Peripheral* addonInstance,
689 const struct JOYSTICK_INFO* joystick);
690 void(__cdecl* reset_button_map)(const struct AddonInstance_Peripheral* addonInstance,
691 const struct JOYSTICK_INFO* joystick,
692 const char* controller_id);
693 void(__cdecl* power_off_joystick)(const struct AddonInstance_Peripheral* addonInstance,
694 unsigned int index);
695 ///}
696 } KodiToAddonFuncTable_Peripheral;
697
698 typedef struct AddonInstance_Peripheral
699 {
700 struct AddonProps_Peripheral* props;
701 struct AddonToKodiFuncTable_Peripheral* toKodi;
702 struct KodiToAddonFuncTable_Peripheral* toAddon;
703 } AddonInstance_Peripheral;
704
705#ifdef __cplusplus
706} /* extern "C" */
707#endif /* __cplusplus */
708
709#endif /* !C_API_ADDONINSTANCE_PERIPHERAL_H */