Improved device naming
This commit is contained in:
parent
a390993f19
commit
35c7d31c74
4 changed files with 59 additions and 21 deletions
|
@ -937,29 +937,29 @@ CommandLineParser::set_device_name(const std::string& name, const std::string& v
|
|||
{
|
||||
// FIXME: insert magic to resolve symbolic names
|
||||
std::string::size_type p = name.find('.');
|
||||
|
||||
uint16_t device_id;
|
||||
uint16_t slot_id;
|
||||
|
||||
if (p == std::string::npos)
|
||||
{
|
||||
uint16_t device_id = str2deviceid(name.substr());
|
||||
uint16_t slot_id = m_options->controller_slot;
|
||||
|
||||
uint32_t devid = UInput::create_device_id(slot_id, device_id);
|
||||
|
||||
m_options->uinput_device_names[devid] = value;
|
||||
device_id = str2deviceid(name.substr());
|
||||
slot_id = SLOTID_AUTO;
|
||||
}
|
||||
else if (p == 0)
|
||||
{
|
||||
device_id = DEVICEID_AUTO;
|
||||
slot_id = str2slotid(name.substr(p+1));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t device_id = str2deviceid(name.substr(0, p));
|
||||
uint16_t slot_id = str2slotid(name.substr(p+1));
|
||||
|
||||
if (slot_id == DEVICEID_AUTO)
|
||||
{
|
||||
slot_id = m_options->controller_slot;
|
||||
}
|
||||
|
||||
uint32_t devid = UInput::create_device_id(slot_id, device_id);
|
||||
|
||||
m_options->uinput_device_names[devid] = value;
|
||||
device_id = str2deviceid(name.substr(0, p));
|
||||
slot_id = str2slotid(name.substr(p+1));
|
||||
}
|
||||
|
||||
uint32_t devid = UInput::create_device_id(slot_id, device_id);
|
||||
|
||||
m_options->uinput_device_names[devid] = value;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "uinput.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "log.hpp"
|
||||
|
||||
UInput::UInput() :
|
||||
|
@ -77,15 +79,26 @@ UInput::get_device_name(uint32_t device_id) const
|
|||
std::ostringstream str;
|
||||
str << it->second;
|
||||
if (slot_id > 0)
|
||||
{
|
||||
str << " #" << slot_id;
|
||||
{
|
||||
str << " #" << (slot_id+1);
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "Xbox Gamepad (userspace driver)";
|
||||
|
||||
it = m_device_names.find(create_device_id(SLOTID_AUTO, DEVICEID_AUTO));
|
||||
|
||||
if (it != m_device_names.end())
|
||||
{
|
||||
str << it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
str << "Xbox Gamepad (userspace driver)";
|
||||
}
|
||||
|
||||
switch(type_id)
|
||||
{
|
||||
case DEVICEID_JOYSTICK:
|
||||
|
@ -105,7 +118,7 @@ UInput::get_device_name(uint32_t device_id) const
|
|||
}
|
||||
if (slot_id > 0)
|
||||
{
|
||||
str << " #" << slot_id;
|
||||
str << " #" << (slot_id+1);
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
|
|
12
test/xboxdrv-device-naming.sh
Executable file
12
test/xboxdrv-device-naming.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
./xboxdrv --daemon \
|
||||
`# regular Xbox360 controller gets flightstick threatment` \
|
||||
--device-name mouse.auto="Virtual Mouse" \
|
||||
--device-name keyboard.auto="Virtual Keyboard" \
|
||||
--mouse \
|
||||
--next-controller \
|
||||
--mouse \
|
||||
"$@"
|
||||
|
||||
# EOF #
|
13
test/xboxdrv-device-naming2.sh
Executable file
13
test/xboxdrv-device-naming2.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
./xboxdrv --daemon \
|
||||
`# regular Xbox360 controller gets flightstick threatment` \
|
||||
--device-name auto.0="Slot1 Controller" \
|
||||
--device-name auto.1="Slot2 Controller" \
|
||||
--device-name auto.auto="Any Controller" \
|
||||
--device-name 0.0="Special Name" \
|
||||
--next-controller \
|
||||
--next-controller \
|
||||
"$@"
|
||||
|
||||
# EOF #
|
Loading…
Add table
Reference in a new issue