How to tell which player chose a device?

Nov 10, 2009 at 8:43 PM

So here is a particular situation that I'm very puzzled over.  Its a special case of a player choosing the MU, then pulling it again right away.  So imagine this situation:

1) Player starts the game with any controller, lets say its controller 2.

2) The storage device selector appears.  Note the storage device selector responds to any controller.

3) A storage device is chosen, lets say the MU is chosen with controller 2.  This triggers the event DeviceSelected, but notice this event uses the default EventArgs parameter and so there is no PlayerIndex information involved.

4) The player then immediately pulls the MU out before the normal game has received any input.  Let's say that we want the player to be prompted to decide what to do when this happens.  The DeviceDisconnected event is triggered (as nicely explained by SimReality), passing us a PlayerIndex that we can use to specify what player to prompt when the dialog appears saying "what do you want to do".

5) Now the tricky bit - what player index do we pass back to EasyStorage in our handler for the DeviceDisconnected event?  No controller has pressed anything that our game code has been able to respond to, yet the popup that will appear next demands a specific PlayerIndex.  If I dont fill something in then EasyStorage will use its default of PlayerOne, but its controller two that is doing the controlling!  I could just ignore the event completely I guess, but I wonder is there a neater way to solve this?

In short then - how can I tell from the DeviceSelected event what player index it was that chose the device?  Its that player that I need to prompt to ask what to do next.

 

Coordinator
Nov 10, 2009 at 8:50 PM

That's up to you to decide. What I would do is tweak your flow to something more like this:

1) Game is on Press Start screen.
2) Controller 2 presses start. Record that PlayerIndex.Two is the primary controller.
3) MU is chosen with any controller (doesn't matter which since it's a shared device).
4) MU is pulled, event fires, and since controller 2 pressed start on the Press Start screen, you pass that index to the event handler to tell it who to prompt.

The ultimate thing is that the device selector, for a shared device like that, doesn't say who picked it because, to the storage system, it doesn't matter since it's a shared StorageDevice. So it's up to your game to keep track of who to prompt. A good way is the Press Start screen (which you can also use to know which controller can control the main menu), but it's totally up to you.

Nov 10, 2009 at 10:05 PM

Thanks for the swift response SimReality, this is starting to make sense now :)