Exemplo n.º 1
1
// Returns the number of seconds this key has been down since last call.
fix key_down_time(int scancode)	{
	fix time_down, time;

	if ((scancode<0)|| (scancode>255)) return 0;

#ifndef NDEBUG
	if (keyd_editor_mode && key_get_shift_status() )
		return 0;  
#endif

	_disable();

	if ( !keyd_pressed[scancode] )	{
		time_down = key_data.TimeKeyHeldDown[scancode];
		key_data.TimeKeyHeldDown[scancode] = 0;
	} else	{
		time = timer_get_fixed_secondsX();
		time_down =  time - key_data.TimeKeyWentDown[scancode];
		key_data.TimeKeyWentDown[scancode] = time;
	}
	_enable();

	return time_down;
}
Exemplo n.º 2
0
void key_flush()
{
	int i;
	fix CurTime;

	_disable();

	// Clear the BIOS buffer
	key_clear_bios_buffer();

	key_data.keyhead = key_data.keytail = 0;

	//Clear the keyboard buffer
	for (i=0; i<KEY_BUFFER_SIZE; i++ )	{
		key_data.keybuffer[i] = 0;
		key_data.time_pressed[i] = 0;
	}
	
	//Clear the keyboard array

	CurTime =timer_get_fixed_secondsX();

	for (i=0; i<256; i++ )	{
		keyd_pressed[i] = 0;
		key_data.TimeKeyWentDown[i] = CurTime;
		key_data.TimeKeyHeldDown[i] = 0;
		key_data.NumDowns[i]=0;
		key_data.NumUps[i]=0;
	}
	_enable();
}
Exemplo n.º 3
0
void mouse_flush()
{
	int i;
	fix CurTime;

	if (!Mouse_installed) 
		return;

	_disable();

	//Clear the mouse data
	CurTime =timer_get_fixed_secondsX();
	for (i=0; i<MOUSE_MAX_BUTTONS; i++ )	{
		Mouse.pressed[i] = 0;
		Mouse.time_went_down[i] = CurTime;
		Mouse.time_held_down[i] = 0;
		Mouse.num_downs[i]=0;
		Mouse.num_ups[i]=0;
	}
	_enable();
}
Exemplo n.º 4
0
// Returns how long this button has been down since last call.
fix mouse_button_down_time(int button)	
{
	fix time_down, time;

	if (!Mouse_installed) 
		return 0;

	_disable();

	if ( !Mouse.pressed[button] )	{
		time_down = Mouse.time_held_down[button];
		Mouse.time_held_down[button] = 0;
	} else	{
		time = timer_get_fixed_secondsX();
		time_down =  time - Mouse.time_went_down[button];
		Mouse.time_went_down[button] = time;
	}

	_enable();

	return time_down;
}
Exemplo n.º 5
0
void __interrupt __far key_handler()
{
	unsigned char scancode, breakbit, temp;
	unsigned short keycode;

#ifndef WATCOM_10
#ifndef NDEBUG
	ubyte * MONO = (ubyte *)(0x0b0000+24*80*2);
	if (  ((MONO[0]=='D') && (MONO[2]=='B') && (MONO[4]=='G') && (MONO[6]=='>')) ||
			((MONO[14]=='<') && (MONO[16]=='i') && (MONO[18]=='>') && (MONO[20]==' ') && (MONO[22]=='-')) ||
			((MONO[0]==200 ) && (MONO[2]==27) && (MONO[4]==17) )
		)
 		_chain_intr( key_data.prev_int_9 );
#endif
#endif

	// Read in scancode
	scancode = inp( 0x60 );

	switch( scancode )	{
	case 0xE0:
		key_data.E0Flag = 0x80;
		break;
	default:
		// Parse scancode and break bit
		if (key_data.E1Flag > 0 )	{		// Special code for Pause, which is E1 1D 45 E1 9D C5
			key_data.E1Flag--;
			if ( scancode == 0x1D )	{
				scancode	= KEY_PAUSE;
				breakbit	= 0;
			} else if ( scancode == 0x9d ) {
				scancode	= KEY_PAUSE;
				breakbit	= 1;
			} else {
				break;		// skip this keycode
			}
		} else if ( scancode==0xE1 )	{
			key_data.E1Flag = 2;
			break;
		} else {
			breakbit	= scancode & 0x80;		// Get make/break bit
			scancode &= 0x7f;						// Strip make/break bit off of scancode
			scancode |= key_data.E0Flag;					// Add in extended key code
		}
		key_data.E0Flag = 0;								// Clear extended key code

		if (breakbit)	{
			// Key going up
			keyd_last_released = scancode;
			keyd_pressed[scancode] = 0;
			key_data.NumUps[scancode]++;
			temp = 0;
			temp |= keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT];
			temp |= keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT];
			temp |= keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL];
