PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PEvent.h
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/devices/PEven.h
4// Purpose: Events processed by Event Loop.
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2004-2026 Shane T. Mueller <smueller@obereed.net>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#ifndef __PEVENT_H__
28#define __PEVENT_H__
29
30#include "PKeyboard.h"
31#include "../base/Variant.h"
32#include "SDL.h"
33
34//These are some super-lightweight structs for
35//representing different events.
36
37//Various useful symbolic enumerations.
38enum
39 {
54 };
55
56
57//Keyboard Events
58typedef struct
59{
60
61 PEBL_Keycode scancode; //this is the scancode--position on the keyboard,
62 //that does not change with a new keyboard layout
63 //Probably not used much as it will be confusing to
64 //end-user.
65
66 PEBL_Keycode key; //This is a keycode--layout-independent key identity event.
67 unsigned int state; //PEBL_PRESSED or PEBL_RELEASED
68 int modkeys; //or'ed set of mod keys.
69
71
72
73//text input event:
74typedef struct
75{
76 unsigned int window;
77 char * text;
78
80
81//This is for more complex input, text in text boxes, handling
82//multi-character and unicode input.
83typedef struct
84{
85 unsigned int window;
86 char * text; //is this managed and deleted?
87 unsigned int start;
88 unsigned int length;
89
91
92
93
94//Mouse movement events
95typedef struct
96{
97 unsigned int x, y;
98 int relx, rely;
99
101
102//Mouse Button event
103typedef struct
104{
105 unsigned int x, y;
106 unsigned button; //123 is left middle right
107 unsigned state; //0 is up; 1 is down???
108
110
111
112//Mouse wheel event
113typedef struct
114{
115 long unsigned int x, y; //position of cursor during wheel
116 long int deltax, deltay;//relative x/y movement of wheel.
117 int direction; //codes reversed mouse wheel garbage
118
120
121
122
123//Mouse Button event
124typedef struct
125{
126 unsigned state; //the bitstate of the port.
127
129
130typedef struct
131{
132 bool value; //Not sure if event has anything in it.
134
135
136typedef struct
137{
138 bool value; //Not sure if event has anything in it.
140
141typedef struct
142{
143 int w;
144 int h;
145 //We may need to keep track of which window.
147
148
149typedef struct
150{
151 int value;
152
154
155
157{
158 public:
159 PEvent(PEBL_DEVICE_TYPE type, long unsigned int time,unsigned int windowID);
160 PEvent(const PEvent & evt);
161
162 ~PEvent();
163
164 operator Variant(); //transforms event into a variant
165 //that is exposed to the user.
166
167 PEBL_DEVICE_TYPE GetType() const {return mType;};
168
169 void SetKeyboardEvent(const PEBL_KeyboardEvent & evt);
171 void SetTextInputEvent(const PEBL_TextInputEvent & evt);
175 void SetPortEvent(const PEBL_PortEvent & evt);
177 void SetMovieEndEvent(const PEBL_MovieEndEvent & evt);
178 void SetWindowEvent(const PEBL_WindowEvent & evt);
179 void SetDummyEvent(const PEBL_DummyEvent & evt);
180
181 int GetState(int iface) const;
182
183 unsigned long int GetEventTime()const {return mEventTime;};
185
188
197
198 private:
199
200 PEBL_DEVICE_TYPE mType;
201
202 union
203 {
215
216 } mEvent;
217
218 //This keeps track of the time the event was
219 //first processed at.
220 unsigned long int mEventTime;
221 unsigned int mWindowID;
222};
223
224
225#endif
PEBL_DEVICE_TYPE
Definition PDevice.h:40
@ PEBL_TIMEOUT
Definition PEvent.h:48
@ PEBL_LEFT
Definition PEvent.h:43
@ PEBL_WINDOWHEIGHT
Definition PEvent.h:52
@ PEBL_RELEASED
Definition PEvent.h:46
@ PEBL_DOWN
Definition PEvent.h:42
@ PEBL_PRESSED
Definition PEvent.h:45
@ PEBL_WINDOWWIDTH
Definition PEvent.h:51
@ PEBL_EQUALS
Definition PEvent.h:49
@ PEBL_DIFFERS
Definition PEvent.h:50
@ PEBL_MOVEMENT
Definition PEvent.h:47
@ PEBL_UNKNOWN
Definition PEvent.h:40
@ PEBL_RIGHT
Definition PEvent.h:44
@ PEBL_UP
Definition PEvent.h:41
@ PEBL_TEXT_INPUT
Definition PEvent.h:53
PEBL_Keycode
Definition PKeyboard.h:78
void SetWindowEvent(const PEBL_WindowEvent &evt)
Definition PEvent.cpp:175
PEBL_WindowEvent GetWindowEvent() const
Definition PEvent.cpp:432
void SetMovieRefreshEvent(const PEBL_MovieRefreshEvent &evt)
Definition PEvent.cpp:163
PEBL_KeyboardEvent keyboardEvent
Definition PEvent.h:204
PEBL_DEVICE_TYPE GetType() const
Definition PEvent.h:167
PEBL_MouseMovementEvent GetMouseMovementEvent() const
Definition PEvent.cpp:341
PEBL_TextInputEvent textInputEvent
Definition PEvent.h:206
PEBL_MouseButtonEvent GetPortEvent() const
PEBL_TextInputEvent GetTextInputEvent() const
Definition PEvent.cpp:324
void SetDummyEvent(const PEBL_DummyEvent &evt)
Definition PEvent.cpp:183
PEBL_MovieRefreshEvent GetMovieRefreshEvent() const
Definition PEvent.cpp:389
PEBL_MouseButtonEvent mouseButtonEvent
Definition PEvent.h:208
void SetKeyboardEvent(const PEBL_KeyboardEvent &evt)
Definition PEvent.cpp:122
unsigned long int GetEventTime() const
Definition PEvent.h:183
PEBL_MouseMovementEvent mouseMovementEvent
Definition PEvent.h:207
PEBL_MouseButtonEvent GetMouseButtonEvent() const
Definition PEvent.cpp:357
PEBL_MovieEndEvent movieEndEvent
Definition PEvent.h:212
PEBL_MouseWheelEvent mouseWheelEvent
Definition PEvent.h:209
PEBL_DummyEvent dummyEvent
Definition PEvent.h:214
PEBL_MouseWheelEvent GetMouseWheelEvent() const
Definition PEvent.cpp:372
PEBL_MovieEndEvent GetMovieEndEvent() const
Definition PEvent.cpp:401
PEBL_WindowEvent windowEvent
Definition PEvent.h:213
void SetMovieEndEvent(const PEBL_MovieEndEvent &evt)
Definition PEvent.cpp:169
PEBL_KeyboardEvent GetKeyboardEvent() const
Definition PEvent.cpp:294
void SetTextInputEvent(const PEBL_TextInputEvent &evt)
Definition PEvent.cpp:136
PEBL_DummyEvent GetDummyEvent() const
Definition PEvent.cpp:414
void SetTextEditingEvent(const PEBL_TextEditingEvent &evt)
Definition PEvent.cpp:130
void SetPortEvent(const PEBL_PortEvent &evt)
int GetState(int iface) const
Definition PEvent.cpp:447
void SetMouseMovementEvent(const PEBL_MouseMovementEvent &evt)
Definition PEvent.cpp:143
PEBL_PortEvent portEvent
Definition PEvent.h:210
PEBL_TextEditingEvent textEditingEvent
Definition PEvent.h:205
PEBL_MovieRefreshEvent movieRefreshEvent
Definition PEvent.h:211
PEBL_TextEditingEvent GetTextEditingEvent() const
Definition PEvent.cpp:312
void SetMouseButtonEvent(const PEBL_MouseButtonEvent &evt)
Definition PEvent.cpp:149
void SetMouseWheelEvent(const PEBL_MouseWheelEvent &evt)
Definition PEvent.cpp:157
~PEvent()
Definition PEvent.cpp:188
unsigned int state
Definition PEvent.h:67
PEBL_Keycode scancode
Definition PEvent.h:61
PEBL_Keycode key
Definition PEvent.h:66
unsigned int x
Definition PEvent.h:105
unsigned int x
Definition PEvent.h:97
long unsigned int x
Definition PEvent.h:115
unsigned state
Definition PEvent.h:126
unsigned int window
Definition PEvent.h:76
unsigned int window
Definition PEvent.h:85
unsigned int length
Definition PEvent.h:88
unsigned int start
Definition PEvent.h:87