Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

PocketHAL/PocketFrog Orientation


PocketHAL/PocketFrog Orientation

Postby EvilMaio » Oct 20, 2006 @ 9:30am

Hi PHAL's fans!

Can you confirm that pockethal holds its orientation variables regarding of pocketpc orientation?

For example, if i develop my application in portrait mode and i launch it in a landscape pocketpc, m_config.orientation is always ORIENTATION_NORMAL or pockethal change its value to ORIENTATION_ROTATE90CCW/ORIENTATION_ROTATE90CW?

And if i develop my application with ORIENTATION_ROTATE90CW and i launch it in a portrait pocketpc, m_config.orientation will be ORIENTATION_NORMAL?

Thanks in advance! ;)
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby fast_rx » Oct 21, 2006 @ 1:43am

Yes, m_config.orientation is independent of wm2003's mode. Should be the same for wm5.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby EvilMaio » Oct 21, 2006 @ 7:22pm

Thanks for your answer ;)

So can you also confirm that pocketfrog internal remapping routines (for dpad arrows and stylus) cant't work when pocketpc is in landscape mode because they always assume that device is in standard portrait mode?

I noticed that when i start a pocketfrog portrait application in a landscape pocketpc, stylus are wrong mapped.
:twisted:
I'm using last pocketfrog 0.8.1 with last pockethal 0.7.7b (or 0.7.7c can't remember :D)
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby fast_rx » Oct 21, 2006 @ 11:03pm

I checked again, with stylus and buttons...

Image is portrait, stylus is portrait and correct, but buttons are rotated (incorrect).

Seems different from what you say. I may have modified PFrog at some point. Don't remember at the moment - I'll have to look at the code when I get a chance.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby EvilMaio » Oct 21, 2006 @ 11:59pm

Please let me know something when you have some time to check that,
i'm going to kill my brain in order to make it work with all screen rotations :evil:
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby EvilMaio » Oct 22, 2006 @ 12:01pm

Well, i'd like to share with community this piece of code i made in order to get device orientation (as said fast_rx, is NOT the pockethal one!)

Starting from this code, i'm going to code a correct stylus/dpad mapping also for devices not in portrait mode (as soon fast_rx confirms me that he had to modify PFrog too :D)

Basically it's only an API call, but this is available only on PPC2003 Second Edition devices and later so this code try to call the function dynamically and works well also on ppc2002 and ppc2003 and it compiles well also on EVC++3.

This code is a patch for pocketfrog 0.8.1 source.

In game.h find struct Config and add:
Code: Select all

int iDeviceScreenRotation;
1 lines; 1 keywds; 0 nums; 1 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  

So it will look like:

Code: Select all









// Configuration
struct Config
{
        LPCTSTR     szWindowName;     // Window title
        Orientation orientation;      // Screen orientation (default = ORIENTATION_NORTH)

        int iDeviceScreenRotation; // device orientation
}

9 lines; 2 keywds; 0 nums; 5 ops; 0 strs; 4 coms    Syntactic Coloring v0.4 - Dan East  


In game.cpp add this code on in Game::Init (i added it just before):

Code: Select all



    // Init input
    if (!PHAL::GetKeyList( &m_keys, m_config.orientation ))
        return false;
3 lines; 3 keywds; 0 nums; 11 ops; 0 strs; 1 coms    Syntactic Coloring v0.4 - Dan East  


I had to declare also some structs that the API call will fill because they're not present in ppc2002 sdk.

Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
    /////////////////////////////////////////////////
    //
    //
    // Detect pocketpc screen orientation
    // this is NOT the pockethal one!
