device-manager.cpp revision 9e681e203a208a1994e83056bbba03f43361c6ff
/*
* 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 <glib.h>
#include <map>
#include <set>
#include <gtk/gtkaccelgroup.h>
#include "device-manager.h"
#include "preferences.h"
#define noDEBUG_VERBOSE 1
static void createFakeList();
{
bool valid = true;
}
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() {}
// 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:
};
: 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 ( !fakeList ) {
}
//devList = fakeList;
if ( dev ) {
#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
}
}
}
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 += ";";
}
tmp += gtk_accelerator_name((*it)->getDevice()->keys[i].keyval, (*it)->getDevice()->keys[i].modifiers);
}
}
}
}
{
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
GdkDeviceKey padKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}};
GdkDeviceKey eraserKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
GdkDeviceKey cursorKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
GdkDeviceKey stylusKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
static void createFakeList() {
if ( !fakeList ) {
// try to find the first *real* core pointer
}
} 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:encoding=utf-8:textwidth=99 :