diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/dmx/input/dmxinputinit.c | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/dmx/input/dmxinputinit.c')
-rw-r--r-- | xorg-server/hw/dmx/input/dmxinputinit.c | 829 |
1 files changed, 474 insertions, 355 deletions
diff --git a/xorg-server/hw/dmx/input/dmxinputinit.c b/xorg-server/hw/dmx/input/dmxinputinit.c index 16ecae38d..b22a41f56 100644 --- a/xorg-server/hw/dmx/input/dmxinputinit.c +++ b/xorg-server/hw/dmx/input/dmxinputinit.c @@ -102,7 +102,7 @@ static DMXLocalInputInfoRec DMXBackendMou = { static DMXLocalInputInfoRec DMXBackendKbd = { "backend-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_BACKEND, - 1, /* With backend-mou or console-mou */ + 1, /* With backend-mou or console-mou */ dmxCommonCopyPrivate, NULL, dmxBackendInit, NULL, NULL, dmxBackendKbdGetInfo, dmxCommonKbdOn, dmxCommonKbdOff, NULL, @@ -123,7 +123,7 @@ static DMXLocalInputInfoRec DMXConsoleMou = { static DMXLocalInputInfoRec DMXConsoleKbd = { "console-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_CONSOLE, - 1, /* With backend-mou or console-mou */ + 1, /* With backend-mou or console-mou */ dmxCommonCopyPrivate, NULL, dmxConsoleInit, dmxConsoleReInit, NULL, dmxConsoleKbdGetInfo, dmxCommonKbdOn, dmxCommonKbdOff, NULL, @@ -133,87 +133,78 @@ static DMXLocalInputInfoRec DMXConsoleKbd = { }; static DMXLocalInputInfoRec DMXLocalDevices[] = { - /* Dummy drivers that can compile on any OS */ + /* Dummy drivers that can compile on any OS */ #ifdef __linux__ - /* Linux-specific drivers */ + /* Linux-specific drivers */ { - "kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1, - kbdLinuxCreatePrivate, kbdLinuxDestroyPrivate, - kbdLinuxInit, NULL, NULL, kbdLinuxGetInfo, - kbdLinuxOn, kbdLinuxOff, NULL, - kbdLinuxVTPreSwitch, kbdLinuxVTPostSwitch, kbdLinuxVTSwitch, - kbdLinuxRead, NULL, NULL, NULL, - NULL, kbdLinuxCtrl, kbdLinuxBell - }, + "kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1, + kbdLinuxCreatePrivate, kbdLinuxDestroyPrivate, + kbdLinuxInit, NULL, NULL, kbdLinuxGetInfo, + kbdLinuxOn, kbdLinuxOff, NULL, + kbdLinuxVTPreSwitch, kbdLinuxVTPostSwitch, kbdLinuxVTSwitch, + kbdLinuxRead, NULL, NULL, NULL, + NULL, kbdLinuxCtrl, kbdLinuxBell}, { - "ms", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, - msLinuxCreatePrivate, msLinuxDestroyPrivate, - msLinuxInit, NULL, NULL, msLinuxGetInfo, - msLinuxOn, msLinuxOff, NULL, - msLinuxVTPreSwitch, msLinuxVTPostSwitch, NULL, - msLinuxRead - }, + "ms", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, + msLinuxCreatePrivate, msLinuxDestroyPrivate, + msLinuxInit, NULL, NULL, msLinuxGetInfo, + msLinuxOn, msLinuxOff, NULL, + msLinuxVTPreSwitch, msLinuxVTPostSwitch, NULL, + msLinuxRead}, { - "ps2", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, - ps2LinuxCreatePrivate, ps2LinuxDestroyPrivate, - ps2LinuxInit, NULL, NULL, ps2LinuxGetInfo, - ps2LinuxOn, ps2LinuxOff, NULL, - ps2LinuxVTPreSwitch, ps2LinuxVTPostSwitch, NULL, - ps2LinuxRead - }, + "ps2", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, + ps2LinuxCreatePrivate, ps2LinuxDestroyPrivate, + ps2LinuxInit, NULL, NULL, ps2LinuxGetInfo, + ps2LinuxOn, ps2LinuxOff, NULL, + ps2LinuxVTPreSwitch, ps2LinuxVTPostSwitch, NULL, + ps2LinuxRead}, #endif #ifdef __linux__ - /* USB drivers, currently only for - Linux, but relatively easy to port to - other OSs */ + /* USB drivers, currently only for + Linux, but relatively easy to port to + other OSs */ { - "usb-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1, - usbCreatePrivate, usbDestroyPrivate, - kbdUSBInit, NULL, NULL, kbdUSBGetInfo, - kbdUSBOn, usbOff, NULL, - NULL, NULL, NULL, - kbdUSBRead, NULL, NULL, NULL, - NULL, kbdUSBCtrl - }, + "usb-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1, + usbCreatePrivate, usbDestroyPrivate, + kbdUSBInit, NULL, NULL, kbdUSBGetInfo, + kbdUSBOn, usbOff, NULL, + NULL, NULL, NULL, + kbdUSBRead, NULL, NULL, NULL, + NULL, kbdUSBCtrl}, { - "usb-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, - usbCreatePrivate, usbDestroyPrivate, - mouUSBInit, NULL, NULL, mouUSBGetInfo, - mouUSBOn, usbOff, NULL, - NULL, NULL, NULL, - mouUSBRead - }, + "usb-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, + usbCreatePrivate, usbDestroyPrivate, + mouUSBInit, NULL, NULL, mouUSBGetInfo, + mouUSBOn, usbOff, NULL, + NULL, NULL, NULL, + mouUSBRead}, { - "usb-oth", DMX_LOCAL_OTHER, DMX_LOCAL_TYPE_LOCAL, 1, - usbCreatePrivate, usbDestroyPrivate, - othUSBInit, NULL, NULL, othUSBGetInfo, - othUSBOn, usbOff, NULL, - NULL, NULL, NULL, - othUSBRead - }, + "usb-oth", DMX_LOCAL_OTHER, DMX_LOCAL_TYPE_LOCAL, 1, + usbCreatePrivate, usbDestroyPrivate, + othUSBInit, NULL, NULL, othUSBGetInfo, + othUSBOn, usbOff, NULL, + NULL, NULL, NULL, + othUSBRead}, #endif { - "dummy-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, - NULL, NULL, NULL, NULL, NULL, dmxDummyMouGetInfo - }, + "dummy-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1, + NULL, NULL, NULL, NULL, NULL, dmxDummyMouGetInfo}, { - "dummy-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1, - NULL, NULL, NULL, NULL, NULL, dmxDummyKbdGetInfo - }, - { NULL } /* Must be last */ + "dummy-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1, + NULL, NULL, NULL, NULL, NULL, dmxDummyKbdGetInfo}, + {NULL} /* Must be last */ }; - #if 11 /*BP*/ -void + void DDXRingBell(int volume, int pitch, int duration) { - /* NO-OP */ + /* NO-OP */ } /* taken from kdrive/src/kinput.c: */ static void -dmxKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl) +dmxKbdCtrl(DeviceIntPtr pDevice, KeybdCtrl * ctrl) { #if 0 KdKeyboardInfo *ki; @@ -228,7 +219,7 @@ dmxKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl) KdSetLeds(ki, ctrl->leds); ki->bellPitch = ctrl->bell_pitch; - ki->bellDuration = ctrl->bell_duration; + ki->bellDuration = ctrl->bell_duration; #endif } @@ -239,7 +230,7 @@ dmxBell(int volume, DeviceIntPtr pDev, pointer arg, int something) #if 0 KeybdCtrl *ctrl = arg; KdKeyboardInfo *ki = NULL; - + for (ki = kdKeyboards; ki; ki = ki->next) { if (ki->dixdev && ki->dixdev->id == pDev->id) break; @@ -247,50 +238,56 @@ dmxBell(int volume, DeviceIntPtr pDev, pointer arg, int something) if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver) return; - + KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration); #endif } #endif /*BP*/ - -static void _dmxChangePointerControl(DMXLocalInputInfoPtr dmxLocal, - PtrCtrl *ctrl) + static void +_dmxChangePointerControl(DMXLocalInputInfoPtr dmxLocal, PtrCtrl * ctrl) { - if (!dmxLocal) return; + if (!dmxLocal) + return; dmxLocal->mctrl = *ctrl; - if (dmxLocal->mCtrl) dmxLocal->mCtrl(&dmxLocal->pDevice->public, ctrl); + if (dmxLocal->mCtrl) + dmxLocal->mCtrl(&dmxLocal->pDevice->public, ctrl); } /** Change the pointer control information for the \a pDevice. If the * device sends core events, then also change the control information * for all of the pointer devices that send core events. */ -void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl *ctrl) +void +dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl * ctrl) { GETDMXLOCALFROMPDEVICE; int i, j; - if (dmxLocal->sendsCore) { /* Do for all core devices */ + if (dmxLocal->sendsCore) { /* Do for all core devices */ for (i = 0; i < dmxNumInputs; i++) { DMXInputInfo *dmxInput = &dmxInputs[i]; - if (dmxInput->detached) continue; + + if (dmxInput->detached) + continue; for (j = 0; j < dmxInput->numDevs; j++) if (dmxInput->devs[j]->sendsCore) _dmxChangePointerControl(dmxInput->devs[j], ctrl); } - } else { /* Do for this device only */ + } + else { /* Do for this device only */ _dmxChangePointerControl(dmxLocal, ctrl); } } -static void _dmxKeyboardKbdCtrlProc(DMXLocalInputInfoPtr dmxLocal, - KeybdCtrl *ctrl) +static void +_dmxKeyboardKbdCtrlProc(DMXLocalInputInfoPtr dmxLocal, KeybdCtrl * ctrl) { dmxLocal->kctrl = *ctrl; if (dmxLocal->kCtrl) { dmxLocal->kCtrl(&dmxLocal->pDevice->public, ctrl); if (dmxLocal->pDevice->kbdfeed) { XkbEventCauseRec cause; + XkbSetCauseUnknown(&cause); /* Generate XKB events, as necessary */ XkbUpdateIndicators(dmxLocal->pDevice, XkbAllIndicatorsMask, False, @@ -299,69 +296,84 @@ static void _dmxKeyboardKbdCtrlProc(DMXLocalInputInfoPtr dmxLocal, } } - /** Change the keyboard control information for the \a pDevice. If the * device sends core events, then also change the control information * for all of the keyboard devices that send core events. */ -void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl) +void +dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl * ctrl) { GETDMXLOCALFROMPDEVICE; int i, j; - if (dmxLocal->sendsCore) { /* Do for all core devices */ + if (dmxLocal->sendsCore) { /* Do for all core devices */ for (i = 0; i < dmxNumInputs; i++) { DMXInputInfo *dmxInput = &dmxInputs[i]; - if (dmxInput->detached) continue; + + if (dmxInput->detached) + continue; for (j = 0; j < dmxInput->numDevs; j++) if (dmxInput->devs[j]->sendsCore) _dmxKeyboardKbdCtrlProc(dmxInput->devs[j], ctrl); } - } else { /* Do for this device only */ + } + else { /* Do for this device only */ _dmxKeyboardKbdCtrlProc(dmxLocal, ctrl); } } -static void _dmxKeyboardBellProc(DMXLocalInputInfoPtr dmxLocal, int percent) +static void +_dmxKeyboardBellProc(DMXLocalInputInfoPtr dmxLocal, int percent) { - if (dmxLocal->kBell) dmxLocal->kBell(&dmxLocal->pDevice->public, - percent, - dmxLocal->kctrl.bell, - dmxLocal->kctrl.bell_pitch, - dmxLocal->kctrl.bell_duration); + if (dmxLocal->kBell) + dmxLocal->kBell(&dmxLocal->pDevice->public, + percent, + dmxLocal->kctrl.bell, + dmxLocal->kctrl.bell_pitch, + dmxLocal->kctrl.bell_duration); } /** Sound the bell on the device. If the device send core events, then * sound the bell on all of the devices that send core events. */ -void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice, - pointer ctrl, int unknown) +void +dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice, + pointer ctrl, int unknown) { GETDMXLOCALFROMPDEVICE; int i, j; - if (dmxLocal->sendsCore) { /* Do for all core devices */ + if (dmxLocal->sendsCore) { /* Do for all core devices */ for (i = 0; i < dmxNumInputs; i++) { DMXInputInfo *dmxInput = &dmxInputs[i]; - if (dmxInput->detached) continue; + + if (dmxInput->detached) + continue; for (j = 0; j < dmxInput->numDevs; j++) if (dmxInput->devs[j]->sendsCore) _dmxKeyboardBellProc(dmxInput->devs[j], percent); } - } else { /* Do for this device only */ + } + else { /* Do for this device only */ _dmxKeyboardBellProc(dmxLocal, percent); } } -static void dmxKeyboardFreeNames(XkbComponentNamesPtr names) +static void +dmxKeyboardFreeNames(XkbComponentNamesPtr names) { - if (names->keycodes) XFree(names->keycodes); - if (names->types) XFree(names->types); - if (names->compat) XFree(names->compat); - if (names->symbols) XFree(names->symbols); - if (names->geometry) XFree(names->geometry); + if (names->keycodes) + XFree(names->keycodes); + if (names->types) + XFree(names->types); + if (names->compat) + XFree(names->compat); + if (names->symbols) + XFree(names->symbols); + if (names->geometry) + XFree(names->geometry); } - -static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info) +static int +dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo * info) { GETDMXINPUTFROMPDEVICE; XkbRMLVOSet rmlvo; @@ -374,14 +386,14 @@ static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info) XkbSetRulesDflts(&rmlvo); if (!info->force && (dmxInput->keycodes - || dmxInput->symbols - || dmxInput->geometry)) { - if (info->freenames) dmxKeyboardFreeNames(&info->names); - info->freenames = 0; + || dmxInput->symbols || dmxInput->geometry)) { + if (info->freenames) + dmxKeyboardFreeNames(&info->names); + info->freenames = 0; info->names.keycodes = dmxInput->keycodes; - info->names.types = NULL; - info->names.compat = NULL; - info->names.symbols = dmxInput->symbols; + info->names.types = NULL; + info->names.compat = NULL; + info->names.symbols = dmxInput->symbols; info->names.geometry = dmxInput->geometry; dmxLogInput(dmxInput, "XKEYBOARD: From command line: %s", @@ -391,7 +403,8 @@ static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info) if (info->names.geometry && *info->names.geometry) dmxLogInputCont(dmxInput, " %s", info->names.geometry); dmxLogInputCont(dmxInput, "\n"); - } else if (info->names.keycodes) { + } + else if (info->names.keycodes) { dmxLogInput(dmxInput, "XKEYBOARD: From device: %s", info->names.keycodes); if (info->names.symbols && *info->names.symbols) @@ -399,36 +412,36 @@ static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info) if (info->names.geometry && *info->names.geometry) dmxLogInputCont(dmxInput, " %s", info->names.geometry); dmxLogInputCont(dmxInput, "\n"); - } else { + } + else { dmxLogInput(dmxInput, "XKEYBOARD: Defaults: %s %s %s %s %s\n", dmxConfigGetXkbRules(), dmxConfigGetXkbLayout(), - dmxConfigGetXkbModel(), - dmxConfigGetXkbVariant() - ? dmxConfigGetXkbVariant() : "", - dmxConfigGetXkbOptions() + dmxConfigGetXkbModel(), dmxConfigGetXkbVariant() + ? dmxConfigGetXkbVariant() : "", dmxConfigGetXkbOptions() ? dmxConfigGetXkbOptions() : ""); } InitKeyboardDeviceStruct(pDevice, &rmlvo, - dmxKeyboardBellProc, - dmxKeyboardKbdCtrlProc); + dmxKeyboardBellProc, dmxKeyboardKbdCtrlProc); - if (info->freenames) dmxKeyboardFreeNames(&info->names); + if (info->freenames) + dmxKeyboardFreeNames(&info->names); return Success; } - -static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) +static int +dmxDeviceOnOff(DeviceIntPtr pDevice, int what) { GETDMXINPUTFROMPDEVICE; - int fd; + int fd; DMXLocalInitInfo info; - int i; - Atom btn_labels[MAX_BUTTONS] = {0}; /* FIXME */ - Atom axis_labels[MAX_VALUATORS] = {0}; /* FIXME */ + int i; + Atom btn_labels[MAX_BUTTONS] = { 0 }; /* FIXME */ + Atom axis_labels[MAX_VALUATORS] = { 0 }; /* FIXME */ - if (dmxInput->detached) return Success; + if (dmxInput->detached) + return Success; memset(&info, 0, sizeof(info)); switch (what) { @@ -450,9 +463,7 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) rmlvo.variant = dmxConfigGetXkbVariant(); rmlvo.options = dmxConfigGetXkbOptions(); - InitKeyboardDeviceStruct(pDevice, - &rmlvo, - dmxBell, dmxKbdCtrl); + InitKeyboardDeviceStruct(pDevice, &rmlvo, dmxBell, dmxKbdCtrl); } if (info.buttonClass) { InitButtonClassDeviceStruct(pDevice, info.numButtons, @@ -462,15 +473,15 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) if (info.numRelAxes && dmxLocal->sendsCore) { InitValuatorClassDeviceStruct(pDevice, info.numRelAxes, axis_labels, - GetMaximumEventsNum(), - Relative); + GetMaximumEventsNum(), Relative); for (i = 0; i < info.numRelAxes; i++) InitValuatorAxisStruct(pDevice, i, axis_labels[i], info.minval[i], info.maxval[i], info.res[i], info.minres[i], info.maxres[i], Relative); - } else if (info.numRelAxes) { + } + else if (info.numRelAxes) { InitValuatorClassDeviceStruct(pDevice, info.numRelAxes, axis_labels, dmxPointerGetMotionBufferSize(), @@ -481,7 +492,8 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) info.maxval[i], info.res[i], info.minres[i], info.maxres[i], Relative); - } else if (info.numAbsAxes) { + } + else if (info.numAbsAxes) { InitValuatorClassDeviceStruct(pDevice, info.numAbsAxes, axis_labels, dmxPointerGetMotionBufferSize(), @@ -494,8 +506,10 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) info.maxres[i], Absolute); } } - if (info.focusClass) InitFocusClassDeviceStruct(pDevice); - if (info.proximityClass) InitProximityClassDeviceStruct(pDevice); + if (info.focusClass) + InitFocusClassDeviceStruct(pDevice); + if (info.proximityClass) + InitProximityClassDeviceStruct(pDevice); if (info.ptrFeedbackClass) InitPtrFeedbackClassDeviceStruct(pDevice, dmxChangePointerControl); if (info.intFeedbackClass || info.strFeedbackClass) @@ -516,12 +530,13 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) break; case DEVICE_OFF: case DEVICE_CLOSE: - /* This can get called twice consecutively: once for a - * detached screen (DEVICE_OFF), and then again at server - * generation time (DEVICE_CLOSE). */ + /* This can get called twice consecutively: once for a + * detached screen (DEVICE_OFF), and then again at server + * generation time (DEVICE_CLOSE). */ if (pDev->on) { dmxSigioUnregister(dmxInput); - if (dmxLocal->off) dmxLocal->off(pDev); + if (dmxLocal->off) + dmxLocal->off(pDev); pDev->on = FALSE; } break; @@ -530,17 +545,19 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) XFree(info.keySyms.map); info.keySyms.map = NULL; } - if (info.xkb) XkbFreeKeyboard(info.xkb, 0, True); + if (info.xkb) + XkbFreeKeyboard(info.xkb, 0, True); return Success; } -static void dmxProcessInputEvents(DMXInputInfo *dmxInput) +static void +dmxProcessInputEvents(DMXInputInfo * dmxInput) { int i; mieqProcessInputEvents(); #if 00 /*BP*/ - miPointerUpdate(); + miPointerUpdate(); #endif if (dmxInput->detached) return; @@ -550,30 +567,44 @@ static void dmxProcessInputEvents(DMXInputInfo *dmxInput) } #if 11 /*BP*/ - mieqProcessInputEvents(); + mieqProcessInputEvents(); #endif } -static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput, - DMXUpdateType type, - WindowPtr pWindow) +static void +dmxUpdateWindowInformation(DMXInputInfo * dmxInput, + DMXUpdateType type, WindowPtr pWindow) { int i; #ifdef PANORAMIX - if (!noPanoramiXExtension && pWindow && pWindow->parent != screenInfo.screens[0]->root) + if (!noPanoramiXExtension && pWindow && + pWindow->parent != screenInfo.screens[0]->root) return; #endif #if DMX_WINDOW_DEBUG { const char *name = "Unknown"; + switch (type) { - case DMX_UPDATE_REALIZE: name = "Realize"; break; - case DMX_UPDATE_UNREALIZE: name = "Unrealize"; break; - case DMX_UPDATE_RESTACK: name = "Restack"; break; - case DMX_UPDATE_COPY: name = "Copy"; break; - case DMX_UPDATE_RESIZE: name = "Resize"; break; - case DMX_UPDATE_REPARENT: name = "Repaint"; break; + case DMX_UPDATE_REALIZE: + name = "Realize"; + break; + case DMX_UPDATE_UNREALIZE: + name = "Unrealize"; + break; + case DMX_UPDATE_RESTACK: + name = "Restack"; + break; + case DMX_UPDATE_COPY: + name = "Copy"; + break; + case DMX_UPDATE_RESIZE: + name = "Resize"; + break; + case DMX_UPDATE_REPARENT: + name = "Repaint"; + break; } dmxLog(dmxDebug, "Window %p changed: %s\n", pWindow, name); } @@ -587,7 +618,8 @@ static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput, type, pWindow); } -static void dmxCollectAll(DMXInputInfo *dmxInput) +static void +dmxCollectAll(DMXInputInfo * dmxInput) { int i; @@ -595,29 +627,29 @@ static void dmxCollectAll(DMXInputInfo *dmxInput) return; for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding) if (dmxInput->devs[i]->collect_events) - dmxInput->devs[i]->collect_events(&dmxInput->devs[i]->pDevice->public, - dmxMotion, - dmxEnqueue, + dmxInput->devs[i]->collect_events(&dmxInput->devs[i]->pDevice-> + public, dmxMotion, dmxEnqueue, dmxCheckSpecialKeys, DMX_BLOCK); } -static void dmxBlockHandler(pointer blockData, OSTimePtr pTimeout, - pointer pReadMask) +static void +dmxBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadMask) { - DMXInputInfo *dmxInput = &dmxInputs[(uintptr_t)blockData]; + DMXInputInfo *dmxInput = &dmxInputs[(uintptr_t) blockData]; static unsigned long generation = 0; - + if (generation != serverGeneration) { generation = serverGeneration; dmxCollectAll(dmxInput); } } -static void dmxSwitchReturn(pointer p) +static void +dmxSwitchReturn(pointer p) { DMXInputInfo *dmxInput = p; - int i; - + int i; + dmxLog(dmxInfo, "Returning from VT %d\n", dmxInput->vt_switched); if (!dmxInput->vt_switched) @@ -629,25 +661,25 @@ static void dmxSwitchReturn(pointer p) dmxInput->vt_switched = 0; } -static void dmxWakeupHandler(pointer blockData, int result, pointer pReadMask) +static void +dmxWakeupHandler(pointer blockData, int result, pointer pReadMask) { - DMXInputInfo *dmxInput = &dmxInputs[(uintptr_t)blockData]; - int i; + DMXInputInfo *dmxInput = &dmxInputs[(uintptr_t) blockData]; + int i; if (dmxInput->vt_switch_pending) { dmxLog(dmxInfo, "Switching to VT %d\n", dmxInput->vt_switch_pending); for (i = 0; i < dmxInput->numDevs; i++) if (dmxInput->devs[i]->vt_pre_switch) dmxInput->devs[i]->vt_pre_switch(dmxInput->devs[i]->private); - dmxInput->vt_switched = dmxInput->vt_switch_pending; + dmxInput->vt_switched = dmxInput->vt_switch_pending; dmxInput->vt_switch_pending = 0; for (i = 0; i < dmxInput->numDevs; i++) { if (dmxInput->devs[i]->vt_switch) { dmxSigioDisableInput(); if (!dmxInput->devs[i]->vt_switch(dmxInput->devs[i]->private, dmxInput->vt_switched, - dmxSwitchReturn, - dmxInput)) + dmxSwitchReturn, dmxInput)) dmxSwitchReturn(dmxInput); break; /* Only call one vt_switch routine */ } @@ -656,35 +688,44 @@ static void dmxWakeupHandler(pointer blockData, int result, pointer pReadMask) dmxCollectAll(dmxInput); } -static char *dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal) +static char * +dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal) { - static int k = 0; - static int m = 0; - static int o = 0; + static int k = 0; + static int m = 0; + static int o = 0; static unsigned long dmxGeneration = 0; + #define LEN 32 - char * buf = malloc(LEN); + char *buf = malloc(LEN); if (dmxGeneration != serverGeneration) { - k = m = o = 0; + k = m = o = 0; dmxGeneration = serverGeneration; } switch (dmxLocal->type) { - case DMX_LOCAL_KEYBOARD: snprintf(buf, LEN, "Keyboard%d", k++); break; - case DMX_LOCAL_MOUSE: snprintf(buf, LEN, "Mouse%d", m++); break; - default: snprintf(buf, LEN, "Other%d", o++); break; + case DMX_LOCAL_KEYBOARD: + snprintf(buf, LEN, "Keyboard%d", k++); + break; + case DMX_LOCAL_MOUSE: + snprintf(buf, LEN, "Mouse%d", m++); + break; + default: + snprintf(buf, LEN, "Other%d", o++); + break; } return buf; } -static DeviceIntPtr dmxAddDevice(DMXLocalInputInfoPtr dmxLocal) +static DeviceIntPtr +dmxAddDevice(DMXLocalInputInfoPtr dmxLocal) { DeviceIntPtr pDevice; - Atom atom; - const char *name = NULL; - char *devname; + Atom atom; + const char *name = NULL; + char *devname; DMXInputInfo *dmxInput; if (!dmxLocal) @@ -693,41 +734,41 @@ static DeviceIntPtr dmxAddDevice(DMXLocalInputInfoPtr dmxLocal) if (dmxLocal->sendsCore) { if (dmxLocal->type == DMX_LOCAL_KEYBOARD && !dmxLocalCoreKeyboard) { - dmxLocal->isCore = 1; + dmxLocal->isCore = 1; dmxLocalCoreKeyboard = dmxLocal; - name = "keyboard"; + name = "keyboard"; } if (dmxLocal->type == DMX_LOCAL_MOUSE && !dmxLocalCorePointer) { - dmxLocal->isCore = 1; - dmxLocalCorePointer = dmxLocal; - name = "pointer"; + dmxLocal->isCore = 1; + dmxLocalCorePointer = dmxLocal; + name = "pointer"; } } if (!name) { - name = "extension"; + name = "extension"; } if (!name) dmxLog(dmxFatal, "Cannot add device %s\n", dmxLocal->name); - pDevice = AddInputDevice(serverClient, dmxDeviceOnOff, TRUE); + pDevice = AddInputDevice(serverClient, dmxDeviceOnOff, TRUE); if (!pDevice) { dmxLog(dmxError, "Too many devices -- cannot add device %s\n", dmxLocal->name); return NULL; } pDevice->public.devicePrivate = dmxLocal; - dmxLocal->pDevice = pDevice; + dmxLocal->pDevice = pDevice; - devname = dmxMakeUniqueDeviceName(dmxLocal); - atom = MakeAtom((char *)devname, strlen(devname), TRUE); + devname = dmxMakeUniqueDeviceName(dmxLocal); + atom = MakeAtom((char *) devname, strlen(devname), TRUE); pDevice->type = atom; pDevice->name = devname; if (dmxLocal->isCore && dmxLocal->type == DMX_LOCAL_MOUSE) { -#if 00 /*BP*/ - miRegisterPointerDevice(screenInfo.screens[0], pDevice); +#if 00 /*BP*/ + miRegisterPointerDevice(screenInfo.screens[0], pDevice); #else /* Nothing? dmxDeviceOnOff() should get called to init, right? */ #endif @@ -740,60 +781,62 @@ static DeviceIntPtr dmxAddDevice(DMXLocalInputInfoPtr dmxLocal) dmxLocal->name, name, devname, dmxLocal->isCore ? " [core]" - : (dmxLocal->sendsCore - ? " [sends core events]" - : "")); + : (dmxLocal->sendsCore ? " [sends core events]" : "")); return pDevice; } -static DMXLocalInputInfoPtr dmxLookupLocal(const char *name) +static DMXLocalInputInfoPtr +dmxLookupLocal(const char *name) { DMXLocalInputInfoPtr pt; - + for (pt = &DMXLocalDevices[0]; pt->name; ++pt) - if (!strcmp(pt->name, name)) return pt; /* search for device name */ + if (!strcmp(pt->name, name)) + return pt; /* search for device name */ return NULL; } /** Copy the local input information from \a s into a new \a devs slot * in \a dmxInput. */ -DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo *dmxInput, - DMXLocalInputInfoPtr s) +DMXLocalInputInfoPtr +dmxInputCopyLocal(DMXInputInfo * dmxInput, DMXLocalInputInfoPtr s) { DMXLocalInputInfoPtr dmxLocal = malloc(sizeof(*dmxLocal)); - + if (!dmxLocal) dmxLog(dmxFatal, "DMXLocalInputInfoPtr: out of memory\n"); memcpy(dmxLocal, s, sizeof(*dmxLocal)); - dmxLocal->inputIdx = dmxInput->inputIdx; - dmxLocal->sendsCore = dmxInput->core; + dmxLocal->inputIdx = dmxInput->inputIdx; + dmxLocal->sendsCore = dmxInput->core; dmxLocal->savedSendsCore = dmxInput->core; - dmxLocal->deviceId = -1; + dmxLocal->deviceId = -1; ++dmxInput->numDevs; dmxInput->devs = realloc(dmxInput->devs, - dmxInput->numDevs * sizeof(*dmxInput->devs)); - dmxInput->devs[dmxInput->numDevs-1] = dmxLocal; - + dmxInput->numDevs * sizeof(*dmxInput->devs)); + dmxInput->devs[dmxInput->numDevs - 1] = dmxLocal; + return dmxLocal; } -static void dmxPopulateLocal(DMXInputInfo *dmxInput, dmxArg a) +static void +dmxPopulateLocal(DMXInputInfo * dmxInput, dmxArg a) { - int i; - int help = 0; + int i; + int help = 0; DMXLocalInputInfoRec *pt; for (i = 1; i < dmxArgC(a); i++) { const char *name = dmxArgV(a, i); + if ((pt = dmxLookupLocal(name))) { dmxInputCopyLocal(dmxInput, pt); - } else { + } + else { if (strlen(name)) - dmxLog(dmxWarning, - "Could not find a driver called %s\n", name); + dmxLog(dmxWarning, "Could not find a driver called %s\n", name); ++help; } } @@ -801,10 +844,17 @@ static void dmxPopulateLocal(DMXInputInfo *dmxInput, dmxArg a) dmxLog(dmxInfo, "Available local device drivers:\n"); for (pt = &DMXLocalDevices[0]; pt->name; ++pt) { const char *type; + switch (pt->type) { - case DMX_LOCAL_KEYBOARD: type = "keyboard"; break; - case DMX_LOCAL_MOUSE: type = "pointer"; break; - default: type = "unknown"; break; + case DMX_LOCAL_KEYBOARD: + type = "keyboard"; + break; + case DMX_LOCAL_MOUSE: + type = "pointer"; + break; + default: + type = "unknown"; + break; } dmxLog(dmxInfo, " %s (%s)\n", pt->name, type); } @@ -812,30 +862,35 @@ static void dmxPopulateLocal(DMXInputInfo *dmxInput, dmxArg a) } } -int dmxInputExtensionErrorHandler(Display *dsp, _Xconst char *name, _Xconst char *reason) +int +dmxInputExtensionErrorHandler(Display * dsp, _Xconst char *name, + _Xconst char *reason) { return 0; } -static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI) +static void +dmxInputScanForExtensions(DMXInputInfo * dmxInput, int doXI) { - XExtensionVersion *ext; - XDeviceInfo *devices; - Display *display; - int num; - int i, j; - XextErrorHandler handler; - - if (!(display = XOpenDisplay(dmxInput->name))) return; - + XExtensionVersion *ext; + XDeviceInfo *devices; + Display *display; + int num; + int i, j; + XextErrorHandler handler; + + if (!(display = XOpenDisplay(dmxInput->name))) + return; + /* Print out information about the XInput Extension. */ handler = XSetExtensionErrorHandler(dmxInputExtensionErrorHandler); - ext = XGetExtensionVersion(display, INAME); + ext = XGetExtensionVersion(display, INAME); XSetExtensionErrorHandler(handler); - - if (!ext || ext == (XExtensionVersion *)NoSuchExtension) { + + if (!ext || ext == (XExtensionVersion *) NoSuchExtension) { dmxLogInput(dmxInput, "%s is not available\n", INAME); - } else { + } + else { dmxLogInput(dmxInput, "Locating devices on %s (%s version %d.%d)\n", dmxInput->name, INAME, ext->major_version, ext->minor_version); @@ -844,31 +899,41 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI) XFree(ext); ext = NULL; - /* Print a list of all devices */ + /* Print a list of all devices */ for (i = 0; i < num; i++) { const char *use = "Unknown"; + switch (devices[i].use) { - case IsXPointer: use = "XPointer"; break; - case IsXKeyboard: use = "XKeyboard"; break; - case IsXExtensionDevice: use = "XExtensionDevice"; break; - case IsXExtensionPointer: use = "XExtensionPointer"; break; - case IsXExtensionKeyboard: use = "XExtensionKeyboard"; break; + case IsXPointer: + use = "XPointer"; + break; + case IsXKeyboard: + use = "XKeyboard"; + break; + case IsXExtensionDevice: + use = "XExtensionDevice"; + break; + case IsXExtensionPointer: + use = "XExtensionPointer"; + break; + case IsXExtensionKeyboard: + use = "XExtensionKeyboard"; + break; } dmxLogInput(dmxInput, " %2d %-10.10s %-16.16s\n", devices[i].id, - devices[i].name ? devices[i].name : "", - use); + devices[i].name ? devices[i].name : "", use); } - /* Search for extensions */ + /* Search for extensions */ for (i = 0; i < num; i++) { switch (devices[i].use) { case IsXKeyboard: for (j = 0; j < dmxInput->numDevs; j++) { DMXLocalInputInfoPtr dmxL = dmxInput->devs[j]; - if (dmxL->type == DMX_LOCAL_KEYBOARD - && dmxL->deviceId < 0) { - dmxL->deviceId = devices[i].id; + + if (dmxL->type == DMX_LOCAL_KEYBOARD && dmxL->deviceId < 0) { + dmxL->deviceId = devices[i].id; dmxL->deviceName = (devices[i].name ? strdup(devices[i].name) : NULL); @@ -878,8 +943,9 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI) case IsXPointer: for (j = 0; j < dmxInput->numDevs; j++) { DMXLocalInputInfoPtr dmxL = dmxInput->devs[j]; + if (dmxL->type == DMX_LOCAL_MOUSE && dmxL->deviceId < 0) { - dmxL->deviceId = devices[i].id; + dmxL->deviceId = devices[i].id; dmxL->deviceName = (devices[i].name ? xstrdup(devices[i].name) : NULL); @@ -895,12 +961,14 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI) /** Re-initialize all the devices described in \a dmxInput. Called from #dmxAdjustCursorBoundaries before the cursor is redisplayed. */ -void dmxInputReInit(DMXInputInfo *dmxInput) +void +dmxInputReInit(DMXInputInfo * dmxInput) { int i; for (i = 0; i < dmxInput->numDevs; i++) { DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; + if (dmxLocal->reinit) dmxLocal->reinit(&dmxLocal->pDevice->public); } @@ -908,28 +976,31 @@ void dmxInputReInit(DMXInputInfo *dmxInput) /** Re-initialize all the devices described in \a dmxInput. Called from #dmxAdjustCursorBoundaries after the cursor is redisplayed. */ -void dmxInputLateReInit(DMXInputInfo *dmxInput) +void +dmxInputLateReInit(DMXInputInfo * dmxInput) { int i; for (i = 0; i < dmxInput->numDevs; i++) { DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; + if (dmxLocal->latereinit) dmxLocal->latereinit(&dmxLocal->pDevice->public); } } /** Initialize all of the devices described in \a dmxInput. */ -void dmxInputInit(DMXInputInfo *dmxInput) +void +dmxInputInit(DMXInputInfo * dmxInput) { - DeviceIntPtr pPointer = NULL, pKeyboard = NULL; - dmxArg a; - const char *name; - int i; - int doXI = 1; /* Include by default */ - int forceConsole = 0; - int doWindows = 1; /* On by default */ - int hasXkb = 0; + DeviceIntPtr pPointer = NULL, pKeyboard = NULL; + dmxArg a; + const char *name; + int i; + int doXI = 1; /* Include by default */ + int forceConsole = 0; + int doWindows = 1; /* On by default */ + int hasXkb = 0; a = dmxArgParse(dmxInput->name); @@ -940,7 +1011,7 @@ void dmxInputInit(DMXInputInfo *dmxInput) ++hasXkb; break; case 2: - dmxInput->symbols = xstrdup(dmxArgV(a, i)); + dmxInput->symbols = xstrdup(dmxArgV(a, i)); ++hasXkb; break; case 3: @@ -948,16 +1019,22 @@ void dmxInputInit(DMXInputInfo *dmxInput) hasXkb = 0; break; case 0: - if (!strcmp(dmxArgV(a, i), "noxi")) doXI = 0; - else if (!strcmp(dmxArgV(a, i), "xi")) doXI = 1; - else if (!strcmp(dmxArgV(a, i), "console")) forceConsole = 1; - else if (!strcmp(dmxArgV(a, i), "noconsole")) forceConsole = 0; - else if (!strcmp(dmxArgV(a, i), "windows")) doWindows = 1; - else if (!strcmp(dmxArgV(a, i), "nowindows")) doWindows = 0; - else if (!strcmp(dmxArgV(a, i), "xkb")) hasXkb = 1; + if (!strcmp(dmxArgV(a, i), "noxi")) + doXI = 0; + else if (!strcmp(dmxArgV(a, i), "xi")) + doXI = 1; + else if (!strcmp(dmxArgV(a, i), "console")) + forceConsole = 1; + else if (!strcmp(dmxArgV(a, i), "noconsole")) + forceConsole = 0; + else if (!strcmp(dmxArgV(a, i), "windows")) + doWindows = 1; + else if (!strcmp(dmxArgV(a, i), "nowindows")) + doWindows = 0; + else if (!strcmp(dmxArgV(a, i), "xkb")) + hasXkb = 1; else { - dmxLog(dmxFatal, - "Unknown input argument: %s\n", dmxArgV(a, i)); + dmxLog(dmxFatal, "Unknown input argument: %s\n", dmxArgV(a, i)); } } } @@ -966,11 +1043,13 @@ void dmxInputInit(DMXInputInfo *dmxInput) if (!strcmp(name, "local")) { dmxPopulateLocal(dmxInput, a); - } else if (!strcmp(name, "dummy")) { + } + else if (!strcmp(name, "dummy")) { dmxInputCopyLocal(dmxInput, &DMXDummyMou); dmxInputCopyLocal(dmxInput, &DMXDummyKbd); dmxLogInput(dmxInput, "Using dummy input\n"); - } else { + } + else { int found; for (found = 0, i = 0; i < dmxNumScreens; i++) { @@ -983,10 +1062,13 @@ void dmxInputInit(DMXInputInfo *dmxInput) dmxLog(dmxWarning, "Cannot use core devices on a backend (%s)" " as XInput devices\n", name); - } else { + } + else { char *pt; - for (pt = (char *)dmxInput->name; pt && *pt; pt++) - if (*pt == ',') *pt = '\0'; + + for (pt = (char *) dmxInput->name; pt && *pt; pt++) + if (*pt == ',') + *pt = '\0'; dmxInputCopyLocal(dmxInput, &DMXBackendMou); dmxInputCopyLocal(dmxInput, &DMXBackendKbd); dmxInput->scrnIdx = i; @@ -999,13 +1081,16 @@ void dmxInputInit(DMXInputInfo *dmxInput) } if (!found || forceConsole) { char *pt; - if (found) dmxInput->console = TRUE; - for (pt = (char *)dmxInput->name; pt && *pt; pt++) - if (*pt == ',') *pt = '\0'; + + if (found) + dmxInput->console = TRUE; + for (pt = (char *) dmxInput->name; pt && *pt; pt++) + if (*pt == ',') + *pt = '\0'; dmxInputCopyLocal(dmxInput, &DMXConsoleMou); dmxInputCopyLocal(dmxInput, &DMXConsoleKbd); if (doWindows) { - dmxInput->windows = TRUE; + dmxInput->windows = TRUE; dmxInput->updateWindowInfo = dmxUpdateWindowInformation; } dmxLogInput(dmxInput, @@ -1016,50 +1101,56 @@ void dmxInputInit(DMXInputInfo *dmxInput) dmxArgFree(a); - /* Locate extensions we may be interested in */ + /* Locate extensions we may be interested in */ dmxInputScanForExtensions(dmxInput, doXI); - + for (i = 0; i < dmxInput->numDevs; i++) { DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; + dmxLocal->pDevice = dmxAddDevice(dmxLocal); if (dmxLocal->isCore) { if (dmxLocal->type == DMX_LOCAL_MOUSE) - pPointer = dmxLocal->pDevice; + pPointer = dmxLocal->pDevice; if (dmxLocal->type == DMX_LOCAL_KEYBOARD) pKeyboard = dmxLocal->pDevice; } } - - dmxInput->processInputEvents = dmxProcessInputEvents; - dmxInput->detached = False; - + + dmxInput->processInputEvents = dmxProcessInputEvents; + dmxInput->detached = False; + RegisterBlockAndWakeupHandlers(dmxBlockHandler, dmxWakeupHandler, - (void *)(uintptr_t)dmxInput->inputIdx); + (void *) (uintptr_t) dmxInput->inputIdx); } -static void dmxInputFreeLocal(DMXLocalInputInfoRec *local) +static void +dmxInputFreeLocal(DMXLocalInputInfoRec * local) { - if (!local) return; + if (!local) + return; if (local->isCore && local->type == DMX_LOCAL_MOUSE) - dmxLocalCorePointer = NULL; + dmxLocalCorePointer = NULL; if (local->isCore && local->type == DMX_LOCAL_KEYBOARD) dmxLocalCoreKeyboard = NULL; - if (local->destroy_private) local->destroy_private(local->private); + if (local->destroy_private) + local->destroy_private(local->private); free(local->history); free(local->valuators); free(local->deviceName); - local->private = NULL; - local->history = NULL; + local->private = NULL; + local->history = NULL; local->deviceName = NULL; free(local); } /** Free all of the memory associated with \a dmxInput */ -void dmxInputFree(DMXInputInfo *dmxInput) +void +dmxInputFree(DMXInputInfo * dmxInput) { int i; - - if (!dmxInput) return; + + if (!dmxInput) + return; free(dmxInput->keycodes); free(dmxInput->symbols); @@ -1070,14 +1161,16 @@ void dmxInputFree(DMXInputInfo *dmxInput) dmxInput->devs[i] = NULL; } free(dmxInput->devs); - dmxInput->devs = NULL; + dmxInput->devs = NULL; dmxInput->numDevs = 0; - if (dmxInput->freename) free(dmxInput->name); - dmxInput->name = NULL; + if (dmxInput->freename) + free(dmxInput->name); + dmxInput->name = NULL; } /** Log information about all of the known devices using #dmxLog(). */ -void dmxInputLogDevices(void) +void +dmxInputLogDevices(void) { int i, j; @@ -1085,34 +1178,43 @@ void dmxInputLogDevices(void) dmxLog(dmxInfo, " Id Name Classes\n"); for (j = 0; j < dmxNumInputs; j++) { DMXInputInfo *dmxInput = &dmxInputs[j]; - const char *pt = strchr(dmxInput->name, ','); - int len = (pt - ? (size_t)(pt-dmxInput->name) - : strlen(dmxInput->name)); + const char *pt = strchr(dmxInput->name, ','); + int len = (pt ? (size_t) (pt - dmxInput->name) + : strlen(dmxInput->name)); for (i = 0; i < dmxInput->numDevs; i++) { DeviceIntPtr pDevice = dmxInput->devs[i]->pDevice; + if (pDevice) { dmxLog(dmxInfo, " %2d%c %-20.20s", pDevice->id, - dmxInput->detached ? 'D' : ' ', - pDevice->name); - if (pDevice->key) dmxLogCont(dmxInfo, " key"); - if (pDevice->valuator) dmxLogCont(dmxInfo, " val"); - if (pDevice->button) dmxLogCont(dmxInfo, " btn"); - if (pDevice->focus) dmxLogCont(dmxInfo, " foc"); - if (pDevice->kbdfeed) dmxLogCont(dmxInfo, " fb/kbd"); - if (pDevice->ptrfeed) dmxLogCont(dmxInfo, " fb/ptr"); - if (pDevice->intfeed) dmxLogCont(dmxInfo, " fb/int"); - if (pDevice->stringfeed) dmxLogCont(dmxInfo, " fb/str"); - if (pDevice->bell) dmxLogCont(dmxInfo, " fb/bel"); - if (pDevice->leds) dmxLogCont(dmxInfo, " fb/led"); + dmxInput->detached ? 'D' : ' ', pDevice->name); + if (pDevice->key) + dmxLogCont(dmxInfo, " key"); + if (pDevice->valuator) + dmxLogCont(dmxInfo, " val"); + if (pDevice->button) + dmxLogCont(dmxInfo, " btn"); + if (pDevice->focus) + dmxLogCont(dmxInfo, " foc"); + if (pDevice->kbdfeed) + dmxLogCont(dmxInfo, " fb/kbd"); + if (pDevice->ptrfeed) + dmxLogCont(dmxInfo, " fb/ptr"); + if (pDevice->intfeed) + dmxLogCont(dmxInfo, " fb/int"); + if (pDevice->stringfeed) + dmxLogCont(dmxInfo, " fb/str"); + if (pDevice->bell) + dmxLogCont(dmxInfo, " fb/bel"); + if (pDevice->leds) + dmxLogCont(dmxInfo, " fb/led"); if (!pDevice->key && !pDevice->valuator && !pDevice->button && !pDevice->focus && !pDevice->kbdfeed && !pDevice->ptrfeed && !pDevice->intfeed - && !pDevice->stringfeed && !pDevice->bell - && !pDevice->leds) dmxLogCont(dmxInfo, " (none)"); - + && !pDevice->stringfeed && !pDevice->bell && !pDevice->leds) + dmxLogCont(dmxInfo, " (none)"); + dmxLogCont(dmxInfo, "\t[i%d/%*.*s", dmxInput->inputIdx, len, len, dmxInput->name); if (dmxInput->devs[i]->deviceId >= 0) @@ -1123,30 +1225,30 @@ void dmxInputLogDevices(void) dmxInput->devs[i]->isCore ? "core" : (dmxInput->devs[i]->sendsCore - ? "extension (sends core events)" - : "extension")); + ? "extension (sends core events)" : "extension")); } } } } /** Detach an input */ -int dmxInputDetach(DMXInputInfo *dmxInput) +int +dmxInputDetach(DMXInputInfo * dmxInput) { int i; - if (dmxInput->detached) return BadAccess; - + if (dmxInput->detached) + return BadAccess; + for (i = 0; i < dmxInput->numDevs; i++) { DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; + dmxLogInput(dmxInput, "Detaching device id %d: %s%s\n", dmxLocal->pDevice->id, dmxLocal->pDevice->name, dmxLocal->isCore ? " [core]" - : (dmxLocal->sendsCore - ? " [sends core events]" - : "")); + : (dmxLocal->sendsCore ? " [sends core events]" : "")); DisableDevice(dmxLocal->pDevice, TRUE); } dmxInput->detached = True; @@ -1155,116 +1257,133 @@ int dmxInputDetach(DMXInputInfo *dmxInput) } /** Search for input associated with \a dmxScreen, and detach. */ -void dmxInputDetachAll(DMXScreenInfo *dmxScreen) +void +dmxInputDetachAll(DMXScreenInfo * dmxScreen) { int i; for (i = 0; i < dmxNumInputs; i++) { DMXInputInfo *dmxInput = &dmxInputs[i]; - if (dmxInput->scrnIdx == dmxScreen->index) dmxInputDetach(dmxInput); + + if (dmxInput->scrnIdx == dmxScreen->index) + dmxInputDetach(dmxInput); } } /** Search for input associated with \a deviceId, and detach. */ -int dmxInputDetachId(int id) +int +dmxInputDetachId(int id) { DMXInputInfo *dmxInput = dmxInputLocateId(id); - if (!dmxInput) return BadValue; - + if (!dmxInput) + return BadValue; + return dmxInputDetach(dmxInput); } -DMXInputInfo *dmxInputLocateId(int id) +DMXInputInfo * +dmxInputLocateId(int id) { int i, j; - + for (i = 0; i < dmxNumInputs; i++) { DMXInputInfo *dmxInput = &dmxInputs[i]; + for (j = 0; j < dmxInput->numDevs; j++) { DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j]; - if (dmxLocal->pDevice->id == id) return dmxInput; + + if (dmxLocal->pDevice->id == id) + return dmxInput; } } return NULL; } -static int dmxInputAttachNew(DMXInputInfo *dmxInput, int *id) +static int +dmxInputAttachNew(DMXInputInfo * dmxInput, int *id) { dmxInputInit(dmxInput); InitAndStartDevices(); - if (id && dmxInput->devs) *id = dmxInput->devs[0]->pDevice->id; + if (id && dmxInput->devs) + *id = dmxInput->devs[0]->pDevice->id; dmxInputLogDevices(); return 0; } -static int dmxInputAttachOld(DMXInputInfo *dmxInput, int *id) +static int +dmxInputAttachOld(DMXInputInfo * dmxInput, int *id) { int i; - + dmxInput->detached = False; for (i = 0; i < dmxInput->numDevs; i++) { DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; - if (id) *id = dmxLocal->pDevice->id; + + if (id) + *id = dmxLocal->pDevice->id; dmxLogInput(dmxInput, "Attaching device id %d: %s%s\n", dmxLocal->pDevice->id, dmxLocal->pDevice->name, dmxLocal->isCore ? " [core]" - : (dmxLocal->sendsCore - ? " [sends core events]" - : "")); + : (dmxLocal->sendsCore ? " [sends core events]" : "")); EnableDevice(dmxLocal->pDevice, TRUE); } dmxInputLogDevices(); return 0; } -int dmxInputAttachConsole(const char *name, int isCore, int *id) +int +dmxInputAttachConsole(const char *name, int isCore, int *id) { - DMXInputInfo *dmxInput; - int i; + DMXInputInfo *dmxInput; + int i; for (i = 0; i < dmxNumInputs; i++) { dmxInput = &dmxInputs[i]; if (dmxInput->scrnIdx == -1 - && dmxInput->detached - && !strcmp(dmxInput->name, name)) { - /* Found match */ + && dmxInput->detached && !strcmp(dmxInput->name, name)) { + /* Found match */ dmxLogInput(dmxInput, "Reattaching detached console input\n"); return dmxInputAttachOld(dmxInput, id); } } - /* No match found */ + /* No match found */ dmxInput = dmxConfigAddInput(xstrdup(name), isCore); dmxInput->freename = TRUE; dmxLogInput(dmxInput, "Attaching new console input\n"); return dmxInputAttachNew(dmxInput, id); } -int dmxInputAttachBackend(int physicalScreen, int isCore, int *id) +int +dmxInputAttachBackend(int physicalScreen, int isCore, int *id) { - DMXInputInfo *dmxInput; + DMXInputInfo *dmxInput; DMXScreenInfo *dmxScreen; - int i; - - if (physicalScreen < 0 || physicalScreen >= dmxNumScreens) return BadValue; + int i; + + if (physicalScreen < 0 || physicalScreen >= dmxNumScreens) + return BadValue; for (i = 0; i < dmxNumInputs; i++) { dmxInput = &dmxInputs[i]; if (dmxInput->scrnIdx != -1 && dmxInput->scrnIdx == physicalScreen) { - /* Found match */ - if (!dmxInput->detached) return BadAccess; /* Already attached */ + /* Found match */ + if (!dmxInput->detached) + return BadAccess; /* Already attached */ dmxScreen = &dmxScreens[physicalScreen]; - if (!dmxScreen->beDisplay) return BadAccess; /* Screen detached */ + if (!dmxScreen->beDisplay) + return BadAccess; /* Screen detached */ dmxLogInput(dmxInput, "Reattaching detached backend input\n"); return dmxInputAttachOld(dmxInput, id); } } - /* No match found */ + /* No match found */ dmxScreen = &dmxScreens[physicalScreen]; - if (!dmxScreen->beDisplay) return BadAccess; /* Screen detached */ + if (!dmxScreen->beDisplay) + return BadAccess; /* Screen detached */ dmxInput = dmxConfigAddInput(dmxScreen->name, isCore); dmxLogInput(dmxInput, "Attaching new backend input\n"); return dmxInputAttachNew(dmxInput, id); |