iutil/evdefs.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

iutil/evdefs.h
Go to the documentation of this file.

    00001 /*
    00002     Event system related interfaces
    00003     Written by Andrew Zabolotny <bit@eltech.ru>
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00018 */
    00019
    00020 /*
    00021                                 *WARNING*
    00022     This file must contain only plain-C code.  Do _not_ insert C++ code.
    00023     This file is imported by non-C++ system driver implementations.
    00024
    00025     Unfortunately, given the way the new event system works, this means
    00026     a lot of things that used to be macros and static values that went
    00027     here are now (fundamentally) C++ method invocations.  Since most of
    00028     these are event names which are only really useful in conjunction
    00029     with C++ event creation, subscription, and scheduling interfaces
    00030     anyway, they have largely moved to csutil/eventnames.h.
    00031 */
    00032
    00041 #ifndef __CS_IUTIL_EVDEFS_H__
    00042 #define __CS_IUTIL_EVDEFS_H__
    00043
    00045 typedef enum _csKeyEventType
    00046 {
    00048   csKeyEventTypeUp = 0,
    00050   csKeyEventTypeDown
    00051 } csKeyEventType;
    00052
    00054 typedef enum _csMouseEventType
    00055 {
    00057   csMouseEventTypeMove = 0,
    00059   csMouseEventTypeUp,
    00061   csMouseEventTypeDown,
    00063   csMouseEventTypeClick,
    00065   csMouseEventTypeDoubleClick
    00066 } csMouseEventType;
    00067
    00073 enum csMouseButton
    00074 {
    00076   csmbNone = -1,
    00078   csmbLeft = 0,
    00080   csmbRight = 1,
    00082   csmbMiddle = 2,
    00084   csmbWheelUp = 3,
    00086   csmbWheelDown = 4,
    00088   csmbExtra1 = 5,
    00090   csmbExtra2 = 6,
    00092   csmbHWheelLeft = 7,
    00094   csmbHWheelRight = 8
    00095 };
    00096
    00102
    00103 typedef enum _csKeyModifierType
    00104 {
    00106   csKeyModifierTypeShift = 0,
    00108   csKeyModifierTypeCtrl,
    00110   csKeyModifierTypeAlt,
    00112   csKeyModifierTypeCapsLock,
    00114   csKeyModifierTypeNumLock,
    00116   csKeyModifierTypeScrollLock,
    00117
    00121   csKeyModifierTypeLast
    00122 } csKeyModifierType;
    00123
    00125 typedef enum _csKeyModifierNumType
    00126 {
    00128   csKeyModifierNumLeft = 0,
    00130   csKeyModifierNumRight,
    00131
    00136   csKeyModifierNumAny = 0x1f
    00137 } csKeyModifierNumType;
    00138
    00140 typedef struct _csKeyModifiers
    00141 {
    00158   unsigned int modifiers[csKeyModifierTypeLast];
    00159 } csKeyModifiers;
    00168
    00169 #define CSMASK_SHIFT            (1 << csKeyModifierTypeShift)
    00170
    00171 #define CSMASK_CTRL             (1 << csKeyModifierTypeCtrl)
    00172
    00173 #define CSMASK_ALT              (1 << csKeyModifierTypeAlt)
    00174
    00175 #define CSMASK_ALLSHIFTS        (CSMASK_SHIFT | CSMASK_CTRL | CSMASK_ALT)
    00176
    00178 #define CSMASK_CAPSLOCK         (1 << csKeyModifierTypeCapsLock)
    00179
    00180 #define CSMASK_NUMLOCK          (1 << csKeyModifierTypeNumLock)
    00181
    00182 #define CSMASK_SCROLLLOCK       (1 << csKeyModifierTypeScrollLock)
    00183
    00184 #define CSMASK_ALLLOCKS (CSMASK_CAPSLOCK | CSMASK_NUMLOCK | CSMASK_SCROLLLOCK)
    00185
    00187 #define CSMASK_ALLMODIFIERS     (CSMASK_CAPSLOCK | CSMASK_NUMLOCK | \
    00188                                  CSMASK_SCROLLLOCK | CSMASK_ALLSHIFTS)
    00189
    00202
    00203 #define CSKEY_ESC                       27
    00204
    00205 #define CSKEY_ENTER                     '\n'
    00206
    00207 #define CSKEY_TAB                       '\t'
    00208
    00209 #define CSKEY_BACKSPACE                 '\b'
    00210
    00211 #define CSKEY_SPACE                     ' '
    00212
    00214 #define CSKEY_SPECIAL_FIRST             0x108000
    00215
    00216 #define CSKEY_SPECIAL_LAST              0x10fffd
    00217
    00218 #define CSKEY_SPECIAL(code)             (CSKEY_SPECIAL_FIRST + (code))
    00219
    00220 #define CSKEY_IS_SPECIAL(rawCode)       \
    00221   ((rawCode >= CSKEY_SPECIAL_FIRST) && ((rawCode) <= CSKEY_SPECIAL_LAST))
    00222
    00223 #define CSKEY_SPECIAL_NUM(rawCode)      ((rawCode) - CSKEY_SPECIAL_FIRST)
    00224
    00226 #define CSKEY_UP                        CSKEY_SPECIAL(0x00)
    00227
    00228 #define CSKEY_DOWN                      CSKEY_SPECIAL(0x01)
    00229
    00230 #define CSKEY_LEFT                      CSKEY_SPECIAL(0x02)
    00231
    00232 #define CSKEY_RIGHT                     CSKEY_SPECIAL(0x03)
    00233
    00234 #define CSKEY_PGUP                      CSKEY_SPECIAL(0x04)
    00235
    00236 #define CSKEY_PGDN                      CSKEY_SPECIAL(0x05)
    00237
    00238 #define CSKEY_HOME                      CSKEY_SPECIAL(0x06)
    00239
    00240 #define CSKEY_END                       CSKEY_SPECIAL(0x07)
    00241
    00242 #define CSKEY_INS                       CSKEY_SPECIAL(0x08)
    00243
    00244 #define CSKEY_DEL                       CSKEY_SPECIAL(0x09)
    00245
    00246 #define CSKEY_CONTEXT                   CSKEY_SPECIAL(0x0a)
    00247
    00248 #define CSKEY_PRINTSCREEN               CSKEY_SPECIAL(0x0b)
    00249
    00250 #define CSKEY_PAUSE                     CSKEY_SPECIAL(0x0c)
    00251
    00252 #define CSKEY_F1                        CSKEY_SPECIAL(0x10)
    00253
    00254 #define CSKEY_F2                        CSKEY_SPECIAL(0x11)
    00255
    00256 #define CSKEY_F3                        CSKEY_SPECIAL(0x12)
    00257
    00258 #define CSKEY_F4                        CSKEY_SPECIAL(0x13)
    00259
    00260 #define CSKEY_F5                        CSKEY_SPECIAL(0x14)
    00261
    00262 #define CSKEY_F6                        CSKEY_SPECIAL(0x15)
    00263
    00264 #define CSKEY_F7                        CSKEY_SPECIAL(0x16)
    00265
    00266 #define CSKEY_F8                        CSKEY_SPECIAL(0x17)
    00267
    00268 #define CSKEY_F9                        CSKEY_SPECIAL(0x18)
    00269
    00270 #define CSKEY_F10                       CSKEY_SPECIAL(0x19)
    00271
    00272 #define CSKEY_F11                       CSKEY_SPECIAL(0x1a)
    00273
    00274 #define CSKEY_F12                       CSKEY_SPECIAL(0x1b)
    00275
    00277 #define CSKEY_MODIFIER_FIRST            0x2000
    00278
    00279 #define CSKEY_MODIFIER_LAST             0x3fff
    00280
    00284 #define CSKEY_MODIFIERTYPE_SHIFT        5
    00285
    00286 #define CSKEY_MODIFIER(type, num)               \
    00287   CSKEY_SPECIAL(CSKEY_MODIFIER_FIRST + ((type) << CSKEY_MODIFIERTYPE_SHIFT) + (num))
    00288
    00289 #define CSKEY_IS_MODIFIER(rawCode)      \
    00290   (CSKEY_IS_SPECIAL(rawCode) &&         \
    00291     ((CSKEY_SPECIAL_NUM(rawCode) >= CSKEY_MODIFIER_FIRST) && \
    00292      (CSKEY_SPECIAL_NUM(rawCode) <= CSKEY_MODIFIER_LAST)))
    00293
    00294 #define CSKEY_MODIFIER_TYPE(rawCode)    \
    00295   (((rawCode) - CSKEY_MODIFIER_FIRST - CSKEY_SPECIAL_FIRST) >> \
    00296   CSKEY_MODIFIERTYPE_SHIFT)
    00297
    00298 #define CSKEY_MODIFIER_NUM(rawCode)     \
    00299   (((rawCode) - CSKEY_MODIFIER_FIRST - CSKEY_SPECIAL_FIRST) & \
    00300   ((1 << CSKEY_MODIFIERTYPE_SHIFT) - 1))
    00301
    00303 #define CSKEY_MODIFIER_COMPARE_MASK(bitmask1, bitmask2)                      \
    00304   ((bitmask1) == (bitmask2)                                                  \
    00305 || ((bitmask1) == (unsigned)(1 << csKeyModifierNumAny) && (bitmask2) != 0)   \
    00306 || ((bitmask2) == (unsigned)(1 << csKeyModifierNumAny) && (bitmask1) != 0))
    00307
    00312 #define CSKEY_MODIFIER_COMPARE_CODE(key1, key2)                              \
    00313   ((CSKEY_MODIFIER_TYPE (key1) == CSKEY_MODIFIER_TYPE (key2))                \
    00314   && ((CSKEY_MODIFIER_NUM(key1) == csKeyModifierNumAny)                      \
    00315     || (CSKEY_MODIFIER_NUM(key2) == csKeyModifierNumAny)                     \
    00316     || (CSKEY_MODIFIER_NUM(key1) == CSKEY_MODIFIER_NUM(key1))))
    00317
    00319 #define CSKEY_SHIFT_NUM(n)              CSKEY_MODIFIER(csKeyModifierTypeShift,n)
    00320
    00321 #define CSKEY_SHIFT_FIRST               CSKEY_SHIFT_NUM(0)
    00322
    00323 #define CSKEY_SHIFT_LAST                CSKEY_SHIFT_NUM(0x1e)
    00324
    00326 #define CSKEY_SHIFT_LEFT                CSKEY_SHIFT_NUM(csKeyModifierNumLeft)
    00327
    00328 #define CSKEY_SHIFT_RIGHT               CSKEY_SHIFT_NUM(csKeyModifierNumRight)
    00329
    00330 #define CSKEY_SHIFT                     CSKEY_SHIFT_NUM(csKeyModifierNumAny)
    00331
    00333 #define CSKEY_CTRL_NUM(n)               CSKEY_MODIFIER(csKeyModifierTypeCtrl,n)
    00334
    00335 #define CSKEY_CTRL_FIRST                CSKEY_CTRL_NUM(0)
    00336
    00337 #define CSKEY_CTRL_LAST                 CSKEY_CTRL_NUM(0x1e)
    00338
    00340 #define CSKEY_CTRL_LEFT                 CSKEY_CTRL_NUM(csKeyModifierNumLeft)
    00341
    00342 #define CSKEY_CTRL_RIGHT                CSKEY_CTRL_NUM(csKeyModifierNumRight)
    00343
    00344 #define CSKEY_CTRL                      CSKEY_CTRL_NUM(csKeyModifierNumAny)
    00345
    00347 #define CSKEY_ALT_NUM(n)                CSKEY_MODIFIER(csKeyModifierTypeAlt,n)
    00348
    00349 #define CSKEY_ALT_FIRST                 CSKEY_ALT_NUM(0)
    00350
    00351 #define CSKEY_ALT_LAST                  CSKEY_ALT_NUM(0x1e)
    00352
    00354 #define CSKEY_ALT_LEFT                  CSKEY_ALT_NUM(csKeyModifierNumLeft)
    00355
    00356 #define CSKEY_ALT_RIGHT                 CSKEY_ALT_NUM(csKeyModifierNumRight)
    00357
    00358 #define CSKEY_ALT                       CSKEY_ALT_NUM(csKeyModifierNumAny)
    00359
    00361 #define CSKEY_PAD_FLAG                  0x4000
    00362
    00363 #define CSKEY_PAD_KEY(code) CSKEY_SPECIAL((unsigned int)(code) | CSKEY_PAD_FLAG)
    00364
    00366 #define CSKEY_IS_PAD_KEY(rawCode)       (((rawCode) & CSKEY_PAD_FLAG) != 0)
    00367
    00370 #define CSKEY_PAD_TO_NORMAL(rawCode)    ((rawCode) & (~CSKEY_PAD_FLAG))
    00371
    00373 #define CSKEY_PAD1                      CSKEY_PAD_KEY('1')
    00374
    00375 #define CSKEY_PAD2                      CSKEY_PAD_KEY('2')
    00376
    00377 #define CSKEY_PAD3                      CSKEY_PAD_KEY('3')
    00378
    00379 #define CSKEY_PAD4                      CSKEY_PAD_KEY('4')
    00380
    00381 #define CSKEY_PAD5                      CSKEY_PAD_KEY('5')
    00382
    00383 #define CSKEY_CENTER                    CSKEY_PAD5
    00384
    00385 #define CSKEY_PAD6                      CSKEY_PAD_KEY('6')
    00386
    00387 #define CSKEY_PAD7                      CSKEY_PAD_KEY('7')
    00388
    00389 #define CSKEY_PAD8                      CSKEY_PAD_KEY('8')
    00390
    00391 #define CSKEY_PAD9                      CSKEY_PAD_KEY('9')
    00392
    00393 #define CSKEY_PAD0                      CSKEY_PAD_KEY('0')
    00394
    00395 #define CSKEY_PADDECIMAL                CSKEY_PAD_KEY('.')
    00396
    00397 #define CSKEY_PADDIV                    CSKEY_PAD_KEY('/')
    00398
    00399 #define CSKEY_PADMULT                   CSKEY_PAD_KEY('*')
    00400
    00401 #define CSKEY_PADMINUS                  CSKEY_PAD_KEY('-')
    00402
    00403 #define CSKEY_PADPLUS                   CSKEY_PAD_KEY('+')
    00404
    00405 #define CSKEY_PADENTER                  CSKEY_PAD_KEY('\n')
    00406
    00411 #define CSKEY_PADNUM \
    00412   (CSKEY_MODIFIER(csKeyModifierTypeNumLock,csKeyModifierNumAny) | CSKEY_PAD_FLAG)
    00413
    00414 #define CSKEY_CAPSLOCK \
    00415   CSKEY_MODIFIER(csKeyModifierTypeCapsLock,csKeyModifierNumAny)
    00416
    00417 #define CSKEY_SCROLLLOCK \
    00418   CSKEY_MODIFIER(csKeyModifierTypeScrollLock,csKeyModifierNumAny)
    00419
    00421 typedef enum _csKeyCharType
    00422 {
    00424   csKeyCharTypeNormal = 0,
    00426   csKeyCharTypeDead
    00427 } csKeyCharType;
    00428
    00443
    00444 #define CSEVTYPE_Keyboard       0x00000001
    00445
    00446 #define CSEVTYPE_Mouse          0x00000002
    00447
    00448 #define CSEVTYPE_Joystick       0x00000004
    00449
    00451 #endif // __CS_IUTIL_EVDEFS_H__