Implemented --evdev-no-grab

This commit is contained in:
Ingo Ruhnke 2010-12-30 23:23:32 +01:00
parent 4e0d0173f3
commit 90ca2b5bb4
8 changed files with 63 additions and 43 deletions

4
NEWS
View file

@ -18,6 +18,10 @@ xboxdrv 0.6.2 - (??/Jan/2011)
* added ability to replay a macro on a button press
* added ability to launch a child program from within xboxdrv, making
wrapper scripts easier to write without race conditions
* added --option NAME=VALUE to allow INI-style config options from
command line
* added --evdev-debug to print out all received events from evdev
* added --evdev-no-grab to avoid a full grab on the event device
xboxdrv 0.6.1 - (21/Dec/2010)

87
TODO
View file

@ -24,49 +24,18 @@ $ sudo pbuilder --build xboxdrv_0.6.1.dsc
$ dput my-ppa xboxdrv_0.6.1_source.changes
Stuff to do before 0.6.1 release:
Stuff to do before 0.6.2 release:
=================================
* split by "," should ignore empty fields
* add "mouse=true" to ini options
* support for macros:
* write documentation for new features
--ui-buttonevent A=macro:file.macro
* AxisFilter: invert(checked), sensitivy(*), deadzone(checked), relative-axis(checked)
syntax:
* ButtonFilter: invert(checked), toggle(checked), auto(checked)
send KEY_A 0
send ABS_X 25
wait 10
send ABS_X 24
* support for programs:
--ui-buttonevent A=exec:/usr/bin/foo
* convert --mouse to use the new input filter
* give some response curve examples:
# Low sensitivity on the stick when LB is pressed:
--ui-axismap lb+y1^resp:-8000:0:8000=ABS_Y,y1=ABS_Y,lb+x1^resp:-8000:0:8000=ABS_X,x1=ABS_X
* figure out how to do absolute mouse positioning in Xorg
* AxisFilter: invert(*), sensitivy(*), deadzone(*), relative-axis(*)
* ButtonFilter: invert(*), autofire(*), toggle(*)
* Not implementable as they need more then one axis: squareaxis, four-way-restrictor, dpad-rotation
* "couldn't convert 'ABS_y' to enum, not a member of EV_ABS"
convert all enum names to uppercase? or does that lead to conflicts in the naming?
* allow giving ini options on command line: xboxdrv '-e' foo=5 (or '-o')
* allow the right side of --ui-buttomap/--ui-axismap to be empty:
* allow the right side of --ui-axismap to be empty:
xboxdrv --ui-buttonmap X1^deadzone:50
@ -76,12 +45,6 @@ Stuff to do before 0.6.1 release:
* fixup guitar
* add an --evdev debug mode that displays events
* support for Playstation button names maybe? cross, triangle, circle, square, R3, L3, ...?
* add more example scripts
* make evdev grab optional:
--evdev-grab
@ -91,6 +54,44 @@ Stuff to do before 0.6.1 release:
receive events.
--evdev-no-grab
Stuff to do before 0.6.x release:
=================================
* REL_ events could need acceleration support, as mouse emulation is currently kind of imprecise
* write example ini configs (as documented source for user customization):
* default config
* two joysticks with one stick
* all buttons and axis shifted by LB and RB
* evdev joystick to xbox360
* dosbox flightstick emulation
* high sensitivty
* mouse emulation
* give some response curve examples:
# Low sensitivity on the stick when LB is pressed:
--ui-axismap lb+y1^resp:-8000:0:8000=ABS_Y,y1=ABS_Y,lb+x1^resp:-8000:0:8000=ABS_X,x1=ABS_X
* figure out how to do absolute mouse positioning in Xorg
* Not implementable as they need more then one axis: squareaxis, four-way-restrictor, dpad-rotation
* "couldn't convert 'ABS_y' to enum, not a member of EV_ABS"
convert all enum names to uppercase? or does that lead to conflicts in the naming?
* support for Playstation button names maybe? cross, triangle, circle, square, R3, L3, ...?
Stuff to do before 0.7.0 release:
=================================

View file

