| @@ -1,18 +1,26 @@ | | | @@ -1,18 +1,26 @@ |
1 | $NetBSD: patch-src_video_wscons_SDL__wsconsevents.c,v 1.9 2015/01/29 12:31:08 jmcneill Exp $ | | 1 | $NetBSD: patch-src_video_wscons_SDL__wsconsevents.c,v 1.10 2015/01/30 12:02:49 wiz Exp $ |
2 | | | 2 | |
3 | --- src/video/wscons/SDL_wsconsevents.c.orig 2012-01-19 06:30:06.000000000 +0000 | | 3 | --- src/video/wscons/SDL_wsconsevents.c.orig 2012-01-19 06:30:06.000000000 +0000 |
4 | +++ src/video/wscons/SDL_wsconsevents.c | | 4 | +++ src/video/wscons/SDL_wsconsevents.c |
5 | @@ -47,14 +47,31 @@ int WSCONS_InitKeyboard(_THIS) | | 5 | @@ -25,6 +25,7 @@ |
| | | 6 | #include <dev/wscons/wsdisplay_usl_io.h> |
| | | 7 | #include <sys/ioctl.h> |
| | | 8 | #include <fcntl.h> |
| | | 9 | +#include <limits.h> |
| | | 10 | #include <unistd.h> |
| | | 11 | #include <termios.h> |
| | | 12 | #include <errno.h> |
| | | 13 | @@ -47,14 +48,31 @@ int WSCONS_InitKeyboard(_THIS) |
6 | return -1; | | 14 | return -1; |
7 | } | | 15 | } |
8 | | | 16 | |
9 | +#if defined(__NetBSD__) | | 17 | +#if defined(__NetBSD__) |
10 | + if (private->kbdType == 0) { | | 18 | + if (private->kbdType == 0) { |
11 | + /* wsmux with no keyboard attached, assumed USB */ | | 19 | + /* wsmux with no keyboard attached, assumed USB */ |
12 | + private->kbdType = WSKBD_TYPE_USB; | | 20 | + private->kbdType = WSKBD_TYPE_USB; |
13 | + } | | 21 | + } |
14 | +#endif | | 22 | +#endif |
15 | + | | 23 | + |
16 | if (tcgetattr(private->fd, &private->saved_tty) == -1) { | | 24 | if (tcgetattr(private->fd, &private->saved_tty) == -1) { |
17 | WSCONS_ReportError("cannot get terminal attributes: %s", strerror(errno)); | | 25 | WSCONS_ReportError("cannot get terminal attributes: %s", strerror(errno)); |
18 | return -1; | | 26 | return -1; |
| @@ -25,53 +33,53 @@ $NetBSD: patch-src_video_wscons_SDL__wsc | | | @@ -25,53 +33,53 @@ $NetBSD: patch-src_video_wscons_SDL__wsc |
25 | + | | 33 | + |
26 | + if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) { | | 34 | + if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) { |
27 | + WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno)); | | 35 | + WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno)); |
28 | + return -1; | | 36 | + return -1; |
29 | + } | | 37 | + } |
30 | + | | 38 | + |
31 | tty = private->saved_tty; | | 39 | tty = private->saved_tty; |
32 | tty.c_iflag = IGNPAR | IGNBRK; | | 40 | tty.c_iflag = IGNPAR | IGNBRK; |
33 | - tty.c_oflag = 0; | | 41 | - tty.c_oflag = 0; |
34 | + //tty.c_oflag = 0; | | 42 | + //tty.c_oflag = 0; |
35 | tty.c_cflag = CREAD | CS8; | | 43 | tty.c_cflag = CREAD | CS8; |
36 | tty.c_lflag = 0; | | 44 | tty.c_lflag = 0; |
37 | tty.c_cc[VTIME] = 0; | | 45 | tty.c_cc[VTIME] = 0; |
38 | @@ -65,8 +82,12 @@ int WSCONS_InitKeyboard(_THIS) | | 46 | @@ -65,8 +83,12 @@ int WSCONS_InitKeyboard(_THIS) |
39 | WSCONS_ReportError("cannot set terminal attributes: %s", strerror(errno)); | | 47 | WSCONS_ReportError("cannot set terminal attributes: %s", strerror(errno)); |
40 | return -1; | | 48 | return -1; |
41 | } | | 49 | } |
42 | - if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) { | | 50 | - if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) { |
43 | - WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno)); | | 51 | - WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno)); |
44 | + | | 52 | + |
45 | + struct wskbd_keyrepeat_data repeat; | | 53 | + struct wskbd_keyrepeat_data repeat; |
46 | + repeat.which = WSKBD_KEYREPEAT_DOALL; | | 54 | + repeat.which = WSKBD_KEYREPEAT_DOALL; |
47 | + repeat.del1 = repeat.delN = UINT_MAX; | | 55 | + repeat.del1 = repeat.delN = UINT_MAX; |
48 | + if (ioctl(private->fd, WSKBDIO_SETKEYREPEAT, &repeat) == -1) { | | 56 | + if (ioctl(private->fd, WSKBDIO_SETKEYREPEAT, &repeat) == -1) { |
49 | + WSCONS_ReportError("cannot set repeat settings: %s", strerror(errno)); | | 57 | + WSCONS_ReportError("cannot set repeat settings: %s", strerror(errno)); |
50 | return -1; | | 58 | return -1; |
51 | } | | 59 | } |
52 | | | 60 | |
53 | @@ -81,6 +102,10 @@ void WSCONS_ReleaseKeyboard(_THIS) | | 61 | @@ -81,6 +103,10 @@ void WSCONS_ReleaseKeyboard(_THIS) |
54 | strerror(errno)); | | 62 | strerror(errno)); |
55 | } | | 63 | } |
56 | if (private->did_save_tty) { | | 64 | if (private->did_save_tty) { |
57 | + if (ioctl(private->fd, WSKBDIO_SETKEYREPEAT, &private->saved_repeat) == -1) { | | 65 | + if (ioctl(private->fd, WSKBDIO_SETKEYREPEAT, &private->saved_repeat) == -1) { |
58 | + WSCONS_ReportError("cannot restore repeat settings: %s", | | 66 | + WSCONS_ReportError("cannot restore repeat settings: %s", |
59 | + strerror(errno)); | | 67 | + strerror(errno)); |
60 | + } | | 68 | + } |
61 | if (tcsetattr(private->fd, TCSANOW, &private->saved_tty) < 0) { | | 69 | if (tcsetattr(private->fd, TCSANOW, &private->saved_tty) < 0) { |
62 | WSCONS_ReportError("cannot restore keynoard attributes: %s", | | 70 | WSCONS_ReportError("cannot restore keynoard attributes: %s", |
63 | strerror(errno)); | | 71 | strerror(errno)); |
64 | @@ -89,8 +114,65 @@ void WSCONS_ReleaseKeyboard(_THIS) | | 72 | @@ -89,8 +115,65 @@ void WSCONS_ReleaseKeyboard(_THIS) |
65 | } | | 73 | } |
66 | } | | 74 | } |
67 | | | 75 | |
68 | -static void updateMouse() | | 76 | -static void updateMouse() |
69 | +int WSCONS_InitMouse(_THIS) | | 77 | +int WSCONS_InitMouse(_THIS) |
70 | { | | 78 | { |
71 | + if (private->mouseFd != -1) { | | 79 | + if (private->mouseFd != -1) { |
72 | +#if defined(WSMOUSEIO_SETVERSION) | | 80 | +#if defined(WSMOUSEIO_SETVERSION) |
73 | + int version = WSMOUSE_EVENT_VERSION; | | 81 | + int version = WSMOUSE_EVENT_VERSION; |
74 | + if (ioctl(private->mouseFd, WSMOUSEIO_SETVERSION, &version) == -1) { | | 82 | + if (ioctl(private->mouseFd, WSMOUSEIO_SETVERSION, &version) == -1) { |
75 | + WSCONS_ReportError("cannot set mouse API version: %s", strerror(errno)); | | 83 | + WSCONS_ReportError("cannot set mouse API version: %s", strerror(errno)); |
76 | + return -1; | | 84 | + return -1; |
77 | + } | | 85 | + } |
| @@ -118,39 +126,39 @@ $NetBSD: patch-src_video_wscons_SDL__wsc | | | @@ -118,39 +126,39 @@ $NetBSD: patch-src_video_wscons_SDL__wsc |
118 | + case WSCONS_EVENT_MOUSE_DELTA_Z: | | 126 | + case WSCONS_EVENT_MOUSE_DELTA_Z: |
119 | + posted += SDL_PrivateMouseButton(SDL_PRESSED, | | 127 | + posted += SDL_PrivateMouseButton(SDL_PRESSED, |
120 | + ev->value > 0 ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN, | | 128 | + ev->value > 0 ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN, |
121 | + 0, 0); | | 129 | + 0, 0); |
122 | + posted += SDL_PrivateMouseButton(SDL_RELEASED, | | 130 | + posted += SDL_PrivateMouseButton(SDL_RELEASED, |
123 | + ev->value > 0 ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN, | | 131 | + ev->value > 0 ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN, |
124 | + 0, 0); | | 132 | + 0, 0); |
125 | + break; | | 133 | + break; |
126 | + } | | 134 | + } |
127 | + } | | 135 | + } |
128 | } | | 136 | } |
129 | | | 137 | |
130 | static SDLKey keymap[128]; | | 138 | static SDLKey keymap[128]; |
131 | @@ -107,6 +189,11 @@ static SDL_keysym *TranslateKey(int scan | | 139 | @@ -107,6 +190,11 @@ static SDL_keysym *TranslateKey(int scan |
132 | if (keysym->sym == SDLK_UNKNOWN) | | 140 | if (keysym->sym == SDLK_UNKNOWN) |
133 | printf("Unknown mapping for scancode %d\n", scancode); | | 141 | printf("Unknown mapping for scancode %d\n", scancode); |
134 | | | 142 | |
135 | + keysym->unicode = 0; | | 143 | + keysym->unicode = 0; |
136 | + if (SDL_TranslateUNICODE) { | | 144 | + if (SDL_TranslateUNICODE) { |
137 | + keysym->unicode = keysym->sym; | | 145 | + keysym->unicode = keysym->sym; |
138 | + } | | 146 | + } |
139 | + | | 147 | + |
140 | return keysym; | | 148 | return keysym; |
141 | } | | 149 | } |
142 | | | 150 | |
143 | @@ -120,19 +207,42 @@ static void updateKeyboard(_THIS) | | 151 | @@ -120,19 +208,42 @@ static void updateKeyboard(_THIS) |
144 | for (i = 0; i < n; i++) { | | 152 | for (i = 0; i < n; i++) { |
145 | unsigned char c = buf[i] & 0x7f; | | 153 | unsigned char c = buf[i] & 0x7f; |
146 | if (c == 224) // special key prefix -- what should we do with it? | | 154 | if (c == 224) // special key prefix -- what should we do with it? |
147 | - continue; | | 155 | - continue; |
148 | + continue; | | 156 | + continue; |
149 | posted += SDL_PrivateKeyboard((buf[i] & 0x80) ? SDL_RELEASED : SDL_PRESSED, | | 157 | posted += SDL_PrivateKeyboard((buf[i] & 0x80) ? SDL_RELEASED : SDL_PRESSED, |
150 | - TranslateKey(c, &keysym)); | | 158 | - TranslateKey(c, &keysym)); |
151 | + TranslateKey(c, &keysym)); | | 159 | + TranslateKey(c, &keysym)); |
152 | } | | 160 | } |
153 | } | | 161 | } |
154 | } | | 162 | } |
155 | | | 163 | |
156 | void WSCONS_PumpEvents(_THIS) | | 164 | void WSCONS_PumpEvents(_THIS) |
| @@ -177,33 +185,33 @@ $NetBSD: patch-src_video_wscons_SDL__wsc | | | @@ -177,33 +185,33 @@ $NetBSD: patch-src_video_wscons_SDL__wsc |
177 | + FD_SET(private->mouseFd, &fds); | | 185 | + FD_SET(private->mouseFd, &fds); |
178 | + | | 186 | + |
179 | + if (select(maxfd+1, &fds, NULL, NULL, &zero) > 0) { | | 187 | + if (select(maxfd+1, &fds, NULL, NULL, &zero) > 0) { |
180 | + if (private->mouseFd != -1 && FD_ISSET(private->mouseFd, &fds)) { | | 188 | + if (private->mouseFd != -1 && FD_ISSET(private->mouseFd, &fds)) { |
181 | + updateMouse(this); | | 189 | + updateMouse(this); |
182 | + } | | 190 | + } |
183 | + if (private->fd != -1 && FD_ISSET(private->fd, &fds)) { | | 191 | + if (private->fd != -1 && FD_ISSET(private->fd, &fds)) { |
184 | + updateKeyboard(this); | | 192 | + updateKeyboard(this); |
185 | + } | | 193 | + } |
186 | + } | | 194 | + } |
187 | } while (posted); | | 195 | } while (posted); |
188 | } | | 196 | } |
189 | | | 197 | |
190 | @@ -146,8 +256,10 @@ void WSCONS_InitOSKeymap(_THIS) | | 198 | @@ -146,8 +257,10 @@ void WSCONS_InitOSKeymap(_THIS) |
191 | } | | 199 | } |
192 | | | 200 | |
193 | switch (private->kbdType) { | | 201 | switch (private->kbdType) { |
194 | -#ifdef WSKBD_TYPE_ZAURUS | | 202 | -#ifdef WSKBD_TYPE_ZAURUS |
195 | +#if defined(WSKBD_TYPE_ZAURUS) | | 203 | +#if defined(WSKBD_TYPE_ZAURUS) |
196 | case WSKBD_TYPE_ZAURUS: | | 204 | case WSKBD_TYPE_ZAURUS: |
197 | +#endif | | 205 | +#endif |
198 | + case WSKBD_TYPE_USB: | | 206 | + case WSKBD_TYPE_USB: |
199 | /* top row */ | | 207 | /* top row */ |
200 | keymap[2] = SDLK_1; | | 208 | keymap[2] = SDLK_1; |
201 | keymap[3] = SDLK_2; | | 209 | keymap[3] = SDLK_2; |
202 | @@ -220,7 +332,6 @@ void WSCONS_InitOSKeymap(_THIS) | | 210 | @@ -220,7 +333,6 @@ void WSCONS_InitOSKeymap(_THIS) |
203 | keymap[77] = SDLK_RIGHT; | | 211 | keymap[77] = SDLK_RIGHT; |
204 | keymap[80] = SDLK_DOWN; | | 212 | keymap[80] = SDLK_DOWN; |
205 | break; | | 213 | break; |
206 | -#endif /* WSKBD_TYPE_ZAURUS */ | | 214 | -#endif /* WSKBD_TYPE_ZAURUS */ |
207 | | | 215 | |
208 | default: | | 216 | default: |
209 | WSCONS_ReportError("Unable to map keys for keyboard type %u", | | 217 | WSCONS_ReportError("Unable to map keys for keyboard type %u", |