package manufacture

/*
#include <uvdbus/smart_sound.h>
#include <uvdbus/ota.h>
*/
import "C"
import (
	"encoding/json"
	"fmt"
	"netease_control_center/nembd/evdev"
)

func KeyApp() error {
	dev, err := evdev.Open("/dev/input/event2")
	if err != nil {
		return err
	}

	for {
		if event, err := dev.ReadOne(); err == nil && event.Type == uint16(evdev.EV_KEY) {
			fmt.Printf("Get %+v\n", event)
			if data, err := json.Marshal(event); err == nil {
				BroadSignalAll(uint32(C.MODULE_MANUFACTURE_CONTROLLER), uint32(C.CMD_TEST_BUTTON_RESP), string(data))
			}
			switch event.Code {
			case evdev.KEY_VOLUMEUP:

			case evdev.KEY_VOLUMEDOWN:

			case evdev.KEY_HOME:

			case evdev.KEY_MUTE:

			default:
				fmt.Printf("Unknow key,%d\n", event.Code)
			}
		}
	}

}
