Page 1 of 1

[VB.NET] Windows 8 Sensors

Posted: Wed Jul 16, 2014 10:45 pm
by comathi
A while back I had to make an end of year project for my IT class and I chose to make a (somewhat believable) clone of the popular mobile game Temple Run. Since we could use Windows tablets instead of the desktop if we wanted, I decided to challenge myself further and use the available sensors on the tablet to control part of the game.

Trouble is, though, that we were using Xojo (formerly known as REALbasic) to develop our applications. It's great and all, but it does not by default support the Windows 8 sensors. VB.NET, on the other hand, does, and Xojo allows you to import DLLs written in another language and use their functions.

So I developped a DLL with a few functions that interface with the different sensors available on a Windows tablet (accelerometer, compas, gyrometer, inclinometer and light sensor). Each function returns a String, but you could easily modify them to return any type of data you wish... I chose String because it worked best with Xojo.

Anyway, I thought I might post the source here, in case you too need these functions outside of a .NET language. Enjoy ;)

Re: [VB.NET] Windows 8 Sensors

Posted: Wed Jul 16, 2014 11:22 pm
by smashapps
I don't have a use for this since I don't use a tablet that this is really cool. Did it take you long?

#Birthday

Re: [VB.NET] Windows 8 Sensors

Posted: Thu Jul 17, 2014 6:22 am
by Dummy1912
wow cool
thanks for sharing never knew this was even possible in vb ;)

can this even used without having win8?

#Birthday

Re: [VB.NET] Windows 8 Sensors

Posted: Thu Jul 17, 2014 7:11 am
by comathi
#smashapps,

The research was the longest part lol. I probably spent close to three weeks looking for ways to use external code in Xojo. Once I found out how, it was very easy to write the DLL, since Microsoft has very good documentation on the subject :)

#Dummy1912,

Unfortunately, this DLL can only be used on Windows 8 because it references system DLLs that are only present in Windows 8.

If you try to use the DLL on something other than Windows 8, it might throw an exception, so you'd better make your program check the Windows version before calling functions.

Thanks guys :)

#Birthday

Re: [VB.NET] Windows 8 Sensors

Posted: Thu Jul 17, 2014 5:15 pm
by Shim
Can you post examples? please

Re: [VB.NET] Windows 8 Sensors

Posted: Thu Jul 17, 2014 5:28 pm
by comathi
Sure! What exactly do you want examples of, though? :lol:

Re: [VB.NET] Windows 8 Sensors

Posted: Fri Jul 18, 2014 5:57 pm
by Shim
usage of the DLL

Re: [VB.NET] Windows 8 Sensors

Posted: Fri Jul 18, 2014 7:24 pm
by comathi
Well that would depend what you're using it in... The DLL is made to be used outside of .NET langugaes, obviously, because .NET already supports the functions available in the DLL.

So say, for example, that you're using Xojo, all you would have to do is import the DLL and reference one of the functions it contains, then you'll be able to call it anywhere in your program.

If you mean how to use the functions, that's all detailled in the source code.