Added RotateAxisModifier

This commit is contained in:
Ingo Ruhnke 2011-01-22 19:31:44 +01:00
parent 386cffe6d8
commit b49dce1dd3
5 changed files with 146 additions and 40 deletions

1
NEWS
View file

@ -14,6 +14,7 @@ xboxdrv 0.6.5 - (??/Jan/2011)
* renamed --ui-toggle to --toggle
* fixed incorrect endpoint detection for Xbox1 controller
* native Playstation 3 USB controller support
* added axis rotation modifier
xboxdrv 0.6.4 - (13/Jan/2011)

59
TODO
View file

@ -22,45 +22,37 @@ add libudev, libusb-1.0 to builddependencies
$ cd ../debian/
$ git checkout master
$ git-import-orig -u 0.6.4 ~/projects/xboxdrv/htdocs/xboxdrv-linux-0.6.4.tar.bz2
$ dch -v "0.6.4-1" "xboxdrv 0.6.4 release"
$ git-import-orig -u 0.7.0 ~/projects/xboxdrv/htdocs/xboxdrv-linux-0.7.0.tar.bz2
$ dch -v "0.7.0-1" "xboxdrv 0.7.0 release"
$ git-buildpackage --git-no-create-orig --git-tag --git-builder="debuild -S"
$ sudo pbuilder --build ../xboxdrv_0.6.4-2.dsc
$ dput my-ppa ../xboxdrv_0.6.4-2_source.changes
$ sudo pbuilder --build ../xboxdrv_0.7.0-1.dsc
$ dput my-ppa ../xboxdrv_0.7.0-1_source.changes
# Ubuntu 10.04 (LTS)
$ cd ../debian/
$ git checkout master-lts
$ git merge master
$ dch -b -v "0.6.4-1~lucid1" --distribution lucid "xboxdrv 0.6.4 backport"
$ dch -b -v "0.7.0-1~lucid1" --distribution lucid "xboxdrv 0.7.0 backport"
$ git-buildpackage --git-no-create-orig --git-debian-branch=master-lts --git-tag --git-builder="debuild -S"
$ sudo pbuilder --build ../xboxdrv_0.6.4-2~lucid1.dsc
$ dput my-ppa ../xboxdrv_0.6.4-2~lucid1_source.changes
$ sudo pbuilder --build ../xboxdrv_0.7.0-1~lucid1.dsc
$ dput my-ppa ../xboxdrv_0.7.0-1~lucid1_source.changes
Stuff to do before 0.6.4 release:
=================================
* uninited variables in KeyButtonEvent screw things up
Stuff to do before 0.7.0 release:
=================================
* Playstation 3 controller support
- http://www.pabr.org/sixlinux/sixlinux.en.html
- http://www.motioninjoy.com/
* fix the FIXME's
* correct chatpad handling for bcd 0x114 type
* fix event output (have it pre-modifier or post-modifier?)
* fix --no-uinput
* something is broken with start/back buttons
* need to hide/disable the toggle button from the normal view
* need to hide/disable the toggle button from the UIButtonmap
* move XBOX_BTN_UNKNOWN behind XBOX_BTN_MAX, so iteration can start
from 0 instead of 1, also fix incorrect iterations all over the
@ -76,17 +68,13 @@ Daemon Related Stuff
* handle multiple controllers in a sane manner (requires cloning of
modifier maps, also auto increment of "auto" device id's)
* get rid of uinput.get_uinput(m_code.device_id)->send(EV_ABS, m_code.code, value) turn into:
uinput.send(m_code.device_id, EV_ABS, m_code.code, value);
or
uinput.send_abs(m_code.device_id, m_code.code, value);
* add: void Uinput::send(XboxGenericMsg& msg, int controller_slot = 0);
* need magic to assign controller to a slot
* need magic to assign controller to a slot:
what: match product/vendor-id, match device name
where: match USB path, match /dev/input/??? path
when: just assign them to the next free slot
* might need magic to give device-ids in a slot fashion:
from: 1-ABS_X (second uinput device)
@ -100,7 +88,11 @@ Daemon Related Stuff
List Output
===========
* make controller type part of the message, instead of manually carrying around type variable
* make controller type part of the message, instead of manually
carrying around type variable:
-> doesn't really work, as some gamepads just emulate other message
types, need to restructure the whole messaging infrastructure
* do modifier/filter dump when --verbose is given
@ -114,17 +106,6 @@ List Output
* add --list-keys --list-x11-keys --list-abs --list-rel --list-button --list-axis etc.
- add pretty printer, to make output look nice
* document modifier syntax and provide examples:
--modifier rotate=X:Y:90,square,round
[modifier]
rotate=X1:Y1:90
four-way-restrictor=X1:Y1
square=X1:Y1
round=X1:Y1
* document significant patches in AUTHORS
2 Added latest version of runxboxdrv from Michael Rans <rans@email.com>

View file

@ -23,6 +23,7 @@
#include "modifier/dpad_rotation_modifier.hpp"
#include "modifier/four_way_restrictor_modifier.hpp"
#include "modifier/square_axis_modifier.hpp"
#include "modifier/rotate_axis_modifier.hpp"
Modifier*
Modifier::from_string(const std::string& name, const std::string& value)
@ -44,7 +45,7 @@ Modifier::from_string(const std::string& name, const std::string& value)
std::vector<std::string> args(tokens.begin(), tokens.end());
if (name == "dpad-rotation")
if (name == "dpad-rotation" || name == "dpad-rotate")
{
return DpadRotationModifier::from_string(args);
}
@ -56,6 +57,10 @@ Modifier::from_string(const std::string& name, const std::string& value)
{
return SquareAxisModifier::from_string(args);
}
else if (name == "rotate")
{
return RotateAxisModifier::from_string(args);
}
else
{
throw std::runtime_error("unknown modifier: " + name);

View file

@ -0,0 +1,75 @@
/*
** Xbox360 USB Gamepad Userspace Driver
** Copyright (C) 2011 Ingo Ruhnke <grumbel@gmx.de>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rotate_axis_modifier.hpp"
#include <stdexcept>
#include <boost/lexical_cast.hpp>
#include <math.h>
RotateAxisModifier*
RotateAxisModifier::from_string(const std::vector<std::string>& args)
{
if (args.size() != 3 && args.size() != 4)
{
throw std::runtime_error("RotateAxisModifier requires three or four arguments");
}
else
{
return new RotateAxisModifier(string2axis(args[0]),
string2axis(args[1]),
boost::lexical_cast<float>(args[2]) * M_PI / 180.0f,
args.size() == 3 ? false : boost::lexical_cast<bool>(args[3]));
}
}
RotateAxisModifier::RotateAxisModifier(XboxAxis xaxis, XboxAxis yaxis, float angle, bool mirror) :
m_xaxis(xaxis),
m_yaxis(yaxis),
m_angle(angle),
m_mirror(mirror)
{
}
void
RotateAxisModifier::update(int msec_delta, XboxGenericMsg& msg)
{
float x = get_axis_float(msg, m_xaxis);
float y = get_axis_float(msg, m_yaxis);
if (m_mirror)
{
x = -x;
}
float length = sqrtf(x*x + y*y);
float angle = atan2f(y, x) + m_angle;
set_axis_float(msg, m_xaxis, cos(angle) * length);
set_axis_float(msg, m_yaxis, sin(angle) * length);
}
std::string
RotateAxisModifier::str() const
{
std::ostringstream out;
out << "rotate:" << m_xaxis << "=" << m_yaxis << ":" << (m_angle/180.0f*M_PI);
return out.str();
}
/* EOF */

View file

@ -0,0 +1,44 @@
/*
** Xbox360 USB Gamepad Userspace Driver
** Copyright (C) 2011 Ingo Ruhnke <grumbel@gmx.de>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HEADER_XBOXDRV_MODIFIER_ROTATE_AXIS_MODIFIER_HPP
#define HEADER_XBOXDRV_MODIFIER_ROTATE_AXIS_MODIFIER_HPP
#include "modifier.hpp"
class RotateAxisModifier : public Modifier
{
public:
static RotateAxisModifier* from_string(const std::vector<std::string>& args);
public:
RotateAxisModifier(XboxAxis xaxis, XboxAxis yaxis, float angle, bool mirror);
void update(int msec_delta, XboxGenericMsg& msg);
std::string str() const;
private:
XboxAxis m_xaxis;
XboxAxis m_yaxis;
float m_angle;
bool m_mirror;
};
#endif
/* EOF */