3 # Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
6 Index: SDL-1.2.7/src/video/qtopia/SDL_QWin.cc
7 ===================================================================
8 --- SDL-1.2.7.orig/src/video/qtopia/SDL_QWin.cc 2005-03-02 22:24:43.457491622 +0100
9 +++ SDL-1.2.7/src/video/qtopia/SDL_QWin.cc 2005-03-02 22:24:46.867009932 +0100
13 SDL - Simple DirectMedia Layer
14 Copyright (C) 1997-2004 Sam Lantinga
18 #include <qapplication.h>
19 +#include <qpe/qpeapplication.h>
20 #include <qdirectpainter_qws.h>
23 +extern int fb_direct;
24 +extern bool is_VGA_machine;
25 +static int mouse_button_mode=1;
27 screenRotationT screenRotation = SDL_QT_NO_ROTATION;
29 SDL_QWin::SDL_QWin(const QSize& size)
30 : QWidget(0, "SDL_main"), my_painter(0), my_image(0),
31 my_inhibit_resize(false), my_mouse_pos(-1,-1), my_flags(0),
32 - my_has_fullscreen(false), my_locked(0)
33 + my_has_fullscreen(false), my_locked(0),
34 + rotation_(0), qteRotation_(0), keyRotation_(0), qteKeyRotation_(0),
35 + isSLA300InputFix_(0)
37 + for (int i = 0; i < 5; i++) curAxis_[i] = 0;
38 setBackgroundMode(NoBackground);
44 void SDL_QWin::setMousePos(const QPoint &pos) {
46 if(my_image->width() == height()) {
47 if (screenRotation == SDL_QT_ROTATION_90)
48 my_mouse_pos = QPoint(height()-pos.y(), pos.x());
56 + if (is_VGA_machine) {
58 + my_mouse_pos = realPos;
60 + switch (qteRotation_) {
65 + realPos.setX(pos.y());
66 + realPos.setY(fbSize_.height() - 1 - pos.x());
69 + realPos.setX(fbSize_.width() - 1 - pos.x());
70 + realPos.setY(fbSize_.height() - 1 - pos.y());
73 + realPos.setX(fbSize_.width() - 1 - pos.y());
74 + realPos.setY(pos.x());
78 + // fprintf(stderr, "setMousePos: realPos(%d, %d)\n", realPos.x(), realPos.y());
80 + int borderWidth = (fbSize_.width() - my_image->width()) >> 1;
81 + int borderHeight = (fbSize_.height() - my_image->height()) >> 1;
82 + if ( rotation_ & 1 ){
83 + borderWidth = (fbSize_.height() - my_image->width()) >> 1;
84 + borderHeight = (fbSize_.width() - my_image->height()) >> 1;
86 + realPos.setX(realPos.x() - borderWidth);
87 + realPos.setY(realPos.y() - borderHeight);
89 + fprintf(stderr, "setMousePos: realPos2(%d, %d)\n", realPos.x(), realPos.y());
91 + switch (rotation_) {
93 + my_mouse_pos = realPos;
96 + my_mouse_pos.setX(realPos.y());
97 + my_mouse_pos.setY(my_image->height() - 1 - realPos.x());
100 + my_mouse_pos.setX(my_image->width() - 1 - realPos.x());
101 + my_mouse_pos.setY(my_image->height() - 1 - realPos.y());
104 + my_mouse_pos.setX(realPos.y());//my_image->width() - 1 - realPos.y());
105 + my_mouse_pos.setY(my_image->height() - realPos.x());
110 +// fprintf(stderr, "setMousePos: mymousePos(%d, %d)\n", (short)my_mouse_pos.x(), (short)my_mouse_pos.y());
115 void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
116 @@ -113,269 +184,318 @@
117 void SDL_QWin::mousePressEvent(QMouseEvent *e) {
119 Qt::ButtonState button = e->button();
120 - SDL_PrivateMouseButton(SDL_PRESSED,
121 - (button & Qt::LeftButton) ? 1 :
122 - ((button & Qt::RightButton) ? 2 : 3),
123 + SDL_PrivateMouseButton(SDL_PRESSED,mouse_button_mode,
124 my_mouse_pos.x(), my_mouse_pos.y());
127 void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
128 setMousePos(e->pos());
129 Qt::ButtonState button = e->button();
130 - SDL_PrivateMouseButton(SDL_RELEASED,
131 - (button & Qt::LeftButton) ? 1 :
132 - ((button & Qt::RightButton) ? 2 : 3),
133 + SDL_PrivateMouseButton(SDL_RELEASED,mouse_button_mode,
134 my_mouse_pos.x(), my_mouse_pos.y());
135 my_mouse_pos = QPoint(-1, -1);
139 -gs_fastRotateBlit_3 ( unsigned short *fb,
140 - unsigned short *bits,
141 - const QRect& rect )
145 +blitRotate3(Uint16 *dstBits, const QSize& dstSize,
146 + const Uint16 *srcBits, const QSize& srcSize,
147 + const QRect& srcBlitRect);
150 +blitRotate0(Uint16 *dstBits, const QSize& dstSize,
151 + const Uint16 *srcBits, const QSize& srcSize,
152 + const QRect& srcBlitRect)
154 - // FIXME: this only works correctly for 240x320 displays
155 - int startx, starty;
158 - startx = rect.left() >> 1;
159 - starty = rect.top() >> 1;
160 - width = ((rect.right() - rect.left()) >> 1) + 2;
161 - height = ((rect.bottom() - rect.top()) >> 1) + 2;
163 - if((startx+width) > 120) {
164 - width = 120 - startx; // avoid horizontal overflow
166 - if((starty+height) > 160) {
167 - height = 160 - starty; // avoid vertical overflow
170 - ulong *sp1, *sp2, *dp1, *dp2;
171 - ulong stop, sbot, dtop, dbot;
173 - sp1 = (ulong*)bits + startx + starty*240;
175 - dp1 = (ulong *)fb + (159 - starty) + startx*320;
177 - int rowadd = (-320*width) - 1;
178 - int rowadd2 = 240 - width;
179 - // transfer in cells of 2x2 pixels in words
180 - for (int y=0; y<height; y++) {
181 - for (int x=0; x<width; x++) {
182 - // read source pixels
186 - dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16);
187 - dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000);
188 - // write to framebuffer
191 - // update source ptrs
193 - // update dest ptrs - 2 pix at a time
197 - // adjust src ptrs - skip a row as we work in pairs
200 - // adjust dest ptrs for rotation
203 + srcBits += srcBlitRect.left() + srcBlitRect.top() * srcSize.width();
204 + dstBits += ((dstSize.width() - srcSize.width()) >> 1)
205 + + (((dstSize.height() - srcSize.height()) >> 1) * dstSize.width());
206 + dstBits += srcBlitRect.left() + srcBlitRect.top() * dstSize.width();
207 + int w = srcBlitRect.width() << 1;
208 + int h = srcBlitRect.height();
211 + memcpy(dstBits, srcBits, w);
212 + dstBits += dstSize.width();
213 + srcBits += srcSize.width();
218 -gs_fastRotateBlit_1 ( unsigned short *fb,
219 - unsigned short *bits,
220 - const QRect& rect ) {
221 - // FIXME: this only works correctly for 240x320 displays
222 - int startx, starty;
225 - startx = rect.left() >> 1;
226 - starty = rect.top() >> 1;
227 - width = ((rect.right() - rect.left()) >> 1) + 2;
228 - height = ((rect.bottom() - rect.top()) >> 1) + 2;
230 - if((startx+width) > 120) {
231 - width = 120 - startx; // avoid horizontal overflow
233 - if((starty+height) > 160) {
234 - height = 160 - starty; // avoid vertical overflow
237 - ulong *sp1, *sp2, *dp1, *dp2;
238 - ulong stop, sbot, dtop, dbot;
239 - fb += 320*239; // Move "fb" to top left corner
240 - sp1 = (ulong*)bits + startx + starty*240;
242 - dp1 = (ulong*)fb - startx * 320 - starty;
244 - int rowadd = (320*width) + 1;
245 - int rowadd2 = 240 - width;
246 - // transfer in cells of 2x2 pixels in words
247 - for (int y=0; y<height; y++) {
248 - for (int x=0; x<width; x++) {
253 - dtop = (stop & 0xffff) + ((sbot & 0xffff)<<16);
254 - dbot = ((stop & 0xffff0000)>>16) + (sbot & 0xffff0000);
258 - // update source ptrs
260 - // update dest ptrs - 2 pix at a time
264 - // adjust src ptrs - skip a row as we work in pairs
267 - // adjust dest ptrs for rotation
272 +blitRotate1(Uint16 *dstBits, const QSize& dstSize,
273 + const Uint16 *srcBits, const QSize& srcSize,
274 + const QRect& srcBlitRect)
276 +// fprintf(stdout, "SDL_QT_ROTATION (1) is not implemented.\n");
277 + blitRotate3(dstBits, dstSize, srcBits, srcSize, srcBlitRect);
280 -// desktop, SL-A300 etc
281 -bool SDL_QWin::repaintRotation0(const QRect& rect) {
282 - if(my_image->width() == width()) {
283 - uchar *fb = (uchar*)my_painter->frameBuffer();
284 - uchar *buf = (uchar*)my_image->bits();
285 - if(rect == my_image->rect()) {
286 - memcpy(fb, buf, width()*height()*2);
288 - int h = rect.height();
289 - int wd = rect.width()<<1;
290 - int fblineadd = my_painter->lineStep();
291 - int buflineadd = my_image->bytesPerLine();
292 - fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
293 - buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
295 - memcpy(fb, buf, wd);
300 +blitRotate2(Uint16 *dstBits, const QSize& dstSize,
301 + const Uint16 *srcBits, const QSize& srcSize,
304 +// if (srcBlitRect.left() & 1)
305 +// srcBlitRect.setLeft(srcBlitRect.left() - 1);
306 +// if (srcBlitRect.right() & 1)
307 +// srcBlitRect.setRight(srcBlitRect.right() - 1);
309 + int dstBorderLeftRight = (dstSize.width() - srcSize.width()) >>1;
310 + int dstBorderTopBottom = (dstSize.height() - srcSize.height()) >>1;
311 + int dstStartOffsetX = dstSize.width() - dstBorderLeftRight - 2;
312 + int dstStartOffsetY = dstSize.height() - dstBorderTopBottom - 1;
313 + int left = srcBlitRect.left() & ~(int)1; // to be 32bit aligned
314 + srcBits += left + srcBlitRect.top() * srcSize.width();
315 + dstBits += dstStartOffsetY * dstSize.width() + dstStartOffsetX;
317 + dstBits -= srcBlitRect.top() * dstSize.width();
319 + Uint32 *pSrc = (Uint32 *)srcBits;
320 + Uint32 *pDst = (Uint32 *)dstBits;
322 + int width = srcBlitRect.width(), width2 = srcBlitRect.width(), w;
323 + if ( srcBlitRect.left() & 1 ){
326 + if ( (srcBlitRect.left()+srcBlitRect.width()) & 1 ){
330 + int height = srcBlitRect.height();
331 + int srcYAdd = srcSize.width() - width2;
332 + int dstYSub = dstSize.width() - width2;
336 + if (srcBlitRect.left() & 1){
337 + *((Uint16 *)pDst) = *(((Uint16 *)pSrc) + 1);
341 - return false; // FIXME: Landscape
343 + *pDst-- = (*pSrc << 16) | (*pSrc >> 16);
346 + if ((srcBlitRect.left()+srcBlitRect.width()) & 1){
347 + *(((Uint16 *)pDst) + 1) = *((Uint16 *)pSrc);
354 - my_painter->fillRect( rect, QBrush( Qt::NoBrush ) );
360 -// Sharp Zaurus SL-5500 etc
361 -bool SDL_QWin::repaintRotation3(const QRect& rect) {
362 - if(my_image->width() == width()) {
363 - ushort *fb = (ushort*)my_painter->frameBuffer();
364 - ushort *buf = (ushort*)my_image->bits();
365 - gs_fastRotateBlit_3(fb, buf, rect);
366 +#define BLIT_ROTATE_3_MOV32
369 +blitRotate3(Uint16 *dstBits, const QSize& dstSize,
370 + const Uint16 *srcBits, const QSize& srcSize,
371 + const QRect& srcBlitRect)
373 + if (srcBlitRect.width() != dstSize.height() ||
374 + srcBlitRect.height() != dstSize.width()) {
376 + const Uint16 *pSrc = srcBits +
377 + (srcBlitRect.left() + srcBlitRect.top() * srcSize.width());
379 + int dstBorderLeftRight = (dstSize.width() - srcSize.height()) >>1;
380 + int dstBorderTopBottom = (dstSize.height() - srcSize.width()) >>1;
381 + int dstStartOffsetX = dstSize.width() - dstBorderLeftRight - 1;
382 + int dstStartOffsetY = dstBorderTopBottom;
383 + Uint16 *pDst = dstBits +
384 + (dstStartOffsetY * dstSize.width() + dstStartOffsetX);
385 + pDst += srcBlitRect.left() * dstSize.width();
386 + pDst -= srcBlitRect.top();
388 + int width = srcBlitRect.width(), height = srcBlitRect.height(), w;
389 + int srcYAdd = srcSize.width() - srcBlitRect.width();
390 + int dstXAdd = dstSize.width();
391 + int dstYSub = (dstSize.width() * srcBlitRect.width()) + 1;
394 + fprintf(stderr, "---- Blit begin\n");
395 + fprintf(stderr, "srcSize.width: %d srcSize.height:%d\n",
396 + srcSize.width(), srcSize.height());
397 + fprintf(stderr, "srcBlitRect.left:%d srcBlitRect.right:%d srcBlitRect.top:%d srcBlitRect.bottom:%d srcBlitRect.width:%d srcBlitRect.height:%d\n",
398 + srcBlitRect.left(), srcBlitRect.right(), srcBlitRect.top(), srcBlitRect.bottom(), srcBlitRect.width(), srcBlitRect.height());
400 + fprintf(stderr, "dstSize.width: %d dstSize.height:%d\n",
401 + dstSize.width(), dstSize.height());
402 + fprintf(stderr, "dstBorderLeftRight:%d dstBorderTopBottom:%d dstStartOffsetX:%d dstStartOffsetY:%d\n",
403 + dstBorderLeftRight, dstBorderTopBottom, dstStartOffsetX, dstStartOffsetY);
404 + fprintf(stderr, "srcYAdd:%d dstXAdd:%d dstYSub:%d\n", srcYAdd, dstXAdd, dstYSub);
416 + // fprintf(stderr, "---- Blit end\n");
419 - if (screenRotation == SDL_QT_ROTATION_90) {
420 - uchar *fb = (uchar*)my_painter->frameBuffer();
421 - uchar *buf = (uchar*)my_image->bits();
422 - if(rect == my_image->rect()) {
423 - memcpy(fb, buf, width()*height()*2);
425 - int h = rect.height();
426 - int wd = rect.width()<<1;
427 - int fblineadd = my_painter->lineStep();
428 - int buflineadd = my_image->bytesPerLine();
429 - fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
430 - buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
432 - memcpy(fb, buf, wd);
437 +#if !defined(BLIT_ROTATE_3_MOV32)
438 + const Uint16 *src = srcBits;
439 + Uint16 *dst = dstBits + (dstSize.width() - 1);
440 + int w = srcBlitRect.width();
441 + int h = srcBlitRect.height();
442 + int i, dstSub = dstSize.width() * w + 1;
443 + int dstAdd = dstSize.width();
451 - } else if (screenRotation == SDL_QT_ROTATION_270) {
452 - int h = rect.height();
453 - int wd = rect.width();
454 - int fblineadd = my_painter->lineStep() - (rect.width() << 1);
455 - int buflineadd = my_image->bytesPerLine() - (rect.width() << 1);
458 - uchar *fb = (uchar*)my_painter->frameBuffer();
459 - uchar *buf = (uchar*)my_image->bits();
461 - fb += ((my_painter->width() - (rect.top() + rect.height())) *
462 - my_painter->lineStep()) + ((my_painter->height() - ((rect.left() +
463 - rect.width()))) << 1);
465 - buf += my_image->bytesPerLine() * (rect.top() + rect.height()) -
466 - (((my_image->width() - (rect.left() + rect.width())) << 1) + 2);
470 - while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--;
475 +#else // BLIT_ROTATE_3_MOV32
476 + Uint32 *src1 = (Uint32 *)(srcBits);
477 + Uint32 *src2 = (Uint32 *)(srcBits + srcSize.width());
478 + Uint32 *dst1 = (Uint32 *)(dstBits + (dstSize.width() - 2));
479 + Uint32 *dst2 = (Uint32 *)(dstBits + (dstSize.width() + dstSize.width() - 2));
480 + int w = srcBlitRect.width() >> 3;
481 + int h = srcBlitRect.height() >> 1;
482 + int i, dstSub = ((dstSize.width() * srcBlitRect.width()) >> 1) + 1;
483 + int dstAdd = dstSize.width();
491 + *dst1 = (a << 16) | (b & 0xFFFF);
492 + *dst2 = (a & 0xFFFF0000) | (b >> 16);
498 + *dst1 = (a << 16) | (b & 0xFFFF);
499 + *dst2 = (a & 0xFFFF0000) | (b >> 16);
505 + *dst1 = (a << 16) | (b & 0xFFFF);
506 + *dst2 = (a & 0xFFFF0000) | (b >> 16);
512 + *dst1 = (a << 16) | (b & 0xFFFF);
513 + *dst2 = (a & 0xFFFF0000) | (b >> 16);
517 + src1 += srcSize.width() >> 1;
518 + src2 += srcSize.width() >> 1;
522 +#endif // BLIT_ROTATE_3_MOV32
528 -bool SDL_QWin::repaintRotation1(const QRect& rect) {
529 - if(my_image->width() == width()) {
530 - ushort *fb = (ushort*)my_painter->frameBuffer();
531 - ushort *buf = (ushort*)my_image->bits();
532 - gs_fastRotateBlit_1(fb, buf, rect);
534 - return false; // FIXME: landscape mode
540 void SDL_QWin::repaintRect(const QRect& rect) {
541 if(!my_painter || !rect.width() || !rect.height()) {
545 - if(QPixmap::defaultDepth() == 16) {
546 - switch(my_painter->transformOrientation()) {
548 - if(repaintRotation3(rect)) { return; }
550 + if (QPixmap::defaultDepth() == 16 && my_painter->numRects() >= 0) {
551 + Uint16 *fb = (Uint16*)my_painter->frameBuffer();
552 + Uint16 *buf = (Uint16*)my_image->bits();
553 + switch (rotation_) {
555 + blitRotate0(fb, fbSize_,
556 + buf, QSize(my_image->width(), my_image->height()),
560 - if(repaintRotation1(rect)) { return; }
561 + blitRotate1(fb, fbSize_,
562 + buf, QSize(my_image->width(), my_image->height()),
566 - if(repaintRotation0(rect)) { return; }
568 + blitRotate2(fb, fbSize_,
569 + buf, QSize(my_image->width(), my_image->height()),
573 + blitRotate3(fb, fbSize_,
574 + buf, QSize(my_image->width(), my_image->height()),
579 - my_painter->drawImage(rect.topLeft(), *my_image, rect);
582 + QDirectPainter pp(this);
583 + pp.drawImage(rect.topLeft(), *my_image, rect);
590 // This paints the current buffer to the screen, when desired.
591 void SDL_QWin::paintEvent(QPaintEvent *ev) {
593 + if(my_image && isVisible() && isActiveWindow()) {
594 + // TODO: better handling
596 repaintRect(ev->rect());
601 +int SDL_QWin::ApplyKeyRotation(int key)
604 + int sdlScancode[] = { SDLK_LEFT, SDLK_DOWN, SDLK_RIGHT, SDLK_UP };
613 + case Qt::Key_Right:
623 +// c = (c + qteKeyRotation_) & 3;
624 +// return sdlScancode[(c - keyRotation_) & 3];
625 + return sdlScancode[(c + qteKeyRotation_ - keyRotation_) & 3];
628 /* Function to translate a keyboard transition and queue the key event
629 * This should probably be a table although this method isn't exactly
632 void SDL_QWin::QueueKey(QKeyEvent *e, int pressed)
635 + if (e->isAutoRepeat())
639 int scancode = e->key();
641 /* Set the keysym information */
642 if(scancode >= 'A' && scancode <= 'Z') {
643 // Qt sends uppercase, SDL wants lowercase
644 @@ -396,26 +516,12 @@
645 case Qt::Key_Home: scancode = SDLK_HOME; break;
646 case Qt::Key_End: scancode = SDLK_END; break;
647 // We want the control keys to rotate with the screen
649 - if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_UP;
650 - else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_DOWN;
651 - else scancode = SDLK_LEFT;
654 - if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_RIGHT;
655 - else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_LEFT;
656 - else scancode = SDLK_UP;
658 - case Qt::Key_Right:
659 - if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_DOWN;
660 - else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_UP;
661 - else scancode = SDLK_RIGHT;
665 + case Qt::Key_Right:
667 - if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_LEFT;
668 - else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_RIGHT;
669 - else scancode = SDLK_DOWN;
671 + scancode = ApplyKeyRotation(scancode);
673 case Qt::Key_Prior: scancode = SDLK_PAGEUP; break;
674 case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break;
675 case Qt::Key_Shift: scancode = SDLK_LSHIFT; break;
677 case Qt::Key_F7: scancode = SDLK_F7; break;
678 case Qt::Key_F8: scancode = SDLK_F8; break;
679 case Qt::Key_F9: scancode = SDLK_F9; break;
680 - case Qt::Key_F10: scancode = SDLK_F10; break;
681 - case Qt::Key_F11: scancode = SDLK_F11; break;
682 - case Qt::Key_F12: scancode = SDLK_F12; break;
684 + scancode = SDLK_F10;
685 + mouse_button_mode=1;
688 + scancode = SDLK_F11;
689 + mouse_button_mode=3;
692 + scancode = SDLK_F12;
693 + mouse_button_mode=2;
695 case Qt::Key_F13: scancode = SDLK_F13; break;
696 case Qt::Key_F14: scancode = SDLK_F14; break;
697 case Qt::Key_F15: scancode = SDLK_F15; break;
698 @@ -452,13 +567,14 @@
700 scancode = SDLK_RETURN;
704 scancode = SDLK_UNKNOWN;
707 - keysym.sym = static_cast<SDLKey>(scancode);
708 + keysym.sym = static_cast<SDLKey>(scancode);
710 - keysym.sym = static_cast<SDLKey>(scancode);
711 + keysym.sym = static_cast<SDLKey>(scancode);
713 keysym.scancode = scancode;
714 keysym.mod = KMOD_NONE;
715 @@ -478,11 +594,82 @@
719 + if (isSLA300InputFix_ &&
720 + (keysym.sym == SDLK_SPACE || (keysym.sym >= 273 && keysym.sym <= 276))) {
721 + if (keysym.sym >= 273) curAxis_[keysym.sym-273] = pressed;
722 + else curAxis_[4] = pressed;
725 /* Queue the key event */
727 - SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
728 + /* fprintf(stderr, "press %d\n", keysym.sym); */
729 + SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
730 + if (isSLA300InputFix_ &&
731 + (keysym.sym >= 273 && keysym.sym <= 276)) {
732 + if (keysym.sym == SDLK_UP) {
734 + keysym.sym = SDLK_DOWN;
735 + keysym.scancode = Qt::Key_Down;
737 + /* fprintf(stderr, "force release %d\n", keysym.sym); */
738 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
741 + else if (keysym.sym == SDLK_DOWN) {
743 + keysym.sym = SDLK_UP;
744 + keysym.scancode = Qt::Key_Up;
746 + /* fprintf(stderr, "force release %d\n", keysym.sym); */
747 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
750 + else if (keysym.sym == SDLK_RIGHT) {
752 + keysym.sym = SDLK_LEFT;
753 + keysym.scancode = Qt::Key_Left;
755 + /* fprintf(stderr, "force release %d\n", keysym.sym); */
756 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
759 + else if (keysym.sym == SDLK_LEFT) {
761 + keysym.sym = SDLK_RIGHT;
762 + keysym.scancode = Qt::Key_Right;
764 + /* fprintf(stderr, "force release %d\n", keysym.sym); */
765 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
770 - SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
771 + /* fprintf(stderr, "release %d\n", keysym.sym); */
772 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
774 + if (isSLA300InputFix_ &&
775 + (keysym.sym == SDLK_SPACE ||
776 + (keysym.sym >= 273 && keysym.sym <= 276))) {
777 + for (int i = 0; i < 4; i++) {
780 + keysym.sym = static_cast<SDLKey>(sym);
781 + if (sym == SDLK_UP) keysym.scancode = Qt::Key_Up;
782 + else if (sym == SDLK_RIGHT) keysym.scancode = Qt::Key_Right;
783 + else if (sym == SDLK_DOWN) keysym.scancode = Qt::Key_Down;
784 + else if (sym == SDLK_LEFT) keysym.scancode = Qt::Key_Left;
786 + /* fprintf(stderr, "force release %d\n", keysym.sym); */
787 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
791 + keysym.scancode = keysym.sym = SDLK_SPACE;
793 + /* fprintf(stderr, "force release %d\n", keysym.sym); */
794 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
801 my_locked--; // decrease lock refcount;
803 if(!my_locked && my_painter) {
805 +// my_painter->end();
809 Index: SDL-1.2.7/src/video/qtopia/SDL_QWin.h
810 ===================================================================
811 --- SDL-1.2.7.orig/src/video/qtopia/SDL_QWin.h 2005-03-02 22:24:43.457491622 +0100
812 +++ SDL-1.2.7/src/video/qtopia/SDL_QWin.h 2005-03-02 22:24:46.868009791 +0100
816 SDL - Simple DirectMedia Layer
817 Copyright (C) 1997-2004 Sam Lantinga
819 class SDL_QWin : public QWidget
821 void QueueKey(QKeyEvent *e, int pressed);
822 + int SDL_QWin::ApplyKeyRotation(int key);
824 SDL_QWin(const QSize& size);
829 QImage *image(void) { return my_image; }
832 void setWFlags(WFlags flags) {
833 QWidget::setWFlags(flags);
836 bool lockScreen(bool force=false);
838 void repaintRect(const QRect& rect);
839 + void setScreenRotation(int sdlr, int qter) {
840 + rotation_ = sdlr; qteRotation_ = qter;
842 + void setKeyRotation(int sdlr, int qter) {
843 + keyRotation_ = sdlr; qteKeyRotation_ = qter;
845 + void setFBSize(QSize& s) { fbSize_ = s; }
846 +// void setSLC700InputFix(bool isEnable) { isSLC700InputFix_ = isEnable; }
847 + void setSLA300InputFix(bool isEnable) { isSLA300InputFix_ = isEnable; }
849 /* Handle resizing of the window */
850 virtual void resizeEvent(QResizeEvent *e);
852 void paintEvent(QPaintEvent *ev);
853 void keyPressEvent(QKeyEvent *e) { QueueKey(e, 1); }
854 void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); }
857 - bool repaintRotation0(const QRect& rect);
858 - bool repaintRotation1(const QRect& rect);
859 - bool repaintRotation3(const QRect& rect);
860 void enableFullscreen();
861 QDirectPainter *my_painter;
865 WFlags my_has_fullscreen;
866 unsigned int my_locked;
867 + int rotation_, qteRotation_;
868 + int keyRotation_, qteKeyRotation_;
870 +// bool isSLC700InputFix_;
871 + bool isSLA300InputFix_;
872 + int curAxis_[5]; // 0: up, 1: down, 2: right, 3: left, 4: center
875 #endif /* _SDL_QWin_h */
876 Index: SDL-1.2.7/src/video/qtopia/SDL_sysmouse.cc
877 ===================================================================
878 --- SDL-1.2.7.orig/src/video/qtopia/SDL_sysmouse.cc 2005-03-02 22:24:43.457491622 +0100
879 +++ SDL-1.2.7/src/video/qtopia/SDL_sysmouse.cc 2005-03-02 22:24:46.868009791 +0100
881 void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
883 SDL_Win->setMousePos(QPoint(x, y));
884 + SDL_PrivateMouseMotion( 0, 0, x, y );
888 Index: SDL-1.2.7/src/video/qtopia/SDL_sysvideo.cc
889 ===================================================================
890 --- SDL-1.2.7.orig/src/video/qtopia/SDL_sysvideo.cc 2005-03-02 22:24:43.458491481 +0100
891 +++ SDL-1.2.7/src/video/qtopia/SDL_sysvideo.cc 2005-03-02 22:24:46.873009084 +0100
895 SDL - Simple DirectMedia Layer
896 Copyright (C) 1997-2004 Sam Lantinga
903 +#include <sys/ioctl.h>
907 +#include <sys/types.h>
908 +#include <sys/wait.h>
909 +#include <linux/fb.h>
910 +#include <sys/mman.h>
911 +#include <asm/page.h>
913 #include <qapplication.h>
914 #include <qpe/qpeapplication.h>
915 +#include <qpe/qcopenvelope_qws.h>
916 +#include <qgfx_qws.h>
917 +#include <qwindowsystem_qws.h>
918 +#include <qwidget.h>
919 +#include <qwidgetlist.h>
920 +#include <qdirectpainter_qws.h>
923 #include "SDL_timer.h"
925 #include "SDL_QWin.h"
926 +#include "SDL_sysvideo.h"
931 #include "SDL_lowvideo.h"
933 //#define QTOPIA_DEBUG
935 #define QT_HIDDEN_SIZE 32 /* starting hidden window size */
938 + static FILE *st_logfp = NULL;
940 + static inline void LOG(char *fmt, ...)
946 + vfprintf(st_logfp, fmt, ap);
947 + if (st_logfp != stderr) {
949 + vfprintf(stderr, fmt, ap);
955 + typedef struct machine_spec {
958 + int qpe_server_rotation;
959 + int init_screen_rot;
964 + MACHINE_SHARP_SL5000D,
965 + MACHINE_SHARP_SL5500,
966 + MACHINE_SHARP_SLA300,
967 + MACHINE_SHARP_SLB500,
968 + MACHINE_SHARP_SLC700,
969 + MACHINE_SHARP_SLC750,
970 + MACHINE_SHARP_SLC760,
971 + MACHINE_SHARP_SLC860,
972 + MACHINE_SHARP_SL6000,
976 + static const machine_spec_t st_machine_spec[] = {
977 + { "Sharp", "SL-5000D", 0 },
978 + { "Sharp", "SL-5500", 0 },
979 + { "Sharp", "SL-A300", 0 },
980 + { "Sharp", "SL-B500", 0 },
981 + { "Sharp", "SL-C700", 0 },
982 + { "Sharp", "SL-C750", 0 },
983 + { "Sharp", "SL-C760", 0 },
984 + { "Sharp", "SL-C860", 0 },
985 + { "Sharp", "SL-6000", 0 },
988 /* Name of the environment variable used to invert the screen rotation or not:
990 - !=0 : Screen is 270° rotated
991 - 0: Screen is 90° rotated*/
992 -#define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
994 + !=0 : Screen is 270- rotated
995 + 0: Screen is 90- rotated*/
996 +#define SDL_QT_ROTATION_ENV_NAME "SDL_QT_ROTATION"
997 +#define SDL_QT_INVERT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
999 /* Initialization/Query functions */
1000 static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat);
1001 static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
1003 static int QT_IconifyWindow(_THIS);
1004 static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode);
1006 + static int console_fd;
1007 + struct fb_var_screeninfo saved_vinfo;
1010 + static int isKHloaded;
1011 + bool is_VGA_machine;
1013 +#define W100FB_CONFIG 0x57415200 /* WAL\00 */
1014 +#define W100INIT_ITEM 0
1015 +#define W100INIT_ALL 1
1016 +#define W100INIT_ITEM_WITH_VAL 2
1017 +#define W100FB_CONFIG_EX 0x57415202 /* WAL\02 */
1020 /* FB driver bootstrap functions */
1022 static int QT_Available(void)
1023 @@ -222,13 +305,34 @@
1025 int QT_VideoInit(_THIS, SDL_PixelFormat *vformat)
1027 - /* Initialize the QPE Application */
1028 + const char *SDL_fbdev;
1029 + struct fb_var_screeninfo vinfo;
1031 + /* Initialize the QPE Application */
1032 /* Determine the screen depth */
1033 vformat->BitsPerPixel = QPixmap::defaultDepth();
1035 // For now we hardcode the current depth because anything else
1036 // might as well be emulated by SDL rather than by Qtopia.
1039 + //frame buffer device open.
1040 + SDL_fbdev = getenv("SDL_FBDEV");
1041 + if ( SDL_fbdev == NULL ) {
1042 + SDL_fbdev = "/dev/fb0";
1044 + console_fd = open(SDL_fbdev, O_RDWR, 0);
1045 + if ( console_fd < 0 ) {
1046 + SDL_SetError("Unable to open %s", SDL_fbdev);
1050 + if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
1051 + SDL_SetError("Couldn't get console pixel format");
1052 + QT_VideoQuit(_this);
1055 + saved_vinfo = vinfo;
1057 QSize desktop_size = qApp->desktop()->size();
1058 QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
1059 desktop_size.width(), desktop_size.height());
1060 @@ -241,7 +345,24 @@
1061 /* Fill in some window manager capabilities */
1062 _this->info.wm_available = 0;
1066 + st_logfp = fopen("/tmp/sdl-qt-debug", "w");
1068 + st_logfp = stderr;
1071 + QT_GrabInput(_this, SDL_GRAB_ON);
1074 + QCopEnvelope e("QPE/KeyHelper", "repeater(int)");
1078 + isKHloaded=(fopen("/home/zaurus/Settings/keyhelper_SDL.xml","r") != NULL) ? 1 : 0;
1080 + system("qcop QPE/KeyHelper \"reload(QString)\" keyhelper_SDL.xml"); //QcopEnvelope can't use.
1081 + LOG("keyhelper_SDL.xml loaded\n");
1088 /* Various screen update functions available */
1089 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
1090 + static void QT_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
1093 static int QT_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
1094 @@ -276,47 +398,428 @@
1098 + static machine_t QT_GetMachine(_THIS)
1101 + machine_t machine = MACHINE_SHARP_SL5000D;
1105 + fp = fopen("/proc/cpuinfo", "rb");
1107 + if (fread(buf, 1, sizeof(buf), fp) > 0) {
1108 + LOG("QT_GetMachine: /proc/cpuinfo is %s\n", buf);
1109 + if (strstr(buf, "SHARP Tosa") != NULL)
1110 + machine = MACHINE_SHARP_SL6000;
1111 + else if (strstr(buf, "Collie") != NULL)
1112 + machine = MACHINE_SHARP_SL5500;
1113 + else if (strstr(buf, "SHARP Poodle") != NULL)
1114 + machine = MACHINE_SHARP_SLB500;
1115 + else if (strstr(buf, "SHARP Corgi") !=NULL)
1116 + machine = MACHINE_SHARP_SLC700;
1117 + else if (strstr(buf, "SHARP Shepherd") !=NULL)
1118 + machine = MACHINE_SHARP_SLC750;
1119 + else if (strstr(buf, "SHARP Husky") !=NULL)
1120 + machine = MACHINE_SHARP_SLC760;
1121 + else if (strstr(buf, "SHARP Boxer") != NULL)
1122 + machine = MACHINE_SHARP_SLC860;
1126 + LOG("QT_GetMachine: Couldn't read /proc/deviceinfo/product.\n");
1127 + LOG(" Now set machine variable to default (SL-5000D)\n");
1130 + LOG(" detected machine is '%s %s'\n",
1131 + st_machine_spec[machine].manif, st_machine_spec[machine].name);
1135 + static void QT_GetQteServerSpec(_THIS, int *rotation, bool *isQvga)
1138 + char buf[FILENAME_MAX];
1140 + int rot = 0, is_qvga = 0;
1142 + user = getenv("USER");
1143 + snprintf(buf, sizeof(buf), "/tmp/qtembedded-%s/QtEmbedded-0.spec",
1144 + user ? user : "root");
1145 + LOG("QT_GetRotation: Read spec from '%s'\n", buf);
1147 + fp = fopen(buf, "rb");
1150 + if ((size = fread(buf, 1, sizeof(buf) - 1, fp)) > 0) {
1152 + LOG(" spec is '%s'\n", buf);
1153 + // get rotation value
1154 + if (strstr(buf, "Rot")) {
1155 + rot = atoi(strstr(buf, "Rot") + 3);
1157 + if (rot < 0 || rot > 3) {
1163 + // get qvga mode in SL-C700
1164 + if (strstr(buf, "Qvga"))
1170 + LOG(" Rot=%d, Qvga=%d\n", rot, is_qvga);
1175 + *isQvga = is_qvga;
1178 /* FIXME: check return values and cleanup here */
1179 SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current,
1180 int width, int height, int bpp, Uint32 flags)
1184 - QSize desktop_size = qApp->desktop()->size();
1185 + QSize qteSize = qApp->desktop()->size();
1190 + struct fb_var_screeninfo vinfo;
1191 + struct fb_fix_screeninfo finfo;
1192 + int tmp_ioctl_data;
1193 + char fb_size_fix = ' ';
1194 + bool isW100patch_kernel = false;
1197 + int mapped_memlen;
1198 + int mapped_offset;
1203 + machine_t machine = QT_GetMachine(_this);
1204 + machine_spec_t machineSpec = st_machine_spec[machine];
1205 + int qteRotation, userRotation, sdlRotation;
1206 + int qteKeyRotation, sdlKeyRotation;
1209 + if (machine == MACHINE_SHARP_SLC700 ||
1210 + machine == MACHINE_SHARP_SLC750 ||
1211 + machine == MACHINE_SHARP_SLC760 ||
1212 + machine == MACHINE_SHARP_SLC860 || // ¾Ü¤·¤¤¤³¤È¤ï¤«¤é¤ó¤±¤É¤È¤ê¤¢¤¨¤º
1213 + machine == MACHINE_SHARP_SL6000 ) { // ¾Ü¤·¤¤¤³¤È¤ï¤«¤é¤ó¤±¤É¤È¤ê¤¢¤¨¤º
1214 + is_VGA_machine = true;
1216 + is_VGA_machine = false;
1219 + // qte ¤Ç¤Î²óž³ÑÅÙ¤ò¼èÆÀ
1220 + QT_GetQteServerSpec(_this, &qteRotation, &isQteQvga);
1222 + // SL-C700 ¤Î¥¹¥¿¥¤¥ë
1223 + bool isInputStyle = false;
1224 + if (is_VGA_machine) {
1225 + int status = system("/home/QtPalmtop/bin/chkhinge");
1226 + if (WEXITSTATUS(status) != 2)
1227 + isInputStyle = true;
1228 + LOG("QT_SetVideoMode: SL-C700 Style is %s\n",
1229 + isInputStyle ? "Input style" : "View style");
1233 - current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen.
1234 + // specity screen setting
1235 + if (is_VGA_machine) {
1237 + // w100 rotation pached kernel check
1238 + isW100patch_kernel = (fopen("/proc/driver/w100/rotation","r") != NULL) ? true : false;
1239 + LOG("Your Kernel is %s\n",isW100patch_kernel ? "Special Kernel" : "Normal Kernel");
1241 + const char *envFb_Size = getenv("SDL_FB_SIZE");
1242 + if (envFb_Size !=NULL) {
1243 + numFb_Size=sscanf(envFb_Size,"%dx%d%c",&fb_xres,&fb_yres,&fb_size_fix);
1248 - if(width <= desktop_size.width()
1249 - && height <= desktop_size.height()) {
1250 - current->w = desktop_size.width();
1251 - current->h = desktop_size.height();
1252 - } else if(width <= desktop_size.height() && height <= desktop_size.width()) {
1254 - char * envString = getenv(SDL_QT_ROTATION_ENV_NAME);
1255 - int envValue = envString ? atoi(envString) : 0;
1256 - screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90;
1257 - current->h = desktop_size.width();
1258 - current->w = desktop_size.height();
1259 + if (numFb_Size >=2) {
1261 + // specity screen mode
1262 + if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
1263 + SDL_SetError("Couldn't get console pixel format");
1264 + QT_VideoQuit(_this);
1268 + vinfo.xres = fb_xres;
1269 + vinfo.xres_virtual = fb_xres;
1270 + vinfo.yres = fb_yres;
1271 + vinfo.yres_virtual = fb_yres;
1273 + if (fb_size_fix == '@') {
1278 + if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) {
1279 + SDL_SetError("Couldn't set console screen info");
1284 + if (isW100patch_kernel) {
1285 + qteSize.setWidth(vinfo.xres);
1286 + qteSize.setHeight(vinfo.yres);
1288 + }else if(vinfo.xres == 320){
1289 + qteSize.setWidth(vinfo.xres);
1290 + qteSize.setHeight(vinfo.yres);
1293 + qteSize.setWidth(vinfo.yres);
1294 + qteSize.setHeight(vinfo.xres);
1298 + if (isW100patch_kernel && (vinfo.xres == 320) && (vinfo.yres == 240)) {
1299 + tmp_ioctl_data=121;
1300 + ioctl(console_fd, W100FB_CONFIG_EX, &tmp_ioctl_data);
1304 + LOG("FBVideoMode: %dx%d%c\n", vinfo.xres, vinfo.yres,fb_size_fix );
1308 + // auto screen mode
1309 + if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
1310 + SDL_SetError("Couldn't get console pixel format");
1311 + QT_VideoQuit(_this);
1315 + if (isW100patch_kernel && (isInputStyle == false) && (vinfo.xres == 240) && (vinfo.yres == 320)) {
1317 + vinfo.xres_virtual = 240;
1319 + vinfo.yres_virtual = 320;
1321 + }else if ((width <= 320) && (height <= 240)) {
1323 + vinfo.xres_virtual = 320;
1325 + vinfo.yres_virtual = 240;
1326 + }else if (isW100patch_kernel && (isInputStyle == true)){
1328 + vinfo.xres_virtual = 640;
1330 + vinfo.yres_virtual = 480;
1334 + vinfo.xres_virtual = 480;
1336 + vinfo.yres_virtual = 640;
1339 + if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) {
1340 + SDL_SetError("Couldn't set console screen info");
1344 + if (isW100patch_kernel) {
1345 + qteSize.setWidth(vinfo.xres);
1346 + qteSize.setHeight(vinfo.yres);
1349 + }else if(vinfo.xres == 320){
1350 + qteSize.setWidth(vinfo.xres);
1351 + qteSize.setHeight(vinfo.yres);
1354 + qteSize.setWidth(vinfo.yres);
1355 + qteSize.setHeight(vinfo.xres);
1359 + if (isW100patch_kernel && (vinfo.xres == 320) && (vinfo.yres == 240)) {
1360 + tmp_ioctl_data=121;
1361 + ioctl(console_fd, W100FB_CONFIG_EX, &tmp_ioctl_data);
1366 + LOG("FBVideoMode: %dx%d%c\n", vinfo.xres, vinfo.yres,fb_size_fix );
1370 + // direct paint setting
1371 + const char *envFb_Direct = getenv("SDL_FB_DIRECT");
1372 + if (envFb_Direct !=NULL)
1373 + fb_direct = envFb_Direct ? atoi(envFb_Direct) : -1;
1375 + if (fb_direct == 1){
1376 + if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
1377 + SDL_SetError("Couldn't get console hardware info");
1378 + QT_VideoQuit(_this);
1381 + if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
1382 + SDL_SetError("Couldn't get console pixel format");
1383 + QT_VideoQuit(_this);
1386 + LOG("Direct paint mode\n");
1389 + // hack for SL-5500
1390 + if (machine == MACHINE_SHARP_SL5500)
1393 + // SL-B500 Íѥϥå¯(¤È¤ê¤¢¤¨¤º¡¢¤Í)
1394 + if (machine == MACHINE_SHARP_SLB500)
1397 + // À¸¥Õ¥ì¡¼¥à¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤òÆÀ¤ë
1398 + if (qteRotation & 1) {
1399 + fbSize.setWidth(qteSize.height());
1400 + fbSize.setHeight(qteSize.width());
1406 + const char *envRotStr = getenv(SDL_QT_ROTATION_ENV_NAME);
1407 + userRotation = envRotStr ? atoi(envRotStr) : -1;
1408 + if ((userRotation >= 0 ? userRotation : qteRotation) & 1) {
1409 + userSize.setWidth(fbSize.height());
1410 + userSize.setHeight(fbSize.width());
1412 + userSize = fbSize;
1415 + if (width <= userSize.width() && height <= userSize.height()) {
1416 + // ´Ä¶ÊÑ¿ô¤Ç²óž³ÑÅÙ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð¡¢¤½¤ì¤òºÇÍ¥À褹¤ë
1417 + if (userRotation >= 0)
1418 + sdlRotation = userRotation;
1420 + // ¤Ç¡¢¤½¤Î»ØÄ̵꤬¤¤¤Î¤Ç¤¢¤ì¤Ð qte ¤Î²óž³ÑÅ٤˹ç¤ï¤»¤ë¤À¤±
1421 + // ¤Ê¤ó¤À¤±¤É¡¢SL-C700 ¤Ç¤Ï¤Á¤ç¤¤Ê£»¨¡£
1422 + if (is_VGA_machine && (fbSize.width() == 320) && (fbSize.height() == 240)) {
1426 + sdlRotation = qteRotation;
1428 + sdlRotation = qteRotation;
1431 + } else if (width <= fbSize.width() && height <= fbSize.height()) {
1433 + if (is_VGA_machine && (fbSize.width() == 320) && (fbSize.height() == 240) && isInputStyle)
1435 + } else if (width <= fbSize.height() && height <= fbSize.width()) {
1438 SDL_SetError("Unsupported resolution, %dx%d\n", width, height);
1442 + if (fb_hwrot == 1)
1445 + if (getenv(SDL_QT_INVERT_ROTATION_ENV_NAME) != NULL) {
1446 + sdlRotation = (sdlRotation + 2) & 3;
1449 + LOG("QT_SetVideoMode: argSize=%dx%d\n", width, height);
1450 + LOG("QT_SetVideoMode: qteSize=%dx%d\n",
1451 + qteSize.width(), qteSize.height());
1452 + LOG("QT_SetVideoMode: fbSize=%dx%d\n",
1453 + fbSize.width(), fbSize.height());
1454 + LOG("QT_SetVideoMode: qteRotation=%d\n", qteRotation);
1455 + LOG("QT_SetVideoMode: userRotation=%d\n", userRotation);
1456 + LOG("QT_SetVideoMode: sdlRotation=%d\n", sdlRotation);
1458 + current->flags = 0;//SDL_FULLSCREEN; // We always run fullscreen.
1459 + current->w = width;
1460 + current->h = height;
1461 + SDL_Win->setScreenRotation(sdlRotation, qteRotation);
1462 + SDL_Win->setFBSize(fbSize);
1464 + if (machine == MACHINE_SHARP_SLA300)
1465 + SDL_Win->setSLA300InputFix(true);
1467 + // keyboard rotation
1468 + qteKeyRotation = qteRotation;
1469 +// fprintf(stderr, "%d\n", (machine == MACHINE_SHARP_SLC700));
1470 +// fprintf(stderr, "%d\n", isQteQvga);
1471 + if (isQteQvga && is_VGA_machine)
1472 + qteKeyRotation = 3;
1473 + else if (machine == MACHINE_SHARP_SLB500)
1474 + qteKeyRotation = 3;
1476 + if (isQteQvga && fb_hwrot == 1)
1477 + qteKeyRotation = 1;
1479 + sdlKeyRotation = sdlRotation;
1481 + SDL_Win->setKeyRotation(sdlKeyRotation, qteKeyRotation);
1483 + LOG("QT_SetVideoMode: qteKeyRotation=%d\n", qteKeyRotation);
1484 + LOG("QT_SetVideoMode: sdlKeyRotation=%d\n", sdlKeyRotation);
1486 if ( flags & SDL_OPENGL ) {
1487 SDL_SetError("OpenGL not supported");
1491 /* Create the QImage framebuffer */
1492 - qimage = new QImage(current->w, current->h, bpp);
1493 - if (qimage->isNull()) {
1494 - SDL_SetError("Couldn't create screen bitmap");
1498 + // frame buffer memory mapping
1499 + if (fb_direct == 1) {
1500 + current->pitch = finfo.line_length;
1501 + current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
1502 + mapped_offset = (((long)finfo.smem_start) -
1503 + (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
1504 + mapped_memlen = finfo.smem_len+mapped_offset;
1505 + if(console_fd >0 ) {
1506 + mapped_mem = mmap(NULL, mapped_memlen,PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
1507 + fb_offset=(vinfo.xres-width)+(vinfo.yres-height)*vinfo.xres;
1508 + current->pixels = (void *)((int )mapped_mem+fb_offset);
1509 + _this->UpdateRects = QT_DirectUpdate;
1511 + qimage = new QImage(current->w, current->h, bpp);
1512 + if (qimage->isNull()) {
1513 + SDL_SetError("Couldn't create screen bitmap");
1517 + current->pixels = (void *)qimage->bits();
1518 + _this->UpdateRects = QT_NormalUpdate;
1519 + SDL_Win->setImage(qimage);
1520 +// SDL_Win->setFullscreen(true); //comment to non update taskbar
1523 + qimage = new QImage(current->w, current->h, bpp);
1524 + if (qimage->isNull()) {
1525 + SDL_SetError("Couldn't create screen bitmap");
1529 + current->pitch = qimage->bytesPerLine();
1530 + current->pixels = (void *)qimage->bits();
1531 + _this->UpdateRects = QT_NormalUpdate;
1532 + SDL_Win->setImage(qimage);
1533 +// SDL_Win->setFullscreen(true); //comment to non update taskbar
1536 - current->pitch = qimage->bytesPerLine();
1537 - current->pixels = (void *)qimage->bits();
1538 - SDL_Win->setImage(qimage);
1539 - _this->UpdateRects = QT_NormalUpdate;
1540 - SDL_Win->setFullscreen(true);
1543 + // fprintf(stderr,"QT_SetVideoMode() qImage:%dx%d %d\n",
1544 + // qimage->width(), qimage->height(), qimage->bytesPerLine());
1548 @@ -361,13 +864,19 @@
1550 if(SDL_Win->lockScreen()) {
1551 for(int i=0; i<numrects; ++i ) {
1552 - QRect rect(rects[i].x, rects[i].y,
1553 - rects[i].w, rects[i].h);
1554 - SDL_Win->repaintRect(rect);
1555 + QRect rect(rects[i].x, rects[i].y,
1556 + rects[i].w, rects[i].h);
1557 + SDL_Win->repaintRect(rect);
1559 SDL_Win->unlockScreen();
1563 + static void QT_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
1568 /* Is the system palette settable? */
1569 int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
1571 @@ -383,10 +892,36 @@
1576 + if ( console_fd > 0 ) {
1577 + /* Restore the original video mode and palette */
1578 + if (fb_hwrot == 1) {
1579 + int tmp_ioctl_data=120;
1580 + ioctl(console_fd, W100FB_CONFIG_EX, &tmp_ioctl_data);
1583 + ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo);
1585 + /* We're all done with the framebuffer */
1586 + close(console_fd);
1590 _this->screen->pixels = NULL;
1591 QT_GrabInput(_this, SDL_GRAB_OFF);
1594 + QCopEnvelope e("QPE/KeyHelper", "repeater(int)");
1599 + system("qcop QPE/KeyHelper \"reload()\""); //QcopEnvelope can't use.
1605 static int QT_IconifyWindow(_THIS) {
1608 Index: SDL-1.2.7/src/video/fbcon/SDL_fbvideo.c
1609 ===================================================================
1610 --- SDL-1.2.7.orig/src/video/fbcon/SDL_fbvideo.c 2005-03-02 22:24:43.458491481 +0100
1611 +++ SDL-1.2.7/src/video/fbcon/SDL_fbvideo.c 2005-03-02 22:24:46.875008802 +0100
1613 #include "SDL_fbmatrox.h"
1614 #include "SDL_fbriva.h"
1617 +/* #define FBCON_DEBUG 1 */
1618 #if defined(i386) && defined(FB_TYPE_VGA_PLANES)
1619 #define VGA16_FBCON_SUPPORT
1620 #ifndef FB_AUX_VGA_PLANES_VGA4
1622 { 0, 0, 720, 576 }, /* PAL */
1623 { 0, 0, 720, 480 }, /* NTSC */
1624 { 0, 0, 640, 480 }, /* 16 bpp: 0x111, or 273 */
1625 + { 0, 0, 480, 640 },
1626 { 0, 0, 640, 400 }, /* 8 bpp: 0x100, or 256 */
1629 + { 0, 0, 240, 320 },
1632 static const struct {
1633 @@ -112,9 +114,11 @@
1635 { 320, 200, 79440, 16, 16, 20, 4, 48, 1, 0, 2 }, /* 70 Hz */
1636 { 320, 240, 63492, 16, 16, 16, 4, 48, 2, 0, 2 }, /* 72 Hz */
1637 + { 240, 320, 63492, 16, 16, 16, 4, 48, 3, 0, 2 }, /* 72 Hz */
1638 { 512, 384, 49603, 48, 16, 16, 1, 64, 3, 0, 0 }, /* 78 Hz */
1639 { 640, 400, 31746, 96, 32, 41, 1, 64, 3, 2, 0 }, /* 85 Hz */
1640 { 640, 480, 31746, 120, 16, 16, 1, 64, 3, 0, 0 }, /* 75 Hz */
1641 + { 480, 640, 31746, 120, 16, 16, 1, 64, 4, 0, 0 }, /* 75 Hz */
1642 { 768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0 }, /* 60 Hz */
1643 { 800, 600, 20000, 64, 56, 23, 37, 120, 6, 3, 0 }, /* 72 Hz */
1644 { 960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0 }, /* 60 Hz */
1645 @@ -152,6 +156,10 @@
1646 struct fb_var_screeninfo *vinfo);
1647 static void FB_RestorePalette(_THIS);
1649 +static char *console_fd_buf;
1650 +static char *mapped_mem_fb;
1651 +static int rotation_flag;
1653 /* FB driver bootstrap functions */
1655 static int FB_Available(void)
1656 @@ -241,18 +249,30 @@
1659 vinfo->bits_per_pixel = (index+1)*8;
1661 - vinfo->xres_virtual = *w;
1663 - vinfo->yres_virtual = *h;
1664 + if ((rotation_flag == 0) || (rotation_flag == 2)) {
1666 + vinfo->xres_virtual = *w;
1668 + vinfo->yres_virtual = *h;
1671 + vinfo->xres_virtual = *h;
1673 + vinfo->yres_virtual = *w;
1675 vinfo->activate = FB_ACTIVATE_TEST;
1676 if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0 ) {
1678 fprintf(stderr, "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n", *w, *h, (index+1)*8, vinfo->xres, vinfo->yres, vinfo->bits_per_pixel);
1680 if ( (((vinfo->bits_per_pixel+7)/8)-1) == index ) {
1683 + if ((rotation_flag == 0) || (rotation_flag == 2)) {
1694 unsigned int current_w;
1695 unsigned int current_h;
1696 const char *SDL_fbdev;
1697 + const char *SDL_rot_flag;
1699 /* Initialize the library */
1700 SDL_fbdev = getenv("SDL_FBDEV");
1701 @@ -344,6 +365,14 @@
1705 + SDL_rot_flag = getenv("SDL_FBROT");
1706 + if ( SDL_rot_flag == NULL ) {
1707 + rotation_flag = 0;
1709 + rotation_flag = atoi(SDL_rot_flag);
1713 #ifndef DISABLE_THREADS
1714 /* Create the hardware surface lock mutex */
1715 hw_lock = SDL_CreateMutex();
1716 @@ -407,13 +436,33 @@
1717 mapped_offset = (((long)finfo.smem_start) -
1718 (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
1719 mapped_memlen = finfo.smem_len+mapped_offset;
1720 - mapped_mem = mmap(NULL, mapped_memlen,
1721 - PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
1722 - if ( mapped_mem == (char *)-1 ) {
1723 - SDL_SetError("Unable to memory map the video hardware");
1724 - mapped_mem = NULL;
1725 - FB_VideoQuit(this);
1727 + if (rotation_flag == 0) {
1728 + mapped_mem = mmap(NULL, mapped_memlen,
1729 + PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
1730 + if ( mapped_mem == (char *)-1 ) {
1731 + SDL_SetError("Unable to memory map the video hardware");
1732 + mapped_mem = NULL;
1733 + FB_VideoQuit(this);
1738 + console_fd_buf = (char *)malloc(640*480*2);
1740 + if (console_fd_buf == NULL){
1741 + SDL_SetError("Unable to memory for buffer");
1745 + mapped_mem_fb = mmap(NULL, mapped_memlen,
1746 + PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
1747 + if ( mapped_mem_fb == (char *)-1 ) {
1748 + SDL_SetError("Unable to memory map the video hardware");
1749 + mapped_mem_fb = NULL;
1750 + FB_VideoQuit(this);
1753 + mapped_mem = console_fd_buf;
1756 /* Determine the current screen depth */
1759 /* Various screen update functions available */
1760 static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
1761 +static void FB_RotationUpdate(_THIS, int numrects, SDL_Rect *rects);
1762 #ifdef VGA16_FBCON_SUPPORT
1763 static void FB_VGA16Update(_THIS, int numrects, SDL_Rect *rects);
1771 /* Set the terminal into graphics mode */
1772 if ( FB_EnterGraphicsMode(this) < 0 ) {
1775 /* Restore the original palette */
1776 FB_RestorePalette(this);
1778 + flags &= ~SDL_DOUBLEBUF;
1780 /* Set the video mode and get the final screen format */
1781 if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
1782 SDL_SetError("Couldn't get console screen info");
1783 @@ -748,13 +800,24 @@
1784 vinfo.activate = FB_ACTIVATE_NOW;
1785 vinfo.accel_flags = 0;
1786 vinfo.bits_per_pixel = bpp;
1787 - vinfo.xres = width;
1788 - vinfo.xres_virtual = width;
1789 - vinfo.yres = height;
1790 - if ( flags & SDL_DOUBLEBUF ) {
1791 - vinfo.yres_virtual = height*2;
1792 + if ((rotation_flag == 0) || (rotation_flag == 2)) {
1793 + vinfo.xres = width;
1794 + vinfo.xres_virtual = width;
1795 + vinfo.yres = height;
1796 + if ( flags & SDL_DOUBLEBUF ) {
1797 + vinfo.yres_virtual = height*2;
1799 + vinfo.yres_virtual = height;
1802 - vinfo.yres_virtual = height;
1803 + vinfo.xres = height;
1804 + vinfo.xres_virtual = height;
1805 + vinfo.yres = width;
1806 + if ( flags & SDL_DOUBLEBUF ) {
1807 + vinfo.yres_virtual = width*2;
1809 + vinfo.yres_virtual = width;
1814 @@ -776,6 +839,15 @@
1818 + vinfo.xres = width;
1819 + vinfo.xres_virtual = width;
1820 + vinfo.yres = height;
1821 + if ( flags & SDL_DOUBLEBUF ) {
1822 + vinfo.yres_virtual = height*2;
1824 + vinfo.yres_virtual = height;
1831 SDL_SetError("Couldn't get console hardware info");
1836 + print_finfo(&finfo);
1838 /* Save hardware palette, if needed */
1839 FB_SavePalette(this, &finfo, &vinfo);
1841 @@ -829,7 +903,11 @@
1842 current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
1843 current->w = vinfo.xres;
1844 current->h = vinfo.yres;
1845 - current->pitch = finfo.line_length;
1846 + if ((rotation_flag == 0) || (rotation_flag == 2) ) {
1847 + current->pitch = finfo.line_length;
1849 + current->pitch = vinfo.xres*2;
1851 current->pixels = mapped_mem+mapped_offset;
1853 /* Set up the information for hardware surfaces */
1857 /* Set the update rectangle function */
1858 - this->UpdateRects = FB_DirectUpdate;
1859 + this->UpdateRects = FB_RotationUpdate;
1863 @@ -1123,6 +1201,89 @@
1867 +static void FB_RotationUpdate(_THIS, int numrects, SDL_Rect *rects)
1869 + unsigned short *pDst;
1870 + unsigned short *pSrc;
1871 + unsigned int width;
1872 + unsigned int height;
1873 + unsigned int srcYAdd;
1874 + unsigned int dstXAdd;
1875 + unsigned int dstYSub;
1877 + unsigned int dstH;
1878 + unsigned int dstW;
1881 + fprintf(stderr,"rotation_flag = %d \n",rotation_flag);
1883 + switch (rotation_flag) {
1887 + memcpy(mapped_mem_fb,mapped_mem,640*480*2);
1890 + memcpy(mapped_mem_fb,mapped_mem,640*480*2);
1893 + dstW=cache_vinfo.xres;
1894 + dstH=cache_vinfo.yres;
1896 + fprintf(stderr,"dstH = %d : dstW = %d : rects->x = %d : rects->y = %d\n",dstH,dstW);
1897 + fprintf(stderr,"rects->x = %d : rects->y = %d : rects->w = %d : rects->h = %d\n",rects->x,rects->y,rects->w,rects->h);
1899 + while (numrects) {
1900 + if (rects->w != dstW || rects->h != dstH) {
1901 + pSrc = mapped_mem + (rects->x + rects->y * dstW)*2;
1902 + pDst = mapped_mem_fb + (dstH-1+rects->x * dstH - rects->y)*2;
1905 + height = rects->h;
1907 + srcYAdd = dstW - rects->w;
1909 + dstYSub = (dstH * rects->w) + 1;
1911 + while (height--) {
1922 + pDst=mapped_mem_fb+dstH*2-2;
1927 + dstYSub=dstW*dstH+1;
1929 + while (height--) {
1950 #ifdef VGA16_FBCON_SUPPORT
1951 /* Code adapted with thanks from the XFree86 VGA16 driver! :) */
1952 #define writeGr(index, value) \
1953 Index: SDL-1.2.7/src/video/fbcon/SDL_fbevents.c
1954 ===================================================================
1955 --- SDL-1.2.7.orig/src/video/fbcon/SDL_fbevents.c 2005-03-02 22:24:43.458491481 +0100
1956 +++ SDL-1.2.7/src/video/fbcon/SDL_fbevents.c 2005-03-02 22:24:46.876008660 +0100
1958 #ifndef GPM_NODE_FIFO
1959 #define GPM_NODE_FIFO "/dev/gpmdata"
1961 +#define POINTERCAL "/etc/pointercal"
1963 +static struct SDL_cal {
1965 + long a, b, c, d, e, f, s;
1969 /* The translation tables from a console scancode to a SDL keysym */
1970 #define NUM_VGAKEYMAPS (1<<KG_CAPSSHIFT)
1977 } mouse_drv = MOUSE_NONE;
1980 mousedev = getenv("SDL_MOUSEDEV");
1983 + const char *sdl_rot_flag;
1984 + sdl_rot_flag = getenv("SDL_FBROT");
1986 /* ELO TOUCHSCREEN SUPPORT */
1988 if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) {
1989 @@ -601,9 +611,39 @@
1990 mouse_drv = MOUSE_MS;
1993 + /* Default to a SLC7X0 touch screen */
1994 + if ( mouse_fd < 0 ) {
1995 + mousedev = "/dev/ts";
1996 + mouse_fd = open(mousedev, O_RDONLY, 0);
1997 + if ( mouse_fd >= 0 ) {
2000 + pcal = fopen(POINTERCAL, "r");
2002 + fprintf(stderr, "Warning: cannot open " POINTERCAL ".\n");
2005 + n = fscanf(pcal, "%d %d %d %d %d %d %d",
2006 + &cal.a, &cal.b, &cal.c, &cal.d, &cal.e, &cal.f, &cal.s);
2008 + fprintf(stderr, "Warning: " POINTERCAL " is unknown format.\n");
2014 + if ( sdl_rot_flag == NULL ) {
2017 + cal.rotate = atoi(sdl_rot_flag);
2019 + mouse_drv = TS_SLC7X0;
2022 if ( mouse_fd < 0 ) {
2023 mouse_drv = MOUSE_NONE;
2029 @@ -678,6 +718,10 @@
2030 packetsize = ELO_PACKET_SIZE;
2037 case NUM_MOUSE_DRVS:
2040 @@ -810,6 +854,25 @@
2045 + /* Get current mouse state */
2046 + button = ((mousebuf[i+1] << 8)+mousebuf[i])/500;
2047 + dx = (mousebuf[i+3] << 8)+mousebuf[i+2];
2048 + dy = (mousebuf[i+5] << 8)+mousebuf[i+4];
2051 + X = (cal.a * dx + cal.b * dy + cal.c) / cal.s;
2052 + Y = (cal.d * dx + cal.e * dy + cal.f) / cal.s;
2056 + if(cal.rotate == 3){
2063 case NUM_MOUSE_DRVS: