most of UI sim patch 708460 from Magnus Holmgren, except the bitmap removal
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3571 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6d522179dc
commit
c6fb565dd9
7 changed files with 279 additions and 98 deletions
|
@ -420,7 +420,7 @@ struct icon_info
|
|||
int row;
|
||||
};
|
||||
|
||||
#define ICON_VOLUME_POS 230
|
||||
#define ICON_VOLUME_POS 224
|
||||
#define ICON_VOLUME_SIZE 20
|
||||
#define ICON_VOLUME_X_SIZE 2
|
||||
|
||||
|
|
|
@ -20,119 +20,180 @@
|
|||
#include <windows.h>
|
||||
#include "uisw32.h"
|
||||
#include "config.h"
|
||||
#include "sh7034.h"
|
||||
#include "button.h"
|
||||
#include "kernel.h"
|
||||
#include "backlight.h"
|
||||
|
||||
#define KEY(k) (HIBYTE(GetKeyState (k)) & 1)
|
||||
/* how long until repeat kicks in */
|
||||
#define REPEAT_START 6
|
||||
|
||||
int last_key ;
|
||||
static int release_mask;
|
||||
static int repeat_mask;
|
||||
/* the speed repeat starts at */
|
||||
#define REPEAT_INTERVAL_START 4
|
||||
|
||||
/* speed repeat finishes at */
|
||||
#define REPEAT_INTERVAL_FINISH 2
|
||||
|
||||
void button_init(void)
|
||||
{
|
||||
last_key = 0 ;
|
||||
}
|
||||
long last_keypress;
|
||||
struct event_queue button_queue;
|
||||
|
||||
int button_set_repeat(int newmask)
|
||||
void button_event(int key, bool pressed)
|
||||
{
|
||||
int oldmask = repeat_mask;
|
||||
repeat_mask = newmask;
|
||||
return oldmask;
|
||||
}
|
||||
bool post = false;
|
||||
int new_btn = 0;
|
||||
int diff = 0;
|
||||
static int count = 0;
|
||||
static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
|
||||
static int lastbtn;
|
||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||
static int repeat_count = 0;
|
||||
static bool repeat = false;
|
||||
|
||||
int button_set_release(int newmask)
|
||||
{
|
||||
int oldmask = release_mask;
|
||||
release_mask = newmask;
|
||||
return oldmask;
|
||||
}
|
||||
|
||||
static int real_button_get(void)
|
||||
{
|
||||
int btn = 0;
|
||||
Sleep (25);
|
||||
|
||||
if (bActive)
|
||||
switch (key)
|
||||
{
|
||||
if (KEY (VK_NUMPAD4) ||
|
||||
KEY (VK_LEFT)) // left button
|
||||
btn |= BUTTON_LEFT;
|
||||
case VK_NUMPAD4:
|
||||
case VK_LEFT:
|
||||
new_btn = BUTTON_LEFT;
|
||||
break;
|
||||
case VK_NUMPAD6:
|
||||
case VK_RIGHT:
|
||||
new_btn = BUTTON_RIGHT;
|
||||
break;
|
||||
case VK_NUMPAD8:
|
||||
case VK_UP:
|
||||
new_btn = BUTTON_UP;
|
||||
break;
|
||||
case VK_NUMPAD2:
|
||||
case VK_DOWN:
|
||||
new_btn = BUTTON_DOWN;
|
||||
break;
|
||||
case VK_ADD:
|
||||
new_btn = BUTTON_ON;
|
||||
break;
|
||||
|
||||
if (KEY (VK_NUMPAD6) ||
|
||||
KEY (VK_RIGHT))
|
||||
btn |= BUTTON_RIGHT; // right button
|
||||
|
||||
if (KEY (VK_NUMPAD8) ||
|
||||
KEY (VK_UP))
|
||||
btn |= BUTTON_UP; // up button
|
||||
|
||||
if (KEY (VK_NUMPAD2) ||
|
||||
KEY (VK_DOWN))
|
||||
btn |= BUTTON_DOWN; // down button
|
||||
|
||||
if (KEY (VK_ADD))
|
||||
btn |= BUTTON_ON; // on button
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
if (KEY (VK_RETURN))
|
||||
btn |= BUTTON_OFF; // off button
|
||||
|
||||
if (KEY (VK_DIVIDE) || KEY(VK_F1))
|
||||
btn |= BUTTON_F1; // F1 button
|
||||
|
||||
if (KEY (VK_MULTIPLY) || KEY(VK_F2))
|
||||
btn |= BUTTON_F2; // F2 button
|
||||
|
||||
if (KEY (VK_SUBTRACT) || KEY(VK_F3))
|
||||
btn |= BUTTON_F3; // F3 button
|
||||
|
||||
if (KEY (VK_NUMPAD5) ||
|
||||
KEY (VK_SPACE))
|
||||
btn |= BUTTON_PLAY; // play button
|
||||
case VK_RETURN:
|
||||
new_btn = BUTTON_OFF;
|
||||
break;
|
||||
case VK_DIVIDE:
|
||||
case VK_F1:
|
||||
new_btn = BUTTON_F1;
|
||||
break;
|
||||
case VK_MULTIPLY:
|
||||
case VK_F2:
|
||||
new_btn = BUTTON_F2;
|
||||
break;
|
||||
case VK_SUBTRACT:
|
||||
case VK_F3:
|
||||
new_btn = BUTTON_F3;
|
||||
break;
|
||||
case VK_NUMPAD5:
|
||||
case VK_SPACE:
|
||||
new_btn = BUTTON_PLAY;
|
||||
break;
|
||||
#else
|
||||
if (KEY (VK_RETURN))
|
||||
btn |= BUTTON_MENU; // menu button
|
||||
case VK_RETURN:
|
||||
new_btn = BUTTON_MENU;
|
||||
break;
|
||||
#endif
|
||||
|
||||
if (btn != 0) {
|
||||
last_key = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
return btn;
|
||||
if (pressed)
|
||||
btn |= new_btn;
|
||||
else
|
||||
btn &= !new_btn;
|
||||
|
||||
/* Lots of stuff copied from real button.c. Not good, I think... */
|
||||
|
||||
/* Find out if a key has been released */
|
||||
diff = btn ^ lastbtn;
|
||||
|
||||
if(diff && (btn & diff) == 0)
|
||||
{
|
||||
queue_post(&button_queue, BUTTON_REL | diff, NULL);
|
||||
}
|
||||
|
||||
if ( btn )
|
||||
{
|
||||
/* normal keypress */
|
||||
if ( btn != lastbtn )
|
||||
{
|
||||
post = true;
|
||||
repeat = false;
|
||||
repeat_speed = REPEAT_INTERVAL_START;
|
||||
|
||||
}
|
||||
else /* repeat? */
|
||||
{
|
||||
if ( repeat )
|
||||
{
|
||||
count--;
|
||||
if (count == 0)
|
||||
{
|
||||
post = true;
|
||||
/* yes we have repeat */
|
||||
repeat_speed--;
|
||||
if (repeat_speed < REPEAT_INTERVAL_FINISH)
|
||||
repeat_speed = REPEAT_INTERVAL_FINISH;
|
||||
count = repeat_speed;
|
||||
|
||||
repeat_count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count++ > REPEAT_START)
|
||||
{
|
||||
post = true;
|
||||
repeat = true;
|
||||
repeat_count = 0;
|
||||
/* initial repeat */
|
||||
count = REPEAT_INTERVAL_START;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( post )
|
||||
{
|
||||
if(repeat)
|
||||
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
|
||||
else
|
||||
queue_post(&button_queue, btn, NULL);
|
||||
|
||||
backlight_on();
|
||||
|
||||
last_keypress = current_tick;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
repeat = false;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
|
||||
}
|
||||
|
||||
void button_init(void)
|
||||
{
|
||||
last_keypress = 0;
|
||||
}
|
||||
|
||||
/* Again copied from real button.c... */
|
||||
|
||||
int button_get(bool block)
|
||||
{
|
||||
int btn;
|
||||
do {
|
||||
struct event ev;
|
||||
|
||||
btn = real_button_get();
|
||||
|
||||
if (btn)
|
||||
break;
|
||||
|
||||
} while (block);
|
||||
|
||||
return btn;
|
||||
if ( block || !queue_empty(&button_queue) ) {
|
||||
queue_wait(&button_queue, &ev);
|
||||
return ev.id;
|
||||
}
|
||||
return BUTTON_NONE;
|
||||
}
|
||||
|
||||
int button_get_w_tmo(int ticks)
|
||||
{
|
||||
int btn;
|
||||
do {
|
||||
btn = real_button_get();
|
||||
|
||||
if(!btn)
|
||||
/* prevent busy-looping */
|
||||
sleep(10); /* one tick! */
|
||||
else
|
||||
return btn;
|
||||
|
||||
} while (--ticks);
|
||||
|
||||
return btn;
|
||||
}
|
||||
struct event ev;
|
||||
queue_wait_w_tmo(&button_queue, &ev, ticks);
|
||||
return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,25 @@ void queue_wait(struct event_queue *q, struct event *ev)
|
|||
*ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
|
||||
}
|
||||
|
||||
void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
|
||||
{
|
||||
unsigned int timeout = current_tick + ticks;
|
||||
|
||||
while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if(q->read != q->write)
|
||||
{
|
||||
*ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
|
||||
}
|
||||
else
|
||||
{
|
||||
ev->id = SYS_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
void queue_post(struct event_queue *q, int id, void *data)
|
||||
{
|
||||
int wr;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <process.h>
|
||||
#include "uisw32.h"
|
||||
#include "lcd.h"
|
||||
#include "lcd-playersim.h"
|
||||
|
||||
unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; /* the display */
|
||||
char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
|
||||
|
@ -32,12 +33,20 @@ BITMAPINFO2 bmi =
|
|||
BI_RGB, 0, 0, 0, 2, 2,
|
||||
},
|
||||
{
|
||||
{UI_LCD_BGCOLOR, 0}, /* green background color */
|
||||
//{UI_LCD_BGCOLOR, 0}, /* green background color */
|
||||
{UI_LCD_BGCOLORLIGHT, 0}, /* green background color */
|
||||
{UI_LCD_BLACK, 0} /* black color */
|
||||
}
|
||||
|
||||
}; /* bitmap information */
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
/* Defined in lcd-playersim.c */
|
||||
extern void lcd_print_char(int x, int y);
|
||||
extern bool lcd_display_redraw;
|
||||
extern unsigned char hardware_buffer_lcd[11][2];
|
||||
static unsigned char lcd_buffer_copy[11][2];
|
||||
#endif
|
||||
|
||||
void lcd_set_invert_display(bool invert)
|
||||
{
|
||||
|
@ -52,6 +61,23 @@ void lcd_update()
|
|||
if (hGUIWnd == NULL)
|
||||
_endthread ();
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
for (y = 0; y < 2; y++)
|
||||
{
|
||||
for (x = 0; x < 11; x++)
|
||||
{
|
||||
if (lcd_display_redraw ||
|
||||
lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
|
||||
{
|
||||
lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
|
||||
lcd_print_char(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lcd_display_redraw = false;
|
||||
#endif
|
||||
|
||||
for (x = 0; x < LCD_WIDTH; x++)
|
||||
for (y = 0; y < LCD_HEIGHT; y++)
|
||||
bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1);
|
||||
|
@ -59,7 +85,7 @@ void lcd_update()
|
|||
InvalidateRect (hGUIWnd, NULL, FALSE);
|
||||
|
||||
/* natural sleep :) Bagder: why is this here? */
|
||||
Sleep (50);
|
||||
//Sleep (50);
|
||||
}
|
||||
|
||||
void lcd_update_rect(int x_start, int y_start,
|
||||
|
@ -106,3 +132,44 @@ void lcd_backlight (bool on)
|
|||
|
||||
InvalidateRect (hGUIWnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
void drawdots(int color, struct coordinate *points, int count)
|
||||
{
|
||||
while (count--)
|
||||
{
|
||||
if (color)
|
||||
{
|
||||
DRAW_PIXEL(points[count].x, points[count].y);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLEAR_PIXEL(points[count].x, points[count].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawrectangles(int color, struct rectangle *points, int count)
|
||||
{
|
||||
while (count--)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int ix;
|
||||
int iy;
|
||||
|
||||
for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
|
||||
{
|
||||
for (y = points[count].y, iy = 0; iy < points[count].width; y++, iy++)
|
||||
{
|
||||
if (color)
|
||||
{
|
||||
DRAW_PIXEL(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLEAR_PIXEL(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ LINK32=link.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# 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
|
||||
# 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
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
|
@ -93,6 +93,15 @@ LINK32=link.exe
|
|||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\firmware\font.c
|
||||
|
||||
!IF "$(CFG)" == "rockbox - Win32 Recorder"
|
||||
|
||||
!ELSEIF "$(CFG)" == "rockbox - Win32 Player"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -510,6 +519,19 @@ SOURCE=".\dir-win32.c"
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\common\font-player.c"
|
||||
|
||||
!IF "$(CFG)" == "rockbox - Win32 Recorder"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "rockbox - Win32 Player"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\io.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
extern void app_main (void *); // mod entry point
|
||||
extern void new_key(int key);
|
||||
|
||||
void button_event(int key, bool pressed);
|
||||
|
||||
// variables
|
||||
HWND hGUIWnd; // the GUI window handle
|
||||
unsigned int uThreadID; // id of mod thread
|
||||
|
@ -172,7 +174,7 @@ LRESULT GUIWndProc (
|
|||
RECT r;
|
||||
|
||||
GetClientRect (hWnd, &r);
|
||||
// blit to screen
|
||||
// blit background image to screen
|
||||
StretchBlt (hDc, 0, 0, r.right, r.bottom,
|
||||
hMemDc, 0, 0, UI_WIDTH, UI_HEIGHT, SRCCOPY);
|
||||
EndPaint (hWnd, &ps);
|
||||
|
@ -187,8 +189,10 @@ LRESULT GUIWndProc (
|
|||
GetClientRect (hWnd, &r);
|
||||
// draw lcd screen
|
||||
StretchDIBits (hDc,
|
||||
UI_LCD_POSX * r.right / UI_WIDTH, UI_LCD_POSY * r.bottom / UI_HEIGHT,
|
||||
LCD_WIDTH * r.right / UI_WIDTH, LCD_HEIGHT * r.bottom / UI_HEIGHT,
|
||||
UI_LCD_POSX * r.right / UI_WIDTH,
|
||||
UI_LCD_POSY * r.bottom / UI_HEIGHT,
|
||||
UI_LCD_WIDTH * r.right / UI_WIDTH,
|
||||
UI_LCD_HEIGHT * r.bottom / UI_HEIGHT,
|
||||
0, 0, LCD_WIDTH, LCD_HEIGHT,
|
||||
bitmap, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, SRCCOPY);
|
||||
|
||||
|
@ -206,6 +210,12 @@ LRESULT GUIWndProc (
|
|||
hGUIWnd = NULL;
|
||||
PostQuitMessage (0);
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
button_event(wParam, true);
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
button_event(wParam, false);
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
|
|
|
@ -35,6 +35,8 @@ typedef unsigned short wchar_t;
|
|||
#define UI_LCD_BLACK 0, 0, 0 // black
|
||||
#define UI_LCD_POSX 59 // x position of lcd
|
||||
#define UI_LCD_POSY 95 // y position of lcd
|
||||
#define UI_LCD_WIDTH 112
|
||||
#define UI_LCD_HEIGHT 64
|
||||
|
||||
#define TM_YIELD WM_USER + 101 // thread message for yield
|
||||
#define TIMER_EVENT 0x34928340
|
||||
|
|
Loading…
Reference in a new issue