Adding specific support for Cintiq 21UX master
authorAristeu Rozanski <arozansk@redhat.com>
Thu, 18 Nov 2010 15:40:29 +0000 (10:40 -0500)
committerAristeu Rozanski <arozansk@redhat.com>
Thu, 18 Nov 2010 15:40:29 +0000 (10:40 -0500)
Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
src-expresskeys/config_read.c
src-expresskeys/config_write.c
src-expresskeys/defines.h
src-expresskeys/event_loop.c
src-expresskeys/get_device.c
src-expresskeys/mark_info.c
src-expresskeys/on_signal.c
src-expresskeys/tablet.c
src-expresskeys/tablet.h

index f4a63c3..bd452e6 100644 (file)
@@ -43,6 +43,7 @@ static int st2_prcurve_malloced;
 extern int be_verbose;
 extern int reread_config;
 
+extern const int ux;
 extern const int ux2;
 extern const int bbo;
 extern const int bee;
@@ -303,6 +304,7 @@ static void prune_field(char* field_begin, char* write_buffer)
 static void handle_field(FILE* errorfp, char* read_buffer, void* address,
                                                                const int model)
 {
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -315,6 +317,7 @@ static void handle_field(FILE* errorfp, char* read_buffer, void* address,
        struct touch_data* tdp = NULL;
        struct wheel_data* wdp = NULL;
        struct button_data* bdp = NULL;
+       struct ux_configstrings* cux;
        struct ux2_configstrings* cux2;
        struct bbo_configstrings* cbbo;
        struct bee_configstrings* cbee;
@@ -328,7 +331,16 @@ static void handle_field(FILE* errorfp, char* read_buffer, void* address,
        struct wheel_string* wsp = NULL;
        struct button_string* bsp = NULL;
 
-       if (model == ux2) {
+       if (model == ux) {
+               pux = address;
+               cdp = &pux->common_data;
+               tdp = &pux->touch_data;
+               bdp = &pux->button_data;
+               cux = ux_configstrings;
+               csp = &cux->common_string;
+               tsp = &cux->touch_string;
+               bsp = &cux->button_string;
+       } else if (model == ux2) {
                pux2 = address;
                cdp = &pux2->common_data;
                tdp = &pux2->touch_data;
@@ -477,7 +489,7 @@ static void handle_field(FILE* errorfp, char* read_buffer, void* address,
        }
 /* HandleTouchStrips TouchRepeatAfter DelayTouchRepeat
  LeftPadTouchUp LeftPadTouchDown RepeatLeftUp RepeatLeftDown */
-       if (model == i3s || model == i3 || model == bee || model == ux2 || model == bbo) {
+       if (model == i3s || model == i3 || model == bee || model == ux2 || model == bbo || model == ux) {
                if (((field = (strstr(read_buffer, tsp->handle_touch))) != NULL)
                        && (((comment = (strchr(read_buffer, '#'))) == NULL)
                                                || (field < comment))) {
@@ -593,6 +605,17 @@ static void handle_field(FILE* errorfp, char* read_buffer, void* address,
                READ_BUTTON(17);
                READ_BUTTON(18);
        }
+       if (model == ux) {
+               READ_BUTTON(1);
+               READ_BUTTON(2);
+               READ_BUTTON(3);
+               READ_BUTTON(4);
+               READ_BUTTON(5);
+               READ_BUTTON(6);
+               READ_BUTTON(7);
+               READ_BUTTON(8);
+       }
+
 /* ButtonRepeatAfter DelayButtonRepeat
  LeftPadButton9/LeftButton
  RepeatButton9/RepeatLeft */
@@ -829,6 +852,7 @@ static void read_body(FILE* errorfp, void* address, const int model,
        st1_prcurve_malloced = 0;
        st2_prcurve_malloced = 0;
 
+       struct ux_program* pux = NULL;
        struct ux2_program* pux2 = NULL;
        struct bbo_program* pbbo = NULL;
        struct bee_program* pbee = NULL;
@@ -837,6 +861,7 @@ static void read_body(FILE* errorfp, void* address, const int model,
        struct g4_program* pg4 = NULL;
        struct g4b_program* pg4b = NULL;
        struct nop_program* pnop = NULL;
+       struct ux_program* pux_base = NULL;
        struct ux2_program* pux2_base = NULL;
        struct bbo_program* pbbo_base = NULL;
        struct bee_program* pbee_base = NULL;
@@ -846,7 +871,14 @@ static void read_body(FILE* errorfp, void* address, const int model,
        struct g4b_program* pg4b_base = NULL;
        struct nop_program* pnop_base = NULL;
 
-       if (model == ux2) {
+       if (model == ux) {
+               pux = address;
+               pux_base = pux;
+               if (reread_config) {
+                       pux->default_program = NULL;
+                       pux->common_data.num_record = 0;
+               }
+       } else if (model == ux2) {
                pux2 = address;
                pux2_base = pux2;
                if (reread_config) {
@@ -987,7 +1019,9 @@ static void read_body(FILE* errorfp, void* address, const int model,
                                continue;
                        }
 
-                       if (pux2) {
+                       if (pux) {
+                               handle_field(errorfp, read_buffer, pux, model);
+                       } else if (pux2) {
                                handle_field(errorfp, read_buffer, pux2, model);
                        } else if (pbbo) {
                                handle_field(errorfp, read_buffer, pbbo, model);
@@ -1008,7 +1042,42 @@ static void read_body(FILE* errorfp, void* address, const int model,
 
 /* End field loop*/
 
-               if (pux2) {
+               if (pux) {
+                       if (pux->common_data.class_name == NULL) {
+                               revert_config = 1;
+                               if (pux->common_data.stylus1_presscurve
+                                                               != NULL) {
+                               free(pux->common_data.stylus1_presscurve);
+                               st1_prcurve_malloced = 0;
+                               pux->common_data.stylus1_presscurve = NULL;
+                               }
+                               if (pux->common_data.stylus2_presscurve
+                                                               != NULL) {
+                               free(pux->common_data.stylus2_presscurve);
+                               st2_prcurve_malloced = 0;
+                               pux->common_data.stylus2_presscurve = NULL;
+                               }
+                       }
+                       if ((pux->common_data.class_name != NULL)
+                               && (strcmp(pux->common_data.class_name,
+                                                       def_rec) == 0)) {
+                               pux_base->default_program = pux;
+                       }
+                       if (pux->common_data.class_name != NULL) {
+                               pgr_recname_malloced = 0;
+                               revert_config = 0;
+                               num_record++;
+                               if (pux->common_data.stylus1_presscurve
+                                                               != NULL) {
+                                       st1_prcurve_malloced = 0;
+                               }
+                               if (pux->common_data.stylus2_presscurve
+                                                               != NULL) {
+                                       st2_prcurve_malloced = 0;
+                               }
+                               pux++;
+                       }
+               } else if (pux2) {
                        if (pux2->common_data.class_name == NULL) {
                                revert_config = 1;
                                if (pux2->common_data.stylus1_presscurve
@@ -1043,7 +1112,7 @@ static void read_body(FILE* errorfp, void* address, const int model,
                                }
                                pux2++;
                        }
-               } if (pbbo) {
+               } else if (pbbo) {
                        if (pbbo->common_data.class_name == NULL) {
                                revert_config = 1;
                                if (pbbo->common_data.stylus1_presscurve
@@ -1295,7 +1364,13 @@ static void read_body(FILE* errorfp, void* address, const int model,
 
        fclose(fp);
 
-       if (model == ux2) {
+       if (model == ux) {
+               pux = address;
+               if (pux->default_program == NULL) {
+                       no_default = 1;
+               }
+               pux->common_data.num_record = num_record;
+       } else if (model == ux2) {
                pux2 = address;
                if (pux2->default_program == NULL) {
                        no_default = 1;
@@ -1474,6 +1549,25 @@ void read_config(FILE* errorfp)
        mip = model_list;
 
        for (i = 0; i < MAXPAD; i++, mip++) {
+               if (mip->ux->common_data.configfile) {
+                       if (be_verbose) {
+                               fprintf(stderr, "%s %s\n", our_cnffile,
+                               mip->ux->common_data.configfile);
+                       }
+
+                       if ((k = read_header(errorfp, write_buffer,
+                                       mip->ux->common_data.configfile))) {
+                               mip->ux->common_data.userconfigversion = k;
+                               if (be_verbose) {
+                                       print_device(stderr,
+                                               mip->ux->common_data.padname,
+                                               mip->ux->common_data.sty1name,
+                                               mip->ux->common_data.sty2name);
+                               }
+                               read_body(errorfp, mip->ux, ux,
+                                       mip->ux->common_data.configfile);
+                       }
+               }
                if (mip->ux2->common_data.configfile) {
                        if (be_verbose) {
                                fprintf(stderr, "%s %s\n", our_cnffile,
index 32abce3..bb04e7e 100644 (file)
@@ -30,6 +30,7 @@ const char* configversion = "4";
 
 /* Externals: */
 
+extern const int ux;
 extern const int ux2;
 extern const int bbo;
 extern const int bee;
@@ -39,6 +40,7 @@ extern const int g4;
 extern const int g4b;
 extern const int nop;
 
+extern const int ux_num_list;
 extern const int ux2_num_list;
 extern const int bbo_num_list;
 extern const int bee_num_list;
@@ -50,6 +52,119 @@ extern const int nop_num_list;
 
 extern const char* our_prog_name;
 
+/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Write a set of records tuned for a Cintiq 21UX tablet:
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+
+static void write_ux(FILE* fp)
+{
+       int i;
+
+       const char* new_record =
+"%%                    # <---  ******** BEGIN NEW PROGRAM RECORD ********\n\n";
+       const char* name_tail = "# Name must be within double quotes \"\"";
+       const char* cur_tail = "# PressCurve must be within double quotes \"\"";
+       const char* sec_tail = "# Seconds (Max 10 - Min 0.01 - Or no delay)";
+       const char* tch_onoff = "# Switch 1/0 (Enable/Disable Touch Strips)";
+       const char* key_tail = "# Keycodes (Max number of keys to send is";
+       const char* tht_tail = "# Switch 1/0 (Finger held at top repeat keys)";
+       const char* thb_tail="# Switch 1/0 (Finger held at bottom repeat keys)";
+       const char* but_tail="# Switch 1/0 (Press and hold button repeat keys)";
+
+       struct ux_program* ip;
+       ip = ux_internal_list;
+       struct ux_configstrings* sp;
+       sp = ux_configstrings;
+
+       for (i = 0; i < ux_num_list; i++, ip++) {
+               fprintf(fp, "%s", new_record);
+
+               fprintf(fp, "%s         \"%s\" %s\n\n",
+               sp->common_string.class_name, ip->common_data.class_name,
+                                                               name_tail);
+
+               fprintf(fp, "%s \"%s\" %s\n",
+               sp->common_string.stylus1_presscurve,
+                               ip->common_data.stylus1_presscurve, cur_tail);
+               fprintf(fp, "%s \"%s\" %s\n\n",
+               sp->common_string.stylus2_presscurve,
+                               ip->common_data.stylus2_presscurve, cur_tail);
+
+               fprintf(fp, "%s %i.%i   %s\n\n",
+               sp->common_string.keycode_delay, *ip->common_data.keycode_delay,
+                               *(ip->common_data.keycode_delay+1), sec_tail);
+
+               fprintf(fp, "%s %i.%i   %s\n",
+               sp->button_string.repeat_after, *ip->button_data.repeat_after,
+                               *(ip->button_data.repeat_after+1), sec_tail);
+               fprintf(fp, "%s %i.%i   %s\n\n",
+               sp->button_string.repeat_delay, *ip->button_data.repeat_delay,
+                               *(ip->button_data.repeat_delay+1), sec_tail);
+
+               fprintf(fp, "%s %i.%i   %s\n",
+               sp->touch_string.repeat_after, *ip->touch_data.repeat_after,
+                               *(ip->touch_data.repeat_after+1), sec_tail);
+               fprintf(fp, "%s %i.%i   %s\n\n",
+               sp->touch_string.repeat_delay, *ip->touch_data.repeat_delay,
+                               *(ip->touch_data.repeat_delay+1), sec_tail);
+
+               fprintf(fp, "%s %i      %s\n\n",
+               sp->touch_string.handle_touch,
+                               *ip->touch_data.handle_touch, tch_onoff);
+
+               fprintf(fp, "%s         %i %i   %s %i)\n",
+               sp->touch_string.left_touch_up,
+                       *ip->touch_data.left_touch_up,
+                       *(ip->touch_data.left_touch_up+1), key_tail, MAXKEYS);
+               fprintf(fp, "%s %i %i   %s %i)\n\n",
+               sp->touch_string.left_touch_down,
+                       *ip->touch_data.left_touch_down,
+                       *(ip->touch_data.left_touch_down+1), key_tail, MAXKEYS);
+
+               fprintf(fp, "%s         %i      %s\n",
+               sp->touch_string.repeat_left_up,
+                               *ip->touch_data.repeat_left_up, tht_tail);
+               fprintf(fp, "%s         %i      %s\n\n",
+               sp->touch_string.repeat_left_down,
+                               *ip->touch_data.repeat_left_down, thb_tail);
+
+               fprintf(fp, "%s         %i %i   %s %i)\n",
+               sp->touch_string.right_touch_up,
+                       *ip->touch_data.right_touch_up,
+                       *(ip->touch_data.right_touch_up+1), key_tail, MAXKEYS);
+               fprintf(fp, "%s %i %i   %s %i)\n\n",
+               sp->touch_string.right_touch_down,
+                       *ip->touch_data.right_touch_down,
+                       *(ip->touch_data.right_touch_down+1), key_tail,MAXKEYS);
+
+               fprintf(fp, "%s         %i      %s\n",
+               sp->touch_string.repeat_right_up,
+                               *ip->touch_data.repeat_right_up, tht_tail);
+               fprintf(fp, "%s         %i      %s\n\n",
+               sp->touch_string.repeat_right_down,
+                               *ip->touch_data.repeat_right_down, thb_tail);
+
+#define UX_BUTTON(n) \
+               fprintf(fp, "%s         %i %i   %s %i)\n", \
+                       sp->button_string.button##n, \
+                       *ip->button_data.button##n, \
+                       *(ip->button_data.button##n + 1), \
+                       key_tail, MAXKEYS); \
+               fprintf(fp, "%s         %i      %s\n", \
+                       sp->button_string.repeat##n, \
+                       *ip->button_data.repeat##n, \
+                       but_tail);
+               UX_BUTTON(1);
+               UX_BUTTON(2);
+               UX_BUTTON(3);
+               UX_BUTTON(4);
+               UX_BUTTON(5);
+               UX_BUTTON(6);
+               UX_BUTTON(7);
+               UX_BUTTON(8);
+       }
+}
+
 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  Write a set of records tuned for a Cintiq 21UX2 tablet:
  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
@@ -884,6 +999,18 @@ static void write_preface(FILE* fp, const int model)
        const char* model_notnop1 =
 "# Some ASCII art showing the \"default\" program record:\n"
 "#\n";
+
+       const char* model_ux =
+"# Cintiq 21UX ExpressKeys Pad\n"
+"#   Left                              Right\n"
+"#  +----+   +---+---+    +---+---+   +----+\n"
+"#  | T  |   |   | 1 |    | 5 |   |   | T  |\n"
+"#  | O  |   | 3 |---|    +---+ 7 |   | O  |\n"
+"#  | U  |   |   | 2 |    | 6 |   |   | U  |\n"
+"#  | C  |   +---+---+    +---+---+   | C  |\n"
+"#  | H  |   |   4   |    |   8   |   | H  |\n"
+"#  +----+   +---+---+    +---+---+   +----+\n"
+"# The N/A keys aren't supported yet\n";
        
        const char* model_ux2 =
 "# Cintiq 21UX2 ExpressKeys Pad\n"
@@ -1051,6 +1178,9 @@ static void write_preface(FILE* fp, const int model)
                fprintf(fp, "%s", model_notnop1);
        }
 
+       if (model == ux)
+               fprintf(fp, "%s", model_ux);
+
        if (model == ux2)
                fprintf(fp, "%s", model_ux2);
 
@@ -1105,7 +1235,9 @@ static void write_if_lacking(FILE* errorfp, const char* configfile, int model)
 
                write_preface(fp, model);
 
-               if (model == ux2) {
+               if (model == ux) {
+                       write_ux(fp);
+               } else if (model == ux2) {
                        write_ux2(fp);
                } else if (model == bbo) {
                        write_bbo(fp);
@@ -1146,6 +1278,10 @@ void write_config(FILE* errorfp)
        mip = model_list;
 
        for (i = 0; i < MAXPAD; i++, mip++) {
+               if (mip->ux->common_data.configfile) {
+                       write_if_lacking(errorfp,
+                                       mip->ux->common_data.configfile, ux);
+               }
                if (mip->ux2->common_data.configfile) {
                        write_if_lacking(errorfp,
                                        mip->ux2->common_data.configfile, ux2);
index cc4d3b5..39d99e1 100644 (file)
@@ -31,8 +31,8 @@ extern void exit_on_error(FILE* errorfp, char* string1, const char* string2,
 the longest keyword (currently RightPadTouchDown + a space = 18) + 32 keycodes
 of max 4 digits length + a space between each of them (sum 178): */
 #define MAXBUFFER 180
-/* 'Models': padless, Graphire4 BlueTooth, Graphire4, Intuos3 small, Intuos3, Bee, Bamboo */
-#define MAXMODEL 8
+/* 'Models': padless, Graphire4 BlueTooth, Graphire4, Intuos3 small, Intuos3, Bee, Bamboo, Cintiq 21UX, Cintiq 21UX2 */
+#define MAXMODEL 9
 /* Max number of tablets per 'model': */
 #define MAXPAD 3
 /* Max number of styli per tablet: */
index d40cb43..6350af9 100644 (file)
@@ -39,6 +39,7 @@ static unsigned long int* id_sty2;
 
 /* Crucial flags to keep track of the event state
  (except for the is_pad. But the future...): */
+static int is_ux;
 static int is_ux2;
 static int is_bbo;
 static int is_bee;
@@ -313,6 +314,11 @@ static void prepare_action(int fake_key, int which_action)
 
        mip = model_list;
        for (i = 0; i < MAXPAD; i++, mip++) {
+               if ((mip->ux->common_data.sty1id != NULL)
+               && (mip->ux->common_data.sty1id == id_sty1)) {
+                       cdp = &mip->ux->common_data;
+                       break;
+               }
                if ((mip->ux2->common_data.sty1id != NULL)
                && (mip->ux2->common_data.sty1id == id_sty1)) {
                        cdp = &mip->ux2->common_data;
@@ -560,6 +566,7 @@ static void do_repeat(void* base_address, void* record_address,
        XDeviceButtonEvent* tmp_button;
        XDeviceMotionEvent* tmp_motion;
 
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -573,7 +580,14 @@ static void do_repeat(void* base_address, void* record_address,
        struct button_data* bdp = NULL;
        struct touch_data* tdp = NULL;
 
-       if (is_ux2) {
+       if (is_ux) {
+               pux = base_address;
+               base_cdp = &pux->common_data;
+               pux = record_address;
+               cdp = &pux->common_data;
+               bdp = &pux->button_data;
+               tdp = &pux->touch_data;
+       } else if (is_ux2) {
                pux2 = base_address;
                base_cdp = &pux2->common_data;
                pux2 = record_address;
@@ -1046,6 +1060,7 @@ static void do_motion(void* base_address, void* record_address,
                rotation = motion->axis_data[0];
        }
 
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -1054,7 +1069,11 @@ static void do_motion(void* base_address, void* record_address,
        struct common_data* cdp = NULL;
        struct touch_data* tdp = NULL;
 
-       if (is_ux2) {
+       if (is_ux) {
+               pux = record_address;
+               cdp = &pux->common_data;
+               tdp = &pux->touch_data;
+       } else if (is_ux2) {
                pux2 = record_address;
                cdp = &pux2->common_data;
                tdp = &pux2->touch_data;
@@ -1257,6 +1276,7 @@ static void do_button(void* base_address, void* record_address,
        int repeat_button = 0;
        int ok_button = 0;
 
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -1269,7 +1289,11 @@ static void do_button(void* base_address, void* record_address,
        struct button_data* bdp = NULL;
        struct wheel_data* wdp = NULL;
 
-       if (is_ux2) {
+       if (is_ux) {
+               pux = record_address;
+               cdp = &pux->common_data;
+               bdp = &pux->button_data;
+       } else if (is_ux2) {
                pux2 = record_address;
                cdp = &pux2->common_data;
                bdp = &pux2->button_data;
@@ -1343,7 +1367,7 @@ static void do_button(void* base_address, void* record_address,
                        }
                        break;
                case 4:
-                       if (is_ux2) {
+                       if (is_ux || is_ux2) {
                                if (*bdp->button4) {
                                        ok_button = 1;
                                        send_keys(bdp->button4, button_state);
@@ -1377,7 +1401,7 @@ configuration file *\n");
                        }
                        return;
                case 5:
-                       if (is_ux2) {
+                       if (is_ux || is_ux2) {
                                if (*bdp->button5) {
                                        ok_button = 1;
                                        send_keys(bdp->button5, button_state);
@@ -1554,6 +1578,7 @@ configuration file *\n");
 
 static void do_stylus(void* base_address, void* record_address)
 {
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -1566,7 +1591,12 @@ static void do_stylus(void* base_address, void* record_address)
        struct common_data* cdp = NULL;
        struct common_data* base_cdp = NULL;
 
-       if (is_ux2) {
+       if (is_ux) {
+               pux = base_address;
+               base_cdp = &pux->common_data;
+               pux = record_address;
+               cdp = &pux->common_data;
+       } else if (is_ux2) {
                pux2 = base_address;
                base_cdp = &pux2->common_data;
                pux2 = record_address;
@@ -1673,6 +1703,7 @@ static void* find_focus(void* record_address, XEvent Event)
        focus_window = None;
        name_change = 0;
 
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -1720,7 +1751,48 @@ static void* find_focus(void* record_address, XEvent Event)
 "--------------------------------------------------------------------------\n");
        }
 
-       if (is_ux2) {
+       if (is_ux) {
+               pux = record_address;
+               if ((focus_window == root) || (class_hint->res_class == NULL)) {
+                       record_address = pux->default_program;
+                       pux = record_address;
+                       if (be_verbose) {
+                               fprintf(stderr, "%s %s\n", prog_focus,
+                                               pux->common_data.class_name);
+                       }
+                       if (strcmp(namebuffer, pux->common_data.class_name)
+                                                                       != 0) {
+                               snprintf(namebuffer, MAXBUFFER, "%s",
+                                               pux->common_data.class_name);
+                               name_change = 1;
+                       }
+                       goto clean_up;
+               }
+               for (i = 0; i < record_num; i++, pux++) {
+                       if (strcmp(class_hint->res_class,
+                                       pux->common_data.class_name) == 0) {
+                               in_list = 1;
+                               break;
+                       }
+               }
+               if (!in_list) {
+                       pux = record_address;
+                       record_address = pux->default_program;
+                       pux = record_address;
+               } else {
+                       record_address = pux;
+               }
+               if (be_verbose) {
+                       fprintf(stderr, "%s %s\n", prog_focus,
+                                               pux->common_data.class_name);
+               }
+               if (strcmp(namebuffer, pux->common_data.class_name) != 0) {
+                       snprintf(namebuffer, MAXBUFFER, "%s",
+                                               pux->common_data.class_name);
+                       name_change = 1;
+               }
+               goto clean_up;
+       } else if (is_ux2) {
                pux2 = record_address;
                if ((focus_window == root) || (class_hint->res_class == NULL)) {
                        record_address = pux2->default_program;
@@ -2078,6 +2150,42 @@ static void* match_id(XDeviceButtonEvent* button, XDeviceMotionEvent* motion)
        if (button) {
                mip = model_list;
                for (i = 0; i < MAXPAD; i++, mip++) {
+                       if ((mip->ux->common_data.padid != NULL
+                       && *mip->ux->common_data.padid ==
+                                       button->deviceid)
+                       || (mip->ux->common_data.sty1id != NULL
+                       && *mip->ux->common_data.sty1id ==
+                                       button->deviceid)
+                       || (mip->ux->common_data.sty2id != NULL
+                       && *mip->ux->common_data.sty2id ==
+                                       button->deviceid)) {
+                               if (mip->ux->default_program == NULL) {
+                                       return NULL;
+                               }
+                               if (mip->ux->common_data.padid != NULL
+                               && *mip->ux->common_data.padid ==
+                                                       button->deviceid) {
+                                       is_pad = 1;
+                                       id_pad = mip->ux->common_data.padid;
+                               } else if (mip->ux->common_data.sty1id != NULL
+                               && *mip->ux->common_data.sty1id ==
+                                                       button->deviceid) {
+                                       is_sty1 = 1;
+                               } else if (mip->ux->common_data.sty2id != NULL
+                               && *mip->ux->common_data.sty2id ==
+                                                       button->deviceid) {
+                                       is_sty2 = 1;
+                               }
+                               is_ux = 1;
+                               record_num = mip->ux->common_data.num_record;
+                               if (mip->ux->common_data.sty1id != NULL) {
+                                       id_sty1 = mip->ux->common_data.sty1id;
+                               }
+                               if (mip->ux->common_data.sty2id != NULL) {
+                                       id_sty2 = mip->ux->common_data.sty2id;
+                               }
+                               return mip->ux;
+                       }
                        if ((mip->ux2->common_data.padid != NULL
                        && *mip->ux2->common_data.padid ==
                                        button->deviceid)
@@ -2360,6 +2468,24 @@ static void* match_id(XDeviceButtonEvent* button, XDeviceMotionEvent* motion)
        } else if (motion) {
                mip = model_list;
                for (i = 0; i < MAXPAD; i++, mip++) {
+                       if ((mip->ux->common_data.padid != NULL)
+                       && (*mip->ux->common_data.padid
+                                       == motion->deviceid)) {
+                               if (mip->ux->default_program == NULL) {
+                                       return NULL;
+                               }
+                               is_pad = 1;
+                               is_ux = 1;
+                               id_pad = mip->ux->common_data.padid;
+                               record_num = mip->ux->common_data.num_record;
+                               if (mip->ux->common_data.sty1id != NULL) {
+                                       id_sty1 = mip->ux->common_data.sty1id;
+                               }
+                               if (mip->ux->common_data.sty2id != NULL) {
+                                       id_sty2 = mip->ux->common_data.sty2id;
+                               }
+                               return mip->ux;
+                       }
                        if ((mip->ux2->common_data.padid != NULL)
                        && (*mip->ux2->common_data.padid
                                        == motion->deviceid)) {
@@ -2509,6 +2635,7 @@ void use_events()
                        }
                }
 
+               is_ux = 0;
                is_ux2 = 0;
                is_bbo = 0;
                is_bee = 0;
index 0a0a2e8..63f018d 100644 (file)
@@ -43,6 +43,7 @@ int proximity_in_type;
 int proximity_out_type;
 
 /* Used in many situations as identification, for math and for flow control: */
+const int ux = 8;
 const int ux2 = 7;
 const int bbo = 6;
 const int bee = 5;
@@ -225,7 +226,7 @@ static int identify_device(char* device_name)
                                return bee;
                        }
                        if ((strncmp(read_buffer, cintiq_21UX, len)) == 0) {
-                               return i3;
+                               return ux;
                        }
                        if (((strncmp(read_buffer, i3_6x8, len)) == 0)
                                || ((strncmp(read_buffer, i3_9x12, len)) == 0)
index 0904a82..b6a5851 100644 (file)
@@ -50,12 +50,16 @@ const char* total_file3_bbo;
 const char* total_file1_ux2;
 const char* total_file2_ux2;
 const char* total_file3_ux2;
+const char* total_file1_ux;
+const char* total_file2_ux;
+const char* total_file3_ux;
 
 /* Externals: */
 
 extern int have_pad;
 extern int have_padless;
 
+extern const int ux;
 extern const int ux2;
 extern const int bbo;
 extern const int bee;
@@ -91,6 +95,20 @@ static void mark_device(const char* device, int row, int column,
                                                        const char* configfile)
 {
        if (device == pad_string) {
+               if (row == ux) {
+                       struct ux_program* p = NULL;
+                       if (column == 0) {
+                               p = ux_1_external_list;
+                       } else if (column == 1) {
+                               p = ux_2_external_list;
+                       } else if (column == 2) {
+                               p = ux_3_external_list;
+                       }
+                       p->common_data.padname = pad_name[row][column];
+                       p->common_data.padid = pad_id[row][column];
+                       p->common_data.configfile = configfile;
+                       return;
+               }
                if (row == ux2) {
                        struct ux2_program* p = NULL;
                        if (column == 0) {
@@ -412,8 +430,35 @@ static void mark_config(const char* device, int row, int column)
        const char* file1_ux2 = "/ux2.conf1";
        const char* file2_ux2 = "/ux2.conf2";
        const char* file3_ux2 = "/ux2.conf3";
+       const char* file1_ux = "/ux.conf1";
+       const char* file2_ux = "/ux.conf2";
+       const char* file3_ux = "/ux.conf3";
 
        switch (row) {
+/* pad Cintiq 21ux */
+       case 8:
+               switch (column) {
+               case 0:
+                       total_file1_ux = path_malloc
+                               ((void*)total_config_dir, (void*)file1_ux);
+                       mark_device(device, row, column, total_file1_ux);
+                       return;
+
+               case 1:
+                       total_file2_ux = path_malloc
+                               ((void*)total_config_dir, (void*)file2_ux);
+                       mark_device(device, row, column, total_file2_ux);
+                       return;
+
+               case 2:
+                       total_file3_ux = path_malloc
+                               ((void*)total_config_dir, (void*)file3_ux);
+                       mark_device(device, row, column, total_file3_ux);
+                       return;
+
+               default:
+                       return;
+               }
 /* pad Cintiq 21ux2 */
        case 7:
                switch (column) {
index c81b77b..8bcf0c2 100644 (file)
@@ -43,6 +43,7 @@ const char* sty2str = "CurrentSty2";
 extern int ok_config;
 extern int go_daemon;
 
+extern const int ux;
 extern const int ux2;
 extern const int bbo;
 extern const int bee;
@@ -95,6 +96,9 @@ extern char* total_file3_bbo;
 extern char* total_file1_ux2;
 extern char* total_file2_ux2;
 extern char* total_file3_ux2;
+extern char* total_file1_ux;
+extern char* total_file2_ux;
+extern char* total_file3_ux;
 
 extern void read_config(FILE* errorfp);
 
@@ -118,11 +122,12 @@ Intuos3/Cintiq, Cintiq 20wsx, Bamboo, Cintiq 21UX2\n");
        fprintf(statusfp, "%i (bee): 0 1 2\n", bee);
        fprintf(statusfp, "%i (bbo): 0 1 2\n", bbo);
        fprintf(statusfp, "%i (ux2): 0 1 2\n\n", ux2);
+       fprintf(statusfp, "%i (ux): 0 1 2\n\n", ux);
        fprintf(statusfp, "* Stylus-index *\n");
        fprintf(statusfp, "0 st1 (nop): 0 1 2 (g4b): 3 4 5 (g4): 6 7 8 \
-(i3s): 9 10 11 (i3): 12 13 14 (bee): 15 16 (bbo): 17 18 (ux2): 19 20\n");
+(i3s): 9 10 11 (i3): 12 13 14 (bee): 15 16 (bbo): 17 18 (ux2): 19 20 (ux): 21 22\n");
        fprintf(statusfp, "1 st2 (nop): 0 1 2 (g4b): 3 4 5 (g4): 6 7 8 \
-(i3s): 9 10 11 (i3): 12 13 14 (bee): 15 16 (bbo): 17 18 (ux2): 19 20\n\n");
+(i3s): 9 10 11 (i3): 12 13 14 (bee): 15 16 (bbo): 17 18 (ux2): 19 20 (ux): 21 22\n\n");
        fprintf(statusfp, "PGR RUNNAME = %s\n", our_prog_name);
        fprintf(statusfp, "PGR VERSION = %s\n", our_prog_version);
        fprintf(statusfp, "USR HOMEDIR = %s\n", getenv("HOME"));
@@ -156,6 +161,7 @@ Intuos3/Cintiq, Cintiq 20wsx, Bamboo, Cintiq 21UX2\n");
 
 static void report_record(FILE* statusfp, void* address, const int model)
 {
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -166,7 +172,10 @@ static void report_record(FILE* statusfp, void* address, const int model)
        struct nop_program* pnop;
        struct common_data* cdp = NULL;
 
-       if (model == ux2) {
+       if (model == ux) {
+               pux = address;
+               cdp = &pux->common_data;
+       } else if (model == ux2) {
                pux2 = address;
                cdp = &pux2->common_data;
        } else if (model == bbo) {
@@ -233,6 +242,7 @@ static void report_common(FILE* statusfp)
        int num_record;
        const char* pgr_records = "PGR RECORDS =";
 
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -246,6 +256,20 @@ static void report_common(FILE* statusfp)
        mip = model_list;
 
        for (i = 0; i < MAXPAD; i++, mip++) {
+               if (mip->ux->common_data.num_record) {
+                       print_common(statusfp, mip->ux->common_data.configfile,
+                                       mip->ux->common_data.userconfigversion,
+                                               mip->ux->common_data.padname,
+                                               mip->ux->common_data.sty1name,
+                                               mip->ux->common_data.sty2name);
+                       num_record = mip->ux->common_data.num_record;
+                       pux = mip->ux;
+                       for (j = 0; j < num_record; j++, pux++) {
+                               report_record(statusfp, pux, ux);
+                       }
+                       fprintf(statusfp, "%s %i (of max %i)\n\n", pgr_records,
+                                                       num_record, MAXRECORDS);
+               }
                if (mip->ux2->common_data.num_record) {
                        print_common(statusfp, mip->ux2->common_data.configfile,
                                        mip->ux2->common_data.userconfigversion,
@@ -438,6 +462,7 @@ void re_read_config(int signum)
 
 static void free_common(void* address, const int model)
 {
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -448,7 +473,10 @@ static void free_common(void* address, const int model)
        struct nop_program* pnop;
        struct common_data* cdp = NULL;
 
-       if (model == ux2) {
+       if (model == ux) {
+               pux = address;
+               cdp = &pux->common_data;
+       } else if (model == ux2) {
                pux2 = address;
                cdp = &pux2->common_data;
        } else if (model == bbo) {
@@ -501,6 +529,7 @@ void clean_up_exit(int signum)
 {
        int i, j;
 
+       struct ux_program* pux;
        struct ux2_program* pux2;
        struct bbo_program* pbbo;
        struct bee_program* pbee;
@@ -527,6 +556,12 @@ void clean_up_exit(int signum)
 
        mip = model_list;
        for (i = 0; i < MAXPAD; i++, mip++) {
+               if (mip->ux->common_data.configfile) {
+                       pux = mip->ux;
+                       for (j = 0; j < MAXRECORDS; j++, pux++) {
+                               free_common(pux, ux);
+                       }
+               }
                if (mip->ux2->common_data.configfile) {
                        pux2 = mip->ux2;
                        for (j = 0; j < MAXRECORDS; j++, pux2++) {
@@ -696,6 +731,18 @@ void clean_up_exit(int signum)
                free(total_file3_ux2);
        }
 
+/*---*/
+
+       if (total_file1_ux) {
+               free(total_file1_ux);
+       }
+       if (total_file2_ux) {
+               free(total_file2_ux);
+       }
+       if (total_file3_ux) {
+               free(total_file3_ux);
+       }
+
 /* The pad devices and styli devices should not be explicitly closed by a
  call to XCloseDevice. It leaves a message from X (in the terminal where X
  is started from) saying: "ProcXCloseDevice to close or not ?" Instead we
index 8d6cf98..c9130f8 100644 (file)
 
 /* Globals: */
 
+struct ux_program ux_internal_list[] = {
+       {
+       .common_data = {
+               .class_name = "default",
+               .stylus1_presscurve = "0 0 100 100",
+               .stylus2_presscurve = "0 0 100 100",
+               },
+       .touch_data = {
+               .handle_touch = { 0 },
+               .repeat_after = { 0, 6 },
+               .repeat_delay = { 0, 1 },
+               .repeat_left_up = { 1 },
+               .repeat_left_down = { 1 },
+               .repeat_right_up = { 1 },
+               .repeat_right_down = { 1 },
+               .left_touch_up = { 994, 0 },
+               .left_touch_down = { 995, 0 },
+               .right_touch_up = { 98, 0 },
+               .right_touch_down = { 104, 0 },
+               },
+       .button_data = {
+               .repeat_after = { 0, 5 },
+               .repeat_delay = { 0, 1 },
+               .button1 = { 50, 0 },
+               .button2 = { 64, 0 },
+               .button3 = { 37, 0 },
+               .button4 = { 65, 0 },
+               .button5 = { 50, 0 },
+               .button6 = { 64, 0 },
+               .button7 = { 37, 0 },
+               .button8 = { 65, 0 },
+               },
+       },
+       {
+       .common_data = {
+               .class_name = "Gimp",
+               .stylus1_presscurve = "0 0 100 100",
+               .stylus2_presscurve = "0 0 100 100",
+               },
+       .touch_data = {
+               .handle_touch = { 0 },
+               .repeat_after = { 0, 6 },
+               .repeat_delay = { 0, 1 },
+               .left_touch_up = { 20, 0 },
+               .left_touch_down = { 61, 0 },
+               .right_touch_up = { 98, 20 },
+               .right_touch_down = { 104, 61 },
+               },
+       .button_data = {
+               .repeat_after = { 0, 5 },
+               .repeat_delay = { 0, 1 },
+               .button1 = { 50, 0 },
+               .button2 = { 64, 0 },
+               .button3 = { 37, 0 },
+               .button4 = { 65, 0 },
+               .button5 = { 37, 29 },
+               .button6 = { 37, 52 },
+               .button7 = { 999, 0 },
+               .button8 = { 65, 0 },
+               },
+       },
+       {
+       .common_data = {
+               .class_name = "Blender",
+               .stylus1_presscurve = "0 0 100 100",
+               .stylus2_presscurve = "0 0 100 100",
+               },
+       .touch_data = {
+               .handle_touch = { 0 },
+               .repeat_after = { 0, 6 },
+               .repeat_delay = { 0, 1 },
+               .repeat_left_up = { 1 },
+               .repeat_left_down = { 1 },
+               .repeat_right_up = { 1 },
+               .repeat_right_down = { 1 },
+               .left_touch_up = { 102, 0 },
+               .left_touch_down = { 100, 0 },
+               .right_touch_up = { 98, 0 },
+               .right_touch_down = { 104, 0 },
+               },
+       .button_data = {
+               .repeat_after = { 0, 5 },
+               .repeat_delay = { 0, 1 },
+               .button1 = { 37, 0 },
+               .button2 = { 9, 0 },
+               .button3 = { 50, 0 },
+               .button4 = { 23, 0 },
+               .button5 = { 37, 29 },
+               .button6 = { 37, 52 },
+               .button7 = { 999, 0 },
+               .button8 = { 65, 0 },
+               },
+       },
+       {
+       .common_data = {
+               .class_name = "XTerm",
+               .stylus1_presscurve = "0 0 100 100",
+               .stylus2_presscurve = "0 0 100 100",
+               },
+       .touch_data = {
+               .repeat_after = { 0, 6 },
+               .repeat_delay = { 0, 1 },
+               },
+       .button_data = {
+               .repeat_after = { 0, 5 },
+               .repeat_delay = { 0, 1 },
+               .button8 = { 999, 0 },
+               },
+       },
+};
+const int ux_num_list = (sizeof ux_internal_list / sizeof ux_internal_list[0]);
+
+struct ux_program ux_1_external_list[MAXRECORDS];
+struct ux_program ux_2_external_list[MAXRECORDS];
+struct ux_program ux_3_external_list[MAXRECORDS];
+
+struct ux_configstrings ux_configstrings[] = {
+{
+       .common_string = {"DelayEachKeycode", "ProgramName", "Stylus1PressCurve", "Stylus2PressCurve"},
+       .touch_string = {"HandleTouchStrips", "TouchRepeatAfter", "DelayTouchRepeat",
+                        "RepeatLeftUp", "RepeatLeftDown", "RepeatRightUp", "RepeatRightDown",
+                        "LeftPadTouchUp", "LeftPadTouchDown", "RightPadTouchUp", "RightPadTouchDown"},
+       .button_string = {
+               .repeat_after = "ButtonRepeatAfter",
+               .repeat_delay = "DelayButtonRepeat",
+               .repeat1 = "RepeatButton1",
+               .repeat2 = "RepeatButton2",
+               .repeat3 = "RepeatButton3",
+               .repeat4 = "RepeatButton4",
+               .repeat5 = "RepeatButton5",
+               .repeat6 = "RepeatButton6",
+               .repeat7 = "RepeatButton7",
+               .repeat8 = "RepeatButton8",
+               .button1 = "LeftPadButton1",
+               .button2 = "LeftPadButton2",
+               .button3 = "LeftPadButton3",
+               .button4 = "LeftPadButton4",
+               .button5 = "RightPadButton5",
+               .button6 = "RightPadButton6",
+               .button7 = "RightPadButton7",
+               .button8 = "RightPadButton8",
+       },
+}};
+
 struct ux2_program ux2_internal_list[] = {
        {
        .common_data = {
@@ -917,12 +1061,15 @@ struct nop_configstrings nop_configstrings[] = {
 };
 
 struct model_index model_list[] = {
-       {ux2_1_external_list, bbo_1_external_list, bee_1_external_list, i3_1_external_list,
-        i3s_1_external_list, g4_1_external_list, g4b_1_external_list, nop_1_external_list},
-       {ux2_2_external_list, bbo_2_external_list, bee_2_external_list, i3_2_external_list,
-        i3s_2_external_list, g4_2_external_list, g4b_2_external_list, nop_2_external_list},
-       {ux2_3_external_list, bbo_3_external_list, bee_3_external_list, i3_3_external_list,
-        i3s_3_external_list, g4_3_external_list, g4b_3_external_list, nop_3_external_list}
+       {ux_1_external_list, ux2_1_external_list, bbo_1_external_list, bee_1_external_list,
+        i3_1_external_list, i3s_1_external_list, g4_1_external_list, g4b_1_external_list,
+        nop_1_external_list},
+       {ux_2_external_list, ux2_2_external_list, bbo_2_external_list, bee_2_external_list,
+        i3_2_external_list, i3s_2_external_list, g4_2_external_list, g4b_2_external_list,
+        nop_2_external_list},
+       {ux_3_external_list, ux2_3_external_list, bbo_3_external_list, bee_3_external_list,
+        i3_3_external_list, i3s_3_external_list, g4_3_external_list, g4b_3_external_list,
+        nop_3_external_list}
 };
 
 /* End Code */
index 1216580..3e8cd81 100644 (file)
@@ -106,6 +106,14 @@ extern struct button_data {
 
 
 /* Data structures (consolidation): */
+extern struct ux_program {
+       struct ux_program* default_program;
+       struct common_data common_data;
+       struct touch_data touch_data;
+       struct button_data button_data;
+} ux_internal_list[], ux_1_external_list[], ux_2_external_list[],
+                                                       ux_3_external_list[];
+
 extern struct ux2_program {
        struct ux2_program* default_program;
        struct common_data common_data;
@@ -242,6 +250,12 @@ extern struct button_string {
 
 /* String structures (consolidation): */
 
+extern struct ux_configstrings {
+       struct common_string common_string;
+       struct touch_string touch_string;
+       struct button_string button_string;
+} ux_configstrings[];
+
 extern struct ux2_configstrings {
        struct common_string common_string;
        struct touch_string touch_string;
@@ -292,6 +306,7 @@ extern struct nop_configstrings {
 /* Data structure (final consolidation): */
 
 extern struct model_index {
+       struct ux_program* ux;
        struct ux2_program* ux2;
        struct bbo_program* bbo;
        struct bee_program* bee;