backlight brightness in MIO - Windows Mobile Development and Hacking General

hi,
I've got a huge problem with brightness,
my code is:
Code:
RegistryKey key = Registry.CurrentUser.OpenSubKey("ControlPanel").OpenSubKey("BackLight", true);
int value = (int)key.GetValue("Brightness");
key.SetValue("Brightness", (value + 1) % 10, RegistryValueKind.DWord);
key.Close();
DoAutoResetEvent("BackLightChangeEvent");
I know what registry values change but I don't know the event name to raise.
I tried "BackLightChangeEvent" and "SDKBackLightChangeEvent",which I found when googling this problem and they didn't work...
Can someone please tell me the event name?

Related

phoneOpen, phoneGetVolume (TAPI)

Hello,
I try to retrieve (then set) the volume, ring type ... of my XDA using TAPI
I call phoneInitializeEx, phoneOpen, phoneGetVolume but I always get the same value for the volume (even if I chnage it of course)
Does anybody knows why ?
Does anybody have and can post a sample code source showing how to unse these functiuns (phoneInitializeEx, phoneOpen, phoneGetVolume, phoneGetStatus ...)
Regards.
To set the phone volume (in mono) try:
Code:
set(DWORD dwVolume)
{
if (dwVolume > 0xFFFF) dwVolume = 0xFFFF;
dwVolume += dwVolume * 0x10000;
DWORD ret;
switch ((ret = waveOutSetVolume(0, dwVolume))) {
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
case (etc....)
}
To get the volume, try:
Code:
DWORD get()
{
DWORD dwVolume;
DWORD ret;
switch ((ret = waveOutGetVolume(0, &dwVolume))) {
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
case (etc...)
}
// Return average of left and right:
if (dwVolume > 0xFFFF) {
dwVolume = ((dwVolume & 0xFFFF) + (dwVolume / 0xFFFF)) / 2;
}
return dwVolume;
}
This is code for XDA I. I have not tried this on XDA II which as we know, has two volume channels.....
Ben.
I upgraded my XDA1 with WM2003 and I have 2 channels for the volume too.
I will try your code but I think this will change only the system volume (I will need to do that too so thanks) but not the phone volume.
First I want to pilot the phone settings (ring, volume...) from an application.
And it seems that only TAPI can do it... but it is not working for the moment
Glad the code will be useful.
If you find the correct method for XDA II, please let me know, I'll need it my self soon.
Ben
Your code works well to set/get the sytem volume
I just modifed it a little as the output is mono
Code:
//**********************************************************************
//Set The System Volume
//Steps (0,13107,26214,39321,52428,65535)
DWORD setVolume(DWORD dwVolume)
{
if (dwVolume > 0xFFFF)
dwVolume = 0xFFFF;
if (dwVolume < 0x0000)
dwVolume = 0x0000;
DWORD ret;
switch ((ret = waveOutSetVolume(0, dwVolume)))
{
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
default :
break;
}
return 0;
}
//**********************************************************************
//Get The System Volume
DWORD getVolume()
{
DWORD dwVolume;
DWORD ret;
switch ((ret = waveOutGetVolume(0, &dwVolume)))
{
case MMSYSERR_NOERROR:
break;
case MMSYSERR_ERROR:
break;
default :
break;
}
dwVolume = (dwVolume & 0xFFFF);
return dwVolume;
}
But the phoneGetVolume still gives incoherent results
Someone see something wrong in the code below ?
I set the phone volume to 0 on the device but PhoneGetvolume send me 40092 ???
Code:
LONG result;
HPHONE hPhone;
DWORD dwVolume;
DWORD dwRingMode;
DWORD dwNumDevs= 01;
DWORD dwAPIVersion=0x00020002;
PHONESTATUS PhoneStatus;
HPHONEAPP hPhoneApp = 0;
PHONEINITIALIZEEXPARAMS PhoneInitializeExParams;
PhoneInitializeExParams.dwTotalSize = 2 * sizeof(PHONEINITIALIZEEXPARAMS);
PhoneInitializeExParams.dwOptions = PHONEINITIALIZEEXOPTION_USEEVENT;
// PhoneInitializeExParams.dwOptions = PHONEINITIALIZEEXOPTION_USEHIDDENWINDOW;
result = phoneInitializeEx(&hPhoneApp,NULL,NULL,NULL,&dwNumDevs,&dwAPIVersion,&PhoneInitializeExParams);
result = phoneOpen(hPhoneApp, 0, &hPhone, dwAPIVersion, 0, 0,PHONEPRIVILEGE_OWNER);
result = phoneGetVolume(hPhone,PHONEHOOKSWITCHDEV_SPEAKER,&dwVolume); //range 0x00000000 to 0x0000FFFF (65535)
In fact when I set the phone volume using
PocketSetVolume the vlaue is well saved because I get it when I use after PocketGetVolume.
But the phone volume is not really changed ?
Nobody has a sample that uses these functions ?
Or not obligatory these functions but others functions that change the phone volume ?
zendrui said:
In fact when I set the phone volume using
PocketSetVolume the vlaue is well saved because I get it when I use after PocketGetVolume.
But the phone volume is not really changed ?
Nobody has a sample that uses these functions ?
Or not obligatory these functions but others functions that change the phone volume ?
Click to expand...
Click to collapse
I have found that by changing the following registry keys, I can change the volume of the Phone
[HKEY_CURRENT_USER\ControlPanel\Volume]
"Ringer"=dword:00000000
Use hex 00000000, 33333333, 66666666, 99999999, cccccccc, ffffffff
[HKEY_CURRENT_USER\ControlPanel\SoundCategories\Ring]
"InitVol"=dword:00000000
Use hex 0, 1, 2, 3, 4, 5
This work beautifully for my Qtek running WM2003, but I have tried the same approach for the system-volume by changing
[HKEY_CURRENT_USER\ControlPanel\Volume]
"Volume"=dword:00000000
Use hex 00000000, 33333333, 66666666, 99999999, cccccccc, ffffffff
But this does not work! I have checked the registry and the value goes in correctely (The in-system volum control stores the same values in the same key).
How can I use the above code-snippets from the .Net Compact Framework? (I'm guessing a P/Invoke but what DLL is the call hidden in)
Cato
I am trying to make it works, but fail...please let me know if you know how to use the registry to update it...my email is
[email protected]
Thanks
I used the P/Invoke sample from Microsoft to get a working sample that read and updated the registry, and simply tried all possible combo's of a 4byte-array to see what would produce the correct result
Cato
I found a article mention it !!!
http://www.cegadgets.com/winceregfaq.htm#2.8 Where are volume and sound settings stored?
Not sure it works or not !!!
Please let me know if you know how to use the AudioUpdateFromRegistry, defined in coredll
Thanks :wink:
One more acticle !!!
http://www.pocketpcdn.com/forum/viewtopic.php?t=111
But I dunno how to make it works.
Any runnable example?
Hello,
after many tries I didn't find how to use TAPI functions ... this seems not towork ..
But you can change all the phone settings (volume, ring mode, ring tone, notifications ...) in the registry ... as I did for PocketZenPhone
See under that key HKEY_CURRENT_USER\ControlPanel
For the system volume I use the functions I posted upper
Hey, any example to do it?
Thanks zendrui
If you use EVC
Simply open the registry key
HKEY Key;
RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
Then use RegQueryValueEx to retrieve the value/setting you want
Hi zendrui,
I am able to update the registry, but I am not able to call AudioUpdateFromRegistry to notify the system to update the status from registry.
Could you able to exeute this API?
Thanks,
Paul
Sorry for the last post didn't have the keys in my mind
So to change the phone volume here are the keys needed
Code:
//dwPhoneVolumeLevel between 0 and 0xFFFFFFFF
res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\Volume"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("Ringer"),0,REG_DWORD,(LPBYTE)&dwPhoneVolumeLevel,sizeof(DWORD));
if (res != ERROR_SUCCESS)
{
RegCloseKey(Key);
return -1;
}
}
RegCloseKey(Key);
//dwInitVol between 1 and 5
res = RegOpenKeyEx(HKEY_CURRENT_USER,_T("\\ControlPanel\\SoundCategories\\Ring"),0,0,&Key);
if (res == ERROR_SUCCESS)
{
res = RegSetValueEx(Key,_T("InitVol"),0,REG_DWORD,(LPBYTE)&dwInitVol,sizeof(DWORD));
if (res != ERROR_SUCCESS)
{
RegCloseKey(Key);
return -1;
}
}
RegCloseKey(Key);
It changes the phone volume and the display
PS : I post this code hoping is to help people to develop freewares (or low low cost software :wink
COOL !!! Thanks zendrui !!!!
Now I can set the Ringer volume !!!
How about set the system sound volume?
Fot the system volume see upper of this thread I posted the code I use. It works perfect
O yes...It works under eVC++
Let me try to implement it in VS.NET
Thanks
bong99 said:
O yes...It works under eVC++
Let me try to implement it in VS.NET
Thanks
Click to expand...
Click to collapse
Please tell me if you make it, as I have tried various P/Invoke calls that all result in a No Supported Exception.
Cato
PS: Sorry that I could not get you a working code before but I was under with the flu last week

Changing speaking loudness on the telephone (with TAPI)

I've a question to change the telephone sound volume of the mda II for speaking. For this I found the function phoneSetVolume(HPHONE hPhone, DWORD dwHookSwitchDev, DWORD dwVolume) of the TAPI.
Now I've the problem that I don't know how to get the handle to the phone (HPHONE).
Can anybody help me?
Thanks!
use phoneOpen
There is still a problem...
Okay, but the function phoneOpen requires also parameters which I don't know where I can get they. For instance the HPHONEAPP. Where can I get the phone application or the deviceID and then the LPPHONE.
I am very thankful to you when you could help me how to get the parameters.
Or is it possible to change the volume of the telephone speaker by changing a registry key? Do you know the key name?
Thanks a lot!
Re: There is still a problem...
phoneInitializeEx gives you PhoneApp and number of phone devices, phoneOpen gives you hPhone, deviceID is probably 0 (test all deviceIDs starting from 0 to the count returned by phoneInitializeEx). Read MSDN for more information.
I don't know the registry key, and modifying it would not change the device volume immediately.
Thanks for your reply!
When I use the function phoneInitializeEx() it returns a value that is negative but not an determined error. Here is my code. Can you say me whats wrong?!
HPHONEAPP lpHPhoneApp;
DWORD lpdwNumDevs;
DWORD lpdwAPIVersion;
PHONEINITIALIZEEXPARAMS lpPhoneInitializeExParams;
long result = phoneInitializeEx(&lpHPhoneApp, NULL, NULL, NULL, &lpdwNumDevs, &lpdwAPIVersion, &lpPhoneInitializeExParams);

RIL

XDA Developers,
Years ago I downloaded the RIL .dll and API from this site. Then it was only half complete and I had to patch it my self.
I am sure development has been completed since then.
Can anybody tell me if RIL is still maintained by this site? In which case, where can I get it?
Specifically I need signal quality on XDA II upwards. If anybody can help me?
Kind Regards,
Ben
After posting, my text RIL was shown with a link to most of the information.
There is one think I can't understand. The stucture returned as as follows:
int nMinSignalStrength; // @field TBD
int nMaxSignalStrength; // @field TBD
int nLowSignalStrength; // @field TBD
int nHighSignalStrength; // @field TBD
Which have the values (On XDA IIs) of -113, -51, -110, -60
Would any member know what the meaning of these values is?
I have then tried to convert the quality to a percentage. But the percentage always reads way to high, or zero.
My guess is that these are DB and therefore logarithmic. Would any member know how to convert to a linar scale?
My guess is something like: log10(n / 3) where n is any of the above or retuned figure.
Any ideas would be very useful!
Regards, Ben.
Hi,
Code:
HRESULT RIL_GetSignalQuality(
HRIL hRil // @parm handle to RIL instance returned by <f RIL_Initialize>
);
returns the following structure:
Code:
typedef struct rilsignalquality_tag {
DWORD cbSize; // @field structure size in bytes
DWORD dwParams; // @field indicates valid parameters
int nSignalStrength; // @field TBD
int nMinSignalStrength; // @field TBD
int nMaxSignalStrength; // @field TBD
DWORD dwBitErrorRate; // @field bit error rate in 1/100 of a percent
int nLowSignalStrength; // @field TBD
int nHighSignalStrength; // @field TBD
} RILSIGNALQUALITY, *LPRILSIGNALQUALITY;
Why don't you just use nSignalStrength? Sounds pretty simple and linear to me? Nothing to calculate...
In trying to make my posting simple. I think I forgot to clarify my problem
First is the problem that the nSignalStrength falls between two values.
But there are two fields it can fall between:
nMinSignalStrength <= nSignalStrength <= nMaxSignalStrength
nLowSignalStrength <= nSignalStrength <= nHighSignalStrength
Which one should be used? Why are there two?
Secondly, I want to show a percentage result between one of the above. But these figures are, I belive, Decibels (BD). Each 3 DB = a doubling of the value. So 1 = 10%, 4 = 20%, 7 = 40% etc...
Therefore a liniar percent placement of nSignalStrengh tells me nothing. Most values are close to Max, and then suddenly zero.
My math is a little rusty I was hoping somebody may have a nice function for returning the linear range from the logarithmic rage….
Thanks again to any members who can offer some help
Ben
Hmm... but what if min and max are just values currently encountered in your local cell? When you move to another cell you may receive different min/max values. Or maybe these are the values of the farest and nearest cell? I don't know either, but your explanation of min/max sounds worse to me than does mine...
This could be correct. The values I have are on my XDA IIs using O2 are:
Min -113
Low -110
High -60
Max -51
Therefore:
Min < Low < nSignalStrength < High < Max
So I am using Low = 0% and High = 100%. But this returnes figures of above 50% when signal is quite low.
I think the linear conversion is exp(value / 3)
Therefore percent is:
percent = (exp(nSignalStrength / 3) - exp(Low / 3)) / (exp(high / 3) - exp(Low / 3)) * 100;
Which seems to give better figures. But I am not sure how accurate it is..
Any experts on signal quality out there, I'd love to hear from them!
Ben
If anybody is following this thread, this *seems* to return a good percentage for signal quality. I am not sure of the quality or accuracy. But it works
static double dValue, dMax;
dValue = (int)data->nSignalStrength; // (int) to convert twos complement signed integer correctly.
dMax = (int)data->nHighSignalStrength; // (int) to convert twos complement signed integer correctly.
dValue -= (int)data->nLowSignalStrength;
dMax -= (int)data->nLowSignalStrength;
dValue = pow(dValue / -3.0, 2);
dMax = pow(dMax / -3.0, 2);
dValue /= dMax;
dValue *= 100;
if (dValue > 100) dValue = 100; // never
if (dValue < 0) dValue = 0; // never
Regards,
Ben
Hi there, i've been following this thread with interest I have a very limited knowlege of C++ but not even on the PPC.
Would you mind attaching or even PMing your cpp so i could possibly learn more ?
I find i learn more by examples, and am quite interested in making an application that can disable the radio then re-enable it after a set ammount of time (so i can swap between sims, i have a dual sim adapter)
Best thing to do is follow the sample code supplied by these nice gues from xda-developers, by clicking on this RIL link.
BUT replace the ril.h in the .zip archive with the ril.h you will find from the link.
(nb: if the author of this .zip archive is reading, it's way out of date to the ril.h on this site. ps, hows the ril development going?)
If you get the sample code working, this will give you some idea of what is possible. Your options may not be possible. But look at the ril.h and the functions listed. If one of them does what you want, give it a go.
Regards,
Ben

volume setting

I am trying to set the volume to my needs then put it back after. I have use the code from ppc developer network and when that did not set the correct volume I also did the registry as well. Don't worry about "reg", its my registry class and it works fine.
DWORD oldReg=0;
oldReg=reg->readDWORDfromReg(name,path);
reg->saveDWORDtoRegistry(name,path,0xffffffff);
WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000 * 1000;
wf.wBitsPerSample = 8;
wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize = 0;
HWAVEOUT hwo;
DWORD dwVolume=0xffffffff;
DWORD oldVolume=0;
int waveDevice=-1;
UINT numberOfDevices=waveOutGetNumDevs();
for(UINT id=0;id<numberOfDevices;id++)
{
if (waveOutOpen(&hwo,id,&wf,0,0,CALLBACK_NULL)==MMSYSERR_NOERROR)
{
waveDevice=id;
waveOutGetVolume(hwo,&oldVolume);
waveOutSetVolume(hwo,dwVolume);
waveOutClose(hwo);
break;
}
}
.........playing sound here all ok....
//put the volume back
if(waveDevice!=-1)
{
if (waveOutOpen(&hwo, waveDevice, &wf, 0, 0, CALLBACK_NULL) == MMSYSERR_NOERROR)
{
waveOutSetVolume(hwo, oldVolume);
waveOutClose(hwo);
}
}
reg->saveDWORDtoRegistry(name,path,oldReg);
I can set the volume to any value below the origional volume but any attempt to set a volume higher just dose nothing. There are no errors (checking left out here), just the same level. I did not seriously expect the registry part to work as I guess there is some event to trigger that change, but others seem to get results from waveOutSetVolume.
Well, I never tried changing volume by code, but I know TCPMP player does it well and it's open source so might be worth taking a look at.
Thanks levenum, I will give it a look.
Before I got a chance to look at that code I got a result. I have been using PlaySound to play a resource with no volume change working. When I use waveOutWrite to play a buffer containing the same data I can get the volume change I am after. There is still something wrong with my code because the sound gets garbled but I think I will figure that part out. I also want to next test playsound with a file instead of a resource.
<edit>
using playsound with the same file plays clear sound but the volume change is not working. Its a pity because to get the waveoutwrite to work properly i had to fill in the WAVEFORMATEX with the CORRECT values. This means that if I am allowing the user to specify files to play I will have to find out the samples per second and bits per sample info before I can use the file.

Need help for making small application

I wanted to make myself an application for switching between profiles for my ringtones.
I'm new at programming but i've been looking for 6 hours now since i'm stuck.
I was thinking of connecting the buttons with a change in the register on the "Ring0"
This is what i have for a vibrating button:
RegistryKey Ourkey = Registry.CurrentUser;
Ourkey = Ourkey.OpenSubKey("ControlPanel", true);
Ourkey = Ourkey.OpenSubKey("Sounds", true);
Ourkey = Ourkey.OpenSubKey("Ring0", true);
Ourkey.SetValue("script",av3w3);
Ourkey.Close();
problem is the av3w3. he gives me an error with it.
Hope someone can help
"Ourkey.SetValue("script",av3w3);"
of av3w3 a varible ?
if so is it the correct type?
if you mean to set the script as a string you need to add ""

Categories

Resources