Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Altering Xonotic Source Code

#1
To whomever of greater knowledge than myself this may pertain to,

I am running Xonotic 0.6.0autobuild(if that means anything) on a 2011 Mac Mini with OSX 10.7.5.

I have an AX.1 afterglow xbox360 controller (wired, USB).

This controller is operating on my system through the "xbox360controller" driver download for Mac.

It works, all inputs are registered.

With adjustments, this controller works with the aforementioned version of Xonotic, and quite well.

MY CONCERN:

The trigger buttons on the back of the xbox360 controller do not register with Xonotic. Speaking mechanics, these buttons are being registered by the driver installed on my Mac as gradated inputs...they are NOT cut and dry on/off-state driven (I dont think this is the problem).

I did some research on the internet, and within the source code for Xonotic I came across a file that handles joystick inputs. (This file is located at: source->darkplaces->vid_shared.c)

Within "vid_shared.c" exists the following lines:

//#include <XInput.h>
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
#define XINPUT_GAMEPAD_START 0x0010
#define XINPUT_GAMEPAD_BACK 0x0020
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
#define XINPUT_GAMEPAD_A 0x1000
#define XINPUT_GAMEPAD_B 0x2000
#define XINPUT_GAMEPAD_X 0x4000
#define XINPUT_GAMEPAD_Y 0x8000
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
#define XUSER_INDEX_ANY 0x000000FF

My belief is that Xonotic has not been coded to support enough joystick inputs to recognize the triggers of my xbox360 controller.

I believe that additional lines such as "LEFT_SHOULDER_2" and "RIGHT_SHOULDER_2" need to be added to the above listed code.

THE QUESTIONS:

If this is an accurate assessment of the situation, how can I discover the associated addresses (i.e 0x0100) of my xbox trigger buttons?

How can I incorporate new code myself into the above lines?

How do I compile the adjusted code once Im done (Im running on a Mac)?

If I have totally missed the mark, who would I contact about this issue so I get results (either through guidance or implementation in future versions)?

Thank you for any assistance!
Reply

#2
(01-11-2013, 08:54 PM)perljamz10 Wrote: To whomever of greater knowledge than myself this may pertain to,

I am running Xonotic 0.6.0autobuild(if that means anything) on a 2011 Mac Mini with OSX 10.7.5.

I have an AX.1 afterglow xbox360 controller (wired, USB).

This controller is operating on my system through the "xbox360controller" driver download for Mac.

It works, all inputs are registered.

With adjustments, this controller works with the aforementioned version of Xonotic, and quite well.

MY CONCERN:

The trigger buttons on the back of the xbox360 controller do not register with Xonotic. Speaking mechanics, these buttons are being registered by the driver installed on my Mac as gradated inputs...they are NOT cut and dry on/off-state driven (I dont think this is the problem).

I did some research on the internet, and within the source code for Xonotic I came across a file that handles joystick inputs. (This file is located at: source->darkplaces->vid_shared.c)

Within "vid_shared.c" exists the following lines:

//#include <XInput.h>
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
#define XINPUT_GAMEPAD_START 0x0010
#define XINPUT_GAMEPAD_BACK 0x0020
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
#define XINPUT_GAMEPAD_A 0x1000
#define XINPUT_GAMEPAD_B 0x2000
#define XINPUT_GAMEPAD_X 0x4000
#define XINPUT_GAMEPAD_Y 0x8000
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
#define XUSER_INDEX_ANY 0x000000FF

My belief is that Xonotic has not been coded to support enough joystick inputs to recognize the triggers of my xbox360 controller.

I believe that additional lines such as "LEFT_SHOULDER_2" and "RIGHT_SHOULDER_2" need to be added to the above listed code.

THE QUESTIONS:

If this is an accurate assessment of the situation, how can I discover the associated addresses (i.e 0x0100) of my xbox trigger buttons?

How can I incorporate new code myself into the above lines?

How do I compile the adjusted code once Im done (Im running on a Mac)?

If I have totally missed the mark, who would I contact about this issue so I get results (either through guidance or implementation in future versions)?

Thank you for any assistance!

Hi.

Let's start with the compiling. I haven't ever done that based on sources shipped in releases or autobuilds. You'll need to use the makefile. The build system uses this, but it probably won't work as is:
Code:
make sdl-release STRIP=: CC="gcc -g1 -arch i386 -arch ppc -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -I.deps/include -L.deps/lib -fno-reorder-blocks -DSUPPORTIPV6"

I can't guide you any further for compilation, as I've never touched that in Mac OS. Perhaps you should try to compile from git if nothing else works. Or join the #xonotic IRC channel on irc.freenode.net, ask, and be very patient.


Now for the joypad part. But don't get into this before you know how to compile and run the engine.

Disclaimer: I'm not a programmer and I don't know much about the game engine. What follows are only pointers to the solution, based on my understanding of the code.

We currently have specific support for the Xbox 360 controller, but this is only for Windows and makes use of its XInput API for the X360 controller. This is implemented in vid_shared.c. Have a look at void VID_Shared_BuildJoyState_Begin. This is called on every frame, I believe, and this is how the analog LT/RT trigger is mapped to a button:
Code:
joystate->button[14] = xinputstate.Gamepad.bLeftTrigger >= XINPUT_GAMEPAD_TRIGGER_THRESHOLD;
joystate->button[15] = xinputstate.Gamepad.bRightTrigger >= XINPUT_GAMEPAD_TRIGGER_THRESHOLD;
where XINPUT_GAMEPAD_TRIGGER_THRESHOLD is #define'd to 30 at the top of the source. Apparently, in void VID_ApplyJoyState, you can also make use of those two analog axes as analog input axes (they are axes 4 and 5, while 0,1 are X/Y for the left thumb stick and 2,3 are X/Y for the right thumb stick).

