static void Init() { KeyboardInit(); MouseInit(0, 0, WIDTH - 1, HEIGHT - 1); CopListActivate(cp); custom->dmacon = DMAF_SETCLR | DMAF_RASTER | DMAF_SPRITE; }
void OutboundThread(void) { WINDOW *local ; /* INITIALIZATION: Paint the local window. Create a */ /* mailbox object to receive keystroke codes from the */ /* keyboard ISR. Initialize the keyboard hardware. */ /* Point interrupt vector 33 at the keyboard ISR. */ /* Unmask the IRQ line in the 8259 PIC. */ local = WindowCreate("Local", 0, 10, 0, 79) ; KeyboardInit() ; /* SerialInit have a guard inside to prevent multiple initializations */ SerialInit() ; for (;;) { BYTE8 err, scan_code ; char ascii ; /* Suspend this thread (let it "sleep") until a */ /* keyboard interrupt posts something to our */ /* mailbox. But first position the cursor */ /* at the next character position as a prompt. */ WindowSelect(local) ; scan_code = ((unsigned) OSQPend(kybd_queue, 0, &err)) & 0xFF ; if (scan_code & 0x80) continue ; /* Key up */ /* The keyboard ISR just woke us up. scan_code */ /* is the keystroke that occurred. First check */ /* to see if it simply changes state, like caps */ /* lock, shift, ctrl, or alt. Then convert the */ /* scancode to ascii using the current state. */ if (SetsKybdState(scan_code)) continue ; ascii = ScanCode2Ascii(scan_code) & 0xFF ; if (!isprint(ascii) && !iscntrl(ascii)) continue ; /* Display the character in the local window. */ WindowPutChar(local, ascii) ; SendPacket(1, &ascii, 1) ; if (ascii == '\r') { static char linefeed = '\n' ; WindowPutChar(local, linefeed) ; SendPacket(1, &linefeed, 1) ; } } }
static void cyg_hal_plf_screen_init_channel(void* __ch_data) { KeyboardInit(); XPos = 0; YPos = 0; ClearScreen(); MoveCursor(); }
int main (){ unsigned int iMainLoopCtr; KeyboardInit(); Led_Init(); DetectorInit(); Timer1Interrupts_Init(250000,&Automat); while(1){ iMainLoopCtr++; } }
int main(int argc, char *argv[]) { MiscAppInit(); if (SDL_Init(SDL_INIT_VIDEO) < 0) { MiscTrace("Couldn't initialize SDL: %s\n",SDL_GetError()); return 1; } MainFrameSetTitle(SSS_TITLE); s_screen = CanvasInit(); MouseInit(); KeyboardInit(); s_screenArea.x = 0; s_screenArea.y = 0; s_screenArea.w = WINDOW_WIDTH; s_screenArea.h = WINDOW_HEIGHT; s_done = 0; #if 0 while (1) { if(MainFrameGetMsg()) { break; } { int k = 0; int width = WINDOW_WIDTH; int height = WINDOW_HEIGHT; CanvasLock(); CanvasSetColor(CanvasRGB(0xff, 0, 0)); CanvasMoveTo(0, 0); CanvasLineTo(width * 2, height * 2); for (k = height / 4; k < height / 2; k++) { CanvasSetPixel(width / 2, k, CanvasRGB(0xff, 0, 0xff)); } CanvasDrawLine(-width, height * 2, width * 2, -height, CanvasRGB(0, 0, 0xff)); CanvasUnlock(); MainFrameRefresh(); } } #else ScriptRun(); #endif KeyboardRelease(); MouseRelease(); CanvasRelease(); SDL_Quit(); return 0; }
void main(void) { HardwareInit(); UartInit(STDIO,115200,DEFAULT_LINE_CTRL); heap_size=free_heap(); #if defined DEBUG test_pattern(); #endif UartPrint(STDOUT,"video initialization\r"); VideoInit(); delay_ms(500); UartPrint(STDOUT,"keyboard initialization: "); if (KeyboardInit()){ UartPrint(STDOUT,"OK\r"); comm_channel=LOCAL_CON; }else{ UartPrint(STDOUT,"keyboard error\r"); UartPrint(STDOUT,"Using uart2 channel.\r"); comm_channel=SERIAL_CON; } text_coord_t cpos; UartPrint(STDOUT,"SD initialization: "); if (!mount(0)){ UartPrint(STDOUT,"Failed\r"); SDCardReady=FALSE; }else{ UartPrint(STDOUT,"succeeded\r"); SDCardReady=TRUE; } UartPrint(STDOUT,"SRAM initialization\r"); sram_init(); UartPrint(STDOUT,"sound initialization.\r"); tune((unsigned int*)&e3k[0]); UartPrint(STDOUT,"initialization completed.\r"); set_cursor(CR_BLOCK); // sauvegare video_buffer dans SRAM clear_screen(); #if defined _DEBUG_ graphics_test(); set_curpos(0,LINE_PER_SCREEN-1); print(comm_channel,"test"); sram_write_block(100000,video_bmp,BMP_SIZE); delay_ms(1000); clear_screen(); delay_ms(1000); sram_read_block(100000,video_bmp,BMP_SIZE); delay_ms(1000); clear_screen(); // print(comm_channel,"heap_size: "); // print_int(comm_channel,heap_size,0); // crlf(); #endif shell(); } // main()
//---------------------------------------------------------------------------------------------------------------------------- // // ÄÚºËÖ÷Èë¿Ú // //---------------------------------------------------------------------------------------------------------------------------- void k_main(void) { unsigned long base_mm; PageDirInit(); KernelGraphicInit(); ConsoleInit(0,0xFFFFFF); ConsolePrintf("Enable The Page"); ConsolePrintOK(); ConsoleMsg(" The Kernel Page Dir at %08x The Page0 at %08x\n",PG_DIR_ADDR,PG_TABLE_ADDR); ConsoleMsg(" The VESA Mapping Page at %08x\n",VESA_PTE); ConsolePrintf("Load The boot Infomation"); ConsolePrintOK(); GetGrubVersion(GrubBootInfo); GetGrubBoot(GrubBootInfo,(int*)&BootParameters.bp_bootdev); GetGrubMemInfo(GrubBootInfo,&base_mm,&BootParameters.bp_ramsize); GetGrubAPM(GrubBootInfo); BootMemInit(); KnlMesQueInit(); PageManagerInit(BootParameters.bp_ramsize); VMemInit(BootParameters.bp_ramsize,0xC0000000-BootParameters.bp_ramsize); TrapInit(); TimerInit(); KeyboardInit(); MouseInit(); //FloppyInit(); HardDiskInit(); //Fat12_Init(); Fat32_Init(); ProcessInit(); SystemCallInit(); __asm__("sti"); ExecInitProc("SHELLER "); SetSwitching(0); while(1); }
int main (){ unsigned int iMainLoopCtr; KeyboardInit(); Led_Init(); DetectorInit(); sServo.eState=CALLIB; Timer1Interrupts_Init(60000,&Automat); while(1){ iMainLoopCtr++; switch(eKeyboard_Read()){ case BUTTON_1:sServo.eState=CALLIB; break; case BUTTON_2:sServo.uiDesiredPosition=50; break; case BUTTON_3:sServo.uiDesiredPosition=100; break; case BUTTON_4:sServo.uiDesiredPosition=150; break; default: break; } } }
void main () { every_gpio_set_dir (LED_PORT, LED_PIN, OUTPUT); every_gpio_write (LED_PORT, LED_PIN, false); every_gpio_set_dir (KEY_PORT, KEY_PIN, INPUT); EVERY_GPIO_SET_PULL (KEY_PORT, KEY_PIN, PULL_UP); buttonWasDown = false; downKey = 0; counter = -1; KeyboardInit (&usbDeviceDefinition, &usbDevice, &hidBehaviour, inBuffer, outBuffer, &idleValue, ¤tProtocol, inReportHandler, outReportHandler); USB_SoftConnect (&usbDevice); SYSCON_StartSystick (71999); // 1KHz }
void xtk_init(void) { KeyboardInit(); }
SDLKeyboard::SDLKeyboard(void) { KeyboardInit(); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; switch(message) { case WM_COMMAND: { int wmId = LOWORD(wParam); /* int wmEvent = HIWORD(wParam); */ switch (wmId) { default: return DefWindowProc(hWnd, message, wParam, lParam); } } break; case WM_CREATE: s_hAppWnd = hWnd; SetWindowPos(hWnd, NULL, 0, 0, -1, -1, SWP_NOSIZE); s_hCanvas = CanvasInit(hWnd); MouseInit(); KeyboardInit(); break; case WM_DESTROY: KeyboardRelease(); MouseRelease(); CanvasRelease(); PostQuitMessage(0); break; case WM_PAINT: { PAINTSTRUCT ps; hdc = BeginPaint(hWnd, &ps); BitBlt(hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, s_hCanvas, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); EndPaint(hWnd, &ps); } break; case WM_KEYDOWN: { switch(wParam) { case VK_CONTROL: break; case VK_ESCAPE: break; } } break; case WM_CHAR: { int Key = (UINT)wParam; MiscTrace("WM_CHAR: %d\n", Key); KeyboardChar(Key); } break; case WM_MOUSEMOVE: { POINT point; point.x = LOWORD(lParam); point.y = HIWORD(lParam); //MiscTrace("WM_MOUSEMOVE: %d, %d\n", point.x, point.y); MouseMove(point.x, point.y); } break; case WM_LBUTTONDOWN: { POINT point; point.x = LOWORD(lParam); point.y = HIWORD(lParam); MiscTrace("WM_LBUTTONDOWN: %d, %d\n", point.x, point.y); MouseLButtonDown(point.x, point.y); } break; case WM_LBUTTONUP: { POINT point; point.x = LOWORD(lParam); point.y = HIWORD(lParam); MiscTrace("WM_LBUTTONUP: %d, %d\n", point.x, point.y); MouseLButtonUp(point.x, point.y); } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput) { /* Allocate memory for the 16-bit address space */ BaseAddress = HeapAlloc(GetProcessHeap(), /*HEAP_ZERO_MEMORY*/ 0, MAX_ADDRESS); if (BaseAddress == NULL) { wprintf(L"FATAL: Failed to allocate VDM memory.\n"); return FALSE; } /* * For diagnostics purposes, we fill the memory with INT 0x03 codes * so that if a program wants to execute random code in memory, we can * retrieve the exact CS:IP where the problem happens. */ RtlFillMemory(BaseAddress, MAX_ADDRESS, 0xCC); /* Initialize I/O ports */ /* Initialize RAM */ /* Initialize the CPU */ /* Initialize the internal clock */ if (!ClockInitialize()) { wprintf(L"FATAL: Failed to initialize the clock\n"); return FALSE; } /* Initialize the CPU */ CpuInitialize(); // Fast486Initialize(&EmulatorContext, // EmulatorReadMemory, // EmulatorWriteMemory, // EmulatorReadIo, // EmulatorWriteIo, // NULL, // EmulatorBiosOperation, // EmulatorIntAcknowledge, // NULL /* TODO: Use a TLB */); /* Initialize DMA */ /* Initialize the PIC, the PIT, the CMOS and the PC Speaker */ PicInitialize(); PitInitialize(); CmosInitialize(); SpeakerInitialize(); /* Set output functions */ PitSetOutFunction(0, NULL, PitChan0Out); PitSetOutFunction(1, NULL, PitChan1Out); PitSetOutFunction(2, NULL, PitChan2Out); /* Register the I/O Ports */ RegisterIoPort(CONTROL_SYSTEM_PORT61H, Port61hRead, Port61hWrite); /* Set the console input mode */ // FIXME: Activate ENABLE_WINDOW_INPUT when we will want to perform actions // upon console window events (screen buffer resize, ...). SetConsoleMode(ConsoleInput, ENABLE_PROCESSED_INPUT /* | ENABLE_WINDOW_INPUT */); // SetConsoleMode(ConsoleOutput, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); /**/EnableExtraHardware(ConsoleInput);/**/ /* Initialize the PS/2 port */ PS2Initialize(); /* Initialize the keyboard and mouse and connect them to their PS/2 ports */ KeyboardInit(0); MouseInit(1); /**************** ATTACH INPUT WITH CONSOLE *****************/ /* Start the input thread */ InputThread = CreateThread(NULL, 0, &PumpConsoleInput, ConsoleInput, 0, NULL); if (InputThread == NULL) { DisplayMessage(L"Failed to create the console input thread."); return FALSE; } /************************************************************/ /* Initialize the VGA */ if (!VgaInitialize(ConsoleOutput)) { DisplayMessage(L"Failed to initialize VGA support."); return FALSE; } /* Initialize the software callback system and register the emulator BOPs */ InitializeInt32(); RegisterBop(BOP_DEBUGGER , EmulatorDebugBreakBop); // RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop); /* Initialize VDD support */ VDDSupInitialize(); return TRUE; }
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput) { USHORT i; /* Initialize memory */ if (!MemInitialize()) { wprintf(L"Memory initialization failed.\n"); return FALSE; } /* Initialize I/O ports */ /* Initialize RAM */ /* Initialize the CPU */ /* Initialize the internal clock */ if (!ClockInitialize()) { wprintf(L"FATAL: Failed to initialize the clock\n"); EmulatorCleanup(); return FALSE; } /* Initialize the CPU */ CpuInitialize(); /* Initialize DMA */ DmaInitialize(); /* Initialize PIC, PIT, CMOS, PC Speaker and PS/2 */ PicInitialize(); PitInitialize(); PitSetOutFunction(0, NULL, PitChan0Out); PitSetOutFunction(1, NULL, PitChan1Out); PitSetOutFunction(2, NULL, PitChan2Out); CmosInitialize(); SpeakerInitialize(); PpiInitialize(); PS2Initialize(); /* Initialize the keyboard and mouse and connect them to their PS/2 ports */ KeyboardInit(0); MouseInit(1); /**************** ATTACH INPUT WITH CONSOLE *****************/ /* Create the task event */ VdmTaskEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ASSERT(VdmTaskEvent != NULL); /* Start the input thread */ InputThread = CreateThread(NULL, 0, &ConsoleEventThread, ConsoleInput, 0, NULL); if (InputThread == NULL) { wprintf(L"FATAL: Failed to create the console input thread.\n"); EmulatorCleanup(); return FALSE; } ResumeEventThread(); /************************************************************/ /* Initialize the VGA */ if (!VgaInitialize(ConsoleOutput)) { wprintf(L"FATAL: Failed to initialize VGA support.\n"); EmulatorCleanup(); return FALSE; } /* Initialize the disk controller */ if (!DiskCtrlInitialize()) { wprintf(L"FATAL: Failed to completely initialize the disk controller.\n"); EmulatorCleanup(); return FALSE; } /* Mount the available floppy disks */ for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i) { if (GlobalSettings.FloppyDisks[i].Length != 0 && GlobalSettings.FloppyDisks[i].Buffer && GlobalSettings.FloppyDisks[i].Buffer != '\0') { if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE)) { DPRINT1("Failed to mount floppy disk file '%wZ'.\n", &GlobalSettings.FloppyDisks[i]); RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[i]); RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[i], NULL, 0); } } } /* * Mount the available hard disks. Contrary to floppies, failing * mounting a hard disk is considered as an unrecoverable error. */ for (i = 0; i < ARRAYSIZE(GlobalSettings.HardDisks); ++i) { if (GlobalSettings.HardDisks[i].Length != 0 && GlobalSettings.HardDisks[i].Buffer && GlobalSettings.HardDisks[i].Buffer != L'\0') { if (!MountDisk(HARD_DISK, i, GlobalSettings.HardDisks[i].Buffer, FALSE)) { wprintf(L"FATAL: Failed to mount hard disk file '%wZ'.\n", &GlobalSettings.HardDisks[i]); EmulatorCleanup(); return FALSE; } } } /* Refresh the menu state */ UpdateVdmMenuDisks(); /* Initialize the software callback system and register the emulator BOPs */ InitializeInt32(); RegisterBop(BOP_DEBUGGER , EmulatorDebugBreakBop); // RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop); /* Initialize VDD support */ VDDSupInitialize(); return TRUE; }