ac97: max buffer should be full samples, games/doom: enable/disable mouse grabbing when switching to the menu
This commit is contained in:
parent
ddfc34d648
commit
9bb72cc699
5 changed files with 28 additions and 17 deletions
|
@ -139,7 +139,7 @@ available(Ring *r)
|
|||
{
|
||||
long m;
|
||||
|
||||
m = (r->nbuf - 1) - buffered(r);
|
||||
m = (r->nbuf - BytesPerSample) - buffered(r);
|
||||
if(m < 0)
|
||||
m = 0;
|
||||
return m;
|
||||
|
|
|
@ -17,6 +17,7 @@ void I_Init (void)
|
|||
{
|
||||
I_InitSound();
|
||||
I_InitGraphics();
|
||||
I_MouseEnable(1);
|
||||
}
|
||||
|
||||
byte* I_ZoneBase (int *size)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <keyboard.h>
|
||||
|
||||
static int resized;
|
||||
static int mouseactive;
|
||||
|
||||
static Rectangle grabout;
|
||||
static Point center;
|
||||
|
@ -19,19 +20,6 @@ static void mouseproc(void*);
|
|||
|
||||
static uchar cmap[3*256];
|
||||
|
||||
static void
|
||||
nocursor(void)
|
||||
{
|
||||
char curs[2*4+2*2*16];
|
||||
int fd;
|
||||
|
||||
if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0)
|
||||
return;
|
||||
memset(curs, 0, sizeof curs);
|
||||
write(fd, curs, sizeof curs);
|
||||
}
|
||||
|
||||
|
||||
void I_InitGraphics(void)
|
||||
{
|
||||
if(initdraw(nil, nil, "doom") < 0)
|
||||
|
@ -41,7 +29,6 @@ void I_InitGraphics(void)
|
|||
|
||||
center = addpt(screen->r.min, Pt(Dx(screen->r)/2, Dy(screen->r)/2));
|
||||
grabout = insetrect(screen->r, Dx(screen->r)/8);
|
||||
nocursor();
|
||||
|
||||
proccreate(kbdproc, nil, 8*1024);
|
||||
proccreate(mouseproc, nil, 8*1024);
|
||||
|
@ -131,6 +118,22 @@ void I_FinishUpdate(void)
|
|||
flushimage(display, 1);
|
||||
}
|
||||
|
||||
void I_MouseEnable(int on)
|
||||
{
|
||||
static char nocurs[2*4+2*2*16];
|
||||
static int fd = -1;
|
||||
|
||||
if(mouseactive == on)
|
||||
return;
|
||||
if(mouseactive = on){
|
||||
if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0)
|
||||
return;
|
||||
write(fd, nocurs, sizeof(nocurs));
|
||||
}else if(fd >= 0) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void I_ReadScreen(byte *scr)
|
||||
{
|
||||
|
@ -277,6 +280,9 @@ mouseproc(void *)
|
|||
resized = 1;
|
||||
/* fall through */
|
||||
case 'm':
|
||||
if(!mouseactive)
|
||||
break;
|
||||
|
||||
m.xy.x = atoi(buf+1+0*12);
|
||||
m.xy.y = atoi(buf+1+1*12);
|
||||
m.buttons = atoi(buf+1+2*12);
|
||||
|
|
|
@ -44,6 +44,7 @@ void I_SetPalette (byte* palette);
|
|||
|
||||
void I_UpdateNoBlit (void);
|
||||
void I_FinishUpdate (void);
|
||||
void I_MouseEnable (int);
|
||||
|
||||
// Wait for vertical retrace or pause a bit.
|
||||
void I_WaitVBL(int count);
|
||||
|
@ -54,7 +55,6 @@ void I_BeginRead (void);
|
|||
void I_EndRead (void);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -1710,10 +1710,12 @@ void M_StartControlPanel (void)
|
|||
// intro might call this repeatedly
|
||||
if (menuactive)
|
||||
return;
|
||||
|
||||
|
||||
menuactive = 1;
|
||||
currentMenu = &MainDef; // JDC
|
||||
itemOn = currentMenu->lastOn; // JDC
|
||||
|
||||
I_MouseEnable(0); // disable mouse grab
|
||||
}
|
||||
|
||||
|
||||
|
@ -1796,6 +1798,8 @@ void M_Drawer (void)
|
|||
void M_ClearMenus (void)
|
||||
{
|
||||
menuactive = 0;
|
||||
I_MouseEnable(1); // enable mouse grabbing
|
||||
|
||||
// if (!netgame && usergame && paused)
|
||||
// sendpause = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue