mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 17:17:09 -04:00
Init XInput2 and register for RawMotion event.
Still working on actually using the event though
This commit is contained in:
parent
6c5285e457
commit
b9a0729694
@ -62,14 +62,14 @@ build_nix32() {
|
||||
echo "Building linux32.."
|
||||
cp $SOURCE_DIR/misc/CCicon_nix32 $SOURCE_DIR/src/CCicon_nix32.o
|
||||
rm cc-nix32
|
||||
gcc *.c $ALL_FLAGS $LINUX_FLAGS CCicon_nix32.o -DCC_COMMIT_SHA=\"$LATEST\" -m32 -o cc-nix32 -lX11 -lpthread -lGL -lm -lcurl -lopenal -ldl
|
||||
gcc *.c $ALL_FLAGS $LINUX_FLAGS CCicon_nix32.o -DCC_COMMIT_SHA=\"$LATEST\" -m32 -o cc-nix32 -lX11 -lXi -lpthread -lGL -lm -lcurl -lopenal -ldl
|
||||
}
|
||||
|
||||
build_nix64() {
|
||||
echo "Building linux64.."
|
||||
cp $SOURCE_DIR/misc/CCicon_nix64 $SOURCE_DIR/src/CCicon_nix64.o
|
||||
rm cc-nix64
|
||||
gcc *.c $ALL_FLAGS $LINUX_FLAGS CCicon_nix64.o -DCC_COMMIT_SHA=\"$LATEST\" -m64 -o cc-nix64 -lX11 -lpthread -lGL -lm -lcurl -lopenal -ldl
|
||||
gcc *.c $ALL_FLAGS $LINUX_FLAGS CCicon_nix64.o -DCC_COMMIT_SHA=\"$LATEST\" -m64 -o cc-nix64 -lX11 -lXi -lpthread -lGL -lm -lcurl -lopenal -ldl
|
||||
}
|
||||
|
||||
build_osx32() {
|
||||
@ -101,7 +101,7 @@ build_rpi() {
|
||||
echo "Building rpi.."
|
||||
cp $SOURCE_DIR/misc/CCicon_rpi $SOURCE_DIR/src/CCicon_rpi.o
|
||||
rm cc-rpi
|
||||
$RPI_CC *.c $ALL_FLAGS $LINUX_FLAGS CCicon_rpi.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-rpi -DCC_BUILD_RPI -I ~/rpi/include -L ~/rpi/lib -lGLESv2 -lEGL -lX11 -lcurl -lopenal -lm -lpthread -ldl -lrt -Wl,-rpath-link ~/rpi/lib
|
||||
$RPI_CC *.c $ALL_FLAGS $LINUX_FLAGS CCicon_rpi.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-rpi -DCC_BUILD_RPI -I ~/rpi/include -L ~/rpi/lib -lGLESv2 -lEGL -lX11 -lXi -lcurl -lopenal -lm -lpthread -ldl -lrt -Wl,-rpath-link ~/rpi/lib
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
|
10
readme.md
10
readme.md
@ -57,7 +57,7 @@ I am assuming you used the installer from http://www.mingw.org/
|
||||
|
||||
Install appropriate libs as required. For ubuntu these are: libx11-dev, libgl1-mesa-dev, libopenal-dev, libcurl4-gnutls-dev or libcurl4-openssl-dev
|
||||
|
||||
```gcc *.c -o ClassiCube -lm -lpthread -lX11 -lGL -lcurl -lopenal -ldl```
|
||||
```gcc *.c -o ClassiCube -lm -lpthread -lX11 -lXi -lGL -lcurl -lopenal -ldl```
|
||||
|
||||
##### Cross compiling for windows:
|
||||
|
||||
@ -78,21 +78,21 @@ Although the regular linux compiliation flags will work fine, to take full advan
|
||||
|
||||
#### FreeBSD
|
||||
|
||||
```clang *.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lGL -lcurl -lopenal -lexecinfo```
|
||||
```clang *.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lcurl -lopenal -lexecinfo```
|
||||
|
||||
#### OpenBSD
|
||||
|
||||
Install libexecinfo package if needed.
|
||||
|
||||
```gcc *.c -o ClassiCube -I /usr/X11R6/include -I /usr/local/include -L /usr/X11R6/lib -L /usr/local/lib -lX11 -lGL -lcurl -lopenal -lexecinfo```
|
||||
```gcc *.c -o ClassiCube -I /usr/X11R6/include -I /usr/local/include -L /usr/X11R6/lib -L /usr/local/lib -lX11 -lXi -lGL -lcurl -lopenal -lexecinfo```
|
||||
|
||||
#### NetBSD
|
||||
|
||||
```gcc *.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lpthread -lX11 -lGL -lcurl -lopenal -lexecinfo```
|
||||
```gcc *.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lpthread -lX11 -lXi -lGL -lcurl -lopenal -lexecinfo```
|
||||
|
||||
#### Solaris
|
||||
|
||||
```gcc *.c -o ClassiCube -lm -lsocket -lX11 -lGL -lcurl -lopenal```
|
||||
```gcc *.c -o ClassiCube -lm -lsocket -lX11 -lXi -lGL -lcurl -lopenal```
|
||||
|
||||
NOTE: You have to change entry->d_type == DT_DIR to Directory_Exists(&path) (TODO do this automatically)
|
||||
|
||||
|
10
src/Makefile
10
src/Makefile
@ -30,11 +30,11 @@ LIBS=-mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),linux)
|
||||
LIBS=-lX11 -lpthread -lGL -lm -lopenal -ldl -lcurl
|
||||
LIBS=-lX11 -lXi -lpthread -lGL -lm -lopenal -ldl -lcurl
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),sunos)
|
||||
LIBS=-lm -lsocket -lX11 -lGL -lcurl -lopenal
|
||||
LIBS=-lm -lsocket -lX11 -lXi -lGL -lcurl -lopenal
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),darwin)
|
||||
@ -46,19 +46,19 @@ ifeq ($(PLAT),freebsd)
|
||||
CC=clang
|
||||
CFLAGS=-g -pipe -rdynamic -I /usr/local/include -fno-math-errno
|
||||
LDFLAGS=-L /usr/local/lib
|
||||
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11 -lm -lpthread
|
||||
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11 -lXi -lm -lpthread
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),openbsd)
|
||||
CFLAGS=-g -pipe -rdynamic -I /usr/X11R6/include -I /usr/local/include -fno-math-errno
|
||||
LDFLAGS=-L /usr/X11R6/lib -L /usr/local/lib
|
||||
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11
|
||||
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11 -lXi
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),netbsd)
|
||||
CFLAGS=-g -pipe -rdynamic -I /usr/X11R7/include -I /usr/pkg/include -fno-math-errno
|
||||
LDFLAGS=-L /usr/X11R7/lib -L /usr/pkg/lib
|
||||
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11
|
||||
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11 -lXi
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),haiku)
|
||||
|
51
src/Window.c
51
src/Window.c
@ -1331,7 +1331,10 @@ static Atom Window_GetSelectionProperty(XEvent* e) {
|
||||
}
|
||||
|
||||
static Bool FilterEvent(Display* d, XEvent* e, XPointer w) {
|
||||
return e->xany.window == (Window)w;
|
||||
return
|
||||
e->xany.window == (Window)w ||
|
||||
!e->xany.window || /* KeymapNotify events don't have a window */
|
||||
e->type == GenericEvent; /* For XInput events */
|
||||
}
|
||||
|
||||
static void HandleWMDestroy(void) {
|
||||
@ -1349,6 +1352,7 @@ static void HandleWMPing(XEvent* e) {
|
||||
XSendEvent(win_display, win_rootWin, false,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask, e);
|
||||
}
|
||||
static void HandleGenericEvent(XEvent* e);
|
||||
|
||||
void Window_ProcessEvents(void) {
|
||||
XEvent e;
|
||||
@ -1356,6 +1360,8 @@ void Window_ProcessEvents(void) {
|
||||
if (!XCheckIfEvent(win_display, &e, FilterEvent, (XPointer)win_handle)) break;
|
||||
|
||||
switch (e.type) {
|
||||
case GenericEvent:
|
||||
HandleGenericEvent(&e); break;
|
||||
case ClientMessage:
|
||||
if (e.xclient.data.l[0] == wm_destroy) {
|
||||
HandleWMDestroy();
|
||||
@ -1803,7 +1809,48 @@ void Window_FreeFramebuffer(Bitmap* bmp) {
|
||||
void Window_OpenKeyboard(void) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
void Window_EnableRawMouse(void) { DefaultEnableRawMouse(); }
|
||||
|
||||
static cc_bool rawMouseInited, rawMouseSupported;
|
||||
static int xiOpcode;
|
||||
|
||||
static void HandleGenericEvent(XEvent* e) {
|
||||
Platform_Log1("OK.. %i", &xiOpcode);
|
||||
if (!rawMouseSupported || e->xcookie.extension != xiOpcode) return;
|
||||
if (!XGetEventData(win_display, &e->xcookie)) return;
|
||||
Platform_Log1("RAW MOUSE EVENT: %i", &e->xcookie.evtype);
|
||||
}
|
||||
|
||||
static void InitRawMouse(void) {
|
||||
XIEventMask evmask;
|
||||
unsigned char masks[(XI_LASTEVENT + 7)/8] = { 0 };
|
||||
int ev, err, major, minor;
|
||||
|
||||
if (!XQueryExtension(win_display, "XInputExtension", &xiOpcode, &ev, &err)) {
|
||||
Platform_LogConst("XInput unsupported");
|
||||
return;
|
||||
}
|
||||
|
||||
major = 2; minor = 0;
|
||||
if (XIQueryVersion(win_display, &major, &minor) != Success) {
|
||||
Platform_Log2("Only XInput %i.%i supported", &major, &minor);
|
||||
return;
|
||||
}
|
||||
|
||||
XISetMask(masks, XI_RawMotion);
|
||||
evmask.deviceid = XIAllMasterDevices;
|
||||
evmask.mask_len = sizeof(masks);
|
||||
evmask.mask = masks;
|
||||
|
||||
XISelectEvents(win_display, win_rootWin, &evmask, 1);
|
||||
rawMouseSupported = true;
|
||||
}
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
DefaultEnableRawMouse();
|
||||
if (!rawMouseInited) InitRawMouse();
|
||||
rawMouseInited = true;
|
||||
}
|
||||
|
||||
void Window_UpdateRawMouse(void) { DefaultUpdateRawMouse(); }
|
||||
void Window_DisableRawMouse(void) { DefaultDisableRawMouse(); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user