[1/2] dinput: Fix gain-related bugs

Vincent Pelletier plr.vincent at gmail.com
Fri Jan 23 18:14:45 CST 2009


Fix gain-related bugs:
 - Initialize gain to maximum value.
 - Gain maximum value is 10000, not 1000.
 - Scale gain before returning it to Windows applications.

I introducted those bugs in the patch implementing gain support. Sorry.

Side note:
Gain support is still incomplete and not-so-correct:
There are 2 levels of gain which need to be supported (device-scoped and 
effect-scoped), but linux only supports device-scoped gain... Which I use to 
implement effect-scoped gain !
I will (hopefuly) submit patches during the week-end to clean this mess.

-- 
Vincent Pelletier
-------------- next part --------------
From ff3b672336499bed2a1ab016c2ceef7c62b21e5b Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <plr.vincent at gmail.com>
Date: Sat, 24 Jan 2009 00:59:48 +0100
Subject: Fix gain-related bugs:
 - Initialize gain to maximum value.
 - Gain maximum value is 10000, not 1000.
 - Scale gain before returning it to Windows applications.

---
 dlls/dinput/effect_linuxinput.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index cb3a010..f57f1be 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -378,7 +378,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_GetParameters(
     }
 
     if (dwFlags & DIEP_GAIN) {
-	peff->dwGain = This->gain;
+	peff->dwGain = This->gain * 10000 / 0xFFFF;
     }
 
     if (dwFlags & DIEP_SAMPLEPERIOD) {
@@ -626,7 +626,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
     /* Gain and Sample Period settings are not supported by the linux
      * event system */
     if (dwFlags & DIEP_GAIN)
-	This->gain = 0xFFFF * peff->dwGain / 1000;
+	This->gain = 0xFFFF * peff->dwGain / 10000;
 
     if (dwFlags & DIEP_SAMPLEPERIOD)
 	TRACE("Sample period requested but no sample period functionality present.\n");
@@ -790,6 +790,7 @@ HRESULT linuxinput_create_effect(
     newEffect->ref = 1;
     newEffect->guid = *rguid;
     newEffect->fd = fd;
+    newEffect->gain = 0xFFFF;
 
     /* set the type.  this cannot be changed over the effect's life. */
     switch (type) {
-- 
1.5.6.5



More information about the wine-patches mailing list