-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
780 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | ||
<section name="SerialShell.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
<startup useLegacyV2RuntimeActivationPolicy="true"> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
<userSettings> | ||
<SerialShell.Properties.Settings> | ||
<setting name="Button1" serializeAs="String"> | ||
<value>BUTTON1</value> | ||
</setting> | ||
<setting name="Button2" serializeAs="String"> | ||
<value>BUTTON2</value> | ||
</setting> | ||
<setting name="Button3" serializeAs="String"> | ||
<value>BUTTON3</value> | ||
</setting> | ||
<setting name="Button4" serializeAs="String"> | ||
<value>BUTTON4</value> | ||
</setting> | ||
<setting name="Left1" serializeAs="String"> | ||
<value>LEFT1</value> | ||
</setting> | ||
<setting name="Right1" serializeAs="String"> | ||
<value>RIGHT1</value> | ||
</setting> | ||
<setting name="Left2" serializeAs="String"> | ||
<value>LEFT2</value> | ||
</setting> | ||
<setting name="Right2" serializeAs="String"> | ||
<value>RIGHT2</value> | ||
</setting> | ||
<setting name="Select" serializeAs="String"> | ||
<value>SELECT</value> | ||
</setting> | ||
<setting name="Start" serializeAs="String"> | ||
<value>START</value> | ||
</setting> | ||
<setting name="Up" serializeAs="String"> | ||
<value>UP</value> | ||
</setting> | ||
<setting name="Down" serializeAs="String"> | ||
<value>DOWN</value> | ||
</setting> | ||
<setting name="Left" serializeAs="String"> | ||
<value>LEFT</value> | ||
</setting> | ||
<setting name="Right" serializeAs="String"> | ||
<value>RIGHT</value> | ||
</setting> | ||
<setting name="LeftAnalogMid" serializeAs="String"> | ||
<value>LEFTANALOGMID</value> | ||
</setting> | ||
<setting name="RightAnalogMid" serializeAs="String"> | ||
<value>RIGHTANALOGMID</value> | ||
</setting> | ||
<setting name="SendEndOfLineChar" serializeAs="String"> | ||
<value>False</value> | ||
</setting> | ||
</SerialShell.Properties.Settings> | ||
</userSettings> | ||
</configuration> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
namespace SerialShell | ||
{ | ||
|
||
public partial class Form1 : Form | ||
public partial class MainForm : Form | ||
{ | ||
//Thread Scanner ; | ||
SerialPort sp; | ||
|
@@ -71,13 +71,36 @@ DeviceInstance di in | |
joystick_timer.Enabled = true; | ||
return true; | ||
} | ||
public Form1() | ||
private void loadsettings() | ||
{ | ||
btn1.Tag = Properties.Settings.Default.Button1; | ||
btn2.Tag = Properties.Settings.Default.Button2; | ||
btn3.Tag = Properties.Settings.Default.Button3; | ||
btn4.Tag = Properties.Settings.Default.Button4; | ||
//l1,,l2,r1,r2 | ||
leftbtn1.Tag = Properties.Settings.Default.Left1; | ||
rightbtn1.Tag = Properties.Settings.Default.Right1; | ||
leftbtn2.Tag = Properties.Settings.Default.Left2; | ||
rightbtn2.Tag = Properties.Settings.Default.Right2; | ||
//select,start | ||
selectbtn.Tag = Properties.Settings.Default.Select; | ||
startbtn.Tag = Properties.Settings.Default.Start; | ||
//up,down,left,right | ||
leftbtn.Tag = Properties.Settings.Default.Left; | ||
rightbtn.Tag = Properties.Settings.Default.Right; | ||
upbtn.Tag = Properties.Settings.Default.Up; | ||
downbtn.Tag = Properties.Settings.Default.Down; | ||
//analogmid | ||
leftanalogmidbtn.Tag = Properties.Settings.Default.LeftAnalogMid; | ||
rightanalogmidbtn.Tag = Properties.Settings.Default.RightAnalogMid; | ||
} | ||
public MainForm() | ||
{ | ||
InitializeComponent(); | ||
|
||
loadsettings(); | ||
sp = new System.IO.Ports.SerialPort("COM1", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); | ||
Refresh.PerformClick(); | ||
|
||
if (!init_joystick()) | ||
MessageBox.Show("Joystick not found"); | ||
} | ||
|
@@ -91,9 +114,13 @@ private void writetoserialport(string msg) | |
{ | ||
if (sp.IsOpen) | ||
{ | ||
sp.WriteLine(msg); | ||
Text1Append("###DATA Sent:" + msg); | ||
if (Properties.Settings.Default.SendEndOfLineChar) | ||
sp.WriteLine(msg); | ||
else sp.Write(msg); | ||
Text1Append("###Sending data:" + msg); | ||
} | ||
else Text1Append("###Error sending data:" + msg); | ||
|
||
} | ||
private void UpdateJoystick() | ||
{ | ||
|
@@ -111,6 +138,19 @@ private void UpdateJoystick() | |
|
||
//Capture Buttons. | ||
byte[] buttons = joystickstate.GetButtons(); | ||
//for (int i = 0; i < buttons.Length; i++) | ||
//{ | ||
// if (buttons[i] != 0) | ||
// { | ||
// MessageBox.Show("Button:" + i + " "); | ||
// } | ||
// } | ||
|
||
if (buttons.Count() < 10) | ||
{ | ||
MessageBox.Show("Invalid joystick"); | ||
return; | ||
} | ||
//btn 0..3 | ||
if (buttons[0] != 0) | ||
btn1.PerformClick(); | ||
|
@@ -134,6 +174,13 @@ private void UpdateJoystick() | |
selectbtn.PerformClick(); | ||
if (buttons[9] != 0) | ||
startbtn.PerformClick(); | ||
if (buttons.Count() >= 12) | ||
{ | ||
if (buttons[10] != 0) | ||
leftanalogmidbtn.PerformClick(); | ||
if (buttons[11] != 0) | ||
rightanalogmidbtn.PerformClick(); | ||
} | ||
//up,down,left,right | ||
if (joystickstate.X == jslow) | ||
leftbtn.PerformClick(); | ||
|
@@ -256,15 +303,22 @@ private void resetjoystick_button_Click(object sender, EventArgs e) | |
|
||
private void aboutbtn_Click(object sender, EventArgs e) | ||
{ | ||
MessageBox.Show(" --- SerialShell - Bluetooth communication V0.1 ---\n\n" + | ||
MessageBox.Show(" --- SerialShell - Bluetooth communication V0.1.1 ---\n\n" + | ||
" Developed by: \n" + | ||
" BOURAOUI AL-Moez L.A\n"+ | ||
" ([email protected])\n\n" + | ||
" License: GPL - 2.0\n\n\n" | ||
, "SerialShell - Bluetooth communication V0.1"); | ||
|
||
, "SerialShell - Bluetooth communication V0.1.1"); | ||
|
||
} | ||
|
||
private void Settings_Click(object sender, EventArgs e) | ||
{ | ||
if ((new settingsForm()).ShowDialog(this) == DialogResult.OK) | ||
Properties.Settings.Default.Save(); | ||
else Properties.Settings.Default.Reload(); | ||
|
||
loadsettings(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.