Adding analog function to xbox 360 triggers

Talk about anything concerning the source code.
Post Reply
Fish
Posts: 2
Joined: Thu Aug 15, 2013 4:45 pm

Adding analog function to xbox 360 triggers

Post by Fish »

Hi Matlo,

First off, I've got to thank you for GIMX, it's incredible! I know the xbox 360 support is only experimental, but I've found that almost everything works flawlessly. Even though nothing is better than a mouse and keyboard for playing a shooter, there's still certain games where I prefer a controller, so I've been trying to add analog function to the triggers. I don't have much coding experience, but after a little experimentation (and a whole lot of googling), I think I may be close...

I changed this portion of report.c:

Code: Select all

  
  if (state[0].user.axis[sa_l2])
  {
    report->ltrigger = 0xFF;
  }
  if (state[0].user.axis[sa_r2])
  {
    report->rtrigger = 0xFF;
  }
into this:

Code: Select all

  axis_value = state[0].user.axis[sa_l2];
  report->ltrigger = clamp(0, axis_value, 255);

  axis_value = state[0].user.axis[sa_r2];
  report->rtrigger = clamp(0, axis_value, 255);
And it worked!.... sort of :lol: I'm getting analog function, but the range is only 0 - 131, instead of 0 - 255. Also, the triggers needed to be pressed in halfway before it would register, but I fixed this within jstest calibration by removing the negative side of the axis ( 0 to 32767, instead of -32767 to 32767). However, within the emuclient L2/R2 still seem to be capped at 131.

If I check "Raw Events" within calibration, jstest reports the trigger axes as 0 - 255, but I'm not quite sure how to set the state of L2 and R2 in GIMX to these raw event values, if that makes any sense. When I use raw events in jstest, gimx reports L2 / R2 as 1 when the triggers are fully pressed.

I'm not asking for a gift wrapped solution or anything, I know your time is limited and I'm already very grateful for this software, but if you have any ideas of where I may be going wrong, and could point me in the right direction, I would really, really appreciate it!

Thanks a lot,
Fish
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Adding analog function to xbox 360 triggers

Post by Matlo »

GIMX creator
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Adding analog function to xbox 360 triggers

Post by Matlo »

I believe your changes are correct.

Did you try to modify the sensitivity?
What calibration parameters are you using? Sensitivity, acceleration, dead zone?
GIMX creator
Fish
Posts: 2
Joined: Thu Aug 15, 2013 4:45 pm

Re: Adding analog function to xbox 360 triggers

Post by Fish »

The sensitivity! How did I forget all about the sensitivity!

I feel so foolish! 0.004 seemed to give perfect 1:1 translation on the sticks, so I set the triggers to the same value and never gave it a second thought. After doubling that to 0.008, I'm finally getting that beautiful 8-bit precision on my triggers :D Thanks so much Matlo!!! Time to go play!
Post Reply