https://imsoftpro.tistory.com/67
[C#/WPF] Joystick 입력 데이터 디스플레이 [MVVM]
WPF 기반에서 조이스틱 입력값을 화면에 실시간으로 디스플레이 1. 참조 파일 설정 - Microsoft.DirectX- Microsoft.DirectX.DirectInput 위 2가지 dll 파일 참조가 필요하다. 참조파일 위치는 아래와 같다. (C:\\Win
imsoftpro.tistory.com
https://developer-talk.tistory.com/190
[C#]문자열 나누기(Split), 자르기(Substring)
문자열을 분리하거나 또는 잘라야 하는 경우 Split() 메서드와 Substring() 메서드를 사용할 수 있습니다. Split() 메서드는 특정 문자열을 기준으로 문자열을 구분하며, SubString() 메서드는 지정된 위치
developer-talk.tistory.com
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=einsbon&logNo=221086003205
https://www.codeproject.com/Articles/839229/OoB-Moving-Webcam-with-Joystick-and-Servos-Arduino
https://github.com/sharpdx/SharpDX/tree/master/Source/SharpDX.DirectInput
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using SharpDX.DirectInput;
namespace EnumDevicesApp
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
//[STAThread]
static void Main()
{
MainForJoystick();
}
static void MainForJoystick()
{
// <1> 기기 검색
// Initialize DirectInput
var directInput = new DirectInput();
// Find a Joystick Guid
var joystickGuid = Guid.Empty;
foreach (var deviceInstance in directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices))
joystickGuid = deviceInstance.InstanceGuid;//디바이스 인스턴스를 넣음
// If Gamepad not found, look for a Joystick
if (joystickGuid == Guid.Empty)//Guid.Empty는 인스턴스가 안들어 있는 것이다 .
foreach (var deviceInstance in directInput.GetDevices(DeviceType.Joystick, DeviceEnumerationFlags.AllDevices))
joystickGuid = deviceInstance.InstanceGuid;// 다시 인스턴스 넣어라
//게임패드 먼저 검색후, 조이 스틱 탐색
// If Joystick not found, throws an error
if (joystickGuid == Guid.Empty)
{
Console.WriteLine("No joystick/Gamepad found.");
Console.ReadKey();//?
Environment.Exit(1);//아무거나 입력하면 강제 종료된다
}
// <2> 조이스틱 선언
// Instantiate the joystick
var joystick = new Joystick(directInput, joystickGuid); //조이스틱 객체 선언
Console.WriteLine("Found Joystick/Gamepad with GUID: {0}", joystickGuid);
// Query all suported ForceFeedback effects
var allEffects = joystick.GetEffects();
foreach (var effectInfo in allEffects)
Console.WriteLine("Effect available {0}", effectInfo.Name);
// Set BufferSize in order to use buffered data.
joystick.Properties.BufferSize = 128;
// Acquire the joystick
joystick.Acquire();
// Poll events from joystick
while (true)
{
joystick.Poll();//조이스틱 조작할 시에
var datas = joystick.GetBufferedData();
foreach (var state in datas)
Console.WriteLine(state);
}
}
}
}
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Diagnostics;
using SharpDX.DirectInput;
namespace EnumDevicesApp
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
//[STAThread]
static void Main()
{
MainForJoystick();
}
static void MainForJoystick()
{
// <1> 기기 검색
// Initialize DirectInput
var directInput = new DirectInput();
// Find a Joystick Guid
var joystickGuid = Guid.Empty;
foreach (var deviceInstance in directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices))
joystickGuid = deviceInstance.InstanceGuid;//디바이스 인스턴스를 넣음
// If Gamepad not found, look for a Joystick
if (joystickGuid == Guid.Empty)//Guid.Empty는 인스턴스가 안들어 있는 것이다 .
foreach (var deviceInstance in directInput.GetDevices(DeviceType.Joystick, DeviceEnumerationFlags.AllDevices))
joystickGuid = deviceInstance.InstanceGuid;// 다시 인스턴스 넣어라
//게임패드 먼저 검색후, 조이 스틱 탐색
// If Joystick not found, throws an error
if (joystickGuid == Guid.Empty)
{
Console.WriteLine("No joystick/Gamepad found.");
Console.ReadKey();//?
Environment.Exit(1);//아무거나 입력하면 강제 종료된다
}
// <2> 조이스틱 선언
// Instantiate the joystick
var joystick = new Joystick(directInput, joystickGuid); //조이스틱 객체 선언
Console.WriteLine("Found Joystick/Gamepad with GUID: {0}", joystickGuid);
// Query all suported ForceFeedback effects
var allEffects = joystick.GetEffects();
foreach (var effectInfo in allEffects)
Console.WriteLine("Effect available {0}", effectInfo.Name);
// Set BufferSize in order to use buffered data.
joystick.Properties.BufferSize = 128;
// Acquire the joystick
joystick.Acquire();
// Poll events from joystick
while (true)
{
joystick.Poll();//조이스틱 조작할 시에
/*var datas = joystick.GetBufferedData();
foreach (var state in datas)
Console.WriteLine(state);
*/
JoystickUpdate[] states = joystick.GetBufferedData();
foreach (var state in states)
{
Console.WriteLine(state);
int x = state.Value;
//JoystickOffset offset = state.Offset;
JoystickOffset offset= state.Offset;
Console.WriteLine(offset);
}
}
}
}
}
위 코드는 반응이 있는 조이스틱의 버튼의 종류를 받는 법이고 . int x=state.Value는 값을 담고 있다
c# panel 의 location 이용해서 표시할 수 있다
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=einsbon&logNo=221086003205
'6_Project > Zigner' 카테고리의 다른 글
비행기 제작 재료 : 카드보드지 (0) | 2023.12.10 |
---|---|
통신 알고리즘 - HC12 테스트 (2) | 2023.12.03 |
통신 알고리즘 - HC12 테스트0 (0) | 2023.12.02 |
통신 알고리즘 - 설계 (0) | 2023.11.30 |
배터리 잔량표시 - 레퍼런스 (0) | 2023.09.27 |