aboutsummaryrefslogtreecommitdiff
path: root/minisdl_audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'minisdl_audio.c')
-rw-r--r--minisdl_audio.c19233
1 files changed, 19233 insertions, 0 deletions
diff --git a/minisdl_audio.c b/minisdl_audio.c
new file mode 100644
index 0000000..e2e2d3f
--- /dev/null
+++ b/minisdl_audio.c
@@ -0,0 +1,19233 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22// (Partial copyright from inline included files dsound.h, dinput.h)
23/****************************************************************************
24 *
25 * Copyright (C) 1996-2000 Microsoft Corporation. All Rights Reserved.
26 *
27 ****************************************************************************/
28
29#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
30#define _CRT_SECURE_NO_WARNINGS
31#define _CRT_NONSTDC_NO_WARNINGS
32#endif
33
34#include "minisdl_audio.h"
35#ifndef _SDL_H
36#define _SDL_H
37
38#ifndef _SDL_main_h
39#define _SDL_main_h
40
41#ifndef SDL_MAIN_HANDLED
42#if defined(__WIN32__)
43
44#define SDL_MAIN_AVAILABLE
45
46#elif defined(__WINRT__)
47
48#define SDL_MAIN_NEEDED
49
50#elif defined(__IPHONEOS__)
51
52#define SDL_MAIN_NEEDED
53
54#elif defined(__ANDROID__)
55
56#define SDL_MAIN_NEEDED
57
58#endif
59#endif
60
61#ifdef __cplusplus
62#define C_LINKAGE "C"
63#else
64#define C_LINKAGE
65#endif
66
67#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
68#define main SDL_main
69#endif
70
71extern C_LINKAGE int SDL_main(int argc, char *argv[]);
72
73#ifdef _begin_code_h
74#error Nested inclusion of begin_code.h
75#endif
76#define _begin_code_h
77
78#ifndef SDL_DEPRECATED
79# if (__GNUC__ >= 4)
80# define SDL_DEPRECATED __attribute__((deprecated))
81# else
82# define SDL_DEPRECATED
83# endif
84#endif
85
86#ifndef DECLSPEC
87# if defined(__WIN32__) || defined(__WINRT__)
88# ifdef __BORLANDC__
89# ifdef BUILD_SDL
90# define DECLSPEC
91# else
92# define DECLSPEC __declspec(dllimport)
93# endif
94# else
95# define DECLSPEC __declspec(dllexport)
96# endif
97# else
98# if defined(__GNUC__) && __GNUC__ >= 4
99# define DECLSPEC __attribute__ ((visibility("default")))
100# elif defined(__GNUC__) && __GNUC__ >= 2
101# define DECLSPEC __declspec(dllexport)
102# else
103# define DECLSPEC
104# endif
105# endif
106#endif
107
108#ifndef SDLCALL
109#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
110#define SDLCALL __cdecl
111#else
112#define SDLCALL
113#endif
114#endif
115
116#ifdef __SYMBIAN32__
117#undef DECLSPEC
118#define DECLSPEC
119#endif
120
121#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
122#ifdef _MSC_VER
123#pragma warning(disable: 4103)
124#endif
125#ifdef __BORLANDC__
126#pragma nopackwarning
127#endif
128#ifdef _M_X64
129
130#pragma pack(push,8)
131#else
132#pragma pack(push,4)
133#endif
134#endif
135
136#ifndef SDL_INLINE
137#if defined(__GNUC__)
138#define SDL_INLINE __inline__
139#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
140 defined(__DMC__) || defined(__SC__) || \
141 defined(__WATCOMC__) || defined(__LCC__) || \
142 defined(__DECC)
143#define SDL_INLINE __inline
144#ifndef __inline__
145#define __inline__ __inline
146#endif
147#else
148#define SDL_INLINE inline
149#ifndef __inline__
150#define __inline__ inline
151#endif
152#endif
153#endif
154
155#ifndef SDL_FORCE_INLINE
156#if defined(_MSC_VER)
157#define SDL_FORCE_INLINE __forceinline
158#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
159#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
160#else
161#define SDL_FORCE_INLINE static SDL_INLINE
162#endif
163#endif
164
165#if !defined(__MACH__)
166#ifndef NULL
167#ifdef __cplusplus
168#define NULL 0
169#else
170#define NULL ((void *)0)
171#endif
172#endif
173#endif
174#ifdef __cplusplus
175extern "C" {
176#endif
177
178extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
179
180#ifdef __WIN32__
181
182extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style,
183 void *hInst);
184extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
185
186#endif
187
188#ifdef __WINRT__
189
190extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel);
191
192#endif
193
194#ifdef __cplusplus
195}
196#endif
197#undef _begin_code_h
198
199#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
200#ifdef __BORLANDC__
201#pragma nopackwarning
202#endif
203#pragma pack(pop)
204#endif
205
206#endif
207#ifndef _SDL_assert_h
208#define _SDL_assert_h
209
210#ifdef _begin_code_h
211#error Nested inclusion of begin_code.h
212#endif
213#define _begin_code_h
214
215#ifndef SDL_DEPRECATED
216# if (__GNUC__ >= 4)
217# define SDL_DEPRECATED __attribute__((deprecated))
218# else
219# define SDL_DEPRECATED
220# endif
221#endif
222
223#ifndef DECLSPEC
224# if defined(__WIN32__) || defined(__WINRT__)
225# ifdef __BORLANDC__
226# ifdef BUILD_SDL
227# define DECLSPEC
228# else
229# define DECLSPEC __declspec(dllimport)
230# endif
231# else
232# define DECLSPEC __declspec(dllexport)
233# endif
234# else
235# if defined(__GNUC__) && __GNUC__ >= 4
236# define DECLSPEC __attribute__ ((visibility("default")))
237# elif defined(__GNUC__) && __GNUC__ >= 2
238# define DECLSPEC __declspec(dllexport)
239# else
240# define DECLSPEC
241# endif
242# endif
243#endif
244
245#ifndef SDLCALL
246#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
247#define SDLCALL __cdecl
248#else
249#define SDLCALL
250#endif
251#endif
252
253#ifdef __SYMBIAN32__
254#undef DECLSPEC
255#define DECLSPEC
256#endif
257
258#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
259#ifdef _MSC_VER
260#pragma warning(disable: 4103)
261#endif
262#ifdef __BORLANDC__
263#pragma nopackwarning
264#endif
265#ifdef _M_X64
266
267#pragma pack(push,8)
268#else
269#pragma pack(push,4)
270#endif
271#endif
272
273#ifndef SDL_INLINE
274#if defined(__GNUC__)
275#define SDL_INLINE __inline__
276#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
277 defined(__DMC__) || defined(__SC__) || \
278 defined(__WATCOMC__) || defined(__LCC__) || \
279 defined(__DECC)
280#define SDL_INLINE __inline
281#ifndef __inline__
282#define __inline__ __inline
283#endif
284#else
285#define SDL_INLINE inline
286#ifndef __inline__
287#define __inline__ inline
288#endif
289#endif
290#endif
291
292#ifndef SDL_FORCE_INLINE
293#if defined(_MSC_VER)
294#define SDL_FORCE_INLINE __forceinline
295#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
296#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
297#else
298#define SDL_FORCE_INLINE static SDL_INLINE
299#endif
300#endif
301
302#if !defined(__MACH__)
303#ifndef NULL
304#ifdef __cplusplus
305#define NULL 0
306#else
307#define NULL ((void *)0)
308#endif
309#endif
310#endif
311
312#ifdef __cplusplus
313extern "C" {
314#endif
315
316#ifndef SDL_ASSERT_LEVEL
317#ifdef SDL_DEFAULT_ASSERT_LEVEL
318#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
319#elif defined(_DEBUG) || defined(DEBUG) || \
320 (defined(__GNUC__) && !defined(__OPTIMIZE__))
321#define SDL_ASSERT_LEVEL 2
322#else
323#define SDL_ASSERT_LEVEL 1
324#endif
325#endif
326
327#if defined(_MSC_VER)
328
329 extern void __cdecl __debugbreak(void);
330 #define SDL_TriggerBreakpoint() __debugbreak()
331#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
332 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
333#elif defined(HAVE_SIGNAL_H)
334 #include <signal.h>
335 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
336#else
337
338 #define SDL_TriggerBreakpoint()
339#endif
340
341#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
342# define SDL_FUNCTION __func__
343#elif ((__GNUC__ >= 2) || defined(_MSC_VER))
344# define SDL_FUNCTION __FUNCTION__
345#else
346# define SDL_FUNCTION "???"
347#endif
348#define SDL_FILE __FILE__
349#define SDL_LINE __LINE__
350
351#ifdef _MSC_VER
352#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
353#else
354#define SDL_NULL_WHILE_LOOP_CONDITION (0)
355#endif
356
357#define SDL_disabled_assert(condition) \
358 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
359
360typedef enum
361{
362 SDL_ASSERTION_RETRY,
363 SDL_ASSERTION_BREAK,
364 SDL_ASSERTION_ABORT,
365 SDL_ASSERTION_IGNORE,
366 SDL_ASSERTION_ALWAYS_IGNORE
367} SDL_assert_state;
368
369typedef struct SDL_assert_data
370{
371 int always_ignore;
372 unsigned int trigger_count;
373 const char *condition;
374 const char *filename;
375 int linenum;
376 const char *function;
377 const struct SDL_assert_data *next;
378} SDL_assert_data;
379
380#if (SDL_ASSERT_LEVEL > 0)
381
382extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
383 const char *,
384 const char *, int)
385#if defined(__clang__)
386#if __has_feature(attribute_analyzer_noreturn)
387
388 __attribute__((analyzer_noreturn))
389#endif
390#endif
391;
392
393#define SDL_enabled_assert(condition) \
394 do { \
395 while ( !(condition) ) { \
396 static struct SDL_assert_data assert_data = { \
397 0, 0, #condition, 0, 0, 0, 0 \
398 }; \
399 const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \
400 SDL_FUNCTION, \
401 SDL_FILE, \
402 SDL_LINE); \
403 if (state == SDL_ASSERTION_RETRY) { \
404 continue; \
405 } else if (state == SDL_ASSERTION_BREAK) { \
406 SDL_TriggerBreakpoint(); \
407 } \
408 break; \
409 } \
410 } while (SDL_NULL_WHILE_LOOP_CONDITION)
411
412#endif
413
414#if SDL_ASSERT_LEVEL == 0
415# define SDL_assert(condition) SDL_disabled_assert(condition)
416# define SDL_assert_release(condition) SDL_disabled_assert(condition)
417# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
418#elif SDL_ASSERT_LEVEL == 1
419# define SDL_assert(condition) SDL_disabled_assert(condition)
420# define SDL_assert_release(condition) SDL_enabled_assert(condition)
421# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
422#elif SDL_ASSERT_LEVEL == 2
423# define SDL_assert(condition) SDL_enabled_assert(condition)
424# define SDL_assert_release(condition) SDL_enabled_assert(condition)
425# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
426#elif SDL_ASSERT_LEVEL == 3
427# define SDL_assert(condition) SDL_enabled_assert(condition)
428# define SDL_assert_release(condition) SDL_enabled_assert(condition)
429# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
430#else
431# error Unknown assertion level.
432#endif
433
434#define SDL_assert_always(condition) SDL_enabled_assert(condition)
435
436typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
437 const SDL_assert_data* data, void* userdata);
438
439extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
440 SDL_AssertionHandler handler,
441 void *userdata);
442
443extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
444
445extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
446
447extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
448
449extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
450
451#ifdef __cplusplus
452}
453#endif
454#undef _begin_code_h
455
456#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
457#ifdef __BORLANDC__
458#pragma nopackwarning
459#endif
460#pragma pack(pop)
461#endif
462
463#endif
464#ifndef _SDL_clipboard_h
465#define _SDL_clipboard_h
466
467#ifdef _begin_code_h
468#error Nested inclusion of begin_code.h
469#endif
470#define _begin_code_h
471
472#ifndef SDL_DEPRECATED
473# if (__GNUC__ >= 4)
474# define SDL_DEPRECATED __attribute__((deprecated))
475# else
476# define SDL_DEPRECATED
477# endif
478#endif
479
480#ifndef DECLSPEC
481# if defined(__WIN32__) || defined(__WINRT__)
482# ifdef __BORLANDC__
483# ifdef BUILD_SDL
484# define DECLSPEC
485# else
486# define DECLSPEC __declspec(dllimport)
487# endif
488# else
489# define DECLSPEC __declspec(dllexport)
490# endif
491# else
492# if defined(__GNUC__) && __GNUC__ >= 4
493# define DECLSPEC __attribute__ ((visibility("default")))
494# elif defined(__GNUC__) && __GNUC__ >= 2
495# define DECLSPEC __declspec(dllexport)
496# else
497# define DECLSPEC
498# endif
499# endif
500#endif
501
502#ifndef SDLCALL
503#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
504#define SDLCALL __cdecl
505#else
506#define SDLCALL
507#endif
508#endif
509
510#ifdef __SYMBIAN32__
511#undef DECLSPEC
512#define DECLSPEC
513#endif
514
515#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
516#ifdef _MSC_VER
517#pragma warning(disable: 4103)
518#endif
519#ifdef __BORLANDC__
520#pragma nopackwarning
521#endif
522#ifdef _M_X64
523
524#pragma pack(push,8)
525#else
526#pragma pack(push,4)
527#endif
528#endif
529
530#ifndef SDL_INLINE
531#if defined(__GNUC__)
532#define SDL_INLINE __inline__
533#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
534 defined(__DMC__) || defined(__SC__) || \
535 defined(__WATCOMC__) || defined(__LCC__) || \
536 defined(__DECC)
537#define SDL_INLINE __inline
538#ifndef __inline__
539#define __inline__ __inline
540#endif
541#else
542#define SDL_INLINE inline
543#ifndef __inline__
544#define __inline__ inline
545#endif
546#endif
547#endif
548
549#ifndef SDL_FORCE_INLINE
550#if defined(_MSC_VER)
551#define SDL_FORCE_INLINE __forceinline
552#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
553#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
554#else
555#define SDL_FORCE_INLINE static SDL_INLINE
556#endif
557#endif
558
559#if !defined(__MACH__)
560#ifndef NULL
561#ifdef __cplusplus
562#define NULL 0
563#else
564#define NULL ((void *)0)
565#endif
566#endif
567#endif
568
569#ifdef __cplusplus
570extern "C" {
571#endif
572
573extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
574
575extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
576
577extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
578
579#ifdef __cplusplus
580}
581#endif
582#undef _begin_code_h
583
584#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
585#ifdef __BORLANDC__
586#pragma nopackwarning
587#endif
588#pragma pack(pop)
589#endif
590
591#endif
592#ifndef _SDL_cpuinfo_h
593#define _SDL_cpuinfo_h
594
595#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
596#include <intrin.h>
597#ifndef _WIN64
598#define __MMX__
599#define __3dNOW__
600#endif
601#define __SSE__
602#define __SSE2__
603#elif defined(__MINGW64_VERSION_MAJOR)
604#include <intrin.h>
605#else
606#ifdef __ALTIVEC__
607#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
608#include <altivec.h>
609#undef pixel
610#endif
611#endif
612#ifdef __MMX__
613#include <mmintrin.h>
614#endif
615#ifdef __3dNOW__
616#include <mm3dnow.h>
617#endif
618#ifdef __SSE__
619#include <xmmintrin.h>
620#endif
621#ifdef __SSE2__
622#include <emmintrin.h>
623#endif
624#endif
625
626#ifdef _begin_code_h
627#error Nested inclusion of begin_code.h
628#endif
629#define _begin_code_h
630
631#ifndef SDL_DEPRECATED
632# if (__GNUC__ >= 4)
633# define SDL_DEPRECATED __attribute__((deprecated))
634# else
635# define SDL_DEPRECATED
636# endif
637#endif
638
639#ifndef DECLSPEC
640# if defined(__WIN32__) || defined(__WINRT__)
641# ifdef __BORLANDC__
642# ifdef BUILD_SDL
643# define DECLSPEC
644# else
645# define DECLSPEC __declspec(dllimport)
646# endif
647# else
648# define DECLSPEC __declspec(dllexport)
649# endif
650# else
651# if defined(__GNUC__) && __GNUC__ >= 4
652# define DECLSPEC __attribute__ ((visibility("default")))
653# elif defined(__GNUC__) && __GNUC__ >= 2
654# define DECLSPEC __declspec(dllexport)
655# else
656# define DECLSPEC
657# endif
658# endif
659#endif
660
661#ifndef SDLCALL
662#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
663#define SDLCALL __cdecl
664#else
665#define SDLCALL
666#endif
667#endif
668
669#ifdef __SYMBIAN32__
670#undef DECLSPEC
671#define DECLSPEC
672#endif
673
674#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
675#ifdef _MSC_VER
676#pragma warning(disable: 4103)
677#endif
678#ifdef __BORLANDC__
679#pragma nopackwarning
680#endif
681#ifdef _M_X64
682
683#pragma pack(push,8)
684#else
685#pragma pack(push,4)
686#endif
687#endif
688
689#ifndef SDL_INLINE
690#if defined(__GNUC__)
691#define SDL_INLINE __inline__
692#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
693 defined(__DMC__) || defined(__SC__) || \
694 defined(__WATCOMC__) || defined(__LCC__) || \
695 defined(__DECC)
696#define SDL_INLINE __inline
697#ifndef __inline__
698#define __inline__ __inline
699#endif
700#else
701#define SDL_INLINE inline
702#ifndef __inline__
703#define __inline__ inline
704#endif
705#endif
706#endif
707
708#ifndef SDL_FORCE_INLINE
709#if defined(_MSC_VER)
710#define SDL_FORCE_INLINE __forceinline
711#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
712#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
713#else
714#define SDL_FORCE_INLINE static SDL_INLINE
715#endif
716#endif
717
718#if !defined(__MACH__)
719#ifndef NULL
720#ifdef __cplusplus
721#define NULL 0
722#else
723#define NULL ((void *)0)
724#endif
725#endif
726#endif
727
728#ifdef __cplusplus
729extern "C" {
730#endif
731
732#define SDL_CACHELINE_SIZE 128
733
734extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
735
736extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
737
738extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
739
740extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
741
742extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
743
744extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
745
746extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
747
748extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
749
750extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
751
752extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
753
754extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
755
756extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
757
758extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
759
760#ifdef __cplusplus
761}
762#endif
763#undef _begin_code_h
764
765#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
766#ifdef __BORLANDC__
767#pragma nopackwarning
768#endif
769#pragma pack(pop)
770#endif
771
772#endif
773#ifndef _SDL_events_h
774#define _SDL_events_h
775
776#ifndef _SDL_video_h
777#define _SDL_video_h
778
779#ifndef _SDL_pixels_h
780#define _SDL_pixels_h
781
782#ifdef _begin_code_h
783#error Nested inclusion of begin_code.h
784#endif
785#define _begin_code_h
786
787#ifndef SDL_DEPRECATED
788# if (__GNUC__ >= 4)
789# define SDL_DEPRECATED __attribute__((deprecated))
790# else
791# define SDL_DEPRECATED
792# endif
793#endif
794
795#ifndef DECLSPEC
796# if defined(__WIN32__) || defined(__WINRT__)
797# ifdef __BORLANDC__
798# ifdef BUILD_SDL
799# define DECLSPEC
800# else
801# define DECLSPEC __declspec(dllimport)
802# endif
803# else
804# define DECLSPEC __declspec(dllexport)
805# endif
806# else
807# if defined(__GNUC__) && __GNUC__ >= 4
808# define DECLSPEC __attribute__ ((visibility("default")))
809# elif defined(__GNUC__) && __GNUC__ >= 2
810# define DECLSPEC __declspec(dllexport)
811# else
812# define DECLSPEC
813# endif
814# endif
815#endif
816
817#ifndef SDLCALL
818#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
819#define SDLCALL __cdecl
820#else
821#define SDLCALL
822#endif
823#endif
824
825#ifdef __SYMBIAN32__
826#undef DECLSPEC
827#define DECLSPEC
828#endif
829
830#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
831#ifdef _MSC_VER
832#pragma warning(disable: 4103)
833#endif
834#ifdef __BORLANDC__
835#pragma nopackwarning
836#endif
837#ifdef _M_X64
838
839#pragma pack(push,8)
840#else
841#pragma pack(push,4)
842#endif
843#endif
844
845#ifndef SDL_INLINE
846#if defined(__GNUC__)
847#define SDL_INLINE __inline__
848#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
849 defined(__DMC__) || defined(__SC__) || \
850 defined(__WATCOMC__) || defined(__LCC__) || \
851 defined(__DECC)
852#define SDL_INLINE __inline
853#ifndef __inline__
854#define __inline__ __inline
855#endif
856#else
857#define SDL_INLINE inline
858#ifndef __inline__
859#define __inline__ inline
860#endif
861#endif
862#endif
863
864#ifndef SDL_FORCE_INLINE
865#if defined(_MSC_VER)
866#define SDL_FORCE_INLINE __forceinline
867#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
868#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
869#else
870#define SDL_FORCE_INLINE static SDL_INLINE
871#endif
872#endif
873
874#if !defined(__MACH__)
875#ifndef NULL
876#ifdef __cplusplus
877#define NULL 0
878#else
879#define NULL ((void *)0)
880#endif
881#endif
882#endif
883
884#ifdef __cplusplus
885extern "C" {
886#endif
887
888#define SDL_ALPHA_OPAQUE 255
889#define SDL_ALPHA_TRANSPARENT 0
890
891enum
892{
893 SDL_PIXELTYPE_UNKNOWN,
894 SDL_PIXELTYPE_INDEX1,
895 SDL_PIXELTYPE_INDEX4,
896 SDL_PIXELTYPE_INDEX8,
897 SDL_PIXELTYPE_PACKED8,
898 SDL_PIXELTYPE_PACKED16,
899 SDL_PIXELTYPE_PACKED32,
900 SDL_PIXELTYPE_ARRAYU8,
901 SDL_PIXELTYPE_ARRAYU16,
902 SDL_PIXELTYPE_ARRAYU32,
903 SDL_PIXELTYPE_ARRAYF16,
904 SDL_PIXELTYPE_ARRAYF32
905};
906
907enum
908{
909 SDL_BITMAPORDER_NONE,
910 SDL_BITMAPORDER_4321,
911 SDL_BITMAPORDER_1234
912};
913
914enum
915{
916 SDL_PACKEDORDER_NONE,
917 SDL_PACKEDORDER_XRGB,
918 SDL_PACKEDORDER_RGBX,
919 SDL_PACKEDORDER_ARGB,
920 SDL_PACKEDORDER_RGBA,
921 SDL_PACKEDORDER_XBGR,
922 SDL_PACKEDORDER_BGRX,
923 SDL_PACKEDORDER_ABGR,
924 SDL_PACKEDORDER_BGRA
925};
926
927enum
928{
929 SDL_ARRAYORDER_NONE,
930 SDL_ARRAYORDER_RGB,
931 SDL_ARRAYORDER_RGBA,
932 SDL_ARRAYORDER_ARGB,
933 SDL_ARRAYORDER_BGR,
934 SDL_ARRAYORDER_BGRA,
935 SDL_ARRAYORDER_ABGR
936};
937
938enum
939{
940 SDL_PACKEDLAYOUT_NONE,
941 SDL_PACKEDLAYOUT_332,
942 SDL_PACKEDLAYOUT_4444,
943 SDL_PACKEDLAYOUT_1555,
944 SDL_PACKEDLAYOUT_5551,
945 SDL_PACKEDLAYOUT_565,
946 SDL_PACKEDLAYOUT_8888,
947 SDL_PACKEDLAYOUT_2101010,
948 SDL_PACKEDLAYOUT_1010102
949};
950
951#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
952
953#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
954 ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
955 ((bits) << 8) | ((bytes) << 0))
956
957#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F)
958#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
959#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
960#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
961#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
962#define SDL_BYTESPERPIXEL(X) \
963 (SDL_ISPIXELFORMAT_FOURCC(X) ? \
964 ((((X) == SDL_PIXELFORMAT_YUY2) || \
965 ((X) == SDL_PIXELFORMAT_UYVY) || \
966 ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
967
968#define SDL_ISPIXELFORMAT_INDEXED(format) \
969 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
970 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
971 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
972 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
973
974#define SDL_ISPIXELFORMAT_ALPHA(format) \
975 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
976 ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
977 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
978 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
979 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
980
981#define SDL_ISPIXELFORMAT_FOURCC(format) \
982 ((format) && (SDL_PIXELFLAG(format) != 1))
983
984enum
985{
986 SDL_PIXELFORMAT_UNKNOWN,
987 SDL_PIXELFORMAT_INDEX1LSB =
988 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
989 1, 0),
990 SDL_PIXELFORMAT_INDEX1MSB =
991 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
992 1, 0),
993 SDL_PIXELFORMAT_INDEX4LSB =
994 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
995 4, 0),
996 SDL_PIXELFORMAT_INDEX4MSB =
997 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
998 4, 0),
999 SDL_PIXELFORMAT_INDEX8 =
1000 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
1001 SDL_PIXELFORMAT_RGB332 =
1002 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
1003 SDL_PACKEDLAYOUT_332, 8, 1),
1004 SDL_PIXELFORMAT_RGB444 =
1005 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
1006 SDL_PACKEDLAYOUT_4444, 12, 2),
1007 SDL_PIXELFORMAT_RGB555 =
1008 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
1009 SDL_PACKEDLAYOUT_1555, 15, 2),
1010 SDL_PIXELFORMAT_BGR555 =
1011 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
1012 SDL_PACKEDLAYOUT_1555, 15, 2),
1013 SDL_PIXELFORMAT_ARGB4444 =
1014 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
1015 SDL_PACKEDLAYOUT_4444, 16, 2),
1016 SDL_PIXELFORMAT_RGBA4444 =
1017 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
1018 SDL_PACKEDLAYOUT_4444, 16, 2),
1019 SDL_PIXELFORMAT_ABGR4444 =
1020 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
1021 SDL_PACKEDLAYOUT_4444, 16, 2),
1022 SDL_PIXELFORMAT_BGRA4444 =
1023 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
1024 SDL_PACKEDLAYOUT_4444, 16, 2),
1025 SDL_PIXELFORMAT_ARGB1555 =
1026 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
1027 SDL_PACKEDLAYOUT_1555, 16, 2),
1028 SDL_PIXELFORMAT_RGBA5551 =
1029 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
1030 SDL_PACKEDLAYOUT_5551, 16, 2),
1031 SDL_PIXELFORMAT_ABGR1555 =
1032 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
1033 SDL_PACKEDLAYOUT_1555, 16, 2),
1034 SDL_PIXELFORMAT_BGRA5551 =
1035 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
1036 SDL_PACKEDLAYOUT_5551, 16, 2),
1037 SDL_PIXELFORMAT_RGB565 =
1038 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
1039 SDL_PACKEDLAYOUT_565, 16, 2),
1040 SDL_PIXELFORMAT_BGR565 =
1041 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
1042 SDL_PACKEDLAYOUT_565, 16, 2),
1043 SDL_PIXELFORMAT_RGB24 =
1044 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
1045 24, 3),
1046 SDL_PIXELFORMAT_BGR24 =
1047 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
1048 24, 3),
1049 SDL_PIXELFORMAT_RGB888 =
1050 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
1051 SDL_PACKEDLAYOUT_8888, 24, 4),
1052 SDL_PIXELFORMAT_RGBX8888 =
1053 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
1054 SDL_PACKEDLAYOUT_8888, 24, 4),
1055 SDL_PIXELFORMAT_BGR888 =
1056 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
1057 SDL_PACKEDLAYOUT_8888, 24, 4),
1058 SDL_PIXELFORMAT_BGRX8888 =
1059 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX,
1060 SDL_PACKEDLAYOUT_8888, 24, 4),
1061 SDL_PIXELFORMAT_ARGB8888 =
1062 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
1063 SDL_PACKEDLAYOUT_8888, 32, 4),
1064 SDL_PIXELFORMAT_RGBA8888 =
1065 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
1066 SDL_PACKEDLAYOUT_8888, 32, 4),
1067 SDL_PIXELFORMAT_ABGR8888 =
1068 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
1069 SDL_PACKEDLAYOUT_8888, 32, 4),
1070 SDL_PIXELFORMAT_BGRA8888 =
1071 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
1072 SDL_PACKEDLAYOUT_8888, 32, 4),
1073 SDL_PIXELFORMAT_ARGB2101010 =
1074 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
1075 SDL_PACKEDLAYOUT_2101010, 32, 4),
1076
1077 SDL_PIXELFORMAT_YV12 =
1078 SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
1079 SDL_PIXELFORMAT_IYUV =
1080 SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
1081 SDL_PIXELFORMAT_YUY2 =
1082 SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
1083 SDL_PIXELFORMAT_UYVY =
1084 SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
1085 SDL_PIXELFORMAT_YVYU =
1086 SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
1087};
1088
1089typedef struct SDL_Color
1090{
1091 Uint8 r;
1092 Uint8 g;
1093 Uint8 b;
1094 Uint8 a;
1095} SDL_Color;
1096#define SDL_Colour SDL_Color
1097
1098typedef struct SDL_Palette
1099{
1100 int ncolors;
1101 SDL_Color *colors;
1102 Uint32 version;
1103 int refcount;
1104} SDL_Palette;
1105
1106typedef struct SDL_PixelFormat
1107{
1108 Uint32 format;
1109 SDL_Palette *palette;
1110 Uint8 BitsPerPixel;
1111 Uint8 BytesPerPixel;
1112 Uint8 padding[2];
1113 Uint32 Rmask;
1114 Uint32 Gmask;
1115 Uint32 Bmask;
1116 Uint32 Amask;
1117 Uint8 Rloss;
1118 Uint8 Gloss;
1119 Uint8 Bloss;
1120 Uint8 Aloss;
1121 Uint8 Rshift;
1122 Uint8 Gshift;
1123 Uint8 Bshift;
1124 Uint8 Ashift;
1125 int refcount;
1126 struct SDL_PixelFormat *next;
1127} SDL_PixelFormat;
1128
1129extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
1130
1131extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
1132 int *bpp,
1133 Uint32 * Rmask,
1134 Uint32 * Gmask,
1135 Uint32 * Bmask,
1136 Uint32 * Amask);
1137
1138extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
1139 Uint32 Rmask,
1140 Uint32 Gmask,
1141 Uint32 Bmask,
1142 Uint32 Amask);
1143
1144extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
1145
1146extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
1147
1148extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
1149
1150extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
1151 SDL_Palette *palette);
1152
1153extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
1154 const SDL_Color * colors,
1155 int firstcolor, int ncolors);
1156
1157extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
1158
1159extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
1160 Uint8 r, Uint8 g, Uint8 b);
1161
1162extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
1163 Uint8 r, Uint8 g, Uint8 b,
1164 Uint8 a);
1165
1166extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
1167 const SDL_PixelFormat * format,
1168 Uint8 * r, Uint8 * g, Uint8 * b);
1169
1170extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
1171 const SDL_PixelFormat * format,
1172 Uint8 * r, Uint8 * g, Uint8 * b,
1173 Uint8 * a);
1174
1175extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);
1176
1177#ifdef __cplusplus
1178}
1179#endif
1180#undef _begin_code_h
1181
1182#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
1183#ifdef __BORLANDC__
1184#pragma nopackwarning
1185#endif
1186#pragma pack(pop)
1187#endif
1188
1189#endif
1190#ifndef _SDL_rect_h
1191#define _SDL_rect_h
1192
1193#ifdef _begin_code_h
1194#error Nested inclusion of begin_code.h
1195#endif
1196#define _begin_code_h
1197
1198#ifndef SDL_DEPRECATED
1199# if (__GNUC__ >= 4)
1200# define SDL_DEPRECATED __attribute__((deprecated))
1201# else
1202# define SDL_DEPRECATED
1203# endif
1204#endif
1205
1206#ifndef DECLSPEC
1207# if defined(__WIN32__) || defined(__WINRT__)
1208# ifdef __BORLANDC__
1209# ifdef BUILD_SDL
1210# define DECLSPEC
1211# else
1212# define DECLSPEC __declspec(dllimport)
1213# endif
1214# else
1215# define DECLSPEC __declspec(dllexport)
1216# endif
1217# else
1218# if defined(__GNUC__) && __GNUC__ >= 4
1219# define DECLSPEC __attribute__ ((visibility("default")))
1220# elif defined(__GNUC__) && __GNUC__ >= 2
1221# define DECLSPEC __declspec(dllexport)
1222# else
1223# define DECLSPEC
1224# endif
1225# endif
1226#endif
1227
1228#ifndef SDLCALL
1229#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
1230#define SDLCALL __cdecl
1231#else
1232#define SDLCALL
1233#endif
1234#endif
1235
1236#ifdef __SYMBIAN32__
1237#undef DECLSPEC
1238#define DECLSPEC
1239#endif
1240
1241#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
1242#ifdef _MSC_VER
1243#pragma warning(disable: 4103)
1244#endif
1245#ifdef __BORLANDC__
1246#pragma nopackwarning
1247#endif
1248#ifdef _M_X64
1249
1250#pragma pack(push,8)
1251#else
1252#pragma pack(push,4)
1253#endif
1254#endif
1255
1256#ifndef SDL_INLINE
1257#if defined(__GNUC__)
1258#define SDL_INLINE __inline__
1259#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
1260 defined(__DMC__) || defined(__SC__) || \
1261 defined(__WATCOMC__) || defined(__LCC__) || \
1262 defined(__DECC)
1263#define SDL_INLINE __inline
1264#ifndef __inline__
1265#define __inline__ __inline
1266#endif
1267#else
1268#define SDL_INLINE inline
1269#ifndef __inline__
1270#define __inline__ inline
1271#endif
1272#endif
1273#endif
1274
1275#ifndef SDL_FORCE_INLINE
1276#if defined(_MSC_VER)
1277#define SDL_FORCE_INLINE __forceinline
1278#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
1279#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
1280#else
1281#define SDL_FORCE_INLINE static SDL_INLINE
1282#endif
1283#endif
1284
1285#if !defined(__MACH__)
1286#ifndef NULL
1287#ifdef __cplusplus
1288#define NULL 0
1289#else
1290#define NULL ((void *)0)
1291#endif
1292#endif
1293#endif
1294
1295#ifdef __cplusplus
1296extern "C" {
1297#endif
1298
1299typedef struct SDL_Point
1300{
1301 int x;
1302 int y;
1303} SDL_Point;
1304
1305typedef struct SDL_Rect
1306{
1307 int x, y;
1308 int w, h;
1309} SDL_Rect;
1310
1311SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
1312{
1313 return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
1314}
1315
1316SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
1317{
1318 return (a && b && (a->x == b->x) && (a->y == b->y) &&
1319 (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
1320}
1321
1322extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
1323 const SDL_Rect * B);
1324
1325extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
1326 const SDL_Rect * B,
1327 SDL_Rect * result);
1328
1329extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
1330 const SDL_Rect * B,
1331 SDL_Rect * result);
1332
1333extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
1334 int count,
1335 const SDL_Rect * clip,
1336 SDL_Rect * result);
1337
1338extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
1339 rect, int *X1,
1340 int *Y1, int *X2,
1341 int *Y2);
1342
1343#ifdef __cplusplus
1344}
1345#endif
1346#undef _begin_code_h
1347
1348#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
1349#ifdef __BORLANDC__
1350#pragma nopackwarning
1351#endif
1352#pragma pack(pop)
1353#endif
1354
1355#endif
1356#ifndef _SDL_surface_h
1357#define _SDL_surface_h
1358
1359#ifndef _SDL_blendmode_h
1360#define _SDL_blendmode_h
1361
1362#ifdef _begin_code_h
1363#error Nested inclusion of begin_code.h
1364#endif
1365#define _begin_code_h
1366
1367#ifndef SDL_DEPRECATED
1368# if (__GNUC__ >= 4)
1369# define SDL_DEPRECATED __attribute__((deprecated))
1370# else
1371# define SDL_DEPRECATED
1372# endif
1373#endif
1374
1375#ifndef DECLSPEC
1376# if defined(__WIN32__) || defined(__WINRT__)
1377# ifdef __BORLANDC__
1378# ifdef BUILD_SDL
1379# define DECLSPEC
1380# else
1381# define DECLSPEC __declspec(dllimport)
1382# endif
1383# else
1384# define DECLSPEC __declspec(dllexport)
1385# endif
1386# else
1387# if defined(__GNUC__) && __GNUC__ >= 4
1388# define DECLSPEC __attribute__ ((visibility("default")))
1389# elif defined(__GNUC__) && __GNUC__ >= 2
1390# define DECLSPEC __declspec(dllexport)
1391# else
1392# define DECLSPEC
1393# endif
1394# endif
1395#endif
1396
1397#ifndef SDLCALL
1398#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
1399#define SDLCALL __cdecl
1400#else
1401#define SDLCALL
1402#endif
1403#endif
1404
1405#ifdef __SYMBIAN32__
1406#undef DECLSPEC
1407#define DECLSPEC
1408#endif
1409
1410#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
1411#ifdef _MSC_VER
1412#pragma warning(disable: 4103)
1413#endif
1414#ifdef __BORLANDC__
1415#pragma nopackwarning
1416#endif
1417#ifdef _M_X64
1418
1419#pragma pack(push,8)
1420#else
1421#pragma pack(push,4)
1422#endif
1423#endif
1424
1425#ifndef SDL_INLINE
1426#if defined(__GNUC__)
1427#define SDL_INLINE __inline__
1428#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
1429 defined(__DMC__) || defined(__SC__) || \
1430 defined(__WATCOMC__) || defined(__LCC__) || \
1431 defined(__DECC)
1432#define SDL_INLINE __inline
1433#ifndef __inline__
1434#define __inline__ __inline
1435#endif
1436#else
1437#define SDL_INLINE inline
1438#ifndef __inline__
1439#define __inline__ inline
1440#endif
1441#endif
1442#endif
1443
1444#ifndef SDL_FORCE_INLINE
1445#if defined(_MSC_VER)
1446#define SDL_FORCE_INLINE __forceinline
1447#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
1448#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
1449#else
1450#define SDL_FORCE_INLINE static SDL_INLINE
1451#endif
1452#endif
1453
1454#if !defined(__MACH__)
1455#ifndef NULL
1456#ifdef __cplusplus
1457#define NULL 0
1458#else
1459#define NULL ((void *)0)
1460#endif
1461#endif
1462#endif
1463
1464#ifdef __cplusplus
1465extern "C" {
1466#endif
1467
1468typedef enum
1469{
1470 SDL_BLENDMODE_NONE = 0x00000000,
1471 SDL_BLENDMODE_BLEND = 0x00000001,
1472 SDL_BLENDMODE_ADD = 0x00000002,
1473 SDL_BLENDMODE_MOD = 0x00000004
1474} SDL_BlendMode;
1475
1476#ifdef __cplusplus
1477}
1478#endif
1479#undef _begin_code_h
1480
1481#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
1482#ifdef __BORLANDC__
1483#pragma nopackwarning
1484#endif
1485#pragma pack(pop)
1486#endif
1487
1488#endif
1489
1490#ifdef _begin_code_h
1491#error Nested inclusion of begin_code.h
1492#endif
1493#define _begin_code_h
1494
1495#ifndef SDL_DEPRECATED
1496# if (__GNUC__ >= 4)
1497# define SDL_DEPRECATED __attribute__((deprecated))
1498# else
1499# define SDL_DEPRECATED
1500# endif
1501#endif
1502
1503#ifndef DECLSPEC
1504# if defined(__WIN32__) || defined(__WINRT__)
1505# ifdef __BORLANDC__
1506# ifdef BUILD_SDL
1507# define DECLSPEC
1508# else
1509# define DECLSPEC __declspec(dllimport)
1510# endif
1511# else
1512# define DECLSPEC __declspec(dllexport)
1513# endif
1514# else
1515# if defined(__GNUC__) && __GNUC__ >= 4
1516# define DECLSPEC __attribute__ ((visibility("default")))
1517# elif defined(__GNUC__) && __GNUC__ >= 2
1518# define DECLSPEC __declspec(dllexport)
1519# else
1520# define DECLSPEC
1521# endif
1522# endif
1523#endif
1524
1525#ifndef SDLCALL
1526#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
1527#define SDLCALL __cdecl
1528#else
1529#define SDLCALL
1530#endif
1531#endif
1532
1533#ifdef __SYMBIAN32__
1534#undef DECLSPEC
1535#define DECLSPEC
1536#endif
1537
1538#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
1539#ifdef _MSC_VER
1540#pragma warning(disable: 4103)
1541#endif
1542#ifdef __BORLANDC__
1543#pragma nopackwarning
1544#endif
1545#ifdef _M_X64
1546
1547#pragma pack(push,8)
1548#else
1549#pragma pack(push,4)
1550#endif
1551#endif
1552
1553#ifndef SDL_INLINE
1554#if defined(__GNUC__)
1555#define SDL_INLINE __inline__
1556#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
1557 defined(__DMC__) || defined(__SC__) || \
1558 defined(__WATCOMC__) || defined(__LCC__) || \
1559 defined(__DECC)
1560#define SDL_INLINE __inline
1561#ifndef __inline__
1562#define __inline__ __inline
1563#endif
1564#else
1565#define SDL_INLINE inline
1566#ifndef __inline__
1567#define __inline__ inline
1568#endif
1569#endif
1570#endif
1571
1572#ifndef SDL_FORCE_INLINE
1573#if defined(_MSC_VER)
1574#define SDL_FORCE_INLINE __forceinline
1575#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
1576#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
1577#else
1578#define SDL_FORCE_INLINE static SDL_INLINE
1579#endif
1580#endif
1581
1582#if !defined(__MACH__)
1583#ifndef NULL
1584#ifdef __cplusplus
1585#define NULL 0
1586#else
1587#define NULL ((void *)0)
1588#endif
1589#endif
1590#endif
1591
1592#ifdef __cplusplus
1593extern "C" {
1594#endif
1595
1596#define SDL_SWSURFACE 0
1597#define SDL_PREALLOC 0x00000001
1598#define SDL_RLEACCEL 0x00000002
1599#define SDL_DONTFREE 0x00000004
1600
1601#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
1602
1603typedef struct SDL_Surface
1604{
1605 Uint32 flags;
1606 SDL_PixelFormat *format;
1607 int w, h;
1608 int pitch;
1609 void *pixels;
1610
1611 void *userdata;
1612
1613 int locked;
1614 void *lock_data;
1615
1616 SDL_Rect clip_rect;
1617
1618 struct SDL_BlitMap *map;
1619
1620 int refcount;
1621} SDL_Surface;
1622
1623typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
1624 struct SDL_Surface * dst, SDL_Rect * dstrect);
1625
1626extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
1627 (Uint32 flags, int width, int height, int depth,
1628 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
1629extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
1630 int width,
1631 int height,
1632 int depth,
1633 int pitch,
1634 Uint32 Rmask,
1635 Uint32 Gmask,
1636 Uint32 Bmask,
1637 Uint32 Amask);
1638extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
1639
1640extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
1641 SDL_Palette * palette);
1642
1643extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
1644
1645extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
1646
1647extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
1648 int freesrc);
1649
1650#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
1651
1652extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
1653 (SDL_Surface * surface, SDL_RWops * dst, int freedst);
1654
1655#define SDL_SaveBMP(surface, file) \
1656 SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
1657
1658extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
1659 int flag);
1660
1661extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
1662 int flag, Uint32 key);
1663
1664extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
1665 Uint32 * key);
1666
1667extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
1668 Uint8 r, Uint8 g, Uint8 b);
1669
1670extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
1671 Uint8 * r, Uint8 * g,
1672 Uint8 * b);
1673
1674extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
1675 Uint8 alpha);
1676
1677extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
1678 Uint8 * alpha);
1679
1680extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
1681 SDL_BlendMode blendMode);
1682
1683extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
1684 SDL_BlendMode *blendMode);
1685
1686extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
1687 const SDL_Rect * rect);
1688
1689extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
1690 SDL_Rect * rect);
1691
1692extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
1693 (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
1694extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
1695 (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
1696
1697extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
1698 Uint32 src_format,
1699 const void * src, int src_pitch,
1700 Uint32 dst_format,
1701 void * dst, int dst_pitch);
1702
1703extern DECLSPEC int SDLCALL SDL_FillRect
1704 (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
1705extern DECLSPEC int SDLCALL SDL_FillRects
1706 (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
1707
1708#define SDL_BlitSurface SDL_UpperBlit
1709
1710extern DECLSPEC int SDLCALL SDL_UpperBlit
1711 (SDL_Surface * src, const SDL_Rect * srcrect,
1712 SDL_Surface * dst, SDL_Rect * dstrect);
1713
1714extern DECLSPEC int SDLCALL SDL_LowerBlit
1715 (SDL_Surface * src, SDL_Rect * srcrect,
1716 SDL_Surface * dst, SDL_Rect * dstrect);
1717
1718extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
1719 const SDL_Rect * srcrect,
1720 SDL_Surface * dst,
1721 const SDL_Rect * dstrect);
1722
1723#define SDL_BlitScaled SDL_UpperBlitScaled
1724
1725extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
1726 (SDL_Surface * src, const SDL_Rect * srcrect,
1727 SDL_Surface * dst, SDL_Rect * dstrect);
1728
1729extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
1730 (SDL_Surface * src, SDL_Rect * srcrect,
1731 SDL_Surface * dst, SDL_Rect * dstrect);
1732
1733#ifdef __cplusplus
1734}
1735#endif
1736#undef _begin_code_h
1737
1738#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
1739#ifdef __BORLANDC__
1740#pragma nopackwarning
1741#endif
1742#pragma pack(pop)
1743#endif
1744
1745#endif
1746
1747#ifdef _begin_code_h
1748#error Nested inclusion of begin_code.h
1749#endif
1750#define _begin_code_h
1751
1752#ifndef SDL_DEPRECATED
1753# if (__GNUC__ >= 4)
1754# define SDL_DEPRECATED __attribute__((deprecated))
1755# else
1756# define SDL_DEPRECATED
1757# endif
1758#endif
1759
1760#ifndef DECLSPEC
1761# if defined(__WIN32__) || defined(__WINRT__)
1762# ifdef __BORLANDC__
1763# ifdef BUILD_SDL
1764# define DECLSPEC
1765# else
1766# define DECLSPEC __declspec(dllimport)
1767# endif
1768# else
1769# define DECLSPEC __declspec(dllexport)
1770# endif
1771# else
1772# if defined(__GNUC__) && __GNUC__ >= 4
1773# define DECLSPEC __attribute__ ((visibility("default")))
1774# elif defined(__GNUC__) && __GNUC__ >= 2
1775# define DECLSPEC __declspec(dllexport)
1776# else
1777# define DECLSPEC
1778# endif
1779# endif
1780#endif
1781
1782#ifndef SDLCALL
1783#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
1784#define SDLCALL __cdecl
1785#else
1786#define SDLCALL
1787#endif
1788#endif
1789
1790#ifdef __SYMBIAN32__
1791#undef DECLSPEC
1792#define DECLSPEC
1793#endif
1794
1795#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
1796#ifdef _MSC_VER
1797#pragma warning(disable: 4103)
1798#endif
1799#ifdef __BORLANDC__
1800#pragma nopackwarning
1801#endif
1802#ifdef _M_X64
1803
1804#pragma pack(push,8)
1805#else
1806#pragma pack(push,4)
1807#endif
1808#endif
1809
1810#ifndef SDL_INLINE
1811#if defined(__GNUC__)
1812#define SDL_INLINE __inline__
1813#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
1814 defined(__DMC__) || defined(__SC__) || \
1815 defined(__WATCOMC__) || defined(__LCC__) || \
1816 defined(__DECC)
1817#define SDL_INLINE __inline
1818#ifndef __inline__
1819#define __inline__ __inline
1820#endif
1821#else
1822#define SDL_INLINE inline
1823#ifndef __inline__
1824#define __inline__ inline
1825#endif
1826#endif
1827#endif
1828
1829#ifndef SDL_FORCE_INLINE
1830#if defined(_MSC_VER)
1831#define SDL_FORCE_INLINE __forceinline
1832#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
1833#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
1834#else
1835#define SDL_FORCE_INLINE static SDL_INLINE
1836#endif
1837#endif
1838
1839#if !defined(__MACH__)
1840#ifndef NULL
1841#ifdef __cplusplus
1842#define NULL 0
1843#else
1844#define NULL ((void *)0)
1845#endif
1846#endif
1847#endif
1848
1849#ifdef __cplusplus
1850extern "C" {
1851#endif
1852
1853typedef struct
1854{
1855 Uint32 format;
1856 int w;
1857 int h;
1858 int refresh_rate;
1859 void *driverdata;
1860} SDL_DisplayMode;
1861
1862typedef struct SDL_Window SDL_Window;
1863
1864typedef enum
1865{
1866 SDL_WINDOW_FULLSCREEN = 0x00000001,
1867 SDL_WINDOW_OPENGL = 0x00000002,
1868 SDL_WINDOW_SHOWN = 0x00000004,
1869 SDL_WINDOW_HIDDEN = 0x00000008,
1870 SDL_WINDOW_BORDERLESS = 0x00000010,
1871 SDL_WINDOW_RESIZABLE = 0x00000020,
1872 SDL_WINDOW_MINIMIZED = 0x00000040,
1873 SDL_WINDOW_MAXIMIZED = 0x00000080,
1874 SDL_WINDOW_INPUT_GRABBED = 0x00000100,
1875 SDL_WINDOW_INPUT_FOCUS = 0x00000200,
1876 SDL_WINDOW_MOUSE_FOCUS = 0x00000400,
1877 SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
1878 SDL_WINDOW_FOREIGN = 0x00000800,
1879 SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000
1880} SDL_WindowFlags;
1881
1882#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000
1883#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
1884#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
1885#define SDL_WINDOWPOS_ISUNDEFINED(X) \
1886 (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
1887
1888#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000
1889#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
1890#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
1891#define SDL_WINDOWPOS_ISCENTERED(X) \
1892 (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
1893
1894typedef enum
1895{
1896 SDL_WINDOWEVENT_NONE,
1897 SDL_WINDOWEVENT_SHOWN,
1898 SDL_WINDOWEVENT_HIDDEN,
1899 SDL_WINDOWEVENT_EXPOSED,
1900 SDL_WINDOWEVENT_MOVED,
1901 SDL_WINDOWEVENT_RESIZED,
1902 SDL_WINDOWEVENT_SIZE_CHANGED,
1903 SDL_WINDOWEVENT_MINIMIZED,
1904 SDL_WINDOWEVENT_MAXIMIZED,
1905 SDL_WINDOWEVENT_RESTORED,
1906 SDL_WINDOWEVENT_ENTER,
1907 SDL_WINDOWEVENT_LEAVE,
1908 SDL_WINDOWEVENT_FOCUS_GAINED,
1909 SDL_WINDOWEVENT_FOCUS_LOST,
1910 SDL_WINDOWEVENT_CLOSE
1911} SDL_WindowEventID;
1912
1913typedef void *SDL_GLContext;
1914
1915typedef enum
1916{
1917 SDL_GL_RED_SIZE,
1918 SDL_GL_GREEN_SIZE,
1919 SDL_GL_BLUE_SIZE,
1920 SDL_GL_ALPHA_SIZE,
1921 SDL_GL_BUFFER_SIZE,
1922 SDL_GL_DOUBLEBUFFER,
1923 SDL_GL_DEPTH_SIZE,
1924 SDL_GL_STENCIL_SIZE,
1925 SDL_GL_ACCUM_RED_SIZE,
1926 SDL_GL_ACCUM_GREEN_SIZE,
1927 SDL_GL_ACCUM_BLUE_SIZE,
1928 SDL_GL_ACCUM_ALPHA_SIZE,
1929 SDL_GL_STEREO,
1930 SDL_GL_MULTISAMPLEBUFFERS,
1931 SDL_GL_MULTISAMPLESAMPLES,
1932 SDL_GL_ACCELERATED_VISUAL,
1933 SDL_GL_RETAINED_BACKING,
1934 SDL_GL_CONTEXT_MAJOR_VERSION,
1935 SDL_GL_CONTEXT_MINOR_VERSION,
1936 SDL_GL_CONTEXT_EGL,
1937 SDL_GL_CONTEXT_FLAGS,
1938 SDL_GL_CONTEXT_PROFILE_MASK,
1939 SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
1940 SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
1941} SDL_GLattr;
1942
1943typedef enum
1944{
1945 SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
1946 SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
1947 SDL_GL_CONTEXT_PROFILE_ES = 0x0004
1948} SDL_GLprofile;
1949
1950typedef enum
1951{
1952 SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
1953 SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
1954 SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
1955 SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
1956} SDL_GLcontextFlag;
1957
1958extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
1959
1960extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
1961
1962extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name);
1963
1964extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
1965
1966extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
1967
1968extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
1969
1970extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex);
1971
1972extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
1973
1974extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
1975
1976extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
1977 SDL_DisplayMode * mode);
1978
1979extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode);
1980
1981extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode);
1982
1983extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
1984
1985extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window);
1986
1987extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
1988 const SDL_DisplayMode
1989 * mode);
1990
1991extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
1992 SDL_DisplayMode * mode);
1993
1994extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
1995
1996extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
1997 int x, int y, int w,
1998 int h, Uint32 flags);
1999
2000extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data);
2001
2002extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
2003
2004extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
2005
2006extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
2007
2008extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
2009 const char *title);
2010
2011extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
2012
2013extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
2014 SDL_Surface * icon);
2015
2016extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
2017 const char *name,
2018 void *userdata);
2019
2020extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
2021 const char *name);
2022
2023extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
2024 int x, int y);
2025
2026extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
2027 int *x, int *y);
2028
2029extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
2030 int h);
2031
2032extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
2033 int *h);
2034
2035extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
2036 int min_w, int min_h);
2037
2038extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
2039 int *w, int *h);
2040
2041extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
2042 int max_w, int max_h);
2043
2044extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window,
2045 int *w, int *h);
2046
2047extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
2048 SDL_bool bordered);
2049
2050extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window);
2051
2052extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window);
2053
2054extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window);
2055
2056extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window);
2057
2058extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window);
2059
2060extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
2061
2062extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
2063 Uint32 flags);
2064
2065extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window);
2066
2067extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
2068
2069extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
2070 const SDL_Rect * rects,
2071 int numrects);
2072
2073extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
2074 SDL_bool grabbed);
2075
2076extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
2077
2078extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness);
2079
2080extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window);
2081
2082extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window,
2083 const Uint16 * red,
2084 const Uint16 * green,
2085 const Uint16 * blue);
2086
2087extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window,
2088 Uint16 * red,
2089 Uint16 * green,
2090 Uint16 * blue);
2091
2092extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window);
2093
2094extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void);
2095
2096extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void);
2097
2098extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void);
2099
2100extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
2101
2102extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
2103
2104extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
2105
2106extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char
2107 *extension);
2108
2109extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
2110
2111extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
2112
2113extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
2114
2115extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
2116 window);
2117
2118extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window,
2119 SDL_GLContext context);
2120
2121extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void);
2122
2123extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
2124
2125extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w,
2126 int *h);
2127
2128extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
2129
2130extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);
2131
2132extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window);
2133
2134extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
2135
2136#ifdef __cplusplus
2137}
2138#endif
2139#undef _begin_code_h
2140
2141#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
2142#ifdef __BORLANDC__
2143#pragma nopackwarning
2144#endif
2145#pragma pack(pop)
2146#endif
2147
2148#endif
2149#ifndef _SDL_keyboard_h
2150#define _SDL_keyboard_h
2151
2152#ifndef _SDL_keycode_h
2153#define _SDL_keycode_h
2154
2155#ifndef _SDL_scancode_h
2156#define _SDL_scancode_h
2157
2158typedef enum
2159{
2160 SDL_SCANCODE_UNKNOWN = 0,
2161
2162 SDL_SCANCODE_A = 4,
2163 SDL_SCANCODE_B = 5,
2164 SDL_SCANCODE_C = 6,
2165 SDL_SCANCODE_D = 7,
2166 SDL_SCANCODE_E = 8,
2167 SDL_SCANCODE_F = 9,
2168 SDL_SCANCODE_G = 10,
2169 SDL_SCANCODE_H = 11,
2170 SDL_SCANCODE_I = 12,
2171 SDL_SCANCODE_J = 13,
2172 SDL_SCANCODE_K = 14,
2173 SDL_SCANCODE_L = 15,
2174 SDL_SCANCODE_M = 16,
2175 SDL_SCANCODE_N = 17,
2176 SDL_SCANCODE_O = 18,
2177 SDL_SCANCODE_P = 19,
2178 SDL_SCANCODE_Q = 20,
2179 SDL_SCANCODE_R = 21,
2180 SDL_SCANCODE_S = 22,
2181 SDL_SCANCODE_T = 23,
2182 SDL_SCANCODE_U = 24,
2183 SDL_SCANCODE_V = 25,
2184 SDL_SCANCODE_W = 26,
2185 SDL_SCANCODE_X = 27,
2186 SDL_SCANCODE_Y = 28,
2187 SDL_SCANCODE_Z = 29,
2188
2189 SDL_SCANCODE_1 = 30,
2190 SDL_SCANCODE_2 = 31,
2191 SDL_SCANCODE_3 = 32,
2192 SDL_SCANCODE_4 = 33,
2193 SDL_SCANCODE_5 = 34,
2194 SDL_SCANCODE_6 = 35,
2195 SDL_SCANCODE_7 = 36,
2196 SDL_SCANCODE_8 = 37,
2197 SDL_SCANCODE_9 = 38,
2198 SDL_SCANCODE_0 = 39,
2199
2200 SDL_SCANCODE_RETURN = 40,
2201 SDL_SCANCODE_ESCAPE = 41,
2202 SDL_SCANCODE_BACKSPACE = 42,
2203 SDL_SCANCODE_TAB = 43,
2204 SDL_SCANCODE_SPACE = 44,
2205
2206 SDL_SCANCODE_MINUS = 45,
2207 SDL_SCANCODE_EQUALS = 46,
2208 SDL_SCANCODE_LEFTBRACKET = 47,
2209 SDL_SCANCODE_RIGHTBRACKET = 48,
2210 SDL_SCANCODE_BACKSLASH = 49,
2211 SDL_SCANCODE_NONUSHASH = 50,
2212 SDL_SCANCODE_SEMICOLON = 51,
2213 SDL_SCANCODE_APOSTROPHE = 52,
2214 SDL_SCANCODE_GRAVE = 53,
2215 SDL_SCANCODE_COMMA = 54,
2216 SDL_SCANCODE_PERIOD = 55,
2217 SDL_SCANCODE_SLASH = 56,
2218
2219 SDL_SCANCODE_CAPSLOCK = 57,
2220
2221 SDL_SCANCODE_F1 = 58,
2222 SDL_SCANCODE_F2 = 59,
2223 SDL_SCANCODE_F3 = 60,
2224 SDL_SCANCODE_F4 = 61,
2225 SDL_SCANCODE_F5 = 62,
2226 SDL_SCANCODE_F6 = 63,
2227 SDL_SCANCODE_F7 = 64,
2228 SDL_SCANCODE_F8 = 65,
2229 SDL_SCANCODE_F9 = 66,
2230 SDL_SCANCODE_F10 = 67,
2231 SDL_SCANCODE_F11 = 68,
2232 SDL_SCANCODE_F12 = 69,
2233
2234 SDL_SCANCODE_PRINTSCREEN = 70,
2235 SDL_SCANCODE_SCROLLLOCK = 71,
2236 SDL_SCANCODE_PAUSE = 72,
2237 SDL_SCANCODE_INSERT = 73,
2238 SDL_SCANCODE_HOME = 74,
2239 SDL_SCANCODE_PAGEUP = 75,
2240 SDL_SCANCODE_DELETE = 76,
2241 SDL_SCANCODE_END = 77,
2242 SDL_SCANCODE_PAGEDOWN = 78,
2243 SDL_SCANCODE_RIGHT = 79,
2244 SDL_SCANCODE_LEFT = 80,
2245 SDL_SCANCODE_DOWN = 81,
2246 SDL_SCANCODE_UP = 82,
2247
2248 SDL_SCANCODE_NUMLOCKCLEAR = 83,
2249 SDL_SCANCODE_KP_DIVIDE = 84,
2250 SDL_SCANCODE_KP_MULTIPLY = 85,
2251 SDL_SCANCODE_KP_MINUS = 86,
2252 SDL_SCANCODE_KP_PLUS = 87,
2253 SDL_SCANCODE_KP_ENTER = 88,
2254 SDL_SCANCODE_KP_1 = 89,
2255 SDL_SCANCODE_KP_2 = 90,
2256 SDL_SCANCODE_KP_3 = 91,
2257 SDL_SCANCODE_KP_4 = 92,
2258 SDL_SCANCODE_KP_5 = 93,
2259 SDL_SCANCODE_KP_6 = 94,
2260 SDL_SCANCODE_KP_7 = 95,
2261 SDL_SCANCODE_KP_8 = 96,
2262 SDL_SCANCODE_KP_9 = 97,
2263 SDL_SCANCODE_KP_0 = 98,
2264 SDL_SCANCODE_KP_PERIOD = 99,
2265
2266 SDL_SCANCODE_NONUSBACKSLASH = 100,
2267 SDL_SCANCODE_APPLICATION = 101,
2268 SDL_SCANCODE_POWER = 102,
2269 SDL_SCANCODE_KP_EQUALS = 103,
2270 SDL_SCANCODE_F13 = 104,
2271 SDL_SCANCODE_F14 = 105,
2272 SDL_SCANCODE_F15 = 106,
2273 SDL_SCANCODE_F16 = 107,
2274 SDL_SCANCODE_F17 = 108,
2275 SDL_SCANCODE_F18 = 109,
2276 SDL_SCANCODE_F19 = 110,
2277 SDL_SCANCODE_F20 = 111,
2278 SDL_SCANCODE_F21 = 112,
2279 SDL_SCANCODE_F22 = 113,
2280 SDL_SCANCODE_F23 = 114,
2281 SDL_SCANCODE_F24 = 115,
2282 SDL_SCANCODE_EXECUTE = 116,
2283 SDL_SCANCODE_HELP = 117,
2284 SDL_SCANCODE_MENU = 118,
2285 SDL_SCANCODE_SELECT = 119,
2286 SDL_SCANCODE_STOP = 120,
2287 SDL_SCANCODE_AGAIN = 121,
2288 SDL_SCANCODE_UNDO = 122,
2289 SDL_SCANCODE_CUT = 123,
2290 SDL_SCANCODE_COPY = 124,
2291 SDL_SCANCODE_PASTE = 125,
2292 SDL_SCANCODE_FIND = 126,
2293 SDL_SCANCODE_MUTE = 127,
2294 SDL_SCANCODE_VOLUMEUP = 128,
2295 SDL_SCANCODE_VOLUMEDOWN = 129,
2296
2297 SDL_SCANCODE_KP_COMMA = 133,
2298 SDL_SCANCODE_KP_EQUALSAS400 = 134,
2299
2300 SDL_SCANCODE_INTERNATIONAL1 = 135,
2301 SDL_SCANCODE_INTERNATIONAL2 = 136,
2302 SDL_SCANCODE_INTERNATIONAL3 = 137,
2303 SDL_SCANCODE_INTERNATIONAL4 = 138,
2304 SDL_SCANCODE_INTERNATIONAL5 = 139,
2305 SDL_SCANCODE_INTERNATIONAL6 = 140,
2306 SDL_SCANCODE_INTERNATIONAL7 = 141,
2307 SDL_SCANCODE_INTERNATIONAL8 = 142,
2308 SDL_SCANCODE_INTERNATIONAL9 = 143,
2309 SDL_SCANCODE_LANG1 = 144,
2310 SDL_SCANCODE_LANG2 = 145,
2311 SDL_SCANCODE_LANG3 = 146,
2312 SDL_SCANCODE_LANG4 = 147,
2313 SDL_SCANCODE_LANG5 = 148,
2314 SDL_SCANCODE_LANG6 = 149,
2315 SDL_SCANCODE_LANG7 = 150,
2316 SDL_SCANCODE_LANG8 = 151,
2317 SDL_SCANCODE_LANG9 = 152,
2318
2319 SDL_SCANCODE_ALTERASE = 153,
2320 SDL_SCANCODE_SYSREQ = 154,
2321 SDL_SCANCODE_CANCEL = 155,
2322 SDL_SCANCODE_CLEAR = 156,
2323 SDL_SCANCODE_PRIOR = 157,
2324 SDL_SCANCODE_RETURN2 = 158,
2325 SDL_SCANCODE_SEPARATOR = 159,
2326 SDL_SCANCODE_OUT = 160,
2327 SDL_SCANCODE_OPER = 161,
2328 SDL_SCANCODE_CLEARAGAIN = 162,
2329 SDL_SCANCODE_CRSEL = 163,
2330 SDL_SCANCODE_EXSEL = 164,
2331
2332 SDL_SCANCODE_KP_00 = 176,
2333 SDL_SCANCODE_KP_000 = 177,
2334 SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
2335 SDL_SCANCODE_DECIMALSEPARATOR = 179,
2336 SDL_SCANCODE_CURRENCYUNIT = 180,
2337 SDL_SCANCODE_CURRENCYSUBUNIT = 181,
2338 SDL_SCANCODE_KP_LEFTPAREN = 182,
2339 SDL_SCANCODE_KP_RIGHTPAREN = 183,
2340 SDL_SCANCODE_KP_LEFTBRACE = 184,
2341 SDL_SCANCODE_KP_RIGHTBRACE = 185,
2342 SDL_SCANCODE_KP_TAB = 186,
2343 SDL_SCANCODE_KP_BACKSPACE = 187,
2344 SDL_SCANCODE_KP_A = 188,
2345 SDL_SCANCODE_KP_B = 189,
2346 SDL_SCANCODE_KP_C = 190,
2347 SDL_SCANCODE_KP_D = 191,
2348 SDL_SCANCODE_KP_E = 192,
2349 SDL_SCANCODE_KP_F = 193,
2350 SDL_SCANCODE_KP_XOR = 194,
2351 SDL_SCANCODE_KP_POWER = 195,
2352 SDL_SCANCODE_KP_PERCENT = 196,
2353 SDL_SCANCODE_KP_LESS = 197,
2354 SDL_SCANCODE_KP_GREATER = 198,
2355 SDL_SCANCODE_KP_AMPERSAND = 199,
2356 SDL_SCANCODE_KP_DBLAMPERSAND = 200,
2357 SDL_SCANCODE_KP_VERTICALBAR = 201,
2358 SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
2359 SDL_SCANCODE_KP_COLON = 203,
2360 SDL_SCANCODE_KP_HASH = 204,
2361 SDL_SCANCODE_KP_SPACE = 205,
2362 SDL_SCANCODE_KP_AT = 206,
2363 SDL_SCANCODE_KP_EXCLAM = 207,
2364 SDL_SCANCODE_KP_MEMSTORE = 208,
2365 SDL_SCANCODE_KP_MEMRECALL = 209,
2366 SDL_SCANCODE_KP_MEMCLEAR = 210,
2367 SDL_SCANCODE_KP_MEMADD = 211,
2368 SDL_SCANCODE_KP_MEMSUBTRACT = 212,
2369 SDL_SCANCODE_KP_MEMMULTIPLY = 213,
2370 SDL_SCANCODE_KP_MEMDIVIDE = 214,
2371 SDL_SCANCODE_KP_PLUSMINUS = 215,
2372 SDL_SCANCODE_KP_CLEAR = 216,
2373 SDL_SCANCODE_KP_CLEARENTRY = 217,
2374 SDL_SCANCODE_KP_BINARY = 218,
2375 SDL_SCANCODE_KP_OCTAL = 219,
2376 SDL_SCANCODE_KP_DECIMAL = 220,
2377 SDL_SCANCODE_KP_HEXADECIMAL = 221,
2378
2379 SDL_SCANCODE_LCTRL = 224,
2380 SDL_SCANCODE_LSHIFT = 225,
2381 SDL_SCANCODE_LALT = 226,
2382 SDL_SCANCODE_LGUI = 227,
2383 SDL_SCANCODE_RCTRL = 228,
2384 SDL_SCANCODE_RSHIFT = 229,
2385 SDL_SCANCODE_RALT = 230,
2386 SDL_SCANCODE_RGUI = 231,
2387
2388 SDL_SCANCODE_MODE = 257,
2389
2390 SDL_SCANCODE_AUDIONEXT = 258,
2391 SDL_SCANCODE_AUDIOPREV = 259,
2392 SDL_SCANCODE_AUDIOSTOP = 260,
2393 SDL_SCANCODE_AUDIOPLAY = 261,
2394 SDL_SCANCODE_AUDIOMUTE = 262,
2395 SDL_SCANCODE_MEDIASELECT = 263,
2396 SDL_SCANCODE_WWW = 264,
2397 SDL_SCANCODE_MAIL = 265,
2398 SDL_SCANCODE_CALCULATOR = 266,
2399 SDL_SCANCODE_COMPUTER = 267,
2400 SDL_SCANCODE_AC_SEARCH = 268,
2401 SDL_SCANCODE_AC_HOME = 269,
2402 SDL_SCANCODE_AC_BACK = 270,
2403 SDL_SCANCODE_AC_FORWARD = 271,
2404 SDL_SCANCODE_AC_STOP = 272,
2405 SDL_SCANCODE_AC_REFRESH = 273,
2406 SDL_SCANCODE_AC_BOOKMARKS = 274,
2407
2408 SDL_SCANCODE_BRIGHTNESSDOWN = 275,
2409 SDL_SCANCODE_BRIGHTNESSUP = 276,
2410 SDL_SCANCODE_DISPLAYSWITCH = 277,
2411 SDL_SCANCODE_KBDILLUMTOGGLE = 278,
2412 SDL_SCANCODE_KBDILLUMDOWN = 279,
2413 SDL_SCANCODE_KBDILLUMUP = 280,
2414 SDL_SCANCODE_EJECT = 281,
2415 SDL_SCANCODE_SLEEP = 282,
2416
2417 SDL_SCANCODE_APP1 = 283,
2418 SDL_SCANCODE_APP2 = 284,
2419
2420 SDL_NUM_SCANCODES = 512
2421} SDL_Scancode;
2422
2423#endif
2424
2425typedef Sint32 SDL_Keycode;
2426
2427#define SDLK_SCANCODE_MASK (1<<30)
2428#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
2429
2430enum
2431{
2432 SDLK_UNKNOWN = 0,
2433
2434 SDLK_RETURN = '\r',
2435 SDLK_ESCAPE = '\033',
2436 SDLK_BACKSPACE = '\b',
2437 SDLK_TAB = '\t',
2438 SDLK_SPACE = ' ',
2439 SDLK_EXCLAIM = '!',
2440 SDLK_QUOTEDBL = '"',
2441 SDLK_HASH = '#',
2442 SDLK_PERCENT = '%',
2443 SDLK_DOLLAR = '$',
2444 SDLK_AMPERSAND = '&',
2445 SDLK_QUOTE = '\'',
2446 SDLK_LEFTPAREN = '(',
2447 SDLK_RIGHTPAREN = ')',
2448 SDLK_ASTERISK = '*',
2449 SDLK_PLUS = '+',
2450 SDLK_COMMA = ',',
2451 SDLK_MINUS = '-',
2452 SDLK_PERIOD = '.',
2453 SDLK_SLASH = '/',
2454 SDLK_0 = '0',
2455 SDLK_1 = '1',
2456 SDLK_2 = '2',
2457 SDLK_3 = '3',
2458 SDLK_4 = '4',
2459 SDLK_5 = '5',
2460 SDLK_6 = '6',
2461 SDLK_7 = '7',
2462 SDLK_8 = '8',
2463 SDLK_9 = '9',
2464 SDLK_COLON = ':',
2465 SDLK_SEMICOLON = ';',
2466 SDLK_LESS = '<',
2467 SDLK_EQUALS = '=',
2468 SDLK_GREATER = '>',
2469 SDLK_QUESTION = '?',
2470 SDLK_AT = '@',
2471
2472 SDLK_LEFTBRACKET = '[',
2473 SDLK_BACKSLASH = '\\',
2474 SDLK_RIGHTBRACKET = ']',
2475 SDLK_CARET = '^',
2476 SDLK_UNDERSCORE = '_',
2477 SDLK_BACKQUOTE = '`',
2478 SDLK_a = 'a',
2479 SDLK_b = 'b',
2480 SDLK_c = 'c',
2481 SDLK_d = 'd',
2482 SDLK_e = 'e',
2483 SDLK_f = 'f',
2484 SDLK_g = 'g',
2485 SDLK_h = 'h',
2486 SDLK_i = 'i',
2487 SDLK_j = 'j',
2488 SDLK_k = 'k',
2489 SDLK_l = 'l',
2490 SDLK_m = 'm',
2491 SDLK_n = 'n',
2492 SDLK_o = 'o',
2493 SDLK_p = 'p',
2494 SDLK_q = 'q',
2495 SDLK_r = 'r',
2496 SDLK_s = 's',
2497 SDLK_t = 't',
2498 SDLK_u = 'u',
2499 SDLK_v = 'v',
2500 SDLK_w = 'w',
2501 SDLK_x = 'x',
2502 SDLK_y = 'y',
2503 SDLK_z = 'z',
2504
2505 SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK),
2506
2507 SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1),
2508 SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2),
2509 SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3),
2510 SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4),
2511 SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5),
2512 SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6),
2513 SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7),
2514 SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8),
2515 SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9),
2516 SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10),
2517 SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11),
2518 SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12),
2519
2520 SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN),
2521 SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK),
2522 SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE),
2523 SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT),
2524 SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME),
2525 SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP),
2526 SDLK_DELETE = '\177',
2527 SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END),
2528 SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN),
2529 SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT),
2530 SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT),
2531 SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN),
2532 SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP),
2533
2534 SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR),
2535 SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE),
2536 SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY),
2537 SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS),
2538 SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS),
2539 SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER),
2540 SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1),
2541 SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2),
2542 SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3),
2543 SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4),
2544 SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5),
2545 SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6),
2546 SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7),
2547 SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8),
2548 SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9),
2549 SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0),
2550 SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD),
2551
2552 SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION),
2553 SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER),
2554 SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS),
2555 SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13),
2556 SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14),
2557 SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15),
2558 SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16),
2559 SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17),
2560 SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18),
2561 SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19),
2562 SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20),
2563 SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21),
2564 SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22),
2565 SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23),
2566 SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24),
2567 SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE),
2568 SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP),
2569 SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU),
2570 SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT),
2571 SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP),
2572 SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN),
2573 SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO),
2574 SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT),
2575 SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY),
2576 SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE),
2577 SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND),
2578 SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE),
2579 SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP),
2580 SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN),
2581 SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA),
2582 SDLK_KP_EQUALSAS400 =
2583 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400),
2584
2585 SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE),
2586 SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ),
2587 SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL),
2588 SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR),
2589 SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR),
2590 SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2),
2591 SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR),
2592 SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT),
2593 SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER),
2594 SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN),
2595 SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL),
2596 SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL),
2597
2598 SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00),
2599 SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000),
2600 SDLK_THOUSANDSSEPARATOR =
2601 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR),
2602 SDLK_DECIMALSEPARATOR =
2603 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR),
2604 SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT),
2605 SDLK_CURRENCYSUBUNIT =
2606 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT),
2607 SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN),
2608 SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN),
2609 SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE),
2610 SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE),
2611 SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB),
2612 SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE),
2613 SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A),
2614 SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B),
2615 SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C),
2616 SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D),
2617 SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E),
2618 SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F),
2619 SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR),
2620 SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER),
2621 SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT),
2622 SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS),
2623 SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER),
2624 SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND),
2625 SDLK_KP_DBLAMPERSAND =
2626 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND),
2627 SDLK_KP_VERTICALBAR =
2628 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR),
2629 SDLK_KP_DBLVERTICALBAR =
2630 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR),
2631 SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON),
2632 SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH),
2633 SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE),
2634 SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT),
2635 SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM),
2636 SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE),
2637 SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL),
2638 SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR),
2639 SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD),
2640 SDLK_KP_MEMSUBTRACT =
2641 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT),
2642 SDLK_KP_MEMMULTIPLY =
2643 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY),
2644 SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE),
2645 SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS),
2646 SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR),
2647 SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY),
2648 SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY),
2649 SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL),
2650 SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL),
2651 SDLK_KP_HEXADECIMAL =
2652 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL),
2653
2654 SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL),
2655 SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT),
2656 SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT),
2657 SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI),
2658 SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL),
2659 SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT),
2660 SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT),
2661 SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI),
2662
2663 SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE),
2664
2665 SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT),
2666 SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV),
2667 SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP),
2668 SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY),
2669 SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE),
2670 SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT),
2671 SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW),
2672 SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL),
2673 SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR),
2674 SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER),
2675 SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH),
2676 SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME),
2677 SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK),
2678 SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD),
2679 SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP),
2680 SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH),
2681 SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS),
2682
2683 SDLK_BRIGHTNESSDOWN =
2684 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN),
2685 SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP),
2686 SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH),
2687 SDLK_KBDILLUMTOGGLE =
2688 SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE),
2689 SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN),
2690 SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP),
2691 SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT),
2692 SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP)
2693};
2694
2695typedef enum
2696{
2697 KMOD_NONE = 0x0000,
2698 KMOD_LSHIFT = 0x0001,
2699 KMOD_RSHIFT = 0x0002,
2700 KMOD_LCTRL = 0x0040,
2701 KMOD_RCTRL = 0x0080,
2702 KMOD_LALT = 0x0100,
2703 KMOD_RALT = 0x0200,
2704 KMOD_LGUI = 0x0400,
2705 KMOD_RGUI = 0x0800,
2706 KMOD_NUM = 0x1000,
2707 KMOD_CAPS = 0x2000,
2708 KMOD_MODE = 0x4000,
2709 KMOD_RESERVED = 0x8000
2710} SDL_Keymod;
2711
2712#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
2713#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)
2714#define KMOD_ALT (KMOD_LALT|KMOD_RALT)
2715#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI)
2716
2717#endif
2718
2719#ifdef _begin_code_h
2720#error Nested inclusion of begin_code.h
2721#endif
2722#define _begin_code_h
2723
2724#ifndef SDL_DEPRECATED
2725# if (__GNUC__ >= 4)
2726# define SDL_DEPRECATED __attribute__((deprecated))
2727# else
2728# define SDL_DEPRECATED
2729# endif
2730#endif
2731
2732#ifndef DECLSPEC
2733# if defined(__WIN32__) || defined(__WINRT__)
2734# ifdef __BORLANDC__
2735# ifdef BUILD_SDL
2736# define DECLSPEC
2737# else
2738# define DECLSPEC __declspec(dllimport)
2739# endif
2740# else
2741# define DECLSPEC __declspec(dllexport)
2742# endif
2743# else
2744# if defined(__GNUC__) && __GNUC__ >= 4
2745# define DECLSPEC __attribute__ ((visibility("default")))
2746# elif defined(__GNUC__) && __GNUC__ >= 2
2747# define DECLSPEC __declspec(dllexport)
2748# else
2749# define DECLSPEC
2750# endif
2751# endif
2752#endif
2753
2754#ifndef SDLCALL
2755#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
2756#define SDLCALL __cdecl
2757#else
2758#define SDLCALL
2759#endif
2760#endif
2761
2762#ifdef __SYMBIAN32__
2763#undef DECLSPEC
2764#define DECLSPEC
2765#endif
2766
2767#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
2768#ifdef _MSC_VER
2769#pragma warning(disable: 4103)
2770#endif
2771#ifdef __BORLANDC__
2772#pragma nopackwarning
2773#endif
2774#ifdef _M_X64
2775
2776#pragma pack(push,8)
2777#else
2778#pragma pack(push,4)
2779#endif
2780#endif
2781
2782#ifndef SDL_INLINE
2783#if defined(__GNUC__)
2784#define SDL_INLINE __inline__
2785#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
2786 defined(__DMC__) || defined(__SC__) || \
2787 defined(__WATCOMC__) || defined(__LCC__) || \
2788 defined(__DECC)
2789#define SDL_INLINE __inline
2790#ifndef __inline__
2791#define __inline__ __inline
2792#endif
2793#else
2794#define SDL_INLINE inline
2795#ifndef __inline__
2796#define __inline__ inline
2797#endif
2798#endif
2799#endif
2800
2801#ifndef SDL_FORCE_INLINE
2802#if defined(_MSC_VER)
2803#define SDL_FORCE_INLINE __forceinline
2804#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
2805#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
2806#else
2807#define SDL_FORCE_INLINE static SDL_INLINE
2808#endif
2809#endif
2810
2811#if !defined(__MACH__)
2812#ifndef NULL
2813#ifdef __cplusplus
2814#define NULL 0
2815#else
2816#define NULL ((void *)0)
2817#endif
2818#endif
2819#endif
2820
2821#ifdef __cplusplus
2822extern "C" {
2823#endif
2824
2825typedef struct SDL_Keysym
2826{
2827 SDL_Scancode scancode;
2828 SDL_Keycode sym;
2829 Uint16 mod;
2830 Uint32 unused;
2831} SDL_Keysym;
2832
2833extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
2834
2835extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
2836
2837extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
2838
2839extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
2840
2841extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);
2842
2843extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
2844
2845extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
2846
2847extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
2848
2849extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
2850
2851extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
2852
2853extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
2854
2855extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
2856
2857extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
2858
2859extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
2860
2861extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void);
2862
2863extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
2864
2865#ifdef __cplusplus
2866}
2867#endif
2868#undef _begin_code_h
2869
2870#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
2871#ifdef __BORLANDC__
2872#pragma nopackwarning
2873#endif
2874#pragma pack(pop)
2875#endif
2876
2877#endif
2878#ifndef _SDL_mouse_h
2879#define _SDL_mouse_h
2880
2881#ifdef _begin_code_h
2882#error Nested inclusion of begin_code.h
2883#endif
2884#define _begin_code_h
2885
2886#ifndef SDL_DEPRECATED
2887# if (__GNUC__ >= 4)
2888# define SDL_DEPRECATED __attribute__((deprecated))
2889# else
2890# define SDL_DEPRECATED
2891# endif
2892#endif
2893
2894#ifndef DECLSPEC
2895# if defined(__WIN32__) || defined(__WINRT__)
2896# ifdef __BORLANDC__
2897# ifdef BUILD_SDL
2898# define DECLSPEC
2899# else
2900# define DECLSPEC __declspec(dllimport)
2901# endif
2902# else
2903# define DECLSPEC __declspec(dllexport)
2904# endif
2905# else
2906# if defined(__GNUC__) && __GNUC__ >= 4
2907# define DECLSPEC __attribute__ ((visibility("default")))
2908# elif defined(__GNUC__) && __GNUC__ >= 2
2909# define DECLSPEC __declspec(dllexport)
2910# else
2911# define DECLSPEC
2912# endif
2913# endif
2914#endif
2915
2916#ifndef SDLCALL
2917#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
2918#define SDLCALL __cdecl
2919#else
2920#define SDLCALL
2921#endif
2922#endif
2923
2924#ifdef __SYMBIAN32__
2925#undef DECLSPEC
2926#define DECLSPEC
2927#endif
2928
2929#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
2930#ifdef _MSC_VER
2931#pragma warning(disable: 4103)
2932#endif
2933#ifdef __BORLANDC__
2934#pragma nopackwarning
2935#endif
2936#ifdef _M_X64
2937
2938#pragma pack(push,8)
2939#else
2940#pragma pack(push,4)
2941#endif
2942#endif
2943
2944#ifndef SDL_INLINE
2945#if defined(__GNUC__)
2946#define SDL_INLINE __inline__
2947#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
2948 defined(__DMC__) || defined(__SC__) || \
2949 defined(__WATCOMC__) || defined(__LCC__) || \
2950 defined(__DECC)
2951#define SDL_INLINE __inline
2952#ifndef __inline__
2953#define __inline__ __inline
2954#endif
2955#else
2956#define SDL_INLINE inline
2957#ifndef __inline__
2958#define __inline__ inline
2959#endif
2960#endif
2961#endif
2962
2963#ifndef SDL_FORCE_INLINE
2964#if defined(_MSC_VER)
2965#define SDL_FORCE_INLINE __forceinline
2966#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
2967#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
2968#else
2969#define SDL_FORCE_INLINE static SDL_INLINE
2970#endif
2971#endif
2972
2973#if !defined(__MACH__)
2974#ifndef NULL
2975#ifdef __cplusplus
2976#define NULL 0
2977#else
2978#define NULL ((void *)0)
2979#endif
2980#endif
2981#endif
2982
2983#ifdef __cplusplus
2984extern "C" {
2985#endif
2986
2987typedef struct SDL_Cursor SDL_Cursor;
2988
2989typedef enum
2990{
2991 SDL_SYSTEM_CURSOR_ARROW,
2992 SDL_SYSTEM_CURSOR_IBEAM,
2993 SDL_SYSTEM_CURSOR_WAIT,
2994 SDL_SYSTEM_CURSOR_CROSSHAIR,
2995 SDL_SYSTEM_CURSOR_WAITARROW,
2996 SDL_SYSTEM_CURSOR_SIZENWSE,
2997 SDL_SYSTEM_CURSOR_SIZENESW,
2998 SDL_SYSTEM_CURSOR_SIZEWE,
2999 SDL_SYSTEM_CURSOR_SIZENS,
3000 SDL_SYSTEM_CURSOR_SIZEALL,
3001 SDL_SYSTEM_CURSOR_NO,
3002 SDL_SYSTEM_CURSOR_HAND,
3003 SDL_NUM_SYSTEM_CURSORS
3004} SDL_SystemCursor;
3005
3006extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
3007
3008extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
3009
3010extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
3011
3012extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
3013 int x, int y);
3014
3015extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
3016
3017extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
3018
3019extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
3020 const Uint8 * mask,
3021 int w, int h, int hot_x,
3022 int hot_y);
3023
3024extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
3025 int hot_x,
3026 int hot_y);
3027
3028extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
3029
3030extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
3031
3032extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
3033
3034extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
3035
3036extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
3037
3038extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
3039
3040#define SDL_BUTTON(X) (1 << ((X)-1))
3041#define SDL_BUTTON_LEFT 1
3042#define SDL_BUTTON_MIDDLE 2
3043#define SDL_BUTTON_RIGHT 3
3044#define SDL_BUTTON_X1 4
3045#define SDL_BUTTON_X2 5
3046#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
3047#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
3048#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
3049#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
3050#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
3051
3052#ifdef __cplusplus
3053}
3054#endif
3055#undef _begin_code_h
3056
3057#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3058#ifdef __BORLANDC__
3059#pragma nopackwarning
3060#endif
3061#pragma pack(pop)
3062#endif
3063
3064#endif
3065#ifndef _SDL_joystick_h
3066#define _SDL_joystick_h
3067
3068#ifdef _begin_code_h
3069#error Nested inclusion of begin_code.h
3070#endif
3071#define _begin_code_h
3072
3073#ifndef SDL_DEPRECATED
3074# if (__GNUC__ >= 4)
3075# define SDL_DEPRECATED __attribute__((deprecated))
3076# else
3077# define SDL_DEPRECATED
3078# endif
3079#endif
3080
3081#ifndef DECLSPEC
3082# if defined(__WIN32__) || defined(__WINRT__)
3083# ifdef __BORLANDC__
3084# ifdef BUILD_SDL
3085# define DECLSPEC
3086# else
3087# define DECLSPEC __declspec(dllimport)
3088# endif
3089# else
3090# define DECLSPEC __declspec(dllexport)
3091# endif
3092# else
3093# if defined(__GNUC__) && __GNUC__ >= 4
3094# define DECLSPEC __attribute__ ((visibility("default")))
3095# elif defined(__GNUC__) && __GNUC__ >= 2
3096# define DECLSPEC __declspec(dllexport)
3097# else
3098# define DECLSPEC
3099# endif
3100# endif
3101#endif
3102
3103#ifndef SDLCALL
3104#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
3105#define SDLCALL __cdecl
3106#else
3107#define SDLCALL
3108#endif
3109#endif
3110
3111#ifdef __SYMBIAN32__
3112#undef DECLSPEC
3113#define DECLSPEC
3114#endif
3115
3116#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
3117#ifdef _MSC_VER
3118#pragma warning(disable: 4103)
3119#endif
3120#ifdef __BORLANDC__
3121#pragma nopackwarning
3122#endif
3123#ifdef _M_X64
3124
3125#pragma pack(push,8)
3126#else
3127#pragma pack(push,4)
3128#endif
3129#endif
3130
3131#ifndef SDL_INLINE
3132#if defined(__GNUC__)
3133#define SDL_INLINE __inline__
3134#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
3135 defined(__DMC__) || defined(__SC__) || \
3136 defined(__WATCOMC__) || defined(__LCC__) || \
3137 defined(__DECC)
3138#define SDL_INLINE __inline
3139#ifndef __inline__
3140#define __inline__ __inline
3141#endif
3142#else
3143#define SDL_INLINE inline
3144#ifndef __inline__
3145#define __inline__ inline
3146#endif
3147#endif
3148#endif
3149
3150#ifndef SDL_FORCE_INLINE
3151#if defined(_MSC_VER)
3152#define SDL_FORCE_INLINE __forceinline
3153#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
3154#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
3155#else
3156#define SDL_FORCE_INLINE static SDL_INLINE
3157#endif
3158#endif
3159
3160#if !defined(__MACH__)
3161#ifndef NULL
3162#ifdef __cplusplus
3163#define NULL 0
3164#else
3165#define NULL ((void *)0)
3166#endif
3167#endif
3168#endif
3169
3170#ifdef __cplusplus
3171extern "C" {
3172#endif
3173
3174struct _SDL_Joystick;
3175typedef struct _SDL_Joystick SDL_Joystick;
3176
3177typedef struct {
3178 Uint8 data[16];
3179} SDL_JoystickGUID;
3180
3181typedef Sint32 SDL_JoystickID;
3182
3183extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
3184
3185extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
3186
3187extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
3188
3189extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
3190
3191extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
3192
3193extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
3194
3195extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
3196
3197extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
3198
3199extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
3200
3201extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
3202
3203extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
3204
3205extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
3206
3207extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
3208
3209extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
3210
3211extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
3212
3213extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
3214
3215extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
3216 int axis);
3217
3218#define SDL_HAT_CENTERED 0x00
3219#define SDL_HAT_UP 0x01
3220#define SDL_HAT_RIGHT 0x02
3221#define SDL_HAT_DOWN 0x04
3222#define SDL_HAT_LEFT 0x08
3223#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
3224#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
3225#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
3226#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
3227
3228extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
3229 int hat);
3230
3231extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
3232 int ball, int *dx, int *dy);
3233
3234extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
3235 int button);
3236
3237extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
3238
3239#ifdef __cplusplus
3240}
3241#endif
3242#undef _begin_code_h
3243
3244#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3245#ifdef __BORLANDC__
3246#pragma nopackwarning
3247#endif
3248#pragma pack(pop)
3249#endif
3250
3251#endif
3252#ifndef _SDL_gamecontroller_h
3253#define _SDL_gamecontroller_h
3254
3255#ifdef _begin_code_h
3256#error Nested inclusion of begin_code.h
3257#endif
3258#define _begin_code_h
3259
3260#ifndef SDL_DEPRECATED
3261# if (__GNUC__ >= 4)
3262# define SDL_DEPRECATED __attribute__((deprecated))
3263# else
3264# define SDL_DEPRECATED
3265# endif
3266#endif
3267
3268#ifndef DECLSPEC
3269# if defined(__WIN32__) || defined(__WINRT__)
3270# ifdef __BORLANDC__
3271# ifdef BUILD_SDL
3272# define DECLSPEC
3273# else
3274# define DECLSPEC __declspec(dllimport)
3275# endif
3276# else
3277# define DECLSPEC __declspec(dllexport)
3278# endif
3279# else
3280# if defined(__GNUC__) && __GNUC__ >= 4
3281# define DECLSPEC __attribute__ ((visibility("default")))
3282# elif defined(__GNUC__) && __GNUC__ >= 2
3283# define DECLSPEC __declspec(dllexport)
3284# else
3285# define DECLSPEC
3286# endif
3287# endif
3288#endif
3289
3290#ifndef SDLCALL
3291#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
3292#define SDLCALL __cdecl
3293#else
3294#define SDLCALL
3295#endif
3296#endif
3297
3298#ifdef __SYMBIAN32__
3299#undef DECLSPEC
3300#define DECLSPEC
3301#endif
3302
3303#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
3304#ifdef _MSC_VER
3305#pragma warning(disable: 4103)
3306#endif
3307#ifdef __BORLANDC__
3308#pragma nopackwarning
3309#endif
3310#ifdef _M_X64
3311
3312#pragma pack(push,8)
3313#else
3314#pragma pack(push,4)
3315#endif
3316#endif
3317
3318#ifndef SDL_INLINE
3319#if defined(__GNUC__)
3320#define SDL_INLINE __inline__
3321#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
3322 defined(__DMC__) || defined(__SC__) || \
3323 defined(__WATCOMC__) || defined(__LCC__) || \
3324 defined(__DECC)
3325#define SDL_INLINE __inline
3326#ifndef __inline__
3327#define __inline__ __inline
3328#endif
3329#else
3330#define SDL_INLINE inline
3331#ifndef __inline__
3332#define __inline__ inline
3333#endif
3334#endif
3335#endif
3336
3337#ifndef SDL_FORCE_INLINE
3338#if defined(_MSC_VER)
3339#define SDL_FORCE_INLINE __forceinline
3340#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
3341#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
3342#else
3343#define SDL_FORCE_INLINE static SDL_INLINE
3344#endif
3345#endif
3346
3347#if !defined(__MACH__)
3348#ifndef NULL
3349#ifdef __cplusplus
3350#define NULL 0
3351#else
3352#define NULL ((void *)0)
3353#endif
3354#endif
3355#endif
3356
3357#ifdef __cplusplus
3358extern "C" {
3359#endif
3360
3361struct _SDL_GameController;
3362typedef struct _SDL_GameController SDL_GameController;
3363
3364typedef enum
3365{
3366 SDL_CONTROLLER_BINDTYPE_NONE = 0,
3367 SDL_CONTROLLER_BINDTYPE_BUTTON,
3368 SDL_CONTROLLER_BINDTYPE_AXIS,
3369 SDL_CONTROLLER_BINDTYPE_HAT
3370} SDL_GameControllerBindType;
3371
3372typedef struct SDL_GameControllerButtonBind
3373{
3374 SDL_GameControllerBindType bindType;
3375 union
3376 {
3377 int button;
3378 int axis;
3379 struct {
3380 int hat;
3381 int hat_mask;
3382 } hat;
3383 } value;
3384
3385} SDL_GameControllerButtonBind;
3386
3387extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw );
3388
3389#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
3390
3391extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString );
3392
3393extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
3394
3395extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller );
3396
3397extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
3398
3399extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
3400
3401extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
3402
3403extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
3404
3405extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
3406
3407extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
3408
3409extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
3410
3411extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
3412
3413typedef enum
3414{
3415 SDL_CONTROLLER_AXIS_INVALID = -1,
3416 SDL_CONTROLLER_AXIS_LEFTX,
3417 SDL_CONTROLLER_AXIS_LEFTY,
3418 SDL_CONTROLLER_AXIS_RIGHTX,
3419 SDL_CONTROLLER_AXIS_RIGHTY,
3420 SDL_CONTROLLER_AXIS_TRIGGERLEFT,
3421 SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
3422 SDL_CONTROLLER_AXIS_MAX
3423} SDL_GameControllerAxis;
3424
3425extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
3426
3427extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
3428
3429extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
3430SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
3431 SDL_GameControllerAxis axis);
3432
3433extern DECLSPEC Sint16 SDLCALL
3434SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
3435 SDL_GameControllerAxis axis);
3436
3437typedef enum
3438{
3439 SDL_CONTROLLER_BUTTON_INVALID = -1,
3440 SDL_CONTROLLER_BUTTON_A,
3441 SDL_CONTROLLER_BUTTON_B,
3442 SDL_CONTROLLER_BUTTON_X,
3443 SDL_CONTROLLER_BUTTON_Y,
3444 SDL_CONTROLLER_BUTTON_BACK,
3445 SDL_CONTROLLER_BUTTON_GUIDE,
3446 SDL_CONTROLLER_BUTTON_START,
3447 SDL_CONTROLLER_BUTTON_LEFTSTICK,
3448 SDL_CONTROLLER_BUTTON_RIGHTSTICK,
3449 SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
3450 SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
3451 SDL_CONTROLLER_BUTTON_DPAD_UP,
3452 SDL_CONTROLLER_BUTTON_DPAD_DOWN,
3453 SDL_CONTROLLER_BUTTON_DPAD_LEFT,
3454 SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
3455 SDL_CONTROLLER_BUTTON_MAX
3456} SDL_GameControllerButton;
3457
3458extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
3459
3460extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
3461
3462extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
3463SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
3464 SDL_GameControllerButton button);
3465
3466extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
3467 SDL_GameControllerButton button);
3468
3469extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
3470
3471#ifdef __cplusplus
3472}
3473#endif
3474#undef _begin_code_h
3475
3476#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3477#ifdef __BORLANDC__
3478#pragma nopackwarning
3479#endif
3480#pragma pack(pop)
3481#endif
3482
3483#endif
3484#ifndef _SDL_quit_h
3485#define _SDL_quit_h
3486
3487#define SDL_QuitRequested() \
3488 (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0))
3489
3490#endif
3491#ifndef _SDL_gesture_h
3492#define _SDL_gesture_h
3493
3494#ifndef _SDL_touch_h
3495#define _SDL_touch_h
3496
3497#ifdef _begin_code_h
3498#error Nested inclusion of begin_code.h
3499#endif
3500#define _begin_code_h
3501
3502#ifndef SDL_DEPRECATED
3503# if (__GNUC__ >= 4)
3504# define SDL_DEPRECATED __attribute__((deprecated))
3505# else
3506# define SDL_DEPRECATED
3507# endif
3508#endif
3509
3510#ifndef DECLSPEC
3511# if defined(__WIN32__) || defined(__WINRT__)
3512# ifdef __BORLANDC__
3513# ifdef BUILD_SDL
3514# define DECLSPEC
3515# else
3516# define DECLSPEC __declspec(dllimport)
3517# endif
3518# else
3519# define DECLSPEC __declspec(dllexport)
3520# endif
3521# else
3522# if defined(__GNUC__) && __GNUC__ >= 4
3523# define DECLSPEC __attribute__ ((visibility("default")))
3524# elif defined(__GNUC__) && __GNUC__ >= 2
3525# define DECLSPEC __declspec(dllexport)
3526# else
3527# define DECLSPEC
3528# endif
3529# endif
3530#endif
3531
3532#ifndef SDLCALL
3533#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
3534#define SDLCALL __cdecl
3535#else
3536#define SDLCALL
3537#endif
3538#endif
3539
3540#ifdef __SYMBIAN32__
3541#undef DECLSPEC
3542#define DECLSPEC
3543#endif
3544
3545#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
3546#ifdef _MSC_VER
3547#pragma warning(disable: 4103)
3548#endif
3549#ifdef __BORLANDC__
3550#pragma nopackwarning
3551#endif
3552#ifdef _M_X64
3553
3554#pragma pack(push,8)
3555#else
3556#pragma pack(push,4)
3557#endif
3558#endif
3559
3560#ifndef SDL_INLINE
3561#if defined(__GNUC__)
3562#define SDL_INLINE __inline__
3563#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
3564 defined(__DMC__) || defined(__SC__) || \
3565 defined(__WATCOMC__) || defined(__LCC__) || \
3566 defined(__DECC)
3567#define SDL_INLINE __inline
3568#ifndef __inline__
3569#define __inline__ __inline
3570#endif
3571#else
3572#define SDL_INLINE inline
3573#ifndef __inline__
3574#define __inline__ inline
3575#endif
3576#endif
3577#endif
3578
3579#ifndef SDL_FORCE_INLINE
3580#if defined(_MSC_VER)
3581#define SDL_FORCE_INLINE __forceinline
3582#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
3583#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
3584#else
3585#define SDL_FORCE_INLINE static SDL_INLINE
3586#endif
3587#endif
3588
3589#if !defined(__MACH__)
3590#ifndef NULL
3591#ifdef __cplusplus
3592#define NULL 0
3593#else
3594#define NULL ((void *)0)
3595#endif
3596#endif
3597#endif
3598
3599#ifdef __cplusplus
3600extern "C" {
3601#endif
3602
3603typedef Sint64 SDL_TouchID;
3604typedef Sint64 SDL_FingerID;
3605
3606typedef struct SDL_Finger
3607{
3608 SDL_FingerID id;
3609 float x;
3610 float y;
3611 float pressure;
3612} SDL_Finger;
3613
3614#define SDL_TOUCH_MOUSEID ((Uint32)-1)
3615
3616extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void);
3617
3618extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
3619
3620extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID);
3621
3622extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index);
3623
3624#ifdef __cplusplus
3625}
3626#endif
3627#undef _begin_code_h
3628
3629#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3630#ifdef __BORLANDC__
3631#pragma nopackwarning
3632#endif
3633#pragma pack(pop)
3634#endif
3635
3636#endif
3637
3638#ifdef _begin_code_h
3639#error Nested inclusion of begin_code.h
3640#endif
3641#define _begin_code_h
3642
3643#ifndef SDL_DEPRECATED
3644# if (__GNUC__ >= 4)
3645# define SDL_DEPRECATED __attribute__((deprecated))
3646# else
3647# define SDL_DEPRECATED
3648# endif
3649#endif
3650
3651#ifndef DECLSPEC
3652# if defined(__WIN32__) || defined(__WINRT__)
3653# ifdef __BORLANDC__
3654# ifdef BUILD_SDL
3655# define DECLSPEC
3656# else
3657# define DECLSPEC __declspec(dllimport)
3658# endif
3659# else
3660# define DECLSPEC __declspec(dllexport)
3661# endif
3662# else
3663# if defined(__GNUC__) && __GNUC__ >= 4
3664# define DECLSPEC __attribute__ ((visibility("default")))
3665# elif defined(__GNUC__) && __GNUC__ >= 2
3666# define DECLSPEC __declspec(dllexport)
3667# else
3668# define DECLSPEC
3669# endif
3670# endif
3671#endif
3672
3673#ifndef SDLCALL
3674#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
3675#define SDLCALL __cdecl
3676#else
3677#define SDLCALL
3678#endif
3679#endif
3680
3681#ifdef __SYMBIAN32__
3682#undef DECLSPEC
3683#define DECLSPEC
3684#endif
3685
3686#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
3687#ifdef _MSC_VER
3688#pragma warning(disable: 4103)
3689#endif
3690#ifdef __BORLANDC__
3691#pragma nopackwarning
3692#endif
3693#ifdef _M_X64
3694
3695#pragma pack(push,8)
3696#else
3697#pragma pack(push,4)
3698#endif
3699#endif
3700
3701#ifndef SDL_INLINE
3702#if defined(__GNUC__)
3703#define SDL_INLINE __inline__
3704#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
3705 defined(__DMC__) || defined(__SC__) || \
3706 defined(__WATCOMC__) || defined(__LCC__) || \
3707 defined(__DECC)
3708#define SDL_INLINE __inline
3709#ifndef __inline__
3710#define __inline__ __inline
3711#endif
3712#else
3713#define SDL_INLINE inline
3714#ifndef __inline__
3715#define __inline__ inline
3716#endif
3717#endif
3718#endif
3719
3720#ifndef SDL_FORCE_INLINE
3721#if defined(_MSC_VER)
3722#define SDL_FORCE_INLINE __forceinline
3723#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
3724#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
3725#else
3726#define SDL_FORCE_INLINE static SDL_INLINE
3727#endif
3728#endif
3729
3730#if !defined(__MACH__)
3731#ifndef NULL
3732#ifdef __cplusplus
3733#define NULL 0
3734#else
3735#define NULL ((void *)0)
3736#endif
3737#endif
3738#endif
3739
3740#ifdef __cplusplus
3741extern "C" {
3742#endif
3743
3744typedef Sint64 SDL_GestureID;
3745
3746extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
3747
3748extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
3749
3750extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst);
3751
3752extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
3753
3754#ifdef __cplusplus
3755}
3756#endif
3757#undef _begin_code_h
3758
3759#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3760#ifdef __BORLANDC__
3761#pragma nopackwarning
3762#endif
3763#pragma pack(pop)
3764#endif
3765
3766#endif
3767
3768#ifdef _begin_code_h
3769#error Nested inclusion of begin_code.h
3770#endif
3771#define _begin_code_h
3772
3773#ifndef SDL_DEPRECATED
3774# if (__GNUC__ >= 4)
3775# define SDL_DEPRECATED __attribute__((deprecated))
3776# else
3777# define SDL_DEPRECATED
3778# endif
3779#endif
3780
3781#ifndef DECLSPEC
3782# if defined(__WIN32__) || defined(__WINRT__)
3783# ifdef __BORLANDC__
3784# ifdef BUILD_SDL
3785# define DECLSPEC
3786# else
3787# define DECLSPEC __declspec(dllimport)
3788# endif
3789# else
3790# define DECLSPEC __declspec(dllexport)
3791# endif
3792# else
3793# if defined(__GNUC__) && __GNUC__ >= 4
3794# define DECLSPEC __attribute__ ((visibility("default")))
3795# elif defined(__GNUC__) && __GNUC__ >= 2
3796# define DECLSPEC __declspec(dllexport)
3797# else
3798# define DECLSPEC
3799# endif
3800# endif
3801#endif
3802
3803#ifndef SDLCALL
3804#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
3805#define SDLCALL __cdecl
3806#else
3807#define SDLCALL
3808#endif
3809#endif
3810
3811#ifdef __SYMBIAN32__
3812#undef DECLSPEC
3813#define DECLSPEC
3814#endif
3815
3816#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
3817#ifdef _MSC_VER
3818#pragma warning(disable: 4103)
3819#endif
3820#ifdef __BORLANDC__
3821#pragma nopackwarning
3822#endif
3823#ifdef _M_X64
3824
3825#pragma pack(push,8)
3826#else
3827#pragma pack(push,4)
3828#endif
3829#endif
3830
3831#ifndef SDL_INLINE
3832#if defined(__GNUC__)
3833#define SDL_INLINE __inline__
3834#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
3835 defined(__DMC__) || defined(__SC__) || \
3836 defined(__WATCOMC__) || defined(__LCC__) || \
3837 defined(__DECC)
3838#define SDL_INLINE __inline
3839#ifndef __inline__
3840#define __inline__ __inline
3841#endif
3842#else
3843#define SDL_INLINE inline
3844#ifndef __inline__
3845#define __inline__ inline
3846#endif
3847#endif
3848#endif
3849
3850#ifndef SDL_FORCE_INLINE
3851#if defined(_MSC_VER)
3852#define SDL_FORCE_INLINE __forceinline
3853#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
3854#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
3855#else
3856#define SDL_FORCE_INLINE static SDL_INLINE
3857#endif
3858#endif
3859
3860#if !defined(__MACH__)
3861#ifndef NULL
3862#ifdef __cplusplus
3863#define NULL 0
3864#else
3865#define NULL ((void *)0)
3866#endif
3867#endif
3868#endif
3869
3870#ifdef __cplusplus
3871extern "C" {
3872#endif
3873
3874#define SDL_RELEASED 0
3875#define SDL_PRESSED 1
3876
3877typedef enum
3878{
3879 SDL_FIRSTEVENT = 0,
3880
3881 SDL_QUIT = 0x100,
3882
3883 SDL_APP_TERMINATING,
3884 SDL_APP_LOWMEMORY,
3885 SDL_APP_WILLENTERBACKGROUND,
3886 SDL_APP_DIDENTERBACKGROUND,
3887 SDL_APP_WILLENTERFOREGROUND,
3888 SDL_APP_DIDENTERFOREGROUND,
3889
3890 SDL_WINDOWEVENT = 0x200,
3891 SDL_SYSWMEVENT,
3892
3893 SDL_KEYDOWN = 0x300,
3894 SDL_KEYUP,
3895 SDL_TEXTEDITING,
3896 SDL_TEXTINPUT,
3897
3898 SDL_MOUSEMOTION = 0x400,
3899 SDL_MOUSEBUTTONDOWN,
3900 SDL_MOUSEBUTTONUP,
3901 SDL_MOUSEWHEEL,
3902
3903 SDL_JOYAXISMOTION = 0x600,
3904 SDL_JOYBALLMOTION,
3905 SDL_JOYHATMOTION,
3906 SDL_JOYBUTTONDOWN,
3907 SDL_JOYBUTTONUP,
3908 SDL_JOYDEVICEADDED,
3909 SDL_JOYDEVICEREMOVED,
3910
3911 SDL_CONTROLLERAXISMOTION = 0x650,
3912 SDL_CONTROLLERBUTTONDOWN,
3913 SDL_CONTROLLERBUTTONUP,
3914 SDL_CONTROLLERDEVICEADDED,
3915 SDL_CONTROLLERDEVICEREMOVED,
3916 SDL_CONTROLLERDEVICEREMAPPED,
3917
3918 SDL_FINGERDOWN = 0x700,
3919 SDL_FINGERUP,
3920 SDL_FINGERMOTION,
3921
3922 SDL_DOLLARGESTURE = 0x800,
3923 SDL_DOLLARRECORD,
3924 SDL_MULTIGESTURE,
3925
3926 SDL_CLIPBOARDUPDATE = 0x900,
3927
3928 SDL_DROPFILE = 0x1000,
3929
3930 SDL_RENDER_TARGETS_RESET = 0x2000,
3931
3932 SDL_USEREVENT = 0x8000,
3933
3934 SDL_LASTEVENT = 0xFFFF
3935} SDL_EventType;
3936
3937typedef struct SDL_CommonEvent
3938{
3939 Uint32 type;
3940 Uint32 timestamp;
3941} SDL_CommonEvent;
3942
3943typedef struct SDL_WindowEvent
3944{
3945 Uint32 type;
3946 Uint32 timestamp;
3947 Uint32 windowID;
3948 Uint8 event;
3949 Uint8 padding1;
3950 Uint8 padding2;
3951 Uint8 padding3;
3952 Sint32 data1;
3953 Sint32 data2;
3954} SDL_WindowEvent;
3955
3956typedef struct SDL_KeyboardEvent
3957{
3958 Uint32 type;
3959 Uint32 timestamp;
3960 Uint32 windowID;
3961 Uint8 state;
3962 Uint8 repeat;
3963 Uint8 padding2;
3964 Uint8 padding3;
3965 SDL_Keysym keysym;
3966} SDL_KeyboardEvent;
3967
3968#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
3969
3970typedef struct SDL_TextEditingEvent
3971{
3972 Uint32 type;
3973 Uint32 timestamp;
3974 Uint32 windowID;
3975 char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
3976 Sint32 start;
3977 Sint32 length;
3978} SDL_TextEditingEvent;
3979
3980#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
3981
3982typedef struct SDL_TextInputEvent
3983{
3984 Uint32 type;
3985 Uint32 timestamp;
3986 Uint32 windowID;
3987 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
3988} SDL_TextInputEvent;
3989
3990typedef struct SDL_MouseMotionEvent
3991{
3992 Uint32 type;
3993 Uint32 timestamp;
3994 Uint32 windowID;
3995 Uint32 which;
3996 Uint32 state;
3997 Sint32 x;
3998 Sint32 y;
3999 Sint32 xrel;
4000 Sint32 yrel;
4001} SDL_MouseMotionEvent;
4002
4003typedef struct SDL_MouseButtonEvent
4004{
4005 Uint32 type;
4006 Uint32 timestamp;
4007 Uint32 windowID;
4008 Uint32 which;
4009 Uint8 button;
4010 Uint8 state;
4011 Uint8 clicks;
4012 Uint8 padding1;
4013 Sint32 x;
4014 Sint32 y;
4015} SDL_MouseButtonEvent;
4016
4017typedef struct SDL_MouseWheelEvent
4018{
4019 Uint32 type;
4020 Uint32 timestamp;
4021 Uint32 windowID;
4022 Uint32 which;
4023 Sint32 x;
4024 Sint32 y;
4025} SDL_MouseWheelEvent;
4026
4027typedef struct SDL_JoyAxisEvent
4028{
4029 Uint32 type;
4030 Uint32 timestamp;
4031 SDL_JoystickID which;
4032 Uint8 axis;
4033 Uint8 padding1;
4034 Uint8 padding2;
4035 Uint8 padding3;
4036 Sint16 value;
4037 Uint16 padding4;
4038} SDL_JoyAxisEvent;
4039
4040typedef struct SDL_JoyBallEvent
4041{
4042 Uint32 type;
4043 Uint32 timestamp;
4044 SDL_JoystickID which;
4045 Uint8 ball;
4046 Uint8 padding1;
4047 Uint8 padding2;
4048 Uint8 padding3;
4049 Sint16 xrel;
4050 Sint16 yrel;
4051} SDL_JoyBallEvent;
4052
4053typedef struct SDL_JoyHatEvent
4054{
4055 Uint32 type;
4056 Uint32 timestamp;
4057 SDL_JoystickID which;
4058 Uint8 hat;
4059 Uint8 value;
4060 Uint8 padding1;
4061 Uint8 padding2;
4062} SDL_JoyHatEvent;
4063
4064typedef struct SDL_JoyButtonEvent
4065{
4066 Uint32 type;
4067 Uint32 timestamp;
4068 SDL_JoystickID which;
4069 Uint8 button;
4070 Uint8 state;
4071 Uint8 padding1;
4072 Uint8 padding2;
4073} SDL_JoyButtonEvent;
4074
4075typedef struct SDL_JoyDeviceEvent
4076{
4077 Uint32 type;
4078 Uint32 timestamp;
4079 Sint32 which;
4080} SDL_JoyDeviceEvent;
4081
4082typedef struct SDL_ControllerAxisEvent
4083{
4084 Uint32 type;
4085 Uint32 timestamp;
4086 SDL_JoystickID which;
4087 Uint8 axis;
4088 Uint8 padding1;
4089 Uint8 padding2;
4090 Uint8 padding3;
4091 Sint16 value;
4092 Uint16 padding4;
4093} SDL_ControllerAxisEvent;
4094
4095typedef struct SDL_ControllerButtonEvent
4096{
4097 Uint32 type;
4098 Uint32 timestamp;
4099 SDL_JoystickID which;
4100 Uint8 button;
4101 Uint8 state;
4102 Uint8 padding1;
4103 Uint8 padding2;
4104} SDL_ControllerButtonEvent;
4105
4106typedef struct SDL_ControllerDeviceEvent
4107{
4108 Uint32 type;
4109 Uint32 timestamp;
4110 Sint32 which;
4111} SDL_ControllerDeviceEvent;
4112
4113typedef struct SDL_TouchFingerEvent
4114{
4115 Uint32 type;
4116 Uint32 timestamp;
4117 SDL_TouchID touchId;
4118 SDL_FingerID fingerId;
4119 float x;
4120 float y;
4121 float dx;
4122 float dy;
4123 float pressure;
4124} SDL_TouchFingerEvent;
4125
4126typedef struct SDL_MultiGestureEvent
4127{
4128 Uint32 type;
4129 Uint32 timestamp;
4130 SDL_TouchID touchId;
4131 float dTheta;
4132 float dDist;
4133 float x;
4134 float y;
4135 Uint16 numFingers;
4136 Uint16 padding;
4137} SDL_MultiGestureEvent;
4138
4139typedef struct SDL_DollarGestureEvent
4140{
4141 Uint32 type;
4142 Uint32 timestamp;
4143 SDL_TouchID touchId;
4144 SDL_GestureID gestureId;
4145 Uint32 numFingers;
4146 float error;
4147 float x;
4148 float y;
4149} SDL_DollarGestureEvent;
4150
4151typedef struct SDL_DropEvent
4152{
4153 Uint32 type;
4154 Uint32 timestamp;
4155 char *file;
4156} SDL_DropEvent;
4157
4158typedef struct SDL_QuitEvent
4159{
4160 Uint32 type;
4161 Uint32 timestamp;
4162} SDL_QuitEvent;
4163
4164typedef struct SDL_OSEvent
4165{
4166 Uint32 type;
4167 Uint32 timestamp;
4168} SDL_OSEvent;
4169
4170typedef struct SDL_UserEvent
4171{
4172 Uint32 type;
4173 Uint32 timestamp;
4174 Uint32 windowID;
4175 Sint32 code;
4176 void *data1;
4177 void *data2;
4178} SDL_UserEvent;
4179
4180struct SDL_SysWMmsg;
4181typedef struct SDL_SysWMmsg SDL_SysWMmsg;
4182
4183typedef struct SDL_SysWMEvent
4184{
4185 Uint32 type;
4186 Uint32 timestamp;
4187 SDL_SysWMmsg *msg;
4188} SDL_SysWMEvent;
4189
4190typedef union SDL_Event
4191{
4192 Uint32 type;
4193 SDL_CommonEvent common;
4194 SDL_WindowEvent window;
4195 SDL_KeyboardEvent key;
4196 SDL_TextEditingEvent edit;
4197 SDL_TextInputEvent text;
4198 SDL_MouseMotionEvent motion;
4199 SDL_MouseButtonEvent button;
4200 SDL_MouseWheelEvent wheel;
4201 SDL_JoyAxisEvent jaxis;
4202 SDL_JoyBallEvent jball;
4203 SDL_JoyHatEvent jhat;
4204 SDL_JoyButtonEvent jbutton;
4205 SDL_JoyDeviceEvent jdevice;
4206 SDL_ControllerAxisEvent caxis;
4207 SDL_ControllerButtonEvent cbutton;
4208 SDL_ControllerDeviceEvent cdevice;
4209 SDL_QuitEvent quit;
4210 SDL_UserEvent user;
4211 SDL_SysWMEvent syswm;
4212 SDL_TouchFingerEvent tfinger;
4213 SDL_MultiGestureEvent mgesture;
4214 SDL_DollarGestureEvent dgesture;
4215 SDL_DropEvent drop;
4216
4217 Uint8 padding[56];
4218} SDL_Event;
4219
4220extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
4221
4222typedef enum
4223{
4224 SDL_ADDEVENT,
4225 SDL_PEEKEVENT,
4226 SDL_GETEVENT
4227} SDL_eventaction;
4228
4229extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
4230 SDL_eventaction action,
4231 Uint32 minType, Uint32 maxType);
4232
4233extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
4234extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
4235
4236extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
4237extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
4238
4239extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
4240
4241extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
4242
4243extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
4244 int timeout);
4245
4246extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
4247
4248typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
4249
4250extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
4251 void *userdata);
4252
4253extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
4254 void **userdata);
4255
4256extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
4257 void *userdata);
4258
4259extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
4260 void *userdata);
4261
4262extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
4263 void *userdata);
4264
4265#define SDL_QUERY -1
4266#define SDL_IGNORE 0
4267#define SDL_DISABLE 0
4268#define SDL_ENABLE 1
4269
4270extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
4271
4272#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
4273
4274extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
4275
4276#ifdef __cplusplus
4277}
4278#endif
4279#undef _begin_code_h
4280
4281#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
4282#ifdef __BORLANDC__
4283#pragma nopackwarning
4284#endif
4285#pragma pack(pop)
4286#endif
4287
4288#endif
4289#include "SDL_filesystem.h"
4290#include "SDL_haptic.h"
4291#ifndef _SDL_hints_h
4292#define _SDL_hints_h
4293
4294#ifdef _begin_code_h
4295#error Nested inclusion of begin_code.h
4296#endif
4297#define _begin_code_h
4298
4299#ifndef SDL_DEPRECATED
4300# if (__GNUC__ >= 4)
4301# define SDL_DEPRECATED __attribute__((deprecated))
4302# else
4303# define SDL_DEPRECATED
4304# endif
4305#endif
4306
4307#ifndef DECLSPEC
4308# if defined(__WIN32__) || defined(__WINRT__)
4309# ifdef __BORLANDC__
4310# ifdef BUILD_SDL
4311# define DECLSPEC
4312# else
4313# define DECLSPEC __declspec(dllimport)
4314# endif
4315# else
4316# define DECLSPEC __declspec(dllexport)
4317# endif
4318# else
4319# if defined(__GNUC__) && __GNUC__ >= 4
4320# define DECLSPEC __attribute__ ((visibility("default")))
4321# elif defined(__GNUC__) && __GNUC__ >= 2
4322# define DECLSPEC __declspec(dllexport)
4323# else
4324# define DECLSPEC
4325# endif
4326# endif
4327#endif
4328
4329#ifndef SDLCALL
4330#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
4331#define SDLCALL __cdecl
4332#else
4333#define SDLCALL
4334#endif
4335#endif
4336
4337#ifdef __SYMBIAN32__
4338#undef DECLSPEC
4339#define DECLSPEC
4340#endif
4341
4342#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
4343#ifdef _MSC_VER
4344#pragma warning(disable: 4103)
4345#endif
4346#ifdef __BORLANDC__
4347#pragma nopackwarning
4348#endif
4349#ifdef _M_X64
4350
4351#pragma pack(push,8)
4352#else
4353#pragma pack(push,4)
4354#endif
4355#endif
4356
4357#ifndef SDL_INLINE
4358#if defined(__GNUC__)
4359#define SDL_INLINE __inline__
4360#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
4361 defined(__DMC__) || defined(__SC__) || \
4362 defined(__WATCOMC__) || defined(__LCC__) || \
4363 defined(__DECC)
4364#define SDL_INLINE __inline
4365#ifndef __inline__
4366#define __inline__ __inline
4367#endif
4368#else
4369#define SDL_INLINE inline
4370#ifndef __inline__
4371#define __inline__ inline
4372#endif
4373#endif
4374#endif
4375
4376#ifndef SDL_FORCE_INLINE
4377#if defined(_MSC_VER)
4378#define SDL_FORCE_INLINE __forceinline
4379#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
4380#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
4381#else
4382#define SDL_FORCE_INLINE static SDL_INLINE
4383#endif
4384#endif
4385
4386#if !defined(__MACH__)
4387#ifndef NULL
4388#ifdef __cplusplus
4389#define NULL 0
4390#else
4391#define NULL ((void *)0)
4392#endif
4393#endif
4394#endif
4395
4396#ifdef __cplusplus
4397extern "C" {
4398#endif
4399
4400#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION"
4401
4402#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER"
4403
4404#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS"
4405
4406#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE"
4407
4408#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_HINT_RENDER_DIRECT3D11_DEBUG"
4409
4410#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY"
4411
4412#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC"
4413
4414#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER"
4415
4416#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE"
4417
4418#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA"
4419
4420#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"
4421
4422#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD"
4423
4424#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP "SDL_MOUSE_RELATIVE_MODE_WARP"
4425
4426#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
4427
4428#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED"
4429
4430#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS"
4431
4432#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK"
4433
4434#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED"
4435
4436#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
4437
4438#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"
4439
4440#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST"
4441
4442#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION"
4443
4444#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED"
4445
4446#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK"
4447
4448#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER"
4449
4450#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
4451
4452#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_HINT_WINRT_PRIVACY_POLICY_URL"
4453
4454#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_HINT_WINRT_PRIVACY_POLICY_LABEL"
4455
4456#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_HINT_WINRT_HANDLE_BACK_BUTTON"
4457
4458#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
4459
4460typedef enum
4461{
4462 SDL_HINT_DEFAULT,
4463 SDL_HINT_NORMAL,
4464 SDL_HINT_OVERRIDE
4465} SDL_HintPriority;
4466
4467extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name,
4468 const char *value,
4469 SDL_HintPriority priority);
4470
4471extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name,
4472 const char *value);
4473
4474extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name);
4475
4476typedef void (*SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue);
4477extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name,
4478 SDL_HintCallback callback,
4479 void *userdata);
4480
4481extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name,
4482 SDL_HintCallback callback,
4483 void *userdata);
4484
4485extern DECLSPEC void SDLCALL SDL_ClearHints(void);
4486
4487#ifdef __cplusplus
4488}
4489#endif
4490#undef _begin_code_h
4491
4492#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
4493#ifdef __BORLANDC__
4494#pragma nopackwarning
4495#endif
4496#pragma pack(pop)
4497#endif
4498
4499#endif
4500#ifndef _SDL_loadso_h
4501#define _SDL_loadso_h
4502
4503#ifdef _begin_code_h
4504#error Nested inclusion of begin_code.h
4505#endif
4506#define _begin_code_h
4507
4508#ifndef SDL_DEPRECATED
4509# if (__GNUC__ >= 4)
4510# define SDL_DEPRECATED __attribute__((deprecated))
4511# else
4512# define SDL_DEPRECATED
4513# endif
4514#endif
4515
4516#ifndef DECLSPEC
4517# if defined(__WIN32__) || defined(__WINRT__)
4518# ifdef __BORLANDC__
4519# ifdef BUILD_SDL
4520# define DECLSPEC
4521# else
4522# define DECLSPEC __declspec(dllimport)
4523# endif
4524# else
4525# define DECLSPEC __declspec(dllexport)
4526# endif
4527# else
4528# if defined(__GNUC__) && __GNUC__ >= 4
4529# define DECLSPEC __attribute__ ((visibility("default")))
4530# elif defined(__GNUC__) && __GNUC__ >= 2
4531# define DECLSPEC __declspec(dllexport)
4532# else
4533# define DECLSPEC
4534# endif
4535# endif
4536#endif
4537
4538#ifndef SDLCALL
4539#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
4540#define SDLCALL __cdecl
4541#else
4542#define SDLCALL
4543#endif
4544#endif
4545
4546#ifdef __SYMBIAN32__
4547#undef DECLSPEC
4548#define DECLSPEC
4549#endif
4550
4551#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
4552#ifdef _MSC_VER
4553#pragma warning(disable: 4103)
4554#endif
4555#ifdef __BORLANDC__
4556#pragma nopackwarning
4557#endif
4558#ifdef _M_X64
4559
4560#pragma pack(push,8)
4561#else
4562#pragma pack(push,4)
4563#endif
4564#endif
4565
4566#ifndef SDL_INLINE
4567#if defined(__GNUC__)
4568#define SDL_INLINE __inline__
4569#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
4570 defined(__DMC__) || defined(__SC__) || \
4571 defined(__WATCOMC__) || defined(__LCC__) || \
4572 defined(__DECC)
4573#define SDL_INLINE __inline
4574#ifndef __inline__
4575#define __inline__ __inline
4576#endif
4577#else
4578#define SDL_INLINE inline
4579#ifndef __inline__
4580#define __inline__ inline
4581#endif
4582#endif
4583#endif
4584
4585#ifndef SDL_FORCE_INLINE
4586#if defined(_MSC_VER)
4587#define SDL_FORCE_INLINE __forceinline
4588#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
4589#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
4590#else
4591#define SDL_FORCE_INLINE static SDL_INLINE
4592#endif
4593#endif
4594
4595#if !defined(__MACH__)
4596#ifndef NULL
4597#ifdef __cplusplus
4598#define NULL 0
4599#else
4600#define NULL ((void *)0)
4601#endif
4602#endif
4603#endif
4604
4605#ifdef __cplusplus
4606extern "C" {
4607#endif
4608
4609extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
4610
4611extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
4612 const char *name);
4613
4614extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
4615
4616#ifdef __cplusplus
4617}
4618#endif
4619#undef _begin_code_h
4620
4621#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
4622#ifdef __BORLANDC__
4623#pragma nopackwarning
4624#endif
4625#pragma pack(pop)
4626#endif
4627
4628#endif
4629#include "SDL_log.h"
4630#ifndef _SDL_messagebox_h
4631#define _SDL_messagebox_h
4632
4633#ifdef _begin_code_h
4634#error Nested inclusion of begin_code.h
4635#endif
4636#define _begin_code_h
4637
4638#ifndef SDL_DEPRECATED
4639# if (__GNUC__ >= 4)
4640# define SDL_DEPRECATED __attribute__((deprecated))
4641# else
4642# define SDL_DEPRECATED
4643# endif
4644#endif
4645
4646#ifndef DECLSPEC
4647# if defined(__WIN32__) || defined(__WINRT__)
4648# ifdef __BORLANDC__
4649# ifdef BUILD_SDL
4650# define DECLSPEC
4651# else
4652# define DECLSPEC __declspec(dllimport)
4653# endif
4654# else
4655# define DECLSPEC __declspec(dllexport)
4656# endif
4657# else
4658# if defined(__GNUC__) && __GNUC__ >= 4
4659# define DECLSPEC __attribute__ ((visibility("default")))
4660# elif defined(__GNUC__) && __GNUC__ >= 2
4661# define DECLSPEC __declspec(dllexport)
4662# else
4663# define DECLSPEC
4664# endif
4665# endif
4666#endif
4667
4668#ifndef SDLCALL
4669#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
4670#define SDLCALL __cdecl
4671#else
4672#define SDLCALL
4673#endif
4674#endif
4675
4676#ifdef __SYMBIAN32__
4677#undef DECLSPEC
4678#define DECLSPEC
4679#endif
4680
4681#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
4682#ifdef _MSC_VER
4683#pragma warning(disable: 4103)
4684#endif
4685#ifdef __BORLANDC__
4686#pragma nopackwarning
4687#endif
4688#ifdef _M_X64
4689
4690#pragma pack(push,8)
4691#else
4692#pragma pack(push,4)
4693#endif
4694#endif
4695
4696#ifndef SDL_INLINE
4697#if defined(__GNUC__)
4698#define SDL_INLINE __inline__
4699#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
4700 defined(__DMC__) || defined(__SC__) || \
4701 defined(__WATCOMC__) || defined(__LCC__) || \
4702 defined(__DECC)
4703#define SDL_INLINE __inline
4704#ifndef __inline__
4705#define __inline__ __inline
4706#endif
4707#else
4708#define SDL_INLINE inline
4709#ifndef __inline__
4710#define __inline__ inline
4711#endif
4712#endif
4713#endif
4714
4715#ifndef SDL_FORCE_INLINE
4716#if defined(_MSC_VER)
4717#define SDL_FORCE_INLINE __forceinline
4718#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
4719#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
4720#else
4721#define SDL_FORCE_INLINE static SDL_INLINE
4722#endif
4723#endif
4724
4725#if !defined(__MACH__)
4726#ifndef NULL
4727#ifdef __cplusplus
4728#define NULL 0
4729#else
4730#define NULL ((void *)0)
4731#endif
4732#endif
4733#endif
4734
4735#ifdef __cplusplus
4736extern "C" {
4737#endif
4738
4739typedef enum
4740{
4741 SDL_MESSAGEBOX_ERROR = 0x00000010,
4742 SDL_MESSAGEBOX_WARNING = 0x00000020,
4743 SDL_MESSAGEBOX_INFORMATION = 0x00000040
4744} SDL_MessageBoxFlags;
4745
4746typedef enum
4747{
4748 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001,
4749 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002
4750} SDL_MessageBoxButtonFlags;
4751
4752typedef struct
4753{
4754 Uint32 flags;
4755 int buttonid;
4756 const char * text;
4757} SDL_MessageBoxButtonData;
4758
4759typedef struct
4760{
4761 Uint8 r, g, b;
4762} SDL_MessageBoxColor;
4763
4764typedef enum
4765{
4766 SDL_MESSAGEBOX_COLOR_BACKGROUND,
4767 SDL_MESSAGEBOX_COLOR_TEXT,
4768 SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
4769 SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
4770 SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
4771 SDL_MESSAGEBOX_COLOR_MAX
4772} SDL_MessageBoxColorType;
4773
4774typedef struct
4775{
4776 SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX];
4777} SDL_MessageBoxColorScheme;
4778
4779typedef struct
4780{
4781 Uint32 flags;
4782 SDL_Window *window;
4783 const char *title;
4784 const char *message;
4785
4786 int numbuttons;
4787 const SDL_MessageBoxButtonData *buttons;
4788
4789 const SDL_MessageBoxColorScheme *colorScheme;
4790} SDL_MessageBoxData;
4791
4792extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
4793
4794extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window);
4795
4796#ifdef __cplusplus
4797}
4798#endif
4799#undef _begin_code_h
4800
4801#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
4802#ifdef __BORLANDC__
4803#pragma nopackwarning
4804#endif
4805#pragma pack(pop)
4806#endif
4807
4808#endif
4809#include "SDL_power.h"
4810#ifndef _SDL_render_h
4811#define _SDL_render_h
4812
4813#ifdef _begin_code_h
4814#error Nested inclusion of begin_code.h
4815#endif
4816#define _begin_code_h
4817
4818#ifndef SDL_DEPRECATED
4819# if (__GNUC__ >= 4)
4820# define SDL_DEPRECATED __attribute__((deprecated))
4821# else
4822# define SDL_DEPRECATED
4823# endif
4824#endif
4825
4826#ifndef DECLSPEC
4827# if defined(__WIN32__) || defined(__WINRT__)
4828# ifdef __BORLANDC__
4829# ifdef BUILD_SDL
4830# define DECLSPEC
4831# else
4832# define DECLSPEC __declspec(dllimport)
4833# endif
4834# else
4835# define DECLSPEC __declspec(dllexport)
4836# endif
4837# else
4838# if defined(__GNUC__) && __GNUC__ >= 4
4839# define DECLSPEC __attribute__ ((visibility("default")))
4840# elif defined(__GNUC__) && __GNUC__ >= 2
4841# define DECLSPEC __declspec(dllexport)
4842# else
4843# define DECLSPEC
4844# endif
4845# endif
4846#endif
4847
4848#ifndef SDLCALL
4849#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
4850#define SDLCALL __cdecl
4851#else
4852#define SDLCALL
4853#endif
4854#endif
4855
4856#ifdef __SYMBIAN32__
4857#undef DECLSPEC
4858#define DECLSPEC
4859#endif
4860
4861#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
4862#ifdef _MSC_VER
4863#pragma warning(disable: 4103)
4864#endif
4865#ifdef __BORLANDC__
4866#pragma nopackwarning
4867#endif
4868#ifdef _M_X64
4869
4870#pragma pack(push,8)
4871#else
4872#pragma pack(push,4)
4873#endif
4874#endif
4875
4876#ifndef SDL_INLINE
4877#if defined(__GNUC__)
4878#define SDL_INLINE __inline__
4879#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
4880 defined(__DMC__) || defined(__SC__) || \
4881 defined(__WATCOMC__) || defined(__LCC__) || \
4882 defined(__DECC)
4883#define SDL_INLINE __inline
4884#ifndef __inline__
4885#define __inline__ __inline
4886#endif
4887#else
4888#define SDL_INLINE inline
4889#ifndef __inline__
4890#define __inline__ inline
4891#endif
4892#endif
4893#endif
4894
4895#ifndef SDL_FORCE_INLINE
4896#if defined(_MSC_VER)
4897#define SDL_FORCE_INLINE __forceinline
4898#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
4899#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
4900#else
4901#define SDL_FORCE_INLINE static SDL_INLINE
4902#endif
4903#endif
4904
4905#if !defined(__MACH__)
4906#ifndef NULL
4907#ifdef __cplusplus
4908#define NULL 0
4909#else
4910#define NULL ((void *)0)
4911#endif
4912#endif
4913#endif
4914
4915#ifdef __cplusplus
4916extern "C" {
4917#endif
4918
4919typedef enum
4920{
4921 SDL_RENDERER_SOFTWARE = 0x00000001,
4922 SDL_RENDERER_ACCELERATED = 0x00000002,
4923 SDL_RENDERER_PRESENTVSYNC = 0x00000004,
4924 SDL_RENDERER_TARGETTEXTURE = 0x00000008
4925} SDL_RendererFlags;
4926
4927typedef struct SDL_RendererInfo
4928{
4929 const char *name;
4930 Uint32 flags;
4931 Uint32 num_texture_formats;
4932 Uint32 texture_formats[16];
4933 int max_texture_width;
4934 int max_texture_height;
4935} SDL_RendererInfo;
4936
4937typedef enum
4938{
4939 SDL_TEXTUREACCESS_STATIC,
4940 SDL_TEXTUREACCESS_STREAMING,
4941 SDL_TEXTUREACCESS_TARGET
4942} SDL_TextureAccess;
4943
4944typedef enum
4945{
4946 SDL_TEXTUREMODULATE_NONE = 0x00000000,
4947 SDL_TEXTUREMODULATE_COLOR = 0x00000001,
4948 SDL_TEXTUREMODULATE_ALPHA = 0x00000002
4949} SDL_TextureModulate;
4950
4951typedef enum
4952{
4953 SDL_FLIP_NONE = 0x00000000,
4954 SDL_FLIP_HORIZONTAL = 0x00000001,
4955 SDL_FLIP_VERTICAL = 0x00000002
4956} SDL_RendererFlip;
4957
4958struct SDL_Renderer;
4959typedef struct SDL_Renderer SDL_Renderer;
4960
4961struct SDL_Texture;
4962typedef struct SDL_Texture SDL_Texture;
4963
4964extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
4965
4966extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
4967 SDL_RendererInfo * info);
4968
4969extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
4970 int width, int height, Uint32 window_flags,
4971 SDL_Window **window, SDL_Renderer **renderer);
4972
4973extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
4974 int index, Uint32 flags);
4975
4976extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
4977
4978extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
4979
4980extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
4981 SDL_RendererInfo * info);
4982
4983extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
4984 int *w, int *h);
4985
4986extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
4987 Uint32 format,
4988 int access, int w,
4989 int h);
4990
4991extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
4992
4993extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
4994 Uint32 * format, int *access,
4995 int *w, int *h);
4996
4997extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
4998 Uint8 r, Uint8 g, Uint8 b);
4999
5000extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
5001 Uint8 * r, Uint8 * g,
5002 Uint8 * b);
5003
5004extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
5005 Uint8 alpha);
5006
5007extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
5008 Uint8 * alpha);
5009
5010extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
5011 SDL_BlendMode blendMode);
5012
5013extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
5014 SDL_BlendMode *blendMode);
5015
5016extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
5017 const SDL_Rect * rect,
5018 const void *pixels, int pitch);
5019
5020extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
5021 const SDL_Rect * rect,
5022 const Uint8 *Yplane, int Ypitch,
5023 const Uint8 *Uplane, int Upitch,
5024 const Uint8 *Vplane, int Vpitch);
5025
5026extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
5027 const SDL_Rect * rect,
5028 void **pixels, int *pitch);
5029
5030extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
5031
5032extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
5033
5034extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
5035 SDL_Texture *texture);
5036
5037extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
5038
5039extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
5040
5041extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
5042
5043extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
5044 const SDL_Rect * rect);
5045
5046extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
5047 SDL_Rect * rect);
5048
5049extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
5050 const SDL_Rect * rect);
5051
5052extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
5053 SDL_Rect * rect);
5054
5055extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
5056 float scaleX, float scaleY);
5057
5058extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
5059 float *scaleX, float *scaleY);
5060
5061extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
5062 Uint8 r, Uint8 g, Uint8 b,
5063 Uint8 a);
5064
5065extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
5066 Uint8 * r, Uint8 * g, Uint8 * b,
5067 Uint8 * a);
5068
5069extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
5070 SDL_BlendMode blendMode);
5071
5072extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
5073 SDL_BlendMode *blendMode);
5074
5075extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
5076
5077extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
5078 int x, int y);
5079
5080extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
5081 const SDL_Point * points,
5082 int count);
5083
5084extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
5085 int x1, int y1, int x2, int y2);
5086
5087extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
5088 const SDL_Point * points,
5089 int count);
5090
5091extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
5092 const SDL_Rect * rect);
5093
5094extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
5095 const SDL_Rect * rects,
5096 int count);
5097
5098extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
5099 const SDL_Rect * rect);
5100
5101extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
5102 const SDL_Rect * rects,
5103 int count);
5104
5105extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
5106 SDL_Texture * texture,
5107 const SDL_Rect * srcrect,
5108 const SDL_Rect * dstrect);
5109
5110extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
5111 SDL_Texture * texture,
5112 const SDL_Rect * srcrect,
5113 const SDL_Rect * dstrect,
5114 const double angle,
5115 const SDL_Point *center,
5116 const SDL_RendererFlip flip);
5117
5118extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
5119 const SDL_Rect * rect,
5120 Uint32 format,
5121 void *pixels, int pitch);
5122
5123extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
5124
5125extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
5126
5127extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
5128
5129extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
5130
5131extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
5132
5133#ifdef __cplusplus
5134}
5135#endif
5136#undef _begin_code_h
5137
5138#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
5139#ifdef __BORLANDC__
5140#pragma nopackwarning
5141#endif
5142#pragma pack(pop)
5143#endif
5144
5145#endif
5146#ifndef _SDL_system_h
5147#define _SDL_system_h
5148
5149#ifdef _begin_code_h
5150#error Nested inclusion of begin_code.h
5151#endif
5152#define _begin_code_h
5153
5154#ifndef SDL_DEPRECATED
5155# if (__GNUC__ >= 4)
5156# define SDL_DEPRECATED __attribute__((deprecated))
5157# else
5158# define SDL_DEPRECATED
5159# endif
5160#endif
5161
5162#ifndef DECLSPEC
5163# if defined(__WIN32__) || defined(__WINRT__)
5164# ifdef __BORLANDC__
5165# ifdef BUILD_SDL
5166# define DECLSPEC
5167# else
5168# define DECLSPEC __declspec(dllimport)
5169# endif
5170# else
5171# define DECLSPEC __declspec(dllexport)
5172# endif
5173# else
5174# if defined(__GNUC__) && __GNUC__ >= 4
5175# define DECLSPEC __attribute__ ((visibility("default")))
5176# elif defined(__GNUC__) && __GNUC__ >= 2
5177# define DECLSPEC __declspec(dllexport)
5178# else
5179# define DECLSPEC
5180# endif
5181# endif
5182#endif
5183
5184#ifndef SDLCALL
5185#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
5186#define SDLCALL __cdecl
5187#else
5188#define SDLCALL
5189#endif
5190#endif
5191
5192#ifdef __SYMBIAN32__
5193#undef DECLSPEC
5194#define DECLSPEC
5195#endif
5196
5197#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
5198#ifdef _MSC_VER
5199#pragma warning(disable: 4103)
5200#endif
5201#ifdef __BORLANDC__
5202#pragma nopackwarning
5203#endif
5204#ifdef _M_X64
5205
5206#pragma pack(push,8)
5207#else
5208#pragma pack(push,4)
5209#endif
5210#endif
5211
5212#ifndef SDL_INLINE
5213#if defined(__GNUC__)
5214#define SDL_INLINE __inline__
5215#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
5216 defined(__DMC__) || defined(__SC__) || \
5217 defined(__WATCOMC__) || defined(__LCC__) || \
5218 defined(__DECC)
5219#define SDL_INLINE __inline
5220#ifndef __inline__
5221#define __inline__ __inline
5222#endif
5223#else
5224#define SDL_INLINE inline
5225#ifndef __inline__
5226#define __inline__ inline
5227#endif
5228#endif
5229#endif
5230
5231#ifndef SDL_FORCE_INLINE
5232#if defined(_MSC_VER)
5233#define SDL_FORCE_INLINE __forceinline
5234#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
5235#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
5236#else
5237#define SDL_FORCE_INLINE static SDL_INLINE
5238#endif
5239#endif
5240
5241#if !defined(__MACH__)
5242#ifndef NULL
5243#ifdef __cplusplus
5244#define NULL 0
5245#else
5246#define NULL ((void *)0)
5247#endif
5248#endif
5249#endif
5250
5251#ifdef __cplusplus
5252extern "C" {
5253#endif
5254
5255#ifdef __WIN32__
5256
5257extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
5258
5259typedef struct IDirect3DDevice9 IDirect3DDevice9;
5260extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer);
5261
5262extern DECLSPEC void SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
5263
5264#endif
5265
5266#if defined(__IPHONEOS__) && __IPHONEOS__
5267
5268extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
5269extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
5270
5271#endif
5272
5273#if defined(__ANDROID__) && __ANDROID__
5274
5275extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv();
5276
5277extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity();
5278
5279#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
5280#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
5281
5282extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath();
5283
5284extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState();
5285
5286extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
5287
5288#endif
5289
5290#if defined(__WINRT__) && __WINRT__
5291
5292typedef enum
5293{
5294
5295 SDL_WINRT_PATH_INSTALLED_LOCATION,
5296
5297 SDL_WINRT_PATH_LOCAL_FOLDER,
5298
5299 SDL_WINRT_PATH_ROAMING_FOLDER,
5300
5301 SDL_WINRT_PATH_TEMP_FOLDER
5302} SDL_WinRT_Path;
5303
5304extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
5305
5306extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
5307
5308#endif
5309
5310#ifdef __cplusplus
5311}
5312#endif
5313#undef _begin_code_h
5314
5315#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
5316#ifdef __BORLANDC__
5317#pragma nopackwarning
5318#endif
5319#pragma pack(pop)
5320#endif
5321
5322#endif
5323#ifndef _SDL_timer_h
5324#define _SDL_timer_h
5325
5326#ifdef _begin_code_h
5327#error Nested inclusion of begin_code.h
5328#endif
5329#define _begin_code_h
5330
5331#ifndef SDL_DEPRECATED
5332# if (__GNUC__ >= 4)
5333# define SDL_DEPRECATED __attribute__((deprecated))
5334# else
5335# define SDL_DEPRECATED
5336# endif
5337#endif
5338
5339#ifndef DECLSPEC
5340# if defined(__WIN32__) || defined(__WINRT__)
5341# ifdef __BORLANDC__
5342# ifdef BUILD_SDL
5343# define DECLSPEC
5344# else
5345# define DECLSPEC __declspec(dllimport)
5346# endif
5347# else
5348# define DECLSPEC __declspec(dllexport)
5349# endif
5350# else
5351# if defined(__GNUC__) && __GNUC__ >= 4
5352# define DECLSPEC __attribute__ ((visibility("default")))
5353# elif defined(__GNUC__) && __GNUC__ >= 2
5354# define DECLSPEC __declspec(dllexport)
5355# else
5356# define DECLSPEC
5357# endif
5358# endif
5359#endif
5360
5361#ifndef SDLCALL
5362#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
5363#define SDLCALL __cdecl
5364#else
5365#define SDLCALL
5366#endif
5367#endif
5368
5369#ifdef __SYMBIAN32__
5370#undef DECLSPEC
5371#define DECLSPEC
5372#endif
5373
5374#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
5375#ifdef _MSC_VER
5376#pragma warning(disable: 4103)
5377#endif
5378#ifdef __BORLANDC__
5379#pragma nopackwarning
5380#endif
5381#ifdef _M_X64
5382
5383#pragma pack(push,8)
5384#else
5385#pragma pack(push,4)
5386#endif
5387#endif
5388
5389#ifndef SDL_INLINE
5390#if defined(__GNUC__)
5391#define SDL_INLINE __inline__
5392#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
5393 defined(__DMC__) || defined(__SC__) || \
5394 defined(__WATCOMC__) || defined(__LCC__) || \
5395 defined(__DECC)
5396#define SDL_INLINE __inline
5397#ifndef __inline__
5398#define __inline__ __inline
5399#endif
5400#else
5401#define SDL_INLINE inline
5402#ifndef __inline__
5403#define __inline__ inline
5404#endif
5405#endif
5406#endif
5407
5408#ifndef SDL_FORCE_INLINE
5409#if defined(_MSC_VER)
5410#define SDL_FORCE_INLINE __forceinline
5411#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
5412#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
5413#else
5414#define SDL_FORCE_INLINE static SDL_INLINE
5415#endif
5416#endif
5417
5418#if !defined(__MACH__)
5419#ifndef NULL
5420#ifdef __cplusplus
5421#define NULL 0
5422#else
5423#define NULL ((void *)0)
5424#endif
5425#endif
5426#endif
5427
5428#ifdef __cplusplus
5429extern "C" {
5430#endif
5431
5432extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
5433
5434#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
5435
5436extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void);
5437
5438extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
5439
5440extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
5441
5442typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
5443
5444typedef int SDL_TimerID;
5445
5446extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
5447 SDL_TimerCallback callback,
5448 void *param);
5449
5450extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);
5451
5452#ifdef __cplusplus
5453}
5454#endif
5455#undef _begin_code_h
5456
5457#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
5458#ifdef __BORLANDC__
5459#pragma nopackwarning
5460#endif
5461#pragma pack(pop)
5462#endif
5463
5464#endif
5465#ifndef _SDL_version_h
5466#define _SDL_version_h
5467
5468#ifdef _begin_code_h
5469#error Nested inclusion of begin_code.h
5470#endif
5471#define _begin_code_h
5472
5473#ifndef SDL_DEPRECATED
5474# if (__GNUC__ >= 4)
5475# define SDL_DEPRECATED __attribute__((deprecated))
5476# else
5477# define SDL_DEPRECATED
5478# endif
5479#endif
5480
5481#ifndef DECLSPEC
5482# if defined(__WIN32__) || defined(__WINRT__)
5483# ifdef __BORLANDC__
5484# ifdef BUILD_SDL
5485# define DECLSPEC
5486# else
5487# define DECLSPEC __declspec(dllimport)
5488# endif
5489# else
5490# define DECLSPEC __declspec(dllexport)
5491# endif
5492# else
5493# if defined(__GNUC__) && __GNUC__ >= 4
5494# define DECLSPEC __attribute__ ((visibility("default")))
5495# elif defined(__GNUC__) && __GNUC__ >= 2
5496# define DECLSPEC __declspec(dllexport)
5497# else
5498# define DECLSPEC
5499# endif
5500# endif
5501#endif
5502
5503#ifndef SDLCALL
5504#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
5505#define SDLCALL __cdecl
5506#else
5507#define SDLCALL
5508#endif
5509#endif
5510
5511#ifdef __SYMBIAN32__
5512#undef DECLSPEC
5513#define DECLSPEC
5514#endif
5515
5516#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
5517#ifdef _MSC_VER
5518#pragma warning(disable: 4103)
5519#endif
5520#ifdef __BORLANDC__
5521#pragma nopackwarning
5522#endif
5523#ifdef _M_X64
5524
5525#pragma pack(push,8)
5526#else
5527#pragma pack(push,4)
5528#endif
5529#endif
5530
5531#ifndef SDL_INLINE
5532#if defined(__GNUC__)
5533#define SDL_INLINE __inline__
5534#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
5535 defined(__DMC__) || defined(__SC__) || \
5536 defined(__WATCOMC__) || defined(__LCC__) || \
5537 defined(__DECC)
5538#define SDL_INLINE __inline
5539#ifndef __inline__
5540#define __inline__ __inline
5541#endif
5542#else
5543#define SDL_INLINE inline
5544#ifndef __inline__
5545#define __inline__ inline
5546#endif
5547#endif
5548#endif
5549
5550#ifndef SDL_FORCE_INLINE
5551#if defined(_MSC_VER)
5552#define SDL_FORCE_INLINE __forceinline
5553#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
5554#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
5555#else
5556#define SDL_FORCE_INLINE static SDL_INLINE
5557#endif
5558#endif
5559
5560#if !defined(__MACH__)
5561#ifndef NULL
5562#ifdef __cplusplus
5563#define NULL 0
5564#else
5565#define NULL ((void *)0)
5566#endif
5567#endif
5568#endif
5569
5570#ifdef __cplusplus
5571extern "C" {
5572#endif
5573
5574typedef struct SDL_version
5575{
5576 Uint8 major;
5577 Uint8 minor;
5578 Uint8 patch;
5579} SDL_version;
5580
5581#define SDL_MAJOR_VERSION 2
5582#define SDL_MINOR_VERSION 0
5583#define SDL_PATCHLEVEL 3
5584
5585#define SDL_VERSION(x) \
5586{ \
5587 (x)->major = SDL_MAJOR_VERSION; \
5588 (x)->minor = SDL_MINOR_VERSION; \
5589 (x)->patch = SDL_PATCHLEVEL; \
5590}
5591
5592#define SDL_VERSIONNUM(X, Y, Z) \
5593 ((X)*1000 + (Y)*100 + (Z))
5594
5595#define SDL_COMPILEDVERSION \
5596 SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
5597
5598#define SDL_VERSION_ATLEAST(X, Y, Z) \
5599 (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
5600
5601extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
5602
5603extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
5604
5605extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
5606
5607#ifdef __cplusplus
5608}
5609#endif
5610#undef _begin_code_h
5611
5612#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
5613#ifdef __BORLANDC__
5614#pragma nopackwarning
5615#endif
5616#pragma pack(pop)
5617#endif
5618
5619#endif
5620
5621#ifdef _begin_code_h
5622#error Nested inclusion of begin_code.h
5623#endif
5624#define _begin_code_h
5625
5626#ifndef SDL_DEPRECATED
5627# if (__GNUC__ >= 4)
5628# define SDL_DEPRECATED __attribute__((deprecated))
5629# else
5630# define SDL_DEPRECATED
5631# endif
5632#endif
5633
5634#ifndef DECLSPEC
5635# if defined(__WIN32__) || defined(__WINRT__)
5636# ifdef __BORLANDC__
5637# ifdef BUILD_SDL
5638# define DECLSPEC
5639# else
5640# define DECLSPEC __declspec(dllimport)
5641# endif
5642# else
5643# define DECLSPEC __declspec(dllexport)
5644# endif
5645# else
5646# if defined(__GNUC__) && __GNUC__ >= 4
5647# define DECLSPEC __attribute__ ((visibility("default")))
5648# elif defined(__GNUC__) && __GNUC__ >= 2
5649# define DECLSPEC __declspec(dllexport)
5650# else
5651# define DECLSPEC
5652# endif
5653# endif
5654#endif
5655
5656#ifndef SDLCALL
5657#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
5658#define SDLCALL __cdecl
5659#else
5660#define SDLCALL
5661#endif
5662#endif
5663
5664#ifdef __SYMBIAN32__
5665#undef DECLSPEC
5666#define DECLSPEC
5667#endif
5668
5669#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
5670#ifdef _MSC_VER
5671#pragma warning(disable: 4103)
5672#endif
5673#ifdef __BORLANDC__
5674#pragma nopackwarning
5675#endif
5676#ifdef _M_X64
5677
5678#pragma pack(push,8)
5679#else
5680#pragma pack(push,4)
5681#endif
5682#endif
5683
5684#ifndef SDL_INLINE
5685#if defined(__GNUC__)
5686#define SDL_INLINE __inline__
5687#elif defined(_MSC_VER) || defined(__BORLANDC__) || \
5688 defined(__DMC__) || defined(__SC__) || \
5689 defined(__WATCOMC__) || defined(__LCC__) || \
5690 defined(__DECC)
5691#define SDL_INLINE __inline
5692#ifndef __inline__
5693#define __inline__ __inline
5694#endif
5695#else
5696#define SDL_INLINE inline
5697#ifndef __inline__
5698#define __inline__ inline
5699#endif
5700#endif
5701#endif
5702
5703#ifndef SDL_FORCE_INLINE
5704#if defined(_MSC_VER)
5705#define SDL_FORCE_INLINE __forceinline
5706#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
5707#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
5708#else
5709#define SDL_FORCE_INLINE static SDL_INLINE
5710#endif
5711#endif
5712
5713#if !defined(__MACH__)
5714#ifndef NULL
5715#ifdef __cplusplus
5716#define NULL 0
5717#else
5718#define NULL ((void *)0)
5719#endif
5720#endif
5721#endif
5722
5723#ifdef __cplusplus
5724extern "C" {
5725#endif
5726
5727#define SDL_INIT_TIMER 0x00000001
5728#define SDL_INIT_AUDIO 0x00000010
5729#define SDL_INIT_VIDEO 0x00000020
5730#define SDL_INIT_JOYSTICK 0x00000200
5731#define SDL_INIT_HAPTIC 0x00001000
5732#define SDL_INIT_GAMECONTROLLER 0x00002000
5733#define SDL_INIT_EVENTS 0x00004000
5734#define SDL_INIT_NOPARACHUTE 0x00100000
5735#define SDL_INIT_EVERYTHING ( \
5736 SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
5737 SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
5738 )
5739
5740extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
5741
5742extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
5743
5744extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
5745
5746extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
5747
5748extern DECLSPEC void SDLCALL SDL_Quit(void);
5749
5750#ifdef __cplusplus
5751}
5752#endif
5753#undef _begin_code_h
5754
5755#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
5756#ifdef __BORLANDC__
5757#pragma nopackwarning
5758#endif
5759#pragma pack(pop)
5760#endif
5761
5762#endif
5763#ifndef _SDL_internal_h
5764#define _SDL_internal_h
5765
5766#endif
5767#ifndef _SDL_internal_h
5768#define _SDL_internal_h
5769
5770#endif
5771
5772#ifndef _SDL_error_c_h
5773#define _SDL_error_c_h
5774
5775#define ERR_MAX_STRLEN 128
5776#define ERR_MAX_ARGS 5
5777
5778typedef struct SDL_error
5779{
5780
5781 int error;
5782
5783 char key[ERR_MAX_STRLEN];
5784
5785 int argc;
5786 union
5787 {
5788 void *value_ptr;
5789#if 0
5790 unsigned char value_c;
5791#endif
5792 int value_i;
5793 double value_f;
5794 char buf[ERR_MAX_STRLEN];
5795 } args[ERR_MAX_ARGS];
5796} SDL_error;
5797
5798extern SDL_error *SDL_GetErrBuf(void);
5799
5800#endif
5801extern SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format);
5802extern SDL_AudioFormat SDL_NextAudioFormat(void);
5803
5804extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
5805
5806extern int SDLCALL SDL_RunAudio(void *audiop);
5807
5808typedef struct
5809{
5810 SDL_AudioFormat src_fmt;
5811 SDL_AudioFormat dst_fmt;
5812 SDL_AudioFilter filter;
5813} SDL_AudioTypeFilters;
5814extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
5815
5816typedef struct
5817{
5818 SDL_AudioFormat fmt;
5819 int channels;
5820 int upsample;
5821 int multiple;
5822 SDL_AudioFilter filter;
5823} SDL_AudioRateFilters;
5824extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
5825#ifndef _SDL_sysaudio_h
5826#define _SDL_sysaudio_h
5827
5828typedef struct SDL_AudioDevice SDL_AudioDevice;
5829#define _THIS SDL_AudioDevice *_this
5830
5831typedef void (*SDL_AddAudioDevice)(const char *name);
5832
5833typedef struct SDL_AudioDriverImpl
5834{
5835 void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
5836 int (*OpenDevice) (_THIS, const char *devname, int iscapture);
5837 void (*ThreadInit) (_THIS);
5838 void (*WaitDevice) (_THIS);
5839 void (*PlayDevice) (_THIS);
5840 Uint8 *(*GetDeviceBuf) (_THIS);
5841 void (*WaitDone) (_THIS);
5842 void (*CloseDevice) (_THIS);
5843 void (*LockDevice) (_THIS);
5844 void (*UnlockDevice) (_THIS);
5845 void (*Deinitialize) (void);
5846
5847 int ProvidesOwnCallbackThread;
5848 int SkipMixerLock;
5849 int HasCaptureSupport;
5850 int OnlyHasDefaultOutputDevice;
5851 int OnlyHasDefaultInputDevice;
5852} SDL_AudioDriverImpl;
5853
5854typedef struct SDL_AudioDriver
5855{
5856
5857 const char *name;
5858
5859 const char *desc;
5860
5861 SDL_AudioDriverImpl impl;
5862
5863 char **outputDevices;
5864 int outputDeviceCount;
5865
5866 char **inputDevices;
5867 int inputDeviceCount;
5868} SDL_AudioDriver;
5869
5870typedef struct
5871{
5872 Uint8 *buffer;
5873 int max_len;
5874 int read_pos, write_pos;
5875} SDL_AudioStreamer;
5876
5877struct SDL_AudioDevice
5878{
5879
5880 SDL_AudioSpec spec;
5881
5882 SDL_AudioCVT convert;
5883
5884 int use_streamer;
5885 SDL_AudioStreamer streamer;
5886
5887 int iscapture;
5888 int enabled;
5889 int paused;
5890 int opened;
5891
5892 Uint8 *fake_stream;
5893
5894 SDL_mutex *mixer_lock;
5895
5896 SDL_Thread *thread;
5897 SDL_threadID threadid;
5898
5899 struct SDL_PrivateAudioData *hidden;
5900};
5901#undef _THIS
5902
5903typedef struct AudioBootStrap
5904{
5905 const char *name;
5906 const char *desc;
5907 int (*init) (SDL_AudioDriverImpl * impl);
5908 int demand_only;
5909} AudioBootStrap;
5910
5911#endif
5912#ifndef _SDL_thread_c_h
5913#define _SDL_thread_c_h
5914
5915#if SDL_THREADS_DISABLED
5916typedef int SYS_ThreadHandle;
5917#elif SDL_THREAD_BEOS
5918#include "beos/SDL_systhread_c.h"
5919#elif SDL_THREAD_EPOC
5920#include "epoc/SDL_systhread_c.h"
5921#elif SDL_THREAD_PTHREAD
5922#include <pthread.h>
5923
5924typedef pthread_t SYS_ThreadHandle;
5925#elif SDL_THREAD_WINDOWS
5926#ifndef _SDL_systhread_c_h
5927#define _SDL_systhread_c_h
5928
5929#ifndef _INCLUDED_WINDOWS_H
5930#define _INCLUDED_WINDOWS_H
5931
5932#if defined(__WIN32__)
5933#define WIN32_LEAN_AND_MEAN
5934#define STRICT
5935#ifndef UNICODE
5936#define UNICODE 1
5937#endif
5938#undef _WIN32_WINNT
5939#define _WIN32_WINNT 0x501
5940#endif
5941
5942#include <windows.h>
5943
5944#if UNICODE
5945#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
5946#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1)
5947#else
5948
5949#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
5950#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
5951#endif
5952
5953extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
5954
5955extern int WIN_SetError(const char *prefix);
5956
5957extern HRESULT WIN_CoInitialize(void);
5958extern void WIN_CoUninitialize(void);
5959
5960#endif
5961
5962typedef HANDLE SYS_ThreadHandle;
5963
5964#endif
5965#elif SDL_THREAD_PSP
5966#include "psp/SDL_systhread_c.h"
5967#else
5968#error Need thread implementation for this platform
5969typedef int SYS_ThreadHandle;
5970#endif
5971
5972struct SDL_Thread
5973{
5974 SDL_threadID threadid;
5975 SYS_ThreadHandle handle;
5976 int status;
5977 SDL_error errbuf;
5978 char *name;
5979 void *data;
5980};
5981
5982extern void SDL_RunThread(void *data);
5983
5984#endif
5985#ifndef _SDL_systhread_h
5986#define _SDL_systhread_h
5987
5988#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
5989extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
5990 pfnSDL_CurrentBeginThread pfnBeginThread,
5991 pfnSDL_CurrentEndThread pfnEndThread);
5992#else
5993extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args);
5994#endif
5995
5996extern void SDL_SYS_SetupThread(const char *name);
5997
5998extern int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority);
5999
6000extern void SDL_SYS_WaitThread(SDL_Thread * thread);
6001
6002#endif
6003#define ROUND_RESOLUTION(X) \
6004 (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
6005
6006extern void SDL_TicksInit(void);
6007extern void SDL_TicksQuit(void);
6008extern int SDL_TimerInit(void);
6009extern void SDL_TimerQuit(void);
6010#ifndef _SDL_udev_h
6011#define _SDL_udev_h
6012
6013#if HAVE_LIBUDEV_H
6014
6015#ifndef SDL_USE_LIBUDEV
6016#define SDL_USE_LIBUDEV 1
6017#endif
6018
6019#include <libudev.h>
6020#include <sys/time.h>
6021#include <sys/types.h>
6022
6023typedef enum
6024{
6025 SDL_UDEV_DEVICEADDED = 0x0001,
6026 SDL_UDEV_DEVICEREMOVED
6027} SDL_UDEV_deviceevent;
6028
6029typedef enum
6030{
6031 SDL_UDEV_DEVICE_MOUSE = 0x0001,
6032 SDL_UDEV_DEVICE_KEYBOARD = 0x0002,
6033 SDL_UDEV_DEVICE_JOYSTICK = 0x0004,
6034 SDL_UDEV_DEVICE_SOUND = 0x0008
6035} SDL_UDEV_deviceclass;
6036
6037typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath);
6038
6039typedef struct SDL_UDEV_CallbackList {
6040 SDL_UDEV_Callback callback;
6041 struct SDL_UDEV_CallbackList *next;
6042} SDL_UDEV_CallbackList;
6043
6044typedef struct SDL_UDEV_PrivateData
6045{
6046 const char *udev_library;
6047 void *udev_handle;
6048 struct udev *udev;
6049 struct udev_monitor *udev_mon;
6050 int ref_count;
6051 SDL_UDEV_CallbackList *first, *last;
6052
6053 const char *(*udev_device_get_action)(struct udev_device *);
6054 const char *(*udev_device_get_devnode)(struct udev_device *);
6055 const char *(*udev_device_get_subsystem)(struct udev_device *);
6056 const char *(*udev_device_get_property_value)(struct udev_device *, const char *);
6057 struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);
6058 void (*udev_device_unref)(struct udev_device *);
6059 int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);
6060 int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *);
6061 struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *);
6062 struct udev_enumerate *(*udev_enumerate_new)(struct udev *);
6063 int (*udev_enumerate_scan_devices)(struct udev_enumerate *);
6064 void (*udev_enumerate_unref)(struct udev_enumerate *);
6065 const char *(*udev_list_entry_get_name)(struct udev_list_entry *);
6066 struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *);
6067 int (*udev_monitor_enable_receiving)(struct udev_monitor *);
6068 int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *);
6069 int (*udev_monitor_get_fd)(struct udev_monitor *);
6070 struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *);
6071 struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *);
6072 void (*udev_monitor_unref)(struct udev_monitor *);
6073 struct udev *(*udev_new)(void);
6074 void (*udev_unref)(struct udev *);
6075 struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum);
6076 dev_t (*udev_device_get_devnum) (struct udev_device *udev_device);
6077} SDL_UDEV_PrivateData;
6078
6079extern int SDL_UDEV_Init(void);
6080extern void SDL_UDEV_Quit(void);
6081extern void SDL_UDEV_UnloadLibrary(void);
6082extern int SDL_UDEV_LoadLibrary(void);
6083extern void SDL_UDEV_Poll(void);
6084extern void SDL_UDEV_Scan(void);
6085extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
6086extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
6087
6088#endif
6089
6090#endif
6091
6092#ifdef SDL_USE_LIBUDEV
6093
6094static char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
6095
6096#undef _THIS
6097#define _THIS SDL_UDEV_PrivateData *_this
6098static _THIS = NULL;
6099
6100static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr);
6101static int SDL_UDEV_load_syms(void);
6102static SDL_bool SDL_UDEV_hotplug_update_available(void);
6103static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev);
6104
6105static SDL_bool
6106SDL_UDEV_load_sym(const char *fn, void **addr)
6107{
6108 *addr = SDL_LoadFunction(_this->udev_handle, fn);
6109 if (*addr == NULL) {
6110
6111 return SDL_FALSE;
6112 }
6113
6114 return SDL_TRUE;
6115}
6116
6117static int
6118SDL_UDEV_load_syms(void)
6119{
6120
6121 #define SDL_UDEV_SYM(x) \
6122 if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->x)) return -1
6123
6124 SDL_UDEV_SYM(udev_device_get_action);
6125 SDL_UDEV_SYM(udev_device_get_devnode);
6126 SDL_UDEV_SYM(udev_device_get_subsystem);
6127 SDL_UDEV_SYM(udev_device_get_property_value);
6128 SDL_UDEV_SYM(udev_device_new_from_syspath);
6129 SDL_UDEV_SYM(udev_device_unref);
6130 SDL_UDEV_SYM(udev_enumerate_add_match_property);
6131 SDL_UDEV_SYM(udev_enumerate_add_match_subsystem);
6132 SDL_UDEV_SYM(udev_enumerate_get_list_entry);
6133 SDL_UDEV_SYM(udev_enumerate_new);
6134 SDL_UDEV_SYM(udev_enumerate_scan_devices);
6135 SDL_UDEV_SYM(udev_enumerate_unref);
6136 SDL_UDEV_SYM(udev_list_entry_get_name);
6137 SDL_UDEV_SYM(udev_list_entry_get_next);
6138 SDL_UDEV_SYM(udev_monitor_enable_receiving);
6139 SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype);
6140 SDL_UDEV_SYM(udev_monitor_get_fd);
6141 SDL_UDEV_SYM(udev_monitor_new_from_netlink);
6142 SDL_UDEV_SYM(udev_monitor_receive_device);
6143 SDL_UDEV_SYM(udev_monitor_unref);
6144 SDL_UDEV_SYM(udev_new);
6145 SDL_UDEV_SYM(udev_unref);
6146 SDL_UDEV_SYM(udev_device_new_from_devnum);
6147 SDL_UDEV_SYM(udev_device_get_devnum);
6148 #undef SDL_UDEV_SYM
6149
6150 return 0;
6151}
6152
6153static SDL_bool
6154SDL_UDEV_hotplug_update_available(void)
6155{
6156 if (_this->udev_mon != NULL) {
6157 const int fd = _this->udev_monitor_get_fd(_this->udev_mon);
6158 fd_set fds;
6159 struct timeval tv;
6160
6161 FD_ZERO(&fds);
6162 FD_SET(fd, &fds);
6163 tv.tv_sec = 0;
6164 tv.tv_usec = 0;
6165 if ((select(fd+1, &fds, NULL, NULL, &tv) > 0) && (FD_ISSET(fd, &fds))) {
6166 return SDL_TRUE;
6167 }
6168 }
6169 return SDL_FALSE;
6170}
6171
6172int
6173SDL_UDEV_Init(void)
6174{
6175 int retval = 0;
6176
6177 if (_this == NULL) {
6178 _this = (SDL_UDEV_PrivateData *) SDL_calloc(1, sizeof(*_this));
6179 if(_this == NULL) {
6180 return SDL_OutOfMemory();
6181 }
6182
6183 retval = SDL_UDEV_LoadLibrary();
6184 if (retval < 0) {
6185 SDL_UDEV_Quit();
6186 return retval;
6187 }
6188
6189 _this->udev = _this->udev_new();
6190 if (_this->udev == NULL) {
6191 SDL_UDEV_Quit();
6192 return SDL_SetError("udev_new() failed");
6193 }
6194
6195 _this->udev_mon = _this->udev_monitor_new_from_netlink(_this->udev, "udev");
6196 if (_this->udev_mon == NULL) {
6197 SDL_UDEV_Quit();
6198 return SDL_SetError("udev_monitor_new_from_netlink() failed");
6199 }
6200
6201 _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL);
6202 _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL);
6203 _this->udev_monitor_enable_receiving(_this->udev_mon);
6204
6205 SDL_UDEV_Scan();
6206
6207 }
6208
6209 _this->ref_count += 1;
6210
6211 return retval;
6212}
6213
6214void
6215SDL_UDEV_Quit(void)
6216{
6217 SDL_UDEV_CallbackList *item;
6218
6219 if (_this == NULL) {
6220 return;
6221 }
6222
6223 _this->ref_count -= 1;
6224
6225 if (_this->ref_count < 1) {
6226
6227 if (_this->udev_mon != NULL) {
6228 _this->udev_monitor_unref(_this->udev_mon);
6229 _this->udev_mon = NULL;
6230 }
6231 if (_this->udev != NULL) {
6232 _this->udev_unref(_this->udev);
6233 _this->udev = NULL;
6234 }
6235
6236 while (_this->first != NULL) {
6237 item = _this->first;
6238 _this->first = _this->first->next;
6239 SDL_free(item);
6240 }
6241
6242 SDL_UDEV_UnloadLibrary();
6243 SDL_free(_this);
6244 _this = NULL;
6245 }
6246}
6247
6248void
6249SDL_UDEV_Scan(void)
6250{
6251 struct udev_enumerate *enumerate = NULL;
6252 struct udev_list_entry *devs = NULL;
6253 struct udev_list_entry *item = NULL;
6254
6255 if (_this == NULL) {
6256 return;
6257 }
6258
6259 enumerate = _this->udev_enumerate_new(_this->udev);
6260 if (enumerate == NULL) {
6261 SDL_UDEV_Quit();
6262 SDL_SetError("udev_monitor_new_from_netlink() failed");
6263 return;
6264 }
6265
6266 _this->udev_enumerate_add_match_subsystem(enumerate, "input");
6267 _this->udev_enumerate_add_match_subsystem(enumerate, "sound");
6268
6269 _this->udev_enumerate_scan_devices(enumerate);
6270 devs = _this->udev_enumerate_get_list_entry(enumerate);
6271 for (item = devs; item; item = _this->udev_list_entry_get_next(item)) {
6272 const char *path = _this->udev_list_entry_get_name(item);
6273 struct udev_device *dev = _this->udev_device_new_from_syspath(_this->udev, path);
6274 if (dev != NULL) {
6275 device_event(SDL_UDEV_DEVICEADDED, dev);
6276 _this->udev_device_unref(dev);
6277 }
6278 }
6279
6280 _this->udev_enumerate_unref(enumerate);
6281}
6282
6283void
6284SDL_UDEV_UnloadLibrary(void)
6285{
6286 if (_this == NULL) {
6287 return;
6288 }
6289
6290 if (_this->udev_handle != NULL) {
6291 SDL_UnloadObject(_this->udev_handle);
6292 _this->udev_handle = NULL;
6293 }
6294}
6295
6296int
6297SDL_UDEV_LoadLibrary(void)
6298{
6299 int retval = 0, i;
6300
6301 if (_this == NULL) {
6302 return SDL_SetError("UDEV not initialized");
6303 }
6304
6305 if (_this->udev_handle == NULL) {
6306 for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
6307 _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
6308 if (_this->udev_handle != NULL) {
6309 retval = SDL_UDEV_load_syms();
6310 if (retval < 0) {
6311 SDL_UDEV_UnloadLibrary();
6312 }
6313 else {
6314 break;
6315 }
6316 }
6317 }
6318
6319 if (_this->udev_handle == NULL) {
6320 retval = -1;
6321
6322 }
6323 }
6324
6325 return retval;
6326}
6327
6328static void
6329device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
6330{
6331 const char *subsystem;
6332 const char *val = NULL;
6333 int devclass = 0;
6334 const char *path;
6335 SDL_UDEV_CallbackList *item;
6336
6337 path = _this->udev_device_get_devnode(dev);
6338 if (path == NULL) {
6339 return;
6340 }
6341
6342 subsystem = _this->udev_device_get_subsystem(dev);
6343 if (SDL_strcmp(subsystem, "sound") == 0) {
6344 devclass = SDL_UDEV_DEVICE_SOUND;
6345 } else if (SDL_strcmp(subsystem, "input") == 0) {
6346 val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
6347 if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
6348 devclass |= SDL_UDEV_DEVICE_JOYSTICK;
6349 }
6350
6351 val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
6352 if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
6353 devclass |= SDL_UDEV_DEVICE_MOUSE;
6354 }
6355
6356 val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
6357 if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
6358 devclass |= SDL_UDEV_DEVICE_KEYBOARD;
6359 }
6360
6361 if (devclass == 0) {
6362 return;
6363 }
6364 } else {
6365 return;
6366 }
6367
6368 for (item = _this->first; item != NULL; item = item->next) {
6369 item->callback(type, devclass, path);
6370 }
6371}
6372
6373void
6374SDL_UDEV_Poll(void)
6375{
6376 struct udev_device *dev = NULL;
6377 const char *action = NULL;
6378
6379 if (_this == NULL) {
6380 return;
6381 }
6382
6383 while (SDL_UDEV_hotplug_update_available()) {
6384 dev = _this->udev_monitor_receive_device(_this->udev_mon);
6385 if (dev == NULL) {
6386 break;
6387 }
6388 action = _this->udev_device_get_action(dev);
6389
6390 if (SDL_strcmp(action, "add") == 0) {
6391 device_event(SDL_UDEV_DEVICEADDED, dev);
6392 } else if (SDL_strcmp(action, "remove") == 0) {
6393 device_event(SDL_UDEV_DEVICEREMOVED, dev);
6394 }
6395
6396 _this->udev_device_unref(dev);
6397 }
6398}
6399
6400int
6401SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
6402{
6403 SDL_UDEV_CallbackList *item;
6404 item = (SDL_UDEV_CallbackList *) SDL_calloc(1, sizeof (SDL_UDEV_CallbackList));
6405 if (item == NULL) {
6406 return SDL_OutOfMemory();
6407 }
6408
6409 item->callback = cb;
6410
6411 if (_this->last == NULL) {
6412 _this->first = _this->last = item;
6413 } else {
6414 _this->last->next = item;
6415 _this->last = item;
6416 }
6417
6418 return 1;
6419}
6420
6421void
6422SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
6423{
6424 SDL_UDEV_CallbackList *item;
6425 SDL_UDEV_CallbackList *prev = NULL;
6426
6427 for (item = _this->first; item != NULL; item = item->next) {
6428
6429 if (item->callback == cb) {
6430 if (prev != NULL) {
6431 prev->next = item->next;
6432 } else {
6433 SDL_assert(_this->first == item);
6434 _this->first = item->next;
6435 }
6436 if (item == _this->last) {
6437 _this->last = prev;
6438 }
6439 SDL_free(item);
6440 return;
6441 }
6442 prev = item;
6443 }
6444
6445}
6446
6447#endif
6448#ifdef SDL_LOADSO_DLOPEN
6449
6450#include <stdio.h>
6451#include <dlfcn.h>
6452
6453void *
6454SDL_LoadObject(const char *sofile)
6455{
6456 void *handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
6457 const char *loaderror = (char *) dlerror();
6458 if (handle == NULL) {
6459 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
6460 }
6461 return (handle);
6462}
6463
6464void *
6465SDL_LoadFunction(void *handle, const char *name)
6466{
6467 void *symbol = dlsym(handle, name);
6468 if (symbol == NULL) {
6469
6470 size_t len = 1 + SDL_strlen(name) + 1;
6471 char *_name = SDL_stack_alloc(char, len);
6472 _name[0] = '_';
6473 SDL_strlcpy(&_name[1], name, len);
6474 symbol = dlsym(handle, _name);
6475 SDL_stack_free(_name);
6476 if (symbol == NULL) {
6477 SDL_SetError("Failed loading %s: %s", name,
6478 (const char *) dlerror());
6479 }
6480 }
6481 return (symbol);
6482}
6483
6484void
6485SDL_UnloadObject(void *handle)
6486{
6487 if (handle != NULL) {
6488 dlclose(handle);
6489 }
6490}
6491
6492#endif
6493#if defined(SDL_LOADSO_DUMMY) || defined(SDL_LOADSO_DISABLED)
6494
6495void *
6496SDL_LoadObject(const char *sofile)
6497{
6498 const char *loaderror = "SDL_LoadObject() not implemented";
6499 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
6500 return (NULL);
6501}
6502
6503void *
6504SDL_LoadFunction(void *handle, const char *name)
6505{
6506 const char *loaderror = "SDL_LoadFunction() not implemented";
6507 SDL_SetError("Failed loading %s: %s", name, loaderror);
6508 return (NULL);
6509}
6510
6511void
6512SDL_UnloadObject(void *handle)
6513{
6514
6515}
6516
6517#endif
6518#ifdef SDL_LOADSO_WINDOWS
6519
6520void *
6521SDL_LoadObject(const char *sofile)
6522{
6523 LPTSTR tstr = WIN_UTF8ToString(sofile);
6524#ifdef __WINRT__
6525
6526 void *handle = (void *) LoadPackagedLibrary(tstr, 0);
6527#else
6528 void *handle = (void *) LoadLibrary(tstr);
6529#endif
6530 SDL_free(tstr);
6531
6532 if (handle == NULL) {
6533 char errbuf[512];
6534 SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
6535 SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf));
6536 WIN_SetError(errbuf);
6537 }
6538 return handle;
6539}
6540
6541void *
6542SDL_LoadFunction(void *handle, const char *name)
6543{
6544 void *symbol = (void *) GetProcAddress((HMODULE) handle, name);
6545 if (symbol == NULL) {
6546 char errbuf[512];
6547 SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
6548 SDL_strlcat(errbuf, name, SDL_arraysize(errbuf));
6549 WIN_SetError(errbuf);
6550 }
6551 return symbol;
6552}
6553
6554void
6555SDL_UnloadObject(void *handle)
6556{
6557 if (handle != NULL) {
6558 FreeLibrary((HMODULE) handle);
6559 }
6560}
6561
6562#endif
6563#if SDL_AUDIO_DRIVER_ALSA
6564
6565#include <sys/types.h>
6566#include <signal.h>
6567#include <errno.h>
6568#include <string.h>
6569
6570#define SDL_AllocAudioMem SDL_malloc
6571#define SDL_FreeAudioMem SDL_free
6572#ifndef _SDL_ALSA_audio_h
6573#define _SDL_ALSA_audio_h
6574
6575#include <alsa/asoundlib.h>
6576
6577#undef _THIS
6578#define _THIS SDL_AudioDevice *this
6579
6580#undef SDLAUDIOHIDDEN
6581#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataALSA*)this->hidden)
6582struct SDL_PrivateAudioDataALSA
6583{
6584
6585 snd_pcm_t *pcm_handle;
6586
6587 Uint8 *mixbuf;
6588 int mixlen;
6589};
6590
6591#endif
6592
6593#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
6594#endif
6595
6596static int (*ALSA_snd_pcm_open)
6597 (snd_pcm_t **, const char *, snd_pcm_stream_t, int);
6598static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm);
6599static snd_pcm_sframes_t(*ALSA_snd_pcm_writei)
6600 (snd_pcm_t *, const void *, snd_pcm_uframes_t);
6601static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int);
6602static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *);
6603static int (*ALSA_snd_pcm_drain) (snd_pcm_t *);
6604static const char *(*ALSA_snd_strerror) (int);
6605static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void);
6606static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void);
6607static void (*ALSA_snd_pcm_hw_params_copy)
6608 (snd_pcm_hw_params_t *, const snd_pcm_hw_params_t *);
6609static int (*ALSA_snd_pcm_hw_params_any) (snd_pcm_t *, snd_pcm_hw_params_t *);
6610static int (*ALSA_snd_pcm_hw_params_set_access)
6611 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
6612static int (*ALSA_snd_pcm_hw_params_set_format)
6613 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
6614static int (*ALSA_snd_pcm_hw_params_set_channels)
6615 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
6616static int (*ALSA_snd_pcm_hw_params_get_channels)
6617 (const snd_pcm_hw_params_t *, unsigned int *);
6618static int (*ALSA_snd_pcm_hw_params_set_rate_near)
6619 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
6620static int (*ALSA_snd_pcm_hw_params_set_period_size_near)
6621 (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
6622static int (*ALSA_snd_pcm_hw_params_get_period_size)
6623 (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
6624static int (*ALSA_snd_pcm_hw_params_set_periods_near)
6625 (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
6626static int (*ALSA_snd_pcm_hw_params_get_periods)
6627 (const snd_pcm_hw_params_t *, unsigned int *, int *);
6628static int (*ALSA_snd_pcm_hw_params_set_buffer_size_near)
6629 (snd_pcm_t *pcm, snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
6630static int (*ALSA_snd_pcm_hw_params_get_buffer_size)
6631 (const snd_pcm_hw_params_t *, snd_pcm_uframes_t *);
6632static int (*ALSA_snd_pcm_hw_params) (snd_pcm_t *, snd_pcm_hw_params_t *);
6633static int (*ALSA_snd_pcm_sw_params_current) (snd_pcm_t *,
6634 snd_pcm_sw_params_t *);
6635static int (*ALSA_snd_pcm_sw_params_set_start_threshold)
6636 (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
6637static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *);
6638static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int);
6639static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int);
6640static int (*ALSA_snd_pcm_sw_params_set_avail_min)
6641 (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
6642
6643#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
6644#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
6645#define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof
6646
6647static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
6648static void *alsa_handle = NULL;
6649
6650static int
6651load_alsa_sym(const char *fn, void **addr)
6652{
6653 *addr = SDL_LoadFunction(alsa_handle, fn);
6654 if (*addr == NULL) {
6655
6656 return 0;
6657 }
6658
6659 return 1;
6660}
6661
6662#define SDL_ALSA_SYM(x) \
6663 if (!load_alsa_sym(#x, (void **) (char *) &ALSA_##x)) return -1
6664#else
6665#define SDL_ALSA_SYM(x) ALSA_##x = x
6666#endif
6667
6668static int
6669load_alsa_syms(void)
6670{
6671 SDL_ALSA_SYM(snd_pcm_open);
6672 SDL_ALSA_SYM(snd_pcm_close);
6673 SDL_ALSA_SYM(snd_pcm_writei);
6674 SDL_ALSA_SYM(snd_pcm_recover);
6675 SDL_ALSA_SYM(snd_pcm_prepare);
6676 SDL_ALSA_SYM(snd_pcm_drain);
6677 SDL_ALSA_SYM(snd_strerror);
6678 SDL_ALSA_SYM(snd_pcm_hw_params_sizeof);
6679 SDL_ALSA_SYM(snd_pcm_sw_params_sizeof);
6680 SDL_ALSA_SYM(snd_pcm_hw_params_copy);
6681 SDL_ALSA_SYM(snd_pcm_hw_params_any);
6682 SDL_ALSA_SYM(snd_pcm_hw_params_set_access);
6683 SDL_ALSA_SYM(snd_pcm_hw_params_set_format);
6684 SDL_ALSA_SYM(snd_pcm_hw_params_set_channels);
6685 SDL_ALSA_SYM(snd_pcm_hw_params_get_channels);
6686 SDL_ALSA_SYM(snd_pcm_hw_params_set_rate_near);
6687 SDL_ALSA_SYM(snd_pcm_hw_params_set_period_size_near);
6688 SDL_ALSA_SYM(snd_pcm_hw_params_get_period_size);
6689 SDL_ALSA_SYM(snd_pcm_hw_params_set_periods_near);
6690 SDL_ALSA_SYM(snd_pcm_hw_params_get_periods);
6691 SDL_ALSA_SYM(snd_pcm_hw_params_set_buffer_size_near);
6692 SDL_ALSA_SYM(snd_pcm_hw_params_get_buffer_size);
6693 SDL_ALSA_SYM(snd_pcm_hw_params);
6694 SDL_ALSA_SYM(snd_pcm_sw_params_current);
6695 SDL_ALSA_SYM(snd_pcm_sw_params_set_start_threshold);
6696 SDL_ALSA_SYM(snd_pcm_sw_params);
6697 SDL_ALSA_SYM(snd_pcm_nonblock);
6698 SDL_ALSA_SYM(snd_pcm_wait);
6699 SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min);
6700 return 0;
6701}
6702
6703#undef SDL_ALSA_SYM
6704
6705#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
6706
6707static void
6708UnloadALSALibrary(void)
6709{
6710 if (alsa_handle != NULL) {
6711 SDL_UnloadObject(alsa_handle);
6712 alsa_handle = NULL;
6713 }
6714}
6715
6716static int
6717LoadALSALibrary(void)
6718{
6719 int retval = 0;
6720 if (alsa_handle == NULL) {
6721 alsa_handle = SDL_LoadObject(alsa_library);
6722 if (alsa_handle == NULL) {
6723 retval = -1;
6724
6725 } else {
6726 retval = load_alsa_syms();
6727 if (retval < 0) {
6728 UnloadALSALibrary();
6729 }
6730 }
6731 }
6732 return retval;
6733}
6734
6735#else
6736
6737static void
6738UnloadALSALibrary(void)
6739{
6740}
6741
6742static int
6743LoadALSALibrary(void)
6744{
6745 load_alsa_syms();
6746 return 0;
6747}
6748
6749#endif
6750
6751static const char *
6752ALSA_get_audio_device(int channels)
6753{
6754 const char *device;
6755
6756 device = SDL_getenv("AUDIODEV");
6757 if (device == NULL) {
6758 switch (channels) {
6759 case 6:
6760 device = "plug:surround51";
6761 break;
6762 case 4:
6763 device = "plug:surround40";
6764 break;
6765 default:
6766 device = "default";
6767 break;
6768 }
6769 }
6770 return device;
6771}
6772
6773static void
6774ALSA_WaitDevice(_THIS)
6775{
6776
6777}
6778
6779#define SWIZ6(T) \
6780 T *ptr = (T *) SDLAUDIOHIDDEN->mixbuf; \
6781 Uint32 i; \
6782 for (i = 0; i < this->spec.samples; i++, ptr += 6) { \
6783 T tmp; \
6784 tmp = ptr[2]; ptr[2] = ptr[4]; ptr[4] = tmp; \
6785 tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \
6786 }
6787
6788static SDL_INLINE void
6789swizzle_alsa_channels_6_64bit(_THIS)
6790{
6791 SWIZ6(Uint64);
6792}
6793
6794static SDL_INLINE void
6795swizzle_alsa_channels_6_32bit(_THIS)
6796{
6797 SWIZ6(Uint32);
6798}
6799
6800static SDL_INLINE void
6801swizzle_alsa_channels_6_16bit(_THIS)
6802{
6803 SWIZ6(Uint16);
6804}
6805
6806static SDL_INLINE void
6807swizzle_alsa_channels_6_8bit(_THIS)
6808{
6809 SWIZ6(Uint8);
6810}
6811
6812#undef SWIZ6
6813
6814static SDL_INLINE void
6815swizzle_alsa_channels(_THIS)
6816{
6817 if (this->spec.channels == 6) {
6818 const Uint16 fmtsize = (this->spec.format & 0xFF);
6819 if (fmtsize == 16)
6820 swizzle_alsa_channels_6_16bit(this);
6821 else if (fmtsize == 8)
6822 swizzle_alsa_channels_6_8bit(this);
6823 else if (fmtsize == 32)
6824 swizzle_alsa_channels_6_32bit(this);
6825 else if (fmtsize == 64)
6826 swizzle_alsa_channels_6_64bit(this);
6827 }
6828
6829}
6830
6831static void
6832ALSA_PlayDevice(_THIS)
6833{
6834 int status;
6835 const Uint8 *sample_buf = (const Uint8 *) SDLAUDIOHIDDEN->mixbuf;
6836 const int frame_size = (((int) (this->spec.format & 0xFF)) / 8) *
6837 this->spec.channels;
6838 snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t) this->spec.samples);
6839
6840 swizzle_alsa_channels(this);
6841
6842 while ( frames_left > 0 && this->enabled ) {
6843
6844 status = ALSA_snd_pcm_writei(SDLAUDIOHIDDEN->pcm_handle,
6845 sample_buf, frames_left);
6846
6847 if (status < 0) {
6848 if (status == -EAGAIN) {
6849
6850 SDL_Delay(1);
6851 continue;
6852 }
6853 status = ALSA_snd_pcm_recover(SDLAUDIOHIDDEN->pcm_handle, status, 0);
6854 if (status < 0) {
6855
6856 fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
6857 ALSA_snd_strerror(status));
6858 this->enabled = 0;
6859 return;
6860 }
6861 continue;
6862 }
6863 sample_buf += status * frame_size;
6864 frames_left -= status;
6865 }
6866}
6867
6868static Uint8 *
6869ALSA_GetDeviceBuf(_THIS)
6870{
6871 return (SDLAUDIOHIDDEN->mixbuf);
6872}
6873
6874static void
6875ALSA_CloseDevice(_THIS)
6876{
6877 if (SDLAUDIOHIDDEN != NULL) {
6878 SDL_FreeAudioMem(SDLAUDIOHIDDEN->mixbuf);
6879 SDLAUDIOHIDDEN->mixbuf = NULL;
6880 if (SDLAUDIOHIDDEN->pcm_handle) {
6881 ALSA_snd_pcm_drain(SDLAUDIOHIDDEN->pcm_handle);
6882 ALSA_snd_pcm_close(SDLAUDIOHIDDEN->pcm_handle);
6883 SDLAUDIOHIDDEN->pcm_handle = NULL;
6884 }
6885 SDL_free(SDLAUDIOHIDDEN);
6886 this->hidden = NULL;
6887 }
6888}
6889
6890static int
6891ALSA_finalize_hardware(_THIS, snd_pcm_hw_params_t *hwparams, int override)
6892{
6893 int status;
6894 snd_pcm_uframes_t bufsize;
6895
6896 status = ALSA_snd_pcm_hw_params(SDLAUDIOHIDDEN->pcm_handle, hwparams);
6897 if ( status < 0 ) {
6898 return(-1);
6899 }
6900
6901 status = ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
6902 if ( status < 0 ) {
6903 return(-1);
6904 }
6905 if ( !override && bufsize != this->spec.samples * 2 ) {
6906 return(-1);
6907 }
6908
6909 this->spec.samples = bufsize / 2;
6910
6911 if ( SDL_getenv("SDL_AUDIO_ALSA_DEBUG") ) {
6912 snd_pcm_uframes_t persize = 0;
6913 unsigned int periods = 0;
6914
6915 ALSA_snd_pcm_hw_params_get_period_size(hwparams, &persize, NULL);
6916 ALSA_snd_pcm_hw_params_get_periods(hwparams, &periods, NULL);
6917
6918 fprintf(stderr,
6919 "ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
6920 persize, periods, bufsize);
6921 }
6922
6923 return(0);
6924}
6925
6926static int
6927ALSA_set_period_size(_THIS, snd_pcm_hw_params_t *params, int override)
6928{
6929 const char *env;
6930 int status;
6931 snd_pcm_hw_params_t *hwparams;
6932 snd_pcm_uframes_t frames;
6933 unsigned int periods;
6934
6935 snd_pcm_hw_params_alloca(&hwparams);
6936 ALSA_snd_pcm_hw_params_copy(hwparams, params);
6937
6938 if ( !override ) {
6939 env = SDL_getenv("SDL_AUDIO_ALSA_SET_PERIOD_SIZE");
6940 if ( env ) {
6941 override = SDL_atoi(env);
6942 if ( override == 0 ) {
6943 return(-1);
6944 }
6945 }
6946 }
6947
6948 frames = this->spec.samples;
6949 status = ALSA_snd_pcm_hw_params_set_period_size_near(
6950 SDLAUDIOHIDDEN->pcm_handle, hwparams, &frames, NULL);
6951 if ( status < 0 ) {
6952 return(-1);
6953 }
6954
6955 periods = 2;
6956 status = ALSA_snd_pcm_hw_params_set_periods_near(
6957 SDLAUDIOHIDDEN->pcm_handle, hwparams, &periods, NULL);
6958 if ( status < 0 ) {
6959 return(-1);
6960 }
6961
6962 return ALSA_finalize_hardware(this, hwparams, override);
6963}
6964
6965static int
6966ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override)
6967{
6968 const char *env;
6969 int status;
6970 snd_pcm_hw_params_t *hwparams;
6971 snd_pcm_uframes_t frames;
6972
6973 snd_pcm_hw_params_alloca(&hwparams);
6974 ALSA_snd_pcm_hw_params_copy(hwparams, params);
6975
6976 if ( !override ) {
6977 env = SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE");
6978 if ( env ) {
6979 override = SDL_atoi(env);
6980 if ( override == 0 ) {
6981 return(-1);
6982 }
6983 }
6984 }
6985
6986 frames = this->spec.samples * 2;
6987 status = ALSA_snd_pcm_hw_params_set_buffer_size_near(
6988 SDLAUDIOHIDDEN->pcm_handle, hwparams, &frames);
6989 if ( status < 0 ) {
6990 return(-1);
6991 }
6992
6993 return ALSA_finalize_hardware(this, hwparams, override);
6994}
6995
6996static int
6997ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
6998{
6999 int status = 0;
7000 snd_pcm_t *pcm_handle = NULL;
7001 snd_pcm_hw_params_t *hwparams = NULL;
7002 snd_pcm_sw_params_t *swparams = NULL;
7003 snd_pcm_format_t format = 0;
7004 SDL_AudioFormat test_format = 0;
7005 unsigned int rate = 0;
7006 unsigned int channels = 0;
7007
7008 this->hidden = (struct SDL_PrivateAudioData *)
7009 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
7010 if (SDLAUDIOHIDDEN == NULL) {
7011 return SDL_OutOfMemory();
7012 }
7013 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
7014
7015 status = ALSA_snd_pcm_open(&pcm_handle,
7016 ALSA_get_audio_device(this->spec.channels),
7017 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
7018
7019 if (status < 0) {
7020 ALSA_CloseDevice(this);
7021 return SDL_SetError("ALSA: Couldn't open audio device: %s",
7022 ALSA_snd_strerror(status));
7023 }
7024
7025 SDLAUDIOHIDDEN->pcm_handle = pcm_handle;
7026
7027 snd_pcm_hw_params_alloca(&hwparams);
7028 status = ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams);
7029 if (status < 0) {
7030 ALSA_CloseDevice(this);
7031 return SDL_SetError("ALSA: Couldn't get hardware config: %s",
7032 ALSA_snd_strerror(status));
7033 }
7034
7035 status = ALSA_snd_pcm_hw_params_set_access(pcm_handle, hwparams,
7036 SND_PCM_ACCESS_RW_INTERLEAVED);
7037 if (status < 0) {
7038 ALSA_CloseDevice(this);
7039 return SDL_SetError("ALSA: Couldn't set interleaved access: %s",
7040 ALSA_snd_strerror(status));
7041 }
7042
7043 status = -1;
7044 for (test_format = SDL_FirstAudioFormat(this->spec.format);
7045 test_format && (status < 0);) {
7046 status = 0;
7047 switch (test_format) {
7048 case AUDIO_U8:
7049 format = SND_PCM_FORMAT_U8;
7050 break;
7051 case AUDIO_S8:
7052 format = SND_PCM_FORMAT_S8;
7053 break;
7054 case AUDIO_S16LSB:
7055 format = SND_PCM_FORMAT_S16_LE;
7056 break;
7057 case AUDIO_S16MSB:
7058 format = SND_PCM_FORMAT_S16_BE;
7059 break;
7060 case AUDIO_U16LSB:
7061 format = SND_PCM_FORMAT_U16_LE;
7062 break;
7063 case AUDIO_U16MSB:
7064 format = SND_PCM_FORMAT_U16_BE;
7065 break;
7066 case AUDIO_S32LSB:
7067 format = SND_PCM_FORMAT_S32_LE;
7068 break;
7069 case AUDIO_S32MSB:
7070 format = SND_PCM_FORMAT_S32_BE;
7071 break;
7072 case AUDIO_F32LSB:
7073 format = SND_PCM_FORMAT_FLOAT_LE;
7074 break;
7075 case AUDIO_F32MSB:
7076 format = SND_PCM_FORMAT_FLOAT_BE;
7077 break;
7078 default:
7079 status = -1;
7080 break;
7081 }
7082 if (status >= 0) {
7083 status = ALSA_snd_pcm_hw_params_set_format(pcm_handle,
7084 hwparams, format);
7085 }
7086 if (status < 0) {
7087 test_format = SDL_NextAudioFormat();
7088 }
7089 }
7090 if (status < 0) {
7091 ALSA_CloseDevice(this);
7092 return SDL_SetError("ALSA: Couldn't find any hardware audio formats");
7093 }
7094 this->spec.format = test_format;
7095
7096 status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams,
7097 this->spec.channels);
7098 channels = this->spec.channels;
7099 if (status < 0) {
7100 status = ALSA_snd_pcm_hw_params_get_channels(hwparams, &channels);
7101 if (status < 0) {
7102 ALSA_CloseDevice(this);
7103 return SDL_SetError("ALSA: Couldn't set audio channels");
7104 }
7105 this->spec.channels = channels;
7106 }
7107
7108 rate = this->spec.freq;
7109 status = ALSA_snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams,
7110 &rate, NULL);
7111 if (status < 0) {
7112 ALSA_CloseDevice(this);
7113 return SDL_SetError("ALSA: Couldn't set audio frequency: %s",
7114 ALSA_snd_strerror(status));
7115 }
7116 this->spec.freq = rate;
7117
7118 if ( ALSA_set_period_size(this, hwparams, 0) < 0 &&
7119 ALSA_set_buffer_size(this, hwparams, 0) < 0 ) {
7120
7121 if ( ALSA_set_period_size(this, hwparams, 1) < 0 ) {
7122 ALSA_CloseDevice(this);
7123 return SDL_SetError("Couldn't set hardware audio parameters: %s", ALSA_snd_strerror(status));
7124 }
7125 }
7126
7127 snd_pcm_sw_params_alloca(&swparams);
7128 status = ALSA_snd_pcm_sw_params_current(pcm_handle, swparams);
7129 if (status < 0) {
7130 ALSA_CloseDevice(this);
7131 return SDL_SetError("ALSA: Couldn't get software config: %s",
7132 ALSA_snd_strerror(status));
7133 }
7134 status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples);
7135 if (status < 0) {
7136 ALSA_CloseDevice(this);
7137 return SDL_SetError("Couldn't set minimum available samples: %s",
7138 ALSA_snd_strerror(status));
7139 }
7140 status =
7141 ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1);
7142 if (status < 0) {
7143 ALSA_CloseDevice(this);
7144 return SDL_SetError("ALSA: Couldn't set start threshold: %s",
7145 ALSA_snd_strerror(status));
7146 }
7147 status = ALSA_snd_pcm_sw_params(pcm_handle, swparams);
7148 if (status < 0) {
7149 ALSA_CloseDevice(this);
7150 return SDL_SetError("Couldn't set software audio parameters: %s",
7151 ALSA_snd_strerror(status));
7152 }
7153
7154 SDL_CalculateAudioSpec(&this->spec);
7155
7156 SDLAUDIOHIDDEN->mixlen = this->spec.size;
7157 SDLAUDIOHIDDEN->mixbuf = (Uint8 *) SDL_AllocAudioMem(SDLAUDIOHIDDEN->mixlen);
7158 if (SDLAUDIOHIDDEN->mixbuf == NULL) {
7159 ALSA_CloseDevice(this);
7160 return SDL_OutOfMemory();
7161 }
7162 SDL_memset(SDLAUDIOHIDDEN->mixbuf, this->spec.silence, SDLAUDIOHIDDEN->mixlen);
7163
7164 ALSA_snd_pcm_nonblock(pcm_handle, 0);
7165
7166 return 0;
7167}
7168
7169static void
7170ALSA_Deinitialize(void)
7171{
7172 UnloadALSALibrary();
7173}
7174
7175static int
7176ALSA_Init(SDL_AudioDriverImpl * impl)
7177{
7178 if (LoadALSALibrary() < 0) {
7179 return 0;
7180 }
7181
7182 impl->OpenDevice = ALSA_OpenDevice;
7183 impl->WaitDevice = ALSA_WaitDevice;
7184 impl->GetDeviceBuf = ALSA_GetDeviceBuf;
7185 impl->PlayDevice = ALSA_PlayDevice;
7186 impl->CloseDevice = ALSA_CloseDevice;
7187 impl->Deinitialize = ALSA_Deinitialize;
7188 impl->OnlyHasDefaultOutputDevice = 1;
7189
7190 return 1;
7191}
7192
7193AudioBootStrap ALSA_bootstrap = {
7194 "alsa", "ALSA PCM audio", ALSA_Init, 0
7195};
7196
7197#endif
7198#if SDL_AUDIO_DRIVER_ARTS
7199
7200#ifdef HAVE_SIGNAL_H
7201#include <signal.h>
7202#endif
7203#include <unistd.h>
7204#include <errno.h>
7205
7206#define SDL_AllocAudioMem SDL_malloc
7207#define SDL_FreeAudioMem SDL_free
7208#ifndef _SDL_artscaudio_h
7209#define _SDL_artscaudio_h
7210
7211#include <artsc.h>
7212
7213#undef _THIS
7214#define _THIS SDL_AudioDevice *this
7215
7216#undef SDLAUDIOHIDDEN
7217#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataARTS*)this->hidden)
7218struct SDL_PrivateAudioDataARTS
7219{
7220
7221 arts_stream_t stream;
7222
7223 pid_t parent;
7224
7225 Uint8 *mixbuf;
7226 int mixlen;
7227
7228 float frame_ticks;
7229 float next_frame;
7230};
7231#define FUDGE_TICKS 10
7232
7233#endif
7234
7235#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
7236#ifndef _SDLname_h_
7237#define _SDLname_h_
7238
7239#if defined(__STDC__) || defined(__cplusplus)
7240#define NeedFunctionPrototypes 1
7241#endif
7242
7243#define SDL_NAME(X) SDL_##X
7244
7245#endif
7246#else
7247#define SDL_NAME(X) X
7248#endif
7249
7250#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
7251
7252static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC;
7253static void *arts_handle = NULL;
7254
7255static int (*SDL_NAME(arts_init)) (void);
7256static void (*SDL_NAME(arts_free)) (void);
7257static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits,
7258 int channels,
7259 const char *name);
7260static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s,
7261 arts_parameter_t param, int value);
7262static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
7263 arts_parameter_t param);
7264static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
7265 int count);
7266static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s);
7267static int (*SDL_NAME(arts_suspend))(void);
7268static int (*SDL_NAME(arts_suspended)) (void);
7269static const char *(*SDL_NAME(arts_error_text)) (int errorcode);
7270
7271#define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
7272static struct
7273{
7274 const char *name;
7275 void **func;
7276} arts_functions[] = {
7277
7278 SDL_ARTS_SYM(arts_init),
7279 SDL_ARTS_SYM(arts_free),
7280 SDL_ARTS_SYM(arts_play_stream),
7281 SDL_ARTS_SYM(arts_stream_set),
7282 SDL_ARTS_SYM(arts_stream_get),
7283 SDL_ARTS_SYM(arts_write),
7284 SDL_ARTS_SYM(arts_close_stream),
7285 SDL_ARTS_SYM(arts_suspend),
7286 SDL_ARTS_SYM(arts_suspended),
7287 SDL_ARTS_SYM(arts_error_text),
7288
7289};
7290
7291#undef SDL_ARTS_SYM
7292
7293static void
7294UnloadARTSLibrary()
7295{
7296 if (arts_handle != NULL) {
7297 SDL_UnloadObject(arts_handle);
7298 arts_handle = NULL;
7299 }
7300}
7301
7302static int
7303LoadARTSLibrary(void)
7304{
7305 int i, retval = -1;
7306
7307 if (arts_handle == NULL) {
7308 arts_handle = SDL_LoadObject(arts_library);
7309 if (arts_handle != NULL) {
7310 retval = 0;
7311 for (i = 0; i < SDL_arraysize(arts_functions); ++i) {
7312 *arts_functions[i].func =
7313 SDL_LoadFunction(arts_handle, arts_functions[i].name);
7314 if (!*arts_functions[i].func) {
7315 retval = -1;
7316 UnloadARTSLibrary();
7317 break;
7318 }
7319 }
7320 }
7321 }
7322
7323 return retval;
7324}
7325
7326#else
7327
7328static void
7329UnloadARTSLibrary()
7330{
7331 return;
7332}
7333
7334static int
7335LoadARTSLibrary(void)
7336{
7337 return 0;
7338}
7339
7340#endif
7341
7342static void
7343ARTS_WaitDevice(_THIS)
7344{
7345 Sint32 ticks;
7346
7347 {
7348 static int cnt = 0;
7349
7350 if (SDLAUDIOHIDDEN->parent && (((++cnt) % 10) == 0)) {
7351 if (kill(SDLAUDIOHIDDEN->parent, 0) < 0 && errno == ESRCH) {
7352 this->enabled = 0;
7353 }
7354 }
7355 }
7356
7357 ticks =
7358 ((Sint32) (SDLAUDIOHIDDEN->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
7359 if (ticks > 0) {
7360 SDL_Delay(ticks);
7361 }
7362}
7363
7364static void
7365ARTS_PlayDevice(_THIS)
7366{
7367
7368 int written = SDL_NAME(arts_write) (SDLAUDIOHIDDEN->stream,
7369 SDLAUDIOHIDDEN->mixbuf,
7370 SDLAUDIOHIDDEN->mixlen);
7371
7372 if (SDLAUDIOHIDDEN->frame_ticks) {
7373 SDLAUDIOHIDDEN->next_frame += SDLAUDIOHIDDEN->frame_ticks;
7374 }
7375
7376 if (written < 0) {
7377 this->enabled = 0;
7378 }
7379#ifdef DEBUG_AUDIO
7380 fprintf(stderr, "Wrote %d bytes of audio data\n", written);
7381#endif
7382}
7383
7384static void
7385ARTS_WaitDone(_THIS)
7386{
7387
7388}
7389
7390static Uint8 *
7391ARTS_GetDeviceBuf(_THIS)
7392{
7393 return (SDLAUDIOHIDDEN->mixbuf);
7394}
7395
7396static void
7397ARTS_CloseDevice(_THIS)
7398{
7399 if (SDLAUDIOHIDDEN != NULL) {
7400 SDL_FreeAudioMem(SDLAUDIOHIDDEN->mixbuf);
7401 SDLAUDIOHIDDEN->mixbuf = NULL;
7402 if (SDLAUDIOHIDDEN->stream) {
7403 SDL_NAME(arts_close_stream) (SDLAUDIOHIDDEN->stream);
7404 SDLAUDIOHIDDEN->stream = 0;
7405 }
7406 SDL_NAME(arts_free) ();
7407 SDL_free(SDLAUDIOHIDDEN);
7408 this->hidden = NULL;
7409 }
7410}
7411
7412static int
7413ARTS_Suspend(void)
7414{
7415 const Uint32 abortms = SDL_GetTicks() + 3000;
7416 while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) {
7417 if ( SDL_NAME(arts_suspend)() ) {
7418 break;
7419 }
7420 }
7421 return SDL_NAME(arts_suspended)();
7422}
7423
7424static int
7425ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
7426{
7427 int rc = 0;
7428 int bits = 0, frag_spec = 0;
7429 SDL_AudioFormat test_format = 0, format = 0;
7430
7431 this->hidden = (struct SDL_PrivateAudioData *)
7432 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
7433 if (SDLAUDIOHIDDEN == NULL) {
7434 return SDL_OutOfMemory();
7435 }
7436 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
7437
7438 for (test_format = SDL_FirstAudioFormat(this->spec.format);
7439 !format && test_format;) {
7440#ifdef DEBUG_AUDIO
7441 fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
7442#endif
7443 switch (test_format) {
7444 case AUDIO_U8:
7445 bits = 8;
7446 format = 1;
7447 break;
7448 case AUDIO_S16LSB:
7449 bits = 16;
7450 format = 1;
7451 break;
7452 default:
7453 format = 0;
7454 break;
7455 }
7456 if (!format) {
7457 test_format = SDL_NextAudioFormat();
7458 }
7459 }
7460 if (format == 0) {
7461 ARTS_CloseDevice(this);
7462 return SDL_SetError("Couldn't find any hardware audio formats");
7463 }
7464 this->spec.format = test_format;
7465
7466 if ((rc = SDL_NAME(arts_init) ()) != 0) {
7467 ARTS_CloseDevice(this);
7468 return SDL_SetError("Unable to initialize ARTS: %s",
7469 SDL_NAME(arts_error_text) (rc));
7470 }
7471
7472 if (!ARTS_Suspend()) {
7473 ARTS_CloseDevice(this);
7474 return SDL_SetError("ARTS can not open audio device");
7475 }
7476
7477 SDLAUDIOHIDDEN->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
7478 bits,
7479 this->spec.channels,
7480 "SDL");
7481
7482 SDL_NAME(arts_write) (SDLAUDIOHIDDEN->stream, "", 0);
7483
7484 SDL_CalculateAudioSpec(&this->spec);
7485
7486 for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec);
7487 if ((0x01 << frag_spec) != this->spec.size) {
7488 ARTS_CloseDevice(this);
7489 return SDL_SetError("Fragment size must be a power of two");
7490 }
7491 frag_spec |= 0x00020000;
7492
7493#ifdef ARTS_P_PACKET_SETTINGS
7494 SDL_NAME(arts_stream_set) (SDLAUDIOHIDDEN->stream,
7495 ARTS_P_PACKET_SETTINGS, frag_spec);
7496#else
7497 SDL_NAME(arts_stream_set) (SDLAUDIOHIDDEN->stream, ARTS_P_PACKET_SIZE,
7498 frag_spec & 0xffff);
7499 SDL_NAME(arts_stream_set) (SDLAUDIOHIDDEN->stream, ARTS_P_PACKET_COUNT,
7500 frag_spec >> 16);
7501#endif
7502 this->spec.size = SDL_NAME(arts_stream_get) (SDLAUDIOHIDDEN->stream,
7503 ARTS_P_PACKET_SIZE);
7504
7505 SDLAUDIOHIDDEN->mixlen = this->spec.size;
7506 SDLAUDIOHIDDEN->mixbuf = (Uint8 *) SDL_AllocAudioMem(SDLAUDIOHIDDEN->mixlen);
7507 if (SDLAUDIOHIDDEN->mixbuf == NULL) {
7508 ARTS_CloseDevice(this);
7509 return SDL_OutOfMemory();
7510 }
7511 SDL_memset(SDLAUDIOHIDDEN->mixbuf, this->spec.silence, this->spec.size);
7512
7513 SDLAUDIOHIDDEN->parent = getpid();
7514
7515 return 0;
7516}
7517
7518static void
7519ARTS_Deinitialize(void)
7520{
7521 UnloadARTSLibrary();
7522}
7523
7524static int
7525ARTS_Init(SDL_AudioDriverImpl * impl)
7526{
7527 if (LoadARTSLibrary() < 0) {
7528 return 0;
7529 } else {
7530 if (SDL_NAME(arts_init) () != 0) {
7531 UnloadARTSLibrary();
7532 SDL_SetError("ARTS: arts_init failed (no audio server?)");
7533 return 0;
7534 }
7535
7536 if (ARTS_Suspend()) {
7537 arts_stream_t stream;
7538 stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
7539 SDL_NAME(arts_write) (stream, "", 0);
7540 SDL_NAME(arts_close_stream) (stream);
7541 }
7542
7543 SDL_NAME(arts_free) ();
7544 }
7545
7546 impl->OpenDevice = ARTS_OpenDevice;
7547 impl->PlayDevice = ARTS_PlayDevice;
7548 impl->WaitDevice = ARTS_WaitDevice;
7549 impl->GetDeviceBuf = ARTS_GetDeviceBuf;
7550 impl->CloseDevice = ARTS_CloseDevice;
7551 impl->WaitDone = ARTS_WaitDone;
7552 impl->Deinitialize = ARTS_Deinitialize;
7553 impl->OnlyHasDefaultOutputDevice = 1;
7554
7555 return 1;
7556}
7557
7558AudioBootStrap ARTS_bootstrap = {
7559 "arts", "Analog RealTime Synthesizer", ARTS_Init, 0
7560};
7561
7562#endif
7563#if SDL_AUDIO_DRIVER_BSD
7564
7565#include <errno.h>
7566#include <unistd.h>
7567#include <fcntl.h>
7568#include <sys/time.h>
7569#include <sys/ioctl.h>
7570#include <sys/stat.h>
7571#include <sys/types.h>
7572#include <sys/audioio.h>
7573
7574#define SDL_AllocAudioMem SDL_malloc
7575#define SDL_FreeAudioMem SDL_free
7576#ifdef USE_BLOCKING_WRITES
7577#define OPEN_FLAGS_OUTPUT O_WRONLY
7578#define OPEN_FLAGS_INPUT O_RDONLY
7579#else
7580#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK)
7581#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
7582#endif
7583
7584void SDL_EnumUnixAudioDevices(int iscapture, int classic,
7585 int (*test) (int fd), SDL_AddAudioDevice addfn);
7586#ifndef _SDL_bsdaudio_h
7587#define _SDL_bsdaudio_h
7588
7589#undef _THIS
7590#define _THIS SDL_AudioDevice *this
7591
7592#undef SDLAUDIOHIDDEN
7593#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataBSDAUDIO*)this->hidden)
7594struct SDL_PrivateAudioDataBSDAUDIO
7595{
7596
7597 int audio_fd;
7598
7599 pid_t parent;
7600
7601 Uint8 *mixbuf;
7602 int mixlen;
7603
7604 float frame_ticks;
7605 float next_frame;
7606};
7607
7608#define FUDGE_TICKS 10
7609
7610#endif
7611
7612static void
7613BSDAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
7614{
7615 SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn);
7616}
7617
7618static void
7619BSDAUDIO_Status(_THIS)
7620{
7621#ifdef DEBUG_AUDIO
7622
7623 audio_info_t info;
7624
7625 if (ioctl(SDLAUDIOHIDDEN->audio_fd, AUDIO_GETINFO, &info) < 0) {
7626 fprintf(stderr, "AUDIO_GETINFO failed.\n");
7627 return;
7628 }
7629 fprintf(stderr, "\n"
7630 "[play/record info]\n"
7631 "buffer size : %d bytes\n"
7632 "sample rate : %i Hz\n"
7633 "channels : %i\n"
7634 "precision : %i-bit\n"
7635 "encoding : 0x%x\n"
7636 "seek : %i\n"
7637 "sample count : %i\n"
7638 "EOF count : %i\n"
7639 "paused : %s\n"
7640 "error occured : %s\n"
7641 "waiting : %s\n"
7642 "active : %s\n"
7643 "",
7644 info.play.buffer_size,
7645 info.play.sample_rate,
7646 info.play.channels,
7647 info.play.precision,
7648 info.play.encoding,
7649 info.play.seek,
7650 info.play.samples,
7651 info.play.eof,
7652 info.play.pause ? "yes" : "no",
7653 info.play.error ? "yes" : "no",
7654 info.play.waiting ? "yes" : "no",
7655 info.play.active ? "yes" : "no");
7656
7657 fprintf(stderr, "\n"
7658 "[audio info]\n"
7659 "monitor_gain : %i\n"
7660 "hw block size : %d bytes\n"
7661 "hi watermark : %i\n"
7662 "lo watermark : %i\n"
7663 "audio mode : %s\n"
7664 "",
7665 info.monitor_gain,
7666 info.blocksize,
7667 info.hiwat, info.lowat,
7668 (info.mode == AUMODE_PLAY) ? "PLAY"
7669 : (info.mode = AUMODE_RECORD) ? "RECORD"
7670 : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?"));
7671
7672#endif
7673}
7674
7675static void
7676BSDAUDIO_WaitDevice(_THIS)
7677{
7678#ifndef USE_BLOCKING_WRITES
7679
7680 if (SDLAUDIOHIDDEN->frame_ticks) {
7681
7682 Sint32 ticks;
7683
7684 ticks = ((Sint32) (SDLAUDIOHIDDEN->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
7685 if (ticks > 0) {
7686 SDL_Delay(ticks);
7687 }
7688 } else {
7689
7690 fd_set fdset;
7691 struct timeval timeout;
7692
7693 FD_ZERO(&fdset);
7694 FD_SET(SDLAUDIOHIDDEN->audio_fd, &fdset);
7695 timeout.tv_sec = 10;
7696 timeout.tv_usec = 0;
7697#ifdef DEBUG_AUDIO
7698 fprintf(stderr, "Waiting for audio to get ready\n");
7699#endif
7700 if (select(SDLAUDIOHIDDEN->audio_fd + 1, NULL, &fdset, NULL, &timeout)
7701 <= 0) {
7702 const char *message =
7703 "Audio timeout - buggy audio driver? (disabled)";
7704
7705 fprintf(stderr, "SDL: %s\n", message);
7706 this->enabled = 0;
7707
7708 SDLAUDIOHIDDEN->audio_fd = -1;
7709#ifdef DEBUG_AUDIO
7710 fprintf(stderr, "Done disabling audio\n");
7711#endif
7712 }
7713#ifdef DEBUG_AUDIO
7714 fprintf(stderr, "Ready!\n");
7715#endif
7716 }
7717#endif
7718}
7719
7720static void
7721BSDAUDIO_PlayDevice(_THIS)
7722{
7723 int written, p = 0;
7724
7725 do {
7726 written = write(SDLAUDIOHIDDEN->audio_fd,
7727 &SDLAUDIOHIDDEN->mixbuf[p], SDLAUDIOHIDDEN->mixlen - p);
7728
7729 if (written > 0)
7730 p += written;
7731 if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) {
7732
7733 perror("audio");
7734 break;
7735 }
7736
7737 if (p < written
7738 || ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) {
7739 SDL_Delay(1);
7740 }
7741 } while (p < written);
7742
7743 if (SDLAUDIOHIDDEN->frame_ticks) {
7744 SDLAUDIOHIDDEN->next_frame += SDLAUDIOHIDDEN->frame_ticks;
7745 }
7746
7747 if (written < 0) {
7748 this->enabled = 0;
7749 }
7750#ifdef DEBUG_AUDIO
7751 fprintf(stderr, "Wrote %d bytes of audio data\n", written);
7752#endif
7753}
7754
7755static Uint8 *
7756BSDAUDIO_GetDeviceBuf(_THIS)
7757{
7758 return (SDLAUDIOHIDDEN->mixbuf);
7759}
7760
7761static void
7762BSDAUDIO_CloseDevice(_THIS)
7763{
7764 if (SDLAUDIOHIDDEN != NULL) {
7765 SDL_FreeAudioMem(SDLAUDIOHIDDEN->mixbuf);
7766 SDLAUDIOHIDDEN->mixbuf = NULL;
7767 if (SDLAUDIOHIDDEN->audio_fd >= 0) {
7768 close(SDLAUDIOHIDDEN->audio_fd);
7769 SDLAUDIOHIDDEN->audio_fd = -1;
7770 }
7771 SDL_free(SDLAUDIOHIDDEN);
7772 this->hidden = NULL;
7773 }
7774}
7775
7776static int
7777BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
7778{
7779 const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
7780 SDL_AudioFormat format = 0;
7781 audio_info_t info;
7782
7783 if (devname == NULL) {
7784 devname = SDL_GetAudioDeviceName(0, iscapture);
7785 if (devname == NULL) {
7786 return SDL_SetError("No such audio device");
7787 }
7788 }
7789
7790 this->hidden = (struct SDL_PrivateAudioData *)
7791 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
7792 if (SDLAUDIOHIDDEN == NULL) {
7793 return SDL_OutOfMemory();
7794 }
7795 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
7796
7797 SDLAUDIOHIDDEN->audio_fd = open(devname, flags, 0);
7798 if (SDLAUDIOHIDDEN->audio_fd < 0) {
7799 return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
7800 }
7801
7802 AUDIO_INITINFO(&info);
7803
7804 SDL_CalculateAudioSpec(&this->spec);
7805
7806 info.mode = AUMODE_PLAY;
7807 if (ioctl(SDLAUDIOHIDDEN->audio_fd, AUDIO_SETINFO, &info) < 0) {
7808 BSDAUDIO_CloseDevice(this);
7809 return SDL_SetError("Couldn't put device into play mode");
7810 }
7811
7812 AUDIO_INITINFO(&info);
7813 for (format = SDL_FirstAudioFormat(this->spec.format);
7814 format; format = SDL_NextAudioFormat()) {
7815 switch (format) {
7816 case AUDIO_U8:
7817 info.play.encoding = AUDIO_ENCODING_ULINEAR;
7818 info.play.precision = 8;
7819 break;
7820 case AUDIO_S8:
7821 info.play.encoding = AUDIO_ENCODING_SLINEAR;
7822 info.play.precision = 8;
7823 break;
7824 case AUDIO_S16LSB:
7825 info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
7826 info.play.precision = 16;
7827 break;
7828 case AUDIO_S16MSB:
7829 info.play.encoding = AUDIO_ENCODING_SLINEAR_BE;
7830 info.play.precision = 16;
7831 break;
7832 case AUDIO_U16LSB:
7833 info.play.encoding = AUDIO_ENCODING_ULINEAR_LE;
7834 info.play.precision = 16;
7835 break;
7836 case AUDIO_U16MSB:
7837 info.play.encoding = AUDIO_ENCODING_ULINEAR_BE;
7838 info.play.precision = 16;
7839 break;
7840 default:
7841 continue;
7842 }
7843
7844 if (ioctl(SDLAUDIOHIDDEN->audio_fd, AUDIO_SETINFO, &info) == 0) {
7845 break;
7846 }
7847 }
7848
7849 if (!format) {
7850 BSDAUDIO_CloseDevice(this);
7851 return SDL_SetError("No supported encoding for 0x%x", this->spec.format);
7852 }
7853
7854 this->spec.format = format;
7855
7856 AUDIO_INITINFO(&info);
7857 info.play.channels = this->spec.channels;
7858 if (ioctl(SDLAUDIOHIDDEN->audio_fd, AUDIO_SETINFO, &info) == -1) {
7859 this->spec.channels = 1;
7860 }
7861 AUDIO_INITINFO(&info);
7862 info.play.sample_rate = this->spec.freq;
7863 info.blocksize = this->spec.size;
7864 info.hiwat = 5;
7865 info.lowat = 3;
7866 (void) ioctl(SDLAUDIOHIDDEN->audio_fd, AUDIO_SETINFO, &info);
7867 (void) ioctl(SDLAUDIOHIDDEN->audio_fd, AUDIO_GETINFO, &info);
7868 this->spec.freq = info.play.sample_rate;
7869
7870 SDLAUDIOHIDDEN->mixlen = this->spec.size;
7871 SDLAUDIOHIDDEN->mixbuf = (Uint8 *) SDL_AllocAudioMem(SDLAUDIOHIDDEN->mixlen);
7872 if (SDLAUDIOHIDDEN->mixbuf == NULL) {
7873 BSDAUDIO_CloseDevice(this);
7874 return SDL_OutOfMemory();
7875 }
7876 SDL_memset(SDLAUDIOHIDDEN->mixbuf, this->spec.silence, this->spec.size);
7877
7878 BSDAUDIO_Status(this);
7879
7880 return 0;
7881}
7882
7883static int
7884BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
7885{
7886
7887 impl->DetectDevices = BSDAUDIO_DetectDevices;
7888 impl->OpenDevice = BSDAUDIO_OpenDevice;
7889 impl->PlayDevice = BSDAUDIO_PlayDevice;
7890 impl->WaitDevice = BSDAUDIO_WaitDevice;
7891 impl->GetDeviceBuf = BSDAUDIO_GetDeviceBuf;
7892 impl->CloseDevice = BSDAUDIO_CloseDevice;
7893
7894 return 1;
7895}
7896
7897AudioBootStrap BSD_AUDIO_bootstrap = {
7898 "bsd", "BSD audio", BSDAUDIO_Init, 0
7899};
7900
7901#endif
7902#if SDL_AUDIO_DRIVER_COREAUDIO
7903
7904#ifndef _SDL_coreaudio_h
7905#define _SDL_coreaudio_h
7906
7907#if !defined(__IPHONEOS__)
7908#define MACOSX_COREAUDIO 1
7909#endif
7910
7911#if MACOSX_COREAUDIO
7912#include <CoreAudio/CoreAudio.h>
7913#include <CoreServices/CoreServices.h>
7914#else
7915#include <AudioToolbox/AudioToolbox.h>
7916#endif
7917
7918#include <AudioUnit/AudioUnit.h>
7919
7920#undef _THIS
7921#define _THIS SDL_AudioDevice *this
7922
7923#undef SDLAUDIOHIDDEN
7924#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataCOREAUDIO*)this->hidden)
7925struct SDL_PrivateAudioDataCOREAUDIO
7926{
7927 AudioUnit audioUnit;
7928 int audioUnitOpened;
7929 void *buffer;
7930 UInt32 bufferOffset;
7931 UInt32 bufferSize;
7932#if MACOSX_COREAUDIO
7933 AudioDeviceID deviceID;
7934#endif
7935};
7936
7937#endif
7938
7939#pragma clang diagnostic ignored "-Wdeprecated-declarations"
7940
7941#define DEBUG_COREAUDIO 0
7942
7943static void COREAUDIO_CloseDevice(_THIS);
7944
7945#define CHECK_RESULT(msg) \
7946 if (result != noErr) { \
7947 COREAUDIO_CloseDevice(this); \
7948 SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \
7949 return 0; \
7950 }
7951
7952#if MACOSX_COREAUDIO
7953typedef void (*addDevFn)(const char *name, AudioDeviceID devId, void *data);
7954
7955static void
7956addToDevList(const char *name, AudioDeviceID devId, void *data)
7957{
7958 SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
7959 addfn(name);
7960}
7961
7962typedef struct
7963{
7964 const char *findname;
7965 AudioDeviceID devId;
7966 int found;
7967} FindDevIdData;
7968
7969static void
7970findDevId(const char *name, AudioDeviceID devId, void *_data)
7971{
7972 FindDevIdData *data = (FindDevIdData *) _data;
7973 if (!data->found) {
7974 if (SDL_strcmp(name, data->findname) == 0) {
7975 data->found = 1;
7976 data->devId = devId;
7977 }
7978 }
7979}
7980
7981static void
7982build_device_list(int iscapture, addDevFn addfn, void *addfndata)
7983{
7984 OSStatus result = noErr;
7985 UInt32 size = 0;
7986 AudioDeviceID *devs = NULL;
7987 UInt32 i = 0;
7988 UInt32 max = 0;
7989
7990 AudioObjectPropertyAddress addr = {
7991 kAudioHardwarePropertyDevices,
7992 kAudioObjectPropertyScopeGlobal,
7993 kAudioObjectPropertyElementMaster
7994 };
7995
7996 result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
7997 0, NULL, &size);
7998 if (result != kAudioHardwareNoError)
7999 return;
8000
8001 devs = (AudioDeviceID *) alloca(size);
8002 if (devs == NULL)
8003 return;
8004
8005 result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
8006 0, NULL, &size, devs);
8007 if (result != kAudioHardwareNoError)
8008 return;
8009
8010 max = size / sizeof (AudioDeviceID);
8011 for (i = 0; i < max; i++) {
8012 CFStringRef cfstr = NULL;
8013 char *ptr = NULL;
8014 AudioDeviceID dev = devs[i];
8015 AudioBufferList *buflist = NULL;
8016 int usable = 0;
8017 CFIndex len = 0;
8018
8019 addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
8020 kAudioDevicePropertyScopeOutput;
8021 addr.mSelector = kAudioDevicePropertyStreamConfiguration;
8022
8023 result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
8024 if (result != noErr)
8025 continue;
8026
8027 buflist = (AudioBufferList *) SDL_malloc(size);
8028 if (buflist == NULL)
8029 continue;
8030
8031 result = AudioObjectGetPropertyData(dev, &addr, 0, NULL,
8032 &size, buflist);
8033
8034 if (result == noErr) {
8035 UInt32 j;
8036 for (j = 0; j < buflist->mNumberBuffers; j++) {
8037 if (buflist->mBuffers[j].mNumberChannels > 0) {
8038 usable = 1;
8039 break;
8040 }
8041 }
8042 }
8043
8044 SDL_free(buflist);
8045
8046 if (!usable)
8047 continue;
8048
8049 addr.mSelector = kAudioObjectPropertyName;
8050 size = sizeof (CFStringRef);
8051 result = AudioObjectGetPropertyData(dev, &addr, 0, NULL, &size, &cfstr);
8052 if (result != kAudioHardwareNoError)
8053 continue;
8054
8055 len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr),
8056 kCFStringEncodingUTF8);
8057
8058 ptr = (char *) SDL_malloc(len + 1);
8059 usable = ((ptr != NULL) &&
8060 (CFStringGetCString
8061 (cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
8062
8063 CFRelease(cfstr);
8064
8065 if (usable) {
8066 len = strlen(ptr);
8067
8068 while ((len > 0) && (ptr[len - 1] == ' ')) {
8069 len--;
8070 }
8071 usable = (len > 0);
8072 }
8073
8074 if (usable) {
8075 ptr[len] = '\0';
8076
8077#if DEBUG_COREAUDIO
8078 printf("COREAUDIO: Found %s device #%d: '%s' (devid %d)\n",
8079 ((iscapture) ? "capture" : "output"),
8080 (int) *devCount, ptr, (int) dev);
8081#endif
8082 addfn(ptr, dev, addfndata);
8083 }
8084 SDL_free(ptr);
8085 }
8086}
8087
8088static void
8089COREAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
8090{
8091 build_device_list(iscapture, addToDevList, addfn);
8092}
8093
8094static int
8095find_device_by_name(_THIS, const char *devname, int iscapture)
8096{
8097 AudioDeviceID devid = 0;
8098 OSStatus result = noErr;
8099 UInt32 size = 0;
8100 UInt32 alive = 0;
8101 pid_t pid = 0;
8102
8103 AudioObjectPropertyAddress addr = {
8104 0,
8105 kAudioObjectPropertyScopeGlobal,
8106 kAudioObjectPropertyElementMaster
8107 };
8108
8109 if (devname == NULL) {
8110 size = sizeof (AudioDeviceID);
8111 addr.mSelector =
8112 ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
8113 kAudioHardwarePropertyDefaultOutputDevice);
8114 result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
8115 0, NULL, &size, &devid);
8116 CHECK_RESULT("AudioHardwareGetProperty (default device)");
8117 } else {
8118 FindDevIdData data;
8119 SDL_zero(data);
8120 data.findname = devname;
8121 build_device_list(iscapture, findDevId, &data);
8122 if (!data.found) {
8123 SDL_SetError("CoreAudio: No such audio device.");
8124 return 0;
8125 }
8126 devid = data.devId;
8127 }
8128
8129 addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
8130 addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
8131 kAudioDevicePropertyScopeOutput;
8132
8133 size = sizeof (alive);
8134 result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
8135 CHECK_RESULT
8136 ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
8137
8138 if (!alive) {
8139 SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
8140 return 0;
8141 }
8142
8143 addr.mSelector = kAudioDevicePropertyHogMode;
8144 size = sizeof (pid);
8145 result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
8146
8147 if ((result == noErr) && (pid != -1)) {
8148 SDL_SetError("CoreAudio: requested device is being hogged.");
8149 return 0;
8150 }
8151
8152 SDLAUDIOHIDDEN->deviceID = devid;
8153 return 1;
8154}
8155#endif
8156
8157static OSStatus
8158outputCallback(void *inRefCon,
8159 AudioUnitRenderActionFlags * ioActionFlags,
8160 const AudioTimeStamp * inTimeStamp,
8161 UInt32 inBusNumber, UInt32 inNumberFrames,
8162 AudioBufferList * ioData)
8163{
8164 SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
8165 AudioBuffer *abuf;
8166 UInt32 remaining, len;
8167 void *ptr;
8168 UInt32 i;
8169
8170 if (!this->enabled || this->paused) {
8171 for (i = 0; i < ioData->mNumberBuffers; i++) {
8172 abuf = &ioData->mBuffers[i];
8173 SDL_memset(abuf->mData, this->spec.silence, abuf->mDataByteSize);
8174 }
8175 return 0;
8176 }
8177
8178 for (i = 0; i < ioData->mNumberBuffers; i++) {
8179 abuf = &ioData->mBuffers[i];
8180 remaining = abuf->mDataByteSize;
8181 ptr = abuf->mData;
8182 while (remaining > 0) {
8183 if (SDLAUDIOHIDDEN->bufferOffset >= SDLAUDIOHIDDEN->bufferSize) {
8184
8185 SDL_LockMutex(this->mixer_lock);
8186 (*this->spec.callback)(this->spec.userdata,
8187 SDLAUDIOHIDDEN->buffer, SDLAUDIOHIDDEN->bufferSize);
8188 SDL_UnlockMutex(this->mixer_lock);
8189 SDLAUDIOHIDDEN->bufferOffset = 0;
8190 }
8191
8192 len = SDLAUDIOHIDDEN->bufferSize - SDLAUDIOHIDDEN->bufferOffset;
8193 if (len > remaining)
8194 len = remaining;
8195 SDL_memcpy(ptr, (char *)SDLAUDIOHIDDEN->buffer +
8196 SDLAUDIOHIDDEN->bufferOffset, len);
8197 ptr = (char *)ptr + len;
8198 remaining -= len;
8199 SDLAUDIOHIDDEN->bufferOffset += len;
8200 }
8201 }
8202
8203 return 0;
8204}
8205
8206static OSStatus
8207inputCallback(void *inRefCon,
8208 AudioUnitRenderActionFlags * ioActionFlags,
8209 const AudioTimeStamp * inTimeStamp,
8210 UInt32 inBusNumber, UInt32 inNumberFrames,
8211 AudioBufferList * ioData)
8212{
8213
8214 return noErr;
8215}
8216
8217static void
8218COREAUDIO_CloseDevice(_THIS)
8219{
8220 if (SDLAUDIOHIDDEN != NULL) {
8221 if (SDLAUDIOHIDDEN->audioUnitOpened) {
8222 OSStatus result = noErr;
8223 AURenderCallbackStruct callback;
8224 const AudioUnitElement output_bus = 0;
8225 const AudioUnitElement input_bus = 1;
8226 const int iscapture = this->iscapture;
8227 const AudioUnitElement bus =
8228 ((iscapture) ? input_bus : output_bus);
8229 const AudioUnitScope scope =
8230 ((iscapture) ? kAudioUnitScope_Output :
8231 kAudioUnitScope_Input);
8232
8233 result = AudioOutputUnitStop(SDLAUDIOHIDDEN->audioUnit);
8234
8235 SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
8236 result = AudioUnitSetProperty(SDLAUDIOHIDDEN->audioUnit,
8237 kAudioUnitProperty_SetRenderCallback,
8238 scope, bus, &callback,
8239 sizeof(callback));
8240
8241 #if MACOSX_COREAUDIO
8242 CloseComponent(SDLAUDIOHIDDEN->audioUnit);
8243 #else
8244 AudioComponentInstanceDispose(SDLAUDIOHIDDEN->audioUnit);
8245 #endif
8246
8247 SDLAUDIOHIDDEN->audioUnitOpened = 0;
8248 }
8249 SDL_free(SDLAUDIOHIDDEN->buffer);
8250 SDL_free(SDLAUDIOHIDDEN);
8251 this->hidden = NULL;
8252 }
8253}
8254
8255static int
8256prepare_audiounit(_THIS, const char *devname, int iscapture,
8257 const AudioStreamBasicDescription * strdesc)
8258{
8259 OSStatus result = noErr;
8260 AURenderCallbackStruct callback;
8261#if MACOSX_COREAUDIO
8262 ComponentDescription desc;
8263 Component comp = NULL;
8264#else
8265 AudioComponentDescription desc;
8266 AudioComponent comp = NULL;
8267#endif
8268 const AudioUnitElement output_bus = 0;
8269 const AudioUnitElement input_bus = 1;
8270 const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
8271 const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output :
8272 kAudioUnitScope_Input);
8273
8274#if MACOSX_COREAUDIO
8275 if (!find_device_by_name(this, devname, iscapture)) {
8276 SDL_SetError("Couldn't find requested CoreAudio device");
8277 return 0;
8278 }
8279#endif
8280
8281 SDL_zero(desc);
8282 desc.componentType = kAudioUnitType_Output;
8283 desc.componentManufacturer = kAudioUnitManufacturer_Apple;
8284
8285#if MACOSX_COREAUDIO
8286 desc.componentSubType = kAudioUnitSubType_DefaultOutput;
8287 comp = FindNextComponent(NULL, &desc);
8288#else
8289 desc.componentSubType = kAudioUnitSubType_RemoteIO;
8290 comp = AudioComponentFindNext(NULL, &desc);
8291#endif
8292
8293 if (comp == NULL) {
8294 SDL_SetError("Couldn't find requested CoreAudio component");
8295 return 0;
8296 }
8297
8298#if MACOSX_COREAUDIO
8299 result = OpenAComponent(comp, &SDLAUDIOHIDDEN->audioUnit);
8300 CHECK_RESULT("OpenAComponent");
8301#else
8302
8303 result = AudioComponentInstanceNew(comp, &SDLAUDIOHIDDEN->audioUnit);
8304 CHECK_RESULT("AudioComponentInstanceNew");
8305#endif
8306
8307 SDLAUDIOHIDDEN->audioUnitOpened = 1;
8308
8309#if MACOSX_COREAUDIO
8310 result = AudioUnitSetProperty(SDLAUDIOHIDDEN->audioUnit,
8311 kAudioOutputUnitProperty_CurrentDevice,
8312 kAudioUnitScope_Global, 0,
8313 &SDLAUDIOHIDDEN->deviceID,
8314 sizeof(AudioDeviceID));
8315 CHECK_RESULT
8316 ("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)");
8317#endif
8318
8319 result = AudioUnitSetProperty(SDLAUDIOHIDDEN->audioUnit,
8320 kAudioUnitProperty_StreamFormat,
8321 scope, bus, strdesc, sizeof(*strdesc));
8322 CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)");
8323
8324 SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
8325 callback.inputProc = ((iscapture) ? inputCallback : outputCallback);
8326 callback.inputProcRefCon = this;
8327 result = AudioUnitSetProperty(SDLAUDIOHIDDEN->audioUnit,
8328 kAudioUnitProperty_SetRenderCallback,
8329 scope, bus, &callback, sizeof(callback));
8330 CHECK_RESULT
8331 ("AudioUnitSetProperty (kAudioUnitProperty_SetRenderCallback)");
8332
8333 SDL_CalculateAudioSpec(&this->spec);
8334
8335 SDLAUDIOHIDDEN->bufferOffset = SDLAUDIOHIDDEN->bufferSize = this->spec.size;
8336 SDLAUDIOHIDDEN->buffer = SDL_malloc(SDLAUDIOHIDDEN->bufferSize);
8337
8338 result = AudioUnitInitialize(SDLAUDIOHIDDEN->audioUnit);
8339 CHECK_RESULT("AudioUnitInitialize");
8340
8341 result = AudioOutputUnitStart(SDLAUDIOHIDDEN->audioUnit);
8342 CHECK_RESULT("AudioOutputUnitStart");
8343
8344 return 1;
8345}
8346
8347static int
8348COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
8349{
8350 AudioStreamBasicDescription strdesc;
8351 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
8352 int valid_datatype = 0;
8353
8354 this->hidden = (struct SDL_PrivateAudioData *)
8355 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
8356 if (SDLAUDIOHIDDEN == NULL) {
8357 return SDL_OutOfMemory();
8358 }
8359 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
8360
8361 SDL_memset(&strdesc, '\0', sizeof(AudioStreamBasicDescription));
8362 strdesc.mFormatID = kAudioFormatLinearPCM;
8363 strdesc.mFormatFlags = kLinearPCMFormatFlagIsPacked;
8364 strdesc.mChannelsPerFrame = this->spec.channels;
8365 strdesc.mSampleRate = this->spec.freq;
8366 strdesc.mFramesPerPacket = 1;
8367
8368 while ((!valid_datatype) && (test_format)) {
8369 this->spec.format = test_format;
8370
8371 switch (test_format) {
8372 case AUDIO_U8:
8373 case AUDIO_S8:
8374 case AUDIO_U16LSB:
8375 case AUDIO_S16LSB:
8376 case AUDIO_U16MSB:
8377 case AUDIO_S16MSB:
8378 case AUDIO_S32LSB:
8379 case AUDIO_S32MSB:
8380 case AUDIO_F32LSB:
8381 case AUDIO_F32MSB:
8382 valid_datatype = 1;
8383 strdesc.mBitsPerChannel = SDL_AUDIO_BITSIZE(this->spec.format);
8384 if (SDL_AUDIO_ISBIGENDIAN(this->spec.format))
8385 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
8386
8387 if (SDL_AUDIO_ISFLOAT(this->spec.format))
8388 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsFloat;
8389 else if (SDL_AUDIO_ISSIGNED(this->spec.format))
8390 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
8391 break;
8392 }
8393 }
8394
8395 if (!valid_datatype) {
8396 COREAUDIO_CloseDevice(this);
8397 return SDL_SetError("Unsupported audio format");
8398 }
8399
8400 strdesc.mBytesPerFrame =
8401 strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
8402 strdesc.mBytesPerPacket =
8403 strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
8404
8405 if (!prepare_audiounit(this, devname, iscapture, &strdesc)) {
8406 COREAUDIO_CloseDevice(this);
8407 return -1;
8408 }
8409
8410 return 0;
8411}
8412
8413static int
8414COREAUDIO_Init(SDL_AudioDriverImpl * impl)
8415{
8416
8417 impl->OpenDevice = COREAUDIO_OpenDevice;
8418 impl->CloseDevice = COREAUDIO_CloseDevice;
8419
8420#if MACOSX_COREAUDIO
8421 impl->DetectDevices = COREAUDIO_DetectDevices;
8422#else
8423 impl->OnlyHasDefaultOutputDevice = 1;
8424
8425 AudioSessionInitialize(NULL, NULL, NULL, nil);
8426 UInt32 category = kAudioSessionCategory_AmbientSound;
8427 AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
8428#endif
8429
8430 impl->ProvidesOwnCallbackThread = 1;
8431
8432 return 1;
8433}
8434
8435AudioBootStrap COREAUDIO_bootstrap = {
8436 "coreaudio", "CoreAudio", COREAUDIO_Init, 0
8437};
8438
8439#endif
8440#if SDL_AUDIO_DRIVER_DSOUND
8441
8442#ifndef _SDL_directsound_h
8443#define _SDL_directsound_h
8444
8445#ifndef _directx_h
8446#define _directx_h
8447
8448#include <mmsystem.h>
8449#ifndef WIN32
8450#define WIN32
8451#endif
8452#undef WINNT
8453
8454#ifndef FAR
8455#define FAR
8456#endif
8457
8458#ifndef MAKE_HRESULT
8459#define MAKE_HRESULT(sev,fac,code) \
8460 ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))))
8461#endif
8462
8463#ifndef S_OK
8464#define S_OK (HRESULT)0x00000000L
8465#endif
8466
8467#ifndef SUCCEEDED
8468#define SUCCEEDED(x) ((HRESULT)(x) >= 0)
8469#endif
8470#ifndef FAILED
8471#define FAILED(x) ((HRESULT)(x)<0)
8472#endif
8473
8474#ifndef E_FAIL
8475#define E_FAIL (HRESULT)0x80000008L
8476#endif
8477#ifndef E_NOINTERFACE
8478#define E_NOINTERFACE (HRESULT)0x80004002L
8479#endif
8480#ifndef E_OUTOFMEMORY
8481#define E_OUTOFMEMORY (HRESULT)0x8007000EL
8482#endif
8483#ifndef E_INVALIDARG
8484#define E_INVALIDARG (HRESULT)0x80070057L
8485#endif
8486#ifndef E_NOTIMPL
8487#define E_NOTIMPL (HRESULT)0x80004001L
8488#endif
8489#ifndef REGDB_E_CLASSNOTREG
8490#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L
8491#endif
8492
8493#ifndef SEVERITY_ERROR
8494#define SEVERITY_ERROR 1
8495#endif
8496
8497#ifndef FACILITY_WIN32
8498#define FACILITY_WIN32 7
8499#endif
8500
8501#ifndef FIELD_OFFSET
8502#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
8503#endif
8504
8505#define DIRECTDRAW_VERSION 0x0700
8506#define DIRECTSOUND_VERSION 0x0800
8507#define DIRECTINPUT_VERSION 0x0500
8508
8509#include <ddraw.h>
8510#define COM_NO_WINDOWS_H
8511#include <objbase.h>
8512#include <float.h>
8513
8514#ifndef DIRECTSOUND_VERSION
8515#define DIRECTSOUND_VERSION 0x0800
8516#endif
8517
8518#ifdef __cplusplus
8519extern "C" {
8520#endif
8521
8522#ifndef __DSOUND_INCLUDED__
8523#define __DSOUND_INCLUDED__
8524
8525#ifndef DX_SHARED_DEFINES
8526
8527typedef float D3DVALUE, *LPD3DVALUE;
8528
8529#ifndef D3DCOLOR_DEFINED
8530typedef DWORD D3DCOLOR;
8531#define D3DCOLOR_DEFINED
8532#endif
8533
8534#ifndef LPD3DCOLOR_DEFINED
8535typedef DWORD *LPD3DCOLOR;
8536#define LPD3DCOLOR_DEFINED
8537#endif
8538
8539#ifndef D3DVECTOR_DEFINED
8540typedef struct _D3DVECTOR {
8541 float x;
8542 float y;
8543 float z;
8544} D3DVECTOR;
8545#define D3DVECTOR_DEFINED
8546#endif
8547
8548#ifndef LPD3DVECTOR_DEFINED
8549typedef D3DVECTOR *LPD3DVECTOR;
8550#define LPD3DVECTOR_DEFINED
8551#endif
8552
8553#define DX_SHARED_DEFINES
8554#endif
8555
8556#define _FACDS 0x878
8557#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code)
8558
8559DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
8560
8561DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b);
8562
8563DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
8564
8565DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1);
8566
8567DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d);
8568
8569DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03);
8570
8571DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03);
8572
8573DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03);
8574
8575DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03);
8576
8577#ifdef __cplusplus
8578struct IDirectSound;
8579struct IDirectSoundBuffer;
8580struct IDirectSound3DListener;
8581struct IDirectSound3DBuffer;
8582struct IDirectSoundCapture;
8583struct IDirectSoundCaptureBuffer;
8584struct IDirectSoundNotify;
8585#endif
8586
8587#if DIRECTSOUND_VERSION >= 0x0800
8588
8589#ifdef __cplusplus
8590struct IDirectSound8;
8591struct IDirectSoundBuffer8;
8592struct IDirectSoundCaptureBuffer8;
8593struct IDirectSoundFXGargle;
8594struct IDirectSoundFXChorus;
8595struct IDirectSoundFXFlanger;
8596struct IDirectSoundFXEcho;
8597struct IDirectSoundFXDistortion;
8598struct IDirectSoundFXCompressor;
8599struct IDirectSoundFXParamEq;
8600struct IDirectSoundFXWavesReverb;
8601struct IDirectSoundFXI3DL2Reverb;
8602struct IDirectSoundCaptureFXAec;
8603struct IDirectSoundCaptureFXNoiseSuppress;
8604struct IDirectSoundFullDuplex;
8605#endif
8606
8607#define IDirectSoundCapture8 IDirectSoundCapture
8608#define IDirectSound3DListener8 IDirectSound3DListener
8609#define IDirectSound3DBuffer8 IDirectSound3DBuffer
8610#define IDirectSoundNotify8 IDirectSoundNotify
8611#define IDirectSoundFXGargle8 IDirectSoundFXGargle
8612#define IDirectSoundFXChorus8 IDirectSoundFXChorus
8613#define IDirectSoundFXFlanger8 IDirectSoundFXFlanger
8614#define IDirectSoundFXEcho8 IDirectSoundFXEcho
8615#define IDirectSoundFXDistortion8 IDirectSoundFXDistortion
8616#define IDirectSoundFXCompressor8 IDirectSoundFXCompressor
8617#define IDirectSoundFXParamEq8 IDirectSoundFXParamEq
8618#define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb
8619#define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb
8620#define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec
8621#define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress
8622#define IDirectSoundFullDuplex8 IDirectSoundFullDuplex
8623
8624#endif
8625
8626typedef struct IDirectSound *LPDIRECTSOUND;
8627typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
8628typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER;
8629typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER;
8630typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE;
8631typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER;
8632typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY;
8633
8634#if DIRECTSOUND_VERSION >= 0x0800
8635typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE;
8636typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS;
8637typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER;
8638typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO;
8639typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION;
8640typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR;
8641typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ;
8642typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB;
8643typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB;
8644typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC;
8645typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS;
8646typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX;
8647
8648typedef struct IDirectSound8 *LPDIRECTSOUND8;
8649typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8;
8650typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8;
8651typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8;
8652typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8;
8653typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8;
8654typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8;
8655typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8;
8656typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8;
8657typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8;
8658typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8;
8659typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8;
8660typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8;
8661typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8;
8662typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8;
8663typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8;
8664typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8;
8665typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8;
8666typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8;
8667
8668#endif
8669
8670#if DIRECTSOUND_VERSION >= 0x0800
8671#define IID_IDirectSoundCapture8 IID_IDirectSoundCapture
8672#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener
8673#define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer
8674#define IID_IDirectSoundNotify8 IID_IDirectSoundNotify
8675#define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle
8676#define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus
8677#define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger
8678#define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho
8679#define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion
8680#define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor
8681#define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq
8682#define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb
8683#define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb
8684#define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec
8685#define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress
8686#define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex
8687#endif
8688
8689#ifndef _LPCWAVEFORMATEX_DEFINED
8690#define _LPCWAVEFORMATEX_DEFINED
8691typedef const WAVEFORMATEX *LPCWAVEFORMATEX;
8692#endif
8693
8694#ifndef __LPCGUID_DEFINED__
8695#define __LPCGUID_DEFINED__
8696typedef const GUID *LPCGUID;
8697#endif
8698
8699typedef LPDIRECTSOUND *LPLPDIRECTSOUND;
8700typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER;
8701typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER;
8702typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER;
8703typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE;
8704typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER;
8705typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY;
8706
8707#if DIRECTSOUND_VERSION >= 0x0800
8708typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8;
8709typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8;
8710typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8;
8711typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8;
8712#endif
8713
8714typedef struct _DSCAPS
8715{
8716 DWORD dwSize;
8717 DWORD dwFlags;
8718 DWORD dwMinSecondarySampleRate;
8719 DWORD dwMaxSecondarySampleRate;
8720 DWORD dwPrimaryBuffers;
8721 DWORD dwMaxHwMixingAllBuffers;
8722 DWORD dwMaxHwMixingStaticBuffers;
8723 DWORD dwMaxHwMixingStreamingBuffers;
8724 DWORD dwFreeHwMixingAllBuffers;
8725 DWORD dwFreeHwMixingStaticBuffers;
8726 DWORD dwFreeHwMixingStreamingBuffers;
8727 DWORD dwMaxHw3DAllBuffers;
8728 DWORD dwMaxHw3DStaticBuffers;
8729 DWORD dwMaxHw3DStreamingBuffers;
8730 DWORD dwFreeHw3DAllBuffers;
8731 DWORD dwFreeHw3DStaticBuffers;
8732 DWORD dwFreeHw3DStreamingBuffers;
8733 DWORD dwTotalHwMemBytes;
8734 DWORD dwFreeHwMemBytes;
8735 DWORD dwMaxContigFreeHwMemBytes;
8736 DWORD dwUnlockTransferRateHwBuffers;
8737 DWORD dwPlayCpuOverheadSwBuffers;
8738 DWORD dwReserved1;
8739 DWORD dwReserved2;
8740} DSCAPS, *LPDSCAPS;
8741
8742typedef const DSCAPS *LPCDSCAPS;
8743
8744typedef struct _DSBCAPS
8745{
8746 DWORD dwSize;
8747 DWORD dwFlags;
8748 DWORD dwBufferBytes;
8749 DWORD dwUnlockTransferRate;
8750 DWORD dwPlayCpuOverhead;
8751} DSBCAPS, *LPDSBCAPS;
8752
8753typedef const DSBCAPS *LPCDSBCAPS;
8754
8755#if DIRECTSOUND_VERSION >= 0x0800
8756
8757 typedef struct _DSEFFECTDESC
8758 {
8759 DWORD dwSize;
8760 DWORD dwFlags;
8761 GUID guidDSFXClass;
8762 DWORD dwReserved1;
8763 DWORD dwReserved2;
8764 } DSEFFECTDESC, *LPDSEFFECTDESC;
8765 typedef const DSEFFECTDESC *LPCDSEFFECTDESC;
8766
8767 #define DSFX_LOCHARDWARE 0x00000001
8768 #define DSFX_LOCSOFTWARE 0x00000002
8769
8770 enum
8771 {
8772 DSFXR_PRESENT,
8773 DSFXR_LOCHARDWARE,
8774 DSFXR_LOCSOFTWARE,
8775 DSFXR_UNALLOCATED,
8776 DSFXR_FAILED,
8777 DSFXR_UNKNOWN,
8778 DSFXR_SENDLOOP
8779 };
8780
8781 typedef struct _DSCEFFECTDESC
8782 {
8783 DWORD dwSize;
8784 DWORD dwFlags;
8785 GUID guidDSCFXClass;
8786 GUID guidDSCFXInstance;
8787 DWORD dwReserved1;
8788 DWORD dwReserved2;
8789 } DSCEFFECTDESC, *LPDSCEFFECTDESC;
8790 typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC;
8791
8792 #define DSCFX_LOCHARDWARE 0x00000001
8793 #define DSCFX_LOCSOFTWARE 0x00000002
8794
8795 #define DSCFXR_LOCHARDWARE 0x00000010
8796 #define DSCFXR_LOCSOFTWARE 0x00000020
8797 #define DSCFXR_UNALLOCATED 0x00000040
8798 #define DSCFXR_FAILED 0x00000080
8799 #define DSCFXR_UNKNOWN 0x00000100
8800
8801#endif
8802
8803typedef struct _DSBUFFERDESC
8804{
8805 DWORD dwSize;
8806 DWORD dwFlags;
8807 DWORD dwBufferBytes;
8808 DWORD dwReserved;
8809 LPWAVEFORMATEX lpwfxFormat;
8810#if DIRECTSOUND_VERSION >= 0x0700
8811 GUID guid3DAlgorithm;
8812#endif
8813} DSBUFFERDESC, *LPDSBUFFERDESC;
8814
8815typedef const DSBUFFERDESC *LPCDSBUFFERDESC;
8816
8817typedef struct _DSBUFFERDESC1
8818{
8819 DWORD dwSize;
8820 DWORD dwFlags;
8821 DWORD dwBufferBytes;
8822 DWORD dwReserved;
8823 LPWAVEFORMATEX lpwfxFormat;
8824} DSBUFFERDESC1, *LPDSBUFFERDESC1;
8825
8826typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1;
8827
8828typedef struct _DS3DBUFFER
8829{
8830 DWORD dwSize;
8831 D3DVECTOR vPosition;
8832 D3DVECTOR vVelocity;
8833 DWORD dwInsideConeAngle;
8834 DWORD dwOutsideConeAngle;
8835 D3DVECTOR vConeOrientation;
8836 LONG lConeOutsideVolume;
8837 D3DVALUE flMinDistance;
8838 D3DVALUE flMaxDistance;
8839 DWORD dwMode;
8840} DS3DBUFFER, *LPDS3DBUFFER;
8841
8842typedef const DS3DBUFFER *LPCDS3DBUFFER;
8843
8844typedef struct _DS3DLISTENER
8845{
8846 DWORD dwSize;
8847 D3DVECTOR vPosition;
8848 D3DVECTOR vVelocity;
8849 D3DVECTOR vOrientFront;
8850 D3DVECTOR vOrientTop;
8851 D3DVALUE flDistanceFactor;
8852 D3DVALUE flRolloffFactor;
8853 D3DVALUE flDopplerFactor;
8854} DS3DLISTENER, *LPDS3DLISTENER;
8855
8856typedef const DS3DLISTENER *LPCDS3DLISTENER;
8857
8858typedef struct _DSCCAPS
8859{
8860 DWORD dwSize;
8861 DWORD dwFlags;
8862 DWORD dwFormats;
8863 DWORD dwChannels;
8864} DSCCAPS, *LPDSCCAPS;
8865
8866typedef const DSCCAPS *LPCDSCCAPS;
8867
8868typedef struct _DSCBUFFERDESC1
8869{
8870 DWORD dwSize;
8871 DWORD dwFlags;
8872 DWORD dwBufferBytes;
8873 DWORD dwReserved;
8874 LPWAVEFORMATEX lpwfxFormat;
8875} DSCBUFFERDESC1, *LPDSCBUFFERDESC1;
8876
8877typedef struct _DSCBUFFERDESC
8878{
8879 DWORD dwSize;
8880 DWORD dwFlags;
8881 DWORD dwBufferBytes;
8882 DWORD dwReserved;
8883 LPWAVEFORMATEX lpwfxFormat;
8884#if DIRECTSOUND_VERSION >= 0x0800
8885 DWORD dwFXCount;
8886 LPDSCEFFECTDESC lpDSCFXDesc;
8887#endif
8888} DSCBUFFERDESC, *LPDSCBUFFERDESC;
8889
8890typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC;
8891
8892typedef struct _DSCBCAPS
8893{
8894 DWORD dwSize;
8895 DWORD dwFlags;
8896 DWORD dwBufferBytes;
8897 DWORD dwReserved;
8898} DSCBCAPS, *LPDSCBCAPS;
8899
8900typedef const DSCBCAPS *LPCDSCBCAPS;
8901
8902typedef struct _DSBPOSITIONNOTIFY
8903{
8904 DWORD dwOffset;
8905 HANDLE hEventNotify;
8906} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY;
8907
8908typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY;
8909
8910typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID);
8911typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID);
8912
8913extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
8914extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext);
8915extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);
8916
8917extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter);
8918extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext);
8919extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);
8920
8921#if DIRECTSOUND_VERSION >= 0x0800
8922extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter);
8923extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter);
8924extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice,
8925 LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd,
8926 DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8,
8927 LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter);
8928#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate
8929
8930extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest);
8931#endif
8932
8933#ifdef UNICODE
8934#define LPDSENUMCALLBACK LPDSENUMCALLBACKW
8935#define DirectSoundEnumerate DirectSoundEnumerateW
8936#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW
8937#else
8938#define LPDSENUMCALLBACK LPDSENUMCALLBACKA
8939#define DirectSoundEnumerate DirectSoundEnumerateA
8940#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA
8941#endif
8942
8943#if !defined(__cplusplus) || defined(CINTERFACE)
8944#ifndef IUnknown_QueryInterface
8945#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
8946#endif
8947#ifndef IUnknown_AddRef
8948#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p)
8949#endif
8950#ifndef IUnknown_Release
8951#define IUnknown_Release(p) (p)->lpVtbl->Release(p)
8952#endif
8953#else
8954#ifndef IUnknown_QueryInterface
8955#define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
8956#endif
8957#ifndef IUnknown_AddRef
8958#define IUnknown_AddRef(p) (p)->AddRef()
8959#endif
8960#ifndef IUnknown_Release
8961#define IUnknown_Release(p) (p)->Release()
8962#endif
8963#endif
8964
8965#ifndef __IReferenceClock_INTERFACE_DEFINED__
8966#define __IReferenceClock_INTERFACE_DEFINED__
8967
8968typedef LONGLONG REFERENCE_TIME;
8969typedef REFERENCE_TIME *LPREFERENCE_TIME;
8970
8971DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70);
8972
8973#undef INTERFACE
8974#define INTERFACE IReferenceClock
8975
8976DECLARE_INTERFACE_(IReferenceClock, IUnknown)
8977{
8978
8979 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
8980 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
8981 STDMETHOD_(ULONG,Release) (THIS) PURE;
8982
8983 STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE;
8984 STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime,
8985 HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE;
8986 STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime,
8987 HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE;
8988 STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE;
8989};
8990
8991#endif
8992
8993#ifndef IReferenceClock_QueryInterface
8994
8995#define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
8996#define IReferenceClock_AddRef(p) IUnknown_AddRef(p)
8997#define IReferenceClock_Release(p) IUnknown_Release(p)
8998
8999#if !defined(__cplusplus) || defined(CINTERFACE)
9000#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a)
9001#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d)
9002#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d)
9003#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a)
9004#else
9005#define IReferenceClock_GetTime(p,a) (p)->GetTime(a)
9006#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d)
9007#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d)
9008#define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a)
9009#endif
9010
9011#endif
9012
9013DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
9014
9015#undef INTERFACE
9016#define INTERFACE IDirectSound
9017
9018DECLARE_INTERFACE_(IDirectSound, IUnknown)
9019{
9020
9021 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9022 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9023 STDMETHOD_(ULONG,Release) (THIS) PURE;
9024
9025 STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE;
9026 STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE;
9027 STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE;
9028 STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE;
9029 STDMETHOD(Compact) (THIS) PURE;
9030 STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE;
9031 STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE;
9032 STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE;
9033};
9034
9035#define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9036#define IDirectSound_AddRef(p) IUnknown_AddRef(p)
9037#define IDirectSound_Release(p) IUnknown_Release(p)
9038
9039#if !defined(__cplusplus) || defined(CINTERFACE)
9040#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c)
9041#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
9042#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b)
9043#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
9044#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p)
9045#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a)
9046#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b)
9047#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
9048#else
9049#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c)
9050#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a)
9051#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b)
9052#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
9053#define IDirectSound_Compact(p) (p)->Compact()
9054#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a)
9055#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b)
9056#define IDirectSound_Initialize(p,a) (p)->Initialize(a)
9057#endif
9058
9059#if DIRECTSOUND_VERSION >= 0x0800
9060
9061DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66);
9062
9063#undef INTERFACE
9064#define INTERFACE IDirectSound8
9065
9066DECLARE_INTERFACE_(IDirectSound8, IDirectSound)
9067{
9068
9069 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9070 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9071 STDMETHOD_(ULONG,Release) (THIS) PURE;
9072
9073 STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE;
9074 STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE;
9075 STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE;
9076 STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE;
9077 STDMETHOD(Compact) (THIS) PURE;
9078 STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE;
9079 STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE;
9080 STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE;
9081
9082 STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE;
9083};
9084
9085#define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b)
9086#define IDirectSound8_AddRef(p) IDirectSound_AddRef(p)
9087#define IDirectSound8_Release(p) IDirectSound_Release(p)
9088#define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c)
9089#define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a)
9090#define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b)
9091#define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b)
9092#define IDirectSound8_Compact(p) IDirectSound_Compact(p)
9093#define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a)
9094#define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a)
9095#define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a)
9096
9097#if !defined(__cplusplus) || defined(CINTERFACE)
9098#define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a)
9099#else
9100#define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a)
9101#endif
9102
9103#endif
9104
9105DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
9106
9107#undef INTERFACE
9108#define INTERFACE IDirectSoundBuffer
9109
9110DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown)
9111{
9112
9113 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9114 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9115 STDMETHOD_(ULONG,Release) (THIS) PURE;
9116
9117 STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE;
9118 STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE;
9119 STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE;
9120 STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE;
9121 STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE;
9122 STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE;
9123 STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE;
9124 STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE;
9125 STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
9126 LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
9127 STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE;
9128 STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE;
9129 STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE;
9130 STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE;
9131 STDMETHOD(SetPan) (THIS_ LONG lPan) PURE;
9132 STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE;
9133 STDMETHOD(Stop) (THIS) PURE;
9134 STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE;
9135 STDMETHOD(Restore) (THIS) PURE;
9136};
9137
9138#define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9139#define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p)
9140#define IDirectSoundBuffer_Release(p) IUnknown_Release(p)
9141
9142#if !defined(__cplusplus) || defined(CINTERFACE)
9143#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
9144#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b)
9145#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c)
9146#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a)
9147#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a)
9148#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a)
9149#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
9150#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
9151#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
9152#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c)
9153#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a)
9154#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a)
9155#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a)
9156#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a)
9157#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a)
9158#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p)
9159#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
9160#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p)
9161#else
9162#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a)
9163#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b)
9164#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c)
9165#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a)
9166#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a)
9167#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a)
9168#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a)
9169#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b)
9170#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g)
9171#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c)
9172#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a)
9173#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a)
9174#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a)
9175#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a)
9176#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a)
9177#define IDirectSoundBuffer_Stop(p) (p)->Stop()
9178#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d)
9179#define IDirectSoundBuffer_Restore(p) (p)->Restore()
9180#endif
9181
9182#if DIRECTSOUND_VERSION >= 0x0800
9183
9184DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e);
9185
9186#undef INTERFACE
9187#define INTERFACE IDirectSoundBuffer8
9188
9189DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer)
9190{
9191
9192 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9193 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9194 STDMETHOD_(ULONG,Release) (THIS) PURE;
9195
9196 STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE;
9197 STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE;
9198 STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE;
9199 STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE;
9200 STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE;
9201 STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE;
9202 STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE;
9203 STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE;
9204 STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
9205 LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
9206 STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE;
9207 STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE;
9208 STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE;
9209 STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE;
9210 STDMETHOD(SetPan) (THIS_ LONG lPan) PURE;
9211 STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE;
9212 STDMETHOD(Stop) (THIS) PURE;
9213 STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE;
9214 STDMETHOD(Restore) (THIS) PURE;
9215
9216 STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE;
9217 STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE;
9218 STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE;
9219};
9220
9221DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5);
9222
9223#define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9224#define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p)
9225#define IDirectSoundBuffer8_Release(p) IUnknown_Release(p)
9226
9227#define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a)
9228#define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b)
9229#define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c)
9230#define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a)
9231#define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a)
9232#define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a)
9233#define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a)
9234#define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b)
9235#define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g)
9236#define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c)
9237#define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a)
9238#define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a)
9239#define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a)
9240#define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a)
9241#define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a)
9242#define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p)
9243#define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d)
9244#define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p)
9245
9246#if !defined(__cplusplus) || defined(CINTERFACE)
9247#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c)
9248#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c)
9249#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d)
9250#else
9251#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c)
9252#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c)
9253#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d)
9254#endif
9255
9256#endif
9257
9258DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
9259
9260#undef INTERFACE
9261#define INTERFACE IDirectSound3DListener
9262
9263DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown)
9264{
9265
9266 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9267 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9268 STDMETHOD_(ULONG,Release) (THIS) PURE;
9269
9270 STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE;
9271 STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE;
9272 STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE;
9273 STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE;
9274 STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE;
9275 STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE;
9276 STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE;
9277 STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE;
9278 STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE;
9279 STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE;
9280 STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront,
9281 D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE;
9282 STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE;
9283 STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE;
9284 STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE;
9285 STDMETHOD(CommitDeferredSettings) (THIS) PURE;
9286};
9287
9288#define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9289#define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p)
9290#define IDirectSound3DListener_Release(p) IUnknown_Release(p)
9291
9292#if !defined(__cplusplus) || defined(CINTERFACE)
9293#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9294#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a)
9295#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a)
9296#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b)
9297#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
9298#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a)
9299#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
9300#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
9301#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b)
9302#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b)
9303#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g)
9304#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d)
9305#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b)
9306#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d)
9307#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p)
9308#else
9309#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a)
9310#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a)
9311#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a)
9312#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b)
9313#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a)
9314#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a)
9315#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a)
9316#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
9317#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b)
9318#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b)
9319#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g)
9320#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d)
9321#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b)
9322#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d)
9323#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings()
9324#endif
9325
9326DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
9327
9328#undef INTERFACE
9329#define INTERFACE IDirectSound3DBuffer
9330
9331DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown)
9332{
9333
9334 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9335 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9336 STDMETHOD_(ULONG,Release) (THIS) PURE;
9337
9338 STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE;
9339 STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE;
9340 STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE;
9341 STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE;
9342 STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE;
9343 STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE;
9344 STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE;
9345 STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE;
9346 STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE;
9347 STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE;
9348 STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE;
9349 STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE;
9350 STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE;
9351 STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE;
9352 STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE;
9353 STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE;
9354 STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE;
9355 STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE;
9356};
9357
9358#define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9359#define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p)
9360#define IDirectSound3DBuffer_Release(p) IUnknown_Release(p)
9361
9362#if !defined(__cplusplus) || defined(CINTERFACE)
9363#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9364#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b)
9365#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a)
9366#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a)
9367#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
9368#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a)
9369#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a)
9370#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a)
9371#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
9372#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
9373#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c)
9374#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d)
9375#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b)
9376#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d)
9377#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b)
9378#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b)
9379#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b)
9380#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d)
9381#else
9382#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a)
9383#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b)
9384#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a)
9385#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a)
9386#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a)
9387#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a)
9388#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a)
9389#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a)
9390#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a)
9391#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
9392#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c)
9393#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d)
9394#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b)
9395#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d)
9396#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b)
9397#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b)
9398#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b)
9399#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d)
9400#endif
9401
9402DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
9403
9404#undef INTERFACE
9405#define INTERFACE IDirectSoundCapture
9406
9407DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown)
9408{
9409
9410 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9411 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9412 STDMETHOD_(ULONG,Release) (THIS) PURE;
9413
9414 STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE;
9415 STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE;
9416 STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE;
9417};
9418
9419#define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9420#define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p)
9421#define IDirectSoundCapture_Release(p) IUnknown_Release(p)
9422
9423#if !defined(__cplusplus) || defined(CINTERFACE)
9424#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c)
9425#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
9426#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
9427#else
9428#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c)
9429#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a)
9430#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a)
9431#endif
9432
9433DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
9434
9435#undef INTERFACE
9436#define INTERFACE IDirectSoundCaptureBuffer
9437
9438DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown)
9439{
9440
9441 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9442 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9443 STDMETHOD_(ULONG,Release) (THIS) PURE;
9444
9445 STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE;
9446 STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE;
9447 STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE;
9448 STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE;
9449 STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE;
9450 STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
9451 LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
9452 STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE;
9453 STDMETHOD(Stop) (THIS) PURE;
9454 STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE;
9455};
9456
9457#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9458#define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p)
9459#define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p)
9460
9461#if !defined(__cplusplus) || defined(CINTERFACE)
9462#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
9463#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b)
9464#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c)
9465#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
9466#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
9467#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
9468#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a)
9469#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p)
9470#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
9471#else
9472#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a)
9473#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b)
9474#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c)
9475#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a)
9476#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b)
9477#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g)
9478#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a)
9479#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop()
9480#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d)
9481#endif
9482
9483#if DIRECTSOUND_VERSION >= 0x0800
9484
9485DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6);
9486
9487#undef INTERFACE
9488#define INTERFACE IDirectSoundCaptureBuffer8
9489
9490DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer)
9491{
9492
9493 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9494 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9495 STDMETHOD_(ULONG,Release) (THIS) PURE;
9496
9497 STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE;
9498 STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE;
9499 STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE;
9500 STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE;
9501 STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE;
9502 STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
9503 LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE;
9504 STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE;
9505 STDMETHOD(Stop) (THIS) PURE;
9506 STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE;
9507
9508 STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE;
9509 STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE;
9510};
9511
9512#define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9513#define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p)
9514#define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p)
9515
9516#define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a)
9517#define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b)
9518#define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c)
9519#define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a)
9520#define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b)
9521#define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g)
9522#define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a)
9523#define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p))
9524#define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d)
9525
9526#if !defined(__cplusplus) || defined(CINTERFACE)
9527#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d)
9528#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b)
9529#else
9530#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d)
9531#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b)
9532#endif
9533
9534#endif
9535
9536DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
9537
9538#undef INTERFACE
9539#define INTERFACE IDirectSoundNotify
9540
9541DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown)
9542{
9543
9544 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9545 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9546 STDMETHOD_(ULONG,Release) (THIS) PURE;
9547
9548 STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE;
9549};
9550
9551#define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9552#define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p)
9553#define IDirectSoundNotify_Release(p) IUnknown_Release(p)
9554
9555#if !defined(__cplusplus) || defined(CINTERFACE)
9556#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b)
9557#else
9558#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b)
9559#endif
9560
9561#ifndef _IKsPropertySet_
9562#define _IKsPropertySet_
9563
9564#ifdef __cplusplus
9565
9566struct IKsPropertySet;
9567#endif
9568
9569typedef struct IKsPropertySet *LPKSPROPERTYSET;
9570
9571#define KSPROPERTY_SUPPORT_GET 0x00000001
9572#define KSPROPERTY_SUPPORT_SET 0x00000002
9573
9574DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93);
9575
9576#undef INTERFACE
9577#define INTERFACE IKsPropertySet
9578
9579DECLARE_INTERFACE_(IKsPropertySet, IUnknown)
9580{
9581
9582 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9583 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9584 STDMETHOD_(ULONG,Release) (THIS) PURE;
9585
9586 STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength,
9587 LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE;
9588 STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength,
9589 LPVOID pPropertyData, ULONG ulDataLength) PURE;
9590 STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE;
9591};
9592
9593#define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9594#define IKsPropertySet_AddRef(p) IUnknown_AddRef(p)
9595#define IKsPropertySet_Release(p) IUnknown_Release(p)
9596
9597#if !defined(__cplusplus) || defined(CINTERFACE)
9598#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g)
9599#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f)
9600#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c)
9601#else
9602#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g)
9603#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f)
9604#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c)
9605#endif
9606
9607#endif
9608
9609#if DIRECTSOUND_VERSION >= 0x0800
9610
9611DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3);
9612
9613typedef struct _DSFXGargle
9614{
9615 DWORD dwRateHz;
9616 DWORD dwWaveShape;
9617} DSFXGargle, *LPDSFXGargle;
9618
9619#define DSFXGARGLE_WAVE_TRIANGLE 0
9620#define DSFXGARGLE_WAVE_SQUARE 1
9621
9622typedef const DSFXGargle *LPCDSFXGargle;
9623
9624#define DSFXGARGLE_RATEHZ_MIN 1
9625#define DSFXGARGLE_RATEHZ_MAX 1000
9626
9627#undef INTERFACE
9628#define INTERFACE IDirectSoundFXGargle
9629
9630DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown)
9631{
9632
9633 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9634 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9635 STDMETHOD_(ULONG,Release) (THIS) PURE;
9636
9637 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE;
9638 STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE;
9639};
9640
9641#define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9642#define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p)
9643#define IDirectSoundFXGargle_Release(p) IUnknown_Release(p)
9644
9645#if !defined(__cplusplus) || defined(CINTERFACE)
9646#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9647#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9648#else
9649#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a)
9650#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a)
9651#endif
9652
9653DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47);
9654
9655typedef struct _DSFXChorus
9656{
9657 FLOAT fWetDryMix;
9658 FLOAT fDepth;
9659 FLOAT fFeedback;
9660 FLOAT fFrequency;
9661 LONG lWaveform;
9662 FLOAT fDelay;
9663 LONG lPhase;
9664} DSFXChorus, *LPDSFXChorus;
9665
9666typedef const DSFXChorus *LPCDSFXChorus;
9667
9668#define DSFXCHORUS_WAVE_TRIANGLE 0
9669#define DSFXCHORUS_WAVE_SIN 1
9670
9671#define DSFXCHORUS_WETDRYMIX_MIN 0.0f
9672#define DSFXCHORUS_WETDRYMIX_MAX 100.0f
9673#define DSFXCHORUS_DEPTH_MIN 0.0f
9674#define DSFXCHORUS_DEPTH_MAX 100.0f
9675#define DSFXCHORUS_FEEDBACK_MIN -99.0f
9676#define DSFXCHORUS_FEEDBACK_MAX 99.0f
9677#define DSFXCHORUS_FREQUENCY_MIN 0.0f
9678#define DSFXCHORUS_FREQUENCY_MAX 10.0f
9679#define DSFXCHORUS_DELAY_MIN 0.0f
9680#define DSFXCHORUS_DELAY_MAX 20.0f
9681#define DSFXCHORUS_PHASE_MIN 0
9682#define DSFXCHORUS_PHASE_MAX 4
9683
9684#define DSFXCHORUS_PHASE_NEG_180 0
9685#define DSFXCHORUS_PHASE_NEG_90 1
9686#define DSFXCHORUS_PHASE_ZERO 2
9687#define DSFXCHORUS_PHASE_90 3
9688#define DSFXCHORUS_PHASE_180 4
9689
9690#undef INTERFACE
9691#define INTERFACE IDirectSoundFXChorus
9692
9693DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown)
9694{
9695
9696 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9697 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9698 STDMETHOD_(ULONG,Release) (THIS) PURE;
9699
9700 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE;
9701 STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE;
9702};
9703
9704#define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9705#define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p)
9706#define IDirectSoundFXChorus_Release(p) IUnknown_Release(p)
9707
9708#if !defined(__cplusplus) || defined(CINTERFACE)
9709#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9710#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9711#else
9712#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a)
9713#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a)
9714#endif
9715
9716DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83);
9717
9718typedef struct _DSFXFlanger
9719{
9720 FLOAT fWetDryMix;
9721 FLOAT fDepth;
9722 FLOAT fFeedback;
9723 FLOAT fFrequency;
9724 LONG lWaveform;
9725 FLOAT fDelay;
9726 LONG lPhase;
9727} DSFXFlanger, *LPDSFXFlanger;
9728
9729typedef const DSFXFlanger *LPCDSFXFlanger;
9730
9731#define DSFXFLANGER_WAVE_TRIANGLE 0
9732#define DSFXFLANGER_WAVE_SIN 1
9733
9734#define DSFXFLANGER_WETDRYMIX_MIN 0.0f
9735#define DSFXFLANGER_WETDRYMIX_MAX 100.0f
9736#define DSFXFLANGER_FREQUENCY_MIN 0.0f
9737#define DSFXFLANGER_FREQUENCY_MAX 10.0f
9738#define DSFXFLANGER_DEPTH_MIN 0.0f
9739#define DSFXFLANGER_DEPTH_MAX 100.0f
9740#define DSFXFLANGER_PHASE_MIN 0
9741#define DSFXFLANGER_PHASE_MAX 4
9742#define DSFXFLANGER_FEEDBACK_MIN -99.0f
9743#define DSFXFLANGER_FEEDBACK_MAX 99.0f
9744#define DSFXFLANGER_DELAY_MIN 0.0f
9745#define DSFXFLANGER_DELAY_MAX 4.0f
9746
9747#define DSFXFLANGER_PHASE_NEG_180 0
9748#define DSFXFLANGER_PHASE_NEG_90 1
9749#define DSFXFLANGER_PHASE_ZERO 2
9750#define DSFXFLANGER_PHASE_90 3
9751#define DSFXFLANGER_PHASE_180 4
9752
9753#undef INTERFACE
9754#define INTERFACE IDirectSoundFXFlanger
9755
9756DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown)
9757{
9758
9759 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9760 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9761 STDMETHOD_(ULONG,Release) (THIS) PURE;
9762
9763 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE;
9764 STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE;
9765};
9766
9767#define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9768#define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p)
9769#define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p)
9770
9771#if !defined(__cplusplus) || defined(CINTERFACE)
9772#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9773#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9774#else
9775#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a)
9776#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a)
9777#endif
9778
9779DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42);
9780
9781typedef struct _DSFXEcho
9782{
9783 FLOAT fWetDryMix;
9784 FLOAT fFeedback;
9785 FLOAT fLeftDelay;
9786 FLOAT fRightDelay;
9787 LONG lPanDelay;
9788} DSFXEcho, *LPDSFXEcho;
9789
9790typedef const DSFXEcho *LPCDSFXEcho;
9791
9792#define DSFXECHO_WETDRYMIX_MIN 0.0f
9793#define DSFXECHO_WETDRYMIX_MAX 100.0f
9794#define DSFXECHO_FEEDBACK_MIN 0.0f
9795#define DSFXECHO_FEEDBACK_MAX 100.0f
9796#define DSFXECHO_LEFTDELAY_MIN 1.0f
9797#define DSFXECHO_LEFTDELAY_MAX 2000.0f
9798#define DSFXECHO_RIGHTDELAY_MIN 1.0f
9799#define DSFXECHO_RIGHTDELAY_MAX 2000.0f
9800#define DSFXECHO_PANDELAY_MIN 0
9801#define DSFXECHO_PANDELAY_MAX 1
9802
9803#undef INTERFACE
9804#define INTERFACE IDirectSoundFXEcho
9805
9806DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown)
9807{
9808
9809 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9810 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9811 STDMETHOD_(ULONG,Release) (THIS) PURE;
9812
9813 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE;
9814 STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE;
9815};
9816
9817#define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9818#define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p)
9819#define IDirectSoundFXEcho_Release(p) IUnknown_Release(p)
9820
9821#if !defined(__cplusplus) || defined(CINTERFACE)
9822#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9823#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9824#else
9825#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a)
9826#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a)
9827#endif
9828
9829DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b);
9830
9831typedef struct _DSFXDistortion
9832{
9833 FLOAT fGain;
9834 FLOAT fEdge;
9835 FLOAT fPostEQCenterFrequency;
9836 FLOAT fPostEQBandwidth;
9837 FLOAT fPreLowpassCutoff;
9838} DSFXDistortion, *LPDSFXDistortion;
9839
9840typedef const DSFXDistortion *LPCDSFXDistortion;
9841
9842#define DSFXDISTORTION_GAIN_MIN -60.0f
9843#define DSFXDISTORTION_GAIN_MAX 0.0f
9844#define DSFXDISTORTION_EDGE_MIN 0.0f
9845#define DSFXDISTORTION_EDGE_MAX 100.0f
9846#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f
9847#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f
9848#define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f
9849#define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f
9850#define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f
9851#define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f
9852
9853#undef INTERFACE
9854#define INTERFACE IDirectSoundFXDistortion
9855
9856DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown)
9857{
9858
9859 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9860 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9861 STDMETHOD_(ULONG,Release) (THIS) PURE;
9862
9863 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE;
9864 STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE;
9865};
9866
9867#define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9868#define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p)
9869#define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p)
9870
9871#if !defined(__cplusplus) || defined(CINTERFACE)
9872#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9873#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9874#else
9875#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a)
9876#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a)
9877#endif
9878
9879DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0);
9880
9881typedef struct _DSFXCompressor
9882{
9883 FLOAT fGain;
9884 FLOAT fAttack;
9885 FLOAT fRelease;
9886 FLOAT fThreshold;
9887 FLOAT fRatio;
9888 FLOAT fPredelay;
9889} DSFXCompressor, *LPDSFXCompressor;
9890
9891typedef const DSFXCompressor *LPCDSFXCompressor;
9892
9893#define DSFXCOMPRESSOR_GAIN_MIN -60.0f
9894#define DSFXCOMPRESSOR_GAIN_MAX 60.0f
9895#define DSFXCOMPRESSOR_ATTACK_MIN 0.01f
9896#define DSFXCOMPRESSOR_ATTACK_MAX 500.0f
9897#define DSFXCOMPRESSOR_RELEASE_MIN 50.0f
9898#define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f
9899#define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f
9900#define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f
9901#define DSFXCOMPRESSOR_RATIO_MIN 1.0f
9902#define DSFXCOMPRESSOR_RATIO_MAX 100.0f
9903#define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f
9904#define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f
9905
9906#undef INTERFACE
9907#define INTERFACE IDirectSoundFXCompressor
9908
9909DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown)
9910{
9911
9912 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9913 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9914 STDMETHOD_(ULONG,Release) (THIS) PURE;
9915
9916 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE;
9917 STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE;
9918};
9919
9920#define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9921#define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p)
9922#define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p)
9923
9924#if !defined(__cplusplus) || defined(CINTERFACE)
9925#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9926#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9927#else
9928#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a)
9929#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a)
9930#endif
9931
9932DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda);
9933
9934typedef struct _DSFXParamEq
9935{
9936 FLOAT fCenter;
9937 FLOAT fBandwidth;
9938 FLOAT fGain;
9939} DSFXParamEq, *LPDSFXParamEq;
9940
9941typedef const DSFXParamEq *LPCDSFXParamEq;
9942
9943#define DSFXPARAMEQ_CENTER_MIN 80.0f
9944#define DSFXPARAMEQ_CENTER_MAX 16000.0f
9945#define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f
9946#define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f
9947#define DSFXPARAMEQ_GAIN_MIN -15.0f
9948#define DSFXPARAMEQ_GAIN_MAX 15.0f
9949
9950#undef INTERFACE
9951#define INTERFACE IDirectSoundFXParamEq
9952
9953DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown)
9954{
9955
9956 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
9957 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
9958 STDMETHOD_(ULONG,Release) (THIS) PURE;
9959
9960 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE;
9961 STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE;
9962};
9963
9964#define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
9965#define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p)
9966#define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p)
9967
9968#if !defined(__cplusplus) || defined(CINTERFACE)
9969#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
9970#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
9971#else
9972#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a)
9973#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a)
9974#endif
9975
9976DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4);
9977
9978typedef struct _DSFXI3DL2Reverb
9979{
9980 LONG lRoom;
9981 LONG lRoomHF;
9982 FLOAT flRoomRolloffFactor;
9983 FLOAT flDecayTime;
9984 FLOAT flDecayHFRatio;
9985 LONG lReflections;
9986 FLOAT flReflectionsDelay;
9987 LONG lReverb;
9988 FLOAT flReverbDelay;
9989 FLOAT flDiffusion;
9990 FLOAT flDensity;
9991 FLOAT flHFReference;
9992} DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb;
9993
9994typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb;
9995
9996#define DSFX_I3DL2REVERB_ROOM_MIN (-10000)
9997#define DSFX_I3DL2REVERB_ROOM_MAX 0
9998#define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000)
9999
10000#define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000)
10001#define DSFX_I3DL2REVERB_ROOMHF_MAX 0
10002#define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100)
10003
10004#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f
10005#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f
10006#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f
10007
10008#define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f
10009#define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f
10010#define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f
10011
10012#define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f
10013#define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f
10014#define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f
10015
10016#define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000)
10017#define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000
10018#define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602)
10019
10020#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f
10021#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f
10022#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f
10023
10024#define DSFX_I3DL2REVERB_REVERB_MIN (-10000)
10025#define DSFX_I3DL2REVERB_REVERB_MAX 2000
10026#define DSFX_I3DL2REVERB_REVERB_DEFAULT (200)
10027
10028#define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f
10029#define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f
10030#define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f
10031
10032#define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f
10033#define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f
10034#define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f
10035
10036#define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f
10037#define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f
10038#define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f
10039
10040#define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f
10041#define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f
10042#define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f
10043
10044#define DSFX_I3DL2REVERB_QUALITY_MIN 0
10045#define DSFX_I3DL2REVERB_QUALITY_MAX 3
10046#define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2
10047
10048#undef INTERFACE
10049#define INTERFACE IDirectSoundFXI3DL2Reverb
10050
10051DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown)
10052{
10053
10054 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
10055 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
10056 STDMETHOD_(ULONG,Release) (THIS) PURE;
10057
10058 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE;
10059 STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE;
10060 STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE;
10061 STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE;
10062 STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE;
10063 STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE;
10064};
10065
10066#define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
10067#define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p)
10068#define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p)
10069
10070#if !defined(__cplusplus) || defined(CINTERFACE)
10071#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
10072#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
10073#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a)
10074#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a)
10075#else
10076#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a)
10077#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a)
10078#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a)
10079#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a)
10080#endif
10081
10082DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25);
10083
10084typedef struct _DSFXWavesReverb
10085{
10086 FLOAT fInGain;
10087 FLOAT fReverbMix;
10088 FLOAT fReverbTime;
10089 FLOAT fHighFreqRTRatio;
10090} DSFXWavesReverb, *LPDSFXWavesReverb;
10091
10092typedef const DSFXWavesReverb *LPCDSFXWavesReverb;
10093
10094#define DSFX_WAVESREVERB_INGAIN_MIN -96.0f
10095#define DSFX_WAVESREVERB_INGAIN_MAX 0.0f
10096#define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f
10097#define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f
10098#define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f
10099#define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f
10100#define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f
10101#define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f
10102#define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f
10103#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f
10104#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f
10105#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f
10106
10107#undef INTERFACE
10108#define INTERFACE IDirectSoundFXWavesReverb
10109
10110DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown)
10111{
10112
10113 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
10114 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
10115 STDMETHOD_(ULONG,Release) (THIS) PURE;
10116
10117 STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE;
10118 STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE;
10119};
10120
10121#define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
10122#define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p)
10123#define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p)
10124
10125#if !defined(__cplusplus) || defined(CINTERFACE)
10126#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
10127#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
10128#else
10129#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a)
10130#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a)
10131#endif
10132
10133DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0x174d3eb9, 0x6696, 0x4fac, 0xa4, 0x6c, 0xa0, 0xac, 0x7b, 0xc9, 0xe2, 0xf);
10134
10135typedef struct _DSCFXAec
10136{
10137 BOOL fEnable;
10138 BOOL fReset;
10139} DSCFXAec, *LPDSCFXAec;
10140
10141typedef const DSCFXAec *LPCDSCFXAec;
10142
10143#undef INTERFACE
10144#define INTERFACE IDirectSoundCaptureFXAec
10145
10146DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown)
10147{
10148
10149 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
10150 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
10151 STDMETHOD_(ULONG,Release) (THIS) PURE;
10152
10153 STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE;
10154 STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE;
10155};
10156
10157#define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
10158#define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p)
10159#define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p)
10160
10161#if !defined(__cplusplus) || defined(CINTERFACE)
10162#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
10163#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
10164#else
10165#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a)
10166#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a)
10167#endif
10168
10169DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca);
10170
10171typedef struct _DSCFXNoiseSuppress
10172{
10173 BOOL fEnable;
10174 BOOL fReset;
10175} DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress;
10176
10177typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress;
10178
10179#undef INTERFACE
10180#define INTERFACE IDirectSoundCaptureFXNoiseSuppress
10181
10182DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown)
10183{
10184
10185 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
10186 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
10187 STDMETHOD_(ULONG,Release) (THIS) PURE;
10188
10189 STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE;
10190 STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE;
10191};
10192
10193#define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
10194#define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p)
10195#define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p)
10196
10197#if !defined(__cplusplus) || defined(CINTERFACE)
10198#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a)
10199#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
10200#else
10201#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a)
10202#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a)
10203#endif
10204
10205#ifndef _IDirectSoundFullDuplex_
10206#define _IDirectSoundFullDuplex_
10207
10208#ifdef __cplusplus
10209
10210struct IDirectSoundFullDuplex;
10211#endif
10212
10213typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX;
10214
10215DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d);
10216
10217#undef INTERFACE
10218#define INTERFACE IDirectSoundFullDuplex
10219
10220DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown)
10221{
10222
10223 STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
10224 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
10225 STDMETHOD_(ULONG,Release) (THIS) PURE;
10226
10227 STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE;
10228};
10229
10230#define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b)
10231#define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p)
10232#define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p)
10233
10234#if !defined(__cplusplus) || defined(CINTERFACE)
10235#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h)
10236#else
10237#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h)
10238#endif
10239
10240#endif
10241
10242#endif
10243
10244#define DS_OK S_OK
10245
10246#define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10)
10247
10248#define DS_INCOMPLETE MAKE_HRESULT(0, _FACDS, 20)
10249
10250#define DSERR_ALLOCATED MAKE_DSHRESULT(10)
10251
10252#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30)
10253
10254#define DSERR_INVALIDPARAM E_INVALIDARG
10255
10256#define DSERR_INVALIDCALL MAKE_DSHRESULT(50)
10257
10258#define DSERR_GENERIC E_FAIL
10259
10260#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70)
10261
10262#define DSERR_OUTOFMEMORY E_OUTOFMEMORY
10263
10264#define DSERR_BADFORMAT MAKE_DSHRESULT(100)
10265
10266#define DSERR_UNSUPPORTED E_NOTIMPL
10267
10268#define DSERR_NODRIVER MAKE_DSHRESULT(120)
10269
10270#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130)
10271
10272#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION
10273
10274#define DSERR_BUFFERLOST MAKE_DSHRESULT(150)
10275
10276#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160)
10277
10278#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170)
10279
10280#define DSERR_NOINTERFACE E_NOINTERFACE
10281
10282#define DSERR_ACCESSDENIED E_ACCESSDENIED
10283
10284#define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180)
10285
10286#define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190)
10287
10288#define DSERR_SENDLOOP MAKE_DSHRESULT(200)
10289
10290#define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210)
10291
10292#define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449)
10293
10294#define DSCAPS_PRIMARYMONO 0x00000001
10295#define DSCAPS_PRIMARYSTEREO 0x00000002
10296#define DSCAPS_PRIMARY8BIT 0x00000004
10297#define DSCAPS_PRIMARY16BIT 0x00000008
10298#define DSCAPS_CONTINUOUSRATE 0x00000010
10299#define DSCAPS_EMULDRIVER 0x00000020
10300#define DSCAPS_CERTIFIED 0x00000040
10301#define DSCAPS_SECONDARYMONO 0x00000100
10302#define DSCAPS_SECONDARYSTEREO 0x00000200
10303#define DSCAPS_SECONDARY8BIT 0x00000400
10304#define DSCAPS_SECONDARY16BIT 0x00000800
10305
10306#define DSSCL_NORMAL 0x00000001
10307#define DSSCL_PRIORITY 0x00000002
10308#define DSSCL_EXCLUSIVE 0x00000003
10309#define DSSCL_WRITEPRIMARY 0x00000004
10310
10311#define DSSPEAKER_HEADPHONE 0x00000001
10312#define DSSPEAKER_MONO 0x00000002
10313#define DSSPEAKER_QUAD 0x00000003
10314#define DSSPEAKER_STEREO 0x00000004
10315#define DSSPEAKER_SURROUND 0x00000005
10316#define DSSPEAKER_5POINT1 0x00000006
10317
10318#define DSSPEAKER_GEOMETRY_MIN 0x00000005
10319#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A
10320#define DSSPEAKER_GEOMETRY_WIDE 0x00000014
10321#define DSSPEAKER_GEOMETRY_MAX 0x000000B4
10322
10323#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16))
10324#define DSSPEAKER_CONFIG(a) ((BYTE)(a))
10325#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF))
10326
10327#define DSBCAPS_PRIMARYBUFFER 0x00000001
10328#define DSBCAPS_STATIC 0x00000002
10329#define DSBCAPS_LOCHARDWARE 0x00000004
10330#define DSBCAPS_LOCSOFTWARE 0x00000008
10331#define DSBCAPS_CTRL3D 0x00000010
10332#define DSBCAPS_CTRLFREQUENCY 0x00000020
10333#define DSBCAPS_CTRLPAN 0x00000040
10334#define DSBCAPS_CTRLVOLUME 0x00000080
10335#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100
10336#define DSBCAPS_CTRLFX 0x00000200
10337#define DSBCAPS_STICKYFOCUS 0x00004000
10338#define DSBCAPS_GLOBALFOCUS 0x00008000
10339#define DSBCAPS_GETCURRENTPOSITION2 0x00010000
10340#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000
10341#define DSBCAPS_LOCDEFER 0x00040000
10342
10343#define DSBPLAY_LOOPING 0x00000001
10344#define DSBPLAY_LOCHARDWARE 0x00000002
10345#define DSBPLAY_LOCSOFTWARE 0x00000004
10346#define DSBPLAY_TERMINATEBY_TIME 0x00000008
10347#define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010
10348#define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020
10349
10350#define DSBSTATUS_PLAYING 0x00000001
10351#define DSBSTATUS_BUFFERLOST 0x00000002
10352#define DSBSTATUS_LOOPING 0x00000004
10353#define DSBSTATUS_LOCHARDWARE 0x00000008
10354#define DSBSTATUS_LOCSOFTWARE 0x00000010
10355#define DSBSTATUS_TERMINATED 0x00000020
10356
10357#define DSBLOCK_FROMWRITECURSOR 0x00000001
10358#define DSBLOCK_ENTIREBUFFER 0x00000002
10359
10360#define DSBFREQUENCY_MIN 100
10361#define DSBFREQUENCY_MAX 100000
10362#define DSBFREQUENCY_ORIGINAL 0
10363
10364#define DSBPAN_LEFT -10000
10365#define DSBPAN_CENTER 0
10366#define DSBPAN_RIGHT 10000
10367
10368#define DSBVOLUME_MIN -10000
10369#define DSBVOLUME_MAX 0
10370
10371#define DSBSIZE_MIN 4
10372#define DSBSIZE_MAX 0x0FFFFFFF
10373#define DSBSIZE_FX_MIN 150
10374
10375#define DS3DMODE_NORMAL 0x00000000
10376#define DS3DMODE_HEADRELATIVE 0x00000001
10377#define DS3DMODE_DISABLE 0x00000002
10378
10379#define DS3D_IMMEDIATE 0x00000000
10380#define DS3D_DEFERRED 0x00000001
10381
10382#define DS3D_MINDISTANCEFACTOR FLT_MIN
10383#define DS3D_MAXDISTANCEFACTOR FLT_MAX
10384#define DS3D_DEFAULTDISTANCEFACTOR 1.0f
10385
10386#define DS3D_MINROLLOFFFACTOR 0.0f
10387#define DS3D_MAXROLLOFFFACTOR 10.0f
10388#define DS3D_DEFAULTROLLOFFFACTOR 1.0f
10389
10390#define DS3D_MINDOPPLERFACTOR 0.0f
10391#define DS3D_MAXDOPPLERFACTOR 10.0f
10392#define DS3D_DEFAULTDOPPLERFACTOR 1.0f
10393
10394#define DS3D_DEFAULTMINDISTANCE 1.0f
10395#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f
10396
10397#define DS3D_MINCONEANGLE 0
10398#define DS3D_MAXCONEANGLE 360
10399#define DS3D_DEFAULTCONEANGLE 360
10400
10401#define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX
10402
10403#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER
10404#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED
10405
10406#define DSCBCAPS_WAVEMAPPED 0x80000000
10407
10408#if DIRECTSOUND_VERSION >= 0x0800
10409#define DSCBCAPS_CTRLFX 0x00000200
10410#endif
10411
10412#define DSCBLOCK_ENTIREBUFFER 0x00000001
10413
10414#define DSCBSTATUS_CAPTURING 0x00000001
10415#define DSCBSTATUS_LOOPING 0x00000002
10416
10417#define DSCBSTART_LOOPING 0x00000001
10418
10419#define DSBPN_OFFSETSTOP 0xFFFFFFFF
10420
10421#define DS_CERTIFIED 0x00000000
10422#define DS_UNCERTIFIED 0x00000001
10423
10424#define DS_SYSTEM_RESOURCES_NO_HOST_RESOURCES 0x00000000
10425#define DS_SYSTEM_RESOURCES_ALL_HOST_RESOURCES 0x7FFFFFFF
10426#define DS_SYSTEM_RESOURCES_UNDEFINED 0x80000000
10427
10428enum
10429{
10430 DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW,
10431 DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW,
10432 DSFX_I3DL2_MATERIAL_PRESET_THINDOOR,
10433 DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR,
10434 DSFX_I3DL2_MATERIAL_PRESET_WOODWALL,
10435 DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL,
10436 DSFX_I3DL2_MATERIAL_PRESET_STONEWALL,
10437 DSFX_I3DL2_MATERIAL_PRESET_CURTAIN
10438};
10439
10440#define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f
10441#define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f
10442#define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f
10443#define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f
10444#define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f
10445#define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f
10446#define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f
10447#define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f
10448
10449enum
10450{
10451 DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT,
10452 DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC,
10453 DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL,
10454 DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM,
10455 DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM,
10456 DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM,
10457 DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM,
10458 DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM,
10459 DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL,
10460 DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE,
10461 DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA,
10462 DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR,
10463 DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY,
10464 DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY,
10465 DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR,
10466 DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY,
10467 DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST,
10468 DSFX_I3DL2_ENVIRONMENT_PRESET_CITY,
10469 DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS,
10470 DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY,
10471 DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN,
10472 DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT,
10473 DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE,
10474 DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER,
10475 DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM,
10476 DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM,
10477 DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM,
10478 DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL,
10479 DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL,
10480 DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE
10481};
10482
10483#define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f
10484#define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f
10485#define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f
10486#define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f
10487#define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f
10488#define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f
10489#define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f
10490#define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f
10491#define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f
10492#define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f
10493#define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f
10494#define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f
10495#define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f
10496#define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f
10497#define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f
10498#define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f
10499#define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f
10500#define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f
10501#define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f
10502#define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f
10503#define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f
10504#define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f
10505#define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f
10506#define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f
10507
10508#define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f
10509#define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f
10510#define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f
10511#define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f
10512#define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f
10513#define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f
10514
10515#define DS3DALG_DEFAULT GUID_NULL
10516
10517DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
10518
10519DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
10520
10521DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
10522
10523#if DIRECTSOUND_VERSION >= 0x0800
10524
10525DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf);
10526
10527DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6);
10528
10529DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98);
10530
10531DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d);
10532
10533DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21);
10534
10535DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57);
10536
10537DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31);
10538
10539DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4);
10540
10541DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c);
10542
10543DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1);
10544
10545DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40);
10546
10547DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10);
10548
10549DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5);
10550
10551DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d);
10552
10553DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0);
10554
10555#endif
10556
10557#endif
10558
10559#ifdef __cplusplus
10560};
10561#endif
10562#ifndef __DINPUT_INCLUDED__
10563#define __DINPUT_INCLUDED__
10564
10565#ifndef DIJ_RINGZERO
10566
10567#ifdef _WIN32
10568#define COM_NO_WINDOWS_H
10569#include <objbase.h>
10570#endif
10571
10572#endif
10573
10574#ifdef __cplusplus
10575extern "C" {
10576#endif
10577
10578#define DIRECTINPUT_HEADER_VERSION 0x0800
10579#ifndef DIRECTINPUT_VERSION
10580#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION
10581#endif
10582
10583#ifndef DIJ_RINGZERO
10584
10585DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10586DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10587
10588DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10589DEFINE_GUID(CLSID_DirectInputDevice8,0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10590
10591DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10592DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10593DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10594DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10595DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
10596DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
10597DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
10598DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
10599DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10600DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10601DEFINE_GUID(IID_IDirectInputDevice2A,0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10602DEFINE_GUID(IID_IDirectInputDevice2W,0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10603DEFINE_GUID(IID_IDirectInputDevice7A,0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
10604DEFINE_GUID(IID_IDirectInputDevice7W,0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
10605DEFINE_GUID(IID_IDirectInputDevice8A,0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
10606DEFINE_GUID(IID_IDirectInputDevice8W,0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
10607DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10608
10609DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10610DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10611DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10612DEFINE_GUID(GUID_RxAxis, 0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10613DEFINE_GUID(GUID_RyAxis, 0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10614DEFINE_GUID(GUID_RzAxis, 0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10615DEFINE_GUID(GUID_Slider, 0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10616
10617DEFINE_GUID(GUID_Button, 0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10618DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10619
10620DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10621
10622DEFINE_GUID(GUID_Unknown, 0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10623
10624DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10625DEFINE_GUID(GUID_SysKeyboard,0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10626DEFINE_GUID(GUID_Joystick ,0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10627DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10628DEFINE_GUID(GUID_SysMouseEm2,0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10629DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10630DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
10631
10632DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10633DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10634DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10635DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10636DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10637DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10638DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10639DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10640DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10641DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10642DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10643DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
10644
10645#endif
10646
10647#if(DIRECTINPUT_VERSION >= 0x0500)
10648
10649#define DIEFT_ALL 0x00000000
10650
10651#define DIEFT_CONSTANTFORCE 0x00000001
10652#define DIEFT_RAMPFORCE 0x00000002
10653#define DIEFT_PERIODIC 0x00000003
10654#define DIEFT_CONDITION 0x00000004
10655#define DIEFT_CUSTOMFORCE 0x00000005
10656#define DIEFT_HARDWARE 0x000000FF
10657#define DIEFT_FFATTACK 0x00000200
10658#define DIEFT_FFFADE 0x00000400
10659#define DIEFT_SATURATION 0x00000800
10660#define DIEFT_POSNEGCOEFFICIENTS 0x00001000
10661#define DIEFT_POSNEGSATURATION 0x00002000
10662#define DIEFT_DEADBAND 0x00004000
10663#define DIEFT_STARTDELAY 0x00008000
10664#define DIEFT_GETTYPE(n) LOBYTE(n)
10665
10666#define DI_DEGREES 100
10667#define DI_FFNOMINALMAX 10000
10668#define DI_SECONDS 1000000
10669
10670typedef struct DICONSTANTFORCE {
10671 LONG lMagnitude;
10672} DICONSTANTFORCE, *LPDICONSTANTFORCE;
10673typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE;
10674
10675typedef struct DIRAMPFORCE {
10676 LONG lStart;
10677 LONG lEnd;
10678} DIRAMPFORCE, *LPDIRAMPFORCE;
10679typedef const DIRAMPFORCE *LPCDIRAMPFORCE;
10680
10681typedef struct DIPERIODIC {
10682 DWORD dwMagnitude;
10683 LONG lOffset;
10684 DWORD dwPhase;
10685 DWORD dwPeriod;
10686} DIPERIODIC, *LPDIPERIODIC;
10687typedef const DIPERIODIC *LPCDIPERIODIC;
10688
10689typedef struct DICONDITION {
10690 LONG lOffset;
10691 LONG lPositiveCoefficient;
10692 LONG lNegativeCoefficient;
10693 DWORD dwPositiveSaturation;
10694 DWORD dwNegativeSaturation;
10695 LONG lDeadBand;
10696} DICONDITION, *LPDICONDITION;
10697typedef const DICONDITION *LPCDICONDITION;
10698
10699typedef struct DICUSTOMFORCE {
10700 DWORD cChannels;
10701 DWORD dwSamplePeriod;
10702 DWORD cSamples;
10703 LPLONG rglForceData;
10704} DICUSTOMFORCE, *LPDICUSTOMFORCE;
10705typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE;
10706
10707typedef struct DIENVELOPE {
10708 DWORD dwSize;
10709 DWORD dwAttackLevel;
10710 DWORD dwAttackTime;
10711 DWORD dwFadeLevel;
10712 DWORD dwFadeTime;
10713} DIENVELOPE, *LPDIENVELOPE;
10714typedef const DIENVELOPE *LPCDIENVELOPE;
10715
10716typedef struct DIEFFECT_DX5 {
10717 DWORD dwSize;
10718 DWORD dwFlags;
10719 DWORD dwDuration;
10720 DWORD dwSamplePeriod;
10721 DWORD dwGain;
10722 DWORD dwTriggerButton;
10723 DWORD dwTriggerRepeatInterval;
10724 DWORD cAxes;
10725 LPDWORD rgdwAxes;
10726 LPLONG rglDirection;
10727 LPDIENVELOPE lpEnvelope;
10728 DWORD cbTypeSpecificParams;
10729 LPVOID lpvTypeSpecificParams;
10730} DIEFFECT_DX5, *LPDIEFFECT_DX5;
10731typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5;
10732
10733typedef struct DIEFFECT {
10734 DWORD dwSize;
10735 DWORD dwFlags;
10736 DWORD dwDuration;
10737 DWORD dwSamplePeriod;
10738 DWORD dwGain;
10739 DWORD dwTriggerButton;
10740 DWORD dwTriggerRepeatInterval;
10741 DWORD cAxes;
10742 LPDWORD rgdwAxes;
10743 LPLONG rglDirection;
10744 LPDIENVELOPE lpEnvelope;
10745 DWORD cbTypeSpecificParams;
10746 LPVOID lpvTypeSpecificParams;
10747#if(DIRECTINPUT_VERSION >= 0x0600)
10748 DWORD dwStartDelay;
10749#endif
10750} DIEFFECT, *LPDIEFFECT;
10751typedef DIEFFECT DIEFFECT_DX6;
10752typedef LPDIEFFECT LPDIEFFECT_DX6;
10753typedef const DIEFFECT *LPCDIEFFECT;
10754
10755#if(DIRECTINPUT_VERSION >= 0x0700)
10756#ifndef DIJ_RINGZERO
10757typedef struct DIFILEEFFECT{
10758 DWORD dwSize;
10759 GUID GuidEffect;
10760 LPCDIEFFECT lpDiEffect;
10761 CHAR szFriendlyName[MAX_PATH];
10762}DIFILEEFFECT, *LPDIFILEEFFECT;
10763typedef const DIFILEEFFECT *LPCDIFILEEFFECT;
10764typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID);
10765#endif
10766#endif
10767
10768#define DIEFF_OBJECTIDS 0x00000001
10769#define DIEFF_OBJECTOFFSETS 0x00000002
10770#define DIEFF_CARTESIAN 0x00000010
10771#define DIEFF_POLAR 0x00000020
10772#define DIEFF_SPHERICAL 0x00000040
10773
10774#define DIEP_DURATION 0x00000001
10775#define DIEP_SAMPLEPERIOD 0x00000002
10776#define DIEP_GAIN 0x00000004
10777#define DIEP_TRIGGERBUTTON 0x00000008
10778#define DIEP_TRIGGERREPEATINTERVAL 0x00000010
10779#define DIEP_AXES 0x00000020
10780#define DIEP_DIRECTION 0x00000040
10781#define DIEP_ENVELOPE 0x00000080
10782#define DIEP_TYPESPECIFICPARAMS 0x00000100
10783#if(DIRECTINPUT_VERSION >= 0x0600)
10784#define DIEP_STARTDELAY 0x00000200
10785#define DIEP_ALLPARAMS_DX5 0x000001FF
10786#define DIEP_ALLPARAMS 0x000003FF
10787#else
10788#define DIEP_ALLPARAMS 0x000001FF
10789#endif
10790#define DIEP_START 0x20000000
10791#define DIEP_NORESTART 0x40000000
10792#define DIEP_NODOWNLOAD 0x80000000
10793#define DIEB_NOTRIGGER 0xFFFFFFFF
10794
10795#define DIES_SOLO 0x00000001
10796#define DIES_NODOWNLOAD 0x80000000
10797
10798#define DIEGES_PLAYING 0x00000001
10799#define DIEGES_EMULATED 0x00000002
10800
10801typedef struct DIEFFESCAPE {
10802 DWORD dwSize;
10803 DWORD dwCommand;
10804 LPVOID lpvInBuffer;
10805 DWORD cbInBuffer;
10806 LPVOID lpvOutBuffer;
10807 DWORD cbOutBuffer;
10808} DIEFFESCAPE, *LPDIEFFESCAPE;
10809
10810#ifndef DIJ_RINGZERO
10811
10812#undef INTERFACE
10813#define INTERFACE IDirectInputEffect
10814
10815DECLARE_INTERFACE_(IDirectInputEffect, IUnknown)
10816{
10817
10818 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
10819 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
10820 STDMETHOD_(ULONG,Release)(THIS) PURE;
10821
10822 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
10823 STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE;
10824 STDMETHOD(GetParameters)(THIS_ LPDIEFFECT,DWORD) PURE;
10825 STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT,DWORD) PURE;
10826 STDMETHOD(Start)(THIS_ DWORD,DWORD) PURE;
10827 STDMETHOD(Stop)(THIS) PURE;
10828 STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE;
10829 STDMETHOD(Download)(THIS) PURE;
10830 STDMETHOD(Unload)(THIS) PURE;
10831 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
10832};
10833
10834typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT;
10835
10836#if !defined(__cplusplus) || defined(CINTERFACE)
10837#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
10838#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p)
10839#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p)
10840#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
10841#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a)
10842#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b)
10843#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b)
10844#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b)
10845#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p)
10846#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a)
10847#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p)
10848#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p)
10849#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a)
10850#else
10851#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
10852#define IDirectInputEffect_AddRef(p) (p)->AddRef()
10853#define IDirectInputEffect_Release(p) (p)->Release()
10854#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
10855#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a)
10856#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b)
10857#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b)
10858#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b)
10859#define IDirectInputEffect_Stop(p) (p)->Stop()
10860#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a)
10861#define IDirectInputEffect_Download(p) (p)->Download()
10862#define IDirectInputEffect_Unload(p) (p)->Unload()
10863#define IDirectInputEffect_Escape(p,a) (p)->Escape(a)
10864#endif
10865
10866#endif
10867
10868#endif
10869
10870#if DIRECTINPUT_VERSION <= 0x700
10871#define DIDEVTYPE_DEVICE 1
10872#define DIDEVTYPE_MOUSE 2
10873#define DIDEVTYPE_KEYBOARD 3
10874#define DIDEVTYPE_JOYSTICK 4
10875
10876#else
10877#define DI8DEVCLASS_ALL 0
10878#define DI8DEVCLASS_DEVICE 1
10879#define DI8DEVCLASS_POINTER 2
10880#define DI8DEVCLASS_KEYBOARD 3
10881#define DI8DEVCLASS_GAMECTRL 4
10882
10883#define DI8DEVTYPE_DEVICE 0x11
10884#define DI8DEVTYPE_MOUSE 0x12
10885#define DI8DEVTYPE_KEYBOARD 0x13
10886#define DI8DEVTYPE_JOYSTICK 0x14
10887#define DI8DEVTYPE_GAMEPAD 0x15
10888#define DI8DEVTYPE_DRIVING 0x16
10889#define DI8DEVTYPE_FLIGHT 0x17
10890#define DI8DEVTYPE_1STPERSON 0x18
10891#define DI8DEVTYPE_DEVICECTRL 0x19
10892#define DI8DEVTYPE_SCREENPOINTER 0x1A
10893#define DI8DEVTYPE_REMOTE 0x1B
10894#define DI8DEVTYPE_SUPPLEMENTAL 0x1C
10895#endif
10896
10897#define DIDEVTYPE_HID 0x00010000
10898
10899#if DIRECTINPUT_VERSION <= 0x700
10900#define DIDEVTYPEMOUSE_UNKNOWN 1
10901#define DIDEVTYPEMOUSE_TRADITIONAL 2
10902#define DIDEVTYPEMOUSE_FINGERSTICK 3
10903#define DIDEVTYPEMOUSE_TOUCHPAD 4
10904#define DIDEVTYPEMOUSE_TRACKBALL 5
10905
10906#define DIDEVTYPEKEYBOARD_UNKNOWN 0
10907#define DIDEVTYPEKEYBOARD_PCXT 1
10908#define DIDEVTYPEKEYBOARD_OLIVETTI 2
10909#define DIDEVTYPEKEYBOARD_PCAT 3
10910#define DIDEVTYPEKEYBOARD_PCENH 4
10911#define DIDEVTYPEKEYBOARD_NOKIA1050 5
10912#define DIDEVTYPEKEYBOARD_NOKIA9140 6
10913#define DIDEVTYPEKEYBOARD_NEC98 7
10914#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8
10915#define DIDEVTYPEKEYBOARD_NEC98106 9
10916#define DIDEVTYPEKEYBOARD_JAPAN106 10
10917#define DIDEVTYPEKEYBOARD_JAPANAX 11
10918#define DIDEVTYPEKEYBOARD_J3100 12
10919
10920#define DIDEVTYPEJOYSTICK_UNKNOWN 1
10921#define DIDEVTYPEJOYSTICK_TRADITIONAL 2
10922#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3
10923#define DIDEVTYPEJOYSTICK_GAMEPAD 4
10924#define DIDEVTYPEJOYSTICK_RUDDER 5
10925#define DIDEVTYPEJOYSTICK_WHEEL 6
10926#define DIDEVTYPEJOYSTICK_HEADTRACKER 7
10927
10928#else
10929#define DI8DEVTYPEMOUSE_UNKNOWN 1
10930#define DI8DEVTYPEMOUSE_TRADITIONAL 2
10931#define DI8DEVTYPEMOUSE_FINGERSTICK 3
10932#define DI8DEVTYPEMOUSE_TOUCHPAD 4
10933#define DI8DEVTYPEMOUSE_TRACKBALL 5
10934#define DI8DEVTYPEMOUSE_ABSOLUTE 6
10935
10936#define DI8DEVTYPEKEYBOARD_UNKNOWN 0
10937#define DI8DEVTYPEKEYBOARD_PCXT 1
10938#define DI8DEVTYPEKEYBOARD_OLIVETTI 2
10939#define DI8DEVTYPEKEYBOARD_PCAT 3
10940#define DI8DEVTYPEKEYBOARD_PCENH 4
10941#define DI8DEVTYPEKEYBOARD_NOKIA1050 5
10942#define DI8DEVTYPEKEYBOARD_NOKIA9140 6
10943#define DI8DEVTYPEKEYBOARD_NEC98 7
10944#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8
10945#define DI8DEVTYPEKEYBOARD_NEC98106 9
10946#define DI8DEVTYPEKEYBOARD_JAPAN106 10
10947#define DI8DEVTYPEKEYBOARD_JAPANAX 11
10948#define DI8DEVTYPEKEYBOARD_J3100 12
10949
10950#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1
10951
10952#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
10953#define DI8DEVTYPEJOYSTICK_STANDARD 2
10954
10955#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
10956#define DI8DEVTYPEGAMEPAD_STANDARD 2
10957#define DI8DEVTYPEGAMEPAD_TILT 3
10958
10959#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
10960#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2
10961#define DI8DEVTYPEDRIVING_DUALPEDALS 3
10962#define DI8DEVTYPEDRIVING_THREEPEDALS 4
10963#define DI8DEVTYPEDRIVING_HANDHELD 5
10964
10965#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
10966#define DI8DEVTYPEFLIGHT_STICK 2
10967#define DI8DEVTYPEFLIGHT_YOKE 3
10968#define DI8DEVTYPEFLIGHT_RC 4
10969
10970#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE
10971#define DI8DEVTYPE1STPERSON_UNKNOWN 2
10972#define DI8DEVTYPE1STPERSON_SIXDOF 3
10973#define DI8DEVTYPE1STPERSON_SHOOTER 4
10974
10975#define DI8DEVTYPESCREENPTR_UNKNOWN 2
10976#define DI8DEVTYPESCREENPTR_LIGHTGUN 3
10977#define DI8DEVTYPESCREENPTR_LIGHTPEN 4
10978#define DI8DEVTYPESCREENPTR_TOUCH 5
10979
10980#define DI8DEVTYPEREMOTE_UNKNOWN 2
10981
10982#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2
10983#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3
10984#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4
10985
10986#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2
10987#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3
10988#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4
10989#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5
10990#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6
10991#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7
10992#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8
10993#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9
10994#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10
10995#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11
10996#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12
10997#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13
10998#endif
10999
11000#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType)
11001#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType)
11002
11003#if(DIRECTINPUT_VERSION >= 0x0500)
11004
11005typedef struct DIDEVCAPS_DX3 {
11006 DWORD dwSize;
11007 DWORD dwFlags;
11008 DWORD dwDevType;
11009 DWORD dwAxes;
11010 DWORD dwButtons;
11011 DWORD dwPOVs;
11012} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3;
11013#endif
11014
11015typedef struct DIDEVCAPS {
11016 DWORD dwSize;
11017 DWORD dwFlags;
11018 DWORD dwDevType;
11019 DWORD dwAxes;
11020 DWORD dwButtons;
11021 DWORD dwPOVs;
11022#if(DIRECTINPUT_VERSION >= 0x0500)
11023 DWORD dwFFSamplePeriod;
11024 DWORD dwFFMinTimeResolution;
11025 DWORD dwFirmwareRevision;
11026 DWORD dwHardwareRevision;
11027 DWORD dwFFDriverVersion;
11028#endif
11029} DIDEVCAPS, *LPDIDEVCAPS;
11030
11031#define DIDC_ATTACHED 0x00000001
11032#define DIDC_POLLEDDEVICE 0x00000002
11033#define DIDC_EMULATED 0x00000004
11034#define DIDC_POLLEDDATAFORMAT 0x00000008
11035#if(DIRECTINPUT_VERSION >= 0x0500)
11036#define DIDC_FORCEFEEDBACK 0x00000100
11037#define DIDC_FFATTACK 0x00000200
11038#define DIDC_FFFADE 0x00000400
11039#define DIDC_SATURATION 0x00000800
11040#define DIDC_POSNEGCOEFFICIENTS 0x00001000
11041#define DIDC_POSNEGSATURATION 0x00002000
11042#define DIDC_DEADBAND 0x00004000
11043#endif
11044#define DIDC_STARTDELAY 0x00008000
11045#if(DIRECTINPUT_VERSION >= 0x050a)
11046#define DIDC_ALIAS 0x00010000
11047#define DIDC_PHANTOM 0x00020000
11048#endif
11049#if(DIRECTINPUT_VERSION >= 0x0800)
11050#define DIDC_HIDDEN 0x00040000
11051#endif
11052
11053#define DIDFT_ALL 0x00000000
11054
11055#define DIDFT_RELAXIS 0x00000001
11056#define DIDFT_ABSAXIS 0x00000002
11057#define DIDFT_AXIS 0x00000003
11058
11059#define DIDFT_PSHBUTTON 0x00000004
11060#define DIDFT_TGLBUTTON 0x00000008
11061#define DIDFT_BUTTON 0x0000000C
11062
11063#define DIDFT_POV 0x00000010
11064#define DIDFT_COLLECTION 0x00000040
11065#define DIDFT_NODATA 0x00000080
11066
11067#define DIDFT_ANYINSTANCE 0x00FFFF00
11068#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE
11069#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8)
11070#define DIDFT_GETTYPE(n) LOBYTE(n)
11071#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8)
11072#define DIDFT_FFACTUATOR 0x01000000
11073#define DIDFT_FFEFFECTTRIGGER 0x02000000
11074#if(DIRECTINPUT_VERSION >= 0x050a)
11075#define DIDFT_OUTPUT 0x10000000
11076#define DIDFT_VENDORDEFINED 0x04000000
11077#define DIDFT_ALIAS 0x08000000
11078#endif
11079
11080#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8)
11081#define DIDFT_NOCOLLECTION 0x00FFFF00
11082
11083#ifndef DIJ_RINGZERO
11084
11085typedef struct _DIOBJECTDATAFORMAT {
11086 const GUID *pguid;
11087 DWORD dwOfs;
11088 DWORD dwType;
11089 DWORD dwFlags;
11090} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT;
11091typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT;
11092
11093typedef struct _DIDATAFORMAT {
11094 DWORD dwSize;
11095 DWORD dwObjSize;
11096 DWORD dwFlags;
11097 DWORD dwDataSize;
11098 DWORD dwNumObjs;
11099 LPDIOBJECTDATAFORMAT rgodf;
11100} DIDATAFORMAT, *LPDIDATAFORMAT;
11101typedef const DIDATAFORMAT *LPCDIDATAFORMAT;
11102
11103#define DIDF_ABSAXIS 0x00000001
11104#define DIDF_RELAXIS 0x00000002
11105
11106#ifdef __cplusplus
11107extern "C" {
11108#endif
11109extern const DIDATAFORMAT c_dfDIMouse;
11110
11111#if(DIRECTINPUT_VERSION >= 0x0700)
11112extern const DIDATAFORMAT c_dfDIMouse2;
11113#endif
11114
11115extern const DIDATAFORMAT c_dfDIKeyboard;
11116
11117#if(DIRECTINPUT_VERSION >= 0x0500)
11118extern const DIDATAFORMAT c_dfDIJoystick;
11119extern const DIDATAFORMAT c_dfDIJoystick2;
11120#endif
11121
11122#ifdef __cplusplus
11123};
11124#endif
11125
11126#if DIRECTINPUT_VERSION > 0x0700
11127
11128typedef struct _DIACTIONA {
11129 UINT_PTR uAppData;
11130 DWORD dwSemantic;
11131 OPTIONAL DWORD dwFlags;
11132 OPTIONAL union {
11133 LPCSTR lptszActionName;
11134 UINT uResIdString;
11135 };
11136 OPTIONAL GUID guidInstance;
11137 OPTIONAL DWORD dwObjID;
11138 OPTIONAL DWORD dwHow;
11139} DIACTIONA, *LPDIACTIONA ;
11140typedef struct _DIACTIONW {
11141 UINT_PTR uAppData;
11142 DWORD dwSemantic;
11143 OPTIONAL DWORD dwFlags;
11144 OPTIONAL union {
11145 LPCWSTR lptszActionName;
11146 UINT uResIdString;
11147 };
11148 OPTIONAL GUID guidInstance;
11149 OPTIONAL DWORD dwObjID;
11150 OPTIONAL DWORD dwHow;
11151} DIACTIONW, *LPDIACTIONW ;
11152#ifdef UNICODE
11153typedef DIACTIONW DIACTION;
11154typedef LPDIACTIONW LPDIACTION;
11155#else
11156typedef DIACTIONA DIACTION;
11157typedef LPDIACTIONA LPDIACTION;
11158#endif
11159
11160typedef const DIACTIONA *LPCDIACTIONA;
11161typedef const DIACTIONW *LPCDIACTIONW;
11162#ifdef UNICODE
11163typedef DIACTIONW DIACTION;
11164typedef LPCDIACTIONW LPCDIACTION;
11165#else
11166typedef DIACTIONA DIACTION;
11167typedef LPCDIACTIONA LPCDIACTION;
11168#endif
11169typedef const DIACTION *LPCDIACTION;
11170
11171#define DIA_FORCEFEEDBACK 0x00000001
11172#define DIA_APPMAPPED 0x00000002
11173#define DIA_APPNOMAP 0x00000004
11174#define DIA_NORANGE 0x00000008
11175#define DIA_APPFIXED 0x00000010
11176
11177#define DIAH_UNMAPPED 0x00000000
11178#define DIAH_USERCONFIG 0x00000001
11179#define DIAH_APPREQUESTED 0x00000002
11180#define DIAH_HWAPP 0x00000004
11181#define DIAH_HWDEFAULT 0x00000008
11182#define DIAH_DEFAULT 0x00000020
11183#define DIAH_ERROR 0x80000000
11184
11185typedef struct _DIACTIONFORMATA {
11186 DWORD dwSize;
11187 DWORD dwActionSize;
11188 DWORD dwDataSize;
11189 DWORD dwNumActions;
11190 LPDIACTIONA rgoAction;
11191 GUID guidActionMap;
11192 DWORD dwGenre;
11193 DWORD dwBufferSize;
11194 OPTIONAL LONG lAxisMin;
11195 OPTIONAL LONG lAxisMax;
11196 OPTIONAL HINSTANCE hInstString;
11197 FILETIME ftTimeStamp;
11198 DWORD dwCRC;
11199 CHAR tszActionMap[MAX_PATH];
11200} DIACTIONFORMATA, *LPDIACTIONFORMATA;
11201typedef struct _DIACTIONFORMATW {
11202 DWORD dwSize;
11203 DWORD dwActionSize;
11204 DWORD dwDataSize;
11205 DWORD dwNumActions;
11206 LPDIACTIONW rgoAction;
11207 GUID guidActionMap;
11208 DWORD dwGenre;
11209 DWORD dwBufferSize;
11210 OPTIONAL LONG lAxisMin;
11211 OPTIONAL LONG lAxisMax;
11212 OPTIONAL HINSTANCE hInstString;
11213 FILETIME ftTimeStamp;
11214 DWORD dwCRC;
11215 WCHAR tszActionMap[MAX_PATH];
11216} DIACTIONFORMATW, *LPDIACTIONFORMATW;
11217#ifdef UNICODE
11218typedef DIACTIONFORMATW DIACTIONFORMAT;
11219typedef LPDIACTIONFORMATW LPDIACTIONFORMAT;
11220#else
11221typedef DIACTIONFORMATA DIACTIONFORMAT;
11222typedef LPDIACTIONFORMATA LPDIACTIONFORMAT;
11223#endif
11224typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA;
11225typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW;
11226#ifdef UNICODE
11227typedef DIACTIONFORMATW DIACTIONFORMAT;
11228typedef LPCDIACTIONFORMATW LPCDIACTIONFORMAT;
11229#else
11230typedef DIACTIONFORMATA DIACTIONFORMAT;
11231typedef LPCDIACTIONFORMATA LPCDIACTIONFORMAT;
11232#endif
11233typedef const DIACTIONFORMAT *LPCDIACTIONFORMAT;
11234
11235#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF
11236#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF
11237#define DIAFTS_UNUSEDDEVICELOW 0x00000000
11238#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000
11239
11240#define DIDBAM_DEFAULT 0x00000000
11241#define DIDBAM_PRESERVE 0x00000001
11242#define DIDBAM_INITIALIZE 0x00000002
11243#define DIDBAM_HWDEFAULTS 0x00000004
11244
11245#define DIDSAM_DEFAULT 0x00000000
11246#define DIDSAM_NOUSER 0x00000001
11247#define DIDSAM_FORCESAVE 0x00000002
11248
11249#define DICD_DEFAULT 0x00000000
11250#define DICD_EDIT 0x00000001
11251
11252#ifndef D3DCOLOR_DEFINED
11253typedef DWORD D3DCOLOR;
11254#define D3DCOLOR_DEFINED
11255#endif
11256
11257typedef struct _DICOLORSET{
11258 DWORD dwSize;
11259 D3DCOLOR cTextFore;
11260 D3DCOLOR cTextHighlight;
11261 D3DCOLOR cCalloutLine;
11262 D3DCOLOR cCalloutHighlight;
11263 D3DCOLOR cBorder;
11264 D3DCOLOR cControlFill;
11265 D3DCOLOR cHighlightFill;
11266 D3DCOLOR cAreaFill;
11267} DICOLORSET, *LPDICOLORSET;
11268typedef const DICOLORSET *LPCDICOLORSET;
11269
11270typedef struct _DICONFIGUREDEVICESPARAMSA{
11271 DWORD dwSize;
11272 DWORD dwcUsers;
11273 LPSTR lptszUserNames;
11274 DWORD dwcFormats;
11275 LPDIACTIONFORMATA lprgFormats;
11276 HWND hwnd;
11277 DICOLORSET dics;
11278 IUnknown FAR * lpUnkDDSTarget;
11279} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA;
11280typedef struct _DICONFIGUREDEVICESPARAMSW{
11281 DWORD dwSize;
11282 DWORD dwcUsers;
11283 LPWSTR lptszUserNames;
11284 DWORD dwcFormats;
11285 LPDIACTIONFORMATW lprgFormats;
11286 HWND hwnd;
11287 DICOLORSET dics;
11288 IUnknown FAR * lpUnkDDSTarget;
11289} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW;
11290#ifdef UNICODE
11291typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS;
11292typedef LPDICONFIGUREDEVICESPARAMSW LPDICONFIGUREDEVICESPARAMS;
11293#else
11294typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS;
11295typedef LPDICONFIGUREDEVICESPARAMSA LPDICONFIGUREDEVICESPARAMS;
11296#endif
11297typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA;
11298typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW;
11299#ifdef UNICODE
11300typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS;
11301typedef LPCDICONFIGUREDEVICESPARAMSW LPCDICONFIGUREDEVICESPARAMS;
11302#else
11303typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS;
11304typedef LPCDICONFIGUREDEVICESPARAMSA LPCDICONFIGUREDEVICESPARAMS;
11305#endif
11306typedef const DICONFIGUREDEVICESPARAMS *LPCDICONFIGUREDEVICESPARAMS;
11307
11308#define DIDIFT_CONFIGURATION 0x00000001
11309#define DIDIFT_OVERLAY 0x00000002
11310
11311#define DIDAL_CENTERED 0x00000000
11312#define DIDAL_LEFTALIGNED 0x00000001
11313#define DIDAL_RIGHTALIGNED 0x00000002
11314#define DIDAL_MIDDLE 0x00000000
11315#define DIDAL_TOPALIGNED 0x00000004
11316#define DIDAL_BOTTOMALIGNED 0x00000008
11317
11318typedef struct _DIDEVICEIMAGEINFOA {
11319 CHAR tszImagePath[MAX_PATH];
11320 DWORD dwFlags;
11321
11322 DWORD dwViewID;
11323 RECT rcOverlay;
11324 DWORD dwObjID;
11325 DWORD dwcValidPts;
11326 POINT rgptCalloutLine[5];
11327 RECT rcCalloutRect;
11328 DWORD dwTextAlign;
11329} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA;
11330typedef struct _DIDEVICEIMAGEINFOW {
11331 WCHAR tszImagePath[MAX_PATH];
11332 DWORD dwFlags;
11333
11334 DWORD dwViewID;
11335 RECT rcOverlay;
11336 DWORD dwObjID;
11337 DWORD dwcValidPts;
11338 POINT rgptCalloutLine[5];
11339 RECT rcCalloutRect;
11340 DWORD dwTextAlign;
11341} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW;
11342#ifdef UNICODE
11343typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO;
11344typedef LPDIDEVICEIMAGEINFOW LPDIDEVICEIMAGEINFO;
11345#else
11346typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO;
11347typedef LPDIDEVICEIMAGEINFOA LPDIDEVICEIMAGEINFO;
11348#endif
11349typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA;
11350typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW;
11351#ifdef UNICODE
11352typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO;
11353typedef LPCDIDEVICEIMAGEINFOW LPCDIDEVICEIMAGEINFO;
11354#else
11355typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO;
11356typedef LPCDIDEVICEIMAGEINFOA LPCDIDEVICEIMAGEINFO;
11357#endif
11358typedef const DIDEVICEIMAGEINFO *LPCDIDEVICEIMAGEINFO;
11359
11360typedef struct _DIDEVICEIMAGEINFOHEADERA {
11361 DWORD dwSize;
11362 DWORD dwSizeImageInfo;
11363 DWORD dwcViews;
11364 DWORD dwcButtons;
11365 DWORD dwcAxes;
11366 DWORD dwcPOVs;
11367 DWORD dwBufferSize;
11368 DWORD dwBufferUsed;
11369 LPDIDEVICEIMAGEINFOA lprgImageInfoArray;
11370} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA;
11371typedef struct _DIDEVICEIMAGEINFOHEADERW {
11372 DWORD dwSize;
11373 DWORD dwSizeImageInfo;
11374 DWORD dwcViews;
11375 DWORD dwcButtons;
11376 DWORD dwcAxes;
11377 DWORD dwcPOVs;
11378 DWORD dwBufferSize;
11379 DWORD dwBufferUsed;
11380 LPDIDEVICEIMAGEINFOW lprgImageInfoArray;
11381} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW;
11382#ifdef UNICODE
11383typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER;
11384typedef LPDIDEVICEIMAGEINFOHEADERW LPDIDEVICEIMAGEINFOHEADER;
11385#else
11386typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER;
11387typedef LPDIDEVICEIMAGEINFOHEADERA LPDIDEVICEIMAGEINFOHEADER;
11388#endif
11389typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA;
11390typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW;
11391#ifdef UNICODE
11392typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER;
11393typedef LPCDIDEVICEIMAGEINFOHEADERW LPCDIDEVICEIMAGEINFOHEADER;
11394#else
11395typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER;
11396typedef LPCDIDEVICEIMAGEINFOHEADERA LPCDIDEVICEIMAGEINFOHEADER;
11397#endif
11398typedef const DIDEVICEIMAGEINFOHEADER *LPCDIDEVICEIMAGEINFOHEADER;
11399
11400#endif
11401
11402#if(DIRECTINPUT_VERSION >= 0x0500)
11403
11404typedef struct DIDEVICEOBJECTINSTANCE_DX3A {
11405 DWORD dwSize;
11406 GUID guidType;
11407 DWORD dwOfs;
11408 DWORD dwType;
11409 DWORD dwFlags;
11410 CHAR tszName[MAX_PATH];
11411} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A;
11412typedef struct DIDEVICEOBJECTINSTANCE_DX3W {
11413 DWORD dwSize;
11414 GUID guidType;
11415 DWORD dwOfs;
11416 DWORD dwType;
11417 DWORD dwFlags;
11418 WCHAR tszName[MAX_PATH];
11419} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W;
11420#ifdef UNICODE
11421typedef DIDEVICEOBJECTINSTANCE_DX3W DIDEVICEOBJECTINSTANCE_DX3;
11422typedef LPDIDEVICEOBJECTINSTANCE_DX3W LPDIDEVICEOBJECTINSTANCE_DX3;
11423#else
11424typedef DIDEVICEOBJECTINSTANCE_DX3A DIDEVICEOBJECTINSTANCE_DX3;
11425typedef LPDIDEVICEOBJECTINSTANCE_DX3A LPDIDEVICEOBJECTINSTANCE_DX3;
11426#endif
11427typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A;
11428typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W;
11429typedef const DIDEVICEOBJECTINSTANCE_DX3 *LPCDIDEVICEOBJECTINSTANCE_DX3;
11430#endif
11431
11432typedef struct DIDEVICEOBJECTINSTANCEA {
11433 DWORD dwSize;
11434 GUID guidType;
11435 DWORD dwOfs;
11436 DWORD dwType;
11437 DWORD dwFlags;
11438 CHAR tszName[MAX_PATH];
11439#if(DIRECTINPUT_VERSION >= 0x0500)
11440 DWORD dwFFMaxForce;
11441 DWORD dwFFForceResolution;
11442 WORD wCollectionNumber;
11443 WORD wDesignatorIndex;
11444 WORD wUsagePage;
11445 WORD wUsage;
11446 DWORD dwDimension;
11447 WORD wExponent;
11448 WORD wReportId;
11449#endif
11450} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA;
11451typedef struct DIDEVICEOBJECTINSTANCEW {
11452 DWORD dwSize;
11453 GUID guidType;
11454 DWORD dwOfs;
11455 DWORD dwType;
11456 DWORD dwFlags;
11457 WCHAR tszName[MAX_PATH];
11458#if(DIRECTINPUT_VERSION >= 0x0500)
11459 DWORD dwFFMaxForce;
11460 DWORD dwFFForceResolution;
11461 WORD wCollectionNumber;
11462 WORD wDesignatorIndex;
11463 WORD wUsagePage;
11464 WORD wUsage;
11465 DWORD dwDimension;
11466 WORD wExponent;
11467 WORD wReportId;
11468#endif
11469} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW;
11470#ifdef UNICODE
11471typedef DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCE;
11472typedef LPDIDEVICEOBJECTINSTANCEW LPDIDEVICEOBJECTINSTANCE;
11473#else
11474typedef DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCE;
11475typedef LPDIDEVICEOBJECTINSTANCEA LPDIDEVICEOBJECTINSTANCE;
11476#endif
11477typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
11478typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;
11479typedef const DIDEVICEOBJECTINSTANCE *LPCDIDEVICEOBJECTINSTANCE;
11480
11481typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID);
11482typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW, LPVOID);
11483#ifdef UNICODE
11484#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKW
11485#else
11486#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKA
11487#endif
11488
11489#if(DIRECTINPUT_VERSION >= 0x0500)
11490#define DIDOI_FFACTUATOR 0x00000001
11491#define DIDOI_FFEFFECTTRIGGER 0x00000002
11492#define DIDOI_POLLED 0x00008000
11493#define DIDOI_ASPECTPOSITION 0x00000100
11494#define DIDOI_ASPECTVELOCITY 0x00000200
11495#define DIDOI_ASPECTACCEL 0x00000300
11496#define DIDOI_ASPECTFORCE 0x00000400
11497#define DIDOI_ASPECTMASK 0x00000F00
11498#endif
11499#if(DIRECTINPUT_VERSION >= 0x050a)
11500#define DIDOI_GUIDISUSAGE 0x00010000
11501#endif
11502
11503typedef struct DIPROPHEADER {
11504 DWORD dwSize;
11505 DWORD dwHeaderSize;
11506 DWORD dwObj;
11507 DWORD dwHow;
11508} DIPROPHEADER, *LPDIPROPHEADER;
11509typedef const DIPROPHEADER *LPCDIPROPHEADER;
11510
11511#define DIPH_DEVICE 0
11512#define DIPH_BYOFFSET 1
11513#define DIPH_BYID 2
11514#if(DIRECTINPUT_VERSION >= 0x050a)
11515#define DIPH_BYUSAGE 3
11516
11517#define DIMAKEUSAGEDWORD(UsagePage, Usage) \
11518 (DWORD)MAKELONG(Usage, UsagePage)
11519#endif
11520
11521typedef struct DIPROPDWORD {
11522 DIPROPHEADER diph;
11523 DWORD dwData;
11524} DIPROPDWORD, *LPDIPROPDWORD;
11525typedef const DIPROPDWORD *LPCDIPROPDWORD;
11526
11527#if(DIRECTINPUT_VERSION >= 0x0800)
11528typedef struct DIPROPPOINTER {
11529 DIPROPHEADER diph;
11530 UINT_PTR uData;
11531} DIPROPPOINTER, *LPDIPROPPOINTER;
11532typedef const DIPROPPOINTER *LPCDIPROPPOINTER;
11533#endif
11534
11535typedef struct DIPROPRANGE {
11536 DIPROPHEADER diph;
11537 LONG lMin;
11538 LONG lMax;
11539} DIPROPRANGE, *LPDIPROPRANGE;
11540typedef const DIPROPRANGE *LPCDIPROPRANGE;
11541
11542#define DIPROPRANGE_NOMIN ((LONG)0x80000000)
11543#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF)
11544
11545#if(DIRECTINPUT_VERSION >= 0x050a)
11546typedef struct DIPROPCAL {
11547 DIPROPHEADER diph;
11548 LONG lMin;
11549 LONG lCenter;
11550 LONG lMax;
11551} DIPROPCAL, *LPDIPROPCAL;
11552typedef const DIPROPCAL *LPCDIPROPCAL;
11553
11554typedef struct DIPROPGUIDANDPATH {
11555 DIPROPHEADER diph;
11556 GUID guidClass;
11557 WCHAR wszPath[MAX_PATH];
11558} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH;
11559typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH;
11560
11561typedef struct DIPROPSTRING {
11562 DIPROPHEADER diph;
11563 WCHAR wsz[MAX_PATH];
11564} DIPROPSTRING, *LPDIPROPSTRING;
11565typedef const DIPROPSTRING *LPCDIPROPSTRING;
11566
11567#endif
11568
11569#if(DIRECTINPUT_VERSION >= 0x0800)
11570#define MAXCPOINTSNUM 8
11571
11572typedef struct _CPOINT
11573{
11574 LONG lP;
11575 DWORD dwLog;
11576} CPOINT, *PCPOINT;
11577
11578typedef struct DIPROPCPOINTS {
11579 DIPROPHEADER diph;
11580 DWORD dwCPointsNum;
11581 CPOINT cp[MAXCPOINTSNUM];
11582} DIPROPCPOINTS, *LPDIPROPCPOINTS;
11583typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS;
11584#endif
11585
11586#ifdef __cplusplus
11587#define MAKEDIPROP(prop) (*(const GUID *)(prop))
11588#else
11589#define MAKEDIPROP(prop) ((REFGUID)(prop))
11590#endif
11591
11592#define DIPROP_BUFFERSIZE MAKEDIPROP(1)
11593
11594#define DIPROP_AXISMODE MAKEDIPROP(2)
11595
11596#define DIPROPAXISMODE_ABS 0
11597#define DIPROPAXISMODE_REL 1
11598
11599#define DIPROP_GRANULARITY MAKEDIPROP(3)
11600
11601#define DIPROP_RANGE MAKEDIPROP(4)
11602
11603#define DIPROP_DEADZONE MAKEDIPROP(5)
11604
11605#define DIPROP_SATURATION MAKEDIPROP(6)
11606
11607#define DIPROP_FFGAIN MAKEDIPROP(7)
11608
11609#define DIPROP_FFLOAD MAKEDIPROP(8)
11610
11611#define DIPROP_AUTOCENTER MAKEDIPROP(9)
11612
11613#define DIPROPAUTOCENTER_OFF 0
11614#define DIPROPAUTOCENTER_ON 1
11615
11616#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10)
11617
11618#define DIPROPCALIBRATIONMODE_COOKED 0
11619#define DIPROPCALIBRATIONMODE_RAW 1
11620
11621#if(DIRECTINPUT_VERSION >= 0x050a)
11622#define DIPROP_CALIBRATION MAKEDIPROP(11)
11623
11624#define DIPROP_GUIDANDPATH MAKEDIPROP(12)
11625
11626#define DIPROP_INSTANCENAME MAKEDIPROP(13)
11627
11628#define DIPROP_PRODUCTNAME MAKEDIPROP(14)
11629#endif
11630
11631#if(DIRECTINPUT_VERSION >= 0x05b2)
11632#define DIPROP_JOYSTICKID MAKEDIPROP(15)
11633
11634#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16)
11635
11636#endif
11637
11638#if(DIRECTINPUT_VERSION >= 0x0700)
11639#define DIPROP_PHYSICALRANGE MAKEDIPROP(18)
11640
11641#define DIPROP_LOGICALRANGE MAKEDIPROP(19)
11642#endif
11643
11644#if(DIRECTINPUT_VERSION >= 0x0800)
11645#define DIPROP_KEYNAME MAKEDIPROP(20)
11646
11647#define DIPROP_CPOINTS MAKEDIPROP(21)
11648
11649#define DIPROP_APPDATA MAKEDIPROP(22)
11650
11651#define DIPROP_SCANCODE MAKEDIPROP(23)
11652
11653#define DIPROP_VIDPID MAKEDIPROP(24)
11654
11655#define DIPROP_USERNAME MAKEDIPROP(25)
11656
11657#define DIPROP_TYPENAME MAKEDIPROP(26)
11658#endif
11659
11660typedef struct DIDEVICEOBJECTDATA_DX3 {
11661 DWORD dwOfs;
11662 DWORD dwData;
11663 DWORD dwTimeStamp;
11664 DWORD dwSequence;
11665} DIDEVICEOBJECTDATA_DX3, *LPDIDEVICEOBJECTDATA_DX3;
11666typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX;
11667
11668typedef struct DIDEVICEOBJECTDATA {
11669 DWORD dwOfs;
11670 DWORD dwData;
11671 DWORD dwTimeStamp;
11672 DWORD dwSequence;
11673#if(DIRECTINPUT_VERSION >= 0x0800)
11674 UINT_PTR uAppData;
11675#endif
11676} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA;
11677typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA;
11678
11679#define DIGDD_PEEK 0x00000001
11680
11681#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \
11682 ((int)((dwSequence1) - (dwSequence2)) cmp 0)
11683#define DISCL_EXCLUSIVE 0x00000001
11684#define DISCL_NONEXCLUSIVE 0x00000002
11685#define DISCL_FOREGROUND 0x00000004
11686#define DISCL_BACKGROUND 0x00000008
11687#define DISCL_NOWINKEY 0x00000010
11688
11689#if(DIRECTINPUT_VERSION >= 0x0500)
11690
11691typedef struct DIDEVICEINSTANCE_DX3A {
11692 DWORD dwSize;
11693 GUID guidInstance;
11694 GUID guidProduct;
11695 DWORD dwDevType;
11696 CHAR tszInstanceName[MAX_PATH];
11697 CHAR tszProductName[MAX_PATH];
11698} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A;
11699typedef struct DIDEVICEINSTANCE_DX3W {
11700 DWORD dwSize;
11701 GUID guidInstance;
11702 GUID guidProduct;
11703 DWORD dwDevType;
11704 WCHAR tszInstanceName[MAX_PATH];
11705 WCHAR tszProductName[MAX_PATH];
11706} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W;
11707#ifdef UNICODE
11708typedef DIDEVICEINSTANCE_DX3W DIDEVICEINSTANCE_DX3;
11709typedef LPDIDEVICEINSTANCE_DX3W LPDIDEVICEINSTANCE_DX3;
11710#else
11711typedef DIDEVICEINSTANCE_DX3A DIDEVICEINSTANCE_DX3;
11712typedef LPDIDEVICEINSTANCE_DX3A LPDIDEVICEINSTANCE_DX3;
11713#endif
11714typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A;
11715typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W;
11716typedef const DIDEVICEINSTANCE_DX3 *LPCDIDEVICEINSTANCE_DX3;
11717#endif
11718
11719typedef struct DIDEVICEINSTANCEA {
11720 DWORD dwSize;
11721 GUID guidInstance;
11722 GUID guidProduct;
11723 DWORD dwDevType;
11724 CHAR tszInstanceName[MAX_PATH];
11725 CHAR tszProductName[MAX_PATH];
11726#if(DIRECTINPUT_VERSION >= 0x0500)
11727 GUID guidFFDriver;
11728 WORD wUsagePage;
11729 WORD wUsage;
11730#endif
11731} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA;
11732typedef struct DIDEVICEINSTANCEW {
11733 DWORD dwSize;
11734 GUID guidInstance;
11735 GUID guidProduct;
11736 DWORD dwDevType;
11737 WCHAR tszInstanceName[MAX_PATH];
11738 WCHAR tszProductName[MAX_PATH];
11739#if(DIRECTINPUT_VERSION >= 0x0500)
11740 GUID guidFFDriver;
11741 WORD wUsagePage;
11742 WORD wUsage;
11743#endif
11744} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
11745#ifdef UNICODE
11746typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE;
11747typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE;
11748#else
11749typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE;
11750typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE;
11751#endif
11752
11753typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
11754typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
11755#ifdef UNICODE
11756typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE;
11757typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE;
11758#else
11759typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE;
11760typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE;
11761#endif
11762typedef const DIDEVICEINSTANCE *LPCDIDEVICEINSTANCE;
11763
11764#undef INTERFACE
11765#define INTERFACE IDirectInputDeviceW
11766
11767DECLARE_INTERFACE_(IDirectInputDeviceW, IUnknown)
11768{
11769
11770 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
11771 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
11772 STDMETHOD_(ULONG,Release)(THIS) PURE;
11773
11774 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
11775 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE;
11776 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
11777 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
11778 STDMETHOD(Acquire)(THIS) PURE;
11779 STDMETHOD(Unacquire)(THIS) PURE;
11780 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
11781 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
11782 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
11783 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
11784 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
11785 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE;
11786 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE;
11787 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
11788 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
11789};
11790
11791typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW;
11792
11793#undef INTERFACE
11794#define INTERFACE IDirectInputDeviceA
11795
11796DECLARE_INTERFACE_(IDirectInputDeviceA, IUnknown)
11797{
11798
11799 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
11800 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
11801 STDMETHOD_(ULONG,Release)(THIS) PURE;
11802
11803 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
11804 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE;
11805 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
11806 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
11807 STDMETHOD(Acquire)(THIS) PURE;
11808 STDMETHOD(Unacquire)(THIS) PURE;
11809 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
11810 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
11811 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
11812 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
11813 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
11814 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE;
11815 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE;
11816 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
11817 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
11818};
11819
11820typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA;
11821
11822#ifdef UNICODE
11823#define IID_IDirectInputDevice IID_IDirectInputDeviceW
11824#define IDirectInputDevice IDirectInputDeviceW
11825#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl
11826#else
11827#define IID_IDirectInputDevice IID_IDirectInputDeviceA
11828#define IDirectInputDevice IDirectInputDeviceA
11829#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl
11830#endif
11831typedef struct IDirectInputDevice *LPDIRECTINPUTDEVICE;
11832
11833#if !defined(__cplusplus) || defined(CINTERFACE)
11834#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
11835#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p)
11836#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p)
11837#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
11838#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
11839#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
11840#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
11841#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p)
11842#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p)
11843#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
11844#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
11845#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
11846#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
11847#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
11848#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
11849#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
11850#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
11851#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
11852#else
11853#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
11854#define IDirectInputDevice_AddRef(p) (p)->AddRef()
11855#define IDirectInputDevice_Release(p) (p)->Release()
11856#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a)
11857#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
11858#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b)
11859#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b)
11860#define IDirectInputDevice_Acquire(p) (p)->Acquire()
11861#define IDirectInputDevice_Unacquire(p) (p)->Unacquire()
11862#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
11863#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
11864#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a)
11865#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a)
11866#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
11867#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
11868#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
11869#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
11870#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
11871#endif
11872
11873#endif
11874
11875#if(DIRECTINPUT_VERSION >= 0x0500)
11876
11877#define DISFFC_RESET 0x00000001
11878#define DISFFC_STOPALL 0x00000002
11879#define DISFFC_PAUSE 0x00000004
11880#define DISFFC_CONTINUE 0x00000008
11881#define DISFFC_SETACTUATORSON 0x00000010
11882#define DISFFC_SETACTUATORSOFF 0x00000020
11883
11884#define DIGFFS_EMPTY 0x00000001
11885#define DIGFFS_STOPPED 0x00000002
11886#define DIGFFS_PAUSED 0x00000004
11887#define DIGFFS_ACTUATORSON 0x00000010
11888#define DIGFFS_ACTUATORSOFF 0x00000020
11889#define DIGFFS_POWERON 0x00000040
11890#define DIGFFS_POWEROFF 0x00000080
11891#define DIGFFS_SAFETYSWITCHON 0x00000100
11892#define DIGFFS_SAFETYSWITCHOFF 0x00000200
11893#define DIGFFS_USERFFSWITCHON 0x00000400
11894#define DIGFFS_USERFFSWITCHOFF 0x00000800
11895#define DIGFFS_DEVICELOST 0x80000000
11896
11897#ifndef DIJ_RINGZERO
11898
11899typedef struct DIEFFECTINFOA {
11900 DWORD dwSize;
11901 GUID guid;
11902 DWORD dwEffType;
11903 DWORD dwStaticParams;
11904 DWORD dwDynamicParams;
11905 CHAR tszName[MAX_PATH];
11906} DIEFFECTINFOA, *LPDIEFFECTINFOA;
11907typedef struct DIEFFECTINFOW {
11908 DWORD dwSize;
11909 GUID guid;
11910 DWORD dwEffType;
11911 DWORD dwStaticParams;
11912 DWORD dwDynamicParams;
11913 WCHAR tszName[MAX_PATH];
11914} DIEFFECTINFOW, *LPDIEFFECTINFOW;
11915#ifdef UNICODE
11916typedef DIEFFECTINFOW DIEFFECTINFO;
11917typedef LPDIEFFECTINFOW LPDIEFFECTINFO;
11918#else
11919typedef DIEFFECTINFOA DIEFFECTINFO;
11920typedef LPDIEFFECTINFOA LPDIEFFECTINFO;
11921#endif
11922typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA;
11923typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW;
11924typedef const DIEFFECTINFO *LPCDIEFFECTINFO;
11925
11926#define DISDD_CONTINUE 0x00000001
11927
11928typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID);
11929typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID);
11930#ifdef UNICODE
11931#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKW
11932#else
11933#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKA
11934#endif
11935typedef BOOL (FAR PASCAL * LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID);
11936
11937#undef INTERFACE
11938#define INTERFACE IDirectInputDevice2W
11939
11940DECLARE_INTERFACE_(IDirectInputDevice2W, IDirectInputDeviceW)
11941{
11942
11943 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
11944 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
11945 STDMETHOD_(ULONG,Release)(THIS) PURE;
11946
11947 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
11948 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE;
11949 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
11950 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
11951 STDMETHOD(Acquire)(THIS) PURE;
11952 STDMETHOD(Unacquire)(THIS) PURE;
11953 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
11954 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
11955 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
11956 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
11957 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
11958 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE;
11959 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE;
11960 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
11961 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
11962
11963 STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE;
11964 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE;
11965 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE;
11966 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE;
11967 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE;
11968 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE;
11969 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
11970 STDMETHOD(Poll)(THIS) PURE;
11971 STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
11972};
11973
11974typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W;
11975
11976#undef INTERFACE
11977#define INTERFACE IDirectInputDevice2A
11978
11979DECLARE_INTERFACE_(IDirectInputDevice2A, IDirectInputDeviceA)
11980{
11981
11982 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
11983 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
11984 STDMETHOD_(ULONG,Release)(THIS) PURE;
11985
11986 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
11987 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE;
11988 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
11989 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
11990 STDMETHOD(Acquire)(THIS) PURE;
11991 STDMETHOD(Unacquire)(THIS) PURE;
11992 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
11993 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
11994 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
11995 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
11996 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
11997 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE;
11998 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE;
11999 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12000 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
12001
12002 STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE;
12003 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE;
12004 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE;
12005 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE;
12006 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE;
12007 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE;
12008 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
12009 STDMETHOD(Poll)(THIS) PURE;
12010 STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12011};
12012
12013typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A;
12014
12015#ifdef UNICODE
12016#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W
12017#define IDirectInputDevice2 IDirectInputDevice2W
12018#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl
12019#else
12020#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A
12021#define IDirectInputDevice2 IDirectInputDevice2A
12022#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl
12023#endif
12024typedef struct IDirectInputDevice2 *LPDIRECTINPUTDEVICE2;
12025
12026#if !defined(__cplusplus) || defined(CINTERFACE)
12027#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
12028#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p)
12029#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p)
12030#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
12031#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
12032#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
12033#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
12034#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p)
12035#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p)
12036#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
12037#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
12038#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
12039#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
12040#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
12041#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
12042#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
12043#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
12044#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
12045#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d)
12046#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c)
12047#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b)
12048#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a)
12049#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a)
12050#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
12051#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a)
12052#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p)
12053#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
12054#else
12055#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
12056#define IDirectInputDevice2_AddRef(p) (p)->AddRef()
12057#define IDirectInputDevice2_Release(p) (p)->Release()
12058#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a)
12059#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
12060#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b)
12061#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b)
12062#define IDirectInputDevice2_Acquire(p) (p)->Acquire()
12063#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire()
12064#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
12065#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
12066#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a)
12067#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a)
12068#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
12069#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
12070#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
12071#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
12072#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
12073#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d)
12074#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c)
12075#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b)
12076#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a)
12077#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a)
12078#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
12079#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a)
12080#define IDirectInputDevice2_Poll(p) (p)->Poll()
12081#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
12082#endif
12083
12084#endif
12085
12086#endif
12087
12088#if(DIRECTINPUT_VERSION >= 0x0700)
12089#define DIFEF_DEFAULT 0x00000000
12090#define DIFEF_INCLUDENONSTANDARD 0x00000001
12091#define DIFEF_MODIFYIFNEEDED 0x00000010
12092
12093#ifndef DIJ_RINGZERO
12094
12095#undef INTERFACE
12096#define INTERFACE IDirectInputDevice7W
12097
12098DECLARE_INTERFACE_(IDirectInputDevice7W, IDirectInputDevice2W)
12099{
12100
12101 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12102 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12103 STDMETHOD_(ULONG,Release)(THIS) PURE;
12104
12105 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
12106 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE;
12107 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
12108 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
12109 STDMETHOD(Acquire)(THIS) PURE;
12110 STDMETHOD(Unacquire)(THIS) PURE;
12111 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
12112 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12113 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
12114 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
12115 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
12116 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE;
12117 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE;
12118 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12119 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
12120 STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE;
12121 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE;
12122 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE;
12123 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE;
12124 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE;
12125 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE;
12126 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
12127 STDMETHOD(Poll)(THIS) PURE;
12128 STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12129
12130 STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE;
12131 STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE;
12132};
12133
12134typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W;
12135
12136#undef INTERFACE
12137#define INTERFACE IDirectInputDevice7A
12138
12139DECLARE_INTERFACE_(IDirectInputDevice7A, IDirectInputDevice2A)
12140{
12141
12142 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12143 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12144 STDMETHOD_(ULONG,Release)(THIS) PURE;
12145
12146 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
12147 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE;
12148 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
12149 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
12150 STDMETHOD(Acquire)(THIS) PURE;
12151 STDMETHOD(Unacquire)(THIS) PURE;
12152 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
12153 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12154 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
12155 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
12156 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
12157 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE;
12158 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE;
12159 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12160 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
12161 STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE;
12162 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE;
12163 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE;
12164 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE;
12165 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE;
12166 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE;
12167 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
12168 STDMETHOD(Poll)(THIS) PURE;
12169 STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12170
12171 STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE;
12172 STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE;
12173};
12174
12175typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A;
12176
12177#ifdef UNICODE
12178#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W
12179#define IDirectInputDevice7 IDirectInputDevice7W
12180#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl
12181#else
12182#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A
12183#define IDirectInputDevice7 IDirectInputDevice7A
12184#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl
12185#endif
12186typedef struct IDirectInputDevice7 *LPDIRECTINPUTDEVICE7;
12187
12188#if !defined(__cplusplus) || defined(CINTERFACE)
12189#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
12190#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p)
12191#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p)
12192#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
12193#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
12194#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
12195#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
12196#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p)
12197#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p)
12198#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
12199#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
12200#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
12201#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
12202#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
12203#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
12204#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
12205#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
12206#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
12207#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d)
12208#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c)
12209#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b)
12210#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a)
12211#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a)
12212#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
12213#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a)
12214#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p)
12215#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
12216#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
12217#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
12218#else
12219#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
12220#define IDirectInputDevice7_AddRef(p) (p)->AddRef()
12221#define IDirectInputDevice7_Release(p) (p)->Release()
12222#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a)
12223#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
12224#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b)
12225#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b)
12226#define IDirectInputDevice7_Acquire(p) (p)->Acquire()
12227#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire()
12228#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
12229#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
12230#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a)
12231#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a)
12232#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
12233#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
12234#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
12235#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
12236#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
12237#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d)
12238#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c)
12239#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b)
12240#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a)
12241#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a)
12242#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
12243#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a)
12244#define IDirectInputDevice7_Poll(p) (p)->Poll()
12245#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
12246#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
12247#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
12248#endif
12249
12250#endif
12251
12252#endif
12253
12254#if(DIRECTINPUT_VERSION >= 0x0800)
12255
12256#ifndef DIJ_RINGZERO
12257
12258#undef INTERFACE
12259#define INTERFACE IDirectInputDevice8W
12260
12261DECLARE_INTERFACE_(IDirectInputDevice8W, IUnknown)
12262{
12263
12264 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12265 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12266 STDMETHOD_(ULONG,Release)(THIS) PURE;
12267
12268 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
12269 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE;
12270 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
12271 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
12272 STDMETHOD(Acquire)(THIS) PURE;
12273 STDMETHOD(Unacquire)(THIS) PURE;
12274 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
12275 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12276 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
12277 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
12278 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
12279 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE;
12280 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE;
12281 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12282 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
12283 STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE;
12284 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE;
12285 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE;
12286 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE;
12287 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE;
12288 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE;
12289 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
12290 STDMETHOD(Poll)(THIS) PURE;
12291 STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12292 STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE;
12293 STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE;
12294 STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE;
12295 STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE;
12296 STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW) PURE;
12297};
12298
12299typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W;
12300
12301#undef INTERFACE
12302#define INTERFACE IDirectInputDevice8A
12303
12304DECLARE_INTERFACE_(IDirectInputDevice8A, IUnknown)
12305{
12306
12307 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12308 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12309 STDMETHOD_(ULONG,Release)(THIS) PURE;
12310
12311 STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE;
12312 STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE;
12313 STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE;
12314 STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE;
12315 STDMETHOD(Acquire)(THIS) PURE;
12316 STDMETHOD(Unacquire)(THIS) PURE;
12317 STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE;
12318 STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12319 STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE;
12320 STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE;
12321 STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE;
12322 STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE;
12323 STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE;
12324 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12325 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE;
12326 STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE;
12327 STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE;
12328 STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE;
12329 STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE;
12330 STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE;
12331 STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE;
12332 STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
12333 STDMETHOD(Poll)(THIS) PURE;
12334 STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE;
12335 STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE;
12336 STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE;
12337 STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE;
12338 STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE;
12339 STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA) PURE;
12340};
12341
12342typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A;
12343
12344#ifdef UNICODE
12345#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W
12346#define IDirectInputDevice8 IDirectInputDevice8W
12347#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl
12348#else
12349#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A
12350#define IDirectInputDevice8 IDirectInputDevice8A
12351#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl
12352#endif
12353typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8;
12354
12355#if !defined(__cplusplus) || defined(CINTERFACE)
12356#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
12357#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p)
12358#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p)
12359#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a)
12360#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c)
12361#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b)
12362#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b)
12363#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p)
12364#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p)
12365#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b)
12366#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
12367#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a)
12368#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a)
12369#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
12370#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c)
12371#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a)
12372#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
12373#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c)
12374#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d)
12375#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c)
12376#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b)
12377#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a)
12378#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a)
12379#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
12380#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a)
12381#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p)
12382#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
12383#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
12384#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
12385#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c)
12386#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c)
12387#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a)
12388#else
12389#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
12390#define IDirectInputDevice8_AddRef(p) (p)->AddRef()
12391#define IDirectInputDevice8_Release(p) (p)->Release()
12392#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a)
12393#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c)
12394#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b)
12395#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b)
12396#define IDirectInputDevice8_Acquire(p) (p)->Acquire()
12397#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire()
12398#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b)
12399#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d)
12400#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a)
12401#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a)
12402#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
12403#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c)
12404#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a)
12405#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
12406#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c)
12407#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d)
12408#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c)
12409#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b)
12410#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a)
12411#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a)
12412#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
12413#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a)
12414#define IDirectInputDevice8_Poll(p) (p)->Poll()
12415#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
12416#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
12417#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
12418#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c)
12419#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c)
12420#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a)
12421#endif
12422
12423#endif
12424
12425#endif
12426
12427#ifndef DIJ_RINGZERO
12428
12429typedef struct _DIMOUSESTATE {
12430 LONG lX;
12431 LONG lY;
12432 LONG lZ;
12433 BYTE rgbButtons[4];
12434} DIMOUSESTATE, *LPDIMOUSESTATE;
12435
12436#if DIRECTINPUT_VERSION >= 0x0700
12437typedef struct _DIMOUSESTATE2 {
12438 LONG lX;
12439 LONG lY;
12440 LONG lZ;
12441 BYTE rgbButtons[8];
12442} DIMOUSESTATE2, *LPDIMOUSESTATE2;
12443#endif
12444
12445#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX)
12446#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY)
12447#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ)
12448#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0)
12449#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1)
12450#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2)
12451#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3)
12452#if (DIRECTINPUT_VERSION >= 0x0700)
12453#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4)
12454#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5)
12455#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6)
12456#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7)
12457#endif
12458#endif
12459
12460#ifndef DIJ_RINGZERO
12461
12462#define DIK_ESCAPE 0x01
12463#define DIK_1 0x02
12464#define DIK_2 0x03
12465#define DIK_3 0x04
12466#define DIK_4 0x05
12467#define DIK_5 0x06
12468#define DIK_6 0x07
12469#define DIK_7 0x08
12470#define DIK_8 0x09
12471#define DIK_9 0x0A
12472#define DIK_0 0x0B
12473#define DIK_MINUS 0x0C
12474#define DIK_EQUALS 0x0D
12475#define DIK_BACK 0x0E
12476#define DIK_TAB 0x0F
12477#define DIK_Q 0x10
12478#define DIK_W 0x11
12479#define DIK_E 0x12
12480#define DIK_R 0x13
12481#define DIK_T 0x14
12482#define DIK_Y 0x15
12483#define DIK_U 0x16
12484#define DIK_I 0x17
12485#define DIK_O 0x18
12486#define DIK_P 0x19
12487#define DIK_LBRACKET 0x1A
12488#define DIK_RBRACKET 0x1B
12489#define DIK_RETURN 0x1C
12490#define DIK_LCONTROL 0x1D
12491#define DIK_A 0x1E
12492#define DIK_S 0x1F
12493#define DIK_D 0x20
12494#define DIK_F 0x21
12495#define DIK_G 0x22
12496#define DIK_H 0x23
12497#define DIK_J 0x24
12498#define DIK_K 0x25
12499#define DIK_L 0x26
12500#define DIK_SEMICOLON 0x27
12501#define DIK_APOSTROPHE 0x28
12502#define DIK_GRAVE 0x29
12503#define DIK_LSHIFT 0x2A
12504#define DIK_BACKSLASH 0x2B
12505#define DIK_Z 0x2C
12506#define DIK_X 0x2D
12507#define DIK_C 0x2E
12508#define DIK_V 0x2F
12509#define DIK_B 0x30
12510#define DIK_N 0x31
12511#define DIK_M 0x32
12512#define DIK_COMMA 0x33
12513#define DIK_PERIOD 0x34
12514#define DIK_SLASH 0x35
12515#define DIK_RSHIFT 0x36
12516#define DIK_MULTIPLY 0x37
12517#define DIK_LMENU 0x38
12518#define DIK_SPACE 0x39
12519#define DIK_CAPITAL 0x3A
12520#define DIK_F1 0x3B
12521#define DIK_F2 0x3C
12522#define DIK_F3 0x3D
12523#define DIK_F4 0x3E
12524#define DIK_F5 0x3F
12525#define DIK_F6 0x40
12526#define DIK_F7 0x41
12527#define DIK_F8 0x42
12528#define DIK_F9 0x43
12529#define DIK_F10 0x44
12530#define DIK_NUMLOCK 0x45
12531#define DIK_SCROLL 0x46
12532#define DIK_NUMPAD7 0x47
12533#define DIK_NUMPAD8 0x48
12534#define DIK_NUMPAD9 0x49
12535#define DIK_SUBTRACT 0x4A
12536#define DIK_NUMPAD4 0x4B
12537#define DIK_NUMPAD5 0x4C
12538#define DIK_NUMPAD6 0x4D
12539#define DIK_ADD 0x4E
12540#define DIK_NUMPAD1 0x4F
12541#define DIK_NUMPAD2 0x50
12542#define DIK_NUMPAD3 0x51
12543#define DIK_NUMPAD0 0x52
12544#define DIK_DECIMAL 0x53
12545#define DIK_OEM_102 0x56
12546#define DIK_F11 0x57
12547#define DIK_F12 0x58
12548#define DIK_F13 0x64
12549#define DIK_F14 0x65
12550#define DIK_F15 0x66
12551#define DIK_KANA 0x70
12552#define DIK_ABNT_C1 0x73
12553#define DIK_CONVERT 0x79
12554#define DIK_NOCONVERT 0x7B
12555#define DIK_YEN 0x7D
12556#define DIK_ABNT_C2 0x7E
12557#define DIK_NUMPADEQUALS 0x8D
12558#define DIK_PREVTRACK 0x90
12559#define DIK_AT 0x91
12560#define DIK_COLON 0x92
12561#define DIK_UNDERLINE 0x93
12562#define DIK_KANJI 0x94
12563#define DIK_STOP 0x95
12564#define DIK_AX 0x96
12565#define DIK_UNLABELED 0x97
12566#define DIK_NEXTTRACK 0x99
12567#define DIK_NUMPADENTER 0x9C
12568#define DIK_RCONTROL 0x9D
12569#define DIK_MUTE 0xA0
12570#define DIK_CALCULATOR 0xA1
12571#define DIK_PLAYPAUSE 0xA2
12572#define DIK_MEDIASTOP 0xA4
12573#define DIK_VOLUMEDOWN 0xAE
12574#define DIK_VOLUMEUP 0xB0
12575#define DIK_WEBHOME 0xB2
12576#define DIK_NUMPADCOMMA 0xB3
12577#define DIK_DIVIDE 0xB5
12578#define DIK_SYSRQ 0xB7
12579#define DIK_RMENU 0xB8
12580#define DIK_PAUSE 0xC5
12581#define DIK_HOME 0xC7
12582#define DIK_UP 0xC8
12583#define DIK_PRIOR 0xC9
12584#define DIK_LEFT 0xCB
12585#define DIK_RIGHT 0xCD
12586#define DIK_END 0xCF
12587#define DIK_DOWN 0xD0
12588#define DIK_NEXT 0xD1
12589#define DIK_INSERT 0xD2
12590#define DIK_DELETE 0xD3
12591#define DIK_LWIN 0xDB
12592#define DIK_RWIN 0xDC
12593#define DIK_APPS 0xDD
12594#define DIK_POWER 0xDE
12595#define DIK_SLEEP 0xDF
12596#define DIK_WAKE 0xE3
12597#define DIK_WEBSEARCH 0xE5
12598#define DIK_WEBFAVORITES 0xE6
12599#define DIK_WEBREFRESH 0xE7
12600#define DIK_WEBSTOP 0xE8
12601#define DIK_WEBFORWARD 0xE9
12602#define DIK_WEBBACK 0xEA
12603#define DIK_MYCOMPUTER 0xEB
12604#define DIK_MAIL 0xEC
12605#define DIK_MEDIASELECT 0xED
12606
12607#define DIK_BACKSPACE DIK_BACK
12608#define DIK_NUMPADSTAR DIK_MULTIPLY
12609#define DIK_LALT DIK_LMENU
12610#define DIK_CAPSLOCK DIK_CAPITAL
12611#define DIK_NUMPADMINUS DIK_SUBTRACT
12612#define DIK_NUMPADPLUS DIK_ADD
12613#define DIK_NUMPADPERIOD DIK_DECIMAL
12614#define DIK_NUMPADSLASH DIK_DIVIDE
12615#define DIK_RALT DIK_RMENU
12616#define DIK_UPARROW DIK_UP
12617#define DIK_PGUP DIK_PRIOR
12618#define DIK_LEFTARROW DIK_LEFT
12619#define DIK_RIGHTARROW DIK_RIGHT
12620#define DIK_DOWNARROW DIK_DOWN
12621#define DIK_PGDN DIK_NEXT
12622
12623#define DIK_CIRCUMFLEX DIK_PREVTRACK
12624
12625#endif
12626
12627#ifndef DIJ_RINGZERO
12628
12629typedef struct DIJOYSTATE {
12630 LONG lX;
12631 LONG lY;
12632 LONG lZ;
12633 LONG lRx;
12634 LONG lRy;
12635 LONG lRz;
12636 LONG rglSlider[2];
12637 DWORD rgdwPOV[4];
12638 BYTE rgbButtons[32];
12639} DIJOYSTATE, *LPDIJOYSTATE;
12640
12641typedef struct DIJOYSTATE2 {
12642 LONG lX;
12643 LONG lY;
12644 LONG lZ;
12645 LONG lRx;
12646 LONG lRy;
12647 LONG lRz;
12648 LONG rglSlider[2];
12649 DWORD rgdwPOV[4];
12650 BYTE rgbButtons[128];
12651 LONG lVX;
12652 LONG lVY;
12653 LONG lVZ;
12654 LONG lVRx;
12655 LONG lVRy;
12656 LONG lVRz;
12657 LONG rglVSlider[2];
12658 LONG lAX;
12659 LONG lAY;
12660 LONG lAZ;
12661 LONG lARx;
12662 LONG lARy;
12663 LONG lARz;
12664 LONG rglASlider[2];
12665 LONG lFX;
12666 LONG lFY;
12667 LONG lFZ;
12668 LONG lFRx;
12669 LONG lFRy;
12670 LONG lFRz;
12671 LONG rglFSlider[2];
12672} DIJOYSTATE2, *LPDIJOYSTATE2;
12673
12674#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX)
12675#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY)
12676#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ)
12677#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx)
12678#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy)
12679#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz)
12680#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \
12681 (n) * sizeof(LONG))
12682#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \
12683 (n) * sizeof(DWORD))
12684#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n))
12685#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0)
12686#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1)
12687#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2)
12688#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3)
12689#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4)
12690#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5)
12691#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6)
12692#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7)
12693#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8)
12694#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9)
12695#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10)
12696#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11)
12697#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12)
12698#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13)
12699#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14)
12700#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15)
12701#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16)
12702#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17)
12703#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18)
12704#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19)
12705#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20)
12706#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21)
12707#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22)
12708#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23)
12709#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24)
12710#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25)
12711#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26)
12712#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27)
12713#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28)
12714#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29)
12715#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30)
12716#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31)
12717
12718#endif
12719
12720#ifndef DIJ_RINGZERO
12721
12722#define DIENUM_STOP 0
12723#define DIENUM_CONTINUE 1
12724
12725typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID);
12726typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW, LPVOID);
12727#ifdef UNICODE
12728#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKW
12729#else
12730#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKA
12731#endif
12732typedef BOOL (FAR PASCAL * LPDICONFIGUREDEVICESCALLBACK)(IUnknown FAR *, LPVOID);
12733
12734#define DIEDFL_ALLDEVICES 0x00000000
12735#define DIEDFL_ATTACHEDONLY 0x00000001
12736#if(DIRECTINPUT_VERSION >= 0x0500)
12737#define DIEDFL_FORCEFEEDBACK 0x00000100
12738#endif
12739#if(DIRECTINPUT_VERSION >= 0x050a)
12740#define DIEDFL_INCLUDEALIASES 0x00010000
12741#define DIEDFL_INCLUDEPHANTOMS 0x00020000
12742#endif
12743#if(DIRECTINPUT_VERSION >= 0x0800)
12744#define DIEDFL_INCLUDEHIDDEN 0x00040000
12745#endif
12746
12747#if(DIRECTINPUT_VERSION >= 0x0800)
12748typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA, LPDIRECTINPUTDEVICE8A, DWORD, DWORD, LPVOID);
12749typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW, LPDIRECTINPUTDEVICE8W, DWORD, DWORD, LPVOID);
12750#ifdef UNICODE
12751#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBW
12752#else
12753#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBA
12754#endif
12755#endif
12756
12757#if(DIRECTINPUT_VERSION >= 0x0800)
12758#define DIEDBS_MAPPEDPRI1 0x00000001
12759#define DIEDBS_MAPPEDPRI2 0x00000002
12760#define DIEDBS_RECENTDEVICE 0x00000010
12761#define DIEDBS_NEWDEVICE 0x00000020
12762#endif
12763
12764#if(DIRECTINPUT_VERSION >= 0x0800)
12765#define DIEDBSFL_ATTACHEDONLY 0x00000000
12766#define DIEDBSFL_THISUSER 0x00000010
12767#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK
12768#define DIEDBSFL_AVAILABLEDEVICES 0x00001000
12769#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000
12770#define DIEDBSFL_NONGAMINGDEVICES 0x00004000
12771#define DIEDBSFL_VALID 0x00007110
12772#endif
12773
12774#undef INTERFACE
12775#define INTERFACE IDirectInputW
12776
12777DECLARE_INTERFACE_(IDirectInputW, IUnknown)
12778{
12779
12780 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12781 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12782 STDMETHOD_(ULONG,Release)(THIS) PURE;
12783
12784 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE;
12785 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE;
12786 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
12787 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12788 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
12789};
12790
12791typedef struct IDirectInputW *LPDIRECTINPUTW;
12792
12793#undef INTERFACE
12794#define INTERFACE IDirectInputA
12795
12796DECLARE_INTERFACE_(IDirectInputA, IUnknown)
12797{
12798
12799 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12800 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12801 STDMETHOD_(ULONG,Release)(THIS) PURE;
12802
12803 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE;
12804 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE;
12805 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
12806 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12807 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
12808};
12809
12810typedef struct IDirectInputA *LPDIRECTINPUTA;
12811
12812#ifdef UNICODE
12813#define IID_IDirectInput IID_IDirectInputW
12814#define IDirectInput IDirectInputW
12815#define IDirectInputVtbl IDirectInputWVtbl
12816#else
12817#define IID_IDirectInput IID_IDirectInputA
12818#define IDirectInput IDirectInputA
12819#define IDirectInputVtbl IDirectInputAVtbl
12820#endif
12821typedef struct IDirectInput *LPDIRECTINPUT;
12822
12823#if !defined(__cplusplus) || defined(CINTERFACE)
12824#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
12825#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p)
12826#define IDirectInput_Release(p) (p)->lpVtbl->Release(p)
12827#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
12828#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
12829#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
12830#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
12831#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
12832#else
12833#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
12834#define IDirectInput_AddRef(p) (p)->AddRef()
12835#define IDirectInput_Release(p) (p)->Release()
12836#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
12837#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
12838#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
12839#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
12840#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b)
12841#endif
12842
12843#undef INTERFACE
12844#define INTERFACE IDirectInput2W
12845
12846DECLARE_INTERFACE_(IDirectInput2W, IDirectInputW)
12847{
12848
12849 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12850 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12851 STDMETHOD_(ULONG,Release)(THIS) PURE;
12852
12853 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE;
12854 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE;
12855 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
12856 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12857 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
12858
12859 STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE;
12860};
12861
12862typedef struct IDirectInput2W *LPDIRECTINPUT2W;
12863
12864#undef INTERFACE
12865#define INTERFACE IDirectInput2A
12866
12867DECLARE_INTERFACE_(IDirectInput2A, IDirectInputA)
12868{
12869
12870 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12871 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12872 STDMETHOD_(ULONG,Release)(THIS) PURE;
12873
12874 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE;
12875 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE;
12876 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
12877 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12878 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
12879
12880 STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE;
12881};
12882
12883typedef struct IDirectInput2A *LPDIRECTINPUT2A;
12884
12885#ifdef UNICODE
12886#define IID_IDirectInput2 IID_IDirectInput2W
12887#define IDirectInput2 IDirectInput2W
12888#define IDirectInput2Vtbl IDirectInput2WVtbl
12889#else
12890#define IID_IDirectInput2 IID_IDirectInput2A
12891#define IDirectInput2 IDirectInput2A
12892#define IDirectInput2Vtbl IDirectInput2AVtbl
12893#endif
12894typedef struct IDirectInput2 *LPDIRECTINPUT2;
12895
12896#if !defined(__cplusplus) || defined(CINTERFACE)
12897#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
12898#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p)
12899#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p)
12900#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
12901#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
12902#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
12903#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
12904#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
12905#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
12906#else
12907#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
12908#define IDirectInput2_AddRef(p) (p)->AddRef()
12909#define IDirectInput2_Release(p) (p)->Release()
12910#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
12911#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
12912#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
12913#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
12914#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b)
12915#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
12916#endif
12917
12918#undef INTERFACE
12919#define INTERFACE IDirectInput7W
12920
12921DECLARE_INTERFACE_(IDirectInput7W, IDirectInput2W)
12922{
12923
12924 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12925 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12926 STDMETHOD_(ULONG,Release)(THIS) PURE;
12927
12928 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE;
12929 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE;
12930 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
12931 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12932 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
12933 STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE;
12934
12935 STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE;
12936};
12937
12938typedef struct IDirectInput7W *LPDIRECTINPUT7W;
12939
12940#undef INTERFACE
12941#define INTERFACE IDirectInput7A
12942
12943DECLARE_INTERFACE_(IDirectInput7A, IDirectInput2A)
12944{
12945
12946 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
12947 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
12948 STDMETHOD_(ULONG,Release)(THIS) PURE;
12949
12950 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE;
12951 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE;
12952 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
12953 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
12954 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
12955 STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE;
12956
12957 STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE;
12958};
12959
12960typedef struct IDirectInput7A *LPDIRECTINPUT7A;
12961
12962#ifdef UNICODE
12963#define IID_IDirectInput7 IID_IDirectInput7W
12964#define IDirectInput7 IDirectInput7W
12965#define IDirectInput7Vtbl IDirectInput7WVtbl
12966#else
12967#define IID_IDirectInput7 IID_IDirectInput7A
12968#define IDirectInput7 IDirectInput7A
12969#define IDirectInput7Vtbl IDirectInput7AVtbl
12970#endif
12971typedef struct IDirectInput7 *LPDIRECTINPUT7;
12972
12973#if !defined(__cplusplus) || defined(CINTERFACE)
12974#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
12975#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p)
12976#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p)
12977#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
12978#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
12979#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
12980#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
12981#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
12982#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
12983#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d)
12984#else
12985#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
12986#define IDirectInput7_AddRef(p) (p)->AddRef()
12987#define IDirectInput7_Release(p) (p)->Release()
12988#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
12989#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
12990#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
12991#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
12992#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b)
12993#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
12994#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d)
12995#endif
12996
12997#if(DIRECTINPUT_VERSION >= 0x0800)
12998#undef INTERFACE
12999#define INTERFACE IDirectInput8W
13000
13001DECLARE_INTERFACE_(IDirectInput8W, IUnknown)
13002{
13003
13004 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
13005 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
13006 STDMETHOD_(ULONG,Release)(THIS) PURE;
13007
13008 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8W *,LPUNKNOWN) PURE;
13009 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE;
13010 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
13011 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
13012 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
13013 STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE;
13014 STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR,LPDIACTIONFORMATW,LPDIENUMDEVICESBYSEMANTICSCBW,LPVOID,DWORD) PURE;
13015 STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSW,DWORD,LPVOID) PURE;
13016};
13017
13018typedef struct IDirectInput8W *LPDIRECTINPUT8W;
13019
13020#undef INTERFACE
13021#define INTERFACE IDirectInput8A
13022
13023DECLARE_INTERFACE_(IDirectInput8A, IUnknown)
13024{
13025
13026 STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
13027 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
13028 STDMETHOD_(ULONG,Release)(THIS) PURE;
13029
13030 STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8A *,LPUNKNOWN) PURE;
13031 STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE;
13032 STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE;
13033 STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE;
13034 STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE;
13035 STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE;
13036 STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR,LPDIACTIONFORMATA,LPDIENUMDEVICESBYSEMANTICSCBA,LPVOID,DWORD) PURE;
13037 STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSA,DWORD,LPVOID) PURE;
13038};
13039
13040typedef struct IDirectInput8A *LPDIRECTINPUT8A;
13041
13042#ifdef UNICODE
13043#define IID_IDirectInput8 IID_IDirectInput8W
13044#define IDirectInput8 IDirectInput8W
13045#define IDirectInput8Vtbl IDirectInput8WVtbl
13046#else
13047#define IID_IDirectInput8 IID_IDirectInput8A
13048#define IDirectInput8 IDirectInput8A
13049#define IDirectInput8Vtbl IDirectInput8AVtbl
13050#endif
13051typedef struct IDirectInput8 *LPDIRECTINPUT8;
13052
13053#if !defined(__cplusplus) || defined(CINTERFACE)
13054#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
13055#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p)
13056#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p)
13057#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
13058#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
13059#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
13060#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
13061#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
13062#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
13063#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
13064#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
13065#else
13066#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
13067#define IDirectInput8_AddRef(p) (p)->AddRef()
13068#define IDirectInput8_Release(p) (p)->Release()
13069#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c)
13070#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
13071#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a)
13072#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
13073#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b)
13074#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
13075#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e)
13076#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d)
13077#endif
13078#endif
13079
13080#if DIRECTINPUT_VERSION > 0x0700
13081
13082extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);
13083
13084#else
13085extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);
13086extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter);
13087#ifdef UNICODE
13088#define DirectInputCreate DirectInputCreateW
13089#else
13090#define DirectInputCreate DirectInputCreateA
13091#endif
13092
13093extern HRESULT WINAPI DirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);
13094
13095#endif
13096
13097#endif
13098
13099#define DI_OK S_OK
13100
13101#define DI_NOTATTACHED S_FALSE
13102
13103#define DI_BUFFEROVERFLOW S_FALSE
13104
13105#define DI_PROPNOEFFECT S_FALSE
13106
13107#define DI_NOEFFECT S_FALSE
13108
13109#define DI_POLLEDDEVICE ((HRESULT)0x00000002L)
13110
13111#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L)
13112
13113#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L)
13114
13115#define DI_TRUNCATED ((HRESULT)0x00000008L)
13116
13117#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL)
13118
13119#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL)
13120
13121#define DI_WRITEPROTECT ((HRESULT)0x00000013L)
13122
13123#define DIERR_OLDDIRECTINPUTVERSION \
13124 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION)
13125
13126#define DIERR_BETADIRECTINPUTVERSION \
13127 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP)
13128
13129#define DIERR_BADDRIVERVER \
13130 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL)
13131
13132#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG
13133
13134#define DIERR_NOTFOUND \
13135 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
13136
13137#define DIERR_OBJECTNOTFOUND \
13138 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
13139
13140#define DIERR_INVALIDPARAM E_INVALIDARG
13141
13142#define DIERR_NOINTERFACE E_NOINTERFACE
13143
13144#define DIERR_GENERIC E_FAIL
13145
13146#define DIERR_OUTOFMEMORY E_OUTOFMEMORY
13147
13148#define DIERR_UNSUPPORTED E_NOTIMPL
13149
13150#define DIERR_NOTINITIALIZED \
13151 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY)
13152
13153#define DIERR_ALREADYINITIALIZED \
13154 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED)
13155
13156#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION
13157
13158#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED
13159
13160#define DIERR_INPUTLOST \
13161 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT)
13162
13163#define DIERR_ACQUIRED \
13164 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY)
13165
13166#define DIERR_NOTACQUIRED \
13167 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS)
13168
13169#define DIERR_READONLY E_ACCESSDENIED
13170
13171#define DIERR_HANDLEEXISTS E_ACCESSDENIED
13172
13173#ifndef E_PENDING
13174#define E_PENDING 0x8000000AL
13175#endif
13176
13177#define DIERR_INSUFFICIENTPRIVS 0x80040200L
13178
13179#define DIERR_DEVICEFULL 0x80040201L
13180
13181#define DIERR_MOREDATA 0x80040202L
13182
13183#define DIERR_NOTDOWNLOADED 0x80040203L
13184
13185#define DIERR_HASEFFECTS 0x80040204L
13186
13187#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L
13188
13189#define DIERR_INCOMPLETEEFFECT 0x80040206L
13190
13191#define DIERR_NOTBUFFERED 0x80040207L
13192
13193#define DIERR_EFFECTPLAYING 0x80040208L
13194
13195#define DIERR_UNPLUGGED 0x80040209L
13196
13197#define DIERR_REPORTFULL 0x8004020AL
13198
13199#define DIERR_MAPFILEFAIL 0x8004020BL
13200
13201#define DIKEYBOARD_ESCAPE 0x81000401
13202#define DIKEYBOARD_1 0x81000402
13203#define DIKEYBOARD_2 0x81000403
13204#define DIKEYBOARD_3 0x81000404
13205#define DIKEYBOARD_4 0x81000405
13206#define DIKEYBOARD_5 0x81000406
13207#define DIKEYBOARD_6 0x81000407
13208#define DIKEYBOARD_7 0x81000408
13209#define DIKEYBOARD_8 0x81000409
13210#define DIKEYBOARD_9 0x8100040A
13211#define DIKEYBOARD_0 0x8100040B
13212#define DIKEYBOARD_MINUS 0x8100040C
13213#define DIKEYBOARD_EQUALS 0x8100040D
13214#define DIKEYBOARD_BACK 0x8100040E
13215#define DIKEYBOARD_TAB 0x8100040F
13216#define DIKEYBOARD_Q 0x81000410
13217#define DIKEYBOARD_W 0x81000411
13218#define DIKEYBOARD_E 0x81000412
13219#define DIKEYBOARD_R 0x81000413
13220#define DIKEYBOARD_T 0x81000414
13221#define DIKEYBOARD_Y 0x81000415
13222#define DIKEYBOARD_U 0x81000416
13223#define DIKEYBOARD_I 0x81000417
13224#define DIKEYBOARD_O 0x81000418
13225#define DIKEYBOARD_P 0x81000419
13226#define DIKEYBOARD_LBRACKET 0x8100041A
13227#define DIKEYBOARD_RBRACKET 0x8100041B
13228#define DIKEYBOARD_RETURN 0x8100041C
13229#define DIKEYBOARD_LCONTROL 0x8100041D
13230#define DIKEYBOARD_A 0x8100041E
13231#define DIKEYBOARD_S 0x8100041F
13232#define DIKEYBOARD_D 0x81000420
13233#define DIKEYBOARD_F 0x81000421
13234#define DIKEYBOARD_G 0x81000422
13235#define DIKEYBOARD_H 0x81000423
13236#define DIKEYBOARD_J 0x81000424
13237#define DIKEYBOARD_K 0x81000425
13238#define DIKEYBOARD_L 0x81000426
13239#define DIKEYBOARD_SEMICOLON 0x81000427
13240#define DIKEYBOARD_APOSTROPHE 0x81000428
13241#define DIKEYBOARD_GRAVE 0x81000429
13242#define DIKEYBOARD_LSHIFT 0x8100042A
13243#define DIKEYBOARD_BACKSLASH 0x8100042B
13244#define DIKEYBOARD_Z 0x8100042C
13245#define DIKEYBOARD_X 0x8100042D
13246#define DIKEYBOARD_C 0x8100042E
13247#define DIKEYBOARD_V 0x8100042F
13248#define DIKEYBOARD_B 0x81000430
13249#define DIKEYBOARD_N 0x81000431
13250#define DIKEYBOARD_M 0x81000432
13251#define DIKEYBOARD_COMMA 0x81000433
13252#define DIKEYBOARD_PERIOD 0x81000434
13253#define DIKEYBOARD_SLASH 0x81000435
13254#define DIKEYBOARD_RSHIFT 0x81000436
13255#define DIKEYBOARD_MULTIPLY 0x81000437
13256#define DIKEYBOARD_LMENU 0x81000438
13257#define DIKEYBOARD_SPACE 0x81000439
13258#define DIKEYBOARD_CAPITAL 0x8100043A
13259#define DIKEYBOARD_F1 0x8100043B
13260#define DIKEYBOARD_F2 0x8100043C
13261#define DIKEYBOARD_F3 0x8100043D
13262#define DIKEYBOARD_F4 0x8100043E
13263#define DIKEYBOARD_F5 0x8100043F
13264#define DIKEYBOARD_F6 0x81000440
13265#define DIKEYBOARD_F7 0x81000441
13266#define DIKEYBOARD_F8 0x81000442
13267#define DIKEYBOARD_F9 0x81000443
13268#define DIKEYBOARD_F10 0x81000444
13269#define DIKEYBOARD_NUMLOCK 0x81000445
13270#define DIKEYBOARD_SCROLL 0x81000446
13271#define DIKEYBOARD_NUMPAD7 0x81000447
13272#define DIKEYBOARD_NUMPAD8 0x81000448
13273#define DIKEYBOARD_NUMPAD9 0x81000449
13274#define DIKEYBOARD_SUBTRACT 0x8100044A
13275#define DIKEYBOARD_NUMPAD4 0x8100044B
13276#define DIKEYBOARD_NUMPAD5 0x8100044C
13277#define DIKEYBOARD_NUMPAD6 0x8100044D
13278#define DIKEYBOARD_ADD 0x8100044E
13279#define DIKEYBOARD_NUMPAD1 0x8100044F
13280#define DIKEYBOARD_NUMPAD2 0x81000450
13281#define DIKEYBOARD_NUMPAD3 0x81000451
13282#define DIKEYBOARD_NUMPAD0 0x81000452
13283#define DIKEYBOARD_DECIMAL 0x81000453
13284#define DIKEYBOARD_OEM_102 0x81000456
13285#define DIKEYBOARD_F11 0x81000457
13286#define DIKEYBOARD_F12 0x81000458
13287#define DIKEYBOARD_F13 0x81000464
13288#define DIKEYBOARD_F14 0x81000465
13289#define DIKEYBOARD_F15 0x81000466
13290#define DIKEYBOARD_KANA 0x81000470
13291#define DIKEYBOARD_ABNT_C1 0x81000473
13292#define DIKEYBOARD_CONVERT 0x81000479
13293#define DIKEYBOARD_NOCONVERT 0x8100047B
13294#define DIKEYBOARD_YEN 0x8100047D
13295#define DIKEYBOARD_ABNT_C2 0x8100047E
13296#define DIKEYBOARD_NUMPADEQUALS 0x8100048D
13297#define DIKEYBOARD_PREVTRACK 0x81000490
13298#define DIKEYBOARD_AT 0x81000491
13299#define DIKEYBOARD_COLON 0x81000492
13300#define DIKEYBOARD_UNDERLINE 0x81000493
13301#define DIKEYBOARD_KANJI 0x81000494
13302#define DIKEYBOARD_STOP 0x81000495
13303#define DIKEYBOARD_AX 0x81000496
13304#define DIKEYBOARD_UNLABELED 0x81000497
13305#define DIKEYBOARD_NEXTTRACK 0x81000499
13306#define DIKEYBOARD_NUMPADENTER 0x8100049C
13307#define DIKEYBOARD_RCONTROL 0x8100049D
13308#define DIKEYBOARD_MUTE 0x810004A0
13309#define DIKEYBOARD_CALCULATOR 0x810004A1
13310#define DIKEYBOARD_PLAYPAUSE 0x810004A2
13311#define DIKEYBOARD_MEDIASTOP 0x810004A4
13312#define DIKEYBOARD_VOLUMEDOWN 0x810004AE
13313#define DIKEYBOARD_VOLUMEUP 0x810004B0
13314#define DIKEYBOARD_WEBHOME 0x810004B2
13315#define DIKEYBOARD_NUMPADCOMMA 0x810004B3
13316#define DIKEYBOARD_DIVIDE 0x810004B5
13317#define DIKEYBOARD_SYSRQ 0x810004B7
13318#define DIKEYBOARD_RMENU 0x810004B8
13319#define DIKEYBOARD_PAUSE 0x810004C5
13320#define DIKEYBOARD_HOME 0x810004C7
13321#define DIKEYBOARD_UP 0x810004C8
13322#define DIKEYBOARD_PRIOR 0x810004C9
13323#define DIKEYBOARD_LEFT 0x810004CB
13324#define DIKEYBOARD_RIGHT 0x810004CD
13325#define DIKEYBOARD_END 0x810004CF
13326#define DIKEYBOARD_DOWN 0x810004D0
13327#define DIKEYBOARD_NEXT 0x810004D1
13328#define DIKEYBOARD_INSERT 0x810004D2
13329#define DIKEYBOARD_DELETE 0x810004D3
13330#define DIKEYBOARD_LWIN 0x810004DB
13331#define DIKEYBOARD_RWIN 0x810004DC
13332#define DIKEYBOARD_APPS 0x810004DD
13333#define DIKEYBOARD_POWER 0x810004DE
13334#define DIKEYBOARD_SLEEP 0x810004DF
13335#define DIKEYBOARD_WAKE 0x810004E3
13336#define DIKEYBOARD_WEBSEARCH 0x810004E5
13337#define DIKEYBOARD_WEBFAVORITES 0x810004E6
13338#define DIKEYBOARD_WEBREFRESH 0x810004E7
13339#define DIKEYBOARD_WEBSTOP 0x810004E8
13340#define DIKEYBOARD_WEBFORWARD 0x810004E9
13341#define DIKEYBOARD_WEBBACK 0x810004EA
13342#define DIKEYBOARD_MYCOMPUTER 0x810004EB
13343#define DIKEYBOARD_MAIL 0x810004EC
13344#define DIKEYBOARD_MEDIASELECT 0x810004ED
13345
13346#define DIMOUSE_XAXISAB (0x82000200 |DIMOFS_X )
13347#define DIMOUSE_YAXISAB (0x82000200 |DIMOFS_Y )
13348#define DIMOUSE_XAXIS (0x82000300 |DIMOFS_X )
13349#define DIMOUSE_YAXIS (0x82000300 |DIMOFS_Y )
13350#define DIMOUSE_WHEEL (0x82000300 |DIMOFS_Z )
13351#define DIMOUSE_BUTTON0 (0x82000400 |DIMOFS_BUTTON0)
13352#define DIMOUSE_BUTTON1 (0x82000400 |DIMOFS_BUTTON1)
13353#define DIMOUSE_BUTTON2 (0x82000400 |DIMOFS_BUTTON2)
13354#define DIMOUSE_BUTTON3 (0x82000400 |DIMOFS_BUTTON3)
13355#define DIMOUSE_BUTTON4 (0x82000400 |DIMOFS_BUTTON4)
13356#define DIMOUSE_BUTTON5 (0x82000400 |DIMOFS_BUTTON5)
13357#define DIMOUSE_BUTTON6 (0x82000400 |DIMOFS_BUTTON6)
13358#define DIMOUSE_BUTTON7 (0x82000400 |DIMOFS_BUTTON7)
13359
13360#define DIVOICE_CHANNEL1 0x83000401
13361#define DIVOICE_CHANNEL2 0x83000402
13362#define DIVOICE_CHANNEL3 0x83000403
13363#define DIVOICE_CHANNEL4 0x83000404
13364#define DIVOICE_CHANNEL5 0x83000405
13365#define DIVOICE_CHANNEL6 0x83000406
13366#define DIVOICE_CHANNEL7 0x83000407
13367#define DIVOICE_CHANNEL8 0x83000408
13368#define DIVOICE_TEAM 0x83000409
13369#define DIVOICE_ALL 0x8300040A
13370#define DIVOICE_RECORDMUTE 0x8300040B
13371#define DIVOICE_PLAYBACKMUTE 0x8300040C
13372#define DIVOICE_TRANSMIT 0x8300040D
13373
13374#define DIVOICE_VOICECOMMAND 0x83000410
13375
13376#define DIVIRTUAL_DRIVING_RACE 0x01000000
13377#define DIAXIS_DRIVINGR_STEER 0x01008A01
13378#define DIAXIS_DRIVINGR_ACCELERATE 0x01039202
13379#define DIAXIS_DRIVINGR_BRAKE 0x01041203
13380#define DIBUTTON_DRIVINGR_SHIFTUP 0x01000C01
13381#define DIBUTTON_DRIVINGR_SHIFTDOWN 0x01000C02
13382#define DIBUTTON_DRIVINGR_VIEW 0x01001C03
13383#define DIBUTTON_DRIVINGR_MENU 0x010004FD
13384
13385#define DIAXIS_DRIVINGR_ACCEL_AND_BRAKE 0x01014A04
13386#define DIHATSWITCH_DRIVINGR_GLANCE 0x01004601
13387#define DIBUTTON_DRIVINGR_BRAKE 0x01004C04
13388#define DIBUTTON_DRIVINGR_DASHBOARD 0x01004405
13389#define DIBUTTON_DRIVINGR_AIDS 0x01004406
13390#define DIBUTTON_DRIVINGR_MAP 0x01004407
13391#define DIBUTTON_DRIVINGR_BOOST 0x01004408
13392#define DIBUTTON_DRIVINGR_PIT 0x01004409
13393#define DIBUTTON_DRIVINGR_ACCELERATE_LINK 0x0103D4E0
13394#define DIBUTTON_DRIVINGR_STEER_LEFT_LINK 0x0100CCE4
13395#define DIBUTTON_DRIVINGR_STEER_RIGHT_LINK 0x0100CCEC
13396#define DIBUTTON_DRIVINGR_GLANCE_LEFT_LINK 0x0107C4E4
13397#define DIBUTTON_DRIVINGR_GLANCE_RIGHT_LINK 0x0107C4EC
13398#define DIBUTTON_DRIVINGR_DEVICE 0x010044FE
13399#define DIBUTTON_DRIVINGR_PAUSE 0x010044FC
13400
13401#define DIVIRTUAL_DRIVING_COMBAT 0x02000000
13402#define DIAXIS_DRIVINGC_STEER 0x02008A01
13403#define DIAXIS_DRIVINGC_ACCELERATE 0x02039202
13404#define DIAXIS_DRIVINGC_BRAKE 0x02041203
13405#define DIBUTTON_DRIVINGC_FIRE 0x02000C01
13406#define DIBUTTON_DRIVINGC_WEAPONS 0x02000C02
13407#define DIBUTTON_DRIVINGC_TARGET 0x02000C03
13408#define DIBUTTON_DRIVINGC_MENU 0x020004FD
13409
13410#define DIAXIS_DRIVINGC_ACCEL_AND_BRAKE 0x02014A04
13411#define DIHATSWITCH_DRIVINGC_GLANCE 0x02004601
13412#define DIBUTTON_DRIVINGC_SHIFTUP 0x02004C04
13413#define DIBUTTON_DRIVINGC_SHIFTDOWN 0x02004C05
13414#define DIBUTTON_DRIVINGC_DASHBOARD 0x02004406
13415#define DIBUTTON_DRIVINGC_AIDS 0x02004407
13416#define DIBUTTON_DRIVINGC_BRAKE 0x02004C08
13417#define DIBUTTON_DRIVINGC_FIRESECONDARY 0x02004C09
13418#define DIBUTTON_DRIVINGC_ACCELERATE_LINK 0x0203D4E0
13419#define DIBUTTON_DRIVINGC_STEER_LEFT_LINK 0x0200CCE4
13420#define DIBUTTON_DRIVINGC_STEER_RIGHT_LINK 0x0200CCEC
13421#define DIBUTTON_DRIVINGC_GLANCE_LEFT_LINK 0x0207C4E4
13422#define DIBUTTON_DRIVINGC_GLANCE_RIGHT_LINK 0x0207C4EC
13423#define DIBUTTON_DRIVINGC_DEVICE 0x020044FE
13424#define DIBUTTON_DRIVINGC_PAUSE 0x020044FC
13425
13426#define DIVIRTUAL_DRIVING_TANK 0x03000000
13427#define DIAXIS_DRIVINGT_STEER 0x03008A01
13428#define DIAXIS_DRIVINGT_BARREL 0x03010202
13429#define DIAXIS_DRIVINGT_ACCELERATE 0x03039203
13430#define DIAXIS_DRIVINGT_ROTATE 0x03020204
13431#define DIBUTTON_DRIVINGT_FIRE 0x03000C01
13432#define DIBUTTON_DRIVINGT_WEAPONS 0x03000C02
13433#define DIBUTTON_DRIVINGT_TARGET 0x03000C03
13434#define DIBUTTON_DRIVINGT_MENU 0x030004FD
13435
13436#define DIHATSWITCH_DRIVINGT_GLANCE 0x03004601
13437#define DIAXIS_DRIVINGT_BRAKE 0x03045205
13438#define DIAXIS_DRIVINGT_ACCEL_AND_BRAKE 0x03014A06
13439#define DIBUTTON_DRIVINGT_VIEW 0x03005C04
13440#define DIBUTTON_DRIVINGT_DASHBOARD 0x03005C05
13441#define DIBUTTON_DRIVINGT_BRAKE 0x03004C06
13442#define DIBUTTON_DRIVINGT_FIRESECONDARY 0x03004C07
13443#define DIBUTTON_DRIVINGT_ACCELERATE_LINK 0x0303D4E0
13444#define DIBUTTON_DRIVINGT_STEER_LEFT_LINK 0x0300CCE4
13445#define DIBUTTON_DRIVINGT_STEER_RIGHT_LINK 0x0300CCEC
13446#define DIBUTTON_DRIVINGT_BARREL_UP_LINK 0x030144E0
13447#define DIBUTTON_DRIVINGT_BARREL_DOWN_LINK 0x030144E8
13448#define DIBUTTON_DRIVINGT_ROTATE_LEFT_LINK 0x030244E4
13449#define DIBUTTON_DRIVINGT_ROTATE_RIGHT_LINK 0x030244EC
13450#define DIBUTTON_DRIVINGT_GLANCE_LEFT_LINK 0x0307C4E4
13451#define DIBUTTON_DRIVINGT_GLANCE_RIGHT_LINK 0x0307C4EC
13452#define DIBUTTON_DRIVINGT_DEVICE 0x030044FE
13453#define DIBUTTON_DRIVINGT_PAUSE 0x030044FC
13454
13455#define DIVIRTUAL_FLYING_CIVILIAN 0x04000000
13456#define DIAXIS_FLYINGC_BANK 0x04008A01
13457#define DIAXIS_FLYINGC_PITCH 0x04010A02
13458#define DIAXIS_FLYINGC_THROTTLE 0x04039203
13459#define DIBUTTON_FLYINGC_VIEW 0x04002401
13460#define DIBUTTON_FLYINGC_DISPLAY 0x04002402
13461#define DIBUTTON_FLYINGC_GEAR 0x04002C03
13462#define DIBUTTON_FLYINGC_MENU 0x040004FD
13463
13464#define DIHATSWITCH_FLYINGC_GLANCE 0x04004601
13465#define DIAXIS_FLYINGC_BRAKE 0x04046A04
13466#define DIAXIS_FLYINGC_RUDDER 0x04025205
13467#define DIAXIS_FLYINGC_FLAPS 0x04055A06
13468#define DIBUTTON_FLYINGC_FLAPSUP 0x04006404
13469#define DIBUTTON_FLYINGC_FLAPSDOWN 0x04006405
13470#define DIBUTTON_FLYINGC_BRAKE_LINK 0x04046CE0
13471#define DIBUTTON_FLYINGC_FASTER_LINK 0x0403D4E0
13472#define DIBUTTON_FLYINGC_SLOWER_LINK 0x0403D4E8
13473#define DIBUTTON_FLYINGC_GLANCE_LEFT_LINK 0x0407C4E4
13474#define DIBUTTON_FLYINGC_GLANCE_RIGHT_LINK 0x0407C4EC
13475#define DIBUTTON_FLYINGC_GLANCE_UP_LINK 0x0407C4E0
13476#define DIBUTTON_FLYINGC_GLANCE_DOWN_LINK 0x0407C4E8
13477#define DIBUTTON_FLYINGC_DEVICE 0x040044FE
13478#define DIBUTTON_FLYINGC_PAUSE 0x040044FC
13479
13480#define DIVIRTUAL_FLYING_MILITARY 0x05000000
13481#define DIAXIS_FLYINGM_BANK 0x05008A01
13482#define DIAXIS_FLYINGM_PITCH 0x05010A02
13483#define DIAXIS_FLYINGM_THROTTLE 0x05039203
13484#define DIBUTTON_FLYINGM_FIRE 0x05000C01
13485#define DIBUTTON_FLYINGM_WEAPONS 0x05000C02
13486#define DIBUTTON_FLYINGM_TARGET 0x05000C03
13487#define DIBUTTON_FLYINGM_MENU 0x050004FD
13488
13489#define DIHATSWITCH_FLYINGM_GLANCE 0x05004601
13490#define DIBUTTON_FLYINGM_COUNTER 0x05005C04
13491#define DIAXIS_FLYINGM_RUDDER 0x05024A04
13492#define DIAXIS_FLYINGM_BRAKE 0x05046205
13493#define DIBUTTON_FLYINGM_VIEW 0x05006405
13494#define DIBUTTON_FLYINGM_DISPLAY 0x05006406
13495#define DIAXIS_FLYINGM_FLAPS 0x05055206
13496#define DIBUTTON_FLYINGM_FLAPSUP 0x05005407
13497#define DIBUTTON_FLYINGM_FLAPSDOWN 0x05005408
13498#define DIBUTTON_FLYINGM_FIRESECONDARY 0x05004C09
13499#define DIBUTTON_FLYINGM_GEAR 0x0500640A
13500#define DIBUTTON_FLYINGM_BRAKE_LINK 0x050464E0
13501#define DIBUTTON_FLYINGM_FASTER_LINK 0x0503D4E0
13502#define DIBUTTON_FLYINGM_SLOWER_LINK 0x0503D4E8
13503#define DIBUTTON_FLYINGM_GLANCE_LEFT_LINK 0x0507C4E4
13504#define DIBUTTON_FLYINGM_GLANCE_RIGHT_LINK 0x0507C4EC
13505#define DIBUTTON_FLYINGM_GLANCE_UP_LINK 0x0507C4E0
13506#define DIBUTTON_FLYINGM_GLANCE_DOWN_LINK 0x0507C4E8
13507#define DIBUTTON_FLYINGM_DEVICE 0x050044FE
13508#define DIBUTTON_FLYINGM_PAUSE 0x050044FC
13509
13510#define DIVIRTUAL_FLYING_HELICOPTER 0x06000000
13511#define DIAXIS_FLYINGH_BANK 0x06008A01
13512#define DIAXIS_FLYINGH_PITCH 0x06010A02
13513#define DIAXIS_FLYINGH_COLLECTIVE 0x06018A03
13514#define DIBUTTON_FLYINGH_FIRE 0x06001401
13515#define DIBUTTON_FLYINGH_WEAPONS 0x06001402
13516#define DIBUTTON_FLYINGH_TARGET 0x06001403
13517#define DIBUTTON_FLYINGH_MENU 0x060004FD
13518
13519#define DIHATSWITCH_FLYINGH_GLANCE 0x06004601
13520#define DIAXIS_FLYINGH_TORQUE 0x06025A04
13521#define DIAXIS_FLYINGH_THROTTLE 0x0603DA05
13522#define DIBUTTON_FLYINGH_COUNTER 0x06005404
13523#define DIBUTTON_FLYINGH_VIEW 0x06006405
13524#define DIBUTTON_FLYINGH_GEAR 0x06006406
13525#define DIBUTTON_FLYINGH_FIRESECONDARY 0x06004C07
13526#define DIBUTTON_FLYINGH_FASTER_LINK 0x0603DCE0
13527#define DIBUTTON_FLYINGH_SLOWER_LINK 0x0603DCE8
13528#define DIBUTTON_FLYINGH_GLANCE_LEFT_LINK 0x0607C4E4
13529#define DIBUTTON_FLYINGH_GLANCE_RIGHT_LINK 0x0607C4EC
13530#define DIBUTTON_FLYINGH_GLANCE_UP_LINK 0x0607C4E0
13531#define DIBUTTON_FLYINGH_GLANCE_DOWN_LINK 0x0607C4E8
13532#define DIBUTTON_FLYINGH_DEVICE 0x060044FE
13533#define DIBUTTON_FLYINGH_PAUSE 0x060044FC
13534
13535#define DIVIRTUAL_SPACESIM 0x07000000
13536#define DIAXIS_SPACESIM_LATERAL 0x07008201
13537#define DIAXIS_SPACESIM_MOVE 0x07010202
13538#define DIAXIS_SPACESIM_THROTTLE 0x07038203
13539#define DIBUTTON_SPACESIM_FIRE 0x07000401
13540#define DIBUTTON_SPACESIM_WEAPONS 0x07000402
13541#define DIBUTTON_SPACESIM_TARGET 0x07000403
13542#define DIBUTTON_SPACESIM_MENU 0x070004FD
13543
13544#define DIHATSWITCH_SPACESIM_GLANCE 0x07004601
13545#define DIAXIS_SPACESIM_CLIMB 0x0701C204
13546#define DIAXIS_SPACESIM_ROTATE 0x07024205
13547#define DIBUTTON_SPACESIM_VIEW 0x07004404
13548#define DIBUTTON_SPACESIM_DISPLAY 0x07004405
13549#define DIBUTTON_SPACESIM_RAISE 0x07004406
13550#define DIBUTTON_SPACESIM_LOWER 0x07004407
13551#define DIBUTTON_SPACESIM_GEAR 0x07004408
13552#define DIBUTTON_SPACESIM_FIRESECONDARY 0x07004409
13553#define DIBUTTON_SPACESIM_LEFT_LINK 0x0700C4E4
13554#define DIBUTTON_SPACESIM_RIGHT_LINK 0x0700C4EC
13555#define DIBUTTON_SPACESIM_FORWARD_LINK 0x070144E0
13556#define DIBUTTON_SPACESIM_BACKWARD_LINK 0x070144E8
13557#define DIBUTTON_SPACESIM_FASTER_LINK 0x0703C4E0
13558#define DIBUTTON_SPACESIM_SLOWER_LINK 0x0703C4E8
13559#define DIBUTTON_SPACESIM_TURN_LEFT_LINK 0x070244E4
13560#define DIBUTTON_SPACESIM_TURN_RIGHT_LINK 0x070244EC
13561#define DIBUTTON_SPACESIM_GLANCE_LEFT_LINK 0x0707C4E4
13562#define DIBUTTON_SPACESIM_GLANCE_RIGHT_LINK 0x0707C4EC
13563#define DIBUTTON_SPACESIM_GLANCE_UP_LINK 0x0707C4E0
13564#define DIBUTTON_SPACESIM_GLANCE_DOWN_LINK 0x0707C4E8
13565#define DIBUTTON_SPACESIM_DEVICE 0x070044FE
13566#define DIBUTTON_SPACESIM_PAUSE 0x070044FC
13567
13568#define DIVIRTUAL_FIGHTING_HAND2HAND 0x08000000
13569#define DIAXIS_FIGHTINGH_LATERAL 0x08008201
13570#define DIAXIS_FIGHTINGH_MOVE 0x08010202
13571#define DIBUTTON_FIGHTINGH_PUNCH 0x08000401
13572#define DIBUTTON_FIGHTINGH_KICK 0x08000402
13573#define DIBUTTON_FIGHTINGH_BLOCK 0x08000403
13574#define DIBUTTON_FIGHTINGH_CROUCH 0x08000404
13575#define DIBUTTON_FIGHTINGH_JUMP 0x08000405
13576#define DIBUTTON_FIGHTINGH_SPECIAL1 0x08000406
13577#define DIBUTTON_FIGHTINGH_SPECIAL2 0x08000407
13578#define DIBUTTON_FIGHTINGH_MENU 0x080004FD
13579
13580#define DIBUTTON_FIGHTINGH_SELECT 0x08004408
13581#define DIHATSWITCH_FIGHTINGH_SLIDE 0x08004601
13582#define DIBUTTON_FIGHTINGH_DISPLAY 0x08004409
13583#define DIAXIS_FIGHTINGH_ROTATE 0x08024203
13584#define DIBUTTON_FIGHTINGH_DODGE 0x0800440A
13585#define DIBUTTON_FIGHTINGH_LEFT_LINK 0x0800C4E4
13586#define DIBUTTON_FIGHTINGH_RIGHT_LINK 0x0800C4EC
13587#define DIBUTTON_FIGHTINGH_FORWARD_LINK 0x080144E0
13588#define DIBUTTON_FIGHTINGH_BACKWARD_LINK 0x080144E8
13589#define DIBUTTON_FIGHTINGH_DEVICE 0x080044FE
13590#define DIBUTTON_FIGHTINGH_PAUSE 0x080044FC
13591
13592#define DIVIRTUAL_FIGHTING_FPS 0x09000000
13593#define DIAXIS_FPS_ROTATE 0x09008201
13594#define DIAXIS_FPS_MOVE 0x09010202
13595#define DIBUTTON_FPS_FIRE 0x09000401
13596#define DIBUTTON_FPS_WEAPONS 0x09000402
13597#define DIBUTTON_FPS_APPLY 0x09000403
13598#define DIBUTTON_FPS_SELECT 0x09000404
13599#define DIBUTTON_FPS_CROUCH 0x09000405
13600#define DIBUTTON_FPS_JUMP 0x09000406
13601#define DIAXIS_FPS_LOOKUPDOWN 0x09018203
13602#define DIBUTTON_FPS_STRAFE 0x09000407
13603#define DIBUTTON_FPS_MENU 0x090004FD
13604
13605#define DIHATSWITCH_FPS_GLANCE 0x09004601
13606#define DIBUTTON_FPS_DISPLAY 0x09004408
13607#define DIAXIS_FPS_SIDESTEP 0x09024204
13608#define DIBUTTON_FPS_DODGE 0x09004409
13609#define DIBUTTON_FPS_GLANCEL 0x0900440A
13610#define DIBUTTON_FPS_GLANCER 0x0900440B
13611#define DIBUTTON_FPS_FIRESECONDARY 0x0900440C
13612#define DIBUTTON_FPS_ROTATE_LEFT_LINK 0x0900C4E4
13613#define DIBUTTON_FPS_ROTATE_RIGHT_LINK 0x0900C4EC
13614#define DIBUTTON_FPS_FORWARD_LINK 0x090144E0
13615#define DIBUTTON_FPS_BACKWARD_LINK 0x090144E8
13616#define DIBUTTON_FPS_GLANCE_UP_LINK 0x0901C4E0
13617#define DIBUTTON_FPS_GLANCE_DOWN_LINK 0x0901C4E8
13618#define DIBUTTON_FPS_DEVICE 0x090044FE
13619#define DIBUTTON_FPS_PAUSE 0x090044FC
13620
13621#define DIVIRTUAL_FIGHTING_THIRDPERSON 0x0A000000
13622#define DIAXIS_TPS_TURN 0x0A020201
13623#define DIAXIS_TPS_MOVE 0x0A010202
13624#define DIBUTTON_TPS_RUN 0x0A000401
13625#define DIBUTTON_TPS_ACTION 0x0A000402
13626#define DIBUTTON_TPS_SELECT 0x0A000403
13627#define DIBUTTON_TPS_USE 0x0A000404
13628#define DIBUTTON_TPS_JUMP 0x0A000405
13629#define DIBUTTON_TPS_MENU 0x0A0004FD
13630
13631#define DIHATSWITCH_TPS_GLANCE 0x0A004601
13632#define DIBUTTON_TPS_VIEW 0x0A004406
13633#define DIBUTTON_TPS_STEPLEFT 0x0A004407
13634#define DIBUTTON_TPS_STEPRIGHT 0x0A004408
13635#define DIAXIS_TPS_STEP 0x0A00C203
13636#define DIBUTTON_TPS_DODGE 0x0A004409
13637#define DIBUTTON_TPS_INVENTORY 0x0A00440A
13638#define DIBUTTON_TPS_TURN_LEFT_LINK 0x0A0244E4
13639#define DIBUTTON_TPS_TURN_RIGHT_LINK 0x0A0244EC
13640#define DIBUTTON_TPS_FORWARD_LINK 0x0A0144E0
13641#define DIBUTTON_TPS_BACKWARD_LINK 0x0A0144E8
13642#define DIBUTTON_TPS_GLANCE_UP_LINK 0x0A07C4E0
13643#define DIBUTTON_TPS_GLANCE_DOWN_LINK 0x0A07C4E8
13644#define DIBUTTON_TPS_GLANCE_LEFT_LINK 0x0A07C4E4
13645#define DIBUTTON_TPS_GLANCE_RIGHT_LINK 0x0A07C4EC
13646#define DIBUTTON_TPS_DEVICE 0x0A0044FE
13647#define DIBUTTON_TPS_PAUSE 0x0A0044FC
13648
13649#define DIVIRTUAL_STRATEGY_ROLEPLAYING 0x0B000000
13650#define DIAXIS_STRATEGYR_LATERAL 0x0B008201
13651#define DIAXIS_STRATEGYR_MOVE 0x0B010202
13652#define DIBUTTON_STRATEGYR_GET 0x0B000401
13653#define DIBUTTON_STRATEGYR_APPLY 0x0B000402
13654#define DIBUTTON_STRATEGYR_SELECT 0x0B000403
13655#define DIBUTTON_STRATEGYR_ATTACK 0x0B000404
13656#define DIBUTTON_STRATEGYR_CAST 0x0B000405
13657#define DIBUTTON_STRATEGYR_CROUCH 0x0B000406
13658#define DIBUTTON_STRATEGYR_JUMP 0x0B000407
13659#define DIBUTTON_STRATEGYR_MENU 0x0B0004FD
13660
13661#define DIHATSWITCH_STRATEGYR_GLANCE 0x0B004601
13662#define DIBUTTON_STRATEGYR_MAP 0x0B004408
13663#define DIBUTTON_STRATEGYR_DISPLAY 0x0B004409
13664#define DIAXIS_STRATEGYR_ROTATE 0x0B024203
13665#define DIBUTTON_STRATEGYR_LEFT_LINK 0x0B00C4E4
13666#define DIBUTTON_STRATEGYR_RIGHT_LINK 0x0B00C4EC
13667#define DIBUTTON_STRATEGYR_FORWARD_LINK 0x0B0144E0
13668#define DIBUTTON_STRATEGYR_BACK_LINK 0x0B0144E8
13669#define DIBUTTON_STRATEGYR_ROTATE_LEFT_LINK 0x0B0244E4
13670#define DIBUTTON_STRATEGYR_ROTATE_RIGHT_LINK 0x0B0244EC
13671#define DIBUTTON_STRATEGYR_DEVICE 0x0B0044FE
13672#define DIBUTTON_STRATEGYR_PAUSE 0x0B0044FC
13673
13674#define DIVIRTUAL_STRATEGY_TURN 0x0C000000
13675#define DIAXIS_STRATEGYT_LATERAL 0x0C008201
13676#define DIAXIS_STRATEGYT_MOVE 0x0C010202
13677#define DIBUTTON_STRATEGYT_SELECT 0x0C000401
13678#define DIBUTTON_STRATEGYT_INSTRUCT 0x0C000402
13679#define DIBUTTON_STRATEGYT_APPLY 0x0C000403
13680#define DIBUTTON_STRATEGYT_TEAM 0x0C000404
13681#define DIBUTTON_STRATEGYT_TURN 0x0C000405
13682#define DIBUTTON_STRATEGYT_MENU 0x0C0004FD
13683
13684#define DIBUTTON_STRATEGYT_ZOOM 0x0C004406
13685#define DIBUTTON_STRATEGYT_MAP 0x0C004407
13686#define DIBUTTON_STRATEGYT_DISPLAY 0x0C004408
13687#define DIBUTTON_STRATEGYT_LEFT_LINK 0x0C00C4E4
13688#define DIBUTTON_STRATEGYT_RIGHT_LINK 0x0C00C4EC
13689#define DIBUTTON_STRATEGYT_FORWARD_LINK 0x0C0144E0
13690#define DIBUTTON_STRATEGYT_BACK_LINK 0x0C0144E8
13691#define DIBUTTON_STRATEGYT_DEVICE 0x0C0044FE
13692#define DIBUTTON_STRATEGYT_PAUSE 0x0C0044FC
13693
13694#define DIVIRTUAL_SPORTS_HUNTING 0x0D000000
13695#define DIAXIS_HUNTING_LATERAL 0x0D008201
13696#define DIAXIS_HUNTING_MOVE 0x0D010202
13697#define DIBUTTON_HUNTING_FIRE 0x0D000401
13698#define DIBUTTON_HUNTING_AIM 0x0D000402
13699#define DIBUTTON_HUNTING_WEAPON 0x0D000403
13700#define DIBUTTON_HUNTING_BINOCULAR 0x0D000404
13701#define DIBUTTON_HUNTING_CALL 0x0D000405
13702#define DIBUTTON_HUNTING_MAP 0x0D000406
13703#define DIBUTTON_HUNTING_SPECIAL 0x0D000407
13704#define DIBUTTON_HUNTING_MENU 0x0D0004FD
13705
13706#define DIHATSWITCH_HUNTING_GLANCE 0x0D004601
13707#define DIBUTTON_HUNTING_DISPLAY 0x0D004408
13708#define DIAXIS_HUNTING_ROTATE 0x0D024203
13709#define DIBUTTON_HUNTING_CROUCH 0x0D004409
13710#define DIBUTTON_HUNTING_JUMP 0x0D00440A
13711#define DIBUTTON_HUNTING_FIRESECONDARY 0x0D00440B
13712#define DIBUTTON_HUNTING_LEFT_LINK 0x0D00C4E4
13713#define DIBUTTON_HUNTING_RIGHT_LINK 0x0D00C4EC
13714#define DIBUTTON_HUNTING_FORWARD_LINK 0x0D0144E0
13715#define DIBUTTON_HUNTING_BACK_LINK 0x0D0144E8
13716#define DIBUTTON_HUNTING_ROTATE_LEFT_LINK 0x0D0244E4
13717#define DIBUTTON_HUNTING_ROTATE_RIGHT_LINK 0x0D0244EC
13718#define DIBUTTON_HUNTING_DEVICE 0x0D0044FE
13719#define DIBUTTON_HUNTING_PAUSE 0x0D0044FC
13720
13721#define DIVIRTUAL_SPORTS_FISHING 0x0E000000
13722#define DIAXIS_FISHING_LATERAL 0x0E008201
13723#define DIAXIS_FISHING_MOVE 0x0E010202
13724#define DIBUTTON_FISHING_CAST 0x0E000401
13725#define DIBUTTON_FISHING_TYPE 0x0E000402
13726#define DIBUTTON_FISHING_BINOCULAR 0x0E000403
13727#define DIBUTTON_FISHING_BAIT 0x0E000404
13728#define DIBUTTON_FISHING_MAP 0x0E000405
13729#define DIBUTTON_FISHING_MENU 0x0E0004FD
13730
13731#define DIHATSWITCH_FISHING_GLANCE 0x0E004601
13732#define DIBUTTON_FISHING_DISPLAY 0x0E004406
13733#define DIAXIS_FISHING_ROTATE 0x0E024203
13734#define DIBUTTON_FISHING_CROUCH 0x0E004407
13735#define DIBUTTON_FISHING_JUMP 0x0E004408
13736#define DIBUTTON_FISHING_LEFT_LINK 0x0E00C4E4
13737#define DIBUTTON_FISHING_RIGHT_LINK 0x0E00C4EC
13738#define DIBUTTON_FISHING_FORWARD_LINK 0x0E0144E0
13739#define DIBUTTON_FISHING_BACK_LINK 0x0E0144E8
13740#define DIBUTTON_FISHING_ROTATE_LEFT_LINK 0x0E0244E4
13741#define DIBUTTON_FISHING_ROTATE_RIGHT_LINK 0x0E0244EC
13742#define DIBUTTON_FISHING_DEVICE 0x0E0044FE
13743#define DIBUTTON_FISHING_PAUSE 0x0E0044FC
13744
13745#define DIVIRTUAL_SPORTS_BASEBALL_BAT 0x0F000000
13746#define DIAXIS_BASEBALLB_LATERAL 0x0F008201
13747#define DIAXIS_BASEBALLB_MOVE 0x0F010202
13748#define DIBUTTON_BASEBALLB_SELECT 0x0F000401
13749#define DIBUTTON_BASEBALLB_NORMAL 0x0F000402
13750#define DIBUTTON_BASEBALLB_POWER 0x0F000403
13751#define DIBUTTON_BASEBALLB_BUNT 0x0F000404
13752#define DIBUTTON_BASEBALLB_STEAL 0x0F000405
13753#define DIBUTTON_BASEBALLB_BURST 0x0F000406
13754#define DIBUTTON_BASEBALLB_SLIDE 0x0F000407
13755#define DIBUTTON_BASEBALLB_CONTACT 0x0F000408
13756#define DIBUTTON_BASEBALLB_MENU 0x0F0004FD
13757
13758#define DIBUTTON_BASEBALLB_NOSTEAL 0x0F004409
13759#define DIBUTTON_BASEBALLB_BOX 0x0F00440A
13760#define DIBUTTON_BASEBALLB_LEFT_LINK 0x0F00C4E4
13761#define DIBUTTON_BASEBALLB_RIGHT_LINK 0x0F00C4EC
13762#define DIBUTTON_BASEBALLB_FORWARD_LINK 0x0F0144E0
13763#define DIBUTTON_BASEBALLB_BACK_LINK 0x0F0144E8
13764#define DIBUTTON_BASEBALLB_DEVICE 0x0F0044FE
13765#define DIBUTTON_BASEBALLB_PAUSE 0x0F0044FC
13766
13767#define DIVIRTUAL_SPORTS_BASEBALL_PITCH 0x10000000
13768#define DIAXIS_BASEBALLP_LATERAL 0x10008201
13769#define DIAXIS_BASEBALLP_MOVE 0x10010202
13770#define DIBUTTON_BASEBALLP_SELECT 0x10000401
13771#define DIBUTTON_BASEBALLP_PITCH 0x10000402
13772#define DIBUTTON_BASEBALLP_BASE 0x10000403
13773#define DIBUTTON_BASEBALLP_THROW 0x10000404
13774#define DIBUTTON_BASEBALLP_FAKE 0x10000405
13775#define DIBUTTON_BASEBALLP_MENU 0x100004FD
13776
13777#define DIBUTTON_BASEBALLP_WALK 0x10004406
13778#define DIBUTTON_BASEBALLP_LOOK 0x10004407
13779#define DIBUTTON_BASEBALLP_LEFT_LINK 0x1000C4E4
13780#define DIBUTTON_BASEBALLP_RIGHT_LINK 0x1000C4EC
13781#define DIBUTTON_BASEBALLP_FORWARD_LINK 0x100144E0
13782#define DIBUTTON_BASEBALLP_BACK_LINK 0x100144E8
13783#define DIBUTTON_BASEBALLP_DEVICE 0x100044FE
13784#define DIBUTTON_BASEBALLP_PAUSE 0x100044FC
13785
13786#define DIVIRTUAL_SPORTS_BASEBALL_FIELD 0x11000000
13787#define DIAXIS_BASEBALLF_LATERAL 0x11008201
13788#define DIAXIS_BASEBALLF_MOVE 0x11010202
13789#define DIBUTTON_BASEBALLF_NEAREST 0x11000401
13790#define DIBUTTON_BASEBALLF_THROW1 0x11000402
13791#define DIBUTTON_BASEBALLF_THROW2 0x11000403
13792#define DIBUTTON_BASEBALLF_BURST 0x11000404
13793#define DIBUTTON_BASEBALLF_JUMP 0x11000405
13794#define DIBUTTON_BASEBALLF_DIVE 0x11000406
13795#define DIBUTTON_BASEBALLF_MENU 0x110004FD
13796
13797#define DIBUTTON_BASEBALLF_SHIFTIN 0x11004407
13798#define DIBUTTON_BASEBALLF_SHIFTOUT 0x11004408
13799#define DIBUTTON_BASEBALLF_AIM_LEFT_LINK 0x1100C4E4
13800#define DIBUTTON_BASEBALLF_AIM_RIGHT_LINK 0x1100C4EC
13801#define DIBUTTON_BASEBALLF_FORWARD_LINK 0x110144E0
13802#define DIBUTTON_BASEBALLF_BACK_LINK 0x110144E8
13803#define DIBUTTON_BASEBALLF_DEVICE 0x110044FE
13804#define DIBUTTON_BASEBALLF_PAUSE 0x110044FC
13805
13806#define DIVIRTUAL_SPORTS_BASKETBALL_OFFENSE 0x12000000
13807#define DIAXIS_BBALLO_LATERAL 0x12008201
13808#define DIAXIS_BBALLO_MOVE 0x12010202
13809#define DIBUTTON_BBALLO_SHOOT 0x12000401
13810#define DIBUTTON_BBALLO_DUNK 0x12000402
13811#define DIBUTTON_BBALLO_PASS 0x12000403
13812#define DIBUTTON_BBALLO_FAKE 0x12000404
13813#define DIBUTTON_BBALLO_SPECIAL 0x12000405
13814#define DIBUTTON_BBALLO_PLAYER 0x12000406
13815#define DIBUTTON_BBALLO_BURST 0x12000407
13816#define DIBUTTON_BBALLO_CALL 0x12000408
13817#define DIBUTTON_BBALLO_MENU 0x120004FD
13818
13819#define DIHATSWITCH_BBALLO_GLANCE 0x12004601
13820#define DIBUTTON_BBALLO_SCREEN 0x12004409
13821#define DIBUTTON_BBALLO_PLAY 0x1200440A
13822#define DIBUTTON_BBALLO_JAB 0x1200440B
13823#define DIBUTTON_BBALLO_POST 0x1200440C
13824#define DIBUTTON_BBALLO_TIMEOUT 0x1200440D
13825#define DIBUTTON_BBALLO_SUBSTITUTE 0x1200440E
13826#define DIBUTTON_BBALLO_LEFT_LINK 0x1200C4E4
13827#define DIBUTTON_BBALLO_RIGHT_LINK 0x1200C4EC
13828#define DIBUTTON_BBALLO_FORWARD_LINK 0x120144E0
13829#define DIBUTTON_BBALLO_BACK_LINK 0x120144E8
13830#define DIBUTTON_BBALLO_DEVICE 0x120044FE
13831#define DIBUTTON_BBALLO_PAUSE 0x120044FC
13832
13833#define DIVIRTUAL_SPORTS_BASKETBALL_DEFENSE 0x13000000
13834#define DIAXIS_BBALLD_LATERAL 0x13008201
13835#define DIAXIS_BBALLD_MOVE 0x13010202
13836#define DIBUTTON_BBALLD_JUMP 0x13000401
13837#define DIBUTTON_BBALLD_STEAL 0x13000402
13838#define DIBUTTON_BBALLD_FAKE 0x13000403
13839#define DIBUTTON_BBALLD_SPECIAL 0x13000404
13840#define DIBUTTON_BBALLD_PLAYER 0x13000405
13841#define DIBUTTON_BBALLD_BURST 0x13000406
13842#define DIBUTTON_BBALLD_PLAY 0x13000407
13843#define DIBUTTON_BBALLD_MENU 0x130004FD
13844
13845#define DIHATSWITCH_BBALLD_GLANCE 0x13004601
13846#define DIBUTTON_BBALLD_TIMEOUT 0x13004408
13847#define DIBUTTON_BBALLD_SUBSTITUTE 0x13004409
13848#define DIBUTTON_BBALLD_LEFT_LINK 0x1300C4E4
13849#define DIBUTTON_BBALLD_RIGHT_LINK 0x1300C4EC
13850#define DIBUTTON_BBALLD_FORWARD_LINK 0x130144E0
13851#define DIBUTTON_BBALLD_BACK_LINK 0x130144E8
13852#define DIBUTTON_BBALLD_DEVICE 0x130044FE
13853#define DIBUTTON_BBALLD_PAUSE 0x130044FC
13854
13855#define DIVIRTUAL_SPORTS_FOOTBALL_FIELD 0x14000000
13856#define DIBUTTON_FOOTBALLP_PLAY 0x14000401
13857#define DIBUTTON_FOOTBALLP_SELECT 0x14000402
13858#define DIBUTTON_FOOTBALLP_HELP 0x14000403
13859#define DIBUTTON_FOOTBALLP_MENU 0x140004FD
13860
13861#define DIBUTTON_FOOTBALLP_DEVICE 0x140044FE
13862#define DIBUTTON_FOOTBALLP_PAUSE 0x140044FC
13863
13864#define DIVIRTUAL_SPORTS_FOOTBALL_QBCK 0x15000000
13865#define DIAXIS_FOOTBALLQ_LATERAL 0x15008201
13866#define DIAXIS_FOOTBALLQ_MOVE 0x15010202
13867#define DIBUTTON_FOOTBALLQ_SELECT 0x15000401
13868#define DIBUTTON_FOOTBALLQ_SNAP 0x15000402
13869#define DIBUTTON_FOOTBALLQ_JUMP 0x15000403
13870#define DIBUTTON_FOOTBALLQ_SLIDE 0x15000404
13871#define DIBUTTON_FOOTBALLQ_PASS 0x15000405
13872#define DIBUTTON_FOOTBALLQ_FAKE 0x15000406
13873#define DIBUTTON_FOOTBALLQ_MENU 0x150004FD
13874
13875#define DIBUTTON_FOOTBALLQ_FAKESNAP 0x15004407
13876#define DIBUTTON_FOOTBALLQ_MOTION 0x15004408
13877#define DIBUTTON_FOOTBALLQ_AUDIBLE 0x15004409
13878#define DIBUTTON_FOOTBALLQ_LEFT_LINK 0x1500C4E4
13879#define DIBUTTON_FOOTBALLQ_RIGHT_LINK 0x1500C4EC
13880#define DIBUTTON_FOOTBALLQ_FORWARD_LINK 0x150144E0
13881#define DIBUTTON_FOOTBALLQ_BACK_LINK 0x150144E8
13882#define DIBUTTON_FOOTBALLQ_DEVICE 0x150044FE
13883#define DIBUTTON_FOOTBALLQ_PAUSE 0x150044FC
13884
13885#define DIVIRTUAL_SPORTS_FOOTBALL_OFFENSE 0x16000000
13886#define DIAXIS_FOOTBALLO_LATERAL 0x16008201
13887#define DIAXIS_FOOTBALLO_MOVE 0x16010202
13888#define DIBUTTON_FOOTBALLO_JUMP 0x16000401
13889#define DIBUTTON_FOOTBALLO_LEFTARM 0x16000402
13890#define DIBUTTON_FOOTBALLO_RIGHTARM 0x16000403
13891#define DIBUTTON_FOOTBALLO_THROW 0x16000404
13892#define DIBUTTON_FOOTBALLO_SPIN 0x16000405
13893#define DIBUTTON_FOOTBALLO_MENU 0x160004FD
13894
13895#define DIBUTTON_FOOTBALLO_JUKE 0x16004406
13896#define DIBUTTON_FOOTBALLO_SHOULDER 0x16004407
13897#define DIBUTTON_FOOTBALLO_TURBO 0x16004408
13898#define DIBUTTON_FOOTBALLO_DIVE 0x16004409
13899#define DIBUTTON_FOOTBALLO_ZOOM 0x1600440A
13900#define DIBUTTON_FOOTBALLO_SUBSTITUTE 0x1600440B
13901#define DIBUTTON_FOOTBALLO_LEFT_LINK 0x1600C4E4
13902#define DIBUTTON_FOOTBALLO_RIGHT_LINK 0x1600C4EC
13903#define DIBUTTON_FOOTBALLO_FORWARD_LINK 0x160144E0
13904#define DIBUTTON_FOOTBALLO_BACK_LINK 0x160144E8
13905#define DIBUTTON_FOOTBALLO_DEVICE 0x160044FE
13906#define DIBUTTON_FOOTBALLO_PAUSE 0x160044FC
13907
13908#define DIVIRTUAL_SPORTS_FOOTBALL_DEFENSE 0x17000000
13909#define DIAXIS_FOOTBALLD_LATERAL 0x17008201
13910#define DIAXIS_FOOTBALLD_MOVE 0x17010202
13911#define DIBUTTON_FOOTBALLD_PLAY 0x17000401
13912#define DIBUTTON_FOOTBALLD_SELECT 0x17000402
13913#define DIBUTTON_FOOTBALLD_JUMP 0x17000403
13914#define DIBUTTON_FOOTBALLD_TACKLE 0x17000404
13915#define DIBUTTON_FOOTBALLD_FAKE 0x17000405
13916#define DIBUTTON_FOOTBALLD_SUPERTACKLE 0x17000406
13917#define DIBUTTON_FOOTBALLD_MENU 0x170004FD
13918
13919#define DIBUTTON_FOOTBALLD_SPIN 0x17004407
13920#define DIBUTTON_FOOTBALLD_SWIM 0x17004408
13921#define DIBUTTON_FOOTBALLD_BULLRUSH 0x17004409
13922#define DIBUTTON_FOOTBALLD_RIP 0x1700440A
13923#define DIBUTTON_FOOTBALLD_AUDIBLE 0x1700440B
13924#define DIBUTTON_FOOTBALLD_ZOOM 0x1700440C
13925#define DIBUTTON_FOOTBALLD_SUBSTITUTE 0x1700440D
13926#define DIBUTTON_FOOTBALLD_LEFT_LINK 0x1700C4E4
13927#define DIBUTTON_FOOTBALLD_RIGHT_LINK 0x1700C4EC
13928#define DIBUTTON_FOOTBALLD_FORWARD_LINK 0x170144E0
13929#define DIBUTTON_FOOTBALLD_BACK_LINK 0x170144E8
13930#define DIBUTTON_FOOTBALLD_DEVICE 0x170044FE
13931#define DIBUTTON_FOOTBALLD_PAUSE 0x170044FC
13932
13933#define DIVIRTUAL_SPORTS_GOLF 0x18000000
13934#define DIAXIS_GOLF_LATERAL 0x18008201
13935#define DIAXIS_GOLF_MOVE 0x18010202
13936#define DIBUTTON_GOLF_SWING 0x18000401
13937#define DIBUTTON_GOLF_SELECT 0x18000402
13938#define DIBUTTON_GOLF_UP 0x18000403
13939#define DIBUTTON_GOLF_DOWN 0x18000404
13940#define DIBUTTON_GOLF_TERRAIN 0x18000405
13941#define DIBUTTON_GOLF_FLYBY 0x18000406
13942#define DIBUTTON_GOLF_MENU 0x180004FD
13943
13944#define DIHATSWITCH_GOLF_SCROLL 0x18004601
13945#define DIBUTTON_GOLF_ZOOM 0x18004407
13946#define DIBUTTON_GOLF_TIMEOUT 0x18004408
13947#define DIBUTTON_GOLF_SUBSTITUTE 0x18004409
13948#define DIBUTTON_GOLF_LEFT_LINK 0x1800C4E4
13949#define DIBUTTON_GOLF_RIGHT_LINK 0x1800C4EC
13950#define DIBUTTON_GOLF_FORWARD_LINK 0x180144E0
13951#define DIBUTTON_GOLF_BACK_LINK 0x180144E8
13952#define DIBUTTON_GOLF_DEVICE 0x180044FE
13953#define DIBUTTON_GOLF_PAUSE 0x180044FC
13954
13955#define DIVIRTUAL_SPORTS_HOCKEY_OFFENSE 0x19000000
13956#define DIAXIS_HOCKEYO_LATERAL 0x19008201
13957#define DIAXIS_HOCKEYO_MOVE 0x19010202
13958#define DIBUTTON_HOCKEYO_SHOOT 0x19000401
13959#define DIBUTTON_HOCKEYO_PASS 0x19000402
13960#define DIBUTTON_HOCKEYO_BURST 0x19000403
13961#define DIBUTTON_HOCKEYO_SPECIAL 0x19000404
13962#define DIBUTTON_HOCKEYO_FAKE 0x19000405
13963#define DIBUTTON_HOCKEYO_MENU 0x190004FD
13964
13965#define DIHATSWITCH_HOCKEYO_SCROLL 0x19004601
13966#define DIBUTTON_HOCKEYO_ZOOM 0x19004406
13967#define DIBUTTON_HOCKEYO_STRATEGY 0x19004407
13968#define DIBUTTON_HOCKEYO_TIMEOUT 0x19004408
13969#define DIBUTTON_HOCKEYO_SUBSTITUTE 0x19004409
13970#define DIBUTTON_HOCKEYO_LEFT_LINK 0x1900C4E4
13971#define DIBUTTON_HOCKEYO_RIGHT_LINK 0x1900C4EC
13972#define DIBUTTON_HOCKEYO_FORWARD_LINK 0x190144E0
13973#define DIBUTTON_HOCKEYO_BACK_LINK 0x190144E8
13974#define DIBUTTON_HOCKEYO_DEVICE 0x190044FE
13975#define DIBUTTON_HOCKEYO_PAUSE 0x190044FC
13976
13977#define DIVIRTUAL_SPORTS_HOCKEY_DEFENSE 0x1A000000
13978#define DIAXIS_HOCKEYD_LATERAL 0x1A008201
13979#define DIAXIS_HOCKEYD_MOVE 0x1A010202
13980#define DIBUTTON_HOCKEYD_PLAYER 0x1A000401
13981#define DIBUTTON_HOCKEYD_STEAL 0x1A000402
13982#define DIBUTTON_HOCKEYD_BURST 0x1A000403
13983#define DIBUTTON_HOCKEYD_BLOCK 0x1A000404
13984#define DIBUTTON_HOCKEYD_FAKE 0x1A000405
13985#define DIBUTTON_HOCKEYD_MENU 0x1A0004FD
13986
13987#define DIHATSWITCH_HOCKEYD_SCROLL 0x1A004601
13988#define DIBUTTON_HOCKEYD_ZOOM 0x1A004406
13989#define DIBUTTON_HOCKEYD_STRATEGY 0x1A004407
13990#define DIBUTTON_HOCKEYD_TIMEOUT 0x1A004408
13991#define DIBUTTON_HOCKEYD_SUBSTITUTE 0x1A004409
13992#define DIBUTTON_HOCKEYD_LEFT_LINK 0x1A00C4E4
13993#define DIBUTTON_HOCKEYD_RIGHT_LINK 0x1A00C4EC
13994#define DIBUTTON_HOCKEYD_FORWARD_LINK 0x1A0144E0
13995#define DIBUTTON_HOCKEYD_BACK_LINK 0x1A0144E8
13996#define DIBUTTON_HOCKEYD_DEVICE 0x1A0044FE
13997#define DIBUTTON_HOCKEYD_PAUSE 0x1A0044FC
13998
13999#define DIVIRTUAL_SPORTS_HOCKEY_GOALIE 0x1B000000
14000#define DIAXIS_HOCKEYG_LATERAL 0x1B008201
14001#define DIAXIS_HOCKEYG_MOVE 0x1B010202
14002#define DIBUTTON_HOCKEYG_PASS 0x1B000401
14003#define DIBUTTON_HOCKEYG_POKE 0x1B000402
14004#define DIBUTTON_HOCKEYG_STEAL 0x1B000403
14005#define DIBUTTON_HOCKEYG_BLOCK 0x1B000404
14006#define DIBUTTON_HOCKEYG_MENU 0x1B0004FD
14007
14008#define DIHATSWITCH_HOCKEYG_SCROLL 0x1B004601
14009#define DIBUTTON_HOCKEYG_ZOOM 0x1B004405
14010#define DIBUTTON_HOCKEYG_STRATEGY 0x1B004406
14011#define DIBUTTON_HOCKEYG_TIMEOUT 0x1B004407
14012#define DIBUTTON_HOCKEYG_SUBSTITUTE 0x1B004408
14013#define DIBUTTON_HOCKEYG_LEFT_LINK 0x1B00C4E4
14014#define DIBUTTON_HOCKEYG_RIGHT_LINK 0x1B00C4EC
14015#define DIBUTTON_HOCKEYG_FORWARD_LINK 0x1B0144E0
14016#define DIBUTTON_HOCKEYG_BACK_LINK 0x1B0144E8
14017#define DIBUTTON_HOCKEYG_DEVICE 0x1B0044FE
14018#define DIBUTTON_HOCKEYG_PAUSE 0x1B0044FC
14019
14020#define DIVIRTUAL_SPORTS_BIKING_MOUNTAIN 0x1C000000
14021#define DIAXIS_BIKINGM_TURN 0x1C008201
14022#define DIAXIS_BIKINGM_PEDAL 0x1C010202
14023#define DIBUTTON_BIKINGM_JUMP 0x1C000401
14024#define DIBUTTON_BIKINGM_CAMERA 0x1C000402
14025#define DIBUTTON_BIKINGM_SPECIAL1 0x1C000403
14026#define DIBUTTON_BIKINGM_SELECT 0x1C000404
14027#define DIBUTTON_BIKINGM_SPECIAL2 0x1C000405
14028#define DIBUTTON_BIKINGM_MENU 0x1C0004FD
14029
14030#define DIHATSWITCH_BIKINGM_SCROLL 0x1C004601
14031#define DIBUTTON_BIKINGM_ZOOM 0x1C004406
14032#define DIAXIS_BIKINGM_BRAKE 0x1C044203
14033#define DIBUTTON_BIKINGM_LEFT_LINK 0x1C00C4E4
14034#define DIBUTTON_BIKINGM_RIGHT_LINK 0x1C00C4EC
14035#define DIBUTTON_BIKINGM_FASTER_LINK 0x1C0144E0
14036#define DIBUTTON_BIKINGM_SLOWER_LINK 0x1C0144E8
14037#define DIBUTTON_BIKINGM_BRAKE_BUTTON_LINK 0x1C0444E8
14038#define DIBUTTON_BIKINGM_DEVICE 0x1C0044FE
14039#define DIBUTTON_BIKINGM_PAUSE 0x1C0044FC
14040
14041#define DIVIRTUAL_SPORTS_SKIING 0x1D000000
14042#define DIAXIS_SKIING_TURN 0x1D008201
14043#define DIAXIS_SKIING_SPEED 0x1D010202
14044#define DIBUTTON_SKIING_JUMP 0x1D000401
14045#define DIBUTTON_SKIING_CROUCH 0x1D000402
14046#define DIBUTTON_SKIING_CAMERA 0x1D000403
14047#define DIBUTTON_SKIING_SPECIAL1 0x1D000404
14048#define DIBUTTON_SKIING_SELECT 0x1D000405
14049#define DIBUTTON_SKIING_SPECIAL2 0x1D000406
14050#define DIBUTTON_SKIING_MENU 0x1D0004FD
14051
14052#define DIHATSWITCH_SKIING_GLANCE 0x1D004601
14053#define DIBUTTON_SKIING_ZOOM 0x1D004407
14054#define DIBUTTON_SKIING_LEFT_LINK 0x1D00C4E4
14055#define DIBUTTON_SKIING_RIGHT_LINK 0x1D00C4EC
14056#define DIBUTTON_SKIING_FASTER_LINK 0x1D0144E0
14057#define DIBUTTON_SKIING_SLOWER_LINK 0x1D0144E8
14058#define DIBUTTON_SKIING_DEVICE 0x1D0044FE
14059#define DIBUTTON_SKIING_PAUSE 0x1D0044FC
14060
14061#define DIVIRTUAL_SPORTS_SOCCER_OFFENSE 0x1E000000
14062#define DIAXIS_SOCCERO_LATERAL 0x1E008201
14063#define DIAXIS_SOCCERO_MOVE 0x1E010202
14064#define DIAXIS_SOCCERO_BEND 0x1E018203
14065#define DIBUTTON_SOCCERO_SHOOT 0x1E000401
14066#define DIBUTTON_SOCCERO_PASS 0x1E000402
14067#define DIBUTTON_SOCCERO_FAKE 0x1E000403
14068#define DIBUTTON_SOCCERO_PLAYER 0x1E000404
14069#define DIBUTTON_SOCCERO_SPECIAL1 0x1E000405
14070#define DIBUTTON_SOCCERO_SELECT 0x1E000406
14071#define DIBUTTON_SOCCERO_MENU 0x1E0004FD
14072
14073#define DIHATSWITCH_SOCCERO_GLANCE 0x1E004601
14074#define DIBUTTON_SOCCERO_SUBSTITUTE 0x1E004407
14075#define DIBUTTON_SOCCERO_SHOOTLOW 0x1E004408
14076#define DIBUTTON_SOCCERO_SHOOTHIGH 0x1E004409
14077#define DIBUTTON_SOCCERO_PASSTHRU 0x1E00440A
14078#define DIBUTTON_SOCCERO_SPRINT 0x1E00440B
14079#define DIBUTTON_SOCCERO_CONTROL 0x1E00440C
14080#define DIBUTTON_SOCCERO_HEAD 0x1E00440D
14081#define DIBUTTON_SOCCERO_LEFT_LINK 0x1E00C4E4
14082#define DIBUTTON_SOCCERO_RIGHT_LINK 0x1E00C4EC
14083#define DIBUTTON_SOCCERO_FORWARD_LINK 0x1E0144E0
14084#define DIBUTTON_SOCCERO_BACK_LINK 0x1E0144E8
14085#define DIBUTTON_SOCCERO_DEVICE 0x1E0044FE
14086#define DIBUTTON_SOCCERO_PAUSE 0x1E0044FC
14087
14088#define DIVIRTUAL_SPORTS_SOCCER_DEFENSE 0x1F000000
14089#define DIAXIS_SOCCERD_LATERAL 0x1F008201
14090#define DIAXIS_SOCCERD_MOVE 0x1F010202
14091#define DIBUTTON_SOCCERD_BLOCK 0x1F000401
14092#define DIBUTTON_SOCCERD_STEAL 0x1F000402
14093#define DIBUTTON_SOCCERD_FAKE 0x1F000403
14094#define DIBUTTON_SOCCERD_PLAYER 0x1F000404
14095#define DIBUTTON_SOCCERD_SPECIAL 0x1F000405
14096#define DIBUTTON_SOCCERD_SELECT 0x1F000406
14097#define DIBUTTON_SOCCERD_SLIDE 0x1F000407
14098#define DIBUTTON_SOCCERD_MENU 0x1F0004FD
14099
14100#define DIHATSWITCH_SOCCERD_GLANCE 0x1F004601
14101#define DIBUTTON_SOCCERD_FOUL 0x1F004408
14102#define DIBUTTON_SOCCERD_HEAD 0x1F004409
14103#define DIBUTTON_SOCCERD_CLEAR 0x1F00440A
14104#define DIBUTTON_SOCCERD_GOALIECHARGE 0x1F00440B
14105#define DIBUTTON_SOCCERD_SUBSTITUTE 0x1F00440C
14106#define DIBUTTON_SOCCERD_LEFT_LINK 0x1F00C4E4
14107#define DIBUTTON_SOCCERD_RIGHT_LINK 0x1F00C4EC
14108#define DIBUTTON_SOCCERD_FORWARD_LINK 0x1F0144E0
14109#define DIBUTTON_SOCCERD_BACK_LINK 0x1F0144E8
14110#define DIBUTTON_SOCCERD_DEVICE 0x1F0044FE
14111#define DIBUTTON_SOCCERD_PAUSE 0x1F0044FC
14112
14113#define DIVIRTUAL_SPORTS_RACQUET 0x20000000
14114#define DIAXIS_RACQUET_LATERAL 0x20008201
14115#define DIAXIS_RACQUET_MOVE 0x20010202
14116#define DIBUTTON_RACQUET_SWING 0x20000401
14117#define DIBUTTON_RACQUET_BACKSWING 0x20000402
14118#define DIBUTTON_RACQUET_SMASH 0x20000403
14119#define DIBUTTON_RACQUET_SPECIAL 0x20000404
14120#define DIBUTTON_RACQUET_SELECT 0x20000405
14121#define DIBUTTON_RACQUET_MENU 0x200004FD
14122
14123#define DIHATSWITCH_RACQUET_GLANCE 0x20004601
14124#define DIBUTTON_RACQUET_TIMEOUT 0x20004406
14125#define DIBUTTON_RACQUET_SUBSTITUTE 0x20004407
14126#define DIBUTTON_RACQUET_LEFT_LINK 0x2000C4E4
14127#define DIBUTTON_RACQUET_RIGHT_LINK 0x2000C4EC
14128#define DIBUTTON_RACQUET_FORWARD_LINK 0x200144E0
14129#define DIBUTTON_RACQUET_BACK_LINK 0x200144E8
14130#define DIBUTTON_RACQUET_DEVICE 0x200044FE
14131#define DIBUTTON_RACQUET_PAUSE 0x200044FC
14132
14133#define DIVIRTUAL_ARCADE_SIDE2SIDE 0x21000000
14134#define DIAXIS_ARCADES_LATERAL 0x21008201
14135#define DIAXIS_ARCADES_MOVE 0x21010202
14136#define DIBUTTON_ARCADES_THROW 0x21000401
14137#define DIBUTTON_ARCADES_CARRY 0x21000402
14138#define DIBUTTON_ARCADES_ATTACK 0x21000403
14139#define DIBUTTON_ARCADES_SPECIAL 0x21000404
14140#define DIBUTTON_ARCADES_SELECT 0x21000405
14141#define DIBUTTON_ARCADES_MENU 0x210004FD
14142
14143#define DIHATSWITCH_ARCADES_VIEW 0x21004601
14144#define DIBUTTON_ARCADES_LEFT_LINK 0x2100C4E4
14145#define DIBUTTON_ARCADES_RIGHT_LINK 0x2100C4EC
14146#define DIBUTTON_ARCADES_FORWARD_LINK 0x210144E0
14147#define DIBUTTON_ARCADES_BACK_LINK 0x210144E8
14148#define DIBUTTON_ARCADES_VIEW_UP_LINK 0x2107C4E0
14149#define DIBUTTON_ARCADES_VIEW_DOWN_LINK 0x2107C4E8
14150#define DIBUTTON_ARCADES_VIEW_LEFT_LINK 0x2107C4E4
14151#define DIBUTTON_ARCADES_VIEW_RIGHT_LINK 0x2107C4EC
14152#define DIBUTTON_ARCADES_DEVICE 0x210044FE
14153#define DIBUTTON_ARCADES_PAUSE 0x210044FC
14154
14155#define DIVIRTUAL_ARCADE_PLATFORM 0x22000000
14156#define DIAXIS_ARCADEP_LATERAL 0x22008201
14157#define DIAXIS_ARCADEP_MOVE 0x22010202
14158#define DIBUTTON_ARCADEP_JUMP 0x22000401
14159#define DIBUTTON_ARCADEP_FIRE 0x22000402
14160#define DIBUTTON_ARCADEP_CROUCH 0x22000403
14161#define DIBUTTON_ARCADEP_SPECIAL 0x22000404
14162#define DIBUTTON_ARCADEP_SELECT 0x22000405
14163#define DIBUTTON_ARCADEP_MENU 0x220004FD
14164
14165#define DIHATSWITCH_ARCADEP_VIEW 0x22004601
14166#define DIBUTTON_ARCADEP_FIRESECONDARY 0x22004406
14167#define DIBUTTON_ARCADEP_LEFT_LINK 0x2200C4E4
14168#define DIBUTTON_ARCADEP_RIGHT_LINK 0x2200C4EC
14169#define DIBUTTON_ARCADEP_FORWARD_LINK 0x220144E0
14170#define DIBUTTON_ARCADEP_BACK_LINK 0x220144E8
14171#define DIBUTTON_ARCADEP_VIEW_UP_LINK 0x2207C4E0
14172#define DIBUTTON_ARCADEP_VIEW_DOWN_LINK 0x2207C4E8
14173#define DIBUTTON_ARCADEP_VIEW_LEFT_LINK 0x2207C4E4
14174#define DIBUTTON_ARCADEP_VIEW_RIGHT_LINK 0x2207C4EC
14175#define DIBUTTON_ARCADEP_DEVICE 0x220044FE
14176#define DIBUTTON_ARCADEP_PAUSE 0x220044FC
14177
14178#define DIVIRTUAL_CAD_2DCONTROL 0x23000000
14179#define DIAXIS_2DCONTROL_LATERAL 0x23008201
14180#define DIAXIS_2DCONTROL_MOVE 0x23010202
14181#define DIAXIS_2DCONTROL_INOUT 0x23018203
14182#define DIBUTTON_2DCONTROL_SELECT 0x23000401
14183#define DIBUTTON_2DCONTROL_SPECIAL1 0x23000402
14184#define DIBUTTON_2DCONTROL_SPECIAL 0x23000403
14185#define DIBUTTON_2DCONTROL_SPECIAL2 0x23000404
14186#define DIBUTTON_2DCONTROL_MENU 0x230004FD
14187
14188#define DIHATSWITCH_2DCONTROL_HATSWITCH 0x23004601
14189#define DIAXIS_2DCONTROL_ROTATEZ 0x23024204
14190#define DIBUTTON_2DCONTROL_DISPLAY 0x23004405
14191#define DIBUTTON_2DCONTROL_DEVICE 0x230044FE
14192#define DIBUTTON_2DCONTROL_PAUSE 0x230044FC
14193
14194#define DIVIRTUAL_CAD_3DCONTROL 0x24000000
14195#define DIAXIS_3DCONTROL_LATERAL 0x24008201
14196#define DIAXIS_3DCONTROL_MOVE 0x24010202
14197#define DIAXIS_3DCONTROL_INOUT 0x24018203
14198#define DIBUTTON_3DCONTROL_SELECT 0x24000401
14199#define DIBUTTON_3DCONTROL_SPECIAL1 0x24000402
14200#define DIBUTTON_3DCONTROL_SPECIAL 0x24000403
14201#define DIBUTTON_3DCONTROL_SPECIAL2 0x24000404
14202#define DIBUTTON_3DCONTROL_MENU 0x240004FD
14203
14204#define DIHATSWITCH_3DCONTROL_HATSWITCH 0x24004601
14205#define DIAXIS_3DCONTROL_ROTATEX 0x24034204
14206#define DIAXIS_3DCONTROL_ROTATEY 0x2402C205
14207#define DIAXIS_3DCONTROL_ROTATEZ 0x24024206
14208#define DIBUTTON_3DCONTROL_DISPLAY 0x24004405
14209#define DIBUTTON_3DCONTROL_DEVICE 0x240044FE
14210#define DIBUTTON_3DCONTROL_PAUSE 0x240044FC
14211
14212#define DIVIRTUAL_CAD_FLYBY 0x25000000
14213#define DIAXIS_CADF_LATERAL 0x25008201
14214#define DIAXIS_CADF_MOVE 0x25010202
14215#define DIAXIS_CADF_INOUT 0x25018203
14216#define DIBUTTON_CADF_SELECT 0x25000401
14217#define DIBUTTON_CADF_SPECIAL1 0x25000402
14218#define DIBUTTON_CADF_SPECIAL 0x25000403
14219#define DIBUTTON_CADF_SPECIAL2 0x25000404
14220#define DIBUTTON_CADF_MENU 0x250004FD
14221
14222#define DIHATSWITCH_CADF_HATSWITCH 0x25004601
14223#define DIAXIS_CADF_ROTATEX 0x25034204
14224#define DIAXIS_CADF_ROTATEY 0x2502C205
14225#define DIAXIS_CADF_ROTATEZ 0x25024206
14226#define DIBUTTON_CADF_DISPLAY 0x25004405
14227#define DIBUTTON_CADF_DEVICE 0x250044FE
14228#define DIBUTTON_CADF_PAUSE 0x250044FC
14229
14230#define DIVIRTUAL_CAD_MODEL 0x26000000
14231#define DIAXIS_CADM_LATERAL 0x26008201
14232#define DIAXIS_CADM_MOVE 0x26010202
14233#define DIAXIS_CADM_INOUT 0x26018203
14234#define DIBUTTON_CADM_SELECT 0x26000401
14235#define DIBUTTON_CADM_SPECIAL1 0x26000402
14236#define DIBUTTON_CADM_SPECIAL 0x26000403
14237#define DIBUTTON_CADM_SPECIAL2 0x26000404
14238#define DIBUTTON_CADM_MENU 0x260004FD
14239
14240#define DIHATSWITCH_CADM_HATSWITCH 0x26004601
14241#define DIAXIS_CADM_ROTATEX 0x26034204
14242#define DIAXIS_CADM_ROTATEY 0x2602C205
14243#define DIAXIS_CADM_ROTATEZ 0x26024206
14244#define DIBUTTON_CADM_DISPLAY 0x26004405
14245#define DIBUTTON_CADM_DEVICE 0x260044FE
14246#define DIBUTTON_CADM_PAUSE 0x260044FC
14247
14248#define DIVIRTUAL_REMOTE_CONTROL 0x27000000
14249#define DIAXIS_REMOTE_SLIDER 0x27050201
14250#define DIBUTTON_REMOTE_MUTE 0x27000401
14251#define DIBUTTON_REMOTE_SELECT 0x27000402
14252#define DIBUTTON_REMOTE_PLAY 0x27002403
14253#define DIBUTTON_REMOTE_CUE 0x27002404
14254#define DIBUTTON_REMOTE_REVIEW 0x27002405
14255#define DIBUTTON_REMOTE_CHANGE 0x27002406
14256#define DIBUTTON_REMOTE_RECORD 0x27002407
14257#define DIBUTTON_REMOTE_MENU 0x270004FD
14258
14259#define DIAXIS_REMOTE_SLIDER2 0x27054202
14260#define DIBUTTON_REMOTE_TV 0x27005C08
14261#define DIBUTTON_REMOTE_CABLE 0x27005C09
14262#define DIBUTTON_REMOTE_CD 0x27005C0A
14263#define DIBUTTON_REMOTE_VCR 0x27005C0B
14264#define DIBUTTON_REMOTE_TUNER 0x27005C0C
14265#define DIBUTTON_REMOTE_DVD 0x27005C0D
14266#define DIBUTTON_REMOTE_ADJUST 0x27005C0E
14267#define DIBUTTON_REMOTE_DIGIT0 0x2700540F
14268#define DIBUTTON_REMOTE_DIGIT1 0x27005410
14269#define DIBUTTON_REMOTE_DIGIT2 0x27005411
14270#define DIBUTTON_REMOTE_DIGIT3 0x27005412
14271#define DIBUTTON_REMOTE_DIGIT4 0x27005413
14272#define DIBUTTON_REMOTE_DIGIT5 0x27005414
14273#define DIBUTTON_REMOTE_DIGIT6 0x27005415
14274#define DIBUTTON_REMOTE_DIGIT7 0x27005416
14275#define DIBUTTON_REMOTE_DIGIT8 0x27005417
14276#define DIBUTTON_REMOTE_DIGIT9 0x27005418
14277#define DIBUTTON_REMOTE_DEVICE 0x270044FE
14278#define DIBUTTON_REMOTE_PAUSE 0x270044FC
14279
14280#define DIVIRTUAL_BROWSER_CONTROL 0x28000000
14281#define DIAXIS_BROWSER_LATERAL 0x28008201
14282#define DIAXIS_BROWSER_MOVE 0x28010202
14283#define DIBUTTON_BROWSER_SELECT 0x28000401
14284#define DIAXIS_BROWSER_VIEW 0x28018203
14285#define DIBUTTON_BROWSER_REFRESH 0x28000402
14286#define DIBUTTON_BROWSER_MENU 0x280004FD
14287
14288#define DIBUTTON_BROWSER_SEARCH 0x28004403
14289#define DIBUTTON_BROWSER_STOP 0x28004404
14290#define DIBUTTON_BROWSER_HOME 0x28004405
14291#define DIBUTTON_BROWSER_FAVORITES 0x28004406
14292#define DIBUTTON_BROWSER_NEXT 0x28004407
14293#define DIBUTTON_BROWSER_PREVIOUS 0x28004408
14294#define DIBUTTON_BROWSER_HISTORY 0x28004409
14295#define DIBUTTON_BROWSER_PRINT 0x2800440A
14296#define DIBUTTON_BROWSER_DEVICE 0x280044FE
14297#define DIBUTTON_BROWSER_PAUSE 0x280044FC
14298
14299#define DIVIRTUAL_DRIVING_MECHA 0x29000000
14300#define DIAXIS_MECHA_STEER 0x29008201
14301#define DIAXIS_MECHA_TORSO 0x29010202
14302#define DIAXIS_MECHA_ROTATE 0x29020203
14303#define DIAXIS_MECHA_THROTTLE 0x29038204
14304#define DIBUTTON_MECHA_FIRE 0x29000401
14305#define DIBUTTON_MECHA_WEAPONS 0x29000402
14306#define DIBUTTON_MECHA_TARGET 0x29000403
14307#define DIBUTTON_MECHA_REVERSE 0x29000404
14308#define DIBUTTON_MECHA_ZOOM 0x29000405
14309#define DIBUTTON_MECHA_JUMP 0x29000406
14310#define DIBUTTON_MECHA_MENU 0x290004FD
14311
14312#define DIBUTTON_MECHA_CENTER 0x29004407
14313#define DIHATSWITCH_MECHA_GLANCE 0x29004601
14314#define DIBUTTON_MECHA_VIEW 0x29004408
14315#define DIBUTTON_MECHA_FIRESECONDARY 0x29004409
14316#define DIBUTTON_MECHA_LEFT_LINK 0x2900C4E4
14317#define DIBUTTON_MECHA_RIGHT_LINK 0x2900C4EC
14318#define DIBUTTON_MECHA_FORWARD_LINK 0x290144E0
14319#define DIBUTTON_MECHA_BACK_LINK 0x290144E8
14320#define DIBUTTON_MECHA_ROTATE_LEFT_LINK 0x290244E4
14321#define DIBUTTON_MECHA_ROTATE_RIGHT_LINK 0x290244EC
14322#define DIBUTTON_MECHA_FASTER_LINK 0x2903C4E0
14323#define DIBUTTON_MECHA_SLOWER_LINK 0x2903C4E8
14324#define DIBUTTON_MECHA_DEVICE 0x290044FE
14325#define DIBUTTON_MECHA_PAUSE 0x290044FC
14326
14327#define DIAXIS_ANY_X_1 0xFF00C201
14328#define DIAXIS_ANY_X_2 0xFF00C202
14329#define DIAXIS_ANY_Y_1 0xFF014201
14330#define DIAXIS_ANY_Y_2 0xFF014202
14331#define DIAXIS_ANY_Z_1 0xFF01C201
14332#define DIAXIS_ANY_Z_2 0xFF01C202
14333#define DIAXIS_ANY_R_1 0xFF024201
14334#define DIAXIS_ANY_R_2 0xFF024202
14335#define DIAXIS_ANY_U_1 0xFF02C201
14336#define DIAXIS_ANY_U_2 0xFF02C202
14337#define DIAXIS_ANY_V_1 0xFF034201
14338#define DIAXIS_ANY_V_2 0xFF034202
14339#define DIAXIS_ANY_A_1 0xFF03C201
14340#define DIAXIS_ANY_A_2 0xFF03C202
14341#define DIAXIS_ANY_B_1 0xFF044201
14342#define DIAXIS_ANY_B_2 0xFF044202
14343#define DIAXIS_ANY_C_1 0xFF04C201
14344#define DIAXIS_ANY_C_2 0xFF04C202
14345#define DIAXIS_ANY_S_1 0xFF054201
14346#define DIAXIS_ANY_S_2 0xFF054202
14347
14348#define DIAXIS_ANY_1 0xFF004201
14349#define DIAXIS_ANY_2 0xFF004202
14350#define DIAXIS_ANY_3 0xFF004203
14351#define DIAXIS_ANY_4 0xFF004204
14352
14353#define DIPOV_ANY_1 0xFF004601
14354#define DIPOV_ANY_2 0xFF004602
14355#define DIPOV_ANY_3 0xFF004603
14356#define DIPOV_ANY_4 0xFF004604
14357
14358#define DIBUTTON_ANY(instance) ( 0xFF004400 | instance )
14359
14360#ifdef __cplusplus
14361};
14362#endif
14363
14364#endif
14365
14366#ifdef _INC_MMSYSTEM
14367#ifndef MMNOJOY
14368
14369#ifndef __VJOYDX_INCLUDED__
14370#define __VJOYDX_INCLUDED__
14371
14372#ifdef __cplusplus
14373extern "C" {
14374#endif
14375
14376#define JOY_PASSDRIVERDATA 0x10000000l
14377
14378WINMMAPI MMRESULT WINAPI joyConfigChanged( DWORD dwFlags );
14379
14380#define JOY_HWS_ISHEADTRACKER 0x02000000l
14381
14382#define JOY_HWS_ISGAMEPORTDRIVER 0x04000000l
14383
14384#define JOY_HWS_ISANALOGPORTDRIVER 0x08000000l
14385
14386#define JOY_HWS_AUTOLOAD 0x10000000l
14387
14388#define JOY_HWS_NODEVNODE 0x20000000l
14389
14390#define JOY_HWS_ISGAMEPORTBUS 0x80000000l
14391#define JOY_HWS_GAMEPORTBUSBUSY 0x00000001l
14392
14393#define JOY_US_VOLATILE 0x00000008L
14394
14395#ifdef __cplusplus
14396};
14397#endif
14398
14399#endif
14400
14401#endif
14402#endif
14403
14404#ifndef DIJ_RINGZERO
14405
14406#ifdef _INC_MMDDK
14407#ifndef MMNOJOYDEV
14408
14409#ifndef __VJOYDXD_INCLUDED__
14410#define __VJOYDXD_INCLUDED__
14411
14412#define JOY_OEMPOLL_PASSDRIVERDATA 7
14413
14414#endif
14415
14416#endif
14417#endif
14418
14419#endif
14420
14421#endif
14422
14423#undef _THIS
14424#define _THIS SDL_AudioDevice *this
14425
14426#undef SDLAUDIOHIDDEN
14427#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataDSOUND*)this->hidden)
14428struct SDL_PrivateAudioDataDSOUND
14429{
14430 LPDIRECTSOUND sound;
14431 LPDIRECTSOUNDBUFFER mixbuf;
14432 int num_buffers;
14433 int mixlen;
14434 DWORD lastchunk;
14435 Uint8 *locked_buf;
14436};
14437
14438#endif
14439
14440#ifndef WAVE_FORMAT_IEEE_FLOAT
14441#define WAVE_FORMAT_IEEE_FLOAT 0x0003
14442#endif
14443
14444static void* DSoundDLL = NULL;
14445typedef HRESULT(WINAPI*fnDirectSoundCreate8)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN);
14446typedef HRESULT(WINAPI*fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
14447typedef HRESULT(WINAPI*fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW,LPVOID);
14448static fnDirectSoundCreate8 pDirectSoundCreate8 = NULL;
14449static fnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL;
14450static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL;
14451
14452static void
14453DSOUND_Unload(void)
14454{
14455 pDirectSoundCreate8 = NULL;
14456 pDirectSoundEnumerateW = NULL;
14457 pDirectSoundCaptureEnumerateW = NULL;
14458
14459 if (DSoundDLL != NULL) {
14460 SDL_UnloadObject(DSoundDLL);
14461 DSoundDLL = NULL;
14462 }
14463}
14464
14465static int
14466DSOUND_Load(void)
14467{
14468 int loaded = 0;
14469
14470 DSOUND_Unload();
14471
14472 DSoundDLL = SDL_LoadObject("DSOUND.DLL");
14473 if (DSoundDLL == NULL) {
14474 SDL_SetError("DirectSound: failed to load DSOUND.DLL");
14475 } else {
14476
14477 #define DSOUNDLOAD(f) { \
14478 p##f = (fn##f) SDL_LoadFunction(DSoundDLL, #f); \
14479 if (!p##f) loaded = 0; \
14480 }
14481 loaded = 1;
14482 DSOUNDLOAD(DirectSoundCreate8);
14483 DSOUNDLOAD(DirectSoundEnumerateW);
14484 DSOUNDLOAD(DirectSoundCaptureEnumerateW);
14485 #undef DSOUNDLOAD
14486
14487 if (!loaded) {
14488 SDL_SetError("DirectSound: System doesn't appear to have DX8.");
14489 }
14490 }
14491
14492 if (!loaded) {
14493 DSOUND_Unload();
14494 }
14495
14496 return loaded;
14497}
14498
14499static int
14500SetDSerror(const char *function, int code)
14501{
14502 static const char *error;
14503 static char errbuf[1024];
14504
14505 errbuf[0] = 0;
14506 switch (code) {
14507 case E_NOINTERFACE:
14508 error = "Unsupported interface -- Is DirectX 8.0 or later installed?";
14509 break;
14510 case DSERR_ALLOCATED:
14511 error = "Audio device in use";
14512 break;
14513 case DSERR_BADFORMAT:
14514 error = "Unsupported audio format";
14515 break;
14516 case DSERR_BUFFERLOST:
14517 error = "Mixing buffer was lost";
14518 break;
14519 case DSERR_CONTROLUNAVAIL:
14520 error = "Control requested is not available";
14521 break;
14522 case DSERR_INVALIDCALL:
14523 error = "Invalid call for the current state";
14524 break;
14525 case DSERR_INVALIDPARAM:
14526 error = "Invalid parameter";
14527 break;
14528 case DSERR_NODRIVER:
14529 error = "No audio device found";
14530 break;
14531 case DSERR_OUTOFMEMORY:
14532 error = "Out of memory";
14533 break;
14534 case DSERR_PRIOLEVELNEEDED:
14535 error = "Caller doesn't have priority";
14536 break;
14537 case DSERR_UNSUPPORTED:
14538 error = "Function not supported";
14539 break;
14540 default:
14541 SDL_snprintf(errbuf, SDL_arraysize(errbuf),
14542 "%s: Unknown DirectSound error: 0x%x", function, code);
14543 break;
14544 }
14545 if (!errbuf[0]) {
14546 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
14547 error);
14548 }
14549 return SDL_SetError("%s", errbuf);
14550}
14551
14552static BOOL CALLBACK
14553FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
14554{
14555 SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
14556 if (guid != NULL) {
14557 char *str = WIN_StringToUTF8(desc);
14558 if (str != NULL) {
14559 addfn(str);
14560 SDL_free(str);
14561 }
14562 }
14563 return TRUE;
14564}
14565
14566static void
14567DSOUND_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
14568{
14569 if (iscapture) {
14570 pDirectSoundCaptureEnumerateW(FindAllDevs, addfn);
14571 } else {
14572 pDirectSoundEnumerateW(FindAllDevs, addfn);
14573 }
14574}
14575
14576static void
14577DSOUND_WaitDevice(_THIS)
14578{
14579 DWORD status = 0;
14580 DWORD cursor = 0;
14581 DWORD junk = 0;
14582 HRESULT result = DS_OK;
14583
14584 result = IDirectSoundBuffer_GetCurrentPosition(SDLAUDIOHIDDEN->mixbuf,
14585 &junk, &cursor);
14586 if (result != DS_OK) {
14587 if (result == DSERR_BUFFERLOST) {
14588 IDirectSoundBuffer_Restore(SDLAUDIOHIDDEN->mixbuf);
14589 }
14590#ifdef DEBUG_SOUND
14591 SetDSerror("DirectSound GetCurrentPosition", result);
14592#endif
14593 return;
14594 }
14595
14596 while ((cursor / SDLAUDIOHIDDEN->mixlen) == SDLAUDIOHIDDEN->lastchunk) {
14597
14598 SDL_Delay(1);
14599
14600 IDirectSoundBuffer_GetStatus(SDLAUDIOHIDDEN->mixbuf, &status);
14601 if ((status & DSBSTATUS_BUFFERLOST)) {
14602 IDirectSoundBuffer_Restore(SDLAUDIOHIDDEN->mixbuf);
14603 IDirectSoundBuffer_GetStatus(SDLAUDIOHIDDEN->mixbuf, &status);
14604 if ((status & DSBSTATUS_BUFFERLOST)) {
14605 break;
14606 }
14607 }
14608 if (!(status & DSBSTATUS_PLAYING)) {
14609 result = IDirectSoundBuffer_Play(SDLAUDIOHIDDEN->mixbuf, 0, 0,
14610 DSBPLAY_LOOPING);
14611 if (result == DS_OK) {
14612 continue;
14613 }
14614#ifdef DEBUG_SOUND
14615 SetDSerror("DirectSound Play", result);
14616#endif
14617 return;
14618 }
14619
14620 result = IDirectSoundBuffer_GetCurrentPosition(SDLAUDIOHIDDEN->mixbuf,
14621 &junk, &cursor);
14622 if (result != DS_OK) {
14623 SetDSerror("DirectSound GetCurrentPosition", result);
14624 return;
14625 }
14626 }
14627}
14628
14629static void
14630DSOUND_PlayDevice(_THIS)
14631{
14632
14633 if (SDLAUDIOHIDDEN->locked_buf) {
14634 IDirectSoundBuffer_Unlock(SDLAUDIOHIDDEN->mixbuf,
14635 SDLAUDIOHIDDEN->locked_buf,
14636 SDLAUDIOHIDDEN->mixlen, NULL, 0);
14637 }
14638
14639}
14640
14641static Uint8 *
14642DSOUND_GetDeviceBuf(_THIS)
14643{
14644 DWORD cursor = 0;
14645 DWORD junk = 0;
14646 HRESULT result = DS_OK;
14647 DWORD rawlen = 0;
14648
14649 SDLAUDIOHIDDEN->locked_buf = NULL;
14650 result = IDirectSoundBuffer_GetCurrentPosition(SDLAUDIOHIDDEN->mixbuf,
14651 &junk, &cursor);
14652 if (result == DSERR_BUFFERLOST) {
14653 IDirectSoundBuffer_Restore(SDLAUDIOHIDDEN->mixbuf);
14654 result = IDirectSoundBuffer_GetCurrentPosition(SDLAUDIOHIDDEN->mixbuf,
14655 &junk, &cursor);
14656 }
14657 if (result != DS_OK) {
14658 SetDSerror("DirectSound GetCurrentPosition", result);
14659 return (NULL);
14660 }
14661 cursor /= SDLAUDIOHIDDEN->mixlen;
14662#ifdef DEBUG_SOUND
14663
14664 {
14665 DWORD spot = cursor;
14666 if (spot < SDLAUDIOHIDDEN->lastchunk) {
14667 spot += SDLAUDIOHIDDEN->num_buffers;
14668 }
14669 if (spot > SDLAUDIOHIDDEN->lastchunk + 1) {
14670 fprintf(stderr, "Audio dropout, missed %d fragments\n",
14671 (spot - (SDLAUDIOHIDDEN->lastchunk + 1)));
14672 }
14673 }
14674#endif
14675 SDLAUDIOHIDDEN->lastchunk = cursor;
14676 cursor = (cursor + 1) % SDLAUDIOHIDDEN->num_buffers;
14677 cursor *= SDLAUDIOHIDDEN->mixlen;
14678
14679 result = IDirectSoundBuffer_Lock(SDLAUDIOHIDDEN->mixbuf, cursor,
14680 SDLAUDIOHIDDEN->mixlen,
14681 (LPVOID *) & SDLAUDIOHIDDEN->locked_buf,
14682 &rawlen, NULL, &junk, 0);
14683 if (result == DSERR_BUFFERLOST) {
14684 IDirectSoundBuffer_Restore(SDLAUDIOHIDDEN->mixbuf);
14685 result = IDirectSoundBuffer_Lock(SDLAUDIOHIDDEN->mixbuf, cursor,
14686 SDLAUDIOHIDDEN->mixlen,
14687 (LPVOID *) &
14688 SDLAUDIOHIDDEN->locked_buf, &rawlen, NULL,
14689 &junk, 0);
14690 }
14691 if (result != DS_OK) {
14692 SetDSerror("DirectSound Lock", result);
14693 return (NULL);
14694 }
14695 return (SDLAUDIOHIDDEN->locked_buf);
14696}
14697
14698static void
14699DSOUND_WaitDone(_THIS)
14700{
14701 Uint8 *stream = DSOUND_GetDeviceBuf(this);
14702
14703 if (stream != NULL) {
14704 SDL_memset(stream, this->spec.silence, SDLAUDIOHIDDEN->mixlen);
14705 DSOUND_PlayDevice(this);
14706 }
14707 DSOUND_WaitDevice(this);
14708
14709 IDirectSoundBuffer_Stop(SDLAUDIOHIDDEN->mixbuf);
14710}
14711
14712static void
14713DSOUND_CloseDevice(_THIS)
14714{
14715 if (SDLAUDIOHIDDEN != NULL) {
14716 if (SDLAUDIOHIDDEN->sound != NULL) {
14717 if (SDLAUDIOHIDDEN->mixbuf != NULL) {
14718
14719 IDirectSoundBuffer_Release(SDLAUDIOHIDDEN->mixbuf);
14720 SDLAUDIOHIDDEN->mixbuf = NULL;
14721 }
14722 IDirectSound_Release(SDLAUDIOHIDDEN->sound);
14723 SDLAUDIOHIDDEN->sound = NULL;
14724 }
14725
14726 SDL_free(SDLAUDIOHIDDEN);
14727 this->hidden = NULL;
14728 }
14729}
14730
14731static int
14732CreateSecondary(_THIS, HWND focus)
14733{
14734 LPDIRECTSOUND sndObj = SDLAUDIOHIDDEN->sound;
14735 LPDIRECTSOUNDBUFFER *sndbuf = &SDLAUDIOHIDDEN->mixbuf;
14736 Uint32 chunksize = this->spec.size;
14737 const int numchunks = 8;
14738 HRESULT result = DS_OK;
14739 DSBUFFERDESC format;
14740 LPVOID pvAudioPtr1, pvAudioPtr2;
14741 DWORD dwAudioBytes1, dwAudioBytes2;
14742 WAVEFORMATEX wfmt;
14743
14744 SDL_zero(wfmt);
14745
14746 if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
14747 wfmt.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
14748 } else {
14749 wfmt.wFormatTag = WAVE_FORMAT_PCM;
14750 }
14751
14752 wfmt.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
14753 wfmt.nChannels = this->spec.channels;
14754 wfmt.nSamplesPerSec = this->spec.freq;
14755 wfmt.nBlockAlign = wfmt.nChannels * (wfmt.wBitsPerSample / 8);
14756 wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
14757
14758 SDL_CalculateAudioSpec(&this->spec);
14759
14760 if (focus) {
14761 result = IDirectSound_SetCooperativeLevel(sndObj,
14762 focus, DSSCL_PRIORITY);
14763 } else {
14764 result = IDirectSound_SetCooperativeLevel(sndObj,
14765 GetDesktopWindow(),
14766 DSSCL_NORMAL);
14767 }
14768 if (result != DS_OK) {
14769 return SetDSerror("DirectSound SetCooperativeLevel", result);
14770 }
14771
14772 SDL_zero(format);
14773 format.dwSize = sizeof(format);
14774 format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
14775 if (!focus) {
14776 format.dwFlags |= DSBCAPS_GLOBALFOCUS;
14777 } else {
14778 format.dwFlags |= DSBCAPS_STICKYFOCUS;
14779 }
14780 format.dwBufferBytes = numchunks * chunksize;
14781 if ((format.dwBufferBytes < DSBSIZE_MIN) ||
14782 (format.dwBufferBytes > DSBSIZE_MAX)) {
14783 return SDL_SetError("Sound buffer size must be between %d and %d",
14784 DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks);
14785 }
14786 format.dwReserved = 0;
14787 format.lpwfxFormat = &wfmt;
14788 result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
14789 if (result != DS_OK) {
14790 return SetDSerror("DirectSound CreateSoundBuffer", result);
14791 }
14792 IDirectSoundBuffer_SetFormat(*sndbuf, &wfmt);
14793
14794 result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes,
14795 (LPVOID *) & pvAudioPtr1, &dwAudioBytes1,
14796 (LPVOID *) & pvAudioPtr2, &dwAudioBytes2,
14797 DSBLOCK_ENTIREBUFFER);
14798 if (result == DS_OK) {
14799 SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1);
14800 IDirectSoundBuffer_Unlock(*sndbuf,
14801 (LPVOID) pvAudioPtr1, dwAudioBytes1,
14802 (LPVOID) pvAudioPtr2, dwAudioBytes2);
14803 }
14804
14805 return (numchunks);
14806}
14807
14808typedef struct FindDevGUIDData
14809{
14810 const char *devname;
14811 GUID guid;
14812 int found;
14813} FindDevGUIDData;
14814
14815static BOOL CALLBACK
14816FindDevGUID(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data)
14817{
14818 if (guid != NULL) {
14819 FindDevGUIDData *data = (FindDevGUIDData *) _data;
14820 char *str = WIN_StringToUTF8(desc);
14821 const int match = (SDL_strcmp(str, data->devname) == 0);
14822 SDL_free(str);
14823 if (match) {
14824 data->found = 1;
14825 SDL_memcpy(&data->guid, guid, sizeof (data->guid));
14826 return FALSE;
14827 }
14828 }
14829 return TRUE;
14830}
14831
14832static int
14833DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
14834{
14835 HRESULT result;
14836 SDL_bool valid_format = SDL_FALSE;
14837 SDL_bool tried_format = SDL_FALSE;
14838 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
14839 FindDevGUIDData devguid;
14840 LPGUID guid = NULL;
14841
14842 if (devname != NULL) {
14843 devguid.found = 0;
14844 devguid.devname = devname;
14845 if (iscapture)
14846 pDirectSoundCaptureEnumerateW(FindDevGUID, &devguid);
14847 else
14848 pDirectSoundEnumerateW(FindDevGUID, &devguid);
14849
14850 if (!devguid.found) {
14851 return SDL_SetError("DirectSound: Requested device not found");
14852 }
14853 guid = &devguid.guid;
14854 }
14855
14856 this->hidden = (struct SDL_PrivateAudioData *)
14857 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
14858 if (SDLAUDIOHIDDEN == NULL) {
14859 return SDL_OutOfMemory();
14860 }
14861 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
14862
14863 result = pDirectSoundCreate8(guid, &SDLAUDIOHIDDEN->sound, NULL);
14864 if (result != DS_OK) {
14865 DSOUND_CloseDevice(this);
14866 return SetDSerror("DirectSoundCreate", result);
14867 }
14868
14869 while ((!valid_format) && (test_format)) {
14870 switch (test_format) {
14871 case AUDIO_U8:
14872 case AUDIO_S16:
14873 case AUDIO_S32:
14874 case AUDIO_F32:
14875 tried_format = SDL_TRUE;
14876 this->spec.format = test_format;
14877 SDLAUDIOHIDDEN->num_buffers = CreateSecondary(this, NULL);
14878 if (SDLAUDIOHIDDEN->num_buffers > 0) {
14879 valid_format = SDL_TRUE;
14880 }
14881 break;
14882 }
14883 test_format = SDL_NextAudioFormat();
14884 }
14885
14886 if (!valid_format) {
14887 DSOUND_CloseDevice(this);
14888 if (tried_format) {
14889 return -1;
14890 }
14891 return SDL_SetError("DirectSound: Unsupported audio format");
14892 }
14893
14894 SDLAUDIOHIDDEN->mixlen = this->spec.size;
14895
14896 return 0;
14897}
14898
14899static void
14900DSOUND_Deinitialize(void)
14901{
14902 DSOUND_Unload();
14903}
14904
14905static int
14906DSOUND_Init(SDL_AudioDriverImpl * impl)
14907{
14908 if (!DSOUND_Load()) {
14909 return 0;
14910 }
14911
14912 impl->DetectDevices = DSOUND_DetectDevices;
14913 impl->OpenDevice = DSOUND_OpenDevice;
14914 impl->PlayDevice = DSOUND_PlayDevice;
14915 impl->WaitDevice = DSOUND_WaitDevice;
14916 impl->WaitDone = DSOUND_WaitDone;
14917 impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
14918 impl->CloseDevice = DSOUND_CloseDevice;
14919 impl->Deinitialize = DSOUND_Deinitialize;
14920
14921 return 1;
14922}
14923
14924AudioBootStrap DSOUND_bootstrap = {
14925 "directsound", "DirectSound", DSOUND_Init, 0
14926};
14927
14928#endif
14929#if SDL_AUDIO_DRIVER_OSS
14930
14931#include <stdio.h>
14932#include <string.h>
14933#include <errno.h>
14934#include <unistd.h>
14935#include <fcntl.h>
14936#include <signal.h>
14937#include <sys/time.h>
14938#include <sys/ioctl.h>
14939#include <sys/stat.h>
14940
14941#if SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
14942
14943#include <soundcard.h>
14944#else
14945
14946#include <sys/soundcard.h>
14947#endif
14948
14949#define SDL_AllocAudioMem SDL_malloc
14950#define SDL_FreeAudioMem SDL_free
14951#ifdef USE_BLOCKING_WRITES
14952#define OPEN_FLAGS_OUTPUT O_WRONLY
14953#define OPEN_FLAGS_INPUT O_RDONLY
14954#else
14955#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK)
14956#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
14957#endif
14958
14959void SDL_EnumUnixAudioDevices(int iscapture, int classic,
14960 int (*test) (int fd), SDL_AddAudioDevice addfn);
14961#ifndef _SDL_dspaudio_h
14962#define _SDL_dspaudio_h
14963
14964#undef _THIS
14965#define _THIS SDL_AudioDevice *this
14966
14967#undef SDLAUDIOHIDDEN
14968#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataDSP*)this->hidden)
14969struct SDL_PrivateAudioDataDSP
14970{
14971
14972 int audio_fd;
14973
14974 Uint8 *mixbuf;
14975 int mixlen;
14976};
14977#define FUDGE_TICKS 10
14978
14979#endif
14980
14981static void
14982DSP_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
14983{
14984 SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn);
14985}
14986
14987static void
14988DSP_CloseDevice(_THIS)
14989{
14990 if (SDLAUDIOHIDDEN != NULL) {
14991 SDL_FreeAudioMem(SDLAUDIOHIDDEN->mixbuf);
14992 SDLAUDIOHIDDEN->mixbuf = NULL;
14993 if (SDLAUDIOHIDDEN->audio_fd >= 0) {
14994 close(SDLAUDIOHIDDEN->audio_fd);
14995 SDLAUDIOHIDDEN->audio_fd = -1;
14996 }
14997 SDL_free(SDLAUDIOHIDDEN);
14998 this->hidden = NULL;
14999 }
15000}
15001
15002static int
15003DSP_OpenDevice(_THIS, const char *devname, int iscapture)
15004{
15005 const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
15006 int format;
15007 int value;
15008 int frag_spec;
15009 SDL_AudioFormat test_format;
15010
15011 if (devname == NULL) {
15012 devname = SDL_GetAudioDeviceName(0, iscapture);
15013 if (devname == NULL) {
15014 return SDL_SetError("No such audio device");
15015 }
15016 }
15017
15018 if (this->spec.channels > 8)
15019 this->spec.channels = 8;
15020 else if (this->spec.channels > 4)
15021 this->spec.channels = 4;
15022 else if (this->spec.channels > 2)
15023 this->spec.channels = 2;
15024
15025 this->hidden = (struct SDL_PrivateAudioData *)
15026 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
15027 if (SDLAUDIOHIDDEN == NULL) {
15028 return SDL_OutOfMemory();
15029 }
15030 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
15031
15032 SDLAUDIOHIDDEN->audio_fd = open(devname, flags, 0);
15033 if (SDLAUDIOHIDDEN->audio_fd < 0) {
15034 DSP_CloseDevice(this);
15035 return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
15036 }
15037 SDLAUDIOHIDDEN->mixbuf = NULL;
15038
15039 {
15040 long ctlflags;
15041 ctlflags = fcntl(SDLAUDIOHIDDEN->audio_fd, F_GETFL);
15042 ctlflags &= ~O_NONBLOCK;
15043 if (fcntl(SDLAUDIOHIDDEN->audio_fd, F_SETFL, ctlflags) < 0) {
15044 DSP_CloseDevice(this);
15045 return SDL_SetError("Couldn't set audio blocking mode");
15046 }
15047 }
15048
15049 if (ioctl(SDLAUDIOHIDDEN->audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
15050 perror("SNDCTL_DSP_GETFMTS");
15051 DSP_CloseDevice(this);
15052 return SDL_SetError("Couldn't get audio format list");
15053 }
15054
15055 format = 0;
15056 for (test_format = SDL_FirstAudioFormat(this->spec.format);
15057 !format && test_format;) {
15058#ifdef DEBUG_AUDIO
15059 fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
15060#endif
15061 switch (test_format) {
15062 case AUDIO_U8:
15063 if (value & AFMT_U8) {
15064 format = AFMT_U8;
15065 }
15066 break;
15067 case AUDIO_S16LSB:
15068 if (value & AFMT_S16_LE) {
15069 format = AFMT_S16_LE;
15070 }
15071 break;
15072 case AUDIO_S16MSB:
15073 if (value & AFMT_S16_BE) {
15074 format = AFMT_S16_BE;
15075 }
15076 break;
15077#if 0
15078
15079 case AUDIO_S8:
15080 if (value & AFMT_S8) {
15081 format = AFMT_S8;
15082 }
15083 break;
15084 case AUDIO_U16LSB:
15085 if (value & AFMT_U16_LE) {
15086 format = AFMT_U16_LE;
15087 }
15088 break;
15089 case AUDIO_U16MSB:
15090 if (value & AFMT_U16_BE) {
15091 format = AFMT_U16_BE;
15092 }
15093 break;
15094#endif
15095 default:
15096 format = 0;
15097 break;
15098 }
15099 if (!format) {
15100 test_format = SDL_NextAudioFormat();
15101 }
15102 }
15103 if (format == 0) {
15104 DSP_CloseDevice(this);
15105 return SDL_SetError("Couldn't find any hardware audio formats");
15106 }
15107 this->spec.format = test_format;
15108
15109 value = format;
15110 if ((ioctl(SDLAUDIOHIDDEN->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
15111 (value != format)) {
15112 perror("SNDCTL_DSP_SETFMT");
15113 DSP_CloseDevice(this);
15114 return SDL_SetError("Couldn't set audio format");
15115 }
15116
15117 value = this->spec.channels;
15118 if (ioctl(SDLAUDIOHIDDEN->audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) {
15119 perror("SNDCTL_DSP_CHANNELS");
15120 DSP_CloseDevice(this);
15121 return SDL_SetError("Cannot set the number of channels");
15122 }
15123 this->spec.channels = value;
15124
15125 value = this->spec.freq;
15126 if (ioctl(SDLAUDIOHIDDEN->audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
15127 perror("SNDCTL_DSP_SPEED");
15128 DSP_CloseDevice(this);
15129 return SDL_SetError("Couldn't set audio frequency");
15130 }
15131 this->spec.freq = value;
15132
15133 SDL_CalculateAudioSpec(&this->spec);
15134
15135 for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec);
15136 if ((0x01U << frag_spec) != this->spec.size) {
15137 DSP_CloseDevice(this);
15138 return SDL_SetError("Fragment size must be a power of two");
15139 }
15140 frag_spec |= 0x00020000;
15141
15142#ifdef DEBUG_AUDIO
15143 fprintf(stderr, "Requesting %d fragments of size %d\n",
15144 (frag_spec >> 16), 1 << (frag_spec & 0xFFFF));
15145#endif
15146 if (ioctl(SDLAUDIOHIDDEN->audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
15147 perror("SNDCTL_DSP_SETFRAGMENT");
15148 }
15149#ifdef DEBUG_AUDIO
15150 {
15151 audio_buf_info info;
15152 ioctl(SDLAUDIOHIDDEN->audio_fd, SNDCTL_DSP_GETOSPACE, &info);
15153 fprintf(stderr, "fragments = %d\n", info.fragments);
15154 fprintf(stderr, "fragstotal = %d\n", info.fragstotal);
15155 fprintf(stderr, "fragsize = %d\n", info.fragsize);
15156 fprintf(stderr, "bytes = %d\n", info.bytes);
15157 }
15158#endif
15159
15160 SDLAUDIOHIDDEN->mixlen = this->spec.size;
15161 SDLAUDIOHIDDEN->mixbuf = (Uint8 *) SDL_AllocAudioMem(SDLAUDIOHIDDEN->mixlen);
15162 if (SDLAUDIOHIDDEN->mixbuf == NULL) {
15163 DSP_CloseDevice(this);
15164 return SDL_OutOfMemory();
15165 }
15166 SDL_memset(SDLAUDIOHIDDEN->mixbuf, this->spec.silence, this->spec.size);
15167
15168 return 0;
15169}
15170
15171static void
15172DSP_PlayDevice(_THIS)
15173{
15174 const Uint8 *mixbuf = SDLAUDIOHIDDEN->mixbuf;
15175 const int mixlen = SDLAUDIOHIDDEN->mixlen;
15176 if (write(SDLAUDIOHIDDEN->audio_fd, mixbuf, mixlen) == -1) {
15177 perror("Audio write");
15178 this->enabled = 0;
15179 }
15180#ifdef DEBUG_AUDIO
15181 fprintf(stderr, "Wrote %d bytes of audio data\n", mixlen);
15182#endif
15183}
15184
15185static Uint8 *
15186DSP_GetDeviceBuf(_THIS)
15187{
15188 return (SDLAUDIOHIDDEN->mixbuf);
15189}
15190
15191static int
15192DSP_Init(SDL_AudioDriverImpl * impl)
15193{
15194
15195 impl->DetectDevices = DSP_DetectDevices;
15196 impl->OpenDevice = DSP_OpenDevice;
15197 impl->PlayDevice = DSP_PlayDevice;
15198 impl->GetDeviceBuf = DSP_GetDeviceBuf;
15199 impl->CloseDevice = DSP_CloseDevice;
15200
15201 return 1;
15202}
15203
15204AudioBootStrap DSP_bootstrap = {
15205 "dsp", "OSS /dev/dsp standard audio", DSP_Init, 0
15206};
15207
15208#endif
15209#define SDL_AllocAudioMem SDL_malloc
15210#define SDL_FreeAudioMem SDL_free
15211
15212#undef _THIS
15213#define _THIS SDL_AudioDevice *_this
15214
15215static SDL_AudioDriver current_audio;
15216static SDL_AudioDevice *open_devices[16];
15217
15218#define DEFAULT_OUTPUT_DEVNAME "System audio output device"
15219#define DEFAULT_INPUT_DEVNAME "System audio capture device"
15220
15221extern AudioBootStrap BSD_AUDIO_bootstrap;
15222extern AudioBootStrap DSP_bootstrap;
15223extern AudioBootStrap ALSA_bootstrap;
15224extern AudioBootStrap PULSEAUDIO_bootstrap;
15225extern AudioBootStrap QSAAUDIO_bootstrap;
15226extern AudioBootStrap SUNAUDIO_bootstrap;
15227extern AudioBootStrap ARTS_bootstrap;
15228extern AudioBootStrap ESD_bootstrap;
15229extern AudioBootStrap NAS_bootstrap;
15230extern AudioBootStrap XAUDIO2_bootstrap;
15231extern AudioBootStrap DSOUND_bootstrap;
15232extern AudioBootStrap WINMM_bootstrap;
15233extern AudioBootStrap PAUDIO_bootstrap;
15234extern AudioBootStrap HAIKUAUDIO_bootstrap;
15235extern AudioBootStrap COREAUDIO_bootstrap;
15236extern AudioBootStrap SNDMGR_bootstrap;
15237extern AudioBootStrap DISKAUD_bootstrap;
15238extern AudioBootStrap DUMMYAUD_bootstrap;
15239extern AudioBootStrap DCAUD_bootstrap;
15240extern AudioBootStrap DART_bootstrap;
15241extern AudioBootStrap NDSAUD_bootstrap;
15242extern AudioBootStrap FUSIONSOUND_bootstrap;
15243extern AudioBootStrap ANDROIDAUD_bootstrap;
15244extern AudioBootStrap PSPAUD_bootstrap;
15245extern AudioBootStrap SNDIO_bootstrap;
15246
15247static const AudioBootStrap *const bootstrap[] = {
15248#if SDL_AUDIO_DRIVER_PULSEAUDIO
15249 &PULSEAUDIO_bootstrap,
15250#endif
15251#if SDL_AUDIO_DRIVER_ALSA
15252 &ALSA_bootstrap,
15253#endif
15254#if SDL_AUDIO_DRIVER_SNDIO
15255 &SNDIO_bootstrap,
15256#endif
15257#if SDL_AUDIO_DRIVER_BSD
15258 &BSD_AUDIO_bootstrap,
15259#endif
15260#if SDL_AUDIO_DRIVER_OSS
15261 &DSP_bootstrap,
15262#endif
15263#if SDL_AUDIO_DRIVER_QSA
15264 &QSAAUDIO_bootstrap,
15265#endif
15266#if SDL_AUDIO_DRIVER_SUNAUDIO
15267 &SUNAUDIO_bootstrap,
15268#endif
15269#if SDL_AUDIO_DRIVER_ARTS
15270 &ARTS_bootstrap,
15271#endif
15272#if SDL_AUDIO_DRIVER_ESD
15273 &ESD_bootstrap,
15274#endif
15275#if SDL_AUDIO_DRIVER_NAS
15276 &NAS_bootstrap,
15277#endif
15278#if SDL_AUDIO_DRIVER_XAUDIO2
15279 &XAUDIO2_bootstrap,
15280#endif
15281#if SDL_AUDIO_DRIVER_DSOUND
15282 &DSOUND_bootstrap,
15283#endif
15284#if SDL_AUDIO_DRIVER_WINMM
15285 &WINMM_bootstrap,
15286#endif
15287#if SDL_AUDIO_DRIVER_PAUDIO
15288 &PAUDIO_bootstrap,
15289#endif
15290#if SDL_AUDIO_DRIVER_HAIKU
15291 &HAIKUAUDIO_bootstrap,
15292#endif
15293#if SDL_AUDIO_DRIVER_COREAUDIO
15294 &COREAUDIO_bootstrap,
15295#endif
15296#if SDL_AUDIO_DRIVER_DISK
15297 &DISKAUD_bootstrap,
15298#endif
15299#if SDL_AUDIO_DRIVER_DUMMY
15300 &DUMMYAUD_bootstrap,
15301#endif
15302#if SDL_AUDIO_DRIVER_FUSIONSOUND
15303 &FUSIONSOUND_bootstrap,
15304#endif
15305#if SDL_AUDIO_DRIVER_ANDROID
15306 &ANDROIDAUD_bootstrap,
15307#endif
15308#if SDL_AUDIO_DRIVER_PSP
15309 &PSPAUD_bootstrap,
15310#endif
15311 NULL
15312};
15313
15314static SDL_AudioDevice *
15315get_audio_device(SDL_AudioDeviceID id)
15316{
15317 id--;
15318 if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
15319 SDL_SetError("Invalid audio device ID");
15320 return NULL;
15321 }
15322
15323 return open_devices[id];
15324}
15325
15326static void
15327SDL_AudioDetectDevices_Default(int iscapture, SDL_AddAudioDevice addfn)
15328{
15329}
15330
15331static void
15332SDL_AudioThreadInit_Default(_THIS)
15333{
15334}
15335
15336static void
15337SDL_AudioWaitDevice_Default(_THIS)
15338{
15339}
15340
15341static void
15342SDL_AudioPlayDevice_Default(_THIS)
15343{
15344}
15345
15346static Uint8 *
15347SDL_AudioGetDeviceBuf_Default(_THIS)
15348{
15349 return NULL;
15350}
15351
15352static void
15353SDL_AudioWaitDone_Default(_THIS)
15354{
15355}
15356
15357static void
15358SDL_AudioCloseDevice_Default(_THIS)
15359{
15360}
15361
15362static void
15363SDL_AudioDeinitialize_Default(void)
15364{
15365}
15366
15367static int
15368SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
15369{
15370 return -1;
15371}
15372
15373static void
15374SDL_AudioLockDevice_Default(SDL_AudioDevice * device)
15375{
15376 if (device->thread && (SDL_ThreadID() == device->threadid)) {
15377 return;
15378 }
15379 SDL_LockMutex(device->mixer_lock);
15380}
15381
15382static void
15383SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
15384{
15385 if (device->thread && (SDL_ThreadID() == device->threadid)) {
15386 return;
15387 }
15388 SDL_UnlockMutex(device->mixer_lock);
15389}
15390
15391static void
15392finalize_audio_entry_points(void)
15393{
15394
15395#define FILL_STUB(x) \
15396 if (current_audio.impl.x == NULL) { \
15397 current_audio.impl.x = SDL_Audio##x##_Default; \
15398 }
15399 FILL_STUB(DetectDevices);
15400 FILL_STUB(OpenDevice);
15401 FILL_STUB(ThreadInit);
15402 FILL_STUB(WaitDevice);
15403 FILL_STUB(PlayDevice);
15404 FILL_STUB(GetDeviceBuf);
15405 FILL_STUB(WaitDone);
15406 FILL_STUB(CloseDevice);
15407 FILL_STUB(LockDevice);
15408 FILL_STUB(UnlockDevice);
15409 FILL_STUB(Deinitialize);
15410#undef FILL_STUB
15411}
15412
15413static void
15414SDL_StreamWrite(SDL_AudioStreamer * stream, Uint8 * buf, int length)
15415{
15416 int i;
15417
15418 for (i = 0; i < length; ++i) {
15419 stream->buffer[stream->write_pos] = buf[i];
15420 ++stream->write_pos;
15421 }
15422}
15423
15424static void
15425SDL_StreamRead(SDL_AudioStreamer * stream, Uint8 * buf, int length)
15426{
15427 int i;
15428
15429 for (i = 0; i < length; ++i) {
15430 buf[i] = stream->buffer[stream->read_pos];
15431 ++stream->read_pos;
15432 }
15433}
15434
15435static int
15436SDL_StreamLength(SDL_AudioStreamer * stream)
15437{
15438 return (stream->write_pos - stream->read_pos) % stream->max_len;
15439}
15440
15441#if 0
15442static int
15443SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
15444{
15445
15446 stream->buffer = (Uint8 *) SDL_malloc(max_len);
15447 if (stream->buffer == NULL) {
15448 return -1;
15449 }
15450
15451 stream->max_len = max_len;
15452 stream->read_pos = 0;
15453 stream->write_pos = 0;
15454
15455 SDL_memset(stream->buffer, silence, max_len);
15456
15457 return 0;
15458}
15459#endif
15460
15461static void
15462SDL_StreamDeinit(SDL_AudioStreamer * stream)
15463{
15464 SDL_free(stream->buffer);
15465}
15466
15467#if defined(ANDROID)
15468#include <android/log.h>
15469#endif
15470
15471int SDLCALL
15472SDL_RunAudio(void *devicep)
15473{
15474 SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
15475 Uint8 *stream;
15476 int stream_len;
15477 void *udata;
15478 void (SDLCALL * fill) (void *userdata, Uint8 * stream, int len);
15479 Uint32 delay;
15480
15481 Uint8 *istream;
15482 int istream_len = 0;
15483
15484 SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
15485
15486 device->threadid = SDL_ThreadID();
15487 current_audio.impl.ThreadInit(device);
15488
15489 fill = device->spec.callback;
15490 udata = device->spec.userdata;
15491
15492 device->use_streamer = 0;
15493
15494 if (device->convert.needed) {
15495#if 0
15496
15497 if (device->convert.len_mult != 1 || device->convert.len_div != 1) {
15498
15499 stream_max_len = 2 * device->spec.size;
15500 if (device->convert.len_mult > device->convert.len_div) {
15501 stream_max_len *= device->convert.len_mult;
15502 stream_max_len /= device->convert.len_div;
15503 }
15504 if (SDL_StreamInit(&device->streamer, stream_max_len, silence) <
15505 0)
15506 return -1;
15507 device->use_streamer = 1;
15508
15509 istream_len =
15510 device->spec.size * device->convert.len_div /
15511 device->convert.len_mult;
15512 }
15513#endif
15514 stream_len = device->convert.len;
15515 } else {
15516 stream_len = device->spec.size;
15517 }
15518
15519 delay = ((device->spec.samples * 1000) / device->spec.freq);
15520
15521 if (device->use_streamer == 1) {
15522
15523 while (device->enabled) {
15524
15525 if (device->paused) {
15526 SDL_Delay(delay);
15527 continue;
15528 }
15529
15530 if (SDL_StreamLength(&device->streamer) < stream_len) {
15531
15532 if (device->convert.needed) {
15533 if (device->convert.buf) {
15534 istream = device->convert.buf;
15535 } else {
15536 continue;
15537 }
15538 } else {
15539
15540 istream = current_audio.impl.GetDeviceBuf(device);
15541 if (istream == NULL) {
15542 istream = device->fake_stream;
15543 }
15544 }
15545
15546 SDL_LockMutex(device->mixer_lock);
15547 (*fill) (udata, istream, istream_len);
15548 SDL_UnlockMutex(device->mixer_lock);
15549
15550 if (device->convert.needed) {
15551 SDL_ConvertAudio(&device->convert);
15552 if (istream == NULL) {
15553 istream = device->fake_stream;
15554 }
15555
15556 SDL_StreamWrite(&device->streamer, device->convert.buf,
15557 device->convert.len_cvt);
15558 } else {
15559 SDL_StreamWrite(&device->streamer, istream, istream_len);
15560 }
15561 }
15562
15563 if (SDL_StreamLength(&device->streamer) >= stream_len) {
15564
15565 if (device->convert.needed) {
15566 if (device->convert.buf) {
15567 stream = device->convert.buf;
15568 } else {
15569 continue;
15570 }
15571 } else {
15572 stream = current_audio.impl.GetDeviceBuf(device);
15573 if (stream == NULL) {
15574 stream = device->fake_stream;
15575 }
15576 }
15577
15578 SDL_StreamRead(&device->streamer, stream, stream_len);
15579
15580 if (stream != device->fake_stream) {
15581 current_audio.impl.PlayDevice(device);
15582
15583 current_audio.impl.WaitDevice(device);
15584 } else {
15585 SDL_Delay(delay);
15586 }
15587 }
15588
15589 }
15590 } else {
15591
15592 const int silence = (int) device->spec.silence;
15593
15594 while (device->enabled) {
15595
15596 if (device->convert.needed) {
15597 if (device->convert.buf) {
15598 stream = device->convert.buf;
15599 } else {
15600 continue;
15601 }
15602 } else {
15603 stream = current_audio.impl.GetDeviceBuf(device);
15604 if (stream == NULL) {
15605 stream = device->fake_stream;
15606 }
15607 }
15608
15609 SDL_LockMutex(device->mixer_lock);
15610 if (device->paused) {
15611 SDL_memset(stream, silence, stream_len);
15612 } else {
15613 (*fill) (udata, stream, stream_len);
15614 }
15615 SDL_UnlockMutex(device->mixer_lock);
15616
15617 if (device->convert.needed) {
15618 SDL_ConvertAudio(&device->convert);
15619 stream = current_audio.impl.GetDeviceBuf(device);
15620 if (stream == NULL) {
15621 stream = device->fake_stream;
15622 }
15623 SDL_memcpy(stream, device->convert.buf,
15624 device->convert.len_cvt);
15625 }
15626
15627 if (stream != device->fake_stream) {
15628 current_audio.impl.PlayDevice(device);
15629
15630 current_audio.impl.WaitDevice(device);
15631 } else {
15632 SDL_Delay(delay);
15633 }
15634 }
15635 }
15636
15637 current_audio.impl.WaitDone(device);
15638
15639 if (device->use_streamer == 1)
15640 SDL_StreamDeinit(&device->streamer);
15641
15642 return (0);
15643}
15644
15645static SDL_AudioFormat
15646SDL_ParseAudioFormat(const char *string)
15647{
15648#define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x
15649 CHECK_FMT_STRING(U8);
15650 CHECK_FMT_STRING(S8);
15651 CHECK_FMT_STRING(U16LSB);
15652 CHECK_FMT_STRING(S16LSB);
15653 CHECK_FMT_STRING(U16MSB);
15654 CHECK_FMT_STRING(S16MSB);
15655 CHECK_FMT_STRING(U16SYS);
15656 CHECK_FMT_STRING(S16SYS);
15657 CHECK_FMT_STRING(U16);
15658 CHECK_FMT_STRING(S16);
15659 CHECK_FMT_STRING(S32LSB);
15660 CHECK_FMT_STRING(S32MSB);
15661 CHECK_FMT_STRING(S32SYS);
15662 CHECK_FMT_STRING(S32);
15663 CHECK_FMT_STRING(F32LSB);
15664 CHECK_FMT_STRING(F32MSB);
15665 CHECK_FMT_STRING(F32SYS);
15666 CHECK_FMT_STRING(F32);
15667#undef CHECK_FMT_STRING
15668 return 0;
15669}
15670
15671int
15672SDL_GetNumAudioDrivers(void)
15673{
15674 return (SDL_arraysize(bootstrap) - 1);
15675}
15676
15677const char *
15678SDL_GetAudioDriver(int index)
15679{
15680 if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
15681 return (bootstrap[index]->name);
15682 }
15683 return (NULL);
15684}
15685
15686int
15687SDL_AudioInit(const char *driver_name)
15688{
15689 int i = 0;
15690 int initialized = 0;
15691 int tried_to_init = 0;
15692
15693 if (SDL_WasInit(SDL_INIT_AUDIO)) {
15694 SDL_AudioQuit();
15695 }
15696
15697 SDL_memset(&current_audio, '\0', sizeof(current_audio));
15698 SDL_memset(open_devices, '\0', sizeof(open_devices));
15699
15700 if (driver_name == NULL) {
15701 driver_name = SDL_getenv("SDL_AUDIODRIVER");
15702 }
15703
15704 for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
15705
15706 const AudioBootStrap *backend = bootstrap[i];
15707 if ((driver_name && (SDL_strncasecmp(backend->name, driver_name, SDL_strlen(driver_name)) != 0)) ||
15708 (!driver_name && backend->demand_only)) {
15709 continue;
15710 }
15711
15712 tried_to_init = 1;
15713 SDL_memset(&current_audio, 0, sizeof(current_audio));
15714 current_audio.name = backend->name;
15715 current_audio.desc = backend->desc;
15716 initialized = backend->init(&current_audio.impl);
15717 }
15718
15719 if (!initialized) {
15720
15721 if (!tried_to_init) {
15722 if (driver_name) {
15723 SDL_SetError("Audio target '%s' not available", driver_name);
15724 } else {
15725 SDL_SetError("No available audio device");
15726 }
15727 }
15728
15729 SDL_memset(&current_audio, 0, sizeof(current_audio));
15730 return (-1);
15731 }
15732
15733 finalize_audio_entry_points();
15734
15735 return (0);
15736}
15737
15738const char *
15739SDL_GetCurrentAudioDriver()
15740{
15741 return current_audio.name;
15742}
15743
15744static void
15745free_device_list(char ***devices, int *devCount)
15746{
15747 int i = *devCount;
15748 if ((i > 0) && (*devices != NULL)) {
15749 while (i--) {
15750 SDL_free((*devices)[i]);
15751 }
15752 }
15753
15754 SDL_free(*devices);
15755
15756 *devices = NULL;
15757 *devCount = 0;
15758}
15759
15760static
15761void SDL_AddCaptureAudioDevice(const char *_name)
15762{
15763 char *name = NULL;
15764 void *ptr = SDL_realloc(current_audio.inputDevices,
15765 (current_audio.inputDeviceCount+1) * sizeof(char*));
15766 if (ptr == NULL) {
15767 return;
15768 }
15769
15770 current_audio.inputDevices = (char **) ptr;
15771 name = SDL_strdup(_name);
15772 current_audio.inputDevices[current_audio.inputDeviceCount++] = name;
15773}
15774
15775static
15776void SDL_AddOutputAudioDevice(const char *_name)
15777{
15778 char *name = NULL;
15779 void *ptr = SDL_realloc(current_audio.outputDevices,
15780 (current_audio.outputDeviceCount+1) * sizeof(char*));
15781 if (ptr == NULL) {
15782 return;
15783 }
15784
15785 current_audio.outputDevices = (char **) ptr;
15786 name = SDL_strdup(_name);
15787 current_audio.outputDevices[current_audio.outputDeviceCount++] = name;
15788}
15789
15790int
15791SDL_GetNumAudioDevices(int iscapture)
15792{
15793 int retval = 0;
15794
15795 if (!SDL_WasInit(SDL_INIT_AUDIO)) {
15796 return -1;
15797 }
15798
15799 if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
15800 return 0;
15801 }
15802
15803 if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
15804 return 1;
15805 }
15806
15807 if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
15808 return 1;
15809 }
15810
15811 if (iscapture) {
15812 free_device_list(&current_audio.inputDevices,
15813 &current_audio.inputDeviceCount);
15814 current_audio.impl.DetectDevices(iscapture, SDL_AddCaptureAudioDevice);
15815 retval = current_audio.inputDeviceCount;
15816 } else {
15817 free_device_list(&current_audio.outputDevices,
15818 &current_audio.outputDeviceCount);
15819 current_audio.impl.DetectDevices(iscapture, SDL_AddOutputAudioDevice);
15820 retval = current_audio.outputDeviceCount;
15821 }
15822
15823 return retval;
15824}
15825
15826const char *
15827SDL_GetAudioDeviceName(int index, int iscapture)
15828{
15829 if (!SDL_WasInit(SDL_INIT_AUDIO)) {
15830 SDL_SetError("Audio subsystem is not initialized");
15831 return NULL;
15832 }
15833
15834 if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
15835 SDL_SetError("No capture support");
15836 return NULL;
15837 }
15838
15839 if (index < 0) {
15840 goto no_such_device;
15841 }
15842
15843 if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
15844 if (index > 0) {
15845 goto no_such_device;
15846 }
15847 return DEFAULT_INPUT_DEVNAME;
15848 }
15849
15850 if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
15851 if (index > 0) {
15852 goto no_such_device;
15853 }
15854 return DEFAULT_OUTPUT_DEVNAME;
15855 }
15856
15857 if (iscapture) {
15858 if (index >= current_audio.inputDeviceCount) {
15859 goto no_such_device;
15860 }
15861 return current_audio.inputDevices[index];
15862 } else {
15863 if (index >= current_audio.outputDeviceCount) {
15864 goto no_such_device;
15865 }
15866 return current_audio.outputDevices[index];
15867 }
15868
15869no_such_device:
15870 SDL_SetError("No such device");
15871 return NULL;
15872}
15873
15874static void
15875close_audio_device(SDL_AudioDevice * device)
15876{
15877 device->enabled = 0;
15878 if (device->thread != NULL) {
15879 SDL_WaitThread(device->thread, NULL);
15880 }
15881 if (device->mixer_lock != NULL) {
15882 SDL_DestroyMutex(device->mixer_lock);
15883 }
15884 SDL_FreeAudioMem(device->fake_stream);
15885 if (device->convert.needed) {
15886 SDL_FreeAudioMem(device->convert.buf);
15887 }
15888 if (device->opened) {
15889 current_audio.impl.CloseDevice(device);
15890 device->opened = 0;
15891 }
15892 SDL_FreeAudioMem(device);
15893}
15894
15895static int
15896prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
15897{
15898 SDL_memcpy(prepared, orig, sizeof(SDL_AudioSpec));
15899
15900 if (orig->callback == NULL) {
15901 SDL_SetError("SDL_OpenAudio() passed a NULL callback");
15902 return 0;
15903 }
15904
15905 if (orig->freq == 0) {
15906 const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
15907 if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
15908 prepared->freq = 22050;
15909 }
15910 }
15911
15912 if (orig->format == 0) {
15913 const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
15914 if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
15915 prepared->format = AUDIO_S16;
15916 }
15917 }
15918
15919 switch (orig->channels) {
15920 case 0:{
15921 const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
15922 if ((!env) || ((prepared->channels = (Uint8) SDL_atoi(env)) == 0)) {
15923 prepared->channels = 2;
15924 }
15925 break;
15926 }
15927 case 1:
15928 case 2:
15929 case 4:
15930 case 6:
15931 break;
15932 default:
15933 SDL_SetError("Unsupported number of audio channels.");
15934 return 0;
15935 }
15936
15937 if (orig->samples == 0) {
15938 const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
15939 if ((!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0)) {
15940
15941 const int samples = (prepared->freq / 1000) * 46;
15942 int power2 = 1;
15943 while (power2 < samples) {
15944 power2 *= 2;
15945 }
15946 prepared->samples = power2;
15947 }
15948 }
15949
15950 SDL_CalculateAudioSpec(prepared);
15951
15952 return 1;
15953}
15954
15955static SDL_AudioDeviceID
15956open_audio_device(const char *devname, int iscapture,
15957 const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
15958 int allowed_changes, int min_id)
15959{
15960 SDL_AudioDeviceID id = 0;
15961 SDL_AudioSpec _obtained;
15962 SDL_AudioDevice *device;
15963 SDL_bool build_cvt;
15964 int i = 0;
15965
15966 if (!SDL_WasInit(SDL_INIT_AUDIO)) {
15967 SDL_SetError("Audio subsystem is not initialized");
15968 return 0;
15969 }
15970
15971 if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
15972 SDL_SetError("No capture support");
15973 return 0;
15974 }
15975
15976 if (!obtained) {
15977 obtained = &_obtained;
15978 }
15979 if (!prepare_audiospec(desired, obtained)) {
15980 return 0;
15981 }
15982
15983 if (devname == NULL) {
15984 devname = SDL_getenv("SDL_AUDIO_DEVICE_NAME");
15985 }
15986
15987 if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
15988 if ((devname) && (SDL_strcmp(devname, DEFAULT_INPUT_DEVNAME) != 0)) {
15989 SDL_SetError("No such device");
15990 return 0;
15991 }
15992 devname = NULL;
15993
15994 for (i = 0; i < SDL_arraysize(open_devices); i++) {
15995 if ((open_devices[i]) && (open_devices[i]->iscapture)) {
15996 SDL_SetError("Audio device already open");
15997 return 0;
15998 }
15999 }
16000 }
16001
16002 if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
16003 if ((devname) && (SDL_strcmp(devname, DEFAULT_OUTPUT_DEVNAME) != 0)) {
16004 SDL_SetError("No such device");
16005 return 0;
16006 }
16007 devname = NULL;
16008
16009 for (i = 0; i < SDL_arraysize(open_devices); i++) {
16010 if ((open_devices[i]) && (!open_devices[i]->iscapture)) {
16011 SDL_SetError("Audio device already open");
16012 return 0;
16013 }
16014 }
16015 }
16016
16017 device = (SDL_AudioDevice *) SDL_AllocAudioMem(sizeof(SDL_AudioDevice));
16018 if (device == NULL) {
16019 SDL_OutOfMemory();
16020 return 0;
16021 }
16022 SDL_memset(device, '\0', sizeof(SDL_AudioDevice));
16023 device->spec = *obtained;
16024 device->enabled = 1;
16025 device->paused = 1;
16026 device->iscapture = iscapture;
16027
16028 if (!current_audio.impl.SkipMixerLock) {
16029 device->mixer_lock = SDL_CreateMutex();
16030 if (device->mixer_lock == NULL) {
16031 close_audio_device(device);
16032 SDL_SetError("Couldn't create mixer lock");
16033 return 0;
16034 }
16035 }
16036
16037 if ( ((iscapture) && (current_audio.inputDevices == NULL)) ||
16038 ((!iscapture) && (current_audio.outputDevices == NULL)) )
16039 SDL_GetNumAudioDevices(iscapture);
16040
16041 if (current_audio.impl.OpenDevice(device, devname, iscapture) < 0) {
16042 close_audio_device(device);
16043 return 0;
16044 }
16045 device->opened = 1;
16046
16047 device->fake_stream = (Uint8 *)SDL_AllocAudioMem(device->spec.size);
16048 if (device->fake_stream == NULL) {
16049 close_audio_device(device);
16050 SDL_OutOfMemory();
16051 return 0;
16052 }
16053
16054 build_cvt = SDL_FALSE;
16055 if (obtained->freq != device->spec.freq) {
16056 if (allowed_changes & SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) {
16057 obtained->freq = device->spec.freq;
16058 } else {
16059 build_cvt = SDL_TRUE;
16060 }
16061 }
16062 if (obtained->format != device->spec.format) {
16063 if (allowed_changes & SDL_AUDIO_ALLOW_FORMAT_CHANGE) {
16064 obtained->format = device->spec.format;
16065 } else {
16066 build_cvt = SDL_TRUE;
16067 }
16068 }
16069 if (obtained->channels != device->spec.channels) {
16070 if (allowed_changes & SDL_AUDIO_ALLOW_CHANNELS_CHANGE) {
16071 obtained->channels = device->spec.channels;
16072 } else {
16073 build_cvt = SDL_TRUE;
16074 }
16075 }
16076
16077 if (device->spec.samples != obtained->samples) {
16078 obtained->samples = device->spec.samples;
16079 SDL_CalculateAudioSpec(obtained);
16080 }
16081
16082 if (build_cvt) {
16083
16084 if (SDL_BuildAudioCVT(&device->convert,
16085 obtained->format, obtained->channels,
16086 obtained->freq,
16087 device->spec.format, device->spec.channels,
16088 device->spec.freq) < 0) {
16089 close_audio_device(device);
16090 return 0;
16091 }
16092 if (device->convert.needed) {
16093 device->convert.len = (int) (((double) device->spec.size) /
16094 device->convert.len_ratio);
16095
16096 device->convert.buf =
16097 (Uint8 *) SDL_AllocAudioMem(device->convert.len *
16098 device->convert.len_mult);
16099 if (device->convert.buf == NULL) {
16100 close_audio_device(device);
16101 SDL_OutOfMemory();
16102 return 0;
16103 }
16104 }
16105 }
16106
16107 for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
16108 if (open_devices[id] == NULL) {
16109 open_devices[id] = device;
16110 break;
16111 }
16112 }
16113
16114 if (id == SDL_arraysize(open_devices)) {
16115 SDL_SetError("Too many open audio devices");
16116 close_audio_device(device);
16117 return 0;
16118 }
16119
16120 if (!current_audio.impl.ProvidesOwnCallbackThread) {
16121
16122 char name[64];
16123 SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) (id + 1));
16124
16125#if defined(__WIN32__) && !defined(HAVE_LIBC)
16126#undef SDL_CreateThread
16127#if SDL_DYNAMIC_API
16128 device->thread = SDL_CreateThread_REAL(SDL_RunAudio, name, device, NULL, NULL);
16129#else
16130 device->thread = SDL_CreateThread(SDL_RunAudio, name, device, NULL, NULL);
16131#endif
16132#else
16133 device->thread = SDL_CreateThread(SDL_RunAudio, name, device);
16134#endif
16135 if (device->thread == NULL) {
16136 SDL_CloseAudioDevice(id + 1);
16137 SDL_SetError("Couldn't create audio thread");
16138 return 0;
16139 }
16140 }
16141
16142 return id + 1;
16143}
16144
16145int
16146SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
16147{
16148 SDL_AudioDeviceID id = 0;
16149
16150 if (!SDL_WasInit(SDL_INIT_AUDIO)) {
16151 if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
16152 return (-1);
16153 }
16154 }
16155
16156 if (open_devices[0] != NULL) {
16157 SDL_SetError("Audio device is already opened");
16158 return (-1);
16159 }
16160
16161 if (obtained) {
16162 id = open_audio_device(NULL, 0, desired, obtained,
16163 SDL_AUDIO_ALLOW_ANY_CHANGE, 1);
16164 } else {
16165 id = open_audio_device(NULL, 0, desired, desired, 0, 1);
16166 }
16167
16168 SDL_assert((id == 0) || (id == 1));
16169 return ((id == 0) ? -1 : 0);
16170}
16171
16172SDL_AudioDeviceID
16173SDL_OpenAudioDevice(const char *device, int iscapture,
16174 const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
16175 int allowed_changes)
16176{
16177 return open_audio_device(device, iscapture, desired, obtained,
16178 allowed_changes, 2);
16179}
16180
16181SDL_AudioStatus
16182SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
16183{
16184 SDL_AudioDevice *device = get_audio_device(devid);
16185 SDL_AudioStatus status = SDL_AUDIO_STOPPED;
16186 if (device && device->enabled) {
16187 if (device->paused) {
16188 status = SDL_AUDIO_PAUSED;
16189 } else {
16190 status = SDL_AUDIO_PLAYING;
16191 }
16192 }
16193 return (status);
16194}
16195
16196SDL_AudioStatus
16197SDL_GetAudioStatus(void)
16198{
16199 return SDL_GetAudioDeviceStatus(1);
16200}
16201
16202void
16203SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
16204{
16205 SDL_AudioDevice *device = get_audio_device(devid);
16206 if (device) {
16207 current_audio.impl.LockDevice(device);
16208 device->paused = pause_on;
16209 current_audio.impl.UnlockDevice(device);
16210 }
16211}
16212
16213void
16214SDL_PauseAudio(int pause_on)
16215{
16216 SDL_PauseAudioDevice(1, pause_on);
16217}
16218
16219void
16220SDL_LockAudioDevice(SDL_AudioDeviceID devid)
16221{
16222
16223 SDL_AudioDevice *device = get_audio_device(devid);
16224 if (device) {
16225 current_audio.impl.LockDevice(device);
16226 }
16227}
16228
16229void
16230SDL_LockAudio(void)
16231{
16232 SDL_LockAudioDevice(1);
16233}
16234
16235void
16236SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
16237{
16238
16239 SDL_AudioDevice *device = get_audio_device(devid);
16240 if (device) {
16241 current_audio.impl.UnlockDevice(device);
16242 }
16243}
16244
16245void
16246SDL_UnlockAudio(void)
16247{
16248 SDL_UnlockAudioDevice(1);
16249}
16250
16251void
16252SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
16253{
16254 SDL_AudioDevice *device = get_audio_device(devid);
16255 if (device) {
16256 close_audio_device(device);
16257 open_devices[devid - 1] = NULL;
16258 }
16259}
16260
16261void
16262SDL_CloseAudio(void)
16263{
16264 SDL_CloseAudioDevice(1);
16265}
16266
16267void
16268SDL_AudioQuit(void)
16269{
16270 SDL_AudioDeviceID i;
16271
16272 if (!current_audio.name) {
16273 return;
16274 }
16275
16276 for (i = 0; i < SDL_arraysize(open_devices); i++) {
16277 if (open_devices[i] != NULL) {
16278 SDL_CloseAudioDevice(i+1);
16279 }
16280 }
16281
16282 current_audio.impl.Deinitialize();
16283 free_device_list(&current_audio.outputDevices,
16284 &current_audio.outputDeviceCount);
16285 free_device_list(&current_audio.inputDevices,
16286 &current_audio.inputDeviceCount);
16287 SDL_memset(&current_audio, '\0', sizeof(current_audio));
16288 SDL_memset(open_devices, '\0', sizeof(open_devices));
16289}
16290
16291#define NUM_FORMATS 10
16292static int format_idx;
16293static int format_idx_sub;
16294static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
16295 {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
16296 AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
16297 {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
16298 AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
16299 {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB,
16300 AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
16301 {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB,
16302 AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
16303 {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB,
16304 AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
16305 {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB,
16306 AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
16307 {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB,
16308 AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8},
16309 {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S16MSB,
16310 AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
16311 {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S16LSB,
16312 AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8},
16313 {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_S16MSB,
16314 AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
16315};
16316
16317SDL_AudioFormat
16318SDL_FirstAudioFormat(SDL_AudioFormat format)
16319{
16320 for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
16321 if (format_list[format_idx][0] == format) {
16322 break;
16323 }
16324 }
16325 format_idx_sub = 0;
16326 return (SDL_NextAudioFormat());
16327}
16328
16329SDL_AudioFormat
16330SDL_NextAudioFormat(void)
16331{
16332 if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
16333 return (0);
16334 }
16335 return (format_list[format_idx][format_idx_sub++]);
16336}
16337
16338void
16339SDL_CalculateAudioSpec(SDL_AudioSpec * spec)
16340{
16341 switch (spec->format) {
16342 case AUDIO_U8:
16343 spec->silence = 0x80;
16344 break;
16345 default:
16346 spec->silence = 0x00;
16347 break;
16348 }
16349 spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
16350 spec->size *= spec->channels;
16351 spec->size *= spec->samples;
16352}
16353
16354void
16355SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume)
16356{
16357
16358 SDL_AudioDevice *device = get_audio_device(1);
16359 if (device != NULL) {
16360 SDL_AudioFormat format;
16361 if (device->convert.needed) {
16362 format = device->convert.src_format;
16363 } else {
16364 format = device->spec.format;
16365 }
16366 SDL_MixAudioFormat(dst, src, format, len, volume);
16367 }
16368}
16369#if SDL_AUDIO_DRIVER_BSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO
16370
16371#include <fcntl.h>
16372#include <sys/types.h>
16373#include <sys/stat.h>
16374#include <unistd.h>
16375
16376#ifdef USE_BLOCKING_WRITES
16377#define OPEN_FLAGS_OUTPUT O_WRONLY
16378#define OPEN_FLAGS_INPUT O_RDONLY
16379#else
16380#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK)
16381#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
16382#endif
16383
16384void SDL_EnumUnixAudioDevices(int iscapture, int classic,
16385 int (*test) (int fd), SDL_AddAudioDevice addfn);
16386
16387#ifndef _PATH_DEV_DSP
16388#if defined(__NETBSD__) || defined(__OPENBSD__)
16389#define _PATH_DEV_DSP "/dev/audio"
16390#else
16391#define _PATH_DEV_DSP "/dev/dsp"
16392#endif
16393#endif
16394#ifndef _PATH_DEV_DSP24
16395#define _PATH_DEV_DSP24 "/dev/sound/dsp"
16396#endif
16397#ifndef _PATH_DEV_AUDIO
16398#define _PATH_DEV_AUDIO "/dev/audio"
16399#endif
16400
16401static SDL_INLINE void
16402test_device(const char *fname, int flags, int (*test) (int fd),
16403 SDL_AddAudioDevice addfn)
16404{
16405 struct stat sb;
16406 if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
16407 const int audio_fd = open(fname, flags, 0);
16408 if (audio_fd >= 0) {
16409 if (test(audio_fd)) {
16410 addfn(fname);
16411 }
16412 close(audio_fd);
16413 }
16414 }
16415}
16416
16417static int
16418test_stub(int fd)
16419{
16420 return 1;
16421}
16422
16423void
16424SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
16425 SDL_AddAudioDevice addfn)
16426{
16427 const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
16428 const char *audiodev;
16429 char audiopath[1024];
16430
16431 if (test == NULL)
16432 test = test_stub;
16433
16434 if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) &&
16435 ((audiodev = SDL_getenv("AUDIODEV")) == NULL)) {
16436 if (classic) {
16437 audiodev = _PATH_DEV_AUDIO;
16438 } else {
16439 struct stat sb;
16440
16441 if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode))
16442 && ((stat(_PATH_DEV_DSP24, &sb) == 0)
16443 && S_ISCHR(sb.st_mode))) {
16444 audiodev = _PATH_DEV_DSP24;
16445 } else {
16446 audiodev = _PATH_DEV_DSP;
16447 }
16448 }
16449 }
16450 test_device(audiodev, flags, test, addfn);
16451
16452 if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
16453 int instance = 0;
16454 while (instance++ <= 64) {
16455 SDL_snprintf(audiopath, SDL_arraysize(audiopath),
16456 "%s%d", audiodev, instance);
16457 test_device(audiopath, flags, test, addfn);
16458 }
16459 }
16460}
16461
16462#endif
16463#if SDL_AUDIO_DRIVER_WINMM
16464
16465#include <mmsystem.h>
16466
16467#ifndef _SDL_winmm_h
16468#define _SDL_winmm_h
16469
16470#undef _THIS
16471#define _THIS SDL_AudioDevice *this
16472
16473#define NUM_BUFFERS 2
16474
16475#undef SDLAUDIOHIDDEN
16476#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataWINMM*)this->hidden)
16477struct SDL_PrivateAudioDataWINMM
16478{
16479 HWAVEOUT hout;
16480 HWAVEIN hin;
16481 HANDLE audio_sem;
16482 Uint8 *mixbuf;
16483 WAVEHDR wavebuf[NUM_BUFFERS];
16484 int next_buffer;
16485};
16486
16487#endif
16488
16489#ifndef WAVE_FORMAT_IEEE_FLOAT
16490#define WAVE_FORMAT_IEEE_FLOAT 0x0003
16491#endif
16492
16493#define DETECT_DEV_IMPL(typ, capstyp) \
16494static void DetectWave##typ##Devs(SDL_AddAudioDevice addfn) { \
16495 const UINT devcount = wave##typ##GetNumDevs(); \
16496 capstyp caps; \
16497 UINT i; \
16498 for (i = 0; i < devcount; i++) { \
16499 if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
16500 char *name = WIN_StringToUTF8(caps.szPname); \
16501 if (name != NULL) { \
16502 addfn(name); \
16503 SDL_free(name); \
16504 } \
16505 } \
16506 } \
16507}
16508
16509DETECT_DEV_IMPL(Out, WAVEOUTCAPS)
16510DETECT_DEV_IMPL(In, WAVEINCAPS)
16511
16512static void
16513WINMM_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
16514{
16515 if (iscapture) {
16516 DetectWaveInDevs(addfn);
16517 } else {
16518 DetectWaveOutDevs(addfn);
16519 }
16520}
16521
16522static void CALLBACK
16523CaptureSound(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance,
16524 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
16525{
16526 SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance;
16527
16528 if (uMsg != WIM_DATA)
16529 return;
16530
16531 ReleaseSemaphore(SDLAUDIOHIDDEN->audio_sem, 1, NULL);
16532}
16533
16534static void CALLBACK
16535FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
16536 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
16537{
16538 SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance;
16539
16540 if (uMsg != WOM_DONE)
16541 return;
16542
16543 ReleaseSemaphore(SDLAUDIOHIDDEN->audio_sem, 1, NULL);
16544}
16545
16546static int
16547SetMMerror(char *function, MMRESULT code)
16548{
16549 int len;
16550 char errbuf[MAXERRORLENGTH];
16551 wchar_t werrbuf[MAXERRORLENGTH];
16552
16553 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
16554 len = SDL_static_cast(int, SDL_strlen(errbuf));
16555
16556 waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len);
16557 WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
16558 MAXERRORLENGTH - len, NULL, NULL);
16559
16560 return SDL_SetError("%s", errbuf);
16561}
16562
16563static void
16564WINMM_WaitDevice(_THIS)
16565{
16566
16567 WaitForSingleObject(SDLAUDIOHIDDEN->audio_sem, INFINITE);
16568}
16569
16570static Uint8 *
16571WINMM_GetDeviceBuf(_THIS)
16572{
16573 return (Uint8 *) (SDLAUDIOHIDDEN->
16574 wavebuf[SDLAUDIOHIDDEN->next_buffer].lpData);
16575}
16576
16577static void
16578WINMM_PlayDevice(_THIS)
16579{
16580
16581 waveOutWrite(SDLAUDIOHIDDEN->hout,
16582 &SDLAUDIOHIDDEN->wavebuf[SDLAUDIOHIDDEN->next_buffer],
16583 sizeof(SDLAUDIOHIDDEN->wavebuf[0]));
16584 SDLAUDIOHIDDEN->next_buffer = (SDLAUDIOHIDDEN->next_buffer + 1) % NUM_BUFFERS;
16585}
16586
16587static void
16588WINMM_WaitDone(_THIS)
16589{
16590 int i, left;
16591
16592 do {
16593 left = NUM_BUFFERS;
16594 for (i = 0; i < NUM_BUFFERS; ++i) {
16595 if (SDLAUDIOHIDDEN->wavebuf[i].dwFlags & WHDR_DONE) {
16596 --left;
16597 }
16598 }
16599 if (left > 0) {
16600 SDL_Delay(100);
16601 }
16602 } while (left > 0);
16603}
16604
16605static void
16606WINMM_CloseDevice(_THIS)
16607{
16608
16609 if (SDLAUDIOHIDDEN != NULL) {
16610 int i;
16611
16612 if (SDLAUDIOHIDDEN->audio_sem) {
16613 CloseHandle(SDLAUDIOHIDDEN->audio_sem);
16614 SDLAUDIOHIDDEN->audio_sem = 0;
16615 }
16616
16617 for (i = 0; i < NUM_BUFFERS; ++i) {
16618 if (SDLAUDIOHIDDEN->wavebuf[i].dwUser != 0xFFFF) {
16619 waveOutUnprepareHeader(SDLAUDIOHIDDEN->hout,
16620 &SDLAUDIOHIDDEN->wavebuf[i],
16621 sizeof(SDLAUDIOHIDDEN->wavebuf[i]));
16622 SDLAUDIOHIDDEN->wavebuf[i].dwUser = 0xFFFF;
16623 }
16624 }
16625
16626 SDL_free(SDLAUDIOHIDDEN->mixbuf);
16627 SDLAUDIOHIDDEN->mixbuf = NULL;
16628
16629 if (SDLAUDIOHIDDEN->hin) {
16630 waveInClose(SDLAUDIOHIDDEN->hin);
16631 SDLAUDIOHIDDEN->hin = 0;
16632 }
16633
16634 if (SDLAUDIOHIDDEN->hout) {
16635 waveOutClose(SDLAUDIOHIDDEN->hout);
16636 SDLAUDIOHIDDEN->hout = 0;
16637 }
16638
16639 SDL_free(SDLAUDIOHIDDEN);
16640 this->hidden = NULL;
16641 }
16642}
16643
16644static SDL_bool
16645PrepWaveFormat(_THIS, UINT devId, WAVEFORMATEX *pfmt, const int iscapture)
16646{
16647 SDL_zerop(pfmt);
16648
16649 if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
16650 pfmt->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
16651 } else {
16652 pfmt->wFormatTag = WAVE_FORMAT_PCM;
16653 }
16654 pfmt->wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
16655
16656 pfmt->nChannels = this->spec.channels;
16657 pfmt->nSamplesPerSec = this->spec.freq;
16658 pfmt->nBlockAlign = pfmt->nChannels * (pfmt->wBitsPerSample / 8);
16659 pfmt->nAvgBytesPerSec = pfmt->nSamplesPerSec * pfmt->nBlockAlign;
16660
16661 if (iscapture) {
16662 return (waveInOpen(0, devId, pfmt, 0, 0, WAVE_FORMAT_QUERY) == 0);
16663 } else {
16664 return (waveOutOpen(0, devId, pfmt, 0, 0, WAVE_FORMAT_QUERY) == 0);
16665 }
16666}
16667
16668static int
16669WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
16670{
16671 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
16672 int valid_datatype = 0;
16673 MMRESULT result;
16674 WAVEFORMATEX waveformat;
16675 UINT devId = WAVE_MAPPER;
16676 char *utf8 = NULL;
16677 UINT i;
16678
16679 if (devname != NULL) {
16680 if (iscapture) {
16681 const UINT devcount = waveInGetNumDevs();
16682 WAVEINCAPS caps;
16683 for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
16684 result = waveInGetDevCaps(i, &caps, sizeof (caps));
16685 if (result != MMSYSERR_NOERROR)
16686 continue;
16687 else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
16688 continue;
16689 else if (SDL_strcmp(devname, utf8) == 0)
16690 devId = i;
16691 SDL_free(utf8);
16692 }
16693 } else {
16694 const UINT devcount = waveOutGetNumDevs();
16695 WAVEOUTCAPS caps;
16696 for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
16697 result = waveOutGetDevCaps(i, &caps, sizeof (caps));
16698 if (result != MMSYSERR_NOERROR)
16699 continue;
16700 else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
16701 continue;
16702 else if (SDL_strcmp(devname, utf8) == 0)
16703 devId = i;
16704 SDL_free(utf8);
16705 }
16706 }
16707
16708 if (devId == WAVE_MAPPER) {
16709 return SDL_SetError("Requested device not found");
16710 }
16711 }
16712
16713 this->hidden = (struct SDL_PrivateAudioData *)
16714 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
16715 if (SDLAUDIOHIDDEN == NULL) {
16716 return SDL_OutOfMemory();
16717 }
16718 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
16719
16720 for (i = 0; i < NUM_BUFFERS; ++i)
16721 SDLAUDIOHIDDEN->wavebuf[i].dwUser = 0xFFFF;
16722
16723 if (this->spec.channels > 2)
16724 this->spec.channels = 2;
16725
16726 if (this->spec.samples < (this->spec.freq / 4))
16727 this->spec.samples = ((this->spec.freq / 4) + 3) & ~3;
16728
16729 while ((!valid_datatype) && (test_format)) {
16730 switch (test_format) {
16731 case AUDIO_U8:
16732 case AUDIO_S16:
16733 case AUDIO_S32:
16734 case AUDIO_F32:
16735 this->spec.format = test_format;
16736 if (PrepWaveFormat(this, devId, &waveformat, iscapture)) {
16737 valid_datatype = 1;
16738 } else {
16739 test_format = SDL_NextAudioFormat();
16740 }
16741 break;
16742
16743 default:
16744 test_format = SDL_NextAudioFormat();
16745 break;
16746 }
16747 }
16748
16749 if (!valid_datatype) {
16750 WINMM_CloseDevice(this);
16751 return SDL_SetError("Unsupported audio format");
16752 }
16753
16754 SDL_CalculateAudioSpec(&this->spec);
16755
16756 if (iscapture) {
16757 result = waveInOpen(&SDLAUDIOHIDDEN->hin, devId, &waveformat,
16758 (DWORD_PTR) CaptureSound, (DWORD_PTR) this,
16759 CALLBACK_FUNCTION);
16760 } else {
16761 result = waveOutOpen(&SDLAUDIOHIDDEN->hout, devId, &waveformat,
16762 (DWORD_PTR) FillSound, (DWORD_PTR) this,
16763 CALLBACK_FUNCTION);
16764 }
16765
16766 if (result != MMSYSERR_NOERROR) {
16767 WINMM_CloseDevice(this);
16768 return SetMMerror("waveOutOpen()", result);
16769 }
16770#ifdef SOUND_DEBUG
16771
16772 {
16773 WAVEOUTCAPS caps;
16774
16775 result = waveOutGetDevCaps((UINT) SDLAUDIOHIDDEN->hout,
16776 &caps, sizeof(caps));
16777 if (result != MMSYSERR_NOERROR) {
16778 WINMM_CloseDevice(this);
16779 return SetMMerror("waveOutGetDevCaps()", result);
16780 }
16781 printf("Audio device: %s\n", caps.szPname);
16782 }
16783#endif
16784
16785 SDLAUDIOHIDDEN->audio_sem =
16786 CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
16787 if (SDLAUDIOHIDDEN->audio_sem == NULL) {
16788 WINMM_CloseDevice(this);
16789 return SDL_SetError("Couldn't create semaphore");
16790 }
16791
16792 SDLAUDIOHIDDEN->mixbuf =
16793 (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
16794 if (SDLAUDIOHIDDEN->mixbuf == NULL) {
16795 WINMM_CloseDevice(this);
16796 return SDL_OutOfMemory();
16797 }
16798 for (i = 0; i < NUM_BUFFERS; ++i) {
16799 SDL_memset(&SDLAUDIOHIDDEN->wavebuf[i], 0,
16800 sizeof(SDLAUDIOHIDDEN->wavebuf[i]));
16801 SDLAUDIOHIDDEN->wavebuf[i].dwBufferLength = this->spec.size;
16802 SDLAUDIOHIDDEN->wavebuf[i].dwFlags = WHDR_DONE;
16803 SDLAUDIOHIDDEN->wavebuf[i].lpData =
16804 (LPSTR) & SDLAUDIOHIDDEN->mixbuf[i * this->spec.size];
16805 result = waveOutPrepareHeader(SDLAUDIOHIDDEN->hout,
16806 &SDLAUDIOHIDDEN->wavebuf[i],
16807 sizeof(SDLAUDIOHIDDEN->wavebuf[i]));
16808 if (result != MMSYSERR_NOERROR) {
16809 WINMM_CloseDevice(this);
16810 return SetMMerror("waveOutPrepareHeader()", result);
16811 }
16812 }
16813
16814 return 0;
16815}
16816
16817static int
16818WINMM_Init(SDL_AudioDriverImpl * impl)
16819{
16820
16821 impl->DetectDevices = WINMM_DetectDevices;
16822 impl->OpenDevice = WINMM_OpenDevice;
16823 impl->PlayDevice = WINMM_PlayDevice;
16824 impl->WaitDevice = WINMM_WaitDevice;
16825 impl->WaitDone = WINMM_WaitDone;
16826 impl->GetDeviceBuf = WINMM_GetDeviceBuf;
16827 impl->CloseDevice = WINMM_CloseDevice;
16828
16829 return 1;
16830}
16831
16832AudioBootStrap WINMM_bootstrap = {
16833 "winmm", "Windows Waveform Audio", WINMM_Init, 0
16834};
16835
16836#endif
16837#if SDL_AUDIO_DRIVER_XAUDIO2
16838
16839#ifdef __GNUC__
16840
16841# define SDL_XAUDIO2_HAS_SDK 1
16842#elif defined(__WINRT__)
16843
16844# define SDL_XAUDIO2_HAS_SDK
16845#else
16846
16847#include <dxsdkver.h>
16848#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
16849# pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
16850#else
16851# define SDL_XAUDIO2_HAS_SDK 1
16852#endif
16853#endif
16854
16855#ifdef SDL_XAUDIO2_HAS_SDK
16856
16857#ifdef WINVER
16858#if WINVER >= 0x0602
16859#define SDL_XAUDIO2_WIN8 1
16860#endif
16861#endif
16862
16863#ifdef __WINRT__
16864#define uuid(x)
16865#define DX_BUILD
16866#endif
16867
16868#define INITGUID 1
16869#include <xaudio2.h>
16870
16871#undef _THIS
16872#define _THIS SDL_AudioDevice *this
16873
16874#ifdef __WINRT__
16875#include "SDL_xaudio2_winrthelpers.h"
16876#endif
16877
16878#ifdef __GNUC__
16879#ifdef THIS
16880#undef THIS
16881#endif
16882#define THIS INTERFACE *p
16883#ifdef THIS_
16884#undef THIS_
16885#endif
16886#define THIS_ INTERFACE *p,
16887#endif
16888
16889#undef SDLAUDIOHIDDEN
16890#define SDLAUDIOHIDDEN ((struct SDL_PrivateAudioDataXAUDIO2*)this->hidden)
16891struct SDL_PrivateAudioDataXAUDIO2
16892{
16893 IXAudio2 *ixa2;
16894 IXAudio2SourceVoice *source;
16895 IXAudio2MasteringVoice *mastering;
16896 SDL_sem * semaphore;
16897 Uint8 *mixbuf;
16898 int mixlen;
16899 Uint8 *nextbuf;
16900};
16901
16902static void
16903XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
16904{
16905 IXAudio2 *ixa2 = NULL;
16906 UINT32 devcount = 0;
16907 UINT32 i = 0;
16908
16909 if (iscapture) {
16910 SDL_SetError("XAudio2: capture devices unsupported.");
16911 return;
16912 } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
16913 SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
16914 return;
16915 } else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
16916 SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed.");
16917 IXAudio2_Release(ixa2);
16918 return;
16919 }
16920
16921 for (i = 0; i < devcount; i++) {
16922 XAUDIO2_DEVICE_DETAILS details;
16923 if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
16924 char *str = WIN_StringToUTF8(details.DisplayName);
16925 if (str != NULL) {
16926 addfn(str);
16927 SDL_free(str);
16928 }
16929 }
16930 }
16931
16932 IXAudio2_Release(ixa2);
16933}
16934
16935static void STDMETHODCALLTYPE
16936VoiceCBOnBufferEnd(THIS_ void *data)
16937{
16938
16939 SDL_AudioDevice *this = (SDL_AudioDevice *) data;
16940 SDL_SemPost(SDLAUDIOHIDDEN->semaphore);
16941}
16942
16943static void STDMETHODCALLTYPE
16944VoiceCBOnVoiceError(THIS_ void *data, HRESULT Error)
16945{
16946
16947 SDL_assert(0 && "write me!");
16948}
16949
16950static void STDMETHODCALLTYPE VoiceCBOnStreamEnd(THIS) {}
16951static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassStart(THIS_ UINT32 b) {}
16952static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassEnd(THIS) {}
16953static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {}
16954static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {}
16955
16956static Uint8 *
16957XAUDIO2_GetDeviceBuf(_THIS)
16958{
16959 return SDLAUDIOHIDDEN->nextbuf;
16960}
16961
16962static void
16963XAUDIO2_PlayDevice(_THIS)
16964{
16965 XAUDIO2_BUFFER buffer;
16966 Uint8 *mixbuf = SDLAUDIOHIDDEN->mixbuf;
16967 Uint8 *nextbuf = SDLAUDIOHIDDEN->nextbuf;
16968 const int mixlen = SDLAUDIOHIDDEN->mixlen;
16969 IXAudio2SourceVoice *source = SDLAUDIOHIDDEN->source;
16970 HRESULT result = S_OK;
16971
16972 if (!this->enabled) {
16973 return;
16974 }
16975
16976 SDL_zero(buffer);
16977 buffer.AudioBytes = mixlen;
16978 buffer.pAudioData = nextbuf;
16979 buffer.pContext = this;
16980
16981 if (nextbuf == mixbuf) {
16982 nextbuf += mixlen;
16983 } else {
16984 nextbuf = mixbuf;
16985 }
16986 SDLAUDIOHIDDEN->nextbuf = nextbuf;
16987
16988 result = IXAudio2SourceVoice_SubmitSourceBuffer(source, &buffer, NULL);
16989 if (result == XAUDIO2_E_DEVICE_INVALIDATED) {
16990
16991 }
16992
16993 if (result != S_OK) {
16994 IXAudio2SourceVoice_FlushSourceBuffers(source);
16995 this->enabled = 0;
16996 }
16997}
16998
16999static void
17000XAUDIO2_WaitDevice(_THIS)
17001{
17002 if (this->enabled) {
17003 SDL_SemWait(SDLAUDIOHIDDEN->semaphore);
17004 }
17005}
17006
17007static void
17008XAUDIO2_WaitDone(_THIS)
17009{
17010 IXAudio2SourceVoice *source = SDLAUDIOHIDDEN->source;
17011 XAUDIO2_VOICE_STATE state;
17012 SDL_assert(!this->enabled);
17013 IXAudio2SourceVoice_Discontinuity(source);
17014#if SDL_XAUDIO2_WIN8
17015 IXAudio2SourceVoice_GetState(source, &state, 0);
17016#else
17017 IXAudio2SourceVoice_GetState(source, &state);
17018#endif
17019 while (state.BuffersQueued > 0) {
17020 SDL_SemWait(SDLAUDIOHIDDEN->semaphore);
17021#if SDL_XAUDIO2_WIN8
17022 IXAudio2SourceVoice_GetState(source, &state, 0);
17023#else
17024 IXAudio2SourceVoice_GetState(source, &state);
17025#endif
17026 }
17027}
17028
17029static void
17030XAUDIO2_CloseDevice(_THIS)
17031{
17032 if (SDLAUDIOHIDDEN != NULL) {
17033 IXAudio2 *ixa2 = SDLAUDIOHIDDEN->ixa2;
17034 IXAudio2SourceVoice *source = SDLAUDIOHIDDEN->source;
17035 IXAudio2MasteringVoice *mastering = SDLAUDIOHIDDEN->mastering;
17036
17037 if (source != NULL) {
17038 IXAudio2SourceVoice_Stop(source, 0, XAUDIO2_COMMIT_NOW);
17039 IXAudio2SourceVoice_FlushSourceBuffers(source);
17040 IXAudio2SourceVoice_DestroyVoice(source);
17041 }
17042 if (ixa2 != NULL) {
17043 IXAudio2_StopEngine(ixa2);
17044 }
17045 if (mastering != NULL) {
17046 IXAudio2MasteringVoice_DestroyVoice(mastering);
17047 }
17048 if (ixa2 != NULL) {
17049 IXAudio2_Release(ixa2);
17050 }
17051 SDL_free(SDLAUDIOHIDDEN->mixbuf);
17052 if (SDLAUDIOHIDDEN->semaphore != NULL) {
17053 SDL_DestroySemaphore(SDLAUDIOHIDDEN->semaphore);
17054 }
17055
17056 SDL_free(SDLAUDIOHIDDEN);
17057 this->hidden = NULL;
17058 }
17059}
17060
17061static int
17062XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
17063{
17064 HRESULT result = S_OK;
17065 WAVEFORMATEX waveformat;
17066 int valid_format = 0;
17067 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
17068 IXAudio2 *ixa2 = NULL;
17069 IXAudio2SourceVoice *source = NULL;
17070#if defined(SDL_XAUDIO2_WIN8)
17071 LPCWSTR devId = NULL;
17072#else
17073 UINT32 devId = 0;
17074#endif
17075
17076 static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
17077 VoiceCBOnVoiceProcessPassStart,
17078 VoiceCBOnVoiceProcessPassEnd,
17079 VoiceCBOnStreamEnd,
17080 VoiceCBOnBufferStart,
17081 VoiceCBOnBufferEnd,
17082 VoiceCBOnLoopEnd,
17083 VoiceCBOnVoiceError
17084 };
17085
17086 static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
17087
17088 if (iscapture) {
17089 return SDL_SetError("XAudio2: capture devices unsupported.");
17090 } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
17091 return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
17092 }
17093
17094#if ! defined(__WINRT__)
17095 if (devname != NULL) {
17096 UINT32 devcount = 0;
17097 UINT32 i = 0;
17098
17099 if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
17100 IXAudio2_Release(ixa2);
17101 return SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
17102 }
17103 for (i = 0; i < devcount; i++) {
17104 XAUDIO2_DEVICE_DETAILS details;
17105 if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
17106 char *str = WIN_StringToUTF8(details.DisplayName);
17107 if (str != NULL) {
17108 const int match = (SDL_strcmp(str, devname) == 0);
17109 SDL_free(str);
17110 if (match) {
17111 devId = i;
17112 break;
17113 }
17114 }
17115 }
17116 }
17117
17118 if (i == devcount) {
17119 IXAudio2_Release(ixa2);
17120 return SDL_SetError("XAudio2: Requested device not found.");
17121 }
17122 }
17123#endif
17124
17125 this->hidden = (struct SDL_PrivateAudioData *)
17126 SDL_malloc((sizeof *SDLAUDIOHIDDEN));
17127 if (SDLAUDIOHIDDEN == NULL) {
17128 IXAudio2_Release(ixa2);
17129 return SDL_OutOfMemory();
17130 }
17131 SDL_memset(SDLAUDIOHIDDEN, 0, (sizeof *SDLAUDIOHIDDEN));
17132
17133 SDLAUDIOHIDDEN->ixa2 = ixa2;
17134 SDLAUDIOHIDDEN->semaphore = SDL_CreateSemaphore(1);
17135 if (SDLAUDIOHIDDEN->semaphore == NULL) {
17136 XAUDIO2_CloseDevice(this);
17137 return SDL_SetError("XAudio2: CreateSemaphore() failed!");
17138 }
17139
17140 while ((!valid_format) && (test_format)) {
17141 switch (test_format) {
17142 case AUDIO_U8:
17143 case AUDIO_S16:
17144 case AUDIO_S32:
17145 case AUDIO_F32:
17146 this->spec.format = test_format;
17147 valid_format = 1;
17148 break;
17149 }
17150 test_format = SDL_NextAudioFormat();
17151 }
17152
17153 if (!valid_format) {
17154 XAUDIO2_CloseDevice(this);
17155 return SDL_SetError("XAudio2: Unsupported audio format");
17156 }
17157
17158 SDL_CalculateAudioSpec(&this->spec);
17159
17160 SDLAUDIOHIDDEN->mixlen = this->spec.size;
17161 SDLAUDIOHIDDEN->mixbuf = (Uint8 *) SDL_malloc(2 * SDLAUDIOHIDDEN->mixlen);
17162 if (SDLAUDIOHIDDEN->mixbuf == NULL) {
17163 XAUDIO2_CloseDevice(this);
17164 return SDL_OutOfMemory();
17165 }
17166 SDLAUDIOHIDDEN->nextbuf = SDLAUDIOHIDDEN->mixbuf;
17167 SDL_memset(SDLAUDIOHIDDEN->mixbuf, 0, 2 * SDLAUDIOHIDDEN->mixlen);
17168
17169#if SDL_XAUDIO2_WIN8
17170 result = IXAudio2_CreateMasteringVoice(ixa2, &SDLAUDIOHIDDEN->mastering,
17171 XAUDIO2_DEFAULT_CHANNELS,
17172 this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects);
17173#else
17174 result = IXAudio2_CreateMasteringVoice(ixa2, &SDLAUDIOHIDDEN->mastering,
17175 XAUDIO2_DEFAULT_CHANNELS,
17176 this->spec.freq, 0, devId, NULL);
17177#endif
17178 if (result != S_OK) {
17179 XAUDIO2_CloseDevice(this);
17180 return SDL_SetError("XAudio2: Couldn't create mastering voice");
17181 }
17182
17183 SDL_zero(waveformat);
17184 if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
17185 waveformat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
17186 } else {
17187 waveformat.wFormatTag = WAVE_FORMAT_PCM;
17188 }
17189 waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
17190 waveformat.nChannels = this->spec.channels;
17191 waveformat.nSamplesPerSec = this->spec.freq;
17192 waveformat.nBlockAlign =
17193 waveformat.nChannels * (waveformat.wBitsPerSample / 8);
17194 waveformat.nAvgBytesPerSec =
17195 waveformat.nSamplesPerSec * waveformat.nBlockAlign;
17196 waveformat.cbSize = sizeof(waveformat);
17197
17198#ifdef __WINRT__
17199
17200 result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
17201 0,
17202 1.0f, &callbacks, NULL, NULL);
17203#else
17204 result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
17205 XAUDIO2_VOICE_NOSRC |
17206 XAUDIO2_VOICE_NOPITCH,
17207 1.0f, &callbacks, NULL, NULL);
17208
17209#endif
17210 if (result != S_OK) {
17211 XAUDIO2_CloseDevice(this);
17212 return SDL_SetError("XAudio2: Couldn't create source voice");
17213 }
17214 SDLAUDIOHIDDEN->source = source;
17215
17216 result = IXAudio2_StartEngine(ixa2);
17217 if (result != S_OK) {
17218 XAUDIO2_CloseDevice(this);
17219 return SDL_SetError("XAudio2: Couldn't start engine");
17220 }
17221
17222 result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW);
17223 if (result != S_OK) {
17224 XAUDIO2_CloseDevice(this);
17225 return SDL_SetError("XAudio2: Couldn't start source voice");
17226 }
17227
17228 return 0;
17229}
17230
17231static void
17232XAUDIO2_Deinitialize(void)
17233{
17234#if defined(__WIN32__)
17235 WIN_CoUninitialize();
17236#endif
17237}
17238
17239#endif
17240
17241static int
17242XAUDIO2_Init(SDL_AudioDriverImpl * impl)
17243{
17244#ifndef SDL_XAUDIO2_HAS_SDK
17245 SDL_SetError("XAudio2: SDL was built without XAudio2 support (old DirectX SDK).");
17246 return 0;
17247#else
17248
17249 IXAudio2 *ixa2 = NULL;
17250#if defined(__WIN32__)
17251
17252 if (FAILED(WIN_CoInitialize())) {
17253 SDL_SetError("XAudio2: CoInitialize() failed");
17254 return 0;
17255 }
17256#endif
17257
17258 if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
17259#if defined(__WIN32__)
17260 WIN_CoUninitialize();
17261#endif
17262 SDL_SetError("XAudio2: XAudio2Create() failed at initialization");
17263 return 0;
17264 }
17265 IXAudio2_Release(ixa2);
17266
17267 impl->DetectDevices = XAUDIO2_DetectDevices;
17268 impl->OpenDevice = XAUDIO2_OpenDevice;
17269 impl->PlayDevice = XAUDIO2_PlayDevice;
17270 impl->WaitDevice = XAUDIO2_WaitDevice;
17271 impl->WaitDone = XAUDIO2_WaitDone;
17272 impl->GetDeviceBuf = XAUDIO2_GetDeviceBuf;
17273 impl->CloseDevice = XAUDIO2_CloseDevice;
17274 impl->Deinitialize = XAUDIO2_Deinitialize;
17275
17276 return 1;
17277#endif
17278}
17279
17280AudioBootStrap XAUDIO2_bootstrap = {
17281 "xaudio2", "XAudio2", XAUDIO2_Init, 0
17282};
17283
17284#endif
17285#if !SDL_THREAD_PTHREAD
17286
17287struct SDL_cond
17288{
17289 SDL_mutex *lock;
17290 int waiting;
17291 int signals;
17292 SDL_sem *wait_sem;
17293 SDL_sem *wait_done;
17294};
17295
17296SDL_cond *
17297SDL_CreateCond(void)
17298{
17299 SDL_cond *cond;
17300
17301 cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
17302 if (cond) {
17303 cond->lock = SDL_CreateMutex();
17304 cond->wait_sem = SDL_CreateSemaphore(0);
17305 cond->wait_done = SDL_CreateSemaphore(0);
17306 cond->waiting = cond->signals = 0;
17307 if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
17308 SDL_DestroyCond(cond);
17309 cond = NULL;
17310 }
17311 } else {
17312 SDL_OutOfMemory();
17313 }
17314 return (cond);
17315}
17316
17317void
17318SDL_DestroyCond(SDL_cond * cond)
17319{
17320 if (cond) {
17321 if (cond->wait_sem) {
17322 SDL_DestroySemaphore(cond->wait_sem);
17323 }
17324 if (cond->wait_done) {
17325 SDL_DestroySemaphore(cond->wait_done);
17326 }
17327 if (cond->lock) {
17328 SDL_DestroyMutex(cond->lock);
17329 }
17330 SDL_free(cond);
17331 }
17332}
17333
17334int
17335SDL_CondSignal(SDL_cond * cond)
17336{
17337 if (!cond) {
17338 return SDL_SetError("Passed a NULL condition variable");
17339 }
17340
17341 SDL_LockMutex(cond->lock);
17342 if (cond->waiting > cond->signals) {
17343 ++cond->signals;
17344 SDL_SemPost(cond->wait_sem);
17345 SDL_UnlockMutex(cond->lock);
17346 SDL_SemWait(cond->wait_done);
17347 } else {
17348 SDL_UnlockMutex(cond->lock);
17349 }
17350
17351 return 0;
17352}
17353
17354int
17355SDL_CondBroadcast(SDL_cond * cond)
17356{
17357 if (!cond) {
17358 return SDL_SetError("Passed a NULL condition variable");
17359 }
17360
17361 SDL_LockMutex(cond->lock);
17362 if (cond->waiting > cond->signals) {
17363 int i, num_waiting;
17364
17365 num_waiting = (cond->waiting - cond->signals);
17366 cond->signals = cond->waiting;
17367 for (i = 0; i < num_waiting; ++i) {
17368 SDL_SemPost(cond->wait_sem);
17369 }
17370
17371 SDL_UnlockMutex(cond->lock);
17372 for (i = 0; i < num_waiting; ++i) {
17373 SDL_SemWait(cond->wait_done);
17374 }
17375 } else {
17376 SDL_UnlockMutex(cond->lock);
17377 }
17378
17379 return 0;
17380}
17381
17382int
17383SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
17384{
17385 int retval;
17386
17387 if (!cond) {
17388 return SDL_SetError("Passed a NULL condition variable");
17389 }
17390
17391 SDL_LockMutex(cond->lock);
17392 ++cond->waiting;
17393 SDL_UnlockMutex(cond->lock);
17394
17395 SDL_UnlockMutex(mutex);
17396
17397 if (ms == SDL_MUTEX_MAXWAIT) {
17398 retval = SDL_SemWait(cond->wait_sem);
17399 } else {
17400 retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
17401 }
17402
17403 SDL_LockMutex(cond->lock);
17404 if (cond->signals > 0) {
17405
17406 if (retval > 0) {
17407 SDL_SemWait(cond->wait_sem);
17408 }
17409
17410 SDL_SemPost(cond->wait_done);
17411
17412 --cond->signals;
17413 }
17414 --cond->waiting;
17415 SDL_UnlockMutex(cond->lock);
17416
17417 SDL_LockMutex(mutex);
17418
17419 return retval;
17420}
17421
17422int
17423SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
17424{
17425 return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
17426}
17427
17428#endif
17429#if !SDL_THREAD_PTHREAD || defined(__MACOSX__) || defined(__IPHONEOS__)
17430#if !SDL_THREAD_WINDOWS
17431
17432#if SDL_THREADS_DISABLED
17433
17434SDL_sem *
17435SDL_CreateSemaphore(Uint32 initial_value)
17436{
17437 SDL_SetError("SDL not built with thread support");
17438 return (SDL_sem *) 0;
17439}
17440
17441void
17442SDL_DestroySemaphore(SDL_sem * sem)
17443{
17444}
17445
17446int
17447SDL_SemTryWait(SDL_sem * sem)
17448{
17449 return SDL_SetError("SDL not built with thread support");
17450}
17451
17452int
17453SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
17454{
17455 return SDL_SetError("SDL not built with thread support");
17456}
17457
17458int
17459SDL_SemWait(SDL_sem * sem)
17460{
17461 return SDL_SetError("SDL not built with thread support");
17462}
17463
17464Uint32
17465SDL_SemValue(SDL_sem * sem)
17466{
17467 return 0;
17468}
17469
17470int
17471SDL_SemPost(SDL_sem * sem)
17472{
17473 return SDL_SetError("SDL not built with thread support");
17474}
17475
17476#else
17477
17478struct SDL_semaphore
17479{
17480 Uint32 count;
17481 Uint32 waiters_count;
17482 SDL_mutex *count_lock;
17483 SDL_cond *count_nonzero;
17484};
17485
17486SDL_sem *
17487SDL_CreateSemaphore(Uint32 initial_value)
17488{
17489 SDL_sem *sem;
17490
17491 sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
17492 if (!sem) {
17493 SDL_OutOfMemory();
17494 return NULL;
17495 }
17496 sem->count = initial_value;
17497 sem->waiters_count = 0;
17498
17499 sem->count_lock = SDL_CreateMutex();
17500 sem->count_nonzero = SDL_CreateCond();
17501 if (!sem->count_lock || !sem->count_nonzero) {
17502 SDL_DestroySemaphore(sem);
17503 return NULL;
17504 }
17505
17506 return sem;
17507}
17508
17509void
17510SDL_DestroySemaphore(SDL_sem * sem)
17511{
17512 if (sem) {
17513 sem->count = 0xFFFFFFFF;
17514 while (sem->waiters_count > 0) {
17515 SDL_CondSignal(sem->count_nonzero);
17516 SDL_Delay(10);
17517 }
17518 SDL_DestroyCond(sem->count_nonzero);
17519 if (sem->count_lock) {
17520 SDL_LockMutex(sem->count_lock);
17521 SDL_UnlockMutex(sem->count_lock);
17522 SDL_DestroyMutex(sem->count_lock);
17523 }
17524 SDL_free(sem);
17525 }
17526}
17527
17528int
17529SDL_SemTryWait(SDL_sem * sem)
17530{
17531 int retval;
17532
17533 if (!sem) {
17534 return SDL_SetError("Passed a NULL semaphore");
17535 }
17536
17537 retval = SDL_MUTEX_TIMEDOUT;
17538 SDL_LockMutex(sem->count_lock);
17539 if (sem->count > 0) {
17540 --sem->count;
17541 retval = 0;
17542 }
17543 SDL_UnlockMutex(sem->count_lock);
17544
17545 return retval;
17546}
17547
17548int
17549SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
17550{
17551 int retval;
17552
17553 if (!sem) {
17554 return SDL_SetError("Passed a NULL semaphore");
17555 }
17556
17557 if (timeout == 0) {
17558 return SDL_SemTryWait(sem);
17559 }
17560
17561 SDL_LockMutex(sem->count_lock);
17562 ++sem->waiters_count;
17563 retval = 0;
17564 while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) {
17565 retval = SDL_CondWaitTimeout(sem->count_nonzero,
17566 sem->count_lock, timeout);
17567 }
17568 --sem->waiters_count;
17569 if (retval == 0) {
17570 --sem->count;
17571 }
17572 SDL_UnlockMutex(sem->count_lock);
17573
17574 return retval;
17575}
17576
17577int
17578SDL_SemWait(SDL_sem * sem)
17579{
17580 return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
17581}
17582
17583Uint32
17584SDL_SemValue(SDL_sem * sem)
17585{
17586 Uint32 value;
17587
17588 value = 0;
17589 if (sem) {
17590 SDL_LockMutex(sem->count_lock);
17591 value = sem->count;
17592 SDL_UnlockMutex(sem->count_lock);
17593 }
17594 return value;
17595}
17596
17597int
17598SDL_SemPost(SDL_sem * sem)
17599{
17600 if (!sem) {
17601 return SDL_SetError("Passed a NULL semaphore");
17602 }
17603
17604 SDL_LockMutex(sem->count_lock);
17605 if (sem->waiters_count > 0) {
17606 SDL_CondSignal(sem->count_nonzero);
17607 }
17608 ++sem->count;
17609 SDL_UnlockMutex(sem->count_lock);
17610
17611 return 0;
17612}
17613
17614#endif
17615
17616#endif
17617#endif
17618#if SDL_THREAD_PTHREAD
17619
17620#define _GNU_SOURCE
17621#include <pthread.h>
17622#include <errno.h>
17623
17624#if !SDL_THREAD_PTHREAD_RECURSIVE_MUTEX && \
17625 !SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
17626#define FAKE_RECURSIVE_MUTEX 1
17627#endif
17628
17629struct SDL_mutex
17630{
17631 pthread_mutex_t id;
17632#if FAKE_RECURSIVE_MUTEX
17633 int recursive;
17634 pthread_t owner;
17635#endif
17636};
17637
17638SDL_mutex *
17639SDL_CreateMutex(void)
17640{
17641 SDL_mutex *mutex;
17642 pthread_mutexattr_t attr;
17643
17644 mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex));
17645 if (mutex) {
17646 pthread_mutexattr_init(&attr);
17647#if SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
17648 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
17649#elif SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
17650 pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
17651#else
17652
17653#endif
17654 if (pthread_mutex_init(&mutex->id, &attr) != 0) {
17655 SDL_SetError("pthread_mutex_init() failed");
17656 SDL_free(mutex);
17657 mutex = NULL;
17658 }
17659 } else {
17660 SDL_OutOfMemory();
17661 }
17662 return (mutex);
17663}
17664
17665void
17666SDL_DestroyMutex(SDL_mutex * mutex)
17667{
17668 if (mutex) {
17669 pthread_mutex_destroy(&mutex->id);
17670 SDL_free(mutex);
17671 }
17672}
17673
17674int
17675SDL_LockMutex(SDL_mutex * mutex)
17676{
17677#if FAKE_RECURSIVE_MUTEX
17678 pthread_t this_thread;
17679#endif
17680
17681 if (mutex == NULL) {
17682 return SDL_SetError("Passed a NULL mutex");
17683 }
17684
17685#if FAKE_RECURSIVE_MUTEX
17686 this_thread = pthread_self();
17687 if (mutex->owner == this_thread) {
17688 ++mutex->recursive;
17689 } else {
17690
17691 if (pthread_mutex_lock(&mutex->id) == 0) {
17692 mutex->owner = this_thread;
17693 mutex->recursive = 0;
17694 } else {
17695 return SDL_SetError("pthread_mutex_lock() failed");
17696 }
17697 }
17698#else
17699 if (pthread_mutex_lock(&mutex->id) < 0) {
17700 return SDL_SetError("pthread_mutex_lock() failed");
17701 }
17702#endif
17703 return 0;
17704}
17705
17706int
17707SDL_TryLockMutex(SDL_mutex * mutex)
17708{
17709 int retval;
17710#if FAKE_RECURSIVE_MUTEX
17711 pthread_t this_thread;
17712#endif
17713
17714 if (mutex == NULL) {
17715 return SDL_SetError("Passed a NULL mutex");
17716 }
17717
17718 retval = 0;
17719#if FAKE_RECURSIVE_MUTEX
17720 this_thread = pthread_self();
17721 if (mutex->owner == this_thread) {
17722 ++mutex->recursive;
17723 } else {
17724
17725 if (pthread_mutex_lock(&mutex->id) == 0) {
17726 mutex->owner = this_thread;
17727 mutex->recursive = 0;
17728 } else if (errno == EBUSY) {
17729 retval = SDL_MUTEX_TIMEDOUT;
17730 } else {
17731 retval = SDL_SetError("pthread_mutex_trylock() failed");
17732 }
17733 }
17734#else
17735 if (pthread_mutex_trylock(&mutex->id) != 0) {
17736 if (errno == EBUSY) {
17737 retval = SDL_MUTEX_TIMEDOUT;
17738 } else {
17739 retval = SDL_SetError("pthread_mutex_trylock() failed");
17740 }
17741 }
17742#endif
17743 return retval;
17744}
17745
17746int
17747SDL_UnlockMutex(SDL_mutex * mutex)
17748{
17749 if (mutex == NULL) {
17750 return SDL_SetError("Passed a NULL mutex");
17751 }
17752
17753#if FAKE_RECURSIVE_MUTEX
17754
17755 if (pthread_self() == mutex->owner) {
17756 if (mutex->recursive) {
17757 --mutex->recursive;
17758 } else {
17759
17760 mutex->owner = 0;
17761 pthread_mutex_unlock(&mutex->id);
17762 }
17763 } else {
17764 return SDL_SetError("mutex not owned by this thread");
17765 }
17766
17767#else
17768 if (pthread_mutex_unlock(&mutex->id) < 0) {
17769 return SDL_SetError("pthread_mutex_unlock() failed");
17770 }
17771#endif
17772
17773 return 0;
17774}
17775
17776#endif
17777#if SDL_THREAD_PTHREAD
17778
17779#include <sys/time.h>
17780#include <unistd.h>
17781#include <errno.h>
17782#include <pthread.h>
17783
17784#ifndef _SDL_mutex_c_h
17785#define _SDL_mutex_c_h
17786
17787//struct SDL_mutex
17788//{
17789// pthread_mutex_t id;
17790//};
17791
17792#endif
17793
17794struct SDL_cond
17795{
17796 pthread_cond_t cond;
17797};
17798
17799SDL_cond *
17800SDL_CreateCond(void)
17801{
17802 SDL_cond *cond;
17803
17804 cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
17805 if (cond) {
17806 if (pthread_cond_init(&cond->cond, NULL) < 0) {
17807 SDL_SetError("pthread_cond_init() failed");
17808 SDL_free(cond);
17809 cond = NULL;
17810 }
17811 }
17812 return (cond);
17813}
17814
17815void
17816SDL_DestroyCond(SDL_cond * cond)
17817{
17818 if (cond) {
17819 pthread_cond_destroy(&cond->cond);
17820 SDL_free(cond);
17821 }
17822}
17823
17824int
17825SDL_CondSignal(SDL_cond * cond)
17826{
17827 int retval;
17828
17829 if (!cond) {
17830 return SDL_SetError("Passed a NULL condition variable");
17831 }
17832
17833 retval = 0;
17834 if (pthread_cond_signal(&cond->cond) != 0) {
17835 return SDL_SetError("pthread_cond_signal() failed");
17836 }
17837 return retval;
17838}
17839
17840int
17841SDL_CondBroadcast(SDL_cond * cond)
17842{
17843 int retval;
17844
17845 if (!cond) {
17846 return SDL_SetError("Passed a NULL condition variable");
17847 }
17848
17849 retval = 0;
17850 if (pthread_cond_broadcast(&cond->cond) != 0) {
17851 return SDL_SetError("pthread_cond_broadcast() failed");
17852 }
17853 return retval;
17854}
17855
17856int
17857SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
17858{
17859 int retval;
17860 struct timeval delta;
17861 struct timespec abstime;
17862
17863 if (!cond) {
17864 return SDL_SetError("Passed a NULL condition variable");
17865 }
17866
17867 gettimeofday(&delta, NULL);
17868
17869 abstime.tv_sec = delta.tv_sec + (ms / 1000);
17870 abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
17871 if (abstime.tv_nsec > 1000000000) {
17872 abstime.tv_sec += 1;
17873 abstime.tv_nsec -= 1000000000;
17874 }
17875
17876 tryagain:
17877 retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
17878 switch (retval) {
17879 case EINTR:
17880 goto tryagain;
17881 break;
17882 case ETIMEDOUT:
17883 retval = SDL_MUTEX_TIMEDOUT;
17884 break;
17885 case 0:
17886 break;
17887 default:
17888 retval = SDL_SetError("pthread_cond_timedwait() failed");
17889 }
17890 return retval;
17891}
17892
17893int
17894SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
17895{
17896 if (!cond) {
17897 return SDL_SetError("Passed a NULL condition variable");
17898 } else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
17899 return SDL_SetError("pthread_cond_wait() failed");
17900 }
17901 return 0;
17902}
17903
17904#endif
17905#if SDL_THREAD_PTHREAD
17906
17907#include <errno.h>
17908#include <pthread.h>
17909#include <semaphore.h>
17910#include <sys/time.h>
17911
17912#if defined(__MACOSX__) || defined(__IPHONEOS__)
17913#else
17914
17915struct SDL_semaphore
17916{
17917 sem_t sem;
17918};
17919
17920SDL_sem *
17921SDL_CreateSemaphore(Uint32 initial_value)
17922{
17923 SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
17924 if (sem) {
17925 if (sem_init(&sem->sem, 0, initial_value) < 0) {
17926 SDL_SetError("sem_init() failed");
17927 SDL_free(sem);
17928 sem = NULL;
17929 }
17930 } else {
17931 SDL_OutOfMemory();
17932 }
17933 return sem;
17934}
17935
17936void
17937SDL_DestroySemaphore(SDL_sem * sem)
17938{
17939 if (sem) {
17940 sem_destroy(&sem->sem);
17941 SDL_free(sem);
17942 }
17943}
17944
17945int
17946SDL_SemTryWait(SDL_sem * sem)
17947{
17948 int retval;
17949
17950 if (!sem) {
17951 return SDL_SetError("Passed a NULL semaphore");
17952 }
17953 retval = SDL_MUTEX_TIMEDOUT;
17954 if (sem_trywait(&sem->sem) == 0) {
17955 retval = 0;
17956 }
17957 return retval;
17958}
17959
17960int
17961SDL_SemWait(SDL_sem * sem)
17962{
17963 int retval;
17964
17965 if (!sem) {
17966 return SDL_SetError("Passed a NULL semaphore");
17967 }
17968
17969 retval = sem_wait(&sem->sem);
17970 if (retval < 0) {
17971 retval = SDL_SetError("sem_wait() failed");
17972 }
17973 return retval;
17974}
17975
17976int
17977SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
17978{
17979 int retval;
17980#ifdef HAVE_SEM_TIMEDWAIT
17981 struct timeval now;
17982 struct timespec ts_timeout;
17983#else
17984 Uint32 end;
17985#endif
17986
17987 if (!sem) {
17988 return SDL_SetError("Passed a NULL semaphore");
17989 }
17990
17991 if (timeout == 0) {
17992 return SDL_SemTryWait(sem);
17993 }
17994 if (timeout == SDL_MUTEX_MAXWAIT) {
17995 return SDL_SemWait(sem);
17996 }
17997
17998#ifdef HAVE_SEM_TIMEDWAIT
17999
18000 gettimeofday(&now, NULL);
18001
18002 now.tv_usec += (timeout % 1000) * 1000;
18003 now.tv_sec += timeout / 1000;
18004
18005 if ( now.tv_usec >= 1000000 ) {
18006 now.tv_usec -= 1000000;
18007 now.tv_sec ++;
18008 }
18009
18010 ts_timeout.tv_sec = now.tv_sec;
18011 ts_timeout.tv_nsec = now.tv_usec * 1000;
18012
18013 do {
18014 retval = sem_timedwait(&sem->sem, &ts_timeout);
18015 } while (retval < 0 && errno == EINTR);
18016
18017 if (retval < 0) {
18018 if (errno == ETIMEDOUT) {
18019 retval = SDL_MUTEX_TIMEDOUT;
18020 } else {
18021 SDL_SetError(strerror(errno));
18022 }
18023 }
18024#else
18025 end = SDL_GetTicks() + timeout;
18026 while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) {
18027 if ((SDL_GetTicks() - end) >= 0) {
18028 break;
18029 }
18030 SDL_Delay(0);
18031 }
18032#endif
18033
18034 return retval;
18035}
18036
18037Uint32
18038SDL_SemValue(SDL_sem * sem)
18039{
18040 int ret = 0;
18041 if (sem) {
18042 sem_getvalue(&sem->sem, &ret);
18043 if (ret < 0) {
18044 ret = 0;
18045 }
18046 }
18047 return (Uint32) ret;
18048}
18049
18050int
18051SDL_SemPost(SDL_sem * sem)
18052{
18053 int retval;
18054
18055 if (!sem) {
18056 return SDL_SetError("Passed a NULL semaphore");
18057 }
18058
18059 retval = sem_post(&sem->sem);
18060 if (retval < 0) {
18061 SDL_SetError("sem_post() failed");
18062 }
18063 return retval;
18064}
18065
18066#endif
18067
18068#endif
18069#if SDL_THREAD_PTHREAD
18070
18071#include <pthread.h>
18072
18073#if HAVE_PTHREAD_NP_H
18074#include <pthread_np.h>
18075#endif
18076
18077#include <signal.h>
18078
18079#ifdef __LINUX__
18080#include <sys/time.h>
18081#include <sys/resource.h>
18082#include <sys/syscall.h>
18083#include <unistd.h>
18084#endif
18085
18086#if defined(__LINUX__) || defined(__MACOSX__) || defined(__IPHONEOS__)
18087#include <dlfcn.h>
18088#ifndef RTLD_DEFAULT
18089#define RTLD_DEFAULT NULL
18090#endif
18091#endif
18092
18093#ifdef __ANDROID__
18094#include "../../core/android/SDL_android.h"
18095#endif
18096
18097static const int sig_list[] = {
18098 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
18099 SIGVTALRM, SIGPROF, 0
18100};
18101
18102static void *
18103RunThread(void *data)
18104{
18105#ifdef __ANDROID__
18106 Android_JNI_SetupThread();
18107#endif
18108 SDL_RunThread(data);
18109 return NULL;
18110}
18111
18112#if defined(__MACOSX__) || defined(__IPHONEOS__)
18113static SDL_bool checked_setname = SDL_FALSE;
18114static int (*ppthread_setname_np)(const char*) = NULL;
18115#elif defined(__LINUX__)
18116static SDL_bool checked_setname = SDL_FALSE;
18117static int (*ppthread_setname_np)(pthread_t, const char*) = NULL;
18118#endif
18119int
18120SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
18121{
18122 pthread_attr_t type;
18123
18124 #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
18125 if (!checked_setname) {
18126 void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np");
18127 #if defined(__MACOSX__) || defined(__IPHONEOS__)
18128 ppthread_setname_np = (int(*)(const char*)) fn;
18129 #elif defined(__LINUX__)
18130 ppthread_setname_np = (int(*)(pthread_t, const char*)) fn;
18131 #endif
18132 checked_setname = SDL_TRUE;
18133 }
18134 #endif
18135
18136 if (pthread_attr_init(&type) != 0) {
18137 return SDL_SetError("Couldn't initialize pthread attributes");
18138 }
18139 pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
18140
18141 if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
18142 return SDL_SetError("Not enough resources to create thread");
18143 }
18144
18145 return 0;
18146}
18147
18148void
18149SDL_SYS_SetupThread(const char *name)
18150{
18151 int i;
18152 sigset_t mask;
18153
18154 if (name != NULL) {
18155 #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
18156 SDL_assert(checked_setname);
18157 if (ppthread_setname_np != NULL) {
18158 #if defined(__MACOSX__) || defined(__IPHONEOS__)
18159 ppthread_setname_np(name);
18160 #elif defined(__LINUX__)
18161 ppthread_setname_np(pthread_self(), name);
18162 #endif
18163 }
18164 #elif HAVE_PTHREAD_SETNAME_NP
18165 pthread_setname_np(pthread_self(), name);
18166 #elif HAVE_PTHREAD_SET_NAME_NP
18167 pthread_set_name_np(pthread_self(), name);
18168 #endif
18169 }
18170
18171 sigemptyset(&mask);
18172 for (i = 0; sig_list[i]; ++i) {
18173 sigaddset(&mask, sig_list[i]);
18174 }
18175 pthread_sigmask(SIG_BLOCK, &mask, 0);
18176
18177#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
18178
18179 {
18180 int oldstate;
18181 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
18182 }
18183#endif
18184}
18185
18186SDL_threadID
18187SDL_ThreadID(void)
18188{
18189 return ((SDL_threadID) pthread_self());
18190}
18191
18192int
18193SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
18194{
18195#ifdef __LINUX__
18196 int value;
18197
18198 if (priority == SDL_THREAD_PRIORITY_LOW) {
18199 value = 19;
18200 } else if (priority == SDL_THREAD_PRIORITY_HIGH) {
18201 value = -20;
18202 } else {
18203 value = 0;
18204 }
18205 if (setpriority(PRIO_PROCESS, syscall(SYS_gettid), value) < 0) {
18206
18207 return SDL_SetError("setpriority() failed");
18208 }
18209 return 0;
18210#else
18211 struct sched_param sched;
18212 int policy;
18213 pthread_t thread = pthread_self();
18214
18215 if (pthread_getschedparam(thread, &policy, &sched) < 0) {
18216 return SDL_SetError("pthread_getschedparam() failed");
18217 }
18218 if (priority == SDL_THREAD_PRIORITY_LOW) {
18219 sched.sched_priority = sched_get_priority_min(policy);
18220 } else if (priority == SDL_THREAD_PRIORITY_HIGH) {
18221 sched.sched_priority = sched_get_priority_max(policy);
18222 } else {
18223 int min_priority = sched_get_priority_min(policy);
18224 int max_priority = sched_get_priority_max(policy);
18225 sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
18226 }
18227 if (pthread_setschedparam(thread, policy, &sched) < 0) {
18228 return SDL_SetError("pthread_setschedparam() failed");
18229 }
18230 return 0;
18231#endif
18232}
18233
18234void
18235SDL_SYS_WaitThread(SDL_Thread * thread)
18236{
18237 pthread_join(thread->handle, 0);
18238}
18239
18240#endif
18241#define ARRAY_CHUNKSIZE 32
18242
18243static int SDL_maxthreads = 0;
18244static int SDL_numthreads = 0;
18245static SDL_Thread **SDL_Threads = NULL;
18246static SDL_mutex *thread_lock = NULL;
18247
18248static int
18249SDL_ThreadsInit(void)
18250{
18251 int retval;
18252
18253 retval = 0;
18254 thread_lock = SDL_CreateMutex();
18255 if (thread_lock == NULL) {
18256 retval = -1;
18257 }
18258 return (retval);
18259}
18260
18261#if 0
18262static void
18263SDL_ThreadsQuit(void)
18264{
18265 SDL_mutex *mutex;
18266
18267 mutex = thread_lock;
18268 thread_lock = NULL;
18269 if (mutex != NULL) {
18270 SDL_DestroyMutex(mutex);
18271 }
18272}
18273#endif
18274
18275static void
18276SDL_AddThread(SDL_Thread * thread)
18277{
18278
18279 if (!thread_lock) {
18280 if (SDL_ThreadsInit() < 0) {
18281 return;
18282 }
18283 }
18284 SDL_LockMutex(thread_lock);
18285
18286#ifdef DEBUG_THREADS
18287 printf("Adding thread (%d already - %d max)\n",
18288 SDL_numthreads, SDL_maxthreads);
18289#endif
18290 if (SDL_numthreads == SDL_maxthreads) {
18291 SDL_Thread **threads;
18292 threads = (SDL_Thread **) SDL_realloc(SDL_Threads,
18293 (SDL_maxthreads +
18294 ARRAY_CHUNKSIZE) *
18295 (sizeof *threads));
18296 if (threads == NULL) {
18297 SDL_OutOfMemory();
18298 goto done;
18299 }
18300 SDL_maxthreads += ARRAY_CHUNKSIZE;
18301 SDL_Threads = threads;
18302 }
18303 SDL_Threads[SDL_numthreads++] = thread;
18304 done:
18305 SDL_mutexV(thread_lock);
18306}
18307
18308static void
18309SDL_DelThread(SDL_Thread * thread)
18310{
18311 int i;
18312
18313 if (!thread_lock) {
18314 return;
18315 }
18316 SDL_LockMutex(thread_lock);
18317 for (i = 0; i < SDL_numthreads; ++i) {
18318 if (thread == SDL_Threads[i]) {
18319 break;
18320 }
18321 }
18322 if (i < SDL_numthreads) {
18323 if (--SDL_numthreads > 0) {
18324 while (i < SDL_numthreads) {
18325 SDL_Threads[i] = SDL_Threads[i + 1];
18326 ++i;
18327 }
18328 } else {
18329 SDL_maxthreads = 0;
18330 SDL_free(SDL_Threads);
18331 SDL_Threads = NULL;
18332 }
18333#ifdef DEBUG_THREADS
18334 printf("Deleting thread (%d left - %d max)\n",
18335 SDL_numthreads, SDL_maxthreads);
18336#endif
18337 }
18338 SDL_mutexV(thread_lock);
18339
18340#if 0
18341 if (SDL_Threads == NULL) {
18342 SDL_ThreadsQuit();
18343 }
18344#endif
18345}
18346
18347static SDL_error SDL_global_error;
18348
18349SDL_error *
18350SDL_GetErrBuf(void)
18351{
18352 SDL_error *errbuf;
18353
18354 errbuf = &SDL_global_error;
18355 if (SDL_Threads) {
18356 int i;
18357 SDL_threadID this_thread;
18358
18359 this_thread = SDL_ThreadID();
18360 SDL_LockMutex(thread_lock);
18361 for (i = 0; i < SDL_numthreads; ++i) {
18362 if (this_thread == SDL_Threads[i]->threadid) {
18363 errbuf = &SDL_Threads[i]->errbuf;
18364 break;
18365 }
18366 }
18367 SDL_mutexV(thread_lock);
18368 }
18369 return (errbuf);
18370}
18371
18372typedef struct
18373{
18374 int (SDLCALL * func) (void *);
18375 void *data;
18376 SDL_Thread *info;
18377 SDL_sem *wait;
18378} thread_args;
18379
18380void
18381SDL_RunThread(void *data)
18382{
18383 thread_args *args = (thread_args *) data;
18384 int (SDLCALL * userfunc) (void *) = args->func;
18385 void *userdata = args->data;
18386 int *statusloc = &args->info->status;
18387
18388 SDL_SYS_SetupThread(args->info->name);
18389
18390 args->info->threadid = SDL_ThreadID();
18391
18392 SDL_SemPost(args->wait);
18393
18394 *statusloc = userfunc(userdata);
18395}
18396
18397#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
18398#undef SDL_CreateThread
18399DECLSPEC SDL_Thread *SDLCALL
18400SDL_CreateThread(int (SDLCALL * fn) (void *),
18401 const char *name, void *data,
18402 pfnSDL_CurrentBeginThread pfnBeginThread,
18403 pfnSDL_CurrentEndThread pfnEndThread)
18404#else
18405DECLSPEC SDL_Thread *SDLCALL
18406SDL_CreateThread(int (SDLCALL * fn) (void *),
18407 const char *name, void *data)
18408#endif
18409{
18410 SDL_Thread *thread;
18411 thread_args *args;
18412 int ret;
18413
18414 thread = (SDL_Thread *) SDL_malloc(sizeof(*thread));
18415 if (thread == NULL) {
18416 SDL_OutOfMemory();
18417 return (NULL);
18418 }
18419 SDL_memset(thread, 0, (sizeof *thread));
18420 thread->status = -1;
18421
18422 if (name != NULL) {
18423 thread->name = SDL_strdup(name);
18424 if (thread->name == NULL) {
18425 SDL_OutOfMemory();
18426 SDL_free(thread);
18427 return (NULL);
18428 }
18429 }
18430
18431 args = (thread_args *) SDL_malloc(sizeof(*args));
18432 if (args == NULL) {
18433 SDL_OutOfMemory();
18434 SDL_free(thread->name);
18435 SDL_free(thread);
18436 return (NULL);
18437 }
18438 args->func = fn;
18439 args->data = data;
18440 args->info = thread;
18441 args->wait = SDL_CreateSemaphore(0);
18442 if (args->wait == NULL) {
18443 SDL_free(thread->name);
18444 SDL_free(thread);
18445 SDL_free(args);
18446 return (NULL);
18447 }
18448
18449 SDL_AddThread(thread);
18450
18451#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
18452 ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
18453#else
18454 ret = SDL_SYS_CreateThread(thread, args);
18455#endif
18456 if (ret >= 0) {
18457
18458 SDL_SemWait(args->wait);
18459 } else {
18460
18461 SDL_DelThread(thread);
18462 SDL_free(thread->name);
18463 SDL_free(thread);
18464 thread = NULL;
18465 }
18466 SDL_DestroySemaphore(args->wait);
18467 SDL_free(args);
18468
18469 return (thread);
18470}
18471
18472SDL_threadID
18473SDL_GetThreadID(SDL_Thread * thread)
18474{
18475 SDL_threadID id;
18476
18477 if (thread) {
18478 id = thread->threadid;
18479 } else {
18480 id = SDL_ThreadID();
18481 }
18482 return id;
18483}
18484
18485const char *
18486SDL_GetThreadName(SDL_Thread * thread)
18487{
18488 return thread->name;
18489}
18490
18491int
18492SDL_SetThreadPriority(SDL_ThreadPriority priority)
18493{
18494 return SDL_SYS_SetThreadPriority(priority);
18495}
18496
18497void
18498SDL_WaitThread(SDL_Thread * thread, int *status)
18499{
18500 if (thread) {
18501 SDL_SYS_WaitThread(thread);
18502 if (status) {
18503 *status = thread->status;
18504 }
18505 SDL_DelThread(thread);
18506 SDL_free(thread->name);
18507 SDL_free(thread);
18508 }
18509}
18510#if SDL_THREAD_WINDOWS
18511
18512struct SDL_mutex
18513{
18514 CRITICAL_SECTION cs;
18515};
18516
18517SDL_mutex *
18518SDL_CreateMutex(void)
18519{
18520 SDL_mutex *mutex;
18521
18522 mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex));
18523 if (mutex) {
18524
18525 InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000);
18526 } else {
18527 SDL_OutOfMemory();
18528 }
18529 return (mutex);
18530}
18531
18532void
18533SDL_DestroyMutex(SDL_mutex * mutex)
18534{
18535 if (mutex) {
18536 DeleteCriticalSection(&mutex->cs);
18537 SDL_free(mutex);
18538 }
18539}
18540
18541int
18542SDL_LockMutex(SDL_mutex * mutex)
18543{
18544 if (mutex == NULL) {
18545 return SDL_SetError("Passed a NULL mutex");
18546 }
18547
18548 EnterCriticalSection(&mutex->cs);
18549 return (0);
18550}
18551
18552int
18553SDL_TryLockMutex(SDL_mutex * mutex)
18554{
18555 int retval = 0;
18556 if (mutex == NULL) {
18557 return SDL_SetError("Passed a NULL mutex");
18558 }
18559
18560 if (TryEnterCriticalSection(&mutex->cs) == 0) {
18561 retval = SDL_MUTEX_TIMEDOUT;
18562 }
18563 return retval;
18564}
18565
18566int
18567SDL_UnlockMutex(SDL_mutex * mutex)
18568{
18569 if (mutex == NULL) {
18570 return SDL_SetError("Passed a NULL mutex");
18571 }
18572
18573 LeaveCriticalSection(&mutex->cs);
18574 return (0);
18575}
18576
18577#endif
18578#if SDL_THREAD_WINDOWS
18579
18580struct SDL_semaphore
18581{
18582 HANDLE id;
18583 LONG count;
18584};
18585
18586SDL_sem *
18587SDL_CreateSemaphore(Uint32 initial_value)
18588{
18589 SDL_sem *sem;
18590
18591 sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
18592 if (sem) {
18593
18594 sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL);
18595 sem->count = initial_value;
18596 if (!sem->id) {
18597 SDL_SetError("Couldn't create semaphore");
18598 SDL_free(sem);
18599 sem = NULL;
18600 }
18601 } else {
18602 SDL_OutOfMemory();
18603 }
18604 return (sem);
18605}
18606
18607void
18608SDL_DestroySemaphore(SDL_sem * sem)
18609{
18610 if (sem) {
18611 if (sem->id) {
18612 CloseHandle(sem->id);
18613 sem->id = 0;
18614 }
18615 SDL_free(sem);
18616 }
18617}
18618
18619int
18620SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
18621{
18622 int retval;
18623 DWORD dwMilliseconds;
18624
18625 if (!sem) {
18626 return SDL_SetError("Passed a NULL sem");
18627 }
18628
18629 if (timeout == SDL_MUTEX_MAXWAIT) {
18630 dwMilliseconds = INFINITE;
18631 } else {
18632 dwMilliseconds = (DWORD) timeout;
18633 }
18634 switch (WaitForSingleObject(sem->id, dwMilliseconds)) {
18635 case WAIT_OBJECT_0:
18636 InterlockedDecrement(&sem->count);
18637 retval = 0;
18638 break;
18639 case WAIT_TIMEOUT:
18640 retval = SDL_MUTEX_TIMEDOUT;
18641 break;
18642 default:
18643 retval = SDL_SetError("WaitForSingleObject() failed");
18644 break;
18645 }
18646 return retval;
18647}
18648
18649int
18650SDL_SemTryWait(SDL_sem * sem)
18651{
18652 return SDL_SemWaitTimeout(sem, 0);
18653}
18654
18655int
18656SDL_SemWait(SDL_sem * sem)
18657{
18658 return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
18659}
18660
18661Uint32
18662SDL_SemValue(SDL_sem * sem)
18663{
18664 if (!sem) {
18665 SDL_SetError("Passed a NULL sem");
18666 return 0;
18667 }
18668 return (Uint32)sem->count;
18669}
18670
18671int
18672SDL_SemPost(SDL_sem * sem)
18673{
18674 if (!sem) {
18675 return SDL_SetError("Passed a NULL sem");
18676 }
18677
18678 InterlockedIncrement(&sem->count);
18679 if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) {
18680 InterlockedDecrement(&sem->count);
18681 return SDL_SetError("ReleaseSemaphore() failed");
18682 }
18683 return 0;
18684}
18685
18686#endif
18687#if SDL_THREAD_WINDOWS
18688
18689#ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD
18690
18691#include <process.h>
18692
18693#if (defined(__MINGW32__) && (__GNUC__ < 4))
18694typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
18695 unsigned (__stdcall *func)(void *), void *arg,
18696 unsigned, unsigned *threadID);
18697typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
18698
18699#elif defined(__WATCOMC__)
18700
18701#if __WATCOMC__ < 1240
18702#define __watcall
18703#endif
18704typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *,
18705 unsigned,
18706 unsigned
18707 (__stdcall *
18708 func) (void
18709 *),
18710 void *arg,
18711 unsigned,
18712 unsigned
18713 *threadID);
18714typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code);
18715
18716#else
18717typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
18718 unsigned (__stdcall *
18719 func) (void
18720 *),
18721 void *arg, unsigned,
18722 unsigned *threadID);
18723typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
18724#endif
18725#endif
18726
18727typedef struct ThreadStartParms
18728{
18729 void *args;
18730 pfnSDL_CurrentEndThread pfnCurrentEndThread;
18731} tThreadStartParms, *pThreadStartParms;
18732
18733static DWORD
18734RunThread(void *data)
18735{
18736 pThreadStartParms pThreadParms = (pThreadStartParms) data;
18737 pfnSDL_CurrentEndThread pfnEndThread = pThreadParms->pfnCurrentEndThread;
18738 void *args = pThreadParms->args;
18739 SDL_free(pThreadParms);
18740 SDL_RunThread(args);
18741 if (pfnEndThread != NULL)
18742 pfnEndThread(0);
18743 return (0);
18744}
18745
18746static DWORD WINAPI
18747RunThreadViaCreateThread(LPVOID data)
18748{
18749 return RunThread(data);
18750}
18751
18752static unsigned __stdcall
18753RunThreadViaBeginThreadEx(void *data)
18754{
18755 return (unsigned) RunThread(data);
18756}
18757
18758#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
18759int
18760SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
18761 pfnSDL_CurrentBeginThread pfnBeginThread,
18762 pfnSDL_CurrentEndThread pfnEndThread)
18763{
18764#else
18765int
18766SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
18767{
18768 pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex;
18769 pfnSDL_CurrentEndThread pfnEndThread = _endthreadex;
18770#endif
18771 pThreadStartParms pThreadParms =
18772 (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
18773 if (!pThreadParms) {
18774 return SDL_OutOfMemory();
18775 }
18776
18777 pThreadParms->pfnCurrentEndThread = pfnEndThread;
18778
18779 pThreadParms->args = args;
18780
18781 if (pfnBeginThread) {
18782 unsigned threadid = 0;
18783 thread->handle = (SYS_ThreadHandle)
18784 ((size_t) pfnBeginThread(NULL, 0, RunThreadViaBeginThreadEx,
18785 pThreadParms, 0, &threadid));
18786 } else {
18787 DWORD threadid = 0;
18788 thread->handle = CreateThread(NULL, 0, RunThreadViaCreateThread,
18789 pThreadParms, 0, &threadid);
18790 }
18791 if (thread->handle == NULL) {
18792 return SDL_SetError("Not enough resources to create thread");
18793 }
18794 return 0;
18795}
18796
18797#ifdef _MSC_VER
18798#pragma pack(push,8)
18799typedef struct tagTHREADNAME_INFO
18800{
18801 DWORD dwType;
18802 LPCSTR szName;
18803 DWORD dwThreadID;
18804 DWORD dwFlags;
18805} THREADNAME_INFO;
18806#pragma pack(pop)
18807#endif
18808
18809void
18810SDL_SYS_SetupThread(const char *name)
18811{
18812 if (name != NULL) {
18813 #if 0
18814 #ifdef _MSC_VER
18815
18816 THREADNAME_INFO inf;
18817 inf.dwType = 0x1000;
18818 inf.szName = name;
18819 inf.dwThreadID = (DWORD) -1;
18820 inf.dwFlags = 0;
18821
18822 __try
18823 {
18824 RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf);
18825 }
18826 __except(EXCEPTION_CONTINUE_EXECUTION)
18827 {
18828
18829 }
18830 #endif
18831 #endif
18832 }
18833}
18834
18835SDL_threadID
18836SDL_ThreadID(void)
18837{
18838 return ((SDL_threadID) GetCurrentThreadId());
18839}
18840
18841int
18842SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
18843{
18844 int value;
18845
18846 if (priority == SDL_THREAD_PRIORITY_LOW) {
18847 value = THREAD_PRIORITY_LOWEST;
18848 } else if (priority == SDL_THREAD_PRIORITY_HIGH) {
18849 value = THREAD_PRIORITY_HIGHEST;
18850 } else {
18851 value = THREAD_PRIORITY_NORMAL;
18852 }
18853 if (!SetThreadPriority(GetCurrentThread(), value)) {
18854 return WIN_SetError("SetThreadPriority()");
18855 }
18856 return 0;
18857}
18858
18859void
18860SDL_SYS_WaitThread(SDL_Thread * thread)
18861{
18862 WaitForSingleObject(thread->handle, INFINITE);
18863 CloseHandle(thread->handle);
18864}
18865
18866#endif
18867#ifdef SDL_TIMER_UNIX
18868
18869#include <stdio.h>
18870#include <sys/time.h>
18871#include <unistd.h>
18872#include <errno.h>
18873
18874#if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME
18875#include <time.h>
18876#endif
18877#ifdef __APPLE__
18878#include <mach/mach_time.h>
18879#endif
18880
18881#if HAVE_CLOCK_GETTIME
18882static struct timespec start_ts;
18883#elif defined(__APPLE__)
18884static uint64_t start_mach;
18885mach_timebase_info_data_t mach_base_info;
18886#endif
18887static SDL_bool has_monotonic_time = SDL_FALSE;
18888static struct timeval start_tv;
18889static SDL_bool ticks_started = SDL_FALSE;
18890
18891void
18892SDL_TicksInit(void)
18893{
18894 if (ticks_started) {
18895 return;
18896 }
18897 ticks_started = SDL_TRUE;
18898
18899#if HAVE_CLOCK_GETTIME
18900 if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) {
18901 has_monotonic_time = SDL_TRUE;
18902 } else
18903#elif defined(__APPLE__)
18904 kern_return_t ret = mach_timebase_info(&mach_base_info);
18905 if (ret == 0) {
18906 has_monotonic_time = SDL_TRUE;
18907 start_mach = mach_absolute_time();
18908 } else
18909#endif
18910 {
18911 gettimeofday(&start_tv, NULL);
18912 }
18913}
18914
18915void
18916SDL_TicksQuit(void)
18917{
18918 ticks_started = SDL_FALSE;
18919}
18920
18921Uint32
18922SDL_GetTicks(void)
18923{
18924 Uint32 ticks;
18925 if (!ticks_started) {
18926 SDL_TicksInit();
18927 }
18928
18929 if (has_monotonic_time) {
18930#if HAVE_CLOCK_GETTIME
18931 struct timespec now;
18932 clock_gettime(CLOCK_MONOTONIC, &now);
18933 ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
18934 start_ts.tv_nsec) / 1000000;
18935#elif defined(__APPLE__)
18936 uint64_t now = mach_absolute_time();
18937 ticks = (((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000;
18938#endif
18939 } else {
18940 struct timeval now;
18941
18942 gettimeofday(&now, NULL);
18943 ticks =
18944 (now.tv_sec - start_tv.tv_sec) * 1000 + (now.tv_usec -
18945 start_tv.tv_usec) / 1000;
18946 }
18947 return (ticks);
18948}
18949
18950Uint64
18951SDL_GetPerformanceCounter(void)
18952{
18953 Uint64 ticks;
18954 if (!ticks_started) {
18955 SDL_TicksInit();
18956 }
18957
18958 if (has_monotonic_time) {
18959#if HAVE_CLOCK_GETTIME
18960 struct timespec now;
18961
18962 clock_gettime(CLOCK_MONOTONIC, &now);
18963 ticks = now.tv_sec;
18964 ticks *= 1000000000;
18965 ticks += now.tv_nsec;
18966#elif defined(__APPLE__)
18967 ticks = mach_absolute_time();
18968#endif
18969 } else {
18970 struct timeval now;
18971
18972 gettimeofday(&now, NULL);
18973 ticks = now.tv_sec;
18974 ticks *= 1000000;
18975 ticks += now.tv_usec;
18976 }
18977 return (ticks);
18978}
18979
18980Uint64
18981SDL_GetPerformanceFrequency(void)
18982{
18983 if (!ticks_started) {
18984 SDL_TicksInit();
18985 }
18986
18987 if (has_monotonic_time) {
18988#if HAVE_CLOCK_GETTIME
18989 return 1000000000;
18990#elif defined(__APPLE__)
18991 Uint64 freq = mach_base_info.denom;
18992 freq *= 1000000000;
18993 freq /= mach_base_info.numer;
18994 return freq;
18995#endif
18996 }
18997
18998 return 1000000;
18999}
19000
19001void
19002SDL_Delay(Uint32 ms)
19003{
19004 int was_error;
19005
19006#if HAVE_NANOSLEEP
19007 struct timespec elapsed, tv;
19008#else
19009 struct timeval tv;
19010 Uint32 then, now, elapsed;
19011#endif
19012
19013#if HAVE_NANOSLEEP
19014 elapsed.tv_sec = ms / 1000;
19015 elapsed.tv_nsec = (ms % 1000) * 1000000;
19016#else
19017 then = SDL_GetTicks();
19018#endif
19019 do {
19020 errno = 0;
19021
19022#if HAVE_NANOSLEEP
19023 tv.tv_sec = elapsed.tv_sec;
19024 tv.tv_nsec = elapsed.tv_nsec;
19025 was_error = nanosleep(&tv, &elapsed);
19026#else
19027
19028 now = SDL_GetTicks();
19029 elapsed = (now - then);
19030 then = now;
19031 if (elapsed >= ms) {
19032 break;
19033 }
19034 ms -= elapsed;
19035 tv.tv_sec = ms / 1000;
19036 tv.tv_usec = (ms % 1000) * 1000;
19037
19038 was_error = select(0, NULL, NULL, NULL, &tv);
19039#endif
19040 } while (was_error && (errno == EINTR));
19041}
19042
19043#endif
19044#ifdef SDL_TIMER_WINDOWS
19045
19046#include <mmsystem.h>
19047
19048static DWORD start;
19049static BOOL ticks_started = FALSE;
19050
19051#ifndef USE_GETTICKCOUNT
19052
19053static BOOL hires_timer_available;
19054
19055static LARGE_INTEGER hires_start_ticks;
19056
19057static LARGE_INTEGER hires_ticks_per_second;
19058
19059#ifndef __WINRT__
19060static void
19061timeSetPeriod(UINT uPeriod)
19062{
19063 static UINT timer_period = 0;
19064
19065 if (uPeriod != timer_period) {
19066 if (timer_period) {
19067 timeEndPeriod(timer_period);
19068 }
19069
19070 timer_period = uPeriod;
19071
19072 if (timer_period) {
19073 timeBeginPeriod(timer_period);
19074 }
19075 }
19076}
19077
19078static void
19079SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
19080{
19081 UINT uPeriod;
19082
19083 if (hint && *hint) {
19084 uPeriod = SDL_atoi(hint);
19085 } else {
19086 uPeriod = 1;
19087 }
19088 if (uPeriod || oldValue != hint) {
19089 timeSetPeriod(uPeriod);
19090 }
19091}
19092#endif
19093
19094#endif
19095
19096void
19097SDL_TicksInit(void)
19098{
19099 if (ticks_started) {
19100 return;
19101 }
19102 ticks_started = SDL_TRUE;
19103
19104#ifdef USE_GETTICKCOUNT
19105 start = GetTickCount();
19106#else
19107
19108 if (QueryPerformanceFrequency(&hires_ticks_per_second) == TRUE) {
19109 hires_timer_available = TRUE;
19110 QueryPerformanceCounter(&hires_start_ticks);
19111 } else {
19112 hires_timer_available = FALSE;
19113#ifdef __WINRT__
19114 start = 0;
19115#else
19116 timeSetPeriod(1);
19117 start = timeGetTime();
19118
19119 SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION,
19120 SDL_TimerResolutionChanged, NULL);
19121#endif
19122 }
19123#endif
19124}
19125
19126void
19127SDL_TicksQuit(void)
19128{
19129#ifndef USE_GETTICKCOUNT
19130 if (!hires_timer_available) {
19131#ifndef __WINRT__
19132 SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION,
19133 SDL_TimerResolutionChanged, NULL);
19134
19135 timeSetPeriod(0);
19136#endif
19137 }
19138#endif
19139
19140 ticks_started = SDL_FALSE;
19141}
19142
19143Uint32
19144SDL_GetTicks(void)
19145{
19146 DWORD now;
19147#ifndef USE_GETTICKCOUNT
19148 LARGE_INTEGER hires_now;
19149#endif
19150
19151 if (!ticks_started) {
19152 SDL_TicksInit();
19153 }
19154
19155#ifdef USE_GETTICKCOUNT
19156 now = GetTickCount();
19157#else
19158 if (hires_timer_available) {
19159 QueryPerformanceCounter(&hires_now);
19160
19161 hires_now.QuadPart -= hires_start_ticks.QuadPart;
19162 hires_now.QuadPart *= 1000;
19163 hires_now.QuadPart /= hires_ticks_per_second.QuadPart;
19164
19165 return (DWORD) hires_now.QuadPart;
19166 } else {
19167#ifdef __WINRT__
19168 now = 0;
19169#else
19170 now = timeGetTime();
19171#endif
19172 }
19173#endif
19174
19175 return (now - start);
19176}
19177
19178Uint64
19179SDL_GetPerformanceCounter(void)
19180{
19181 LARGE_INTEGER counter;
19182
19183 if (!QueryPerformanceCounter(&counter)) {
19184 return SDL_GetTicks();
19185 }
19186 return counter.QuadPart;
19187}
19188
19189Uint64
19190SDL_GetPerformanceFrequency(void)
19191{
19192 LARGE_INTEGER frequency;
19193
19194 if (!QueryPerformanceFrequency(&frequency)) {
19195 return 1000;
19196 }
19197 return frequency.QuadPart;
19198}
19199
19200#ifdef __WINRT__
19201static void
19202Sleep(DWORD timeout)
19203{
19204 static HANDLE mutex = 0;
19205 if ( ! mutex )
19206 {
19207 mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS);
19208 }
19209 WaitForSingleObjectEx(mutex, timeout, FALSE);
19210}
19211#endif
19212
19213void
19214SDL_Delay(Uint32 ms)
19215{
19216 Sleep(ms);
19217}
19218
19219#endif
19220
19221int SDL_ConvertAudio(SDL_AudioCVT* c) { return 0; }
19222int SDL_BuildAudioCVT(SDL_AudioCVT* c,SDL_AudioFormat sf, Uint8 sc, int sr, SDL_AudioFormat df, Uint8 dc, int dr) { return 0; }
19223void SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, Uint32 len, int volume) { }
19224static char SDL_Audio_Init_Done = 0;
19225Uint32 SDL_WasInit(Uint32 flags) { return (flags &16 ? SDL_Audio_Init_Done : 0); }
19226int SDL_InitSubSystem(Uint32 flags) { return (flags &16 ? (SDL_Audio_Init_Done = 1) : 0); }
19227#ifdef __WIN32__
19228char* WIN_StringToUTF8(const unsigned short* s) { int l = WideCharToMultiByte(CP_UTF8,0,(LPCWSTR)s,-1,0,0,0,0); char* b = (char*)malloc(l); WideCharToMultiByte(CP_UTF8, 0, (LPWSTR)s, -1, b, l, NULL, NULL); return b; }
19229unsigned short* WIN_UTF8ToString(const char* s) { int l = MultiByteToWideChar(CP_UTF8,0,s,-1,NULL,0); unsigned short* b = (unsigned short*)malloc(l*sizeof(short)); MultiByteToWideChar(CP_UTF8,0,s,-1,(LPWSTR)b,l); return b; }
19230#if (defined(_MSC_VER) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
19231#pragma comment (lib, "winmm.lib")
19232#endif
19233#endif