dinput: Add effect gain support

Vincent Pelletier plr.vincent at gmail.com
Mon Jan 19 14:52:41 CST 2009


-- 
Vincent Pelletier
-------------- next part --------------
From 33f7ae8b3785ff063bb90875b054b38d3591805e Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <plr.vincent at gmail.com>
Date: Sun, 18 Jan 2009 19:02:14 +0100
Subject: Add gain support. Apply gain before playing an effect.

---
 dlls/dinput/effect_linuxinput.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index eb6a2b5..7144dae 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -54,6 +54,7 @@ struct LinuxInputEffectImpl
     GUID	guid;
 
     struct ff_effect    effect; /* Effect data */
+    int                 gain;   /* Effect gain */
     int*                fd;     /* Parent device */
     struct list        *entry;  /* Entry into the parent's list of effects */
 };
@@ -379,9 +380,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_GetParameters(
     }
 
     if (dwFlags & DIEP_GAIN) {
-	/* the linux input ff driver apparently has no support
-         * for setting the device's gain. */
-	peff->dwGain = DI_FFNOMINALMAX;
+	peff->dwGain = This->gain;
     }
 
     if (dwFlags & DIEP_SAMPLEPERIOD) {
@@ -513,6 +512,12 @@ static HRESULT WINAPI LinuxInputEffectImpl_Start(
     }
 
     event.type = EV_FF;
+
+    event.code = FF_GAIN;
+    event.value = This->gain;
+    if (write(*(This->fd), &event, sizeof(event)) == -1)
+	FIXME("Failed setting gain. Error: %d \"%s\".\n", errno, strerror(errno));
+
     event.code = This->effect.id;
     event.value = dwIterations;
     if (write(*(This->fd), &event, sizeof(event)) == -1) {
@@ -623,7 +628,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
     /* Gain and Sample Period settings are not supported by the linux
      * event system */
     if (dwFlags & DIEP_GAIN)
-	TRACE("Gain requested but no gain functionality present.\n");
+	This->gain = 0xFFFFUL * peff->dwGain / 1000;
 
     if (dwFlags & DIEP_SAMPLEPERIOD)
 	TRACE("Sample period requested but no sample period functionality present.\n");
-- 
1.5.6.5



More information about the wine-patches mailing list