CrystalSpace

Public API Reference

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
00091 };
00092 
00098 
00099 typedef enum _csKeyModifierType
00100 {
00102   csKeyModifierTypeShift = 0,
00104   csKeyModifierTypeCtrl,
00106   csKeyModifierTypeAlt,
00108   csKeyModifierTypeCapsLock,
00110   csKeyModifierTypeNumLock,
00112   csKeyModifierTypeScrollLock,
00113   
00117   csKeyModifierTypeLast
00118 } csKeyModifierType;
00119 
00121 typedef enum _csKeyModifierNumType
00122 {
00124   csKeyModifierNumLeft = 0,
00126   csKeyModifierNumRight,
00127   
00132   csKeyModifierNumAny = 0x1f
00133 } csKeyModifierNumType;
00134 
00136 typedef struct _csKeyModifiers
00137 {
00154   unsigned int modifiers[csKeyModifierTypeLast];
00155 } csKeyModifiers;
00164 
00165 #define CSMASK_SHIFT            (1 << csKeyModifierTypeShift)
00167 #define CSMASK_CTRL             (1 << csKeyModifierTypeCtrl)
00169 #define CSMASK_ALT              (1 << csKeyModifierTypeAlt)
00171 #define CSMASK_ALLSHIFTS        (CSMASK_SHIFT | CSMASK_CTRL | CSMASK_ALT)
00172 
00174 #define CSMASK_CAPSLOCK         (1 << csKeyModifierTypeCapsLock)
00176 #define CSMASK_NUMLOCK          (1 << csKeyModifierTypeNumLock)
00178 #define CSMASK_SCROLLLOCK       (1 << csKeyModifierTypeScrollLock)
00180 #define CSMASK_ALLMODIFIERS     (CSMASK_CAPSLOCK | CSMASK_NUMLOCK | \
00181                                  CSMASK_SCROLLLOCK | CSMASK_ALLSHIFTS)
00182 
00195 
00196 #define CSKEY_ESC                       27
00198 #define CSKEY_ENTER                     '\n'
00200 #define CSKEY_TAB                       '\t'
00202 #define CSKEY_BACKSPACE                 '\b'
00204 #define CSKEY_SPACE                     ' '
00205 
00207 #define CSKEY_SPECIAL_FIRST             0x108000
00209 #define CSKEY_SPECIAL_LAST              0x10fffd
00211 #define CSKEY_SPECIAL(code)             (CSKEY_SPECIAL_FIRST + (code))
00213 #define CSKEY_IS_SPECIAL(rawCode)       \
00214   ((rawCode >= CSKEY_SPECIAL_FIRST) && ((rawCode) <= CSKEY_SPECIAL_LAST))
00216 #define CSKEY_SPECIAL_NUM(rawCode)      ((rawCode) - CSKEY_SPECIAL_FIRST)
00217 
00219 #define CSKEY_UP                        CSKEY_SPECIAL(0x00)
00221 #define CSKEY_DOWN                      CSKEY_SPECIAL(0x01)
00223 #define CSKEY_LEFT                      CSKEY_SPECIAL(0x02)
00225 #define CSKEY_RIGHT                     CSKEY_SPECIAL(0x03)
00227 #define CSKEY_PGUP                      CSKEY_SPECIAL(0x04)
00229 #define CSKEY_PGDN                      CSKEY_SPECIAL(0x05)
00231 #define CSKEY_HOME                      CSKEY_SPECIAL(0x06)
00233 #define CSKEY_END                       CSKEY_SPECIAL(0x07)
00235 #define CSKEY_INS                       CSKEY_SPECIAL(0x08)
00237 #define CSKEY_DEL                       CSKEY_SPECIAL(0x09)
00239 #define CSKEY_CONTEXT                   CSKEY_SPECIAL(0x0a)
00241 #define CSKEY_PRINTSCREEN               CSKEY_SPECIAL(0x0b)
00243 #define CSKEY_PAUSE                     CSKEY_SPECIAL(0x0c)
00245 #define CSKEY_F1                        CSKEY_SPECIAL(0x10)
00247 #define CSKEY_F2                        CSKEY_SPECIAL(0x11)
00249 #define CSKEY_F3                        CSKEY_SPECIAL(0x12)
00251 #define CSKEY_F4                        CSKEY_SPECIAL(0x13)
00253 #define CSKEY_F5                        CSKEY_SPECIAL(0x14)
00255 #define CSKEY_F6                        CSKEY_SPECIAL(0x15)
00257 #define CSKEY_F7                        CSKEY_SPECIAL(0x16)
00259 #define CSKEY_F8                        CSKEY_SPECIAL(0x17)
00261 #define CSKEY_F9                        CSKEY_SPECIAL(0x18)
00263 #define CSKEY_F10                       CSKEY_SPECIAL(0x19)
00265 #define CSKEY_F11                       CSKEY_SPECIAL(0x1a)
00267 #define CSKEY_F12                       CSKEY_SPECIAL(0x1b)
00268 
00270 #define CSKEY_MODIFIER_FIRST            0x2000
00272 #define CSKEY_MODIFIER_LAST             0x3fff
00273 
00277 #define CSKEY_MODIFIERTYPE_SHIFT        5
00279 #define CSKEY_MODIFIER(type, num)               \
00280   CSKEY_SPECIAL(CSKEY_MODIFIER_FIRST + ((type) << CSKEY_MODIFIERTYPE_SHIFT) + (num))
00282 #define CSKEY_IS_MODIFIER(rawCode)      \
00283   (CSKEY_IS_SPECIAL(rawCode) &&         \
00284     ((CSKEY_SPECIAL_NUM(rawCode) >= CSKEY_MODIFIER_FIRST) && \
00285      (CSKEY_SPECIAL_NUM(rawCode) <= CSKEY_MODIFIER_LAST)))
00287 #define CSKEY_MODIFIER_TYPE(rawCode)    \
00288   (((rawCode) - CSKEY_MODIFIER_FIRST - CSKEY_SPECIAL_FIRST) >> \
00289   CSKEY_MODIFIERTYPE_SHIFT)
00291 #define CSKEY_MODIFIER_NUM(rawCode)     \
00292   (((rawCode) - CSKEY_MODIFIER_FIRST - CSKEY_SPECIAL_FIRST) & \
00293   ((1 << CSKEY_MODIFIERTYPE_SHIFT) - 1))  
00294 
00296 #define CSKEY_MODIFIER_COMPARE_MASK(bitmask1, bitmask2)                      \
00297   ((bitmask1) == (bitmask2)                                                  \
00298 || ((bitmask1) == (unsigned)(1 << csKeyModifierNumAny) && (bitmask2) != 0)   \
00299 || ((bitmask2) == (unsigned)(1 << csKeyModifierNumAny) && (bitmask1) != 0))
00300 
00305 #define CSKEY_MODIFIER_COMPARE_CODE(key1, key2)                              \
00306   ((CSKEY_MODIFIER_TYPE (key1) == CSKEY_MODIFIER_TYPE (key2))                \
00307   && ((CSKEY_MODIFIER_NUM(key1) == csKeyModifierNumAny)                      \
00308     || (CSKEY_MODIFIER_NUM(key2) == csKeyModifierNumAny)                     \
00309     || (CSKEY_MODIFIER_NUM(key1) == CSKEY_MODIFIER_NUM(key1))))
00310 
00312 #define CSKEY_SHIFT_NUM(n)              CSKEY_MODIFIER(csKeyModifierTypeShift,n)
00314 #define CSKEY_SHIFT_FIRST               CSKEY_SHIFT_NUM(0)
00316 #define CSKEY_SHIFT_LAST                CSKEY_SHIFT_NUM(0x1e)
00317 
00319 #define CSKEY_SHIFT_LEFT                CSKEY_SHIFT_NUM(csKeyModifierNumLeft)
00321 #define CSKEY_SHIFT_RIGHT               CSKEY_SHIFT_NUM(csKeyModifierNumRight)
00323 #define CSKEY_SHIFT                     CSKEY_SHIFT_NUM(csKeyModifierNumAny)
00324 
00326 #define CSKEY_CTRL_NUM(n)               CSKEY_MODIFIER(csKeyModifierTypeCtrl,n)
00328 #define CSKEY_CTRL_FIRST                CSKEY_CTRL_NUM(0)
00330 #define CSKEY_CTRL_LAST                 CSKEY_CTRL_NUM(0x1e)
00331 
00333 #define CSKEY_CTRL_LEFT                 CSKEY_CTRL_NUM(csKeyModifierNumLeft)
00335 #define CSKEY_CTRL_RIGHT                CSKEY_CTRL_NUM(csKeyModifierNumRight)
00337 #define CSKEY_CTRL                      CSKEY_CTRL_NUM(csKeyModifierNumAny)
00338 
00340 #define CSKEY_ALT_NUM(n)                CSKEY_MODIFIER(csKeyModifierTypeAlt,n)
00342 #define CSKEY_ALT_FIRST                 CSKEY_ALT_NUM(0)
00344 #define CSKEY_ALT_LAST                  CSKEY_ALT_NUM(0x1e)
00345 
00347 #define CSKEY_ALT_LEFT                  CSKEY_ALT_NUM(csKeyModifierNumLeft)
00349 #define CSKEY_ALT_RIGHT                 CSKEY_ALT_NUM(csKeyModifierNumRight)
00351 #define CSKEY_ALT                       CSKEY_ALT_NUM(csKeyModifierNumAny)
00352 
00354 #define CSKEY_PAD_FLAG                  0x4000
00356 #define CSKEY_PAD_KEY(code) CSKEY_SPECIAL((unsigned int)(code) | CSKEY_PAD_FLAG)
00357 
00359 #define CSKEY_IS_PAD_KEY(rawCode)       (((rawCode) & CSKEY_PAD_FLAG) != 0)
00360 
00363 #define CSKEY_PAD_TO_NORMAL(rawCode)    ((rawCode) & (~CSKEY_PAD_FLAG))
00364 
00366 #define CSKEY_PAD1                      CSKEY_PAD_KEY('1')
00368 #define CSKEY_PAD2                      CSKEY_PAD_KEY('2')
00370 #define CSKEY_PAD3                      CSKEY_PAD_KEY('3')
00372 #define CSKEY_PAD4                      CSKEY_PAD_KEY('4')
00374 #define CSKEY_PAD5                      CSKEY_PAD_KEY('5')
00376 #define CSKEY_CENTER                    CSKEY_PAD5
00378 #define CSKEY_PAD6                      CSKEY_PAD_KEY('6')
00380 #define CSKEY_PAD7                      CSKEY_PAD_KEY('7')
00382 #define CSKEY_PAD8                      CSKEY_PAD_KEY('8')
00384 #define CSKEY_PAD9                      CSKEY_PAD_KEY('9')
00386 #define CSKEY_PAD0                      CSKEY_PAD_KEY('0')
00388 #define CSKEY_PADDECIMAL                CSKEY_PAD_KEY('.')
00390 #define CSKEY_PADDIV                    CSKEY_PAD_KEY('/')
00392 #define CSKEY_PADMULT                   CSKEY_PAD_KEY('*')
00394 #define CSKEY_PADMINUS                  CSKEY_PAD_KEY('-')
00396 #define CSKEY_PADPLUS                   CSKEY_PAD_KEY('+')
00398 #define CSKEY_PADENTER                  CSKEY_PAD_KEY('\n')
00399 
00404 #define CSKEY_PADNUM \
00405   CSKEY_MODIFIER(csKeyModifierTypeNumLock,csKeyModifierNumAny) | CSKEY_PAD_FLAG
00407 #define CSKEY_CAPSLOCK \
00408   CSKEY_MODIFIER(csKeyModifierTypeCapsLock,csKeyModifierNumAny)
00410 #define CSKEY_SCROLLLOCK \
00411   CSKEY_MODIFIER(csKeyModifierTypeScrollLock,csKeyModifierNumAny)
00412 
00414 typedef enum _csKeyCharType
00415 {
00417   csKeyCharTypeNormal = 0,
00419   csKeyCharTypeDead
00420 } csKeyCharType;
00421 
00436 
00437 #define CSEVTYPE_Keyboard       0x00000001
00439 #define CSEVTYPE_Mouse          0x00000002
00441 #define CSEVTYPE_Joystick       0x00000004
00442 
00444 #endif // __CS_IUTIL_EVDEFS_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3