#ifndef NDEBUG
			temp |= keyd_pressed[KEY_DELETE];
			if ( !(keyd_editor_mode && temp) )
#endif		// NOTICE LINK TO ABOVE IF!!!!
				key_data.TimeKeyHeldDown[scancode] += timer_get_fixed_secondsX() - key_data.TimeKeyWentDown[scancode];
		} else {
			// Key going down
			keyd_last_pressed = scancode;
			keyd_time_when_last_pressed = timer_get_fixed_secondsX();
			if (!keyd_pressed[scancode])	{
				// First time down
				key_data.TimeKeyWentDown[scancode] = timer_get_fixed_secondsX();
				keyd_pressed[scancode] = 1;
				key_data.NumDowns[scancode]++;
#ifndef NDEBUG
				if ( (keyd_pressed[KEY_LSHIFT]) && (scancode == KEY_BACKSP) ) 	{
					keyd_pressed[KEY_LSHIFT] = 0;
					Int5();
				}
#endif
			} else if (!keyd_repeat) {
				// Don't buffer repeating key if repeat mode is off
				scancode = 0xAA;		
			} 

			if ( scancode!=0xAA ) {
				keycode = scancode;

				if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT] )
					keycode |= KEY_SHIFTED;

				if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT] )
					keycode |= KEY_ALTED;

				if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL] )
					keycode |= KEY_CTRLED;

#ifndef NDEBUG
				if ( keyd_pressed[KEY_DELETE] )
					keycode |= KEY_DEBUGGED;
#endif

				temp = key_data.keytail+1;
				if ( temp >= KEY_BUFFER_SIZE ) temp=0;

				if (temp!=key_data.keyhead)	{
					key_data.keybuffer[key_data.keytail] = keycode;
					key_data.time_pressed[key_data.keytail] = keyd_time_when_last_pressed;
					key_data.keytail = temp;
				}
			}
		}
	}

#ifndef NDEBUG
#ifdef PASS_KEYS_TO_BIOS
	_chain_intr( key_data.prev_int_9 );
