Beispiel #1
0
int HandleEvents()
{
#if 0
	XEvent event;
	int ret = 0;
	
	if (XPending(dpy)) {
		do {
			XNextEvent(dpy, &event);
			switch(event.type) {
				case KeyPress:
					keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 1);
					ret = 1;
					break; 
				case KeyRelease:
					keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 0);
					ret = 0;
					break;
				case Expose:
					BlastScreen();
					break;
				case ClientMessage:
					if (event.xclient.data.l[0] == wmDeleteWindow)
						Quit(NULL);
					break;
				default:
					break;
			}
		} while (XPending(dpy));
	}
	return ret;
#else
	return 0;
#endif
}
Beispiel #2
0
void INL_Update()
{
	MAEvent event;
	while (maGetEvent(&event)) {
			switch(event.type) {
				case EVENT_TYPE_POINTER_PRESSED:
					keyboard_handler(sc_Space, 1);
				break;
				case EVENT_TYPE_POINTER_RELEASED:
					keyboard_handler(sc_Space, 0);
				break;

				case EVENT_TYPE_KEY_PRESSED:
					if(event.key == MAK_1) {
						FrameBuffer_setOrientation(gOrientation++);
						VW_UpdateScreen();
						break;
					}
					keyboard_handler(XKeysymToScancode(event.key), 1);
					break;
				case EVENT_TYPE_KEY_RELEASED:
					keyboard_handler(XKeysymToScancode(event.key), 0);
					break;
				case EVENT_TYPE_CLOSE:
					Quit(NULL);
					break;
				case EVENT_TYPE_AUDIOBUFFER_FILL:
					AudioBufferFill();
					break;
				default:
					break;
			}
	}
	//VW_UpdateScreen();
}
Beispiel #3
0
void INL_Update()
{
	SDL_Event event;
	boolean DebouncedKeyboard[NumCodes];
	
	memcpy(DebouncedKeyboard, InternalKeyboard, sizeof(DebouncedKeyboard));
	
	/* poll joysticks */
	SDL_JoystickUpdate();
		
	if (SDL_PollEvent(&event)) {
		do {
			switch(event.type) {
				case SDL_KEYDOWN:
					keyboard_handler(XKeysymToScancode(event.key.keysym.sym), 1);
					break;
				case SDL_KEYUP:
					keyboard_handler(XKeysymToScancode(event.key.keysym.sym), 0);
					break;
				case SDL_QUIT:
					/* TODO do something here */
					break;
				default:
					break;
			}
		} while (SDL_PollEvent(&event));
	}
	
	if (InternalKeyboard[sc_Alt] && 
	(!DebouncedKeyboard[sc_Return] && InternalKeyboard[sc_Return])) {
		SDL_GrabMode gm;
		
		SDL_WM_ToggleFullScreen(surface);
		
		gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
		if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN))
			SDL_ShowCursor(1);
		else
			SDL_ShowCursor(0);
	}
	
	if (InternalKeyboard[sc_Control] &&
	(!DebouncedKeyboard[sc_G] && InternalKeyboard[sc_G])) {
		SDL_GrabMode gm;
		
		gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
		SDL_WM_GrabInput((gm == SDL_GRAB_ON) ? SDL_GRAB_OFF : SDL_GRAB_ON);
		
		gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
		if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN))
			SDL_ShowCursor(1);
		else
			SDL_ShowCursor(0);
	}
	
	/* ctrl-z for iconify window? */
}
Beispiel #4
0
Datei: key.c Projekt: paud/d2x-xl
int key_getch()
{
	KEYCODE kcKey;
		keyboard_handler();
	while (!PopKey (&kcKey, NULL))
	{
		keyboard_handler ();
	}

	return kcKey;
}
Beispiel #5
0
void generic_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	UINT8 new_code;
	new_code = keyboard_handler(m_last_code, &m_scan_line);
	if ((m_last_code != new_code) && (new_code))
		send_key(new_code);
	m_last_code = new_code;
}
Beispiel #6
0
int kbd_test_timed_scan(unsigned short n)
{
	int ipc_status, r, exit = 0, max, counter = 0, flag = 0;
	unsigned long irq1, irq2, data;
	message msg;

	irq2 = subscribe_int(TIMER0_IRQ, IRQ_REENABLE, &timer0_id);
	irq1 = subscribe_int(KB_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &kb_id);
	if (irq1 == -1 || irq2 == -1) return -1;  // check if subscribe_int failed

	max = n*60;

	do
	{
		r = driver_receive(ANY, &msg, &ipc_status);
		if (r != 0)
		{
			printf("driver_receive failed with: %d", r);
			continue;
		}

		if (is_ipc_notify(ipc_status))
		{
			switch (_ENDPOINT_P(msg.m_source))
			{
			case HARDWARE:
				if (msg.NOTIFY_ARG & irq1)
				{
					counter = 0;
					data = keyboard_handler(0);
					flag = print_scancodes(data, flag);
					if (data == ESC)
					{
						printf("Done\n");
						exit = 1;
					}
				}
				if (msg.NOTIFY_ARG & irq2)
				{
					counter++;
					if (counter >= max)
					{
						printf("Done\n");
						exit = 1;
					}
				}
				break;
			default:
				break;
			}
		}
	} while (exit == 0);

	unsubscribe_int(&kb_id);
	unsubscribe_int(&timer0_id);

	return 0;
}
Beispiel #7
0
Datei: key.c Projekt: paud/d2x-xl
KEYCODE KeyInKeyTime(fix * pTime)
{
	KEYCODE kcKey = 0;

	keyboard_handler ();

	PopKey (&kcKey, pTime);

	return kcKey;
}
Beispiel #8
0
void
handler_033_for_keyboard    (the_x86_regs * regs)
{
  /* kbprintf   (   "Handler 033: keyboard (%d)\n", regs->int_no); */
  /* kttyprintf (0, "Handler 033: keyboard (%d)\n", regs->int_no); */

  keyboard_handler (regs);

  finish_isr (regs);

  return;
}
Beispiel #9
0
//Interrupt receptor
void interupt_handler(int time)
{
	int ipc_status;
	message msg;
	//int irq_set=timer_subscribe_int();
	int error;
	//ligar RTC
	unsigned long regB;
	counter = 0;
	regB = read_rtc(RTC_REG_B);
	regB = regB ^ RTC_UIE;
	write_rtc(RTC_REG_B,regB);

	while(counter<(time*60) && check_number_of_tries()==0) {
		/* Get a request message. */
		error = driver_receive(ANY, &msg, &ipc_status);
		if (error != 0 ) {
			printf("driver_receive failed with: %d",error);
			continue;
		}
		if (is_ipc_notify(ipc_status))
		{
			/* received notification */
			switch (_ENDPOINT_P(msg.m_source))
			{
			case HARDWARE: /* hardware interrupt notification */
				/*if ((msg.NOTIFY_ARG & BIT(0)) && (counter%60==0)) //subscribed interruptTimer
				{
					//timer_int_handler(counter); //same function as in lab3
					RTC_handler_date();
					counter++;
				}
				else*/
				if(msg.NOTIFY_ARG & BIT(1))
				{
					keyboard_handler(); //different function from the original
				}

				break;
			default:
				break; /* no other notifications expected: do nothing */
			}

		} else
		{ /* received a standard message, not a notification */
			/* no standard messages expected: do nothing */
		}
		counter++;
	}

	return;

}
Beispiel #10
0
int HandleEvents()
{
	XEvent event;
	int ret = 0;
	
	if (XPending(dpy)) {
		do {
			XNextEvent(dpy, &event);
			switch(event.type) {
				case KeyPress:
					keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 1);
					ret = 1;
					break; 
				case KeyRelease:
					keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 0);
					ret = 0;
					break;
				case Expose:
					RedrawScreen();
					break;
				case ConfigureNotify:
					glViewport(0, 0, event.xconfigure.width, event.xconfigure.height);
					glPixelZoom(1.0f, -1.0f);
					glRasterPos2f(-1.0f, 1.0f);
					RedrawScreen();
					break;
				case ClientMessage:
					if (event.xclient.data.l[0] == wmDeleteWindow)
						Quit(NULL);
					break;
				default:
					break;
			}
		} while (XPending(dpy));
	}
	return ret;
}
Beispiel #11
0
/****************************************************************
 IRQ Common Handler Routine
****************************************************************/
void irq_handler(registers_t regs)
{
    switch (regs.int_no) {
        case 32:
            // Called directly from irq0()
            break;
        case 33:
            keyboard_handler(regs);
            break;
        default:
            break;
    }
    // Send EOI signal to Master PIC
    outb(0x20, 0x20);
}
Beispiel #12
0
Datei: key.c Projekt: paud/d2x-xl
unsigned int keyDownCount(KEYCODE kcKey)
{
	int n;
		keyboard_handler();
	if ((kcKey < 0) || (kcKey > 127))
	{
		n = 0;
	}
	else
	{
		n = g_rgcDowns [kcKey];
		g_rgcDowns [kcKey] = 0;
	}

	return n;
}
Beispiel #13
0
Datei: wgl.c Projekt: paud/d2x-xl
long PASCAL DescentWndProc(HWND hWnd,UINT message,
						   WPARAM wParam,LPARAM lParam )
{
  switch(message)
  {

   case WM_KEYDOWN:
   case WM_KEYUP:
	if (WMKey_Handler_Ready) {
//      key_wparam=wParam; key_lparam=lParam; key_msg=message;
	  keyboard_handler();
	}
	break;
   case WM_MOUSEMOVE:
   case WM_LBUTTONDOWN:
   case WM_LBUTTONUP:
   case WM_RBUTTONDOWN:
   case WM_RBUTTONUP:
   case WM_NCMOUSEMOVE:
   case WM_NCLBUTTONDOWN:
   case WM_NCLBUTTONUP:
   case WM_NCRBUTTONDOWN:
   case WM_NCRBUTTONUP:
	 break;
   case WM_PALETTECHANGED:
   case WM_PALETTEISCHANGING:
	 return 0;
   case WM_KILLFOCUS:
	 if (!GLPREF_windowed)
		 ShowWindow(g_hWnd, SW_SHOWMINNOACTIVE);//this minimizes the game after you alt-tab out.
	 break;
   case WM_ACTIVATE:
	 wgl_game_activate((!(LOWORD(wParam) == WA_INACTIVE)),(BOOL) HIWORD(wParam);
	 break;
   case WM_ACTIVATEAPP:
//     Win32_Key_Hook(wParam);
// DPH: This doesn't work... no idea why not...
	 break;
   case WM_DESTROY:
         finiObjects();
	 PostQuitMessage(0);
	 break;
   default:
	 return DefWindowProc(hWnd,message,wParam,lParam);
  }
  return 1;
}
Beispiel #14
0
int kbd_test_scan(unsigned short ass)
{
	int ipc_status, r, exit = 0, flag = 0;
	unsigned long irq_set, data;
	message msg;

	irq_set = subscribe_int(KB_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &kb_id);
	if (irq_set == -1) return -1;  // check if subscribe_int failed

	do
	{
		r = driver_receive(ANY, &msg, &ipc_status);
		if (r != 0)
		{
			printf("driver_receive failed with: %d", r);
			continue;
		}

		if (is_ipc_notify(ipc_status))
		{
			switch (_ENDPOINT_P(msg.m_source))
			{
			case HARDWARE:
				if (msg.NOTIFY_ARG & irq_set)
				{
					data = keyboard_handler(ass);
					flag = print_scancodes(data, flag);
					if (data == ESC)
					{
						printf("Done\n");
						exit = 1;
					}
				}
				break;
			default:
				break;
			}
		}
	} while (exit == 0);

	unsubscribe_int(&kb_id);

	return 0;
}
Beispiel #15
0
Datei: key.c Projekt: paud/d2x-xl
// Returns the number of seconds this key has been down since last call.
fix KeyDownTime(KEYCODE kcKey)
{
	ULONG timeElapsed;
		keyboard_handler();
	if ((kcKey<0) || (kcKey>127)) return 0;

	if (keyd_pressed [kcKey])
	{
		fix timeNow = TimerGetFixedSeconds ();
		timeElapsed = timeNow - g_rgtimeDown [kcKey];
		g_rgtimeDown [kcKey] = timeNow;
	}
	else
	{
		timeElapsed = g_rgtimeElapsed [kcKey];
		g_rgtimeElapsed [kcKey] = 0;
	}

	return timeElapsed;;
}
Beispiel #16
0
Datei: init.c Projekt: btb/d2x
long PASCAL DescentWndProc(HWND hWnd,UINT message,
						   WPARAM wParam,LPARAM lParam )
{
  switch(message)
  {

   case WM_KEYDOWN:
   case WM_KEYUP:
	if (WMKey_Handler_Ready) {
//      key_wparam=wParam; key_lparam=lParam; key_msg=message;
	  keyboard_handler();
	}
	break;
   case WM_MOUSEMOVE:
   case WM_LBUTTONDOWN:
   case WM_LBUTTONUP:
   case WM_RBUTTONDOWN:
   case WM_RBUTTONUP:
   case WM_NCMOUSEMOVE:
   case WM_NCLBUTTONDOWN:
   case WM_NCLBUTTONUP:
   case WM_NCRBUTTONDOWN:
   case WM_NCRBUTTONUP:
	 break;
   case WM_PALETTECHANGED:
   case WM_PALETTEISCHANGING:
   return 0;
   case WM_ACTIVATEAPP:
//     Win32_Key_Hook(wParam);
// DPH: This doesn't work... no idea why not...
	 break;
   case WM_DESTROY:
	 finiObjects();
	 PostQuitMessage(0);
	 break;
  }
  return DefWindowProc(hWnd,message,wParam,lParam);
}
Beispiel #17
0
int main(void) {

    set_up_planets();

    /* Create a pixmap font from a TrueType file. */
    font = ftglCreatePixmapFont("FreeSans.ttf");
    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(screen_x, screen_y, 0, SDL_OPENGL|SDL_DOUBLEBUF|SDL_RESIZABLE);
    SDL_WM_SetCaption("Simple Window", "Simple Window");
    atexit(SDL_Quit);

    for(;;) {
        SDL_Event event;
        while(SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                return 0;
            }

            if (event.type == SDL_VIDEORESIZE) {
                screen = SDL_SetVideoMode(event.resize.w,event.resize.h, 0, SDL_OPENGL|SDL_DOUBLEBUF|SDL_RESIZABLE);
                glViewport(0,0,event.resize.w,event.resize.h);
                screen_x=event.resize.w;
                screen_y=event.resize.h;
            }

            if (event.type == SDL_MOUSEBUTTONDOWN) {
                mouse_handler( event.button.x, event.button.y );
            }

            if (event.type == SDL_KEYDOWN) {
                keyboard_handler( event.key.keysym.sym );
            }
        }
        draw();
    }
    return 0;
}
Beispiel #18
0
Datei: key.c Projekt: paud/d2x-xl
KEYCODE key_peekkey ()
{
		keyboard_handler();
	return 0;
}
Beispiel #19
0
void keyboard_handlerx(myint code, myint press)
{
	keyboard_handler(SVGALibToScancode(code), press);
}