1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __KERNEL_HPP_
|
---|
10 | #define __KERNEL_HPP_
|
---|
11 |
|
---|
12 | #include "arch.hh"
|
---|
13 |
|
---|
14 | class i4_event_handler_class;
|
---|
15 | class i4_device_class;
|
---|
16 | class i4_event_reaction_class;
|
---|
17 | class i4_event;
|
---|
18 |
|
---|
19 | /*
|
---|
20 | The kernel is used to send all events to i4_event_handlers. Currently whenever it gets an
|
---|
21 | event it calls it virtual when() function and determines if the event should be que up and
|
---|
22 | sent later (if when returns LATER) or sent immediatly (if when() return NOW or ANYTIME).
|
---|
23 |
|
---|
24 | example ussage :
|
---|
25 |
|
---|
26 | kernel.send_event(send_to,&ev);
|
---|
27 |
|
---|
28 | */
|
---|
29 |
|
---|
30 |
|
---|
31 | class i4_kernel_device_class
|
---|
32 | {
|
---|
33 | enum {
|
---|
34 | TYPE_MOUSE_MOVE,
|
---|
35 | TYPE_MOUSE_BUTTON_DOWN,
|
---|
36 | TYPE_MOUSE_BUTTON_UP,
|
---|
37 | TYPE_KEY_PRESS,
|
---|
38 | TYPE_KEY_RELEASE,
|
---|
39 | TYPE_DISPLAY_CHANGE, // when display screen changes (size, location, etc).
|
---|
40 | TYPE_DISPLAY_CLOSE,
|
---|
41 | TYPE_SYSTEM_SIGNAL,
|
---|
42 | TYPE_IDLE,
|
---|
43 | TYPE_DO_COMMAND,
|
---|
44 | TYPE_END_COMMAND,
|
---|
45 | TYPE_DRAG_DROP_EVENT,
|
---|
46 | LAST_TYPE
|
---|
47 | };
|
---|
48 |
|
---|
49 | #ifndef I4_RETAIL
|
---|
50 | void show_pending();
|
---|
51 | #endif
|
---|
52 | protected :
|
---|
53 |
|
---|
54 |
|
---|
55 | struct response_type
|
---|
56 | {
|
---|
57 | i4_event_handler_class *who;
|
---|
58 | response_type *next;
|
---|
59 | response_type(i4_event_handler_class *who, response_type *next) : who(who), next(next) {}
|
---|
60 | } *response[LAST_TYPE];
|
---|
61 |
|
---|
62 | i4_device_class *device_list;
|
---|
63 |
|
---|
64 | i4_bool can_send_idle;
|
---|
65 | w32 milliseconds_before_idle_events_sent;
|
---|
66 | void check_for_idle();
|
---|
67 |
|
---|
68 | public :
|
---|
69 |
|
---|
70 | int events_sent; // app uses this. if no events are sent and app is idle, then app sleeps
|
---|
71 |
|
---|
72 | void set_milliseconds_before_idle_events_sent(w32 milli_seconds);
|
---|
73 |
|
---|
74 | virtual i4_bool process_events(); // returns true if an event was dispatched
|
---|
75 |
|
---|
76 | void send_event(i4_event_handler_class *send_to, i4_event *ev);
|
---|
77 |
|
---|
78 | void send(i4_event_reaction_class *r); // r includes event and who to send to
|
---|
79 |
|
---|
80 | // call this if you want to deque any pending events for yourself
|
---|
81 | // this is called automatically by event_handler's desturctor ref_count!=0
|
---|
82 | void deque_events(i4_event_handler_class *for_who);
|
---|
83 |
|
---|
84 | // this used used mainly by the 3ds tool because the process_events()
|
---|
85 | // never gets a chance to be called
|
---|
86 | i4_bool flush_events();
|
---|
87 |
|
---|
88 |
|
---|
89 | // call this when you want the kernel to think the use is not idle even though no user
|
---|
90 | // events are coming in (so it won't send out IDLE events for idle_time)
|
---|
91 | void not_idle();
|
---|
92 |
|
---|
93 | // this will add you to a list to receive events of this type
|
---|
94 | virtual void request_events(i4_event_handler_class *for_who, w32 event_types);
|
---|
95 |
|
---|
96 | // you will no longer receive events you requested previously
|
---|
97 | virtual void unrequest_events(i4_event_handler_class *for_who, w32 event_types);
|
---|
98 |
|
---|
99 | void add_device(i4_device_class *device); // returns 16 bits device id
|
---|
100 | void remove_device(i4_device_class *device);
|
---|
101 | i4_kernel_device_class();
|
---|
102 |
|
---|
103 | void broadcast_event_type(i4_event *ev, w32 event_type);
|
---|
104 | void delete_handler(i4_event_handler_class *handler);
|
---|
105 | } ;
|
---|
106 |
|
---|
107 | extern i4_kernel_device_class i4_kernel;
|
---|
108 |
|
---|
109 | #endif
|
---|