#if defined(FROG_PPC)

    typedef struct d_evicemodeA {
        BYTE   dmDeviceName[CCHDEVICENAME];
        WORD dmSpecVersion;
        WORD dmDriverVersion;
        WORD dmSize;
        WORD dmDriverExtra;
        DWORD dmFields;
        short dmOrientation;
        short dmPaperSize;
        short dmPaperLength;
        short dmPaperWidth;
        short dmScale;
        short dmCopies;
        short dmDefaultSource;
        short dmPrintQuality;
        short dmColor;
        short dmDuplex;
        short dmYResolution;
        short dmTTOption;
        short dmCollate;
        BYTE   dmFormName[CCHFORMNAME];
        WORD   dmLogPixels;
        DWORD  dmBitsPerPel;
        DWORD  dmPelsWidth;
        DWORD  dmPelsHeight;
        DWORD  dmDisplayFlags;
        DWORD  dmDisplayFrequency;
        DWORD  dmICMMethod;
        DWORD  dmICMIntent;
        DWORD  dmMediaType;
        DWORD  dmDitherType;
        DWORD  dmICCManufacturer;
        DWORD  dmICCModel;
        DWORD  dmPanningWidth;
        DWORD  dmPanningHeight;
        DWORD  dmDisplayOrientation;
    } DEVMODEA_WM5, *PDEVMODEA_WM5, *NPDEVMODEA_WM5, *LPDEVMODEA_WM5;

    typedef struct d_evicemodeW {
        WCHAR  dmDeviceName[CCHDEVICENAME];
        WORD dmSpecVersion;
        WORD dmDriverVersion;
        WORD dmSize;
        WORD dmDriverExtra;
        DWORD dmFields;
        short dmOrientation;
        short dmPaperSize;
        short dmPaperLength;
        short dmPaperWidth;
        short dmScale;
        short dmCopies;
        short dmDefaultSource;
        short dmPrintQuality;
        short dmColor;
        short dmDuplex;
        short dmYResolution;
        short dmTTOption;
        short dmCollate;
        WCHAR  dmFormName[CCHFORMNAME];
        WORD   dmLogPixels;
        DWORD  dmBitsPerPel;
        DWORD  dmPelsWidth;
        DWORD  dmPelsHeight;
        DWORD  dmDisplayFlags;
        DWORD  dmDisplayFrequency;
        DWORD  dmDisplayOrientation;
    } DEVMODEW_WM5, *PDEVMODEW_WM5, *NPDEVMODEW_WM5, *LPDEVMODEW_WM5;

    #ifdef UNICODE
        typedef DEVMODEW_WM5 DEVMODE_WM5;
        typedef PDEVMODEW_WM5 PDEVMODE_WM5;
        typedef NPDEVMODEW_WM5 NPDEVMODE_WM5;
        typedef LPDEVMODEW_WM5 LPDEVMODE_WM5;
    #else
        typedef DEVMODEA_WM5 DEVMODE_WM5;
        typedef PDEVMODEA_WM5 PDEVMODE_WM5;
        typedef NPDEVMODEA_WM5 NPDEVMODE_WM5;
        typedef LPDEVMODEA_WM5 LPDEVMODE_WM5;
    #endif

    // start DLL API call

    typedef LONG (CALLBACK* LPFNDLLFUNC1)(LPCTSTR, LPDEVMODE_WM5, HWND, DWORD, LPVOID);

    LPFNDLLFUNC1 lpfnDllFunc1;
    HINSTANCE h = LoadLibrary(_T("CoreDLL.dll"));
    if (!= NULL)
    {
        lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(h,_T("ChangeDisplaySettingsEx"));
        if (lpfnDllFunc1) {
            /*DEVMODE */DEVMODE_WM5 devmode = {0};
            devmode.dmSize = sizeof(DEVMODE_WM5);
            devmode.dmFields = /*DM_DISPLAYORIENTATION*/0x00800000L;
            lpfnDllFunc1(NULL, &devmode, 0, /*CDS_TEST*/0x00000002, NULL);

            if (devmode.dmDisplayOrientation==0 /*DMDO_0*/)
                m_config.iDeviceScreenRotation=0;
            else if (devmode.dmDisplayOrientation==1 /*DMDO_90*/)
                m_config.iDeviceScreenRotation=90;
            else if (devmode.dmDisplayOrientation==2 /*DMDO_180*/)
                m_config.iDeviceScreenRotation=180;
            else if (devmode.dmDisplayOrientation==4 /*DMDO_270*/)
                m_config.iDeviceScreenRotation=270;
            else
                m_config.iDeviceScreenRotation=0;

        } else {
            // GetProcAddress failed! We'll assume standard orientation
            m_config.iDeviceScreenRotation=0;
        }
        FreeLibrary(h);
    } else {
        // LoadLibrary failed - we'll assume standard orientation
        m_config.iDeviceScreenRotation=0;
    }
