summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/sim_icons.c2
-rw-r--r--uisimulator/win32/button.c233
-rw-r--r--uisimulator/win32/kernel.c19
-rw-r--r--uisimulator/win32/lcd-win32.c71
-rw-r--r--uisimulator/win32/rockbox.dsp24
-rw-r--r--uisimulator/win32/uisw32.c16
-rw-r--r--uisimulator/win32/uisw32.h2
7 files changed, 274 insertions, 93 deletions
diff --git a/uisimulator/common/sim_icons.c b/uisimulator/common/sim_icons.c
index 76a3f4499b..e647455402 100644
--- a/uisimulator/common/sim_icons.c
+++ b/uisimulator/common/sim_icons.c
@@ -420,7 +420,7 @@ struct icon_info
420 int row; 420 int row;
421}; 421};
422 422
423#define ICON_VOLUME_POS 230 423#define ICON_VOLUME_POS 224
424#define ICON_VOLUME_SIZE 20 424#define ICON_VOLUME_SIZE 20
425#define ICON_VOLUME_X_SIZE 2 425#define ICON_VOLUME_X_SIZE 2
426 426
diff --git a/uisimulator/win32/button.c b/uisimulator/win32/button.c
index 7176cbc20c..807e08fe22 100644
--- a/uisimulator/win32/button.c
+++ b/uisimulator/win32/button.c
@@ -20,119 +20,180 @@
20#include <windows.h> 20#include <windows.h>
21#include "uisw32.h" 21#include "uisw32.h"
22#include "config.h" 22#include "config.h"
23#include "sh7034.h"
24#include "button.h" 23#include "button.h"
25#include "kernel.h" 24#include "kernel.h"
25#include "backlight.h"
26 26
27#define KEY(k) (HIBYTE(GetKeyState (k)) & 1) 27/* how long until repeat kicks in */
28#define REPEAT_START 6
28 29
29int last_key ; 30/* the speed repeat starts at */
30static int release_mask; 31#define REPEAT_INTERVAL_START 4
31static int repeat_mask;
32 32
33/* speed repeat finishes at */
34#define REPEAT_INTERVAL_FINISH 2
33 35
34void button_init(void) 36long last_keypress;
35{ 37struct event_queue button_queue;
36 last_key = 0 ;
37}
38 38
39int button_set_repeat(int newmask) 39void button_event(int key, bool pressed)
40{ 40{
41 int oldmask = repeat_mask; 41 bool post = false;
42 repeat_mask = newmask; 42 int new_btn = 0;
43 return oldmask; 43 int diff = 0;
44} 44 static int count = 0;
45 static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
46 static int lastbtn;
47 static int repeat_speed = REPEAT_INTERVAL_START;
48 static int repeat_count = 0;
49 static bool repeat = false;
50
51 switch (key)
52 {
53 case VK_NUMPAD4:
54 case VK_LEFT:
55 new_btn = BUTTON_LEFT;
56 break;
57 case VK_NUMPAD6:
58 case VK_RIGHT:
59 new_btn = BUTTON_RIGHT;
60 break;
61 case VK_NUMPAD8:
62 case VK_UP:
63 new_btn = BUTTON_UP;
64 break;
65 case VK_NUMPAD2:
66 case VK_DOWN:
67 new_btn = BUTTON_DOWN;
68 break;
69 case VK_ADD:
70 new_btn = BUTTON_ON;
71 break;
45 72
46int button_set_release(int newmask) 73#ifdef HAVE_RECORDER_KEYPAD
47{ 74 case VK_RETURN:
48 int oldmask = release_mask; 75 new_btn = BUTTON_OFF;
49 release_mask = newmask; 76 break;
50 return oldmask; 77 case VK_DIVIDE:
51} 78 case VK_F1:
79 new_btn = BUTTON_F1;
80 break;
81 case VK_MULTIPLY:
82 case VK_F2:
83 new_btn = BUTTON_F2;
84 break;
85 case VK_SUBTRACT:
86 case VK_F3:
87 new_btn = BUTTON_F3;
88 break;
89 case VK_NUMPAD5:
90 case VK_SPACE:
91 new_btn = BUTTON_PLAY;
92 break;
93#else
94 case VK_RETURN:
95 new_btn = BUTTON_MENU;
96 break;
97#endif
98 }
52 99
53static int real_button_get(void) 100 if (pressed)
54{ 101 btn |= new_btn;
55 int btn = 0; 102 else
56 Sleep (25); 103 btn &= !new_btn;
104
105 /* Lots of stuff copied from real button.c. Not good, I think... */
57 106
58 if (bActive) 107 /* Find out if a key has been released */
108 diff = btn ^ lastbtn;
109
110 if(diff && (btn & diff) == 0)
59 { 111 {
60 if (KEY (VK_NUMPAD4) || 112 queue_post(&button_queue, BUTTON_REL | diff, NULL);
61 KEY (VK_LEFT)) // left button 113 }
62 btn |= BUTTON_LEFT;
63 114
64 if (KEY (VK_NUMPAD6) || 115 if ( btn )
65 KEY (VK_RIGHT)) 116 {
66 btn |= BUTTON_RIGHT; // right button 117 /* normal keypress */
118 if ( btn != lastbtn )
119 {
120 post = true;
121 repeat = false;
122 repeat_speed = REPEAT_INTERVAL_START;
67 123
68 if (KEY (VK_NUMPAD8) || 124 }
69 KEY (VK_UP)) 125 else /* repeat? */
70 btn |= BUTTON_UP; // up button 126 {
127 if ( repeat )
128 {
129 count--;
130 if (count == 0)
131 {
132 post = true;
133 /* yes we have repeat */
134 repeat_speed--;
135 if (repeat_speed < REPEAT_INTERVAL_FINISH)
136 repeat_speed = REPEAT_INTERVAL_FINISH;
137 count = repeat_speed;
138
139 repeat_count++;
140 }
141 }
142 else
143 {
144 if (count++ > REPEAT_START)
145 {
146 post = true;
147 repeat = true;
148 repeat_count = 0;
149 /* initial repeat */
150 count = REPEAT_INTERVAL_START;
151 }
152 }
153 }
71 154
72 if (KEY (VK_NUMPAD2) || 155 if ( post )
73 KEY (VK_DOWN)) 156 {
74 btn |= BUTTON_DOWN; // down button 157 if(repeat)
158 queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
159 else
160 queue_post(&button_queue, btn, NULL);
75 161
76 if (KEY (VK_ADD)) 162 backlight_on();
77 btn |= BUTTON_ON; // on button
78
79#ifdef HAVE_RECORDER_KEYPAD
80 if (KEY (VK_RETURN))
81 btn |= BUTTON_OFF; // off button
82
83 if (KEY (VK_DIVIDE) || KEY(VK_F1))
84 btn |= BUTTON_F1; // F1 button
85
86 if (KEY (VK_MULTIPLY) || KEY(VK_F2))
87 btn |= BUTTON_F2; // F2 button
88
89 if (KEY (VK_SUBTRACT) || KEY(VK_F3))
90 btn |= BUTTON_F3; // F3 button
91
92 if (KEY (VK_NUMPAD5) ||
93 KEY (VK_SPACE))
94 btn |= BUTTON_PLAY; // play button
95#else
96 if (KEY (VK_RETURN))
97 btn |= BUTTON_MENU; // menu button
98#endif
99 163
100 if (btn != 0) { 164 last_keypress = current_tick;
101 last_key = 0 ; 165 }
102 } 166 }
167 else
168 {
169 repeat = false;
170 count = 0;
103 } 171 }
104 172
105 return btn; 173 lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
106} 174}
107 175
108int button_get(bool block) 176void button_init(void)
109{ 177{
110 int btn; 178 last_keypress = 0;
111 do { 179}
112 180
113 btn = real_button_get(); 181/* Again copied from real button.c... */
114 182
115 if (btn) 183int button_get(bool block)
116 break; 184{
117 185 struct event ev;
118 } while (block);
119 186
120 return btn; 187 if ( block || !queue_empty(&button_queue) ) {
188 queue_wait(&button_queue, &ev);
189 return ev.id;
190 }
191 return BUTTON_NONE;
121} 192}
122 193
123int button_get_w_tmo(int ticks) 194int button_get_w_tmo(int ticks)
124{ 195{
125 int btn; 196 struct event ev;
126 do { 197 queue_wait_w_tmo(&button_queue, &ev, ticks);
127 btn = real_button_get(); 198 return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
128 199}
129 if(!btn)
130 /* prevent busy-looping */
131 sleep(10); /* one tick! */
132 else
133 return btn;
134
135 } while (--ticks);
136
137 return btn;
138}
diff --git a/uisimulator/win32/kernel.c b/uisimulator/win32/kernel.c
index 150b8e42cc..567ed9ee39 100644
--- a/uisimulator/win32/kernel.c
+++ b/uisimulator/win32/kernel.c
@@ -56,6 +56,25 @@ void queue_wait(struct event_queue *q, struct event *ev)
56 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; 56 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
57} 57}
58 58
59void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
60{
61 unsigned int timeout = current_tick + ticks;
62
63 while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
64 {
65 sleep(1);
66 }
67
68 if(q->read != q->write)
69 {
70 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
71 }
72 else
73 {
74 ev->id = SYS_TIMEOUT;
75 }
76}
77
59void queue_post(struct event_queue *q, int id, void *data) 78void queue_post(struct event_queue *q, int id, void *data)
60{ 79{
61 int wr; 80 int wr;
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
index 2b582c0e28..dcdb16f1f1 100644
--- a/uisimulator/win32/lcd-win32.c
+++ b/uisimulator/win32/lcd-win32.c
@@ -21,6 +21,7 @@
21#include <process.h> 21#include <process.h>
22#include "uisw32.h" 22#include "uisw32.h"
23#include "lcd.h" 23#include "lcd.h"
24#include "lcd-playersim.h"
24 25
25unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; /* the display */ 26unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; /* the display */
26char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ 27char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
@@ -32,12 +33,20 @@ BITMAPINFO2 bmi =
32 BI_RGB, 0, 0, 0, 2, 2, 33 BI_RGB, 0, 0, 0, 2, 2,
33 }, 34 },
34 { 35 {
35 {UI_LCD_BGCOLOR, 0}, /* green background color */ 36 //{UI_LCD_BGCOLOR, 0}, /* green background color */
37 {UI_LCD_BGCOLORLIGHT, 0}, /* green background color */
36 {UI_LCD_BLACK, 0} /* black color */ 38 {UI_LCD_BLACK, 0} /* black color */
37 } 39 }
38 40
39}; /* bitmap information */ 41}; /* bitmap information */
40 42
43#ifdef HAVE_LCD_CHARCELLS
44/* Defined in lcd-playersim.c */
45extern void lcd_print_char(int x, int y);
46extern bool lcd_display_redraw;
47extern unsigned char hardware_buffer_lcd[11][2];
48static unsigned char lcd_buffer_copy[11][2];
49#endif
41 50
42void lcd_set_invert_display(bool invert) 51void lcd_set_invert_display(bool invert)
43{ 52{
@@ -52,6 +61,23 @@ void lcd_update()
52 if (hGUIWnd == NULL) 61 if (hGUIWnd == NULL)
53 _endthread (); 62 _endthread ();
54 63
64#ifdef HAVE_LCD_CHARCELLS
65 for (y = 0; y < 2; y++)
66 {
67 for (x = 0; x < 11; x++)
68 {
69 if (lcd_display_redraw ||
70 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
71 {
72 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
73 lcd_print_char(x, y);
74 }
75 }
76 }
77
78 lcd_display_redraw = false;
79#endif
80
55 for (x = 0; x < LCD_WIDTH; x++) 81 for (x = 0; x < LCD_WIDTH; x++)
56 for (y = 0; y < LCD_HEIGHT; y++) 82 for (y = 0; y < LCD_HEIGHT; y++)
57 bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); 83 bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1);
@@ -59,7 +85,7 @@ void lcd_update()
59 InvalidateRect (hGUIWnd, NULL, FALSE); 85 InvalidateRect (hGUIWnd, NULL, FALSE);
60 86
61 /* natural sleep :) Bagder: why is this here? */ 87 /* natural sleep :) Bagder: why is this here? */
62 Sleep (50); 88 //Sleep (50);
63} 89}
64 90
65void lcd_update_rect(int x_start, int y_start, 91void lcd_update_rect(int x_start, int y_start,
@@ -106,3 +132,44 @@ void lcd_backlight (bool on)
106 132
107 InvalidateRect (hGUIWnd, NULL, FALSE); 133 InvalidateRect (hGUIWnd, NULL, FALSE);
108} 134}
135
136void drawdots(int color, struct coordinate *points, int count)
137{
138 while (count--)
139 {
140 if (color)
141 {
142 DRAW_PIXEL(points[count].x, points[count].y);
143 }
144 else
145 {
146 CLEAR_PIXEL(points[count].x, points[count].y);
147 }
148 }
149}
150
151void drawrectangles(int color, struct rectangle *points, int count)
152{
153 while (count--)
154 {
155 int x;
156 int y;
157 int ix;
158 int iy;
159
160 for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
161 {
162 for (y = points[count].y, iy = 0; iy < points[count].width; y++, iy++)
163 {
164 if (color)
165 {
166 DRAW_PIXEL(x, y);
167 }
168 else
169 {
170 CLEAR_PIXEL(x, y);
171 }
172 }
173 }
174 }
175}
diff --git a/uisimulator/win32/rockbox.dsp b/uisimulator/win32/rockbox.dsp
index b551a5fb25..47492faecd 100644
--- a/uisimulator/win32/rockbox.dsp
+++ b/uisimulator/win32/rockbox.dsp
@@ -69,7 +69,7 @@ LINK32=link.exe
69# PROP Ignore_Export_Lib 0 69# PROP Ignore_Export_Lib 0
70# PROP Target_Dir "" 70# PROP Target_Dir ""
71# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 71# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
72# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../firmware/export" /I "../../firmware/drivers" /I "../../firmware/common" /I "../common" /I "../win32" /I "../../apps" /I "../../apps/player" /D "HAVE_LCD_CHARCELLS" /D "HAVE_PLAYER_KEYPAD" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_CONFIG_H" /D "GETTIMEOFDAY_TWO_ARGS" /D "SIMULATOR" /D APPSVERSION=\"WIN32SIM\" /YX /FD /GZ /c 72# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../firmware/export" /I "../../firmware/drivers" /I "../../firmware/common" /I "../common" /I "../win32" /I "../../apps" /I "../../apps/player" /D "HAVE_LCD_CHARCELLS" /D "HAVE_PLAYER_KEYPAD" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_CONFIG_H" /D "GETTIMEOFDAY_TWO_ARGS" /D "SIMULATOR" /D APPSVERSION=\"WIN32SIM\" /FR /YX /FD /GZ /c
73# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 73# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75# ADD BASE RSC /l 0x407 /d "_DEBUG" 75# ADD BASE RSC /l 0x407 /d "_DEBUG"
@@ -93,6 +93,15 @@ LINK32=link.exe
93# Begin Source File 93# Begin Source File
94 94
95SOURCE=..\..\firmware\font.c 95SOURCE=..\..\firmware\font.c
96
97!IF "$(CFG)" == "rockbox - Win32 Recorder"
98
99!ELSEIF "$(CFG)" == "rockbox - Win32 Player"
100
101# PROP Exclude_From_Build 1
102
103!ENDIF
104
96# End Source File 105# End Source File
97# Begin Source File 106# Begin Source File
98 107
@@ -510,6 +519,19 @@ SOURCE=".\dir-win32.c"
510# End Source File 519# End Source File
511# Begin Source File 520# Begin Source File
512 521
522SOURCE="..\common\font-player.c"
523
524!IF "$(CFG)" == "rockbox - Win32 Recorder"
525
526# PROP Exclude_From_Build 1
527
528!ELSEIF "$(CFG)" == "rockbox - Win32 Player"
529
530!ENDIF
531
532# End Source File
533# Begin Source File
534
513SOURCE=.\io.c 535SOURCE=.\io.c
514# End Source File 536# End Source File
515# Begin Source File 537# Begin Source File
diff --git a/uisimulator/win32/uisw32.c b/uisimulator/win32/uisw32.c
index b4747b138e..3cfa3aed7c 100644
--- a/uisimulator/win32/uisw32.c
+++ b/uisimulator/win32/uisw32.c
@@ -34,6 +34,8 @@
34extern void app_main (void *); // mod entry point 34extern void app_main (void *); // mod entry point
35extern void new_key(int key); 35extern void new_key(int key);
36 36
37void button_event(int key, bool pressed);
38
37// variables 39// variables
38HWND hGUIWnd; // the GUI window handle 40HWND hGUIWnd; // the GUI window handle
39unsigned int uThreadID; // id of mod thread 41unsigned int uThreadID; // id of mod thread
@@ -172,7 +174,7 @@ LRESULT GUIWndProc (
172 RECT r; 174 RECT r;
173 175
174 GetClientRect (hWnd, &r); 176 GetClientRect (hWnd, &r);
175 // blit to screen 177 // blit background image to screen
176 StretchBlt (hDc, 0, 0, r.right, r.bottom, 178 StretchBlt (hDc, 0, 0, r.right, r.bottom,
177 hMemDc, 0, 0, UI_WIDTH, UI_HEIGHT, SRCCOPY); 179 hMemDc, 0, 0, UI_WIDTH, UI_HEIGHT, SRCCOPY);
178 EndPaint (hWnd, &ps); 180 EndPaint (hWnd, &ps);
@@ -187,8 +189,10 @@ LRESULT GUIWndProc (
187 GetClientRect (hWnd, &r); 189 GetClientRect (hWnd, &r);
188 // draw lcd screen 190 // draw lcd screen
189 StretchDIBits (hDc, 191 StretchDIBits (hDc,
190 UI_LCD_POSX * r.right / UI_WIDTH, UI_LCD_POSY * r.bottom / UI_HEIGHT, 192 UI_LCD_POSX * r.right / UI_WIDTH,
191 LCD_WIDTH * r.right / UI_WIDTH, LCD_HEIGHT * r.bottom / UI_HEIGHT, 193 UI_LCD_POSY * r.bottom / UI_HEIGHT,
194 UI_LCD_WIDTH * r.right / UI_WIDTH,
195 UI_LCD_HEIGHT * r.bottom / UI_HEIGHT,
192 0, 0, LCD_WIDTH, LCD_HEIGHT, 196 0, 0, LCD_WIDTH, LCD_HEIGHT,
193 bitmap, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, SRCCOPY); 197 bitmap, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, SRCCOPY);
194 198
@@ -206,6 +210,12 @@ LRESULT GUIWndProc (
206 hGUIWnd = NULL; 210 hGUIWnd = NULL;
207 PostQuitMessage (0); 211 PostQuitMessage (0);
208 break; 212 break;
213 case WM_KEYDOWN:
214 button_event(wParam, true);
215 break;
216 case WM_KEYUP:
217 button_event(wParam, false);
218 break;
209 } 219 }
210 220
211 return DefWindowProc (hWnd, uMsg, wParam, lParam); 221 return DefWindowProc (hWnd, uMsg, wParam, lParam);
diff --git a/uisimulator/win32/uisw32.h b/uisimulator/win32/uisw32.h
index 6b8c3f6ff7..2efa699dad 100644
--- a/uisimulator/win32/uisw32.h
+++ b/uisimulator/win32/uisw32.h
@@ -35,6 +35,8 @@ typedef unsigned short wchar_t;
35#define UI_LCD_BLACK 0, 0, 0 // black 35#define UI_LCD_BLACK 0, 0, 0 // black
36#define UI_LCD_POSX 59 // x position of lcd 36#define UI_LCD_POSX 59 // x position of lcd
37#define UI_LCD_POSY 95 // y position of lcd 37#define UI_LCD_POSY 95 // y position of lcd
38#define UI_LCD_WIDTH 112
39#define UI_LCD_HEIGHT 64
38 40
39#define TM_YIELD WM_USER + 101 // thread message for yield 41#define TM_YIELD WM_USER + 101 // thread message for yield
40#define TIMER_EVENT 0x34928340 42#define TIMER_EVENT 0x34928340