Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Input


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 wisey   Members   -  Reputation: 135

Like
0Likes
Like

Posted 25 June 2012 - 02:29 PM

I’m trying to port some C#/xna code into vc++/direct. I’m struggling with keyboard and mouse input yet again. I hope you can offer some suggestions. I’m not going to write a test case because the problem pertains to how input is handled in WinAPI etc.

My problem is the way the C# code handles keyboard and mouse input. As you can see by the C# code below, KeyboardInput provides the functionality for handling key releases and mouse down, mouse up and mouse move.

http://ideone.com/TO4rl

It uses syntax like this:

MouseInput.MouseDown += new MouseClickHandler(MouseInput_MouseDown);

I’m not sure what’s happening with this code but I assume that when somebody clicks the Mouse Down then the MouseInput_MouseDown() function is being called.

If you compare this to how I’ve been laying it out in c++.

http://ideone.com/Cbjw5

http://ideone.com/VMGHd

As you can see, each down and up of a key or mouse button has its own bool. And then I’m performing logic depending on the state of these bools. But i’m finding that there is too many of them, and I never know where to reset the state of them. I’m posting the state of these bools from main here:

http://ideone.com/g3Q1B

My main issue is that my update method is going to become too cluttered. And using this method is very slow progress. One thing i’ve considered is separating out the triggering of each event into different methods but update is being called repeatedly and I only want certain functions to be called if a given set of conditions is met (if a key is pressed or released).

So where do you think i’m going wrong and how can I change it for the better. Oh, I realise that Logans XNA code has types for handling input (MouseInput and KeyboardInput). These are built into xna. I’m assuming it has overrides for the += but i’m reaching the limit of my understanding just saying that and have no idea what I’m doing.

So is there a library of code built into vc++/directx to help me handle this. Is there a lib I can install and use, or do I have to write something to handle this myself.

I’m kind of answering my own questions as I write this which is why it is good to post questions on forums. It helps you understand your own problem better.

--
Wisey

Sponsor:

#2 wisey   Members   -  Reputation: 135

Like
0Likes
Like

Posted 26 June 2012 - 10:03 AM

Somebody in irc said that there's no replies because this is a boring topic field. But i'm quite stuck with this problem. Please help. I understand that it might be my c++ skills that are lacking.

--
Wisey

#3 tomalak   Members   -  Reputation: 124

Like
0Likes
Like

Posted 27 June 2012 - 05:11 AM

Somebody in irc said that there's no replies because this is a boring topic field.


No, there are no replies because:

I’m not going to write a test case


And because:

I’m kind of answering my own questions as I write this which is why it is good to post questions on forums


is wrong. Write your questions out in a private area if you haven't finished working through the problem. Then post a specific, precise question relating only to what you still do not understand. People don't have spare time to donate for decoding your thought processes!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS