checked in (request 45133) OBS-URL: https://build.opensuse.org/request/show/45133 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/orca?expand=0&rev=71
1302 lines
39 KiB
Diff
1302 lines
39 KiB
Diff
diff -ruN orca-2.22.1/src/brl/brl.h orca-brld/src/brl/brl.h
|
|
--- orca-2.22.1/src/brl/brl.h 1970-01-01 01:00:00.000000000 +0100
|
|
+++ orca-brld/src/brl/brl.h 2008-07-02 16:58:28.019175000 +0200
|
|
@@ -0,0 +1,125 @@
|
|
+#ifndef _BRL_H
|
|
+#define MYLiB "/usr/lib/suse-blinux/lib/libsbl-fhp.so.1"
|
|
+#define _BRL_H
|
|
+
|
|
+#define MAXNAMELEN 20
|
|
+#define MAXPATHLEN 100
|
|
+#define MAXSCRIPTS 200
|
|
+#define NAMELEN 7
|
|
+
|
|
+/* orca key-bindings */
|
|
+#define ORCA_LNUP 0x01
|
|
+#define ORCA_LNDN 0x02
|
|
+#define ORCA_LNLFT 0x17
|
|
+#define ORCA_LNRGT 0x18
|
|
+#define ORCA_TOPLEFT 0x0b
|
|
+#define ORCA_BOTLEFT 0x0c
|
|
+#define ORCA_CSRTRK 0x1d
|
|
+typedef struct
|
|
+{
|
|
+ int brl, kbd;
|
|
+} brlkbd;
|
|
+
|
|
+/* entries of $SBLDIR/keymap/ */
|
|
+typedef struct
|
|
+{
|
|
+ brlkbd resetbrl, line01, topleft, botleft;
|
|
+ brlkbd winup, windn, lnlft, lnrgt;
|
|
+ brlkbd lnup, lndn, csrtrk, syscsr, softcsr;
|
|
+ brlkbd chrlft, chrrgt, hwinlft, hwinrgt, fwinlft;
|
|
+ brlkbd fwinrgt, csrjump, csrjmpvert, keyup;
|
|
+ brlkbd keydn, keyrgt, keylft, keyenter, keyesc, csrvisoff;
|
|
+ brlkbd jmpmark1, jmpmark2, jmpmark3, jmpmark4;
|
|
+ brlkbd attr1, attr2, attr3, attr4;
|
|
+ brlkbd csrtrkoff, prof1, prof2, prof3, prof4;
|
|
+ brlkbd attroff, attrmodonoff, sixdotsonoff, csrblinkonoff;
|
|
+ brlkbd csrblockonoff, cutbegin, cutend, paste;
|
|
+ brlkbd spktocsr, spkfromcsr;
|
|
+ brlkbd spkmod, spkoff;
|
|
+ brlkbd spkcurln, spkscrtocsr, spkscrfromcsr;
|
|
+ brlkbd nextlang, prevlang;
|
|
+ brlkbd nextfrq, prevfrq;
|
|
+ brlkbd nextspd, prevspd;
|
|
+ brlkbd nextvol, prevvol;
|
|
+ brlkbd nextvoice, prevvoice;
|
|
+ brlkbd nextspec, prevspec;
|
|
+ brlkbd spkcharmod;
|
|
+ brlkbd kbdsniffon1, kbdsniffon2, kbdsniffoff;
|
|
+ brlkbd soundonoff, loadkeymap, autoprofonoff;
|
|
+ brlkbd setmark, jmptomark;
|
|
+ int lineroutend, lineroutbeg, csrroutend, csrroutbeg;
|
|
+ brlkbd scripts[MAXSCRIPTS];
|
|
+ char scriptnames[MAXSCRIPTS][MAXNAMELEN];
|
|
+}
|
|
+keymap_file;
|
|
+
|
|
+/* entries of /etc/suse-blinux.conf */
|
|
+typedef struct
|
|
+{
|
|
+ char brlname[MAXNAMELEN];
|
|
+ char brld_auth_key[MAXNAMELEN];
|
|
+ char brld_host[MAXNAMELEN];
|
|
+ int brld_port;
|
|
+ char brlport[MAXNAMELEN];
|
|
+ char spkname[MAXNAMELEN];
|
|
+ char spkport[MAXNAMELEN];
|
|
+ int keydelay, repeatdelay, profdelay, sleep;
|
|
+ int debug;
|
|
+ char brltbl[MAXNAMELEN];
|
|
+ char profile1[MAXNAMELEN];
|
|
+ char profile2[MAXNAMELEN];
|
|
+ char profile3[MAXNAMELEN];
|
|
+ char profile4[MAXNAMELEN];
|
|
+ char progpath[MAXPATHLEN];
|
|
+} sbl_config;
|
|
+
|
|
+/* info structure for brailledisplays */
|
|
+struct brlinfo
|
|
+{
|
|
+ char name[50];
|
|
+ char fullname[80];
|
|
+ int cols;
|
|
+ int st_cells;
|
|
+ int offvert;
|
|
+ int offhor;
|
|
+ int baud;
|
|
+};
|
|
+
|
|
+/* Braille information structure */
|
|
+typedef struct
|
|
+{
|
|
+ int brl_fd;
|
|
+ unsigned char *disp; /* display contents - allocted by the driver */
|
|
+ int x, y; /* size of display */
|
|
+}
|
|
+brldim; /* used for writing to a braille display */
|
|
+
|
|
+/* only for libs */
|
|
+typedef struct
|
|
+{
|
|
+ char *identifier; /* name of driver */
|
|
+/* Routines provided by the braille driver library: */
|
|
+ void (*setxtty) (int tty);
|
|
+ void (*setlock) (int lock);
|
|
+ int (*getxtty) ();
|
|
+ int (*getlock) ();
|
|
+ struct brlinfo (*identify) (const char *, const char *); /* print start-up messages */
|
|
+ void (*debug) (unsigned int dbg); /* set driver debuging */
|
|
+ void (*initialize) (brldim *, const char *); /* initialise Braille display */
|
|
+ void (*close) (brldim *); /* close braille display */
|
|
+ void (*write) (brldim *); /* write to braille display */
|
|
+ int (*read) (int *); /* get key press from braille display */
|
|
+ void (*setstatus) (const unsigned char *); /* set status cells */
|
|
+
|
|
+}
|
|
+braille_driver;
|
|
+
|
|
+/* function to load the sbl configuartion files */
|
|
+void getsblconf (sbl_config * sblconf, char *conf);
|
|
+brlkbd keytrans (char *);
|
|
+void getkeymap (sbl_config sblconf, char *profname, char *homedir);
|
|
+
|
|
+/* helper function to parse the config files */
|
|
+int confread (char *realname);
|
|
+char *confsearch (char *serchstring);
|
|
+#endif
|
|
diff -ruN orca-2.22.1/src/brl/brlmodule.c orca-brld/src/brl/brlmodule.c
|
|
--- orca-2.22.1/src/brl/brlmodule.c 2008-03-08 13:27:36.000000000 +0100
|
|
+++ orca-brld/src/brl/brlmodule.c 2008-07-02 16:58:28.033159000 +0200
|
|
@@ -19,33 +19,33 @@
|
|
* Boston, MA 02111-1307, USA.
|
|
*
|
|
*/
|
|
+
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <dlfcn.h>
|
|
#include <glib.h>
|
|
#include <Python.h>
|
|
+#include <fcntl.h>
|
|
+#include "brl.h"
|
|
+#include "libbrld.h"
|
|
|
|
+/* global variables - config stuff */
|
|
+static sbl_config sblconf;
|
|
+static char varvec[200][150];
|
|
+static keymap_file keymap;
|
|
|
|
-/* BrlAPI function pointers - these map directly to BrlAPI 3.6.2 methods.
|
|
- */
|
|
-static int (*brlapi_initializeConnection)(const void *clientSettings,
|
|
- const void *usedSettings);
|
|
-static void (*brlapi_closeConnection)(void);
|
|
-
|
|
-static int (*brlapi_getDriverId)(unsigned char *id, unsigned int n);
|
|
-static int (*brlapi_getDriverName)(unsigned char *name, unsigned int n);
|
|
-static int (*brlapi_getDisplaySize)(unsigned int *x, unsigned int *y);
|
|
+static brld_interface *brld = NULL; /* filled by dynamic libbrld */
|
|
|
|
-static int (*brlapi_getTty) (int tty, int how);
|
|
-static int (*brlapi_leaveTty) (void);
|
|
+static void *libbrld = NULL; /* handle to driver */
|
|
|
|
-static int (*brlapi_writeText) (int cursor, const unsigned char *str);
|
|
-static int (*brlapi_writeDots) (const unsigned char *dots);
|
|
+static int csrvis = 1, csr_form = 1;
|
|
+static int old_csr = 0;
|
|
+static char old_text[100] = "", old_attr[100]="";
|
|
|
|
-static int (*brlapi_readKey) (int block, unsigned int *code);
|
|
+#define BRL_SYMBOL "brld"
|
|
|
|
/* A non-zero value indicates this module has been initialized and is
|
|
- * ready for communication with BrlTTY.
|
|
+ * ready for communication with brld.
|
|
*/
|
|
static long brl_initialized = 0;
|
|
|
|
@@ -55,39 +55,109 @@
|
|
static PyObject *brl_callback = NULL;
|
|
|
|
/* The g_io_add_watch (see glib docs) that keeps track of input events
|
|
- * coming from BrlTTY.
|
|
+ * coming from brld.
|
|
*/
|
|
-static gboolean brlapi_io_cb(GIOChannel *ch,
|
|
- GIOCondition condition,
|
|
- void *data) {
|
|
-
|
|
- unsigned int keypress;
|
|
- PyObject *result;
|
|
- PyObject *args;
|
|
- PyGILState_STATE gstate;
|
|
-
|
|
- while (brlapi_readKey(0, &keypress) == 1) {
|
|
- if (!brl_callback) {
|
|
- break;
|
|
- }
|
|
- args = Py_BuildValue("(i)", keypress);
|
|
- gstate = PyGILState_Ensure();
|
|
- result = PyObject_CallObject(brl_callback, args);
|
|
- if (result != NULL) {
|
|
- Py_DECREF(result);
|
|
- } else {
|
|
- PyErr_Print();
|
|
- }
|
|
- PyGILState_Release(gstate);
|
|
- Py_DECREF(args);
|
|
- }
|
|
- return TRUE;
|
|
+static gboolean brl_sbl_io_cb (GIOChannel * ch,
|
|
+ GIOCondition condition, void *data)
|
|
+{
|
|
+
|
|
+ int key, pressed;
|
|
+ static int lastkey = 0;
|
|
+ PyObject *result;
|
|
+ PyObject *args;
|
|
+ PyGILState_STATE gstate;
|
|
+
|
|
+/* do this to avoid compiler warnings */
|
|
+ if (ch && condition && data)
|
|
+ usleep (1);
|
|
+
|
|
+ key = brld->getkey (&pressed);
|
|
+ {
|
|
+ if (key && !csrvis)
|
|
+ {
|
|
+ csrvis = 1;
|
|
+ brld->write (old_csr - 1, old_text, old_attr);
|
|
+ }
|
|
+
|
|
+ if (pressed && lastkey >= 1000)
|
|
+ lastkey = 0;
|
|
+
|
|
+ if (!lastkey && pressed)
|
|
+ lastkey = key;
|
|
+ else
|
|
+ lastkey = (lastkey * 1000) + key;
|
|
+ if (!brl_callback)
|
|
+ {
|
|
+/* break;*/
|
|
+ }
|
|
+ if (lastkey == keymap.lnup.brl)
|
|
+ key = ORCA_LNUP;
|
|
+ else if (lastkey == keymap.lndn.brl)
|
|
+ key = ORCA_LNDN;
|
|
+ else if (lastkey == keymap.lnlft.brl)
|
|
+ key = ORCA_LNLFT;
|
|
+ else if (lastkey == keymap.lnrgt.brl)
|
|
+ key = ORCA_LNRGT;
|
|
+ else if (lastkey == keymap.topleft.brl)
|
|
+ key = ORCA_TOPLEFT;
|
|
+ else if (lastkey == keymap.botleft.brl)
|
|
+ key = ORCA_BOTLEFT;
|
|
+ else if (lastkey == keymap.csrtrk.brl)
|
|
+ key = ORCA_CSRTRK;
|
|
+ else if (lastkey == keymap.csrvisoff.brl)
|
|
+ {
|
|
+ csrvis = 0;
|
|
+ brld->write (-1, old_text, old_attr);
|
|
+ key = 0;
|
|
+ }
|
|
+ else if (lastkey == keymap.csrblockonoff.brl)
|
|
+ {
|
|
+ if (csr_form)
|
|
+ csr_form = 0;
|
|
+ else
|
|
+ csr_form = 1;
|
|
+ brld->cursor (csr_form);
|
|
+ brld->write (csrvis ? (old_csr - 1) : -1, old_text, old_attr);
|
|
+ key = 0;
|
|
+ }
|
|
+ else if (lastkey >= keymap.csrroutbeg && lastkey <= keymap.csrroutend)
|
|
+ {
|
|
+ if (pressed)
|
|
+ key = (lastkey - keymap.csrroutbeg) + 0x100;
|
|
+
|
|
+ lastkey = 0;
|
|
+ }
|
|
+ else
|
|
+ key = 0;
|
|
+
|
|
+ if (!pressed)
|
|
+ {
|
|
+ lastkey = 0;
|
|
+ }
|
|
+
|
|
+ pressed = 0;
|
|
+
|
|
+ args = Py_BuildValue ("(i)", key);
|
|
+
|
|
+ gstate = PyGILState_Ensure ();
|
|
+ result = PyObject_CallObject (brl_callback, args);
|
|
+ if (result != NULL)
|
|
+ {
|
|
+ Py_DECREF (result);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ PyErr_Print ();
|
|
+ }
|
|
+ PyGILState_Release (gstate);
|
|
+ Py_DECREF (args);
|
|
+ }
|
|
+ return TRUE;
|
|
}
|
|
|
|
-
|
|
/* Initializes the brl module, connecting to BrlTTY. Returns 0 on failure or
|
|
* 1 on success. The first argument is optional and indicated the tty to
|
|
- * open. The default value for this argument is -1, which means to let BrlTTY
|
|
+ * open. The default value for this argument is -1, which means to let brld
|
|
* use its default logic. A typical value might be 7 which is usually what
|
|
* the CONTROLVT should be set to for a console running the X11 server. The
|
|
* second argument is also optional and is to be passed to brlapi_getTty and
|
|
@@ -95,316 +165,529 @@
|
|
* BrlTTY commands (BRLCOMMANDS=0). The default value is to give us
|
|
* BRLCOMMANDS.
|
|
*/
|
|
-static PyObject *brl_module_init(PyObject *self,
|
|
- PyObject *args) {
|
|
- int tty = -1;
|
|
- int how = 0; /* BRLCOMMANDS */
|
|
- int ttyNum;
|
|
-
|
|
- void *brlapi_library;
|
|
- int brlapi_fd;
|
|
- GIOChannel *brlapi_channel;
|
|
-
|
|
- if (brl_initialized) {
|
|
- PyErr_SetString(PyExc_StandardError, "Already initialized");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if (!PyArg_ParseTuple (args, "|ii:init", &tty, &how))
|
|
- return NULL;
|
|
-
|
|
- /* Open the brlapi library
|
|
- */
|
|
- brlapi_library = dlopen("libbrlapi.so", RTLD_LAZY);
|
|
- if (!brlapi_library) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to load libbrlapi.so");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- /* Load the functions */
|
|
-
|
|
- brlapi_initializeConnection =
|
|
- (int (*)(const void *, const void *)) dlsym(brlapi_library,
|
|
- "brlapi_initializeConnection");
|
|
- if (!brlapi_initializeConnection) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_initializeConnection in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_closeConnection =
|
|
- (void (*)(void)) dlsym(brlapi_library,
|
|
- "brlapi_closeConnection");
|
|
- if (!brlapi_closeConnection) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_closeConnection in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_getDriverId =
|
|
- (int (*)(unsigned char *, unsigned int)) dlsym(brlapi_library,
|
|
- "brlapi_getDriverId");
|
|
- if (!brlapi_getDriverId) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_getDriverId in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_getDriverName =
|
|
- (int (*)(unsigned char *, unsigned int)) dlsym(brlapi_library,
|
|
- "brlapi_getDriverName");
|
|
- if (!brlapi_getDriverName) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_getDriverName in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_getDisplaySize =
|
|
- (int (*)(unsigned int *, unsigned int *)) dlsym(brlapi_library,
|
|
- "brlapi_getDisplaySize");
|
|
- if (!brlapi_getDisplaySize) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_getDisplaySize in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_getTty =
|
|
- (int (*) (int tty, int how)) dlsym(brlapi_library,
|
|
- "brlapi_getTty");
|
|
- if (!brlapi_getTty) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_getTty in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_leaveTty =
|
|
- (int (*) (void)) dlsym(brlapi_library,
|
|
- "brlapi_leaveTty");
|
|
- if (!brlapi_leaveTty) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_leaveTty in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_writeText =
|
|
- (int (*) (int, const unsigned char *)) dlsym(brlapi_library,
|
|
- "brlapi_writeText");
|
|
- if (!brlapi_writeText) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_writeText in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_writeDots =
|
|
- (int (*) (const unsigned char *)) dlsym(brlapi_library,
|
|
- "brlapi_writeDots");
|
|
- if (!brlapi_writeDots) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_writeDots in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- brlapi_readKey =
|
|
- (int (*) (int, unsigned int *)) dlsym(brlapi_library,
|
|
- "brlapi_readKey");
|
|
- if (!brlapi_readKey) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed to find brlapi_readKey in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- /* Connect to BrlTTY
|
|
- */
|
|
- brlapi_fd = brlapi_initializeConnection(NULL, NULL);
|
|
- if (brlapi_fd >= 0) {
|
|
- /* Take over the owning tty.
|
|
- */
|
|
- ttyNum = brlapi_getTty(tty,
|
|
- 0); /* HOW = give me BRLCOMMANDS */
|
|
- if (ttyNum == -1) {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed on call to brlapi_getTty in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- /* Setup the GIOChannel to receive notifications of Braille
|
|
- * key events
|
|
- */
|
|
- brlapi_channel = g_io_channel_unix_new(brlapi_fd);
|
|
- g_io_add_watch(brlapi_channel,
|
|
- G_IO_IN,
|
|
- brlapi_io_cb,
|
|
- NULL);
|
|
- brl_initialized = 1;
|
|
- return PyInt_FromLong(brl_initialized);
|
|
- } else {
|
|
- PyErr_SetString(
|
|
- PyExc_StandardError,
|
|
- "Failed on call to brlapi_initializeConnection in BrlTTY");
|
|
- return NULL;
|
|
- }
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_shutdown(PyObject *self) {
|
|
- if (brl_initialized) {
|
|
- /* [[[TODO: WDW - clean up the g_io_channel here? Logged
|
|
- * as bugzilla bug 319649.]]]
|
|
- */
|
|
- brlapi_leaveTty();
|
|
- brlapi_closeConnection();
|
|
- }
|
|
- brl_initialized = 0;
|
|
- return PyInt_FromLong(1);
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_getDriverId (PyObject *self) {
|
|
- unsigned char id[3];
|
|
-
|
|
- if (!brl_initialized) {
|
|
- Py_INCREF (Py_None);
|
|
- return Py_None;
|
|
- }
|
|
-
|
|
- if (brlapi_getDriverId(id, sizeof(id)) >= 0) {
|
|
- return PyString_FromString((const char *) id);
|
|
- } else {
|
|
- Py_INCREF (Py_None);
|
|
- return Py_None;
|
|
- }
|
|
-
|
|
- return Py_None;
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_getDriverName(PyObject *self) {
|
|
- unsigned char name[80];
|
|
-
|
|
- if (!brl_initialized) {
|
|
- Py_INCREF(Py_None);
|
|
- return Py_None;
|
|
- }
|
|
-
|
|
- if (brlapi_getDriverName(name, sizeof(name)) >= 0) {
|
|
- return PyString_FromString((const char *) name);
|
|
- } else {
|
|
- Py_INCREF (Py_None);
|
|
- return Py_None;
|
|
- }
|
|
-
|
|
- return Py_None;
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_getDisplayWidth(PyObject *self) {
|
|
- unsigned int x, y;
|
|
-
|
|
- if (!brl_initialized) {
|
|
- return PyInt_FromLong(0);
|
|
- }
|
|
-
|
|
- brlapi_getDisplaySize(&x, &y);
|
|
- return PyInt_FromLong(x);
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_getDisplayHeight(PyObject *self) {
|
|
- unsigned int x, y;
|
|
-
|
|
- if (!brl_initialized) {
|
|
- return PyInt_FromLong(0);
|
|
- }
|
|
-
|
|
- brlapi_getDisplaySize(&x, &y);
|
|
- return PyInt_FromLong(y);
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_writeText(PyObject *self,
|
|
- PyObject *args) {
|
|
- int cursor;
|
|
- char *str;
|
|
-
|
|
- if (!PyArg_ParseTuple(args, "is:writeText", &cursor, &str)) {
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if (brl_initialized) {
|
|
- brlapi_writeText(cursor, (const unsigned char *) str);
|
|
- }
|
|
-
|
|
- Py_INCREF(Py_None);
|
|
- return Py_None;
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_writeDots(PyObject *self,
|
|
- PyObject *args) {
|
|
- char *str;
|
|
-
|
|
- if (!PyArg_ParseTuple(args, "s:writeText", &str)) {
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if (brl_initialized) {
|
|
- brlapi_writeDots((const unsigned char *) str);
|
|
- }
|
|
- Py_INCREF(Py_None);
|
|
- return Py_None;
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_registerCallback(PyObject *self,
|
|
- PyObject *args) {
|
|
- if (brl_callback) {
|
|
- Py_DECREF (brl_callback);
|
|
- }
|
|
- if (brl_initialized) {
|
|
- brl_callback = PyTuple_GetItem(args, 0);
|
|
- Py_INCREF(brl_callback);
|
|
- }
|
|
- Py_INCREF(Py_None);
|
|
- return Py_None;
|
|
-}
|
|
-
|
|
-
|
|
-static PyObject *brl_module_unregisterCallback(PyObject *self) {
|
|
- if (brl_callback)
|
|
- Py_DECREF(brl_callback);
|
|
- brl_callback = NULL;
|
|
- Py_INCREF(Py_None);
|
|
- return Py_None;
|
|
+static PyObject *brl_module_init (PyObject * self, PyObject * args)
|
|
+{
|
|
+ int tty = -1;
|
|
+ int how = 0; /* BRLCOMMANDS */
|
|
+
|
|
+ GIOChannel *brl_channel;
|
|
+
|
|
+ fprintf (stderr, "try to init brl\n");
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+ if (brl_initialized)
|
|
+ {
|
|
+ PyErr_SetString (PyExc_StandardError, "Already initialized");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (!PyArg_ParseTuple (args, "|ii:init", &tty, &how))
|
|
+ return NULL;
|
|
+
|
|
+ const char *error = NULL;
|
|
+ int sock_fd = 0;
|
|
+
|
|
+ getsblconf (&sblconf, NULL);
|
|
+
|
|
+ if (libbrld)
|
|
+ dlclose (libbrld);
|
|
+
|
|
+ libbrld = dlopen ("libbrld.so.1", RTLD_LAZY);
|
|
+
|
|
+ if (libbrld == NULL)
|
|
+ libbrld = dlopen ("/usr/local/lib/libbrld.so.1", RTLD_LAZY);
|
|
+
|
|
+ if (libbrld == NULL)
|
|
+ libbrld = dlopen ("/tmp/suse-blinux/libbrld.so.1", RTLD_LAZY);
|
|
+
|
|
+ if (libbrld == NULL)
|
|
+ {
|
|
+ fprintf (stderr, "error: can't load libbrld.so.1\n");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ brld = (brld_interface *) dlsym (libbrld, BRL_SYMBOL);
|
|
+
|
|
+ error = dlerror ();
|
|
+
|
|
+ if (error)
|
|
+ {
|
|
+ fprintf (stderr, "%s\n", error);
|
|
+ return 0;
|
|
+ }
|
|
+ fprintf (stderr, "try to open brld-conn\n");
|
|
+ if ((sock_fd = brld->open ("localhost", 8888)) < 0)
|
|
+ {
|
|
+ fprintf (stderr, "error: connecting brld\n");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ fprintf (stderr, "try to reg to brld\n");
|
|
+ if (brld->reg (X11, "default"))
|
|
+ {
|
|
+ fprintf (stderr, "error: brld registration failed\n");
|
|
+ brld->close ();
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ brld->getalias (sblconf.brlname);
|
|
+
|
|
+/* set event mode to get SIGIO*/
|
|
+ brld->seteventmode ();
|
|
+
|
|
+ /* set translation-table to text */
|
|
+ brld->texttbl ();
|
|
+
|
|
+ /* set block-cursor */
|
|
+ brld->cursor (csr_form);
|
|
+
|
|
+ getkeymap (sblconf, NULL, NULL);
|
|
+ /* Setup the GIOChannel to receive notifications of Braille key events */
|
|
+ brl_channel = g_io_channel_unix_new (sock_fd);
|
|
+ g_io_add_watch (brl_channel, G_IO_IN, brl_sbl_io_cb, NULL);
|
|
+ brl_initialized = 1;
|
|
+ return PyInt_FromLong (brl_initialized);
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_shutdown (PyObject * self)
|
|
+{
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+ if (brl_initialized)
|
|
+ {
|
|
+ brld->close ();
|
|
+ }
|
|
+ brl_initialized = 0;
|
|
+ if (libbrld)
|
|
+ dlclose (libbrld);
|
|
+ return PyInt_FromLong (1);
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_getDriverId (PyObject * self)
|
|
+{
|
|
+
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+
|
|
+ if (!brl_initialized)
|
|
+ {
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
+ }
|
|
+
|
|
+ return PyString_FromString ((const char *) "sbl");
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_getDriverName (PyObject * self)
|
|
+{
|
|
+ char name[80];
|
|
+
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+ if (!brl_initialized)
|
|
+ {
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
+ }
|
|
+
|
|
+ brld->getname (name);
|
|
+ if (strlen (name) > 0)
|
|
+ {
|
|
+ return PyString_FromString ((const char *) name);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
+ }
|
|
+
|
|
+ return Py_None;
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_getDisplayWidth (PyObject * self)
|
|
+{
|
|
+
|
|
+ int x = 0, y = 0;
|
|
+
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+
|
|
+ if (!brl_initialized)
|
|
+ {
|
|
+ return PyInt_FromLong (0);
|
|
+ }
|
|
+
|
|
+ brld->getxy (&x, &y);
|
|
+ return PyInt_FromLong (x);
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_getDisplayHeight (PyObject * self)
|
|
+{
|
|
+
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+
|
|
+ if (!brl_initialized)
|
|
+ {
|
|
+ return PyInt_FromLong (0);
|
|
+ }
|
|
+
|
|
+/* we only support displays with one line */
|
|
+ return PyInt_FromLong (1);
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_writeText (PyObject * self, PyObject * args)
|
|
+{
|
|
+ int cursor;
|
|
+ char *str;
|
|
+ char *attr;
|
|
+
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+
|
|
+ if (!PyArg_ParseTuple (args, "iss:writeText", &cursor, &str, &attr))
|
|
+ {
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (brl_initialized)
|
|
+ {
|
|
+
|
|
+ if (old_csr != cursor || strcmp (old_text, str) || strcmp(old_attr, attr))
|
|
+ {
|
|
+ brld->write (csrvis ? (cursor - 1) : -1, str, attr);
|
|
+ old_csr = cursor;
|
|
+ strcpy (old_text, str);
|
|
+ strcpy(old_attr,attr);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_writeDots (PyObject * self, PyObject * args)
|
|
+{
|
|
+ char *str;
|
|
+
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+
|
|
+ if (!PyArg_ParseTuple (args, "s:writeText", &str))
|
|
+ {
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (brl_initialized)
|
|
+ {
|
|
+ brld->write (-1, str, NULL);
|
|
+ }
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_registerCallback (PyObject * self,
|
|
+ PyObject * args)
|
|
+{
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+ if (brl_callback)
|
|
+ {
|
|
+ Py_DECREF (brl_callback);
|
|
+ }
|
|
+ if (brl_initialized)
|
|
+ {
|
|
+ brl_callback = PyTuple_GetItem (args, 0);
|
|
+ Py_INCREF (brl_callback);
|
|
+ }
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
+}
|
|
+
|
|
+static PyObject *brl_module_unregisterCallback (PyObject * self)
|
|
+{
|
|
+/* just to avoid compiler warnings */
|
|
+ if (self)
|
|
+ usleep (1);
|
|
+
|
|
+ if (brl_callback)
|
|
+ {
|
|
+ Py_DECREF (brl_callback);
|
|
+ }
|
|
+
|
|
+ brl_callback = NULL;
|
|
+ Py_INCREF (Py_None);
|
|
+ return Py_None;
|
|
}
|
|
|
|
-
|
|
static PyMethodDef brl_methods[] = {
|
|
- {"init", (PyCFunction) brl_module_init, METH_VARARGS},
|
|
- {"shutdown", (PyCFunction) brl_module_shutdown, METH_NOARGS},
|
|
- {"getDriverId", (PyCFunction) brl_module_getDriverId, METH_NOARGS},
|
|
- {"getDriverName", (PyCFunction) brl_module_getDriverName, METH_NOARGS},
|
|
- {"getDisplayWidth", (PyCFunction) brl_module_getDisplayWidth, METH_NOARGS},
|
|
- {"getDisplayHeight", (PyCFunction) brl_module_getDisplayWidth, METH_NOARGS},
|
|
- {"writeText", (PyCFunction) brl_module_writeText, METH_VARARGS},
|
|
- {"writeDots", (PyCFunction) brl_module_writeDots, METH_VARARGS},
|
|
- {"registerCallback", (PyCFunction) brl_module_registerCallback, METH_VARARGS},
|
|
- {"unregisterCallback", (PyCFunction) brl_module_unregisterCallback, METH_NOARGS},
|
|
- {NULL, NULL}
|
|
+ {"init", (PyCFunction) brl_module_init, METH_VARARGS, NULL},
|
|
+ {"shutdown", (PyCFunction) brl_module_shutdown, METH_NOARGS, NULL},
|
|
+ {"getDriverId", (PyCFunction) brl_module_getDriverId, METH_NOARGS, NULL},
|
|
+ {"getDriverName", (PyCFunction) brl_module_getDriverName, METH_NOARGS,
|
|
+ NULL},
|
|
+ {"getDisplayWidth", (PyCFunction) brl_module_getDisplayWidth, METH_NOARGS,
|
|
+ NULL},
|
|
+ {"getDisplayHeight", (PyCFunction) brl_module_getDisplayHeight, METH_NOARGS,
|
|
+ NULL},
|
|
+ {"writeText", (PyCFunction) brl_module_writeText, METH_VARARGS, NULL},
|
|
+ {"writeDots", (PyCFunction) brl_module_writeDots, METH_VARARGS, NULL},
|
|
+ {"registerCallback", (PyCFunction) brl_module_registerCallback,
|
|
+ METH_VARARGS, NULL},
|
|
+ {"unregisterCallback", (PyCFunction) brl_module_unregisterCallback,
|
|
+ METH_NOARGS, NULL},
|
|
+ {NULL, NULL, 0, NULL}
|
|
};
|
|
|
|
-void initbrl (void) {
|
|
- (void) Py_InitModule ("brl", brl_methods);
|
|
+void initbrl (void)
|
|
+{
|
|
+ (void) Py_InitModule ("brl", brl_methods);
|
|
+}
|
|
+
|
|
+/* load sbl configuration files */
|
|
+
|
|
+void getsblconf (sbl_config * sblconf, char *conf)
|
|
+{
|
|
+ char str[100];
|
|
+
|
|
+ if (!conf)
|
|
+ confread ("/etc/suse-blinux.conf");
|
|
+ else
|
|
+ confread (conf);
|
|
+
|
|
+ confsearch (strcpy (sblconf->brld_host, "brld_host"));
|
|
+ confsearch (strcpy (str, "brld_port"));
|
|
+ if (atoi (str))
|
|
+ sblconf->brld_port = atoi (str);
|
|
+ else
|
|
+ sblconf->brld_port = 8888;
|
|
+
|
|
+ confsearch (strcpy (str, "brld_auth_key"));
|
|
+ if (str[0] != 0)
|
|
+ strcpy (sblconf->brld_auth_key, str);
|
|
+ else
|
|
+ strcpy (sblconf->brld_auth_key, "default");
|
|
+
|
|
+ confsearch (strcpy (sblconf->progpath, "progpath"));
|
|
+}
|
|
+
|
|
+void getkeymap (sbl_config sblconf, char *profname, char *homedir)
|
|
+{
|
|
+ char str[120];
|
|
+
|
|
+ sprintf (str, "%s/.suse-blinux/keymap/%s.map.%s", homedir, sblconf.brlname,
|
|
+ profname);
|
|
+ if (!confread (str))
|
|
+ {
|
|
+ sprintf (str, "%s/.suse-blinux/keymap/%s.map", homedir, sblconf.brlname);
|
|
+ if (!confread (str))
|
|
+ {
|
|
+ sprintf (str, "%s/keymap/%s.map.%s", sblconf.progpath,
|
|
+ sblconf.brlname, profname);
|
|
+ if (!confread (str))
|
|
+ {
|
|
+ sprintf (str, "%s/keymap/%s.map", sblconf.progpath,
|
|
+ sblconf.brlname);
|
|
+ confread (str);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ keymap.kbdsniffon1 = keytrans (confsearch (strcpy (str, "kbdsniffon1")));
|
|
+ keymap.kbdsniffon2 = keytrans (confsearch (strcpy (str, "kbdsniffon2")));
|
|
+ keymap.kbdsniffoff = keytrans (confsearch (strcpy (str, "kbdsniffoff")));
|
|
+ keymap.resetbrl = keytrans (confsearch (strcpy (str, "resetbrl")));
|
|
+ keymap.line01 = keytrans (confsearch (strcpy (str, "line01")));
|
|
+ keymap.topleft = keytrans (confsearch (strcpy (str, "topleft")));
|
|
+ keymap.botleft = keytrans (confsearch (strcpy (str, "botleft")));
|
|
+ keymap.winup = keytrans (confsearch (strcpy (str, "winup")));
|
|
+ keymap.windn = keytrans (confsearch (strcpy (str, "windn")));
|
|
+ keymap.lnlft = keytrans (confsearch (strcpy (str, "lnlft")));
|
|
+ keymap.lnrgt = keytrans (confsearch (strcpy (str, "lnrgt")));
|
|
+ keymap.lnup = keytrans (confsearch (strcpy (str, "lnup")));
|
|
+ keymap.lndn = keytrans (confsearch (strcpy (str, "lndn")));
|
|
+ keymap.csrtrk = keytrans (confsearch (strcpy (str, "csrtrk")));
|
|
+ keymap.syscsr = keytrans (confsearch (strcpy (str, "syscsr")));
|
|
+ keymap.softcsr = keytrans (confsearch (strcpy (str, "softcsr")));
|
|
+ keymap.chrlft = keytrans (confsearch (strcpy (str, "chrlft")));
|
|
+ keymap.chrrgt = keytrans (confsearch (strcpy (str, "chrrgt")));
|
|
+ keymap.hwinlft = keytrans (confsearch (strcpy (str, "hwinlft")));
|
|
+ keymap.hwinrgt = keytrans (confsearch (strcpy (str, "hwinrgt")));
|
|
+ keymap.fwinlft = keytrans (confsearch (strcpy (str, "fwinlft")));
|
|
+ keymap.fwinrgt = keytrans (confsearch (strcpy (str, "fwinrgt")));
|
|
+ keymap.csrjump = keytrans (confsearch (strcpy (str, "csrjump")));
|
|
+ keymap.csrjmpvert = keytrans (confsearch (strcpy (str, "csrjmpvert")));
|
|
+ keymap.keyup = keytrans (confsearch (strcpy (str, "keyup")));
|
|
+ keymap.keydn = keytrans (confsearch (strcpy (str, "keydn")));
|
|
+ keymap.keylft = keytrans (confsearch (strcpy (str, "keylft")));
|
|
+ keymap.keyrgt = keytrans (confsearch (strcpy (str, "keyrgt")));
|
|
+ keymap.keyenter = keytrans (confsearch (strcpy (str, "keyenter")));
|
|
+ keymap.keyesc = keytrans (confsearch (strcpy (str, "keyesc")));
|
|
+ keymap.csrvisoff = keytrans (confsearch (strcpy (str, "csrvisoff")));
|
|
+ keymap.jmpmark1 = keytrans (confsearch (strcpy (str, "jmpmark1")));
|
|
+ keymap.jmpmark2 = keytrans (confsearch (strcpy (str, "jmpmark2")));
|
|
+ keymap.jmpmark3 = keytrans (confsearch (strcpy (str, "jmpmark3")));
|
|
+ keymap.jmpmark4 = keytrans (confsearch (strcpy (str, "jmpmark4")));
|
|
+ keymap.setmark = keytrans (confsearch (strcpy (str, "setmark")));
|
|
+ keymap.jmptomark = keytrans (confsearch (strcpy (str, "jmptomark")));
|
|
+ keymap.attr1 = keytrans (confsearch (strcpy (str, "attr1")));
|
|
+ keymap.attr2 = keytrans (confsearch (strcpy (str, "attr2")));
|
|
+ keymap.attr3 = keytrans (confsearch (strcpy (str, "attr3")));
|
|
+ keymap.attr4 = keytrans (confsearch (strcpy (str, "attr4")));
|
|
+ keymap.csrtrkoff = keytrans (confsearch (strcpy (str, "csrtrkoff")));
|
|
+ keymap.prof1 = keytrans (confsearch (strcpy (str, "prof1")));
|
|
+ keymap.prof2 = keytrans (confsearch (strcpy (str, "prof2")));
|
|
+ keymap.prof3 = keytrans (confsearch (strcpy (str, "prof3")));
|
|
+ keymap.prof4 = keytrans (confsearch (strcpy (str, "prof4")));
|
|
+ keymap.attroff = keytrans (confsearch (strcpy (str, "attroff")));
|
|
+ keymap.attrmodonoff = keytrans (confsearch (strcpy (str, "attrmodonoff")));
|
|
+ keymap.sixdotsonoff = keytrans (confsearch (strcpy (str, "sixdotsonoff")));
|
|
+ keymap.csrblinkonoff =
|
|
+ keytrans (confsearch (strcpy (str, "csrblinkonoff")));
|
|
+ keymap.csrblockonoff =
|
|
+ keytrans (confsearch (strcpy (str, "csrblockonoff")));
|
|
+ keymap.cutbegin = keytrans (confsearch (strcpy (str, "cutbegin")));
|
|
+ keymap.cutend = keytrans (confsearch (strcpy (str, "cutend")));
|
|
+ keymap.loadkeymap = keytrans (confsearch (strcpy (str, "loadkeymap")));
|
|
+ keymap.paste = keytrans (confsearch (strcpy (str, "paste")));
|
|
+ keymap.soundonoff = keytrans (confsearch (strcpy (str, "soundonoff")));
|
|
+ keymap.autoprofonoff =
|
|
+ keytrans (confsearch (strcpy (str, "autoprofonoff")));
|
|
+ keymap.spktocsr = keytrans (confsearch (strcpy (str, "spktocsr")));
|
|
+ keymap.spkcurln = keytrans (confsearch (strcpy (str, "spkcurln")));
|
|
+ keymap.spkscrtocsr = keytrans (confsearch (strcpy (str, "spkscrtocsr")));
|
|
+ keymap.spkscrfromcsr =
|
|
+ keytrans (confsearch (strcpy (str, "spkscrfromcsr")));
|
|
+ keymap.spkfromcsr = keytrans (confsearch (strcpy (str, "spkfromcsr")));
|
|
+ keymap.spkmod = keytrans (confsearch (strcpy (str, "spkmod")));
|
|
+ keymap.spkoff = keytrans (confsearch (strcpy (str, "spkoff")));
|
|
+ keymap.nextlang = keytrans (confsearch (strcpy (str, "nextlang")));
|
|
+ keymap.nextvol = keytrans (confsearch (strcpy (str, "nextvol")));
|
|
+ keymap.nextvoice = keytrans (confsearch (strcpy (str, "nextvoice")));
|
|
+ keymap.nextspec = keytrans (confsearch (strcpy (str, "nextspec")));
|
|
+ keymap.nextfrq = keytrans (confsearch (strcpy (str, "nextfrq")));
|
|
+ keymap.nextspd = keytrans (confsearch (strcpy (str, "nextspd")));
|
|
+ keymap.prevlang = keytrans (confsearch (strcpy (str, "prevlang")));
|
|
+ keymap.prevvol = keytrans (confsearch (strcpy (str, "prevvol")));
|
|
+ keymap.prevvoice = keytrans (confsearch (strcpy (str, "prevvoice")));
|
|
+ keymap.prevspec = keytrans (confsearch (strcpy (str, "prevspec")));
|
|
+ keymap.prevfrq = keytrans (confsearch (strcpy (str, "prevfrq")));
|
|
+ keymap.prevspd = keytrans (confsearch (strcpy (str, "prevspd")));
|
|
+ keymap.spkcharmod = keytrans (confsearch (strcpy (str, "spkcharmod")));
|
|
+
|
|
+ keymap.csrroutbeg = atoi (confsearch (strcpy (str, "csrroutbeg")) + 1);
|
|
+ keymap.csrroutend = atoi (confsearch (strcpy (str, "csrroutend")) + 1);
|
|
+ keymap.lineroutbeg = atoi (confsearch (strcpy (str, "lineroutbeg")) + 1);
|
|
+ keymap.lineroutend = atoi (confsearch (strcpy (str, "lineroutend")) + 1);
|
|
+}
|
|
+
|
|
+#define CKEYS 37
|
|
+brlkbd keytrans (char *str)
|
|
+{
|
|
+ brlkbd keys;
|
|
+ unsigned int i = 0;
|
|
+ int code = 0, kbdcode = 0;
|
|
+ char key1[10] = "", key2[10] = "", kbdstr[30] = "";
|
|
+
|
|
+ keys.kbd = 0;
|
|
+ keys.brl = 0;
|
|
+
|
|
+ for (i = 0; i < strlen (str); i++)
|
|
+ if (str[i] == ',')
|
|
+ kbdcode = i;
|
|
+ if (strlen (str) < 2)
|
|
+ {
|
|
+ keys.brl = 0;
|
|
+ keys.kbd = 0;
|
|
+ return keys;
|
|
+ }
|
|
+ if (str[kbdcode] == ',')
|
|
+ {
|
|
+ str[kbdcode] = 0;
|
|
+ }
|
|
+ else
|
|
+ kbdstr[0] = 0;
|
|
+ if (strlen (str) > 3)
|
|
+ {
|
|
+ strncpy (key1, str, 4);
|
|
+ key1[4] = 0;
|
|
+ if (strlen (str) > 4)
|
|
+ strcpy (key2, str + 5);
|
|
+ key2[4] = 0;
|
|
+ code = 0;
|
|
+ code = (atoi (key1 + 1));
|
|
+ if (strlen (key2))
|
|
+ code = (code * 1000) + atoi (key2 + 1);
|
|
+
|
|
+ keys.brl = code;
|
|
+ } /* if */
|
|
+ else
|
|
+ keys.brl = 0;
|
|
+
|
|
+ memset (key1, 0, sizeof (key1));
|
|
+ code = 0;
|
|
+ return keys;
|
|
+
|
|
+}
|
|
+
|
|
+/* helper function to parse the config files */
|
|
+int confread (char *realname)
|
|
+{
|
|
+ FILE *pname;
|
|
+ int i = 0;
|
|
+ char row[100] = "";
|
|
+
|
|
+ pname = fopen (realname, "r");
|
|
+ if (pname == NULL)
|
|
+ return 0;
|
|
+ while (!feof (pname))
|
|
+ {
|
|
+ fgets (row, 80, pname);
|
|
+ if (row[0] != '#' && strlen (row) > 5)
|
|
+ {
|
|
+ strcpy (varvec[i], row);
|
|
+ i++;
|
|
+ }
|
|
+ if (feof (pname))
|
|
+ break;
|
|
+ }
|
|
+ fclose (pname);
|
|
+ varvec[i][0] = 0;
|
|
+ return 1;
|
|
+}
|
|
+
|
|
+char *confsearch (char *searchstring)
|
|
+{
|
|
+ int i = 0, end = 0;
|
|
+
|
|
+ strcat (searchstring, "=\0");
|
|
+ do
|
|
+ {
|
|
+ if (strncmp (varvec[i], searchstring, strlen (searchstring)) == 0)
|
|
+ {
|
|
+ strcpy (searchstring, varvec[i] + strlen (searchstring));
|
|
+ end = 1;
|
|
+ }
|
|
+ i++;
|
|
+ }
|
|
+ while (varvec[i][0] != 0 && !end);
|
|
+
|
|
+ if (!end)
|
|
+ {
|
|
+ searchstring[0] = 0;
|
|
+ return searchstring;
|
|
+ }
|
|
+
|
|
+ if (strlen (searchstring))
|
|
+ searchstring[strlen (searchstring) - 1] = 0;
|
|
+ return searchstring;
|
|
}
|
|
diff -ruN orca-2.22.1/src/brl/libbrld.h orca-brld/src/brl/libbrld.h
|
|
--- orca-2.22.1/src/brl/libbrld.h 1970-01-01 01:00:00.000000000 +0100
|
|
+++ orca-brld/src/brl/libbrld.h 2008-07-02 16:58:28.043145000 +0200
|
|
@@ -0,0 +1,114 @@
|
|
+#ifndef _LIBBRLD_H
|
|
+#define _LIBBRLD_H
|
|
+
|
|
+#define MAX_MSG_LEN 800
|
|
+/* registration types */
|
|
+#define TEXT 1
|
|
+#define X11 2
|
|
+#define ADMIN 3
|
|
+#define BRLD_TIMEOUT -3
|
|
+#define BRLD_CMD_ERR -2
|
|
+#define BRLD_NO_CONN -4
|
|
+#define BRLD_CLIENT_TIMEOUT 20 /* in seconds */
|
|
+
|
|
+typedef struct
|
|
+{
|
|
+ int (*open) (char *, int);
|
|
+ int (*reg) (int, char *);
|
|
+ void (*close) ();
|
|
+ int (*getkey) (int *);
|
|
+ int (*write) (int, char *, char *);
|
|
+ int (*reset) ();
|
|
+ int (*getname) (char *name);
|
|
+ int (*getalias) (char *alias);
|
|
+ int (*getxy) (int *x, int *y);
|
|
+ int (*cursor) (int form);
|
|
+ int (*attrtbl) ();
|
|
+ int (*texttbl) ();
|
|
+ void (*seteventmode) ();
|
|
+ int (*unseteventmode) ();
|
|
+} brld_interface;
|
|
+
|
|
+/* connect to brld
|
|
+ * if hostname is NULL - we assume localhost
|
|
+ * if port is 0 - we assume default
|
|
+ * returns >=0 = (socket_fd) <0 = failed
|
|
+ */
|
|
+
|
|
+int brld_open (char *host, int port);
|
|
+
|
|
+/* register your application */
|
|
+int brld_reg (int type, char *authkey);
|
|
+
|
|
+/* close connection to brld */
|
|
+void brld_close ();
|
|
+
|
|
+/* get a brlkey from brld
|
|
+ * retunrs the key-value or <=0 on error
|
|
+ * pressed is 1 on if key is pressed - 0 if key is released
|
|
+ */
|
|
+int brld_getkey (int *pressed);
|
|
+
|
|
+/* write a string to the braille-display
|
|
+ * the string will be translated in brld
|
|
+ * csrpos - is the brl-cursor positon csrpos=-1 means cursor off
|
|
+ * text - is a plain text string (zero terminated)
|
|
+ * attr - is an attribute string (zero terminated)
|
|
+ * text and attr should have the same length otherwise attr will be ignored
|
|
+ * if you want to display the string "hello wolrd"
|
|
+ * and "world" should be underlined by dot 7 and 8
|
|
+ * do the following:
|
|
+ * brld_write(-1,"hello world"," -----");
|
|
+ * the "-" character in attr indicates the underline
|
|
+ */
|
|
+int brld_write (int csrpos, char *text, char *attr);
|
|
+
|
|
+/* braille device reset */
|
|
+int brld_reset ();
|
|
+
|
|
+/* get the fullname of the connected brailledisplay
|
|
+ * retunrn 0= OK - not 0 = failed
|
|
+ */
|
|
+
|
|
+int brld_getname (char *name);
|
|
+
|
|
+/* get the shortname of the connected brailledisplay
|
|
+ * retunr 0=OK - not 0 = failed
|
|
+ */
|
|
+int brld_getalias (char *alias);
|
|
+
|
|
+/* get braille-celss and lines
|
|
+ * return 0=OK - not 0=failed
|
|
+ */
|
|
+int brld_getxy (int *x, int *y);
|
|
+
|
|
+/* set braille-cursor form
|
|
+ * form=0 - block-cursor
|
|
+ * form=1 - underline the cursor position with dot 7 and 8
|
|
+ * return 0=OK - not 0 failed
|
|
+ */
|
|
+int brld_cursor (int form);
|
|
+
|
|
+/* set braille translation table to attribute
|
|
+ * attribute mode for displaying a attribute pattern in conosle-applications
|
|
+ * return 0=OK - not 0=failed
|
|
+ */
|
|
+int brld_attrtbl ();
|
|
+
|
|
+/* set braille translation table to text
|
|
+ * use the normal text-translation-table
|
|
+ * return 0=OK - not 0=failed
|
|
+ */
|
|
+int brld_texttbl ();
|
|
+
|
|
+/* set the event-mode for incoming key-storkes
|
|
+ * needed if the connected applications wants to use SIGIO like orca
|
|
+ */
|
|
+void brld_seteventmode ();
|
|
+
|
|
+/* disable event-mode
|
|
+ * the application has to poll
|
|
+ * return 0=OK - not 0=failed
|
|
+ */
|
|
+int brld_unseteventmode ();
|
|
+#endif
|
|
diff -ruN orca-2.22.1/src/orca/braille.py orca-brld/src/orca/braille.py
|
|
--- orca-2.22.1/src/orca/braille.py 2008-03-08 13:27:38.000000000 +0100
|
|
+++ orca-brld/src/orca/braille.py 2008-07-02 17:05:17.037243000 +0200
|
|
@@ -936,7 +936,7 @@
|
|
if brlAPIRunning:
|
|
brlAPI.writeText("", 0)
|
|
else:
|
|
- brl.writeText(0, "")
|
|
+ brl.writeText(0, "", "")
|
|
return
|
|
|
|
# Now determine the location of the cursor. First, we'll figure
|
|
@@ -1027,7 +1027,13 @@
|
|
|
|
brlAPI.write(writeStruct)
|
|
else:
|
|
- brl.writeText(cursorCell, substring)
|
|
+ attr_str=""
|
|
+ if attributeMask:
|
|
+ attr_str=attributeMask[startPos:endPos].replace('\x00',' ')
|
|
+ if len(attr_str) < len(substring):
|
|
+ attr_str+=' ' * (len(substring) - len(attr_str))
|
|
+
|
|
+ brl.writeText(cursorCell, substring, attr_str)
|
|
|
|
if settings.enableBrailleMonitor:
|
|
if not monitor:
|