paul@38 | 1 | /* |
paul@38 | 2 | * Common functions for keypad description access. These are provided in a |
paul@38 | 3 | * header file for convenient incorporation into libraries without worrying |
paul@38 | 4 | * about linkage, symbol visibility, and so on. |
paul@38 | 5 | * |
paul@38 | 6 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@38 | 7 | * |
paul@38 | 8 | * This program is free software; you can redistribute it and/or |
paul@38 | 9 | * modify it under the terms of the GNU General Public License as |
paul@38 | 10 | * published by the Free Software Foundation; either version 2 of |
paul@38 | 11 | * the License, or (at your option) any later version. |
paul@38 | 12 | * |
paul@38 | 13 | * This program is distributed in the hope that it will be useful, |
paul@38 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@38 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@38 | 16 | * GNU General Public License for more details. |
paul@38 | 17 | * |
paul@38 | 18 | * You should have received a copy of the GNU General Public License |
paul@38 | 19 | * along with this program; if not, write to the Free Software |
paul@38 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@38 | 21 | * Boston, MA 02110-1301, USA |
paul@38 | 22 | */ |
paul@38 | 23 | |
paul@38 | 24 | #pragma once |
paul@38 | 25 | |
paul@38 | 26 | #include "keypad.h" |
paul@38 | 27 | |
paul@38 | 28 | /* Obtain the common instance. */ |
paul@38 | 29 | |
paul@38 | 30 | void *keypad_get(void) |
paul@38 | 31 | { |
paul@38 | 32 | return reinterpret_cast<void *>(Keypad::get_keypad()); |
paul@38 | 33 | } |
paul@38 | 34 | |
paul@38 | 35 | /* Number of keypad columns. */ |
paul@38 | 36 | |
paul@38 | 37 | int keypad_columns(void *keypad) |
paul@38 | 38 | { |
paul@38 | 39 | return static_cast<Keypad *>(keypad)->columns(); |
paul@38 | 40 | } |
paul@38 | 41 | |
paul@38 | 42 | /* Number of keypad rows, used by each value in the column array. */ |
paul@38 | 43 | |
paul@38 | 44 | int keypad_rows(void *keypad) |
paul@38 | 45 | { |
paul@38 | 46 | return static_cast<Keypad *>(keypad)->rows(); |
paul@38 | 47 | } |
paul@38 | 48 | |
paul@38 | 49 | /* Keycode accessors. */ |
paul@38 | 50 | |
paul@38 | 51 | int keypad_code(void *keypad, int column, int row) |
paul@38 | 52 | { |
paul@38 | 53 | return static_cast<Keypad *>(keypad)->code(column, row); |
paul@38 | 54 | } |