src/video/win32_v.cpp
changeset 5758 4b10d28b54c7
parent 5587 167d9a91ef02
child 5759 213aacbe7b07
equal deleted inserted replaced
5757:04e5be1f7d71 5758:4b10d28b54c7
   349 
   349 
   350 		case WM_KEYDOWN: {
   350 		case WM_KEYDOWN: {
   351 			// this is the rewritten ascii input function
   351 			// this is the rewritten ascii input function
   352 			// it disables windows deadkey handling --> more linux like :D
   352 			// it disables windows deadkey handling --> more linux like :D
   353 			wchar_t w = 0;
   353 			wchar_t w = 0;
       
   354 #if !defined(WINCE)
   354 			byte ks[256];
   355 			byte ks[256];
       
   356 #endif
   355 			uint scancode;
   357 			uint scancode;
   356 			uint32 pressed_key;
   358 			uint32 pressed_key;
   357 
   359 
       
   360 #if defined(WINCE)
       
   361 			/* On WinCE GetKeyboardState isn't supported */
       
   362 			w = wParam;
       
   363 #else
   358 			GetKeyboardState(ks);
   364 			GetKeyboardState(ks);
   359 			if (ToUnicode(wParam, 0, ks, &w, 1, 0) != 1) {
   365 			if (ToUnicode(wParam, 0, ks, &w, 1, 0) != 1) {
   360 				/* On win9x ToUnicode always fails, so fall back to ToAscii */
   366 				/* On win9x ToUnicode always fails, so fall back to ToAscii */
   361 				if (ToAscii(wParam, 0, ks, (LPWORD)&w, 0) != 1) w = 0; // no translation was possible
   367 				if (ToAscii(wParam, 0, ks, (LPWORD)&w, 0) != 1) w = 0; // no translation was possible
   362 			}
   368 			}
       
   369 #endif
   363 
   370 
   364 			pressed_key = w | MapWindowsKey(wParam) << 16;
   371 			pressed_key = w | MapWindowsKey(wParam) << 16;
   365 
   372 
   366 			scancode = GB(lParam, 16, 8);
   373 			scancode = GB(lParam, 16, 8);
   367 			if (scancode == 41) pressed_key = w | WKC_BACKQUOTE << 16;
   374 			if (scancode == 41) pressed_key = w | WKC_BACKQUOTE << 16;
   407 				}
   414 				}
   408 				ClientSizeChanged(LOWORD(lParam), HIWORD(lParam));
   415 				ClientSizeChanged(LOWORD(lParam), HIWORD(lParam));
   409 			}
   416 			}
   410 			return 0;
   417 			return 0;
   411 
   418 
       
   419 #if !defined(WINCE)
   412 		case WM_SIZING: {
   420 		case WM_SIZING: {
   413 			RECT* r = (RECT*)lParam;
   421 			RECT* r = (RECT*)lParam;
   414 			RECT r2;
   422 			RECT r2;
   415 			int w, h;
   423 			int w, h;
   416 
   424 
   470 				case WMSZ_TOPRIGHT:
   478 				case WMSZ_TOPRIGHT:
   471 					r->top = r->bottom - h;
   479 					r->top = r->bottom - h;
   472 					r->right = r->left + w;
   480 					r->right = r->left + w;
   473 					break;
   481 					break;
   474 			}
   482 			}
       
   483 #endif
   475 			return TRUE;
   484 			return TRUE;
   476 		}
   485 		}
   477 
   486 
   478 // needed for wheel
   487 // needed for wheel
   479 #if !defined(WM_MOUSEWHEEL)
   488 #if !defined(WM_MOUSEWHEEL)
   536 	if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) {
   545 	if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) {
   537 		DestroyWindow(_wnd.main_wnd);
   546 		DestroyWindow(_wnd.main_wnd);
   538 		_wnd.main_wnd = 0;
   547 		_wnd.main_wnd = 0;
   539 	}
   548 	}
   540 
   549 
       
   550 #if defined(WINCE)
       
   551 	/* WinCE is always fullscreen */
       
   552 #else
   541 	if (full_screen) {
   553 	if (full_screen) {
   542 		DEVMODE settings;
   554 		DEVMODE settings;
   543 
   555 
   544 		memset(&settings, 0, sizeof(settings));
   556 		memset(&settings, 0, sizeof(settings));
   545 		settings.dmSize = sizeof(settings);
   557 		settings.dmSize = sizeof(settings);
   559 		}
   571 		}
   560 	} else if (_wnd.fullscreen) {
   572 	} else if (_wnd.fullscreen) {
   561 		// restore display?
   573 		// restore display?
   562 		ChangeDisplaySettings(NULL, 0);
   574 		ChangeDisplaySettings(NULL, 0);
   563 	}
   575 	}
       
   576 #endif
   564 
   577 
   565 	{
   578 	{
   566 		RECT r;
   579 		RECT r;
   567 		DWORD style, showstyle;
   580 		DWORD style, showstyle;
   568 		int x, y, w, h;
   581 		int x, y, w, h;
   577 			/* On window creation, check if we were in maximize mode before */
   590 			/* On window creation, check if we were in maximize mode before */
   578 			if (_window_maximize) showstyle = SW_SHOWMAXIMIZED;
   591 			if (_window_maximize) showstyle = SW_SHOWMAXIMIZED;
   579 			SetRect(&r, 0, 0, _wnd.width, _wnd.height);
   592 			SetRect(&r, 0, 0, _wnd.width, _wnd.height);
   580 		}
   593 		}
   581 
   594 
       
   595 #if !defined(WINCE)
   582 		AdjustWindowRect(&r, style, FALSE);
   596 		AdjustWindowRect(&r, style, FALSE);
       
   597 #endif
   583 		w = r.right - r.left;
   598 		w = r.right - r.left;
   584 		h = r.bottom - r.top;
   599 		h = r.bottom - r.top;
   585 		x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
   600 		x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
   586 		y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
   601 		y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
   587 
   602 
   667 };
   682 };
   668 
   683 
   669 static void FindResolutions(void)
   684 static void FindResolutions(void)
   670 {
   685 {
   671 	uint n = 0;
   686 	uint n = 0;
       
   687 #if defined(WINCE)
       
   688 	/* EnumDisplaySettingsW is only supported in CE 4.2+ */
       
   689 	/* XXX -- One might argue that we assume 4.2+ on every system. Then we can use this function safely */
       
   690 #else
   672 	uint i;
   691 	uint i;
   673 	DEVMODEA dm;
   692 	DEVMODEA dm;
   674 
   693 
   675 	/* XXX - EnumDisplaySettingsW crashes with unicows.dll on Windows95
   694 	/* XXX - EnumDisplaySettingsW crashes with unicows.dll on Windows95
   676 	 * Doesn't really matter since we don't pass a string anyways, but still
   695 	 * Doesn't really matter since we don't pass a string anyways, but still
   693 				_resolutions[j][1] = dm.dmPelsHeight;
   712 				_resolutions[j][1] = dm.dmPelsHeight;
   694 				if (++n == lengthof(_resolutions)) break;
   713 				if (++n == lengthof(_resolutions)) break;
   695 			}
   714 			}
   696 		}
   715 		}
   697 	}
   716 	}
       
   717 #endif
   698 
   718 
   699 	/* We have found no resolutions, show the default list */
   719 	/* We have found no resolutions, show the default list */
   700 	if (n == 0) {
   720 	if (n == 0) {
   701 		memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
   721 		memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
   702 		n = lengthof(default_resolutions);
   722 		n = lengthof(default_resolutions);
   733 {
   753 {
   734 	DeleteObject(_wnd.gdi_palette);
   754 	DeleteObject(_wnd.gdi_palette);
   735 	DeleteObject(_wnd.dib_sect);
   755 	DeleteObject(_wnd.dib_sect);
   736 	DestroyWindow(_wnd.main_wnd);
   756 	DestroyWindow(_wnd.main_wnd);
   737 
   757 
       
   758 #if !defined(WINCE)
   738 	if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);
   759 	if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);
       
   760 #endif
   739 	if (_double_size) {
   761 	if (_double_size) {
   740 		_cur_resolution[0] *= 2;
   762 		_cur_resolution[0] *= 2;
   741 		_cur_resolution[1] *= 2;
   763 		_cur_resolution[1] *= 2;
   742 	}
   764 	}
   743 
   765 
   835 			GameLoop();
   857 			GameLoop();
   836 			_cursor.delta.x = _cursor.delta.y = 0;
   858 			_cursor.delta.x = _cursor.delta.y = 0;
   837 
   859 
   838 			if (_force_full_redraw) MarkWholeScreenDirty();
   860 			if (_force_full_redraw) MarkWholeScreenDirty();
   839 
   861 
       
   862 #if !defined(WINCE)
   840 			GdiFlush();
   863 			GdiFlush();
       
   864 #endif
   841 			_screen.dst_ptr = _wnd.buffer_bits;
   865 			_screen.dst_ptr = _wnd.buffer_bits;
   842 			UpdateWindows();
   866 			UpdateWindows();
   843 			CheckPaletteAnim();
   867 			CheckPaletteAnim();
   844 		} else {
   868 		} else {
   845 			Sleep(1);
   869 			Sleep(1);
       
   870 #if !defined(WINCE)
   846 			GdiFlush();
   871 			GdiFlush();
       
   872 #endif
   847 			_screen.dst_ptr = _wnd.buffer_bits;
   873 			_screen.dst_ptr = _wnd.buffer_bits;
   848 			DrawTextMessage();
   874 			DrawTextMessage();
   849 			DrawMouseCursor();
   875 			DrawMouseCursor();
   850 		}
   876 		}
   851 	}
   877 	}