copied JoystickAImpl_GetDeviceData from joystick_linux.c to joystick_linuxinput.c

Christoph Frick frick at sc-networks.de
Tue Oct 18 03:07:51 CDT 2005


This patch makes the joystick via the event interface working in the
game IL2-Sturmovik.

ChangeLog
	Copied the implementation of JoystickAImpl_GetDeviceData from
	joystick_linux.c

-- 
cu

--- dlls/dinput/joystick_linuxinput.c.orig	2005-10-17 21:11:14.000000000 +0200
+++ dlls/dinput/joystick_linuxinput.c	2005-10-18 00:42:51.000000000 +0200
@@ -833,17 +833,68 @@
 					      DWORD flags
 ) {
   JoystickImpl *This = (JoystickImpl *)iface;
+  DWORD len;
+  int nqtail;
+  HRESULT hr = DI_OK;
 
-  FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
+  TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
+
+  if (This->joyfd==-!1) {
+    WARN("not acquired\n");
+    return DIERR_NOTACQUIRED;
+  }
 
   joy_polldev(This);
   if (flags & DIGDD_PEEK)
     FIXME("DIGDD_PEEK\n");
 
+  len = ((This->queue_head < This->queue_tail) ? This->queue_len : 0)
+    + (This->queue_head - This->queue_tail);
+  if (len > *entries)
+    len = *entries;
+
   if (dod == NULL) {
+    if (len)
+      TRACE("Application discarding %ld event(s).\n", len);
+
+    *entries = len;
+    nqtail = This->queue_tail + len;
+    while (nqtail >= This->queue_len)
+      nqtail -= This->queue_len;
   } else {
+    if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3)) {
+      ERR("Wrong structure size !\n");
+      return DIERR_INVALIDPARAM;
   }
-  return 0;
+
+    if (len)
+      TRACE("Application retrieving %ld event(s).\n", len);
+
+    *entries = 0;
+    nqtail = This->queue_tail;
+    while (len) {
+      /* Copy the buffered data into the application queue */
+      memcpy((char *)dod + *entries * dodsize, This->data_queue + nqtail, dodsize);
+      /* Advance position */
+      nqtail++;
+      if (nqtail >= This->queue_len)
+        nqtail -= This->queue_len;
+      (*entries)++;
+      len--;
+    }
+  }
+
+  if (This->overflow) {
+    hr = DI_BUFFEROVERFLOW;
+    if (!(flags & DIGDD_PEEK)) {
+      This->overflow = FALSE;
+    }
+  }
+
+  if (!(flags & DIGDD_PEEK))
+    This->queue_tail = nqtail;
+
+  return hr;
 }
 
 /******************************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20051018/45706be4/attachment.pgp


More information about the wine-patches mailing list