Exemple #1
0
func messageCallback(window C.HWND, message C.UINT, w C.WPARAM, l C.LPARAM) C.LRESULT {
	switch message {
	case C.WM_KEYDOWN:
		if !isKeyRepeat(l) {
			switch w {
			case C.VK_LEFT:
				game.HandleInput(InputEvent{GoLeft, true, charIndex})
			case C.VK_RIGHT:
				game.HandleInput(InputEvent{GoRight, true, charIndex})
			case C.VK_UP, C.VK_SPACE:
				game.HandleInput(InputEvent{Jump, true, charIndex})
			case C.VK_ESCAPE:
				game.HandleInput(InputEvent{QuitGame, true, charIndex})
			}
		}
		return 1
	case C.WM_KEYUP:
		switch w {
		case C.VK_LEFT:
			game.HandleInput(InputEvent{GoLeft, false, charIndex})
		case C.VK_RIGHT:
			game.HandleInput(InputEvent{GoRight, false, charIndex})
		case C.VK_UP, C.VK_SPACE:
			game.HandleInput(InputEvent{Jump, false, charIndex})
		case C.VK_F11:
			toggleFullscreen(window)
		case C.VK_ESCAPE:
			game.HandleInput(InputEvent{QuitGame, false, charIndex})
			C.PostQuitMessage(0)
		}
		return 1
	case C.WM_SIZE:
		if camera != nil {
			windowW, windowH = lowWord(uint(l)), highWord(uint(l))
			camera.setWindowSize(windowW, windowH)
		}
		return 1
	case C.WM_DESTROY:
		C.PostQuitMessage(0)
		return 1
	default:
		return C.DefWindowProc(window, message, w, l)
	}
}
Exemple #2
0
func (window *Win32Window) WndProc(hwnd C.HWND, message C.UINT, wParam C.WPARAM, lParam C.LPARAM) C.LRESULT {
	if message == 0x0002 {
		C.PostQuitMessage(0)
		return 0
	}

	if window.Callback != nil {
		if window.Callback(window, uint32(message), uintptr(unsafe.Pointer(&wParam)), uintptr(unsafe.Pointer(&lParam))) == true {
			return 0
		}
	}

	return C.DefWindowProc(hwnd, message, wParam, lParam)
}
Exemple #3
0
func uistop() {
	C.PostQuitMessage(0)
}