diff --git a/src/device-manager.cpp b/src/device-manager.cpp
index 9cf4583c698f1bfc379f2350536e9e4ea12d63d0..09fd7cb5f788cc7970ada63da52cfcd018d361ba 100644 (file)
--- a/src/device-manager.cpp
+++ b/src/device-manager.cpp
virtual gint getNumKeys() const {return device->num_keys;}
virtual Glib::ustring getLink() const {return link;}
virtual void setLink( Glib::ustring const& link ) {this->link = link;}
+ virtual gint getLiveAxes() const {return liveAxes;}
+ virtual void setLiveAxes(gint axes) {liveAxes = axes;}
virtual gint getLiveButtons() const {return liveButtons;}
virtual void setLiveButtons(gint buttons) {liveButtons = buttons;}
Glib::ustring name;
Gdk::InputSource source;
Glib::ustring link;
+ guint liveAxes;
guint liveButtons;
};
name(device->name ? device->name : ""),
source(static_cast<Gdk::InputSource>(device->source)),
link(),
+ liveAxes(0),
liveButtons(0)
{
switch ( source ) {
DeviceManagerImpl();
virtual std::list<InputDevice const *> getDevices();
virtual sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalDeviceChanged();
+ virtual sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalAxesChanged();
virtual sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalButtonsChanged();
virtual sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalLinkChanged();
+ virtual void addAxis(Glib::ustring const & id, gint axis);
virtual void addButton(Glib::ustring const & id, gint button);
virtual void setLinkedTo(Glib::ustring const & id, Glib::ustring const& link);
protected:
std::list<InputDeviceImpl*> devices;
sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalDeviceChangedPriv;
+ sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalAxesChangedPriv;
sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalButtonsChangedPriv;
sigc::signal<void, const Glib::RefPtr<InputDevice>& > signalLinkChangedPriv;
};
@@ -179,6 +186,11 @@ sigc::signal<void, const Glib::RefPtr<InputDevice>& > DeviceManagerImpl::signalD
return signalDeviceChangedPriv;
}
+sigc::signal<void, const Glib::RefPtr<InputDevice>& > DeviceManagerImpl::signalAxesChanged()
+{
+ return signalAxesChangedPriv;
+}
+
sigc::signal<void, const Glib::RefPtr<InputDevice>& > DeviceManagerImpl::signalButtonsChanged()
{
return signalButtonsChangedPriv;
@@ -189,6 +201,23 @@ sigc::signal<void, const Glib::RefPtr<InputDevice>& > DeviceManagerImpl::signalL
return signalLinkChangedPriv;
}
+void DeviceManagerImpl::addAxis(Glib::ustring const & id, gint axis)
+{
+ if ( axis >= 0 && axis < static_cast<gint>(bitVals.size()) ) {
+ std::list<InputDeviceImpl*>::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
+ if ( it != devices.end() ) {
+ gint mask = bitVals[axis];
+ if ( (mask & (*it)->getLiveAxes()) == 0 ) {
+ (*it)->setLiveAxes((*it)->getLiveAxes() | mask);
+
+ // Only signal if a new axis was added
+ (*it)->reference();
+ signalAxesChangedPriv.emit(Glib::RefPtr<InputDevice>(*it));
+ }
+ }
+ }
+}
+
void DeviceManagerImpl::addButton(Glib::ustring const & id, gint button)
{
if ( button >= 0 && button < static_cast<gint>(bitVals.size()) ) {
}
}
-
void DeviceManagerImpl::setLinkedTo(Glib::ustring const & id, Glib::ustring const& link)
{
std::list<InputDeviceImpl*>::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
if ( it != devices.end() ) {
InputDeviceImpl* dev = *it;
- // Need to be sure the target of the link exists
- it = std::find_if(devices.begin(), devices.end(), IdMatcher(link));
- if ( it != devices.end() ) {
- InputDeviceImpl* targetDev = *it;
- if ( (dev->getLink() != link) || (targetDev->getLink() != id) ) {
- // only muck about if they aren't already linked
- std::list<InputDeviceImpl*> changedItems;
- // Is something else already using that link?
+
+ InputDeviceImpl* targetDev = 0;
+ if ( !link.empty() ) {
+ // Need to be sure the target of the link exists
+ it = std::find_if(devices.begin(), devices.end(), IdMatcher(link));
+ if ( it != devices.end() ) {
+ targetDev = *it;
+ }
+ }
+
+
+ if ( (link.empty() && !dev->getLink().empty())
+ || (targetDev && (targetDev->getLink() != id)) ) {
+ // only muck about if they aren't already linked
+ std::list<InputDeviceImpl*> changedItems;
+
+ if ( targetDev ) {
+ // Is something else already using that link?
it = std::find_if(devices.begin(), devices.end(), LinkMatcher(link));
if ( it != devices.end() ) {
(*it)->setLink("");
changedItems.push_back(*it);
}
- it = std::find_if(devices.begin(), devices.end(), LinkMatcher(id));
- if ( it != devices.end() ) {
- (*it)->setLink("");
- changedItems.push_back(*it);
- }
- dev->setLink(link);
+ }
+ it = std::find_if(devices.begin(), devices.end(), LinkMatcher(id));
+ if ( it != devices.end() ) {
+ (*it)->setLink("");
+ changedItems.push_back(*it);
+ }
+ if ( targetDev ) {
targetDev->setLink(id);
changedItems.push_back(targetDev);
- changedItems.push_back(dev);
+ }
+ dev->setLink(link);
+ changedItems.push_back(dev);
- for ( std::list<InputDeviceImpl*>::const_iterator iter = changedItems.begin(); iter != changedItems.end(); ++iter ) {
- (*iter)->reference();
- signalLinkChangedPriv.emit(Glib::RefPtr<InputDevice>(*iter));
- }
+ for ( std::list<InputDeviceImpl*>::const_iterator iter = changedItems.begin(); iter != changedItems.end(); ++iter ) {
+ (*iter)->reference();
+ signalLinkChangedPriv.emit(Glib::RefPtr<InputDevice>(*iter));
}
}
}
static void createFakeList() {
if ( !fakeList ) {
- fakeout[0].name = "pad";
+ fakeout[0].name = g_strdup("pad");
fakeout[0].source = GDK_SOURCE_PEN;
fakeout[0].mode = GDK_MODE_SCREEN;
fakeout[0].has_cursor = TRUE;
fakeout[0].num_keys = 8;
fakeout[0].keys = padKeys;
- fakeout[1].name = "eraser";
+ fakeout[1].name = g_strdup("eraser");
fakeout[1].source = GDK_SOURCE_ERASER;
fakeout[1].mode = GDK_MODE_SCREEN;
fakeout[1].has_cursor = TRUE;
fakeout[1].num_keys = 7;
fakeout[1].keys = eraserKeys;
- fakeout[2].name = "cursor";
+ fakeout[2].name = g_strdup("cursor");
fakeout[2].source = GDK_SOURCE_CURSOR;
fakeout[2].mode = GDK_MODE_SCREEN;
fakeout[2].has_cursor = TRUE;
fakeout[2].num_keys = 7;
fakeout[2].keys = cursorKeys;
- fakeout[3].name = "stylus";
+ fakeout[3].name = g_strdup("stylus");
fakeout[3].source = GDK_SOURCE_PEN;
fakeout[3].mode = GDK_MODE_SCREEN;
fakeout[3].has_cursor = TRUE;
if ( devList && devList->data ) {
fakeout[4] = *((GdkDevice*)devList->data);
} else {
- fakeout[4].name = "Core Pointer";
+ fakeout[4].name = g_strdup("Core Pointer");
fakeout[4].source = GDK_SOURCE_MOUSE;
fakeout[4].mode = GDK_MODE_SCREEN;
fakeout[4].has_cursor = TRUE;