mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-22 21:09:34 -10:00
"win32": the keyboard and the mouse from the window and the oldest calls of the Windows API. Raw input needs Windows XP and DirectInput 8 needs DirectX 8; a build for Windows 95 or NT 4.0 had neither, so it had the null input driver and could not be given a key. - Keys. The window procedure sees every key go down and come up and already turns each into a scancode for the key events it sends. It tells this driver the same (win32_input_key_message(), one call where the scancode is worked out): a bit a scancode. The window can be the video thread's, so the bits are atomic words - set and cleared there, loaded at the poll - and nothing is locked. The frontend asks for the keys it has binds for once a poll (keys_down), as it does of the other keyboard drivers. - Its key map (rarch_key_map_win32) is DirectInput's in numbers: scancodes, the extended keys with 0x80 added. No DirectX header. - Mouse. Where the cursor is in the window at each poll, and its left, right and middle buttons (GetAsyncKeyState(), the two swapped where the user has them swapped), published for the frontend to answer the mouse, the pointer and the lightgun from. - Only while the window is the foreground one. Without it nothing is down, and a key held when the window lost the foreground is not down when it has it back. What it does not have: a wheel, buttons four and five, motion past the screen's edge (motion is how far the cursor went), a grab. And no controllers - that is a joypad driver's, and the one for these Windows, the multimedia library's joystick calls, is not written yet. Built where HAVE_WIN32INPUT is defined (HAVE_WIN32INPUT=1), which nothing turns on by default but the Visual C++ 6 project in the commit after this. It is chosen by name, or where neither raw input nor DirectInput is built or starts. Run: the Windows build with it compiled in, under Wine, through the scripted keyboard session - the core sees the same 63 lines with "win32" as with "dinput", and DirectInput's own are the same as before this. samples/input/win32_input runs the driver against a real window under Wine: the key map both ways, keys down and up, an extended key against the keypad key under it, the top bit of a word, nothing down with another window in front, the mouse's place and motion. Not run on a Windows machine, of any age.
27 lines
921 B
Makefile
27 lines
921 B
Makefile
# The plain Win32 input driver against a real window, under Wine.
|
|
# Needs a mingw compiler, wine and an X display (xvfb-run).
|
|
TARGET := win32_input_test.exe
|
|
CC := x86_64-w64-mingw32-gcc
|
|
WINE ?= $(shell command -v wine64 || command -v wine)
|
|
XVFB ?= $(shell command -v xvfb-run >/dev/null 2>&1 && echo "xvfb-run -a")
|
|
|
|
ROOT := ../../..
|
|
CFLAGS += -std=gnu99 -O1 -Wall -Wno-unused-function \
|
|
-DRARCH_INTERNAL -DHAVE_THREADS -DHAVE_WIN32INPUT \
|
|
-I$(ROOT) -I$(ROOT)/libretro-common/include -I$(ROOT)/deps
|
|
|
|
all: $(TARGET)
|
|
|
|
$(TARGET): win32_input_test.c $(ROOT)/input/drivers/win32_input.c $(ROOT)/input/input_keymaps.c
|
|
$(CC) $(CFLAGS) -o $@ win32_input_test.c $(ROOT)/input/input_keymaps.c \
|
|
$(ROOT)/libretro-common/compat/compat_strl.c
|
|
|
|
check: all
|
|
@test -n "$(WINE)" || { echo "no wine" >&2; exit 1; }
|
|
WINEDEBUG=-all $(XVFB) $(WINE) ./$(TARGET)
|
|
|
|
clean:
|
|
rm -f $(TARGET)
|
|
|
|
.PHONY: all check clean
|