device-manager.cpp revision a438d4906a0354ff3897f1ce53d6e3cf04fb06c6
/*
* Inkscape::DeviceManager - a view of input devices available.
*
* Copyright 2010 Jon A. Cruz <jon@joncruz.org>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "device-manager.h"
#include <map>
#include <set>
#include "preferences.h"
#include <gtkmm/accelkey.h>
#if WITH_GTKMM_3_0
# include <gdkmm/devicemanager.h>
#endif
#define noDEBUG_VERBOSE 1
// This is a copy of the private fields of the GdkDevice object, used in order
// to create a list of "fake" devices.
struct GdkDeviceFake {
bool has_cursor;
int num_axes;
int num_keys;
};
static void createFakeList();
{
bool valid = true;
#if WITH_GTKMM_3_0
#else
#endif
&& num_axes_matches && num_keys_matches)
valid = false;
}
return valid;
}
namespace Inkscape {
pair<gint, gint>(0, 1), pair<gint, gint>(1, 1 << 1), pair<gint, gint>(2, 1 << 2), pair<gint, gint>(3, 1 << 3),
pair<gint, gint>(4, 1 << 4), pair<gint, gint>(5, 1 << 5), pair<gint, gint>(6, 1 << 6), pair<gint, gint>(7, 1 << 7),
pair<gint, gint>(8, 1 << 8), pair<gint, gint>(9, 1 << 9), pair<gint, gint>(10, 1 << 10), pair<gint, gint>(11, 1 << 11),
pair<gint, gint>(12, 1 << 12), pair<gint, gint>(13, 1 << 13), pair<gint, gint>(14, 1 << 14), pair<gint, gint>(15, 1 << 15),
pair<gint, gint>(16, 1 << 16), pair<gint, gint>(17, 1 << 17), pair<gint, gint>(18, 1 << 18), pair<gint, gint>(19, 1 << 19),
pair<gint, gint>(20, 1 << 20), pair<gint, gint>(21, 1 << 21), pair<gint, gint>(22, 1 << 22), pair<gint, gint>(23, 1 << 23)
};
static const int RUNAWAY_MAX = 1000;
{
switch (source) {
case GDK_SOURCE_MOUSE:
name ="pointer";
break;
case GDK_SOURCE_PEN:
name ="pen";
break;
case GDK_SOURCE_ERASER:
name ="eraser";
break;
case GDK_SOURCE_CURSOR:
name ="cursor";
break;
default:
name = "tablet";
}
return name;
}
{
static bool init = false;
if (!init) {
init = true;
}
return mapping;
}
{
static bool init = false;
if (!init) {
init = true;
for (std::map<Glib::ustring, Gdk::AxisUse>::iterator it = getStringToAxis().begin(); it != getStringToAxis().end(); ++it) {
}
}
return mapping;
}
{
static bool init = false;
if (!init) {
init = true;
}
return mapping;
}
{
static bool init = false;
if (!init) {
init = true;
for (std::map<Glib::ustring, Gdk::InputMode>::iterator it = getStringToMode().begin(); it != getStringToMode().end(); ++it) {
}
}
return mapping;
}
{}
InputDevice::~InputDevice() {}
class InputDeviceImpl : public InputDevice {
public:
virtual ~InputDeviceImpl() {}
#if WITH_GTKMM_3_0
#else
#endif
// internal methods not on public superclass:
private:
void operator=(InputDeviceImpl const &); // no assign
static Glib::ustring createId(Glib::ustring const &id, Gdk::InputSource source, std::set<Glib::ustring> &knownIDs);
};
public:
private:
};
public:
private:
};
InputDeviceImpl::InputDeviceImpl(Glib::RefPtr<Gdk::Device> device, std::set<Glib::ustring> &knownIDs)
: InputDevice(),
id(),
link(),
liveAxes(0),
liveButtons(0)
{
}
{
// Start with only allowing printable ASCII. Check later for more refinements.
}
switch ( source ) {
case Gdk::SOURCE_MOUSE:
base = "M:";
break;
case Gdk::SOURCE_CURSOR:
base = "C:";
break;
case Gdk::SOURCE_PEN:
base = "P:";
break;
case Gdk::SOURCE_ERASER:
base = "E:";
break;
default:
base = "?:";
}
if (badName) {
} else {
}
// now ensure that all IDs become unique in a session.
int num = 1;
}
return result;
}
class DeviceManagerImpl : public DeviceManager {
public:
virtual void loadConfig();
virtual void saveConfig();
protected:
};
devices()
{
#if WITH_GTKMM_3_0
#else
#endif
if ( !fakeList ) {
}
//devList = fakeList;
for ( std::vector< Glib::RefPtr<Gdk::Device> >::iterator dev = devList.begin(); dev != devList.end(); ++dev ) {
#if WITH_GTKMM_3_0
// GTK+ 3 has added keyboards to the list of supported devices.
#endif
#if DEBUG_VERBOSE
g_message("device: name[%s] source[0x%x] mode[0x%x] cursor[%s] axis count[%d] key count[%d]", dev->name, dev->source, dev->mode,
#endif
#if WITH_GTKMM_3_0
}
#endif
}
}
void DeviceManagerImpl::loadConfig()
{
for (std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = devices.begin(); it != devices.end(); ++it) {
}
}
//
}
}
}
}
}
}
}
}
}
void DeviceManagerImpl::saveConfig()
{
for (std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = devices.begin(); it != devices.end(); ++it) {
if (i > 0) {
tmp += ";";
}
}
tmp = "";
if (i > 0) {
tmp += ";";
}
}
}
}
}
{
for ( std::list<Glib::RefPtr<InputDeviceImpl> >::const_iterator it = devices.begin(); it != devices.end(); ++it ) {
}
return tmp;
}
{
std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
if (success) {
} else {
}
}
}
}
{
std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
}
} else {
g_warning("Invalid device axis number %d on extended input device [%s]", index, (*it)->getId().c_str());
}
}
}
}
void DeviceManagerImpl::setKey( Glib::ustring const & id, guint index, guint keyval, Gdk::ModifierType mods )
{
//static void setDeviceKey( GdkDevice* device, guint index, guint keyval, GdkModifierType modifiers )
//
std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
}
}
}
{
return signalDeviceChangedPriv;
}
{
return signalAxesChangedPriv;
}
{
return signalButtonsChangedPriv;
}
{
return signalLinkChangedPriv;
}
{
std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
// Only signal if a new axis was added
}
}
}
}
{
std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
// Only signal if a new button was added
}
}
}
}
{
std::list<Glib::RefPtr<InputDeviceImpl> >::iterator it = std::find_if(devices.begin(), devices.end(), IdMatcher(id));
// Need to be sure the target of the link exists
}
}
// only muck about if they aren't already linked
if ( targetDev ) {
// Is something else already using that link?
}
}
}
if ( targetDev ) {
}
for ( std::list<Glib::RefPtr<InputDeviceImpl> >::const_iterator iter = changedItems.begin(); iter != changedItems.end(); ++iter ) {
}
}
}
}
static DeviceManagerImpl* theInstance = 0;
{
}
DeviceManager::~DeviceManager() {
}
if ( !theInstance ) {
theInstance = new DeviceManagerImpl();
}
return *theInstance;
}
} // namespace Inkscape
static void createFakeList() {
if ( !fakeList ) {
// try to find the first *real* core pointer
#if WITH_GTKMM_3_0
#else
#endif
// Set iterator to point at beginning of device list
// Skip past any items in the device list that are not mice
++dev;
}
#if WITH_GTKMM_3_0
#else
#endif
} else {
}
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :