1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
--- a/client/gui-sdl/gui_main.c 2010-10-05 02:45:33.008848029 +0200
+++ b/client/gui-sdl/gui_main.c 2010-10-07 13:17:01.548258233 +0200
@@ -78,6 +78,10 @@
#include "gui_main.h"
+#ifdef KBDMOUSE
+#include KBDMOUSE
+#endif
+
#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
#define MAP_SCROLL_TIMER_INTERVAL 500
@@ -496,6 +500,108 @@
return(1);
}
+#ifdef KBDMOUSE
+
+int keyboard_mouse(SDL_Event *event)
+{
+ SDL_Event new;
+ int x, y;
+
+ switch (event->type) {
+ case SDL_KEYDOWN:
+ switch ((int)event->key.keysym.sym) {
+ case KBDMOUSE_LEFT_CLICK:
+ case KBDMOUSE_MIDDLE_CLICK:
+ case KBDMOUSE_RIGHT_CLICK:
+ SDL_GetMouseState(&x, &y);
+
+ new = (SDL_Event) {
+ .type = SDL_MOUSEBUTTONDOWN,
+ .button = {
+ .type = SDL_MOUSEBUTTONDOWN,
+ .which = 0,
+ .state = SDL_PRESSED,
+ .x = (Uint16)x,
+ .y = (Uint16)y
+ }
+ };
+ switch ((int)event->key.keysym.sym) {
+ case KBDMOUSE_LEFT_CLICK: new.button.button = SDL_BUTTON_LEFT; break;
+ case KBDMOUSE_MIDDLE_CLICK: new.button.button = SDL_BUTTON_MIDDLE; break;
+ case KBDMOUSE_RIGHT_CLICK: new.button.button = SDL_BUTTON_RIGHT; break;
+ }
+
+ SDL_PushEvent(&new);
+ return 0;
+
+ case KBDMOUSE_UP:
+ case KBDMOUSE_DOWN:
+ case KBDMOUSE_LEFT:
+ case KBDMOUSE_RIGHT:
+ SDL_GetMouseState(&x, &y);
+
+ switch ((int)event->key.keysym.sym) {
+ case KBDMOUSE_UP: y -= KBDMOUSE_STEP; break;
+ case KBDMOUSE_DOWN: y += KBDMOUSE_STEP; break;
+ case KBDMOUSE_RIGHT: x += KBDMOUSE_STEP; break;
+ case KBDMOUSE_LEFT: x -= KBDMOUSE_STEP; break;
+ }
+
+ SDL_WarpMouse((Uint16)x, (Uint16)y);
+ return 0;
+ }
+ break;
+
+ case SDL_KEYUP:
+ switch ((int)event->key.keysym.sym) {
+ case KBDMOUSE_LEFT_CLICK:
+ case KBDMOUSE_MIDDLE_CLICK:
+ case KBDMOUSE_RIGHT_CLICK:
+ SDL_GetMouseState(&x, &y);
+
+ new = (SDL_Event) {
+ .type = SDL_MOUSEBUTTONUP,
+ .button = {
+ .type = SDL_MOUSEBUTTONUP,
+ .which = 0,
+ .state = SDL_RELEASED,
+ .x = (Uint16)x,
+ .y = (Uint16)y
+ }
+ };
+ switch ((int)event->key.keysym.sym) {
+ case KBDMOUSE_LEFT_CLICK: new.button.button = SDL_BUTTON_LEFT; break;
+ case KBDMOUSE_MIDDLE_CLICK: new.button.button = SDL_BUTTON_MIDDLE; break;
+ case KBDMOUSE_RIGHT_CLICK: new.button.button = SDL_BUTTON_RIGHT; break;
+ }
+
+ SDL_PushEvent(&new);
+ return 0;
+
+ case KBDMOUSE_UP:
+ case KBDMOUSE_DOWN:
+ case KBDMOUSE_LEFT:
+ case KBDMOUSE_RIGHT:
+ return 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return -1;
+}
+
+#else
+
+int keyboard_mouse(SDL_Event *event __attribute__((unused)))
+{
+ return -1;
+}
+
+#endif
+
/**************************************************************************
...
**************************************************************************/
@@ -596,6 +702,9 @@
while (SDL_PollEvent(&Main.event) == 1) {
+ if (!keyboard_mouse(&Main.event))
+ continue;
+
switch (Main.event.type) {
case SDL_QUIT:
@@ -763,6 +872,10 @@
putenv((char *)"SDL_VIDEO_CENTERED=yes");
init_sdl(iSDL_Flags);
+
+#ifdef KBDMOUSE
+ SDL_EnableKeyRepeat(KBDMOUSE_REPEAT_DELAY, KBDMOUSE_REPEAT_INTERVAL);
+#endif
freelog(LOG_NORMAL, _("Using Video Output: %s"),
SDL_VideoDriverName(device, sizeof(device)));
--- a/client/gui-sdl/widget_edit.c 2010-10-05 04:29:20.907598799 +0200
+++ b/client/gui-sdl/widget_edit.c 2010-10-05 04:41:51.888846695 +0200
@@ -30,6 +30,10 @@
#include "widget.h"
#include "widget_p.h"
+#ifdef KBDMOUSE
+#include KBDMOUSE
+#endif
+
struct UniChar {
struct UniChar *next;
struct UniChar *prev;
@@ -730,9 +734,13 @@
del_chain(pEdt.pBeginTextChain);
FREESURFACE(pEdt.pBg);
-
+
+#ifdef KBDMOUSE
+ SDL_EnableKeyRepeat(KBDMOUSE_REPEAT_DELAY, KBDMOUSE_REPEAT_INTERVAL);
+#else
/* disable repeate key */
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
+#endif
/* disable Unicode */
SDL_EnableUNICODE(0);
|