Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1349 for code


Ignore:
Timestamp:
May 21, 2008, 9:07:08 PM (17 years ago)
Author:
rgrieder
Message:
  • merged input branch back to trunk
Location:
code/trunk
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/bin/keybindings.ini

    r1293 r1349  
    11[KeyBinder]
    2 P_UNASSIGNED=activateConsole
    3 R_UNASSIGNED=
    4 H_UNASSIGNED=
    5 P_ESCAPE="exit"
    6 R_ESCAPE=
    7 H_ESCAPE=
    8 P_1=
    9 R_1=
    10 H_1=
    11 P_2=
    12 R_2=
    13 H_2=
    14 P_3=
    15 R_3=
    16 H_3=
    17 P_4=
    18 R_4=
    19 H_4=
    20 P_5=
    21 R_5=
    22 H_5=
    23 P_6=
    24 R_6=
    25 H_6=
    26 P_7="exec disco.txt"
    27 R_7=
    28 H_7=
    29 P_8=
    30 R_8=
    31 H_8=
    32 P_9="disco.txt"
    33 R_9=
    34 H_9=
    35 P_0=
    36 R_0=
    37 H_0=
    38 P_MINUS=
    39 R_MINUS=
    40 H_MINUS=
    41 P_EQUALS=activateConsole
    42 R_EQUALS=
    43 H_EQUALS=
    44 P_BACK=
    45 R_BACK=
    46 H_BACK=
    47 P_TAB=
    48 R_TAB=
    49 H_TAB=
    50 P_Q=
    51 R_Q=
    52 H_Q=
    53 P_W=
    54 R_W=
    55 H_W=
    56 P_E=
    57 R_E=
    58 H_E=
    59 P_R=
    60 R_R=
    61 H_R=
    62 P_T=
    63 R_T=
    64 H_T=
    65 P_Y=
    66 R_Y=
    67 H_Y=
    68 P_U=
    69 R_U=
    70 H_U=
    71 P_I=
    72 R_I=
    73 H_I=
    74 P_O=
    75 R_O=
    76 H_O=
    77 P_P=
    78 R_P=
    79 H_P=
    80 P_LBRACKET=
    81 R_LBRACKET=
    82 H_LBRACKET=
    83 P_RBRACKET=
    84 R_RBRACKET=
    85 H_RBRACKET=
    86 P_RETURN=
    87 R_RETURN=
    88 H_RETURN=
    89 P_LCONTROL=
    90 R_LCONTROL=
    91 H_LCONTROL=
    92 P_A=
    93 R_A=
    94 H_A=
    95 P_S=
    96 R_S=
    97 H_S=
    98 P_D=
    99 R_D=
    100 H_D=
    101 P_F=
    102 R_F=
    103 H_F=
    104 P_G=
    105 R_G=
    106 H_G=
    107 P_H=
    108 R_H=
    109 H_H=
    110 P_J=
    111 R_J=
    112 H_J=
    113 P_K=
    114 R_K=
    115 H_K=
    116 P_L=
    117 R_L=
    118 H_L=
    119 P_SEMICOLON=
    120 R_SEMICOLON=
    121 H_SEMICOLON=
    122 P_APOSTROPHE=
    123 R_APOSTROPHE=
    124 H_APOSTROPHE=
    125 P_GRAVE=activateConsole
    126 R_GRAVE=
    127 H_GRAVE=
    128 P_LSHIFT=
    129 R_LSHIFT=
    130 H_LSHIFT=
    131 P_BACKSLASH=
    132 R_BACKSLASH=
    133 H_BACKSLASH=
    134 P_Z=
    135 R_Z=
    136 H_Z=
    137 P_X=
    138 R_X=
    139 H_X=
    140 P_C=
    141 R_C=
    142 H_C=
    143 P_V=
    144 R_V=
    145 H_V=
    146 P_B=
    147 R_B=
    148 H_B=
    149 P_N=
    150 R_N=
    151 H_N=
    152 P_M=
    153 R_M=
    154 H_M=
    155 P_COMMA=
    156 R_COMMA=
    157 H_COMMA=
    158 P_PERIOD=
    159 R_PERIOD=
    160 H_PERIOD=
    161 P_SLASH=
    162 R_SLASH=
    163 H_SLASH=
    164 P_RSHIFT=
    165 R_RSHIFT=
    166 H_RSHIFT=
    167 P_MULTIPLY=
    168 R_MULTIPLY=
    169 H_MULTIPLY=
    170 P_LMENU=
    171 R_LMENU=
    172 H_LMENU=
    173 P_SPACE=
    174 R_SPACE=
    175 H_SPACE=
    176 P_CAPITAL=
    177 R_CAPITAL=
    178 H_CAPITAL=
    179 P_F1=
    180 R_F1=
    181 H_F1=
    182 P_F2=
    183 R_F2=
    184 H_F2=
    185 P_F3=
    186 R_F3=
    187 H_F3=
    188 P_F4=
    189 R_F4=
    190 H_F4=
    191 P_F5=
    192 R_F5=
    193 H_F5=
    194 P_F6=
    195 R_F6=
    196 H_F6=
    197 P_F7=
    198 R_F7=
    199 H_F7=
    200 P_F8=
    201 R_F8=
    202 H_F8=
    203 P_F9=
    204 R_F9=
    205 H_F9=
    206 P_F10=
    207 R_F10=
    208 H_F10=
    209 P_NUMLOCK=
    210 R_NUMLOCK=
    211 H_NUMLOCK=
    212 P_SCROLL=
    213 R_SCROLL=
    214 H_SCROLL=
    215 P_NUMPAD7=
    216 R_NUMPAD7=
    217 H_NUMPAD7=
    218 P_NUMPAD8=
    219 R_NUMPAD8=
    220 H_NUMPAD8=
    221 P_NUMPAD9=
    222 R_NUMPAD9=
    223 H_NUMPAD9=
    224 P_SUBTRACT=
    225 R_SUBTRACT=
    226 H_SUBTRACT=
    227 P_NUMPAD4=
    228 R_NUMPAD4=
    229 H_NUMPAD4=
    230 P_NUMPAD5=
    231 R_NUMPAD5=
    232 H_NUMPAD5=
    233 P_NUMPAD6=
    234 R_NUMPAD6=
    235 H_NUMPAD6=
    236 P_ADD=
    237 R_ADD=
    238 H_ADD=
    239 P_NUMPAD1=
    240 R_NUMPAD1=
    241 H_NUMPAD1=
    242 P_NUMPAD2=
    243 R_NUMPAD2=
    244 H_NUMPAD2=
    245 P_NUMPAD3=
    246 R_NUMPAD3=
    247 H_NUMPAD3=
    248 P_NUMPAD0=
    249 R_NUMPAD0=
    250 H_NUMPAD0=
    251 P_DECIMAL=
    252 R_DECIMAL=
    253 H_DECIMAL=
    254 P_=
    255 R_=
    256 H_=
    257 P_OEM_102=
    258 R_OEM_102=
    259 H_OEM_102=
    260 P_F11=
    261 R_F11=
    262 H_F11=
    263 P_F12=
    264 R_F12=
    265 H_F12=
    266 P_F13=
    267 R_F13=
    268 H_F13=
    269 P_F14=
    270 R_F14=
    271 H_F14=
    272 P_F15=
    273 R_F15=
    274 H_F15=
    275 P_KANA=
    276 R_KANA=
    277 H_KANA=
    278 P_ABNT_C1=
    279 R_ABNT_C1=
    280 H_ABNT_C1=
    281 P_CONVERT=
    282 R_CONVERT=
    283 H_CONVERT=
    284 P_NOCONVERT=
    285 R_NOCONVERT=
    286 H_NOCONVERT=
    287 P_YEN=
    288 R_YEN=
    289 H_YEN=
    290 P_ABNT_C2=
    291 R_ABNT_C2=
    292 H_ABNT_C2=
    293 P_NUMPADEQUALS=
    294 R_NUMPADEQUALS=
    295 H_NUMPADEQUALS=
    296 P_PREVTRACK=
    297 R_PREVTRACK=
    298 H_PREVTRACK=
    299 P_AT=
    300 R_AT=
    301 H_AT=
    302 P_COLON=
    303 R_COLON=
    304 H_COLON=
    305 P_UNDERLINE=
    306 R_UNDERLINE=
    307 H_UNDERLINE=
    308 P_KANJI=
    309 R_KANJI=
    310 H_KANJI=
    311 P_STOP=
    312 R_STOP=
    313 H_STOP=
    314 P_AX=
    315 R_AX=
    316 H_AX=
    317 P_UNLABELED=
    318 R_UNLABELED=
    319 H_UNLABELED=
    320 P_NEXTTRACK=
    321 R_NEXTTRACK=
    322 H_NEXTTRACK=
    323 P_NUMPADENTER=activateConsole
    324 R_NUMPADENTER=
    325 H_NUMPADENTER=
    326 P_RCONTROL=
    327 R_RCONTROL=
    328 H_RCONTROL=
    329 P_MUTE=
    330 R_MUTE=
    331 H_MUTE=
    332 P_CALCULATOR=
    333 R_CALCULATOR=
    334 H_CALCULATOR=
    335 P_PLAYPAUSE=
    336 R_PLAYPAUSE=
    337 H_PLAYPAUSE=
    338 P_MEDIASTOP=exit
    339 R_MEDIASTOP=
    340 H_MEDIASTOP=
    341 P_VOLUMEDOWN=
    342 R_VOLUMEDOWN=
    343 H_VOLUMEDOWN=
    344 P_VOLUMEUP=
    345 R_VOLUMEUP=
    346 H_VOLUMEUP=
    347 P_WEBHOME=
    348 R_WEBHOME=
    349 H_WEBHOME=
    350 P_NUMPADCOMMA=
    351 R_NUMPADCOMMA=
    352 H_NUMPADCOMMA=
    353 P_DIVIDE=
    354 R_DIVIDE=
    355 H_DIVIDE=
    356 P_SYSRQ=
    357 R_SYSRQ=
    358 H_SYSRQ=
    359 P_RMENU=
    360 R_RMENU=
    361 H_RMENU=
    362 P_PAUSE=
    363 R_PAUSE=
    364 H_PAUSE=
    365 P_HOME=
    366 R_HOME=
    367 H_HOME=
    368 P_UP=
    369 R_UP=
    370 H_UP=
    371 P_PGUP=
    372 R_PGUP=
    373 H_PGUP=
    374 P_LEFT=
    375 R_LEFT=
    376 H_LEFT=
    377 P_RIGHT=
    378 R_RIGHT=
    379 H_RIGHT=
    380 P_END=
    381 R_END=
    382 H_END=
    383 P_DOWN=
    384 R_DOWN=
    385 H_DOWN=
    386 P_PGDOWN=
    387 R_PGDOWN=
    388 H_PGDOWN=
    389 P_INSERT=
    390 R_INSERT=
    391 H_INSERT=
    392 P_DELETE=
    393 R_DELETE=
    394 H_DELETE=
    395 P_LWIN=
    396 R_LWIN=
    397 H_LWIN=
    398 P_RWIN=
    399 R_RWIN=
    400 H_RWIN=
    401 P_APPS=
    402 R_APPS=
    403 H_APPS=
    404 P_POWER=
    405 R_POWER=
    406 H_POWER=
    407 P_SLEEP=
    408 R_SLEEP=
    409 H_SLEEP=
    410 P_WAKE=
    411 R_WAKE=
    412 H_WAKE=
    413 P_WEBSEARCH=
    414 R_WEBSEARCH=
    415 H_WEBSEARCH=
    416 P_WEBFAVORITES=
    417 R_WEBFAVORITES=
    418 H_WEBFAVORITES=
    419 P_WEBREFRESH=
    420 R_WEBREFRESH=
    421 H_WEBREFRESH=
    422 P_WEBSTOP=
    423 R_WEBSTOP=
    424 H_WEBSTOP=
    425 P_WEBFORWARD=
    426 R_WEBFORWARD=
    427 H_WEBFORWARD=
    428 P_WEBBACK=
    429 R_WEBBACK=
    430 H_WEBBACK=
    431 P_MYCOMPUTER=
    432 R_MYCOMPUTER=
    433 H_MYCOMPUTER=
    434 P_MAIL=
    435 R_MAIL=
    436 H_MAIL=
    437 P_MEDIASELECT=
    438 R_MEDIASELECT=
    439 H_MEDIASELECT=
    440 P_MouseLeft=
    441 R_MouseLeft=
    442 H_MouseLeft=
    443 P_MouseRight=
    444 R_MouseRight=
    445 H_MouseRight=
    446 P_MouseMiddle=
    447 R_MouseMiddle=
    448 H_MouseMiddle=
    449 P_MouseButton3=
    450 R_MouseButton3=
    451 H_MouseButton3=
    452 P_MouseButton4=
    453 R_MouseButton4=
    454 H_MouseButton4=
    455 P_MouseButton5=
    456 R_MouseButton5=
    457 H_MouseButton5=
    458 P_MouseButton6=
    459 R_MouseButton6=
    460 H_MouseButton6=
    461 P_MouseButton7=
    462 R_MouseButton7=
    463 H_MouseButton7=
    464 P_JoyStick0=
    465 R_JoyStick0=
    466 H_JoyStick0=
    467 P_JoyStick1=
    468 R_JoyStick1=
    469 H_JoyStick1=
    470 P_JoyStick2=
    471 R_JoyStick2=
    472 H_JoyStick2=
    473 P_JoyStick3=
    474 R_JoyStick3=
    475 H_JoyStick3=
    476 P_JoyStick4=
    477 R_JoyStick4=
    478 H_JoyStick4=
    479 P_JoyStick5=
    480 R_JoyStick5=
    481 H_JoyStick5=
    482 P_JoyStick6=
    483 R_JoyStick6=
    484 H_JoyStick6=
    485 P_JoyStick7=
    486 R_JoyStick7=
    487 H_JoyStick7=
    488 P_JoyStick8=
    489 R_JoyStick8=
    490 H_JoyStick8=
    491 P_JoyStick9=
    492 R_JoyStick9=
    493 H_JoyStick9=
    494 P_JoyStick10=
    495 R_JoyStick10=
    496 H_JoyStick10=
    497 P_JoyStick11=
    498 R_JoyStick11=
    499 H_JoyStick11=
    500 P_JoyStick12=
    501 R_JoyStick12=
    502 H_JoyStick12=
    503 P_JoyStick13=
    504 R_JoyStick13=
    505 H_JoyStick13=
    506 P_JoyStick14=
    507 R_JoyStick14=
    508 H_JoyStick14=
    509 P_JoyStick15=
    510 R_JoyStick15=
    511 H_JoyStick15=
    512 P_JoyStick16=
    513 R_JoyStick16=
    514 H_JoyStick16=
    515 P_JoyStick17=
    516 R_JoyStick17=
    517 H_JoyStick17=
    518 P_JoyStick18=
    519 R_JoyStick18=
    520 H_JoyStick18=
    521 P_JoyStick19=
    522 R_JoyStick19=
    523 H_JoyStick19=
    524 P_JoyStick20=
    525 R_JoyStick20=
    526 H_JoyStick20=
    527 P_JoyStick21=
    528 R_JoyStick21=
    529 H_JoyStick21=
    530 P_JoyStick22=
    531 R_JoyStick22=
    532 H_JoyStick22=
    533 P_JoyStick23=
    534 R_JoyStick23=
    535 H_JoyStick23=
    536 P_JoyStick24=
    537 R_JoyStick24=
    538 H_JoyStick24=
    539 P_JoyStick25=
    540 R_JoyStick25=
    541 H_JoyStick25=
    542 P_JoyStick26=
    543 R_JoyStick26=
    544 H_JoyStick26=
    545 P_JoyStick27=
    546 R_JoyStick27=
    547 H_JoyStick27=
    548 P_JoyStick28=
    549 R_JoyStick28=
    550 H_JoyStick28=
    551 P_JoyStick29=
    552 R_JoyStick29=
    553 H_JoyStick29=
    554 P_JoyStick30=
    555 R_JoyStick30=
    556 H_JoyStick30=
    557 P_JoyStick31=
    558 R_JoyStick31=
    559 H_JoyStick31=
     2KeyUNASSIGNED=
     3KeyESCAPE=exit
     4Key1=
     5Key2=
     6Key3=
     7Key4=
     8Key5=
     9Key6=
     10Key7=
     11Key8=
     12Key9=
     13Key0=
     14KeyMINUS=
     15KeyEQUALS=activateConsole
     16KeyBACK=
     17KeyTAB=
     18KeyQ=
     19KeyW=
     20KeyE=
     21KeyR=
     22KeyT=
     23KeyY=
     24KeyU=
     25KeyI=
     26KeyO=
     27KeyP=
     28KeyLBRACKET=
     29KeyRBRACKET=
     30KeyRETURN=
     31KeyLCONTROL=
     32KeyA=
     33KeyS=
     34KeyD=
     35KeyF=
     36KeyG=
     37KeyH=
     38KeyJ=
     39KeyK=
     40KeyL=
     41KeySEMICOLON=
     42KeyAPOSTROPHE=
     43KeyGRAVE=activateConsole
     44KeyLSHIFT=
     45KeyBACKSLASH=
     46KeyZ=
     47KeyX=
     48KeyC=
     49KeyV=
     50KeyB=
     51KeyN=
     52KeyM=
     53KeyCOMMA=
     54KeyPERIOD=
     55KeySLASH=
     56KeyRSHIFT=
     57KeyMULTIPLY=
     58KeyLMENU=
     59KeySPACE=
     60KeyCAPITAL=
     61KeyF1=
     62KeyF2=
     63KeyF3=
     64KeyF4=
     65KeyF5=
     66KeyF6=
     67KeyF7=
     68KeyF8=
     69KeyF9=
     70KeyF10=
     71KeyNUMLOCK=
     72KeySCROLL=
     73KeyNUMPAD7=
     74KeyNUMPAD8=
     75KeyNUMPAD9=
     76KeySUBTRACT=
     77KeyNUMPAD4=
     78KeyNUMPAD5=
     79KeyNUMPAD6=
     80KeyADD=
     81KeyNUMPAD1=
     82KeyNUMPAD2=
     83KeyNUMPAD3=
     84KeyNUMPAD0=
     85KeyDECIMAL=
     86Key=
     87KeyOEM_102=
     88KeyF11=
     89KeyF12=
     90KeyF13=
     91KeyF14=
     92KeyF15=
     93KeyKANA=
     94KeyABNT_C1=
     95KeyCONVERT=
     96KeyNOCONVERT=
     97KeyYEN=
     98KeyABNT_C2=
     99KeyNUMPADEQUALS=
     100KeyPREVTRACK=
     101KeyAT=
     102KeyCOLON=
     103KeyUNDERLINE=
     104KeyKANJI=
     105KeySTOP=
     106KeyAX=
     107KeyUNLABELED=
     108KeyNEXTTRACK=
     109KeyNUMPADENTER=activateConsole
     110KeyRCONTROL=
     111KeyMUTE=
     112KeyCALCULATOR=
     113KeyPLAYPAUSE=
     114KeyMEDIASTOP=
     115KeyVOLUMEDOWN=
     116KeyVOLUMEUP=
     117KeyWEBHOME=
     118KeyNUMPADCOMMA=
     119KeyDIVIDE=
     120KeySYSRQ=
     121KeyRMENU=
     122KeyPAUSE=
     123KeyHOME=
     124KeyUP=
     125KeyPGUP=
     126KeyLEFT=
     127KeyRIGHT=
     128KeyEND=
     129KeyDOWN=
     130KeyPGDOWN=
     131KeyINSERT=
     132KeyDELETE=
     133KeyLWIN=
     134KeyRWIN=
     135KeyAPPS=
     136KeyPOWER=
     137KeySLEEP=
     138KeyWAKE=
     139KeyWEBSEARCH=
     140KeyWEBFAVORITES=
     141KeyWEBREFRESH=
     142KeyWEBSTOP=exit
     143KeyWEBFORWARD=
     144KeyWEBBACK=
     145KeyMYCOMPUTER=
     146KeyMAIL=
     147KeyMEDIASELECT=
     148MouseLeft=
     149MouseRight=
     150MouseMiddle=
     151MouseButton3=
     152MouseButton4=
     153MouseButton5=
     154MouseButton6=
     155MouseButton7=
     156MouseWheel1Up=#AxisAmp 0.1 slomo
     157MouseWheel1Down=#AxisAmp 0.1 slomo
     158MouseWheel2Up=
     159MouseWheel2Down=
     160MouseXPos= #exit | ButtonThreshold 0.85
     161MouseXNeg=
     162MouseYPos=
     163MouseYNeg=
     164Empty1Pos=
     165Empty1Neg=
     166Empty2Pos=
     167Empty2Neg=
     168JoyAxis1Pos=
     169JoyAxis1Neg=
     170JoyAxis2Pos=
     171JoyAxis2Neg=
     172JoyAxis3Pos=
     173JoyAxis3Neg=
     174JoyAxis4Pos=
     175JoyAxis4Neg=
     176JoyAxis5Pos=
     177JoyAxis5Neg=#AxisAmp 10 slomo | ButtonThreshold 0.9 | onPress exit
     178JoyAxis6Pos=#AxisAmp  10 slomo
     179JoyAxis6Neg=
     180JoyAxis7Pos=
     181JoyAxis7Neg=
     182JoyAxis8Pos=
     183JoyAxis8Neg=
     184JoyAxis9Pos=
     185JoyAxis9Neg=
     186JoyAxis10Pos=
     187JoyAxis10Neg=
     188JoyAxis11Pos=
     189JoyAxis11Neg=
     190JoyAxis12Pos=
     191JoyAxis12Neg=
     192JoyAxis13Pos=
     193JoyAxis13Neg=
     194JoyAxis14Pos=
     195JoyAxis14Neg=
     196JoyAxis15Pos=
     197JoyAxis15Neg=
     198JoyAxis16Pos=
     199JoyAxis16Neg=
     200JoyAxis17Pos=
     201JoyAxis17Neg=
     202JoyAxis18Pos=
     203JoyAxis18Neg=
     204JoyAxis19Pos=
     205JoyAxis19Neg=
     206JoyAxis20Pos=
     207JoyAxis20Neg=
     208JoyAxis21Pos=
     209JoyAxis21Neg=
     210JoyAxis22Pos=
     211JoyAxis22Neg=
     212JoyAxis23Pos=
     213JoyAxis23Neg=
     214JoyAxis24Pos=
     215JoyAxis24Neg=
     216JoyButton0=
     217JoyButton1=
     218JoyButton2=
     219JoyButton3=
     220JoyButton4=
     221JoyButton5=
     222JoyButton6=
     223JoyButton7=
     224JoyButton8=
     225JoyButton9=
     226JoyButton10=
     227JoyButton11=
     228JoyButton12=
     229JoyButton13=
     230JoyButton14=
     231JoyButton15=
     232JoyButton16=
     233JoyButton17=
     234JoyButton18=
     235JoyButton19=
     236JoyButton20=
     237JoyButton21=
     238JoyButton22=
     239JoyButton23=
     240JoyButton24=
     241JoyButton25=
     242JoyButton26=
     243JoyButton27=
     244JoyButton28=
     245JoyButton29=
     246JoyButton30=
     247JoyButton31=
     248JoyPOV1North=
     249JoyPOV1South=
     250JoyPOV1East=
     251JoyPOV1West=
     252JoyPOV2North=
     253JoyPOV2South=
     254JoyPOV2East=
     255JoyPOV2West=
     256JoyPOV3North=
     257JoyPOV3South=
     258JoyPOV3East=
     259JoyPOV3West=
     260JoyPOV4North=
     261JoyPOV4South=
     262JoyPOV4East=
     263JoyPOV4West=
    560264
  • code/trunk/src/core/CommandExecutor.cc

    r1214 r1349  
    3131#include "util/String.h"
    3232#include "util/Convert.h"
     33#include "util/SubString.h"
    3334#include "Identifier.h"
    3435#include "Language.h"
     
    173174    }
    174175
    175     KeybindMode CommandEvaluation::getKeybindMode()
     176    KeybindMode::Enum CommandEvaluation::getKeybindMode()
    176177    {
    177178        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
     
    198199        }
    199200        // FIXME: Had to insert a return statement
    200         return (KeybindMode)0;
     201        return (KeybindMode::Enum)0;
    201202    }
    202203
  • code/trunk/src/core/CommandExecutor.h

    r1293 r1349  
    7070    std::string read(const std::string& filename);
    7171
    72     enum KeybindMode {}; // temporary
    73 
    7472    ///////////////////////
    7573    // CommandEvaluation //
     
    8280            CommandEvaluation();
    8381
    84             KeybindMode getKeybindMode();
     82            KeybindMode::Enum getKeybindMode();
    8583            bool isValid() const;
    8684
     
    8987            inline std::string getAdditionalParameter() const
    9088                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
    91             inline std::string getCommandString() const { return this->processedCommand_; }
     89            inline ExecutorStatic* getEvaluatedExecutor() { return evaluatedExecutor_; }
     90            inline std::string getCommandString() { return this->processedCommand_; }
    9291
    9392            void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
  • code/trunk/src/core/CorePrereqs.h

    r1293 r1349  
    7878#endif
    7979
     80  namespace KeybindMode
     81  {
     82    enum Enum
     83    {
     84      OnPress,
     85      OnHold,
     86      OnRelease,
     87      None
     88    };
     89  };
     90
    8091  typedef std::string LanguageEntryLabel;
    8192
  • code/trunk/src/core/Executor.cc

    r1062 r1349  
    3939        this->name_ = name;
    4040        this->accessLevel_ = level;
     41        this->keybindMode_ = KeybindMode::OnPress;
     42        this->axisParamIndex_ = -1;
     43        this->bAxisRelative_ = false;
    4144
    4245        this->bAddedDescription_ = false;
  • code/trunk/src/core/Executor.h

    r1062 r1349  
    204204                { return this->accessLevel_; }
    205205
     206            inline Executor& setKeybindMode(KeybindMode::Enum mode)
     207                { this->keybindMode_ = mode; return *this; }
     208            inline KeybindMode::Enum getKeybindMode() const
     209                { return this->keybindMode_; }
     210
     211            inline Executor& setAxisParamIndex(int index)
     212                { this->axisParamIndex_ = index; return *this; }
     213            inline int getAxisParamIndex() const
     214                { return this->axisParamIndex_; }
     215
     216            inline Executor& setIsAxisRelative(bool val)
     217                { this->bAxisRelative_ = val; return *this; }
     218            inline int getIsAxisRelative() const
     219                { return this->bAxisRelative_; }
     220
    206221            Executor& setDefaultValues(const MultiTypeMath& param1);
    207222            Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2);
     
    233248            MultiTypeMath defaultValue_[MAX_FUNCTOR_ARGUMENTS];
    234249            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
     250
     251            KeybindMode::Enum keybindMode_;
     252            int axisParamIndex_;
     253            bool bAxisRelative_;
    235254
    236255        private:
  • code/trunk/src/core/InputBuffer.cc

    r1293 r1349  
    173173  }
    174174
     175  /**
     176  * This tick() function is called by the InputManager if the InputBuffer is active.
     177  * @param dt Delta time
     178  */
    175179  void InputBuffer::tick(float dt)
    176180  {
     
    187191  }
    188192
    189   bool InputBuffer::keyPressed(const KeyEvent &evt)
     193  void InputBuffer::keyPressed(const KeyEvent &evt)
    190194  {
    191195    lastKey_ = evt.key;
     
    195199
    196200    processKey(evt);
    197     return true;
    198   }
    199 
    200   bool InputBuffer::keyHeld(const KeyEvent& evt)
     201  }
     202
     203  void InputBuffer::keyHeld(const KeyEvent& evt)
    201204  {
    202205    if (evt.key == lastKey_)
     
    208211      }
    209212    }
    210     return true;
    211213  }
    212214
  • code/trunk/src/core/InputBuffer.h

    r1293 r1349  
    4343  {};
    4444
    45   class _CoreExport InputBuffer : public KeyHandler, public TickableReal
     45  class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass
    4646  {
    4747    struct InputBufferListenerTuple
     
    101101    bool charIsAllowed(const char& input);
    102102
    103     bool keyPressed (const KeyEvent& evt);
    104     bool keyReleased(const KeyEvent& evt) { return true; }
    105     bool keyHeld    (const KeyEvent& evt);
     103    void keyPressed (const KeyEvent& evt);
     104    void keyReleased(const KeyEvent& evt) { }
     105    void keyHeld    (const KeyEvent& evt);
    106106    void processKey (const KeyEvent &e);
    107107
  • code/trunk/src/core/InputHandler.cc

    r1293 r1349  
    3434#include "InputHandler.h"
    3535#include "util/Convert.h"
     36#include "util/SubString.h"
     37#include "util/String.h"
    3638#include "Debug.h"
    3739#include "ConfigValueIncludes.h"
    3840#include "CoreIncludes.h"
    3941#include "CommandExecutor.h"
     42#include "Executor.h"
    4043
    4144namespace orxonox
    4245{
    4346  // ###############################
     47  // ######      Button       ######
     48  // ###############################
     49
     50  bool BufferedParamCommand::execute()
     51  {
     52    if (nValuesAdded_)
     53    {
     54      BufferedParamCommand& cmd = *this;
     55      cmd.evaluation_.setEvaluatedParameter(cmd.paramIndex_, cmd.value_);
     56      // reset
     57      cmd.nValuesAdded_ = 0;
     58      cmd.value_ = 0;
     59      return CommandExecutor::execute(cmd.evaluation_);
     60    }
     61    else
     62      return true;
     63  }
     64
     65  bool SimpleCommand::execute(float abs, float rel)
     66  {
     67    return CommandExecutor::execute(evaluation_);
     68  }
     69
     70  bool ParamCommand::execute(float abs, float rel)
     71  {
     72    BufferedParamCommand& paramCommand = *paramCommand_;
     73    // command has an additional parameter
     74    if (bRelative_ && (rel > 0 || rel < 0))
     75    {
     76      // we have to calculate a relative movement.
     77      // paramModifier_ says how much one keystroke is
     78      paramCommand.value_ += paramModifier_ * rel;
     79    }
     80    else if (abs > 0 || abs < 0)
     81    {
     82      // we have to calculate absolute position of the axis.
     83      // Since there might be another axis that is affected, we have to wait and
     84      // store the result in a temporary place
     85      paramCommand.value_ = (paramCommand.value_ * paramCommand.nValuesAdded_ + paramModifier_ * abs)
     86                            /++paramCommand.nValuesAdded_;
     87    }
     88    return true;
     89  }
     90
     91  void Button::clear()
     92  {
     93    for (unsigned int j = 0; j < 3; j++)
     94    {
     95      if (nCommands_[j])
     96      {
     97        // delete all commands and the command pointer array
     98        for (unsigned int i = 0; i < nCommands_[j]; i++)
     99          delete commands_[j][i];
     100        delete[] commands_[j];
     101        commands_[j] = 0;
     102        nCommands_[j] = 0;
     103      }
     104      else
     105      {
     106        commands_[j] = 0;
     107      }
     108    }
     109  }
     110
     111  void Button::parse(std::vector<BufferedParamCommand*>& paramCommandBuffer)
     112  {
     113    if (isEmpty(bindingString_))
     114    {
     115      clear();
     116      return;
     117    }
     118
     119    // use std::vector for a temporary dynamic array
     120    std::vector<BaseCommand*> commands[3];
     121
     122
     123    // separate the commands
     124    SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
     125        '\\', false, '"', false, '(', ')', false, '\0');
     126
     127    for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
     128    {
     129      if (commandStrings[iCommand] != "")
     130      {
     131        SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
     132            '\\', false, '"', false, '(', ')', false, '\0');
     133       
     134        unsigned int iToken = 0;
     135
     136        // for real axes, we can feed a ButtonThreshold argument as entire command
     137        if (getLowercase(tokens[0]) == "buttonthreshold")
     138        {
     139          if (tokens.size() == 1)
     140            continue;
     141          // may fail, but doesn't matter
     142          convertValue(&buttonThreshold_, tokens[1]);
     143          continue;
     144        }
     145
     146        // first argument can be OnPress, OnHold OnRelease or nothing
     147        KeybindMode::Enum mode = KeybindMode::None;
     148        if (getLowercase(tokens[iToken]) == "onpress")
     149          mode = KeybindMode::OnPress,   iToken++;
     150        if (getLowercase(tokens[iToken]) == "onrelease")
     151          mode = KeybindMode::OnRelease, iToken++;
     152        if (getLowercase(tokens[iToken]) == "onhold")
     153          mode = KeybindMode::OnHold,    iToken++;
     154
     155        if (iToken == tokens.size())
     156          continue;
     157
     158        // second argument can be the amplitude for the case it as an axis command
     159        // default amplitude is 1.0f
     160        float paramModifier = 1.0f;
     161        if (getLowercase(tokens[iToken]) == "axisamp")
     162        {
     163          iToken++;
     164          if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
     165          {
     166            COUT(2) << "Error while parsing key binding " << name_
     167                << ". Numeric expression expected afer 'AxisAmp', switching to default value" << std::endl;
     168            if (iToken == tokens.size())
     169              continue;
     170          }
     171          iToken++;
     172        }
     173
     174        // no more arguments expected except for the actual command
     175        if (iToken == tokens.size())
     176          continue;
     177
     178        std::string commandStr;
     179        while (iToken != tokens.size())
     180          commandStr += tokens[iToken++] + " ";
     181
     182        // evaluate the command
     183        CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
     184        if (!eval.isValid())
     185          continue;
     186
     187        // check for param command
     188        int paramIndex = eval.getEvaluatedExecutor()->getAxisParamIndex();
     189        // TODO: check in Executor for correct paramIndex
     190        if (paramIndex >= 0)
     191        {
     192          // parameter supported command
     193          ParamCommand* cmd = new ParamCommand();
     194          cmd->paramModifier_ = paramModifier;
     195          cmd->bRelative_ = eval.getEvaluatedExecutor()->getIsAxisRelative();
     196
     197          // add command to the buffer if not yet existing
     198          for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer.size(); iParamCmd++)
     199          {
     200            if (getLowercase(paramCommandBuffer[iParamCmd]->evaluation_.getCommandString())
     201                == getLowercase(commandStr))
     202            {
     203              // already in list
     204              cmd->paramCommand_ = paramCommandBuffer[iParamCmd];
     205              break;
     206            }
     207          }
     208          if (cmd->paramCommand_ == 0)
     209          {
     210            cmd->paramCommand_ = new BufferedParamCommand();
     211            paramCommandBuffer.push_back(cmd->paramCommand_);
     212            cmd->paramCommand_->evaluation_ = eval;
     213            cmd->paramCommand_->paramIndex_ = paramIndex;
     214          }
     215
     216
     217          // we don't know whether this is an actual axis or just a button
     218          if (mode == KeybindMode::None)
     219          {
     220            if (!addParamCommand(cmd))
     221            {
     222              mode = eval.getEvaluatedExecutor()->getKeybindMode();
     223              commands[mode].push_back(cmd);
     224            }
     225          }
     226        }
     227        else
     228        {
     229          SimpleCommand* cmd = new SimpleCommand();
     230          cmd->evaluation_ = eval;
     231
     232          //TODO: check CommandEvaluation for correct KeybindMode
     233          if (mode == KeybindMode::None)
     234            mode = eval.getEvaluatedExecutor()->getKeybindMode();
     235
     236          commands[mode].push_back(cmd);
     237        }
     238      }
     239    }
     240
     241    for (unsigned int j = 0; j < 3; j++)
     242    {
     243      nCommands_[j] = commands[j].size();
     244      if (nCommands_[j])
     245      {
     246        commands_[j] = new BaseCommand*[nCommands_[j]];
     247        for (unsigned int i = 0; i < commands[j].size(); i++)
     248          commands_[j][i] = commands[j][i];
     249      }
     250      else
     251        commands_[j] = 0;
     252    }
     253  }
     254
     255  bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
     256  {
     257    // execute all the parsed commands in the string
     258    for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
     259      commands_[mode][iCommand]->execute(abs, rel);
     260    return true;
     261  }
     262
     263  void HalfAxis::clear()
     264  {
     265    Button::clear();
     266    if (nParamCommands_)
     267    {
     268      // delete all commands and the command pointer array
     269      for (unsigned int i = 0; i < nParamCommands_; i++)
     270        delete paramCommands_[i];
     271      delete[] paramCommands_;
     272    }
     273    else
     274    {
     275      nParamCommands_ = 0; nParamCommands_ = 0;
     276    }
     277  }
     278 
     279  bool HalfAxis::addParamCommand(ParamCommand* command)
     280  {
     281    ParamCommand** cmds = paramCommands_;
     282    paramCommands_ = new ParamCommand*[++nParamCommands_];
     283    unsigned int i;
     284    for (i = 0; i < nParamCommands_ - 1; i++)
     285      paramCommands_[i] = cmds[i];
     286    paramCommands_[i] = command;
     287    delete[] cmds;
     288    return true;
     289  }
     290
     291  bool HalfAxis::execute()
     292  {
     293    bool success = true;
     294    for (unsigned int i = 0; i < nParamCommands_; i++)
     295      success = success && paramCommands_[i]->execute(absVal_, relVal_);
     296    return success;
     297  }
     298
     299
     300  // ###############################
    44301  // ######     KeyBinder     ######
    45302  // ###############################
     
    48305    @brief Constructor that does as little as necessary.
    49306  */
    50   KeyBinder::KeyBinder()
     307  KeyBinder::KeyBinder() : deriveTime_(0.0f)
    51308  {
    52309    RegisterObject(KeyBinder);
    53     clearBindings();
    54 
     310
     311    // keys
    55312    std::string keyNames[] = {
    56     "UNASSIGNED",
    57     "ESCAPE",
    58     "1",
    59     "2",
    60     "3",
    61     "4",
    62     "5",
    63     "6",
    64     "7",
    65     "8",
    66     "9",
    67     "0",
    68     "MINUS",
    69     "EQUALS",
    70     "BACK",
    71     "TAB",
    72     "Q",
    73     "W",
    74     "E",
    75     "R",
    76     "T",
    77     "Y",
    78     "U",
    79     "I",
    80     "O",
    81     "P",
    82     "LBRACKET",
    83     "RBRACKET",
    84     "RETURN",
    85     "LCONTROL",
    86     "A",
    87     "S",
    88     "D",
    89     "F",
    90     "G",
    91     "H",
    92     "J",
    93     "K",
    94     "L",
    95     "SEMICOLON",
    96     "APOSTROPHE",
    97     "GRAVE",
    98     "LSHIFT",
    99     "BACKSLASH",
    100     "Z",
    101     "X",
    102     "C",
    103     "V",
    104     "B",
    105     "N",
    106     "M",
    107     "COMMA",
    108     "PERIOD",
    109     "SLASH",
    110     "RSHIFT",
    111     "MULTIPLY",
    112     "LMENU",
    113     "SPACE",
    114     "CAPITAL",
    115     "F1",
    116     "F2",
    117     "F3",
    118     "F4",
    119     "F5",
    120     "F6",
    121     "F7",
    122     "F8",
    123     "F9",
    124     "F10",
    125     "NUMLOCK",
    126     "SCROLL",
    127     "NUMPAD7",
    128     "NUMPAD8",
    129     "NUMPAD9",
    130     "SUBTRACT",
    131     "NUMPAD4",
    132     "NUMPAD5",
    133     "NUMPAD6",
    134     "ADD",
    135     "NUMPAD1",
    136     "NUMPAD2",
    137     "NUMPAD3",
    138     "NUMPAD0",
    139     "DECIMAL",
    140     "","",
    141     "OEM_102",
    142     "F11",
    143     "F12",
    144     "","","","","","","","","","","",
    145     "F13",
    146     "F14",
    147     "F15",
    148     "","","","","","","","","","",
    149     "KANA",
    150     "","",
    151     "ABNT_C1",
    152     "","","","","",
    153     "CONVERT",
    154     "",
    155     "NOCONVERT",
    156     "",
    157     "YEN",
    158     "ABNT_C2",
    159     "","","","","","","","","","","","","","",
    160     "NUMPADEQUALS",
    161     "","",
    162     "PREVTRACK",
    163     "AT",
    164     "COLON",
    165     "UNDERLINE",
    166     "KANJI",
    167     "STOP",
    168     "AX",
    169     "UNLABELED",
    170     "NEXTTRACK",
    171     "","",
    172     "NUMPADENTER",
    173     "RCONTROL",
    174     "","",
    175     "MUTE",
    176     "CALCULATOR",
    177     "PLAYPAUSE",
    178     "",
    179     "MEDIASTOP",
    180     "","","","","","","","","",
    181     "VOLUMEDOWN",
    182     "",
    183     "VOLUMEUP",
    184     "",
    185     "WEBHOME",
    186     "NUMPADCOMMA",
    187     "",
    188     "DIVIDE",
    189     "",
    190     "SYSRQ",
    191     "RMENU",
    192     "","","","","","","","","","","","",
    193     "PAUSE",
    194     "",
    195     "HOME",
    196     "UP",
    197     "PGUP",
    198     "",
    199     "LEFT",
    200     "",
    201     "RIGHT",
    202     "",
    203     "END",
    204     "DOWN",
    205     "PGDOWN",
    206     "INSERT",
    207     "DELETE",
    208     "","","","","","","",
    209     "LWIN",
    210     "RWIN",
    211     "APPS",
    212     "POWER",
    213     "SLEEP",
    214     "","","",
    215     "WAKE",
    216     "",
    217     "WEBSEARCH",
    218     "WEBFAVORITES",
    219     "WEBREFRESH",
    220     "WEBSTOP",
    221     "WEBFORWARD",
    222     "WEBBACK",
    223     "MYCOMPUTER",
    224     "MAIL",
    225     "MEDIASELECT"
     313      "UNASSIGNED",
     314      "ESCAPE",
     315      "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
     316      "MINUS", "EQUALS", "BACK", "TAB",
     317      "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
     318      "LBRACKET", "RBRACKET",
     319      "RETURN", "LCONTROL",
     320      "A", "S", "D", "F", "G", "H", "J", "K", "L",
     321      "SEMICOLON", "APOSTROPHE", "GRAVE",
     322      "LSHIFT", "BACKSLASH",
     323      "Z", "X", "C", "V", "B", "N", "M",
     324      "COMMA", "PERIOD", "SLASH",
     325      "RSHIFT",
     326      "MULTIPLY",
     327      "LMENU",
     328      "SPACE",
     329      "CAPITAL",
     330      "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
     331      "NUMLOCK", "SCROLL",
     332      "NUMPAD7", "NUMPAD8", "NUMPAD9",
     333      "SUBTRACT",
     334      "NUMPAD4", "NUMPAD5", "NUMPAD6",
     335      "ADD",
     336      "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0",
     337      "DECIMAL",
     338      "","",
     339      "OEM_102",
     340      "F11", "F12",
     341      "","","","","","","","","","","",
     342      "F13", "F14", "F15",
     343      "","","","","","","","","","",
     344      "KANA",
     345      "","",
     346      "ABNT_C1",
     347      "","","","","",
     348      "CONVERT",
     349      "",
     350      "NOCONVERT",
     351      "",
     352      "YEN",
     353      "ABNT_C2",
     354      "","","","","","","","","","","","","","",
     355      "NUMPADEQUALS",
     356      "","",
     357      "PREVTRACK",
     358      "AT",
     359      "COLON", "UNDERLINE",
     360      "KANJI",
     361      "STOP",
     362      "AX",
     363      "UNLABELED",
     364      "NEXTTRACK",
     365      "","",
     366      "NUMPADENTER",
     367      "RCONTROL",
     368      "","",
     369      "MUTE",
     370      "CALCULATOR",
     371      "PLAYPAUSE",
     372      "",
     373      "MEDIASTOP",
     374      "","","","","","","","","",
     375      "VOLUMEDOWN",
     376      "",
     377      "VOLUMEUP",
     378      "",
     379      "WEBHOME",
     380      "NUMPADCOMMA",
     381      "",
     382      "DIVIDE",
     383      "",
     384      "SYSRQ",
     385      "RMENU",
     386      "","","","","","","","","","","","",
     387      "PAUSE",
     388      "",
     389      "HOME",
     390      "UP",
     391      "PGUP",
     392      "",
     393      "LEFT",
     394      "",
     395      "RIGHT",
     396      "",
     397      "END", "DOWN", "PGDOWN", "INSERT", "DELETE",
     398      "","","","","","","",
     399      "LWIN", "RWIN", "APPS",
     400      "POWER", "SLEEP",
     401      "","","",
     402      "WAKE",
     403      "",
     404      "WEBSEARCH", "WEBFAVORITES", "WEBREFRESH", "WEBSTOP", "WEBFORWARD", "WEBBACK",
     405      "MYCOMPUTER", "MAIL", "MEDIASELECT"
    226406    };
    227     for (int i = 0; i < numberOfKeys_s; i++)
    228       keyNames_[i] = keyNames[i];
    229 
     407    for (unsigned int i = 0; i < nKeys_s; i++)
     408      keys_[i].name_ = "Key" + keyNames[i];
     409
     410    // mouse buttons
    230411    std::string mouseButtonNames[] = {
    231412      "MouseLeft", "MouseRight", "MouseMiddle",
    232413      "MouseButton3", "MouseButton4", "MouseButton5",
    233       "MouseButton6", "MouseButton7" };
    234     for (int i = 0; i < numberOfMouseButtons_s; i++)
    235       mouseButtonNames_[i] = mouseButtonNames[i];
    236 
    237     for (int i = 0; i < numberOfJoyStickButtons_s; i++)
    238       joyStickButtonNames_[i] = "JoyStick" + getConvertedValue<int, std::string>(i);
     414      "MouseButton6", "MouseButton7",
     415      "MouseWheel1Up", "MouseWheel1Down",
     416      "MouseWheel2Up", "MouseWheel2Down" };
     417    for (unsigned int i = 0; i < nMouseButtons_s; i++)
     418      mouseButtons_[i].name_ = mouseButtonNames[i];
     419
     420    // joy stick buttons
     421    for (unsigned int i = 0; i < 32; i++)
     422      joyStickButtons_[i].name_ = "JoyButton" + getConvertedValue<int, std::string>(i);
     423    for (unsigned int i = 32; i < nJoyStickButtons_s; i += 4)
     424    {
     425                  joyStickButtons_[i + 0].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "North";
     426                  joyStickButtons_[i + 1].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "South";
     427                  joyStickButtons_[i + 2].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "East";
     428                  joyStickButtons_[i + 3].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "West";
     429    }
     430
     431    // half axes
     432    std::string rawNames[nHalfAxes_s/2];
     433    rawNames[0] = "MouseX";
     434    rawNames[1] = "MouseY";
     435    rawNames[2] = "Empty1";
     436    rawNames[3] = "Empty2";
     437    for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
     438      rawNames[i] = "JoyAxis" + getConvertedValue<int, std::string>(i - 3);
     439    for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
     440    {
     441      halfAxes_[i * 2 + 0].name_ = rawNames[i] + "Pos";
     442      halfAxes_[i * 2 + 1].name_ = rawNames[i] + "Neg";
     443    }
     444
     445    for (unsigned int i = 0; i < this->nHalfAxes_s; i++)
     446      halfAxes_[i].buttonThreshold_ = buttonThreshold_;
    239447  }
    240448
     
    244452  KeyBinder::~KeyBinder()
    245453  {
     454    // almost no destructors required because most of the arrays are static.
     455    clearBindings(); // does some destruction work
     456  }
     457
     458  /**
     459    @brief Loads the key and button bindings.
     460    @return True if loading succeeded.
     461  */
     462  void KeyBinder::loadBindings()
     463  {
     464    COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
     465
     466    ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
     467    clearBindings();
     468    setConfigValues();
     469
     470    COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
    246471  }
    247472
     
    251476  void KeyBinder::setConfigValues()
    252477  {
    253     ConfigValueContainer* cont;
    254     std::string modes[] = {"P_", "R_", "H_"};
     478    SetConfigValue(analogThreshold_, 0.01f)  .description("Threshold for analog axes until which the state is 0.");
     479    SetConfigValue(bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
     480    SetConfigValue(derivePeriod_, 0.1f)      .description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
     481    SetConfigValue(mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
     482
     483    float oldThresh = buttonThreshold_;
     484    SetConfigValue(buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");
     485    if (oldThresh != buttonThreshold_)
     486      for (unsigned int i = 0; i < nHalfAxes_s; i++)
     487        if (halfAxes_[i].buttonThreshold_ == oldThresh)
     488          halfAxes_[i].buttonThreshold_ = buttonThreshold_;
    255489
    256490    // keys
    257     for (int i = 0; i < numberOfKeys_s; i++)
    258     {
    259       for (int j = 0; j < 3; j++)
    260       {
    261         cont = getIdentifier()->getConfigValueContainer(modes[j] + keyNames_[i]);
    262         if (!cont)
    263         {
    264           cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), modes[j] + keyNames_[i], "");
    265           getIdentifier()->addConfigValueContainer(modes[j] + keyNames_[i], cont);
    266         }
    267         switch (j)
    268         {
    269           case 0:
    270             cont->getValue(&bindingsKeyPress_[i].commandStr);
    271             break;
    272           case 1:
    273             cont->getValue(&bindingsKeyRelease_[i].commandStr);
    274             break;
    275           case 2:
    276             cont->getValue(&bindingsKeyHold_[i].commandStr);
    277         }
    278       }
    279     }
    280 
     491    for (unsigned int i = 0; i < nKeys_s; i++)
     492      readTrigger(keys_[i]);
    281493    // mouse buttons
    282     for (int i = 0; i < numberOfMouseButtons_s; i++)
    283     {
    284       for (int j = 0; j < 3; j++)
    285       {
    286         cont = getIdentifier()->getConfigValueContainer(modes[j] + mouseButtonNames_[i]);
    287         if (!cont)
    288         {
    289           cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), modes[j] + mouseButtonNames_[i], "");
    290           getIdentifier()->addConfigValueContainer(modes[j] + mouseButtonNames_[i], cont);
    291         }
    292         switch (j)
    293         {
    294           case 0:
    295             cont->getValue(&bindingsMouseButtonPress_[i].commandStr);
    296             break;
    297           case 1:
    298             cont->getValue(&bindingsMouseButtonRelease_[i].commandStr);
    299             break;
    300           case 2:
    301             cont->getValue(&bindingsMouseButtonHold_[i].commandStr);
    302         }
    303       }
    304     }
    305 
     494    for (unsigned int i = 0; i < nMouseButtons_s; i++)
     495      readTrigger(mouseButtons_[i]);
    306496    // joy stick buttons
    307     for (int i = 0; i < numberOfJoyStickButtons_s; i++)
    308     {
    309       for (int j = 0; j < 3; j++)
    310       {
    311         cont = getIdentifier()->getConfigValueContainer(modes[j] + joyStickButtonNames_[i]);
    312         if (!cont)
    313         {
    314           cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), modes[j] + joyStickButtonNames_[i], "");
    315           getIdentifier()->addConfigValueContainer(modes[j] + joyStickButtonNames_[i], cont);
    316         }
    317         switch (j)
    318         {
    319           case 0:
    320             cont->getValue(&bindingsJoyStickButtonPress_[i].commandStr);
    321             break;
    322           case 1:
    323             cont->getValue(&bindingsJoyStickButtonRelease_[i].commandStr);
    324             break;
    325           case 2:
    326             cont->getValue(&bindingsJoyStickButtonHold_[i].commandStr);
    327         }
    328       }
     497    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
     498      readTrigger(joyStickButtons_[i]);
     499    // half axes
     500    for (unsigned int i = 0; i < nHalfAxes_s; i++)
     501      readTrigger(halfAxes_[i]);
     502  }
     503
     504  void KeyBinder::readTrigger(Button& button)
     505  {
     506    // config value stuff
     507    ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer(button.name_);
     508    if (!cont)
     509    {
     510      cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), button.name_, "");
     511      getIdentifier()->addConfigValueContainer(button.name_, cont);
     512    }
     513    std::string old = button.bindingString_;
     514    cont->getValue(&button.bindingString_);
     515
     516    // keybinder stuff
     517    if (old != button.bindingString_)
     518    {
     519      // binding has changed
     520      button.parse(paramCommandBuffer_);
    329521    }
    330522  }
     
    333525    @brief Overwrites all bindings with ""
    334526  */
    335   void KeyBinder::clearBindings()
    336   {
    337     for (int i = 0; i < numberOfKeys_s; i++)
    338     {
    339       bindingsKeyPress_  [i].commandStr = "";
    340       bindingsKeyRelease_[i].commandStr = "";
    341       bindingsKeyHold_   [i].commandStr = "";
    342     }
    343     for (int i = 0; i < numberOfMouseButtons_s; i++)
    344     {
    345       bindingsMouseButtonPress_  [i].commandStr = "";
    346       bindingsMouseButtonRelease_[i].commandStr = "";
    347       bindingsMouseButtonHold_   [i].commandStr = "";
    348     }
    349     for (int i = 0; i < numberOfJoyStickButtons_s; i++)
    350     {
    351       bindingsJoyStickButtonPress_  [i].commandStr = "";
    352       bindingsJoyStickButtonRelease_[i].commandStr = "";
    353       bindingsJoyStickButtonHold_   [i].commandStr = "";
    354     }
    355   }
    356 
    357   /**
    358     @brief Loads the key and button bindings.
    359     @return True if loading succeeded.
    360   */
    361   bool KeyBinder::loadBindings()
    362   {
    363     COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings..." << std::endl;
    364 
    365     ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
    366     setConfigValues();
    367 
    368     // evaluate the key bindings
    369     // TODO: what if binding is invalid?
    370     for (int i = 0; i < numberOfKeys_s; i++)
    371     {
    372       if (bindingsKeyPress_[i].commandStr != "")
     527  void KeyBinder::clearBindings(bool bInit)
     528  {
     529    for (unsigned int i = 0; i < nKeys_s; i++)
     530      keys_[i].clear();
     531
     532    for (unsigned int i = 0; i < nMouseButtons_s; i++)
     533      mouseButtons_[i].clear();
     534
     535    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
     536      joyStickButtons_[i].clear();
     537
     538    for (unsigned int i = 0; i < nHalfAxes_s; i++)
     539      halfAxes_[i].clear();
     540
     541    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
     542      delete paramCommandBuffer_[i];
     543    paramCommandBuffer_.clear();
     544  }
     545
     546  void KeyBinder::tick(float dt)
     547  {
     548    // we have to process all the analog input since there is e.g. no 'mouseDoesntMove' event.
     549    for (unsigned int i = 0; i < nHalfAxes_s; i++)
     550    {
     551      if (halfAxes_[i].hasChanged_)
    373552      {
    374         bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
    375         bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
     553        if (!halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ > halfAxes_[i].buttonThreshold_)
     554        {
     555          halfAxes_[i].wasDown_ = true;
     556          if (halfAxes_[i].nCommands_[KeybindMode::OnPress])
     557            halfAxes_[i].execute(KeybindMode::OnPress);
     558        }
     559        else if (halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ < halfAxes_[i].buttonThreshold_)
     560        {
     561          halfAxes_[i].wasDown_ = false;
     562          if (halfAxes_[i].nCommands_[KeybindMode::OnRelease])
     563            halfAxes_[i].execute(KeybindMode::OnRelease);
     564        }
     565        if (halfAxes_[i].wasDown_)
     566        {
     567          if (halfAxes_[i].nCommands_[KeybindMode::OnHold])
     568            halfAxes_[i].execute(KeybindMode::OnHold);
     569        }
     570        halfAxes_[i].hasChanged_ = false;
    376571      }
    377     }
    378 
    379     COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
    380     return true;
    381   }
    382 
    383   bool KeyBinder::executeSimpleBinding(KeyBinding& binding)
    384   {
    385     if (binding.commandStr != "")
    386     {
    387       if (binding.commandStr != binding.evaluation.getCommandString())
     572
     573      // these are the actually useful axis bindings for analog input AND output
     574      if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_)
    388575      {
    389         // key binding has changed, reevaluate the command string.
    390         binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
    391         binding.commandStr = binding.evaluation.getCommandString();
     576        halfAxes_[i].execute();
    392577      }
    393       COUT(ORX_DEBUG) << "Keybinding: Executing command: " << binding.commandStr << std::endl;
    394       CommandExecutor::execute(binding.commandStr);
    395     }
    396 
    397     return true;
    398   }
    399 
    400 
    401   /**
    402     @brief Event handler for the keyPressed Event.
    403     @param e Event information
    404   */
    405   bool KeyBinder::keyPressed(const KeyEvent& evt)
    406   {
    407     // find the appropriate key binding
    408     executeSimpleBinding(bindingsKeyPress_[int(evt.key)]);
    409 
    410     return true;
    411   }
    412 
    413   /**
    414     @brief Event handler for the keyReleased Event.
    415     @param e Event information
    416   */
    417   bool KeyBinder::keyReleased(const KeyEvent& evt)
    418   {
    419     // find the appropriate key binding
    420     executeSimpleBinding(bindingsKeyRelease_[int(evt.key)]);
    421 
    422     return true;
    423   }
    424 
    425   /**
    426     @brief Event handler for the keyHeld Event.
    427     @param e Mouse state information
    428   */
    429   bool KeyBinder::keyHeld(const KeyEvent& evt)
    430   {
    431     // find the appropriate key binding
    432     executeSimpleBinding(bindingsKeyHold_[int(evt.key)]);
    433 
    434     return true;
    435   }
     578    }
     579
     580    if (bDeriveMouseInput_)
     581    {
     582      if (deriveTime_ > derivePeriod_)
     583      {
     584        deriveTime_ = 0.0f;
     585        //CCOUT(3) << "mouse abs: ";
     586        for (int i = 0; i < 2; i++)
     587        {
     588          if (mouseRelative_[i] > 0)
     589          {
     590            halfAxes_[2*i + 0].absVal_ = mouseRelative_[i] * derivePeriod_ / 500 * mouseSensitivity_;
     591            halfAxes_[2*i + 1].absVal_ = 0.0f;
     592          }
     593          else if (mouseRelative_[0] < 0)
     594          {
     595            halfAxes_[2*i + 0].absVal_ = 0.0f;
     596            halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] * derivePeriod_ / 500 * mouseSensitivity_;
     597          }
     598          //COUT(3) << mouseRelative_[i] << " | ";
     599          mouseRelative_[i] = 0;
     600        }
     601        //COUT(3) << std::endl;
     602      }
     603      else
     604        deriveTime_ += dt;
     605    }
     606
     607    // execute all buffered bindings (addional parameter)
     608    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
     609      paramCommandBuffer_[i]->execute();
     610
     611    // always reset the relative movement of the mouse
     612    for (unsigned int i = 0; i < 8; i++)
     613      halfAxes_[i].relVal_ = 0.0f;
     614  }
     615
     616  void KeyBinder::keyPressed (const KeyEvent& evt)
     617  { keys_[evt.key].execute(KeybindMode::OnPress); }
     618
     619  void KeyBinder::keyReleased(const KeyEvent& evt)
     620  { keys_[evt.key].execute(KeybindMode::OnRelease); }
     621
     622  void KeyBinder::keyHeld    (const KeyEvent& evt)
     623  { keys_[evt.key].execute(KeybindMode::OnHold); }
     624
     625
     626  void KeyBinder::mouseButtonPressed (MouseButton::Enum id)
     627  { mouseButtons_[id].execute(KeybindMode::OnPress); }
     628
     629  void KeyBinder::mouseButtonReleased(MouseButton::Enum id)
     630  { mouseButtons_[id].execute(KeybindMode::OnRelease); }
     631
     632  void KeyBinder::mouseButtonHeld    (MouseButton::Enum id)
     633  { mouseButtons_[id].execute(KeybindMode::OnHold); }
     634
     635
     636  void KeyBinder::joyStickButtonPressed (int joyStickID, int button)
     637  { joyStickButtons_[button].execute(KeybindMode::OnPress); }
     638
     639  void KeyBinder::joyStickButtonReleased(int joyStickID, int button)
     640  { joyStickButtons_[button].execute(KeybindMode::OnRelease); }
     641
     642  void KeyBinder::joyStickButtonHeld    (int joyStickID, int button)
     643  { joyStickButtons_[button].execute(KeybindMode::OnHold); }
    436644
    437645  /**
     
    439647    @param e Mouse state information
    440648  */
    441   bool KeyBinder::mouseMoved(const MouseState &evt)
    442   {
    443     /*if (bindingMouseMoved_.commandStr != "")
    444     {
    445       if (bindingMouseMoved_.commandStr != bindingMouseMoved_.evaluation.getCommandString())
     649  void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
     650  {
     651    if (!bDeriveMouseInput_)
     652    {
     653      // y axis of mouse input is inverted
     654      int rel[] = { rel_.x, -rel_.y };
     655
     656      //COUT(3) << rel[0] << " | " << rel[1] << std::endl;
     657
     658      for (int i = 0; i < 2; i++)
    446659      {
    447         // key binding has changed, reevaluate the command string.
    448         bindingMouseMoved_.evaluation = CommandExecutor::evaluate(bindingMouseMoved_.commandStr);
    449         bindingMouseMoved_.commandStr = bindingMouseMoved_.evaluation.getCommandString();
     660        if (rel[i])
     661        {
     662          // absolute
     663          if (mousePosition_[i] >= 0)
     664          {
     665            mousePosition_[i] += rel[i];
     666            halfAxes_[0 + 2*i].hasChanged_ = true;
     667            if (mousePosition_[i] < 0)
     668            {
     669              halfAxes_[1 + 2*i].hasChanged_ = true;
     670              halfAxes_[1 + 2*i].absVal_ = -((float)mousePosition_[i])/1024 * mouseSensitivity_;
     671              halfAxes_[0 + 2*i].absVal_ =  0.0f;
     672            }
     673            else
     674              halfAxes_[1 + 2*i].absVal_ =  ((float)mousePosition_[i])/1024 * mouseSensitivity_;
     675          }
     676          else
     677          {
     678            mousePosition_[i] += rel[i];
     679            halfAxes_[1 + 2*i].hasChanged_ = true;
     680            if (mousePosition_[i] > 0)
     681            {
     682              halfAxes_[0 + 2*i].hasChanged_ = true;
     683              halfAxes_[0 + 2*i].absVal_ =  ((float)mousePosition_[i])/1024 * mouseSensitivity_;
     684              halfAxes_[1 + 2*i].absVal_ =  0.0f;
     685            }
     686            else
     687              halfAxes_[1 + 2*i].absVal_ = -((float)mousePosition_[i])/1024 * mouseSensitivity_;
     688          }
     689
     690          // relative
     691          if (rel[i] > 0)
     692            halfAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/1024 * mouseSensitivity_;
     693          else
     694            halfAxes_[1 + 2*i].relVal_ = -((float)rel[i])/1024 * mouseSensitivity_;
     695        }
    450696      }
    451       COUT(3) << "Executing command: " << bindingMouseMoved_.commandStr << std::endl;
    452 
    453       bindingMouseMoved_.evaluation.setEvaluatedParameter(
    454       CommandExecutor::execute(bindingMouseMoved_.commandStr);
    455     }*/
    456 
    457     return true;
     697    }
     698    else
     699    {
     700      mouseRelative_[0] += rel_.x;
     701      mouseRelative_[1] -= rel_.y;
     702    }
    458703  }
    459704
     
    462707    @param e Mouse state information
    463708  */
    464   bool KeyBinder::mouseScrolled(const MouseState &evt)
    465   {
    466     return true;
    467   }
    468 
    469   /**
    470     @brief Event handler for the mousePressed Event.
    471     @param e Event information
    472     @param id The ID of the mouse button
    473   */
    474   bool KeyBinder::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
    475   {
    476     // find the appropriate key binding
    477     executeSimpleBinding(bindingsMouseButtonPress_[int(id)]);
    478 
    479     return true;
    480   }
    481 
    482   /**
    483     @brief Event handler for the mouseReleased Event.
    484     @param e Event information
    485     @param id The ID of the mouse button
    486   */
    487   bool KeyBinder::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
    488   {
    489     // find the appropriate key binding
    490     executeSimpleBinding(bindingsMouseButtonRelease_[int(id)]);
    491 
    492     return true;
    493   }
    494 
    495   /**
    496     @brief Event handler for the mouseHeld Event.
    497     @param e Event information
    498     @param id The ID of the mouse button
    499   */
    500   bool KeyBinder::mouseButtonHeld(const MouseState& state, MouseButton::Enum id)
    501   {
    502     // find the appropriate key binding
    503     executeSimpleBinding(bindingsMouseButtonHold_[int(id)]);
    504 
    505     return true;
    506   }
    507 
    508   bool KeyBinder::joyStickButtonPressed(const JoyStickState& state, int button)
    509   {
    510     // find the appropriate key binding
    511     executeSimpleBinding(bindingsJoyStickButtonPress_[button]);
    512 
    513     return true;
    514   }
    515 
    516   bool KeyBinder::joyStickButtonReleased(const JoyStickState& state, int button)
    517   {
    518     // find the appropriate key binding
    519     executeSimpleBinding(bindingsJoyStickButtonRelease_[button]);
    520 
    521     return true;
    522   }
    523 
    524   bool KeyBinder::joyStickButtonHeld(const JoyStickState& state, int button)
    525   {
    526     // find the appropriate key binding
    527     executeSimpleBinding(bindingsJoyStickButtonHold_[button]);
    528 
    529     return true;
    530   }
    531 
    532   bool KeyBinder::joyStickAxisMoved(const JoyStickState& state, int axis)
    533   {
    534     return true;
    535   }
    536 
    537   bool KeyBinder::joyStickSliderMoved(const JoyStickState& state, int index)
    538   {
    539     return true;
    540   }
    541 
    542   bool KeyBinder::joyStickPovMoved(const JoyStickState& state, int index)
    543   {
    544     return true;
    545   }
    546 
    547   bool KeyBinder::joyStickVector3Moved(const JoyStickState& state, int index)
    548   {
    549     return true;
    550   }
    551 
     709  void KeyBinder::mouseScrolled(int abs, int rel)
     710  {
     711    //COUT(3) << mouseButtons_[8].name_ << "   " << abs << " | " << rel << std::endl;
     712
     713    if (rel > 0)
     714      for (int i = 0; i < rel/120; i++)
     715        mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
     716    else
     717      for (int i = 0; i < -rel/120; i++)
     718        mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
     719  }
     720
     721  void KeyBinder::joyStickAxisMoved(int joyStickID, int axis, int value)
     722  {
     723    // TODO: check whether 16 bit integer as general axis value is a good idea (works under windows)
     724    CCOUT(3) << halfAxes_[8 + axis].name_ << std::endl;
     725    if (value >= 0)
     726    {
     727      halfAxes_[8 + axis].absVal_ = ((float)value)/0x8000;
     728      halfAxes_[8 + axis].relVal_ = ((float)value)/0x8000;
     729      halfAxes_[8 + axis].hasChanged_ = true;
     730    }
     731    else
     732    {
     733      halfAxes_[8 + axis + 1].absVal_ = -((float)value)/0x8000;
     734      halfAxes_[8 + axis + 1].relVal_ = -((float)value)/0x8000;
     735      halfAxes_[8 + axis + 1].hasChanged_ = true;
     736    }
     737  }
    552738
    553739
  • code/trunk/src/core/InputHandler.h

    r1293 r1349  
    3838
    3939#include <string>
     40#include <vector>
    4041
    4142#include "ois/OIS.h"
     43#include "util/Math.h"
    4244#include "OrxonoxClass.h"
    4345#include "CommandExecutor.h"
     
    4648namespace orxonox
    4749{
    48   namespace KeybindSetting
    49   {
    50     enum KeybindSetting
    51     {
    52       None,
    53       OnPress,
    54       OnRelease,
    55       Continuous,
    56     };
    57   }
    58 
    59   struct _CoreExport KeyBinding
    60   {
    61     std::string commandStr;
    62     CommandEvaluation evaluation;
    63   };
    64  
     50  class _CoreExport BaseCommand
     51  {
     52  public:
     53    virtual ~BaseCommand() { }
     54    virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;
     55  };
     56
     57  class _CoreExport BufferedParamCommand
     58  {
     59  public:
     60    BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
     61    bool execute();
     62
     63    float value_;
     64    unsigned int nValuesAdded_;
     65    int paramIndex_;
     66    CommandEvaluation evaluation_;
     67  };
     68
     69  class _CoreExport SimpleCommand : public BaseCommand
     70  {
     71  public:
     72    bool execute(float abs = 1.0f, float rel = 1.0f);
     73
     74    CommandEvaluation evaluation_;
     75  };
     76
     77  class _CoreExport ParamCommand : public BaseCommand
     78  {
     79  public:
     80    ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }
     81    bool execute(float abs = 1.0f, float rel = 1.0f);
     82
     83    bool bRelative_;
     84    float paramModifier_;
     85    BufferedParamCommand* paramCommand_;
     86  };
     87
     88  class _CoreExport Button
     89  {
     90  public:
     91    Button() { nCommands_[0]=0; nCommands_[1]=0; nCommands_[2]=0; clear(); }
     92    virtual ~Button() { clear(); }
     93    virtual void clear();
     94    virtual bool addParamCommand(ParamCommand* command) { return false; }
     95    void parse(std::vector<BufferedParamCommand*>& paramCommandBuffer);
     96    bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
     97
     98    //! The configured string value
     99    std::string bindingString_;
     100    //! Name of the trigger as strings
     101    std::string name_;
     102    //! Basic commands for OnPress, OnHold and OnRelease
     103    BaseCommand** commands_[3];
     104    //! Number of basic commands
     105    unsigned int nCommands_[3];
     106    //! Says how much it takes for an analog axis to trigger a button
     107    //! Note: This variable is here to have only one parse() function.
     108    float buttonThreshold_;
     109  };
     110
     111
     112  class _CoreExport HalfAxis : public Button
     113  {
     114  public:
     115    HalfAxis() : relVal_(0.0f), absVal_(0.0f), paramCommands_(0), nParamCommands_(0),
     116                 wasDown_(false), hasChanged_(false) { }
     117    using Button::execute;
     118    bool execute();
     119    //bool execute(KeybindMode::Enum mode) { return Button::execute(mode); }
     120    bool addParamCommand(ParamCommand* command);
     121    void clear();
     122
     123    // axis related
     124    float relVal_;
     125    float absVal_;
     126    ParamCommand** paramCommands_;
     127    unsigned int nParamCommands_;
     128
     129    // button related
     130    bool wasDown_;
     131    bool hasChanged_;
     132  };
     133
    65134
    66135  /**
    67     @brief Captures mouse, keyboard and joy stick input while in the actual game mode.
     136    @brief Handles mouse, keyboard and joy stick input while in the actual game mode.
    68137           Manages the key bindings.
    69138  */
     
    74143    ~KeyBinder();
    75144
    76     bool loadBindings();
    77     void clearBindings();
     145    void loadBindings();
     146    void clearBindings(bool bInit = false);
    78147
    79148    void setConfigValues();
    80149
    81150  private: // functions
    82 
    83     bool executeSimpleBinding(KeyBinding &binding);
    84 
    85     bool keyPressed (const KeyEvent& evt);
    86     bool keyReleased(const KeyEvent& evt);
    87     bool keyHeld    (const KeyEvent& evt);
    88 
    89     bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
    90     bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
    91     bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id);
    92     bool mouseMoved         (const MouseState& state);
    93     bool mouseScrolled      (const MouseState& state);
    94 
    95     bool joyStickButtonPressed (const JoyStickState& state, int button);
    96     bool joyStickButtonReleased(const JoyStickState& state, int button);
    97     bool joyStickButtonHeld    (const JoyStickState& state, int button);
    98     bool joyStickAxisMoved     (const JoyStickState& state, int axis)  ;
    99     bool joyStickSliderMoved   (const JoyStickState& state, int index) ;
    100     bool joyStickPovMoved      (const JoyStickState& state, int index) ;
    101     bool joyStickVector3Moved  (const JoyStickState& state, int index) ;
     151    void readTrigger(Button& button);
     152
     153    //static void clearBundle(KeyBindingBundle& bundle, bool bInit);
     154    //static void redimensionBinding(KeyBinding& binding);
     155
     156    void tick(float dt);
     157
     158    void keyPressed (const KeyEvent& evt);
     159    void keyReleased(const KeyEvent& evt);
     160    void keyHeld    (const KeyEvent& evt);
     161
     162    void mouseButtonPressed (MouseButton::Enum id);
     163    void mouseButtonReleased(MouseButton::Enum id);
     164    void mouseButtonHeld    (MouseButton::Enum id);
     165    void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
     166    void mouseScrolled      (int abs, int rel);
     167
     168    void joyStickButtonPressed (int joyStickID, int button);
     169    void joyStickButtonReleased(int joyStickID, int button);
     170    void joyStickButtonHeld    (int joyStickID, int button);
     171    void joyStickAxisMoved     (int joyStickID, int axis, int value);
    102172
    103173  private: // variables
    104 
    105174    //! denotes the number of different keys there are in OIS.
    106     static const int numberOfKeys_s = 0xEE;
    107     //! Array of input events for every pressed key
    108     KeyBinding bindingsKeyPress_  [numberOfKeys_s];
    109     //! Array of input events for every released key
    110     KeyBinding bindingsKeyRelease_[numberOfKeys_s];
    111     //! Array of input events for every held key
    112     KeyBinding bindingsKeyHold_   [numberOfKeys_s];
    113     //! Names of the keys as strings
    114     std::string keyNames_[numberOfKeys_s];
     175    static const unsigned int nKeys_s = 0xEE;
     176    //! Actual key bindings as bundle for Press, Hold and Release
     177    Button keys_ [nKeys_s];
    115178
    116179    //! denotes the number of different mouse buttons there are in OIS.
    117     static const int numberOfMouseButtons_s = 8;
    118     //! Array of input events for every pressed mouse button
    119     KeyBinding bindingsMouseButtonPress_  [numberOfMouseButtons_s];
    120     //! Array of input events for every released mouse button
    121     KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s];
    122     //! Array of input events for every held mouse button
    123     KeyBinding bindingsMouseButtonHold_   [numberOfMouseButtons_s];
    124     //! Key binding for mouse moved event
    125     KeyBinding bindingMouseMoved_;
    126     //! Key binding for mouse scrolled event
    127     KeyBinding bindingMouseScrolled_;
    128     //! Names of the mouse buttons as strings
    129     std::string mouseButtonNames_[numberOfMouseButtons_s];
     180    static const unsigned int nMouseButtons_s = 8 + 2*2; // 8 buttons and 2 scroll wheels
     181    //! Actual key bindings as bundle for Press, Hold and Release
     182    Button mouseButtons_ [nMouseButtons_s];
    130183
    131184    //! denotes the number of different joy stick buttons there are in OIS.
    132     static const int numberOfJoyStickButtons_s = 32;
    133     //! Array of input events for every pressed joy stick button
    134     KeyBinding bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
    135     //! Array of input events for every released joy stick button
    136     KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
    137     //! Array of input events for every held joy stick button
    138     KeyBinding bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
    139     //! Names of the joy stick buttons as strings
    140     std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
    141 
     185    static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
     186    //! Actual key bindings as bundle for Press, Hold and Release
     187    Button joyStickButtons_ [nJoyStickButtons_s];
     188
     189    //! denotes the number of half axes (every axis twice) there can be.
     190    static const unsigned int nHalfAxes_s = 56;
     191    /**
     192    * Array with all the half axes for mouse and joy sticks.
     193    * Keep in mind that the positions are fixed and that the first entry is the
     194    * positive one and the second is negative.
     195    * Sequence is as follows:
     196    *  0 -  3: Mouse x and y
     197    *  4 -  7: empty
     198    *  8 - 23: joy stick (slider) axes 1 to 8
     199    * 24 - 55: joy stick axes 1 - 16
     200    */
     201    HalfAxis halfAxes_[nHalfAxes_s];
     202
     203    /**
     204    * Commands that have additional parameters (axes) are executed at the end of
     205    * the tick() so that all values can be buffered for single execution.
     206    */
     207    std::vector<BufferedParamCommand*> paramCommandBuffer_;
     208
     209    //! Keeps track of the absolute mouse value (incl. scroll wheel)
     210    int mousePosition_[3];
     211    //! Used to derive mouse input if requested
     212    int mouseRelative_[2];
     213    float deriveTime_;
     214
     215    //##### ConfigValues #####
     216    //! Threshold for analog triggers until which the state is 0.
     217    float analogThreshold_;
     218    //! Threshold for analog triggers until which the button is not pressed.
     219    float buttonThreshold_;
     220    //! Derive mouse input for absolute values?
     221    bool bDeriveMouseInput_;
     222    //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
     223    float derivePeriod_;
     224    //! mouse sensitivity
     225    float mouseSensitivity_;
    142226  };
    143227
  • code/trunk/src/core/InputInterfaces.h

    r1293 r1349  
    3838
    3939#include "ois/OIS.h"
     40#include "util/Math.h"
    4041
    4142namespace orxonox
     
    239240  };
    240241
    241   typedef OIS::MouseState MouseState;
    242 
    243   class _CoreExport JoyStickState : OIS::JoyStickState
     242  //typedef OIS::MouseState MouseState;
     243
     244  /*class _CoreExport JoyStickState
    244245  {
    245246  public:
     
    247248    JoyStickState() { clear(); }
    248249    int mJoyStickID;
     250                JoyStickState() { clear(); }
     251
     252                std::vector<bool> mButtons;
     253                int axes[16];
     254                std::vector<Vector3> mVectors;
     255  };*/
     256
     257  class _CoreExport InputTickable
     258  {
     259  public:
     260    virtual ~InputTickable() { }
     261    virtual void tick(float dt) = 0;
    249262  };
    250263
     
    252265    @brief Interface class used for key input listeners.
    253266  */
    254   class _CoreExport KeyHandler
     267  class _CoreExport KeyHandler : virtual public InputTickable
    255268  {
    256269  public:
    257270    virtual ~KeyHandler() { }
    258     virtual bool keyPressed (const KeyEvent& evt) = 0;
    259     virtual bool keyReleased(const KeyEvent& evt) = 0;
    260     virtual bool keyHeld    (const KeyEvent& evt) = 0;
     271    virtual void keyPressed (const KeyEvent& evt) = 0;
     272    virtual void keyReleased(const KeyEvent& evt) = 0;
     273    virtual void keyHeld    (const KeyEvent& evt) = 0;
    261274  };
    262275
     
    264277    @brief Interface class used for mouse input listeners.
    265278  */
    266   class _CoreExport MouseHandler
     279  class _CoreExport MouseHandler : virtual public InputTickable
    267280  {
    268281  public:
    269282    virtual ~MouseHandler() { }
    270     virtual bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id) = 0;
    271     virtual bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id) = 0;
    272     virtual bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) = 0;
    273     virtual bool mouseMoved         (const MouseState& state) = 0;
    274     virtual bool mouseScrolled      (const MouseState& state) = 0;
     283    virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
     284    virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
     285    virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
     286    virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
     287    virtual void mouseScrolled      (int abs, int rel)    = 0;
    275288  };
    276289
     
    279292    @brief Interface class used for joy stick input listeners.
    280293  */
    281   class _CoreExport JoyStickHandler
     294  class _CoreExport JoyStickHandler : virtual public InputTickable
    282295  {
    283296  public:
    284297    virtual ~JoyStickHandler() { }
    285     virtual bool joyStickButtonPressed (const JoyStickState& state, int button) = 0;
    286     virtual bool joyStickButtonReleased(const JoyStickState& state, int button) = 0;
    287     virtual bool joyStickButtonHeld    (const JoyStickState& state, int button) = 0;
    288     virtual bool joyStickAxisMoved     (const JoyStickState& state, int axis)   = 0;
    289     virtual bool joyStickSliderMoved   (const JoyStickState& state, int index) {return true;}
    290     virtual bool joyStickPovMoved      (const JoyStickState& state, int index) {return true;}
    291     virtual bool joyStickVector3Moved  (const JoyStickState& state, int index) {return true;}
     298    virtual void joyStickButtonPressed (int joyStickID, int button) = 0;
     299    virtual void joyStickButtonReleased(int joyStickID, int button) = 0;
     300    virtual void joyStickButtonHeld    (int joyStickID, int button) = 0;
     301    virtual void joyStickAxisMoved     (int joyStickID, int axis, int value) = 0;
     302    //virtual bool joyStickVector3Moved  (int joyStickID, int index /*, fill list*/) {return true;}
    292303  };
    293304
  • code/trunk/src/core/InputManager.cc

    r1293 r1349  
    9898      windowHndStr << (unsigned int)windowHnd;
    9999      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    100 
     100      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
     101      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
    101102//#if defined OIS_LINUX_PLATFORM
    102103//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
     
    126127
    127128      // Set mouse/joystick region
    128       setWindowExtents(windowWidth, windowHeight);
     129      if (mouse_)
     130      {
     131        //// hack the mouse position
     132        //((OIS::MouseState&)mouse_->getMouseState()).X.abs = windowWidth/2;
     133        //((OIS::MouseState&)mouse_->getMouseState()).Y.abs = windowHeight/2;
     134        setWindowExtents(windowWidth, windowHeight);
     135      }
    129136
    130137      state_ = IS_NONE;
     
    267274    activeJoyStickHandlers_.resize(joySticksSize_);
    268275    joyStickButtonsDown_.resize(joySticksSize_);
     276    povStates_.resize(joySticksSize_);
     277    sliderStates_.resize(joySticksSize_);
    269278    return success;
    270279  }
     
    350359  }
    351360
     361  void InputManager::_updateTickables()
     362  {
     363    // we can use a set to have a list of unique pointers (an object can implement all 3 handlers)
     364    std::set<InputTickable*> tempSet;
     365    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
     366      tempSet.insert(activeKeyHandlers_[iHandler]);
     367    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
     368      tempSet.insert(activeMouseHandlers_[iHandler]);
     369    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
     370      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     371        tempSet.insert(activeJoyStickHandlers_[iJoyStick][iHandler]);
     372
     373    // copy the content of the set back to the actual vector
     374    activeHandlers_.clear();
     375    for (std::set<InputTickable*>::const_iterator itHandler = tempSet.begin(); itHandler != tempSet.end(); itHandler++)
     376      activeHandlers_.push_back(*itHandler);
     377  }
     378
    352379
    353380  // #################################
     
    380407          // normal play mode
    381408          // note: we assume that the handlers exist since otherwise, something's wrong anyway.
    382           activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
    383           activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    384           if (getMouseHandler("SpaceShip"))
    385             activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
    386           for (unsigned int i = 0; i < joySticksSize_; i++)
    387             activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
     409          enableKeyHandler("keybinder");
     410          enableMouseHandler("keybinder");
     411          enableMouseHandler("SpaceShip");
     412          enableJoyStickHandler("keybinder", 0);
    388413          break;
    389414
    390415        case IS_GUI:
    391           // FIXME: do stuff
     416          // TODO: do stuff
    392417          break;
    393418
    394419        case IS_CONSOLE:
    395           activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    396           if (getMouseHandler("SpaceShip"))
    397             activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
    398           for (unsigned int i = 0; i < joySticksSize_; i++)
    399             activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
    400 
    401           activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
     420          enableMouseHandler("keybinder");
     421          enableMouseHandler("SpaceShip");
     422          enableJoyStickHandler("keybinder", 0);
     423          enableKeyHandler("buffer");
    402424          break;
    403425
     
    426448    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
    427449      for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
    428         activeMouseHandlers_[iHandler]->mouseButtonHeld(mouse_->getMouseState(), mouseButtonsDown_[iButton]);
     450        activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
    429451
    430452    // call all the handlers for the held joy stick button events
     
    432454      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
    433455        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    434           activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(
    435               JoyStickState(joySticks_[iJoyStick]->getJoyStickState(), iJoyStick), joyStickButtonsDown_[iJoyStick][iButton]);
     456          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
     457
     458
     459    // call the ticks
     460    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
     461      activeHandlers_[iHandler]->tick(dt);
    436462  }
    437463
     
    508534    {
    509535      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    510         activeMouseHandlers_[i]->mouseMoved(e.state);
     536        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
     537            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
    511538    }
    512539
     
    515542    {
    516543      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    517         activeMouseHandlers_[i]->mouseScrolled(e.state);
     544        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
    518545    }
    519546
     
    536563
    537564    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    538       activeMouseHandlers_[i]->mouseButtonPressed(e.state, (MouseButton::Enum)id);
     565      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
    539566
    540567    return true;
     
    559586
    560587    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    561       activeMouseHandlers_[i]->mouseButtonReleased(e.state, (MouseButton::Enum)id);
     588      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
    562589
    563590    return true;
     
    584611
    585612    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    586       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(JoyStickState(arg.state, iJoyStick), button);
     613      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
    587614
    588615    return true;
     
    609636
    610637    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    611       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(JoyStickState(arg.state, iJoyStick), button);
     638      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
    612639
    613640    return true;
     
    616643  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
    617644  {
     645    //CCOUT(3) << arg.state.mAxes[axis].abs << std::endl;
    618646    // use the device to identify which one called the method
    619647    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     
    622650      iJoyStick++;
    623651
     652    // keep in mind that the first 8 axes are reserved for the sliders
    624653    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    625       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(JoyStickState(arg.state, iJoyStick), axis);
     654      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
    626655
    627656    return true;
     
    630659  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
    631660  {
     661    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
    632662    // use the device to identify which one called the method
    633663    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     
    636666      iJoyStick++;
    637667
    638     for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    639       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickSliderMoved(JoyStickState(arg.state, iJoyStick), id);
     668    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
     669    {
     670      // slider X axis changed
     671      sliderStates_[iJoyStick].sliderStates[id].x = arg.state.mSliders[id].abX;
     672      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     673        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, id * 2, arg.state.mSliders[id].abX);
     674    }
     675    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
     676    {
     677      // slider Y axis changed
     678      sliderStates_[iJoyStick].sliderStates[id].y = arg.state.mSliders[id].abY;
     679      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     680        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
     681    }
    640682
    641683    return true;
     
    650692      iJoyStick++;
    651693
    652     for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    653       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickPovMoved(JoyStickState(arg.state, iJoyStick), id);
    654 
    655     return true;
    656   }
    657 
    658   bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
     694    // translate the POV into 8 simple buttons
     695    int lastState = povStates_[iJoyStick][id];
     696    if (lastState & OIS::Pov::North)
     697      buttonReleased(arg, 32 + id * 4 + 0);
     698    if (lastState & OIS::Pov::South)
     699      buttonReleased(arg, 32 + id * 4 + 1);
     700    if (lastState & OIS::Pov::East)
     701      buttonReleased(arg, 32 + id * 4 + 2);
     702    if (lastState & OIS::Pov::West)
     703      buttonReleased(arg, 32 + id * 4 + 3);
     704   
     705    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
     706    int currentState = povStates_[iJoyStick][id];
     707    if (currentState & OIS::Pov::North)
     708      buttonPressed(arg, 32 + id * 4 + 0);
     709    if (currentState & OIS::Pov::South)
     710      buttonPressed(arg, 32 + id * 4 + 1);
     711    if (currentState & OIS::Pov::East)
     712      buttonPressed(arg, 32 + id * 4 + 2);
     713    if (currentState & OIS::Pov::West)
     714      buttonPressed(arg, 32 + id * 4 + 3);
     715
     716    return true;
     717  }
     718
     719  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
    659720  {
    660721    // use the device to identify which one called the method
     
    668729
    669730    return true;
    670   }
     731  }*/
    671732
    672733
     
    735796  }
    736797
    737   const MouseState InputManager::getMouseState()
     798  /*const MouseState InputManager::getMouseState()
    738799  {
    739800    if (_getSingleton().mouse_)
     
    741802    else
    742803      return MouseState();
    743   }
    744 
    745   const JoyStickState InputManager::getJoyStickState(unsigned int ID)
     804  }*/
     805
     806  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
    746807  {
    747808    if (ID < _getSingleton().joySticksSize_)
     
    749810    else
    750811      return JoyStickState();
    751   }
     812  }*/
    752813
    753814
     
    882943      if ((*it) == (*mapIt).second)
    883944      {
    884         _getSingleton().stateRequest_ = IS_CUSTOM;
    885945        return true;
    886946      }
     
    888948    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
    889949    _getSingleton().stateRequest_ = IS_CUSTOM;
     950    _getSingleton()._updateTickables();
    890951    return true;
    891952  }
     
    910971        _getSingleton().activeKeyHandlers_.erase(it);
    911972        _getSingleton().stateRequest_ = IS_CUSTOM;
     973        _getSingleton()._updateTickables();
    912974        return true;
    913975      }
    914976    }
    915     _getSingleton().stateRequest_ = IS_CUSTOM;
    916977    return true;
    917978  }
     
    10101071      if ((*it) == (*mapIt).second)
    10111072      {
    1012         _getSingleton().stateRequest_ = IS_CUSTOM;
    10131073        return true;
    10141074      }
     
    10161076    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
    10171077    _getSingleton().stateRequest_ = IS_CUSTOM;
     1078    _getSingleton()._updateTickables();
    10181079    return true;
    10191080  }
     
    10381099        _getSingleton().activeMouseHandlers_.erase(it);
    10391100        _getSingleton().stateRequest_ = IS_CUSTOM;
     1101        _getSingleton()._updateTickables();
    10401102        return true;
    10411103      }
    10421104    }
    1043     _getSingleton().stateRequest_ = IS_CUSTOM;
    10441105    return true;
    10451106  }
     
    11471208      if ((*it) == (*handlerIt).second)
    11481209      {
    1149         _getSingleton().stateRequest_ = IS_CUSTOM;
    11501210        return true;
    11511211      }
     
    11531213    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
    11541214    _getSingleton().stateRequest_ = IS_CUSTOM;
     1215    _getSingleton()._updateTickables();
    11551216    return true;
    11561217  }
     
    11801241        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
    11811242        _getSingleton().stateRequest_ = IS_CUSTOM;
     1243        _getSingleton()._updateTickables();
    11821244        return true;
    11831245      }
  • code/trunk/src/core/InputManager.h

    r1293 r1349  
    4242
    4343#include "ois/OIS.h"
     44#include "util/Math.h"
    4445#include "Tickable.h"
    4546#include "InputInterfaces.h"
     
    4748namespace orxonox
    4849{
     50  /**
     51  * Helper class to realise a vector<int[4]>
     52  */
     53  class POVStates
     54  {
     55  public:
     56    int operator[](unsigned int index) { return povStates[index]; }
     57    int povStates[4];
     58  };
     59
     60  /**
     61  * Helper class to realise a vector< {int[4], int[4]} >
     62  */
     63  class SliderStates
     64  {
     65  public:
     66    IntVector2 sliderStates[4];
     67  };
     68
    4969  /**
    5070    @brief Captures and distributes mouse and keyboard input.
     
    85105    static bool isModifierDown(KeyboardModifier::Enum modifier);
    86106    static bool isKeyDown(KeyCode::Enum key);
    87     static const MouseState getMouseState();
    88     static const JoyStickState getJoyStickState(unsigned int ID);
     107    //static const MouseState getMouseState();
     108    //static const JoyStickState getJoyStickState(unsigned int ID);
    89109
    90110    static void setWindowExtents(const int width, const int height);
     
    130150    void _destroyMouse();
    131151    void _destroyJoySticks();
     152
     153    void _updateTickables();
    132154
    133155    void tick(float dt);
     
    144166    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
    145167    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
    146     bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
     168    //bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
    147169
    148170    static InputManager& _getSingleton();
     
    160182    unsigned int keyboardModifiers_;
    161183
     184    //! Keeps track of the joy stick POV states
     185    std::vector<POVStates>                      povStates_;
     186    //! Keeps track of the possibly two slider axes
     187    std::vector<SliderStates>                   sliderStates_;
     188
    162189    std::map<std::string, KeyHandler*>          keyHandlers_;
    163190    std::map<std::string, MouseHandler*>        mouseHandlers_;
     
    167194    std::vector<MouseHandler*>                  activeMouseHandlers_;
    168195    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
     196    std::vector<InputTickable*>                 activeHandlers_;
    169197
    170198    std::vector<Key>                            keysDown_;
  • code/trunk/src/core/SignalHandler.cc

    r1293 r1349  
    150150  {
    151151    std::cout << "Trying to restore XAutoKeyRepeat" << std::endl;
    152         Display* display;
    153           if ((display = XOpenDisplay(0)))
    154     {
    155                         XAutoRepeatOn(display);
    156                   XCloseDisplay(display);
     152    Display* display;
     153    if ((display = XOpenDisplay(0)))
     154    {
     155      XAutoRepeatOn(display);
     156      XCloseDisplay(display);
    157157    }
    158158  }
     
    320320
    321321  std::string timeString = "\n\n\n\n"
    322                            "=======================================================\n"
    323                            "= time: " + std::string(ctime(&now)) +
    324                            "=======================================================\n";
     322                     "=======================================================\n"
     323                     "= time: " + std::string(ctime(&now)) +
     324         "=======================================================\n";
    325325  bt.insert(0, timeString);
    326326
  • code/trunk/src/ois/OISJoyStick.cpp

    r1219 r1349  
    3636
    3737//----------------------------------------------------------------------------//
    38 int JoyStick::getNumberOfComponents(ComponentType cType)
     38int JoyStick::getNumberOfComponents(ComponentType cType) const
    3939{
    4040        switch( cType )
     
    5656
    5757//----------------------------------------------------------------------------//
    58 float JoyStick::getVector3Sensitivity()
     58float JoyStick::getVector3Sensitivity() const
    5959{
    6060        return mVector3Sensitivity;
     
    6868
    6969//----------------------------------------------------------------------------//
    70 JoyStickListener* JoyStick::getEventCallback()
     70JoyStickListener* JoyStick::getEventCallback() const
    7171{
    7272        return mListener;
  • code/trunk/src/ois/OISJoyStick.h

    r1219 r1349  
    168168                        The ComponentType you are interested in knowing about
    169169                */
    170                 int getNumberOfComponents(ComponentType cType);
     170                int getNumberOfComponents(ComponentType cType) const;
    171171
    172172                /**
     
    184184                        Returns the sensitivity cutoff for Vector3 Component
    185185                */
    186                 float getVector3Sensitivity();
     186                float getVector3Sensitivity() const;
    187187
    188188                /**
     
    196196
    197197                /** @remarks Returns currently set callback.. or null */
    198                 JoyStickListener* getEventCallback();
     198                JoyStickListener* getEventCallback() const;
    199199
    200200                /** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */
  • code/trunk/src/ois/OISKeyboard.cpp

    r1219 r1349  
    3333
    3434//----------------------------------------------------------------------//
    35 bool Keyboard::isModifierDown( Modifier mod )
     35bool Keyboard::isModifierDown( Modifier mod ) const
    3636{
    3737#if defined(OIS_MSVC_COMPILER)
  • code/trunk/src/ois/OISKeyboard.h

    r1219 r1349  
    220220                        A KeyCode to check
    221221                */
    222                 virtual bool isKeyDown( KeyCode key ) = 0;
     222                virtual bool isKeyDown( KeyCode key ) const = 0;
    223223
    224224                /**
     
    235235                        Returns currently set callback.. or 0
    236236                */
    237                 KeyListener* getEventCallback() {return mListener;}
     237                KeyListener* getEventCallback() const {return mListener;}
    238238
    239239                //! TextTranslation Mode
     
    260260                        Returns current translation mode
    261261                */
    262                 TextTranslationMode getTextTranslation(){return mTextMode;}
     262                TextTranslationMode getTextTranslation() const {return mTextMode;}
    263263               
    264264                /**
     
    286286                        Check modifier status
    287287                */
    288                 bool isModifierDown( Modifier mod );
     288                bool isModifierDown( Modifier mod ) const;
    289289
    290290                /**
     
    293293                        (in the form of 1 is down and 0 is up)
    294294                */
    295                 virtual void copyKeyStates( char keys[256] ) = 0;
     295                virtual void copyKeyStates( char keys[256] ) const = 0;
    296296               
    297297        protected:
  • code/trunk/src/ois/OISMouse.h

    r1219 r1349  
    120120
    121121                /** @remarks Returns currently set callback.. or 0 */
    122                 MouseListener* getEventCallback() {return mListener;}
     122                MouseListener* getEventCallback() const {return mListener;}
    123123
    124124                /** @remarks Returns the state of the mouse - is valid for both buffered and non buffered mode */
  • code/trunk/src/ois/OISObject.h

    r1219 r1349  
    4545
    4646                /** @remarks Returns this input object's creator */
    47                 InputManager* getCreator() { return mCreator; }
     47                InputManager* getCreator() const { return mCreator; }
    4848
    4949                /** @remarks Sets buffered mode */
  • code/trunk/src/ois/linux/LinuxKeyboard.cpp

    r1219 r1349  
    290290
    291291//-------------------------------------------------------------------//
    292 bool LinuxKeyboard::isKeyDown( KeyCode key )
     292bool LinuxKeyboard::isKeyDown( KeyCode key ) const
    293293{
    294294        return (KeyBuffer[key]);
     
    449449
    450450//-------------------------------------------------------------------//
    451 void LinuxKeyboard::copyKeyStates( char keys[256] )
     451void LinuxKeyboard::copyKeyStates( char keys[256] ) const
    452452{
    453453        memcpy( keys, KeyBuffer, 256 );
  • code/trunk/src/ois/linux/LinuxKeyboard.h

    r1219 r1349  
    3838
    3939                /** @copydoc Keyboard::isKeyDown */
    40                 virtual bool isKeyDown( KeyCode key );
     40                virtual bool isKeyDown( KeyCode key ) const;
    4141
    4242                /** @copydoc Keyboard::getAsString */
     
    4444
    4545                /** @copydoc Keyboard::copyKeyStates */
    46                 virtual void copyKeyStates( char keys[256] );
     46                virtual void copyKeyStates( char keys[256] ) const;
    4747
    4848                /** @copydoc Object::setBuffered */
  • code/trunk/src/ois/mac/MacKeyboard.cpp

    r1219 r1349  
    130130
    131131//-------------------------------------------------------------------//
    132 bool MacKeyboard::isKeyDown( KeyCode key )
     132bool MacKeyboard::isKeyDown( KeyCode key ) const
    133133{
    134134        return (bool)KeyBuffer[key];
     
    321321
    322322//-------------------------------------------------------------------//
    323 void MacKeyboard::copyKeyStates( char keys[256] )
     323void MacKeyboard::copyKeyStates( char keys[256] ) const
    324324{
    325325        memcpy( keys, KeyBuffer, 256 );
  • code/trunk/src/ois/mac/MacKeyboard.h

    r1219 r1349  
    4343       
    4444        // unbuffered keydown check
    45         virtual bool isKeyDown( KeyCode key );
     45        virtual bool isKeyDown( KeyCode key ) const;
    4646       
    4747        // This will send listener events if buffered is on.
     
    5151       
    5252        // Copies the current key buffer
    53         virtual void copyKeyStates( char keys[256] );
     53        virtual void copyKeyStates( char keys[256] ) const;
    5454       
    5555        // Returns a description of the given key
  • code/trunk/src/ois/win32/Win32JoyStick.cpp

    r1219 r1349  
    149149        diptr.diph.dwHow        = DIPH_BYID;
    150150        diptr.diph.dwObj        = lpddoi->dwType;
    151         //Add the high bit in so that an axis value of zero does not mean a null userdata
    152         diptr.uData             = 0x80000000 | _this->_AxisNumber;
     151        //Add a magic number to recognise we set seomthing
     152        diptr.uData             = 0x13130000 | _this->_AxisNumber;
    153153
    154154        //Check if axis is slider, if so, do not treat as regular axis
     
    166166
    167167        //Increase for next time through
    168         _this->_AxisNumber += 1;
     168        if(GUID_Slider != lpddoi->guidType)
     169                _this->_AxisNumber += 1;
    169170
    170171        //Set range
     
    238239        for(unsigned int i = 0; i < entries; ++i)
    239240        {
    240                 //First check to see if event entry is a Axis we enumerated earlier
    241                 if( diBuff[i].uAppData != 0xFFFFFFFF && diBuff[i].uAppData > 0 )
     241                //This may seem outof order, but is in order of the way these variables
     242                //are declared in the JoyStick State 2 structure.
     243                switch(diBuff[i].dwOfs)
    242244                {
    243                         int axis = (int)(0x7FFFFFFF & diBuff[i].uAppData); //Mask out the high bit
    244                         assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
    245                         mState.mAxes[axis].abs = diBuff[i].dwData;
    246                         axisMoved[axis] = true;
    247                 }
    248                 else
    249                 {
    250                         //This may seem outof order, but is in order of the way these variables
    251                         //are declared in the JoyStick State 2 structure.
    252                         switch(diBuff[i].dwOfs)
     245                //------ slider -//
     246                case DIJOFS_SLIDER0(0):
     247                        sliderMoved[0] = true;
     248                        mState.mSliders[0].abX = diBuff[i].dwData;
     249                        break;
     250                case DIJOFS_SLIDER0(1):
     251                        sliderMoved[0] = true;
     252                        mState.mSliders[0].abY = diBuff[i].dwData;
     253                        break;
     254                //----- Max 4 POVs Next ---------------//
     255                case DIJOFS_POV(0):
     256                        if(!_changePOV(0,diBuff[i]))
     257                                return;
     258                        break;
     259                case DIJOFS_POV(1):
     260                        if(!_changePOV(1,diBuff[i]))
     261                                return;
     262                        break;
     263                case DIJOFS_POV(2):
     264                        if(!_changePOV(2,diBuff[i]))
     265                                return;
     266                        break;
     267                case DIJOFS_POV(3):
     268                        if(!_changePOV(3,diBuff[i]))
     269                                return;
     270                        break;
     271                case DIJOFS_SLIDER1(0):
     272                        sliderMoved[1] = true;
     273                        mState.mSliders[1].abX = diBuff[i].dwData;
     274                        break;
     275                case DIJOFS_SLIDER1(1):
     276                        sliderMoved[1] = true;
     277                        mState.mSliders[1].abY = diBuff[i].dwData;
     278                        break;
     279                case DIJOFS_SLIDER2(0):
     280                        sliderMoved[2] = true;
     281                        mState.mSliders[2].abX = diBuff[i].dwData;
     282                        break;
     283                case DIJOFS_SLIDER2(1):
     284                        sliderMoved[2] = true;
     285                        mState.mSliders[2].abY = diBuff[i].dwData;
     286                        break;
     287                case DIJOFS_SLIDER3(0):
     288                        sliderMoved[3] = true;
     289                        mState.mSliders[3].abX = diBuff[i].dwData;
     290                        break;
     291                case DIJOFS_SLIDER3(1):
     292                        sliderMoved[3] = true;
     293                        mState.mSliders[3].abY = diBuff[i].dwData;
     294                        break;
     295                //-----------------------------------------//
     296                default:
     297                        //Handle Button Events Easily using the DX Offset Macros
     298                        if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
    253299                        {
    254                         //------ slider -//
    255                         case DIJOFS_SLIDER0(0):
    256                                 sliderMoved[0] = true;
    257                                 mState.mSliders[0].abX = diBuff[i].dwData;
    258                                 break;
    259                         case DIJOFS_SLIDER0(1):
    260                                 sliderMoved[0] = true;
    261                                 mState.mSliders[0].abY = diBuff[i].dwData;
    262                                 break;
    263                         //----- Max 4 POVs Next ---------------//
    264                         case DIJOFS_POV(0):
    265                                 if(!_changePOV(0,diBuff[i]))
     300                                if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
    266301                                        return;
    267                                 break;
    268                         case DIJOFS_POV(1):
    269                                 if(!_changePOV(1,diBuff[i]))
    270                                         return;
    271                                 break;
    272                         case DIJOFS_POV(2):
    273                                 if(!_changePOV(2,diBuff[i]))
    274                                         return;
    275                                 break;
    276                         case DIJOFS_POV(3):
    277                                 if(!_changePOV(3,diBuff[i]))
    278                                         return;
    279                                 break;
    280                         case DIJOFS_SLIDER1(0):
    281                                 sliderMoved[1] = true;
    282                                 mState.mSliders[1].abX = diBuff[i].dwData;
    283                                 break;
    284                         case DIJOFS_SLIDER1(1):
    285                                 sliderMoved[1] = true;
    286                                 mState.mSliders[1].abY = diBuff[i].dwData;
    287                                 break;
    288                         case DIJOFS_SLIDER2(0):
    289                                 sliderMoved[2] = true;
    290                                 mState.mSliders[2].abX = diBuff[i].dwData;
    291                                 break;
    292                         case DIJOFS_SLIDER2(1):
    293                                 sliderMoved[2] = true;
    294                                 mState.mSliders[2].abY = diBuff[i].dwData;
    295                                 break;
    296                         case DIJOFS_SLIDER3(0):
    297                                 sliderMoved[3] = true;
    298                                 mState.mSliders[3].abX = diBuff[i].dwData;
    299                                 break;
    300                         case DIJOFS_SLIDER3(1):
    301                                 sliderMoved[3] = true;
    302                                 mState.mSliders[3].abY = diBuff[i].dwData;
    303                                 break;
    304                         //-----------------------------------------//
    305                         default:
    306                                 //Handle Button Events Easily using the DX Offset Macros
    307                                 if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
     302                        }
     303                        else if((short)(diBuff[i].uAppData >> 16) == 0x1313)
     304                        {       //If it was nothing else, might be axis enumerated earlier (determined by magic number)
     305                                int axis = (int)(0x0000FFFF & diBuff[i].uAppData); //Mask out the high bit
     306                                assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
     307
     308                                if(axis >= 0 && axis < (int)mState.mAxes.size())
    308309                                {
    309                                         if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
    310                                                 return;
     310                                        mState.mAxes[axis].abs = diBuff[i].dwData;
     311                                        axisMoved[axis] = true;
    311312                                }
    312                                 break;
    313                         } //end case
    314                 } //End else
     313                        }
     314
     315                        break;
     316                } //end case
    315317        } //end for
    316318
  • code/trunk/src/ois/win32/Win32KeyBoard.cpp

    r1219 r1349  
    105105        DWORD entries = KEYBOARD_DX_BUFFERSIZE;
    106106        HRESULT hr;
     107        //Only one keyboard allowed per app, so static is ok
     108        static bool verifyAfterAltTab = false;
    107109
    108110        hr = mKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
     
    110112        {
    111113                hr = mKeyboard->Acquire();
     114                if (hr == E_ACCESSDENIED)
     115                        verifyAfterAltTab = true;
     116
    112117                while( hr == DIERR_INPUTLOST )
    113118                        hr = mKeyboard->Acquire();
     119
    114120                return;
    115121        }
     
    121127        for(unsigned int i = 0; i < entries; ++i )
    122128        {
    123                 //If the mListener returns false, that means that we are probably deleted...
     129                //If the listener returns false, that means that we are probably deleted...
    124130                //send no more events and just leave as the this pointer is invalid now...
    125131                bool ret = true;
     
    159165                if(ret == false)
    160166                        break;
     167        }
     168
     169        // If a lost device/access denied was detected, recover gracefully with new events
     170        if(verifyAfterAltTab)
     171        {
     172                bool ret = true;
     173               
     174                //Copy old buffer to temp location to compare against
     175                unsigned char keyBufferCopy[256];
     176                memcpy(keyBufferCopy, KeyBuffer, 256);
     177
     178                //Update new state
     179                _read();
     180
     181                for (unsigned i = 0; i < 256; i++)
     182                {
     183                        if (keyBufferCopy[i] != KeyBuffer[i])
     184                        {
     185                                if (mListener)
     186                                {
     187                                        if (KeyBuffer[i])
     188                                                ret = mListener->keyPressed( KeyEvent( this, (KeyCode)i, _translateText((KeyCode)i) ) );
     189                                        else
     190                                                ret = mListener->keyReleased( KeyEvent( this, (KeyCode)i, 0 ) );
     191                                }
     192                        }
     193
     194                        //If user returned false from callback, return immediately
     195                        if(ret == false)
     196                                return;
     197                }
     198
     199                verifyAfterAltTab = false;
    161200        }
    162201}
     
    243282
    244283//--------------------------------------------------------------------------------------------------//
    245 bool Win32Keyboard::isKeyDown( KeyCode key )
     284bool Win32Keyboard::isKeyDown( KeyCode key ) const
    246285{
    247286        return (KeyBuffer[key] & 0x80) != 0;
     
    272311
    273312//--------------------------------------------------------------------------------------------------//
    274 void Win32Keyboard::copyKeyStates( char keys[256] )
     313void Win32Keyboard::copyKeyStates( char keys[256] ) const
    275314{
    276315        for(int i = 0; i < 256; ++i)
  • code/trunk/src/ois/win32/Win32KeyBoard.h

    r1219 r1349  
    4646
    4747                /** @copydoc Keyboard::isKeyDown */
    48                 virtual bool isKeyDown( KeyCode key );
     48                virtual bool isKeyDown( KeyCode key ) const;
    4949               
    5050                /** @copydoc Keyboard::getAsString */
     
    5252
    5353                /** @copydoc Keyboard::copyKeyStates */
    54                 virtual void copyKeyStates( char keys[256] );
     54                virtual void copyKeyStates( char keys[256] ) const;
    5555
    5656                /** @copydoc Object::setBuffered */
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1293 r1349  
    99 *   modify it under the terms of the GNU General Public License
    1010 *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or (atl your option) any later version.
    12  *lo
     11 *   of the License, or (at your option) any later version.
     12 *
    1313 *   This program is distributed in the hope that it will be useful,
    1414 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  • code/trunk/src/orxonox/Orxonox.cc

    r1293 r1349  
    8383namespace orxonox
    8484{
    85   ConsoleCommandShortcut(Orxonox, exit, AccessLevel::None);
    86   ConsoleCommandShortcut(Orxonox, slomo, AccessLevel::Offline).setDefaultValue(0, 1.0);
     85  ConsoleCommandShortcut(Orxonox, exit, AccessLevel::None).setKeybindMode(KeybindMode::OnPress);
     86  ConsoleCommandShortcut(Orxonox, slomo, AccessLevel::Offline).setDefaultValue(0, 1.0)
     87    .setAxisParamIndex(0).setIsAxisRelative(false);
    8788  ConsoleCommandShortcut(Orxonox, setTimeFactor, AccessLevel::Offline).setDefaultValue(0, 1.0);
    8889  ConsoleCommandShortcut(Orxonox, activateConsole, AccessLevel::None);
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1293 r1349  
    3838
    3939#include "CameraHandler.h"
    40 #include "tinyxml/tinyxml.h"
    41 #include "ois/OIS.h"
    42 #include "util/Convert.h"
     40//#include "util/Convert.h"
    4341#include "util/Math.h"
    4442#include "core/CoreIncludes.h"
     
    219217    }
    220218
    221     void SpaceShip::loadParams(TiXmlElement* xmlElem)
    222     {
    223         Model::loadParams(xmlElem);
    224         this->create();
    225         this->getFocus();
    226 /*
    227         if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
    228         {
    229             std::string forwardStr = xmlElem->Attribute("forward");
    230             std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");
    231             std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");
    232             std::string looprightleftStr = xmlElem->Attribute("looprightleft");
    233 
    234             String2Number<float>(this->maxSpeedForward_, forwardStr);
    235             String2Number<float>(this->maxSpeedRotateUpDown_, rotateupdownStr);
    236             String2Number<float>(this->maxSpeedRotateRightLeft_, rotaterightleftStr);
    237             String2Number<float>(this->maxSpeedLoopRightLeft_, looprightleftStr);
    238 
    239             COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;
    240       }
    241 */
    242         if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp"))
    243         {
    244 
    245             std::string msStr = xmlElem->Attribute("maxSpeed");
    246             std::string msabsStr = xmlElem->Attribute("maxSideAndBackSpeed");
    247             std::string mrStr = xmlElem->Attribute("maxRotation");
    248             std::string taStr = xmlElem->Attribute("transAcc");
    249             std::string raStr = xmlElem->Attribute("rotAcc");
    250             std::string tdStr = xmlElem->Attribute("transDamp");
    251             std::string rdStr = xmlElem->Attribute("rotDamp");
    252 
    253             convertValue<std::string, float>(&this->maxSpeed_, msStr);
    254             convertValue<std::string, float>(&this->maxSideAndBackSpeed_, msabsStr);
    255             convertValue<std::string, float>(&this->maxRotation_, mrStr);
    256             convertValue<std::string, float>(&this->translationAcceleration_, taStr);
    257             convertValue<std::string, float>(&this->rotationAcceleration_, raStr);
    258             convertValue<std::string, float>(&this->translationDamping_, tdStr);
    259             convertValue<std::string, float>(&this->rotationDamping_, rdStr);
    260 
    261             this->maxRotationRadian_ = Radian(this->maxRotation_);
    262             this->rotationAccelerationRadian_ = Radian(this->rotationAcceleration_);
    263             this->rotationDampingRadian_ = Radian(this->rotationDamping_);
    264 
    265             COUT(4) << "Loader: Initialized SpaceShip" << std::endl;
    266         }
    267 
    268         if (xmlElem->Attribute("camera"))
    269         {
    270             this->setCamera();
    271         }
    272     }
    273 
    274219    void SpaceShip::setCamera(const std::string& camera)
    275220    {
     
    351296    }
    352297
    353     bool SpaceShip::mouseMoved(const MouseState& state)
     298    void SpaceShip::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    354299    {
    355300/*
     
    368313        if (this->bRMousePressed_)
    369314        {
    370             this->camNode_->roll(Degree(-state.X.rel * 0.10));
    371             this->camNode_->yaw(Degree(state.Y.rel * 0.10));
     315            this->camNode_->roll(Degree(-rel.x * 0.10));
     316            this->camNode_->yaw(Degree(rel.y * 0.10));
    372317        }
    373318        else
    374319        {
    375             float minDimension = state.height;
    376             if (state.width < minDimension)
    377                 minDimension = state.width;
    378 
    379             this->mouseX_ += state.X.rel;
     320            float minDimension = clippingSize.y;
     321            if (clippingSize.x < minDimension)
     322                minDimension = clippingSize.x;
     323
     324            this->mouseX_ += rel.x;
    380325            if (this->mouseX_ < -minDimension)
    381326                this->mouseX_ = -minDimension;
     
    383328                this->mouseX_ = minDimension;
    384329
    385             this->mouseY_ += state.Y.rel;
     330            this->mouseY_ += rel.y;
    386331            if (this->mouseY_ < -minDimension)
    387332                this->mouseY_ = -minDimension;
     
    407352            this->mouseYRotation_ = Radian(yRotation);
    408353        }
    409 
    410         return true;
    411     }
    412 
    413     bool SpaceShip::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
     354    }
     355
     356    void SpaceShip::mouseButtonPressed(MouseButton::Enum id)
    414357    {
    415358        if (id == MouseButton::Left)
     
    417360        else if (id == MouseButton::Right)
    418361            this->bRMousePressed_ = true;
    419 
    420         return true;
    421     }
    422 
    423     bool SpaceShip::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
     362    }
     363
     364    void SpaceShip::mouseButtonReleased(MouseButton::Enum id)
    424365    {
    425366        if (id == MouseButton::Left)
     
    430371            this->camNode_->resetOrientation();
    431372        }
    432 
    433         return true;
    434373    }
    435374
     
    564503        else
    565504            this->tt_->setRate(0);
    566 
    567 /*
    568         if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    569             this->moveForward(speed);
    570         else
    571             this->moveForward(0);
    572 
    573         if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    574             this->brakeForward(speed);
    575         else
    576             this->brakeForward(speed/10);
    577 
    578         if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    579             this->loopRight(loop);
    580         else
    581             this->loopRight(0);
    582 
    583         if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    584             this->loopLeft(loop);
    585         else
    586             this->loopLeft(0);
    587 
    588         if(moved)
    589         {
    590             if (mouseY<=0)
    591                 this->rotateUp(-mouseY*rotate);
    592             if (mouseY>0)
    593                 this->rotateDown(mouseY*rotate);
    594             if (mouseX>0)
    595                 this->rotateRight(mouseX*rotate);
    596             if (mouseX<=0)
    597                 this->rotateLeft(-mouseX*rotate);
    598 
    599             mouseY = 0;
    600             mouseX = 0;
    601             moved = false;
    602         }*/
    603 /*        else
    604         {
    605             this->rotateUp(0);
    606             this->rotateDown(0);
    607             this->rotateRight(0);
    608             this->rotateLeft(0);
    609         }*/
    610 /*
    611         if(moveForward_ > 0)
    612         {
    613             accelerationForward_ = moveForward_;
    614             if(speedForward_ < maxSpeedForward_)
    615                 speedForward_ += accelerationForward_*dt;
    616             if(speedForward_ > maxSpeedForward_)
    617                 speedForward_ = maxSpeedForward_;
    618         }
    619 
    620         if(moveForward_ <= 0)
    621         {
    622             accelerationForward_ = -brakeForward_;
    623             if(speedForward_ > 0)
    624                 speedForward_ += accelerationForward_*dt;
    625             if(speedForward_ < 0)
    626                 speedForward_ = 0;
    627         }
    628 
    629         if(rotateUp_ > 0)
    630         {
    631             accelerationRotateUpDown_ = rotateUp_;
    632             if(speedRotateUpDown_ < maxSpeedRotateUpDown_)
    633                 speedRotateUpDown_ += accelerationRotateUpDown_*dt;
    634             if(speedRotateUpDown_ > maxSpeedRotateUpDown_)
    635             speedRotateUpDown_ = maxSpeedRotateUpDown_;
    636         }
    637 
    638         if(rotateDown_ > 0)
    639         {
    640             accelerationRotateUpDown_ = rotateDown_;
    641             if(speedRotateUpDown_ > -maxSpeedRotateUpDown_)
    642                 speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
    643             if(speedRotateUpDown_ < -maxSpeedRotateUpDown_)
    644                 speedRotateUpDown_ = -maxSpeedRotateUpDown_;
    645         }
    646 
    647         if(rotateUp_ == 0 && rotateDown_ == 0)
    648         {
    649             accelerationRotateUpDown_ = brakeRotate_;
    650             if(speedRotateUpDown_ > 0)
    651                 speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
    652             if(speedRotateUpDown_ < 0)
    653                 speedRotateUpDown_ += accelerationRotateUpDown_*dt;
    654             if(fabs(speedRotateUpDown_) < accelerationRotateUpDown_*dt)
    655                 speedRotateUpDown_ = 0;
    656         }
    657 
    658         if(rotateRight_ > 0)
    659         {
    660             accelerationRotateRightLeft_ = rotateRight_;
    661             if(speedRotateRightLeft_ > -maxSpeedRotateRightLeft_)
    662                 speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
    663             if(speedRotateRightLeft_ < -maxSpeedRotateRightLeft_)
    664                 speedRotateRightLeft_ = -maxSpeedRotateRightLeft_;
    665         }
    666 
    667         if(rotateLeft_ > 0)
    668         {
    669             accelerationRotateRightLeft_ = rotateLeft_;
    670             if(speedRotateRightLeft_ < maxSpeedRotateRightLeft_)
    671                 speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
    672             if(speedRotateRightLeft_ > maxSpeedRotateRightLeft_)
    673                 speedRotateRightLeft_ = maxSpeedRotateRightLeft_;
    674         }
    675 
    676         if(rotateRight_ == 0 && rotateLeft_ == 0)
    677         {
    678             accelerationRotateRightLeft_ = brakeRotate_;
    679             if(speedRotateRightLeft_ > 0)
    680                 speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
    681             if(speedRotateRightLeft_ < 0)
    682                 speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
    683             if(fabs(speedRotateRightLeft_) < accelerationRotateRightLeft_*dt)
    684                 speedRotateRightLeft_ = 0;
    685         }
    686 
    687         if(loopRight_ > 0)
    688         {
    689             accelerationLoopRightLeft_ = loopRight_;
    690             if(speedLoopRightLeft_ < maxSpeedLoopRightLeft_)
    691                 speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
    692             if(speedLoopRightLeft_ > maxSpeedLoopRightLeft_)
    693                 speedLoopRightLeft_ = maxSpeedLoopRightLeft_;
    694         }
    695 
    696         if(loopLeft_ > 0)
    697         {
    698             accelerationLoopRightLeft_ = loopLeft_;
    699             if(speedLoopRightLeft_ > -maxSpeedLoopRightLeft_)
    700                 speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
    701             if(speedLoopRightLeft_ < -maxSpeedLoopRightLeft_)
    702                 speedLoopRightLeft_ = -maxSpeedLoopRightLeft_;
    703         }
    704 
    705         if(loopLeft_ == 0 && loopRight_ == 0)
    706         {
    707             accelerationLoopRightLeft_ = brakeLoop_;
    708             if(speedLoopRightLeft_ > 0)
    709                 speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
    710             if(speedLoopRightLeft_ < 0)
    711                 speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
    712             if(fabs(speedLoopRightLeft_) < accelerationLoopRightLeft_*dt)
    713                 speedLoopRightLeft_ = 0;
    714         }
    715 
    716         Vector3 transVector = Vector3::ZERO;
    717 */
    718 /*
    719         transVector.z = 1;
    720         this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
    721         this->pitch(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
    722         this->yaw(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
    723         this->roll(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
    724 */
    725 /*
    726         transVector.x = 1;
    727         this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
    728         this->yaw(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
    729         this->roll(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
    730         this->pitch(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
    731 */
    732     }
    733 /*
    734     void SpaceShip::moveForward(float moveForward) {
    735         moveForward_ = moveForward;
    736     }
    737 
    738     void SpaceShip::rotateUp(float rotateUp) {
    739         rotateUp_ = rotateUp;
    740     }
    741 
    742     void SpaceShip::rotateDown(float rotateDown) {
    743         rotateDown_ = rotateDown;
    744     }
    745 
    746     void SpaceShip::rotateLeft(float rotateLeft) {
    747         rotateLeft_ = rotateLeft;
    748     }
    749 
    750     void SpaceShip::rotateRight(float rotateRight) {
    751         rotateRight_ = rotateRight;
    752     }
    753 
    754     void SpaceShip::loopLeft(float loopLeft) {
    755         loopLeft_ = loopLeft;
    756     }
    757 
    758     void SpaceShip::loopRight(float loopRight) {
    759         loopRight_ = loopRight;
    760     }
    761 
    762     void SpaceShip::brakeForward(float brakeForward) {
    763         brakeForward_ = brakeForward;
    764     }
    765 
    766     void SpaceShip::brakeRotate(float brakeRotate) {
    767         brakeRotate_ = brakeRotate;
    768     }
    769 
    770     void SpaceShip::brakeLoop(float brakeLoop) {
    771         brakeLoop_ = brakeLoop;
    772     }
    773 
    774     void SpaceShip::maxSpeedForward(float maxSpeedForward) {
    775         maxSpeedForward_ = maxSpeedForward;
    776     }
    777 
    778     void SpaceShip::maxSpeedRotateUpDown(float maxSpeedRotateUpDown) {
    779         maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
    780     }
    781 
    782     void SpaceShip::maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft) {
    783         maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
    784     }
    785 
    786     void SpaceShip::maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft) {
    787         maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
    788     }
    789 */
     505    }
     506
    790507}
  • code/trunk/src/orxonox/objects/SpaceShip.h

    r1293 r1349  
    5050            void init();
    5151            void setConfigValues();
    52             virtual void loadParams(TiXmlElement* xmlElem);
    5352            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5453            virtual void tick(float dt);
     
    6867                { SpaceShip::instance_s->setMaxSpeed(value); }
    6968
    70             bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
    71             bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
    72             bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) { return true; }
    73             bool mouseMoved         (const MouseState& state);
    74             bool mouseScrolled      (const MouseState& state) { return true; }
     69            void mouseButtonPressed (MouseButton::Enum id);
     70            void mouseButtonReleased(MouseButton::Enum id);
     71            void mouseButtonHeld    (MouseButton::Enum id) { }
     72            void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
     73            void mouseScrolled      (int abs, int rel) { }
    7574
    7675
  • code/trunk/src/util/Math.h

    r1062 r1349  
    147147}
    148148
     149class _UtilExport IntVector2
     150{
     151public:
     152  IntVector2() : x(0), y(0) { }
     153  IntVector2(int _x, int _y) : x(_x), y(_y) { }
     154  int x;
     155  int y;
     156};
     157
     158class _UtilExport IntVector3
     159{
     160public:
     161  IntVector3() : x(0), y(0), z(0) { }
     162  IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
     163  int x;
     164  int y;
     165  int z;
     166};
     167
    149168#endif /* _Util_Math_H__ */
  • code/trunk/src/util/SubString.cc

    r1056 r1349  
    6767SubString::SubString(const std::string& string,
    6868                     const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
    69                      char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar,
     69                     char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar,
    7070                     char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
    7171{
    72   SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
     72  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
    7373}
    7474
  • code/trunk/src/util/SubString.h

    r1062 r1349  
    8989  SubString(const std::string& string,
    9090            const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false,
    91             char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
     91            char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
    9292            char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
    9393  SubString(unsigned int argc, const char** argv);
Note: See TracChangeset for help on using the changeset viewer.