Skip to content

Commit

Permalink
Merge pull request #54 from KevinZonda/patch-2
Browse files Browse the repository at this point in the history
Replace C.DWORD due to not compiling
  • Loading branch information
aveenismail authored Apr 25, 2024
2 parents 904f223 + 8b5ed83 commit 1e945f4
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions usb_winusb.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build windows
// +build windows

package main
Expand All @@ -34,26 +35,28 @@ var device struct {
mtx sync.Mutex
}

func (e C.DWORD) Error() string {
type C_DWORD C.DWORD

func (e C_DWORD) Error() string {
return fmt.Sprintf("Windows Error: 0x%x", uint(e))
}

const (
SUCCESS C.DWORD = C.ERROR_SUCCESS
ERROR_INVALID_STATE C.DWORD = C.ERROR_INVALID_STATE
ERROR_INVALID_HANDLE C.DWORD = C.ERROR_INVALID_HANDLE
ERROR_INVALID_PARAMETER C.DWORD = C.ERROR_INVALID_PARAMETER
ERROR_OUTOFMEMORY C.DWORD = C.ERROR_OUTOFMEMORY
ERROR_GEN_FAILURE C.DWORD = C.ERROR_GEN_FAILURE
ERROR_OBJECT_NOT_FOUND C.DWORD = C.ERROR_OBJECT_NOT_FOUND
ERROR_NOT_SUPPORTED C.DWORD = C.ERROR_NOT_SUPPORTED
ERROR_SHARING_VIOLATION C.DWORD = C.ERROR_SHARING_VIOLATION
ERROR_BAD_COMMAND C.DWORD = C.ERROR_BAD_COMMAND
SUCCESS C_DWORD = C.ERROR_SUCCESS
ERROR_INVALID_STATE C_DWORD = C.ERROR_INVALID_STATE
ERROR_INVALID_HANDLE C_DWORD = C.ERROR_INVALID_HANDLE
ERROR_INVALID_PARAMETER C_DWORD = C.ERROR_INVALID_PARAMETER
ERROR_OUTOFMEMORY C_DWORD = C.ERROR_OUTOFMEMORY
ERROR_GEN_FAILURE C_DWORD = C.ERROR_GEN_FAILURE
ERROR_OBJECT_NOT_FOUND C_DWORD = C.ERROR_OBJECT_NOT_FOUND
ERROR_NOT_SUPPORTED C_DWORD = C.ERROR_NOT_SUPPORTED
ERROR_SHARING_VIOLATION C_DWORD = C.ERROR_SHARING_VIOLATION
ERROR_BAD_COMMAND C_DWORD = C.ERROR_BAD_COMMAND
)

func winusbError(err error) error {
if err != SUCCESS {
return err
func winusbError(err C.DWORD) error {
if err != C.ERROR_SUCCESS {
return C_DWORD(err)
}
return nil
}
Expand Down

0 comments on commit 1e945f4

Please sign in to comment.