Skip to content

Commit

Permalink
remove if 0
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Aug 21, 2018
1 parent dd1aace commit b0eda8e
Showing 1 changed file with 0 additions and 285 deletions.
285 changes: 0 additions & 285 deletions daphne/daphne-1.0-src/io/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,291 +797,6 @@ void SDL_check_input()
// else the coin queue is empty, so we needn't do anything ...
}

#if 0
// RJS NOTE - event processing here
// processes incoming input
void process_event(SDL_Event *event)
{
unsigned int i = 0;

switch (event->type)
{
case SDL_KEYDOWN:
reset_idle(); // added by JFA for -idleexit
if (g_game->get_game_type() != GAME_THAYERS)
{
process_keydown(event->key.keysym.sym);
}
// We use a special case for Thayers Quest
else
{
thayers *l_thayers = (thayers *)(g_game);
// cast game class to a thayers class so we can call a thayers-specific function

// make sure cast succeeded
if (l_thayers)
{
l_thayers->process_keydown(event->key.keysym.sym);
}
// else cast failed, and we would crash if we tried to call process_keydown
// cast would fail if g_game is not a thayers class
}
break;
case SDL_KEYUP:
// MPO : since con_getkey doesn't catch the key up event, we shouldn't call reset_idle here.
//reset_idle(); // added by JFA for -idleexit

if (g_game->get_game_type() != GAME_THAYERS)
{
process_keyup(event->key.keysym.sym);
}
// We use a special case for Thayers Quest
else
{
thayers *l_thayers = (thayers *)(g_game);
// cast game class to thayers class so we can call a thayers-specific function

// make sure cast succeeded
if (l_thayers)
{
l_thayers->process_keyup(event->key.keysym.sym);
}
// else cast failed and we would crash if we tried to call process_keyup
// cast would fail if g_game is not a thayers class
}
break;
case SDL_JOYAXISMOTION:
//reset_idle(); // added by JFA for -idleexit
// reset_idle removed here because the analog controls were registering
// even when the joystick was not in use. Joystick buttons still reset the idle.
process_joystick_motion(event);
break;
case SDL_JOYHATMOTION:
// only process events for the first hat
if ( event->jhat.hat == 0 )
{
reset_idle();
process_joystick_hat_motion(event);
}
break;
case SDL_JOYBUTTONDOWN:
{
reset_idle(); // added by JFA for -idleexit

// RJS ADD - get joystick buttons map
int * joystick_buttons_map = get_joystick_buttons_map();

// added by Russ
// loop through buttons and look for a press
// RJS CHANGE
// for (i = 0; i < (sizeof(joystick_buttons_map) / sizeof(int)); i++) {
for (i = 0; i < MAX_DEFINED_JOYSTICK_BUTTONS; i++) {
if (event->jbutton.button == i) {
input_enable((uint8_t)joystick_buttons_map[i]);
break;
}
}
break;
}

case SDL_JOYBUTTONUP:
{
reset_idle(); // added by JFA for -idleexit

// RJS ADD - get jopystick buttons map
int * joystick_buttons_map = get_joystick_buttons_map();

// added by Russ
// RJS CHANGE
// for (i = 0; i < (sizeof(joystick_buttons_map) / sizeof(int)); i++) {
for (i = 0; i < MAX_DEFINED_JOYSTICK_BUTTONS; i++) {
if (event->jbutton.button == i) {
input_disable((uint8_t)joystick_buttons_map[i]);
break;
}
}

break;
}

case SDL_MOUSEBUTTONDOWN:
// added by ScottD
// loop through buttons and look for a press
for (i = 0; i < (sizeof(mouse_buttons_map) / sizeof(int)); i++) {
if (event->button.button == i) {
input_enable((uint8_t)mouse_buttons_map[i]);
break;
}
}
break;
case SDL_MOUSEBUTTONUP:
// added by ScottD
for (i = 0; i < (sizeof(mouse_buttons_map) / sizeof(int)); i++) {
if (event->button.button == i) {
input_disable((uint8_t)mouse_buttons_map[i]);
break;
}
}
break;
case SDL_MOUSEMOTION:
// added by ScottD
g_game->OnMouseMotion(event->motion.x, event->motion.y, event->motion.xrel, event->motion.yrel);
break;
case SDL_QUIT:
// if they are trying to close the window
set_quitflag();
break;
default:
break;
}

// added by JFA for -idleexit
if (get_idleexit() > 0 && elapsed_ms_time(idle_timer) > get_idleexit()) set_quitflag();
}

