Commit graph

227 commits

Author SHA1 Message Date
Daniel Gibson
befe732dbb Fix new[]/delete missmatches and memory leaks found by clang's ASAN
Sometimes memory was allocated with new[] but freed with delete instead
of delete[], which is wrong.
And there were some small memory leaks, too.
Furtunately clang's AddressSanitizer detected all that so I could easily
fix it.

(There seem to be some more small memory leaks which are harder to fix,
though)
2015-12-17 18:11:03 +01:00
Daniel Gibson
df90fce6a5 small improvement for handling up to 8 mouse buttons
as we do int buttonIndex = ev.button.button - SDL_BUTTON_LEFT;
it's only consistent to do if(ev.button.button < SDL_BUTTON_LEFT + 8)

it doesn't really make any difference as long as SDL_BUTTON_LEFT is 1,
but this way it's safe for SDL3 or whatever future version might break
the ABI.
2015-12-13 03:49:29 +01:00
Sébastien Noel
32feff2be1 handle up to 8 buttons with SDL2 based on https://github.com/RobertBeckebans/RBDOOM-3-BFG/pull/213
it's buggy on Linux/X11 before 2.0.4, but it works fine on other platforms
extra bonus: don't generate garbage events for unknown mouse buttons
2015-12-13 03:30:43 +01:00
Daniel Gibson
c5ad45368a Workaround to better support AZERTY keyboards
The first row of AZERTY-Keyboards (used in France and Belgium) doesn't
have numbers as keys but ², &, é, ", ', (, -, è, _, ç, à, ), =
(with small differences between France and Belgium).
For some of those keys we don't have keycodes - and neither does SDL2.
See also https://bugzilla.libsdl.org/show_bug.cgi?id=3188

As a workaround, just map those keys to 1, 2, ..., 9, 0 anyway, as those
are keys Quake2 already knows (and those chars are printed on the keys
too, for typing they're reachable via shift).
This workaround only works for SDL2, as SDL1.2 doesn't have Scancodes
which we need to identify the keys.

This should obsolete one part of pull request #135
2015-11-22 23:21:30 +01:00
Daniel Gibson
4198f92bd5 ignore unknown SDL events
they just spam the console and don't matter anyway.
for example, on OS X you get lots of SDL_FINGER* events that spam
the console.
2015-10-23 18:19:46 +02:00
Daniel Gibson
8f4f1ca39f Get rid of "WARNING: unknown event 770" on Windows
It's an SDL_TEXTEDITING event which we seem to get on Windows whenever
the Window gains focus (or is created). I think it can be safely
ignored, so that's what I do.

I also changed how those warnings are printed - as a hex number now,
because they're defined as hex numbers in the SDL source and it's easier
to find out what kind of event it is this way.
2015-10-05 15:14:42 +02:00
svdijk
dd082b78de Win32: Add an icon to the dhewm3 executable 2015-10-03 09:17:30 +02:00
Daniel Gibson
412dad6758 Sys_GetEvent(): Don't return res_none when more events are available
If res_none (event with .evType == EV_NONE) is returned,
idEventLoop::RunEventLoop() will assume there are no more events this
frame => pending events will be delayed til next frame (or later if
again res_none is returned in the meantime).
So res_none shouldn't be returned just because there was an SDL event
we didn't care about or we did care about but don't generate a doom3
event for (but toggle fullscreen or something).
Instead we should just fetch and handle the next SDL event.
2015-09-30 15:58:50 +02:00
Daniel Gibson
66f7b6aa87 no allocation per SDL_TEXTINPUT event
those event have a max size (SDL_TEXTINPUTEVENT_TEXT_SIZE) so we can
just use a static buffer.
2015-09-30 15:41:14 +02:00
Francisco Magalhães
32afbca7c1 Add support for brazilian keyboard layout 2015-09-30 15:12:10 +02:00
Daniel Gibson
c333a46373 Linux: Fix fallback to look for gamedata in /usr/local/games/doom3/
Before checking there I look for gamedata next to the executable, but
the check was broken: I got the directory the executable is in and
checked if it exists.. well.. of course it does, but that doesn't mean
there's game data in it..
So now I check if that directory actually has a "base/" subdirectory
(or whatever is #defined in BASE_GAMEDIR) and if that fails
/usr/local/games/doom3/ is tried instead.

Thanks chungy for pointing the bug out in #97 !
2015-09-30 15:07:51 +02:00
Daniel Gibson
0327a42ad9 Fix input on Windows with SDL2 (fix #100)
Seems like the ::SetFocus() in main() screwed it up.
2015-09-28 15:35:57 +02:00
Daniel Gibson
5c99ff4657 make "./dhewm3 +set in_tty 0" actually work
the problem was that the CVar was initialized from the commandline
*after* Posix_InitConsoleInput() is called, so it was too late.
common->StartupVariable() seems to be the right way to initialize a
CVar early.
2015-09-27 18:14:06 +02:00
Daniel Gibson
1de6ab0d50 Fix some compiler warnings (wrong types, superfluous checks, printf-fuckup) 2015-09-27 18:12:16 +02:00
Daniel Gibson
555d233867 Window Icon, make in_nograb work with SDL2 2015-03-02 00:03:30 +01:00
hurikhan
2d27c807d1 SDL2 support fix 2013-07-22 23:45:10 +08:00
Rohit Nirmal
c20218f9cd Minor spelling fix. 2013-07-13 23:07:22 -05:00
Kevin Doyon
6407881cff Fix SDL2 compile-errors, made it work on Win64
.. when compiled with MSVC2012
2013-05-02 21:13:06 +02:00
Yamagi Burmeister
9a9babf8d6 Add a new cvar "r_waylandcompat"
Commit 9e158470 set the SDL OpenGL attribut SDL_GL_ALPHA_SIZE to 0 since
the alpha channel is used by Wayland. But for X11 the GLX 1.4 specification
clearly states: "If the requested number of bits in attrib_list for a
particular color component is 0 or GLX_DONT_CARE, then the number of
bits for that component is not considered." So if SDL_GL_ALPHA_SIZE is
0 a framebuffer without an alpha channel is created. This is no problem
on the default GLX module due to a non standard implementation but
manifests with Nvidias GLX module. The consequence are render mistakes
like in game display showing static or the flashlight looking weird.
2012-11-13 23:33:00 +01:00
Daniel Gibson
8c6e4eb38a Add support for norwegian keyboard layout
via "in_kbd norwegian". It's the '|' and '§' chars (124, 167)

Fixes #33
2012-11-13 23:18:45 +01:00
Daniel Gibson
6d9a43cb23 On Linux/Unix, return EXE-path as base-path if BUILD_DATADIR fails
Using this path was the old behavior and is expected by many users.
2012-11-13 23:16:03 +01:00
Daniel Gibson
5936422d9d Fix freezing of dedicated server window on Windows
The code was donated by motorsep, thanks!
2012-11-12 20:18:00 +01:00
Daniel Gibson
105fdb0624 Fix dedicated server for Windows
* the OpenAL function definitions mustn't include __declspec(dllimport)
  => fixed by pretending to compile OpenAL statically
* glimp.cpp shouldn't be used in dedicated-only mode (as it was already
  the case on Linux and OSX)
  => No special handling for ID_DEDICATED needed in glimp.cpp, as it's not
   used anyway
* add APIENTRY to every gl function in stub_gl.cpp for compatibility
  with windows headers and MSVC
* remove GL/gl.h #include from win_local.h as it's not needed
* in qgl.h, when building dedicated server for windows, redefine WINGDIAPI
  to nothing for SDL_opengl.h #include to get rid off __declspec(dllimport)
  by using #pragma push_macro and pop_macro, because our stub is no dll.

Fixes https://github.com/dhewm/dhewm3/issues/39
2012-11-12 20:18:00 +01:00
Daniel Gibson
1f25568762 Remove duplicate functions from openal_stub.cpp + extern C
Some functions were duplicated, the only difference was a const in one
parameter. The definitions in the header were with const, so I kept
those versions.
Also, the functions in the header are pure C, so add extern "C",
this fixes issues with MSVC and the formerly duplicated functions.
2012-11-12 20:15:08 +01:00
Daniel Gibson
fa8f092e67 Unset key modifiers when regaining focus to unset ALT
There used to be a bug (discussed in #40), that ALT was still set after
using ALT-Tab. Thus when next pressing enter fullscreen was toggled.
This should now be fixed by unsetting the modifiers when focus is
regained (SDL_ACTIVEEVENT or SDL_WINDOWEVENT_FOCUS_GAINED).
2012-09-08 16:45:07 +02:00
dhewg
1b1787bb50 Disable the warning if the mouse grab request fails
This fails on some SDL drivers and just spams the console.
2012-07-28 12:54:25 +02:00
dhewg
9e15847083 Don't use alpha bits for the GL config
Wayland actually uses this.
2012-07-28 12:51:02 +02:00
dhewg
89071f1f57 Provide a stub for GLimp_GrabInput()
Fixes compilation of the dedicated server.
2012-07-20 21:04:04 +02:00
dhewg
918e06cf00 Add SDL2 support to sys/osx/DOOMController.mm 2012-07-20 17:41:40 +02:00
dhewg
ed121102f4 Add SDL2 support to sys/win32/SDL_win32_main.c 2012-07-20 17:34:38 +02:00
dhewg
454bebf99f Add SDL2 support in sys/glimp.cpp 2012-07-20 17:34:37 +02:00
dhewg
4f2f855105 Add SDL2 support in sys/events.cpp 2012-07-20 17:34:36 +02:00
dhewg
b8765ccf22 Move GrabInput() and rename to GLimp_GrabInput()
SDL2 supports multiple windows, and the grabbing is set per
window, so move it to sys/glimp.cpp.
2012-07-20 17:34:34 +02:00
dhewg
6dcf07974d Cleanup GrabInput()
Convert to bitflags to ease moving it.
2012-07-20 17:34:34 +02:00
dhewg
a75387c55e Add SDL2 support in sys/threads.cpp 2012-07-20 17:34:33 +02:00
dhewg
5639720c1c Add FindSDL2.cmake for SDL2
This is just a modified version of FindSDL.cmake
2012-07-20 16:43:39 +02:00
dhewg
63fdea82b4 Get rid of wglext.h
Good riddance.
2012-07-20 16:43:37 +02:00
dhewg
ac921bc99f Get rid of editor specific win32 vars
We don't compile any mfc crap for our own good, so get rid of these.
2012-07-20 16:43:36 +02:00
dhewg
bf922dfc59 Get rid of glConfig.wgl_extensions_string
Unused and nobody cares.
2012-07-20 00:13:05 +02:00
dhewg
138b7b1def Remove the ATI fragment shader emulation
This was only used by the r200 renderer on OSX.
2012-07-20 00:12:59 +02:00
dhewg
2cad07c38e Delete util_stub.cpp
Unused.
2012-07-20 00:12:57 +02:00
dhewg
a96635219c Fix pointer check/access in Sys_InitNetworking()
Reported by scaronni.
Fixes #25.
2012-07-17 18:25:06 +02:00
dhewg
390b6a493d Try to find a steam install for the base path 2012-07-06 19:47:34 +02:00
dhewg
90bd14564f Remove redundant setenv() call
The version which overwrites existing envvars is just below.
2012-07-06 01:41:12 +02:00
dhewg
5a9c2006ff Get rid of Posix_EarlyInit() and Posix_LateInit()
Since we don't have our own signal handler anymore, those two
init functions can be merged into the existing Sys_Init(), which
is already called by common->Init().
2012-07-06 01:39:01 +02:00
dhewg
0bc457063f Get rid of the signal handler
SDL covers this via e.g. SDL_QUIT event on ctrl+c.
2012-07-06 01:31:27 +02:00
dhewg
d2b7eac843 Get rid of Sys_SetFatalError()
Unnecessary.
2012-07-06 01:24:25 +02:00
dhewg
33c841ef4c Get rid of socks proxy code in win_net.cpp
That was never active.
2012-07-06 01:07:02 +02:00
dhewg
7c06aa16b8 Fix warnings in win_net.cpp
warning: variable ‘err’ set but not used [-Wunused-but-set-variable]
warning: unused variable ‘len’ [-Wunused-variable]
warning: format ‘%d’ expects argument of type ‘int’, but argument 3
         has type ‘long long unsigned int’ [-Wformat]
2012-07-06 01:07:01 +02:00
dhewg
d6dd8c636b Fix sys/cpu.cpp for msvc 64bit 2012-07-06 01:06:59 +02:00