Made a Joystick/Mouse patch to improve control

Make suggestions for improving one of the best games on the net!
Post Reply
User avatar
Workaphobia
Master Sergeant
Master Sergeant
Posts: 252
Joined: Wed May 26, 2004 7:29 pm

Made a Joystick/Mouse patch to improve control

Post by Workaphobia » Sat Dec 17, 2005 10:00 pm

For those players who compile from source, and/or the devs ;) ...

I just resumed my first attempt at modding from a while ago. I don't even think I can call it a mod since it's just a dozen extra lines of code.

Anyway, it:
  • allows 12 joystick buttons instead of the previous hard coded limit of 10
  • fixes a bug in the way speed and rotation from mouse input is calculated, so that the edges of the mouse box are the actual limits of your tank's movement. Without this adjustment, you don't reach full speed until you go *slightly* beyond the line.
  • makes it so that when backing up with the mouse, you reach full reverse at the bottom line, instead of half way to the bottom like before. This may be hard for players to adjust to - I wouldn't know since I don't play with the mouse. It's rather easy to remove this part though.
  • separates the movement code for the joystick and the mouse. When I looked at how BZ currently handles joystick input, I was pretty surprised. For some reason, joy input is roughly converted to mouse coordinates before being analyzed, which results in wasting about half of the analog stick's input range. Dividing it has given me a much greater degree of control. Also, the slow keyboard and binocular buttons (which you can map to joystick buttons of course) now affect joystick movement by reducing your speed and/or angular speed.
I know, most people probably think this is minor, but it makes a heck of a lot of difference in the battle field for me.
Attachments
ControlImprovements.txt
Hope this is in the right format...
(3.92 KiB) Downloaded 75 times
"Nifty News Fifty: When news breaks, we give you the pieces."

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5173
Joined: Fri Dec 13, 2002 4:11 am
Location: https://discord.gg/NN9uAvx
Contact:

Post by JeffM » Sat Dec 17, 2005 10:27 pm

moved to enhancments

User avatar
Skeeve
Private First Class
Private First Class
Posts: 122
Joined: Sun Jun 04, 2006 3:27 pm
Location: Near Aix La Chappel

Post by Skeeve » Tue Jul 11, 2006 2:27 pm

I like that one!

I also made an enhancement to use both analog joysticks my gamepad has. The one that is configured works with your enhancements.

The other one gets precedence when it's used but is reduced to half the speed.

in SDLJoystick.cxx:

Code: Select all

void			SDLJoystick::getJoy(int& x, int& y)
  x = y = 0;

  if (!joystickID)
    return;

  int x2, y2;
  x2= y2= 0;
  
  SDL_JoystickUpdate();
  x = SDL_JoystickGetAxis(joystickID, xAxis);
  y = SDL_JoystickGetAxis(joystickID, yAxis);
  // Get the other Axes ( xor 2 will be the same direction but the other stick)
  x2 = SDL_JoystickGetAxis(joystickID, xAxis ^ 2);
  y2 = SDL_JoystickGetAxis(joystickID, yAxis ^ 2);
  // check the other stick
  if (abs(x2) > 200) {
	  x= (x2 - ( x2>0 ? 200 : -200) );
	  x2= 2;
  }
  else {
	  x2= 1;
  }
  if (abs(y2) > 200) {
	  y= (y2 - ( y2>0 ? 200 : -200) );
	  y2= 2;
  }
  else {
	  y2= 1;
  }

  // this is unchanged
  x = x * 1000 / 32768;
  y = y * 1000 / 32768;

  // ballistic
  // Added the quotient x2 and y2
  x = (x * abs(x)) / 1000 / x2;
  y = (y * abs(y)) / 1000 / y2;
}
Avatar created with South Park Studio

Don't you hate it when your posts get deleted without any note?

User avatar
Workaphobia
Master Sergeant
Master Sergeant
Posts: 252
Joined: Wed May 26, 2004 7:29 pm

Post by Workaphobia » Thu Jul 27, 2006 3:49 am

(First post in these forums in half a year)
Woah, feedback. Not just that, but positive feedback. Thanks.

So it looks like you're using the second stick to scale the output of the first one, for boosts and the like? Sounds hard to control. :) I remember one time I modified something so that I could have "tank-style" movement, where the left and right treads are controlled independently, and turning is based on which one's moving faster. The result was slightly interesting but almost impossible to play with.

I've been meaning to stop being lazy and code something, but couldn't think of much to do. If I get into BZ again, I may rummage through the source again.
"Nifty News Fifty: When news breaks, we give you the pieces."

User avatar
Skeeve
Private First Class
Private First Class
Posts: 122
Joined: Sun Jun 04, 2006 3:27 pm
Location: Near Aix La Chappel

Post by Skeeve » Thu Jul 27, 2006 5:35 am

Workaphobia wrote:(First post in these forums in half a year)
So it looks like you're using the second stick to scale the output of the first one,
Nope. If the second one is used, the first one is ignored. If the second one is moved all the way up, the tanks travels at half it's maximum speed.
Avatar created with South Park Studio

Don't you hate it when your posts get deleted without any note?

User avatar
DTRemenak
General
General
Posts: 625
Joined: Thu Jan 16, 2003 4:54 am
Location: U.S.
Contact:

Post by DTRemenak » Thu Jul 27, 2006 9:43 pm

Workaphobia wrote:Woah, feedback. Not just that, but positive feedback. Thanks.
Hmm, I guess I forgot to post here. I checked in most of your patch (along with some other changes) to CVS head several months ago. If you'd like credit in the changelog as a real person instead of just a callsign, send me your real name and I'll use it.

Commit log:
Thu Feb 9 07:43:18 2006 UTC (5 months, 2 weeks ago) by dtremenak
Branch: MAIN

Input changes (some derived from a patch by workaphobia):
Allow 12 joystick buttons
Fix mousebox edge positioning (full speed at line, not at line + nomotionsize / 2)
Revise joystick coordinate handling to be independent of mousebox positioning (prep for sensitivity setting)
Make slow binoculars a selectable option that applies to all input types
Make slow motion keybinding affect all input types and change menus appropriately
Simplify ReverseControls code

User avatar
chickin
Private First Class
Private First Class
Posts: 41
Joined: Sun Feb 26, 2006 1:25 am
Location: greenville, south carolina, USA
Contact:

Post by chickin » Sat Sep 02, 2006 10:40 pm

