Coin Logo http://www.sim.no
http://www.coin3d.org

SoKeyboardEvent.h
1#ifndef COIN_SOKEYBOARDEVENT_H
2#define COIN_SOKEYBOARDEVENT_H
3
4/**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Systems in Motion about acquiring
18 * a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25\**************************************************************************/
26
27#include <Inventor/events/SoButtonEvent.h>
28
29// Avoid problem with Microsoft Visual C++ Win32 API headers (yes,
30// they actually #define DELETE in their WINNT.H header file).
31#ifdef DELETE
32#define SOKEYBOARDEVENT_UNDEF_DELETE
33#undef DELETE
34#endif // DELETE
35
36
37#define SO_KEY_PRESS_EVENT(EVENT, KEY) \
38 (SoKeyboardEvent::isKeyPressEvent(EVENT, SoKeyboardEvent::KEY))
39
40#define SO_KEY_RELEASE_EVENT(EVENT, KEY) \
41 (SoKeyboardEvent::isKeyReleaseEvent(EVENT, SoKeyboardEvent::KEY))
42
43
44class COIN_DLL_API SoKeyboardEvent : public SoButtonEvent {
46
47 SO_EVENT_HEADER();
48
49public:
50 enum Key {
51 ANY = 0,
52 UNDEFINED = 1,
53
54 LEFT_SHIFT = 0xffe1, RIGHT_SHIFT, LEFT_CONTROL, RIGHT_CONTROL,
55 LEFT_ALT = 0xffe9, RIGHT_ALT,
56
57 NUMBER_0 = 0x0030, NUMBER_1, NUMBER_2, NUMBER_3, NUMBER_4, NUMBER_5,
58 NUMBER_6, NUMBER_7, NUMBER_8, NUMBER_9,
59
60 A = 0x0061, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T,
61 U, V, W, X, Y, Z,
62
63 HOME = 0xff50, LEFT_ARROW, UP_ARROW, RIGHT_ARROW, DOWN_ARROW,
64 PAGE_UP, PAGE_DOWN, END,
65 PRIOR = 0xff55, NEXT,
66
67 PAD_ENTER = 0xff8d,
68 PAD_F1 = 0xff91, PAD_F2, PAD_F3, PAD_F4,
69 PAD_0 = 0xff9e, PAD_1 = 0xff9c, PAD_2 = 0xff99, PAD_3 = 0xff9b,
70 PAD_4 = 0xff96, PAD_5 = 0xff9d, PAD_6 = 0xff98, PAD_7 = 0xff95,
71 PAD_8 = 0xff97, PAD_9 = 0xff9a,
72 PAD_ADD = 0xffab, PAD_SUBTRACT = 0xffad,
73 PAD_MULTIPLY = 0xffaa, PAD_DIVIDE = 0xffaf,
74 PAD_SPACE = 0xff8d, PAD_TAB = 0xff89,
75 PAD_INSERT = 0xff9e, PAD_DELETE = 0xff9f, PAD_PERIOD = 0xff9f,
76
77 F1 = 0xffbe, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
78
79 BACKSPACE = 0xff08, TAB = 0xff09,
80 RETURN = 0xff0d, ENTER = 0xff0d,
81 PAUSE = 0xff13, SCROLL_LOCK = 0xff14,
82 ESCAPE = 0xff1b, DELETE = 0xffff, KEY_DELETE = DELETE,
83 PRINT = 0xff61, INSERT = 0xff63,
84 NUM_LOCK = 0xff7f, CAPS_LOCK = 0xffe5, SHIFT_LOCK = 0xffe6,
85
86 SPACE = 0x0020, APOSTROPHE = 0x0027,
87 COMMA = 0x002c, MINUS = 0x002d, PERIOD = 0x002e, SLASH = 0x002f,
88 SEMICOLON = 0x003b, EQUAL = 0x003d,
89 BRACKETLEFT = 0x005b, BACKSLASH = 0x005c,
90 BRACKETRIGHT = 0x005d, GRAVE = 0x0060
91 };
92
93 SoKeyboardEvent(void);
94 virtual ~SoKeyboardEvent();
95
96 void setKey(SoKeyboardEvent::Key key);
97 SoKeyboardEvent::Key getKey(void) const;
98
99 void setPrintableCharacter(const char c);
100 char getPrintableCharacter(void) const;
101
102 static SbBool isKeyPressEvent(const SoEvent * e,
103 SoKeyboardEvent::Key whichKey);
104 static SbBool isKeyReleaseEvent(const SoEvent * e,
105 SoKeyboardEvent::Key whichKey);
106
107 static void initClass(void);
108
109private:
110 Key key;
111 char printable;
112 char isprintableset;
113};
114
115
116// Avoid problem with Microsoft Win32 API headers (see above). Define
117// DELETE back to its value in the MSVC header file.
118//
119// FIXME: we shouldn't uncritically trust this value to come from the
120// MSVC headers, but rather check in the block at the top to see that
121// it matches the value we believe it does. Alternatively, we could
122// just don't bother to set it back -- it seems quite unlikely that
123// this would break any client code, but if so, it would be a simple
124// fix on the client side to get around it -- just rearrange
125// headers. 20040629 mortene.
126#ifdef SOKEYBOARDEVENT_UNDEF_DELETE
127#define DELETE (0x00010000L)
128#undef SOKEYBOARDEVENT_UNDEF_DELETE
129#endif // SOKEYBOARDEVENT_UNDEF_DELETE
130
131#endif // !COIN_SOKEYBOARDEVENT_H
The SoButtonEvent class is the base class for all button events.
Definition SoButtonEvent.h:29
static void initClass(void)
Definition SoButtonEvent.cpp:65
The SoEvent class is the base class for all Coin events.
Definition SoEvent.h:34
The SoKeyboardEvent class contains information about keyboard interaction.
Definition SoKeyboardEvent.h:44
Key
Definition SoKeyboardEvent.h:50

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Jan 22 2024 for Coin by Doxygen. 1.10.0