Suggestions (#3) - wminput/plugins/ir_ptr.c (#81) - Message List

wminput/plugins/ir_ptr.c
 unsolved

I've made some changes that in my opinion provide superior tracking.

Added definitions:

#define XY_SCALE 1.2 // Track the pointer 20% off screen

Modify wminput_info() to look like this:

struct wmplugin_info *wmplugin_info() {
	static unsigned char info_init = 0;
	if (!info_init) {
		info.button_count = 0;
		info.axis_count = 2;
		info.axis_info[0].name = "X";
		info.axis_info[0].type = WMPLUGIN_REL;
		info.axis_info[0].max  = CWIID_IR_X_MAX;
		info.axis_info[0].min  = 0;
		info.axis_info[0].fuzz = 10;  //adjust to preference
		info.axis_info[0].flat = 0;
		info.axis_info[1].name = "Y";
		info.axis_info[1].type = WMPLUGIN_REL;
		info.axis_info[1].max  = CWIID_IR_Y_MAX;
		info.axis_info[1].min  = 0;
		info.axis_info[1].fuzz = 10; //adjust to preference
		info.axis_info[1].flat = 0;
		info.param_count = 0;
		info_init = 1;
	}
	return &info;
}

Then modify wmplugin_exec.

Add to variables declaration:

int dx,dy;

Then change the actual tracking algorithm:

if ((src_index == -1) || !ir_mesg->src[src_index].valid) {
		data.axes[0].valid = data.axes[1].valid = 0;
	}
	else {
		data.axes[0].valid = data.axes[1].valid = 1;
		dx = ir_mesg->src[src_index].pos[CWIID_X];
		dy = ir_mesg->src[src_index].pos[CWIID_Y];
		data.axes[0].value = CWIID_IR_X_MAX - ((1-XY_SCALE)/2) * CWIID_IR_X_MAX - dx*XY_SCALE;
		data.axes[1].value = dy*XY_SCALE + ((1-XY_SCALE)/2) * CWIID_IR_Y_MAX;
	      }

Once this code has been modified, you must change the ir_ptr config file to:

Plugin.ir_ptr.X = ~ABS_X

Plugin.ir_ptr.Y = ~ABS_Y

(Edit: I believe that is what they are by default.)

And bang. Much better tracking. I use one IR source at the top of my screen for tracking. Thanks to the maker of ir_fps for some code snippets and a better understanding of what's going on.

  • Message #24350

    Could you post a patch so we can see what you're changing?

    • Message #24351

      I made a patch and attached it to ticket #60.

      • Message #24352

        Thank you, nickishappy. I actually have very little knowledge of C or coding in general and I don't know how to make a patch.

        • Message #24353

          I make a copy of trunk from svn, make my changes to the copy then do:

          diff -urpN ./trunk/ ./copy_of_trunk/ > name_of.patch
          

          to test a patch, I make a backup copy of trunk, then from it's parent directory do:

          patch -p0 -u --verbose < name_of.patch
          

          This automatically applys the patch to the trunk directory.

          Hope that helps

Attachments

No attachments created.