summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.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/game.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/game.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h1212
1 files changed, 1212 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h
new file mode 100644
index 0000000..c97fa5d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h
@@ -0,0 +1,1212 @@
1/*
2 * Copyright (C) 2014-2020 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_GAME_H
12#define C_API_ADDONINSTANCE_GAME_H
13
14#include "../addon_base.h"
15
16#include <stddef.h> /* size_t */
17
18//==============================================================================
19/// @ingroup cpp_kodi_addon_game_Defs
20/// @brief **Port ID used when topology is unknown**
21#define DEFAULT_PORT_ID "1"
22//------------------------------------------------------------------------------
23
24#ifdef __cplusplus
25extern "C"
26{
27#endif /* __cplusplus */
28
29 //============================================================================
30 /// @ingroup cpp_kodi_addon_game_Defs
31 /// @brief **Game add-on error codes**
32 ///
33 /// Used as return values on most Game related functions.
34 ///
35 typedef enum GAME_ERROR
36 {
37 /// @brief no error occurred
38 GAME_ERROR_NO_ERROR,
39
40 /// @brief an unknown error occurred
41 GAME_ERROR_UNKNOWN,
42
43 /// @brief the method that the frontend called is not implemented
44 GAME_ERROR_NOT_IMPLEMENTED,
45
46 /// @brief the command was rejected by the game client
47 GAME_ERROR_REJECTED,
48
49 /// @brief the parameters of the method that was called are invalid for this operation
50 GAME_ERROR_INVALID_PARAMETERS,
51
52 /// @brief the command failed
53 GAME_ERROR_FAILED,
54
55 /// @brief no game is loaded
56 GAME_ERROR_NOT_LOADED,
57
58 /// @brief game requires restricted resources
59 GAME_ERROR_RESTRICTED,
60 } GAME_ERROR;
61 //----------------------------------------------------------------------------
62
63 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
64 /// @defgroup cpp_kodi_addon_game_Defs_AudioStream 1. Audio stream
65 /// @ingroup cpp_kodi_addon_game_Defs
66 /// @brief **The for Audio stream used data system**
67 ///
68 /// Used to give Addon currently used audio stream configuration on Kodi and
69 /// arrays to give related data to Kodi on callbacks.
70 ///
71 ///@{
72
73 //============================================================================
74 /// @brief **Stream Format**
75 ///
76 /// From Kodi requested specified audio sample format.
77 ///
78 typedef enum GAME_PCM_FORMAT
79 {
80 GAME_PCM_FORMAT_UNKNOWN,
81
82 /// @brief S16NE sample format
83 GAME_PCM_FORMAT_S16NE,
84 } GAME_PCM_FORMAT;
85 //----------------------------------------------------------------------------
86
87 //============================================================================
88 /// @brief **Audio channel**
89 ///
90 /// Channel identification flags.
91 ///
92 typedef enum GAME_AUDIO_CHANNEL
93 {
94 /// @brief Channel list terminator
95 GAME_CH_NULL,
96
97 /// @brief Channel front left
98 GAME_CH_FL,
99
100 /// @brief Channel front right
101 GAME_CH_FR,
102
103 /// @brief Channel front center
104 GAME_CH_FC,
105
106 /// @brief Channel Low Frequency Effects / Subwoofer
107 GAME_CH_LFE,
108
109 /// @brief Channel back left
110 GAME_CH_BL,
111
112 /// @brief Channel back right
113 GAME_CH_BR,
114
115 /// @brief Channel front left over center
116 GAME_CH_FLOC,
117
118 /// @brief Channel front right over center
119 GAME_CH_FROC,
120
121 /// @brief Channel back center
122 GAME_CH_BC,
123
124 /// @brief Channel surround/side left
125 GAME_CH_SL,
126
127 /// @brief Channel surround/side right
128 GAME_CH_SR,
129
130 /// @brief Channel top front left
131 GAME_CH_TFL,
132
133 /// @brief Channel top front right
134 GAME_CH_TFR,
135
136 /// @brief Channel top front center
137 GAME_CH_TFC,
138
139 /// @brief Channel top center
140 GAME_CH_TC,
141
142 /// @brief Channel top back left
143 GAME_CH_TBL,
144
145 /// @brief Channel top back right
146 GAME_CH_TBR,
147
148 /// @brief Channel top back center
149 GAME_CH_TBC,
150
151 /// @brief Channel bacl left over center
152 GAME_CH_BLOC,
153
154 /// @brief Channel back right over center
155 GAME_CH_BROC,
156 } GAME_AUDIO_CHANNEL;
157 //----------------------------------------------------------------------------
158
159 //============================================================================
160 /// @brief **Game audio stream properties**
161 ///
162 /// Used by Kodi to pass the currently required audio stream settings to the addon
163 ///
164 typedef struct game_stream_audio_properties
165 {
166 GAME_PCM_FORMAT format;
167 const GAME_AUDIO_CHANNEL* channel_map;
168 } ATTRIBUTE_PACKED game_stream_audio_properties;
169 //----------------------------------------------------------------------------
170
171 //============================================================================
172 /// @brief **Audio stream packet**
173 ///
174 /// This packet contains audio stream data passed to Kodi.
175 ///
176 typedef struct game_stream_audio_packet
177 {
178 /// @brief Pointer for audio stream data given to Kodi
179 const uint8_t* data;
180
181 /// @brief Size of data array
182 size_t size;
183 } ATTRIBUTE_PACKED game_stream_audio_packet;
184 //----------------------------------------------------------------------------
185
186 ///@}
187
188 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
189 /// @defgroup cpp_kodi_addon_game_Defs_VideoStream 2. Video stream
190 /// @ingroup cpp_kodi_addon_game_Defs
191 /// @brief **The for Video stream used data system**
192 ///
193 /// Used to give Addon currently used video stream configuration on Kodi and
194 /// arrays to give related data to Kodi on callbacks.
195 ///
196 ///@{
197
198 //============================================================================
199 /// @brief **Pixel format**
200 ///
201 /// From Kodi requested specified video RGB color model format.
202 ///
203 typedef enum GAME_PIXEL_FORMAT
204 {
205 GAME_PIXEL_FORMAT_UNKNOWN,
206
207 /// @brief 0RGB8888 Format
208 GAME_PIXEL_FORMAT_0RGB8888,
209
210 /// @brief RGB565 Format
211 GAME_PIXEL_FORMAT_RGB565,
212
213 /// @brief 0RGB1555 Format
214 GAME_PIXEL_FORMAT_0RGB1555,
215 } GAME_PIXEL_FORMAT;
216 //----------------------------------------------------------------------------
217
218 //============================================================================
219 /// @brief **Video rotation position**
220 ///
221 /// To define position how video becomes shown.
222 ///
223 typedef enum GAME_VIDEO_ROTATION
224 {
225 /// @brief 0° and Without rotation
226 GAME_VIDEO_ROTATION_0,
227
228 /// @brief rotate 90° counterclockwise
229 GAME_VIDEO_ROTATION_90_CCW,
230
231 /// @brief rotate 180° counterclockwise
232 GAME_VIDEO_ROTATION_180_CCW,
233
234 /// @brief rotate 270° counterclockwise
235 GAME_VIDEO_ROTATION_270_CCW,
236 } GAME_VIDEO_ROTATION;
237 //----------------------------------------------------------------------------
238
239 //============================================================================
240 /// @brief **Game video stream properties**
241 ///
242 /// Used by Kodi to pass the currently required video stream settings to the addon
243 ///
244 typedef struct game_stream_video_properties
245 {
246 /// @brief The to used pixel format
247 GAME_PIXEL_FORMAT format;
248
249 /// @brief The nominal used width
250 unsigned int nominal_width;
251
252 /// @brief The nominal used height
253 unsigned int nominal_height;
254
255 /// @brief The maximal used width
256 unsigned int max_width;
257
258 /// @brief The maximal used height
259 unsigned int max_height;
260
261 /// @brief On video stream used aspect ration
262 ///
263 /// @note If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed
264 float aspect_ratio;
265 } ATTRIBUTE_PACKED game_stream_video_properties;
266 //----------------------------------------------------------------------------
267
268 //============================================================================
269 /// @brief **Video stream packet**
270 ///
271 /// This packet contains video stream data passed to Kodi.
272 ///
273 typedef struct game_stream_video_packet
274 {
275 /// @brief Video height
276 unsigned int width;
277
278 /// @brief Video width
279 unsigned int height;
280
281 /// @brief Width @ref GAME_VIDEO_ROTATION defined rotation angle.
282 GAME_VIDEO_ROTATION rotation;
283
284 /// @brief Pointer for video stream data given to Kodi
285 const uint8_t* data;
286
287 /// @brief Size of data array
288 size_t size;
289 } ATTRIBUTE_PACKED game_stream_video_packet;
290 //----------------------------------------------------------------------------
291
292 ///@}
293
294 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
295 /// @defgroup cpp_kodi_addon_game_Defs_HardwareFramebuffer 3. Hardware framebuffer stream
296 /// @ingroup cpp_kodi_addon_game_Defs
297 /// @brief **Hardware framebuffer stream data**
298 ///
299 ///@{
300
301 //============================================================================
302 /// @brief **Hardware framebuffer type**
303 ///
304 typedef enum GAME_HW_CONTEXT_TYPE
305 {
306 /// @brief None context
307 GAME_HW_CONTEXT_NONE,
308
309 /// @brief OpenGL 2.x. Driver can choose to use latest compatibility context
310 GAME_HW_CONTEXT_OPENGL,
311
312 /// @brief OpenGL ES 2.0
313 GAME_HW_CONTEXT_OPENGLES2,
314
315 /// @brief Modern desktop core GL context. Use major/minor fields to set GL version
316 GAME_HW_CONTEXT_OPENGL_CORE,
317
318 /// @brief OpenGL ES 3.0
319 GAME_HW_CONTEXT_OPENGLES3,
320
321 /// @brief OpenGL ES 3.1+. Set major/minor fields.
322 GAME_HW_CONTEXT_OPENGLES_VERSION,
323
324 /// @brief Vulkan
325 GAME_HW_CONTEXT_VULKAN
326 } GAME_HW_CONTEXT_TYPE;
327 //----------------------------------------------------------------------------
328
329 //============================================================================
330 /// @brief **Hardware framebuffer properties**
331 ///
332 typedef struct game_stream_hw_framebuffer_properties
333 {
334 /// @brief The API to use.
335 ///
336 GAME_HW_CONTEXT_TYPE context_type;
337
338 /// @brief Set if render buffers should have depth component attached.
339 ///
340 /// @todo: Obsolete
341 ///
342 bool depth;
343
344 /// @brief Set if stencil buffers should be attached.
345 ///
346 /// If depth and stencil are true, a packed 24/8 buffer will be added.
347 /// Only attaching stencil is invalid and will be ignored.
348 ///
349 /// @todo: Obsolete.
350 ///
351 bool stencil;
352
353 /// @brief Use conventional bottom-left origin convention.
354 ///
355 /// If false, standard top-left origin semantics are used.
356 ///
357 /// @todo: Move to GL specific interface
358 ///
359 bool bottom_left_origin;
360
361 /// @brief Major version number for core GL context or GLES 3.1+.
362 unsigned int version_major;
363
364 /// @brief Minor version number for core GL context or GLES 3.1+.
365 unsigned int version_minor;
366
367 /// @brief If this is true, the frontend will go very far to avoid resetting context
368 /// in scenarios like toggling fullscreen, etc.
369 ///
370 /// @todo: Obsolete? Maybe frontend should just always assume this...
371 ///
372 /// The reset callback might still be called in extreme situations such as if
373 /// the context is lost beyond recovery.
374 ///
375 /// For optimal stability, set this to false, and allow context to be reset at
376 /// any time.
377 ///
378 bool cache_context;
379
380 /// @brief Creates a debug context.
381 bool debug_context;
382 } ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties;
383 //----------------------------------------------------------------------------
384
385 //============================================================================
386 /// @brief **Hardware framebuffer buffer**
387 ///
388 typedef struct game_stream_hw_framebuffer_buffer
389 {
390 /// @brief
391 uintptr_t framebuffer;
392 } ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer;
393 //----------------------------------------------------------------------------
394
395 //============================================================================
396 /// @brief **Hardware framebuffer packet**
397 ///
398 typedef struct game_stream_hw_framebuffer_packet
399 {
400 /// @brief
401 uintptr_t framebuffer;
402 } ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet;
403 //----------------------------------------------------------------------------
404
405 //============================================================================
406 /// @brief **Hardware framebuffer process function address**
407 ///
408 typedef void (*game_proc_address_t)(void);
409 //----------------------------------------------------------------------------
410
411 ///@}
412
413 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
414 /// @defgroup cpp_kodi_addon_game_Defs_SoftwareFramebuffer 4. Software framebuffer stream
415 /// @ingroup cpp_kodi_addon_game_Defs
416 /// @brief **Software framebuffer stream data**
417 ///
418 ///@{
419
420 //============================================================================
421 /// @brief **Game video stream properties**
422 ///
423 /// Used by Kodi to pass the currently required video stream settings to the addon
424 ///
425 typedef game_stream_video_properties game_stream_sw_framebuffer_properties;
426 //----------------------------------------------------------------------------
427
428 //============================================================================
429 /// @brief **Hardware framebuffer type**
430 ///
431 typedef struct game_stream_sw_framebuffer_buffer
432 {
433 GAME_PIXEL_FORMAT format;
434 uint8_t* data;
435 size_t size;
436 } ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer;
437 //----------------------------------------------------------------------------
438
439 //============================================================================
440 /// @brief **Video stream packet**
441 ///
442 /// This packet contains video stream data passed to Kodi.
443 ///
444 typedef game_stream_video_packet game_stream_sw_framebuffer_packet;
445 //----------------------------------------------------------------------------
446
447 ///@}
448
449 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
450 /// @defgroup cpp_kodi_addon_game_Defs_StreamTypes 5. Stream types
451 /// @ingroup cpp_kodi_addon_game_Defs
452 /// @brief **Stream types data**
453 ///
454 ///@{
455
456 //============================================================================
457 /// @brief **Game stream types**
458 ///
459 typedef enum GAME_STREAM_TYPE
460 {
461 /// @brief Unknown
462 GAME_STREAM_UNKNOWN,
463
464 /// @brief Audio stream
465 GAME_STREAM_AUDIO,
466
467 /// @brief Video stream
468 GAME_STREAM_VIDEO,
469
470 /// @brief Hardware framebuffer
471 GAME_STREAM_HW_FRAMEBUFFER,
472
473 /// @brief Software framebuffer
474 GAME_STREAM_SW_FRAMEBUFFER,
475 } GAME_STREAM_TYPE;
476 //----------------------------------------------------------------------------
477
478 //============================================================================
479 /// @brief **Immutable stream metadata**
480 ///
481 /// This metadata is provided when the stream is opened. If any stream
482 /// properties change, a new stream must be opened.
483 ///
484 typedef struct game_stream_properties
485 {
486 /// @brief
487 GAME_STREAM_TYPE type;
488 union
489 {
490 /// @brief
491 game_stream_audio_properties audio;
492
493 /// @brief
494 game_stream_video_properties video;
495
496 /// @brief
497 game_stream_hw_framebuffer_properties hw_framebuffer;
498
499 /// @brief
500 game_stream_sw_framebuffer_properties sw_framebuffer;
501 };
502 } ATTRIBUTE_PACKED game_stream_properties;
503 //----------------------------------------------------------------------------
504
505 //============================================================================
506 /// @brief **Stream buffers for hardware rendering and zero-copy support**
507 ///
508 typedef struct game_stream_buffer
509 {
510 /// @brief
511 GAME_STREAM_TYPE type;
512 union
513 {
514 /// @brief
515 game_stream_hw_framebuffer_buffer hw_framebuffer;
516
517 /// @brief
518 game_stream_sw_framebuffer_buffer sw_framebuffer;
519 };
520 } ATTRIBUTE_PACKED game_stream_buffer;
521 //----------------------------------------------------------------------------
522
523 //============================================================================
524 /// @brief **Stream packet and ephemeral metadata**
525 ///
526 /// This packet contains stream data and accompanying metadata. The metadata
527 /// is ephemeral, meaning it only applies to the current packet and can change
528 /// from packet to packet in the same stream.
529 ///
530 typedef struct game_stream_packet
531 {
532 /// @brief
533 GAME_STREAM_TYPE type;
534 union
535 {
536 /// @brief
537 game_stream_audio_packet audio;
538
539 /// @brief
540 game_stream_video_packet video;
541
542 /// @brief
543 game_stream_hw_framebuffer_packet hw_framebuffer;
544
545 /// @brief
546 game_stream_sw_framebuffer_packet sw_framebuffer;
547 };
548 } ATTRIBUTE_PACKED game_stream_packet;
549 //----------------------------------------------------------------------------
550
551 ///@}
552
553 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
554 /// @defgroup cpp_kodi_addon_game_Defs_GameTypes 6. Game types
555 /// @ingroup cpp_kodi_addon_game_Defs
556 /// @brief **Game types data**
557 ///
558 ///@{
559
560 //============================================================================
561 /// @brief **Game reguin definition**
562 ///
563 /// Returned from game_get_region()
564 typedef enum GAME_REGION
565 {
566 /// @brief Game region unknown
567 GAME_REGION_UNKNOWN,
568
569 /// @brief Game region NTSC
570 GAME_REGION_NTSC,
571
572 /// @brief Game region PAL
573 GAME_REGION_PAL,
574 } GAME_REGION;
575 //----------------------------------------------------------------------------
576
577 //============================================================================
578 /// @brief **Special game types passed into game_load_game_special().**
579 ///
580 /// @remark Only used when multiple ROMs are required.
581 ///
582 typedef enum SPECIAL_GAME_TYPE
583 {
584 /// @brief Game Type BSX
585 SPECIAL_GAME_TYPE_BSX,
586
587 /// @brief Game Type BSX slotted
588 SPECIAL_GAME_TYPE_BSX_SLOTTED,
589
590 /// @brief Game Type sufami turbo
591 SPECIAL_GAME_TYPE_SUFAMI_TURBO,
592
593 /// @brief Game Type super game boy
594 SPECIAL_GAME_TYPE_SUPER_GAME_BOY,
595 } SPECIAL_GAME_TYPE;
596 //----------------------------------------------------------------------------
597
598 //============================================================================
599 /// @brief **Game Memory**
600 ///
601 typedef enum GAME_MEMORY
602 {
603 /// @brief Passed to game_get_memory_data/size(). If the memory type doesn't apply
604 /// to the implementation NULL/0 can be returned.
605 GAME_MEMORY_MASK = 0xff,
606
607 /// @brief Regular save ram.
608 ///
609 /// This ram is usually found on a game cartridge, backed
610 /// up by a battery. If save game data is too complex for a single memory
611 /// buffer, the SYSTEM_DIRECTORY environment callback can be used.
612 GAME_MEMORY_SAVE_RAM = 0,
613
614 /// @brief Some games have a built-in clock to keep track of time.
615 ///
616 /// This memory is usually just a couple of bytes to keep track of time.
617 GAME_MEMORY_RTC = 1,
618
619 /// @brief System ram lets a frontend peek into a game systems main RAM
620 GAME_MEMORY_SYSTEM_RAM = 2,
621
622 /// @brief Video ram lets a frontend peek into a game systems video RAM (VRAM)
623 GAME_MEMORY_VIDEO_RAM = 3,
624
625 /// @brief Special memory type
626 GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM),
627
628 /// @brief Special memory type
629 GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM),
630
631 /// @brief Special memory type
632 GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM = ((3 << 8) | GAME_MEMORY_SAVE_RAM),
633
634 /// @brief Special memory type
635 GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM = ((4 << 8) | GAME_MEMORY_SAVE_RAM),
636
637 /// @brief Special memory type
638 GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM),
639
640 /// @brief Special memory type
641 GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC),
642 } GAME_MEMORY;
643 //----------------------------------------------------------------------------
644
645 //============================================================================
646 /// @brief **ID values for SIMD CPU features**
647 typedef enum GAME_SIMD
648 {
649 /// @brief SIMD CPU SSE
650 GAME_SIMD_SSE = (1 << 0),
651
652 /// @brief SIMD CPU SSE2
653 GAME_SIMD_SSE2 = (1 << 1),
654
655 /// @brief SIMD CPU VMX
656 GAME_SIMD_VMX = (1 << 2),
657
658 /// @brief SIMD CPU VMX128
659 GAME_SIMD_VMX128 = (1 << 3),
660
661 /// @brief SIMD CPU AVX
662 GAME_SIMD_AVX = (1 << 4),
663
664 /// @brief SIMD CPU NEON
665 GAME_SIMD_NEON = (1 << 5),
666
667 /// @brief SIMD CPU SSE3
668 GAME_SIMD_SSE3 = (1 << 6),
669
670 /// @brief SIMD CPU SSSE3
671 GAME_SIMD_SSSE3 = (1 << 7),
672
673 /// @brief SIMD CPU MMX
674 GAME_SIMD_MMX = (1 << 8),
675
676 /// @brief SIMD CPU MMXEXT
677 GAME_SIMD_MMXEXT = (1 << 9),
678
679 /// @brief SIMD CPU SSE4
680 GAME_SIMD_SSE4 = (1 << 10),
681
682 /// @brief SIMD CPU SSE42
683 GAME_SIMD_SSE42 = (1 << 11),
684
685 /// @brief SIMD CPU AVX2
686 GAME_SIMD_AVX2 = (1 << 12),
687
688 /// @brief SIMD CPU VFPU
689 GAME_SIMD_VFPU = (1 << 13),
690 } GAME_SIMD;
691 //----------------------------------------------------------------------------
692
693 ///@}
694
695 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
696 /// @defgroup cpp_kodi_addon_game_Defs_InputTypes 7. Input types
697 /// @ingroup cpp_kodi_addon_game_Defs
698 /// @brief **Input types**
699 ///
700 ///@{
701
702 //============================================================================
703 /// @brief
704 typedef enum GAME_INPUT_EVENT_SOURCE
705 {
706 /// @brief
707 GAME_INPUT_EVENT_DIGITAL_BUTTON,
708
709 /// @brief
710 GAME_INPUT_EVENT_ANALOG_BUTTON,
711
712 /// @brief
713 GAME_INPUT_EVENT_AXIS,
714
715 /// @brief
716 GAME_INPUT_EVENT_ANALOG_STICK,
717
718 /// @brief
719 GAME_INPUT_EVENT_ACCELEROMETER,
720
721 /// @brief
722 GAME_INPUT_EVENT_KEY,
723
724 /// @brief
725 GAME_INPUT_EVENT_RELATIVE_POINTER,
726
727 /// @brief
728 GAME_INPUT_EVENT_ABSOLUTE_POINTER,
729
730 /// @brief
731 GAME_INPUT_EVENT_MOTOR,
732 } GAME_INPUT_EVENT_SOURCE;
733 //----------------------------------------------------------------------------
734
735 //============================================================================
736 /// @brief
737 typedef enum GAME_KEY_MOD
738 {
739 /// @brief
740 GAME_KEY_MOD_NONE = 0x0000,
741
742 /// @brief
743 GAME_KEY_MOD_SHIFT = 0x0001,
744
745 /// @brief
746 GAME_KEY_MOD_CTRL = 0x0002,
747
748 /// @brief
749 GAME_KEY_MOD_ALT = 0x0004,
750
751 /// @brief
752 GAME_KEY_MOD_META = 0x0008,
753
754 /// @brief
755 GAME_KEY_MOD_SUPER = 0x0010,
756
757 /// @brief
758 GAME_KEY_MOD_NUMLOCK = 0x0100,
759
760 /// @brief
761 GAME_KEY_MOD_CAPSLOCK = 0x0200,
762
763 /// @brief
764 GAME_KEY_MOD_SCROLLOCK = 0x0400,
765 } GAME_KEY_MOD;
766 //----------------------------------------------------------------------------
767
768 //============================================================================
769 /// @brief Type of port on the virtual game console
770 typedef enum GAME_PORT_TYPE
771 {
772 /// @brief Game port unknown
773 GAME_PORT_UNKNOWN,
774
775 /// @brief Game port Keyboard
776 GAME_PORT_KEYBOARD,
777
778 /// @brief Game port mouse
779 GAME_PORT_MOUSE,
780
781 /// @brief Game port controller
782 GAME_PORT_CONTROLLER,
783 } GAME_PORT_TYPE;
784 //----------------------------------------------------------------------------
785
786 /*! @cond PRIVATE */
787 /*!
788 * @brief "C" Game add-on controller layout.
789 *
790 * Structure used to interface in "C" between Kodi and Addon.
791 *
792 * See @ref AddonGameControllerLayout for description of values.
793 */
794 typedef struct game_controller_layout
795 {
796 char* controller_id;
797 bool provides_input; // False for multitaps
798 char** digital_buttons;
799 unsigned int digital_button_count;
800 char** analog_buttons;
801 unsigned int analog_button_count;
802 char** analog_sticks;
803 unsigned int analog_stick_count;
804 char** accelerometers;
805 unsigned int accelerometer_count;
806 char** keys;
807 unsigned int key_count;
808 char** rel_pointers;
809 unsigned int rel_pointer_count;
810 char** abs_pointers;
811 unsigned int abs_pointer_count;
812 char** motors;
813 unsigned int motor_count;
814 } ATTRIBUTE_PACKED game_controller_layout;
815 /*! @endcond */
816
817 struct game_input_port;
818
819 //============================================================================
820 /// @brief Device that can provide input
821 typedef struct game_input_device
822 {
823 /// @brief ID used in the Kodi controller API
824 const char* controller_id;
825
826 /// @brief
827 const char* port_address;
828
829 /// @brief
830 struct game_input_port* available_ports;
831
832 /// @brief
833 unsigned int port_count;
834 } ATTRIBUTE_PACKED game_input_device;
835 //----------------------------------------------------------------------------
836
837 //============================================================================
838 /// @brief Port that can provide input
839 ///
840 /// Ports can accept multiple devices and devices can have multiple ports, so
841 /// the topology of possible configurations is a tree structure of alternating
842 /// port and device nodes.
843 ///
844 typedef struct game_input_port
845 {
846 /// @brief
847 GAME_PORT_TYPE type;
848
849 /// @brief Required for GAME_PORT_CONTROLLER type
850 const char* port_id;
851
852 /// @brief
853 game_input_device* accepted_devices;
854
855 /// @brief
856 unsigned int device_count;
857 } ATTRIBUTE_PACKED game_input_port;
858 //----------------------------------------------------------------------------
859
860 //============================================================================
861 /// @brief The input topology is the possible ways to connect input devices
862 ///
863 /// This represents the logical topology, which is the possible connections that
864 /// the game client's logic can handle. It is strictly a subset of the physical
865 /// topology. Loops are not allowed.
866 ///
867 typedef struct game_input_topology
868 {
869 /// @brief The list of ports on the virtual game console
870 game_input_port* ports;
871
872 /// @brief The number of ports
873 unsigned int port_count;
874
875 /// @brief A limit on the number of input-providing devices, or -1 for no limit
876 int player_limit;
877 } ATTRIBUTE_PACKED game_input_topology;
878 //----------------------------------------------------------------------------
879
880 //============================================================================
881 /// @brief
882 typedef struct game_digital_button_event
883 {
884 /// @brief
885 bool pressed;
886 } ATTRIBUTE_PACKED game_digital_button_event;
887 //----------------------------------------------------------------------------
888
889 //============================================================================
890 /// @brief
891 typedef struct game_analog_button_event
892 {
893 /// @brief
894 float magnitude;
895 } ATTRIBUTE_PACKED game_analog_button_event;
896 //----------------------------------------------------------------------------
897
898 //============================================================================
899 /// @brief
900 typedef struct game_axis_event
901 {
902 /// @brief
903 float position;
904 } ATTRIBUTE_PACKED game_axis_event;
905 //----------------------------------------------------------------------------
906
907 //============================================================================
908 /// @brief
909 typedef struct game_analog_stick_event
910 {
911 /// @brief
912 float x;
913
914 /// @brief
915 float y;
916 } ATTRIBUTE_PACKED game_analog_stick_event;
917 //----------------------------------------------------------------------------
918
919 //============================================================================
920 /// @brief
921 typedef struct game_accelerometer_event
922 {
923 /// @brief
924 float x;
925
926 /// @brief
927 float y;
928
929 /// @brief
930 float z;
931 } ATTRIBUTE_PACKED game_accelerometer_event;
932 //----------------------------------------------------------------------------
933
934 //============================================================================
935 /// @brief
936 typedef struct game_key_event
937 {
938 /// @brief
939 bool pressed;
940
941 /// @brief If the keypress generates a printing character
942 ///
943 /// The unicode value contains the character generated. If the key is a
944 /// non-printing character, e.g. a function or arrow key, the unicode value
945 /// is zero.
946 uint32_t unicode;
947
948 /// @brief
949 GAME_KEY_MOD modifiers;
950 } ATTRIBUTE_PACKED game_key_event;
951 //----------------------------------------------------------------------------
952
953 //============================================================================
954 /// @brief
955 typedef struct game_rel_pointer_event
956 {
957 /// @brief
958 int x;
959
960 /// @brief
961 int y;
962 } ATTRIBUTE_PACKED game_rel_pointer_event;
963 //----------------------------------------------------------------------------
964
965 //============================================================================
966 /// @brief
967 typedef struct game_abs_pointer_event
968 {
969 /// @brief
970 bool pressed;
971
972 /// @brief
973 float x;
974
975 /// @brief
976 float y;
977 } ATTRIBUTE_PACKED game_abs_pointer_event;
978 //----------------------------------------------------------------------------
979
980 //============================================================================
981 /// @brief
982 typedef struct game_motor_event
983 {
984 /// @brief
985 float magnitude;
986 } ATTRIBUTE_PACKED game_motor_event;
987 //----------------------------------------------------------------------------
988
989 //============================================================================
990 /// @brief
991 typedef struct game_input_event
992 {
993 /// @brief
994 GAME_INPUT_EVENT_SOURCE type;
995
996 /// @brief
997 const char* controller_id;
998
999 /// @brief
1000 GAME_PORT_TYPE port_type;
1001
1002 /// @brief
1003 const char* port_address;
1004
1005 /// @brief
1006 const char* feature_name;
1007 union
1008 {
1009 /// @brief
1010 struct game_digital_button_event digital_button;
1011
1012 /// @brief
1013 struct game_analog_button_event analog_button;
1014
1015 /// @brief
1016 struct game_axis_event axis;
1017
1018 /// @brief
1019 struct game_analog_stick_event analog_stick;
1020
1021 /// @brief
1022 struct game_accelerometer_event accelerometer;
1023
1024 /// @brief
1025 struct game_key_event key;
1026
1027 /// @brief
1028 struct game_rel_pointer_event rel_pointer;
1029
1030 /// @brief
1031 struct game_abs_pointer_event abs_pointer;
1032
1033 /// @brief
1034 struct game_motor_event motor;
1035 };
1036 } ATTRIBUTE_PACKED game_input_event;
1037 //----------------------------------------------------------------------------
1038
1039 ///@}
1040
1041 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1042 /// @defgroup cpp_kodi_addon_game_Defs_EnvironmentTypes 8. Environment types
1043 /// @ingroup cpp_kodi_addon_game_Defs
1044 /// @brief **Environment types**
1045 ///
1046 ///@{
1047
1048 //============================================================================
1049 /// @brief Game system timing
1050 ///
1051 struct game_system_timing
1052 {
1053 /// @brief FPS of video content.
1054 double fps;
1055
1056 /// @brief Sampling rate of audio.
1057 double sample_rate;
1058 };
1059 //----------------------------------------------------------------------------
1060
1061 ///@}
1062
1063
1064 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1065
1066 /*!
1067 * @brief Game properties
1068 *
1069 * Not to be used outside this header.
1070 */
1071 typedef struct AddonProps_Game
1072 {
1073 /*!
1074 * The path of the game client being loaded.
1075 */
1076 const char* game_client_dll_path;
1077
1078 /*!
1079 * Paths to proxy DLLs used to load the game client.
1080 */
1081 const char** proxy_dll_paths;
1082
1083 /*!
1084 * Number of proxy DLL paths provided.
1085 */
1086 unsigned int proxy_dll_count;
1087
1088 /*!
1089 * The "system" directories of the frontend. These directories can be used to
1090 * store system-specific ROMs such as BIOSes, configuration data, etc.
1091 */
1092 const char** resource_directories;
1093
1094 /*!
1095 * Number of resource directories provided
1096 */
1097 unsigned int resource_directory_count;
1098
1099 /*!
1100 * The writable directory of the frontend. This directory can be used to store
1101 * SRAM, memory cards, high scores, etc, if the game client cannot use the
1102 * regular memory interface, GetMemoryData().
1103 */
1104 const char* profile_directory;
1105
1106 /*!
1107 * The value of the <supports_vfs> property from addon.xml
1108 */
1109 bool supports_vfs;
1110
1111 /*!
1112 * The extensions in the <extensions> property from addon.xml
1113 */
1114 const char** extensions;
1115
1116 /*!
1117 * Number of extensions provided
1118 */
1119 unsigned int extension_count;
1120 } AddonProps_Game;
1121
1122 typedef void* KODI_GAME_STREAM_HANDLE;
1123
1124 /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */
1125
1126 struct AddonInstance_Game;
1127
1128 /*!
1129 * @brief Game callbacks
1130 *
1131 * Not to be used outside this header.
1132 */
1133 typedef struct AddonToKodiFuncTable_Game
1134 {
1135 KODI_HANDLE kodiInstance;
1136
1137 void (*CloseGame)(KODI_HANDLE kodiInstance);
1138 KODI_GAME_STREAM_HANDLE (*OpenStream)(KODI_HANDLE, const struct game_stream_properties*);
1139 bool (*GetStreamBuffer)(KODI_HANDLE,
1140 KODI_GAME_STREAM_HANDLE,
1141 unsigned int,
1142 unsigned int,
1143 struct game_stream_buffer*);
1144 void (*AddStreamData)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE, const struct game_stream_packet*);
1145 void (*ReleaseStreamBuffer)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE, struct game_stream_buffer*);
1146 void (*CloseStream)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE);
1147 game_proc_address_t (*HwGetProcAddress)(KODI_HANDLE kodiInstance, const char* symbol);
1148 bool (*InputEvent)(KODI_HANDLE kodiInstance, const struct game_input_event* event);
1149 } AddonToKodiFuncTable_Game;
1150
1151 /*!
1152 * @brief Game function hooks
1153 *
1154 * Not to be used outside this header.
1155 */
1156 typedef struct KodiToAddonFuncTable_Game
1157 {
1158 KODI_HANDLE addonInstance;
1159
1160 GAME_ERROR(__cdecl* LoadGame)(const struct AddonInstance_Game*, const char*);
1161 GAME_ERROR(__cdecl* LoadGameSpecial)
1162 (const struct AddonInstance_Game*, enum SPECIAL_GAME_TYPE, const char**, size_t);
1163 GAME_ERROR(__cdecl* LoadStandalone)(const struct AddonInstance_Game*);
1164 GAME_ERROR(__cdecl* UnloadGame)(const struct AddonInstance_Game*);
1165 GAME_ERROR(__cdecl* GetGameTiming)
1166 (const struct AddonInstance_Game*, struct game_system_timing*);
1167 GAME_REGION(__cdecl* GetRegion)(const struct AddonInstance_Game*);
1168 bool(__cdecl* RequiresGameLoop)(const struct AddonInstance_Game*);
1169 GAME_ERROR(__cdecl* RunFrame)(const struct AddonInstance_Game*);
1170 GAME_ERROR(__cdecl* Reset)(const struct AddonInstance_Game*);
1171 GAME_ERROR(__cdecl* HwContextReset)(const struct AddonInstance_Game*);
1172 GAME_ERROR(__cdecl* HwContextDestroy)(const struct AddonInstance_Game*);
1173 bool(__cdecl* HasFeature)(const struct AddonInstance_Game*, const char*, const char*);
1174 game_input_topology*(__cdecl* GetTopology)(const struct AddonInstance_Game*);
1175 void(__cdecl* FreeTopology)(const struct AddonInstance_Game*, struct game_input_topology*);
1176 void(__cdecl* SetControllerLayouts)(const struct AddonInstance_Game*,
1177 const struct game_controller_layout*,
1178 unsigned int);
1179 bool(__cdecl* EnableKeyboard)(const struct AddonInstance_Game*, bool, const char*);
1180 bool(__cdecl* EnableMouse)(const struct AddonInstance_Game*, bool, const char*);
1181 bool(__cdecl* ConnectController)(const struct AddonInstance_Game*,
1182 bool,
1183 const char*,
1184 const char*);
1185 bool(__cdecl* InputEvent)(const struct AddonInstance_Game*, const struct game_input_event*);
1186 size_t(__cdecl* SerializeSize)(const struct AddonInstance_Game*);
1187 GAME_ERROR(__cdecl* Serialize)(const struct AddonInstance_Game*, uint8_t*, size_t);
1188 GAME_ERROR(__cdecl* Deserialize)(const struct AddonInstance_Game*, const uint8_t*, size_t);
1189 GAME_ERROR(__cdecl* CheatReset)(const struct AddonInstance_Game*);
1190 GAME_ERROR(__cdecl* GetMemory)
1191 (const struct AddonInstance_Game*, enum GAME_MEMORY, uint8_t**, size_t*);
1192 GAME_ERROR(__cdecl* SetCheat)
1193 (const struct AddonInstance_Game*, unsigned int, bool, const char*);
1194 } KodiToAddonFuncTable_Game;
1195
1196 /*!
1197 * @brief Game instance
1198 *
1199 * Not to be used outside this header.
1200 */
1201 typedef struct AddonInstance_Game
1202 {
1203 struct AddonProps_Game* props;
1204 struct AddonToKodiFuncTable_Game* toKodi;
1205 struct KodiToAddonFuncTable_Game* toAddon;
1206 } AddonInstance_Game;
1207
1208#ifdef __cplusplus
1209}
1210#endif /* __cplusplus */
1211
1212#endif /* !C_API_ADDONINSTANCE_GAME_H */