Now I was able to decipher a lot of very sloppy code and decided to rewrite the project to be cleaner (to which everyone exclaimed excitedly "do that!")
I got part way through though and there's some code that doesn't make sense to me and the person who wrote it is gone so I can't ask them questions about it (and from what I've seen of their code they may not be able to answer it anyway... cuz they're not a programmer they're a scientist)
So I've got a project that displays an object and on button presses or mouse clicks (depending on what's being done) the object will rotate or move around the screen...
So I go scanning for how those events are handled and I find the following code is in place to interpret these things...
void input(w, data, call)
Widget w;
caddr_t data;
XmDrawingAreaCallbackStruct *call;
{
XEvent *event = call->event;
XButtonEvent *xbutton = (XButtonEvent *)event;
XKeyEvent *xkey = (XKeyEvent *) event;
XMotionEvent *move = (XMotionEvent *) event;
if (event->type == ButtonPress){
if (xbutton->button == Button1){
pressed =1;
oldx = xbutton->x-oldx;
oldy = xbutton->y-oldy;
return;
}
}
/* from there on out until input closes it's more code that is either variations on what I've just posted or code I understand but for your sanity and mine let me leave that out for the moment*/
I don't understand what any of that means pretty much so I was going to keep that intact and assume the guy at least kind of knew what he was doing...
So that looks something like a function call (and since I don't really know C or how C handles events or things like that I'm praying it functions anything like a function would) and then I scour the code for something that calls it and the only reference to input in all the code is a line way down in main...
XtAddCallback(box, XminputCallBack, input, NULL);
now I've never seen anything like this before ever but since it's the only reference to input which I should mention contains like a fourth of code for the project
So my question is this
Is this what calls 'input' or do I need to go back and keep searching?
If this is what calls it, is there a way I could... I don't know... pass it a series of data that I was kind of hoping to initialize in main and wouldn't be accessible by it? Maybe a structure which I learned about in my other thread and realized that there were other good places where I could use it in my code to make things significantly easier on myself...
Is this even the best way to do it? Or should I just leave it alone and thank the coding gods it works because I don't know anything about it?

New Topic/Question
Reply




MultiQuote






|