-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
libretro.h
7828 lines (7116 loc) · 282 KB
/
libretro.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* libretro.h is a simple API that allows for the creation of games and emulators.
*
* @file libretro.h
* @version 1
* @author libretro
* @copyright Copyright (C) 2010-2023 The RetroArch team
*
* @paragraph LICENSE
* The following license statement only applies to this libretro API header (libretro.h).
*
* Copyright (C) 2010-2023 The RetroArch team
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBRETRO_H__
#define LIBRETRO_H__
#include <stdint.h>
#include <stddef.h>
#include <limits.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __cplusplus
#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
/* Hack applied for MSVC when compiling in C89 mode
* as it isn't C99-compliant. */
#define bool unsigned char
#define true 1
#define false 0
#else
#include <stdbool.h>
#endif
#endif
#ifndef RETRO_CALLCONV
# if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)
# define RETRO_CALLCONV __attribute__((cdecl))
# elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)
# define RETRO_CALLCONV __cdecl
# else
# define RETRO_CALLCONV /* all other platforms only have one calling convention each */
# endif
#endif
#ifndef RETRO_API
# if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# ifdef RETRO_IMPORT_SYMBOLS
# ifdef __GNUC__
# define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))
# else
# define RETRO_API RETRO_CALLCONV __declspec(dllimport)
# endif
# else
# ifdef __GNUC__
# define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))
# else
# define RETRO_API RETRO_CALLCONV __declspec(dllexport)
# endif
# endif
# else
# if defined(__GNUC__) && __GNUC__ >= 4
# define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
# else
# define RETRO_API RETRO_CALLCONV
# endif
# endif
#endif
/**
* The major version of the libretro API and ABI.
* Cores may support multiple versions,
* or they may reject cores with unsupported versions.
* It is only incremented for incompatible API/ABI changes;
* this generally implies a function was removed or changed,
* or that a \c struct had fields removed or changed.
* @note A design goal of libretro is to avoid having to increase this value at all costs.
* This is why there are APIs that are "extended" or "V2".
*/
#define RETRO_API_VERSION 1
/**
* @defgroup RETRO_DEVICE Input Devices
* @brief Libretro's fundamental device abstractions.
*
* Libretro's input system consists of abstractions over standard device types,
* such as a joypad (with or without analog), mouse, keyboard, light gun, or an abstract pointer.
* Instead of managing input devices themselves,
* cores need only to map their own concept of a controller to libretro's abstractions.
* This makes it possible for frontends to map the abstract types to a real input device
* without having to worry about the correct use of arbitrary (real) controller layouts.
* @{
*/
#define RETRO_DEVICE_TYPE_SHIFT 8
#define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1)
/**
* Defines an ID for a subclass of a known device type.
*
* To define a subclass ID, use this macro like so:
* @code{c}
* #define RETRO_DEVICE_SUPER_SCOPE RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_LIGHTGUN, 1)
* #define RETRO_DEVICE_JUSTIFIER RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_LIGHTGUN, 2)
* @endcode
*
* Correct use of this macro allows a frontend to select a suitable physical device
* to map to the emulated device.
*
* @note Cores must use the base ID when polling for input,
* and frontends must only accept the base ID for this purpose.
* Polling for input using subclass IDs is reserved for future definition.
*
* @param base One of the \ref RETRO_DEVICE "base device types".
* @param id A unique ID, with respect to \c base.
* Must be a non-negative integer.
* @return A unique subclass ID.
* @see retro_controller_description
* @see retro_set_controller_port_device
*/
#define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base)
/**
* @defgroup RETRO_DEVICE Input Device Classes
* @{
*/
/**
* Indicates no input.
*
* When provided as the \c device argument to \c retro_input_state_t,
* all other arguments are ignored and zero is returned.
*
* @see retro_input_state_t
*/
#define RETRO_DEVICE_NONE 0
/**
* An abstraction around a game controller, known as a "RetroPad".
*
* The RetroPad is modelled after a SNES controller,
* but with additional L2/R2/L3/R3 buttons
* (similar to a PlayStation controller).
*
* When provided as the \c device argument to \c retro_input_state_t,
* the \c id argument denotes the button (including D-Pad directions) to query.
* The result of said query will be 1 if the button is down, 0 if not.
*
* There is one exception; if \c RETRO_DEVICE_ID_JOYPAD_MASK is queried
* (and the frontend supports this query),
* the result will be a bitmask of all pressed buttons.
*
* @see retro_input_state_t
* @see RETRO_DEVICE_ANALOG
* @see RETRO_DEVICE_ID_JOYPAD
* @see RETRO_DEVICE_ID_JOYPAD_MASK
* @see RETRO_ENVIRONMENT_GET_INPUT_BITMASKS
*/
#define RETRO_DEVICE_JOYPAD 1
/**
* An abstraction around a mouse, similar to the SNES Mouse but with more buttons.
*
* When provided as the \c device argument to \c retro_input_state_t,
* the \c id argument denotes the button or axis to query.
* For buttons, the result of said query
* will be 1 if the button is down or 0 if not.
* For mouse wheel axes, the result
* will be 1 if the wheel was rotated in that direction and 0 if not.
* For the mouse pointer axis, the result will be thee mouse's movement
* relative to the last poll.
* The core is responsible for tracking the mouse's position,
* and the frontend is responsible for preventing interference
* by the real hardware pointer (if applicable).
*
* @note This should only be used for cores that emulate mouse input,
* such as for home computers
* or consoles with mouse attachments.
* Cores that emulate light guns should use \c RETRO_DEVICE_LIGHTGUN,
* and cores that emulate touch screens should use \c RETRO_DEVICE_POINTER.
*
* @see RETRO_DEVICE_POINTER
* @see RETRO_DEVICE_LIGHTGUN
*/
#define RETRO_DEVICE_MOUSE 2
/**
* An abstraction around a keyboard.
*
* When provided as the \c device argument to \c retro_input_state_t,
* the \c id argument denotes the key to poll.
*
* @note This should only be used for cores that emulate keyboard input,
* such as for home computers
* or consoles with keyboard attachments.
* Cores that emulate gamepads should use \c RETRO_DEVICE_JOYPAD or \c RETRO_DEVICE_ANALOG,
* and leave keyboard compatibility to the frontend.
*
* @see RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK
* @see retro_key
*/
#define RETRO_DEVICE_KEYBOARD 3
/**
* An abstraction around a light gun, similar to the PlayStation's Guncon.
*
* When provided as the \c device argument to \c retro_input_state_t,
* the \c id argument denotes one of several possible inputs.
*
* The gun's coordinates are reported in screen space (similar to the pointer)
* in the range of [-0x8000, 0x7fff].
* Zero is the center of the game's screen
* and -0x8000 represents out-of-bounds.
* The trigger and various auxiliary buttons are also reported.
*
* @note A forced off-screen shot can be requested for auto-reloading
* function in some games.
*
* @see RETRO_DEVICE_POINTER
*/
#define RETRO_DEVICE_LIGHTGUN 4
/**
* An extension of the RetroPad that supports analog input.
*
* The analog RetroPad provides two virtual analog sticks (similar to DualShock controllers)
* and allows any button to be treated as analog (similar to Xbox shoulder triggers).
*
* When provided as the \c device argument to \c retro_input_state_t,
* the \c id argument denotes an analog axis or an analog button.
*
* Analog axes are reported in the range of [-0x8000, 0x7fff],
* with the X axis being positive towards the right
* and the Y axis being positive towards the bottom.
*
* Analog buttons are reported in the range of [0, 0x7fff],
* where 0 is unpressed and 0x7fff is fully pressed.
*
* @note Cores should only use this type if they need analog input.
* Otherwise, \c RETRO_DEVICE_JOYPAD should be used.
* @see RETRO_DEVICE_JOYPAD
*/
#define RETRO_DEVICE_ANALOG 5
/**
* Input Device: Pointer.
*
* Abstracts the concept of a pointing mechanism, e.g. touch.
* This allows libretro to query in absolute coordinates where on the
* screen a mouse (or something similar) is being placed.
* For a touch centric device, coordinates reported are the coordinates
* of the press.
*
* Coordinates in X and Y are reported as:
* [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
* and 0x7fff corresponds to the far right/bottom of the screen.
* The "screen" is here defined as area that is passed to the frontend and
* later displayed on the monitor.
*
* The frontend is free to scale/resize this screen as it sees fit, however,
* (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
* game image, etc.
*
* To check if the pointer coordinates are valid (e.g. a touch display
* actually being touched), \c RETRO_DEVICE_ID_POINTER_PRESSED returns 1 or 0.
*
* If using a mouse on a desktop, \c RETRO_DEVICE_ID_POINTER_PRESSED will
* usually correspond to the left mouse button, but this is a frontend decision.
* \c RETRO_DEVICE_ID_POINTER_PRESSED will only return 1 if the pointer is
* inside the game screen.
*
* For multi-touch, the index variable can be used to successively query
* more presses.
* If index = 0 returns true for \c _PRESSED, coordinates can be extracted
* with \c _X, \c _Y for index = 0. One can then query \c _PRESSED, \c _X, \c _Y with
* index = 1, and so on.
* Eventually \c _PRESSED will return false for an index. No further presses
* are registered at this point.
*
* @see RETRO_DEVICE_MOUSE
* @see RETRO_DEVICE_ID_POINTER_X
* @see RETRO_DEVICE_ID_POINTER_Y
* @see RETRO_DEVICE_ID_POINTER_PRESSED
*/
#define RETRO_DEVICE_POINTER 6
/** @} */
/** @defgroup RETRO_DEVICE_ID_JOYPAD RetroPad Input
* @brief Digital buttons for the RetroPad.
*
* Button placement is comparable to that of a SNES controller,
* combined with the shoulder buttons of a PlayStation controller.
* These values can also be used for the \c id field of \c RETRO_DEVICE_INDEX_ANALOG_BUTTON
* to represent analog buttons (usually shoulder triggers).
* @{
*/
/** The equivalent of the SNES controller's south face button. */
#define RETRO_DEVICE_ID_JOYPAD_B 0
/** The equivalent of the SNES controller's west face button. */
#define RETRO_DEVICE_ID_JOYPAD_Y 1
/** The equivalent of the SNES controller's left-center button. */
#define RETRO_DEVICE_ID_JOYPAD_SELECT 2
/** The equivalent of the SNES controller's right-center button. */
#define RETRO_DEVICE_ID_JOYPAD_START 3
/** Up on the RetroPad's D-pad. */
#define RETRO_DEVICE_ID_JOYPAD_UP 4
/** Down on the RetroPad's D-pad. */
#define RETRO_DEVICE_ID_JOYPAD_DOWN 5
/** Left on the RetroPad's D-pad. */
#define RETRO_DEVICE_ID_JOYPAD_LEFT 6
/** Right on the RetroPad's D-pad. */
#define RETRO_DEVICE_ID_JOYPAD_RIGHT 7
/** The equivalent of the SNES controller's east face button. */
#define RETRO_DEVICE_ID_JOYPAD_A 8
/** The equivalent of the SNES controller's north face button. */
#define RETRO_DEVICE_ID_JOYPAD_X 9
/** The equivalent of the SNES controller's left shoulder button. */
#define RETRO_DEVICE_ID_JOYPAD_L 10
/** The equivalent of the SNES controller's right shoulder button. */
#define RETRO_DEVICE_ID_JOYPAD_R 11
/** The equivalent of the PlayStation's rear left shoulder button. */
#define RETRO_DEVICE_ID_JOYPAD_L2 12
/** The equivalent of the PlayStation's rear right shoulder button. */
#define RETRO_DEVICE_ID_JOYPAD_R2 13
/**
* The equivalent of the PlayStation's left analog stick button,
* although the actual button need not be in this position.
*/
#define RETRO_DEVICE_ID_JOYPAD_L3 14
/**
* The equivalent of the PlayStation's right analog stick button,
* although the actual button need not be in this position.
*/
#define RETRO_DEVICE_ID_JOYPAD_R3 15
/**
* Represents a bitmask that describes the state of all \c RETRO_DEVICE_ID_JOYPAD button constants,
* rather than the state of a single button.
*
* @see RETRO_ENVIRONMENT_GET_INPUT_BITMASKS
* @see RETRO_DEVICE_JOYPAD
*/
#define RETRO_DEVICE_ID_JOYPAD_MASK 256
/** @} */
/** @defgroup RETRO_DEVICE_ID_ANALOG Analog RetroPad Input
* @{
*/
/* Index / Id values for ANALOG device. */
#define RETRO_DEVICE_INDEX_ANALOG_LEFT 0
#define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1
#define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2
#define RETRO_DEVICE_ID_ANALOG_X 0
#define RETRO_DEVICE_ID_ANALOG_Y 1
/** @} */
/* Id values for MOUSE. */
#define RETRO_DEVICE_ID_MOUSE_X 0
#define RETRO_DEVICE_ID_MOUSE_Y 1
#define RETRO_DEVICE_ID_MOUSE_LEFT 2
#define RETRO_DEVICE_ID_MOUSE_RIGHT 3
#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7
#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8
#define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9
#define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10
/* Id values for LIGHTGUN. */
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/
#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/
#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2
#define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4
#define RETRO_DEVICE_ID_LIGHTGUN_START 6
#define RETRO_DEVICE_ID_LIGHTGUN_SELECT 7
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C 8
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP 9
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12
/* deprecated */
#define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/
#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/
#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/
#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/
#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/
/* Id values for POINTER. */
#define RETRO_DEVICE_ID_POINTER_X 0
#define RETRO_DEVICE_ID_POINTER_Y 1
#define RETRO_DEVICE_ID_POINTER_PRESSED 2
#define RETRO_DEVICE_ID_POINTER_COUNT 3
/** @} */
/* Returned from retro_get_region(). */
#define RETRO_REGION_NTSC 0
#define RETRO_REGION_PAL 1
/**
* Identifiers for supported languages.
* @see RETRO_ENVIRONMENT_GET_LANGUAGE
*/
enum retro_language
{
RETRO_LANGUAGE_ENGLISH = 0,
RETRO_LANGUAGE_JAPANESE = 1,
RETRO_LANGUAGE_FRENCH = 2,
RETRO_LANGUAGE_SPANISH = 3,
RETRO_LANGUAGE_GERMAN = 4,
RETRO_LANGUAGE_ITALIAN = 5,
RETRO_LANGUAGE_DUTCH = 6,
RETRO_LANGUAGE_PORTUGUESE_BRAZIL = 7,
RETRO_LANGUAGE_PORTUGUESE_PORTUGAL = 8,
RETRO_LANGUAGE_RUSSIAN = 9,
RETRO_LANGUAGE_KOREAN = 10,
RETRO_LANGUAGE_CHINESE_TRADITIONAL = 11,
RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12,
RETRO_LANGUAGE_ESPERANTO = 13,
RETRO_LANGUAGE_POLISH = 14,
RETRO_LANGUAGE_VIETNAMESE = 15,
RETRO_LANGUAGE_ARABIC = 16,
RETRO_LANGUAGE_GREEK = 17,
RETRO_LANGUAGE_TURKISH = 18,
RETRO_LANGUAGE_SLOVAK = 19,
RETRO_LANGUAGE_PERSIAN = 20,
RETRO_LANGUAGE_HEBREW = 21,
RETRO_LANGUAGE_ASTURIAN = 22,
RETRO_LANGUAGE_FINNISH = 23,
RETRO_LANGUAGE_INDONESIAN = 24,
RETRO_LANGUAGE_SWEDISH = 25,
RETRO_LANGUAGE_UKRAINIAN = 26,
RETRO_LANGUAGE_CZECH = 27,
RETRO_LANGUAGE_CATALAN_VALENCIA = 28,
RETRO_LANGUAGE_CATALAN = 29,
RETRO_LANGUAGE_BRITISH_ENGLISH = 30,
RETRO_LANGUAGE_HUNGARIAN = 31,
RETRO_LANGUAGE_BELARUSIAN = 32,
RETRO_LANGUAGE_GALICIAN = 33,
RETRO_LANGUAGE_NORWEGIAN = 34,
RETRO_LANGUAGE_LAST,
/** Defined to ensure that <tt>sizeof(retro_language) == sizeof(int)</tt>. Do not use. */
RETRO_LANGUAGE_DUMMY = INT_MAX
};
/** @defgroup RETRO_MEMORY Memory Types
* @{
*/
/* Passed to retro_get_memory_data/size().
* If the memory type doesn't apply to the
* implementation NULL/0 can be returned.
*/
#define RETRO_MEMORY_MASK 0xff
/* Regular save RAM. This RAM is usually found on a game cartridge,
* backed up by a battery.
* If save game data is too complex for a single memory buffer,
* the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment
* callback can be used. */
#define RETRO_MEMORY_SAVE_RAM 0
/* Some games have a built-in clock to keep track of time.
* This memory is usually just a couple of bytes to keep track of time.
*/
#define RETRO_MEMORY_RTC 1
/* System ram lets a frontend peek into a game systems main RAM. */
#define RETRO_MEMORY_SYSTEM_RAM 2
/* Video ram lets a frontend peek into a game systems video RAM (VRAM). */
#define RETRO_MEMORY_VIDEO_RAM 3
/** @} */
/* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */
enum retro_key
{
RETROK_UNKNOWN = 0,
RETROK_FIRST = 0,
RETROK_BACKSPACE = 8,
RETROK_TAB = 9,
RETROK_CLEAR = 12,
RETROK_RETURN = 13,
RETROK_PAUSE = 19,
RETROK_ESCAPE = 27,
RETROK_SPACE = 32,
RETROK_EXCLAIM = 33,
RETROK_QUOTEDBL = 34,
RETROK_HASH = 35,
RETROK_DOLLAR = 36,
RETROK_AMPERSAND = 38,
RETROK_QUOTE = 39,
RETROK_LEFTPAREN = 40,
RETROK_RIGHTPAREN = 41,
RETROK_ASTERISK = 42,
RETROK_PLUS = 43,
RETROK_COMMA = 44,
RETROK_MINUS = 45,
RETROK_PERIOD = 46,
RETROK_SLASH = 47,
RETROK_0 = 48,
RETROK_1 = 49,
RETROK_2 = 50,
RETROK_3 = 51,
RETROK_4 = 52,
RETROK_5 = 53,
RETROK_6 = 54,
RETROK_7 = 55,
RETROK_8 = 56,
RETROK_9 = 57,
RETROK_COLON = 58,
RETROK_SEMICOLON = 59,
RETROK_LESS = 60,
RETROK_EQUALS = 61,
RETROK_GREATER = 62,
RETROK_QUESTION = 63,
RETROK_AT = 64,
RETROK_LEFTBRACKET = 91,
RETROK_BACKSLASH = 92,
RETROK_RIGHTBRACKET = 93,
RETROK_CARET = 94,
RETROK_UNDERSCORE = 95,
RETROK_BACKQUOTE = 96,
RETROK_a = 97,
RETROK_b = 98,
RETROK_c = 99,
RETROK_d = 100,
RETROK_e = 101,
RETROK_f = 102,
RETROK_g = 103,
RETROK_h = 104,
RETROK_i = 105,
RETROK_j = 106,
RETROK_k = 107,
RETROK_l = 108,
RETROK_m = 109,
RETROK_n = 110,
RETROK_o = 111,
RETROK_p = 112,
RETROK_q = 113,
RETROK_r = 114,
RETROK_s = 115,
RETROK_t = 116,
RETROK_u = 117,
RETROK_v = 118,
RETROK_w = 119,
RETROK_x = 120,
RETROK_y = 121,
RETROK_z = 122,
RETROK_LEFTBRACE = 123,
RETROK_BAR = 124,
RETROK_RIGHTBRACE = 125,
RETROK_TILDE = 126,
RETROK_DELETE = 127,
RETROK_KP0 = 256,
RETROK_KP1 = 257,
RETROK_KP2 = 258,
RETROK_KP3 = 259,
RETROK_KP4 = 260,
RETROK_KP5 = 261,
RETROK_KP6 = 262,
RETROK_KP7 = 263,
RETROK_KP8 = 264,
RETROK_KP9 = 265,
RETROK_KP_PERIOD = 266,
RETROK_KP_DIVIDE = 267,
RETROK_KP_MULTIPLY = 268,
RETROK_KP_MINUS = 269,
RETROK_KP_PLUS = 270,
RETROK_KP_ENTER = 271,
RETROK_KP_EQUALS = 272,
RETROK_UP = 273,
RETROK_DOWN = 274,
RETROK_RIGHT = 275,
RETROK_LEFT = 276,
RETROK_INSERT = 277,
RETROK_HOME = 278,
RETROK_END = 279,
RETROK_PAGEUP = 280,
RETROK_PAGEDOWN = 281,
RETROK_F1 = 282,
RETROK_F2 = 283,
RETROK_F3 = 284,
RETROK_F4 = 285,
RETROK_F5 = 286,
RETROK_F6 = 287,
RETROK_F7 = 288,
RETROK_F8 = 289,
RETROK_F9 = 290,
RETROK_F10 = 291,
RETROK_F11 = 292,
RETROK_F12 = 293,
RETROK_F13 = 294,
RETROK_F14 = 295,
RETROK_F15 = 296,
RETROK_NUMLOCK = 300,
RETROK_CAPSLOCK = 301,
RETROK_SCROLLOCK = 302,
RETROK_RSHIFT = 303,
RETROK_LSHIFT = 304,
RETROK_RCTRL = 305,
RETROK_LCTRL = 306,
RETROK_RALT = 307,
RETROK_LALT = 308,
RETROK_RMETA = 309,
RETROK_LMETA = 310,
RETROK_LSUPER = 311,
RETROK_RSUPER = 312,
RETROK_MODE = 313,
RETROK_COMPOSE = 314,
RETROK_HELP = 315,
RETROK_PRINT = 316,
RETROK_SYSREQ = 317,
RETROK_BREAK = 318,
RETROK_MENU = 319,
RETROK_POWER = 320,
RETROK_EURO = 321,
RETROK_UNDO = 322,
RETROK_OEM_102 = 323,
RETROK_BROWSER_BACK = 324,
RETROK_BROWSER_FORWARD = 325,
RETROK_BROWSER_REFRESH = 326,
RETROK_BROWSER_STOP = 327,
RETROK_BROWSER_SEARCH = 328,
RETROK_BROWSER_FAVORITES = 329,
RETROK_BROWSER_HOME = 330,
RETROK_VOLUME_MUTE = 331,
RETROK_VOLUME_DOWN = 332,
RETROK_VOLUME_UP = 333,
RETROK_MEDIA_NEXT = 334,
RETROK_MEDIA_PREV = 335,
RETROK_MEDIA_STOP = 336,
RETROK_MEDIA_PLAY_PAUSE = 337,
RETROK_LAUNCH_MAIL = 338,
RETROK_LAUNCH_MEDIA = 339,
RETROK_LAUNCH_APP1 = 340,
RETROK_LAUNCH_APP2 = 341,
RETROK_LAST,
RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
};
enum retro_mod
{
RETROKMOD_NONE = 0x0000,
RETROKMOD_SHIFT = 0x01,
RETROKMOD_CTRL = 0x02,
RETROKMOD_ALT = 0x04,
RETROKMOD_META = 0x08,
RETROKMOD_NUMLOCK = 0x10,
RETROKMOD_CAPSLOCK = 0x20,
RETROKMOD_SCROLLOCK = 0x40,
RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
};
/**
* @defgroup RETRO_ENVIRONMENT Environment Callbacks
* @{
*/
/**
* This bit indicates that the associated environment call is experimental,
* and may be changed or removed in the future.
* Frontends should mask out this bit before handling the environment call.
*/
#define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000
/** Frontend-internal environment callbacks should include this bit. */
#define RETRO_ENVIRONMENT_PRIVATE 0x20000
/* Environment commands. */
/**
* Requests the frontend to set the screen rotation.
*
* @param[in] data <tt>const unsigned*</tt>.
* Valid values are 0, 1, 2, and 3.
* These numbers respectively set the screen rotation to 0, 90, 180, and 270 degrees counter-clockwise.
* @returns \c true if the screen rotation was set successfully.
*/
#define RETRO_ENVIRONMENT_SET_ROTATION 1
/**
* Queries whether the core should use overscan or not.
*
* @param[out] data <tt>bool*</tt>.
* Set to \c true if the core should use overscan,
* \c false if it should be cropped away.
* @returns \c true if the environment call is available.
* Does \em not indicate whether overscan should be used.
* @deprecated As of 2019 this callback is considered deprecated in favor of
* using core options to manage overscan in a more nuanced, core-specific way.
*/
#define RETRO_ENVIRONMENT_GET_OVERSCAN 2
/**
* Queries whether the frontend supports frame duping,
* in the form of passing \c NULL to the video frame callback.
*
* @param[out] data <tt>bool*</tt>.
* Set to \c true if the frontend supports frame duping.
* @returns \c true if the environment call is available.
* @see retro_video_refresh_t
*/
#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3
/*
* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),
* and reserved to avoid possible ABI clash.
*/
/**
* @brief Displays a user-facing message for a short time.
*
* Use this callback to convey important status messages,
* such as errors or the result of long-running operations.
* For trivial messages or logging, use \c RETRO_ENVIRONMENT_GET_LOG_INTERFACE or \c stderr.
*
* \code{.c}
* void set_message_example(void)
* {
* struct retro_message msg;
* msg.frames = 60 * 5; // 5 seconds
* msg.msg = "Hello world!";
*
* environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &msg);
* }
* \endcode
*
* @deprecated Prefer using \c RETRO_ENVIRONMENT_SET_MESSAGE_EXT for new code,
* as it offers more features.
* Only use this environment call for compatibility with older cores or frontends.
*
* @param[in] data <tt>const struct retro_message*</tt>.
* Details about the message to show to the user.
* Behavior is undefined if <tt>NULL</tt>.
* @returns \c true if the environment call is available.
* @see retro_message
* @see RETRO_ENVIRONMENT_GET_LOG_INTERFACE
* @see RETRO_ENVIRONMENT_SET_MESSAGE_EXT
* @see RETRO_ENVIRONMENT_SET_MESSAGE
* @see RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION
* @note The frontend must make its own copy of the message and the underlying string.
*/
#define RETRO_ENVIRONMENT_SET_MESSAGE 6
/**
* Requests the frontend to shutdown the core.
* Should only be used if the core can exit on its own,
* such as from a menu item in a game
* or an emulated power-off in an emulator.
*
* @param data Ignored.
* @returns \c true if the environment call is available.
*/
#define RETRO_ENVIRONMENT_SHUTDOWN 7
/**
* Gives a hint to the frontend of how demanding this core is on the system.
* For example, reporting a level of 2 means that
* this implementation should run decently on frontends
* of level 2 and above.
*
* It can be used by the frontend to potentially warn
* about too demanding implementations.
*
* The levels are "floating".
*
* This function can be called on a per-game basis,
* as a core may have different demands for different games or settings.
* If called, it should be called in <tt>retro_load_game()</tt>.
* @param[in] data <tt>const unsigned*</tt>.
*/
#define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8
/**
* Returns the path to the frontend's system directory,
* which can be used to store system-specific configuration
* such as BIOS files or cached data.
*
* @param[out] data <tt>const char**</tt>.
* Pointer to the \c char* in which the system directory will be saved.
* The string is managed by the frontend and must not be modified or freed by the core.
* May be \c NULL if no system directory is defined,
* in which case the core should find an alternative directory.
* @return \c true if the environment call is available,
* even if the value returned in \c data is <tt>NULL</tt>.
* @note Historically, some cores would use this folder for save data such as memory cards or SRAM.
* This is now discouraged in favor of \c RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY.
* @see RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY
*/
#define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9
/**
* Sets the internal pixel format used by the frontend for rendering.
* The default pixel format is \c RETRO_PIXEL_FORMAT_0RGB1555 for compatibility reasons,
* although it's considered deprecated and shouldn't be used by new code.
*
* @param[in] data <tt>const enum retro_pixel_format *</tt>.
* Pointer to the pixel format to use.
* @returns \c true if the pixel format was set successfully,
* \c false if it's not supported or this callback is unavailable.
* @note This function should be called inside \c retro_load_game()
* or <tt>retro_get_system_av_info()</tt>.
* @see retro_pixel_format
*/
#define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
/**
* Sets an array of input descriptors for the frontend
* to present to the user for configuring the core's controls.
*
* This function can be called at any time,
* preferably early in the core's life cycle.
* Ideally, no later than \c retro_load_game().
*
* @param[in] data <tt>const struct retro_input_descriptor *</tt>.
* An array of input descriptors terminated by one whose
* \c retro_input_descriptor::description field is set to \c NULL.
* Behavior is undefined if \c NULL.
* @return \c true if the environment call is recognized.
* @see retro_input_descriptor
*/
#define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11
/**
* Sets a callback function used to notify the core about keyboard events.
* This should only be used for cores that specifically need keyboard input,
* such as for home computer emulators or games with text entry.
*
* @param[in] data <tt>const struct retro_keyboard_callback *</tt>.
* Pointer to the callback function.
* Behavior is undefined if <tt>NULL</tt>.
* @return \c true if the environment call is recognized.
* @see retro_keyboard_callback
* @see retro_key
*/
#define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12
/**
* Sets an interface that the frontend can use to insert and remove disks
* from the emulated console's disk drive.
* Can be used for optical disks, floppy disks, or any other game storage medium
* that can be swapped at runtime.
*
* This is intended for multi-disk games that expect the player
* to manually swap disks at certain points in the game.
*
* @deprecated Prefer using \c RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE
* over this environment call, as it supports additional features.
* Only use this callback to maintain compatibility
* with older cores or frontends.
*
* @param[in] data <tt>const struct retro_disk_control_callback *</tt>.
* Pointer to the callback functions to use.
* May be \c NULL, in which case the existing disk callback is deregistered.
* @return \c true if this environment call is available,
* even if \c data is \c NULL.
* @see retro_disk_control_callback
* @see RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE
*/
#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13
/**
* Requests that a frontend enable a particular hardware rendering API.
*
* If successful, the frontend will create a context (and other related resources)
* that the core can use for rendering.
* The framebuffer will be at least as large as
* the maximum dimensions provided in <tt>retro_get_system_av_info</tt>.
*
* @param[in, out] data <tt>struct retro_hw_render_callback *</tt>.
* Pointer to the hardware render callback struct.
* Used to define callbacks for the hardware-rendering life cycle,
* as well as to request a particular rendering API.
* @return \c true if the environment call is recognized
* and the requested rendering API is supported.
* \c false if \c data is \c NULL
* or the frontend can't provide the requested rendering API.
* @see retro_hw_render_callback
* @see retro_video_refresh_t
* @see RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER
* @note Should be called in <tt>retro_load_game()</tt>.
* @note If HW rendering is used, pass only \c RETRO_HW_FRAME_BUFFER_VALID or
* \c NULL to <tt>retro_video_refresh_t</tt>.
*/
#define RETRO_ENVIRONMENT_SET_HW_RENDER 14
/**
* Retrieves a core option's value from the frontend.
* \c retro_variable::key should be set to an option key
* that was previously set in \c RETRO_ENVIRONMENT_SET_VARIABLES
* (or a similar environment call).
*
* @param[in,out] data <tt>struct retro_variable *</tt>.
* Pointer to a single \c retro_variable struct.
* See the documentation for \c retro_variable for details
* on which fields are set by the frontend or core.
* May be \c NULL.
* @returns \c true if the environment call is available,
* even if \c data is \c NULL or the key it specifies is not found.
* @note Passing \c NULL in to \c data can be useful to
* test for support of this environment call without looking up any variables.
* @see retro_variable
* @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2
* @see RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE
*/
#define RETRO_ENVIRONMENT_GET_VARIABLE 15
/**
* Notifies the frontend of the core's available options.
*
* The core may check these options later using \c RETRO_ENVIRONMENT_GET_VARIABLE.
* The frontend may also present these options to the user
* in its own configuration UI.
*
* This should be called the first time as early as possible,
* ideally in \c retro_set_environment.
* The core may later call this function again
* to communicate updated options to the frontend,
* but the number of core options must not change.
*
* Here's an example that sets two options.
*
* @code
* void set_variables_example(void)
* {
* struct retro_variable options[] = {
* { "foo_speedhack", "Speed hack; false|true" }, // false by default
* { "foo_displayscale", "Display scale factor; 1|2|3|4" }, // 1 by default
* { NULL, NULL },
* };
*
* environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, &options);
* }
* @endcode
*
* The possible values will generally be displayed and stored as-is by the frontend.
*
* @deprecated Prefer using \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 for new code,
* as it offers more features such as categories and translation.
* Only use this environment call to maintain compatibility
* with older frontends or cores.
* @note Keep the available options (and their possible values) as low as possible;
* it should be feasible to cycle through them without a keyboard.
* @param[in] data <tt>const struct retro_variable *</tt>.
* Pointer to an array of \c retro_variable structs that define available core options,
* terminated by a <tt>{ NULL, NULL }</tt> element.