- removed define tags out of COpenGL.*
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@8 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
#include "CInput.h"
|
||||
#include "../CLogFile.h"
|
||||
|
||||
#ifdef WIZ
|
||||
#include "gp2x.h"
|
||||
#endif
|
||||
|
||||
CInput::CInput() {
|
||||
|
||||
@@ -127,9 +130,14 @@ bool CInput::readNewEvent(int position)
|
||||
return true;
|
||||
break;
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
#ifdef WIZ
|
||||
WIZ_EmuKeyboard( Event.jbutton.button, 1 );
|
||||
return false;
|
||||
#else
|
||||
InputCommand[position].joyeventtype = ETYPE_JOYBUTTON;
|
||||
InputCommand[position].joybutton = Event.jbutton.button;
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case SDL_JOYAXISMOTION:
|
||||
InputCommand[position].joyeventtype = ETYPE_JOYAXIS;
|
||||
@@ -180,8 +188,11 @@ void CInput::pollEvents()
|
||||
processJoystickButton(0);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef WIZ
|
||||
WIZ_AdjustVolume( volume_direction );
|
||||
#endif
|
||||
}
|
||||
|
||||
void CInput::processJoystickAxis(void)
|
||||
@@ -206,6 +217,9 @@ void CInput::processJoystickAxis(void)
|
||||
}
|
||||
void CInput::processJoystickButton(int value)
|
||||
{
|
||||
#ifdef WIZ
|
||||
WIZ_EmuKeyboard( Event.jbutton.button, value );
|
||||
#else
|
||||
unsigned int i;
|
||||
for(i=0 ; i<NUMBER_OF_COMMANDS ; i++)
|
||||
{
|
||||
@@ -216,6 +230,7 @@ void CInput::processJoystickButton(int value)
|
||||
InputCommand[i].active = value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CInput::sendKey(int key){ immediate_keytable[key] = true; }
|
||||
@@ -376,3 +391,133 @@ void CInput::flushKeys(void)
|
||||
memset(immediate_keytable,false,KEYTABLE_SIZE);
|
||||
memset(last_immediate_keytable,false,KEYTABLE_SIZE);
|
||||
}
|
||||
|
||||
#ifdef WIZ
|
||||
void CInput::WIZ_EmuKeyboard( int button, int value )
|
||||
{
|
||||
SDL_Event fakeevent1, fakeevent2;
|
||||
|
||||
//printf( "Button %d Value %d\n", button, value );
|
||||
|
||||
if( value == 1 ) {
|
||||
fakeevent1.type = SDL_KEYDOWN;
|
||||
fakeevent1.key.state = SDL_PRESSED;
|
||||
fakeevent1.key.type = SDL_KEYDOWN;
|
||||
fakeevent1.key.keysym.mod = KMOD_NONE;
|
||||
|
||||
fakeevent2.type = SDL_KEYDOWN;
|
||||
fakeevent2.key.state = SDL_PRESSED;
|
||||
fakeevent2.key.type = SDL_KEYDOWN;
|
||||
fakeevent2.key.keysym.mod = KMOD_NONE;
|
||||
}
|
||||
else {
|
||||
fakeevent1.type = SDL_KEYUP;
|
||||
fakeevent1.key.state = SDL_RELEASED;
|
||||
fakeevent1.key.type = SDL_KEYUP;
|
||||
fakeevent1.key.keysym.mod = KMOD_NONE;
|
||||
|
||||
fakeevent2.type = SDL_KEYUP;
|
||||
fakeevent2.key.state = SDL_RELEASED;
|
||||
fakeevent2.key.type = SDL_KEYUP;
|
||||
fakeevent2.key.keysym.mod = KMOD_NONE;
|
||||
}
|
||||
|
||||
//printf( "Button %d %d\n", button, value );
|
||||
fakeevent1.key.keysym.sym = SDLK_UNKNOWN;
|
||||
fakeevent2.key.keysym.sym = SDLK_UNKNOWN;
|
||||
switch(button)
|
||||
{
|
||||
case GP2X_BUTTON_LEFT:
|
||||
fakeevent1.key.keysym.sym = SDLK_LEFT;
|
||||
break;
|
||||
case GP2X_BUTTON_RIGHT:
|
||||
fakeevent1.key.keysym.sym = SDLK_RIGHT;
|
||||
break;
|
||||
case GP2X_BUTTON_UP:
|
||||
fakeevent1.key.keysym.sym = SDLK_UP;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWN:
|
||||
fakeevent1.key.keysym.sym = SDLK_DOWN;
|
||||
break;
|
||||
case GP2X_BUTTON_SELECT:
|
||||
fakeevent1.key.keysym.sym = SDLK_RETURN;
|
||||
break;
|
||||
case GP2X_BUTTON_START:
|
||||
fakeevent1.key.keysym.sym = SDLK_ESCAPE;
|
||||
break;
|
||||
case GP2X_BUTTON_L:
|
||||
fakeevent1.key.keysym.sym = SDLK_q;
|
||||
fakeevent2.key.keysym.sym = SDLK_1;
|
||||
break;
|
||||
case GP2X_BUTTON_R:
|
||||
fakeevent1.key.keysym.sym = SDLK_t;
|
||||
fakeevent2.key.keysym.sym = SDLK_2;
|
||||
break;
|
||||
case GP2X_BUTTON_A:
|
||||
fakeevent1.key.keysym.sym = SDLK_a;
|
||||
break;
|
||||
case GP2X_BUTTON_B:
|
||||
fakeevent1.key.keysym.sym = SDLK_b;
|
||||
break;
|
||||
case GP2X_BUTTON_X:
|
||||
fakeevent1.key.keysym.sym = SDLK_n;
|
||||
break;
|
||||
case GP2X_BUTTON_Y:
|
||||
fakeevent1.key.keysym.sym = SDLK_y;
|
||||
fakeevent2.key.keysym.sym = SDLK_F3;
|
||||
break;
|
||||
case GP2X_BUTTON_VOLUP:
|
||||
if( value == 1)
|
||||
volume_direction = VOLUME_UP;
|
||||
else
|
||||
volume_direction = VOLUME_NOCHG;
|
||||
break;
|
||||
case GP2X_BUTTON_VOLDOWN:
|
||||
if( value == 1)
|
||||
volume_direction = VOLUME_DOWN;
|
||||
else
|
||||
volume_direction = VOLUME_NOCHG;
|
||||
break;
|
||||
}
|
||||
|
||||
if( fakeevent1.key.keysym.sym != SDLK_UNKNOWN )
|
||||
{
|
||||
SDL_PushEvent (&fakeevent1);
|
||||
}
|
||||
|
||||
if( fakeevent2.key.keysym.sym != SDLK_UNKNOWN )
|
||||
{
|
||||
SDL_PushEvent (&fakeevent2);
|
||||
}
|
||||
}
|
||||
|
||||
void CInput::WIZ_AdjustVolume( int direction )
|
||||
{
|
||||
if( direction != VOLUME_NOCHG )
|
||||
{
|
||||
if( volume <= 10 )
|
||||
{
|
||||
if( direction == VOLUME_UP ) volume += VOLUME_CHANGE_RATE/2;
|
||||
if( direction == VOLUME_DOWN ) volume -= VOLUME_CHANGE_RATE/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( direction == VOLUME_UP ) volume += VOLUME_CHANGE_RATE;
|
||||
if( direction == VOLUME_DOWN ) volume -= VOLUME_CHANGE_RATE;
|
||||
}
|
||||
|
||||
if( volume < VOLUME_MIN ) volume = VOLUME_MIN;
|
||||
if( volume > VOLUME_MAX ) volume = VOLUME_MAX;
|
||||
|
||||
printf( "Volume Change: %i\n", volume );
|
||||
|
||||
unsigned long soundDev = open("/dev/mixer", O_RDWR);
|
||||
if(soundDev)
|
||||
{
|
||||
int vol = ((volume << 8) | volume);
|
||||
ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol);
|
||||
close(soundDev);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user