Thu Jan 29 11:28:50 2015 UTC ()
fix wscons keyboard


(jmcneill)
diff -r1.68 -r1.69 pkgsrc/devel/SDL/distinfo
diff -r1.6 -r1.7 pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsevents.c
diff -r1.1 -r1.2 pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsvideo.h

cvs diff -r1.68 -r1.69 pkgsrc/devel/SDL/distinfo (expand / switch to unified diff)

--- pkgsrc/devel/SDL/distinfo 2015/01/29 01:56:02 1.68
+++ pkgsrc/devel/SDL/distinfo 2015/01/29 11:28:50 1.69
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1$NetBSD: distinfo,v 1.68 2015/01/29 01:56:02 jmcneill Exp $ 1$NetBSD: distinfo,v 1.69 2015/01/29 11:28:50 jmcneill Exp $
2 2
3SHA1 (SDL-1.2.15.tar.gz) = 0c5f193ced810b0d7ce3ab06d808cbb5eef03a2c 3SHA1 (SDL-1.2.15.tar.gz) = 0c5f193ced810b0d7ce3ab06d808cbb5eef03a2c
4RMD160 (SDL-1.2.15.tar.gz) = d4802a090cb4a24eeb0c8ce5690802f596d394c3 4RMD160 (SDL-1.2.15.tar.gz) = d4802a090cb4a24eeb0c8ce5690802f596d394c3
5Size (SDL-1.2.15.tar.gz) = 3920622 bytes 5Size (SDL-1.2.15.tar.gz) = 3920622 bytes
6SHA1 (patch-aa) = 00fb7a85caf8fc9f08298d0a07a4587757fdffb0 6SHA1 (patch-aa) = 00fb7a85caf8fc9f08298d0a07a4587757fdffb0
7SHA1 (patch-ac) = 8b2dddff9ad449b19b35ef364e2d960e46284563 7SHA1 (patch-ac) = 8b2dddff9ad449b19b35ef364e2d960e46284563
8SHA1 (patch-src_audio_sun_SDL__sunaudio.c) = 4b492b40d39e6444037dfda55766e4a149cc6c30 8SHA1 (patch-src_audio_sun_SDL__sunaudio.c) = 4b492b40d39e6444037dfda55766e4a149cc6c30
9SHA1 (patch-src_joystick_bsd_SDL__sysjoystick.c) = 4ea0136f231729129b82e5f7ee4b9eaf68a13876 9SHA1 (patch-src_joystick_bsd_SDL__sysjoystick.c) = 4ea0136f231729129b82e5f7ee4b9eaf68a13876
10SHA1 (patch-src_video_quartz_SDL__QuartzVideo.h) = 19d952bade06dbd646e94f42139c38436969b1a8 10SHA1 (patch-src_video_quartz_SDL__QuartzVideo.h) = 19d952bade06dbd646e94f42139c38436969b1a8
11SHA1 (patch-src_video_wscons_SDL__wsconsevents.c) = f7519864e9c13ad69eae9a42df22a944586ab93b 11SHA1 (patch-src_video_wscons_SDL__wsconsevents.c) = 1205a549f4ba1f1bc7185081407f79545421e75e
12SHA1 (patch-src_video_wscons_SDL__wsconsevents__c.h) = 97206e2aca0b620005217d9d07ad1177516cac92 12SHA1 (patch-src_video_wscons_SDL__wsconsevents__c.h) = 97206e2aca0b620005217d9d07ad1177516cac92
13SHA1 (patch-src_video_wscons_SDL__wsconsvideo.c) = 17e048ccb201ae961e820ab880d5a588b2db2639 13SHA1 (patch-src_video_wscons_SDL__wsconsvideo.c) = 17e048ccb201ae961e820ab880d5a588b2db2639
14SHA1 (patch-src_video_wscons_SDL__wsconsvideo.h) = 82028df57cf3de95152278924ffe3134fe32f85a 14SHA1 (patch-src_video_wscons_SDL__wsconsvideo.h) = efc75da910cfe370b7361a0b9d2b90837c6b9aa9
15SHA1 (patch-src_video_x11_SDL_x11video.c) = 624fbb7e701d6de6ec93096beea7c085125934aa 15SHA1 (patch-src_video_x11_SDL_x11video.c) = 624fbb7e701d6de6ec93096beea7c085125934aa

cvs diff -r1.6 -r1.7 pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsevents.c (expand / switch to unified diff)

--- pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsevents.c 2015/01/29 01:56:02 1.6
+++ pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsevents.c 2015/01/29 11:28:50 1.7
@@ -1,66 +1,103 @@ @@ -1,66 +1,103 @@
1$NetBSD: patch-src_video_wscons_SDL__wsconsevents.c,v 1.6 2015/01/29 01:56:02 jmcneill Exp $ 1$NetBSD: patch-src_video_wscons_SDL__wsconsevents.c,v 1.7 2015/01/29 11:28:50 jmcneill 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,6 +47,13 @@ int WSCONS_InitKeyboard(_THIS) 5@@ -47,14 +47,31 @@ int WSCONS_InitKeyboard(_THIS)
6 return -1; 6 return -1;
7 } 7 }
8  8
9+#if defined(__NetBSD__) 9+#if defined(__NetBSD__)
10+ if (private->kbdType == 0) { 10+ if (private->kbdType == 0) {
11+ /* wsmux with no keyboard attached, assumed USB */ 11+ /* wsmux with no keyboard attached, assumed USB */
12+ private->kbdType = WSKBD_TYPE_USB; 12+ private->kbdType = WSKBD_TYPE_USB;
13+ } 13+ }
14+#endif 14+#endif
15+ 15+
16 if (tcgetattr(private->fd, &private->saved_tty) == -1) { 16 if (tcgetattr(private->fd, &private->saved_tty) == -1) {
17 WSCONS_ReportError("cannot get terminal attributes: %s", strerror(errno)); 17 WSCONS_ReportError("cannot get terminal attributes: %s", strerror(errno));
18 return -1; 18 return -1;
19@@ -65,6 +72,7 @@ int WSCONS_InitKeyboard(_THIS) 19 }
 20+ if (ioctl(private->fd, WSKBDIO_GETKEYREPEAT, &private->saved_repeat) == -1) {
 21+ WSCONS_ReportError("cannot get repeat settings: %s", strerror(errno));
 22+ return -1;
 23+ }
 24 private->did_save_tty = 1;
 25+
 26+ if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) {
 27+ WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno));
 28+ return -1;
 29+ }
 30+
 31 tty = private->saved_tty;
 32 tty.c_iflag = IGNPAR | IGNBRK;
 33- tty.c_oflag = 0;
 34+ //tty.c_oflag = 0;
 35 tty.c_cflag = CREAD | CS8;
 36 tty.c_lflag = 0;
 37 tty.c_cc[VTIME] = 0;
 38@@ -65,8 +82,12 @@ int WSCONS_InitKeyboard(_THIS)
20 WSCONS_ReportError("cannot set terminal attributes: %s", strerror(errno)); 39 WSCONS_ReportError("cannot set terminal attributes: %s", strerror(errno));
21 return -1; 40 return -1;
22 } 41 }
 42- if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) {
 43- WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno));
