Skip to content

Commit 5bc8996

Browse files
authored
Merge pull request #26 from Neotron-Compute/release/v0.8.0
Release/v0.8.0
2 parents ddc0405 + 589ed9a commit 5bc8996

File tree

5 files changed

+65
-271
lines changed

5 files changed

+65
-271
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "neotron-common-bios"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
authors = ["Jonathan 'theJPster' Pallant <[email protected]>"]
55
edition = "2018"
66
description = "Common BIOS code and API for all Neotron systems."
@@ -13,3 +13,4 @@ readme = "README.md"
1313

1414
[dependencies]
1515
chrono = { version = "0.4", default-features=false }
16+
pc-keyboard = "0.7"

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ dual licensed as above, without any additional terms or conditions.
4141

4242
### Unreleased Changes
4343

44+
* None
45+
46+
### v0.8.0
47+
48+
* `audio_mixer_channel_get_info` now returns an `Option` not `Result`
49+
* Add `impl From<core::option::Option for Option`
50+
* Add `impl From<Option for core::option::Option`
51+
* Add `impl From<core::result::Result for Result`
52+
* Add `impl From<Result for core::result::Result`
53+
* Clarify that some parameters are actually expected to be numeric IDs
54+
* Use [`pc-keyboard::KeyCode`](https://crates.io/crates/pc-keyboard) to define Key Codes.
55+
4456
### v0.7.0
4557

4658
* Change `time_get` to `time_clock_get`

src/hid.rs

Lines changed: 1 addition & 248 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Imports
2525
// ============================================================================
2626

27-
// None
27+
pub use pc_keyboard::KeyCode;
2828

2929
// ============================================================================
3030
// Constants
@@ -50,253 +50,6 @@ pub enum HidEvent {
5050
MouseInput(MouseData),
5151
}
5252

53-
/// Represents a single key on a standard keyboard.
54-
///
55-
/// These keys are labelled according to their function on a standard United
56-
/// States layout 104-key keyboard. If you have a different layout keyboard,
57-
/// the symbol printed in the key you pressed may not match the `KeyCode`
58-
/// value it generates. For example, if you press the `Z` key on a German
59-
/// keyboard, you will get `KeyCode::Y` because that same key is the `Y` key
60-
/// on a US keyboard.
61-
#[repr(u8)]
62-
#[derive(Copy, Clone, PartialEq, Eq, Debug, PartialOrd, Ord)]
63-
pub enum KeyCode {
64-
/// The left-hand `Alt` key
65-
AltLeft,
66-
/// The right-hand `Alt` (or `AltGr`) key
67-
AltRight,
68-
/// The Down cursor key
69-
ArrowDown,
70-
/// The Left cursor key
71-
ArrowLeft,
72-
/// The Right cursor key
73-
ArrowRight,
74-
/// The Up cursor key
75-
ArrowUp,
76-
/// The `\\|` key
77-
BackSlash,
78-
/// The `Backspace` (`Bksp` or `<--`) key
79-
Backspace,
80-
/// The `\`~` key.
81-
///
82-
/// Left of the `1` key. On a UK keyboard this is `\`¬|`.
83-
BackTick,
84-
/// The `[{` key
85-
BracketSquareLeft,
86-
/// The `]}` key
87-
BracketSquareRight,
88-
/// The `Caps Lock` key
89-
CapsLock,
90-
/// The `,<` key
91-
Comma,
92-
/// The left-most `Control` (`Ctrl`) key
93-
ControlLeft,
94-
/// The right-most `Control` (`Ctrl`) key
95-
ControlRight,
96-
/// The `Delete` (`Del`) key
97-
Delete,
98-
/// The `End` key
99-
End,
100-
/// The `Enter` (`Return`) key, on the right-hand side of the letters.
101-
Enter,
102-
/// The `Escape` (`Esc`) key
103-
Escape,
104-
/// The `=+` key
105-
Equals,
106-
/// The `F1` key
107-
F1,
108-
/// The `F2` key
109-
F2,
110-
/// The `F3` key
111-
F3,
112-
/// The `F4` key
113-
F4,
114-
/// The `F5` key
115-
F5,
116-
/// The `F6` key
117-
F6,
118-
/// The `F7` key
119-
F7,
120-
/// The `F8` key
121-
F8,
122-
/// The `F9` key
123-
F9,
124-
/// The `F10` key
125-
F10,
126-
/// The `F11` key
127-
F11,
128-
/// The `F12` key
129-
F12,
130-
/// The `.>` key
131-
Fullstop,
132-
/// The `Home` key
133-
Home,
134-
/// The `Insert` key
135-
Insert,
136-
/// The `1!` key
137-
Key1,
138-
/// The `2@` key
139-
Key2,
140-
/// The `3#` key
141-
Key3,
142-
/// The `4$` key
143-
Key4,
144-
/// The `5%` key
145-
Key5,
146-
/// The `6^` key
147-
Key6,
148-
/// The `7&` key
149-
Key7,
150-
/// The `8*` key
151-
Key8,
152-
/// The `9(` key
153-
Key9,
154-
/// The `0)` key
155-
Key0,
156-
/// The `Right-click Menu` key
157-
Menus,
158-
/// The `-_` key
159-
Minus,
160-
/// The `0` key on the Numeric Keypad
161-
Numpad0,
162-
/// The `1` key on the Numeric Keypad
163-
Numpad1,
164-
/// The `2` key on the Numeric Keypad
165-
Numpad2,
166-
/// The `3` key on the Numeric Keypad
167-
Numpad3,
168-
/// The `4` key on the Numeric Keypad
169-
Numpad4,
170-
/// The `5` key on the Numeric Keypad
171-
Numpad5,
172-
/// The `6` key on the Numeric Keypad
173-
Numpad6,
174-
/// The `7` key on the Numeric Keypad
175-
Numpad7,
176-
/// The `8` key on the Numeric Keypad
177-
Numpad8,
178-
/// The `9` key on the Numeric Keypad
179-
Numpad9,
180-
/// The `Enter` key on the Numeric Keypad
181-
NumpadEnter,
182-
/// The `Num Lock` key on the Numeric Keypad
183-
NumpadLock,
184-
/// The `/` key on the Numeric Keypad
185-
NumpadSlash,
186-
/// The `*` key on the Numeric Keypad
187-
NumpadStar,
188-
/// The `-` key on the Numeric Keypad
189-
NumpadMinus,
190-
/// The `.` key on the Numeric Keypad
191-
NumpadPeriod,
192-
/// The `+` key on the Numeric Keypad
193-
NumpadPlus,
194-
/// The `Page Down` key
195-
PageDown,
196-
/// The `Page Up` key
197-
PageUp,
198-
/// The `Pause/Break` key
199-
PauseBreak,
200-
/// The `Print Screen` (`PrtScr`) key
201-
PrintScreen,
202-
/// The `Scroll Lock` key
203-
ScrollLock,
204-
/// The `;:` key
205-
SemiColon,
206-
/// The left-most shift key
207-
ShiftLeft,
208-
/// The right-most shift key
209-
ShiftRight,
210-
/// The `/?` key
211-
Slash,
212-
/// The `Space` key
213-
Spacebar,
214-
/// The `Tab` key
215-
Tab,
216-
/// The `'` key
217-
Quote,
218-
/// The left-most Windows (or GUI) key
219-
WindowsLeft,
220-
/// The right-most Windows (or GUI) key
221-
WindowsRight,
222-
/// The `Aa` key
223-
A,
224-
/// The `Bb` key
225-
B,
226-
/// The `Cc` key
227-
C,
228-
/// The `Dd` key
229-
D,
230-
/// The `Ee` key
231-
E,
232-
/// The `Ff` key
233-
F,
234-
/// The `Gg` key
235-
G,
236-
/// The `Hh` key
237-
H,
238-
/// The `Ii` key
239-
I,
240-
/// The `Jj` key
241-
J,
242-
/// The `Kk` key
243-
K,
244-
/// The `Ll` key
245-
L,
246-
/// The `Mm` key
247-
M,
248-
/// The `Nn` key
249-
N,
250-
/// The `Oo` key
251-
O,
252-
/// The `Pp` key
253-
P,
254-
/// The `Qq` key
255-
Q,
256-
/// The `Rr` key
257-
R,
258-
/// The `Ss` key
259-
S,
260-
/// The `Tt` key
261-
T,
262-
/// The `Uu` key
263-
U,
264-
/// The `Vv` key
265-
V,
266-
/// The `Ww` key
267-
W,
268-
/// The `Xx` key
269-
X,
270-
/// The `Yy` key
271-
Y,
272-
/// The `Zz` key
273-
Z,
274-
/// Found on non-US (e.g. UK) keyboards next to the main *Return* key.
275-
HashTilde,
276-
/// Media transport: previous track
277-
PrevTrack,
278-
/// Media transport: next track
279-
NextTrack,
280-
/// Media transport: mute audio
281-
Mute,
282-
/// Application key: open calculator
283-
Calculator,
284-
/// Media transport: play audio
285-
Play,
286-
/// Media transport: stop audio
287-
Stop,
288-
/// Media transport: turn volume down
289-
VolumeDown,
290-
/// Media transport: turn volume up
291-
VolumeUp,
292-
/// Media transport: open browser to homepage
293-
WWWHome,
294-
/// Keyboard Power On Test passed.
295-
///
296-
/// Expect this once on start-up.
297-
PowerOnTestOk,
298-
}
299-
30053
/// Represents the movement of a mouse over the previous period of time, and
30154
/// the current state of the mouse buttons.
30255
#[repr(C)]

src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ pub struct Api {
8989
/// that is an Operating System level design feature. These APIs just
9090
/// reflect the raw hardware, in a similar manner to the registers exposed
9191
/// by a memory-mapped UART peripheral.
92-
pub serial_get_info: extern "C" fn(device: u8) -> crate::Option<serial::DeviceInfo>,
92+
pub serial_get_info: extern "C" fn(device_id: u8) -> crate::Option<serial::DeviceInfo>,
9393
/// Set the options for a given serial device. An error is returned if the
9494
/// options are invalid for that serial device.
95-
pub serial_configure: extern "C" fn(device: u8, config: serial::Config) -> crate::Result<()>,
95+
pub serial_configure: extern "C" fn(device_id: u8, config: serial::Config) -> crate::Result<()>,
9696
/// Write bytes to a serial port. There is no sense of 'opening' or
9797
/// 'closing' the device - serial devices are always open. If the return
9898
/// value is `Ok(n)`, the value `n` may be less than the size of the given
9999
/// buffer. If so, that means not all of the data could be transmitted -
100100
/// only the first `n` bytes were.
101101
pub serial_write: extern "C" fn(
102-
device: u8,
102+
device_id: u8,
103103
data: ApiByteSlice,
104104
timeout: crate::Option<Timeout>,
105105
) -> crate::Result<usize>,
@@ -110,7 +110,7 @@ pub struct Api {
110110
/// could be received - only the first `n` bytes were (and hence only the
111111
/// first `n` bytes of the given buffer now contain data).
112112
pub serial_read: extern "C" fn(
113-
device: u8,
113+
device_id: u8,
114114
data: ApiBuffer,
115115
timeout: crate::Option<Timeout>,
116116
) -> crate::Result<usize>,
@@ -320,7 +320,7 @@ pub struct Api {
320320
///
321321
/// I²C Bus 0 should be the one connected to the Neotron Bus.
322322
/// I²C Bus 1 is typically the VGA DDC bus.
323-
pub i2c_bus_get_info: extern "C" fn(i2c_bus: u8) -> crate::Option<i2c::BusInfo>,
323+
pub i2c_bus_get_info: extern "C" fn(bus_id: u8) -> crate::Option<i2c::BusInfo>,
324324
/// Transact with a I²C Device on an I²C Bus
325325
///
326326
/// * `i2c_bus` - Which I²C Bus to use
@@ -341,7 +341,7 @@ pub struct Api {
341341
/// # Ok::<(), neotron_common_bios::Error>(())
342342
/// ```
343343
pub i2c_write_read: extern "C" fn(
344-
i2c_bus: u8,
344+
bus_id: u8,
345345
i2c_device_address: u8,
346346
tx: ApiByteSlice,
347347
tx2: ApiByteSlice,
@@ -353,7 +353,7 @@ pub struct Api {
353353
// ========================================================================
354354
/// Get information about the Audio Mixer channels
355355
pub audio_mixer_channel_get_info:
356-
extern "C" fn(audio_mixer_id: u8) -> crate::Result<audio::MixerChannelInfo>,
356+
extern "C" fn(audio_mixer_id: u8) -> crate::Option<audio::MixerChannelInfo>,
357357
/// Set an Audio Mixer level
358358
pub audio_mixer_channel_set_level:
359359
extern "C" fn(audio_mixer_id: u8, level: u8) -> crate::Result<()>,
@@ -530,12 +530,12 @@ pub struct Api {
530530
/// The set of devices is not expected to change at run-time - removal of
531531
/// media is indicated with a boolean field in the
532532
/// `block_dev::DeviceInfo` structure.
533-
pub block_dev_get_info: extern "C" fn(device: u8) -> crate::Option<block_dev::DeviceInfo>,
533+
pub block_dev_get_info: extern "C" fn(device_id: u8) -> crate::Option<block_dev::DeviceInfo>,
534534
/// Eject a disk from the drive.
535535
///
536536
/// Will return an error if this device is not removable. Does not return an
537537
/// error if the drive is already empty.
538-
pub block_dev_eject: extern "C" fn(device: u8) -> crate::Result<()>,
538+
pub block_dev_eject: extern "C" fn(device_id: u8) -> crate::Result<()>,
539539
/// Write one or more sectors to a block device.
540540
///
541541
/// The function will block until all data is written. The array pointed
@@ -545,7 +545,7 @@ pub struct Api {
545545
/// There are no requirements on the alignment of `data` but if it is
546546
/// aligned, the BIOS may be able to use a higher-performance code path.
547547
pub block_write: extern "C" fn(
548-
device: u8,
548+
device_id: u8,
549549
start_block: block_dev::BlockIdx,
550550
num_blocks: u8,
551551
data: ApiByteSlice,
@@ -559,7 +559,7 @@ pub struct Api {
559559
/// There are no requirements on the alignment of `data` but if it is
560560
/// aligned, the BIOS may be able to use a higher-performance code path.
561561
pub block_read: extern "C" fn(
562-
device: u8,
562+
device_id: u8,
563563
start_block: block_dev::BlockIdx,
564564
num_blocks: u8,
565565
data: ApiBuffer,
@@ -574,7 +574,7 @@ pub struct Api {
574574
/// There are no requirements on the alignment of `data` but if it is
575575
/// aligned, the BIOS may be able to use a higher-performance code path.
576576
pub block_verify: extern "C" fn(
577-
device: u8,
577+
device_id: u8,
578578
start_block: block_dev::BlockIdx,
579579
num_blocks: u8,
580580
data: ApiByteSlice,

0 commit comments

Comments
 (0)