disk_control_interface.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /* Copyright (C) 2010-2020 The RetroArch team
  2. *
  3. * ---------------------------------------------------------------------------------------
  4. * The following license statement only applies to this file (disk_control_interface.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 __DISK_CONTROL_INTERFACE_H
  23. #define __DISK_CONTROL_INTERFACE_H
  24. #include <retro_common_api.h>
  25. #include <libretro.h>
  26. #include <boolean.h>
  27. #include "disk_index_file.h"
  28. RETRO_BEGIN_DECLS
  29. /* Holds all objects to operate the disk
  30. * control interface */
  31. typedef struct
  32. {
  33. struct retro_disk_control_ext_callback cb; /* ptr alignment */
  34. disk_index_file_t index_record; /* unsigned alignment */
  35. unsigned initial_num_images;
  36. bool record_enabled;
  37. } disk_control_interface_t;
  38. /*****************/
  39. /* Configuration */
  40. /*****************/
  41. /**
  42. * disk_control_set_callback:
  43. *
  44. * Set v0 disk interface callback functions
  45. **/
  46. void disk_control_set_callback(
  47. disk_control_interface_t *disk_control,
  48. const struct retro_disk_control_callback *cb);
  49. /**
  50. * disk_control_set_ext_callback:
  51. *
  52. * Set v1+ disk interface callback functions
  53. **/
  54. void disk_control_set_ext_callback(
  55. disk_control_interface_t *disk_control,
  56. const struct retro_disk_control_ext_callback *cb);
  57. /**********/
  58. /* Status */
  59. /**********/
  60. /**
  61. * disk_control_enabled:
  62. *
  63. * Leaf function.
  64. *
  65. * @return true if core supports basic disk control functionality
  66. * - set_eject_state
  67. * - get_eject_state
  68. * - get_image_index
  69. * - set_image_index
  70. * - get_num_images
  71. **/
  72. bool disk_control_enabled(
  73. disk_control_interface_t *disk_control);
  74. /**
  75. * disk_control_append_enabled:
  76. *
  77. * Leaf function.
  78. *
  79. * @return true if core supports disk append functionality
  80. * - replace_image_index
  81. * - add_image_index
  82. **/
  83. bool disk_control_append_enabled(
  84. disk_control_interface_t *disk_control);
  85. /**
  86. * disk_control_image_label_enabled:
  87. *
  88. * Leaf function.
  89. *
  90. * @return true if core supports image labels
  91. * - get_image_label
  92. **/
  93. bool disk_control_image_label_enabled(
  94. disk_control_interface_t *disk_control);
  95. /**
  96. * disk_control_initial_image_enabled:
  97. *
  98. * Leaf function.
  99. *
  100. * @return true if core supports setting initial disk index
  101. * - set_initial_image
  102. * - get_image_path
  103. **/
  104. bool disk_control_initial_image_enabled(
  105. disk_control_interface_t *disk_control);
  106. /***********/
  107. /* Getters */
  108. /***********/
  109. /**
  110. * disk_control_get_eject_state:
  111. *
  112. * @return true if disk is currently ejected
  113. **/
  114. bool disk_control_get_eject_state(
  115. disk_control_interface_t *disk_control);
  116. /**
  117. * disk_control_get_num_images:
  118. *
  119. * @return number of disk images registered by the core
  120. **/
  121. unsigned disk_control_get_num_images(
  122. disk_control_interface_t *disk_control);
  123. /**
  124. * disk_control_get_image_index:
  125. *
  126. * @return currently selected disk image index
  127. **/
  128. unsigned disk_control_get_image_index(
  129. disk_control_interface_t *disk_control);
  130. /**
  131. * disk_control_get_image_label:
  132. *
  133. * Fetches core-provided disk image label
  134. * (label is set to an empty string if core
  135. * does not support image labels)
  136. **/
  137. void disk_control_get_image_label(
  138. disk_control_interface_t *disk_control,
  139. unsigned index, char *label, size_t len);
  140. /***********/
  141. /* Setters */
  142. /***********/
  143. /**
  144. * disk_control_set_eject_state:
  145. *
  146. * Sets the eject state of the virtual disk tray
  147. **/
  148. bool disk_control_set_eject_state(
  149. disk_control_interface_t *disk_control,
  150. bool eject, bool verbosity);
  151. /**
  152. * disk_control_set_index:
  153. *
  154. * Sets currently selected disk index
  155. *
  156. * NOTE: Will fail if disk is not currently ejected
  157. **/
  158. bool disk_control_set_index(
  159. disk_control_interface_t *disk_control,
  160. unsigned index, bool verbosity);
  161. /**
  162. * disk_control_set_index_next:
  163. *
  164. * Increments selected disk index
  165. **/
  166. bool disk_control_set_index_next(
  167. disk_control_interface_t *disk_control,
  168. bool verbosity);
  169. /**
  170. * disk_control_set_index_prev:
  171. *
  172. * Decrements selected disk index
  173. **/
  174. bool disk_control_set_index_prev(
  175. disk_control_interface_t *disk_control,
  176. bool verbosity);
  177. /**
  178. * disk_control_append_image:
  179. *
  180. * Appends specified image file to disk image list
  181. **/
  182. bool disk_control_append_image(
  183. disk_control_interface_t *disk_control,
  184. const char *image_path);
  185. /*****************************/
  186. /* 'Initial index' functions */
  187. /*****************************/
  188. /**
  189. * disk_control_set_initial_index:
  190. *
  191. * Attempts to set current core's initial disk index.
  192. * > disk_control->record_enabled will be set to
  193. * 'false' if core does not support initial
  194. * index functionality
  195. * > disk_control->index_record will be loaded
  196. * from file (if an existing record is found)
  197. * NOTE: Must be called immediately before
  198. * loading content
  199. **/
  200. bool disk_control_set_initial_index(
  201. disk_control_interface_t *disk_control,
  202. const char *content_path,
  203. const char *dir_savefile);
  204. /**
  205. * disk_control_verify_initial_index:
  206. *
  207. * Checks that initial index has been set correctly
  208. * and provides user notification.
  209. * > Sets disk_control->initial_num_images if
  210. * if functionality is supported by core
  211. * NOTE: Must be called immediately after
  212. * loading content
  213. **/
  214. bool disk_control_verify_initial_index(
  215. disk_control_interface_t *disk_control,
  216. bool verbosity);
  217. /**
  218. * disk_control_save_image_index:
  219. *
  220. * Saves current disk index to file, if supported
  221. * by current core
  222. **/
  223. bool disk_control_save_image_index(
  224. disk_control_interface_t *disk_control);
  225. RETRO_END_DECLS
  226. #endif