Chapter 14 DirectInput의 전말

Slides:



Advertisements
Similar presentations
1 Interaction Devices CIS 487/587 Bruce R. Maxim UM-Dearborn.
Advertisements

DirectInput® 9.0 C. Shane Evans / Bernard George Program Manager DirectX Microsoft ® Corporation.
I/O means Input and Output. One way: use standard input and standard output. To read in data, use scanf() (or a few other functions) To write out data,
Windows Basics: The Mouse. The Mouse Before you can explore the Desktop and Taskbar, you must know how to use your mouse. Your mouse is a pointing device.
Computer Graphics1 Windows NT Graphics Interface.
Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
CSC 270 – Survey of Programming Languages C Lecture 6 – Pointers and Dynamic Arrays Modified from Dr. Siegfried.
CS 450 Module R1. R1 Introduction In Module R1, you will implement a user interface (command handler). There are a couple of options: ▫Command Line: interface.
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
Pointer, malloc and realloc 1. Name entered was 6 char, not enough space to put null terminator 2 Array of char.
Intro to COM What is it and how do I use it?. Objectives Teach the fundamentals of COM. Understand the reason for using it. Learn to make a simple in-process.
Input from Controller and Keyboard in XNA Game Studio Express Game Design Experience Professor Jim Whitehead February 12, 2008 Creative Commons Attribution.
Data Types in the Kernel Sarah Diesburg COP 5641.
1 DirectX CIS 487/587 Bruce R. Maxim UM-Dearborn.
Actors, Cameras, Action ! Scenes, Actors, Cameras 3D Transformations
 Universal Serial Bus 컴퓨터와 주변기기를 연결하는 데 쓰이는 입출력 표준 가운데 하나 (USB 1.0, 1.1, 2.0, 3.0 등 )
