libretro.h 219 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191
  1. /* Copyright (C) 2010-2020 The RetroArch team
  2. *
  3. * ---------------------------------------------------------------------------------------
  4. * The following license statement only applies to this libretro API header (libretro.h).
  5. * ---------------------------------------------------------------------------------------
  6. *
  7. * Permission is hereby granted, free of charge,
  8. * to any person obtaining a copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
  11. * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef LIBRETRO_H__
  23. #define LIBRETRO_H__
  24. #include <stdint.h>
  25. #include <stddef.h>
  26. #include <limits.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #ifndef __cplusplus
  31. #if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
  32. /* Hack applied for MSVC when compiling in C89 mode
  33. * as it isn't C99-compliant. */
  34. #define bool unsigned char
  35. #define true 1
  36. #define false 0
  37. #else
  38. #include <stdbool.h>
  39. #endif
  40. #endif
  41. #ifndef RETRO_CALLCONV
  42. # if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)
  43. # define RETRO_CALLCONV __attribute__((cdecl))
  44. # elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)
  45. # define RETRO_CALLCONV __cdecl
  46. # else
  47. # define RETRO_CALLCONV /* all other platforms only have one calling convention each */
  48. # endif
  49. #endif
  50. #ifndef RETRO_API
  51. # if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
  52. # ifdef RETRO_IMPORT_SYMBOLS
  53. # ifdef __GNUC__
  54. # define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))
  55. # else
  56. # define RETRO_API RETRO_CALLCONV __declspec(dllimport)
  57. # endif
  58. # else
  59. # ifdef __GNUC__
  60. # define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))
  61. # else
  62. # define RETRO_API RETRO_CALLCONV __declspec(dllexport)
  63. # endif
  64. # endif
  65. # else
  66. # if defined(__GNUC__) && __GNUC__ >= 4
  67. # define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
  68. # else
  69. # define RETRO_API RETRO_CALLCONV
  70. # endif
  71. # endif
  72. #endif
  73. /* Used for checking API/ABI mismatches that can break libretro
  74. * implementations.
  75. * It is not incremented for compatible changes to the API.
  76. */
  77. #define RETRO_API_VERSION 1
  78. /*
  79. * Libretro's fundamental device abstractions.
  80. *
  81. * Libretro's input system consists of some standardized device types,
  82. * such as a joypad (with/without analog), mouse, keyboard, lightgun
  83. * and a pointer.
  84. *
  85. * The functionality of these devices are fixed, and individual cores
  86. * map their own concept of a controller to libretro's abstractions.
  87. * This makes it possible for frontends to map the abstract types to a
  88. * real input device, and not having to worry about binding input
  89. * correctly to arbitrary controller layouts.
  90. */
  91. #define RETRO_DEVICE_TYPE_SHIFT 8
  92. #define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1)
  93. #define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base)
  94. /* Input disabled. */
  95. #define RETRO_DEVICE_NONE 0
  96. /* The JOYPAD is called RetroPad. It is essentially a Super Nintendo
  97. * controller, but with additional L2/R2/L3/R3 buttons, similar to a
  98. * PS1 DualShock. */
  99. #define RETRO_DEVICE_JOYPAD 1
  100. /* The mouse is a simple mouse, similar to Super Nintendo's mouse.
  101. * X and Y coordinates are reported relatively to last poll (poll callback).
  102. * It is up to the libretro implementation to keep track of where the mouse
  103. * pointer is supposed to be on the screen.
  104. * The frontend must make sure not to interfere with its own hardware
  105. * mouse pointer.
  106. */
  107. #define RETRO_DEVICE_MOUSE 2
  108. /* KEYBOARD device lets one poll for raw key pressed.
  109. * It is poll based, so input callback will return with the current
  110. * pressed state.
  111. * For event/text based keyboard input, see
  112. * RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
  113. */
  114. #define RETRO_DEVICE_KEYBOARD 3
  115. /* LIGHTGUN device is similar to Guncon-2 for PlayStation 2.
  116. * It reports X/Y coordinates in screen space (similar to the pointer)
  117. * in the range [-0x8000, 0x7fff] in both axes, with zero being center and
  118. * -0x8000 being out of bounds.
  119. * As well as reporting on/off screen state. It features a trigger,
  120. * start/select buttons, auxiliary action buttons and a
  121. * directional pad. A forced off-screen shot can be requested for
  122. * auto-reloading function in some games.
  123. */
  124. #define RETRO_DEVICE_LIGHTGUN 4
  125. /* The ANALOG device is an extension to JOYPAD (RetroPad).
  126. * Similar to DualShock2 it adds two analog sticks and all buttons can
  127. * be analog. This is treated as a separate device type as it returns
  128. * axis values in the full analog range of [-0x7fff, 0x7fff],
  129. * although some devices may return -0x8000.
  130. * Positive X axis is right. Positive Y axis is down.
  131. * Buttons are returned in the range [0, 0x7fff].
  132. * Only use ANALOG type when polling for analog values.
  133. */
  134. #define RETRO_DEVICE_ANALOG 5
  135. /* Abstracts the concept of a pointing mechanism, e.g. touch.
  136. * This allows libretro to query in absolute coordinates where on the
  137. * screen a mouse (or something similar) is being placed.
  138. * For a touch centric device, coordinates reported are the coordinates
  139. * of the press.
  140. *
  141. * Coordinates in X and Y are reported as:
  142. * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
  143. * and 0x7fff corresponds to the far right/bottom of the screen.
  144. * The "screen" is here defined as area that is passed to the frontend and
  145. * later displayed on the monitor.
  146. *
  147. * The frontend is free to scale/resize this screen as it sees fit, however,
  148. * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
  149. * game image, etc.
  150. *
  151. * To check if the pointer coordinates are valid (e.g. a touch display
  152. * actually being touched), PRESSED returns 1 or 0.
  153. *
  154. * If using a mouse on a desktop, PRESSED will usually correspond to the
  155. * left mouse button, but this is a frontend decision.
  156. * PRESSED will only return 1 if the pointer is inside the game screen.
  157. *
  158. * For multi-touch, the index variable can be used to successively query
  159. * more presses.
  160. * If index = 0 returns true for _PRESSED, coordinates can be extracted
  161. * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with
  162. * index = 1, and so on.
  163. * Eventually _PRESSED will return false for an index. No further presses
  164. * are registered at this point. */
  165. #define RETRO_DEVICE_POINTER 6
  166. /* Buttons for the RetroPad (JOYPAD).
  167. * The placement of these is equivalent to placements on the
  168. * Super Nintendo controller.
  169. * L2/R2/L3/R3 buttons correspond to the PS1 DualShock.
  170. * Also used as id values for RETRO_DEVICE_INDEX_ANALOG_BUTTON */
  171. #define RETRO_DEVICE_ID_JOYPAD_B 0
  172. #define RETRO_DEVICE_ID_JOYPAD_Y 1
  173. #define RETRO_DEVICE_ID_JOYPAD_SELECT 2
  174. #define RETRO_DEVICE_ID_JOYPAD_START 3
  175. #define RETRO_DEVICE_ID_JOYPAD_UP 4
  176. #define RETRO_DEVICE_ID_JOYPAD_DOWN 5
  177. #define RETRO_DEVICE_ID_JOYPAD_LEFT 6
  178. #define RETRO_DEVICE_ID_JOYPAD_RIGHT 7
  179. #define RETRO_DEVICE_ID_JOYPAD_A 8
  180. #define RETRO_DEVICE_ID_JOYPAD_X 9
  181. #define RETRO_DEVICE_ID_JOYPAD_L 10
  182. #define RETRO_DEVICE_ID_JOYPAD_R 11
  183. #define RETRO_DEVICE_ID_JOYPAD_L2 12
  184. #define RETRO_DEVICE_ID_JOYPAD_R2 13
  185. #define RETRO_DEVICE_ID_JOYPAD_L3 14
  186. #define RETRO_DEVICE_ID_JOYPAD_R3 15
  187. #define RETRO_DEVICE_ID_JOYPAD_MASK 256
  188. /* Index / Id values for ANALOG device. */
  189. #define RETRO_DEVICE_INDEX_ANALOG_LEFT 0
  190. #define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1
  191. #define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2
  192. #define RETRO_DEVICE_ID_ANALOG_X 0
  193. #define RETRO_DEVICE_ID_ANALOG_Y 1
  194. /* Id values for MOUSE. */
  195. #define RETRO_DEVICE_ID_MOUSE_X 0
  196. #define RETRO_DEVICE_ID_MOUSE_Y 1
  197. #define RETRO_DEVICE_ID_MOUSE_LEFT 2
  198. #define RETRO_DEVICE_ID_MOUSE_RIGHT 3
  199. #define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
  200. #define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
  201. #define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
  202. #define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7
  203. #define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8
  204. #define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9
  205. #define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10
  206. /* Id values for LIGHTGUN. */
  207. #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/
  208. #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/
  209. #define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/
  210. #define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2
  211. #define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/
  212. #define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3
  213. #define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4
  214. #define RETRO_DEVICE_ID_LIGHTGUN_START 6
  215. #define RETRO_DEVICE_ID_LIGHTGUN_SELECT 7
  216. #define RETRO_DEVICE_ID_LIGHTGUN_AUX_C 8
  217. #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP 9
  218. #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10
  219. #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11
  220. #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12
  221. /* deprecated */
  222. #define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/
  223. #define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/
  224. #define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/
  225. #define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/
  226. #define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/
  227. /* Id values for POINTER. */
  228. #define RETRO_DEVICE_ID_POINTER_X 0
  229. #define RETRO_DEVICE_ID_POINTER_Y 1
  230. #define RETRO_DEVICE_ID_POINTER_PRESSED 2
  231. #define RETRO_DEVICE_ID_POINTER_COUNT 3
  232. /* Returned from retro_get_region(). */
  233. #define RETRO_REGION_NTSC 0
  234. #define RETRO_REGION_PAL 1
  235. /* Id values for LANGUAGE */
  236. enum retro_language
  237. {
  238. RETRO_LANGUAGE_ENGLISH = 0,
  239. RETRO_LANGUAGE_JAPANESE = 1,
  240. RETRO_LANGUAGE_FRENCH = 2,
  241. RETRO_LANGUAGE_SPANISH = 3,
  242. RETRO_LANGUAGE_GERMAN = 4,
  243. RETRO_LANGUAGE_ITALIAN = 5,
  244. RETRO_LANGUAGE_DUTCH = 6,
  245. RETRO_LANGUAGE_PORTUGUESE_BRAZIL = 7,
  246. RETRO_LANGUAGE_PORTUGUESE_PORTUGAL = 8,
  247. RETRO_LANGUAGE_RUSSIAN = 9,
  248. RETRO_LANGUAGE_KOREAN = 10,
  249. RETRO_LANGUAGE_CHINESE_TRADITIONAL = 11,
  250. RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12,
  251. RETRO_LANGUAGE_ESPERANTO = 13,
  252. RETRO_LANGUAGE_POLISH = 14,
  253. RETRO_LANGUAGE_VIETNAMESE = 15,
  254. RETRO_LANGUAGE_ARABIC = 16,
  255. RETRO_LANGUAGE_GREEK = 17,
  256. RETRO_LANGUAGE_TURKISH = 18,
  257. RETRO_LANGUAGE_SLOVAK = 19,
  258. RETRO_LANGUAGE_PERSIAN = 20,
  259. RETRO_LANGUAGE_HEBREW = 21,
  260. RETRO_LANGUAGE_ASTURIAN = 22,
  261. RETRO_LANGUAGE_FINNISH = 23,
  262. RETRO_LANGUAGE_INDONESIAN = 24,
  263. RETRO_LANGUAGE_SWEDISH = 25,
  264. RETRO_LANGUAGE_UKRAINIAN = 26,
  265. RETRO_LANGUAGE_CZECH = 27,
  266. RETRO_LANGUAGE_CATALAN_VALENCIA = 28,
  267. RETRO_LANGUAGE_CATALAN = 29,
  268. RETRO_LANGUAGE_BRITISH_ENGLISH = 30,
  269. RETRO_LANGUAGE_HUNGARIAN = 31,
  270. RETRO_LANGUAGE_LAST,
  271. /* Ensure sizeof(enum) == sizeof(int) */
  272. RETRO_LANGUAGE_DUMMY = INT_MAX
  273. };
  274. /* Passed to retro_get_memory_data/size().
  275. * If the memory type doesn't apply to the
  276. * implementation NULL/0 can be returned.
  277. */
  278. #define RETRO_MEMORY_MASK 0xff
  279. /* Regular save RAM. This RAM is usually found on a game cartridge,
  280. * backed up by a battery.
  281. * If save game data is too complex for a single memory buffer,
  282. * the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment
  283. * callback can be used. */
  284. #define RETRO_MEMORY_SAVE_RAM 0
  285. /* Some games have a built-in clock to keep track of time.
  286. * This memory is usually just a couple of bytes to keep track of time.
  287. */
  288. #define RETRO_MEMORY_RTC 1
  289. /* System ram lets a frontend peek into a game systems main RAM. */
  290. #define RETRO_MEMORY_SYSTEM_RAM 2
  291. /* Video ram lets a frontend peek into a game systems video RAM (VRAM). */
  292. #define RETRO_MEMORY_VIDEO_RAM 3
  293. /* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */
  294. enum retro_key
  295. {
  296. RETROK_UNKNOWN = 0,
  297. RETROK_FIRST = 0,
  298. RETROK_BACKSPACE = 8,
  299. RETROK_TAB = 9,
  300. RETROK_CLEAR = 12,
  301. RETROK_RETURN = 13,
  302. RETROK_PAUSE = 19,
  303. RETROK_ESCAPE = 27,
  304. RETROK_SPACE = 32,
  305. RETROK_EXCLAIM = 33,
  306. RETROK_QUOTEDBL = 34,
  307. RETROK_HASH = 35,
  308. RETROK_DOLLAR = 36,
  309. RETROK_AMPERSAND = 38,
  310. RETROK_QUOTE = 39,
  311. RETROK_LEFTPAREN = 40,
  312. RETROK_RIGHTPAREN = 41,
  313. RETROK_ASTERISK = 42,
  314. RETROK_PLUS = 43,
  315. RETROK_COMMA = 44,
  316. RETROK_MINUS = 45,
  317. RETROK_PERIOD = 46,
  318. RETROK_SLASH = 47,
  319. RETROK_0 = 48,
  320. RETROK_1 = 49,
  321. RETROK_2 = 50,
  322. RETROK_3 = 51,
  323. RETROK_4 = 52,
  324. RETROK_5 = 53,
  325. RETROK_6 = 54,
  326. RETROK_7 = 55,
  327. RETROK_8 = 56,
  328. RETROK_9 = 57,
  329. RETROK_COLON = 58,
  330. RETROK_SEMICOLON = 59,
  331. RETROK_LESS = 60,
  332. RETROK_EQUALS = 61,
  333. RETROK_GREATER = 62,
  334. RETROK_QUESTION = 63,
  335. RETROK_AT = 64,
  336. RETROK_LEFTBRACKET = 91,
  337. RETROK_BACKSLASH = 92,
  338. RETROK_RIGHTBRACKET = 93,
  339. RETROK_CARET = 94,
  340. RETROK_UNDERSCORE = 95,
  341. RETROK_BACKQUOTE = 96,
  342. RETROK_a = 97,
  343. RETROK_b = 98,
  344. RETROK_c = 99,
  345. RETROK_d = 100,
  346. RETROK_e = 101,
  347. RETROK_f = 102,
  348. RETROK_g = 103,
  349. RETROK_h = 104,
  350. RETROK_i = 105,
  351. RETROK_j = 106,
  352. RETROK_k = 107,
  353. RETROK_l = 108,
  354. RETROK_m = 109,
  355. RETROK_n = 110,
  356. RETROK_o = 111,
  357. RETROK_p = 112,
  358. RETROK_q = 113,
  359. RETROK_r = 114,
  360. RETROK_s = 115,
  361. RETROK_t = 116,
  362. RETROK_u = 117,
  363. RETROK_v = 118,
  364. RETROK_w = 119,
  365. RETROK_x = 120,
  366. RETROK_y = 121,
  367. RETROK_z = 122,
  368. RETROK_LEFTBRACE = 123,
  369. RETROK_BAR = 124,
  370. RETROK_RIGHTBRACE = 125,
  371. RETROK_TILDE = 126,
  372. RETROK_DELETE = 127,
  373. RETROK_KP0 = 256,
  374. RETROK_KP1 = 257,
  375. RETROK_KP2 = 258,
  376. RETROK_KP3 = 259,
  377. RETROK_KP4 = 260,
  378. RETROK_KP5 = 261,
  379. RETROK_KP6 = 262,
  380. RETROK_KP7 = 263,
  381. RETROK_KP8 = 264,
  382. RETROK_KP9 = 265,
  383. RETROK_KP_PERIOD = 266,
  384. RETROK_KP_DIVIDE = 267,
  385. RETROK_KP_MULTIPLY = 268,
  386. RETROK_KP_MINUS = 269,
  387. RETROK_KP_PLUS = 270,
  388. RETROK_KP_ENTER = 271,
  389. RETROK_KP_EQUALS = 272,
  390. RETROK_UP = 273,
  391. RETROK_DOWN = 274,
  392. RETROK_RIGHT = 275,
  393. RETROK_LEFT = 276,
  394. RETROK_INSERT = 277,
  395. RETROK_HOME = 278,
  396. RETROK_END = 279,
  397. RETROK_PAGEUP = 280,
  398. RETROK_PAGEDOWN = 281,
  399. RETROK_F1 = 282,
  400. RETROK_F2 = 283,
  401. RETROK_F3 = 284,
  402. RETROK_F4 = 285,
  403. RETROK_F5 = 286,
  404. RETROK_F6 = 287,
  405. RETROK_F7 = 288,
  406. RETROK_F8 = 289,
  407. RETROK_F9 = 290,
  408. RETROK_F10 = 291,
  409. RETROK_F11 = 292,
  410. RETROK_F12 = 293,
  411. RETROK_F13 = 294,
  412. RETROK_F14 = 295,
  413. RETROK_F15 = 296,
  414. RETROK_NUMLOCK = 300,
  415. RETROK_CAPSLOCK = 301,
  416. RETROK_SCROLLOCK = 302,
  417. RETROK_RSHIFT = 303,
  418. RETROK_LSHIFT = 304,
  419. RETROK_RCTRL = 305,
  420. RETROK_LCTRL = 306,
  421. RETROK_RALT = 307,
  422. RETROK_LALT = 308,
  423. RETROK_RMETA = 309,
  424. RETROK_LMETA = 310,
  425. RETROK_LSUPER = 311,
  426. RETROK_RSUPER = 312,
  427. RETROK_MODE = 313,
  428. RETROK_COMPOSE = 314,
  429. RETROK_HELP = 315,
  430. RETROK_PRINT = 316,
  431. RETROK_SYSREQ = 317,
  432. RETROK_BREAK = 318,
  433. RETROK_MENU = 319,
  434. RETROK_POWER = 320,
  435. RETROK_EURO = 321,
  436. RETROK_UNDO = 322,
  437. RETROK_OEM_102 = 323,
  438. RETROK_LAST,
  439. RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
  440. };
  441. enum retro_mod
  442. {
  443. RETROKMOD_NONE = 0x0000,
  444. RETROKMOD_SHIFT = 0x01,
  445. RETROKMOD_CTRL = 0x02,
  446. RETROKMOD_ALT = 0x04,
  447. RETROKMOD_META = 0x08,
  448. RETROKMOD_NUMLOCK = 0x10,
  449. RETROKMOD_CAPSLOCK = 0x20,
  450. RETROKMOD_SCROLLOCK = 0x40,
  451. RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
  452. };
  453. /* If set, this call is not part of the public libretro API yet. It can
  454. * change or be removed at any time. */
  455. #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000
  456. /* Environment callback to be used internally in frontend. */
  457. #define RETRO_ENVIRONMENT_PRIVATE 0x20000
  458. /* Environment commands. */
  459. #define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * --
  460. * Sets screen rotation of graphics.
  461. * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180,
  462. * 270 degrees counter-clockwise respectively.
  463. */
  464. #define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * --
  465. * NOTE: As of 2019 this callback is considered deprecated in favor of
  466. * using core options to manage overscan in a more nuanced, core-specific way.
  467. *
  468. * Boolean value whether or not the implementation should use overscan,
  469. * or crop away overscan.
  470. */
  471. #define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * --
  472. * Boolean value whether or not frontend supports frame duping,
  473. * passing NULL to video frame callback.
  474. */
  475. /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),
  476. * and reserved to avoid possible ABI clash.
  477. */
  478. #define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * --
  479. * Sets a message to be displayed in implementation-specific manner
  480. * for a certain amount of 'frames'.
  481. * Should not be used for trivial messages, which should simply be
  482. * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
  483. * fallback, stderr).
  484. */
  485. #define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) --
  486. * Requests the frontend to shutdown.
  487. * Should only be used if game has a specific
  488. * way to shutdown the game from a menu item or similar.
  489. */
  490. #define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8
  491. /* const unsigned * --
  492. * Gives a hint to the frontend how demanding this implementation
  493. * is on a system. E.g. reporting a level of 2 means
  494. * this implementation should run decently on all frontends
  495. * of level 2 and up.
  496. *
  497. * It can be used by the frontend to potentially warn
  498. * about too demanding implementations.
  499. *
  500. * The levels are "floating".
  501. *
  502. * This function can be called on a per-game basis,
  503. * as certain games an implementation can play might be
  504. * particularly demanding.
  505. * If called, it should be called in retro_load_game().
  506. */
  507. #define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9
  508. /* const char ** --
  509. * Returns the "system" directory of the frontend.
  510. * This directory can be used to store system specific
  511. * content such as BIOSes, configuration data, etc.
  512. * The returned value can be NULL.
  513. * If so, no such directory is defined,
  514. * and it's up to the implementation to find a suitable directory.
  515. *
  516. * NOTE: Some cores used this folder also for "save" data such as
  517. * memory cards, etc, for lack of a better place to put it.
  518. * This is now discouraged, and if possible, cores should try to
  519. * use the new GET_SAVE_DIRECTORY.
  520. */
  521. #define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
  522. /* const enum retro_pixel_format * --
  523. * Sets the internal pixel format used by the implementation.
  524. * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.
  525. * This pixel format however, is deprecated (see enum retro_pixel_format).
  526. * If the call returns false, the frontend does not support this pixel
  527. * format.
  528. *
  529. * This function should be called inside retro_load_game() or
  530. * retro_get_system_av_info().
  531. */
  532. #define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11
  533. /* const struct retro_input_descriptor * --
  534. * Sets an array of retro_input_descriptors.
  535. * It is up to the frontend to present this in a usable way.
  536. * The array is terminated by retro_input_descriptor::description
  537. * being set to NULL.
  538. * This function can be called at any time, but it is recommended
  539. * to call it as early as possible.
  540. */
  541. #define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12
  542. /* const struct retro_keyboard_callback * --
  543. * Sets a callback function used to notify core about keyboard events.
  544. */
  545. #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13
  546. /* const struct retro_disk_control_callback * --
  547. * Sets an interface which frontend can use to eject and insert
  548. * disk images.
  549. * This is used for games which consist of multiple images and
  550. * must be manually swapped out by the user (e.g. PSX).
  551. */
  552. #define RETRO_ENVIRONMENT_SET_HW_RENDER 14
  553. /* struct retro_hw_render_callback * --
  554. * Sets an interface to let a libretro core render with
  555. * hardware acceleration.
  556. * Should be called in retro_load_game().
  557. * If successful, libretro cores will be able to render to a
  558. * frontend-provided framebuffer.
  559. * The size of this framebuffer will be at least as large as
  560. * max_width/max_height provided in get_av_info().
  561. * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or
  562. * NULL to retro_video_refresh_t.
  563. */
  564. #define RETRO_ENVIRONMENT_GET_VARIABLE 15
  565. /* struct retro_variable * --
  566. * Interface to acquire user-defined information from environment
  567. * that cannot feasibly be supported in a multi-system way.
  568. * 'key' should be set to a key which has already been set by
  569. * SET_VARIABLES.
  570. * 'data' will be set to a value or NULL.
  571. */
  572. #define RETRO_ENVIRONMENT_SET_VARIABLES 16
  573. /* const struct retro_variable * --
  574. * Allows an implementation to signal the environment
  575. * which variables it might want to check for later using
  576. * GET_VARIABLE.
  577. * This allows the frontend to present these variables to
  578. * a user dynamically.
  579. * This should be called the first time as early as
  580. * possible (ideally in retro_set_environment).
  581. * Afterward it may be called again for the core to communicate
  582. * updated options to the frontend, but the number of core
  583. * options must not change from the number in the initial call.
  584. *
  585. * 'data' points to an array of retro_variable structs
  586. * terminated by a { NULL, NULL } element.
  587. * retro_variable::key should be namespaced to not collide
  588. * with other implementations' keys. E.g. A core called
  589. * 'foo' should use keys named as 'foo_option'.
  590. * retro_variable::value should contain a human readable
  591. * description of the key as well as a '|' delimited list
  592. * of expected values.
  593. *
  594. * The number of possible options should be very limited,
  595. * i.e. it should be feasible to cycle through options
  596. * without a keyboard.
  597. *
  598. * First entry should be treated as a default.
  599. *
  600. * Example entry:
  601. * { "foo_option", "Speed hack coprocessor X; false|true" }
  602. *
  603. * Text before first ';' is description. This ';' must be
  604. * followed by a space, and followed by a list of possible
  605. * values split up with '|'.
  606. *
  607. * Only strings are operated on. The possible values will
  608. * generally be displayed and stored as-is by the frontend.
  609. */
  610. #define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17
  611. /* bool * --
  612. * Result is set to true if some variables are updated by
  613. * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.
  614. * Variables should be queried with GET_VARIABLE.
  615. */
  616. #define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18
  617. /* const bool * --
  618. * If true, the libretro implementation supports calls to
  619. * retro_load_game() with NULL as argument.
  620. * Used by cores which can run without particular game data.
  621. * This should be called within retro_set_environment() only.
  622. */
  623. #define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19
  624. /* const char ** --
  625. * Retrieves the absolute path from where this libretro
  626. * implementation was loaded.
  627. * NULL is returned if the libretro was loaded statically
  628. * (i.e. linked statically to frontend), or if the path cannot be
  629. * determined.
  630. * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can
  631. * be loaded without ugly hacks.
  632. */
  633. /* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.
  634. * It was not used by any known core at the time,
  635. * and was removed from the API. */
  636. #define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
  637. /* const struct retro_frame_time_callback * --
  638. * Lets the core know how much time has passed since last
  639. * invocation of retro_run().
  640. * The frontend can tamper with the timing to fake fast-forward,
  641. * slow-motion, frame stepping, etc.
  642. * In this case the delta time will use the reference value
  643. * in frame_time_callback..
  644. */
  645. #define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22
  646. /* const struct retro_audio_callback * --
  647. * Sets an interface which is used to notify a libretro core about audio
  648. * being available for writing.
  649. * The callback can be called from any thread, so a core using this must
  650. * have a thread safe audio implementation.
  651. * It is intended for games where audio and video are completely
  652. * asynchronous and audio can be generated on the fly.
  653. * This interface is not recommended for use with emulators which have
  654. * highly synchronous audio.
  655. *
  656. * The callback only notifies about writability; the libretro core still
  657. * has to call the normal audio callbacks
  658. * to write audio. The audio callbacks must be called from within the
  659. * notification callback.
  660. * The amount of audio data to write is up to the implementation.
  661. * Generally, the audio callback will be called continously in a loop.
  662. *
  663. * Due to thread safety guarantees and lack of sync between audio and
  664. * video, a frontend can selectively disallow this interface based on
  665. * internal configuration. A core using this interface must also
  666. * implement the "normal" audio interface.
  667. *
  668. * A libretro core using SET_AUDIO_CALLBACK should also make use of
  669. * SET_FRAME_TIME_CALLBACK.
  670. */
  671. #define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23
  672. /* struct retro_rumble_interface * --
  673. * Gets an interface which is used by a libretro core to set
  674. * state of rumble motors in controllers.
  675. * A strong and weak motor is supported, and they can be
  676. * controlled indepedently.
  677. * Should be called from either retro_init() or retro_load_game().
  678. * Should not be called from retro_set_environment().
  679. * Returns false if rumble functionality is unavailable.
  680. */
  681. #define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24
  682. /* uint64_t * --
  683. * Gets a bitmask telling which device type are expected to be
  684. * handled properly in a call to retro_input_state_t.
  685. * Devices which are not handled or recognized always return
  686. * 0 in retro_input_state_t.
  687. * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).
  688. * Should only be called in retro_run().
  689. */
  690. #define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  691. /* struct retro_sensor_interface * --
  692. * Gets access to the sensor interface.
  693. * The purpose of this interface is to allow
  694. * setting state related to sensors such as polling rate,
  695. * enabling/disable it entirely, etc.
  696. * Reading sensor state is done via the normal
  697. * input_state_callback API.
  698. */
  699. #define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  700. /* struct retro_camera_callback * --
  701. * Gets an interface to a video camera driver.
  702. * A libretro core can use this interface to get access to a
  703. * video camera.
  704. * New video frames are delivered in a callback in same
  705. * thread as retro_run().
  706. *
  707. * GET_CAMERA_INTERFACE should be called in retro_load_game().
  708. *
  709. * Depending on the camera implementation used, camera frames
  710. * will be delivered as a raw framebuffer,
  711. * or as an OpenGL texture directly.
  712. *
  713. * The core has to tell the frontend here which types of
  714. * buffers can be handled properly.
  715. * An OpenGL texture can only be handled when using a
  716. * libretro GL core (SET_HW_RENDER).
  717. * It is recommended to use a libretro GL core when
  718. * using camera interface.
  719. *
  720. * The camera is not started automatically. The retrieved start/stop
  721. * functions must be used to explicitly
  722. * start and stop the camera driver.
  723. */
  724. #define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27
  725. /* struct retro_log_callback * --
  726. * Gets an interface for logging. This is useful for
  727. * logging in a cross-platform way
  728. * as certain platforms cannot use stderr for logging.
  729. * It also allows the frontend to
  730. * show logging information in a more suitable way.
  731. * If this interface is not used, libretro cores should
  732. * log to stderr as desired.
  733. */
  734. #define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28
  735. /* struct retro_perf_callback * --
  736. * Gets an interface for performance counters. This is useful
  737. * for performance logging in a cross-platform way and for detecting
  738. * architecture-specific features, such as SIMD support.
  739. */
  740. #define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29
  741. /* struct retro_location_callback * --
  742. * Gets access to the location interface.
  743. * The purpose of this interface is to be able to retrieve
  744. * location-based information from the host device,
  745. * such as current latitude / longitude.
  746. */
  747. #define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */
  748. #define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30
  749. /* const char ** --
  750. * Returns the "core assets" directory of the frontend.
  751. * This directory can be used to store specific assets that the
  752. * core relies upon, such as art assets,
  753. * input data, etc etc.
  754. * The returned value can be NULL.
  755. * If so, no such directory is defined,
  756. * and it's up to the implementation to find a suitable directory.
  757. */
  758. #define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31
  759. /* const char ** --
  760. * Returns the "save" directory of the frontend, unless there is no
  761. * save directory available. The save directory should be used to
  762. * store SRAM, memory cards, high scores, etc, if the libretro core
  763. * cannot use the regular memory interface (retro_get_memory_data()).
  764. *
  765. * If the frontend cannot designate a save directory, it will return
  766. * NULL to indicate that the core should attempt to operate without a
  767. * save directory set.
  768. *
  769. * NOTE: early libretro cores used the system directory for save
  770. * files. Cores that need to be backwards-compatible can still check
  771. * GET_SYSTEM_DIRECTORY.
  772. */
  773. #define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32
  774. /* const struct retro_system_av_info * --
  775. * Sets a new av_info structure. This can only be called from
  776. * within retro_run().
  777. * This should *only* be used if the core is completely altering the
  778. * internal resolutions, aspect ratios, timings, sampling rate, etc.
  779. * Calling this can require a full reinitialization of video/audio
  780. * drivers in the frontend,
  781. *
  782. * so it is important to call it very sparingly, and usually only with
  783. * the users explicit consent.
  784. * An eventual driver reinitialize will happen so that video and
  785. * audio callbacks
  786. * happening after this call within the same retro_run() call will
  787. * target the newly initialized driver.
  788. *
  789. * This callback makes it possible to support configurable resolutions
  790. * in games, which can be useful to
  791. * avoid setting the "worst case" in max_width/max_height.
  792. *
  793. * ***HIGHLY RECOMMENDED*** Do not call this callback every time
  794. * resolution changes in an emulator core if it's
  795. * expected to be a temporary change, for the reasons of possible
  796. * driver reinitialization.
  797. * This call is not a free pass for not trying to provide
  798. * correct values in retro_get_system_av_info(). If you need to change
  799. * things like aspect ratio or nominal width/height,
  800. * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant
  801. * of SET_SYSTEM_AV_INFO.
  802. *
  803. * If this returns false, the frontend does not acknowledge a
  804. * changed av_info struct.
  805. */
  806. #define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33
  807. /* const struct retro_get_proc_address_interface * --
  808. * Allows a libretro core to announce support for the
  809. * get_proc_address() interface.
  810. * This interface allows for a standard way to extend libretro where
  811. * use of environment calls are too indirect,
  812. * e.g. for cases where the frontend wants to call directly into the core.
  813. *
  814. * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK
  815. * **MUST** be called from within retro_set_environment().
  816. */
  817. #define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34
  818. /* const struct retro_subsystem_info * --
  819. * This environment call introduces the concept of libretro "subsystems".
  820. * A subsystem is a variant of a libretro core which supports
  821. * different kinds of games.
  822. * The purpose of this is to support e.g. emulators which might
  823. * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo.
  824. * It can also be used to pick among subsystems in an explicit way
  825. * if the libretro implementation is a multi-system emulator itself.
  826. *
  827. * Loading a game via a subsystem is done with retro_load_game_special(),
  828. * and this environment call allows a libretro core to expose which
  829. * subsystems are supported for use with retro_load_game_special().
  830. * A core passes an array of retro_game_special_info which is terminated
  831. * with a zeroed out retro_game_special_info struct.
  832. *
  833. * If a core wants to use this functionality, SET_SUBSYSTEM_INFO
  834. * **MUST** be called from within retro_set_environment().
  835. */
  836. #define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35
  837. /* const struct retro_controller_info * --
  838. * This environment call lets a libretro core tell the frontend
  839. * which controller subclasses are recognized in calls to
  840. * retro_set_controller_port_device().
  841. *
  842. * Some emulators such as Super Nintendo support multiple lightgun
  843. * types which must be specifically selected from. It is therefore
  844. * sometimes necessary for a frontend to be able to tell the core
  845. * about a special kind of input device which is not specifcally
  846. * provided by the Libretro API.
  847. *
  848. * In order for a frontend to understand the workings of those devices,
  849. * they must be defined as a specialized subclass of the generic device
  850. * types already defined in the libretro API.
  851. *
  852. * The core must pass an array of const struct retro_controller_info which
  853. * is terminated with a blanked out struct. Each element of the
  854. * retro_controller_info struct corresponds to the ascending port index
  855. * that is passed to retro_set_controller_port_device() when that function
  856. * is called to indicate to the core that the frontend has changed the
  857. * active device subclass. SEE ALSO: retro_set_controller_port_device()
  858. *
  859. * The ascending input port indexes provided by the core in the struct
  860. * are generally presented by frontends as ascending User # or Player #,
  861. * such as Player 1, Player 2, Player 3, etc. Which device subclasses are
  862. * supported can vary per input port.
  863. *
  864. * The first inner element of each entry in the retro_controller_info array
  865. * is a retro_controller_description struct that specifies the names and
  866. * codes of all device subclasses that are available for the corresponding
  867. * User or Player, beginning with the generic Libretro device that the
  868. * subclasses are derived from. The second inner element of each entry is the
  869. * total number of subclasses that are listed in the retro_controller_description.
  870. *
  871. * NOTE: Even if special device types are set in the libretro core,
  872. * libretro should only poll input based on the base input device types.
  873. */
  874. #define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  875. /* const struct retro_memory_map * --
  876. * This environment call lets a libretro core tell the frontend
  877. * about the memory maps this core emulates.
  878. * This can be used to implement, for example, cheats in a core-agnostic way.
  879. *
  880. * Should only be used by emulators; it doesn't make much sense for
  881. * anything else.
  882. * It is recommended to expose all relevant pointers through
  883. * retro_get_memory_* as well.
  884. */
  885. #define RETRO_ENVIRONMENT_SET_GEOMETRY 37
  886. /* const struct retro_game_geometry * --
  887. * This environment call is similar to SET_SYSTEM_AV_INFO for changing
  888. * video parameters, but provides a guarantee that drivers will not be
  889. * reinitialized.
  890. * This can only be called from within retro_run().
  891. *
  892. * The purpose of this call is to allow a core to alter nominal
  893. * width/heights as well as aspect ratios on-the-fly, which can be
  894. * useful for some emulators to change in run-time.
  895. *
  896. * max_width/max_height arguments are ignored and cannot be changed
  897. * with this call as this could potentially require a reinitialization or a
  898. * non-constant time operation.
  899. * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required.
  900. *
  901. * A frontend must guarantee that this environment call completes in
  902. * constant time.
  903. */
  904. #define RETRO_ENVIRONMENT_GET_USERNAME 38
  905. /* const char **
  906. * Returns the specified username of the frontend, if specified by the user.
  907. * This username can be used as a nickname for a core that has online facilities
  908. * or any other mode where personalization of the user is desirable.
  909. * The returned value can be NULL.
  910. * If this environ callback is used by a core that requires a valid username,
  911. * a default username should be specified by the core.
  912. */
  913. #define RETRO_ENVIRONMENT_GET_LANGUAGE 39
  914. /* unsigned * --
  915. * Returns the specified language of the frontend, if specified by the user.
  916. * It can be used by the core for localization purposes.
  917. */
  918. #define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  919. /* struct retro_framebuffer * --
  920. * Returns a preallocated framebuffer which the core can use for rendering
  921. * the frame into when not using SET_HW_RENDER.
  922. * The framebuffer returned from this call must not be used
  923. * after the current call to retro_run() returns.
  924. *
  925. * The goal of this call is to allow zero-copy behavior where a core
  926. * can render directly into video memory, avoiding extra bandwidth cost by copying
  927. * memory from core to video memory.
  928. *
  929. * If this call succeeds and the core renders into it,
  930. * the framebuffer pointer and pitch can be passed to retro_video_refresh_t.
  931. * If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used,
  932. * the core must pass the exact
  933. * same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER;
  934. * i.e. passing a pointer which is offset from the
  935. * buffer is undefined. The width, height and pitch parameters
  936. * must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER.
  937. *
  938. * It is possible for a frontend to return a different pixel format
  939. * than the one used in SET_PIXEL_FORMAT. This can happen if the frontend
  940. * needs to perform conversion.
  941. *
  942. * It is still valid for a core to render to a different buffer
  943. * even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds.
  944. *
  945. * A frontend must make sure that the pointer obtained from this function is
  946. * writeable (and readable).
  947. */
  948. #define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  949. /* const struct retro_hw_render_interface ** --
  950. * Returns an API specific rendering interface for accessing API specific data.
  951. * Not all HW rendering APIs support or need this.
  952. * The contents of the returned pointer is specific to the rendering API
  953. * being used. See the various headers like libretro_vulkan.h, etc.
  954. *
  955. * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
  956. * Similarly, after context_destroyed callback returns,
  957. * the contents of the HW_RENDER_INTERFACE are invalidated.
  958. */
  959. #define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  960. /* const bool * --
  961. * If true, the libretro implementation supports achievements
  962. * either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS
  963. * or via retro_get_memory_data/retro_get_memory_size.
  964. *
  965. * This must be called before the first call to retro_run.
  966. */
  967. #define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  968. /* const struct retro_hw_render_context_negotiation_interface * --
  969. * Sets an interface which lets the libretro core negotiate with frontend how a context is created.
  970. * The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.
  971. * This interface will be used when the frontend is trying to create a HW rendering context,
  972. * so it will be used after SET_HW_RENDER, but before the context_reset callback.
  973. */
  974. #define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44
  975. /* uint64_t * --
  976. * Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't
  977. * recognize or support. Should be set in either retro_init or retro_load_game, but not both.
  978. */
  979. #define RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT (44 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  980. /* N/A (null) * --
  981. * The frontend will try to use a 'shared' hardware context (mostly applicable
  982. * to OpenGL) when a hardware context is being set up.
  983. *
  984. * Returns true if the frontend supports shared hardware contexts and false
  985. * if the frontend does not support shared hardware contexts.
  986. *
  987. * This will do nothing on its own until SET_HW_RENDER env callbacks are
  988. * being used.
  989. */
  990. #define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  991. /* struct retro_vfs_interface_info * --
  992. * Gets access to the VFS interface.
  993. * VFS presence needs to be queried prior to load_game or any
  994. * get_system/save/other_directory being called to let front end know
  995. * core supports VFS before it starts handing out paths.
  996. * It is recomended to do so in retro_set_environment
  997. */
  998. #define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  999. /* struct retro_led_interface * --
  1000. * Gets an interface which is used by a libretro core to set
  1001. * state of LEDs.
  1002. */
  1003. #define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1004. /* int * --
  1005. * Tells the core if the frontend wants audio or video.
  1006. * If disabled, the frontend will discard the audio or video,
  1007. * so the core may decide to skip generating a frame or generating audio.
  1008. * This is mainly used for increasing performance.
  1009. * Bit 0 (value 1): Enable Video
  1010. * Bit 1 (value 2): Enable Audio
  1011. * Bit 2 (value 4): Use Fast Savestates.
  1012. * Bit 3 (value 8): Hard Disable Audio
  1013. * Other bits are reserved for future use and will default to zero.
  1014. * If video is disabled:
  1015. * * The frontend wants the core to not generate any video,
  1016. * including presenting frames via hardware acceleration.
  1017. * * The frontend's video frame callback will do nothing.
  1018. * * After running the frame, the video output of the next frame should be
  1019. * no different than if video was enabled, and saving and loading state
  1020. * should have no issues.
  1021. * If audio is disabled:
  1022. * * The frontend wants the core to not generate any audio.
  1023. * * The frontend's audio callbacks will do nothing.
  1024. * * After running the frame, the audio output of the next frame should be
  1025. * no different than if audio was enabled, and saving and loading state
  1026. * should have no issues.
  1027. * Fast Savestates:
  1028. * * Guaranteed to be created by the same binary that will load them.
  1029. * * Will not be written to or read from the disk.
  1030. * * Suggest that the core assumes loading state will succeed.
  1031. * * Suggest that the core updates its memory buffers in-place if possible.
  1032. * * Suggest that the core skips clearing memory.
  1033. * * Suggest that the core skips resetting the system.
  1034. * * Suggest that the core may skip validation steps.
  1035. * Hard Disable Audio:
  1036. * * Used for a secondary core when running ahead.
  1037. * * Indicates that the frontend will never need audio from the core.
  1038. * * Suggests that the core may stop synthesizing audio, but this should not
  1039. * compromise emulation accuracy.
  1040. * * Audio output for the next frame does not matter, and the frontend will
  1041. * never need an accurate audio state in the future.
  1042. * * State will never be saved when using Hard Disable Audio.
  1043. */
  1044. #define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1045. /* struct retro_midi_interface ** --
  1046. * Returns a MIDI interface that can be used for raw data I/O.
  1047. */
  1048. #define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1049. /* bool * --
  1050. * Boolean value that indicates whether or not the frontend is in
  1051. * fastforwarding mode.
  1052. */
  1053. #define RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE (50 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1054. /* float * --
  1055. * Float value that lets us know what target refresh rate
  1056. * is curently in use by the frontend.
  1057. *
  1058. * The core can use the returned value to set an ideal
  1059. * refresh rate/framerate.
  1060. */
  1061. #define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS (51 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1062. /* bool * --
  1063. * Boolean value that indicates whether or not the frontend supports
  1064. * input bitmasks being returned by retro_input_state_t. The advantage
  1065. * of this is that retro_input_state_t has to be only called once to
  1066. * grab all button states instead of multiple times.
  1067. *
  1068. * If it returns true, you can pass RETRO_DEVICE_ID_JOYPAD_MASK as 'id'
  1069. * to retro_input_state_t (make sure 'device' is set to RETRO_DEVICE_JOYPAD).
  1070. * It will return a bitmask of all the digital buttons.
  1071. */
  1072. #define RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION 52
  1073. /* unsigned * --
  1074. * Unsigned value is the API version number of the core options
  1075. * interface supported by the frontend. If callback return false,
  1076. * API version is assumed to be 0.
  1077. *
  1078. * In legacy code, core options are set by passing an array of
  1079. * retro_variable structs to RETRO_ENVIRONMENT_SET_VARIABLES.
  1080. * This may be still be done regardless of the core options
  1081. * interface version.
  1082. *
  1083. * If version is >= 1 however, core options may instead be set by
  1084. * passing an array of retro_core_option_definition structs to
  1085. * RETRO_ENVIRONMENT_SET_CORE_OPTIONS, or a 2D array of
  1086. * retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
  1087. * This allows the core to additionally set option sublabel information
  1088. * and/or provide localisation support.
  1089. *
  1090. * If version is >= 2, core options may instead be set by passing
  1091. * a retro_core_options_v2 struct to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
  1092. * or an array of retro_core_options_v2 structs to
  1093. * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL. This allows the core
  1094. * to additionally set optional core option category information
  1095. * for frontends with core option category support.
  1096. */
  1097. #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 53
  1098. /* const struct retro_core_option_definition ** --
  1099. * Allows an implementation to signal the environment
  1100. * which variables it might want to check for later using
  1101. * GET_VARIABLE.
  1102. * This allows the frontend to present these variables to
  1103. * a user dynamically.
  1104. * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
  1105. * returns an API version of >= 1.
  1106. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
  1107. * This should be called the first time as early as
  1108. * possible (ideally in retro_set_environment).
  1109. * Afterwards it may be called again for the core to communicate
  1110. * updated options to the frontend, but the number of core
  1111. * options must not change from the number in the initial call.
  1112. *
  1113. * 'data' points to an array of retro_core_option_definition structs
  1114. * terminated by a { NULL, NULL, NULL, {{0}}, NULL } element.
  1115. * retro_core_option_definition::key should be namespaced to not collide
  1116. * with other implementations' keys. e.g. A core called
  1117. * 'foo' should use keys named as 'foo_option'.
  1118. * retro_core_option_definition::desc should contain a human readable
  1119. * description of the key.
  1120. * retro_core_option_definition::info should contain any additional human
  1121. * readable information text that a typical user may need to
  1122. * understand the functionality of the option.
  1123. * retro_core_option_definition::values is an array of retro_core_option_value
  1124. * structs terminated by a { NULL, NULL } element.
  1125. * > retro_core_option_definition::values[index].value is an expected option
  1126. * value.
  1127. * > retro_core_option_definition::values[index].label is a human readable
  1128. * label used when displaying the value on screen. If NULL,
  1129. * the value itself is used.
  1130. * retro_core_option_definition::default_value is the default core option
  1131. * setting. It must match one of the expected option values in the
  1132. * retro_core_option_definition::values array. If it does not, or the
  1133. * default value is NULL, the first entry in the
  1134. * retro_core_option_definition::values array is treated as the default.
  1135. *
  1136. * The number of possible option values should be very limited,
  1137. * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
  1138. * i.e. it should be feasible to cycle through options
  1139. * without a keyboard.
  1140. *
  1141. * Example entry:
  1142. * {
  1143. * "foo_option",
  1144. * "Speed hack coprocessor X",
  1145. * "Provides increased performance at the expense of reduced accuracy",
  1146. * {
  1147. * { "false", NULL },
  1148. * { "true", NULL },
  1149. * { "unstable", "Turbo (Unstable)" },
  1150. * { NULL, NULL },
  1151. * },
  1152. * "false"
  1153. * }
  1154. *
  1155. * Only strings are operated on. The possible values will
  1156. * generally be displayed and stored as-is by the frontend.
  1157. */
  1158. #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL 54
  1159. /* const struct retro_core_options_intl * --
  1160. * Allows an implementation to signal the environment
  1161. * which variables it might want to check for later using
  1162. * GET_VARIABLE.
  1163. * This allows the frontend to present these variables to
  1164. * a user dynamically.
  1165. * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
  1166. * returns an API version of >= 1.
  1167. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
  1168. * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
  1169. * This should be called the first time as early as
  1170. * possible (ideally in retro_set_environment).
  1171. * Afterwards it may be called again for the core to communicate
  1172. * updated options to the frontend, but the number of core
  1173. * options must not change from the number in the initial call.
  1174. *
  1175. * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS,
  1176. * with the addition of localisation support. The description of the
  1177. * RETRO_ENVIRONMENT_SET_CORE_OPTIONS callback should be consulted
  1178. * for further details.
  1179. *
  1180. * 'data' points to a retro_core_options_intl struct.
  1181. *
  1182. * retro_core_options_intl::us is a pointer to an array of
  1183. * retro_core_option_definition structs defining the US English
  1184. * core options implementation. It must point to a valid array.
  1185. *
  1186. * retro_core_options_intl::local is a pointer to an array of
  1187. * retro_core_option_definition structs defining core options for
  1188. * the current frontend language. It may be NULL (in which case
  1189. * retro_core_options_intl::us is used by the frontend). Any items
  1190. * missing from this array will be read from retro_core_options_intl::us
  1191. * instead.
  1192. *
  1193. * NOTE: Default core option values are always taken from the
  1194. * retro_core_options_intl::us array. Any default values in
  1195. * retro_core_options_intl::local array will be ignored.
  1196. */
  1197. #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY 55
  1198. /* struct retro_core_option_display * --
  1199. *
  1200. * Allows an implementation to signal the environment to show
  1201. * or hide a variable when displaying core options. This is
  1202. * considered a *suggestion*. The frontend is free to ignore
  1203. * this callback, and its implementation not considered mandatory.
  1204. *
  1205. * 'data' points to a retro_core_option_display struct
  1206. *
  1207. * retro_core_option_display::key is a variable identifier
  1208. * which has already been set by SET_VARIABLES/SET_CORE_OPTIONS.
  1209. *
  1210. * retro_core_option_display::visible is a boolean, specifying
  1211. * whether variable should be displayed
  1212. *
  1213. * Note that all core option variables will be set visible by
  1214. * default when calling SET_VARIABLES/SET_CORE_OPTIONS.
  1215. */
  1216. #define RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER 56
  1217. /* unsigned * --
  1218. *
  1219. * Allows an implementation to ask frontend preferred hardware
  1220. * context to use. Core should use this information to deal
  1221. * with what specific context to request with SET_HW_RENDER.
  1222. *
  1223. * 'data' points to an unsigned variable
  1224. */
  1225. #define RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION 57
  1226. /* unsigned * --
  1227. * Unsigned value is the API version number of the disk control
  1228. * interface supported by the frontend. If callback return false,
  1229. * API version is assumed to be 0.
  1230. *
  1231. * In legacy code, the disk control interface is defined by passing
  1232. * a struct of type retro_disk_control_callback to
  1233. * RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.
  1234. * This may be still be done regardless of the disk control
  1235. * interface version.
  1236. *
  1237. * If version is >= 1 however, the disk control interface may
  1238. * instead be defined by passing a struct of type
  1239. * retro_disk_control_ext_callback to
  1240. * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.
  1241. * This allows the core to provide additional information about
  1242. * disk images to the frontend and/or enables extra
  1243. * disk control functionality by the frontend.
  1244. */
  1245. #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE 58
  1246. /* const struct retro_disk_control_ext_callback * --
  1247. * Sets an interface which frontend can use to eject and insert
  1248. * disk images, and also obtain information about individual
  1249. * disk image files registered by the core.
  1250. * This is used for games which consist of multiple images and
  1251. * must be manually swapped out by the user (e.g. PSX, floppy disk
  1252. * based systems).
  1253. */
  1254. #define RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 59
  1255. /* unsigned * --
  1256. * Unsigned value is the API version number of the message
  1257. * interface supported by the frontend. If callback returns
  1258. * false, API version is assumed to be 0.
  1259. *
  1260. * In legacy code, messages may be displayed in an
  1261. * implementation-specific manner by passing a struct
  1262. * of type retro_message to RETRO_ENVIRONMENT_SET_MESSAGE.
  1263. * This may be still be done regardless of the message
  1264. * interface version.
  1265. *
  1266. * If version is >= 1 however, messages may instead be
  1267. * displayed by passing a struct of type retro_message_ext
  1268. * to RETRO_ENVIRONMENT_SET_MESSAGE_EXT. This allows the
  1269. * core to specify message logging level, priority and
  1270. * destination (OSD, logging interface or both).
  1271. */
  1272. #define RETRO_ENVIRONMENT_SET_MESSAGE_EXT 60
  1273. /* const struct retro_message_ext * --
  1274. * Sets a message to be displayed in an implementation-specific
  1275. * manner for a certain amount of 'frames'. Additionally allows
  1276. * the core to specify message logging level, priority and
  1277. * destination (OSD, logging interface or both).
  1278. * Should not be used for trivial messages, which should simply be
  1279. * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
  1280. * fallback, stderr).
  1281. */
  1282. #define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 61
  1283. /* unsigned * --
  1284. * Unsigned value is the number of active input devices
  1285. * provided by the frontend. This may change between
  1286. * frames, but will remain constant for the duration
  1287. * of each frame.
  1288. * If callback returns true, a core need not poll any
  1289. * input device with an index greater than or equal to
  1290. * the number of active devices.
  1291. * If callback returns false, the number of active input
  1292. * devices is unknown. In this case, all input devices
  1293. * should be considered active.
  1294. */
  1295. #define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 62
  1296. /* const struct retro_audio_buffer_status_callback * --
  1297. * Lets the core know the occupancy level of the frontend
  1298. * audio buffer. Can be used by a core to attempt frame
  1299. * skipping in order to avoid buffer under-runs.
  1300. * A core may pass NULL to disable buffer status reporting
  1301. * in the frontend.
  1302. */
  1303. #define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 63
  1304. /* const unsigned * --
  1305. * Sets minimum frontend audio latency in milliseconds.
  1306. * Resultant audio latency may be larger than set value,
  1307. * or smaller if a hardware limit is encountered. A frontend
  1308. * is expected to honour requests up to 512 ms.
  1309. *
  1310. * - If value is less than current frontend
  1311. * audio latency, callback has no effect
  1312. * - If value is zero, default frontend audio
  1313. * latency is set
  1314. *
  1315. * May be used by a core to increase audio latency and
  1316. * therefore decrease the probability of buffer under-runs
  1317. * (crackling) when performing 'intensive' operations.
  1318. * A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK
  1319. * to implement audio-buffer-based frame skipping may achieve
  1320. * optimal results by setting the audio latency to a 'high'
  1321. * (typically 6x or 8x) integer multiple of the expected
  1322. * frame time.
  1323. *
  1324. * WARNING: This can only be called from within retro_run().
  1325. * Calling this can require a full reinitialization of audio
  1326. * drivers in the frontend, so it is important to call it very
  1327. * sparingly, and usually only with the users explicit consent.
  1328. * An eventual driver reinitialize will happen so that audio
  1329. * callbacks happening after this call within the same retro_run()
  1330. * call will target the newly initialized driver.
  1331. */
  1332. #define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64
  1333. /* const struct retro_fastforwarding_override * --
  1334. * Used by a libretro core to override the current
  1335. * fastforwarding mode of the frontend.
  1336. * If NULL is passed to this function, the frontend
  1337. * will return true if fastforwarding override
  1338. * functionality is supported (no change in
  1339. * fastforwarding state will occur in this case).
  1340. */
  1341. #define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 65
  1342. /* const struct retro_system_content_info_override * --
  1343. * Allows an implementation to override 'global' content
  1344. * info parameters reported by retro_get_system_info().
  1345. * Overrides also affect subsystem content info parameters
  1346. * set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO.
  1347. * This function must be called inside retro_set_environment().
  1348. * If callback returns false, content info overrides
  1349. * are unsupported by the frontend, and will be ignored.
  1350. * If callback returns true, extended game info may be
  1351. * retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
  1352. * in retro_load_game() or retro_load_game_special().
  1353. *
  1354. * 'data' points to an array of retro_system_content_info_override
  1355. * structs terminated by a { NULL, false, false } element.
  1356. * If 'data' is NULL, no changes will be made to the frontend;
  1357. * a core may therefore pass NULL in order to test whether
  1358. * the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and
  1359. * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported
  1360. * by the frontend.
  1361. *
  1362. * For struct member descriptions, see the definition of
  1363. * struct retro_system_content_info_override.
  1364. *
  1365. * Example:
  1366. *
  1367. * - struct retro_system_info:
  1368. * {
  1369. * "My Core", // library_name
  1370. * "v1.0", // library_version
  1371. * "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions
  1372. * true, // need_fullpath
  1373. * false // block_extract
  1374. * }
  1375. *
  1376. * - Array of struct retro_system_content_info_override:
  1377. * {
  1378. * {
  1379. * "md|sms|gg", // extensions
  1380. * false, // need_fullpath
  1381. * true // persistent_data
  1382. * },
  1383. * {
  1384. * "sg", // extensions
  1385. * false, // need_fullpath
  1386. * false // persistent_data
  1387. * },
  1388. * { NULL, false, false }
  1389. * }
  1390. *
  1391. * Result:
  1392. * - Files of type m3u, cue, iso, chd will not be
  1393. * loaded by the frontend. Frontend will pass a
  1394. * valid path to the core, and core will handle
  1395. * loading internally
  1396. * - Files of type md, sms, gg will be loaded by
  1397. * the frontend. A valid memory buffer will be
  1398. * passed to the core. This memory buffer will
  1399. * remain valid until retro_deinit() returns
  1400. * - Files of type sg will be loaded by the frontend.
  1401. * A valid memory buffer will be passed to the core.
  1402. * This memory buffer will remain valid until
  1403. * retro_load_game() (or retro_load_game_special())
  1404. * returns
  1405. *
  1406. * NOTE: If an extension is listed multiple times in
  1407. * an array of retro_system_content_info_override
  1408. * structs, only the first instance will be registered
  1409. */
  1410. #define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 66
  1411. /* const struct retro_game_info_ext ** --
  1412. * Allows an implementation to fetch extended game
  1413. * information, providing additional content path
  1414. * and memory buffer status details.
  1415. * This function may only be called inside
  1416. * retro_load_game() or retro_load_game_special().
  1417. * If callback returns false, extended game information
  1418. * is unsupported by the frontend. In this case, only
  1419. * regular retro_game_info will be available.
  1420. * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed
  1421. * to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
  1422. * returns true.
  1423. *
  1424. * 'data' points to an array of retro_game_info_ext structs.
  1425. *
  1426. * For struct member descriptions, see the definition of
  1427. * struct retro_game_info_ext.
  1428. *
  1429. * - If function is called inside retro_load_game(),
  1430. * the retro_game_info_ext array is guaranteed to
  1431. * have a size of 1 - i.e. the returned pointer may
  1432. * be used to access directly the members of the
  1433. * first retro_game_info_ext struct, for example:
  1434. *
  1435. * struct retro_game_info_ext *game_info_ext;
  1436. * if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext))
  1437. * printf("Content Directory: %s\n", game_info_ext->dir);
  1438. *
  1439. * - If the function is called inside retro_load_game_special(),
  1440. * the retro_game_info_ext array is guaranteed to have a
  1441. * size equal to the num_info argument passed to
  1442. * retro_load_game_special()
  1443. */
  1444. #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 67
  1445. /* const struct retro_core_options_v2 * --
  1446. * Allows an implementation to signal the environment
  1447. * which variables it might want to check for later using
  1448. * GET_VARIABLE.
  1449. * This allows the frontend to present these variables to
  1450. * a user dynamically.
  1451. * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
  1452. * returns an API version of >= 2.
  1453. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
  1454. * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
  1455. * This should be called the first time as early as
  1456. * possible (ideally in retro_set_environment).
  1457. * Afterwards it may be called again for the core to communicate
  1458. * updated options to the frontend, but the number of core
  1459. * options must not change from the number in the initial call.
  1460. * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
  1461. * version of >= 2, this callback is guaranteed to succeed
  1462. * (i.e. callback return value does not indicate success)
  1463. * If callback returns true, frontend has core option category
  1464. * support.
  1465. * If callback returns false, frontend does not have core option
  1466. * category support.
  1467. *
  1468. * 'data' points to a retro_core_options_v2 struct, containing
  1469. * of two pointers:
  1470. * - retro_core_options_v2::categories is an array of
  1471. * retro_core_option_v2_category structs terminated by a
  1472. * { NULL, NULL, NULL } element. If retro_core_options_v2::categories
  1473. * is NULL, all core options will have no category and will be shown
  1474. * at the top level of the frontend core option interface. If frontend
  1475. * does not have core option category support, categories array will
  1476. * be ignored.
  1477. * - retro_core_options_v2::definitions is an array of
  1478. * retro_core_option_v2_definition structs terminated by a
  1479. * { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }
  1480. * element.
  1481. *
  1482. * >> retro_core_option_v2_category notes:
  1483. *
  1484. * - retro_core_option_v2_category::key should contain string
  1485. * that uniquely identifies the core option category. Valid
  1486. * key characters are [a-z, A-Z, 0-9, _, -]
  1487. * Namespace collisions with other implementations' category
  1488. * keys are permitted.
  1489. * - retro_core_option_v2_category::desc should contain a human
  1490. * readable description of the category key.
  1491. * - retro_core_option_v2_category::info should contain any
  1492. * additional human readable information text that a typical
  1493. * user may need to understand the nature of the core option
  1494. * category.
  1495. *
  1496. * Example entry:
  1497. * {
  1498. * "advanced_settings",
  1499. * "Advanced",
  1500. * "Options affecting low-level emulation performance and accuracy."
  1501. * }
  1502. *
  1503. * >> retro_core_option_v2_definition notes:
  1504. *
  1505. * - retro_core_option_v2_definition::key should be namespaced to not
  1506. * collide with other implementations' keys. e.g. A core called
  1507. * 'foo' should use keys named as 'foo_option'. Valid key characters
  1508. * are [a-z, A-Z, 0-9, _, -].
  1509. * - retro_core_option_v2_definition::desc should contain a human readable
  1510. * description of the key. Will be used when the frontend does not
  1511. * have core option category support. Examples: "Aspect Ratio" or
  1512. * "Video > Aspect Ratio".
  1513. * - retro_core_option_v2_definition::desc_categorized should contain a
  1514. * human readable description of the key, which will be used when
  1515. * frontend has core option category support. Example: "Aspect Ratio",
  1516. * where associated retro_core_option_v2_category::desc is "Video".
  1517. * If empty or NULL, the string specified by
  1518. * retro_core_option_v2_definition::desc will be used instead.
  1519. * retro_core_option_v2_definition::desc_categorized will be ignored
  1520. * if retro_core_option_v2_definition::category_key is empty or NULL.
  1521. * - retro_core_option_v2_definition::info should contain any additional
  1522. * human readable information text that a typical user may need to
  1523. * understand the functionality of the option.
  1524. * - retro_core_option_v2_definition::info_categorized should contain
  1525. * any additional human readable information text that a typical user
  1526. * may need to understand the functionality of the option, and will be
  1527. * used when frontend has core option category support. This is provided
  1528. * to accommodate the case where info text references an option by
  1529. * name/desc, and the desc/desc_categorized text for that option differ.
  1530. * If empty or NULL, the string specified by
  1531. * retro_core_option_v2_definition::info will be used instead.
  1532. * retro_core_option_v2_definition::info_categorized will be ignored
  1533. * if retro_core_option_v2_definition::category_key is empty or NULL.
  1534. * - retro_core_option_v2_definition::category_key should contain a
  1535. * category identifier (e.g. "video" or "audio") that will be
  1536. * assigned to the core option if frontend has core option category
  1537. * support. A categorized option will be shown in a subsection/
  1538. * submenu of the frontend core option interface. If key is empty
  1539. * or NULL, or if key does not match one of the
  1540. * retro_core_option_v2_category::key values in the associated
  1541. * retro_core_option_v2_category array, option will have no category
  1542. * and will be shown at the top level of the frontend core option
  1543. * interface.
  1544. * - retro_core_option_v2_definition::values is an array of
  1545. * retro_core_option_value structs terminated by a { NULL, NULL }
  1546. * element.
  1547. * --> retro_core_option_v2_definition::values[index].value is an
  1548. * expected option value.
  1549. * --> retro_core_option_v2_definition::values[index].label is a
  1550. * human readable label used when displaying the value on screen.
  1551. * If NULL, the value itself is used.
  1552. * - retro_core_option_v2_definition::default_value is the default
  1553. * core option setting. It must match one of the expected option
  1554. * values in the retro_core_option_v2_definition::values array. If
  1555. * it does not, or the default value is NULL, the first entry in the
  1556. * retro_core_option_v2_definition::values array is treated as the
  1557. * default.
  1558. *
  1559. * The number of possible option values should be very limited,
  1560. * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
  1561. * i.e. it should be feasible to cycle through options
  1562. * without a keyboard.
  1563. *
  1564. * Example entries:
  1565. *
  1566. * - Uncategorized:
  1567. *
  1568. * {
  1569. * "foo_option",
  1570. * "Speed hack coprocessor X",
  1571. * NULL,
  1572. * "Provides increased performance at the expense of reduced accuracy.",
  1573. * NULL,
  1574. * NULL,
  1575. * {
  1576. * { "false", NULL },
  1577. * { "true", NULL },
  1578. * { "unstable", "Turbo (Unstable)" },
  1579. * { NULL, NULL },
  1580. * },
  1581. * "false"
  1582. * }
  1583. *
  1584. * - Categorized:
  1585. *
  1586. * {
  1587. * "foo_option",
  1588. * "Advanced > Speed hack coprocessor X",
  1589. * "Speed hack coprocessor X",
  1590. * "Setting 'Advanced > Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
  1591. * "Setting 'Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
  1592. * "advanced_settings",
  1593. * {
  1594. * { "false", NULL },
  1595. * { "true", NULL },
  1596. * { "unstable", "Turbo (Unstable)" },
  1597. * { NULL, NULL },
  1598. * },
  1599. * "false"
  1600. * }
  1601. *
  1602. * Only strings are operated on. The possible values will
  1603. * generally be displayed and stored as-is by the frontend.
  1604. */
  1605. #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 68
  1606. /* const struct retro_core_options_v2_intl * --
  1607. * Allows an implementation to signal the environment
  1608. * which variables it might want to check for later using
  1609. * GET_VARIABLE.
  1610. * This allows the frontend to present these variables to
  1611. * a user dynamically.
  1612. * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
  1613. * returns an API version of >= 2.
  1614. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
  1615. * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
  1616. * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
  1617. * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2.
  1618. * This should be called the first time as early as
  1619. * possible (ideally in retro_set_environment).
  1620. * Afterwards it may be called again for the core to communicate
  1621. * updated options to the frontend, but the number of core
  1622. * options must not change from the number in the initial call.
  1623. * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
  1624. * version of >= 2, this callback is guaranteed to succeed
  1625. * (i.e. callback return value does not indicate success)
  1626. * If callback returns true, frontend has core option category
  1627. * support.
  1628. * If callback returns false, frontend does not have core option
  1629. * category support.
  1630. *
  1631. * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
  1632. * with the addition of localisation support. The description of the
  1633. * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 callback should be consulted
  1634. * for further details.
  1635. *
  1636. * 'data' points to a retro_core_options_v2_intl struct.
  1637. *
  1638. * - retro_core_options_v2_intl::us is a pointer to a
  1639. * retro_core_options_v2 struct defining the US English
  1640. * core options implementation. It must point to a valid struct.
  1641. *
  1642. * - retro_core_options_v2_intl::local is a pointer to a
  1643. * retro_core_options_v2 struct defining core options for
  1644. * the current frontend language. It may be NULL (in which case
  1645. * retro_core_options_v2_intl::us is used by the frontend). Any items
  1646. * missing from this struct will be read from
  1647. * retro_core_options_v2_intl::us instead.
  1648. *
  1649. * NOTE: Default core option values are always taken from the
  1650. * retro_core_options_v2_intl::us struct. Any default values in
  1651. * the retro_core_options_v2_intl::local struct will be ignored.
  1652. */
  1653. #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 69
  1654. /* const struct retro_core_options_update_display_callback * --
  1655. * Allows a frontend to signal that a core must update
  1656. * the visibility of any dynamically hidden core options,
  1657. * and enables the frontend to detect visibility changes.
  1658. * Used by the frontend to update the menu display status
  1659. * of core options without requiring a call of retro_run().
  1660. * Must be called in retro_set_environment().
  1661. */
  1662. #define RETRO_ENVIRONMENT_SET_VARIABLE 70
  1663. /* const struct retro_variable * --
  1664. * Allows an implementation to notify the frontend
  1665. * that a core option value has changed.
  1666. *
  1667. * retro_variable::key and retro_variable::value
  1668. * must match strings that have been set previously
  1669. * via one of the following:
  1670. *
  1671. * - RETRO_ENVIRONMENT_SET_VARIABLES
  1672. * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS
  1673. * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL
  1674. * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2
  1675. * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL
  1676. *
  1677. * After changing a core option value via this
  1678. * callback, RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE
  1679. * will return true.
  1680. *
  1681. * If data is NULL, no changes will be registered
  1682. * and the callback will return true; an
  1683. * implementation may therefore pass NULL in order
  1684. * to test whether the callback is supported.
  1685. */
  1686. #define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1687. /* struct retro_throttle_state * --
  1688. * Allows an implementation to get details on the actual rate
  1689. * the frontend is attempting to call retro_run().
  1690. */
  1691. #define RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT (72 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1692. /* int * --
  1693. * Tells the core about the context the frontend is asking for savestate.
  1694. * (see enum retro_savestate_context)
  1695. */
  1696. #define RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT (73 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1697. /* struct retro_hw_render_context_negotiation_interface * --
  1698. * Before calling SET_HW_RNEDER_CONTEXT_NEGOTIATION_INTERFACE, a core can query
  1699. * which version of the interface is supported.
  1700. *
  1701. * Frontend looks at interface_type and returns the maximum supported
  1702. * context negotiation interface version.
  1703. * If the interface_type is not supported or recognized by the frontend, a version of 0
  1704. * must be returned in interface_version and true is returned by frontend.
  1705. *
  1706. * If this environment call returns true with interface_version greater than 0,
  1707. * a core can always use a negotiation interface version larger than what the frontend returns, but only
  1708. * earlier versions of the interface will be used by the frontend.
  1709. * A frontend must not reject a negotiation interface version that is larger than
  1710. * what the frontend supports. Instead, the frontend will use the older entry points that it recognizes.
  1711. * If this is incompatible with a particular core's requirements, it can error out early.
  1712. *
  1713. * Backwards compatibility note:
  1714. * This environment call was introduced after Vulkan v1 context negotiation.
  1715. * If this environment call is not supported by frontend - i.e. the environment call returns false -
  1716. * only Vulkan v1 context negotiation is supported (if Vulkan HW rendering is supported at all).
  1717. * If a core uses Vulkan negotiation interface with version > 1, negotiation may fail unexpectedly.
  1718. * All future updates to the context negotiation interface implies that frontend must support
  1719. * this environment call to query support.
  1720. */
  1721. #define RETRO_ENVIRONMENT_GET_JIT_CAPABLE 74
  1722. /* bool * --
  1723. * Result is set to true if the frontend has already verified JIT can be
  1724. * used, mainly for use iOS/tvOS. On other platforms the result is true.
  1725. */
  1726. #define RETRO_ENVIRONMENT_GET_MICROPHONE_INTERFACE (75 | RETRO_ENVIRONMENT_EXPERIMENTAL)
  1727. /* struct retro_microphone_interface * --
  1728. * Returns an interface that can be used to receive input from the microphone driver.
  1729. *
  1730. * Returns true if microphone support is available,
  1731. * even if no microphones are plugged in.
  1732. * Returns false if mic support is disabled or unavailable.
  1733. *
  1734. * This callback can be invoked at any time,
  1735. * even before the microphone driver is ready.
  1736. */
  1737. /* VFS functionality */
  1738. /* File paths:
  1739. * File paths passed as parameters when using this API shall be well formed UNIX-style,
  1740. * using "/" (unquoted forward slash) as directory separator regardless of the platform's native separator.
  1741. * Paths shall also include at least one forward slash ("game.bin" is an invalid path, use "./game.bin" instead).
  1742. * Other than the directory separator, cores shall not make assumptions about path format:
  1743. * "C:/path/game.bin", "http://example.com/game.bin", "#game/game.bin", "./game.bin" (without quotes) are all valid paths.
  1744. * Cores may replace the basename or remove path components from the end, and/or add new components;
  1745. * however, cores shall not append "./", "../" or multiple consecutive forward slashes ("//") to paths they request to front end.
  1746. * The frontend is encouraged to make such paths work as well as it can, but is allowed to give up if the core alters paths too much.
  1747. * Frontends are encouraged, but not required, to support native file system paths (modulo replacing the directory separator, if applicable).
  1748. * Cores are allowed to try using them, but must remain functional if the front rejects such requests.
  1749. * Cores are encouraged to use the libretro-common filestream functions for file I/O,
  1750. * as they seamlessly integrate with VFS, deal with directory separator replacement as appropriate
  1751. * and provide platform-specific fallbacks in cases where front ends do not support VFS. */
  1752. /* Opaque file handle
  1753. * Introduced in VFS API v1 */
  1754. struct retro_vfs_file_handle;
  1755. /* Opaque directory handle
  1756. * Introduced in VFS API v3 */
  1757. struct retro_vfs_dir_handle;
  1758. /* File open flags
  1759. * Introduced in VFS API v1 */
  1760. #define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */
  1761. #define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) /* Write only mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified */
  1762. #define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/
  1763. #define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */
  1764. /* These are only hints. The frontend may choose to ignore them. Other than RAM/CPU/etc use,
  1765. and how they react to unlikely external interference (for example someone else writing to that file,
  1766. or the file's server going down), behavior will not change. */
  1767. #define RETRO_VFS_FILE_ACCESS_HINT_NONE (0)
  1768. /* Indicate that the file will be accessed many times. The frontend should aggressively cache everything. */
  1769. #define RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS (1 << 0)
  1770. /* Seek positions */
  1771. #define RETRO_VFS_SEEK_POSITION_START 0
  1772. #define RETRO_VFS_SEEK_POSITION_CURRENT 1
  1773. #define RETRO_VFS_SEEK_POSITION_END 2
  1774. /* stat() result flags
  1775. * Introduced in VFS API v3 */
  1776. #define RETRO_VFS_STAT_IS_VALID (1 << 0)
  1777. #define RETRO_VFS_STAT_IS_DIRECTORY (1 << 1)
  1778. #define RETRO_VFS_STAT_IS_CHARACTER_SPECIAL (1 << 2)
  1779. /* Get path from opaque handle. Returns the exact same path passed to file_open when getting the handle
  1780. * Introduced in VFS API v1 */
  1781. typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file_handle *stream);
  1782. /* Open a file for reading or writing. If path points to a directory, this will
  1783. * fail. Returns the opaque file handle, or NULL for error.
  1784. * Introduced in VFS API v1 */
  1785. typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints);
  1786. /* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on success, -1 on failure.
  1787. * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
  1788. * Introduced in VFS API v1 */
  1789. typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *stream);
  1790. /* Return the size of the file in bytes, or -1 for error.
  1791. * Introduced in VFS API v1 */
  1792. typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream);
  1793. /* Truncate file to specified size. Returns 0 on success or -1 on error
  1794. * Introduced in VFS API v2 */
  1795. typedef int64_t (RETRO_CALLCONV *retro_vfs_truncate_t)(struct retro_vfs_file_handle *stream, int64_t length);
  1796. /* Get the current read / write position for the file. Returns -1 for error.
  1797. * Introduced in VFS API v1 */
  1798. typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream);
  1799. /* Set the current read/write position for the file. Returns the new position, -1 for error.
  1800. * Introduced in VFS API v1 */
  1801. typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position);
  1802. /* Read data from a file. Returns the number of bytes read, or -1 for error.
  1803. * Introduced in VFS API v1 */
  1804. typedef int64_t (RETRO_CALLCONV *retro_vfs_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len);
  1805. /* Write data to a file. Returns the number of bytes written, or -1 for error.
  1806. * Introduced in VFS API v1 */
  1807. typedef int64_t (RETRO_CALLCONV *retro_vfs_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len);
  1808. /* Flush pending writes to file, if using buffered IO. Returns 0 on sucess, or -1 on failure.
  1809. * Introduced in VFS API v1 */
  1810. typedef int (RETRO_CALLCONV *retro_vfs_flush_t)(struct retro_vfs_file_handle *stream);
  1811. /* Delete the specified file. Returns 0 on success, -1 on failure
  1812. * Introduced in VFS API v1 */
  1813. typedef int (RETRO_CALLCONV *retro_vfs_remove_t)(const char *path);
  1814. /* Rename the specified file. Returns 0 on success, -1 on failure
  1815. * Introduced in VFS API v1 */
  1816. typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const char *new_path);
  1817. /* Stat the specified file. Retruns a bitmask of RETRO_VFS_STAT_* flags, none are set if path was not valid.
  1818. * Additionally stores file size in given variable, unless NULL is given.
  1819. * Introduced in VFS API v3 */
  1820. typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size);
  1821. /* Create the specified directory. Returns 0 on success, -1 on unknown failure, -2 if already exists.
  1822. * Introduced in VFS API v3 */
  1823. typedef int (RETRO_CALLCONV *retro_vfs_mkdir_t)(const char *dir);
  1824. /* Open the specified directory for listing. Returns the opaque dir handle, or NULL for error.
  1825. * Support for the include_hidden argument may vary depending on the platform.
  1826. * Introduced in VFS API v3 */
  1827. typedef struct retro_vfs_dir_handle *(RETRO_CALLCONV *retro_vfs_opendir_t)(const char *dir, bool include_hidden);
  1828. /* Read the directory entry at the current position, and move the read pointer to the next position.
  1829. * Returns true on success, false if already on the last entry.
  1830. * Introduced in VFS API v3 */
  1831. typedef bool (RETRO_CALLCONV *retro_vfs_readdir_t)(struct retro_vfs_dir_handle *dirstream);
  1832. /* Get the name of the last entry read. Returns a string on success, or NULL for error.
  1833. * The returned string pointer is valid until the next call to readdir or closedir.
  1834. * Introduced in VFS API v3 */
  1835. typedef const char *(RETRO_CALLCONV *retro_vfs_dirent_get_name_t)(struct retro_vfs_dir_handle *dirstream);
  1836. /* Check if the last entry read was a directory. Returns true if it was, false otherwise (or on error).
  1837. * Introduced in VFS API v3 */
  1838. typedef bool (RETRO_CALLCONV *retro_vfs_dirent_is_dir_t)(struct retro_vfs_dir_handle *dirstream);
  1839. /* Close the directory and release its resources. Must be called if opendir returns non-NULL. Returns 0 on success, -1 on failure.
  1840. * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
  1841. * Introduced in VFS API v3 */
  1842. typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle *dirstream);
  1843. struct retro_vfs_interface
  1844. {
  1845. /* VFS API v1 */
  1846. retro_vfs_get_path_t get_path;
  1847. retro_vfs_open_t open;
  1848. retro_vfs_close_t close;
  1849. retro_vfs_size_t size;
  1850. retro_vfs_tell_t tell;
  1851. retro_vfs_seek_t seek;
  1852. retro_vfs_read_t read;
  1853. retro_vfs_write_t write;
  1854. retro_vfs_flush_t flush;
  1855. retro_vfs_remove_t remove;
  1856. retro_vfs_rename_t rename;
  1857. /* VFS API v2 */
  1858. retro_vfs_truncate_t truncate;
  1859. /* VFS API v3 */
  1860. retro_vfs_stat_t stat;
  1861. retro_vfs_mkdir_t mkdir;
  1862. retro_vfs_opendir_t opendir;
  1863. retro_vfs_readdir_t readdir;
  1864. retro_vfs_dirent_get_name_t dirent_get_name;
  1865. retro_vfs_dirent_is_dir_t dirent_is_dir;
  1866. retro_vfs_closedir_t closedir;
  1867. };
  1868. struct retro_vfs_interface_info
  1869. {
  1870. /* Set by core: should this be higher than the version the front end supports,
  1871. * front end will return false in the RETRO_ENVIRONMENT_GET_VFS_INTERFACE call
  1872. * Introduced in VFS API v1 */
  1873. uint32_t required_interface_version;
  1874. /* Frontend writes interface pointer here. The frontend also sets the actual
  1875. * version, must be at least required_interface_version.
  1876. * Introduced in VFS API v1 */
  1877. struct retro_vfs_interface *iface;
  1878. };
  1879. enum retro_hw_render_interface_type
  1880. {
  1881. RETRO_HW_RENDER_INTERFACE_VULKAN = 0,
  1882. RETRO_HW_RENDER_INTERFACE_D3D9 = 1,
  1883. RETRO_HW_RENDER_INTERFACE_D3D10 = 2,
  1884. RETRO_HW_RENDER_INTERFACE_D3D11 = 3,
  1885. RETRO_HW_RENDER_INTERFACE_D3D12 = 4,
  1886. RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5,
  1887. RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX
  1888. };
  1889. /* Base struct. All retro_hw_render_interface_* types
  1890. * contain at least these fields. */
  1891. struct retro_hw_render_interface
  1892. {
  1893. enum retro_hw_render_interface_type interface_type;
  1894. unsigned interface_version;
  1895. };
  1896. typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state);
  1897. struct retro_led_interface
  1898. {
  1899. retro_set_led_state_t set_led_state;
  1900. };
  1901. /* Retrieves the current state of the MIDI input.
  1902. * Returns true if it's enabled, false otherwise. */
  1903. typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);
  1904. /* Retrieves the current state of the MIDI output.
  1905. * Returns true if it's enabled, false otherwise */
  1906. typedef bool (RETRO_CALLCONV *retro_midi_output_enabled_t)(void);
  1907. /* Reads next byte from the input stream.
  1908. * Returns true if byte is read, false otherwise. */
  1909. typedef bool (RETRO_CALLCONV *retro_midi_read_t)(uint8_t *byte);
  1910. /* Writes byte to the output stream.
  1911. * 'delta_time' is in microseconds and represent time elapsed since previous write.
  1912. * Returns true if byte is written, false otherwise. */
  1913. typedef bool (RETRO_CALLCONV *retro_midi_write_t)(uint8_t byte, uint32_t delta_time);
  1914. /* Flushes previously written data.
  1915. * Returns true if successful, false otherwise. */
  1916. typedef bool (RETRO_CALLCONV *retro_midi_flush_t)(void);
  1917. struct retro_midi_interface
  1918. {
  1919. retro_midi_input_enabled_t input_enabled;
  1920. retro_midi_output_enabled_t output_enabled;
  1921. retro_midi_read_t read;
  1922. retro_midi_write_t write;
  1923. retro_midi_flush_t flush;
  1924. };
  1925. enum retro_hw_render_context_negotiation_interface_type
  1926. {
  1927. RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0,
  1928. RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX
  1929. };
  1930. /* Base struct. All retro_hw_render_context_negotiation_interface_* types
  1931. * contain at least these fields. */
  1932. struct retro_hw_render_context_negotiation_interface
  1933. {
  1934. enum retro_hw_render_context_negotiation_interface_type interface_type;
  1935. unsigned interface_version;
  1936. };
  1937. /* Serialized state is incomplete in some way. Set if serialization is
  1938. * usable in typical end-user cases but should not be relied upon to
  1939. * implement frame-sensitive frontend features such as netplay or
  1940. * rerecording. */
  1941. #define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0)
  1942. /* The core must spend some time initializing before serialization is
  1943. * supported. retro_serialize() will initially fail; retro_unserialize()
  1944. * and retro_serialize_size() may or may not work correctly either. */
  1945. #define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1)
  1946. /* Serialization size may change within a session. */
  1947. #define RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE (1 << 2)
  1948. /* Set by the frontend to acknowledge that it supports variable-sized
  1949. * states. */
  1950. #define RETRO_SERIALIZATION_QUIRK_FRONT_VARIABLE_SIZE (1 << 3)
  1951. /* Serialized state can only be loaded during the same session. */
  1952. #define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4)
  1953. /* Serialized state cannot be loaded on an architecture with a different
  1954. * endianness from the one it was saved on. */
  1955. #define RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT (1 << 5)
  1956. /* Serialized state cannot be loaded on a different platform from the one it
  1957. * was saved on for reasons other than endianness, such as word size
  1958. * dependence */
  1959. #define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6)
  1960. #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */
  1961. #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */
  1962. #define RETRO_MEMDESC_SYSTEM_RAM (1 << 2) /* The memory area is system RAM. This is main RAM of the gaming system. */
  1963. #define RETRO_MEMDESC_SAVE_RAM (1 << 3) /* The memory area is save RAM. This RAM is usually found on a game cartridge, backed up by a battery. */
  1964. #define RETRO_MEMDESC_VIDEO_RAM (1 << 4) /* The memory area is video RAM (VRAM) */
  1965. #define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */
  1966. #define RETRO_MEMDESC_ALIGN_4 (2 << 16)
  1967. #define RETRO_MEMDESC_ALIGN_8 (3 << 16)
  1968. #define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */
  1969. #define RETRO_MEMDESC_MINSIZE_4 (2 << 24)
  1970. #define RETRO_MEMDESC_MINSIZE_8 (3 << 24)
  1971. struct retro_memory_descriptor
  1972. {
  1973. uint64_t flags;
  1974. /* Pointer to the start of the relevant ROM or RAM chip.
  1975. * It's strongly recommended to use 'offset' if possible, rather than
  1976. * doing math on the pointer.
  1977. *
  1978. * If the same byte is mapped my multiple descriptors, their descriptors
  1979. * must have the same pointer.
  1980. * If 'start' does not point to the first byte in the pointer, put the
  1981. * difference in 'offset' instead.
  1982. *
  1983. * May be NULL if there's nothing usable here (e.g. hardware registers and
  1984. * open bus). No flags should be set if the pointer is NULL.
  1985. * It's recommended to minimize the number of descriptors if possible,
  1986. * but not mandatory. */
  1987. void *ptr;
  1988. size_t offset;
  1989. /* This is the location in the emulated address space
  1990. * where the mapping starts. */
  1991. size_t start;
  1992. /* Which bits must be same as in 'start' for this mapping to apply.
  1993. * The first memory descriptor to claim a certain byte is the one
  1994. * that applies.
  1995. * A bit which is set in 'start' must also be set in this.
  1996. * Can be zero, in which case each byte is assumed mapped exactly once.
  1997. * In this case, 'len' must be a power of two. */
  1998. size_t select;
  1999. /* If this is nonzero, the set bits are assumed not connected to the
  2000. * memory chip's address pins. */
  2001. size_t disconnect;
  2002. /* This one tells the size of the current memory area.
  2003. * If, after start+disconnect are applied, the address is higher than
  2004. * this, the highest bit of the address is cleared.
  2005. *
  2006. * If the address is still too high, the next highest bit is cleared.
  2007. * Can be zero, in which case it's assumed to be infinite (as limited
  2008. * by 'select' and 'disconnect'). */
  2009. size_t len;
  2010. /* To go from emulated address to physical address, the following
  2011. * order applies:
  2012. * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. */
  2013. /* The address space name must consist of only a-zA-Z0-9_-,
  2014. * should be as short as feasible (maximum length is 8 plus the NUL),
  2015. * and may not be any other address space plus one or more 0-9A-F
  2016. * at the end.
  2017. * However, multiple memory descriptors for the same address space is
  2018. * allowed, and the address space name can be empty. NULL is treated
  2019. * as empty.
  2020. *
  2021. * Address space names are case sensitive, but avoid lowercase if possible.
  2022. * The same pointer may exist in multiple address spaces.
  2023. *
  2024. * Examples:
  2025. * blank+blank - valid (multiple things may be mapped in the same namespace)
  2026. * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace)
  2027. * 'A'+'B' - valid (neither is a prefix of each other)
  2028. * 'S'+blank - valid ('S' is not in 0-9A-F)
  2029. * 'a'+blank - valid ('a' is not in 0-9A-F)
  2030. * 'a'+'A' - valid (neither is a prefix of each other)
  2031. * 'AR'+blank - valid ('R' is not in 0-9A-F)
  2032. * 'ARB'+blank - valid (the B can't be part of the address either, because
  2033. * there is no namespace 'AR')
  2034. * blank+'B' - not valid, because it's ambigous which address space B1234
  2035. * would refer to.
  2036. * The length can't be used for that purpose; the frontend may want
  2037. * to append arbitrary data to an address, without a separator. */
  2038. const char *addrspace;
  2039. /* TODO: When finalizing this one, add a description field, which should be
  2040. * "WRAM" or something roughly equally long. */
  2041. /* TODO: When finalizing this one, replace 'select' with 'limit', which tells
  2042. * which bits can vary and still refer to the same address (limit = ~select).
  2043. * TODO: limit? range? vary? something else? */
  2044. /* TODO: When finalizing this one, if 'len' is above what 'select' (or
  2045. * 'limit') allows, it's bankswitched. Bankswitched data must have both 'len'
  2046. * and 'select' != 0, and the mappings don't tell how the system switches the
  2047. * banks. */
  2048. /* TODO: When finalizing this one, fix the 'len' bit removal order.
  2049. * For len=0x1800, pointer 0x1C00 should go to 0x1400, not 0x0C00.
  2050. * Algorithm: Take bits highest to lowest, but if it goes above len, clear
  2051. * the most recent addition and continue on the next bit.
  2052. * TODO: Can the above be optimized? Is "remove the lowest bit set in both
  2053. * pointer and 'len'" equivalent? */
  2054. /* TODO: Some emulators (MAME?) emulate big endian systems by only accessing
  2055. * the emulated memory in 32-bit chunks, native endian. But that's nothing
  2056. * compared to Darek Mihocka <http://www.emulators.com/docs/nx07_vm101.htm>
  2057. * (section Emulation 103 - Nearly Free Byte Reversal) - he flips the ENTIRE
  2058. * RAM backwards! I'll want to represent both of those, via some flags.
  2059. *
  2060. * I suspect MAME either didn't think of that idea, or don't want the #ifdef.
  2061. * Not sure which, nor do I really care. */
  2062. /* TODO: Some of those flags are unused and/or don't really make sense. Clean
  2063. * them up. */
  2064. };
  2065. /* The frontend may use the largest value of 'start'+'select' in a
  2066. * certain namespace to infer the size of the address space.
  2067. *
  2068. * If the address space is larger than that, a mapping with .ptr=NULL
  2069. * should be at the end of the array, with .select set to all ones for
  2070. * as long as the address space is big.
  2071. *
  2072. * Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags):
  2073. * SNES WRAM:
  2074. * .start=0x7E0000, .len=0x20000
  2075. * (Note that this must be mapped before the ROM in most cases; some of the
  2076. * ROM mappers
  2077. * try to claim $7E0000, or at least $7E8000.)
  2078. * SNES SPC700 RAM:
  2079. * .addrspace="S", .len=0x10000
  2080. * SNES WRAM mirrors:
  2081. * .flags=MIRROR, .start=0x000000, .select=0xC0E000, .len=0x2000
  2082. * .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000
  2083. * SNES WRAM mirrors, alternate equivalent descriptor:
  2084. * .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF
  2085. * (Various similar constructions can be created by combining parts of
  2086. * the above two.)
  2087. * SNES LoROM (512KB, mirrored a couple of times):
  2088. * .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024
  2089. * .flags=CONST, .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*1024
  2090. * SNES HiROM (4MB):
  2091. * .flags=CONST, .start=0x400000, .select=0x400000, .len=4*1024*1024
  2092. * .flags=CONST, .offset=0x8000, .start=0x008000, .select=0x408000, .len=4*1024*1024
  2093. * SNES ExHiROM (8MB):
  2094. * .flags=CONST, .offset=0, .start=0xC00000, .select=0xC00000, .len=4*1024*1024
  2095. * .flags=CONST, .offset=4*1024*1024, .start=0x400000, .select=0xC00000, .len=4*1024*1024
  2096. * .flags=CONST, .offset=0x8000, .start=0x808000, .select=0xC08000, .len=4*1024*1024
  2097. * .flags=CONST, .offset=4*1024*1024+0x8000, .start=0x008000, .select=0xC08000, .len=4*1024*1024
  2098. * Clarify the size of the address space:
  2099. * .ptr=NULL, .select=0xFFFFFF
  2100. * .len can be implied by .select in many of them, but was included for clarity.
  2101. */
  2102. struct retro_memory_map
  2103. {
  2104. const struct retro_memory_descriptor *descriptors;
  2105. unsigned num_descriptors;
  2106. };
  2107. struct retro_controller_description
  2108. {
  2109. /* Human-readable description of the controller. Even if using a generic
  2110. * input device type, this can be set to the particular device type the
  2111. * core uses. */
  2112. const char *desc;
  2113. /* Device type passed to retro_set_controller_port_device(). If the device
  2114. * type is a sub-class of a generic input device type, use the
  2115. * RETRO_DEVICE_SUBCLASS macro to create an ID.
  2116. *
  2117. * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */
  2118. unsigned id;
  2119. };
  2120. struct retro_controller_info
  2121. {
  2122. const struct retro_controller_description *types;
  2123. unsigned num_types;
  2124. };
  2125. struct retro_subsystem_memory_info
  2126. {
  2127. /* The extension associated with a memory type, e.g. "psram". */
  2128. const char *extension;
  2129. /* The memory type for retro_get_memory(). This should be at
  2130. * least 0x100 to avoid conflict with standardized
  2131. * libretro memory types. */
  2132. unsigned type;
  2133. };
  2134. struct retro_subsystem_rom_info
  2135. {
  2136. /* Describes what the content is (SGB BIOS, GB ROM, etc). */
  2137. const char *desc;
  2138. /* Same definition as retro_get_system_info(). */
  2139. const char *valid_extensions;
  2140. /* Same definition as retro_get_system_info(). */
  2141. bool need_fullpath;
  2142. /* Same definition as retro_get_system_info(). */
  2143. bool block_extract;
  2144. /* This is set if the content is required to load a game.
  2145. * If this is set to false, a zeroed-out retro_game_info can be passed. */
  2146. bool required;
  2147. /* Content can have multiple associated persistent
  2148. * memory types (retro_get_memory()). */
  2149. const struct retro_subsystem_memory_info *memory;
  2150. unsigned num_memory;
  2151. };
  2152. struct retro_subsystem_info
  2153. {
  2154. /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */
  2155. const char *desc;
  2156. /* A computer friendly short string identifier for the subsystem type.
  2157. * This name must be [a-z].
  2158. * E.g. if desc is "Super GameBoy", this can be "sgb".
  2159. * This identifier can be used for command-line interfaces, etc.
  2160. */
  2161. const char *ident;
  2162. /* Infos for each content file. The first entry is assumed to be the
  2163. * "most significant" content for frontend purposes.
  2164. * E.g. with Super GameBoy, the first content should be the GameBoy ROM,
  2165. * as it is the most "significant" content to a user.
  2166. * If a frontend creates new file paths based on the content used
  2167. * (e.g. savestates), it should use the path for the first ROM to do so. */
  2168. const struct retro_subsystem_rom_info *roms;
  2169. /* Number of content files associated with a subsystem. */
  2170. unsigned num_roms;
  2171. /* The type passed to retro_load_game_special(). */
  2172. unsigned id;
  2173. };
  2174. typedef void (RETRO_CALLCONV *retro_proc_address_t)(void);
  2175. /* libretro API extension functions:
  2176. * (None here so far).
  2177. *
  2178. * Get a symbol from a libretro core.
  2179. * Cores should only return symbols which are actual
  2180. * extensions to the libretro API.
  2181. *
  2182. * Frontends should not use this to obtain symbols to standard
  2183. * libretro entry points (static linking or dlsym).
  2184. *
  2185. * The symbol name must be equal to the function name,
  2186. * e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".
  2187. * The returned function pointer must be cast to the corresponding type.
  2188. */
  2189. typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym);
  2190. struct retro_get_proc_address_interface
  2191. {
  2192. retro_get_proc_address_t get_proc_address;
  2193. };
  2194. enum retro_log_level
  2195. {
  2196. RETRO_LOG_DEBUG = 0,
  2197. RETRO_LOG_INFO,
  2198. RETRO_LOG_WARN,
  2199. RETRO_LOG_ERROR,
  2200. RETRO_LOG_DUMMY = INT_MAX
  2201. };
  2202. /* Logging function. Takes log level argument as well. */
  2203. typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level,
  2204. const char *fmt, ...);
  2205. struct retro_log_callback
  2206. {
  2207. retro_log_printf_t log;
  2208. };
  2209. /* Performance related functions */
  2210. /* ID values for SIMD CPU features */
  2211. #define RETRO_SIMD_SSE (1 << 0)
  2212. #define RETRO_SIMD_SSE2 (1 << 1)
  2213. #define RETRO_SIMD_VMX (1 << 2)
  2214. #define RETRO_SIMD_VMX128 (1 << 3)
  2215. #define RETRO_SIMD_AVX (1 << 4)
  2216. #define RETRO_SIMD_NEON (1 << 5)
  2217. #define RETRO_SIMD_SSE3 (1 << 6)
  2218. #define RETRO_SIMD_SSSE3 (1 << 7)
  2219. #define RETRO_SIMD_MMX (1 << 8)
  2220. #define RETRO_SIMD_MMXEXT (1 << 9)
  2221. #define RETRO_SIMD_SSE4 (1 << 10)
  2222. #define RETRO_SIMD_SSE42 (1 << 11)
  2223. #define RETRO_SIMD_AVX2 (1 << 12)
  2224. #define RETRO_SIMD_VFPU (1 << 13)
  2225. #define RETRO_SIMD_PS (1 << 14)
  2226. #define RETRO_SIMD_AES (1 << 15)
  2227. #define RETRO_SIMD_VFPV3 (1 << 16)
  2228. #define RETRO_SIMD_VFPV4 (1 << 17)
  2229. #define RETRO_SIMD_POPCNT (1 << 18)
  2230. #define RETRO_SIMD_MOVBE (1 << 19)
  2231. #define RETRO_SIMD_CMOV (1 << 20)
  2232. #define RETRO_SIMD_ASIMD (1 << 21)
  2233. typedef uint64_t retro_perf_tick_t;
  2234. typedef int64_t retro_time_t;
  2235. struct retro_perf_counter
  2236. {
  2237. const char *ident;
  2238. retro_perf_tick_t start;
  2239. retro_perf_tick_t total;
  2240. retro_perf_tick_t call_cnt;
  2241. bool registered;
  2242. };
  2243. /* Returns current time in microseconds.
  2244. * Tries to use the most accurate timer available.
  2245. */
  2246. typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void);
  2247. /* A simple counter. Usually nanoseconds, but can also be CPU cycles.
  2248. * Can be used directly if desired (when creating a more sophisticated
  2249. * performance counter system).
  2250. * */
  2251. typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void);
  2252. /* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */
  2253. typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void);
  2254. /* Asks frontend to log and/or display the state of performance counters.
  2255. * Performance counters can always be poked into manually as well.
  2256. */
  2257. typedef void (RETRO_CALLCONV *retro_perf_log_t)(void);
  2258. /* Register a performance counter.
  2259. * ident field must be set with a discrete value and other values in
  2260. * retro_perf_counter must be 0.
  2261. * Registering can be called multiple times. To avoid calling to
  2262. * frontend redundantly, you can check registered field first. */
  2263. typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter);
  2264. /* Starts a registered counter. */
  2265. typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter);
  2266. /* Stops a registered counter. */
  2267. typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter);
  2268. /* For convenience it can be useful to wrap register, start and stop in macros.
  2269. * E.g.:
  2270. * #ifdef LOG_PERFORMANCE
  2271. * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name))
  2272. * #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name))
  2273. * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name))
  2274. * #else
  2275. * ... Blank macros ...
  2276. * #endif
  2277. *
  2278. * These can then be used mid-functions around code snippets.
  2279. *
  2280. * extern struct retro_perf_callback perf_cb; * Somewhere in the core.
  2281. *
  2282. * void do_some_heavy_work(void)
  2283. * {
  2284. * RETRO_PERFORMANCE_INIT(cb, work_1;
  2285. * RETRO_PERFORMANCE_START(cb, work_1);
  2286. * heavy_work_1();
  2287. * RETRO_PERFORMANCE_STOP(cb, work_1);
  2288. *
  2289. * RETRO_PERFORMANCE_INIT(cb, work_2);
  2290. * RETRO_PERFORMANCE_START(cb, work_2);
  2291. * heavy_work_2();
  2292. * RETRO_PERFORMANCE_STOP(cb, work_2);
  2293. * }
  2294. *
  2295. * void retro_deinit(void)
  2296. * {
  2297. * perf_cb.perf_log(); * Log all perf counters here for example.
  2298. * }
  2299. */
  2300. struct retro_perf_callback
  2301. {
  2302. retro_perf_get_time_usec_t get_time_usec;
  2303. retro_get_cpu_features_t get_cpu_features;
  2304. retro_perf_get_counter_t get_perf_counter;
  2305. retro_perf_register_t perf_register;
  2306. retro_perf_start_t perf_start;
  2307. retro_perf_stop_t perf_stop;
  2308. retro_perf_log_t perf_log;
  2309. };
  2310. /* FIXME: Document the sensor API and work out behavior.
  2311. * It will be marked as experimental until then.
  2312. */
  2313. enum retro_sensor_action
  2314. {
  2315. RETRO_SENSOR_ACCELEROMETER_ENABLE = 0,
  2316. RETRO_SENSOR_ACCELEROMETER_DISABLE,
  2317. RETRO_SENSOR_GYROSCOPE_ENABLE,
  2318. RETRO_SENSOR_GYROSCOPE_DISABLE,
  2319. RETRO_SENSOR_ILLUMINANCE_ENABLE,
  2320. RETRO_SENSOR_ILLUMINANCE_DISABLE,
  2321. RETRO_SENSOR_DUMMY = INT_MAX
  2322. };
  2323. /* Id values for SENSOR types. */
  2324. #define RETRO_SENSOR_ACCELEROMETER_X 0
  2325. #define RETRO_SENSOR_ACCELEROMETER_Y 1
  2326. #define RETRO_SENSOR_ACCELEROMETER_Z 2
  2327. #define RETRO_SENSOR_GYROSCOPE_X 3
  2328. #define RETRO_SENSOR_GYROSCOPE_Y 4
  2329. #define RETRO_SENSOR_GYROSCOPE_Z 5
  2330. #define RETRO_SENSOR_ILLUMINANCE 6
  2331. typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port,
  2332. enum retro_sensor_action action, unsigned rate);
  2333. typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id);
  2334. struct retro_sensor_interface
  2335. {
  2336. retro_set_sensor_state_t set_sensor_state;
  2337. retro_sensor_get_input_t get_sensor_input;
  2338. };
  2339. enum retro_camera_buffer
  2340. {
  2341. RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0,
  2342. RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER,
  2343. RETRO_CAMERA_BUFFER_DUMMY = INT_MAX
  2344. };
  2345. /* Starts the camera driver. Can only be called in retro_run(). */
  2346. typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void);
  2347. /* Stops the camera driver. Can only be called in retro_run(). */
  2348. typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void);
  2349. /* Callback which signals when the camera driver is initialized
  2350. * and/or deinitialized.
  2351. * retro_camera_start_t can be called in initialized callback.
  2352. */
  2353. typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void);
  2354. /* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.
  2355. * Width, height and pitch are similar to retro_video_refresh_t.
  2356. * First pixel is top-left origin.
  2357. */
  2358. typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer,
  2359. unsigned width, unsigned height, size_t pitch);
  2360. /* A callback for when OpenGL textures are used.
  2361. *
  2362. * texture_id is a texture owned by camera driver.
  2363. * Its state or content should be considered immutable, except for things like
  2364. * texture filtering and clamping.
  2365. *
  2366. * texture_target is the texture target for the GL texture.
  2367. * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly
  2368. * more depending on extensions.
  2369. *
  2370. * affine points to a packed 3x3 column-major matrix used to apply an affine
  2371. * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))
  2372. * After transform, normalized texture coord (0, 0) should be bottom-left
  2373. * and (1, 1) should be top-right (or (width, height) for RECTANGLE).
  2374. *
  2375. * GL-specific typedefs are avoided here to avoid relying on gl.h in
  2376. * the API definition.
  2377. */
  2378. typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id,
  2379. unsigned texture_target, const float *affine);
  2380. struct retro_camera_callback
  2381. {
  2382. /* Set by libretro core.
  2383. * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).
  2384. */
  2385. uint64_t caps;
  2386. /* Desired resolution for camera. Is only used as a hint. */
  2387. unsigned width;
  2388. unsigned height;
  2389. /* Set by frontend. */
  2390. retro_camera_start_t start;
  2391. retro_camera_stop_t stop;
  2392. /* Set by libretro core if raw framebuffer callbacks will be used. */
  2393. retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer;
  2394. /* Set by libretro core if OpenGL texture callbacks will be used. */
  2395. retro_camera_frame_opengl_texture_t frame_opengl_texture;
  2396. /* Set by libretro core. Called after camera driver is initialized and
  2397. * ready to be started.
  2398. * Can be NULL, in which this callback is not called.
  2399. */
  2400. retro_camera_lifetime_status_t initialized;
  2401. /* Set by libretro core. Called right before camera driver is
  2402. * deinitialized.
  2403. * Can be NULL, in which this callback is not called.
  2404. */
  2405. retro_camera_lifetime_status_t deinitialized;
  2406. };
  2407. /* Sets the interval of time and/or distance at which to update/poll
  2408. * location-based data.
  2409. *
  2410. * To ensure compatibility with all location-based implementations,
  2411. * values for both interval_ms and interval_distance should be provided.
  2412. *
  2413. * interval_ms is the interval expressed in milliseconds.
  2414. * interval_distance is the distance interval expressed in meters.
  2415. */
  2416. typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms,
  2417. unsigned interval_distance);
  2418. /* Start location services. The device will start listening for changes to the
  2419. * current location at regular intervals (which are defined with
  2420. * retro_location_set_interval_t). */
  2421. typedef bool (RETRO_CALLCONV *retro_location_start_t)(void);
  2422. /* Stop location services. The device will stop listening for changes
  2423. * to the current location. */
  2424. typedef void (RETRO_CALLCONV *retro_location_stop_t)(void);
  2425. /* Get the position of the current location. Will set parameters to
  2426. * 0 if no new location update has happened since the last time. */
  2427. typedef bool (RETRO_CALLCONV *retro_location_get_position_t)(double *lat, double *lon,
  2428. double *horiz_accuracy, double *vert_accuracy);
  2429. /* Callback which signals when the location driver is initialized
  2430. * and/or deinitialized.
  2431. * retro_location_start_t can be called in initialized callback.
  2432. */
  2433. typedef void (RETRO_CALLCONV *retro_location_lifetime_status_t)(void);
  2434. struct retro_location_callback
  2435. {
  2436. retro_location_start_t start;
  2437. retro_location_stop_t stop;
  2438. retro_location_get_position_t get_position;
  2439. retro_location_set_interval_t set_interval;
  2440. retro_location_lifetime_status_t initialized;
  2441. retro_location_lifetime_status_t deinitialized;
  2442. };
  2443. enum retro_rumble_effect
  2444. {
  2445. RETRO_RUMBLE_STRONG = 0,
  2446. RETRO_RUMBLE_WEAK = 1,
  2447. RETRO_RUMBLE_DUMMY = INT_MAX
  2448. };
  2449. /* Sets rumble state for joypad plugged in port 'port'.
  2450. * Rumble effects are controlled independently,
  2451. * and setting e.g. strong rumble does not override weak rumble.
  2452. * Strength has a range of [0, 0xffff].
  2453. *
  2454. * Returns true if rumble state request was honored.
  2455. * Calling this before first retro_run() is likely to return false. */
  2456. typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port,
  2457. enum retro_rumble_effect effect, uint16_t strength);
  2458. struct retro_rumble_interface
  2459. {
  2460. retro_set_rumble_state_t set_rumble_state;
  2461. };
  2462. /* Notifies libretro that audio data should be written. */
  2463. typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void);
  2464. /* True: Audio driver in frontend is active, and callback is
  2465. * expected to be called regularily.
  2466. * False: Audio driver in frontend is paused or inactive.
  2467. * Audio callback will not be called until set_state has been
  2468. * called with true.
  2469. * Initial state is false (inactive).
  2470. */
  2471. typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled);
  2472. struct retro_audio_callback
  2473. {
  2474. retro_audio_callback_t callback;
  2475. retro_audio_set_state_callback_t set_state;
  2476. };
  2477. /* Notifies a libretro core of time spent since last invocation
  2478. * of retro_run() in microseconds.
  2479. *
  2480. * It will be called right before retro_run() every frame.
  2481. * The frontend can tamper with timing to support cases like
  2482. * fast-forward, slow-motion and framestepping.
  2483. *
  2484. * In those scenarios the reference frame time value will be used. */
  2485. typedef int64_t retro_usec_t;
  2486. typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec);
  2487. struct retro_frame_time_callback
  2488. {
  2489. retro_frame_time_callback_t callback;
  2490. /* Represents the time of one frame. It is computed as
  2491. * 1000000 / fps, but the implementation will resolve the
  2492. * rounding to ensure that framestepping, etc is exact. */
  2493. retro_usec_t reference;
  2494. };
  2495. /* Notifies a libretro core of the current occupancy
  2496. * level of the frontend audio buffer.
  2497. *
  2498. * - active: 'true' if audio buffer is currently
  2499. * in use. Will be 'false' if audio is
  2500. * disabled in the frontend
  2501. *
  2502. * - occupancy: Given as a value in the range [0,100],
  2503. * corresponding to the occupancy percentage
  2504. * of the audio buffer
  2505. *
  2506. * - underrun_likely: 'true' if the frontend expects an
  2507. * audio buffer underrun during the
  2508. * next frame (indicates that a core
  2509. * should attempt frame skipping)
  2510. *
  2511. * It will be called right before retro_run() every frame. */
  2512. typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)(
  2513. bool active, unsigned occupancy, bool underrun_likely);
  2514. struct retro_audio_buffer_status_callback
  2515. {
  2516. retro_audio_buffer_status_callback_t callback;
  2517. };
  2518. /* Pass this to retro_video_refresh_t if rendering to hardware.
  2519. * Passing NULL to retro_video_refresh_t is still a frame dupe as normal.
  2520. * */
  2521. #define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1)
  2522. /* Invalidates the current HW context.
  2523. * Any GL state is lost, and must not be deinitialized explicitly.
  2524. * If explicit deinitialization is desired by the libretro core,
  2525. * it should implement context_destroy callback.
  2526. * If called, all GPU resources must be reinitialized.
  2527. * Usually called when frontend reinits video driver.
  2528. * Also called first time video driver is initialized,
  2529. * allowing libretro core to initialize resources.
  2530. */
  2531. typedef void (RETRO_CALLCONV *retro_hw_context_reset_t)(void);
  2532. /* Gets current framebuffer which is to be rendered to.
  2533. * Could change every frame potentially.
  2534. */
  2535. typedef uintptr_t (RETRO_CALLCONV *retro_hw_get_current_framebuffer_t)(void);
  2536. /* Get a symbol from HW context. */
  2537. typedef retro_proc_address_t (RETRO_CALLCONV *retro_hw_get_proc_address_t)(const char *sym);
  2538. enum retro_hw_context_type
  2539. {
  2540. RETRO_HW_CONTEXT_NONE = 0,
  2541. /* OpenGL 2.x. Driver can choose to use latest compatibility context. */
  2542. RETRO_HW_CONTEXT_OPENGL = 1,
  2543. /* OpenGL ES 2.0. */
  2544. RETRO_HW_CONTEXT_OPENGLES2 = 2,
  2545. /* Modern desktop core GL context. Use version_major/
  2546. * version_minor fields to set GL version. */
  2547. RETRO_HW_CONTEXT_OPENGL_CORE = 3,
  2548. /* OpenGL ES 3.0 */
  2549. RETRO_HW_CONTEXT_OPENGLES3 = 4,
  2550. /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3,
  2551. * use the corresponding enums directly. */
  2552. RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,
  2553. /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */
  2554. RETRO_HW_CONTEXT_VULKAN = 6,
  2555. /* Direct3D11, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */
  2556. RETRO_HW_CONTEXT_D3D11 = 7,
  2557. /* Direct3D10, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */
  2558. RETRO_HW_CONTEXT_D3D10 = 8,
  2559. /* Direct3D12, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */
  2560. RETRO_HW_CONTEXT_D3D12 = 9,
  2561. /* Direct3D9, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */
  2562. RETRO_HW_CONTEXT_D3D9 = 10,
  2563. RETRO_HW_CONTEXT_DUMMY = INT_MAX
  2564. };
  2565. struct retro_hw_render_callback
  2566. {
  2567. /* Which API to use. Set by libretro core. */
  2568. enum retro_hw_context_type context_type;
  2569. /* Called when a context has been created or when it has been reset.
  2570. * An OpenGL context is only valid after context_reset() has been called.
  2571. *
  2572. * When context_reset is called, OpenGL resources in the libretro
  2573. * implementation are guaranteed to be invalid.
  2574. *
  2575. * It is possible that context_reset is called multiple times during an
  2576. * application lifecycle.
  2577. * If context_reset is called without any notification (context_destroy),
  2578. * the OpenGL context was lost and resources should just be recreated
  2579. * without any attempt to "free" old resources.
  2580. */
  2581. retro_hw_context_reset_t context_reset;
  2582. /* Set by frontend.
  2583. * TODO: This is rather obsolete. The frontend should not
  2584. * be providing preallocated framebuffers. */
  2585. retro_hw_get_current_framebuffer_t get_current_framebuffer;
  2586. /* Set by frontend.
  2587. * Can return all relevant functions, including glClear on Windows. */
  2588. retro_hw_get_proc_address_t get_proc_address;
  2589. /* Set if render buffers should have depth component attached.
  2590. * TODO: Obsolete. */
  2591. bool depth;
  2592. /* Set if stencil buffers should be attached.
  2593. * TODO: Obsolete. */
  2594. bool stencil;
  2595. /* If depth and stencil are true, a packed 24/8 buffer will be added.
  2596. * Only attaching stencil is invalid and will be ignored. */
  2597. /* Use conventional bottom-left origin convention. If false,
  2598. * standard libretro top-left origin semantics are used.
  2599. * TODO: Move to GL specific interface. */
  2600. bool bottom_left_origin;
  2601. /* Major version number for core GL context or GLES 3.1+. */
  2602. unsigned version_major;
  2603. /* Minor version number for core GL context or GLES 3.1+. */
  2604. unsigned version_minor;
  2605. /* If this is true, the frontend will go very far to avoid
  2606. * resetting context in scenarios like toggling fullscreen, etc.
  2607. * TODO: Obsolete? Maybe frontend should just always assume this ...
  2608. */
  2609. bool cache_context;
  2610. /* The reset callback might still be called in extreme situations
  2611. * such as if the context is lost beyond recovery.
  2612. *
  2613. * For optimal stability, set this to false, and allow context to be
  2614. * reset at any time.
  2615. */
  2616. /* A callback to be called before the context is destroyed in a
  2617. * controlled way by the frontend. */
  2618. retro_hw_context_reset_t context_destroy;
  2619. /* OpenGL resources can be deinitialized cleanly at this step.
  2620. * context_destroy can be set to NULL, in which resources will
  2621. * just be destroyed without any notification.
  2622. *
  2623. * Even when context_destroy is non-NULL, it is possible that
  2624. * context_reset is called without any destroy notification.
  2625. * This happens if context is lost by external factors (such as
  2626. * notified by GL_ARB_robustness).
  2627. *
  2628. * In this case, the context is assumed to be already dead,
  2629. * and the libretro implementation must not try to free any OpenGL
  2630. * resources in the subsequent context_reset.
  2631. */
  2632. /* Creates a debug context. */
  2633. bool debug_context;
  2634. };
  2635. /* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
  2636. * Called by the frontend in response to keyboard events.
  2637. * down is set if the key is being pressed, or false if it is being released.
  2638. * keycode is the RETROK value of the char.
  2639. * character is the text character of the pressed key. (UTF-32).
  2640. * key_modifiers is a set of RETROKMOD values or'ed together.
  2641. *
  2642. * The pressed/keycode state can be indepedent of the character.
  2643. * It is also possible that multiple characters are generated from a
  2644. * single keypress.
  2645. * Keycode events should be treated separately from character events.
  2646. * However, when possible, the frontend should try to synchronize these.
  2647. * If only a character is posted, keycode should be RETROK_UNKNOWN.
  2648. *
  2649. * Similarily if only a keycode event is generated with no corresponding
  2650. * character, character should be 0.
  2651. */
  2652. typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode,
  2653. uint32_t character, uint16_t key_modifiers);
  2654. struct retro_keyboard_callback
  2655. {
  2656. retro_keyboard_event_t callback;
  2657. };
  2658. /* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE &
  2659. * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.
  2660. * Should be set for implementations which can swap out multiple disk
  2661. * images in runtime.
  2662. *
  2663. * If the implementation can do this automatically, it should strive to do so.
  2664. * However, there are cases where the user must manually do so.
  2665. *
  2666. * Overview: To swap a disk image, eject the disk image with
  2667. * set_eject_state(true).
  2668. * Set the disk index with set_image_index(index). Insert the disk again
  2669. * with set_eject_state(false).
  2670. */
  2671. /* If ejected is true, "ejects" the virtual disk tray.
  2672. * When ejected, the disk image index can be set.
  2673. */
  2674. typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected);
  2675. /* Gets current eject state. The initial state is 'not ejected'. */
  2676. typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void);
  2677. /* Gets current disk index. First disk is index 0.
  2678. * If return value is >= get_num_images(), no disk is currently inserted.
  2679. */
  2680. typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void);
  2681. /* Sets image index. Can only be called when disk is ejected.
  2682. * The implementation supports setting "no disk" by using an
  2683. * index >= get_num_images().
  2684. */
  2685. typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index);
  2686. /* Gets total number of images which are available to use. */
  2687. typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void);
  2688. struct retro_game_info;
  2689. /* Replaces the disk image associated with index.
  2690. * Arguments to pass in info have same requirements as retro_load_game().
  2691. * Virtual disk tray must be ejected when calling this.
  2692. *
  2693. * Replacing a disk image with info = NULL will remove the disk image
  2694. * from the internal list.
  2695. * As a result, calls to get_image_index() can change.
  2696. *
  2697. * E.g. replace_image_index(1, NULL), and previous get_image_index()
  2698. * returned 4 before.
  2699. * Index 1 will be removed, and the new index is 3.
  2700. */
  2701. typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index,
  2702. const struct retro_game_info *info);
  2703. /* Adds a new valid index (get_num_images()) to the internal disk list.
  2704. * This will increment subsequent return values from get_num_images() by 1.
  2705. * This image index cannot be used until a disk image has been set
  2706. * with replace_image_index. */
  2707. typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void);
  2708. /* Sets initial image to insert in drive when calling
  2709. * core_load_game().
  2710. * Since we cannot pass the initial index when loading
  2711. * content (this would require a major API change), this
  2712. * is set by the frontend *before* calling the core's
  2713. * retro_load_game()/retro_load_game_special() implementation.
  2714. * A core should therefore cache the index/path values and handle
  2715. * them inside retro_load_game()/retro_load_game_special().
  2716. * - If 'index' is invalid (index >= get_num_images()), the
  2717. * core should ignore the set value and instead use 0
  2718. * - 'path' is used purely for error checking - i.e. when
  2719. * content is loaded, the core should verify that the
  2720. * disk specified by 'index' has the specified file path.
  2721. * This is to guard against auto selecting the wrong image
  2722. * if (for example) the user should modify an existing M3U
  2723. * playlist. We have to let the core handle this because
  2724. * set_initial_image() must be called before loading content,
  2725. * i.e. the frontend cannot access image paths in advance
  2726. * and thus cannot perform the error check itself.
  2727. * If set path and content path do not match, the core should
  2728. * ignore the set 'index' value and instead use 0
  2729. * Returns 'false' if index or 'path' are invalid, or core
  2730. * does not support this functionality
  2731. */
  2732. typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const char *path);
  2733. /* Fetches the path of the specified disk image file.
  2734. * Returns 'false' if index is invalid (index >= get_num_images())
  2735. * or path is otherwise unavailable.
  2736. */
  2737. typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len);
  2738. /* Fetches a core-provided 'label' for the specified disk
  2739. * image file. In the simplest case this may be a file name
  2740. * (without extension), but for cores with more complex
  2741. * content requirements information may be provided to
  2742. * facilitate user disk swapping - for example, a core
  2743. * running floppy-disk-based content may uniquely label
  2744. * save disks, data disks, level disks, etc. with names
  2745. * corresponding to in-game disk change prompts (so the
  2746. * frontend can provide better user guidance than a 'dumb'
  2747. * disk index value).
  2748. * Returns 'false' if index is invalid (index >= get_num_images())
  2749. * or label is otherwise unavailable.
  2750. */
  2751. typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len);
  2752. struct retro_disk_control_callback
  2753. {
  2754. retro_set_eject_state_t set_eject_state;
  2755. retro_get_eject_state_t get_eject_state;
  2756. retro_get_image_index_t get_image_index;
  2757. retro_set_image_index_t set_image_index;
  2758. retro_get_num_images_t get_num_images;
  2759. retro_replace_image_index_t replace_image_index;
  2760. retro_add_image_index_t add_image_index;
  2761. };
  2762. struct retro_disk_control_ext_callback
  2763. {
  2764. retro_set_eject_state_t set_eject_state;
  2765. retro_get_eject_state_t get_eject_state;
  2766. retro_get_image_index_t get_image_index;
  2767. retro_set_image_index_t set_image_index;
  2768. retro_get_num_images_t get_num_images;
  2769. retro_replace_image_index_t replace_image_index;
  2770. retro_add_image_index_t add_image_index;
  2771. /* NOTE: Frontend will only attempt to record/restore
  2772. * last used disk index if both set_initial_image()
  2773. * and get_image_path() are implemented */
  2774. retro_set_initial_image_t set_initial_image; /* Optional - may be NULL */
  2775. retro_get_image_path_t get_image_path; /* Optional - may be NULL */
  2776. retro_get_image_label_t get_image_label; /* Optional - may be NULL */
  2777. };
  2778. enum retro_pixel_format
  2779. {
  2780. /* 0RGB1555, native endian.
  2781. * 0 bit must be set to 0.
  2782. * This pixel format is default for compatibility concerns only.
  2783. * If a 15/16-bit pixel format is desired, consider using RGB565. */
  2784. RETRO_PIXEL_FORMAT_0RGB1555 = 0,
  2785. /* XRGB8888, native endian.
  2786. * X bits are ignored. */
  2787. RETRO_PIXEL_FORMAT_XRGB8888 = 1,
  2788. /* RGB565, native endian.
  2789. * This pixel format is the recommended format to use if a 15/16-bit
  2790. * format is desired as it is the pixel format that is typically
  2791. * available on a wide range of low-power devices.
  2792. *
  2793. * It is also natively supported in APIs like OpenGL ES. */
  2794. RETRO_PIXEL_FORMAT_RGB565 = 2,
  2795. /* Ensure sizeof() == sizeof(int). */
  2796. RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX
  2797. };
  2798. enum retro_savestate_context
  2799. {
  2800. /* Standard savestate written to disk. */
  2801. RETRO_SAVESTATE_CONTEXT_NORMAL = 0,
  2802. /* Savestate where you are guaranteed that the same instance will load the save state.
  2803. * You can store internal pointers to code or data.
  2804. * It's still a full serialization and deserialization, and could be loaded or saved at any time.
  2805. * It won't be written to disk or sent over the network.
  2806. */
  2807. RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1,
  2808. /* Savestate where you are guaranteed that the same emulator binary will load that savestate.
  2809. * You can skip anything that would slow down saving or loading state but you can not store internal pointers.
  2810. * It won't be written to disk or sent over the network.
  2811. * Example: "Second Instance" runahead
  2812. */
  2813. RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY = 2,
  2814. /* Savestate used within a rollback netplay feature.
  2815. * You should skip anything that would unnecessarily increase bandwidth usage.
  2816. * It won't be written to disk but it will be sent over the network.
  2817. */
  2818. RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY = 3,
  2819. /* Ensure sizeof() == sizeof(int). */
  2820. RETRO_SAVESTATE_CONTEXT_UNKNOWN = INT_MAX
  2821. };
  2822. struct retro_message
  2823. {
  2824. const char *msg; /* Message to be displayed. */
  2825. unsigned frames; /* Duration in frames of message. */
  2826. };
  2827. enum retro_message_target
  2828. {
  2829. RETRO_MESSAGE_TARGET_ALL = 0,
  2830. RETRO_MESSAGE_TARGET_OSD,
  2831. RETRO_MESSAGE_TARGET_LOG
  2832. };
  2833. enum retro_message_type
  2834. {
  2835. RETRO_MESSAGE_TYPE_NOTIFICATION = 0,
  2836. RETRO_MESSAGE_TYPE_NOTIFICATION_ALT,
  2837. RETRO_MESSAGE_TYPE_STATUS,
  2838. RETRO_MESSAGE_TYPE_PROGRESS
  2839. };
  2840. struct retro_message_ext
  2841. {
  2842. /* Message string to be displayed/logged */
  2843. const char *msg;
  2844. /* Duration (in ms) of message when targeting the OSD */
  2845. unsigned duration;
  2846. /* Message priority when targeting the OSD
  2847. * > When multiple concurrent messages are sent to
  2848. * the frontend and the frontend does not have the
  2849. * capacity to display them all, messages with the
  2850. * *highest* priority value should be shown
  2851. * > There is no upper limit to a message priority
  2852. * value (within the bounds of the unsigned data type)
  2853. * > In the reference frontend (RetroArch), the same
  2854. * priority values are used for frontend-generated
  2855. * notifications, which are typically assigned values
  2856. * between 0 and 3 depending upon importance */
  2857. unsigned priority;
  2858. /* Message logging level (info, warn, error, etc.) */
  2859. enum retro_log_level level;
  2860. /* Message destination: OSD, logging interface or both */
  2861. enum retro_message_target target;
  2862. /* Message 'type' when targeting the OSD
  2863. * > RETRO_MESSAGE_TYPE_NOTIFICATION: Specifies that a
  2864. * message should be handled in identical fashion to
  2865. * a standard frontend-generated notification
  2866. * > RETRO_MESSAGE_TYPE_NOTIFICATION_ALT: Specifies that
  2867. * message is a notification that requires user attention
  2868. * or action, but that it should be displayed in a manner
  2869. * that differs from standard frontend-generated notifications.
  2870. * This would typically correspond to messages that should be
  2871. * displayed immediately (independently from any internal
  2872. * frontend message queue), and/or which should be visually
  2873. * distinguishable from frontend-generated notifications.
  2874. * For example, a core may wish to inform the user of
  2875. * information related to a disk-change event. It is
  2876. * expected that the frontend itself may provide a
  2877. * notification in this case; if the core sends a
  2878. * message of type RETRO_MESSAGE_TYPE_NOTIFICATION, an
  2879. * uncomfortable 'double-notification' may occur. A message
  2880. * of RETRO_MESSAGE_TYPE_NOTIFICATION_ALT should therefore
  2881. * be presented such that visual conflict with regular
  2882. * notifications does not occur
  2883. * > RETRO_MESSAGE_TYPE_STATUS: Indicates that message
  2884. * is not a standard notification. This typically
  2885. * corresponds to 'status' indicators, such as a core's
  2886. * internal FPS, which are intended to be displayed
  2887. * either permanently while a core is running, or in
  2888. * a manner that does not suggest user attention or action
  2889. * is required. 'Status' type messages should therefore be
  2890. * displayed in a different on-screen location and in a manner
  2891. * easily distinguishable from both standard frontend-generated
  2892. * notifications and messages of type RETRO_MESSAGE_TYPE_NOTIFICATION_ALT
  2893. * > RETRO_MESSAGE_TYPE_PROGRESS: Indicates that message reports
  2894. * the progress of an internal core task. For example, in cases
  2895. * where a core itself handles the loading of content from a file,
  2896. * this may correspond to the percentage of the file that has been
  2897. * read. Alternatively, an audio/video playback core may use a
  2898. * message of type RETRO_MESSAGE_TYPE_PROGRESS to display the current
  2899. * playback position as a percentage of the runtime. 'Progress' type
  2900. * messages should therefore be displayed as a literal progress bar,
  2901. * where:
  2902. * - 'retro_message_ext.msg' is the progress bar title/label
  2903. * - 'retro_message_ext.progress' determines the length of
  2904. * the progress bar
  2905. * NOTE: Message type is a *hint*, and may be ignored
  2906. * by the frontend. If a frontend lacks support for
  2907. * displaying messages via alternate means than standard
  2908. * frontend-generated notifications, it will treat *all*
  2909. * messages as having the type RETRO_MESSAGE_TYPE_NOTIFICATION */
  2910. enum retro_message_type type;
  2911. /* Task progress when targeting the OSD and message is
  2912. * of type RETRO_MESSAGE_TYPE_PROGRESS
  2913. * > -1: Unmetered/indeterminate
  2914. * > 0-100: Current progress percentage
  2915. * NOTE: Since message type is a hint, a frontend may ignore
  2916. * progress values. Where relevant, a core should therefore
  2917. * include progress percentage within the message string,
  2918. * such that the message intent remains clear when displayed
  2919. * as a standard frontend-generated notification */
  2920. int8_t progress;
  2921. };
  2922. /* Describes how the libretro implementation maps a libretro input bind
  2923. * to its internal input system through a human readable string.
  2924. * This string can be used to better let a user configure input. */
  2925. struct retro_input_descriptor
  2926. {
  2927. /* Associates given parameters with a description. */
  2928. unsigned port;
  2929. unsigned device;
  2930. unsigned index;
  2931. unsigned id;
  2932. /* Human readable description for parameters.
  2933. * The pointer must remain valid until
  2934. * retro_unload_game() is called. */
  2935. const char *description;
  2936. };
  2937. struct retro_system_info
  2938. {
  2939. /* All pointers are owned by libretro implementation, and pointers must
  2940. * remain valid until it is unloaded. */
  2941. const char *library_name; /* Descriptive name of library. Should not
  2942. * contain any version numbers, etc. */
  2943. const char *library_version; /* Descriptive version of core. */
  2944. const char *valid_extensions; /* A string listing probably content
  2945. * extensions the core will be able to
  2946. * load, separated with pipe.
  2947. * I.e. "bin|rom|iso".
  2948. * Typically used for a GUI to filter
  2949. * out extensions. */
  2950. /* Libretro cores that need to have direct access to their content
  2951. * files, including cores which use the path of the content files to
  2952. * determine the paths of other files, should set need_fullpath to true.
  2953. *
  2954. * Cores should strive for setting need_fullpath to false,
  2955. * as it allows the frontend to perform patching, etc.
  2956. *
  2957. * If need_fullpath is true and retro_load_game() is called:
  2958. * - retro_game_info::path is guaranteed to have a valid path
  2959. * - retro_game_info::data and retro_game_info::size are invalid
  2960. *
  2961. * If need_fullpath is false and retro_load_game() is called:
  2962. * - retro_game_info::path may be NULL
  2963. * - retro_game_info::data and retro_game_info::size are guaranteed
  2964. * to be valid
  2965. *
  2966. * See also:
  2967. * - RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY
  2968. * - RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY
  2969. */
  2970. bool need_fullpath;
  2971. /* If true, the frontend is not allowed to extract any archives before
  2972. * loading the real content.
  2973. * Necessary for certain libretro implementations that load games
  2974. * from zipped archives. */
  2975. bool block_extract;
  2976. };
  2977. /* Defines overrides which modify frontend handling of
  2978. * specific content file types.
  2979. * An array of retro_system_content_info_override is
  2980. * passed to RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
  2981. * NOTE: In the following descriptions, references to
  2982. * retro_load_game() may be replaced with
  2983. * retro_load_game_special() */
  2984. struct retro_system_content_info_override
  2985. {
  2986. /* A list of file extensions for which the override
  2987. * should apply, delimited by a 'pipe' character
  2988. * (e.g. "md|sms|gg")
  2989. * Permitted file extensions are limited to those
  2990. * included in retro_system_info::valid_extensions
  2991. * and/or retro_subsystem_rom_info::valid_extensions */
  2992. const char *extensions;
  2993. /* Overrides the need_fullpath value set in
  2994. * retro_system_info and/or retro_subsystem_rom_info.
  2995. * To reiterate:
  2996. *
  2997. * If need_fullpath is true and retro_load_game() is called:
  2998. * - retro_game_info::path is guaranteed to contain a valid
  2999. * path to an existent file
  3000. * - retro_game_info::data and retro_game_info::size are invalid
  3001. *
  3002. * If need_fullpath is false and retro_load_game() is called:
  3003. * - retro_game_info::path may be NULL
  3004. * - retro_game_info::data and retro_game_info::size are guaranteed
  3005. * to be valid
  3006. *
  3007. * In addition:
  3008. *
  3009. * If need_fullpath is true and retro_load_game() is called:
  3010. * - retro_game_info_ext::full_path is guaranteed to contain a valid
  3011. * path to an existent file
  3012. * - retro_game_info_ext::archive_path may be NULL
  3013. * - retro_game_info_ext::archive_file may be NULL
  3014. * - retro_game_info_ext::dir is guaranteed to contain a valid path
  3015. * to the directory in which the content file exists
  3016. * - retro_game_info_ext::name is guaranteed to contain the
  3017. * basename of the content file, without extension
  3018. * - retro_game_info_ext::ext is guaranteed to contain the
  3019. * extension of the content file in lower case format
  3020. * - retro_game_info_ext::data and retro_game_info_ext::size
  3021. * are invalid
  3022. *
  3023. * If need_fullpath is false and retro_load_game() is called:
  3024. * - If retro_game_info_ext::file_in_archive is false:
  3025. * - retro_game_info_ext::full_path is guaranteed to contain
  3026. * a valid path to an existent file
  3027. * - retro_game_info_ext::archive_path may be NULL
  3028. * - retro_game_info_ext::archive_file may be NULL
  3029. * - retro_game_info_ext::dir is guaranteed to contain a
  3030. * valid path to the directory in which the content file exists
  3031. * - retro_game_info_ext::name is guaranteed to contain the
  3032. * basename of the content file, without extension
  3033. * - retro_game_info_ext::ext is guaranteed to contain the
  3034. * extension of the content file in lower case format
  3035. * - If retro_game_info_ext::file_in_archive is true:
  3036. * - retro_game_info_ext::full_path may be NULL
  3037. * - retro_game_info_ext::archive_path is guaranteed to
  3038. * contain a valid path to an existent compressed file
  3039. * inside which the content file is located
  3040. * - retro_game_info_ext::archive_file is guaranteed to
  3041. * contain a valid path to an existent content file
  3042. * inside the compressed file referred to by
  3043. * retro_game_info_ext::archive_path
  3044. * e.g. for a compressed file '/path/to/foo.zip'
  3045. * containing 'bar.sfc'
  3046. * > retro_game_info_ext::archive_path will be '/path/to/foo.zip'
  3047. * > retro_game_info_ext::archive_file will be 'bar.sfc'
  3048. * - retro_game_info_ext::dir is guaranteed to contain a
  3049. * valid path to the directory in which the compressed file
  3050. * (containing the content file) exists
  3051. * - retro_game_info_ext::name is guaranteed to contain
  3052. * EITHER
  3053. * 1) the basename of the compressed file (containing
  3054. * the content file), without extension
  3055. * OR
  3056. * 2) the basename of the content file inside the
  3057. * compressed file, without extension
  3058. * In either case, a core should consider 'name' to
  3059. * be the canonical name/ID of the the content file
  3060. * - retro_game_info_ext::ext is guaranteed to contain the
  3061. * extension of the content file inside the compressed file,
  3062. * in lower case format
  3063. * - retro_game_info_ext::data and retro_game_info_ext::size are
  3064. * guaranteed to be valid */
  3065. bool need_fullpath;
  3066. /* If need_fullpath is false, specifies whether the content
  3067. * data buffer available in retro_load_game() is 'persistent'
  3068. *
  3069. * If persistent_data is false and retro_load_game() is called:
  3070. * - retro_game_info::data and retro_game_info::size
  3071. * are valid only until retro_load_game() returns
  3072. * - retro_game_info_ext::data and retro_game_info_ext::size
  3073. * are valid only until retro_load_game() returns
  3074. *
  3075. * If persistent_data is true and retro_load_game() is called:
  3076. * - retro_game_info::data and retro_game_info::size
  3077. * are valid until retro_deinit() returns
  3078. * - retro_game_info_ext::data and retro_game_info_ext::size
  3079. * are valid until retro_deinit() returns */
  3080. bool persistent_data;
  3081. };
  3082. /* Similar to retro_game_info, but provides extended
  3083. * information about the source content file and
  3084. * game memory buffer status.
  3085. * And array of retro_game_info_ext is returned by
  3086. * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
  3087. * NOTE: In the following descriptions, references to
  3088. * retro_load_game() may be replaced with
  3089. * retro_load_game_special() */
  3090. struct retro_game_info_ext
  3091. {
  3092. /* - If file_in_archive is false, contains a valid
  3093. * path to an existent content file (UTF-8 encoded)
  3094. * - If file_in_archive is true, may be NULL */
  3095. const char *full_path;
  3096. /* - If file_in_archive is false, may be NULL
  3097. * - If file_in_archive is true, contains a valid path
  3098. * to an existent compressed file inside which the
  3099. * content file is located (UTF-8 encoded) */
  3100. const char *archive_path;
  3101. /* - If file_in_archive is false, may be NULL
  3102. * - If file_in_archive is true, contain a valid path
  3103. * to an existent content file inside the compressed
  3104. * file referred to by archive_path (UTF-8 encoded)
  3105. * e.g. for a compressed file '/path/to/foo.zip'
  3106. * containing 'bar.sfc'
  3107. * > archive_path will be '/path/to/foo.zip'
  3108. * > archive_file will be 'bar.sfc' */
  3109. const char *archive_file;
  3110. /* - If file_in_archive is false, contains a valid path
  3111. * to the directory in which the content file exists
  3112. * (UTF-8 encoded)
  3113. * - If file_in_archive is true, contains a valid path
  3114. * to the directory in which the compressed file
  3115. * (containing the content file) exists (UTF-8 encoded) */
  3116. const char *dir;
  3117. /* Contains the canonical name/ID of the content file
  3118. * (UTF-8 encoded). Intended for use when identifying
  3119. * 'complementary' content named after the loaded file -
  3120. * i.e. companion data of a different format (a CD image
  3121. * required by a ROM), texture packs, internally handled
  3122. * save files, etc.
  3123. * - If file_in_archive is false, contains the basename
  3124. * of the content file, without extension
  3125. * - If file_in_archive is true, then string is
  3126. * implementation specific. A frontend may choose to
  3127. * set a name value of:
  3128. * EITHER
  3129. * 1) the basename of the compressed file (containing
  3130. * the content file), without extension
  3131. * OR
  3132. * 2) the basename of the content file inside the
  3133. * compressed file, without extension
  3134. * RetroArch sets the 'name' value according to (1).
  3135. * A frontend that supports routine loading of
  3136. * content from archives containing multiple unrelated
  3137. * content files may set the 'name' value according
  3138. * to (2). */
  3139. const char *name;
  3140. /* - If file_in_archive is false, contains the extension
  3141. * of the content file in lower case format
  3142. * - If file_in_archive is true, contains the extension
  3143. * of the content file inside the compressed file,
  3144. * in lower case format */
  3145. const char *ext;
  3146. /* String of implementation specific meta-data. */
  3147. const char *meta;
  3148. /* Memory buffer of loaded game content. Will be NULL:
  3149. * IF
  3150. * - retro_system_info::need_fullpath is true and
  3151. * retro_system_content_info_override::need_fullpath
  3152. * is unset
  3153. * OR
  3154. * - retro_system_content_info_override::need_fullpath
  3155. * is true */
  3156. const void *data;
  3157. /* Size of game content memory buffer, in bytes */
  3158. size_t size;
  3159. /* True if loaded content file is inside a compressed
  3160. * archive */
  3161. bool file_in_archive;
  3162. /* - If data is NULL, value is unset/ignored
  3163. * - If data is non-NULL:
  3164. * - If persistent_data is false, data and size are
  3165. * valid only until retro_load_game() returns
  3166. * - If persistent_data is true, data and size are
  3167. * are valid until retro_deinit() returns */
  3168. bool persistent_data;
  3169. };
  3170. struct retro_game_geometry
  3171. {
  3172. unsigned base_width; /* Nominal video width of game. */
  3173. unsigned base_height; /* Nominal video height of game. */
  3174. unsigned max_width; /* Maximum possible width of game. */
  3175. unsigned max_height; /* Maximum possible height of game. */
  3176. float aspect_ratio; /* Nominal aspect ratio of game. If
  3177. * aspect_ratio is <= 0.0, an aspect ratio
  3178. * of base_width / base_height is assumed.
  3179. * A frontend could override this setting,
  3180. * if desired. */
  3181. };
  3182. struct retro_system_timing
  3183. {
  3184. double fps; /* FPS of video content. */
  3185. double sample_rate; /* Sampling rate of audio. */
  3186. };
  3187. struct retro_system_av_info
  3188. {
  3189. struct retro_game_geometry geometry;
  3190. struct retro_system_timing timing;
  3191. };
  3192. struct retro_variable
  3193. {
  3194. /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
  3195. * If NULL, obtains the complete environment string if more
  3196. * complex parsing is necessary.
  3197. * The environment string is formatted as key-value pairs
  3198. * delimited by semicolons as so:
  3199. * "key1=value1;key2=value2;..."
  3200. */
  3201. const char *key;
  3202. /* Value to be obtained. If key does not exist, it is set to NULL. */
  3203. const char *value;
  3204. };
  3205. struct retro_core_option_display
  3206. {
  3207. /* Variable to configure in RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY */
  3208. const char *key;
  3209. /* Specifies whether variable should be displayed
  3210. * when presenting core options to the user */
  3211. bool visible;
  3212. };
  3213. /* Maximum number of values permitted for a core option
  3214. * > Note: We have to set a maximum value due the limitations
  3215. * of the C language - i.e. it is not possible to create an
  3216. * array of structs each containing a variable sized array,
  3217. * so the retro_core_option_definition values array must
  3218. * have a fixed size. The size limit of 128 is a balancing
  3219. * act - it needs to be large enough to support all 'sane'
  3220. * core options, but setting it too large may impact low memory
  3221. * platforms. In practise, if a core option has more than
  3222. * 128 values then the implementation is likely flawed.
  3223. * To quote the above API reference:
  3224. * "The number of possible options should be very limited
  3225. * i.e. it should be feasible to cycle through options
  3226. * without a keyboard."
  3227. */
  3228. #define RETRO_NUM_CORE_OPTION_VALUES_MAX 128
  3229. struct retro_core_option_value
  3230. {
  3231. /* Expected option value */
  3232. const char *value;
  3233. /* Human-readable value label. If NULL, value itself
  3234. * will be displayed by the frontend */
  3235. const char *label;
  3236. };
  3237. struct retro_core_option_definition
  3238. {
  3239. /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. */
  3240. const char *key;
  3241. /* Human-readable core option description (used as menu label) */
  3242. const char *desc;
  3243. /* Human-readable core option information (used as menu sublabel) */
  3244. const char *info;
  3245. /* Array of retro_core_option_value structs, terminated by NULL */
  3246. struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
  3247. /* Default core option value. Must match one of the values
  3248. * in the retro_core_option_value array, otherwise will be
  3249. * ignored */
  3250. const char *default_value;
  3251. };
  3252. #ifdef __PS3__
  3253. #undef local
  3254. #endif
  3255. struct retro_core_options_intl
  3256. {
  3257. /* Pointer to an array of retro_core_option_definition structs
  3258. * - US English implementation
  3259. * - Must point to a valid array */
  3260. struct retro_core_option_definition *us;
  3261. /* Pointer to an array of retro_core_option_definition structs
  3262. * - Implementation for current frontend language
  3263. * - May be NULL */
  3264. struct retro_core_option_definition *local;
  3265. };
  3266. struct retro_core_option_v2_category
  3267. {
  3268. /* Variable uniquely identifying the
  3269. * option category. Valid key characters
  3270. * are [a-z, A-Z, 0-9, _, -] */
  3271. const char *key;
  3272. /* Human-readable category description
  3273. * > Used as category menu label when
  3274. * frontend has core option category
  3275. * support */
  3276. const char *desc;
  3277. /* Human-readable category information
  3278. * > Used as category menu sublabel when
  3279. * frontend has core option category
  3280. * support
  3281. * > Optional (may be NULL or an empty
  3282. * string) */
  3283. const char *info;
  3284. };
  3285. struct retro_core_option_v2_definition
  3286. {
  3287. /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
  3288. * Valid key characters are [a-z, A-Z, 0-9, _, -] */
  3289. const char *key;
  3290. /* Human-readable core option description
  3291. * > Used as menu label when frontend does
  3292. * not have core option category support
  3293. * e.g. "Video > Aspect Ratio" */
  3294. const char *desc;
  3295. /* Human-readable core option description
  3296. * > Used as menu label when frontend has
  3297. * core option category support
  3298. * e.g. "Aspect Ratio", where associated
  3299. * retro_core_option_v2_category::desc
  3300. * is "Video"
  3301. * > If empty or NULL, the string specified by
  3302. * desc will be used as the menu label
  3303. * > Will be ignored (and may be set to NULL)
  3304. * if category_key is empty or NULL */
  3305. const char *desc_categorized;
  3306. /* Human-readable core option information
  3307. * > Used as menu sublabel */
  3308. const char *info;
  3309. /* Human-readable core option information
  3310. * > Used as menu sublabel when frontend
  3311. * has core option category support
  3312. * (e.g. may be required when info text
  3313. * references an option by name/desc,
  3314. * and the desc/desc_categorized text
  3315. * for that option differ)
  3316. * > If empty or NULL, the string specified by
  3317. * info will be used as the menu sublabel
  3318. * > Will be ignored (and may be set to NULL)
  3319. * if category_key is empty or NULL */
  3320. const char *info_categorized;
  3321. /* Variable specifying category (e.g. "video",
  3322. * "audio") that will be assigned to the option
  3323. * if frontend has core option category support.
  3324. * > Categorized options will be displayed in a
  3325. * subsection/submenu of the frontend core
  3326. * option interface
  3327. * > Specified string must match one of the
  3328. * retro_core_option_v2_category::key values
  3329. * in the associated retro_core_option_v2_category
  3330. * array; If no match is not found, specified
  3331. * string will be considered as NULL
  3332. * > If specified string is empty or NULL, option will
  3333. * have no category and will be shown at the top
  3334. * level of the frontend core option interface */
  3335. const char *category_key;
  3336. /* Array of retro_core_option_value structs, terminated by NULL */
  3337. struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
  3338. /* Default core option value. Must match one of the values
  3339. * in the retro_core_option_value array, otherwise will be
  3340. * ignored */
  3341. const char *default_value;
  3342. };
  3343. struct retro_core_options_v2
  3344. {
  3345. /* Array of retro_core_option_v2_category structs,
  3346. * terminated by NULL
  3347. * > If NULL, all entries in definitions array
  3348. * will have no category and will be shown at
  3349. * the top level of the frontend core option
  3350. * interface
  3351. * > Will be ignored if frontend does not have
  3352. * core option category support */
  3353. struct retro_core_option_v2_category *categories;
  3354. /* Array of retro_core_option_v2_definition structs,
  3355. * terminated by NULL */
  3356. struct retro_core_option_v2_definition *definitions;
  3357. };
  3358. struct retro_core_options_v2_intl
  3359. {
  3360. /* Pointer to a retro_core_options_v2 struct
  3361. * > US English implementation
  3362. * > Must point to a valid struct */
  3363. struct retro_core_options_v2 *us;
  3364. /* Pointer to a retro_core_options_v2 struct
  3365. * - Implementation for current frontend language
  3366. * - May be NULL */
  3367. struct retro_core_options_v2 *local;
  3368. };
  3369. /* Used by the frontend to monitor changes in core option
  3370. * visibility. May be called each time any core option
  3371. * value is set via the frontend.
  3372. * - On each invocation, the core must update the visibility
  3373. * of any dynamically hidden options using the
  3374. * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY environment
  3375. * callback.
  3376. * - On the first invocation, returns 'true' if the visibility
  3377. * of any core option has changed since the last call of
  3378. * retro_load_game() or retro_load_game_special().
  3379. * - On each subsequent invocation, returns 'true' if the
  3380. * visibility of any core option has changed since the last
  3381. * time the function was called. */
  3382. typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void);
  3383. struct retro_core_options_update_display_callback
  3384. {
  3385. retro_core_options_update_display_callback_t callback;
  3386. };
  3387. struct retro_game_info
  3388. {
  3389. const char *path; /* Path to game, UTF-8 encoded.
  3390. * Sometimes used as a reference for building other paths.
  3391. * May be NULL if game was loaded from stdin or similar,
  3392. * but in this case some cores will be unable to load `data`.
  3393. * So, it is preferable to fabricate something here instead
  3394. * of passing NULL, which will help more cores to succeed.
  3395. * retro_system_info::need_fullpath requires
  3396. * that this path is valid. */
  3397. const void *data; /* Memory buffer of loaded game. Will be NULL
  3398. * if need_fullpath was set. */
  3399. size_t size; /* Size of memory buffer. */
  3400. const char *meta; /* String of implementation specific meta-data. */
  3401. };
  3402. #define RETRO_MEMORY_ACCESS_WRITE (1 << 0)
  3403. /* The core will write to the buffer provided by retro_framebuffer::data. */
  3404. #define RETRO_MEMORY_ACCESS_READ (1 << 1)
  3405. /* The core will read from retro_framebuffer::data. */
  3406. #define RETRO_MEMORY_TYPE_CACHED (1 << 0)
  3407. /* The memory in data is cached.
  3408. * If not cached, random writes and/or reading from the buffer is expected to be very slow. */
  3409. struct retro_framebuffer
  3410. {
  3411. void *data; /* The framebuffer which the core can render into.
  3412. Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.
  3413. The initial contents of data are unspecified. */
  3414. unsigned width; /* The framebuffer width used by the core. Set by core. */
  3415. unsigned height; /* The framebuffer height used by the core. Set by core. */
  3416. size_t pitch; /* The number of bytes between the beginning of a scanline,
  3417. and beginning of the next scanline.
  3418. Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
  3419. enum retro_pixel_format format; /* The pixel format the core must use to render into data.
  3420. This format could differ from the format used in
  3421. SET_PIXEL_FORMAT.
  3422. Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
  3423. unsigned access_flags; /* How the core will access the memory in the framebuffer.
  3424. RETRO_MEMORY_ACCESS_* flags.
  3425. Set by core. */
  3426. unsigned memory_flags; /* Flags telling core how the memory has been mapped.
  3427. RETRO_MEMORY_TYPE_* flags.
  3428. Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
  3429. };
  3430. /* Used by a libretro core to override the current
  3431. * fastforwarding mode of the frontend */
  3432. struct retro_fastforwarding_override
  3433. {
  3434. /* Specifies the runtime speed multiplier that
  3435. * will be applied when 'fastforward' is true.
  3436. * For example, a value of 5.0 when running 60 FPS
  3437. * content will cap the fast-forward rate at 300 FPS.
  3438. * Note that the target multiplier may not be achieved
  3439. * if the host hardware has insufficient processing
  3440. * power.
  3441. * Setting a value of 0.0 (or greater than 0.0 but
  3442. * less than 1.0) will result in an uncapped
  3443. * fast-forward rate (limited only by hardware
  3444. * capacity).
  3445. * If the value is negative, it will be ignored
  3446. * (i.e. the frontend will use a runtime speed
  3447. * multiplier of its own choosing) */
  3448. float ratio;
  3449. /* If true, fastforwarding mode will be enabled.
  3450. * If false, fastforwarding mode will be disabled. */
  3451. bool fastforward;
  3452. /* If true, and if supported by the frontend, an
  3453. * on-screen notification will be displayed while
  3454. * 'fastforward' is true.
  3455. * If false, and if supported by the frontend, any
  3456. * on-screen fast-forward notifications will be
  3457. * suppressed */
  3458. bool notification;
  3459. /* If true, the core will have sole control over
  3460. * when fastforwarding mode is enabled/disabled;
  3461. * the frontend will not be able to change the
  3462. * state set by 'fastforward' until either
  3463. * 'inhibit_toggle' is set to false, or the core
  3464. * is unloaded */
  3465. bool inhibit_toggle;
  3466. };
  3467. /* During normal operation. Rate will be equal to the core's internal FPS. */
  3468. #define RETRO_THROTTLE_NONE 0
  3469. /* While paused or stepping single frames. Rate will be 0. */
  3470. #define RETRO_THROTTLE_FRAME_STEPPING 1
  3471. /* During fast forwarding.
  3472. * Rate will be 0 if not specifically limited to a maximum speed. */
  3473. #define RETRO_THROTTLE_FAST_FORWARD 2
  3474. /* During slow motion. Rate will be less than the core's internal FPS. */
  3475. #define RETRO_THROTTLE_SLOW_MOTION 3
  3476. /* While rewinding recorded save states. Rate can vary depending on the rewind
  3477. * speed or be 0 if the frontend is not aiming for a specific rate. */
  3478. #define RETRO_THROTTLE_REWINDING 4
  3479. /* While vsync is active in the video driver and the target refresh rate is
  3480. * lower than the core's internal FPS. Rate is the target refresh rate. */
  3481. #define RETRO_THROTTLE_VSYNC 5
  3482. /* When the frontend does not throttle in any way. Rate will be 0.
  3483. * An example could be if no vsync or audio output is active. */
  3484. #define RETRO_THROTTLE_UNBLOCKED 6
  3485. struct retro_throttle_state
  3486. {
  3487. /* The current throttling mode. Should be one of the values above. */
  3488. unsigned mode;
  3489. /* How many times per second the frontend aims to call retro_run.
  3490. * Depending on the mode, it can be 0 if there is no known fixed rate.
  3491. * This won't be accurate if the total processing time of the core and
  3492. * the frontend is longer than what is available for one frame. */
  3493. float rate;
  3494. };
  3495. /**
  3496. * Opaque handle to a microphone that's been opened for use.
  3497. * The underlying object is accessed or created with \c retro_microphone_interface_t.
  3498. */
  3499. typedef struct retro_microphone retro_microphone_t;
  3500. /**
  3501. * Parameters for configuring a microphone.
  3502. * Some of these might not be honored,
  3503. * depending on the available hardware and driver configuration.
  3504. */
  3505. typedef struct retro_microphone_params
  3506. {
  3507. /**
  3508. * The desired sample rate of the microphone's input, in Hz.
  3509. * The microphone's input will be resampled,
  3510. * so cores can ask for whichever frequency they need.
  3511. *
  3512. * If zero, some reasonable default will be provided by the frontend
  3513. * (usually from its config file).
  3514. *
  3515. * @see retro_get_mic_rate_t
  3516. */
  3517. unsigned rate;
  3518. } retro_microphone_params_t;
  3519. /**
  3520. * @copydoc retro_microphone_interface::open_mic
  3521. */
  3522. typedef retro_microphone_t *(RETRO_CALLCONV *retro_open_mic_t)(const retro_microphone_params_t *params);
  3523. /**
  3524. * @copydoc retro_microphone_interface::close_mic
  3525. */
  3526. typedef void (RETRO_CALLCONV *retro_close_mic_t)(retro_microphone_t *microphone);
  3527. /**
  3528. * @copydoc retro_microphone_interface::get_params
  3529. */
  3530. typedef bool (RETRO_CALLCONV *retro_get_mic_params_t)(const retro_microphone_t *microphone, retro_microphone_params_t *params);
  3531. /**
  3532. * @copydoc retro_microphone_interface::set_mic_state
  3533. */
  3534. typedef bool (RETRO_CALLCONV *retro_set_mic_state_t)(retro_microphone_t *microphone, bool state);
  3535. /**
  3536. * @copydoc retro_microphone_interface::get_mic_state
  3537. */
  3538. typedef bool (RETRO_CALLCONV *retro_get_mic_state_t)(const retro_microphone_t *microphone);
  3539. /**
  3540. * @copydoc retro_microphone_interface::read_mic
  3541. */
  3542. typedef int (RETRO_CALLCONV *retro_read_mic_t)(retro_microphone_t *microphone, int16_t* samples, size_t num_samples);
  3543. /**
  3544. * The current version of the microphone interface.
  3545. * Will be incremented whenever \c retro_microphone_interface or \c retro_microphone_params_t
  3546. * receive new fields.
  3547. *
  3548. * Frontends using cores built against older mic interface versions
  3549. * should not access fields introduced in newer versions.
  3550. */
  3551. #define RETRO_MICROPHONE_INTERFACE_VERSION 1
  3552. /**
  3553. * An interface for querying the microphone and accessing data read from it.
  3554. *
  3555. * @see RETRO_ENVIRONMENT_GET_MICROPHONE_INTERFACE
  3556. */
  3557. struct retro_microphone_interface
  3558. {
  3559. /**
  3560. * The version of this microphone interface.
  3561. * Set by the core to request a particular version,
  3562. * and set by the frontend to indicate the returned version.
  3563. * 0 indicates that the interface is invalid or uninitialized.
  3564. */
  3565. unsigned interface_version;
  3566. /**
  3567. * Initializes a new microphone.
  3568. * Assuming that microphone support is enabled and provided by the frontend,
  3569. * cores may call this function whenever necessary.
  3570. * A microphone could be opened throughout a core's lifetime,
  3571. * or it could wait until a microphone is plugged in to the emulated device.
  3572. *
  3573. * The returned handle will be valid until it's freed,
  3574. * even if the audio driver is reinitialized.
  3575. *
  3576. * This function is not guaranteed to be thread-safe.
  3577. *
  3578. * @param args[in] Parameters used to create the microphone.
  3579. * May be \c NULL, in which case the default value of each parameter will be used.
  3580. *
  3581. * @returns Pointer to the newly-opened microphone,
  3582. * or \c NULL if one couldn't be opened.
  3583. * This likely means that no microphone is plugged in and recognized,
  3584. * or the maximum number of supported microphones has been reached.
  3585. *
  3586. * @note Microphones are \em inactive by default;
  3587. * to begin capturing audio, call \c set_mic_state.
  3588. * @see retro_microphone_params_t
  3589. */
  3590. retro_open_mic_t open_mic;
  3591. /**
  3592. * Closes a microphone that was initialized with \c open_mic.
  3593. * Calling this function will stop all microphone activity
  3594. * and free up the resources that it allocated.
  3595. * Afterwards, the handle is invalid and must not be used.
  3596. *
  3597. * A frontend may close opened microphones when unloading content,
  3598. * but this behavior is not guaranteed.
  3599. * Cores should close their microphones when exiting, just to be safe.
  3600. *
  3601. * @param microphone Pointer to the microphone that was allocated by \c open_mic.
  3602. * If \c NULL, this function does nothing.
  3603. *
  3604. * @note The handle might be reused if another microphone is opened later.
  3605. */
  3606. retro_close_mic_t close_mic;
  3607. /**
  3608. * Returns the configured parameters of this microphone.
  3609. * These may differ from what was requested depending on
  3610. * the driver and device configuration.
  3611. *
  3612. * Cores should check these values before they start fetching samples.
  3613. *
  3614. * Will not change after the mic was opened.
  3615. *
  3616. * @param microphone[in] Opaque handle to the microphone
  3617. * whose parameters will be retrieved.
  3618. * @param params[out] The parameters object that the
  3619. * microphone's parameters will be copied to.
  3620. *
  3621. * @return \c true if the parameters were retrieved,
  3622. * \c false if there was an error.
  3623. */
  3624. retro_get_mic_params_t get_params;
  3625. /**
  3626. * Enables or disables the given microphone.
  3627. * Microphones are disabled by default
  3628. * and must be explicitly enabled before they can be used.
  3629. * Disabled microphones will not process incoming audio samples,
  3630. * and will therefore have minimal impact on overall performance.
  3631. * Cores may enable microphones throughout their lifetime,
  3632. * or only for periods where they're needed.
  3633. *
  3634. * Cores that accept microphone input should be able to operate without it;
  3635. * we suggest substituting silence in this case.
  3636. *
  3637. * @param microphone Opaque handle to the microphone
  3638. * whose state will be adjusted.
  3639. * This will have been provided by \c open_mic.
  3640. * @param state \c true if the microphone should receive audio input,
  3641. * \c false if it should be idle.
  3642. * @returns \c true if the microphone's state was successfully set,
  3643. * \c false if \c microphone is invalid
  3644. * or if there was an error.
  3645. */
  3646. retro_set_mic_state_t set_mic_state;
  3647. /**
  3648. * Queries the active state of a microphone at the given index.
  3649. * Will return whether the microphone is enabled,
  3650. * even if the driver is paused.
  3651. *
  3652. * @param microphone Opaque handle to the microphone
  3653. * whose state will be queried.
  3654. * @return \c true if the provided \c microphone is valid and active,
  3655. * \c false if not or if there was an error.
  3656. */
  3657. retro_get_mic_state_t get_mic_state;
  3658. /**
  3659. * Retrieves the input processed by the microphone since the last call.
  3660. * \em Must be called every frame unless \c microphone is disabled,
  3661. * similar to how \c retro_audio_sample_batch_t works.
  3662. *
  3663. * @param[in] microphone Opaque handle to the microphone
  3664. * whose recent input will be retrieved.
  3665. * @param[out] samples The buffer that will be used to store the microphone's data.
  3666. * Microphone input is in mono (i.e. one number per sample).
  3667. * Should be large enough to accommodate the expected number of samples per frame;
  3668. * for example, a 44.1kHz sample rate at 60 FPS would require space for 735 samples.
  3669. * @param[in] num_samples The size of the data buffer in samples (\em not bytes).
  3670. * Microphone input is in mono, so a "frame" and a "sample" are equivalent in length here.
  3671. *
  3672. * @return The number of samples that were copied into \c samples.
  3673. * If \c microphone is pending driver initialization,
  3674. * this function will copy silence of the requested length into \c samples.
  3675. *
  3676. * Will return -1 if the microphone is disabled,
  3677. * the audio driver is paused,
  3678. * or there was an error.
  3679. */
  3680. retro_read_mic_t read_mic;
  3681. };
  3682. /* Callbacks */
  3683. /* Environment callback. Gives implementations a way of performing
  3684. * uncommon tasks. Extensible. */
  3685. typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data);
  3686. /* Render a frame. Pixel format is 15-bit 0RGB1555 native endian
  3687. * unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).
  3688. *
  3689. * Width and height specify dimensions of buffer.
  3690. * Pitch specifices length in bytes between two lines in buffer.
  3691. *
  3692. * For performance reasons, it is highly recommended to have a frame
  3693. * that is packed in memory, i.e. pitch == width * byte_per_pixel.
  3694. * Certain graphic APIs, such as OpenGL ES, do not like textures
  3695. * that are not packed in memory.
  3696. */
  3697. typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width,
  3698. unsigned height, size_t pitch);
  3699. /* Renders a single audio frame. Should only be used if implementation
  3700. * generates a single sample at a time.
  3701. * Format is signed 16-bit native endian.
  3702. */
  3703. typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right);
  3704. /* Renders multiple audio frames in one go.
  3705. *
  3706. * One frame is defined as a sample of left and right channels, interleaved.
  3707. * I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames.
  3708. * Only one of the audio callbacks must ever be used.
  3709. */
  3710. typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data,
  3711. size_t frames);
  3712. /* Polls input. */
  3713. typedef void (RETRO_CALLCONV *retro_input_poll_t)(void);
  3714. /* Queries for input for player 'port'. device will be masked with
  3715. * RETRO_DEVICE_MASK.
  3716. *
  3717. * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that
  3718. * have been set with retro_set_controller_port_device()
  3719. * will still use the higher level RETRO_DEVICE_JOYPAD to request input.
  3720. */
  3721. typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device,
  3722. unsigned index, unsigned id);
  3723. /* Sets callbacks. retro_set_environment() is guaranteed to be called
  3724. * before retro_init().
  3725. *
  3726. * The rest of the set_* functions are guaranteed to have been called
  3727. * before the first call to retro_run() is made. */
  3728. RETRO_API void retro_set_environment(retro_environment_t);
  3729. RETRO_API void retro_set_video_refresh(retro_video_refresh_t);
  3730. RETRO_API void retro_set_audio_sample(retro_audio_sample_t);
  3731. RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
  3732. RETRO_API void retro_set_input_poll(retro_input_poll_t);
  3733. RETRO_API void retro_set_input_state(retro_input_state_t);
  3734. /* Library global initialization/deinitialization. */
  3735. RETRO_API void retro_init(void);
  3736. RETRO_API void retro_deinit(void);
  3737. /* Must return RETRO_API_VERSION. Used to validate ABI compatibility
  3738. * when the API is revised. */
  3739. RETRO_API unsigned retro_api_version(void);
  3740. /* Gets statically known system info. Pointers provided in *info
  3741. * must be statically allocated.
  3742. * Can be called at any time, even before retro_init(). */
  3743. RETRO_API void retro_get_system_info(struct retro_system_info *info);
  3744. /* Gets information about system audio/video timings and geometry.
  3745. * Can be called only after retro_load_game() has successfully completed.
  3746. * NOTE: The implementation of this function might not initialize every
  3747. * variable if needed.
  3748. * E.g. geom.aspect_ratio might not be initialized if core doesn't
  3749. * desire a particular aspect ratio. */
  3750. RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info);
  3751. /* Sets device to be used for player 'port'.
  3752. * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all
  3753. * available ports.
  3754. * Setting a particular device type is not a guarantee that libretro cores
  3755. * will only poll input based on that particular device type. It is only a
  3756. * hint to the libretro core when a core cannot automatically detect the
  3757. * appropriate input device type on its own. It is also relevant when a
  3758. * core can change its behavior depending on device type.
  3759. *
  3760. * As part of the core's implementation of retro_set_controller_port_device,
  3761. * the core should call RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS to notify the
  3762. * frontend if the descriptions for any controls have changed as a
  3763. * result of changing the device type.
  3764. */
  3765. RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device);
  3766. /* Resets the current game. */
  3767. RETRO_API void retro_reset(void);
  3768. /* Runs the game for one video frame.
  3769. * During retro_run(), input_poll callback must be called at least once.
  3770. *
  3771. * If a frame is not rendered for reasons where a game "dropped" a frame,
  3772. * this still counts as a frame, and retro_run() should explicitly dupe
  3773. * a frame if GET_CAN_DUPE returns true.
  3774. * In this case, the video callback can take a NULL argument for data.
  3775. */
  3776. RETRO_API void retro_run(void);
  3777. /* Returns the amount of data the implementation requires to serialize
  3778. * internal state (save states).
  3779. * Between calls to retro_load_game() and retro_unload_game(), the
  3780. * returned size is never allowed to be larger than a previous returned
  3781. * value, to ensure that the frontend can allocate a save state buffer once.
  3782. */
  3783. RETRO_API size_t retro_serialize_size(void);
  3784. /* Serializes internal state. If failed, or size is lower than
  3785. * retro_serialize_size(), it should return false, true otherwise. */
  3786. RETRO_API bool retro_serialize(void *data, size_t size);
  3787. RETRO_API bool retro_unserialize(const void *data, size_t size);
  3788. RETRO_API void retro_cheat_reset(void);
  3789. RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);
  3790. /* Loads a game.
  3791. * Return true to indicate successful loading and false to indicate load failure.
  3792. */
  3793. RETRO_API bool retro_load_game(const struct retro_game_info *game);
  3794. /* Loads a "special" kind of game. Should not be used,
  3795. * except in extreme cases. */
  3796. RETRO_API bool retro_load_game_special(
  3797. unsigned game_type,
  3798. const struct retro_game_info *info, size_t num_info
  3799. );
  3800. /* Unloads the currently loaded game. Called before retro_deinit(void). */
  3801. RETRO_API void retro_unload_game(void);
  3802. /* Gets region of game. */
  3803. RETRO_API unsigned retro_get_region(void);
  3804. /* Gets region of memory. */
  3805. RETRO_API void *retro_get_memory_data(unsigned id);
  3806. RETRO_API size_t retro_get_memory_size(unsigned id);
  3807. #ifdef __cplusplus
  3808. }
  3809. #endif
  3810. #endif