- LongPowerOff fix (so that it actually uses the AppSettings), and for Pro Controller

- Began trying out BT pairing modes
This commit is contained in:
David Khachaturov 2020-05-09 18:35:21 +01:00
parent 3b10bb609f
commit ce3cb236b1
2 changed files with 17 additions and 6 deletions

View file

@ -44,7 +44,7 @@
<!-- Determines whether or not to use HidGuardian (improves compatibility with other programs, like Steam, when set to "false") -->
<!-- When "true", BetterJoyForCemu will hide the Pro/Joycons from other programs to prevent glitching out on exit and to prevent DI/XI clashes in certain programs -->
<!-- Default: false -->
<add key="UseHIDG" value="true" />
<add key="UseHIDG" value="false" />
<!-- Determines whether or not to enable (experimental - currently default controller to pro) support for 3rd-party controllers. Adds a "Calibrate" button. -->
@ -79,11 +79,12 @@
<!-- Have ShowAsXInput as false if using this -->
<!-- Default: false -->
<add key="ShowAsDS4" value="false"/>
<!-- Automatically power off joycons at program exit -->
<!-- Default: false -->
<add key="AutoPowerOff" value="false" />
<!-- Power off joycons when Capture (left only) or Home (right only or combined) buttons are pressed for a long interval (2s) -->
<!-- Default: false -->
<add key="HomeLongPowerOff" value="false" />
<!-- Default: true -->
<add key="HomeLongPowerOff" value="true" />
</appSettings>
</configuration>

View file

@ -375,6 +375,14 @@ namespace BetterJoyForCemu {
dump_calibration_data();
}
// Bluetooth manual pairing
byte[] btmac_host = Program.btMAC.GetAddressBytes();
// send host MAC and acquire Joycon MAC
//byte[] reply = Subcommand(0x01, new byte[] { 0x01, btmac_host[5], btmac_host[4], btmac_host[3], btmac_host[2], btmac_host[1], btmac_host[0] }, 7, true);
//byte[] LTKhash = Subcommand(0x01, new byte[] { 0x02 }, 1, true);
// save pairing info
//Subcommand(0x01, new byte[] { 0x03 }, 1, true);
BlinkHomeLight();
a[0] = leds_;
@ -427,6 +435,7 @@ namespace BetterJoyForCemu {
public void PowerOff() {
if (state > state_.DROPPED) {
HIDapi.hid_set_nonblocking(handle, 0);
SetHCIState(0x00);
state = state_.DROPPED;
}
@ -604,15 +613,16 @@ namespace BetterJoyForCemu {
string extraGyroFeature = ConfigurationManager.AppSettings["GyroToJoyOrMouse"];
int GyroMouseSensitivity = Int32.Parse(ConfigurationManager.AppSettings["GyroMouseSensitivity"]);
bool HomeLongPowerOff = Boolean.Parse(ConfigurationManager.AppSettings["HomeLongPowerOff"]);
private void DoThingsWithButtons() {
int powerOffButton = (int)((!isLeft || other != null) ? Button.HOME : Button.CAPTURE);
int powerOffButton = (int)((isPro || !isLeft || other != null) ? Button.HOME : Button.CAPTURE);
if (buttons[powerOffButton]) {
if (HomeLongPowerOff && buttons[powerOffButton]) {
long timestamp = Stopwatch.GetTimestamp();
if ((timestamp - buttons_down_timestamp[powerOffButton]) / 10000 > 2000.0) {
PowerOff();
if (other != null)
other.PowerOff();
PowerOff();
return;
}
}