DVR HD-800H H 채널 실시간 HD-SDI Stand Alone 타입 DVR 제품 소개 제품 소개 8 채널 HD-SDI stand-alone 타입 DVR (H.264 와 JPEG 듀얼 코델 지원 ) SMPTE 292M 표준 규격에 따른 HD-SDI 영상.
CHAPTER 3 The Component Object Model and DirectX © 2008 Cengage Learning EMEA.
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
9/20/20151 Interaction Devices CIS 577 Bruce R. Maxim UM-Dearborn.
Done by Jash ALL ABOUT A COMPUTER. WHAT ARE YOU GOING TO LEARN? You are going to learn about a computer. By the end of this slide show you will know basic.
1 Data Structures A Data Structure is an arrangement of data in memory. A Data Structure is an arrangement of data in memory.  The purpose is to map real.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
CSE3AGT Paul Taylor Stupid Conventions! l = Long p = Pointer h = handle g = global wnd = Windows WM = Windows Message d3d = Direct3D hr = HRESULT.
CHAPTER 5 Input Control © 2008 Cengage Learning EMEA.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
64 CONTROLLER 64 CONTROLLER AARON RIDENOUR, RYAN WOOSTER, ALEX JAECKEL.
Renesas Technology America, Inc. Flash!. CPU Rewrite CPU-rewrite is a term that refers to an Renesas MCU’s ability to erase/program its own internal Flash.
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 4 Pointers and Dynamic Arrays Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
IT CookBook, 초보자의 첫 번째 엑셀 2007 엑셀 2007 기초. 2 이 장에서 배울 내용  Section 01 엑셀 2007 기본 기능 익히기  Section 02 데이터 입력 및 편집  Section 03 워크시트 편집 및 관리  Section 04.
Chapter9_10 Circuit & Packet Switching
Chapter 13 DirectSound 로 잡음 만들기. 2 History of Sound Programming Sound programming always gets put off until the end DOS –Third party sound libraries:
Youn-Hee Han, In-Seok Kang {yhhan, Laboratory of Intelligent Networks Advanced Technology Research Center Korea University of Technology.
컴퓨터 전자음악 입문 5 교시 Tutorials 1 가상악기 더하기 & Opening and Playing.
5-6 Memory Ref. Instruction
Interacting with your Computer Chapter 2 Learning Objectives Identify five key groups on standard computer keyboard Name six special purpose keys.
First IEC 1 High-level Data Link Control  비트 중심 Protocol  Point-to-Point 및 Multi-Point Link 지원  Half Duplex 와 full Duplex 모두 지원  Flow Control Sliding.
line.net/ okpop.com/bar elythereflashin dex.html.
Haptic & Direct User Input with DirectInput ® 8 API Graphics Lab. Korea Univ.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Chapter 11: Data Files and File Processing Files and streams Creating a sequential access file Reading data from a sequential access file Using fgetc()
Chapter 7 : File Processing1 File-Oriented Input & Output CHAPTER 7.
1 CHAPTER6 CHAPTER 6. Objectives: You’ll learn about;  Introduction  Files and streams  Creating a sequential access file  Reading data from a sequential.
University of New Mexico
GAM666 – Introduction To Game Programming ● DirectInput is the part of DirectX for managing input devices, such as keyboard, mouse and joystick ● Supports.
영상 획득 영상 저장 카메라 파라메터 커스텀 이미지
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
(Icommand & Processing). NXT The NXT is the brain of a MINDSTORMS® robot. It's an intelligent, computer- controlled LEGO® brick that lets a MINDSTORMS.
Chapter 18 Virtual Circuit Switching : Frame Relay and ATM
The Spartan®-3E FPGA Starter Kit board. A computer mouse is designed mainly to detect two-dimensional motion on a surface. Its internal circuit measures.
HTC Android Projector User Guide v Agenda Setup and Demo Environment Launch Projector Installer Launch Projector Application Q&A.
3461 SR Compatibility SR Compatibility  S = Stimulus, the input device that is being manipulated or stimulated  R = Response, the visual, aural,
방명록 제작. 목차  기본 레이아웃  DB 구조  방명록 구조  코드 설명  화면 설명.
User Interface Programming in C#: Basics and Events Chris North CS 3724: HCI.
Chapter 16 GPDUMB Engine Part II. 2 GPDUMB2 Engine.
Indoor Location Inference based on mobile network -Term project proposal – -1 조 권요셉, 김태욱 -5 조 고우균, 김진우.
Graphics OpenGL OpenGL Introduction 컴퓨터 그래픽스 김 창 헌.
Java Programming Language (3) - Input/Output Stream –
ARDUINO 실습 과제 보 고서. PWM 은 아날로그 출력이라는 함수를 사용하게 되는데 이 출력에는 3, 5, 6, 9, 10, 11 번의 핀만 사용 가능. ( 숫자 옆 에 ~ 표시 )
실험 구성 (DC모터 속도제어) -Matlab xPC Target 이용
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
CS 134 Alternate Inputs.
CHAPTER 5 Input Control © 2008 Cengage Learning EMEA.
Programming Input Devices
Windows Programming Lecture 09.
Game Programming (User Input)
IoT Programming the Particle Photon.
Presentation transcript:

Chapter 14 DirectInput의 전말

이 장에서는 - DirectDinput에 대해서 파악하기 - 키보드 장치 생성하고 사용하기 - 마우스 사용하기 - 조이스틱 설정하기

DirectX 가 지원하는 입력장치 키보드: 표준 QWERTY 키보드 마우스: 2버튼 그리고 3버튼 마우스 조이스틱과 비행 요크: 아날로그와 디지털 조이스틱/비행-요크는 6만큼의 자유도와 최대 32개의 버튼을 지원한다. 운전대 컨트롤: 아날로그 디지털 운전 시뮬레이션용 패들: 다양한 회전 장치 포스-피드백(force-feedback) 장치: 기계적인 액튜에이터(actuator)가 있어서, 컴퓨터가 진동시키거나 모양을 바꿀 수 있는 조이스틱 또는 다른 장치들. 가상현실 헤드기어 트래킹 시스템(virtual reality headgear tracking system): 가상현실 헤드기어의 위치와 회전을 지원. (착용자의 머리의 상태를 전송.)

DirectInput 인터페이스의 구조

DirectInput의 사용 DINPUT.LIB, DINPUT8.LIB, DINPUT.H

DirectInput 사용 순서 1. DirectInput8Create()으로 주요 DirectInput 객체를 생성한다. 2. CreateDevicde()으로 하나 혹은 그 이상의 입력 장치를 생성한다. 각각에 대해서 GUID가 필요하다. 따라서, DirectInput이 모든 입력 장치를 나열하도록 요청할 수도 있다. 3. SetCooperativeLevel()으로, 각 장치의 협력 수준을 설정한다. 4. SetDataFormat()으로 각장치의 데이터 형식을 설정하고, SetProperty()로 특별한 속성들을 설정한다. 5. Acquire()로 각 입력장치를 획득한다. 이 단계는 각 입력 장치를 주요 DirectInputDevice8에 추가한다. 6. GetDeviceState()로 입력을 받는다. 수동 폴링이 필요한 장치는 Poll()을 호출한다

DirectInput 생성 LPDIRECTINPUT8 lpdi; // main DirectInput object HRESULT WINAPI DirectInput8Create( HINSTANCE hinst, // instance of application DWORD dwVersion, // backward version compatibility REFIID riidltf, // interface id being requested LPVOID* ppvOut, // pointer to interface LPUNKNOWN punkOuter); // com stuff, null #include “DINPUT.H” LPDIRECTINPUT8 lpdi; // pointer to DirectInput object // create DirectInput object if (DirectInput8Create(main_instance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&lpdi,NULL)!=DI_OK) { /* error */ }

키보드 입력 1. 키보드 장치를 생성한다. 2. 키보드의 협력 수준을 설정한다. 3. 키보드 장치를 위한 데이터 형식을 설정한다. 4. 키보드 장치를 얻어온다(aquire).

여러 개의 device들이 하나의 DirectInput device를 구성할 수도 있다.

DirectInput Object (객체) 하나의 device에 여러 개의 object가 존재 가능

CreateDevice Function HRESULT CreateDevice( REFGUID rguid, // GUID of device to create LPDIRECTINPUTDEVICE *lplpDIDev,// ptr to device interface LPUNKNOWN pUnkOuter); // always NULL GUID_SysKeyboard: 기본 시스템 키보드 GUID_SysMouse: 기본 시스템 마우스 #define INITGUID 와 OBJBASE.H 필요

CreateDevice Example #define INITGUID // needed to get the GUIDS in here #include <OBJBASE.H> // COM stuff #include “DINPUT.H” // you need this! LPDIRECTINPUT8 lpdi; // main DirectInput object // create DirectInput object if (DirectInput8Create(main_instance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&lpdi,NULL)!=DI_OK) { /* error */ } LPDIRECTINPUTDEVICE8 lpdikey; // the keyboard device // create keyboard device if (lpdi->CreateDevice(GUID_SysKeyboard, &lpdikey,NULL)!=DI_OK) { /* error */ }

협력 수준의 설정 Value Meaning DISCL_BACKGROUND Your application can use a DirectInput device whether the application is idling in the background or active in the foreground. DISCL_FOREGROUND The application requires foreground access. If foreground access is granted, the device is automatically unacquired when the associated window moves to the background. DISCL_EXCLUSIVE After you acquire the device, no other application can request exclusive access to it; however, other applications can still request nonexclusive access. DISCL_NONEXCLUSIVE The application requires nonexclusive access. Access to the device does not interfere with other applications that are accessing the same device.

협력 수준의 설정 DISCL_BACKGROUND | DISCL_NONEXCLISIVE 를 협력 설정으로 사용해야 한다. if (lpdikey->SetCooperativeLevel(main_window_handle, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)!=DI_OK) { /* error */ }

데이터 형식의 설정 Custom-made Data formats c_dfDIKeyboard c_dfDIMouse DIDATAFORMAT df; SetDataFormat(&df); // ptr to data format structure Custom-made Data formats c_dfDIKeyboard c_dfDIMouse c_dfDIJoystick c_dfDIJoystick2 : for force feedback device if (FAILED(lpdikey->SetDataFormat(&c_dfDIKeyboard))) { … }

Acquire Device를 입력 스트림에 추가하고 데이터를 입수할 수 있도록 만드는 것이다. if (FAILED(lpdikey->Acquire())) { … }

Keyboard 읽어오기 키보드 상태는 256 BYTE 요소의 배열 int ship_x = 100, ship_y = 100; // initial ship position // storage for the keyboard data UCHAR keystate[256]; // in your main loop, you would do this if (lpdikey->GetDeviceState(256, keystate)!=DI_OK) { /* something’s amiss */ } // test whether the player is “moving” the ship if (keystate[DIK_RIGHT] & 0x80) ship_x++; if (keystate[DIK_LEFT] & 0x80) ship_x--; if (keystate[DIK_DOWN] & 0x80) ship_y++; if (keystate[DIK_UP] & 0x80) ship_y--; 키보드 상태는 256 BYTE 요소의 배열

DirectInput 키보드 가상 키 코드 DIK_ESCAPE ESC키 DIK_0 - DIK_9 메인 키보드의 0-9 DIK_A - DIK_Z A-Z DIK_RETURN 메인 키보드의 엔터키 DIK_LCONTROL 왼쪽 Ctrl키 DIK_RCONTROL 오른쪽 Ctrl키 DIK_SPACE 스페이스바 DIK_F1 - DIK_F12 펑션키 F1-F12 DIK_UP (위)화살표 DIK_DOWN (아래)화살표 DIK_LEFT (왼쪽)화살표 DIK_RIGHT (오른쪽)화살표 DIK_PRIOR Page Up DIK_NEXT Page Down

Unacquire lpdikey->Unacquire( ) Temporarily stop to get the device input By Acquire( ) the input can be reactivated.

DEMO 14_1

마우스 입력 LPDIRECTINPUTDEVICE8 lpdimouse; // the mouse device // create mouse device if (lpdi->CreateDevice(GUID_SysMouse, &lpdimouse,NULL)!=DI_OK) { } if (lpdimouse->SetCooperativeLevel(main_window_handle, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)!=DI_OK) { } // set data format, notice the use of the address operator if (lpdikey->SetDataFormat(&c_dfDIMouse)!=DI_OK) { /* error */ } // acquire the mouse if (lpdimouse->Acquire()!=DI_OK) { /* error */ }

Mouse – Relative Mode

마우스 입력 typedef struct { LONG lX; // x-axis of mouse LONG lY; // y-axis of mouse LONG lZ; // z-axis of mouse, typically a wheel or dial BYTE rgbButtons[4]; // buttons of the mouse, high bit means pressed } DIMOUSESTATE, *LPDIMOUSESTATE; // this holds the mouse data DIMOUSESTATE mouse_state; // get mouse data if (lpdimouse->GetDeviceState(sizeof(DIMOUSESTATE) (LPVOID)&mouse_state)!=DI_OK) { /* problem */ } // test left button if (mouse_state.rgbButtons[0]) { /* do whatever */ } else if (mouse_state.rgbButtons[1]) { /* do whatever */ }

마우스 입력 // is the mouse moving right if (mouse_state.lX > 0 ) else // check for left motion if (mouse_state.lX < 0) { /* left */ } // is the mouse moving down if (mouse_state.lY > 0 ) { /* down *} else // check for upward motion if (mouse_state.lY < 0) { /* up */ }

DEMO14_2