how to input joystick in c++ to this code?

Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2006
Posts: 1
Reputation: denyildani is an unknown quantity at this point 
Solved Threads: 0
denyildani denyildani is offline Offline
Newbie Poster

how to input joystick in c++ to this code?

 
0
  #1
Dec 1st, 2006
Hi all,
I want to input joystick to my code,which is very simple smile.gif.I searched the net but find out that people use DirectInput , etc... but i want a very simple application, for example like when you pull right, a variable in the code changes from 0 to 10,whne you pull left another variable changes from 2 to 8, etc... I use VC++ v6.0, no .NET,no C# please. here i send a sample code I wrote in which i wanna input joystick for sometry. thank you everyone.

#include <time.h>
#include <iostream>

using namespace std;

void wait ( double seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLK_TCK ;
while (clock() < endwait) {}
}

int main()
{

double t;
double delt;
double delf;
double function;

cout<< "Derivative of the function : "<<endl;
cin>>delf ;
cout<< "Time deviation : "<<endl;
cin>>delt;

t=0.0;
function=0.0;

do {

function = function+ delf*delt ;

// here i want to add joystick reading here
// joy1= ....???
//joy2= .....???
// like : when i move left,it reads 5 for joy1, and when i move right it reads 3 for joy2, etc...
// moreover,it eould be superb if also i can read the value as how much i move joystick,
//for example, when i move it from center to left end,joy1 value increases from 0 to 8.
// PLEASE HELP //

wait (delt);
t=t+delt;
cout<<" Function is "<<function<<endl;
// modifed function with joystick input :
//function=

} while (t <= 40);
return 0;
}
Last edited by ~s.o.s~; Dec 1st, 2006 at 12:59 pm. Reason: A
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,462
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: how to input joystick in c++ to this code?

 
0
  #2
Dec 1st, 2006
C and C++ do not support joysticks or mice (mouses??) There is no simple solution and any solution must use os-specific api functions. DirectX, DirectDraw, etc are complicated and not for beginners. If you search google you might find a useful device driver for your program.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1
Reputation: nasgaillean is an unknown quantity at this point 
Solved Threads: 0
nasgaillean nasgaillean is offline Offline
Newbie Poster

Re: how to input joystick in c++ to this code?

 
0
  #3
Feb 18th, 2009
If you are using the microsoft development for vis c++ and are using windows; include the mmsystem.h and the library winmm.lib; both of which access the methods of the win32API for joysticks. The following link should give you more direction. http://msdn.microsoft.com/en-us/library/ms713447.aspx
If you are not using windows and vis c++ from microsoft, I'm don't have those answers yet. sorry.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 25
Reputation: MyRedz is an unknown quantity at this point 
Solved Threads: 0
MyRedz MyRedz is offline Offline
Light Poster

Re: how to input joystick in c++ to this code?

 
-1
  #4
Mar 25th, 2009
if u want joystick..
it's hard.
better stick to keyboard or mouse ones..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC