Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1323


Ignore:
Timestamp:
May 19, 2008, 10:50:09 AM (17 years ago)
Author:
rgrieder
Message:

Basically, almost everything about the input management is written, but I wasn't yet able to test things.

Location:
code/branches/input
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/bin/keybindings.ini

    r1293 r1323  
    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=OnHold fire | OnHold AxisAmp -2.4 lookUpDown | OnPress 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=
     156MouseXPos=
     157MouseXNeg=
     158MouseYPos=
     159MouseYNeg=
     160MouseWheel1Pos=
     161MouseWheel1Neg=
     162MouseWheel2Pos=
     163MouseWheel2Neg=
     164JoyAxis1Pos=
     165JoyAxis1Neg=
     166JoyAxis2Pos=
     167JoyAxis2Neg=
     168JoyAxis3Pos=
     169JoyAxis3Neg=
     170JoyAxis4Pos=
     171JoyAxis4Neg=
     172JoyAxis5Pos=
     173JoyAxis5Neg=
     174JoyAxis6Pos=
     175JoyAxis6Neg=
     176JoyAxis7Pos=
     177JoyAxis7Neg=
     178JoyAxis8Pos=
     179JoyAxis8Neg=
     180JoyAxis9Pos=
     181JoyAxis9Neg=
     182JoyAxis10Pos=
     183JoyAxis10Neg=
     184JoyAxis11Pos=
     185JoyAxis11Neg=
     186JoyAxis12Pos=
     187JoyAxis12Neg=
     188JoyAxis13Pos=
     189JoyAxis13Neg=
     190JoyAxis14Pos=
     191JoyAxis14Neg=
     192JoyAxis15Pos=
     193JoyAxis15Neg=
     194JoyAxis16Pos=
     195JoyAxis16Neg=
     196JoyAxis17Pos=
     197JoyAxis17Neg=
     198JoyAxis18Pos=
     199JoyAxis18Neg=
     200JoyAxis19Pos=
     201JoyAxis19Neg=
     202JoyAxis20Pos=
     203JoyAxis20Neg=
     204JoyAxis21Pos=
     205JoyAxis21Neg=
     206JoyAxis22Pos=
     207JoyAxis22Neg=
     208JoyAxis23Pos=
     209JoyAxis23Neg=
     210JoyAxis24Pos=
     211JoyAxis24Neg=
     212JoyButton0=
     213JoyButton1=
     214JoyButton2=
     215JoyButton3=
     216JoyButton4=
     217JoyButton5=
     218JoyButton6=
     219JoyButton7=
     220JoyButton8=
     221JoyButton9=
     222JoyButton10=
     223JoyButton11=
     224JoyButton12=
     225JoyButton13=
     226JoyButton14=
     227JoyButton15=
     228JoyButton16=
     229JoyButton17=
     230JoyButton18=
     231JoyButton19=
     232JoyButton20=
     233JoyButton21=
     234JoyButton22=
     235JoyButton23=
     236JoyButton24=
     237JoyButton25=
     238JoyButton26=
     239JoyButton27=
     240JoyButton28=
     241JoyButton29=
     242JoyButton30=
     243JoyButton31=
     244JoyPOV1North=
     245JoyPOV1South=
     246JoyPOV1East=
     247JoyPOV1West=
     248JoyPOV2North=
     249JoyPOV2South=
     250JoyPOV2East=
     251JoyPOV2West=
     252JoyPOV3North=
     253JoyPOV3South=
     254JoyPOV3East=
     255JoyPOV3West=
     256JoyPOV4North=
     257JoyPOV4South=
     258JoyPOV4East=
     259JoyPOV4West=
    560260
  • code/branches/input/src/core/CommandExecutor.cc

    r1214 r1323  
    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/branches/input/src/core/CommandExecutor.h

    r1293 r1323  
    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 Executor* getExecutor() { return 0; }
    9290
    9391            void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
  • code/branches/input/src/core/CorePrereqs.h

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

    r1062 r1323  
    233233            MultiTypeMath defaultValue_[MAX_FUNCTOR_ARGUMENTS];
    234234            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
     235            KeybindMode::Enum keybindMode_;
     236            int axisParameter_;
    235237
    236238        private:
  • code/branches/input/src/core/InputBuffer.cc

    r1293 r1323  
    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  {
  • code/branches/input/src/core/InputBuffer.h

    r1293 r1323  
    4343  {};
    4444
    45   class _CoreExport InputBuffer : public KeyHandler, public TickableReal
     45  class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass
    4646  {
    4747    struct InputBufferListenerTuple
  • code/branches/input/src/core/InputHandler.cc

    r1293 r1323  
    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
     
    5154  {
    5255    RegisterObject(KeyBinder);
    53     clearBindings();
    54 
     56    clearBindings(true);
     57
     58    // keys
    5559    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"
     60      "UNASSIGNED",
     61      "ESCAPE",
     62      "1",
     63      "2",
     64      "3",
     65      "4",
     66      "5",
     67      "6",
     68      "7",
     69      "8",
     70      "9",
     71      "0",
     72      "MINUS",
     73      "EQUALS",
     74      "BACK",
     75      "TAB",
     76      "Q",
     77      "W",
     78      "E",
     79      "R",
     80      "T",
     81      "Y",
     82      "U",
     83      "I",
     84      "O",
     85      "P",
     86      "LBRACKET",
     87      "RBRACKET",
     88      "RETURN",
     89      "LCONTROL",
     90      "A",
     91      "S",
     92      "D",
     93      "F",
     94      "G",
     95      "H",
     96      "J",
     97      "K",
     98      "L",
     99      "SEMICOLON",
     100      "APOSTROPHE",
     101      "GRAVE",
     102      "LSHIFT",
     103      "BACKSLASH",
     104      "Z",
     105      "X",
     106      "C",
     107      "V",
     108      "B",
     109      "N",
     110      "M",
     111      "COMMA",
     112      "PERIOD",
     113      "SLASH",
     114      "RSHIFT",
     115      "MULTIPLY",
     116      "LMENU",
     117      "SPACE",
     118      "CAPITAL",
     119      "F1",
     120      "F2",
     121      "F3",
     122      "F4",
     123      "F5",
     124      "F6",
     125      "F7",
     126      "F8",
     127      "F9",
     128      "F10",
     129      "NUMLOCK",
     130      "SCROLL",
     131      "NUMPAD7",
     132      "NUMPAD8",
     133      "NUMPAD9",
     134      "SUBTRACT",
     135      "NUMPAD4",
     136      "NUMPAD5",
     137      "NUMPAD6",
     138      "ADD",
     139      "NUMPAD1",
     140      "NUMPAD2",
     141      "NUMPAD3",
     142      "NUMPAD0",
     143      "DECIMAL",
     144      "","",
     145      "OEM_102",
     146      "F11",
     147      "F12",
     148      "","","","","","","","","","","",
     149      "F13",
     150      "F14",
     151      "F15",
     152      "","","","","","","","","","",
     153      "KANA",
     154      "","",
     155      "ABNT_C1",
     156      "","","","","",
     157      "CONVERT",
     158      "",
     159      "NOCONVERT",
     160      "",
     161      "YEN",
     162      "ABNT_C2",
     163      "","","","","","","","","","","","","","",
     164      "NUMPADEQUALS",
     165      "","",
     166      "PREVTRACK",
     167      "AT",
     168      "COLON",
     169      "UNDERLINE",
     170      "KANJI",
     171      "STOP",
     172      "AX",
     173      "UNLABELED",
     174      "NEXTTRACK",
     175      "","",
     176      "NUMPADENTER",
     177      "RCONTROL",
     178      "","",
     179      "MUTE",
     180      "CALCULATOR",
     181      "PLAYPAUSE",
     182      "",
     183      "MEDIASTOP",
     184      "","","","","","","","","",
     185      "VOLUMEDOWN",
     186      "",
     187      "VOLUMEUP",
     188      "",
     189      "WEBHOME",
     190      "NUMPADCOMMA",
     191      "",
     192      "DIVIDE",
     193      "",
     194      "SYSRQ",
     195      "RMENU",
     196      "","","","","","","","","","","","",
     197      "PAUSE",
     198      "",
     199      "HOME",
     200      "UP",
     201      "PGUP",
     202      "",
     203      "LEFT",
     204      "",
     205      "RIGHT",
     206      "",
     207      "END",
     208      "DOWN",
     209      "PGDOWN",
     210      "INSERT",
     211      "DELETE",
     212      "","","","","","","",
     213      "LWIN",
     214      "RWIN",
     215      "APPS",
     216      "POWER",
     217      "SLEEP",
     218      "","","",
     219      "WAKE",
     220      "",
     221      "WEBSEARCH",
     222      "WEBFAVORITES",
     223      "WEBREFRESH",
     224      "WEBSTOP",
     225      "WEBFORWARD",
     226      "WEBBACK",
     227      "MYCOMPUTER",
     228      "MAIL",
     229      "MEDIASELECT"
    226230    };
    227     for (int i = 0; i < numberOfKeys_s; i++)
    228       keyNames_[i] = keyNames[i];
    229 
     231    for (int i = 0; i < nKeys_s; i++)
     232      namesKeys_[i] = "Key" + keyNames[i];
     233
     234    // mouse buttons
    230235    std::string mouseButtonNames[] = {
    231236      "MouseLeft", "MouseRight", "MouseMiddle",
    232237      "MouseButton3", "MouseButton4", "MouseButton5",
    233238      "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);
     239    for (int i = 0; i < nMouseButtons_s; i++)
     240      namesMouseButtons_[i] = mouseButtonNames[i];
     241
     242    // joy stick buttons
     243    for (int i = 0; i < 32; i++)
     244      namesJoyStickButtons_[i] = "JoyButton" + getConvertedValue<int, std::string>(i);
     245    for (int i = 32; i < nJoyStickButtons_s; i += 4)
     246    {
     247                  namesJoyStickButtons_[i + 0] = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "North";
     248                  namesJoyStickButtons_[i + 1] = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "South";
     249                  namesJoyStickButtons_[i + 2] = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "East";
     250                  namesJoyStickButtons_[i + 3] = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "West";
     251    }
     252
     253    // half axes
     254    std::string rawNames[nHalfAxes_s/2];
     255    rawNames[0] = "MouseX";
     256    rawNames[1] = "MouseY";
     257    rawNames[2] = "MouseWheel1";
     258    rawNames[3] = "MouseWheel2";
     259    for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
     260      rawNames[i] = "JoyAxis" + getConvertedValue<int, std::string>(i - 3);
     261    for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
     262    {
     263      namesHalfAxes_[i * 2 + 0] = rawNames[i] + "Pos";
     264      namesHalfAxes_[i * 2 + 1] = rawNames[i] + "Neg";
     265    }
    239266  }
    240267
     
    244271  KeyBinder::~KeyBinder()
    245272  {
     273    // almost no destructors required because most of the arrays are static.
     274    clearBindings(); // does some destruction work
    246275  }
    247276
     
    251280  void KeyBinder::setConfigValues()
    252281  {
    253     ConfigValueContainer* cont;
    254     std::string modes[] = {"P_", "R_", "H_"};
    255 
     282    bool success = true;
    256283    // 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 
     284    success |= readBindings(namesKeys_, bindingStringsKeys_, bindingsKeys_, nKeys_s);
    281285    // 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 
     286    success |= readBindings(namesMouseButtons_, bindingStringsMouseButtons_, bindingsMouseButtons_, nMouseButtons_s);
    306287    // 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       }
    329     }
     288    success |= readBindings(namesJoyStickButtons_, bindingStringsJoyStickButtons_,
     289        bindingsJoyStickButtons_, nJoyStickButtons_s);
     290    // half axes
     291    success |= readBindings(namesHalfAxes_, bindingStringsHalfAxes_, bindingsHalfAxes_, nHalfAxes_s);
     292   
     293    // TODO: what happens if parsing didn't succeed in all parts? nothing?
     294  }
     295
     296  bool KeyBinder::readBindings(std::string* names, std::string* bindingStrings,
     297      KeyBindingBundle* bindings, unsigned int size)
     298  {
     299    for (unsigned int i = 0; i < size; i++)
     300    {
     301      // config value stuff
     302      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer(names[i]);
     303      if (!cont)
     304      {
     305        cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), names[i], "");
     306        getIdentifier()->addConfigValueContainer(names[i], cont);
     307      }
     308      std::string old = bindingStrings[i];
     309      cont->getValue(&bindingStrings[i]);
     310
     311      // keybinder stuff
     312      if (old != bindingStrings[i])
     313      {
     314        // binding has changed
     315        if (bindingStrings[i] == "")
     316        {
     317          // empty binding, occurs at least the first time since init value is " "
     318          bindings[i].OnPress.clear();
     319          bindings[i].OnRelease.clear();
     320          bindings[i].OnHold.clear();
     321        }
     322        else
     323        {
     324          // actually parse the command(s)
     325          SubString commands(bindingStrings[i], "|", SubString::WhiteSpaces, false,
     326              '\\', false, '"', false, '(', ')', false, '\0');
     327          bindings[i].OnHold.nCommands = 0;
     328          bindings[i].OnHold.commands = new SimpleCommand[64];
     329          bindings[i].OnPress.nCommands = 0;
     330          bindings[i].OnPress.commands = new SimpleCommand[64];
     331          bindings[i].OnRelease.nCommands = 0;
     332          bindings[i].OnRelease.commands = new SimpleCommand[64];
     333          for (unsigned int iCommand = 0; iCommand < commands.size(); iCommand++)
     334          {
     335            if (commands[iCommand] != "")
     336            {
     337              SubString tokens(commands[iCommand], " ", SubString::WhiteSpaces, false,
     338                  '\\', false, '"', false, '(', ')', false, '\0');
     339             
     340              unsigned int iToken = 0;
     341
     342              // first argument can be OnPress, OnHold OnRelease or nothing
     343              KeybindMode::Enum mode = KeybindMode::None;
     344              if (getLowercase(tokens[iToken]) == "onpress")
     345                mode = KeybindMode::OnPress,   iToken++;
     346              if (getLowercase(tokens[iToken]) == "onrelease")
     347                mode = KeybindMode::OnRelease, iToken++;
     348              if (getLowercase(tokens[iToken]) == "onhold")
     349                mode = KeybindMode::OnHold,    iToken++;
     350
     351              if (iToken == tokens.size())
     352                continue;
     353
     354              SimpleCommand* cmd = new SimpleCommand();
     355
     356              // second argument can be the amplitude for the case it as an axis command
     357              // default amplitude is 1.0f
     358              if (getLowercase(tokens[iToken]) == "axisamp")
     359              {
     360                iToken++;
     361                float value;
     362                if (iToken == tokens.size() || !convertValue(&value, tokens[iToken]))
     363                {
     364                  CCOUT(2) << "Error while parsing key binding " << names[i]
     365                      << ". Numeric expression expected afer 'AxisAmp', switching to default value" << std::endl;
     366                  if (iToken == tokens.size())
     367                  {
     368                    delete cmd;
     369                    continue;
     370                  }
     371                  cmd->axisModifier = 1.0f;
     372                }
     373                else
     374                  cmd->axisModifier = value;
     375                iToken++;
     376              }
     377              else
     378                cmd->axisModifier = 1.0f;
     379
     380              // no more arguments expected except for the actual command
     381              if (iToken == tokens.size())
     382              { // no command given
     383                delete cmd;
     384                continue;
     385              }
     386              while (iToken != tokens.size())
     387                cmd->commandStr += tokens[iToken++] + " ";
     388
     389              // check whether we exceed 64 commands...
     390              if (bindings[i].OnHold.nCommands == 64 || bindings[i].OnPress.nCommands == 64
     391                  || bindings[i].OnRelease.nCommands == 64)
     392              {
     393                CCOUT(2) << "Error while parsing key binding " << names[i]
     394                    << ". You shouldn't assign more than 64 key bindings to one key "
     395                    << "just to test the parser" << std::endl;
     396              }
     397
     398              // evaluate the command
     399              cmd->axisCommand = 0;
     400              CommandEvaluation& eval = CommandExecutor::evaluate(cmd->commandStr);
     401              // TOOD: check for axis command
     402              if (false)
     403              {
     404                cmd->axisCommand->commandStr = cmd->commandStr;
     405                cmd->commandStr = "";
     406                cmd->axisCommand->evaluation = eval;
     407                // add command to the buffer if not yet existing
     408                for (unsigned int iAxisCmd = 0; iAxisCmd < axisCommands_.size(); iAxisCmd++)
     409                {
     410                  if (getLowercase(axisCommands_[iAxisCmd]->commandStr) == getLowercase(cmd->commandStr))
     411                  {
     412                    // already in list
     413                    cmd->axisCommand = axisCommands_[iAxisCmd];
     414                    break;
     415                  }
     416                }
     417                if (cmd->axisCommand == 0)
     418                {
     419                  cmd->axisCommand = new AxisCommand();
     420                  axisCommands_.push_back(cmd->axisCommand);
     421                }
     422                // TODO: check for relative/absolute command
     423                cmd->axisCommand->bRelative = false;
     424
     425                // axis commands are always OnHold
     426                *(bindings[i].OnHold.commands + bindings[i].OnHold.nCommands++) = *cmd;
     427              }
     428              else
     429              {
     430                cmd->evaluation = eval;
     431
     432                // TODO: determine whether the command is OnHold, OnPress or OnRelease
     433                switch (mode)
     434                {
     435                case KeybindMode::None:
     436                  *(bindings[i].OnPress.commands + bindings[i].OnPress.nCommands++) = *cmd;
     437                  break;
     438                case KeybindMode::OnPress:
     439                  *(bindings[i].OnPress.commands + bindings[i].OnPress.nCommands++) = *cmd;
     440                  break;
     441                case KeybindMode::OnHold:
     442                  *(bindings[i].OnHold.commands + bindings[i].OnHold.nCommands++) = *cmd;
     443                  break;
     444                case KeybindMode::OnRelease:
     445                  *(bindings[i].OnRelease.commands + bindings[i].OnRelease.nCommands++) = *cmd;
     446                  break;                     
     447                }
     448              }
     449            }
     450          }
     451
     452          // redimension arrays with simple commands
     453          SimpleCommand* sCmd = bindings[i].OnHold.commands;
     454          if (bindings[i].OnHold.nCommands)
     455          {
     456            bindings[i].OnHold.commands = new SimpleCommand[bindings[i].OnHold.nCommands];
     457            for (unsigned int iCmd = 0; iCmd < bindings[i].OnHold.nCommands; iCmd++)
     458              bindings[i].OnHold.commands[iCmd] = sCmd[iCmd];
     459          }
     460          else
     461            bindings[i].OnHold.commands = 0;
     462          delete[] sCmd;
     463
     464          sCmd = bindings[i].OnPress.commands;
     465          if (bindings[i].OnPress.nCommands)
     466          {
     467            bindings[i].OnPress.commands = new SimpleCommand[bindings[i].OnPress.nCommands];
     468            for (unsigned int iCmd = 0; iCmd < bindings[i].OnPress.nCommands; iCmd++)
     469              bindings[i].OnPress.commands[iCmd] = sCmd[iCmd];
     470          }
     471          else
     472            bindings[i].OnPress.commands = 0;
     473          delete[] sCmd;
     474
     475          sCmd = bindings[i].OnRelease.commands;
     476          if (bindings[i].OnRelease.nCommands)
     477          {
     478            bindings[i].OnRelease.commands = new SimpleCommand[bindings[i].OnRelease.nCommands];
     479            for (unsigned int iCmd = 0; iCmd < bindings[i].OnRelease.nCommands; iCmd++)
     480              bindings[i].OnRelease.commands[iCmd] = sCmd[iCmd];
     481          }
     482          else
     483            bindings[i].OnRelease.commands = 0;
     484          delete[] sCmd;
     485        }
     486      }
     487    }
     488    return true;
    330489  }
    331490
     
    333492    @brief Overwrites all bindings with ""
    334493  */
    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     }
     494  void KeyBinder::clearBindings(bool bInit)
     495  {
     496    for (int i = 0; i < nKeys_s; i++)
     497    {
     498      clearBundle(bindingsKeys_[i], bInit);
     499      bindingStringsKeys_[i] = " ";
     500    }
     501    for (int i = 0; i < nMouseButtons_s; i++)
     502    {
     503      clearBundle(bindingsMouseButtons_[i], bInit);
     504      bindingStringsMouseButtons_[i] = " ";
     505    }
     506    for (int i = 0; i < nJoyStickButtons_s; i++)
     507    {
     508      clearBundle(bindingsJoyStickButtons_[i], bInit);
     509      bindingStringsJoyStickButtons_[i] = " ";
     510    }
     511    for (int i = 0; i < nHalfAxes_s; i++)
     512    {
     513      clearBundle(bindingsHalfAxes_[i], bInit);
     514      bindingStringsHalfAxes_[i] = " ";
     515    }
     516    for (unsigned int i = 0; i < axisCommands_.size(); i++)
     517      delete axisCommands_[i];
     518    axisCommands_.clear();
     519  }
     520
     521  void KeyBinder::clearBundle(KeyBindingBundle& bundle, bool bInit)
     522  {
     523    if (!bInit)
     524    {
     525      if (bundle.OnHold.nCommands)
     526        delete[] bundle.OnHold.commands;
     527      if (bundle.OnPress.nCommands)
     528        delete[] bundle.OnPress.commands;
     529      if (bundle.OnRelease.nCommands)
     530        delete[] bundle.OnRelease.commands;
     531    }
     532    bundle.OnPress.nCommands = 0;
     533    bundle.OnHold.nCommands = 0;
     534    bundle.OnRelease.nCommands = 0;
    355535  }
    356536
     
    361541  bool KeyBinder::loadBindings()
    362542  {
    363     COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings..." << std::endl;
     543    COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
     544
     545    // clear half axes
     546    for (unsigned int i = 0; i < nHalfAxes_s; i++)
     547    {
     548      halfAxes_[i].hasChanged = false;
     549      halfAxes_[i].abs = 0.0f;
     550      halfAxes_[i].rel = 0.0f;
     551      halfAxes_[i].wasDown = false;
     552      halfAxes_[i].threshold = 0.01f;
     553    }
    364554
    365555    ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
     556    clearBindings();
    366557    setConfigValues();
    367558
    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 != "")
    373       {
    374         bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
    375         bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
    376       }
    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())
    388       {
    389         // key binding has changed, reevaluate the command string.
    390         binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
    391         binding.commandStr = binding.evaluation.getCommandString();
    392       }
    393       COUT(ORX_DEBUG) << "Keybinding: Executing command: " << binding.commandStr << std::endl;
    394       CommandExecutor::execute(binding.commandStr);
    395     }
    396 
     559    COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
     560    return true;
     561  }
     562
     563  void KeyBinder::tick(float dt)
     564  {
     565    // we have to process all the analog input since there is e.g. no 'mouseDoesntMove' event.
     566    for (unsigned int i = 0; i < nHalfAxes_s; i++)
     567    {
     568      if (!halfAxes_[i].hasChanged)
     569      {
     570        if (!halfAxes_[i].wasDown && halfAxes_[i].abs > halfAxes_[i].threshold)
     571        {
     572          halfAxes_[i].wasDown = true;
     573          if (bindingsHalfAxes_[i].OnPress.nCommands)
     574            executeBinding(bindingsHalfAxes_[i].OnPress, halfAxes_[i].rel, halfAxes_[i].abs);
     575        }
     576        else if (halfAxes_[i].wasDown && halfAxes_[i].abs < halfAxes_[i].threshold)
     577        {
     578          halfAxes_[i].wasDown = false;
     579          if (bindingsHalfAxes_[i].OnRelease.nCommands)
     580            executeBinding(bindingsHalfAxes_[i].OnRelease, halfAxes_[i].rel, halfAxes_[i].abs);
     581        }
     582        if (halfAxes_[i].wasDown)
     583        {
     584          executeBinding(bindingsHalfAxes_[i].OnHold, halfAxes_[i].rel, halfAxes_[i].abs);
     585        }
     586        halfAxes_[i].hasChanged = false;
     587      }
     588    }
     589
     590    // execute all buffered bindings (addional parameter)
     591    for (unsigned int i = 0; i < axisCommands_.size(); i++)
     592    {
     593      if (axisCommands_[i]->nValuesAdded > 0)
     594      {
     595        axisCommands_[i]->evaluation.setEvaluatedParameter(0, axisCommands_[i]->value);
     596        // reset
     597        axisCommands_[i]->nValuesAdded = 0;
     598        axisCommands_[i]->value = 0.0f;
     599      }
     600    }
     601  }
     602
     603  bool KeyBinder::executeBinding(KeyBinding& binding, float axisRel, float axisAbs)
     604  {
     605    // execute all the parsed commands in the string
     606    for (unsigned int iCommand = 0; iCommand < binding.nCommands; iCommand++)
     607    {
     608      SimpleCommand& command = binding.commands[iCommand];
     609      if (command.axisCommand)
     610      {
     611        AxisCommand& axisCommand = *command.axisCommand;
     612        // command has an additional parameter
     613        if (command.axisCommand->bRelative)
     614        {
     615          // we have to calculate a relative movement.
     616          // amplitude says how much one keystroke is
     617          axisCommand.value += command.axisModifier * axisRel;
     618        }
     619        else
     620        {
     621          // we have to calculate absolute position of the axis.
     622          // for a key this simply is 1, but multiplied by a user defined factor
     623          // since there might be another axis that is affected, we have to wait and
     624          // store the result in a temporary place
     625          axisCommand.value =
     626              (axisCommand.value * (axisCommand.nValuesAdded++) + command.axisModifier * axisAbs)
     627              / axisCommand.nValuesAdded;
     628        }
     629      }
     630      else
     631      {
     632        // simple command, just execute directly
     633        // TODO: calculate whether this a Press, Release or Hold event
     634        CommandExecutor::execute(command.evaluation);
     635      }
     636    }
    397637    return true;
    398638  }
     
    406646  {
    407647    // find the appropriate key binding
    408     executeSimpleBinding(bindingsKeyPress_[int(evt.key)]);
     648    executeBinding(bindingsKeys_[int(evt.key)].OnPress, 1.0, 1.0);
    409649
    410650    return true;
     
    418658  {
    419659    // find the appropriate key binding
    420     executeSimpleBinding(bindingsKeyRelease_[int(evt.key)]);
     660    executeBinding(bindingsKeys_[int(evt.key)].OnRelease, 1.0, 1.0);
    421661
    422662    return true;
     
    430670  {
    431671    // find the appropriate key binding
    432     executeSimpleBinding(bindingsKeyHold_[int(evt.key)]);
     672    executeBinding(bindingsKeys_[int(evt.key)].OnHold, 1.0, 1.0);
    433673
    434674    return true;
     
    439679    @param e Mouse state information
    440680  */
    441   bool KeyBinder::mouseMoved(const MouseState &evt)
    442   {
    443     /*if (bindingMouseMoved_.commandStr != "")
    444     {
    445       if (bindingMouseMoved_.commandStr != bindingMouseMoved_.evaluation.getCommandString())
    446       {
    447         // key binding has changed, reevaluate the command string.
    448         bindingMouseMoved_.evaluation = CommandExecutor::evaluate(bindingMouseMoved_.commandStr);
    449         bindingMouseMoved_.commandStr = bindingMouseMoved_.evaluation.getCommandString();
    450       }
    451       COUT(3) << "Executing command: " << bindingMouseMoved_.commandStr << std::endl;
    452 
    453       bindingMouseMoved_.evaluation.setEvaluatedParameter(
    454       CommandExecutor::execute(bindingMouseMoved_.commandStr);
    455     }*/
     681  bool KeyBinder::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
     682  {
     683    halfAxes_[0].hasChanged = true;
     684    halfAxes_[1].hasChanged = true;
     685    halfAxes_[2].hasChanged = true;
     686    halfAxes_[3].hasChanged = true;
     687    // translate absolute mouse position into joystick like behaviour
     688    if (clippingSize.x > clippingSize.y)
     689    {
     690      int margin = (clippingSize.x - clippingSize.y) / 2;
     691      if (abs.x - margin > clippingSize.y)
     692      {
     693        halfAxes_[0].abs = 1.0f;
     694        halfAxes_[1].abs = 0.0f;
     695      }
     696      else if (abs.x < margin)
     697      {
     698        halfAxes_[0].abs = 0.0f;
     699        halfAxes_[1].abs = 1.0f;
     700      }
     701      else
     702      {
     703        float temp = ((float)abs.x) / clippingSize.y * 2 - 1;
     704        if (temp > 0)
     705        {
     706          halfAxes_[0].abs = temp;
     707          halfAxes_[1].abs = 0.0f;
     708        }
     709        else
     710        {
     711          halfAxes_[0].abs = 0.0f;
     712          halfAxes_[1].abs = -temp;
     713        }
     714      }
     715
     716      float temp = -((float)abs.y) / clippingSize.y * 2 + 1;
     717      if (temp > 0)
     718      {
     719        halfAxes_[2].abs = temp;
     720        halfAxes_[3].abs = 0.0;
     721      }
     722      else
     723      {
     724        halfAxes_[2].abs = 0.0;
     725        halfAxes_[3].abs = -temp;
     726      }
     727    }
     728    else
     729    {
     730      float temp = ((float)abs.x) / clippingSize.x * 2 - 1;
     731      if (temp > 0)
     732      {
     733        halfAxes_[0].abs = temp;
     734        halfAxes_[1].abs = 0.0;
     735      }
     736      else
     737      {
     738        halfAxes_[0].abs = 0.0;
     739        halfAxes_[1].abs = -temp;
     740      }
     741
     742      int margin = (clippingSize.y - clippingSize.x) / 2;
     743      if (abs.y - margin > clippingSize.x)
     744      {
     745        halfAxes_[2].abs = 0.0;
     746        halfAxes_[3].abs = 1.0;
     747      }
     748      else if (abs.y < margin)
     749      {
     750        halfAxes_[2].abs = 1.0;
     751        halfAxes_[3].abs = 0.0;
     752      }
     753      else
     754      {
     755        float temp = -((float)abs.y) / clippingSize.x * 2 + 1;
     756        if (temp > 0)
     757        {
     758          halfAxes_[2].abs = temp;
     759          halfAxes_[3].abs = 0.0;
     760        }
     761        else
     762        {
     763          halfAxes_[2].abs = 0.0;
     764          halfAxes_[3].abs = -temp;
     765        }
     766      }
     767    }
     768   
     769    // relative movements
     770    if (rel.x > 0)
     771    {
     772      halfAxes_[0].rel = rel.x;
     773      halfAxes_[1].rel = 0.0;
     774    }
     775    else
     776    {
     777      halfAxes_[0].rel = 0.0;
     778      halfAxes_[1].rel = rel.x;
     779    }
     780
     781    if (rel.y /*!*/ < /*!*/ 0)
     782    {
     783      halfAxes_[0].rel = -rel.y;
     784      halfAxes_[1].rel = 0.0;
     785    }
     786    else
     787    {
     788      halfAxes_[0].rel = 0.0;
     789      halfAxes_[1].rel = -rel.y;
     790    }
    456791
    457792    return true;
     
    462797    @param e Mouse state information
    463798  */
    464   bool KeyBinder::mouseScrolled(const MouseState &evt)
    465   {
     799  bool KeyBinder::mouseScrolled(int abs, int rel)
     800  {
     801    // TODO: obvious...
    466802    return true;
    467803  }
     
    472808    @param id The ID of the mouse button
    473809  */
    474   bool KeyBinder::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
     810  bool KeyBinder::mouseButtonPressed(MouseButton::Enum id)
    475811  {
    476812    // find the appropriate key binding
    477     executeSimpleBinding(bindingsMouseButtonPress_[int(id)]);
     813    executeBinding(bindingsMouseButtons_[int(id)].OnPress, 1.0, 1.0);
    478814
    479815    return true;
     
    485821    @param id The ID of the mouse button
    486822  */
    487   bool KeyBinder::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
     823  bool KeyBinder::mouseButtonReleased(MouseButton::Enum id)
    488824  {
    489825    // find the appropriate key binding
    490     executeSimpleBinding(bindingsMouseButtonRelease_[int(id)]);
     826    executeBinding(bindingsMouseButtons_[int(id)].OnRelease, 1.0, 1.0);
    491827
    492828    return true;
     
    498834    @param id The ID of the mouse button
    499835  */
    500   bool KeyBinder::mouseButtonHeld(const MouseState& state, MouseButton::Enum id)
     836  bool KeyBinder::mouseButtonHeld(MouseButton::Enum id)
    501837  {
    502838    // 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)
     839    executeBinding(bindingsMouseButtons_[int(id)].OnHold, 1.0, 1.0);
     840
     841    return true;
     842  }
     843
     844  bool KeyBinder::joyStickButtonPressed(int joyStickID, int button)
    509845  {
    510846    // find the appropriate key binding
    511     executeSimpleBinding(bindingsJoyStickButtonPress_[button]);
    512 
    513     return true;
    514   }
    515 
    516   bool KeyBinder::joyStickButtonReleased(const JoyStickState& state, int button)
     847    executeBinding(bindingsJoyStickButtons_[button].OnPress, 1.0, 1.0);
     848
     849    return true;
     850  }
     851
     852  bool KeyBinder::joyStickButtonReleased(int joyStickID, int button)
    517853  {
    518854    // find the appropriate key binding
    519     executeSimpleBinding(bindingsJoyStickButtonRelease_[button]);
    520 
    521     return true;
    522   }
    523 
    524   bool KeyBinder::joyStickButtonHeld(const JoyStickState& state, int button)
     855    executeBinding(bindingsJoyStickButtons_[button].OnRelease, 1.0, 1.0);
     856
     857    return true;
     858  }
     859
     860  bool KeyBinder::joyStickButtonHeld(int joyStickID, int button)
    525861  {
    526862    // 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 
     863    executeBinding(bindingsJoyStickButtons_[button].OnHold, 1.0, 1.0);
     864
     865    return true;
     866  }
     867
     868  bool KeyBinder::joyStickAxisMoved(int joyStickID, int axis, int value)
     869  {
     870    // TODO: check whether 16 bit integer as general axis value is a good idea (works under windows)
     871    halfAxes_[8 + axis].hasChanged = true;
     872    if (value >= 0)
     873    {
     874      halfAxes_[8 + axis].abs = ((float)value)/0x1000;
     875      halfAxes_[8 + axis].hasChanged = true;
     876    }
     877    else
     878    {
     879      halfAxes_[8 + axis + 1].abs = -((float)value)/0x1000;
     880      halfAxes_[8 + axis + 1].hasChanged = true;
     881    }
     882    return true;
     883  }
    552884
    553885
  • code/branches/input/src/core/InputHandler.h

    r1293 r1323  
    4040
    4141#include "ois/OIS.h"
     42#include "util/Math.h"
    4243#include "OrxonoxClass.h"
    4344#include "CommandExecutor.h"
     
    4647namespace orxonox
    4748{
    48   namespace KeybindSetting
    49   {
    50     enum KeybindSetting
    51     {
    52       None,
    53       OnPress,
    54       OnRelease,
    55       Continuous,
    56     };
    57   }
    58 
    59   struct _CoreExport KeyBinding
     49  struct _CoreExport AxisCommand
    6050  {
    6151    std::string commandStr;
    6252    CommandEvaluation evaluation;
    63   };
    64  
     53    bool bRelative;
     54    float value;
     55    unsigned int nValuesAdded;
     56  };
     57
     58  struct _CoreExport SimpleCommand
     59  {
     60    // for simple binding; direct
     61    std::string commandStr;
     62    CommandEvaluation evaluation;
     63
     64    // axis binding; buffered
     65    AxisCommand* axisCommand;
     66    float axisModifier;
     67  };
     68
     69  struct _CoreExport KeyBinding
     70  {
     71    void clear() { commands = 0; nCommands = 0; }
     72    SimpleCommand* commands;
     73    unsigned int nCommands;
     74  };
     75
     76  struct _CoreExport KeyBindingBundle
     77  {
     78    KeyBinding OnPress;
     79    KeyBinding OnRelease;
     80    KeyBinding OnHold;
     81  };
     82
     83  struct _CoreExport HalfAxis
     84  {
     85    float rel;
     86    float abs;
     87    float threshold;
     88    bool wasDown;
     89    bool hasChanged;
     90  };
     91
    6592
    6693  /**
     
    75102
    76103    bool loadBindings();
    77     void clearBindings();
     104    void clearBindings(bool bInit = false);
    78105
    79106    void setConfigValues();
    80107
    81108  private: // functions
    82 
    83     bool executeSimpleBinding(KeyBinding &binding);
     109    bool readBindings(std::string* names, std::string* bindingStrings, KeyBindingBundle* bindings, unsigned int size);
     110    bool executeBinding(KeyBinding& binding, float axisRel, float axisAbs);
     111    void clearBundle(KeyBindingBundle& bundle, bool bInit);
     112
     113    void tick(float dt);
    84114
    85115    bool keyPressed (const KeyEvent& evt);
     
    87117    bool keyHeld    (const KeyEvent& evt);
    88118
    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) ;
     119    bool mouseButtonPressed (MouseButton::Enum id);
     120    bool mouseButtonReleased(MouseButton::Enum id);
     121    bool mouseButtonHeld    (MouseButton::Enum id);
     122    bool mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
     123    bool mouseScrolled      (int abs, int rel);
     124
     125    bool joyStickButtonPressed (int joyStickID, int button);
     126    bool joyStickButtonReleased(int joyStickID, int button);
     127    bool joyStickButtonHeld    (int joyStickID, int button);
     128    bool joyStickAxisMoved     (int joyStickID, int axis, int value)  ;
    102129
    103130  private: // variables
    104 
    105131    //! 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];
     132    static const unsigned int nKeys_s = 0xEE;
     133    //! Actual key bindings as bundle for Press, Hold and Release
     134    KeyBindingBundle bindingsKeys_ [nKeys_s];
    113135    //! Names of the keys as strings
    114     std::string keyNames_[numberOfKeys_s];
     136    std::string namesKeys_         [nKeys_s];
     137    //! The configured string values
     138    std::string bindingStringsKeys_[nKeys_s];
    115139
    116140    //! 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_;
     141    static const unsigned int nMouseButtons_s = 8;
     142    //! Actual key bindings as bundle for Press, Hold and Release
     143    KeyBindingBundle bindingsMouseButtons_ [nMouseButtons_s];
    128144    //! Names of the mouse buttons as strings
    129     std::string mouseButtonNames_[numberOfMouseButtons_s];
     145    std::string namesMouseButtons_         [nMouseButtons_s];
     146    //! The configured string values
     147    std::string bindingStringsMouseButtons_[nMouseButtons_s];
    130148
    131149    //! 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];
     150    static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
     151    //! Actual key bindings as bundle for Press, Hold and Release
     152    KeyBindingBundle bindingsJoyStickButtons_ [nJoyStickButtons_s];
    139153    //! Names of the joy stick buttons as strings
    140     std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
    141 
     154    std::string namesJoyStickButtons_         [nJoyStickButtons_s];
     155    //! The configured string values
     156    std::string bindingStringsJoyStickButtons_[nJoyStickButtons_s];
     157
     158    //! denotes the number of half axes (every axis twice) there can be.
     159    static const unsigned int nHalfAxes_s = 56;
     160    /**
     161    * Array with all the half axes for mouse and joy sticks.
     162    * Bear in mind that the positions are fixed and that the first entry is the
     163    * positive one and the second is negative.
     164    * Sequence is as follows:
     165    *  0 -  3: Mouse x and y
     166    *  4 -  7: Mouse scroll wheels 1 and 2 (2 not yet supported)
     167    *  8 - 23: joy stick (slider) axes 1 to 8
     168    * 24 - 55: joy stick axes 1 - 16
     169    */
     170    HalfAxis halfAxes_[nHalfAxes_s];
     171    //! Actual key bindings as bundle for Press, Hold and Release
     172    KeyBindingBundle bindingsHalfAxes_ [nHalfAxes_s];
     173    //! Names of the half axes
     174    std::string namesHalfAxes_         [nHalfAxes_s];
     175    //! The configured string values
     176    std::string bindingStringsHalfAxes_[nHalfAxes_s];
     177
     178    /**
     179    * Commands that have additional parameters (axes) are executed at the end of
     180    * the tick() so that all values can be buffered for single execution.
     181    */
     182    std::vector<AxisCommand*> axisCommands_;
    142183  };
    143184
  • code/branches/input/src/core/InputInterfaces.h

    r1293 r1323  
    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:
     
    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 bool mouseButtonPressed (MouseButton::Enum id) = 0;
     284    virtual bool mouseButtonReleased(MouseButton::Enum id) = 0;
     285    virtual bool mouseButtonHeld    (MouseButton::Enum id) = 0;
     286    virtual bool mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
     287    virtual bool 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 bool joyStickButtonPressed (int joyStickID, int button) = 0;
     299    virtual bool joyStickButtonReleased(int joyStickID, int button) = 0;
     300    virtual bool joyStickButtonHeld    (int joyStickID, int button) = 0;
     301    virtual bool joyStickAxisMoved     (int joyStickID, int axis, int value) = 0;
     302    //virtual bool joyStickVector3Moved  (int joyStickID, int index /*, fill list*/) {return true;}
    292303  };
    293304
  • code/branches/input/src/core/InputManager.cc

    r1293 r1323  
    267267    activeJoyStickHandlers_.resize(joySticksSize_);
    268268    joyStickButtonsDown_.resize(joySticksSize_);
     269    povStates_.resize(joySticksSize_);
     270    sliderStates_.resize(joySticksSize_);
    269271    return success;
    270272  }
     
    348350    }
    349351    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
     352  }
     353
     354  void InputManager::_updateTickables()
     355  {
     356    // we can use a set to have a list of unique pointers (an object can implement all 3 handlers)
     357    std::set<InputTickable*> tempSet;
     358    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
     359      tempSet.insert(activeKeyHandlers_[iHandler]);
     360    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
     361      tempSet.insert(activeMouseHandlers_[iHandler]);
     362    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
     363      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     364        tempSet.insert(activeJoyStickHandlers_[iJoyStick][iHandler]);
     365
     366    // copy the content of the set back to the actual vector
     367    activeHandlers_.clear();
     368    for (std::set<InputTickable*>::const_iterator itHandler = tempSet.begin(); itHandler != tempSet.end(); itHandler++)
     369      activeHandlers_.push_back(*itHandler);
    350370  }
    351371
     
    389409
    390410        case IS_GUI:
    391           // FIXME: do stuff
     411          // TODO: do stuff
    392412          break;
    393413
     
    426446    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
    427447      for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
    428         activeMouseHandlers_[iHandler]->mouseButtonHeld(mouse_->getMouseState(), mouseButtonsDown_[iButton]);
     448        activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
    429449
    430450    // call all the handlers for the held joy stick button events
     
    432452      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
    433453        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    434           activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(
    435               JoyStickState(joySticks_[iJoyStick]->getJoyStickState(), iJoyStick), joyStickButtonsDown_[iJoyStick][iButton]);
     454          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
     455
     456
     457    // call the ticks
     458    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
     459      activeHandlers_[iHandler]->tick(dt);
    436460  }
    437461
     
    508532    {
    509533      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    510         activeMouseHandlers_[i]->mouseMoved(e.state);
     534        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
     535            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
    511536    }
    512537
     
    515540    {
    516541      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    517         activeMouseHandlers_[i]->mouseScrolled(e.state);
     542        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
    518543    }
    519544
     
    536561
    537562    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    538       activeMouseHandlers_[i]->mouseButtonPressed(e.state, (MouseButton::Enum)id);
     563      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
    539564
    540565    return true;
     
    559584
    560585    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    561       activeMouseHandlers_[i]->mouseButtonReleased(e.state, (MouseButton::Enum)id);
     586      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
    562587
    563588    return true;
     
    584609
    585610    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    586       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(JoyStickState(arg.state, iJoyStick), button);
     611      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
    587612
    588613    return true;
     
    609634
    610635    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    611       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(JoyStickState(arg.state, iJoyStick), button);
     636      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
    612637
    613638    return true;
     
    616641  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
    617642  {
     643    //CCOUT(3) << arg.state.mAxes[axis].abs << std::endl;
    618644    // use the device to identify which one called the method
    619645    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     
    622648      iJoyStick++;
    623649
     650    // keep in mind that the first 8 axes are reserved for the sliders
    624651    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    625       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(JoyStickState(arg.state, iJoyStick), axis);
     652      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
    626653
    627654    return true;
     
    630657  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
    631658  {
     659    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
    632660    // use the device to identify which one called the method
    633661    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     
    636664      iJoyStick++;
    637665
    638     for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    639       activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickSliderMoved(JoyStickState(arg.state, iJoyStick), id);
     666    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
     667    {
     668      // slider X axis changed
     669      sliderStates_[iJoyStick].sliderStates[id].x = arg.state.mSliders[id].abX;
     670      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     671        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, id * 2, arg.state.mSliders[id].abX);
     672    }
     673    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
     674    {
     675      // slider Y axis changed
     676      sliderStates_[iJoyStick].sliderStates[id].y = arg.state.mSliders[id].abY;
     677      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     678        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
     679    }
    640680
    641681    return true;
     
    650690      iJoyStick++;
    651691
    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)
     692    // translate the POV into 8 simple buttons
     693    int lastState = povStates_[iJoyStick][id];
     694    if (lastState & OIS::Pov::North)
     695      buttonReleased(arg, 32 + id * 4 + 0);
     696    if (lastState & OIS::Pov::South)
     697      buttonReleased(arg, 32 + id * 4 + 1);
     698    if (lastState & OIS::Pov::East)
     699      buttonReleased(arg, 32 + id * 4 + 2);
     700    if (lastState & OIS::Pov::West)
     701      buttonReleased(arg, 32 + id * 4 + 3);
     702   
     703    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
     704    int currentState = povStates_[iJoyStick][id];
     705    if (currentState & OIS::Pov::North)
     706      buttonPressed(arg, 32 + id * 4 + 0);
     707    if (currentState & OIS::Pov::South)
     708      buttonPressed(arg, 32 + id * 4 + 1);
     709    if (currentState & OIS::Pov::East)
     710      buttonPressed(arg, 32 + id * 4 + 2);
     711    if (currentState & OIS::Pov::West)
     712      buttonPressed(arg, 32 + id * 4 + 3);
     713
     714    return true;
     715  }
     716
     717  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
    659718  {
    660719    // use the device to identify which one called the method
     
    668727
    669728    return true;
    670   }
     729  }*/
    671730
    672731
     
    735794  }
    736795
    737   const MouseState InputManager::getMouseState()
     796  /*const MouseState InputManager::getMouseState()
    738797  {
    739798    if (_getSingleton().mouse_)
     
    741800    else
    742801      return MouseState();
    743   }
    744 
    745   const JoyStickState InputManager::getJoyStickState(unsigned int ID)
     802  }*/
     803
     804  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
    746805  {
    747806    if (ID < _getSingleton().joySticksSize_)
     
    749808    else
    750809      return JoyStickState();
    751   }
     810  }*/
    752811
    753812
     
    882941      if ((*it) == (*mapIt).second)
    883942      {
    884         _getSingleton().stateRequest_ = IS_CUSTOM;
    885943        return true;
    886944      }
     
    888946    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
    889947    _getSingleton().stateRequest_ = IS_CUSTOM;
     948    _getSingleton()._updateTickables();
    890949    return true;
    891950  }
     
    910969        _getSingleton().activeKeyHandlers_.erase(it);
    911970        _getSingleton().stateRequest_ = IS_CUSTOM;
     971        _getSingleton()._updateTickables();
    912972        return true;
    913973      }
    914974    }
    915     _getSingleton().stateRequest_ = IS_CUSTOM;
    916975    return true;
    917976  }
     
    10101069      if ((*it) == (*mapIt).second)
    10111070      {
    1012         _getSingleton().stateRequest_ = IS_CUSTOM;
    10131071        return true;
    10141072      }
     
    10161074    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
    10171075    _getSingleton().stateRequest_ = IS_CUSTOM;
     1076    _getSingleton()._updateTickables();
    10181077    return true;
    10191078  }
     
    10381097        _getSingleton().activeMouseHandlers_.erase(it);
    10391098        _getSingleton().stateRequest_ = IS_CUSTOM;
     1099        _getSingleton()._updateTickables();
    10401100        return true;
    10411101      }
    10421102    }
    1043     _getSingleton().stateRequest_ = IS_CUSTOM;
    10441103    return true;
    10451104  }
     
    11471206      if ((*it) == (*handlerIt).second)
    11481207      {
    1149         _getSingleton().stateRequest_ = IS_CUSTOM;
    11501208        return true;
    11511209      }
     
    11531211    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
    11541212    _getSingleton().stateRequest_ = IS_CUSTOM;
     1213    _getSingleton()._updateTickables();
    11551214    return true;
    11561215  }
     
    11801239        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
    11811240        _getSingleton().stateRequest_ = IS_CUSTOM;
     1241        _getSingleton()._updateTickables();
    11821242        return true;
    11831243      }
  • code/branches/input/src/core/InputManager.h

    r1293 r1323  
    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/branches/input/src/core/SignalHandler.cc

    r1293 r1323  
    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/branches/input/src/orxonox/objects/SpaceShip.cc

    r1293 r1323  
    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    bool 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;
     
    411356    }
    412357
    413     bool SpaceShip::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
     358    bool SpaceShip::mouseButtonPressed(MouseButton::Enum id)
    414359    {
    415360        if (id == MouseButton::Left)
     
    421366    }
    422367
    423     bool SpaceShip::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
     368    bool SpaceShip::mouseButtonReleased(MouseButton::Enum id)
    424369    {
    425370        if (id == MouseButton::Left)
     
    564509        else
    565510            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 */
     511    }
     512
    790513}
  • code/branches/input/src/orxonox/objects/SpaceShip.h

    r1293 r1323  
    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            bool mouseButtonPressed (MouseButton::Enum id);
     70            bool mouseButtonReleased(MouseButton::Enum id);
     71            bool mouseButtonHeld    (MouseButton::Enum id) { return true; }
     72            bool mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
     73            bool mouseScrolled      (int abs, int rel) { return true; }
    7574
    7675
  • code/branches/input/src/util/Math.h

    r1062 r1323  
    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
    149158#endif /* _Util_Math_H__ */
  • code/branches/input/src/util/SubString.cc

    r1056 r1323  
    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/branches/input/src/util/SubString.h

    r1062 r1323  
    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);
  • code/branches/input/visual_studio/vc8/network.vcproj

    r1293 r1323  
    7070                <Configuration
    7171                        Name="Release|Win32"
    72                         ConfigurationType="2"
     72                        ConfigurationType="4"
    7373                        InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\network_properties.vsprops"
    7474                        CharacterSet="1"
     
    103103                        />
    104104                        <Tool
    105                                 Name="VCLinkerTool"
     105                                Name="VCLibrarianTool"
    106106                        />
    107107                        <Tool
     
    109109                        />
    110110                        <Tool
    111                                 Name="VCManifestTool"
    112                         />
    113                         <Tool
    114111                                Name="VCXDCMakeTool"
    115112                        />
     
    119116                        <Tool
    120117                                Name="VCFxCopTool"
    121                         />
    122                         <Tool
    123                                 Name="VCAppVerifierTool"
    124                         />
    125                         <Tool
    126                                 Name="VCWebDeploymentTool"
    127118                        />
    128119                        <Tool
  • code/branches/input/visual_studio/vc8/orxonox.vcproj

    r1293 r1323  
    165165                        </File>
    166166                        <File
     167                                RelativePath="..\..\src\orxonox\PlayerManager.cc"
     168                                >
     169                        </File>
     170                        <File
    167171                                RelativePath="..\..\src\orxonox\PrecompiledHeaderFiles.cc"
    168172                                >
     
    444448                        <File
    445449                                RelativePath="..\..\src\orxonox\OrxonoxStableHeaders.h"
     450                                >
     451                        </File>
     452                        <File
     453                                RelativePath="..\..\src\orxonox\PlayerManager.h"
    446454                                >
    447455                        </File>
Note: See TracChangeset for help on using the changeset viewer.