mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 07:58:51 +01:00
bluetooth compiled
This commit is contained in:
parent
7bd15e3583
commit
e8c9c1e7f7
@ -1,12 +1,21 @@
|
||||
package Bluetooth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"log"
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/font"
|
||||
|
||||
bleapi "github.com/muka/go-bluetooth/api"
|
||||
|
||||
"github.com/muka/go-bluetooth/bluez/profile"
|
||||
@ -38,20 +47,20 @@ func NewBleForgetConfirmPage() *BleForgetConfirmPage {
|
||||
p := &BleForgetConfirmPage{}
|
||||
|
||||
p.ConfirmText = "Confirm Forget?"
|
||||
p.UI.ConfirmPage.ConfirmText = p.ConfirmText
|
||||
p.ConfirmPage.ConfirmText = p.ConfirmText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *BleForgetConfirmPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == CurKeys["B"] {
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.SnapMsg("Deleting")
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
@ -160,10 +169,9 @@ func (self *BleInfoPage) Init() {
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
|
||||
self.ConfirmPage1 = BleForgetConfirmPage()
|
||||
self.ConfirmPage1 = NewBleForgetConfirmPage()
|
||||
self.ConfirmPage1.Screen = self.Screen
|
||||
self.ConfirmPage1.Name = "Confirm Forget"
|
||||
self.ConfirmPage1.Parent = self
|
||||
self.ConfirmPage1.Init()
|
||||
|
||||
}
|
||||
@ -199,8 +207,8 @@ func (self *BleInfoPage) GenList() {
|
||||
|
||||
sm_text := ""
|
||||
if k == "UUIDs" {
|
||||
if len(v)> 1 {
|
||||
sm_text = v[0]
|
||||
if len(v.([]string))> 1 {
|
||||
sm_text = v.([]string)[0]
|
||||
}else{
|
||||
sm_text = "<empty>"
|
||||
}
|
||||
@ -232,7 +240,7 @@ func (self *BleInfoPage) ScrollUp() {
|
||||
self.PsIndex = 0
|
||||
}
|
||||
|
||||
cur_li = self.MyList[self.PsIndex]
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
|
||||
x,y := cur_li.Coord()
|
||||
|
||||
@ -257,7 +265,7 @@ func (self *BleInfoPage) ScrollDown() {
|
||||
self.PsIndex = 0
|
||||
}
|
||||
|
||||
cur_li = self.MyList[self.PsIndex]
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
|
||||
x,y := cur_li.Coord()
|
||||
|
||||
@ -392,7 +400,7 @@ func (self *BleInfoPage) Draw() {
|
||||
|
||||
self.Scroller.UpdateSize(len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self._Scroller.Draw()
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
self.Ps.(*BleInfoPageSelector).Width = self.Width
|
||||
@ -444,7 +452,7 @@ func (self *BleListMessageBox) Draw() {
|
||||
type BluetoothPage struct{
|
||||
UI.Page
|
||||
|
||||
Devices []api.Device
|
||||
Devices []bleapi.Device
|
||||
|
||||
BlePassword string
|
||||
Connecting bool
|
||||
@ -461,7 +469,7 @@ type BluetoothPage struct{
|
||||
MsgBox *BleListMessageBox
|
||||
ConnectTry int
|
||||
|
||||
BlockCb ??
|
||||
//BlockCb ??
|
||||
|
||||
LastStatusMsg string
|
||||
ADAPTER_DEV string // == adapterID
|
||||
@ -508,16 +516,16 @@ func (self *BluetoothPage) Init() {
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
ps = &BleListSelector{}
|
||||
ps := &BleListSelector{}
|
||||
ps.Parent = self
|
||||
ps.Width = Width - 12
|
||||
ps.Width = UI.Width - 12
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
msgbox := NewBleListMessageBox()
|
||||
msgbox.CanvasHWND = self.CanvasHWND
|
||||
msgbox.Init(" ",UI.Fonts["veramono12"])
|
||||
msgbox.Init(" ",UI.Fonts["veramono12"],nil)
|
||||
msgbox.Parent = self
|
||||
|
||||
self.MsgBox = msgbox
|
||||
@ -576,7 +584,7 @@ func (self *BluetoothPage) GenNetworkList() {
|
||||
start_y := 0
|
||||
|
||||
|
||||
for i v := range self.Devices { // v == bleapi.Device
|
||||
for i, v := range self.Devices { // v == bleapi.Device
|
||||
|
||||
props, err := v.GetProperties()
|
||||
if err != nil {
|
||||
@ -612,7 +620,7 @@ func (self *BluetoothPage) GenNetworkList() {
|
||||
|
||||
func (self *BluetoothPage) Rescan() {
|
||||
|
||||
self.Scanning = True
|
||||
self.Scanning = true
|
||||
self.ShowBox("Bluetooth scanning")
|
||||
self.Screen.FootBar.UpdateNavText("Scanning")
|
||||
|
||||
@ -621,7 +629,7 @@ func (self *BluetoothPage) Rescan() {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
err := bleapi.StartDiscovery()
|
||||
err = bleapi.StartDiscovery()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -737,7 +745,7 @@ func (self *BluetoothPage) Draw() {
|
||||
|
||||
|
||||
if len(self.MyList) * NetItemDefaultHeight > self.Height {
|
||||
self.Ps.Width = self.Width - 11
|
||||
self.Ps.(*BleListSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
@ -748,7 +756,7 @@ func (self *BluetoothPage) Draw() {
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
self.Ps.Width = self.Width
|
||||
self.Ps.(*BleListSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
v.Draw()
|
||||
@ -1,10 +1,23 @@
|
||||
package Bluetooth
|
||||
|
||||
import (
|
||||
|
||||
//"fmt"
|
||||
|
||||
bleapi "github.com/muka/go-bluetooth/api"
|
||||
"github.com/muka/go-bluetooth/bluez/profile"
|
||||
//"github.com/muka/go-bluetooth/emitter"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
|
||||
)
|
||||
var NetItemDefaultHeight = 30
|
||||
|
||||
@ -135,7 +148,7 @@ func (self *NetItem) Connect() {
|
||||
|
||||
func (self *NetItem) Draw() {
|
||||
for k,v := range self.Labels {
|
||||
x,y := v.Coord()
|
||||
x,_ := v.Coord()
|
||||
_,h := v.Size()
|
||||
self.Labels[k].NewCoord(x, self.PosY+(self.Height - h)/2)
|
||||
self.Labels[k].Draw()
|
||||
@ -1,11 +1,12 @@
|
||||
package Bluetooth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/muka/go-bluetooth/api"
|
||||
//"github.com/muka/go-bluetooth/emitter"
|
||||
"github.com/muka/go-bluetooth/emitter"
|
||||
"github.com/muka/go-bluetooth/linux"
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@ import (
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Sound"
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Brightness"
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Wifi"
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Bluetooth"
|
||||
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/LauncherPy"
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Update"
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Storage"
|
||||
@ -90,7 +92,8 @@ func (self *SettingsPage) GenList() []*UI.UIPlugin {
|
||||
alist := []*UI.UIPlugin{
|
||||
|
||||
&UI.UIPlugin{0,"", "Wifi", "Wi-Fi",&Wifi.APIOBJ},
|
||||
|
||||
&UI.UIPlugin{0,"", "Bluetooth", "Bluetooth",&Bluetooth.APIOBJ},
|
||||
|
||||
&UI.UIPlugin{0,"", "Sound", "Sound Volume" , &Sound.APIOBJ},
|
||||
&UI.UIPlugin{0,"", "Brightness", "BackLight Brightness", &Brightness.APIOBJ},
|
||||
&UI.UIPlugin{0,"", "Storage", "", &Storage.APIOBJ},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user