SDL_hidapi_ps3.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* This driver supports both simplified reports and the extended input reports enabled by Steam.
  19. Code and logic contributed by Valve Corporation under the SDL zlib license.
  20. */
  21. #include "../../SDL_internal.h"
  22. #ifdef SDL_JOYSTICK_HIDAPI
  23. #include "SDL_hints.h"
  24. #include "SDL_events.h"
  25. #include "SDL_timer.h"
  26. #include "SDL_joystick.h"
  27. #include "SDL_gamecontroller.h"
  28. #include "../../SDL_hints_c.h"
  29. #include "../SDL_sysjoystick.h"
  30. #include "SDL_hidapijoystick_c.h"
  31. #include "SDL_hidapi_rumble.h"
  32. #ifdef SDL_JOYSTICK_HIDAPI_PS3
  33. /* Define this if you want to log all packets from the controller */
  34. /*#define DEBUG_PS3_PROTOCOL*/
  35. #define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8))
  36. typedef enum
  37. {
  38. k_EPS3ReportIdState = 1,
  39. k_EPS3ReportIdEffects = 1,
  40. } EPS3ReportId;
  41. typedef struct {
  42. SDL_HIDAPI_Device *device;
  43. SDL_Joystick *joystick;
  44. SDL_bool is_shanwan;
  45. SDL_bool report_sensors;
  46. SDL_bool effects_updated;
  47. Uint8 last_state[USB_PACKET_LENGTH];
  48. int player_index;
  49. Uint8 rumble_left;
  50. Uint8 rumble_right;
  51. } SDL_DriverPS3_Context;
  52. static int HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size);
  53. static void
  54. HIDAPI_DriverPS3_RegisterHints(SDL_HintCallback callback, void *userdata)
  55. {
  56. SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS3, callback, userdata);
  57. }
  58. static void
  59. HIDAPI_DriverPS3_UnregisterHints(SDL_HintCallback callback, void *userdata)
  60. {
  61. SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS3, callback, userdata);
  62. }
  63. static SDL_bool
  64. HIDAPI_DriverPS3_IsEnabled(void)
  65. {
  66. #ifdef __MACOSX__
  67. return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3,
  68. SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI,
  69. SDL_HIDAPI_DEFAULT));
  70. #else
  71. /* Linux already has good PS3 drivers and controller initialization fails on Windows,
  72. * so don't bother using this driver on other platforms.
  73. */
  74. return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_FALSE);
  75. #endif
  76. }
  77. static SDL_bool
  78. HIDAPI_DriverPS3_IsSupportedDevice(const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
  79. {
  80. if (vendor_id == USB_VENDOR_SONY && product_id == USB_PRODUCT_SONY_DS3) {
  81. return SDL_TRUE;
  82. }
  83. return SDL_FALSE;
  84. }
  85. static const char *
  86. HIDAPI_DriverPS3_GetDeviceName(const char *name, Uint16 vendor_id, Uint16 product_id)
  87. {
  88. if (vendor_id == USB_VENDOR_SONY) {
  89. if (name && SDL_strncasecmp(name, "ShanWan", 7) == 0) {
  90. return "ShanWan PS3 Controller";
  91. } else {
  92. return "PS3 Controller";
  93. }
  94. }
  95. return NULL;
  96. }
  97. static int ReadFeatureReport(SDL_hid_device *dev, Uint8 report_id, Uint8 *report, size_t length)
  98. {
  99. SDL_memset(report, 0, length);
  100. report[0] = report_id;
  101. return SDL_hid_get_feature_report(dev, report, length);
  102. }
  103. static int SendFeatureReport(SDL_hid_device *dev, Uint8 *report, size_t length)
  104. {
  105. return SDL_hid_send_feature_report(dev, report, length);
  106. }
  107. static SDL_bool
  108. HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
  109. {
  110. return HIDAPI_JoystickConnected(device, NULL);
  111. }
  112. static int
  113. HIDAPI_DriverPS3_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id)
  114. {
  115. return -1;
  116. }
  117. static int
  118. HIDAPI_DriverPS3_UpdateEffects(SDL_HIDAPI_Device *device)
  119. {
  120. SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context;
  121. Uint8 effects[] = {
  122. 0x01, 0xff, 0x00, 0xff, 0x00,
  123. 0x00, 0x00, 0x00, 0x00, 0x00,
  124. 0xff, 0x27, 0x10, 0x00, 0x32,
  125. 0xff, 0x27, 0x10, 0x00, 0x32,
  126. 0xff, 0x27, 0x10, 0x00, 0x32,
  127. 0xff, 0x27, 0x10, 0x00, 0x32,
  128. 0x00, 0x00, 0x00, 0x00, 0x00
  129. };
  130. effects[2] = ctx->rumble_right ? 1 : 0;
  131. effects[4] = ctx->rumble_left;
  132. effects[9] = (0x01 << (1+(ctx->player_index % 4)));
  133. return HIDAPI_DriverPS3_SendJoystickEffect(device, ctx->joystick, &effects, sizeof(effects));
  134. }
  135. static void
  136. HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index)
  137. {
  138. SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context;
  139. if (!ctx) {
  140. return;
  141. }
  142. ctx->player_index = player_index;
  143. /* This will set the new LED state based on the new player index */
  144. HIDAPI_DriverPS3_UpdateEffects(device);
  145. }
  146. static SDL_bool
  147. HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
  148. {
  149. SDL_DriverPS3_Context *ctx;
  150. ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx));
  151. if (!ctx) {
  152. SDL_OutOfMemory();
  153. return SDL_FALSE;
  154. }
  155. ctx->device = device;
  156. ctx->joystick = joystick;
  157. device->dev = SDL_hid_open_path(device->path, 0);
  158. if (!device->dev) {
  159. SDL_free(ctx);
  160. SDL_SetError("Couldn't open %s", device->path);
  161. return SDL_FALSE;
  162. }
  163. device->context = ctx;
  164. if (SDL_strncasecmp(device->name, "ShanWan", 7) == 0) {
  165. ctx->is_shanwan = SDL_TRUE;
  166. }
  167. /* Set the controller into report mode over Bluetooth */
  168. {
  169. Uint8 data[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
  170. SendFeatureReport(device->dev, data, sizeof(data));
  171. }
  172. /* Set the controller into report mode over USB */
  173. {
  174. Uint8 data[USB_PACKET_LENGTH];
  175. int size;
  176. if ((size = ReadFeatureReport(device->dev, 0xf2, data, 17)) < 0) {
  177. SDL_SetError("Couldn't read feature report 0xf2");
  178. return SDL_FALSE;
  179. }
  180. #ifdef DEBUG_PS3_PROTOCOL
  181. HIDAPI_DumpPacket("PS3 0xF2 packet: size = %d", data, size);
  182. #endif
  183. if ((size = ReadFeatureReport(device->dev, 0xf5, data, 8)) < 0) {
  184. SDL_SetError("Couldn't read feature report 0xf5");
  185. return SDL_FALSE;
  186. }
  187. #ifdef DEBUG_PS3_PROTOCOL
  188. HIDAPI_DumpPacket("PS3 0xF5 packet: size = %d", data, size);
  189. #endif
  190. if (!ctx->is_shanwan) {
  191. /* An output report could cause ShanWan controllers to rumble non-stop */
  192. SDL_hid_write(device->dev, data, 1);
  193. }
  194. }
  195. /* Initialize player index (needed for setting LEDs) */
  196. ctx->player_index = SDL_JoystickGetPlayerIndex(joystick);
  197. /* Initialize the joystick capabilities */
  198. joystick->nbuttons = 15;
  199. joystick->naxes = 16;
  200. joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
  201. SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f);
  202. return SDL_TRUE;
  203. }
  204. static int
  205. HIDAPI_DriverPS3_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
  206. {
  207. SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context;
  208. ctx->rumble_left = (low_frequency_rumble >> 8);
  209. ctx->rumble_right = (high_frequency_rumble >> 8);
  210. return HIDAPI_DriverPS3_UpdateEffects(device);
  211. }
  212. static int
  213. HIDAPI_DriverPS3_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
  214. {
  215. return SDL_Unsupported();
  216. }
  217. static Uint32
  218. HIDAPI_DriverPS3_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
  219. {
  220. return SDL_JOYCAP_RUMBLE;
  221. }
  222. static int
  223. HIDAPI_DriverPS3_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
  224. {
  225. return SDL_Unsupported();
  226. }
  227. static int
  228. HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *effect, int size)
  229. {
  230. Uint8 data[49];
  231. int report_size, offset;
  232. SDL_zeroa(data);
  233. data[0] = k_EPS3ReportIdEffects;
  234. report_size = sizeof(data);
  235. offset = 1;
  236. SDL_memcpy(&data[offset], effect, SDL_min((sizeof(data) - offset), (size_t)size));
  237. if (SDL_HIDAPI_SendRumble(device, data, report_size) != report_size) {
  238. return SDL_SetError("Couldn't send rumble packet");
  239. }
  240. return 0;
  241. }
  242. static int
  243. HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled)
  244. {
  245. SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context;
  246. ctx->report_sensors = enabled;
  247. return 0;
  248. }
  249. static float
  250. HIDAPI_DriverPS3_ScaleAccel(Sint16 value)
  251. {
  252. return (float)(value - 511) / 113.0f;
  253. }
  254. static void
  255. HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size)
  256. {
  257. Sint16 axis;
  258. if (ctx->last_state[2] != data[2]) {
  259. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  260. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
  261. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[2] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
  262. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[2] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  263. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  264. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  265. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  266. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
  267. }
  268. if (ctx->last_state[3] != data[3]) {
  269. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
  270. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  271. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  272. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  273. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  274. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[3] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
  275. }
  276. if (ctx->last_state[4] != data[4]) {
  277. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  278. }
  279. axis = ((int)data[18] * 257) - 32768;
  280. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
  281. axis = ((int)data[19] * 257) - 32768;
  282. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
  283. axis = ((int)data[6] * 257) - 32768;
  284. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
  285. axis = ((int)data[7] * 257) - 32768;
  286. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis);
  287. axis = ((int)data[8] * 257) - 32768;
  288. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis);
  289. axis = ((int)data[9] * 257) - 32768;
  290. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
  291. /* Buttons are mapped as axes in the order they appear in the button enumeration */
  292. {
  293. static int button_axis_offsets[] = {
  294. 24, /* SDL_CONTROLLER_BUTTON_A */
  295. 23, /* SDL_CONTROLLER_BUTTON_B */
  296. 25, /* SDL_CONTROLLER_BUTTON_X */
  297. 22, /* SDL_CONTROLLER_BUTTON_Y */
  298. 0, /* SDL_CONTROLLER_BUTTON_BACK */
  299. 0, /* SDL_CONTROLLER_BUTTON_GUIDE */
  300. 0, /* SDL_CONTROLLER_BUTTON_START */
  301. 0, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */
  302. 0, /* SDL_CONTROLLER_BUTTON_RIGHTSTICK */
  303. 20, /* SDL_CONTROLLER_BUTTON_LEFTSHOULDER */
  304. 21, /* SDL_CONTROLLER_BUTTON_RIGHTSHOULDER */
  305. 14, /* SDL_CONTROLLER_BUTTON_DPAD_UP */
  306. 16, /* SDL_CONTROLLER_BUTTON_DPAD_DOWN */
  307. 17, /* SDL_CONTROLLER_BUTTON_DPAD_LEFT */
  308. 15, /* SDL_CONTROLLER_BUTTON_DPAD_RIGHT */
  309. };
  310. int i, axis_index = 6;
  311. for (i = 0; i < SDL_arraysize(button_axis_offsets); ++i) {
  312. int offset = button_axis_offsets[i];
  313. if (!offset) {
  314. /* This button doesn't report as an axis */
  315. continue;
  316. }
  317. axis = ((int)data[offset] * 257) - 32768;
  318. SDL_PrivateJoystickAxis(joystick, axis_index, axis);
  319. ++axis_index;
  320. }
  321. }
  322. if (ctx->report_sensors) {
  323. float sensor_data[3];
  324. sensor_data[0] = HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[41], data[42]));
  325. sensor_data[1] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[45], data[46]));
  326. sensor_data[2] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[43], data[44]));
  327. SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, sensor_data, SDL_arraysize(sensor_data));
  328. }
  329. SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
  330. }
  331. static SDL_bool
  332. HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device)
  333. {
  334. SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context;
  335. SDL_Joystick *joystick = NULL;
  336. Uint8 data[USB_PACKET_LENGTH];
  337. int size;
  338. if (device->num_joysticks > 0) {
  339. joystick = SDL_JoystickFromInstanceID(device->joysticks[0]);
  340. }
  341. if (!joystick) {
  342. return SDL_FALSE;
  343. }
  344. while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) {
  345. #ifdef DEBUG_PS3_PROTOCOL
  346. HIDAPI_DumpPacket("PS3 packet: size = %d", data, size);
  347. #endif
  348. switch (data[0]) {
  349. case k_EPS3ReportIdState:
  350. if (data[1] == 0xFF) {
  351. /* Invalid data packet, ignore */
  352. break;
  353. }
  354. HIDAPI_DriverPS3_HandleStatePacket(joystick, ctx, data, size);
  355. /* Wait for the first report to set the LED state after the controller stops blinking */
  356. if (!ctx->effects_updated) {
  357. HIDAPI_DriverPS3_UpdateEffects(device);
  358. ctx->effects_updated = SDL_TRUE;
  359. }
  360. break;
  361. default:
  362. #ifdef DEBUG_JOYSTICK
  363. SDL_Log("Unknown PS3 packet: 0x%.2x\n", data[0]);
  364. #endif
  365. break;
  366. }
  367. }
  368. if (size < 0) {
  369. /* Read error, device is disconnected */
  370. HIDAPI_JoystickDisconnected(device, joystick->instance_id);
  371. }
  372. return (size >= 0);
  373. }
  374. static void
  375. HIDAPI_DriverPS3_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
  376. {
  377. SDL_LockMutex(device->dev_lock);
  378. {
  379. SDL_hid_close(device->dev);
  380. device->dev = NULL;
  381. SDL_free(device->context);
  382. device->context = NULL;
  383. }
  384. SDL_UnlockMutex(device->dev_lock);
  385. }
  386. static void
  387. HIDAPI_DriverPS3_FreeDevice(SDL_HIDAPI_Device *device)
  388. {
  389. }
  390. SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3 =
  391. {
  392. SDL_HINT_JOYSTICK_HIDAPI_PS3,
  393. SDL_TRUE,
  394. HIDAPI_DriverPS3_RegisterHints,
  395. HIDAPI_DriverPS3_UnregisterHints,
  396. HIDAPI_DriverPS3_IsEnabled,
  397. HIDAPI_DriverPS3_IsSupportedDevice,
  398. HIDAPI_DriverPS3_GetDeviceName,
  399. HIDAPI_DriverPS3_InitDevice,
  400. HIDAPI_DriverPS3_GetDevicePlayerIndex,
  401. HIDAPI_DriverPS3_SetDevicePlayerIndex,
  402. HIDAPI_DriverPS3_UpdateDevice,
  403. HIDAPI_DriverPS3_OpenJoystick,
  404. HIDAPI_DriverPS3_RumbleJoystick,
  405. HIDAPI_DriverPS3_RumbleJoystickTriggers,
  406. HIDAPI_DriverPS3_GetJoystickCapabilities,
  407. HIDAPI_DriverPS3_SetJoystickLED,
  408. HIDAPI_DriverPS3_SendJoystickEffect,
  409. HIDAPI_DriverPS3_SetJoystickSensorsEnabled,
  410. HIDAPI_DriverPS3_CloseJoystick,
  411. HIDAPI_DriverPS3_FreeDevice,
  412. };
  413. #endif /* SDL_JOYSTICK_HIDAPI_PS3 */
  414. #endif /* SDL_JOYSTICK_HIDAPI */
  415. /* vi: set ts=4 sw=4 expandtab: */