@@ -4,7 +4,8 @@ import Profile from "./Profile.vue";
4
4
import ProfileModel from " ../../model/Profile" ;
5
5
import LocalIndexDB from " ../../model/LocalIndexDB" ;
6
6
import {assembleBlankProfile , getProfileButtonSelector } from " ../../helper/profileTools" ;
7
- import {inject , Ref , ref } from " vue" ;
7
+ import {inject , ref } from " vue" ;
8
+ import type {Ref } from " vue" ;
8
9
import Joystick from " ../../model/Joystick" ;
9
10
import Trigger from " ../../model/Trigger" ;
10
11
import ButtonMapping from " ../../model/ButtonMapping" ;
@@ -19,6 +20,8 @@ const savedProfiles: Ref<Array<ProfileModel>> = ref([]);
19
20
const emit = defineEmits ([' selected-profile' , ' delete-profile' ]);
20
21
21
22
const db: LocalIndexDB = inject (' db' ) as LocalIndexDB ;
23
+ const hidController = inject (' HIDController' ) as Ref <HIDDevice >;
24
+ const getProfiles = inject (' getProfiles' ) as Function ;
22
25
23
26
db .getAll ().then ((profiles : Array <ProfileModel >) => savedProfiles .value = profiles .map ((profileEntry : any ) => {
24
27
@@ -47,6 +50,17 @@ const deleteProfileConfirm = (profile: ProfileModel) => {
47
50
}
48
51
}
49
52
53
+ const clearProfileFromControllerMemory = async (profile : ProfileModel , position : number ) => {
54
+
55
+ if (confirm (` Are you sure you want to clear ${profile .getLabel ()} from the controller memory? ` ) &&
56
+ hidController .value ) {
57
+ const bytes = new Uint8Array (64 );
58
+ bytes [1 ] = 1 + position ;
59
+ await hidController .value ?.sendFeatureReport (0x68 , bytes .slice (1 , bytes .length ));
60
+ getProfiles ();
61
+ }
62
+ }
63
+
50
64
const createNewProfile = () => {
51
65
let name = prompt (" New profile name" );
52
66
if (name ) {
@@ -64,9 +78,17 @@ const createNewProfile = () => {
64
78
<section >
65
79
<section class =" profiles" v-if =" profiles" >
66
80
<Profile @selected-profile =" (selectedProfile) => $emit('selected-profile', selectedProfile)"
67
- v-for =" profile in profiles"
81
+ v-for =" ( profile, i) in profiles"
68
82
:profile =" profile" >
69
- <p >{{ getProfileButtonSelector(profile.getProfileButtonSelector()) }}</p >
83
+ <div class =" profile-right" >
84
+ <span class =" button-combination" >
85
+ <span class =" fn-button" >FN</span >
86
+ <img class =" action-button" :src =" getProfileButtonSelector((profile as ProfileModel).getProfileButtonSelector())" alt =" button" >
87
+ </span >
88
+ <button class =" clear-button" @click =" $event.stopPropagation(); clearProfileFromControllerMemory(profile, i)" >
89
+ Clear
90
+ </button >
91
+ </div >
70
92
</Profile >
71
93
</section >
72
94
<section class =" profiles saved" >
@@ -113,10 +135,45 @@ const createNewProfile = () => {
113
135
font-weight : bold ;
114
136
}
115
137
138
+ .button-combination {
139
+ display : flex ;
140
+ gap : 12px ;
141
+ padding : 8px 0 ;
142
+ }
143
+
144
+ .fn-button {
145
+ width : 30px ;
146
+ text-align : center ;
147
+ height : 20px ;
148
+ background-color : #0f0f10 ;
149
+ color : #a4aaad ;
150
+ padding : 2px ;
151
+ border-radius : 4px ;
152
+ }
153
+
154
+ .action-button {
155
+ width : 24px ;
156
+ height : 24px ;
157
+ }
158
+
159
+ .clear-button {
160
+ all : unset ;
161
+ cursor : pointer ;
162
+ font-weight : bold ;
163
+ border : 1px solid #ffffff ;
164
+ margin-bottom : 10px ;
165
+ padding : 5px 12px ;
166
+ }
167
+
168
+ .clear-button :hover {
169
+ background-color : #0f0f10 ;
170
+ }
171
+
116
172
@media (prefers-color-scheme: dark) {
117
173
.overview {
118
174
background-color : #f25f4c ;
119
175
}
176
+
120
177
.create-new-profile button {
121
178
background-color : #ff8906 ;
122
179
font-weight : bold ;
0 commit comments