Patch for dinput keyboard

Ove Kaaven ovehk at ping.uio.no
Sat May 18 22:28:33 CDT 2002


On Sun, 19 May 2002 arjen at blehq.org wrote:

> > +	/* SysKeyboardAImpl */
> > +	BYTE                            keystate[256];
> 
> There is not a real reason to get a keystate per keyboard, as there is
> only one keyboard. I made this global. Is that OK?

Probably, current_lock is global anyway.

> How do you know the data_queue is free (NULL)?

The SetProperty code was just copied from mouse/main.c, so if there's a
bug in it, it's there too.

> I have this game that does not acquire the device. Guess what? It works
> with windows.

Hmm. Guess the docs don't tell the whole truth then, as usual.

> DI_OK?

Right. dinput.h defines it as:

#define DI_OK                           S_OK

so it's the canonical return value from DirectInput methods.

> > +	    *entries = 0;
> > +	    nqtail = This->queue_tail;
> > +	    while (len) {
> > +		DWORD span = ((This->queue_head < nqtail) ? This->queue_len : This->queue_head)
> 
> If dodsize > 16 then span = 1, but I don't really get the algorithm.

This is also copied from mouse/main.c and works there. The algorithm is
simply about determining how much can be copied with a single memcpy,
taking in account buffer wraparound and stuff. Here, it determines whether
it can copy all the way to the queue head immediately, or stop at the end
of the buffer first, before wrapping around to the beginning of it.

> > +		    - nqtail;
> > +		if (span > len) span = len;


> > +	    This->hook = SetWindowsHookExW( WH_KEYBOARD_LL, dinput_keyboard_hook, 0, 0 );
> > +
> > +	    /* Read current keyboard state */
> > +	    memset(&This->keystate, 0, 256);
> > +	    for (i = 0; i < 0x100; i++)
> > +	    {
> > +		WORD vkey = MapVirtualKeyA( i, 1 ); /* FIXME: use map mode 3 when implemented */
> > +		if (vkey && (GetAsyncKeyState( vkey ) & 0x8000))
> 
> This does not work (see earlier mails). but it isn't needed when keystate
> is global.

It works in WineX since map mode 3 is actually implemented there. I may be
able to submit the patch that implements it if you want, it's not a very
big patch.

> Could you send me the file instead of the patch, as I don't really know
> what to do with this patch.

OK.

> To get involved in politics anyway: you can have the changes I make to
> this patch.

Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c.gz
Type: application/octet-stream
Size: 4053 bytes
Desc: 
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20020519/697cb87b/main.c.obj


More information about the wine-devel mailing list