// if a key is pressed, we go here
// RJS CHANGE
// void process_keydown(SDLKey key)
void process_keydown(SDL_Keycode key)
{
// go through each key def (defined in enum in daphne.h) and check to see if the key entered matches
// If we have a match, the switch to be used is the value of the index "move"
for (uint8_t move = 0; move < SWITCH_COUNT; move++)
{
if ((key == g_key_defs[move][0]) || (key == g_key_defs[move][1]))
{
input_enable(move);
}
}
}

// if a key is released, we go here
// RJS CHANGE
// void process_keyup(SDLKey key)
void process_keyup(SDL_Keycode key)
{
// go through each key def (defined in enum in daphne.h) and check to see if the key entered matches
// If we have a match, the switch to be used is the value of the index "move"
for (uint8_t move = 0; move < SWITCH_COUNT; move++)
{
if ((key == g_key_defs[move][0]) || (key == g_key_defs[move][1]))
{
input_disable(move);
}
}
}

// processes movements of the joystick
void process_joystick_motion(SDL_Event *event)
{

static int x_axis_in_use = 0; // true if joystick is left or right
static int y_axis_in_use = 0; // true if joystick is up or down

// if they are moving along the verticle axis
if (event->jaxis.axis == 1)
{
// if they're moving up
if (event->jaxis.value < -JOY_AXIS_MID)
{
input_enable(SWITCH_UP);
y_axis_in_use = 1;
}
// if they're moving down
else if (event->jaxis.value > JOY_AXIS_MID)
{
input_enable(SWITCH_DOWN);
y_axis_in_use = 1;
}

// if they just barely stopped moving up or down
else if (y_axis_in_use == 1)
{
input_disable(SWITCH_UP);
input_disable(SWITCH_DOWN);
y_axis_in_use = 0;
}
} // end verticle axis

// horizontal axis
else
{
// if they're moving right
if (event->jaxis.value > JOY_AXIS_MID)
{
input_enable(SWITCH_RIGHT);
x_axis_in_use = 1;
}
// if they're moving left
else if (event->jaxis.value < -JOY_AXIS_MID)
{
input_enable(SWITCH_LEFT);
x_axis_in_use = 1;
}
// if they just barely stopped moving right or left
else if (x_axis_in_use == 1)
{
input_disable(SWITCH_RIGHT);
input_disable(SWITCH_LEFT);
x_axis_in_use = 0;
}
} // end horizontal axis
}

// processes movement of the joystick hat
void process_joystick_hat_motion(SDL_Event *event)
{

static uint8_t prev_hat_position = SDL_HAT_CENTERED;

if ( ( event->jhat.value & SDL_HAT_UP ) && !( prev_hat_position & SDL_HAT_UP ) )
{
// hat moved to the up position
input_enable(SWITCH_UP);
}
else if ( !( event->jhat.value & SDL_HAT_UP ) && ( prev_hat_position & SDL_HAT_UP ) )
{
// up hat released
input_disable(SWITCH_UP);
}

if ( ( event->jhat.value & SDL_HAT_RIGHT ) && !( prev_hat_position & SDL_HAT_RIGHT ) )
{
// hat moved to the right position
input_enable(SWITCH_RIGHT);
}
else if ( !( event->jhat.value & SDL_HAT_RIGHT ) && ( prev_hat_position & SDL_HAT_RIGHT ) )
{
// right hat released
input_disable(SWITCH_RIGHT);
}

if ( ( event->jhat.value & SDL_HAT_DOWN ) && !( prev_hat_position & SDL_HAT_DOWN ) )
{
// hat moved to the down position
input_enable(SWITCH_DOWN);
}
else if ( !( event->jhat.value & SDL_HAT_DOWN ) && ( prev_hat_position & SDL_HAT_DOWN ) )
{
// down hat released
input_disable(SWITCH_DOWN);
}

if ( ( event->jhat.value & SDL_HAT_LEFT ) && !( prev_hat_position & SDL_HAT_LEFT ) )
{
// hat moved to the left position
input_enable(SWITCH_LEFT);
}
else if ( !( event->jhat.value & SDL_HAT_LEFT ) && ( prev_hat_position & SDL_HAT_LEFT ) )
{
// left hat released
input_disable(SWITCH_LEFT);
}

prev_hat_position = event->jhat.value;
}
#endif

bool input_pause(bool fPause)
{
bool fCurrentState = g_game->get_game_paused();
Expand Down

0 comments on commit b0eda8e

Please sign in to comment.