|
From: knittl <kn...@us...> - 2009-08-03 08:41:40
|
Module: performous
Branch: master
Commit: 6ae148f285e8b0c1bbdaaf61e4af7809d35519af
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Aug 3 03:54:41 2009 +0300
Fix repeating enter/shift causing extra pick events.
---
game/joystick.cc | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 89e7f3e..d64e74e 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -130,6 +130,7 @@ bool input::pushEvent(SDL_Event _e) {
using namespace input::Private;
Event event;
+ static bool pickPressed[2] = {}; // HACK for tracking enter and rshift status
switch(_e.type) {
case SDL_KEYDOWN: {
int button = 0;
@@ -137,6 +138,8 @@ bool input::pushEvent(SDL_Event _e) {
if(!devices[joy_id].assigned()) return false;
switch(_e.key.keysym.sym) {
case SDLK_RETURN:
+ if (pickPressed[0]) return true; // repeating
+ pickPressed[0] = true;
event.type = input::Event::PICK;
event.button = 1;
for( unsigned int i = 0 ; i < BUTTONS ; ++i ) {
@@ -145,6 +148,8 @@ bool input::pushEvent(SDL_Event _e) {
devices[joy_id].addEvent(event);
return true;
case SDLK_RSHIFT:
+ if (pickPressed[1]) return true; // repeating
+ pickPressed[1] = true;
event.type = input::Event::PICK;
event.button = 0;
for( unsigned int i = 0 ; i < BUTTONS ; ++i ) {
@@ -180,6 +185,8 @@ bool input::pushEvent(SDL_Event _e) {
joy_id = UINT_MAX;
if(!devices[joy_id].assigned()) return false;
switch(_e.key.keysym.sym) {
+ case SDLK_RETURN: pickPressed[0] = false; return true;
+ case SDLK_RSHIFT: pickPressed[1] = false; return true;
case SDLK_F5: case SDLK_5:
button++;
case SDLK_F4: case SDLK_4:
|