@ -95,6 +95,7 @@ enum {
OPTION_LIST_CONTROLLER,
OPTION_MOUSE,
OPTION_EVDEV,
OPTION_EVDEV_NO_GRAB,
OPTION_EVDEV_DEBUG,
OPTION_EVDEV_ABSMAP,
OPTION_EVDEV_KEYMAP,
@ -148,6 +149,7 @@ CommandLineParser::init_argp()
.add_option(OPTION_TYPE, 0, "type", "TYPE", "Ignore autodetection and enforce controller type (xbox, xbox-mat, xbox360, xbox360-wireless, xbox360-guitar)")
.add_option(OPTION_EVDEV, 0, "evdev", "DEVICE", "Read events from a evdev device, instead of USB")
.add_option(OPTION_EVDEV_DEBUG, 0, "evdev-debug", "", "Print out all events received from evdev")
.add_option(OPTION_EVDEV_NO_GRAB, 0, "evdev-no-grab", "", "Do not grab the event device, allow other apps to receive events")
.add_option(OPTION_EVDEV_ABSMAP, 0, "evdev-absmap", "MAP", "Map evdev key events to Xbox360 button events")
.add_option(OPTION_EVDEV_KEYMAP, 0, "evdev-keymap", "MAP", "Map evdev abs events to Xbox360 axis events")
.add_newline()
@ -220,6 +222,7 @@ CommandLineParser::init_ini(Options* opts)
("four-way-restrictor", &opts->four_way_restrictor)
("dpad-rotation", &opts->dpad_rotation)
("evdev", &opts->evdev_device)
("evdev-grab", &opts->evdev_grab)
("evdev-debug", &opts->evdev_debug)
("config", boost::bind(&CommandLineParser::read_config_file, this, opts, _1))
("alt-config", boost::bind(&CommandLineParser::read_alt_config_file, this, opts, _1))
@ -491,6 +494,10 @@ CommandLineParser::parse_args(int argc, char** argv, Options* options)
opts.evdev_debug = true;
break;
case OPTION_EVDEV_NO_GRAB:
opts.evdev_grab = false;
break;
case OPTION_EVDEV_ABSMAP:
process_name_value_string(opt.argument, boost::bind(&CommandLineParser::set_evdev_absmap, this, _1, _2));
break;

View file

@ -40,9 +40,11 @@
EvdevController::EvdevController(const std::string& filename,
const EvdevAbsMap& absmap,
const std::map<int, XboxButton>& keymap,
bool grab,
bool debug) :
m_fd(-1),
m_name(),
m_grab(grab),
m_debug(debug),
m_absmap(absmap),
m_keymap(keymap),
@ -67,6 +69,7 @@ EvdevController::EvdevController(const std::string& filename,
std::cout << "Name: " << m_name << std::endl;
}
if (m_grab)
{ // grab the device, so it doesn't broadcast events into the wild
int ret = ioctl(m_fd, EVIOCGRAB, 1);
if ( ret == -1 )

View file

@ -35,6 +35,7 @@ class EvdevController : public XboxGenericController
private:
int m_fd;
std::string m_name;
bool m_grab;
bool m_debug;
EvdevAbsMap m_absmap;
@ -52,6 +53,7 @@ public:
EvdevController(const std::string& filename,
const EvdevAbsMap& absmap,
const std::map<int, XboxButton>& keyMap,
bool grab,
bool debug);
void set_rumble(uint8_t left, uint8_t right);

View file

@ -51,6 +51,7 @@ Options::Options() :
four_way_restrictor(false),
dpad_rotation(0),
evdev_device(),
evdev_grab(true),
evdev_debug(false)
{
}

View file

@ -79,6 +79,7 @@ public:
std::string evdev_device;
EvdevAbsMap evdev_absmap;
std::map<int, XboxButton> evdev_keymap;
bool evdev_grab;
bool evdev_debug;
std::vector<std::string> exec;

View file

@ -523,6 +523,7 @@ Xboxdrv::run_main(const Options& opts)
controller = std::auto_ptr<XboxGenericController>(new EvdevController(opts.evdev_device,
opts.evdev_absmap,
opts.evdev_keymap,
opts.evdev_grab,
opts.evdev_debug));
// FIXME: ugly, should be part of XboxGenericController