repeater-patch

来自「gpm-1.20.0.tar.gz」· 代码 · 共 38 行

TXT
38
字号
--- mice.c.orig Tue Sep 25 17:48:30 2001+++ mice.c      Tue Sep 25 17:48:32 2001@@ -203,6 +203,21 @@ int realposx=-1, realposy=-1;  /*========================================================================*/+/* + * When repeating, it is important not to try to repeat more bits of dx and+ * dy than the protocol can handle.  Otherwise, you may end up repeating the+ * low bits of a large value, which causes erratic motion.+ */++static int limit_delta(int delta, int min, int max)+{+    return+        delta > max ? max :+        delta < min ? min+                    : delta;+}++/*========================================================================*/ /*  * Ok, here we are: first, provide the functions; initialization is later.  * The return value is the number of unprocessed bytes@@ -423,10 +438,13 @@ static int R_msc(Gpm_Event *state, int fd) {   signed char buffer[5];+  int dx, dy;    /* sluggish... */   buffer[0]=(state->buttons ^ 0x07) | 0x80;+  dx = limit_delta(state->dx, -256, 254);   buffer[3] =  state->dx - (buffer[1] = state->dx/2); /* Markus */+  dy = limit_delta(state->dy, -256, 254);   buffer[4] = -state->dy - (buffer[2] = -state->dy/2);   return write(fd,buffer,5);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?