Subversion Repositories Kolibri OS

Rev

Rev 3622 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3622 Rev 4224
1
/*
1
/*
2
 * Copyright 2013 SoUrcerer sourcerer@bk.ru
2
 * Copyright 2013 SoUrcerer sourcerer@bk.ru
3
 *
3
 *
4
 * This file is part of libnsfb, http://www.netsurf-browser.org/
4
 * This file is part of libnsfb, http://www.netsurf-browser.org/
5
 * Licenced under the MIT License,
5
 * Licenced under the MIT License,
6
 *                http://www.opensource.org/licenses/mit-license.php
6
 *                http://www.opensource.org/licenses/mit-license.php
7
 */
7
 */
8
 
8
 
9
#include 
9
#include 
10
#include 
10
#include 
11
 
11
 
12
#include "libnsfb.h"
12
#include "libnsfb.h"
13
#include "libnsfb_event.h"
13
#include "libnsfb_event.h"
14
#include "libnsfb_plot.h"
14
#include "libnsfb_plot.h"
15
#include "libnsfb_plot_util.h"
15
#include "libnsfb_plot_util.h"
16
 
16
 
17
#include "nsfb.h"
17
#include "nsfb.h"
18
#include "surface.h"
18
#include "surface.h"
19
#include "palette.h"
19
#include "palette.h"
20
#include "plot.h"
20
#include "plot.h"
21
#include "cursor.h"
21
#include "cursor.h"
22
 
22
 
23
 
23
 
24
#include 
24
#include 
25
 
25
 
26
 
26
 
27
 
27
 
28
unsigned char * pixels;
28
unsigned char * pixels;
29
 
29
 
30
 inline void f65(unsigned x, unsigned y, unsigned w, unsigned h, char *d)
30
 inline void f65(unsigned x, unsigned y, unsigned w, unsigned h, char *d)
31
{
31
{
32
asm("pusha");
32
asm("pusha");
33
asm ("nop"::"D"(0), "c"(w*65536+h), "d"(x*65536+y), "b"(d));
33
asm ("nop"::"D"(0), "c"(w*65536+h), "d"(x*65536+y), "b"(d));
34
asm ("xor %eax, %eax");
34
asm ("xor %eax, %eax");
35
asm ("movl %eax, %ebp");
35
asm ("movl %eax, %ebp");
36
asm ("pushl $32");
36
asm ("pushl $32");
37
asm ("popl %esi");
37
asm ("popl %esi");
38
asm ("int $0x40"::"a"(65));
38
asm ("int $0x40"::"a"(65));
39
asm("popa");
39
asm("popa");
40
}
40
}
41
 
41
 
-
 
42
 
-
 
43
unsigned kol_mouse_posw()
-
 
44
{
-
 
45
unsigned error;
-
 
46
asm volatile ("int $0x40":"=a"(error):"a"(37), "b"(1));
-
 
47
return error;
-
 
48
}
-
 
49
 
-
 
50
 
-
 
51
unsigned kol_mouse_btn()
-
 
52
{
-
 
53
unsigned error;
-
 
54
asm volatile ("int $0x40":"=a"(error):"a"(37), "b"(2));
-
 
55
return error;
-
 
56
}
-
 
57
 
-
 
58
unsigned kol_scancodes()
-
 
59
{
-
 
60
unsigned error;
-
 
61
asm volatile ("int $0x40":"=a"(error):"a"(66), "b"(1), "c"(1));
-
 
62
return error;
-
 
63
}
-
 
64
 
42
 
65
 
43
void kolibri_redraw(nsfb_t *nsfb){
66
void kolibri_redraw(nsfb_t *nsfb){
44
	
67
	
45
 
68
 
46
 f65(0,0, nsfb->width, nsfb->height, pixels);
69
 f65(0,0, nsfb->width, nsfb->height, pixels);
47
 
70
 
48
}
71
}
-
 
72
 
-
 
73
 
-
 
74
unsigned kol_skin_h()
-
 
75
{
-
 
76
unsigned error;
-
 
77
asm volatile ("int $0x40":"=a"(error):"a"(48), "b"(4));
-
 
78
return error;
-
 
79
}
-
 
80
 
-
 
81
unsigned kol_area(char *data)
-
 
82
{
-
 
83
unsigned error;
-
 
84
asm volatile ("int $0x40":"=a"(error):"a"(9), "b"(data), "c"(0xffffffff));
-
 
85
return error;
-
 
86
}
-
 
87
 
49
 
88
 
50
void kolibri_window_redraw(nsfb_t *nsfb){
89
void kolibri_window_redraw(nsfb_t *nsfb){
51
	
90
	
52
 __menuet__window_redraw(1);
91
 __menuet__window_redraw(1);
53
 __menuet__define_window(100,100,nsfb->width,nsfb->height,0x43000080,0x800000FF,0x000080);
92
 __menuet__define_window(100,100,nsfb->width+9,nsfb->height+kol_skin_h(),0x34000080,0x800000FF,"Netsurf");
54
 __menuet__write_text(3,3,0xFFFFFF,"Netsurf",7);
93
 //__menuet__write_text(3,3,0xFFFFFF,"Netsurf",7);
55
__menuet__debug_out("f65 is mighty!\n");
94
//__menuet__debug_out("f65 is mighty!\n");
56
 
95
 
57
//here put image pixels! it's 32bpp
96
//here put image pixels! it's 32bpp
58
 f65(0,0, nsfb->width, nsfb->height, pixels);
97
 f65(0,0, nsfb->width, nsfb->height, pixels);
59
 __menuet__window_redraw(2);
98
 __menuet__window_redraw(2);
-
 
99
 
-
 
100
 
-
 
101
 
60
}
102
}
61
 
103
 
62
 
104
 
63
 
105
 