The Xbox 360 buttons also have their own keycodes associated apparently, and they are defined in joybuttonkey360. That should not really matter, I think?

Anyway, if you want to use LT/RT as buttons, I think you need to implement a threshold in VID_Shared_BuildJoyState_Finish as is done in Windows and set the state of the relevant buttons in joystate (see joybuttonkey to see which button number you want to use). I said _Finish because vid_sdl.c handles the input to set the joystate, then calls VID_Shared_BuildJoyState_Finish. You can use VID_Shared_BuildJoyState_Finish to set buttons acorting to the analog axes' values. Note that the values range from -1 to 1, so don't try to use 30 as a threshold (that's an XInput thing, it goes from 0 to 255 I think?)

If you're using the driver from tattiebogle.net, the mappings can be found on the net: LT/RT are axes 5 and 6. I guess what you can do then is use VID_JoyState_GetAxis. If there's another driver, you can either download a joystick test program (I'm sure that exists) or try to set the cvar joy_axisforward to increasing values until LT/RT make you go forward ingame.)


I can't think of a person to contact that isn't constantly busy and will not get back to you for sure. You can always try the #darkplaces IRC channel on irc.oftc.net. Talk to LordHavoc or maybe divVerent.
Reply

#3
For anyone who is has talent in coding and interested in furthering native all-around support for gamepads... it would be so awesome if Xonotic, and all games really, would have such an intuitive configuration interface and support as NRage's plugin for Project 64.

http://sourceforge.net/projects/nragev20/
http://sourceforge.net/p/nragev20/code/73/tree/

I've had little success at assigning look and turn to a one of the thumbsticks on a working and registered original xbox controller. Maybe I need to modify the config file manually?
Reply

#4
How did you try doing so? You can assign axes to actions using using the ingame console (there's no real practical GUI for this). Open the console (shift-escape) and type joy_. Then, press tab. You'll get a list of joystick-related cvars. The ones you're looking for are the joy_axis* ones (or, if you're using Windows and the X360 controller, the joy_x360_axis* ones).

Assign axis 2 to pitch by typing joy_axispitch 2. You can reverse the axis by using negative values.
Reply

#5
(02-22-2013, 05:32 PM)Mr. Bougo Wrote: How did you try doing so? You can assign axes to actions using using the ingame console (there's no real practical GUI for this). Open the console (shift-escape) and type joy_. Then, press tab. You'll get a list of joystick-related cvars. The ones you're looking for are the joy_axis* ones (or, if you're using Windows and the X360 controller, the joy_x360_axis* ones).

Assign axis 2 to pitch by typing joy_axispitch 2. You can reverse the axis by using negative values.

Excellent. So a negative would then be joy_axispitch -2.

Thanks.
Reply

#6
Smile

Sorry for the absence of a menu interface to configure this, but people generally don't think of Xonotic as a gamepad-friendly game.
Reply

#7
(02-26-2013, 01:58 AM)Mr. Bougo Wrote: Smile

Sorry for the absence of a menu interface to configure this, but people generally don't think of Xonotic as a gamepad-friendly game.

Oh, that's fine. I believe it is fun to try to even make it work as a challenge. The only work there is to go is with the triggers (joy2key or otherwise) and maybe adding look/pitch L&R and turn/yaw L&R just above the movement entries. Btw, may I have a hit as to which file might contain the input section of the menu if anyone knows it offhand? (Edited hereSmile I'm going to guess somewhere near or in menu.c possibly.

Ramble: I do enjoy using the gamepad, but another reason I'm interest in this is my $50 mouse has an issue with physically sticking (plastic on plastic) with the right button so I'm doing it a bit out of revenge or spite. That and I recently rediscovered project 64 with the original xbox gamepad through NRage's plugin so I want to make it work elsewhere too.
Reply

#8
The input section is in qcsrc/menu/xonotic/dialog_settings_input.c and in dialog_settings_input_userbind.c and maybe other files like keybinder.c.

I really like N-Rage for input settings too. The advanced settings are as good as they get.
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  Trying to understand darkplaces source code wiefie 37 7,747 09-22-2017, 01:37 PM
Last Post: Lyberta
  Xonotic QCC source won't compile with GMQCC? kristus 4 3,543 11-04-2014, 08:14 PM
Last Post: Mario
Question media source files of vehicles? poVoq 13 7,529 02-21-2012, 06:16 PM
Last Post: tZork
  Planning to help with the code - where to start? Exitium 10 7,575 09-19-2011, 10:25 AM
Last Post: Lord Canistra
  Want to start helping with Xonotic code JayWalker 4 5,429 03-20-2011, 01:46 AM
Last Post: Akari
  Source code for the 0.1 preview release? twistedlincoln 4 5,945 01-03-2011, 09:18 AM
Last Post: twistedlincoln
  Darkplaces Code master[mind] 3 4,507 11-28-2010, 05:02 AM
Last Post: SavageX
  Codendi, the open source platform for Application Lifecycle Management (ALM) PGP_Qz 2 6,034 11-20-2010, 03:48 PM
Last Post: Spaceman
  editing nexiuz source code Jono 3 4,368 04-27-2010, 03:19 AM
Last Post: tZork

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-