PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Cursor input isn't working as expected in WM6 emu. images

Hi! A few days ago I discovered Edge and decided to port my game project (which is a work in progress) to make use of it. Unfortunately I don't own a PocketPC myself, so I'm developing it using VC++ Express 2005/embedded Visual C++ 4 + Windows Mobile 6 Emulator Images.

Today, I was working on the project and found out that in one of the game screens the cursor doesn't work as expected when I use the WM6 emulator, although it works fine in the desktop version. More specifically, the buttons in the custom-made GUI system I'm using should change their color whenever the cursor is hovered above them and I've found this button that changes its color in the desktop version but not on the WM6 one.

I made a backup of the project and trimmed it to the bare minimum but the problem is still there. Has anyone ever experienced this kind of problem? Oh, by the way, the game is running at 480x640.

Thanks in advance for your answer,

--Nacho
PointOfLight · 16 Jan 2008, 14:43 UTC
If I understand correctly, you're saying that you're not actually pressing a mouse button, right? This shouldn't work on the WM6 emulator. Because PocketPC devices require the screen to be touched in order for the device to know where the Stylus is, there really isn't such a thing as a "hover mode" in the PocketPC world.
PointOfLight wrote:If I understand correctly, you're saying that you're not actually pressing a mouse button, right? This shouldn't work on the WM6 emulator. Because PocketPC devices require the screen to be touched in order for the device to know where the Stylus is, there really isn't such a thing as a "hover mode" in the PocketPC world.


No, I'm keeping the left mouse button pressed while I move the cursor. Sorry if I didn't make that clear in my first post.

--Nacho
PointOfLight · 16 Jan 2008, 14:58 UTC
Sorry about the misunderstanding. I will have to defer to the experts, then, because while I develop for the PocketPC I don't use Edge at this point. If I might inquire, though, what is the event that you're trapping?
PointOfLight wrote:If I might inquire, though, what is the event that you're trapping?


I added a textbox to my program that reports the cursor's screen coordinates and whether it's being pressed or not and it displays the same information in both versions.

Some supplementary information about my problem: there's a screen with two buttons and one of them changes its color whenever the mouse/emulated stylus hover above it but the other one only changes its color in the PC version. The source code and the epk file used to store some xml files and bitmaps are the same.

--Nacho
PointOfLight · 16 Jan 2008, 17:38 UTC
Is there any chance you could post some source for us to take a look at? Also, can I infer from what you're saying that you have multiple bitmaps for each button representing the different colors? If so, have you tried viewing the "faulty" one in the emulator outside of your application to see if the PocketPC is simply having a problem displaying the bitmap in general?
PointOfLight wrote:Is there any chance you could post some source for us to take a look at?


The source code spans several files. I trimmed it down as much as I could but it's still quite large to post here. I can upload the binaries of both versions, though, maybe my emulator image is broken? (I tried reinstalling it, but who knows).

PointOfLight wrote:Also, can I infer from what you're saying that you have multiple bitmaps for each button representing the different colors? If so, have you tried viewing the "faulty" one in the emulator outside of your application to see if the PocketPC is simply having a problem displaying the bitmap in general?


Yes, that's correct. Before loading a new game state, the GUI system parses an XML file that contains a "GUI theme" description. This file defines several things such as the filenames of the images used by the widgets. It also defines one or more "Button Types", which specify which images are used for the buttons "normal state", "hovered state", "pressed state" and "disabled state" and the font that must be used for the button's caption. This is the GUI theme file I'm using:

Code:

<GUITheme>
<Image ID="0" EDGEPacketFilename="SPMData.epk" Filename="soda.bmp"/>
<Image ID="1" EDGEPacketFilename="SPMData.epk" Filename="soda2.bmp"/>
<Image ID="2" EDGEPacketFilename="SPMData.epk" Filename="soda3.bmp"/>
<Image ID="3" EDGEPacketFilename="SPMData.epk" Filename="UpArrow.bmp"/>
<Image ID="4" EDGEPacketFilename="SPMData.epk" Filename="DownArrow.bmp"/>
<Image ID="5" EDGEPacketFilename="SPMData.epk" Filename="MsgBox.bmp"/>
<Image ID="6" EDGEPacketFilename="SPMData.epk" Filename="MsgBoxButton.bmp"/>
<Image ID="7" EDGEPacketFilename="SPMData.epk" Filename="soda4.bmp"/>
<ButtonType ID="0" NormalStateImgID="0" PushedStateImgID="1" HoveredStateImgID="2" DisabledStateImgID="7" FontID="1"/>
<ButtonType ID="1" NormalStateImgID="1" PushedStateImgID="2" HoveredStateImgID="0" DisabledStateImgID="7" FontID="0"/>
<ListBoxType ID="0" UpArrowImgID="3" DownArrowImgID="4" FontID="1" MaxItemsVisible="5" MaxCharsPerItem="30"/>
<StaticTextType ID="0" UsesBackgroundImg="YES" BackgroundImgID="0" FontID="1" HAlign="Left" VAlign="Top" Wrapped="YES"/>
<StaticTextType ID="1" UsesBackgroundImg="NO" FontID="1" HAlign="Left" VAlign="Top" Wrapped="YES"/>
<MessageBoxType ID="0" TitleFontID="1" TextFontID="1"
ButtonsFontID="1" BackgroundImgID="5" ButtonsImgID="6"
ButtonsRelDistTop="70" TitleBarDistTop="10" TitleHAlign="Center" TitleVAlign="Center" MsgRelDistHorz="5" MsgRelDistTop="15"
MsgRelDistBottom="60" MsgHAlign="Center" MsgVAlign="Center" MsgWrapped="YES"/>
</GUITheme>


After the GUI theme file is read, the GUI manager reads yet another file which contains the information for every widget in the game state that is about to be loaded. For example, two buttons might have a different caption but use the same Button Type. This is the GUI file from the game state that is not working:

Code:

<GUIElements GUIThemeID="0" FontFileID="0">
<GUIElement>
<Ctg>Button</Ctg>
<ID>500</ID>
<TypeID>0</TypeID>
<Parent>0</Parent>
<Corners C1="160" C2="10" C3="320" C4="40"/>
<Text>MAIN MENU</Text>
<Tooltip> </Tooltip>
</GUIElement>
<GUIElement>
<Ctg>Button</Ctg>
<ID>501</ID>
<TypeID>0</TypeID>
<Parent>0</Parent>
<Corners C1="160" C2="60" C3="320" C4="90"/>
<Text>HQ</Text>
<Tooltip> </Tooltip>
</GUIElement>
<GUIElement>
<Ctg>StaticText</Ctg>
<ID>502</ID>
<TypeID>0</TypeID>
<Parent>0</Parent>
<Corners C1="20" C2="400" C3="180" C4="600"/>
<Text>FUNDS:</Text>
</GUIElement>
</GUIElements>


As you can see, both buttons use the same "ButtonType" (TypeID), which is 0. Since I can correctly see one of them, I assume the emulator is not having any trouble in displaying the bitmaps.

Thanks for your help,

--Nacho
PointOfLight · 16 Jan 2008, 18:10 UTC
Unfortunately I wouldn't be able to try it until I get home tonight, but if you want to either post a binary or would feel more comfortable emailing it to me, I'd be happy to give it a shot. I actually have a WM6 device as well, but unfortunately it's just 240x320, so that won't help any.
Eric, thanks for your help. I PM'ed you a rar file with both binaries and the epk file.

--Nacho
PointOfLight · 17 Jan 2008, 14:15 UTC
I ran the program last night, and it appears that the first time I go to the screen in question the button does not work as you desire, but on subsequent trips to that screen it works just fine. If I shut down the application and restart the same thing happens.
PointOfLight wrote:I ran the program last night, and it appears that the first time I go to the screen in question the button does not work as you desire, but on subsequent trips to that screen it works just fine. If I shut down the application and restart the same thing happens.


What you described happens in the Pocket PC version, right? Does the desktop version work fine?

--Nacho

Edit: If anyone reading this thread happens to own a PocketPC 2003 that supports a 480x640 resolution and doesn't mind testing the executable on it, please PM me.
Hi Nacho,

It seems like you're using some unitialized variables. For example, are you setting your class variables in the class constructor?
PointOfLight · 17 Jan 2008, 15:07 UTC
The desktop version did work fine for me. If the variables weren't initialized correctly, shouldn't it fail on both systems?
Well, it's kind of random. That's why these bugs seem to pop up at odd times, and it's hard to debug. Take the following example:

Code:

bool prevclickhold;

void CheckMouseEvent(void)
{
if (!ecd.input->ClickHold() && prevclickhold)
{
ClassEConsole::MsgWindow("Mouse released");
prevclickhold = false;
}
}


The variable prevclickhold can contain any value because it isn't initialized. The value it has depends on the system memory. It's even possible for this value to be true on the first PC, while it's false on the other.

In this case the code only works correct if the variable happens to be false at program startup, otherwise the message will never be shown.
edge wrote:Hi Nacho,

It seems like you're using some unitialized variables. For example, are you setting your class variables in the class constructor?


Ouch! Yes, you're right! I forgot to set m_bEnabled to true in CButton's constructor :oops:

Sorry for having bothered here at the forums, but since the desktop version worked fine I thought the code was correct.

Thanks again for all your help!

--Nacho
PointOfLight · 17 Jan 2008, 18:56 UTC
Glad you figured it out. Sorry I wasn't really any help. So what kind of game are you making?
It's a manager-style game, where the player plays the role of the Director of the space program. I cannot show any screenshot right now because it's all just (very) bad programmer art, but I'm planning to hire a pixel artist soon so hopefully I'll be able to show something in a few weeks.

--Nacho