Remapping POWER button

Hi to all,
how i can remap POWER BUTTON with the aim to replace the POWER_STATE_SUSPEND with a POWER_STATE_IDLE !

Thanks for any help,
Muzero


Answer this question

Remapping POWER button

  • Vishal_LogicaCMG

    Hi,

    I have tried this, but when my Mio A701 switches off after 1 minute of idle time (enabled in power manager), all apps stop running.

    I have changed the "SuspendToUnattendedMode" from 0 to 1 in the registry. That makes no difference.

    I have produced this C# code:

    public enum PowerMode
    {
    ReevaluateStat = 0x0001,
    PowerChange = 0x0002,
    UnattendedMode = 0x0003,
    SuspendKeyOrPwrButtonPressed = 0x0004,
    SuspendKeyReleased = 0x0005,
    AppButtonPressed = 0x0006
    }

    [DllImport("CoreDll.dll")]
    public static extern void PowerPolicyNotify(PowerMode powermode, int flags);

    On start of app:
    PowerManagement.PowerPolicyNotify(PowerManagement.PowerMode.UnattendedMode, 1);

    On end of app:
    PowerManagement.PowerPolicyNotify(PowerManagement.PowerMode.UnattendedMode, 0);

    My application still seems to stop running when the device "switches" off due to idle on the battery.

    I need my application to remain running in unattended mode when the screen switches off.

    Using .Net CF2, VS2005, WM5 on a Mio A701.



  • Big5824

    Hi

    I have been testing my applications using PlaySound(....)

    PlaySound will work in Unattended mode so you can hear

    what happens or what is happening..

    One good way to test your apps is to use the WM5 Emulator.

    I found that if the Emulator works, the Hardware MAY NOT

    function the same because of implementation problems.

    The Emulator is the reference standard.

    Allan


  • OasisGames

    Many Thanks for your help, you solved all my problems! :)
    Muzero

  • NJCoughlan

    You do not remap the power button - instead you should use PM API:

    PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE);

    to ensure that your application keeps running even after power button has been pressed



  • William Nordgren

    Hello,

    I tried to use this code in my c# project but it doesn't work, have anyone been able to use PowerPolicyNotify in c#

    // Mikael

    Mike12 wrote:

    Hi,

    I have tried this, but when my Mio A701 switches off after 1 minute of idle time (enabled in power manager), all apps stop running.

    I have changed the "SuspendToUnattendedMode" from 0 to 1 in the registry. That makes no difference.

    I have produced this C# code:

    public enum PowerMode
    {
    ReevaluateStat = 0x0001,
    PowerChange = 0x0002,
    UnattendedMode = 0x0003,
    SuspendKeyOrPwrButtonPressed = 0x0004,
    SuspendKeyReleased = 0x0005,
    AppButtonPressed = 0x0006
    }

    [DllImport("CoreDll.dll")]
    public static extern void PowerPolicyNotify(PowerMode powermode, int flags);

    On start of app:
    PowerManagement.PowerPolicyNotify(PowerManagement.PowerMode.UnattendedMode, 1);

    On end of app:
    PowerManagement.PowerPolicyNotify(PowerManagement.PowerMode.UnattendedMode, 0);

    My application still seems to stop running when the device "switches" off due to idle on the battery.

    I need my application to remain running in unattended mode when the screen switches off.

    Using .Net CF2, VS2005, WM5 on a Mio A701.


  • Remapping POWER button