mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
Map SDL joystick device trackball input to mouse input
git-svn-id: https://svn.eduke32.com/eduke32@8367 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/src/sdlayer.cpp
This commit is contained in:
parent
cbfb675577
commit
441b0460aa
2 changed files with 10 additions and 2 deletions
|
@ -116,6 +116,7 @@ typedef struct
|
||||||
void (*pCallback)(int32_t, int32_t);
|
void (*pCallback)(int32_t, int32_t);
|
||||||
int32_t bits;
|
int32_t bits;
|
||||||
int32_t numAxes;
|
int32_t numAxes;
|
||||||
|
int32_t numBalls;
|
||||||
int32_t numButtons;
|
int32_t numButtons;
|
||||||
int32_t numHats;
|
int32_t numHats;
|
||||||
int32_t isGameController;
|
int32_t isGameController;
|
||||||
|
|
|
@ -748,8 +748,10 @@ void joyScanDevices()
|
||||||
buildprintf("Using controller %s\n", SDL_GameControllerName(controller));
|
buildprintf("Using controller %s\n", SDL_GameControllerName(controller));
|
||||||
|
|
||||||
joystick.numAxes = SDL_CONTROLLER_AXIS_MAX;
|
joystick.numAxes = SDL_CONTROLLER_AXIS_MAX;
|
||||||
|
joystick.numBalls = 0;
|
||||||
joystick.numButtons = SDL_CONTROLLER_BUTTON_MAX;
|
joystick.numButtons = SDL_CONTROLLER_BUTTON_MAX;
|
||||||
joystick.numHats = 0;
|
joystick.numHats = 0;
|
||||||
|
|
||||||
joystick.isGameController = 1;
|
joystick.isGameController = 1;
|
||||||
|
|
||||||
Xfree(joystick.pAxis);
|
Xfree(joystick.pAxis);
|
||||||
|
@ -772,11 +774,15 @@ void joyScanDevices()
|
||||||
|
|
||||||
// KEEPINSYNC duke3d/src/gamedefs.h, mact/include/_control.h
|
// KEEPINSYNC duke3d/src/gamedefs.h, mact/include/_control.h
|
||||||
joystick.numAxes = min(9, SDL_JoystickNumAxes(joydev));
|
joystick.numAxes = min(9, SDL_JoystickNumAxes(joydev));
|
||||||
|
joystick.numBalls = SDL_JoystickNumBalls(joydev);
|
||||||
joystick.numButtons = min(32, SDL_JoystickNumButtons(joydev));
|
joystick.numButtons = min(32, SDL_JoystickNumButtons(joydev));
|
||||||
joystick.numHats = min((36 - joystick.numButtons) / 4, SDL_JoystickNumHats(joydev));
|
joystick.numHats = min((36 - joystick.numButtons) / 4, SDL_JoystickNumHats(joydev));
|
||||||
|
|
||||||
joystick.isGameController = 0;
|
joystick.isGameController = 0;
|
||||||
|
|
||||||
initprintf("Joystick %d has %d axes, %d buttons, and %d hat(s).\n", i+1, joystick.numAxes, joystick.numButtons, joystick.numHats);
|
buildprint("Joystick ", i+1, " has ", joystick.numAxes, " axes, ", joystick.numButtons, " buttons, ",
|
||||||
|
(joystick.numHats ? std::to_string(joystick.numHats).c_str() : "no"), " hats, and ",
|
||||||
|
(joystick.numBalls ? std::to_string(joystick.numBalls).c_str() : "no"), " balls.\n");
|
||||||
|
|
||||||
Xfree(joystick.pAxis);
|
Xfree(joystick.pAxis);
|
||||||
joystick.pAxis = (int32_t *)Xcalloc(joystick.numAxes, sizeof(int32_t));
|
joystick.pAxis = (int32_t *)Xcalloc(joystick.numAxes, sizeof(int32_t));
|
||||||
|
@ -1659,6 +1665,7 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
|
||||||
switch (ev->type)
|
switch (ev->type)
|
||||||
{
|
{
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
//case SDL_JOYBALLMOTION:
|
||||||
{
|
{
|
||||||
// The menus need this, even in non GUI-capture mode
|
// The menus need this, even in non GUI-capture mode
|
||||||
event_t event;
|
event_t event;
|
||||||
|
|
Loading…
Reference in a new issue