How do you use it? (I'm a newbie for code and that stuff).

Thx.
Chickin.

User avatar
MacMan92
Private First Class
Private First Class
Posts: 26
Joined: Thu Apr 13, 2006 2:40 pm
Location: New York
Contact:

Post by MacMan92 » Sun Sep 17, 2006 8:09 pm

If someone could, it would be nice to have something for the POV hat (the little mini-joystick on top of the actual joystick), like just treating it as arrow keys and allowing you to assign things for it to do, and maybe making the joystick twist (on certain joysticks, you can twist the handle) do something. I have a logitech Extreme 3D Pro joystick and you can twist it, but the hat, twist, and throttle don't do anything. I'm going to add an enhancement so that the tank movement is controlled by one set of keys or a controller, and the gun is controlled by another, so you could move sideways without facing sideways and things like that.

User avatar
Skeeve
Private First Class
Private First Class
Posts: 122
Joined: Sun Jun 04, 2006 3:27 pm
Location: Near Aix La Chappel

Post by Skeeve » Sun Sep 17, 2006 9:40 pm

A patch for the hatswitch is already done.
Avatar created with South Park Studio

Don't you hate it when your posts get deleted without any note?

User avatar
MacMan92
Private First Class
Private First Class
Posts: 26
Joined: Thu Apr 13, 2006 2:40 pm
Location: New York
Contact:

Post by MacMan92 » Mon Sep 18, 2006 7:38 pm

Really :?: :!: Could you tell me where to get it please? And also how to install it. Thanks.

User avatar
Skeeve
Private First Class
Private First Class
Posts: 122
Joined: Sun Jun 04, 2006 3:27 pm
Location: Near Aix La Chappel

Post by Skeeve » Mon Sep 18, 2006 11:01 pm

Tech Support wrote:Really :?: :!: Could you tell me where to get it please? And also how to install it. Thanks.
you get it from sourceforge as a patch and it's installed (applied to the source code) like any other patch. So you have to be able to compile in order to use it.
Avatar created with South Park Studio

Don't you hate it when your posts get deleted without any note?

User avatar
MacMan92
Private First Class
Private First Class
Posts: 26
Joined: Thu Apr 13, 2006 2:40 pm
Location: New York
Contact:

Post by MacMan92 » Tue Sep 19, 2006 11:42 pm

Oh. I can't do that. I installed BZFlag from the binary and if I tried to compile, it probably would mess something up. Is there any app (or person) that I could go to that could compile it for me? Sorry, I'm a total NOOB at this kind of thing.

User avatar
Skeeve
Private First Class
Private First Class
Posts: 122
Joined: Sun Jun 04, 2006 3:27 pm
Location: Near Aix La Chappel

Post by Skeeve » Wed Sep 20, 2006 5:58 am

Why not way for then next release? It should be in then.
Avatar created with South Park Studio

Don't you hate it when your posts get deleted without any note?

User avatar
MacMan92
Private First Class
Private First Class
Posts: 26
Joined: Thu Apr 13, 2006 2:40 pm
Location: New York
Contact:

Post by MacMan92 » Wed Sep 20, 2006 8:42 pm

It is going to be in the next release? OK, I can wait. Any idea when it's coming out?

User avatar
A Meteorite
Private First Class
Private First Class
Posts: 1786
Joined: Thu Apr 28, 2005 12:56 am
Location: California, U.S.
Contact:

Post by A Meteorite » Wed Sep 20, 2006 10:57 pm

Tech Support wrote:It is going to be in the next release?
If the devs committed it.
Tech Support wrote:Any idea when it's coming out?
When it's done. ;) The devs don't set a time or date until it's very close to the time they feel it's ready for release. Based on past releases and current progress... I'd say 6-12 months. Probably the 8 month range. It'd probably be better to learn how to compile yourself and add it in. :)
Image
Owner @ BZFX
Core Admin @ CAN

Email me: bzmet…@gmail.com

User avatar
Skeeve
Private First Class
Private First Class
Posts: 122
Joined: Sun Jun 04, 2006 3:27 pm
Location: Near Aix La Chappel

Post by Skeeve » Wed Sep 20, 2006 11:08 pm

A Meteorite wrote:
Tech Support wrote:It is going to be in the next release?
If the devs committed it.
It's currently in HEAD, if I'm not completely mistaken.
Avatar created with South Park Studio

Don't you hate it when your posts get deleted without any note?

User avatar
MacMan92
Private First Class
Private First Class
Posts: 26
Joined: Thu Apr 13, 2006 2:40 pm
Location: New York
Contact:

Post by MacMan92 » Thu Sep 21, 2006 12:21 am

A Meteorite wrote:It'd probably be better to learn how to compile yourself and add it in. :)
It might take 8 months for me to be able to get it working right :mrgreen: . Anyway, it's nothing urgent, it's just a convinence.
Skeeve wrote:It's currently in HEAD, if I'm not completely mistaken.
Um... What's HEAD?
Image
Image
Image - LOL :-)
Image
Image

BZFlag-2.0.8
Apple PowerBook G4 15'' 1.67GHz, 80GB internal, 250GB external Lacie D2 Extreme
Mac OS 10.4.8

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5173
Joined: Fri Dec 13, 2002 4:11 am
Location: https://discord.gg/NN9uAvx
Contact:

Post by JeffM » Thu Sep 21, 2006 12:47 am

HEAD is the term used for the "top" of our source code storage system. Basicly the latest code, that will become the next major release.

at present, HEAD is 2.1.x to be released as 2.2

User avatar
MacMan92
Private First Class
Private First Class
Posts: 26
Joined: Thu Apr 13, 2006 2:40 pm
Location: New York
Contact:

Post by MacMan92 » Thu Sep 21, 2006 11:05 pm

OK, thanks :D .
Image
Image
Image - LOL :-)
Image
Image

BZFlag-2.0.8
Apple PowerBook G4 15'' 1.67GHz, 80GB internal, 250GB external Lacie D2 Extreme
Mac OS 10.4.8

Post Reply