#endif
#endif

	temp = inp(0x61);		// Get current port 61h state
	temp |= 0x80;			// Turn on bit 7 to signal clear keybrd
	outp( 0x61, temp );	// Send to port
	temp &= 0x7f;			// Turn off bit 7 to signal break
	outp( 0x61, temp );	// Send to port
	outp( 0x20, 0x20 );	// Reset interrupt controller
}
Exemplo n.º 6
0
void _loadds far mouse_handler (int m_ax, int mbx, int mcx, int mdx, int msi, int mdi)
{
#pragma aux mouse_handler parm [EAX] [EBX] [ECX] [EDX] [ESI] [EDI]

	Mouse.ctime = timer_get_fixed_secondsX();

	if (m_ax & ME_LB_P)	{	// left button pressed
		if (!Mouse.pressed[MB_LEFT])	{
			Mouse.pressed[MB_LEFT] = 1;
			Mouse.time_went_down[MB_LEFT] = Mouse.ctime;
		}
		Mouse.num_downs[MB_LEFT]++;
	} else if (m_ax & ME_LB_R )	{  // left button released
		if (Mouse.pressed[MB_LEFT])	{
			Mouse.pressed[MB_LEFT] = 0;
			Mouse.time_held_down[MB_LEFT] += Mouse.ctime-Mouse.time_went_down[MB_LEFT];
		}
		Mouse.num_ups[MB_LEFT]++;
	}

	if (m_ax & ME_RB_P ) {	// right button pressed
		if (!Mouse.pressed[MB_RIGHT])	{
			Mouse.pressed[MB_RIGHT] = 1;
			Mouse.time_went_down[MB_RIGHT] = Mouse.ctime;
		}
		Mouse.num_downs[MB_RIGHT]++;
	} else if (m_ax & ME_RB_R )	{// right button released
		if (Mouse.pressed[MB_RIGHT])	{
			Mouse.pressed[MB_RIGHT] = 0;
			Mouse.time_held_down[MB_RIGHT] += Mouse.ctime-Mouse.time_went_down[MB_RIGHT];
		}
		Mouse.num_ups[MB_RIGHT]++;
	}

	if (m_ax & ME_MB_P )	{ // middle button pressed
		if (!Mouse.pressed[MB_MIDDLE])	{
			Mouse.pressed[MB_MIDDLE] = 1;
			Mouse.time_went_down[MB_MIDDLE] = Mouse.ctime;
		}
		Mouse.num_downs[MB_MIDDLE]++;
	} else if (m_ax & ME_MB_R )	{ // middle button released
		if (Mouse.pressed[MB_MIDDLE])	{
			Mouse.pressed[MB_MIDDLE] = 0;
			Mouse.time_held_down[MB_MIDDLE] += Mouse.ctime-Mouse.time_went_down[MB_MIDDLE];
		}
		Mouse.num_ups[MB_MIDDLE]++;
	}

	if (Mouse.cyberman && (m_ax & (ME_Z_C|ME_P_C|ME_B_C|ME_H_C)))	{
		Mouse.x_info = (event_info *)((msi & 0xFFFF) << 4);

		if (m_ax & ME_Z_C )	{ // z axis changed
			if (Mouse.pressed[MB_Z_UP])	{
			 	// z up released
				Mouse.pressed[MB_Z_UP] = 0;
				Mouse.time_held_down[MB_Z_UP] += Mouse.ctime-Mouse.time_went_down[MB_Z_UP];
				Mouse.num_ups[MB_Z_UP]++;
			}  else if ( Mouse.x_info->z>0 )	{
			 	// z up pressed
				Mouse.pressed[MB_Z_UP] = 1;
				Mouse.time_went_down[MB_Z_UP]=Mouse.ctime;
				Mouse.num_downs[MB_Z_UP]++;
			}
			if (Mouse.pressed[MB_Z_DOWN])	{
			 	// z down released
				Mouse.pressed[MB_Z_DOWN] = 0;
				Mouse.time_held_down[MB_Z_DOWN] += Mouse.ctime-Mouse.time_went_down[MB_Z_DOWN];
				Mouse.num_ups[MB_Z_DOWN]++;
			}  else if ( Mouse.x_info->z<0 )	{
			 	// z down pressed
				Mouse.pressed[MB_Z_DOWN] = 1;
				Mouse.time_went_down[MB_Z_DOWN]=Mouse.ctime;
				Mouse.num_downs[MB_Z_DOWN]++;
			}
		}
		if (m_ax & ME_P_C )	{ // pitch changed
			if (Mouse.pressed[MB_PITCH_BACKWARD])	{
			 	// pitch backward released
				Mouse.pressed[MB_PITCH_BACKWARD] = 0;
				Mouse.time_held_down[MB_PITCH_BACKWARD] += Mouse.ctime-Mouse.time_went_down[MB_PITCH_BACKWARD];
				Mouse.num_ups[MB_PITCH_BACKWARD]++;
			}  else if ( Mouse.x_info->pitch>0 )	{
			 	// pitch backward pressed
				Mouse.pressed[MB_PITCH_BACKWARD] = 1;
				Mouse.time_went_down[MB_PITCH_BACKWARD]=Mouse.ctime;
				Mouse.num_downs[MB_PITCH_BACKWARD]++;
			}
			if (Mouse.pressed[MB_PITCH_FORWARD])	{
			 	// pitch forward released
				Mouse.pressed[MB_PITCH_FORWARD] = 0;
				Mouse.time_held_down[MB_PITCH_FORWARD] += Mouse.ctime-Mouse.time_went_down[MB_PITCH_FORWARD];
				Mouse.num_ups[MB_PITCH_FORWARD]++;
			}  else if ( Mouse.x_info->pitch<0 )	{
			 	// pitch forward pressed
				Mouse.pressed[MB_PITCH_FORWARD] = 1;
				Mouse.time_went_down[MB_PITCH_FORWARD]=Mouse.ctime;
				Mouse.num_downs[MB_PITCH_FORWARD]++;
			}
		}

		if (m_ax & ME_B_C )	{ // bank changed
			if (Mouse.pressed[MB_BANK_LEFT])	{
			 	// bank left released
				Mouse.pressed[MB_BANK_LEFT] = 0;
				Mouse.time_held_down[MB_BANK_LEFT] += Mouse.ctime-Mouse.time_went_down[MB_BANK_LEFT];
				Mouse.num_ups[MB_BANK_LEFT]++;
			}  else if ( Mouse.x_info->bank>0 )	{
			 	// bank left pressed
				Mouse.pressed[MB_BANK_LEFT] = 1;
				Mouse.time_went_down[MB_BANK_LEFT]=Mouse.ctime;
				Mouse.num_downs[MB_BANK_LEFT]++;
			}
			if (Mouse.pressed[MB_BANK_RIGHT])	{
			 	// bank right released
				Mouse.pressed[MB_BANK_RIGHT] = 0;
				Mouse.time_held_down[MB_BANK_RIGHT] += Mouse.ctime-Mouse.time_went_down[MB_BANK_RIGHT];
				Mouse.num_ups[MB_BANK_RIGHT]++;
			}  else if ( Mouse.x_info->bank<0 )	{
			 	// bank right pressed
				Mouse.pressed[MB_BANK_RIGHT] = 1;
				Mouse.time_went_down[MB_BANK_RIGHT]=Mouse.ctime;
				Mouse.num_downs[MB_BANK_RIGHT]++;
			}
		}

		if (m_ax & ME_H_C )	{ // heading changed
			if (Mouse.pressed[MB_HEAD_LEFT])	{
			 	// head left released
				Mouse.pressed[MB_HEAD_LEFT] = 0;
				Mouse.time_held_down[MB_HEAD_LEFT] += Mouse.ctime-Mouse.time_went_down[MB_HEAD_LEFT];
				Mouse.num_ups[MB_HEAD_LEFT]++;
			}  else if ( Mouse.x_info->heading>0 )	{
			 	// head left pressed
				Mouse.pressed[MB_HEAD_LEFT] = 1;
				Mouse.time_went_down[MB_HEAD_LEFT]=Mouse.ctime;
				Mouse.num_downs[MB_HEAD_LEFT]++;
			}
			if (Mouse.pressed[MB_HEAD_RIGHT])	{
			 	// head right released
				Mouse.pressed[MB_HEAD_RIGHT] = 0;
				Mouse.time_held_down[MB_HEAD_RIGHT] += Mouse.ctime-Mouse.time_went_down[MB_HEAD_RIGHT];
				Mouse.num_ups[MB_HEAD_RIGHT]++;
			}  else if ( Mouse.x_info->heading<0 )	{
			 	// head right pressed
				Mouse.pressed[MB_HEAD_RIGHT] = 1;
				Mouse.time_went_down[MB_HEAD_RIGHT]=Mouse.ctime;
				Mouse.num_downs[MB_HEAD_RIGHT]++;
			}
		}
	}
	
}