Skip to content

Commit

Permalink
Version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
abdalmoez committed May 7, 2020
1 parent 71e0329 commit 70a7a68
Show file tree
Hide file tree
Showing 13 changed files with 780 additions and 69 deletions.
60 changes: 60 additions & 0 deletions SerialShell/App.config
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>
133 changes: 103 additions & 30 deletions SerialShell/MainForm.Designer.cs

Large diffs are not rendered by default.

72 changes: 63 additions & 9 deletions SerialShell/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace SerialShell
{

public partial class Form1 : Form
public partial class MainForm : Form
{
//Thread Scanner ;
SerialPort sp;
Expand Down Expand Up @@ -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");
}
Expand All @@ -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()
{
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
}
}
}
10 changes: 10 additions & 0 deletions SerialShell/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@
5mUNe6s1HrfElkKowseOVMxywaAVzQrsA9MT5gByPzMLoql7zDEMwQj9rg15zBZfnnFGv6HGLPyaOcMX
CzQTDOvA9NEJzGKBlq3wwtXx7o2UXFAEwgm/leC2CU7pA1/oqWlCT+Av8KYzMEczttZuBS8zzP54idwB
6WFqZQCAIpIAAAAASUVORK5CYII=
</value>
</data>
<data name="Settings.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAD8SURBVDhPnZM7TgMxEEAXFA4AEhKhQxyOii6nCEKipA49
F4CCkg4KhChyjDSQRPDeymN5P9pd8aQXbXZmbY89rgaY4we+4bEvxpihHwX3+Ju89UXiAs1tcISPuMcn
vMEtxgDfuMSX9N9cv8lcYiRP0YlOscE79iX3+YodHrBMWuMi6XMZMzdzhm7YDiPhEw8wOMQvjLglrNAN
rTYYgfAK21xjO+8H6592YOoATl4vw+W4rAiMlWC5lm35mX9vYuDRlElDeuQNbIqyhCnafJloZQO2q71f
bq5tbXs/oxN1Wlm8IPW5Ju4wBnDDgnPsXKY+TtCr7JUub2lBVf0BlwyJDUagWw8AAAAASUVORK5CYII=
</value>
</data>
<data name="aboutbtn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
2 changes: 1 addition & 1 deletion SerialShell/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new MainForm());
}
}
}
7 changes: 3 additions & 4 deletions SerialShell/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SerialPort-Bluetooth Communication")]
[assembly: AssemblyTitle("SerialShell - Bluetooth Communication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("AMDreamSoft")]
[assembly: AssemblyProduct("SerialPort-Bluetooth Communication")]
[assembly: AssemblyProduct("SerialShell - Bluetooth Communication")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand All @@ -33,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]
4 changes: 2 additions & 2 deletions SerialShell/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 70a7a68

Please sign in to comment.