OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Problem with processing keystokes


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
verybigbadboy
User


Joined: 15 Jun 2010
Posts: 28

PostPosted: Fri Jan 21, 2011 11:20 am    Post subject:
Problem with processing keystokes
Reply with quote

Hi,

I have a problem with processing keystokes in osg-viewer window.

I would like to tell about this problem and propound resolution.

First i need to explain what is problem i have:

Assume that you want process ASDW keydown like as in Counter-Strike and F to flash light.

that you need to do?
you need to create something like

Code:
case osgGA::GUIEventAdapter::KEYDOWN:
  switch(ea.getKey())
  {
    case 'w':
    // go forward
    break;
    ...
  }


It will work until you need to add crouch.

let's see what will be in this case:

after key is pressed there is message recieved
Code:
case WM_KEYDOWN    :
case WM_SYSKEYDOWN :


their handlers do the following:

adaptKey(wParam, lParam, keySymbol, modifierMask);
1. getting a virtual key code
2. converting virtual key code to symbol code

then there is a call of
Code:
getEventQueue()->keyPress(keySymbol, eventTime);

with GUIEventAdapter created inside it, what contain keySymbol


i.e. now to turn flashlight we have to do steps below:

Code:
case osgGA::GUIEventAdapter::KEYDOWN:
  switch(ea.getKey())
  {
    case 'F':
    case 'f':
    case 'f'-0x40 :  // for processing with CTRL
    // do something
  }


as we don't know whick key is pressed by user, we have to include all possibilities:

I suggest using virtual keys codes both with current key handles, as the following:
Code:
   adaptKey(wParam, lParam, keySymbol, modifierMask, virtualKey);
   ...
   getEventQueue()->keyPress(keySymbol, virtualKey eventTime);

What do you think about it?
Thank you!

Cheers,
Alexander
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 8580

PostPosted: Mon Jan 24, 2011 4:48 pm    Post subject:
Problem with processing keystokes
Reply with quote

Hi Alexander,

I'm afraid I'm not familiar with Win32 API for keyboard bindings so
I've to dive into the GraphicsWindowWin32.cpp to understand your
suggestion about passing a "VirtualKey". From reading the code it
looks to me like the VirtualKey is Win32 specific which would mean the
client code would also need to be platform specific so an ideal
candidate for integration.

Quote:
From what I can make of the functionality you are after what you are
after is an unmodified key, i.e. no shift/no control key modification
- just the raw key code.

Reviewing the GraphicsWindowWin32::adaptKey(..) method the lines of code:

else if ((keySymbol & 0xff00)==0)
{
char asciiKey[2];
int numChars = ::ToAscii(wParam, (lParam>>16)&0xff, keyState,
reinterpret_cast<WORD*>(asciiKey), 0);
if (numChars>0) keySymbol = asciiKey[0];
}

Look to me to be the ones that are likely to be applying the key
modification. If this is correct then passing the modifying keySymbol
as well as the modified keySymbol should be sufficient. This would
still require osgGA::GUIEventAdatper to have a new
getRawKey()/getUnmodifiedKey() field and osgViewer to be tweaked to
set this new field, but I open to this.

Thoughts?
Robert.


On Fri, Jan 21, 2011 at 11:20 AM, Alexander Sinditskiy
<> wrote:
Quote:
Hi,

I have a problem with  processing keystokes in osg-viewer window.

I would like to tell about this problem and propound resolution.

First i need to explain what is problem i have:

Assume that you want process ASDW keydown like as in Counter-Strike and F to flash light.

that you need to do?
you need to create something like


Code:
case osgGA::GUIEventAdapter::KEYDOWN:
 switch(ea.getKey())
 {
   case 'w':
   // go forward
   break;
   ...
 }



It will work until you need to add crouch.

let's see what will be in this case:

after key is pressed there is message recieved

Code:
case WM_KEYDOWN    :
case WM_SYSKEYDOWN :



their handlers do the following:

 adaptKey(wParam, lParam, keySymbol, modifierMask);
  1. getting a virtual key code
  2. converting virtual key code to symbol code

 then there is a call of

Code:
getEventQueue()->keyPress(keySymbol, eventTime);


 with GUIEventAdapter created inside it, what contain keySymbol


i.e. now to turn flashlight we have to do steps below:


Code:
case osgGA::GUIEventAdapter::KEYDOWN:
 switch(ea.getKey())
 {
   case 'F':
   case 'f':
   case 'f'-0x40 :  // for processing with CTRL
   // do something
 }



as we don't know whick key is pressed by user, we have to include all possibilities:

I suggest using virtual keys codes both with current key handles, as the following:

Code:
  adaptKey(wParam, lParam, keySymbol, modifierMask, virtualKey);
  ...
  getEventQueue()->keyPress(keySymbol, virtualKey eventTime);



What do you think about it?
Thank you!

Cheers,
Alexander

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35850#35850









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
verybigbadboy
User


Joined: 15 Jun 2010
Posts: 28

PostPosted: Thu Jan 27, 2011 12:06 am    Post subject:
Reply with quote

Hello Robert,

I created topic in submission
http://forum.openscenegraph.org/viewtopic.php?t=7631
please look it.

Thank you!

Cheers,
Alexander
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts [SOLVED] Problem with version 3.2.1 a... Andrés Build system [build] 2 Mon Sep 22, 2014 12:56 pm View latest post
No new posts OSG MFC Debug Memory leak detection p... Hyunsoo General 0 Wed Sep 17, 2014 8:22 am View latest post
No new posts OSG MFC problem natalie_estevez80 General 3 Wed Sep 17, 2014 7:18 am View latest post
No new posts iOS: flickering problem when changing... a.terenzi General 0 Sun Aug 31, 2014 1:43 pm View latest post
No new posts OSG Linker Problem and 13.10 raider General 3 Sun Aug 10, 2014 5:50 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP