Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Pages: [1] 2 3

Author Topic: Possible WiiMote support  (Read 10075 times)

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« on: December 29, 2006, 03:05:27 PM »

Thanks to Walaber's work in getting Wii-Mote working with his game, I have been made aware of some HID code to interface with the controller on the PC (only Win32 - I imagine, evetually, the Wii-Mote will get a proper linux driver and will show up as a joystick anyway). I will be looking into integrating this into OIS as soon as I get some more time on my hands.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Possible WiiMote support
« Reply #1 on: December 29, 2006, 03:45:23 PM »

That would be cool.  Last I checked the open-source drivers for it though did not support pointing, has that been fixed yet?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #2 on: December 29, 2006, 05:15:05 PM »

I'm not too familar (yet) with the WiiMote; however, I think the pointing uses the IR thingy-ma-gigger :) and there is initial support for IR in those HID drivers.. though, he states there are some issues.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Possible WiiMote support
« Reply #3 on: December 29, 2006, 05:38:45 PM »

Still sounds like it is much further along then the last time I saw the drivers about two weeks ago. Nice...
Logged

vectrex

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 33
    • View Profile
    • http://www.kartsim.com
Possible WiiMote support
« Reply #4 on: December 29, 2006, 06:46:53 PM »

this is great news, I was just looking at his code yesterday and it looks good

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #5 on: December 31, 2006, 02:07:17 PM »

I'm adding an abstract factory object class, that users can now register to allow supprting custom types. This will also help add in WiiMote support so that it appears as a regular joystick. Of course, now, I am also adding a createInputObject method to take the vendor name to allow you to try to specify something like createInputObject("WiiMote", OISJoyStick, true);

This will also allow you to create custom keyboard/mice factories in the long run. Say, for instance you want to support multiple mice.. Well, DirectInput only allows you to create one mouse, using a custom factory for mice, with a vendor name of your chosing to create the mouse, you could have your own factory using Window's messages (raw input) to handle multiple mice. Or, if you wanted to simulate something like a keyboard from a text file (for demo purposes), your custom keyboard factory could load in a text file, and create keyboard events through your own keyboard object.

Anyway, this should make the usage of custom devices easier. Got a lot of work to do, as this is a prety big refactoring of some creation code.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Possible WiiMote support
« Reply #6 on: December 31, 2006, 05:57:52 PM »

Very cool.  I definitally see nice uses with that.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #7 on: January 01, 2007, 12:24:01 PM »

Quote from: "OvermindDL1"
Very cool.  I definitally see nice uses with that.


One thing that I've been looking into a bit today, is PC remote controls. Using http://www.lirc.org/ for Linux or http://winlirc.sourceforge.net/ for Windows - I believe they have the same TCP/IP interface, OIS could also support remote controls :) Would be cool for media player type applications, or other unique PC applications.

But, your right, the uses of supporting custom controls via a plugin/factory type system are pretty cool. Of course, I will leave the ability to remove such features from OIS builds (in Linux, by use of configure switches or in Windows by header defines).
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #8 on: January 01, 2007, 07:15:04 PM »

From a brief search, I have found a couple lib's for interfacing with the WiiMote (both making use of Win32's HID interface):

#1 http://simulatedcomicproduct.com/2006/12/cwiimote-02.php
One Walaber used. Has rudimentary support for Nunchucks & IR support. Seems to only support a polling device readings. Supports vibration & led setting.

#2 http://digitalretrograde.com/projects/wiim/
Seems to support both polling & event driven reporting. Also supports setting LED statuses.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #9 on: January 12, 2007, 05:47:15 PM »

Ok, I have WiiMote now :D

So far, I have managed to get the WiiMote connected to my PC and create the device with OIS (connect to it and receive button/axis data).

