diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7eb29c..875db3b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,7 +166,7 @@ jobs: - name: Build Mbed TLS run: | cd mbedtls-${{ env.MBEDTLS_VERSION }} - cat ../patches/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1 + cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1 mkdir build cd build cmake .. \ @@ -530,7 +530,7 @@ jobs: - name: Build Mbed TLS run: | cd mbedtls-${{ env.MBEDTLS_VERSION }} - cat ../patches/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1 + cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1 mkdir build cd build cmake .. \ @@ -584,6 +584,7 @@ jobs: - name: Build GPM run: | cd gpm-${{ env.GPM_VERSION }} + cat ../patches/gpm/*.patch | patch -sN -d . -p1 ./autogen.sh ./configure \ ${{ env.CONFIGURE_ARGS }} diff --git a/patches/gpm/001_missing_V_option.patch b/patches/gpm/001_missing_V_option.patch new file mode 100644 index 0000000..cb35a27 --- /dev/null +++ b/patches/gpm/001_missing_V_option.patch @@ -0,0 +1,23 @@ +Description: Add no-op option -V for compatibility + +Index: b/src/daemon/cmdline.c +=================================================================== +--- a/src/daemon/cmdline.c 2008-05-29 02:26:08.000000000 +0300 ++++ b/src/daemon/cmdline.c 2008-06-11 05:46:23.000000000 +0300 +@@ -32,7 +32,7 @@ + void cmdline(int argc, char **argv) + { + extern struct options option; +- char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:Tuv23"; ++ char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV23"; + int opt; + + /* initialize for the dual mouse */ +@@ -81,6 +81,7 @@ void cmdline(int argc, char **argv) + case 'u': option.autodetect = 1; break; + case 'T': opt_test++; break; + case 'v': printf(GPM_MESS_VERSION "\n"); exit(0); ++ case 'V': /* Compat code */ break; + case '2': (which_mouse->opt_three) = -1; break; + case '3': (which_mouse->opt_three) = 1; break; + default: exit(usage("commandline")); diff --git a/patches/gpm/010_ps2_rework.patch b/patches/gpm/010_ps2_rework.patch new file mode 100644 index 0000000..a11e714 --- /dev/null +++ b/patches/gpm/010_ps2_rework.patch @@ -0,0 +1,501 @@ +Description: PS/2 rework +Author: Zephaniah E. Hull + +--- a/src/headers/gpmInt.h ++++ b/src/headers/gpmInt.h +@@ -54,6 +54,7 @@ + #define GPM_AUX_ID_ERROR -1 + #define GPM_AUX_ID_PS2 0 + #define GPM_AUX_ID_IMPS2 3 ++#define GPM_AUX_ID_EXPS2 4 + + /* these are shameless stolen from /usr/src/linux/include/linux/pc_keyb.h */ + +@@ -65,6 +66,7 @@ + #define GPM_AUX_SET_SAMPLE 0xF3 /* Set sample rate */ + #define GPM_AUX_ENABLE_DEV 0xF4 /* Enable aux device */ + #define GPM_AUX_DISABLE_DEV 0xF5 /* Disable aux device */ ++#define GPM_AUX_DEFAULTS 0xF6 /* Reset to defaults */ + #define GPM_AUX_RESET 0xFF /* Reset aux device */ + #define GPM_AUX_ACK 0xFA /* Command byte ACK. */ + +--- a/src/daemon/startup.c ++++ b/src/daemon/startup.c +@@ -35,21 +35,9 @@ + + void startup(int argc, char **argv) + { +- int i, opt; ++ int i, j, opt; ++ char *p; + +- static struct { +- char *in; +- char *out; +- } seq[] = { +- {"123","01234567"}, +- {"132","02134657"}, +- {"213","01452367"}, /* warning: these must be readable as integers... */ +- {"231","02461357"}, +- {"312","04152637"}, +- {"321","04261537"}, +- {NULL,NULL} +- }; +- + /* log to debug, who we are */ + gpm_report(GPM_PR_DEBUG, GPM_MESS_VERSION); + +@@ -92,16 +80,23 @@ + which_mouse=mouse_table+i; /* used to access options */ + if ((which_mouse->opt_accel) < 1) exit(usage("acceleration")); + if ((which_mouse->opt_delta) < 2) exit(usage("delta")); +- if (strlen((which_mouse->opt_sequence)) != 3 || atoi((which_mouse->opt_sequence))<100) ++ if (strlen(which_mouse->opt_sequence) <= 0) + exit(usage("sequence")); +- if ((which_mouse->opt_glidepoint_tap) > 3) exit(usage("glidepoint tap button")); +- if ((which_mouse->opt_glidepoint_tap)) +- (which_mouse->opt_glidepoint_tap)=GPM_B_LEFT >> ((which_mouse->opt_glidepoint_tap)-1); + + /* choose the sequence */ +- for (opt=0; seq[opt].in && strcmp(seq[opt].in,(which_mouse->opt_sequence)); opt++) ; +- if(!seq[opt].in) exit(usage("button sequence")); +- (which_mouse->opt_sequence)=strdup(seq[opt].out); /* I can rewrite on it */ ++ for (j = 0; j < 9; j++) ++ which_mouse->opt_buts[j] = 1 << j; ++ ++ for (p = which_mouse->opt_sequence, j = 0; *p != '\0'; p++, j++) { ++ if ((*p < '0') || (*p > '9')) ++ exit(usage("button sequence")); ++ which_mouse->opt_buts[j] = (1 << (*p - '1')); ++ } ++ ++ if (which_mouse->opt_glidepoint_tap > 9) ++ exit(usage("glidepoint tap button")); ++ if (which_mouse->opt_glidepoint_tap) ++ which_mouse->opt_glidepoint_tap = which_mouse->opt_buts[which_mouse->opt_glidepoint_tap - 1]; + + /* look for the mouse type */ + (which_mouse->m_type) = find_mouse_by_name((which_mouse->opt_type)); +--- a/src/mice.c ++++ b/src/mice.c +@@ -5,6 +5,7 @@ + * Copyright (C) 1994-2000 Alessandro Rubini + * Copyright (C) 1998,1999 Ian Zimmerman + * Copyright (C) 2001-2008 Nico Schottelius ++ * Copyright (C) 2002 Zephaniah E. Hull + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -55,6 +56,7 @@ + #include + #include /* stat() */ + #include /* select() */ ++#include /* poll() */ + + #include /* MAJOR */ + #include +@@ -603,14 +605,21 @@ + return 0; + } + ++/* ++ * PS/2 mouse parser. ++ * Also called by the 'children' of the PS/2 mouse, for insanity sake. ++ * -- Zephaniah E. Hull. ++ */ + static int M_ps2(Gpm_Event *state, unsigned char *data) + { + static int tap_active=0; /* there exist glidepoint ps2 mice */ + +- state->buttons= +- !!(data[0]&1) * GPM_B_LEFT + +- !!(data[0]&2) * GPM_B_RIGHT + +- !!(data[0]&4) * GPM_B_MIDDLE; ++ state->wdx = state->wdy = 0; ++ ++ state->buttons = ++ ((data[0] & 0x02) ? (1 << 0) : 0) | // Right. ++ ((data[0] & 0x04) ? (1 << 1) : 0) | // Middle. ++ ((data[0] & 0x01) ? (1 << 2) : 0); // Left. + + if (data[0]==0 && (which_mouse->opt_glidepoint_tap)) /* by default this is false */ + state->buttons = tap_active = (which_mouse->opt_glidepoint_tap); +@@ -639,27 +648,28 @@ + return 0; + } + ++/* ++ * I cheat, because the two protocols are almost identical except for ++ * the 4th and 5th buttons, I just handle both. ++ * ++ * Note, the only thing that I've seen describe the 4th and 5th buttons ++ * for the IMPS/2 protocol is the X4 source, someone let me know if they ++ * actually see this used? ++ * -- Zephaniah E. Hull. ++ */ + static int M_imps2(Gpm_Event *state, unsigned char *data) + { +- +- static int tap_active=0; /* there exist glidepoint ps2 mice */ +- state->wdx = state->wdy = 0; /* Clear them.. */ +- state->dx = state->dy = state->wdx = state->wdy = 0; +- +- state->buttons= ((data[0] & 1) << 2) /* left */ +- | ((data[0] & 6) >> 1); /* middle and right */ +- +- if (data[0]==0 && (which_mouse->opt_glidepoint_tap)) // by default this is false +- state->buttons = tap_active = (which_mouse->opt_glidepoint_tap); +- else if (tap_active) { +- if (data[0]==8) +- state->buttons = tap_active = 0; +- else state->buttons = tap_active; +- } ++ M_ps2(state, data); + + /* Standard movement.. */ + state->dx = (data[0] & 0x10) ? data[1] - 256 : data[1]; + state->dy = (data[0] & 0x20) ? -(data[2] - 256) : -data[2]; ++ ++ state->buttons += ++ ((data[0] & 0x40) ? (1 << 3) : 0) | // IMPS/2 Button 4 ++ ((data[0] & 0x80) ? (1 << 4) : 0) | // IMPS/2 Button 5 ++ ((data[3] & 0x10) ? (1 << 3) : 0) | // EXPS/2 Button 4 ++ ((data[3] & 0x20) ? (1 << 4) : 0); // EXPS/2 Button 5 + + /* The wheels.. */ + unsigned char wheel = data[3] & 0x0f; +@@ -723,17 +733,6 @@ + return 0; + } + +-/* standard ps2 */ +-static Gpm_Type *I_ps2(int fd, unsigned short flags, +- struct Gpm_Type *type, int argc, char **argv) +-{ +- static unsigned char s[] = { 246, 230, 244, 243, 100, 232, 3, }; +- write (fd, s, sizeof (s)); +- usleep (30000); +- tcflush (fd, TCIFLUSH); +- return type; +-} +- + static Gpm_Type *I_netmouse(int fd, unsigned short flags, + struct Gpm_Type *type, int argc, char **argv) + { +@@ -1930,92 +1929,168 @@ + * + * Returns 0 if OK, or >0 if 1 or more errors occurred. + */ +-static int write_to_mouse(int fd, unsigned char *data, size_t len) ++static int write_ps2(int fd, unsigned char cmd0, unsigned char cmd1, ++ size_t num, size_t rnum, unsigned long int sleep) + { +- int i; +- int error = 0; +- for (i = 0; i < len; i++) { +- unsigned char c; +- write(fd, &data[i], 1); +- read(fd, &c, 1); +- if (c != GPM_AUX_ACK) error++; ++ int i, error = 0, rcnt; ++ unsigned char cmd[2], ret[512]; ++ ++ cmd[0] = cmd0; ++ cmd[1] = cmd1; ++ ++ if (sleep == -1) ++ sleep = 50000; ++ ++ alarm(5); ++ rcnt = write(fd, cmd, num); ++ alarm(0); ++ if (rcnt != num) ++ return 1; ++ ++ usleep(sleep); ++ ++ alarm(5); ++ rcnt = read(fd, ret, rnum); ++ alarm(0); ++ ++ usleep(sleep); ++ ++ if (rcnt <= 0) ++ error++; ++ ++ for (i = 0; i < rcnt; i++) { ++ if (ret[i] != GPM_AUX_ACK) { ++ gpm_report(GPM_PR_ERR, "write_ps2: %d %d, %x", rcnt, i, ret[i]); ++ error++; ++ } + } + +- /* flush any left-over input */ +- usleep (30000); +- tcflush (fd, TCIFLUSH); + return(error); + } + ++static Gpm_Type *get_mouse_type(char *name) ++{ ++ Gpm_Type *type; + ++ for (type = mice; type->fun; type++) { ++ if (strcmp(type->name, name) == 0) ++ return(type); ++ } ++ return NULL; ++} ++ + /* intellimouse, ps2 version: Ben Pfaff and Colin Plumb */ + /* Autodetect: Steve Bennett */ +-static Gpm_Type *I_imps2(int fd, unsigned short flags, struct Gpm_Type *type, +- int argc, char **argv) ++static Gpm_Type *I_ps2(int fd, unsigned short flags_unused, ++ struct Gpm_Type *type, int argc, char **argv) + { +- int id; +- static unsigned char basic_init[] = { GPM_AUX_ENABLE_DEV, GPM_AUX_SET_SAMPLE, 100 }; +- static unsigned char imps2_init[] = { GPM_AUX_SET_SAMPLE, 200, GPM_AUX_SET_SAMPLE, 100, GPM_AUX_SET_SAMPLE, 80, }; +- static unsigned char ps2_init[] = { GPM_AUX_SET_SCALE11, GPM_AUX_ENABLE_DEV, GPM_AUX_SET_SAMPLE, 100, GPM_AUX_SET_RES, 3, }; +- +- /* Do a basic init in case the mouse is confused */ +- write_to_mouse(fd, basic_init, sizeof (basic_init)); +- +- /* Now try again and make sure we have a PS/2 mouse */ +- if (write_to_mouse(fd, basic_init, sizeof (basic_init)) != 0) { +- gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_INIT); +- return(NULL); +- } ++ int id, error = 0, rate; ++ ++ /* Flush any existing input. */ ++ tcflush(fd, TCIOFLUSH); + +- /* Try to switch to 3 button mode */ +- if (write_to_mouse(fd, imps2_init, sizeof (imps2_init)) != 0) { +- gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_FAILED); ++ if (write_ps2(fd, GPM_AUX_DEFAULTS, '\0', 1, 1, -1)) { ++ gpm_report(GPM_PR_ERR, "PS/2 mouse failed init"); + return(NULL); + } + +- /* Read the mouse id */ +- id = read_mouse_id(fd); +- if (id == GPM_AUX_ID_ERROR) { +- gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_MID_FAIL); +- id = GPM_AUX_ID_PS2; ++ // Magic to enable the IMPS/2 protocol. ++ if ((!strcmp(type->name, "imps2")) || (!strcmp(type->name, "autops2"))) { ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 100, 2, 2, -1); ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 80, 2, 2, -1); ++ if (error) { ++ gpm_report(GPM_PR_ERR, "imps2: PS/2 mouse failed (3 button) init"); ++ return(NULL); ++ } + } +- +- /* And do the real initialisation */ +- if (write_to_mouse(fd, ps2_init, sizeof (ps2_init)) != 0) { +- gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_SETUP_FAIL); ++ if ((!strcmp(type->name, "exps2")) || (!strcmp(type->name, "autops2"))) { ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 80, 2, 2, -1); ++ if (error) { ++ gpm_report(GPM_PR_ERR, "exps2: PS/2 mouse failed (3 button) init"); ++ return (NULL); ++ } + } + +- if (id == GPM_AUX_ID_IMPS2) { +- /* Really an intellipoint, so initialise 3 button mode (4 byte packets) */ +- gpm_report(GPM_PR_INFO,GPM_MESS_IMPS2_AUTO); +- return type; +- } +- if (id != GPM_AUX_ID_PS2) { +- gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_BAD_ID, id); ++ if (write_ps2(fd, GPM_AUX_SET_SCALE11, '\0', 1, 1, -1)) { ++ gpm_report(GPM_PR_ERR, "PS/2 mouse failed init: Unable to set 1:1 scale."); ++ return (NULL); ++ } ++ ++ if (which_mouse->opt_sample > 0) { ++ if (which_mouse->opt_sample >= 200) rate = 200; ++ else if (which_mouse->opt_sample >= 100) rate = 100; ++ else if (which_mouse->opt_sample >= 80) rate = 80; ++ else if (which_mouse->opt_sample >= 60) rate = 60; ++ else if (which_mouse->opt_sample >= 40) rate = 40; ++ else if (which_mouse->opt_sample >= 20) rate = 20; ++ else if (which_mouse->opt_sample >= 10) rate = 10; ++ else rate = 100; ++ } else { ++ rate = 100; ++ } ++ ++ if (write_ps2(fd, GPM_AUX_SET_SAMPLE, rate, 2, 1, -1)) { ++ gpm_report(GPM_PR_ERR, "PS/2 mouse failed init: Unable to set rate."); ++ return (NULL); ++ } ++ ++ if (!strcmp(type->name, "autops2")) { ++ /* Read the mouse id */ ++ id = read_mouse_id(fd); ++ ++ switch (id) { ++ case GPM_AUX_ID_ERROR: ++ gpm_report(GPM_PR_ERR, "Unable to read PS/2 mouse ID: Using base PS/2 protocol.\n"); ++ write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); ++ write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); ++ return get_mouse_type("ps2"); ++ case GPM_AUX_ID_PS2: ++ gpm_report(GPM_PR_INFO, "Detected base PS/2 protocol mouse."); ++ write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); ++ write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); ++ return get_mouse_type("ps2"); ++ case GPM_AUX_ID_IMPS2: ++ gpm_report(GPM_PR_INFO, "Detected IMPS/2 protocol mouse."); ++ write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); ++ write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); ++ return get_mouse_type("imps2"); ++ case GPM_AUX_ID_EXPS2: ++ gpm_report(GPM_PR_INFO, "Detected EXPS/2 protocol mouse."); ++ write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); ++ write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); ++ return get_mouse_type("exps2"); ++ default: ++ gpm_report(GPM_PR_ERR, "Unknown mouse ID, using base PS/2 protocol."); ++ write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); ++ write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); ++ return get_mouse_type("ps2"); ++ } + } +- else gpm_report(GPM_PR_INFO,GPM_MESS_IMPS2_PS2); + +- for (type=mice; type->fun; type++) +- if (strcmp(type->name, "ps2") == 0) return(type); ++ write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); ++ write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); + +- /* ps2 was not found!!! */ +- return(NULL); ++ return type; + } + +-/* +- * This works with Dexxa Optical Mouse, but because in X same initstring +- * is named ExplorerPS/2 so I named it in the same way. +- */ +-static Gpm_Type *I_exps2(int fd, unsigned short flags, +- struct Gpm_Type *type, int argc, char **argv) ++/* PS/2 Init */ ++static Gpm_Type *I_fuimps2(int fd, unsigned short flags, ++ struct Gpm_Type *type, int argc, char **argv) + { +- static unsigned char s1[] = { 243, 200, 243, 200, 243, 80, }; ++ int error = 0; + + if (check_no_argv(argc, argv)) return NULL; + +- write (fd, s1, sizeof (s1)); +- usleep (30000); +- tcflush (fd, TCIFLUSH); ++ // Magic to enable the IMPS/2 protocol. ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 100, 2, 2, -1); ++ error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 80, 2, 2, -1); ++ if (error) ++ gpm_report(GPM_PR_ERR, "fuimps2: %d errors in init, ignoring.", error); ++ + return type; + } + +@@ -2409,9 +2484,12 @@ + "", M_evdev, I_empty, STD_FLG, + {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL}, + #endif /* HAVE_LINUX_INPUT_H */ +- {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons, wheel unused", +- "ExplorerPS/2", M_imps2, I_exps2, STD_FLG, +- {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, ++ {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons (wheel is repeated).", ++ "ExplorerPS/2", M_imps2, I_ps2, STD_FLG, ++ {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, ++ {"autops2","For PS/2 type mouse, specific protocol will be auto detected", ++ "", M_ps2, I_ps2, STD_FLG, ++ {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, 0}, + #ifdef HAVE_LINUX_JOYSTICK_H + {"js", "For joystick mouse emulation", + "Joystick", M_js, NULL, 0, +@@ -2423,10 +2501,14 @@ + {"gunze", "Gunze touch-screens (only button-1 events, by now)", + "", M_gunze, I_gunze, STD_FLG, + {0xF9, 0x50, 0xF0, 0x30}, 11, 1, 0, 1, NULL}, +- {"imps2","For the Microsoft IntelliMouse on a PS/2 port (round\n" +- " connector with 6 pins), 3 buttons (wheel is repeated).", +- "", M_imps2, I_imps2, STD_FLG, ++ {"imps2","For the Microsoft IntelliMouse on a PS/2 port\n" ++ "(round connector with 6 pins), 3 buttons (wheel is repeated).", ++ "", M_imps2, I_ps2, STD_FLG, + {0xC0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, R_imps2}, ++ {"fuimps2","For BROKEN wheel mice on a PS/2 port\n" ++ "(round connector with 6 pins), 3 buttons (wheel is repeated).", ++ "", M_imps2, I_fuimps2, STD_FLG, ++ {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, + {"logi", "For old serial Logitech mice.", + "Logitech", M_logi, I_logi, CS8 | CSTOPB | STD_FLG, + {0xe0, 0x80, 0x80, 0x00}, 3, 3, 0, 0, 0}, +@@ -2463,10 +2545,12 @@ + " Try it if '-t ms' does not work.", + "", M_bare, I_pnp, CS7 | STD_FLG, + {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, +- {"ps2", "For most busmice connected to a PS/2 port (round with 6 metal\n" +- " pins).", ++ {"ps2", "For PS/2 mice (round with 6 metal pins).\n", + "PS/2", M_ps2, I_ps2, STD_FLG, + {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, R_ps2}, ++ {"fups2", "For /BROKEN/ PS/2 mice (round with 6 metal pins).\n", ++ "PS/2", M_ps2, I_empty, STD_FLG, ++ {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, 0}, + {"sun", "For Sun (Sparc) mice.", + "", M_sun, I_serial, CS8 | CSTOPB | STD_FLG, + {0xf8, 0x80, 0x00, 0x00}, 3, 1, 0, 0, R_sun}, +--- a/src/daemon/processmouse.c ++++ b/src/daemon/processmouse.c +@@ -46,6 +46,7 @@ + static int fine_dx, + fine_dy, + i, j, m, ++ obuttons, + newB=0, /* old buttons and Type to chain events */ + oldB=0, + oldT=0; +@@ -91,8 +92,18 @@ + event->modifiers = nEvent.modifiers; /* propagate modifiers */ + + /* propagate buttons */ ++ /* Change the button order */ ++ obuttons = nEvent.buttons; ++ nEvent.buttons = 0; ++ for (j = 0; j < 8; j++) { ++ if (obuttons & (1 << j)) { ++ nEvent.buttons |= which_mouse->opt_buts[j]; ++ } ++ } ++#if 0 + nEvent.buttons = ((which_mouse->opt_sequence)[nEvent.buttons&7]&7) | + (nEvent.buttons & ~7); /* change the order */ ++#endif + oldB=newB; newB=nEvent.buttons; + if (!i) event->buttons=nEvent.buttons; + +--- a/src/headers/daemon.h ++++ b/src/headers/daemon.h +@@ -97,6 +97,7 @@ + char *opt_options; /* extra textual configuration */ + Gpm_Type *m_type; + int fd; ++ int opt_buts[9]; + }; + + /************************************************************************* diff --git a/patches/gpm/014_has_mouse_control.patch b/patches/gpm/014_has_mouse_control.patch new file mode 100644 index 0000000..a29ac54 --- /dev/null +++ b/patches/gpm/014_has_mouse_control.patch @@ -0,0 +1,39 @@ +Description: source code of gpm_has_mouse_control helper + +Index: b/contrib/control/gpm_has_mouse_control.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ b/contrib/control/gpm_has_mouse_control.c 2007-12-10 08:25:45.000000000 +0200 +@@ -0,0 +1,20 @@ ++#include ++#include ++#include ++#include ++#include ++ ++int main (int argc, char **argv) ++{ ++ int fd; ++ int mode; ++ fd = open ("/dev/tty0", O_RDONLY); ++ if (fd == -1) ++ fd = open ("/dev/vc/0", O_RDONLY); ++ if (fd == -1) ++ perror ("open"); ++ if (ioctl (fd, KDGETMODE, &mode) != 0) ++ perror ("ioctl"); ++ exit(mode); ++} ++ +Index: b/contrib/control/Makefile +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ b/contrib/control/Makefile 2007-12-10 08:25:45.000000000 +0200 +@@ -0,0 +1,7 @@ ++CC := gcc ++ ++all: gpm_has_mouse_control.c ++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpm_has_mouse_control -Wall gpm_has_mouse_control.c ++ ++clean: ++ -rm -f gpm_has_mouse_control diff --git a/patches/gpm/031_max_consoles.patch b/patches/gpm/031_max_consoles.patch new file mode 100644 index 0000000..26d7124 --- /dev/null +++ b/patches/gpm/031_max_consoles.patch @@ -0,0 +1,107 @@ +Description: Use MAX_NR_CONSOLES instead of MAX_VC + +--- a/src/daemon/gpm.c ++++ b/src/daemon/gpm.c +@@ -93,7 +93,7 @@ + int fifofd=-1; + + int eventFlag=0; +-Gpm_Cinfo *cinfo[MAX_VC+1]; ++Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1]; + + time_t last_selection_time; + time_t opt_age_limit = 0; +--- a/src/daemon/old_main.c ++++ b/src/daemon/old_main.c +@@ -141,7 +141,7 @@ + signal(SIGWINCH,gpm_killed); /* reinstall handler */ + + /* and notify clients */ +- for(i=0; inext) kill(ci->data.pid,SIGWINCH); + } +@@ -214,7 +214,7 @@ + /*........................ got request */ + + /* itz 10-22-96 check _all_ clients, not just those on top! */ +- for (i=0; pending && (i<=MAX_VC); i++) { ++ for (i=0; pending && (i<=MAX_NR_CONSOLES); i++) { + Gpm_Cinfo* ci; + for (ci = cinfo[i]; pending && ci; ci = ci->next) { + if (FD_ISSET(ci->fd,&selSet)) { +--- a/src/daemon/processconn.c ++++ b/src/daemon/processconn.c +@@ -67,8 +67,8 @@ + return -1; + } + +- if((vc = request->vc) > MAX_VC) { +- gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_VC); ++ if((vc = request->vc) > MAX_NR_CONSOLES) { ++ gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_NR_CONSOLES); + free(info); + close(newfd); + return -1; +--- a/src/daemon/processrequest.c ++++ b/src/daemon/processrequest.c +@@ -41,7 +41,7 @@ + + gpm_report(GPM_PR_INFO, GPM_MESS_CON_REQUEST, ci->fd, vc); + +- if (vc>MAX_VC) return -1; ++ if (vc>MAX_NR_CONSOLES) return -1; + + /* itz 10-22-96 this shouldn't happen now */ + if (vc==-1) gpm_report(GPM_PR_OOPS, GPM_MESS_UNKNOWN_FD); +--- a/src/headers/daemon.h ++++ b/src/headers/daemon.h +@@ -26,6 +26,7 @@ + */ + #include "gpm.h" /* Gpm_Event */ + #include /* fd_set */ ++#include /* for cinfo -- to be moved to os/linux in 2.x! */ + + /************************************************************************* + * Types / structures +@@ -104,13 +105,6 @@ + * Macros + */ + +-/* How many virtual consoles are managed? */ +-#ifndef MAX_NR_CONSOLES +-# define MAX_NR_CONSOLES 64 /* this is always sure */ +-#endif +- +-#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */ +- + /* for adding a mouse; add_mouse */ + #define GPM_ADD_DEVICE 0 + #define GPM_ADD_TYPE 1 +@@ -174,7 +168,7 @@ + extern int eventFlag; + extern struct winsize win; + +-extern Gpm_Cinfo *cinfo[MAX_VC+1]; ++extern Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1]; + + extern struct mouse_features mouse_table[3], + *which_mouse; /*the current one*/ +--- a/src/headers/gpmCfg.h ++++ b/src/headers/gpmCfg.h +@@ -32,14 +32,6 @@ + #include + #endif + +-/* FIXME: still needed ?? */ +-/* How many virtual consoles are managed? */ +-#ifndef MAX_NR_CONSOLES +-# define MAX_NR_CONSOLES 64 /* this is always sure */ +-#endif +- +-#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */ +- + /* How many buttons may the mouse have? */ + /* #define MAX_BUTTONS 3 ===> not used, it is hardwired :-( */ + diff --git a/patches/gpm/080_cross-compile.patch b/patches/gpm/080_cross-compile.patch new file mode 100644 index 0000000..15c3589 --- /dev/null +++ b/patches/gpm/080_cross-compile.patch @@ -0,0 +1,13 @@ +Description: Add AC_CANONICAL_HOST + +--- a/configure.ac.footer ++++ b/configure.ac.footer +@@ -35,6 +35,8 @@ + # Find programs + # + ++AC_CANONICAL_HOST ++ + AC_PROG_CC + AC_PROG_LIBTOOL + AC_PROG_INSTALL diff --git a/patches/gpm/092_fix-format-not-a-string-literal-and-no-format-arguments.patch b/patches/gpm/092_fix-format-not-a-string-literal-and-no-format-arguments.patch new file mode 100644 index 0000000..87e5958 --- /dev/null +++ b/patches/gpm/092_fix-format-not-a-string-literal-and-no-format-arguments.patch @@ -0,0 +1,16 @@ +Description: Fix FTBFS with -Wformat-security +Author: Axel Beckert +Bug-Debian: https://bugs.debian.org/888792 +Bug-Debian: https://bugs.debian.org/888797 + +--- a/src/lib/report-lib.c ++++ b/src/lib/report-lib.c +@@ -47,7 +47,7 @@ + log_level = LOG_CRIT; break; + } + #ifdef HAVE_VSYSLOG +- syslog(log_level, string); ++ syslog(log_level, "%s", string); + vsyslog(log_level, text, ap); + #else + fprintf(stderr,"%s[%s(%d)]:\n",string,file,line); diff --git a/patches/gpm/093_fix-typos.patch b/patches/gpm/093_fix-typos.patch new file mode 100644 index 0000000..3e940b4 --- /dev/null +++ b/patches/gpm/093_fix-typos.patch @@ -0,0 +1,133 @@ +Description: Fix spelling errors found by lintian +Author: Axel Beckert + +--- a/doc/FAQ ++++ b/doc/FAQ +@@ -132,7 +132,7 @@ + to keep hold of processor time for at least 1 second). + - no pnp vendor will be able to support three buttons any more (no + more mouse protocols, all mice must behave the same). +- - similary, only 1200 baud devices (any serial device) are supported, ++ - similarly, only 1200 baud devices (any serial device) are supported, + because the initialization string of pnp devices only tells + the vendor and release, with no information about required + port configuration. +--- a/doc/doc.gpm.in ++++ b/doc/doc.gpm.in +@@ -394,7 +394,7 @@ + automatically forces the @emph{repeater} (@samp{\-R}) option on. + + @item \-o @var{list-of-extra-options} +- The option works similary to the ``\-o'' option of mount; it is ++ The option works similarly to the ``\-o'' option of mount; it is + used to specify a list of ``extra options'' that are specific + to each mouse type. The list is comma-separated. The options + @samp{dtr}, @samp{rts} or @samp{both} are used by the serial +--- a/src/daemon/old_main.c ++++ b/src/daemon/old_main.c +@@ -190,7 +190,7 @@ + /*....................................... got mouse, process event */ + /* + * Well, actually, run a loop to maintain inlining of functions without +- * lenghtening the file. This is not too clean a code, but it works.... ++ * lengthening the file. This is not too clean a code, but it works.... + */ + + for (i=1; i <= 1+opt_double; i++) { +--- a/src/mice.c ++++ b/src/mice.c +@@ -122,7 +122,7 @@ + break; + } + if (p->type == ARGV_END) { /* not found */ +- fprintf(stderr, "%s: Uknown option \"%s\" for pointer \"%s\"\n", ++ fprintf(stderr, "%s: Unknown option \"%s\" for pointer \"%s\"\n", + option.progname, argv[i], argv[0]); + errors++; + continue; +--- a/src/prog/mouse-test.c ++++ b/src/prog/mouse-test.c +@@ -524,7 +524,7 @@ + Gpm_Event event; + + if (packetsize!=cur->this->packetlen) { +- REMOVETYPE(cur,"different packet lenght"); ++ REMOVETYPE(cur,"different packet length"); + continue; + } + +--- a/src/synaptics.c ++++ b/src/synaptics.c +@@ -2471,7 +2471,7 @@ + #define PS2_SCALE_11 0xE6 /* Set scale to 1:1 */ + + +-/* Normal ps2 responce */ ++/* Normal ps2 response */ + #define PS2_ERROR 0xFC /* Error, after a reset,resend or disconnect*/ + #define PS2_ACK 0xFA /* Command acknowledge */ + #define PS2_READY 0xAA /* Send after a calibration or ERROR */ +@@ -2538,7 +2538,7 @@ + } + + # ifdef DEBUG_PUTBYTE_ACK +- gpm_report(GPM_PR_DEBUG,"Responce %X to byte %X",ack,b); ++ gpm_report(GPM_PR_DEBUG,"Response %X to byte %X",ack,b); + # endif + + return ack; +@@ -2565,11 +2565,11 @@ + + /* Do some sanity checking */ + if((response[0] & 0xFC) != 0x84) { +- gpm_report (GPM_PR_ERR,"Byte 0 of stick device responce is not valid"); ++ gpm_report (GPM_PR_ERR,"Byte 0 of stick device response is not valid"); + return -1; + } + if((response[3] & 0xCC) != 0xC4) { +- gpm_report (GPM_PR_ERR,"Byte 3 of stick device responce is not valid"); ++ gpm_report (GPM_PR_ERR,"Byte 3 of stick device response is not valid"); + return -1; + } + } +@@ -2844,7 +2844,7 @@ + byte status,id_code = PS2_MOUSE_IDCODE; + byte reset_cmd = PS2_RESET; + +- gpm_report(GPM_PR_DEBUG,"Reseting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad")); ++ gpm_report(GPM_PR_DEBUG,"Resetting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad")); + + /* Send reset command without eating the ack. */ + if(!stick) { +@@ -2871,11 +2871,11 @@ + usleep(750000); + + if ( (status = syn_ps2_getbyte(fd,stick)) != PS2_READY ){ +- gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: No READY, got %02X.\n" ++ gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: No READY, got %02X.\n" + "Check pc_keyb.c for reconnect smartness.\n",status); + } + if ( (id_code = syn_ps2_getbyte(fd,stick)) != PS2_MOUSE_IDCODE){ +- gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: Wrong ID, got %02X.\n",id_code); ++ gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: Wrong ID, got %02X.\n",id_code); + } + + } +@@ -3155,7 +3155,7 @@ + + void syn_serial_reset(int fd) + { +- gpm_report (GPM_PR_INFO,"Reseting Synaptic Serial Touchpad."); ++ gpm_report (GPM_PR_INFO,"Resetting Synaptic Serial Touchpad."); + + syn_serial_set_mode (fd, (RELATIVE_MODE | + HIGH_REPORT_RATE | +@@ -3247,7 +3247,7 @@ + + void syn_ps2_reset (int fd) + { +- gpm_report (GPM_PR_INFO,"Reseting Synaptic PS/2 Touchpad."); ++ gpm_report (GPM_PR_INFO,"Resetting Synaptic PS/2 Touchpad."); + + /* Stop incoming motion data (of whatever kind absolute/relative). */ + tp_ps2_disable_data(fd); diff --git a/patches/gpm/094_gpm-1.20.7-glibc-2.26-1.patch b/patches/gpm/094_gpm-1.20.7-glibc-2.26-1.patch new file mode 100644 index 0000000..1a6868e --- /dev/null +++ b/patches/gpm/094_gpm-1.20.7-glibc-2.26-1.patch @@ -0,0 +1,63 @@ +Origin: http://download.nutyx.org/x86_64/rolling/cli/gpm/gpm-1.20.7-consolidated-1.patch +Bug: https://github.com/telmich/gpm/issues/21 +Bug-Debian: https://bugs.debian.org/886903 +Bug-LFS: https://wiki.linuxfromscratch.org/blfs/ticket/9616#ticket +Author: tnut from nutyx.org, https://github.com/tnut +Description: Fix FTBFS with glibc 2.26 + +--- a/src/daemon/open_console.c ++++ b/src/daemon/open_console.c +@@ -24,6 +24,10 @@ + #include /* ioctl */ + #include /* major() */ + ++#ifdef HAVE_SYS_SYSMACROS_H ++#include /* major() w/newer glibc */ ++#endif ++ + /* Linux specific (to be outsourced in gpm2 */ + #include /* for serial console check */ + #include /* for serial console check */ +--- a/src/prog/gpm-root.y ++++ b/src/prog/gpm-root.y +@@ -443,6 +443,7 @@ + } + + /*---------------------------------------------------------------------*/ ++#if 0 + static int f_debug_one(FILE *f, Draw *draw) + { + DrawItem *ip; +@@ -465,6 +466,7 @@ + #undef LINE + return 0; + } ++#endif + + int f_debug(int mode, DrawItem *self, int uid) + { +@@ -960,10 +962,8 @@ + /*------------*/ + static inline void scr_restore(int fd, FILE *f, unsigned char *buffer, int vc) + { +- int x,y, dumpfd; ++ int dumpfd; + char dumpname[20]; +- +- x=buffer[2]; y=buffer[3]; + + /* WILL NOT WORK WITH DEVFS! FIXME! */ + sprintf(dumpname,"/dev/vcsa%i",vc); +@@ -1196,11 +1196,7 @@ + LOG_DAEMON : LOG_USER); + /* reap your zombies */ + childaction.sa_handler=reap_children; +-#if defined(__GLIBC__) +- __sigemptyset(&childaction.sa_mask); +-#else /* __GLIBC__ */ +- childaction.sa_mask=0; +-#endif /* __GLIBC__ */ ++ sigemptyset(&childaction.sa_mask); + childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */ + sigaction(SIGCHLD,&childaction,NULL); + diff --git a/patches/gpm/095_fix-compilation-with-gcc-10.patch b/patches/gpm/095_fix-compilation-with-gcc-10.patch new file mode 100644 index 0000000..c8be146 --- /dev/null +++ b/patches/gpm/095_fix-compilation-with-gcc-10.patch @@ -0,0 +1,20 @@ +Description: FTBFS with gcc-10 due to -fno-commons +Author: Sergei Trofimovich +Reviewed-By: Helmut Grohne +Origin: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f7e2ac82fc5a1847c132057fb7de1a996d66c76 +Forwarded: https://github.com/telmich/gpm/pull/37 +Bug: https://github.com/telmich/gpm/pull/37 +Bug-Gentoo: https://bugs.gentoo.org/705878 +Bug-Debian: https://bugs.debian.org/953266 + +--- a/src/headers/daemon.h ++++ b/src/headers/daemon.h +@@ -176,7 +176,7 @@ + extern Gpm_Type mice[]; + extern Gpm_Type *repeated_type; + +-time_t last_selection_time; ++extern time_t last_selection_time; + + + diff --git a/patches/gpm/096_fix-compilation-against-musl-libc.patch b/patches/gpm/096_fix-compilation-against-musl-libc.patch new file mode 100644 index 0000000..cfb8b1c --- /dev/null +++ b/patches/gpm/096_fix-compilation-against-musl-libc.patch @@ -0,0 +1,69 @@ +Description: Add musl support + * Use SA_NODEFER instead of its non-standard alias SA_NOMASK. + * Add missing sys/select.h and fcntl.h includes. + * Use standard sigemptyset unconditionally. + * Define SA_INTERRUPT if it's not defined (historical no-op). + * With these changes gpm builds against musl libc. +Author: Szabolcs Nagy +Bug-Debian: https://bugs.debian.org/813751 + +--- a/src/lib/liblow.c ++++ b/src/lib/liblow.c +@@ -179,7 +179,7 @@ + /* Reincarnation. Prepare for another death early. */ + sigemptyset(&sa.sa_mask); + sa.sa_handler = gpm_suspend_hook; +- sa.sa_flags = SA_NOMASK; ++ sa.sa_flags = SA_NODEFER; + sigaction (SIGTSTP, &sa, 0); + + /* Pop the gpm stack by closing the useless connection */ +@@ -386,7 +386,7 @@ + + /* if signal was originally ignored, job control is not supported */ + if (gpm_saved_suspend_hook.sa_handler != SIG_IGN) { +- sa.sa_flags = SA_NOMASK; ++ sa.sa_flags = SA_NODEFER; + sa.sa_handler = gpm_suspend_hook; + sigaction(SIGTSTP, &sa, 0); + } +--- a/src/prog/display-buttons.c ++++ b/src/prog/display-buttons.c +@@ -36,6 +36,7 @@ + #include /* printf() */ + #include /* time() */ + #include /* errno */ ++#include /* fd_set, FD_ZERO */ + #include /* gpm information */ + + /* display resulting data */ +--- a/src/prog/display-coords.c ++++ b/src/prog/display-coords.c +@@ -37,6 +37,7 @@ + #include /* printf() */ + #include /* time() */ + #include /* errno */ ++#include /* fd_set, FD_ZERO */ + #include /* gpm information */ + + /* display resulting data */ +--- a/src/prog/gpm-root.y ++++ b/src/prog/gpm-root.y +@@ -1197,6 +1197,9 @@ + /* reap your zombies */ + childaction.sa_handler=reap_children; + sigemptyset(&childaction.sa_mask); ++#ifndef SA_INTERRUPT ++#define SA_INTERRUPT 0 ++#endif + childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */ + sigaction(SIGCHLD,&childaction,NULL); + +--- a/contrib/control/gpm_has_mouse_control.c ++++ b/contrib/control/gpm_has_mouse_control.c +@@ -1,4 +1,4 @@ +-#include ++#include + #include + #include + #include diff --git a/patches/0001-Allow-empty-x509-cert-issuer.patch b/patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch similarity index 100% rename from patches/0001-Allow-empty-x509-cert-issuer.patch rename to patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch