Topic : User Input Programming
Author : Yordan Gyurchev
Page : << Previous 3  
Go to page :


system control "Alt + Enter" to handle the toggle-fullscreen operation. And another control "Enter" for, let’s say, a jump action. With the current algorithm running both controls will signal a positive state but you probably do not want to activate the jump action every time the player switches between full screen and windowed mode. Solution: just clear the keys you have already checked. Wait, we said that we would probably want some keys shared among the different controls but clearing checked keys cancels this possibility. To fix that we should introduce an additional "clear" flag and if it is present on the current control we clear all key states associated with it.

Listing 6: Updating single control state and clearing keys if clear flag is set

if (control.flags&WJ_CTRLS_OPAND2)
  ...
if (control.flag&WJ_CTRLS_CLEAR)
  keys[control.key[0]] = keys[control.key[1]] =
    keys[control.key[2]] = keys[control.key[3]] = 0;


Debugging


Once you have implemented the user input you will come across some debugging problems. Imagine that there is a breakpoint, which returns the program flow to the debugger. Input devices are not unacquired properly and further execution is dubious. So what should we do?

One way is to use the remote debugging options!!! And this is the best way to debug the user input system. However it is much easier to debug locally and if you are after some errors which you know are not in your input system, I would recommend bypassing DirectInput during the debugging procedure. Remember that we have a routine (method) that tracks the message queue. There's the input information during debugging process.

Outcome

So I think I have outlined my idea. There is a lot of work out there in user input. I don’t pretend this is the way to do it. It just seems right to me.

Page : << Previous 3