Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Adding or removing an OIS device  (Read 923 times)

tgraupmann

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 43
    • View Profile
    • The Code Blog of Tag
Adding or removing an OIS device
« on: February 03, 2008, 04:44:50 PM »

Is there an OIS callback event that detects an addition or removal of a device?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: Adding or removing an OIS device
« Reply #1 on: February 04, 2008, 06:21:28 AM »

This was to implemented, as well as removal of a used device, and plugged back in. But so far, this has not been implemented.

Number one reason:
* DirectX does not have any callbacks for this (from what I've seen)
* Neither does the Linux Events (as far as I know)

This would mean OIS would have to constantly poll the OS for new devices.. Quite painful. However, there probably are some OS methods to monitor removal/inserting of new devices. A patch would be welcome, but this is a big addition and not something I will have time for for quite a while.

Though, the place I see where this is the biggest plus is on console systems. This is the main system where someone would plug/unplug devices a lot more. On a PC, it simply doesn't happen very often. And currently, there is no official platform port, so no implementation.
Logged

Jabberwocky

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 2
    • View Profile
Re: Adding or removing an OIS device
« Reply #2 on: June 03, 2011, 11:42:53 AM »

Quote
On a PC, it simply doesn't happen very often.

The main problem I run across is with a wireless gamepad controller (PC). 
This is what happens:
1.  I start my game.
2.  I realize my wireless gamepad has turned itself off (to preserve batteries)
3.  I hit the "turn on" button on my gamepad
4.  But it's already too late, because my game code has already initialized and the OIS query found no joysticks.

This isn't a critical bug, just a minor annoyance that might confuse some users.  Still, I thought I'd post in case anyone else has come across a solution for this.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: Adding or removing an OIS device
« Reply #3 on: June 05, 2011, 07:42:16 AM »

The solution on Windows is to hook into device changed (added/removed) events (may need to be a top most window, possibly keep one created but hidden). Then, you get the message in your window's win proc. and at that time you could get the VID/PID/hid info about the device and determine if it is something you want to handle (ie reenumerate).

On Linux, one would probably want to use libUdev and watch for event messages. I'm sure Mac has an equivalent method for detecting events.

Ideally this would/could be in OIS, but it is a pretty big patch to accomplish this.
Logged

Jabberwocky

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 2
    • View Profile
Re: Adding or removing an OIS device
« Reply #4 on: June 05, 2011, 09:29:24 PM »

Cool, thanks pjcast, I appreciate the pointer on how to tackle this.
Logged