#else
    // On desktop, assume always standard orientation
    m_config.iDeviceScreenRotation=0;
#endif
    //
    //
    // End of PocketPC Screen orientation detect
    /////////////////////////////////////////////////
130 lines; 59 keywds; 16 nums; 205 ops; 2 strs; 20 coms    Syntactic Coloring v0.4 - Dan East  


Now on my pfrog games, i can get real pocketpc orientation with:
Code: Select all

m_config.iDeviceScreenRotation
1 lines; 0 keywds; 0 nums; 1 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  
it will be 0,90,180,270 according to current device orientation.
While with:
Code: Select all

m_config.orientation
1 lines; 0 keywds; 0 nums; 1 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  

i have PocketHal screen orientation

I tested on my wm5 device and it gave correct values on all orientations, i don't know if this will be useful for someone, but who knows.. :D
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby fast_rx » Oct 22, 2006 @ 4:07pm

Here's what I have in my device to logic functions. Note that the entire section for buttons is commented out, and I had forgotten that I fixed the stylus...

Basically, what I've got works correctly with the stylus, but not with the buttons (maybe I just need to uncomment the code below?)

Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
void Game::DeviceToLogical( int& button ) const
{
#if defined(_WIN32_WCE)
/*
    switch (m_config.orientation)
    {
    case ORIENTATION_ROTATE90CCW:
        if (button == m_keys.vkUp) button = m_keys.vkRight;
        else if (button == m_keys.vkLeft) button = m_keys.vkUp;
        else if (button == m_keys.vkDown) button = m_keys.vkLeft;
        else if (button == m_keys.vkRight) button = m_keys.vkDown;
        break;

    case ORIENTATION_ROTATE90CW:
        if (button == m_keys.vkUp) button = m_keys.vkLeft;
        else if (button == m_keys.vkLeft) button = m_keys.vkDown;
        else if (button == m_keys.vkDown) button = m_keys.vkRight;
        else if (button == m_keys.vkRight) button = m_keys.vkUp;
        break;

    case ORIENTATION_ROTATE180:
        if (button == m_keys.vkUp) button = m_keys.vkDown;
        else if (button == m_keys.vkLeft) button = m_keys.vkRight;
        else if (button == m_keys.vkDown) button = m_keys.vkUp;
        else if (button == m_keys.vkRight) button = m_keys.vkLeft;
        break;
    }
*/

#endif
}



//fixme: don't use hard coded values for width and height
void Game::DeviceToLogical( Point& P ) const
{
    switch (m_config.orientation)
    {
    case ORIENTATION_ROTATE90CCW:
        swap( P.x, P.);
//JLE 02/27/2006
        P.= stylusheight - 1 - P.x;
        break;

    case ORIENTATION_ROTATE90CW:
        swap( P.x, P.);
        P.= styluswidth - 1 - P.y;
        break;

    case ORIENTATION_ROTATE180:
        P.= styluswidth - 1 - P.x;
        P.= stylusheight - 1 - P.y;
        break;
    }
}
55 lines; 15 keywds; 4 nums; 63 ops; 0 strs; 3 coms    Syntactic Coloring v0.4 - Dan East  


styluswidth and stylusheight are defined in game's private class in game.h.

They are set at the end of Game::Init()
Code: Select all









    // In case ORIENTATION_UNKNOWN was selected
    m_config.orientation = m_display->GetOrientation();

