Allow deadzone in percentage

This commit is contained in:
Ingo Ruhnke 2009-01-18 09:43:44 +01:00
parent ade5823276
commit 77729257e3
5 changed files with 39 additions and 10 deletions

5
NEWS
View file

@ -1,3 +1,8 @@
xboxdrv 0.4.4 - (??/Jan/2009)
=============================
xboxdrv 0.4.3 - (17/Jan/2009)
=============================

4
README
View file

@ -142,6 +142,10 @@ value to something higher:
A value of 4000 works quite well for most games.
You can also give the deadzone in percentage:
% ./xboxdrv --deadzone 15%
[[ Square Axis ]]
-----------------

14
TODO
View file

@ -5,20 +5,18 @@ Pre Release Testing:
* --dpad-only check that X/Y act properly
* --dpad-as-button check buttons are working and no useless axis present
TAG=0.4.2
TAG=v0.4.4
git tag ${TAG}
git-archive --format=tar --prefix="xboxdrv-linux-${TAG}/" ${TAG} | bzip2 -c > /tmp/xboxdrv-linux-${TAG}.tar.bz2
git push --tags
Stuff to do before 0.4.3 release:
=================================
* improve force feedback output a little bit
Stuff to do before 0.5 release:
===============================
* create dummy joystick, mouse and keyboard buttons so that the
devices always act as they should, also figure out the exakt minimum
requirements for each device.
* guitar doesn't get a guide button?!
* add --detach option that detaches any existing driver
@ -48,6 +46,8 @@ http://www.immersion.com/developer/downloads/ImmFundamentals/HTML/
Later versions:
===============
* add axis specific deadzones or deal with LT/RT somehow
* figure out which devices xorg/hal handles as keyboard and how to
make it always happen, seems to require two keyboard keys, devices
with only one aren't registered

View file

@ -103,7 +103,7 @@ Xbox360Controller::read(XboxGenericMsg& msg, bool verbose, int timeout)
else if (ret < 0)
{ // Error
std::ostringstream str;
str << "USBError: " << ret << "\n" << usb_strerror();
str << "Xbox360Controller: USBError: " << ret << "\n" << usb_strerror();
throw std::runtime_error(str.str());
}
else if (ret == 0)

View file

@ -449,7 +449,7 @@ void print_led_help()
void print_version()
{
std::cout
<< "xboxdrv 0.4.3\n"
<< "xboxdrv 0.4.4\n"
<< "Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>\n"
<< "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
<< "This is free software: you are free to change and redistribute it.\n"
@ -457,6 +457,26 @@ void print_version()
<< std::endl;
}
int to_number(int range, const std::string& str)
{
if (str.empty())
{
return 0;
}
else
{
if (str[str.size() - 1] == '%')
{
int percent = std::max(0, std::min(100, boost::lexical_cast<int>(str.substr(0, str.size()-1))));
return range * percent / 100;
}
else
{
return std::max(0, std::min(range, boost::lexical_cast<int>(str)));
}
}
}
void parse_command_line(int argc, char** argv, CommandLineOptions& opts)
{
for(int i = 1; i < argc; ++i)
@ -720,7 +740,7 @@ void parse_command_line(int argc, char** argv, CommandLineOptions& opts)
++i;
if (i < argc)
{
opts.deadzone = atoi(argv[i]);
opts.deadzone = to_number(32767, argv[i]);
}
else
{