Now, I'm currently contemplating how best to present Wii values to the user. I currently havethe WiiMote as a joystick, which would allow me to present to values as buttons and axes (-32k to +32k). However, I'm not sure if converting the values the wii mote gives to axis values would really do the control justice. So, I may make a seperate device type entirely for the Wii to use - so there would be Mouse, Keyboard, JoyStick, and some other device (not sure of a name yet) that handles orientations (such as the vector values Wiimote gives)...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #10 on: January 12, 2007, 09:05:55 PM »

Well, I've run into the first major issue... I havn't managed to find any information yet (and I'm not positive if it is a local thing, my bluetooth adapter, or a Window's DirectInput thing). Anyway... the problem lies in the fact that, once the WiiMote is attached to OIS (and only when the "Bluetooth Human Interface Device Service" is started, and another joystick is attached and created with OIS). When it comes time to shutdown OIS, it seems the joystick (not the mouse or keyboard) crashes on the call to Release(). Again, this only happens when the HID Service is enabled...

Although, this could be just my joystick, as I am not using a normal joystick, but am using the open source XBCD drivers for a modified Xbox controller. Perhaps it is not interacting nicely with other HID devices :/ I am leaning towards this, as mouse and keyboard Release() normally. Anyway, needs more research and testing... And, would be nice if anyone else with a regular joystick & Wii could test this too.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #11 on: January 12, 2007, 09:47:00 PM »

Actually, for the first issue, instead of a whole new class... I am adding a new component type (Vector3). And, JoyStick will just maintain a list of these. So, the Wiimote can still be a joystick, it just has no axes or POVs. But, will have a vector3, buttons, and I will make the arrow keys report as a HAT/POV type control :)
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #12 on: January 12, 2007, 11:29:46 PM »

Ok, making some more progress.. so might as well blog about it here:

I have all buttons working now. They update their status and fire off events if in buffered mode with a listener. WiiMote buttons go from 0-7 in OIS now.

Also, I converted the WiiMote arrow key buttons into a HAT/POV value (since, that is what it technically is). So, JoyStickState.mPOV[0] of the WiiMote joystick will have the values of that component.

I think (besides chucks, IR, rumble, & speaker) the only thing left to get in is really just motion sensing. I think OIS will do nothing to mess with the values, just give you what I get. The values are roughly a Unit vector (but not quite... the length is sometimes a bit longer than 1.. however, I don't think it matters for an app if the value is a normalised vector or not as far as usefullness goes). The only thing, is that the values of the remote flutuate quite a bit (even when at rest).. I may have to allow the app to provide a small deadzone type value for the Vector3 component. The value would be in percentage of deviation... so, OIS would not generate an event if the change was less than (say) 2%.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #13 on: January 13, 2007, 10:18:56 AM »

I think I've come to the conclusion that I will need to implement threads for WiiMote support (to elimiate potential lag due to blocking read calls). And, since I think that 1 thread per WiiMote sounds like too much, I think there will be one thread to handle all WiiMotes currently created.

Also, each OISWiiMote will use a lockless (fixed size) ring buffer storing position/button reports. To help reduce the buffer getting filled up really quickly with non-events (small twitchy wiimote orientation changes), there will be an angle cutoff where value changes will be ignored.

To implement threads, I normally use ptypes. However, since ptypes has fallen out of development... and since boost is eventually going to be part of the C++ standard, I might as well concede now and start using it ;) So, I will use boost::threads, which fits, because I was planning on using boost::asio for networking support too (LIRC/WinIRC).
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Possible WiiMote support
« Reply #14 on: January 13, 2007, 03:38:49 PM »

Ok, I am having a heck of a time trying to figure out how to bind a member function pointer to boost::thread :?

It seems function0 can only handle static methods that take no parameters... In Ogre, I see that the use of the mothod uses one of the getSingletonPtrs() to get a hold of the class instance from the static member.. but, I don't want to create a singleton, I want to either pass in a value to a static method, or have a member function pointer... Anyone have any ideas or code? You would think that this would be a primary neccessity with using a C++ thread library :(
Logged
Pages: [1] 2 3