Fixed more in-game keys
This commit is contained in:
@@ -402,7 +402,8 @@ void Game::handleEventsPlayOn() {
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_KEYDOWN: {
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_MOUSEBUTTONDOWN: {
|
||||
if (paused) pause();
|
||||
racers->handleEvent(input.translate(event), input.isPressed(event));
|
||||
break;
|
||||
@@ -448,6 +449,7 @@ void Game::handleEventsPlayOn() {
|
||||
}
|
||||
case SDL_JOYAXISMOTION:
|
||||
case SDL_JOYBUTTONUP:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
racers->handleEvent(input.translate(event), input.isPressed(event));
|
||||
break;
|
||||
case SDL_QUIT: {
|
||||
|
||||
@@ -22,6 +22,7 @@ using namespace std;
|
||||
#include <vector>
|
||||
#include "input.h"
|
||||
#include "SDL.h"
|
||||
#include "settings.h"
|
||||
|
||||
Input input;
|
||||
|
||||
@@ -101,12 +102,14 @@ const SDLKey Input::translate(const SDL_Event& event) {
|
||||
if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) {
|
||||
return (SDLKey) (1040 + event.jbutton.button);
|
||||
}
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
|
||||
return SDLK_LCTRL; // settings->getPlayerEventKeys(0).find(PE_FIRE_WEAPONS)->second;
|
||||
}
|
||||
return (SDLKey) 0;
|
||||
}
|
||||
|
||||
const bool Input::isPressed(const SDL_Event& event) {
|
||||
/* || event.type == SDL_MOUSEBUTTONDOWN*/
|
||||
if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_KEYDOWN) return true;
|
||||
if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_KEYDOWN || event.type == SDL_MOUSEBUTTONDOWN) return true;
|
||||
if (event.type == SDL_JOYAXISMOTION) return event.jaxis.value / initialSensitivity;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void SetDifficulty::draw() {
|
||||
r.h = heavyFighterIcon1->h;
|
||||
SDL_BlitSurface( heavyFighterIcon1, 0, screen, &r );
|
||||
}
|
||||
fontHighlighted->drawStr( screen, 100, 400, "Press \"1\"", FONT_ALIGN_CENTERED );
|
||||
fontHighlighted->drawStr( screen, 100, 400, "Press \"Volume Up\"", FONT_ALIGN_CENTERED );
|
||||
fontHighlighted->drawStr( screen, 100, 430, "To Change", FONT_ALIGN_CENTERED );
|
||||
}
|
||||
else {
|
||||
@@ -124,7 +124,7 @@ void SetDifficulty::draw() {
|
||||
r.h = heavyFighterIcon1->h;
|
||||
SDL_BlitSurface( heavyFighterIcon1, 0, screen, &r );
|
||||
}
|
||||
fontHighlighted->drawStr( screen, 100, 400, "Press \"1\"", FONT_ALIGN_CENTERED );
|
||||
fontHighlighted->drawStr( screen, 100, 400, "Press \"Volume Up\"", FONT_ALIGN_CENTERED );
|
||||
fontHighlighted->drawStr( screen, 100, 430, "To Change", FONT_ALIGN_CENTERED );
|
||||
font->drawStr( screen, 560, 270, "Player 2", FONT_ALIGN_CENTERED );
|
||||
if ( playerTwoLightFighter ) {
|
||||
@@ -140,7 +140,7 @@ void SetDifficulty::draw() {
|
||||
r.h = heavyFighterIcon2->h;
|
||||
SDL_BlitSurface( heavyFighterIcon2, 0, screen, &r );
|
||||
}
|
||||
fontHighlighted->drawStr( screen, 560, 400, "Press \"2\"", FONT_ALIGN_CENTERED );
|
||||
fontHighlighted->drawStr( screen, 560, 400, "Press \"Volume Down\"", FONT_ALIGN_CENTERED );
|
||||
fontHighlighted->drawStr( screen, 560, 430, "To Change", FONT_ALIGN_CENTERED );
|
||||
}
|
||||
}
|
||||
@@ -154,11 +154,11 @@ void SetDifficulty::handleEvents( GameStates &gameState ) {
|
||||
switch(event.type) {
|
||||
case SDL_KEYDOWN: {
|
||||
switch ( event.key.keysym.sym ) {
|
||||
case SDLK_1: {
|
||||
case SDLK_PAGEUP: {
|
||||
playerOneLightFighter = !playerOneLightFighter;
|
||||
break;
|
||||
}
|
||||
case SDLK_2: {
|
||||
case SDLK_PAGEDOWN: {
|
||||
playerTwoLightFighter = !playerTwoLightFighter;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -421,6 +421,10 @@ const PlayerKeys Settings::getPlayerKeys(unsigned int player) const {
|
||||
return pk;
|
||||
}
|
||||
|
||||
const PlayerEventKeys & Settings::getPlayerEventKeys(unsigned int player) const {
|
||||
return playerKeys[player];
|
||||
}
|
||||
|
||||
void Settings::setKeyNames() {
|
||||
/*
|
||||
keyName[ (SDLKey)0 ] = "UNKNOWN";
|
||||
|
||||
@@ -64,6 +64,7 @@ class Settings {
|
||||
|
||||
void settingsDialog(SdlCompat_AcceleratedSurface *screen);
|
||||
const PlayerKeys getPlayerKeys(unsigned int player) const;
|
||||
const PlayerEventKeys & getPlayerEventKeys(unsigned int player) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user