Direct Input ANSI C Example Needed

Hi I've tried googling this but it keeps coming up with either C++ or C# examples, I'd like an example in pure ANSI C, reason for this is I'm trying to make a custom framework that can compile in C++, C# and OBJC with little or no errors (hence ANSI C89/C90).

I'd like examples for keyboards, mice and joy pads. (As a note I'm using keybd, mouse and joypd respectively for my variables).

Edit: I'm going to bed now, probably won't check back until about 16:00 onwards tomorrow
Last edited on
closed account (N36fSL3A)
Converting C++ from C is relatively straight forward if you have knowledge with both. Can you give a tutorial link so we can help you understand?
Thanks for the reply, the only link I actually bookmarked was this one since it did at least give me a rough understanding
http://www.toymaker.info/Games/html/directinput.html

Edit:
Found out that I was more or less doing it right but just needed to add ->lpVtbl between the objects and the functions and then also reference the obj as the first parameter. To deal with that pain of a difference I'll use a macro like this:
1
2
3
4
5
6
7
#ifdef __cplusplus
#define ZXDI( OBJ )      OBJ
#define ZXDI_THIS( OBJ )
#else
#define ZXDI( OBJ )      OBJ->lpVtbl
#define ZXDI_THIS( OBJ ) OBJ,
#endif 

Which put an end to errors like this
1
2
3
4
5
||=== Build: libzxs-x64-d-vc in libzxs (compiler: Microsoft Visual C++ 2010) ===|
main.c|309|error C2039: 'CreateDevice' : is not a member of 'IDirectInput8A'|
main.c|318|error C2039: 'SetDataFormat' : is not a member of 'IDirectInputDevice8A'|
main.c|319|error C2039: 'SetCooperativeLevel' : is not a member of 'IDirectInputDevice8A'|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Last edited on
Topic archived. No new replies allowed.