Patch adding Wii support by tueidj, part 4: joystick support

- sdlayer.c: custom "get joystick button names" routine
- jmact/mouse.c: packs some joystick events into the value returned by
  MOUSE_GetButtons(): bits used are 256, 512, 4096, 8192
- MOUSE_Init() --> Mouse_Init(), presumably because of a name clash?
- comments out right-shift of joystick analog values by 5, maybe this fixes
  the scale problems with the joystick on the PC too?

git-svn-id: https://svn.eduke32.com/eduke32@2624 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-05-01 12:38:43 +00:00
parent bc70806d32
commit a1d3c2dcea
4 changed files with 90 additions and 8 deletions

View file

@ -546,6 +546,7 @@ void uninitinput(void)
}
}
#ifndef GEKKO
const char *getjoyname(int32_t what, int32_t num)
{
static char tmp[64];
@ -571,6 +572,65 @@ const char *getjoyname(int32_t what, int32_t num)
return NULL;
}
}
#else
static const char *joynames[3][15] =
{
{
"Left Stick X",
"Left Stick Y",
"Right Stick X",
"Right Stick Y",
"wtf4",
"wtf5",
"wtf6",
"wtf7",
"wtf9",
},
{
"Button A",
"Button B",
"Button 1",
"Button 2",
"Button -",
"Button +",
"Button NULL",
"Button Z",
"Button C",
"Button X",
"Button Y",
"Trigger L",
"Trigger R",
"Trigger zL",
"Trigger zR",
},
{
"D-PAD Up",
"D-PAD Right",
"D-PAD Down",
"D-PAD Left",
}
};
const char *getjoyname(int32_t what, int32_t num)
{
switch (what)
{
case 0: // axis
if ((unsigned)num > (unsigned)joynumaxes) return NULL;
return joynames[0][num];
case 1: // button
if ((unsigned)num > (unsigned)joynumbuttons) return NULL;
return joynames[1][num];
case 2: // hat
if ((unsigned)num > (unsigned)joynumhats) return NULL;
return joynames[2][num];
default:
return NULL;
}
}
#endif
//

View file

@ -82,7 +82,7 @@ void CONTROL_GetMouseDelta(void)
int32_t CONTROL_StartMouse(void)
{
CONTROL_NumMouseButtons = MAXMOUSEBUTTONS;
return MOUSE_Init();
return Mouse_Init();
}
void CONTROL_GetJoyAbs(void)
@ -98,7 +98,7 @@ void CONTROL_GetJoyDelta(void)
int32_t i;
for (i=0; i<joynumaxes; i++)
CONTROL_JoyAxes[i].analog = joyaxis[i] >> 5;
CONTROL_JoyAxes[i].analog = joyaxis[i]; // >> 5;
}
int32_t CONTROL_StartJoy(int32_t joy)
@ -490,7 +490,11 @@ void CONTROL_GetDeviceButtons(void)
if (CONTROL_MouseEnabled)
{
DoGetDeviceButtons(
#ifdef GEKKO
MOUSE_GetButtons()&0x3F, t,
#else
MOUSE_GetButtons(), t,
#endif
CONTROL_NumMouseButtons,
CONTROL_MouseButtonState,
CONTROL_MouseButtonClickedTime,
@ -829,7 +833,7 @@ int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t
// case controltype_keyboardandmouse:
CONTROL_NumMouseAxes = MAXMOUSEAXES;
CONTROL_NumMouseButtons = MAXMOUSEBUTTONS;
CONTROL_MousePresent = MOUSE_Init();
CONTROL_MousePresent = Mouse_Init();
CONTROL_MouseEnabled = CONTROL_MousePresent;
// break;
@ -841,7 +845,7 @@ int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t
// break;
//}
#if 0
#ifdef GEKKO
if (CONTROL_MousePresent)
initprintf("CONTROL_Startup: Mouse Present\n");
if (CONTROL_JoyPresent)

View file

@ -37,8 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mouse.h"
#include "baselayer.h"
int32_t MOUSE_Init(void)
int32_t Mouse_Init(void)
{
initmouse();
return ((inputdevices & 2) == 2);
@ -64,7 +63,26 @@ void MOUSE_HideCursor(void)
int32_t MOUSE_GetButtons(void)
{
int32_t buttons;
readmousebstatus(&buttons);
#ifdef GEKKO
buttons |= (joyb&3)<<8;
switch (joyhat[0]) { // stupid hat values....
case 0:
case 4500:
case 27500:
buttons |= 4096;
break;
case 18000:
case 13500:
case 22500:
buttons |= 8192;
default:
break;
}
#endif
return buttons;
}

View file

@ -41,11 +41,11 @@ extern "C" {
#define RIGHT_MOUSE_PRESSED( button ) ( ( ( button ) & RIGHT_MOUSE ) != 0 )
#define MIDDLE_MOUSE_PRESSED( button ) ( ( ( button ) & MIDDLE_MOUSE ) != 0 )
int32_t MOUSE_Init( void );
int32_t Mouse_Init( void );
void MOUSE_Shutdown( void );
void MOUSE_ShowCursor( void );
void MOUSE_HideCursor( void );
int32_t MOUSE_GetButtons( void );
int32_t MOUSE_GetButtons( void );
int32_t MOUSE_ClearButton( int32_t b );
void MOUSE_GetDelta( int32_t*x, int32_t*y );