Added --dpad-rotation option
This commit is contained in:
parent
3aa7a6b60c
commit
5464b17f3d
7 changed files with 148 additions and 0 deletions
|
@ -446,6 +446,20 @@ output. This option is useful for games such as Tetris, that
|
|||
don't need diagonals and where you don't want to accidently
|
||||
trigger the down-move while trying to do a left/right move.
|
||||
.TP
|
||||
\*(T<\fB\-\-dpad\-rotation\fR\*(T> \fIDEGREE\fR
|
||||
Allows you to rotate the
|
||||
dpad. \fIDEGREE\fR
|
||||
must be a multiple of 45. This can be useful in
|
||||
isometric games where the playfield itself is rotated,
|
||||
thus a:
|
||||
|
||||
.nf
|
||||
\*(T<xboxdrv \-\-dpad\-rotation 45\*(T>
|
||||
.fi
|
||||
|
||||
Will give you controls that are relative to your
|
||||
character instead of your viewpoint.
|
||||
.TP
|
||||
\*(T<\fB\-\-axis\-sensitivty \fR\*(T>\fIAXIS=SENSITIVITY\fR,...
|
||||
The sensitive of an axis can be adjusted via --axis-sensitivty:
|
||||
|
||||
|
|
|
@ -603,6 +603,24 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--dpad-rotation</option> <replaceable class="parameter">DEGREE</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Allows you to rotate the
|
||||
dpad. <replaceable class="parameter">DEGREE</replaceable>
|
||||
must be a multiple of 45. This can be useful in
|
||||
isometric games where the playfield itself is rotated,
|
||||
thus a:
|
||||
</para>
|
||||
<programlisting>xboxdrv --dpad-rotation 45</programlisting>
|
||||
<para>
|
||||
Will give you controls that are relative to your
|
||||
character instead of your viewpoint.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--axis-sensitivty <replaceable class="parameter">AXIS=SENSITIVITY</replaceable></option>,...</term>
|
||||
<listitem>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "arg_parser.hpp"
|
||||
|
@ -66,6 +67,7 @@ enum {
|
|||
OPTION_RELATIVE_AXIS,
|
||||
OPTION_SQUARE_AXIS,
|
||||
OPTION_FOUR_WAY_RESTRICTOR,
|
||||
OPTION_DPAD_ROTATION,
|
||||
OPTION_AXIS_SENSITIVITY,
|
||||
OPTION_HELP_LED,
|
||||
OPTION_DEVICE_BY_ID,
|
||||
|
@ -104,6 +106,7 @@ CommandLineOptions::CommandLineOptions() :
|
|||
axis_sensitivity_map(),
|
||||
square_axis(false),
|
||||
four_way_restrictor(false),
|
||||
dpad_rotation(0),
|
||||
argp()
|
||||
{
|
||||
busid[0] = '\0';
|
||||
|
@ -160,10 +163,13 @@ CommandLineOptions::CommandLineOptions() :
|
|||
.add_option(OPTION_UI_AXISMAP, 0, "ui-axismap", "MAP", "Changes the uinput events send when moving a axis (example: X1=ABS_X2)")
|
||||
.add_option(OPTION_SQUARE_AXIS, 0, "square-axis", "", "Cause the diagonals to be reported as (1,1) instead of (0.7, 0.7)")
|
||||
.add_option(OPTION_FOUR_WAY_RESTRICTOR,0, "four-way-restrictor", "", "Restrict axis movement to one axis at a time")
|
||||
.add_option(OPTION_DPAD_ROTATION, 0, "dpad-rotation", "DEGREE", "Rotate the dpad by the given DEGREE, must be a multiple of 45")
|
||||
.add_option(OPTION_AXIS_SENSITIVITY, 0, "axis-sensitivity", "MAP", "Adjust the axis sensitivity (example: X1=2.0,Y1=1.0)")
|
||||
.add_option(OPTION_RELATIVE_AXIS, 0, "relative-axis", "MAP", "Make an axis emulate a joystick throttle (example: y2=64000)")
|
||||
.add_option(OPTION_AUTOFIRE, 0, "autofire", "MAP", "Cause the given buttons to act as autofire (example: A=250)")
|
||||
.add_option(OPTION_CALIBRARIOTION, 0, "calibration", "MAP", "Changes the calibration for the given axis (example: X2=-32768:0:32767)")
|
||||
|
||||
.add_text("Force Feedback: ")
|
||||
.add_option(OPTION_FORCE_FEEDBACK, 0, "force-feedback", "", "Enable force feedback support")
|
||||
.add_option(OPTION_RUMBLE_GAIN, 0, "rumble-gain", "NUM", "Set relative rumble strength (default: 255)")
|
||||
.add_newline()
|
||||
|
@ -438,6 +444,16 @@ CommandLineOptions::parse_args(int argc, char** argv)
|
|||
opts.four_way_restrictor = true;
|
||||
break;
|
||||
|
||||
case OPTION_DPAD_ROTATION:
|
||||
{
|
||||
int degree = boost::lexical_cast<int>(opt.argument);
|
||||
degree /= 45;
|
||||
degree %= 8;
|
||||
if (degree < 0) degree += 8;
|
||||
opts.dpad_rotation = degree;
|
||||
}
|
||||
break;
|
||||
|
||||
case OPTION_SQUARE_AXIS:
|
||||
opts.square_axis = true;
|
||||
break;
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
std::vector<AxisSensitivityMapping> axis_sensitivity_map;
|
||||
bool square_axis;
|
||||
bool four_way_restrictor;
|
||||
int dpad_rotation;
|
||||
ArgParser argp;
|
||||
|
||||
public:
|
||||
|
|
|
@ -406,4 +406,98 @@ void apply_four_way_restrictor(XboxGenericMsg& msg, const CommandLineOptions& op
|
|||
}
|
||||
}
|
||||
|
||||
void apply_dpad_rotator(XboxGenericMsg& msg, const CommandLineOptions& opts)
|
||||
{
|
||||
int up = get_button(msg, XBOX_DPAD_UP);
|
||||
int down = get_button(msg, XBOX_DPAD_DOWN);
|
||||
int left = get_button(msg, XBOX_DPAD_LEFT);
|
||||
int right = get_button(msg, XBOX_DPAD_RIGHT);
|
||||
|
||||
// -1: not pressed, 0: up, 1: up/right, ...
|
||||
int direction = -1;
|
||||
if (up && !down && !left && !right)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
else if (up && !down && !left && right)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
else if (!up && !down && !left && right)
|
||||
{
|
||||
direction = 2;
|
||||
}
|
||||
else if (!up && down && !left && right)
|
||||
{
|
||||
direction = 3;
|
||||
}
|
||||
else if (!up && down && !left && !right)
|
||||
{
|
||||
direction = 4;
|
||||
}
|
||||
else if (!up && down && left && !right)
|
||||
{
|
||||
direction = 5;
|
||||
}
|
||||
else if (!up && !down && left && !right)
|
||||
{
|
||||
direction = 6;
|
||||
}
|
||||
else if (up && !down && left && !right)
|
||||
{
|
||||
direction = 7;
|
||||
}
|
||||
|
||||
if (direction != -1)
|
||||
{
|
||||
direction += opts.dpad_rotation;
|
||||
direction %= 8;
|
||||
if (direction < 0)
|
||||
direction += 8;
|
||||
|
||||
set_button(msg, XBOX_DPAD_UP, 0);
|
||||
set_button(msg, XBOX_DPAD_DOWN, 0);
|
||||
set_button(msg, XBOX_DPAD_LEFT, 0);
|
||||
set_button(msg, XBOX_DPAD_RIGHT, 0);
|
||||
switch(direction)
|
||||
{
|
||||
case 0:
|
||||
set_button(msg, XBOX_DPAD_UP, 1);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
set_button(msg, XBOX_DPAD_UP, 1);
|
||||
set_button(msg, XBOX_DPAD_RIGHT, 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
set_button(msg, XBOX_DPAD_RIGHT, 1);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
set_button(msg, XBOX_DPAD_RIGHT, 1);
|
||||
set_button(msg, XBOX_DPAD_DOWN, 1);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
set_button(msg, XBOX_DPAD_DOWN, 1);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
set_button(msg, XBOX_DPAD_DOWN, 1);
|
||||
set_button(msg, XBOX_DPAD_LEFT, 1);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
set_button(msg, XBOX_DPAD_LEFT, 1);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
set_button(msg, XBOX_DPAD_UP, 1);
|
||||
set_button(msg, XBOX_DPAD_LEFT, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -165,6 +165,7 @@ void apply_deadzone(XboxGenericMsg& msg, const CommandLineOptions& opts);
|
|||
void apply_square_axis(XboxGenericMsg& msg);
|
||||
void apply_axis_sensitivity(XboxGenericMsg& msg, const CommandLineOptions& opts);
|
||||
void apply_four_way_restrictor(XboxGenericMsg& msg, const CommandLineOptions& opts);
|
||||
void apply_dpad_rotator(XboxGenericMsg& msg, const CommandLineOptions& opts);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -286,6 +286,9 @@ Xboxdrv::apply_modifier(XboxGenericMsg& msg, int msec_delta, const CommandLineOp
|
|||
|
||||
if (opts.four_way_restrictor)
|
||||
apply_four_way_restrictor(msg, opts);
|
||||
|
||||
if (opts.dpad_rotation)
|
||||
apply_dpad_rotator(msg, opts);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -588,6 +591,7 @@ Xboxdrv::print_info(struct usb_device* dev,
|
|||
|
||||
std::cout << "Square Axis: " << ((opts.square_axis) ? "yes" : "no") << std::endl;
|
||||
std::cout << "4-Way Restrictor: " << ((opts.four_way_restrictor) ? "yes" : "no") << std::endl;
|
||||
std::cout << "Dpad Rotation: " << opts.dpad_rotation * 45 << " degree" << std::endl;
|
||||
|
||||
std::cout << "ButtonMap: ";
|
||||
if (opts.button_map.empty())
|
||||
|
|
Loading…
Reference in a new issue