Skip to content

Commit 34a7e16

Browse files
authored
Merge pull request #11 from SEPIA-Framework/dev
fixed a bug where disconnected BT devices crashed the android app
2 parents 1c6ac75 + e8af0eb commit 34a7e16

File tree

6 files changed

+50
-8
lines changed

6 files changed

+50
-8
lines changed

config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<preference name="android-windowSoftInputMode" value="adjustSize" />
5555
<!-- custom manifest changes -->
5656
<custom-preference name="android-manifest/application/activity/@android:theme" value="@style/SplashTheme"/> <!-- Theme mainly for splash screen or background colors -->
57+
<custom-preference name="android-manifest/application/activity/@android:configChanges" value="orientation|keyboardHidden|keyboard|screenSize|locale|navigation"/> <!-- Navigation is for bluetooth restart! -->
5758

5859
<!--intents-->
5960
<allow-intent href="market:*" />

www/css/sepiaFW-style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ html {
6565
background-position: calc(50% + 1px) center;
6666
}
6767
html.dark {
68-
background-color: #000;
68+
background-color: #000;
69+
background-image: none;
6970
}
7071
body {
7172
/*font-family: 'Roboto', sans-serif;*/

www/input-controls.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,34 @@
22
<div class='sepiaFW-carousel-pane-container'>
33
<!-- Page 1 -->
44
<div id="sepiaFW-frame-page-1" class='sepiaFW-frames-page sepiaFW-carousel-pane'>
5-
<h3>Controllers and Hotkeys</h3>
5+
<h3>Controllers and Hotkeys (Beta)</h3>
66
<p>Note: Buttons work everywhere, hotkeys work in Always-On mode <b>only</b>.</p>
7-
<div style="display: flex; flex-wrap: wrap; justify-content: center;">
7+
<div style="display: flex; flex-direction: column; flex-wrap: wrap; justify-content: center;">
88
<div>
9-
<p style="width:100%;">Define hotkeys:</p>
9+
<p style="width:100%;"><u>Define hotkeys:</u></p>
1010
<button id="SepiaFW-hotkeys-define-mic">Toggle microphone</button>
1111
<button id="SepiaFW-hotkeys-define-back">Back</button>
1212
</div>
1313
<div>
14-
<p style="width:100%;">Define buttons:</p>
14+
<label>Ignore keys: </label><input id="SepiaFW-hotkeys-ignore-key1"
15+
style="width: 48px; background: transparent; border-bottom: 1px solid; color: inherit;">
16+
</div>
17+
<div>
18+
<p style="width:100%;"><u>Define buttons:</u></p>
1519
<button id="SepiaFW-buttons-define-mic">Toggle microphone</button>
1620
<button id="SepiaFW-buttons-define-back">Back</button>
1721
</div>
22+
<!--<div>
23+
<label>Ignore buttons: </label><input id="SepiaFW-buttons-ignore-btn1"
24+
style="width: 48px; background: transparent; border-bottom: 1px solid; color: inherit;">
25+
</div>-->
1826
<div>
19-
<p style="width:100%;">Settings</p>
27+
<p style="width:100%;"><u>Settings</u></p>
2028
<button id="SepiaFW-input-controls-store">Store settings</button>
2129
<button id="SepiaFW-input-controls-clear">Clear settings</button>
2230
</div>
2331
</div>
32+
<hr>
2433
<div id="SepiaFW-input-controls-debug" style="overflow-y: auto; white-space: pre-wrap;"></div>
2534
</div>
2635
<!-- Page 2 -->

www/scripts/sepiaFW.alwaysOn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function sepiaFW_build_always_on(){
2626
onFinishSetup: AlwaysOn.onFinishSetup,
2727
onOpen: AlwaysOn.onOpen,
2828
onClose: AlwaysOn.onClose,
29-
theme: "dark"
29+
theme: "dark_full"
3030
});
3131
}
3232

www/scripts/sepiaFW.frames.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ function sepiaFW_build_frames(){
1919

2020
//theme
2121
if (info.theme && info.theme == "dark"){
22+
$('#sepiaFW-frames-view').addClass('dark');
23+
$('.sepiaFW-frames-page').addClass('dark');
24+
}else if (info.theme && info.theme == "dark_full"){
2225
$('html').addClass('dark');
2326
$('#sepiaFW-frames-view').addClass('dark');
2427
$('.sepiaFW-frames-page').addClass('dark');
25-
}else{
28+
}else{
2629
$('html').removeClass('dark');
2730
$('#sepiaFW-frames-view').removeClass('dark');
2831
$('.sepiaFW-frames-page').removeClass('dark');

www/scripts/sepiaFW.inputControls.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ function sepiaFW_build_input_controls() {
3434
$('#SepiaFW-hotkeys-define-back').off().on('click', function(){
3535
InputControls.defineHotkeyFunction(backButton);
3636
});
37+
//Ignore keys
38+
$('#SepiaFW-hotkeys-ignore-key1').off().on('change', function(){
39+
if (this.value){
40+
ignoreKeys = JSON.parse("[" + this.value + "]");
41+
settingsAppendDebug("New ignore keys: " + JSON.stringify(ignoreKeys));
42+
}
43+
});
3744
//Buttons for button mappings
3845
$('#SepiaFW-buttons-define-mic').off().on('click', function(){
3946
InputControls.defineButtonFunction(toggleMicrophone);
@@ -68,8 +75,11 @@ function sepiaFW_build_input_controls() {
6875
});
6976
settingsAppendDebug("<b>Hotkey matrix:</b>");
7077
settingsAppendDebug(convertActionMatrixToString(hotkeyActionMatrix));
78+
settingsAppendDebug("<b>Ignoring keys:</b>");
79+
settingsAppendDebug(JSON.stringify(ignoreKeys));
7180
settingsAppendDebug("<b>Button matrix:</b>");
7281
settingsAppendDebug(convertActionMatrixToString(buttonActionMatrix));
82+
settingsAppendDebug("<hr>");
7383
settingsAppendDebug("<b>Controller and key events:</b>");
7484

7585
SepiaFW.ui.scrollToTop('sepiaFW-frame-page-1');
@@ -89,20 +99,32 @@ function sepiaFW_build_input_controls() {
8999
var keys = convertActionMatrixToString(hotkeyActionMatrix);
90100
SepiaFW.data.set("input-controls-buttons", buttons);
91101
SepiaFW.data.set("input-controls-hotkeys", keys);
102+
SepiaFW.data.set("input-controls-ignore", JSON.stringify({
103+
"keys": ignoreKeys,
104+
"buttons": ignoreButtons
105+
}));
92106
SepiaFW.debug.log('Stored hotkeys and button settings in client storage.');
93107
SepiaFW.ui.showPopup('Stored hotkeys and button settings.');
94108
}
95109
InputControls.clearMappings = function(){
96110
SepiaFW.data.set("input-controls-buttons", "");
97111
SepiaFW.data.set("input-controls-hotkeys", "");
112+
SepiaFW.data.set("input-controls-ignore", "");
98113
SepiaFW.debug.log('Cleared hotkeys and button settings from client storage.');
99114
SepiaFW.ui.showPopup('Cleared hotkeys and button settings (please reload app).');
100115
}
101116
InputControls.importMappings = function(){
102117
var buttonsMapString = SepiaFW.data.get("input-controls-buttons");
103118
var keysMapString = SepiaFW.data.get("input-controls-hotkeys");
119+
var ignoresString = SepiaFW.data.get("input-controls-ignore");
104120
if (buttonsMapString) buttonActionMatrix = importJsonToActionMatrix(buttonsMapString);
105121
if (keysMapString) hotkeyActionMatrix = importJsonToActionMatrix(keysMapString);
122+
if (ignoresString){
123+
ignoresJson = JSON.parse(ignoresString);
124+
ignoreKeys = ignoresJson.keys;
125+
$('#SepiaFW-hotkeys-ignore-key1').val(JSON.stringify(ignoreKeys).replace(/\[|\]/g, ""));
126+
ignoreButtons = ignoresJson.buttons;
127+
}
106128
SepiaFW.debug.log('Imported hotkeys and button settings from client storage.');
107129
}
108130
function convertActionMatrixToString(actionMatrix){
@@ -127,6 +149,7 @@ function sepiaFW_build_input_controls() {
127149
//--------------- Keyboard Shortcuts ----------------
128150

129151
var hotkeyActionMatrix = {}; //{unicode-key} -> action
152+
var ignoreKeys = []; //for quirky controllers that always fire more than one event at the same time
130153

131154
InputControls.listenToGlobalHotkeys = function(){
132155
if (InputControls.useGamepads && InputControls.useHotkeysInAlwaysOn){
@@ -144,6 +167,10 @@ function sepiaFW_build_input_controls() {
144167
//Evaluate hotkey press
145168
function onHotkey(event){
146169
var e = event || window.event; // for IE to cover IEs window event-object
170+
//ignore?
171+
if (ignoreKeys && ignoreKeys.length > 0 && $.inArray(e.which, ignoreKeys) > -1){
172+
return;
173+
}
147174
if (InputControls.settingsAreOpen){
148175
settingsAppendDebug('Key pressed with unicode: ' + e.which);
149176
}
@@ -173,6 +200,7 @@ function sepiaFW_build_input_controls() {
173200
var controllers = {}; //Object to hold all connected controllers {"1":..,"2":..}
174201
var buttonMatrix = {}; //2D "object" with {controllerIndex}{buttonIndex} that holds current "pressed" state
175202
var buttonActionMatrix = {}; //2D "object" with {controllerIndex}{buttonIndex} that holds action method (if any)
203+
var ignoreButtons = []; //for quirky controllers that always fire more than one event at the same time
176204
var isGamepadListening = false;
177205

178206
//Used for state scan-loop

0 commit comments

Comments
 (0)