From 9c0e7d529094e1a8b7ecd661d491a123b2c4664e Mon Sep 17 00:00:00 2001 From: org Date: Wed, 6 Sep 2023 13:25:56 +0300 Subject: [PATCH 1/3] Real device bindings --- Breaknes/Breaknes/Build/IOConfig.json | 73 +++++++++++-- .../FormBindingDendyController.Designer.cs | 2 + .../Breaknes/FormBindingDendyController.cs | 5 + .../FormBindingFamiController1.Designer.cs | 2 + .../Breaknes/FormBindingFamiController1.cs | 5 + .../FormBindingFamiController2.Designer.cs | 2 + .../Breaknes/FormBindingFamiController2.cs | 5 + .../FormBindingNESController.Designer.cs | 2 + Breaknes/Breaknes/FormBindingNESController.cs | 5 + .../Breaknes/FormWaitInputEvent.Designer.cs | 8 ++ Breaknes/Breaknes/FormWaitInputEvent.cs | 22 ++++ Breaknes/Breaknes/FormWaitInputEvent.resx | 3 + Breaknes/Breaknes/IOProcessing.cs | 103 +++++++++++++++++- Breaknes/BreaksCore/AbstractBoard.h | 2 - Breaknes/BreaksCore/CoreApi.cpp | 2 +- 15 files changed, 225 insertions(+), 16 deletions(-) diff --git a/Breaknes/Breaknes/Build/IOConfig.json b/Breaknes/Breaknes/Build/IOConfig.json index 963be19f..dfdc2d26 100644 --- a/Breaknes/Breaknes/Build/IOConfig.json +++ b/Breaknes/Breaknes/Build/IOConfig.json @@ -15,29 +15,86 @@ "bindings": [ { "actuator_id": 0, - "binding": "Dummy binding" + "binding": "PointOfViewControllers0_Up" }, { "actuator_id": 4, - "binding": "Dummy binding" + "binding": "Buttons6" + }, + { + "actuator_id": 1, + "binding": "PointOfViewControllers0_Down" + }, + { + "actuator_id": 2, + "binding": "PointOfViewControllers0_Left" + }, + { + "actuator_id": 3, + "binding": "PointOfViewControllers0_Right" + }, + { + "actuator_id": 5, + "binding": "Buttons7" + }, + { + "actuator_id": 6, + "binding": "Buttons0" + }, + { + "actuator_id": 7, + "binding": "Buttons1" } ] }, { "device_id": 3, "name": "NES P1", - "attached": [], - "bindings": [] - }, - { - "device_id": 65539, - "name": "V1", "attached": [ { "board": "NES-001 (PCB rev. -01 to -04)", "port": 0 } ], + "bindings": [ + { + "actuator_id": 0, + "binding": "Up" + }, + { + "actuator_id": 1, + "binding": "Down" + }, + { + "actuator_id": 2, + "binding": "Left" + }, + { + "actuator_id": 3, + "binding": "Right" + }, + { + "actuator_id": 4, + "binding": "A" + }, + { + "actuator_id": 5, + "binding": "S" + }, + { + "actuator_id": 6, + "binding": "Z" + }, + { + "actuator_id": 7, + "binding": "X" + } + ] + }, + { + "device_id": 65539, + "name": "V1", + "attached": [], "bindings": [ { "actuator_id": 0, diff --git a/Breaknes/Breaknes/FormBindingDendyController.Designer.cs b/Breaknes/Breaknes/FormBindingDendyController.Designer.cs index ca7f3c5f..d126b2bc 100644 --- a/Breaknes/Breaknes/FormBindingDendyController.Designer.cs +++ b/Breaknes/Breaknes/FormBindingDendyController.Designer.cs @@ -218,9 +218,11 @@ private void InitializeComponent() AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(801, 476); Controls.Add(splitContainer1); + KeyPreview = true; Name = "FormBindingDendyController"; Text = "Dendy Controller Binding"; Load += FormBindingDendyController_Load; + KeyDown += FormBindingDendyController_KeyDown; tabControl1.ResumeLayout(false); tabPage1.ResumeLayout(false); splitContainer1.Panel1.ResumeLayout(false); diff --git a/Breaknes/Breaknes/FormBindingDendyController.cs b/Breaknes/Breaknes/FormBindingDendyController.cs index 313dcf74..2db2a38f 100644 --- a/Breaknes/Breaknes/FormBindingDendyController.cs +++ b/Breaknes/Breaknes/FormBindingDendyController.cs @@ -153,5 +153,10 @@ private void ShowBindings(int actuator_id) } } } + + private void FormBindingDendyController_KeyDown(object sender, KeyEventArgs e) + { + Close(); + } } } diff --git a/Breaknes/Breaknes/FormBindingFamiController1.Designer.cs b/Breaknes/Breaknes/FormBindingFamiController1.Designer.cs index fa6fb505..676a1e49 100644 --- a/Breaknes/Breaknes/FormBindingFamiController1.Designer.cs +++ b/Breaknes/Breaknes/FormBindingFamiController1.Designer.cs @@ -218,9 +218,11 @@ private void InitializeComponent() AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(801, 434); Controls.Add(splitContainer1); + KeyPreview = true; Name = "FormBindingFamiController1"; Text = "Famicom Controller Port1 Binding"; Load += FormBindingFamiController1_Load; + KeyDown += FormBindingFamiController1_KeyDown; splitContainer1.Panel1.ResumeLayout(false); splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit(); diff --git a/Breaknes/Breaknes/FormBindingFamiController1.cs b/Breaknes/Breaknes/FormBindingFamiController1.cs index d1da6945..9cc445df 100644 --- a/Breaknes/Breaknes/FormBindingFamiController1.cs +++ b/Breaknes/Breaknes/FormBindingFamiController1.cs @@ -153,5 +153,10 @@ private void ShowBindings(int actuator_id) } } } + + private void FormBindingFamiController1_KeyDown(object sender, KeyEventArgs e) + { + Close(); + } } } diff --git a/Breaknes/Breaknes/FormBindingFamiController2.Designer.cs b/Breaknes/Breaknes/FormBindingFamiController2.Designer.cs index 3b3a7d63..dd3563ca 100644 --- a/Breaknes/Breaknes/FormBindingFamiController2.Designer.cs +++ b/Breaknes/Breaknes/FormBindingFamiController2.Designer.cs @@ -218,9 +218,11 @@ private void InitializeComponent() AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(823, 475); Controls.Add(splitContainer1); + KeyPreview = true; Name = "FormBindingFamiController2"; Text = "Famicom Controller Port2 Binding"; Load += FormBindingFamiController2_Load; + KeyDown += FormBindingFamiController2_KeyDown; splitContainer1.Panel1.ResumeLayout(false); splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit(); diff --git a/Breaknes/Breaknes/FormBindingFamiController2.cs b/Breaknes/Breaknes/FormBindingFamiController2.cs index 1679624e..cb750415 100644 --- a/Breaknes/Breaknes/FormBindingFamiController2.cs +++ b/Breaknes/Breaknes/FormBindingFamiController2.cs @@ -153,5 +153,10 @@ private void ShowBindings(int actuator_id) } } } + + private void FormBindingFamiController2_KeyDown(object sender, KeyEventArgs e) + { + Close(); + } } } diff --git a/Breaknes/Breaknes/FormBindingNESController.Designer.cs b/Breaknes/Breaknes/FormBindingNESController.Designer.cs index deb3e307..9017e9a3 100644 --- a/Breaknes/Breaknes/FormBindingNESController.Designer.cs +++ b/Breaknes/Breaknes/FormBindingNESController.Designer.cs @@ -218,9 +218,11 @@ private void InitializeComponent() AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(809, 471); Controls.Add(splitContainer1); + KeyPreview = true; Name = "FormBindingNESController"; Text = "NES Controller Binding"; Load += FormBindingNESController_Load; + KeyDown += FormBindingNESController_KeyDown; splitContainer1.Panel1.ResumeLayout(false); splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit(); diff --git a/Breaknes/Breaknes/FormBindingNESController.cs b/Breaknes/Breaknes/FormBindingNESController.cs index 9bde78c8..4a970b31 100644 --- a/Breaknes/Breaknes/FormBindingNESController.cs +++ b/Breaknes/Breaknes/FormBindingNESController.cs @@ -153,5 +153,10 @@ private void ShowBindings(int actuator_id) } } } + + private void FormBindingNESController_KeyDown(object sender, KeyEventArgs e) + { + Close(); + } } } diff --git a/Breaknes/Breaknes/FormWaitInputEvent.Designer.cs b/Breaknes/Breaknes/FormWaitInputEvent.Designer.cs index db56250c..acd102d5 100644 --- a/Breaknes/Breaknes/FormWaitInputEvent.Designer.cs +++ b/Breaknes/Breaknes/FormWaitInputEvent.Designer.cs @@ -29,6 +29,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { label1 = new Label(); + backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); SuspendLayout(); // // label1 @@ -42,6 +43,11 @@ private void InitializeComponent() label1.TabIndex = 0; label1.Text = "Press a button or key on the input device..."; // + // backgroundWorker1 + // + backgroundWorker1.WorkerSupportsCancellation = true; + backgroundWorker1.DoWork += backgroundWorker1_DoWork; + // // FormWaitInputEvent // AutoScaleDimensions = new SizeF(7F, 15F); @@ -52,6 +58,7 @@ private void InitializeComponent() Name = "FormWaitInputEvent"; StartPosition = FormStartPosition.CenterParent; Text = "Wait Input Event"; + Load += FormWaitInputEvent_Load; KeyDown += FormWaitInputEvent_KeyDown; ResumeLayout(false); PerformLayout(); @@ -60,5 +67,6 @@ private void InitializeComponent() #endregion private Label label1; + private System.ComponentModel.BackgroundWorker backgroundWorker1; } } \ No newline at end of file diff --git a/Breaknes/Breaknes/FormWaitInputEvent.cs b/Breaknes/Breaknes/FormWaitInputEvent.cs index 8df33ebd..511178af 100644 --- a/Breaknes/Breaknes/FormWaitInputEvent.cs +++ b/Breaknes/Breaknes/FormWaitInputEvent.cs @@ -18,8 +18,30 @@ private void FormWaitInputEvent_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { + backgroundWorker1.CancelAsync(); + bindstr = null; Close(); } } + + private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) + { + while(!backgroundWorker1.CancellationPending) + { + io.PollDevices(); + + if (io.event_queue.Count != 0) + { + bindstr = io.event_queue[0].name; + io.event_queue.Clear(); + Close(); + } + } + } + + private void FormWaitInputEvent_Load(object sender, EventArgs e) + { + backgroundWorker1.RunWorkerAsync(); + } } } diff --git a/Breaknes/Breaknes/FormWaitInputEvent.resx b/Breaknes/Breaknes/FormWaitInputEvent.resx index af32865e..fa7aa79e 100644 --- a/Breaknes/Breaknes/FormWaitInputEvent.resx +++ b/Breaknes/Breaknes/FormWaitInputEvent.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/Breaknes/Breaknes/IOProcessing.cs b/Breaknes/Breaknes/IOProcessing.cs index befad14d..711b5689 100644 --- a/Breaknes/Breaknes/IOProcessing.cs +++ b/Breaknes/Breaknes/IOProcessing.cs @@ -26,7 +26,7 @@ public class IOEvent { public string name = ""; public UInt32 value = 0; - public int device_handle = -1; + public int device_handle = -1; // -1: broadcast } public class IOProcessor @@ -34,7 +34,8 @@ public class IOProcessor Keyboard? keyboard = null; Joystick? joystick = null; List devices = new(); - List event_queue = new(); + // Made public so that the bindings dialog can poll input devices by getting events from the queue + public List event_queue = new(); public IOProcessor() { @@ -87,20 +88,102 @@ public void PollDevices() { List events = new(); + // Translate keyboard events + if (keyboard != null) { keyboard.Poll(); var datas = keyboard.GetBufferedData(); foreach (var state in datas) - Console.WriteLine(state); + { + IOEvent key_event = new(); + key_event.name = state.Key.ToString(); + key_event.value = (uint)(state.IsPressed ? 1 : 0); + key_event.device_handle = -1; + events.Add(key_event); + } } + // Translate events from joystick (TODO: only one is supported so far) + if (joystick != null) { joystick.Poll(); var datas = joystick.GetBufferedData(); foreach (var state in datas) + { Console.WriteLine(state); + + IOEvent joy_event = new(); + + string offset = state.Offset.ToString(); + + if (offset.StartsWith("Button")) + { + joy_event.name = offset; + joy_event.value = (uint)(state.Value != 0 ? 1 : 0); + joy_event.device_handle = -1; + events.Add(joy_event); + } + else if (offset.StartsWith("PointOfViewControllers")) + { + switch (state.Value) + { + // I don't know who came up with such a "brilliant" idea to make the D-Pad in such a way, but as it is. Pushback will be considered as pushback in all directions + case -1: + IOEvent joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 0; + joy_event1.device_handle = -1; + events.Add(joy_event1); + IOEvent joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 0; + joy_event2.device_handle = -1; + events.Add(joy_event2); + IOEvent joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 0; + joy_event3.device_handle = -1; + events.Add(joy_event3); + IOEvent joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 0; + joy_event4.device_handle = -1; + events.Add(joy_event4); + break; + case 0: + joy_event.name = offset + "_Up"; + joy_event.value = 1; + joy_event.device_handle = -1; + events.Add(joy_event); + break; + case 9000: + joy_event.name = offset + "_Right"; + joy_event.value = 1; + joy_event.device_handle = -1; + events.Add(joy_event); + break; + case 18000: + joy_event.name = offset + "_Down"; + joy_event.value = 1; + joy_event.device_handle = -1; + events.Add(joy_event); + break; + case 27000: + joy_event.name = offset + "_Left"; + joy_event.value = 1; + joy_event.device_handle = -1; + events.Add(joy_event); + break; + } + } + } + + foreach (var io_event in events) + { + DumpEvent(io_event); + } } event_queue.AddRange(events); @@ -117,9 +200,19 @@ public void DispatchEventQueue() { foreach (var binding in attached_device.device.bindings) { - if (binding.binding == io_event.name && attached_device.handle == io_event.device_handle) + if (binding.binding == io_event.name) { - BreaksCore.IOSetState(attached_device.handle, binding.actuator_id, io_event.value); + if (io_event.device_handle >= 0) + { + if (attached_device.handle == io_event.device_handle) + { + BreaksCore.IOSetState(attached_device.handle, binding.actuator_id, io_event.value); + } + } + else + { + BreaksCore.IOSetState(attached_device.handle, binding.actuator_id, io_event.value); + } } } } diff --git a/Breaknes/BreaksCore/AbstractBoard.h b/Breaknes/BreaksCore/AbstractBoard.h index 591c563f..d24ec6a5 100644 --- a/Breaknes/BreaksCore/AbstractBoard.h +++ b/Breaknes/BreaksCore/AbstractBoard.h @@ -1,7 +1,5 @@ #pragma once -// TBD: The API will be extended to handle I/O devices (controllers, expansion ports) - namespace Breaknes { struct RGB_Triplet diff --git a/Breaknes/BreaksCore/CoreApi.cpp b/Breaknes/BreaksCore/CoreApi.cpp index 86a3bfb0..09a0202f 100644 --- a/Breaknes/BreaksCore/CoreApi.cpp +++ b/Breaknes/BreaksCore/CoreApi.cpp @@ -15,7 +15,7 @@ extern "C" { if (board == nullptr) { - printf("CreateBoard\n"); + printf("CreateBoard %s, apu: %s, ppu: %s, cart: %s\n", boardName, apu, ppu, p1); Breaknes::BoardFactory bf(boardName, apu, ppu, p1); CreateDebugHub(false); board = bf.CreateInstance(); From 161372cd9db8ac7dc766665a3e6bee8b1c6bb433 Mon Sep 17 00:00:00 2001 From: org Date: Wed, 6 Sep 2023 13:26:53 +0300 Subject: [PATCH 2/3] Update IOConfig.json --- Breaknes/Breaknes/Build/IOConfig.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Breaknes/Breaknes/Build/IOConfig.json b/Breaknes/Breaknes/Build/IOConfig.json index dfdc2d26..ea9de335 100644 --- a/Breaknes/Breaknes/Build/IOConfig.json +++ b/Breaknes/Breaknes/Build/IOConfig.json @@ -133,12 +133,7 @@ { "device_id": 65537, "name": "Fami1", - "attached": [ - { - "board": "HVC-CPU-01", - "port": 0 - } - ], + "attached": [], "bindings": [ { "actuator_id": 0, From c4c971eca90de2b5d6ec39427de4d9af8c15bf71 Mon Sep 17 00:00:00 2001 From: org Date: Wed, 6 Sep 2023 13:42:11 +0300 Subject: [PATCH 3/3] Cryptic DirectInput D-Pad event translations --- Breaknes/Breaknes/IOProcessing.cs | 205 +++++++++++++++++++++++++++--- 1 file changed, 185 insertions(+), 20 deletions(-) diff --git a/Breaknes/Breaknes/IOProcessing.cs b/Breaknes/Breaknes/IOProcessing.cs index 711b5689..1254027e 100644 --- a/Breaknes/Breaknes/IOProcessing.cs +++ b/Breaknes/Breaknes/IOProcessing.cs @@ -127,54 +127,219 @@ public void PollDevices() } else if (offset.StartsWith("PointOfViewControllers")) { + IOEvent joy_event1; + IOEvent joy_event2; + IOEvent joy_event3; + IOEvent joy_event4; + switch (state.Value) { // I don't know who came up with such a "brilliant" idea to make the D-Pad in such a way, but as it is. Pushback will be considered as pushback in all directions case -1: - IOEvent joy_event1 = new(); + joy_event1 = new(); joy_event1.name = offset + "_Up"; joy_event1.value = 0; joy_event1.device_handle = -1; events.Add(joy_event1); - IOEvent joy_event2 = new(); + joy_event2 = new(); joy_event2.name = offset + "_Right"; joy_event2.value = 0; joy_event2.device_handle = -1; events.Add(joy_event2); - IOEvent joy_event3 = new(); + joy_event3 = new(); joy_event3.name = offset + "_Down"; joy_event3.value = 0; joy_event3.device_handle = -1; events.Add(joy_event3); - IOEvent joy_event4 = new(); + joy_event4 = new(); joy_event4.name = offset + "_Left"; joy_event4.value = 0; joy_event4.device_handle = -1; events.Add(joy_event4); break; + // Up case 0: - joy_event.name = offset + "_Up"; - joy_event.value = 1; - joy_event.device_handle = -1; - events.Add(joy_event); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 1; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 0; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 0; + joy_event3.device_handle = -1; + events.Add(joy_event3); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 0; + joy_event4.device_handle = -1; + events.Add(joy_event4); + break; + // Up-Right + case 4500: + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 1; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 1; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 0; + joy_event3.device_handle = -1; + events.Add(joy_event3); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 0; + joy_event4.device_handle = -1; + events.Add(joy_event4); break; + // Right case 9000: - joy_event.name = offset + "_Right"; - joy_event.value = 1; - joy_event.device_handle = -1; - events.Add(joy_event); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 1; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 0; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 0; + joy_event3.device_handle = -1; + events.Add(joy_event3); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 0; + joy_event4.device_handle = -1; + events.Add(joy_event4); + break; + // Right-Down + case 13500: + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 1; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 1; + joy_event3.device_handle = -1; + events.Add(joy_event3); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 0; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 0; + joy_event4.device_handle = -1; + events.Add(joy_event4); break; + // Down case 18000: - joy_event.name = offset + "_Down"; - joy_event.value = 1; - joy_event.device_handle = -1; - events.Add(joy_event); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 1; + joy_event3.device_handle = -1; + events.Add(joy_event3); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 0; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 0; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 0; + joy_event4.device_handle = -1; + events.Add(joy_event4); + break; + // Down-Left + case 22500: + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 1; + joy_event3.device_handle = -1; + events.Add(joy_event3); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 1; + joy_event4.device_handle = -1; + events.Add(joy_event4); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 0; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 0; + joy_event2.device_handle = -1; + events.Add(joy_event2); break; + // Left case 27000: - joy_event.name = offset + "_Left"; - joy_event.value = 1; - joy_event.device_handle = -1; - events.Add(joy_event); + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 1; + joy_event4.device_handle = -1; + events.Add(joy_event4); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 0; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 0; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 0; + joy_event3.device_handle = -1; + events.Add(joy_event3); + break; + // Left-Up + case 31500: + joy_event4 = new(); + joy_event4.name = offset + "_Left"; + joy_event4.value = 1; + joy_event4.device_handle = -1; + events.Add(joy_event4); + joy_event1 = new(); + joy_event1.name = offset + "_Up"; + joy_event1.value = 1; + joy_event1.device_handle = -1; + events.Add(joy_event1); + joy_event2 = new(); + joy_event2.name = offset + "_Right"; + joy_event2.value = 0; + joy_event2.device_handle = -1; + events.Add(joy_event2); + joy_event3 = new(); + joy_event3.name = offset + "_Down"; + joy_event3.value = 0; + joy_event3.device_handle = -1; + events.Add(joy_event3); break; } }