23+ 44+
24 if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) { 45+ struct wskbd_keyrepeat_data repeat;
25 WSCONS_ReportError("cannot set raw keyboard mode: %s", strerror(errno)); 46+ repeat.which = WSKBD_KEYREPEAT_DOALL;
 47+ repeat.del1 = repeat.delN = UINT_MAX;
 48+ if (ioctl(private->fd, WSKBDIO_SETKEYREPEAT, &repeat) == -1) {
 49+ WSCONS_ReportError("cannot set repeat settings: %s", strerror(errno));
26 return -1; 50 return -1;
27@@ -89,8 +97,57 @@ void WSCONS_ReleaseKeyboard(_THIS) 51 }
 52
 53@@ -81,6 +102,10 @@ void WSCONS_ReleaseKeyboard(_THIS)
 54 strerror(errno));
 55 }
 56 if (private->did_save_tty) {
 57+ if (ioctl(private->fd, WSKBDIO_SETKEYREPEAT, &private->saved_repeat) == -1) {
 58+ WSCONS_ReportError("cannot restore repeat settings: %s",
 59+ strerror(errno));
 60+ }
 61 if (tcsetattr(private->fd, TCSANOW, &private->saved_tty) < 0) {
 62 WSCONS_ReportError("cannot restore keynoard attributes: %s",
 63 strerror(errno));
 64@@ -89,8 +114,57 @@ void WSCONS_ReleaseKeyboard(_THIS)
28 } 65 }
29 } 66 }
30  67
31-static void updateMouse() 68-static void updateMouse()
32+int WSCONS_InitMouse(_THIS) 69+int WSCONS_InitMouse(_THIS)
33+{ 70 {
34+ if (private->mouseFd != -1) { 71+ if (private->mouseFd != -1) {
35+#if defined(WSMOUSEIO_SETVERSION) 72+#if defined(WSMOUSEIO_SETVERSION)
36+ int version = WSMOUSE_EVENT_VERSION; 73+ int version = WSMOUSE_EVENT_VERSION;
37+ if (ioctl(private->mouseFd, WSMOUSEIO_SETVERSION, &version) == -1) { 74+ if (ioctl(private->mouseFd, WSMOUSEIO_SETVERSION, &version) == -1) {
38+ WSCONS_ReportError("cannot set mouse API version: %s", strerror(errno)); 75+ WSCONS_ReportError("cannot set mouse API version: %s", strerror(errno));
39+ return -1; 76+ return -1;
40+ } 77+ }
41+#endif 78+#endif
42+ } 79+ }
43+ return 0; 80+ return 0;
44+} 81+}
45+ 82+
46+void WSCONS_ReleaseMouse(_THIS) 83+void WSCONS_ReleaseMouse(_THIS)
47+{ 84+{
48+} 85+}
49+ 86+
50+#define NUMEVENTS 64 87+#define NUMEVENTS 64
51+ 88+
52+static void updateMouse(_THIS) 89+static void updateMouse(_THIS)
53 { 90+{
54+ struct wscons_event evlist[NUMEVENTS]; 91+ struct wscons_event evlist[NUMEVENTS];
55+ struct wscons_event *ev = evlist; 92+ struct wscons_event *ev = evlist;
56+ int nev, i; 93+ int nev, i;
57+ ssize_t len; 94+ ssize_t len;
58+ 95+
59+ len = read(private->mouseFd, evlist, sizeof(evlist)); 96+ len = read(private->mouseFd, evlist, sizeof(evlist));
60+ if (len == -1) { 97+ if (len == -1) {
61+ WSCONS_ReportError("Failed to read wsmouse event: %s", strerror(errno)); 98+ WSCONS_ReportError("Failed to read wsmouse event: %s", strerror(errno));
62+ return; 99+ return;
63+ } 100+ }
64+ 101+
65+ nev = len / sizeof(*ev); 102+ nev = len / sizeof(*ev);
66+ 103+
@@ -73,27 +110,27 @@ $NetBSD: patch-src_video_wscons_SDL__wsc @@ -73,27 +110,27 @@ $NetBSD: patch-src_video_wscons_SDL__wsc
73+ posted += SDL_PrivateMouseButton(SDL_PRESSED, ev->value+1, 0, 0); 110+ posted += SDL_PrivateMouseButton(SDL_PRESSED, ev->value+1, 0, 0);
74+ break; 111+ break;
75+ case WSCONS_EVENT_MOUSE_DELTA_X: 112+ case WSCONS_EVENT_MOUSE_DELTA_X:
76+ posted += SDL_PrivateMouseMotion(0, 1, ev->value, 0); 113+ posted += SDL_PrivateMouseMotion(0, 1, ev->value, 0);
77+ break; 114+ break;
78+ case WSCONS_EVENT_MOUSE_DELTA_Y: 115+ case WSCONS_EVENT_MOUSE_DELTA_Y:
79+ posted += SDL_PrivateMouseMotion(0, 1, 0, -ev->value); 116+ posted += SDL_PrivateMouseMotion(0, 1, 0, -ev->value);
80+ break; 117+ break;
81+ } 118+ }
82+ } 119+ }
83 } 120 }
84  121
85 static SDLKey keymap[128]; 122 static SDLKey keymap[128];
86@@ -120,19 +177,42 @@ static void updateKeyboard(_THIS) 123@@ -120,19 +194,42 @@ static void updateKeyboard(_THIS)
87 for (i = 0; i < n; i++) { 124 for (i = 0; i < n; i++) {
88 unsigned char c = buf[i] & 0x7f; 125 unsigned char c = buf[i] & 0x7f;
89 if (c == 224) // special key prefix -- what should we do with it? 126 if (c == 224) // special key prefix -- what should we do with it?
90- continue; 127- continue;
91+ continue; 128+ continue;
92 posted += SDL_PrivateKeyboard((buf[i] & 0x80) ? SDL_RELEASED : SDL_PRESSED, 129 posted += SDL_PrivateKeyboard((buf[i] & 0x80) ? SDL_RELEASED : SDL_PRESSED,
93- TranslateKey(c, &keysym)); 130- TranslateKey(c, &keysym));
94+ TranslateKey(c, &keysym)); 131+ TranslateKey(c, &keysym));
95 } 132 }
96 } 133 }
97 } 134 }
98  135
99 void WSCONS_PumpEvents(_THIS) 136 void WSCONS_PumpEvents(_THIS)
@@ -120,96 +157,33 @@ $NetBSD: patch-src_video_wscons_SDL__wsc @@ -120,96 +157,33 @@ $NetBSD: patch-src_video_wscons_SDL__wsc
120+ FD_SET(private->mouseFd, &fds); 157+ FD_SET(private->mouseFd, &fds);
121+ 158+
122+ if (select(maxfd+1, &fds, NULL, NULL, &zero) > 0) { 159+ if (select(maxfd+1, &fds, NULL, NULL, &zero) > 0) {
123+ if (private->mouseFd != -1 && FD_ISSET(private->mouseFd, &fds)) { 160+ if (private->mouseFd != -1 && FD_ISSET(private->mouseFd, &fds)) {
124+ updateMouse(this); 161+ updateMouse(this);
125+ } 162+ }
126+ if (private->fd != -1 && FD_ISSET(private->fd, &fds)) { 163+ if (private->fd != -1 && FD_ISSET(private->fd, &fds)) {
127+ updateKeyboard(this); 164+ updateKeyboard(this);
128+ } 165+ }
129+ } 166+ }
130 } while (posted); 167 } while (posted);
131 } 168 }
132  169
133@@ -146,7 +226,72 @@ void WSCONS_InitOSKeymap(_THIS) 170@@ -146,8 +243,10 @@ void WSCONS_InitOSKeymap(_THIS)
134 } 171 }
135  172
136 switch (private->kbdType) { 173 switch (private->kbdType) {
137-#ifdef WSKBD_TYPE_ZAURUS 174-#ifdef WSKBD_TYPE_ZAURUS
138+ case WSKBD_TYPE_USB: 
139+ for (i=4; i <= 29; i++) { 
140+ keymap[i] = SDLK_a + (i-4); 
141+ } 
142+ for (i=30; i <= 38; i++) { 
143+ keymap[i] = SDLK_1 + (i-30); 
144+ } 
145+ keymap[39] = SDLK_0; 
146+ keymap[40] = SDLK_RETURN; 
147+ keymap[41] = SDLK_ESCAPE; 
148+ keymap[42] = SDLK_BACKSPACE; 
149+ keymap[43] = SDLK_TAB; 
150+ keymap[44] = SDLK_SPACE; 
151+ keymap[45] = SDLK_MINUS; 
152+ keymap[46] = SDLK_EQUALS; 
153+ keymap[47] = SDLK_LEFTBRACKET; 
154+ keymap[48] = SDLK_RIGHTBRACKET; 
155+ keymap[49] = SDLK_BACKSLASH; 
156+ keymap[50] = SDLK_BACKSLASH; 
157+ keymap[51] = SDLK_SEMICOLON; 
158+ keymap[52] = SDLK_QUOTE; 
159+ keymap[53] = SDLK_BACKQUOTE; 
160+ keymap[54] = SDLK_COMMA; 
161+ keymap[55] = SDLK_PERIOD; 
162+ keymap[56] = SDLK_SLASH; 
163+ keymap[57] = SDLK_CAPSLOCK; 
164+ for (i=58; i <= 69; i++) { 
165+ keymap[i] = SDLK_F1 + (i-58); 
166+ } 
167+ keymap[70] = SDLK_PRINT; 
168+ keymap[71] = SDLK_SCROLLOCK; 
169+ keymap[72] = SDLK_PAUSE; 
170+ keymap[73] = SDLK_INSERT; 
171+ keymap[74] = SDLK_HOME; 
172+ keymap[75] = SDLK_PAGEUP; 
173+ keymap[76] = SDLK_DELETE; 
174+ keymap[77] = SDLK_END; 
175+ keymap[78] = SDLK_PAGEDOWN; 
176+ keymap[79] = SDLK_RIGHT; 
177+ keymap[80] = SDLK_LEFT; 
178+ keymap[81] = SDLK_DOWN; 
179+ keymap[82] = SDLK_UP; 
180+ keymap[83] = SDLK_NUMLOCK; 
181+ keymap[84] = SDLK_KP_DIVIDE; 
182+ keymap[85] = SDLK_KP_MULTIPLY; 
183+ keymap[86] = SDLK_KP_MINUS; 
184+ keymap[87] = SDLK_KP_PLUS; 
185+ keymap[88] = SDLK_KP_ENTER; 
186+ for (i=89; i <= 97; i++) { 
187+ keymap[i] = SDLK_KP1 + (i-89); 
188+ } 
189+ keymap[98] = SDLK_KP0; 
190+ keymap[99] = SDLK_KP_PERIOD; 
191+ keymap[100] = SDLK_LESS; 
192+ keymap[101] = SDLK_MENU; 
193+ keymap[102] = SDLK_POWER; 
194+ keymap[103] = SDLK_KP_EQUALS; 
195+ keymap[104] = SDLK_F13; 
196+ keymap[105] = SDLK_F14; 
197+ keymap[106] = SDLK_F15; 
198+ keymap[109] = SDLK_POWER; 
199+ keymap[117] = SDLK_HELP; 
200+ 
201+ break; 
202+ 
203+#if defined(WSKBD_TYPE_ZAURUS) 175+#if defined(WSKBD_TYPE_ZAURUS)
204 case WSKBD_TYPE_ZAURUS: 176 case WSKBD_TYPE_ZAURUS:
 177+#endif
 178+ case WSKBD_TYPE_USB:
205 /* top row */ 179 /* top row */
206 keymap[2] = SDLK_1; 180 keymap[2] = SDLK_1;
207@@ -220,7 +365,7 @@ void WSCONS_InitOSKeymap(_THIS) 181 keymap[3] = SDLK_2;
 182@@ -220,7 +319,6 @@ void WSCONS_InitOSKeymap(_THIS)
208 keymap[77] = SDLK_RIGHT; 183 keymap[77] = SDLK_RIGHT;
209 keymap[80] = SDLK_DOWN; 184 keymap[80] = SDLK_DOWN;
210 break; 185 break;
211-#endif /* WSKBD_TYPE_ZAURUS */ 186-#endif /* WSKBD_TYPE_ZAURUS */
212+#endif 
213  187
214 default: 188 default:
215 WSCONS_ReportError("Unable to map keys for keyboard type %u",  189 WSCONS_ReportError("Unable to map keys for keyboard type %u",

cvs diff -r1.1 -r1.2 pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsvideo.h (expand / switch to unified diff)

--- pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsvideo.h 2015/01/29 01:56:23 1.1
+++ pkgsrc/devel/SDL/patches/patch-src_video_wscons_SDL__wsconsvideo.h 2015/01/29 11:28:50 1.2
@@ -1,12 +1,20 @@ @@ -1,12 +1,20 @@
1$NetBSD: patch-src_video_wscons_SDL__wsconsvideo.h,v 1.1 2015/01/29 01:56:23 jmcneill Exp $ 1$NetBSD: patch-src_video_wscons_SDL__wsconsvideo.h,v 1.2 2015/01/29 11:28:50 jmcneill Exp $
2 2
3--- src/video/wscons/SDL_wsconsvideo.h.orig 2012-01-19 06:30:06.000000000 +0000 3--- src/video/wscons/SDL_wsconsvideo.h.orig 2012-01-19 06:30:06.000000000 +0000
4+++ src/video/wscons/SDL_wsconsvideo.h 4+++ src/video/wscons/SDL_wsconsvideo.h
5@@ -50,6 +50,7 @@ typedef void WSCONS_bitBlit(Uint8 *src_p 5@@ -50,6 +50,7 @@ typedef void WSCONS_bitBlit(Uint8 *src_p
6  6
7 struct SDL_PrivateVideoData { 7 struct SDL_PrivateVideoData {
8 int fd; /* file descriptor of open device */ 8 int fd; /* file descriptor of open device */
9+ int mouseFd; /* file descriptor of open mouse device */ 9+ int mouseFd; /* file descriptor of open mouse device */
10 struct wsdisplay_fbinfo info; /* frame buffer characteristics */ 10 struct wsdisplay_fbinfo info; /* frame buffer characteristics */
11 int physlinebytes; /* number of bytes per row */ 11 int physlinebytes; /* number of bytes per row */
12 int redMask, greenMask, blueMask; 12 int redMask, greenMask, blueMask;
 13@@ -70,6 +71,7 @@ struct SDL_PrivateVideoData {
 14 unsigned int kbdType;
 15 int did_save_tty;
 16 struct termios saved_tty;
 17+ struct wskbd_keyrepeat_data saved_repeat;
 18 };
 19
 20