Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Mar 26, 2017 12:03 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Using GameInputManager
PostPosted: Fri Jul 27, 2007 8:47 am 
Offline

Joined: Fri Sep 30, 2005 11:31 am
Posts: 205
Location: Helsinki, Finland
I've been looking for a generic method to hook special USB keyboards and other controllers to my app and finally ended up playing with the GameInputManager. I just a search on the forum with that word and got only 4 threads as result. Either this means nobody has ever had any problems with the class or that very few people actually uses it. Somehow the latter sounds more probable, especially since the examples in LR are a tad vague.

Anyway, my problem is simple: how do I get an event out of any element in a device I know by name? I was surprised how complicated this was since one could assume that a game input device would be just like any other control and provide events in the same way. The best solution I got so far was to create a class, make that a thread, create event interfaces as 'action' and 'connected' and then put the following code in the run handler:

dim i as integer

if mManager=nil then
mManager=New GameInputManager
end

//look for device that identifies itself as name xkeys that can have up to 88 keys

for i=0 to mManager.DeviceCount-1
if mManager.device(i).name="xkeys" then
DeviceIndex=i
end
next

Do

if mManager.Device(DeviceIndex).Connected then

connected(true)

for i=0 to 87

if mManager.device(DeviceIndex).Element(i).Value=1 and PreviousValue(i)=0 then
PreviousValue(i)=1
action(i)

end
if mManager.device(DeviceIndex).Element(i).Value=0 and PreviousValue(i)=1 then
PreviousValue(i)=0

end

next

else

connected(false)

end

Loop Until Window1=nil


There has to be an easier way to get notified if a user hits certain element than browsing through all the devices and elements in an continuous loop.


EDIT: I'm not sure if this would be the only solution but I added a feature request to add a couple of events in the GameInputManager to make it more like a control. If you agree, add this in your watch list:
http://www.realsoftware.com/feedback/vi ... d=raknenrt


Top
 Profile  
 
 Post subject: Re: Using GameInputManager
PostPosted: Tue Aug 14, 2012 11:54 am 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
It's a very old post i know.

There seems to be no more example other than the documentation explains.
But maybe there is somebody who knows how to bring event based button/value capture to the GameInputElement.value.

I hope someone can help, as it seems i can only "poll" the value over and over again to get a recent value.
If anyone has a better option or some other way i would apreciate to hear it.

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
 
 Post subject: Re: Using GameInputManager
PostPosted: Fri Aug 17, 2012 3:17 am 
Offline

Joined: Fri Sep 30, 2005 11:19 am
Posts: 275
Hmm... I briefly remember using the GameInputManager ages ago, and yes - polling was my solution then. Back then I mostly used polling rathern than events when it comes to game input control (even keyboard and mouse) because you'd generally get much better results.

But I don't see how one couldn't create a special class, containg GameInputElemtents and Events for them or what not, and a loop checking their Value and raising the right Event.

_________________
"If you look carefully at my lips, you'll realize that I'm actually saying something else."
Brainswitch Machina - REALStudio/REALbasic
RBScriptExtender - give RBScript power to work with any class


Top
 Profile  
 
 Post subject: Re: Using GameInputManager
PostPosted: Fri Aug 17, 2012 9:10 am 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
Agent wrote:
Hmm... I briefly remember using the GameInputManager ages ago, and yes - polling was my solution then. Back then I mostly used polling rathern than events when it comes to game input control (even keyboard and mouse) because you'd generally get much better results.

But I don't see how one couldn't create a special class, containg GameInputElemtents and Events for them or what not, and a loop checking their Value and raising the right Event.


Thanks agent,

I think i would need to use polling and a timer..
Event-based is much better for me but still i'll try it..

Thanks for the info.

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
 
 Post subject: Re: Using GameInputManager
PostPosted: Sat Aug 25, 2012 4:08 am 
Offline

Joined: Fri Sep 30, 2005 11:31 am
Posts: 205
Location: Helsinki, Finland
I ended up the USB Plugin that is part of the MBSPlugins on that product. Still wasn't able to get rid of polling and making it cross-platform was a bit of challenge but it worked. The issue behind all this has probably something to do with USB being very different than serial connection where it was easier to notify when data was flowing in.

_________________
==========================
OSX 10.6.8 with REAL Studio 2011rel4.3
OSX 10.8.1 with REAL Studio 2011rel4.3
W7N 64 bit with REAL Studio 2011rel4.3
MBS, Einhugur, Elfdata plugins
Database servers: DB2, MySQL, PostgreSQL


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group