KeyCodes

This topic contains 5 replies, has 5 voices, and was last updated by  Gordon 8 years, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #29538

    Hi there again,

    I am now trying to access the numeric keypad to make the game do some stuff.
    I’ve found the PVRShellKeyName enumerator, but it only includes the action keys (action 1, action2, screenshot, select, up, down, left, right…)
    Is there a way to detect the keypress on a number similar to PVRShellIsKeyPressed(PVRShellKeyNameSELECT), for example?

    Thanks!

    #32168

    Xmas
    Member

    Hi,

    PVRShell is meant to be a minimal platform abstraction layer, so we included only a small number of keys that would likely be present on most devices. It should be easy to extend the system to your needs though, by modifying the platform-specific PVRShellOS.cpp in the ShellOS<your OS> folder.

    #32169

    vezza
    Member

    Hi there,
    related to this topic, I have a question about how the keys are handled. I am implementing a simple motion model to navigate in 3D that uses keys to move. I wanted to do some smooth transitions (so to accelerate gradually when the user starts a motion) but I’m having serious troubles. To do that of course I need to interpolate over a few frames to accelerate from zero to my target speed. But that assumes that I can check if the same key is still pressed.
    Now, it looks like I can only get one “key pressed” message at the beginning, than if I read again (with “PVRShellIsKeyPressed”) at the next frame it returns the Null value, as if no key was pressed. This is probably due to the fact that the SDK is checking if a key was pressed at the previous frame, not if it was already pressed…
    Did I get it right? I yes, is there any plan to add support for this?

    Note that for example the Windows emulator traps “WM_KEYDOWN” messages. That message holds the info about the previous state of the key, so the information could be wrapped in the SDK (but I have no idea if and how this is also available in Symbian).
    Tthanks,

       Luca

    #32170

    Gordon
    Moderator

    PVRShell only stores the last key that was pressed and only if that key is from the small selection that is supported. When you call PVRShellIsKeyPressed on a key and it returns true then that stored key value is cleared and will not be set until a key is again pressed. This means that when you try to check for your key in the next frame PVRShell will return false. The key only gets set again when it is pressed again (or the OS automatically keyrepeats e.g. on Windows).

    If you’re on a platform that receives keyup and keydown events it’s pretty easy to alter the shell to give you constant input. I did it using a bit field where each key had a bit set and could be masked out to check if it was pressed. A keydown event meant set the bit for that key, keyup meant clear it.

    If you are working on a platform that provides this kind of keyup/keydown interface I would recommend that you use this as it allows for smooth input and multiple simultaneous keypresses, for instance (I doubt it’s the most optimal solution nevertheless).

    Unfortunately, this is beyond the scope of our SDK for, as Xmas says, PVRShell is a minimal abstraction layer that has to cover a lot of different platforms. Getting keyup and keydown events on some of these is non-trivial or impossible which is why it’s not been implemented this way.

    In the PODPlayer I simulate smooth input for moving the free camera by giving the camera a position and a velocity. When I receive a key press to move forward I accelerate the camera by adding a vetor in the current direction to its velocity (and check the velocity against a maximum IIRC). If no key is pressed then the velocity decays (by division I think) to a smooth stop. The result is not perfect; for instance it doesn’t deal with multiple keys at all.

    Aside from experimenting with the code, I would suggest you refer to a specific Symbian forum for more help (if this is indeed your platform). If you’re unsure about something in the PVRShell source files we’ll try to answer your questions, though.

    #32171

    JTEngel21
    Member

    Is there a way to read in mouse clicks from the left and right mouse buttons?  Is that done through the Remote Control section of PVRShellOS.cpp?

    #32172

    Gordon
    Moderator

    Which platform are you interested in (I’m not aware of a Symbian device with a mouse atm)? This functionality is already part of the WindowsPC PVRShell – search for prefButtonState and prefPointerLocation in PVRShell.h for more information.

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.