## Public API Reference

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

- 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
    00074 typedef enum _csKeyModifierType
    00075 {
    00077   csKeyModifierTypeShift = 0,
    00079   csKeyModifierTypeCtrl,
    00081   csKeyModifierTypeAlt,
    00083   csKeyModifierTypeCapsLock,
    00085   csKeyModifierTypeNumLock,
    00087   csKeyModifierTypeScrollLock,
    00088
    00092   csKeyModifierTypeLast
    00093 } csKeyModifierType;
    00094
    00096 typedef enum _csKeyModifierNumType
    00097 {
    00099   csKeyModifierNumLeft = 0,
    00101   csKeyModifierNumRight,
    00102
    00107   csKeyModifierNumAny = 0x1f
    00108 } csKeyModifierNumType;
    00109
    00111 typedef struct _csKeyModifiers
    00112 {
    00129   unsigned int modifiers[csKeyModifierTypeLast];
    00130 } csKeyModifiers;
    00139
    00140 #define CSMASK_SHIFT            (1 << csKeyModifierTypeShift)
    00141
    00142 #define CSMASK_CTRL             (1 << csKeyModifierTypeCtrl)
    00143
    00144 #define CSMASK_ALT              (1 << csKeyModifierTypeAlt)
    00145
    00146 #define CSMASK_ALLSHIFTS        (CSMASK_SHIFT | CSMASK_CTRL | CSMASK_ALT)
    00147
    00149 #define CSMASK_CAPSLOCK         (1 << csKeyModifierTypeCapsLock)
    00150
    00151 #define CSMASK_NUMLOCK          (1 << csKeyModifierTypeNumLock)
    00152
    00153 #define CSMASK_SCROLLLOCK       (1 << csKeyModifierTypeScrollLock)
    00154
    00155 #define CSMASK_ALLMODIFIERS     (CSMASK_CAPSLOCK | CSMASK_NUMLOCK | \
    00156                                  CSMASK_SCROLLLOCK | CSMASK_ALLSHIFTS)
    00157
    00170
    00171 #define CSKEY_ESC                       27
    00172
    00173 #define CSKEY_ENTER                     '\n'
    00174
    00175 #define CSKEY_TAB                       '\t'
    00176
    00177 #define CSKEY_BACKSPACE                 '\b'
    00178
    00179 #define CSKEY_SPACE                     ' '
    00180
    00182 #define CSKEY_SPECIAL_FIRST             0x108000
    00183
    00184 #define CSKEY_SPECIAL_LAST              0x10fffd
    00185
    00186 #define CSKEY_SPECIAL(code)             (CSKEY_SPECIAL_FIRST + (code))
    00187
    00188 #define CSKEY_IS_SPECIAL(rawCode)       \
    00189   ((rawCode >= CSKEY_SPECIAL_FIRST) && ((rawCode) <= CSKEY_SPECIAL_LAST))
    00190
    00191 #define CSKEY_SPECIAL_NUM(rawCode)      ((rawCode) - CSKEY_SPECIAL_FIRST)
    00192
    00194 #define CSKEY_UP                        CSKEY_SPECIAL(0x00)
    00195
    00196 #define CSKEY_DOWN                      CSKEY_SPECIAL(0x01)
    00197
    00198 #define CSKEY_LEFT                      CSKEY_SPECIAL(0x02)
    00199
    00200 #define CSKEY_RIGHT                     CSKEY_SPECIAL(0x03)
    00201
    00202 #define CSKEY_PGUP                      CSKEY_SPECIAL(0x04)
    00203
    00204 #define CSKEY_PGDN                      CSKEY_SPECIAL(0x05)
    00205
    00206 #define CSKEY_HOME                      CSKEY_SPECIAL(0x06)
    00207
    00208 #define CSKEY_END                       CSKEY_SPECIAL(0x07)
    00209
    00210 #define CSKEY_INS                       CSKEY_SPECIAL(0x08)
    00211
    00212 #define CSKEY_DEL                       CSKEY_SPECIAL(0x09)
    00213
    00214 #define CSKEY_CONTEXT                   CSKEY_SPECIAL(0x0a)
    00215
    00216 #define CSKEY_PRINTSCREEN               CSKEY_SPECIAL(0x0b)
    00217
    00218 #define CSKEY_PAUSE                     CSKEY_SPECIAL(0x0c)
    00219
    00220 #define CSKEY_F1                        CSKEY_SPECIAL(0x10)
    00221
    00222 #define CSKEY_F2                        CSKEY_SPECIAL(0x11)
    00223
    00224 #define CSKEY_F3                        CSKEY_SPECIAL(0x12)
    00225
    00226 #define CSKEY_F4                        CSKEY_SPECIAL(0x13)
    00227
    00228 #define CSKEY_F5                        CSKEY_SPECIAL(0x14)
    00229
    00230 #define CSKEY_F6                        CSKEY_SPECIAL(0x15)
    00231
    00232 #define CSKEY_F7                        CSKEY_SPECIAL(0x16)
    00233
    00234 #define CSKEY_F8                        CSKEY_SPECIAL(0x17)
    00235
    00236 #define CSKEY_F9                        CSKEY_SPECIAL(0x18)
    00237
    00238 #define CSKEY_F10                       CSKEY_SPECIAL(0x19)
    00239
    00240 #define CSKEY_F11                       CSKEY_SPECIAL(0x1a)
    00241
    00242 #define CSKEY_F12                       CSKEY_SPECIAL(0x1b)
    00243
    00245 #define CSKEY_MODIFIER_FIRST            0x2000
    00246
    00247 #define CSKEY_MODIFIER_LAST             0x3fff
    00248
    00252 #define CSKEY_MODIFIERTYPE_SHIFT        5
    00253
    00254 #define CSKEY_MODIFIER(type, num)               \
    00255   CSKEY_SPECIAL(CSKEY_MODIFIER_FIRST + ((type) << CSKEY_MODIFIERTYPE_SHIFT) + (num))
    00256
    00257 #define CSKEY_IS_MODIFIER(rawCode)      \
    00258   (CSKEY_IS_SPECIAL(rawCode) &&         \
    00259     ((CSKEY_SPECIAL_NUM(rawCode) >= CSKEY_MODIFIER_FIRST) && \
    00260      (CSKEY_SPECIAL_NUM(rawCode) <= CSKEY_MODIFIER_LAST)))
    00261
    00262 #define CSKEY_MODIFIER_TYPE(rawCode)    \
    00263   (((rawCode) - CSKEY_MODIFIER_FIRST - CSKEY_SPECIAL_FIRST) >> \
    00264   CSKEY_MODIFIERTYPE_SHIFT)
    00265
    00266 #define CSKEY_MODIFIER_NUM(rawCode)     \
    00267   (((rawCode) - CSKEY_MODIFIER_FIRST - CSKEY_SPECIAL_FIRST) & \
    00268   ((1 << CSKEY_MODIFIERTYPE_SHIFT) - 1))
    00269
    00271 #define CSKEY_MODIFIER_COMPARE(bitmask1, bitmask2)                           \
    00272   ((bitmask1) == (bitmask2)                                                  \
    00273 || ((bitmask1) == (unsigned)(1 << csKeyModifierNumAny) && (bitmask2) != 0)   \
    00274 || ((bitmask2) == (unsigned)(1 << csKeyModifierNumAny) && (bitmask1) != 0))
    00275
    00277 #define CSKEY_SHIFT_NUM(n)              CSKEY_MODIFIER(csKeyModifierTypeShift,n)
    00278
    00279 #define CSKEY_SHIFT_FIRST               CSKEY_SHIFT_NUM(0)
    00280
    00281 #define CSKEY_SHIFT_LAST                CSKEY_SHIFT_NUM(0x1e)
    00282
    00284 #define CSKEY_SHIFT_LEFT                CSKEY_SHIFT_NUM(csKeyModifierNumLeft)
    00285
    00286 #define CSKEY_SHIFT_RIGHT               CSKEY_SHIFT_NUM(csKeyModifierNumRight)
    00287
    00288 #define CSKEY_SHIFT                     CSKEY_SHIFT_NUM(csKeyModifierNumAny)
    00289
    00291 #define CSKEY_CTRL_NUM(n)               CSKEY_MODIFIER(csKeyModifierTypeCtrl,n)
    00292
    00293 #define CSKEY_CTRL_FIRST                CSKEY_CTRL_NUM(0)
    00294
    00295 #define CSKEY_CTRL_LAST                 CSKEY_CTRL_NUM(0x1e)
    00296
    00298 #define CSKEY_CTRL_LEFT                 CSKEY_CTRL_NUM(csKeyModifierNumLeft)
    00299
    00300 #define CSKEY_CTRL_RIGHT                CSKEY_CTRL_NUM(csKeyModifierNumRight)
    00301
    00302 #define CSKEY_CTRL                      CSKEY_CTRL_NUM(csKeyModifierNumAny)
    00303
    00305 #define CSKEY_ALT_NUM(n)                CSKEY_MODIFIER(csKeyModifierTypeAlt,n)
    00306
    00307 #define CSKEY_ALT_FIRST                 CSKEY_ALT_NUM(0)
    00308
    00309 #define CSKEY_ALT_LAST                  CSKEY_ALT_NUM(0x1e)
    00310
    00312 #define CSKEY_ALT_LEFT                  CSKEY_ALT_NUM(csKeyModifierNumLeft)
    00313
    00314 #define CSKEY_ALT_RIGHT                 CSKEY_ALT_NUM(csKeyModifierNumRight)
    00315
    00316 #define CSKEY_ALT                       CSKEY_ALT_NUM(csKeyModifierNumAny)
    00317
    00319 #define CSKEY_PAD_FLAG                  0x4000
    00320
    00321 #define CSKEY_PAD_KEY(code) CSKEY_SPECIAL((unsigned int)(code) | CSKEY_PAD_FLAG)
    00322
    00324 #define CSKEY_IS_PAD_KEY(rawCode)       (((rawCode) & CSKEY_PAD_FLAG) != 0)
    00325
    00328 #define CSKEY_PAD_TO_NORMAL(rawCode)    ((rawCode) & (~CSKEY_PAD_FLAG))
    00329
    00331 #define CSKEY_PAD1                      CSKEY_PAD_KEY('1')
    00332
    00333 #define CSKEY_PAD2                      CSKEY_PAD_KEY('2')
    00334
    00335 #define CSKEY_PAD3                      CSKEY_PAD_KEY('3')
    00336
    00337 #define CSKEY_PAD4                      CSKEY_PAD_KEY('4')
    00338
    00339 #define CSKEY_PAD5                      CSKEY_PAD_KEY('5')
    00340
    00341 #define CSKEY_CENTER                    CSKEY_PAD5
    00342
    00343 #define CSKEY_PAD6                      CSKEY_PAD_KEY('6')
    00344
    00345 #define CSKEY_PAD7                      CSKEY_PAD_KEY('7')
    00346
    00347 #define CSKEY_PAD8                      CSKEY_PAD_KEY('8')
    00348
    00349 #define CSKEY_PAD9                      CSKEY_PAD_KEY('9')
    00350
    00351 #define CSKEY_PAD0                      CSKEY_PAD_KEY('0')
    00352
    00353 #define CSKEY_PADDECIMAL                CSKEY_PAD_KEY('.')
    00354
    00355 #define CSKEY_PADDIV                    CSKEY_PAD_KEY('/')
    00356
    00357 #define CSKEY_PADMULT                   CSKEY_PAD_KEY('*')
    00358
    00359 #define CSKEY_PADMINUS                  CSKEY_PAD_KEY('-')
    00360
    00361 #define CSKEY_PADPLUS                   CSKEY_PAD_KEY('+')
    00362
    00363 #define CSKEY_PADENTER                  CSKEY_PAD_KEY('\n')
    00364
    00369 #define CSKEY_PADNUM \
    00370   CSKEY_MODIFIER(csKeyModifierTypeNumLock,csKeyModifierNumAny) | CSKEY_PAD_FLAG
    00371
    00372 #define CSKEY_CAPSLOCK \
    00373   CSKEY_MODIFIER(csKeyModifierTypeCapsLock,csKeyModifierNumAny)
    00374
    00375 #define CSKEY_SCROLLLOCK \
    00376   CSKEY_MODIFIER(csKeyModifierTypeScrollLock,csKeyModifierNumAny)
    00377
    00379 typedef enum _csKeyCharType
    00380 {
    00382   csKeyCharTypeNormal = 0,
    00384   csKeyCharTypeDead
    00385 } csKeyCharType;
    00386
    00401
    00402 #define CSEVTYPE_Keyboard       0x00000001
    00403
    00404 #define CSEVTYPE_Mouse          0x00000002
    00405
    00406 #define CSEVTYPE_Joystick       0x00000004
    00407
    00409 #endif // __CS_IUTIL_EVDEFS_H__