Hello, I've just started using DarkGDK, i've made an basic input class, maybe it'll be useful to somebody.
class inputClass{
public:
//returns whether the the mouse was left clicked last loop
bool lastClick;
//value of mouseclick
int mouseClick;
//mouse coordinates
int mouseX;
int mouseY;
//coordinates of last left click
int cMouseX;
int cMouseY;
//is the left mouse button being dragged
bool dragging;
// if the left mouse button is held
bool held;
//required for the 'wasDragged()' function
bool sdragging;
//mousemove x,y,z
int mmz;
int mmy;
int mmx;
//function to see if the mouse has just stopped being dragged
bool wasDragged(){
if( sdragging == 1 ){
return 1;
sdragging = 0;
}else{
return 0;
};
};
//update input, call this at the end of each loop
void update(){
if( sdragging == 1 ){
sdragging = 0;
};
mouseClick = dbMouseClick();
if( mouseClick == 1 ){
if( lastClick ==1 ){
held = 1;
}else{
held = 0;
cMouseX = dbMouseX();
cMouseY = dbMouseY();
};
lastClick = 1;
}else{
lastClick = 0;
held = 0;
};
if( held == 1 ){
if( ( dbMouseX() != cMouseX )|| (dbMouseY() != cMouseY ) ) {
dragging = 1;
}else{
dragging = 0;
};
}else{
if( dragging == 1){
dragging = 0;
sdragging = 1;
};
};
mouseX = dbMouseX();
mouseY = dbMouseY();
mmz = dbMouseMoveZ();
mmy = dbMouseMoveY();
mmx = dbMouseMoveY();
};
};