64
static bool 
106
static bool 
65
kolibricopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
107
kolibricopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
66
{
108
{
67
   
109
   
68
    char *pixels = nsfb->surface_priv;
110
    char *pixels = nsfb->surface_priv;
69
    nsfb_bbox_t allbox;
111
    nsfb_bbox_t allbox;
70
    struct nsfb_cursor_s *cursor = nsfb->cursor;
112
    struct nsfb_cursor_s *cursor = nsfb->cursor;
71
 
113
 
72
    nsfb_plot_add_rect(srcbox, dstbox, &allbox);
114
    nsfb_plot_add_rect(srcbox, dstbox, &allbox);
73
 
115
 
74
	int x,y,w,h;
116
	int x,y,w,h;
75
    x = srcbox->x0;
117
    x = srcbox->x0;
76
    y = srcbox->y0;
118
    y = srcbox->y0;
77
    w = srcbox->x1 - srcbox->x0;
119
    w = srcbox->x1 - srcbox->x0;
78
    h = srcbox->y1 - srcbox->y0;
120
    h = srcbox->y1 - srcbox->y0;
79
    
121
    
80
    int tx, ty, tw, th;
122
    int tx, ty, tw, th;
81
    
123
    
82
    tx = dstbox->x0;
124
    tx = dstbox->x0;
83
    ty = dstbox->y0;
125
    ty = dstbox->y0;
84
    tw = dstbox->x1 - dstbox->x0;
126
    tw = dstbox->x1 - dstbox->x0;
85
    th = dstbox->y1 - dstbox->y0;
127
    th = dstbox->y1 - dstbox->y0;
86
    
128
    
87
    char pst[255];
129
   // char pst[255];
88
    sprintf (pst, "Src %d,%d %dx%d Dst %d,%d %dx%d \n", x,y,w,h,tx,ty,tw,th);
130
  //  sprintf (pst, "Src %d,%d %dx%d Dst %d,%d %dx%d \n", x,y,w,h,tx,ty,tw,th);
89
    __menuet__debug_out(pst);
131
   // __menuet__debug_out(pst);
90
    
132
    
91
    int px, py, pp;
133
    int px, py, pp;
92
    
134
    
93
 
135
 
94
    
136
    
95
    for (px=x; px
137
    for (px=x; px
96
		for (py=y;py
138
		for (py=y;py
97
			for (pp=0; pp<4; pp++) {
139
			for (pp=0; pp<4; pp++) {
98
				
140
				
99
				pixels[4*(px+tx)*nsfb->width+4*(py+ty)+pp]=pixels[4*px*nsfb->width+4*py+pp];
141
				pixels[4*(px+tx)*nsfb->width+4*(py+ty)+pp]=pixels[4*px*nsfb->width+4*py+pp];
100
				
142
				
101
				
143
				
102
			}
144
			}
103
    
145
    
104
    
146
    
105
    
147
    
106
    
148
    
107
	kolibri_redraw(nsfb);
149
	kolibri_redraw(nsfb);
108
 
150
 
109
    return true;
151
    return true;
110
 
152
 
111
}
153
}
112
 
154
 
113
static int kolibri_set_geometry(nsfb_t *nsfb, int width, int height,
155
static int kolibri_set_geometry(nsfb_t *nsfb, int width, int height,
114
        enum nsfb_format_e format)
156
        enum nsfb_format_e format)
115
{
157
{
116
    if (nsfb->surface_priv != NULL)
158
    if (nsfb->surface_priv != NULL)
117
        return -1; /* fail if surface already initialised */
159
        return -1; /* fail if surface already initialised */
118
 
160
 
119
    nsfb->width = width;
161
    nsfb->width = width;
120
    nsfb->height = height;
162
    nsfb->height = height;
121
    nsfb->format = format;
163
    nsfb->format = format;
122
	
164
	
123
	pixels=(char *)malloc(width*height*4);
165
	pixels=(char *)malloc(width*height*4);
124
	
166
	
125
    /* select default sw plotters for format */
167
    /* select default sw plotters for format */
126
    select_plotters(nsfb);
168
    select_plotters(nsfb);
127
 
169
 
128
    //nsfb->plotter_fns->copy = kolibricopy;
170
    //nsfb->plotter_fns->copy = kolibricopy;
129
 
171
 
130
    return 0;
172
    return 0;
131
}
173
}
132
unsigned pz, pb;
174
unsigned pz, pb;
133
 
175
 
134
static int kolibri_initialise(nsfb_t *nsfb)
176
static int kolibri_initialise(nsfb_t *nsfb)
135
{
177
{
136
    enum nsfb_format_e fmt;
178
    enum nsfb_format_e fmt;
-
 
179
 
-
 
180
	kol_scancodes(); 
137
 
181
 
138
pz=0;
182
pz=0;
139
pb=0;
183
pb=0;
140
 
184
 
141
__menuet__debug_out("Start UI\n");
185
__menuet__debug_out("Start UI\n");
142
 
186
 
143
    if (nsfb->surface_priv != NULL)
187
    if (nsfb->surface_priv != NULL)
144
        return -1;
188
        return -1;
145
 
189
 
146
    /* sanity checked depth. */
190
    /* sanity checked depth. */
147
    if ((nsfb->bpp != 32) ) {
191
    if ((nsfb->bpp != 32) ) {
148
		
192
		
149
		__menuet__debug_out("Wrong bpp\n");
193
		__menuet__debug_out("Wrong bpp\n");
150
        return -1; }
194
        return -1; }
151
 
195
 
152
	
196
	
153
	        fmt = NSFB_FMT_XRGB8888;
197
	        fmt = NSFB_FMT_XRGB8888;
154
    
198
    
155
    /* If we didn't get what we asked for, reselect plotters */
199
    /* If we didn't get what we asked for, reselect plotters */
156
    if (nsfb->format != fmt) {
200
    if (nsfb->format != fmt) {
157
        nsfb->format = fmt;
201
        nsfb->format = fmt;
158
 
202
 
159
        if (kolibri_set_geometry(nsfb, nsfb->width, nsfb->height,
203
        if (kolibri_set_geometry(nsfb, nsfb->width, nsfb->height,
160
                nsfb->format) != 0) {
204
                nsfb->format) != 0) {
161
					
205
					
162
					__menuet__debug_out("can't set geometry\n");
206
					__menuet__debug_out("can't set geometry\n");
163
            return -1;
207
            return -1;
164
        }
208
        }
165
    }
209
    }
166
 
210
 
167
    nsfb->surface_priv = pixels;
211
    nsfb->surface_priv = pixels;
168
 
212
 
169
    nsfb->ptr = pixels;
213
    nsfb->ptr = pixels;
170
    nsfb->linelen = (nsfb->width * nsfb->bpp) / 8;
214
    nsfb->linelen = (nsfb->width * nsfb->bpp) / 8;
171
    
215
    
172
    __menuet__debug_out("Redraw\n");
216
    __menuet__debug_out("Redraw\n");
173
    kolibri_redraw(nsfb);
217
    kolibri_redraw(nsfb);
174
    
218
    
175
    __menuet__set_bitfield_for_wanted_events(EVENT_REDRAW|EVENT_KEY|EVENT_BUTTON|EVENT_MOUSE_CHANGE);
219
    __menuet__set_bitfield_for_wanted_events(EVENT_REDRAW|EVENT_KEY|EVENT_BUTTON|EVENT_MOUSE_CHANGE);
176
 
220
 
177
    return 0;
221
    return 0;
178
}
222
}
179
 
223
 
180
 
224
 
181
 
225
 
182
static int kolibri_finalise(nsfb_t *nsfb)
226
static int kolibri_finalise(nsfb_t *nsfb)
183
{
227
{
184
    nsfb=nsfb;
228
    nsfb=nsfb;
185
    __menuet__sys_exit();
229
    __menuet__sys_exit();
186
    return 0;
230
    return 0;
187
}
231
}
188
 
232
 
189
 
-
 
190
unsigned kol_mouse_posw()
233
 
191
{
234
 
192
unsigned error;
-
 
193
asm volatile ("int $0x40":"=a"(error):"a"(37), "b"(1));
235
int isup(int scan){
194
return error;
236
	return (scan&0x80)>>7;
-
 
237
}
-
 
238
 
-
 
239
int scan2key(int scan){
-
 
240
	int keycode=(scan&0x0FF7F);
-
 
241
	/* MAIN KB - NUMS */
-
 
242
	if (keycode == 0x02) return NSFB_KEY_1;
-
 
243
	if (keycode == 0x03) return NSFB_KEY_2;
-
 
244
	if (keycode == 0x04) return NSFB_KEY_3;
-
 
245
	if (keycode == 0x05) return NSFB_KEY_4;
-
 
246
	if (keycode == 0x06) return NSFB_KEY_5;
-
 
247
	if (keycode == 0x07) return NSFB_KEY_6;
-
 
248
	if (keycode == 0x08) return NSFB_KEY_7;
-
 
249
	if (keycode == 0x09) return NSFB_KEY_8;
-
 
250
	if (keycode == 0x0A) return NSFB_KEY_9;
-
 
251
	if (keycode == 0x0B) return NSFB_KEY_0;
-
 
252
	
-
 
253
	if (keycode == 0x10) return NSFB_KEY_q;
-
 
254
	if (keycode == 0x11) return NSFB_KEY_w;
-
 
255
	if (keycode == 0x12) return NSFB_KEY_e;
-
 
256
	if (keycode == 0x13) return NSFB_KEY_r;
-
 
257
	if (keycode == 0x14) return NSFB_KEY_t;
-
 
258
	if (keycode == 0x15) return NSFB_KEY_y;
-
 
259
	if (keycode == 0x16) return NSFB_KEY_u;
-
 
260
	if (keycode == 0x17) return NSFB_KEY_i;
-
 
261
	if (keycode == 0x18) return NSFB_KEY_o;
-
 
262
	if (keycode == 0x19) return NSFB_KEY_p;
-
 
263
	if (keycode == 0x1A) return NSFB_KEY_LEFTBRACKET;
-
 
264
	if (keycode == 0x1B) return NSFB_KEY_RIGHTBRACKET;
-
 
265
	
-
 
266
	if (keycode == 0x1E) return NSFB_KEY_a;
-
 
267
	if (keycode == 0x1F) return NSFB_KEY_s;
-
 
268
	if (keycode == 0x20) return NSFB_KEY_d;
-
 
269
	if (keycode == 0x21) return NSFB_KEY_f;
-
 
270
	if (keycode == 0x22) return NSFB_KEY_g;
-
 
271
	if (keycode == 0x23) return NSFB_KEY_h;
-
 
272
	if (keycode == 0x24) return NSFB_KEY_j;
-
 
273
	if (keycode == 0x25) return NSFB_KEY_k;
-
 
274
	if (keycode == 0x26) return NSFB_KEY_l;
-
 
275
	
-
 
276
	if (keycode == 0x2C) return NSFB_KEY_z;
-
 
277
	if (keycode == 0x2D) return NSFB_KEY_x;
-
 
278
	if (keycode == 0x2E) return NSFB_KEY_c;
-
 
279
	if (keycode == 0x2F) return NSFB_KEY_v;
-
 
280
	if (keycode == 0x30) return NSFB_KEY_b;
-
 
281
	if (keycode == 0x31) return NSFB_KEY_n;
-
 
282
	if (keycode == 0x32) return NSFB_KEY_m;
-
 
283
	
-
 
284
	if (keycode == 0x27) return NSFB_KEY_SEMICOLON;
-
 
285
	if (keycode == 0x28) return NSFB_KEY_QUOTEDBL;
-
 
286
	if (keycode == 0x2B) return NSFB_KEY_BACKSLASH;
-
 
287
	if (keycode == 0x33) return NSFB_KEY_COMMA;
-
 
288
	if (keycode == 0x34) return NSFB_KEY_PERIOD;
-
 
289
	if (keycode == 0x35) return NSFB_KEY_SLASH;
-
 
290
	if (keycode == 0x0C) return NSFB_KEY_MINUS;
-
 
291
	if (keycode == 0x0D) return NSFB_KEY_EQUALS;
-
 
292
	
-
 
293
	if (keycode == 0x0E) return NSFB_KEY_BACKSPACE;
-
 
294
	if (keycode == 0xE053) return NSFB_KEY_DELETE;
-
 
295
	if (keycode == 0x2A) return NSFB_KEY_LSHIFT;
-
 
296
	if (keycode == 0x36) return NSFB_KEY_RSHIFT;
-
 
297
	
-
 
298
	if (keycode == 0x1C) return NSFB_KEY_RETURN;
-
 
299
	
-
 
300
	if (keycode == 0xE04B) return NSFB_KEY_LEFT;
-
 
301
	if (keycode == 0xE04D) return NSFB_KEY_RIGHT;
-
 
302
	if (keycode == 0xE048) return NSFB_KEY_UP;
-
 
303
	if (keycode == 0xE050) return NSFB_KEY_DOWN;
-
 
304
	
-
 
305
	if (keycode == 0x3F) return NSFB_KEY_F5;
-
 
306
	
-
 
307
	if (keycode == 0x39) return NSFB_KEY_SPACE;
-
 
308
	if (keycode == 0x01) return NSFB_KEY_ESCAPE;
-
 
309
	
-
 
310
	if (keycode == 0x38) return NSFB_KEY_LALT;
-
 
311
	if (keycode == 0x1D) return NSFB_KEY_LCTRL;
-
 
312
	if (keycode == 0xE038) return NSFB_KEY_RALT;
-
 
313
	if (keycode == 0xE01D) return NSFB_KEY_RCTRL;
-
 
314
	
-
 
315
	
-
 
316
	if (keycode == 0xE047) return NSFB_KEY_HOME;
-
 
317
	if (keycode == 0xE04F) return NSFB_KEY_END;
-
 
318
	if (keycode == 0xE049) return NSFB_KEY_PAGEUP;
-
 
319
	if (keycode == 0xE051) return NSFB_KEY_PAGEDOWN;
195
}
-
 
196
 
-
 
197
 
-
 
198
unsigned kol_mouse_btn()
-
 
199
{
-
 
200
unsigned error;
320
	
-
 
321
	return NSFB_KEY_UNKNOWN;
-
 
322
	
-
 
323
}
201
asm volatile ("int $0x40":"=a"(error):"a"(37), "b"(2));
324
 
202
return error;
325
int ispowerkey(int scan){
203
}
326
	return (scan&0xE000)>>15;
204
 
327
}
205
 
328
 
206
 
329
 
207
static bool kolibri_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
330
static bool kolibri_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
208
{
331
{
209
    int got_event;
332
    int got_event;
210
    
-
 
-
 
333
    static int scanfull=0;
211
 
334
 
212
    nsfb = nsfb; /* unused */
335
    nsfb = nsfb; /* unused */
-
 
336
 
213
 
337
	
214
       got_event = __menuet__check_for_event();
338
       got_event = __menuet__check_for_event();
215
 
339
 
216
    if (got_event == 0) {
340
    if (got_event == 0) {
217
        return false;
341
        return false;
218
    }
342
    }
219
 
343
 
220
    event->type = NSFB_EVENT_NONE;
344
    event->type = NSFB_EVENT_NONE;
221
 
345
 
222
	 if (got_event==1) { //key pressed
346
	 if (got_event==1) { //key pressed
223
    kolibri_window_redraw(nsfb);
347
    kolibri_window_redraw(nsfb);
224
	
348
	
225
	}
349
	}
226
 
350
 
227
    if (got_event==2) { //key pressed
351
    if (got_event==2) { //key pressed
-
 
352
    int scanz = __menuet__getkey();
-
 
353
    
-
 
354
    //char dbs[64];
-
 
355
    
-
 
356
    //__menuet__debug_out("KEY PRESSED\n");
-
 
357
    
-
 
358
   // sprintf (dbs, "FULLKEY BEFORE: F:%x\n", scanfull);
-
 
359
	//__menuet__debug_out(dbs);
-
 
360
	
-
 
361
	if (scanz==0xE0) {
-
 
362
		scanfull=0xE000;
-
 
363
		return true;
-
 
364
	} else {
-
 
365
		scanfull=scanfull+scanz;
-
 
366
	}
-
 
367
	
-
 
368
    //sprintf (dbs, "FULLKEY AFTER: F:%x\n", scanfull);
-
 
369
	//__menuet__debug_out(dbs);
-
 
370
    
-
 
371
    
-
 
372
	if (isup(scanfull)==1) {
-
 
373
	event->type = NSFB_EVENT_KEY_UP;} else {
228
    event->type = NSFB_EVENT_KEY_UP;
374
	event->type = NSFB_EVENT_KEY_DOWN;}
-
 
375
		
229
	event->value.keycode = __menuet__getkey();
376
	event->value.keycode = scan2key(scanfull);
-
 
377
	
-
 
378
	//sprintf (dbs, "KEY: %x F:%x %d %d\n", scanz, scanfull, isup(scanz), scan2key(scanz));
-
 
379
	//__menuet__debug_out(dbs);
-
 
380
	
-
 
381
	scanfull=0;
-
 
382
	
230
	return true;
383
	return true;
-
 
384
 
231
	}
385
	}
232
	
386
	
233
	if (got_event==3) { //key pressed
387
	if (got_event==3) { //key pressed
234
    if (__menuet__get_button_id()==1) kolibri_finalise(nsfb);
388
    if (__menuet__get_button_id()==1) kolibri_finalise(nsfb);
235
	return true;
389
	return true;
236
	}
390
	}
237
	
391
	
238
	if (got_event==6) { //key pressed
392
	if (got_event==6) { //key pressed
239
	unsigned z=kol_mouse_posw();
393
	unsigned z=kol_mouse_posw();
240
	unsigned b=kol_mouse_btn();
394
	unsigned b=kol_mouse_btn();
241
		
395
		
242
		
396
		
243
		if (pz!=z) {
397
		if (pz!=z) {
244
			event->type = NSFB_EVENT_MOVE_ABSOLUTE;
398
			event->type = NSFB_EVENT_MOVE_ABSOLUTE;
245
			event->value.vector.x = (z&0xffff0000)>>16; //sdlevent.motion.x;
399
			event->value.vector.x = (z&0xffff0000)>>16; //sdlevent.motion.x;
246
			event->value.vector.y = z&0xffff; //sdlevent.motion.y;
400
			event->value.vector.y = z&0xffff; //sdlevent.motion.y;
247
			event->value.vector.z = 0;
401
			event->value.vector.z = 0;
248
			pz=z;
402
			pz=z;
249
			return true;
403
			return true;
250
		}
404
		}
251
		
405
		
252
		
406
		
253
		if (pb!=b) {
407
		if (pb!=b) {
254
			unsigned t=b&1;
408
			unsigned t=b&1;
255
			if (t==0) {
409
			if (t==0) {
256
				event->type = NSFB_EVENT_KEY_UP;
410
				event->type = NSFB_EVENT_KEY_UP;
257
			    event->value.keycode = NSFB_KEY_MOUSE_1;
411
			    event->value.keycode = NSFB_KEY_MOUSE_1;
258
			} else {
412
			} else {
259
				event->type = NSFB_EVENT_KEY_DOWN;
413
				event->type = NSFB_EVENT_KEY_DOWN;
260
			    event->value.keycode = NSFB_KEY_MOUSE_1;
414
			    event->value.keycode = NSFB_KEY_MOUSE_1;
261
			}
415
			}
262
			pb=b;		
416
			pb=b;		
263
			return true;
417
			return true;
264
		}
418
		}
265
		
419
		
266
	}
420
	}
267
 
421
 
268
    /*
422
    /*
269
 
423
 
270
    case SDL_MOUSEBUTTONDOWN:
424
    case SDL_MOUSEBUTTONDOWN:
271
	event->type = NSFB_EVENT_KEY_DOWN;
425
	event->type = NSFB_EVENT_KEY_DOWN;
272
 
426
 
273
	switch (sdlevent.button.button) {
427
	switch (sdlevent.button.button) {
274
 
428
 
275
	case SDL_BUTTON_LEFT:
429
	case SDL_BUTTON_LEFT:
276
	    event->value.keycode = NSFB_KEY_MOUSE_1;
430
	    event->value.keycode = NSFB_KEY_MOUSE_1;
277
	    break;
431
	    break;
278
 
432
 
279
	case SDL_BUTTON_MIDDLE:
433
	case SDL_BUTTON_MIDDLE:
280
	    event->value.keycode = NSFB_KEY_MOUSE_2;
434
	    event->value.keycode = NSFB_KEY_MOUSE_2;
281
	    break;
435
	    break;
282
 
436
 
283
	case SDL_BUTTON_RIGHT:
437
	case SDL_BUTTON_RIGHT:
284
	    event->value.keycode = NSFB_KEY_MOUSE_3;
438
	    event->value.keycode = NSFB_KEY_MOUSE_3;
285
	    break;
439
	    break;
286
 
440
 
287
	}
441
	}
288
	break;
442
	break;
289
 
443
 
290
    case SDL_MOUSEBUTTONUP:
444
    case SDL_MOUSEBUTTONUP:
291
	event->type = NSFB_EVENT_KEY_UP;
445
	event->type = NSFB_EVENT_KEY_UP;
292
 
446
 
293
	switch (sdlevent.button.button) {
447
	switch (sdlevent.button.button) {
294
 
448
 
295
	case SDL_BUTTON_LEFT:
449
	case SDL_BUTTON_LEFT:
296
	    event->value.keycode = NSFB_KEY_MOUSE_1;
450
	    event->value.keycode = NSFB_KEY_MOUSE_1;
297
	    break;
451
	    break;
298
 
452
 
299
	case SDL_BUTTON_MIDDLE:
453
	case SDL_BUTTON_MIDDLE:
300
	    event->value.keycode = NSFB_KEY_MOUSE_2;
454
	    event->value.keycode = NSFB_KEY_MOUSE_2;
301
	    break;
455
	    break;
302
 
456
 
303
	case SDL_BUTTON_RIGHT:
457
	case SDL_BUTTON_RIGHT:
304
	    event->value.keycode = NSFB_KEY_MOUSE_3;
458
	    event->value.keycode = NSFB_KEY_MOUSE_3;
305
	    break;
459
	    break;
306
 
460
 
307
	}
461
	}
308
	break;
462
	break;
309
 
463
 
310
    case SDL_MOUSEMOTION:
464
    case SDL_MOUSEMOTION:
311
	event->type = NSFB_EVENT_MOVE_ABSOLUTE;
465
	event->type = NSFB_EVENT_MOVE_ABSOLUTE;
312
	event->value.vector.x = sdlevent.motion.x;
466
	event->value.vector.x = sdlevent.motion.x;
313
	event->value.vector.y = sdlevent.motion.y;
467
	event->value.vector.y = sdlevent.motion.y;
314
	event->value.vector.z = 0;
468
	event->value.vector.z = 0;
315
	break;
469
	break;
316
 
470
 
317
    case SDL_QUIT:
471
    case SDL_QUIT:
318
	event->type = NSFB_EVENT_CONTROL;
472
	event->type = NSFB_EVENT_CONTROL;
319
	event->value.controlcode = NSFB_CONTROL_QUIT;
473
	event->value.controlcode = NSFB_CONTROL_QUIT;
320
	break;
474
	break;
321
 
475
 
322
    case SDL_USEREVENT:
476
    case SDL_USEREVENT:
323
	event->type = NSFB_EVENT_CONTROL;
477
	event->type = NSFB_EVENT_CONTROL;
324
	event->value.controlcode = NSFB_CONTROL_TIMEOUT;
478
	event->value.controlcode = NSFB_CONTROL_TIMEOUT;
325
	break;
479
	break;
326
 
480
 
327
    }
481
    }
328
	*/
482
	*/
329
    return true;
483
    return true;
330
}
484
}
331
 
485
 
332
 
486
 
333
static int kolibri_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
487
static int kolibri_claim(nsfb_t *nsfb, nsfb_bbox_t *box)
334
{
488
{
335
	/*
489
	/*
336
    if ((cursor != NULL) &&
490
    if ((cursor != NULL) &&
337
        (cursor->plotted == true) &&
491
        (cursor->plotted == true) &&
338
        (nsfb_plot_bbox_intersect(box, &cursor->loc))) {
492
        (nsfb_plot_bbox_intersect(box, &cursor->loc))) {
339
        nsfb_cursor_clear(nsfb, cursor);
493
        nsfb_cursor_clear(nsfb, cursor);
340
    } */
494
    } */
341
	return 0; //stub yet
495
	return 0; //stub yet
342
}
496
}
343
 
497
 
344
static int kolibri_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
498
static int kolibri_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
345
{
499
{
346
	return true; //stub yet
500
	return true; //stub yet
347
}
501
}
348
 
502
 
349
 
503
 
350
 
504
 
351
static int kolibri_update(nsfb_t *nsfb, nsfb_bbox_t *box)
505
static int kolibri_update(nsfb_t *nsfb, nsfb_bbox_t *box)
352
{
506
{
353
    /*SDL_Surface *sdl_screen = nsfb->surface_priv;
507
    /*SDL_Surface *sdl_screen = nsfb->surface_priv;
354
    struct nsfb_cursor_s *cursor = nsfb->cursor;
508
    struct nsfb_cursor_s *cursor = nsfb->cursor;
355
 
509
 
356
    if ((cursor != NULL) &&
510
    if ((cursor != NULL) &&
357
	(cursor->plotted == false)) {
511
	(cursor->plotted == false)) {
358
        nsfb_cursor_plot(nsfb, cursor);
512
        nsfb_cursor_plot(nsfb, cursor);
359
    }
513
    }
360
 
514
 
361
    SDL_UpdateRect(sdl_screen,
515
    SDL_UpdateRect(sdl_screen,
362
                   box->x0,
516
                   box->x0,
363
                   box->y0,
517
                   box->y0,
364
                   box->x1 - box->x0,
518
                   box->x1 - box->x0,
365
                   box->y1 - box->y0);
519
                   box->y1 - box->y0);
366
  */
520
  */
367
  
521
  
368
  //Ask for window redraw here!
522
  //Ask for window redraw here!
369
  
523
  
370
	kolibri_redraw(nsfb);
524
	kolibri_redraw(nsfb);
371
    return 0;
525
    return 0;
372
}
526
}
373
 
527
 
374
const nsfb_surface_rtns_t kolibri_rtns = {
528
const nsfb_surface_rtns_t kolibri_rtns = {
375
    .initialise = kolibri_initialise,
529
    .initialise = kolibri_initialise,
376
    .finalise = kolibri_finalise,
530
    .finalise = kolibri_finalise,
377
    .input = kolibri_input,
531
    .input = kolibri_input,
378
    .claim = kolibri_claim,
532
    .claim = kolibri_claim,
379
    .update = kolibri_update,
533
    .update = kolibri_update,
380
    .cursor = kolibri_cursor,
534
    .cursor = kolibri_cursor,
381
    .geometry = kolibri_set_geometry,
535
    .geometry = kolibri_set_geometry,
382
};
536
};
383
 
537
 
384
NSFB_SURFACE_DEF(kolibri, NSFB_SURFACE_KOLIBRI, &kolibri_rtns)
538
NSFB_SURFACE_DEF(kolibri, NSFB_SURFACE_KOLIBRI, &kolibri_rtns)
385
 
539
 
386
/*
540
/*
387
 * Local variables:
541
 * Local variables:
388
 *  c-basic-offset: 4
542
 *  c-basic-offset: 4
389
 *  tab-width: 8
543
 *  tab-width: 8
390
 * End:
544
 * End:
391
 */
545
 */
392
>
546
>