libretro.h 206 KB

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