// JLE 02/27/2006
    stylusheight = m_display->GetHeight();
    styluswidth = m_display->GetWidth();
    if (m_config.orientation == ORIENTATION_ROTATE90CW || m_config.orientation == ORIENTATION_ROTATE90CCW)
        swap( stylusheight, styluswidth );

9 lines; 1 keywds; 0 nums; 33 ops; 0 strs; 2 coms    Syntactic Coloring v0.4 - Dan East  
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby EvilMaio » Oct 22, 2006 @ 4:28pm

Mmmh..you're checking only for pockethal orientation, at this point..i'm really stucked... 8O

If pocketpc is set in landscape mode 320x240 and we launch a portrait 240x320 pocketfrog application, how can this work for you if pockethal consider only its screen orientation? 8O
(so in that case it won't map the coordinates)
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby fast_rx » Oct 22, 2006 @ 6:51pm

Maybe it's the device you're using? Or the version I've got?

I'm using PHal 0.7.7c (I think) with an axim X30.

Seems to me that it would be a function of PHal to give you the buttons correctly... via the
PHAL::GetKeyList( &m_keys, m_config.orientation )

Just to make sure we're clear:
*your programs correctly handle the buttons but not the stylus.
*My programs are correct with stylus but not buttons.


Should I post a checkout program to see if it's the same on your device?
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby EvilMaio » Oct 22, 2006 @ 7:00pm

Yes please if you post a test program, this would be great!


This was the situation before i modified pocketfrog:

Actually, with latest pocketfrog 0.8.1 (no patches) and latest pockethal 0.7.7 the game gives always wrong mapped stylus (and buttons) when pocketpc isn't in portrait default mode.

If i try a demo pockethal application with m_config.orient = normal/90cw/90ccw/180 on a portrait pocketpc, the pocketfrog correctly remap buttons and stylus.

I tried it on my Asus MyPal A636N (this is my first and unique wm5 device at the moment :( )
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby fast_rx » Oct 22, 2006 @ 11:31pm

Here's a test program...

Reports the status of dpad and stylus. You can change the PFrog orientation, but it requires a restart...

On my x30, the only issue is the dpad when started in wm2003 portrait mode.
Attachments
ButtonTest.zip
Button Test Program
(54.56 KiB) Downloaded 466 times
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby EvilMaio » Oct 23, 2006 @ 12:23am

Wow! Stylus works well with every pocketpc/pockethal combination with your sample! 8O
I'll implement your patch on my pocketfrog and will recheck all again :cry:
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby fast_rx » Oct 23, 2006 @ 1:44am

I tried to use your detection code to fix the button rotation issue, but my setup is EVC3/wm2003. It reports devmode.dmDisplayOrientation==0 no matter what...

Actually, I noticed that it looks like my device flips to portrait just before my app runs. Then on exit, I see a brief portrait image just before it returns to landscape.

I think I've spent enough time on this, and if anyone complains - just tell them to run it in portrait mode.

Of course, if you come up with something that works, I'll use it.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby EvilMaio » Oct 23, 2006 @ 8:40am

Oh, that's strange that code works perfectly on WM5 and all structs was taken from 2003 sdk :o

Anyway..thanks a lot for your time :D
I really appreciate that.
User avatar
EvilMaio
pm Member
 
Posts: 45
Joined: Apr 26, 2005 @ 3:05pm


Postby hrissan » Mar 10, 2007 @ 2:47pm

Just for information, on Fujitsu Siemens PocketLoox 720 the Button Test demo works right for stylus, but does not work right for buttons. Or may be I do not understand how it should work. :)

In landscape, when the "up" button is pressed (which points to the screen), the Button Demo reports "right".

On the other way, It seems logical, because when I hold device in landscape mode, this button points to the right...

So, what the demo should tell us in landscape mode, when the "up" button is pressed? (which points to screen)
hrissan
pm Member
 
Posts: 30
Joined: Mar 10, 2007 @ 1:38pm


Next

Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron