Skip to content

Commit

Permalink
cleanup and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny-Dasilva committed Sep 24, 2020
1 parent ae8a60e commit e0738ba
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 2,029 deletions.
File renamed without changes.
64 changes: 0 additions & 64 deletions Py_Keyboard.egg-info/PKG-INFO

This file was deleted.

13 changes: 0 additions & 13 deletions Py_Keyboard.egg-info/SOURCES.txt

This file was deleted.

1 change: 0 additions & 1 deletion Py_Keyboard.egg-info/dependency_links.txt

This file was deleted.

1 change: 0 additions & 1 deletion Py_Keyboard.egg-info/top_level.txt

This file was deleted.

54 changes: 13 additions & 41 deletions Py_Keyboard/HID.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
# The MIT License (MIT)

#

"""
`adafruit_hid.keyboard_layout_us.KeyboardLayoutUS`
=======================================================
* Author(s): Dan Halbert
"""
import time


Expand Down Expand Up @@ -474,16 +465,20 @@ def write(self, string):
# Write abc followed by Enter to the keyboard
layout.write('abc\\n')
"""
written_codes = []
for char in string:
keycode = self._char_to_keycode(char)
# If this is a shifted char, clear the SHIFT flag and press the SHIFT key.
if keycode & self.SHIFT_FLAG:
keycode &= ~self.SHIFT_FLAG
self.writer(Keycode.SHIFT)
self.writer(keycode)
result = self.writer(Keycode.SHIFT)
written_codes.append(result)
result = self.writer(keycode)
written_codes.append(result)


self.release_all()

return (written_codes)

def keycodes(self, char):
"""Return a tuple of keycodes needed to type the given character.
Expand Down Expand Up @@ -533,6 +528,7 @@ def press(self, keycodes):
self._add_keycode_to_report(int(keycode))
send_report(self.report)
Keyboard.release_all(self)
return self.report

def writer(self, *keycodes):

Expand All @@ -541,6 +537,8 @@ def writer(self, *keycodes):

send_report(self.report)

return self.report

def release(self, *keycodes):

for keycode in keycodes:
Expand Down Expand Up @@ -594,39 +592,13 @@ def _remove_keycode_from_report(self, keycode):



# The MIT License (MIT)
#
# Copyright (c) 2017 Dan Halbert
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

"""
`adafruit_hid.keyboard.Keyboard`
====================================================
* Author(s): Scott Shawcroft, Dan Halbert
"""

def send_report(report):
""" write bytes to HID device """
with open('/dev/hidg0', 'rb+') as fd:
fd.write(report)





Binary file added Py_Keyboard/__pycache__/HID.cpython-38.pyc
Binary file not shown.
Binary file added Py_Keyboard/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,30 @@ kbd.write('ls\n')



```

### Editing
All write operations are done inside the `send_report` function inside `Py_Keyboard>HID.py`

bytes written can be returned from the press and write function

```python


from Py_Keyboard.HID import Keyboard

kbd = Keyboard()

bytes_press = kbd.press("CONTROL ALT T")
print(bytes_press)
bytes_write = kbd.write('ls\n')
print(bytes_write)
```

### Keycodes
Keycodes are graciously borrowed from adafruit

see documentation [here](Py_Keyboard/keycodes.py)


## to do
Expand Down
Binary file removed __pycache__/ada_hid.cpython-36.pyc
Binary file not shown.
Binary file removed __pycache__/adafruit_hid.cpython-36.pyc
Binary file not shown.
Binary file removed __pycache__/keycode.cpython-36.pyc
Binary file not shown.
127 changes: 0 additions & 127 deletions build/lib/Py_Keyboard/API.py

This file was deleted.

Loading

0 comments on commit e0738ba

Please sign in to comment.